SqlCollectionVds.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using CoreFS.CA06;
  6. using System.Data;
  7. using System.Collections;
  8. namespace Core.Mes.Client.Common
  9. {
  10. /// <summary>
  11. /// vds sql 集合
  12. /// </summary>
  13. public class SqlCollectionVds
  14. {
  15. /// <summary>
  16. /// vds report sql
  17. /// </summary>
  18. public class VdsReportSqlCollection
  19. {
  20. /// <summary>
  21. /// vds 操作记录表
  22. /// </summary>
  23. /// <param name="sqlConditionList"></param>
  24. /// <returns></returns>
  25. public static string returnSqlOfVdsReportDailyOperation(ArrayList sqlConditionList)
  26. {
  27. string sqlStr = @"select distinct to_char(a.OPTDATE, 'yyyy-MM-dd hh24:mi') OPTDATE,
  28. a.HEATNO,
  29. decode(substr(a.shiftcode, 1, 1),
  30. '1',
  31. '早',
  32. '2',
  33. '中',
  34. '3',
  35. '晚') BC,
  36. decode(substr(a.shiftcode, 2, 1),
  37. '1',
  38. '甲',
  39. '2',
  40. '乙',
  41. '3',
  42. '丙',
  43. '4',
  44. '丁') BB,
  45. a.LMLTEMPT,
  46. b.MaxSPvalue,
  47. b.MinSPVALUE,
  48. b.AvgSPVALUE,
  49. a.PLANSTEEL,
  50. a.HEATPROCESSNO,
  51. to_char(a.ARRIVETIME,'hh24:mi:ss')ARRIVETIME,
  52. I.POTNO,
  53. I.POTDISTINCTION,
  54. a.WSID,
  55. a.RESIDUETHICKNESS,
  56. a.CLEARENCELHEIGHT,
  57. a.ARFTEMPT,
  58. to_char(a.VACBEGINTIME,'hh24:mi')VACBEGINTIME,
  59. a.ARRIVEH,
  60. a.VACUUMPRESS VAC_MIN,
  61. to_char(a.HYDGENSTARTTIME,'hh24:mi')HYDGENSTARTTIME,
  62. a.ARBTEMPT ARBTEMPT_A,
  63. to_char(a.VACLOSETIME,'hh24:mi')VACLOSETIME,
  64. a.LEAVEH,
  65. to_char(a.HYDGENENDTIME,'hh24:mi')HYDGENENDTIME,
  66. '' PROPHASE,
  67. '' INTERIM,
  68. '' LATE,
  69. a.FLEXIBLEBLOWTIME,
  70. --a.VACUUMPRESS,
  71. FLOOR(nvl(a.VAC_KEEP_TIME / 60, 0)) VAC_KEEP_TIME,
  72. a.VAC_TIME VACUUMTIME,
  73. a.STEAM_TEM,
  74. a.STEAM_PRES,
  75. a.STEAM_FLUX,
  76. to_char(a.LEAVETIME,'hh24:mi') LEAVETIME,
  77. p.PLAN_LINES,
  78. u.PFBALETEMPT,
  79. a.ARBTEMPT,
  80. u.HEAT_SEQ HEAT_NUM,
  81. a.MEMO,
  82. a.blowprocess,
  83. a.replacefjg,
  84. a.MEMO ex_mome,
  85. --a.sppm,
  86. a.thermometer,
  87. a.sampler,
  88. a.replacedesiccant,
  89. a.blowisok,
  90. a.replacegd,
  91. a.steamconsume,
  92. a.arconsume,
  93. max(case when a.HEATNO = w.HEATNO and w.xh = w.cnt then w.c end) over(partition by a.HEATNO) Y_C,
  94. max(case when a.HEATNO = w.HEATNO and w.xh = w.cnt then w.si end) over(partition by a.HEATNO) Y_SI,
  95. max(case when a.HEATNO = w.HEATNO and w.xh = w.cnt then w.MN end) over(partition by a.HEATNO) Y_MN,
  96. max(case when a.HEATNO = w.HEATNO and w.xh = w.cnt then w.P end) over(partition by a.HEATNO) Y_P,
  97. max(case when a.HEATNO = w.HEATNO and w.xh = w.cnt then w.S end) over(partition by a.HEATNO) Y_S,
  98. max(case when a.HEATNO = w.HEATNO and w.xh = w.cnt then w.ALS end) over(partition by a.HEATNO) Y_ALS,
  99. max(case when a.HEATNO = w.HEATNO and w.xh = w.cnt then w.NB end) over(partition by a.HEATNO) Y_NB,
  100. max(case when a.HEATNO = w.HEATNO and w.xh = w.cnt then w.V end) over(partition by a.HEATNO) Y_V,
  101. max(case when a.HEATNO = w.HEATNO and w.xh = w.cnt then w.TI end) over(partition by a.HEATNO) Y_TI,
  102. max(case when a.HEATNO = w.HEATNO and w.xh = w.cnt then w.CU end) over(partition by a.HEATNO) Y_CU,
  103. max(case when a.HEATNO = w.HEATNO and w.xh = w.cnt then w.N end) over(partition by a.HEATNO) Y_N,
  104. max(case when a.HEATNO = w.HEATNO and w.xh = w.cnt then w.B end) over(partition by a.HEATNO) Y_B,
  105. max(case when a.HEATNO = t4.HEATNO and t4.xh = t4.cnt then t4.c end) over(partition by a.HEATNO) C_C,
  106. max(case when a.HEATNO = t4.HEATNO and t4.xh = t4.cnt then t4.SI end) over(partition by a.HEATNO) C_SI,
  107. max(case when a.HEATNO = t4.HEATNO and t4.xh = t4.cnt then t4.MN end) over(partition by a.HEATNO) C_MN,
  108. max(case when a.HEATNO = t4.HEATNO and t4.xh = t4.cnt then t4.P end) over(partition by a.HEATNO) C_P,
  109. max(case when a.HEATNO = t4.HEATNO and t4.xh = t4.cnt then t4.S end) over(partition by a.HEATNO) C_S,
  110. max(case when a.HEATNO = t4.HEATNO and t4.xh = t4.cnt then t4.ALS end) over(partition by a.HEATNO) C_ALS,
  111. max(case when a.HEATNO = t4.HEATNO and t4.xh = t4.cnt then t4.NB end) over(partition by a.HEATNO) C_NB,
  112. max(case when a.HEATNO = t4.HEATNO and t4.xh = t4.cnt then t4.V end) over(partition by a.HEATNO) C_V,
  113. max(case when a.HEATNO = t4.HEATNO and t4.xh = t4.cnt then t4.TI end) over(partition by a.HEATNO) C_TI,
  114. max(case when a.HEATNO = t4.HEATNO and t4.xh = t4.cnt then t4.CU end) over(partition by a.HEATNO) C_CU,
  115. max(case when a.HEATNO = t4.HEATNO and t4.xh = t4.cnt then t4.N end) over(partition by a.HEATNO) C_N,
  116. max(case when a.HEATNO = t4.HEATNO and t4.xh = t4.cnt then t4.B end) over(partition by a.HEATNO) C_B,
  117. max(case when a.HEATNO = t4.HEATNO and t4.xh = t4.cnt then t4.N end) over(partition by a.HEATNO) C_NI,
  118. max(case when a.HEATNO = t4.HEATNO and t4.xh = t4.cnt then t4.B end) over(partition by a.HEATNO) C_MO,
  119. max(case when a.HEATNO = t4.HEATNO and t4.xh = t4.cnt then t4.N end) over(partition by a.HEATNO) C_CR,
  120. GetStandardVaule(a.HEATNO,t4.MN,t4.NI,t4.MO,t4.NB,t4.V,t4.ALS,t4.CR,t4.CU) CFFC,
  121. '' ETGYEXRECORD,a.OPTPERSONNEL,REFINETIME,
  122. max(case when a.HEATNO = t4.HEATNO and t4.xh = t4.cnt then t4.S end) over(partition by a.HEATNO)*10000 SPPM,
  123. max(case when a.HEATNO = w.HEATNO and w.xh = w.cnt then w.S end) over(partition by a.HEATNO)*10000 LF_SPPM,
  124. HYDROGENPOLE,CHANGEFJG,VAC_END_TEMP
  125. from (select *
  126. from stl_vds_optinfo where disposaltime = '01' {0}
  127. union
  128. select * from j#stl_vds_optinfo where disposaltime = '01' {0} ) a,
  129. (select *
  130. from stl_BOF_OPTINFO where 1 = 1 {1}
  131. union
  132. select * from J#stl_BOF_OPTINFO where 1 = 1 {1}) I,
  133. (select *
  134. from STL_CCM_OPTINFO where disposaltime = '01' {1}
  135. union
  136. select * from J#stl_CCM_OPTINFO where disposaltime = '01' {1} ) u,
  137. (select HEATNO, maxSPvalue, MinSPVALUE, avgSPVALUE
  138. from (select max(SAMPLINGVALUE) maxSPvalue,
  139. min(SAMPLINGVALUE) MinSPVALUE,
  140. round(avg(SAMPLINGVALUE), 2) avgSPVALUE,
  141. HEATNO
  142. from stl_tempsampling where substr(samplingdepict,1,4)='中包温度'
  143. {2}
  144. group by HEATNO
  145. union
  146. select max(SAMPLINGVALUE) maxSPvalue,
  147. min(SAMPLINGVALUE) MinSPVALUE,
  148. round(avg(SAMPLINGVALUE), 2) avgSPVALUE,
  149. HEATNO
  150. from J#stl_tempsampling where substr(samplingdepict,1,4)='中包温度' {2}
  151. group by HEATNO)) b,
  152. (select *
  153. from ppc_steel_heat where 1 = 1 {3}
  154. union
  155. select * from J#ppc_steel_heat where 1 = 1 {3}) p,
  156. (select y.*
  157. from (select x.*,count(1) over(partition by x.HEATNO) cnt,
  158. row_number() over(partition by x.HEATNO order by x.ASSAYTYPECODE) xh
  159. from (select t.*
  160. from stl_chemelement t where upper(SUBSTR(CHECKNO, 12, 1)) = 'I'
  161. and upper(SUBSTR(CHECKNO, -1)) = 'S'
  162. {4}
  163. union
  164. select t.*
  165. from j#stl_CHEMELEMENT t where upper(SUBSTR(CHECKNO, 12, 1)) = 'I'
  166. and upper(SUBSTR(CHECKNO, -1)) = 'S'
  167. {4}
  168. ) x) y
  169. where y.xh in (1, round(y.cnt / 2), y.cnt)) w,
  170. (select y.*
  171. from (select x.*,count(1) over(partition by x.HEATNO) cnt,
  172. row_number() over (partition by x.HEATNO order by x.ASSAYTYPECODE) xh
  173. from (select t.*
  174. from stl_CHEMELEMENT t
  175. where upper(SUBSTR(CHECKNO, -1)) = 'S'
  176. and upper(SUBSTR(CHECKNO, 12, 2)) = 'GP'
  177. {4}
  178. union
  179. select t.*
  180. from J#stl_CHEMELEMENT t
  181. where upper(SUBSTR(CHECKNO, -1)) = 'S'
  182. and upper(SUBSTR(CHECKNO, 12, 2)) = 'GP'
  183. {4}
  184. ) x) y where y.xh = y.cnt
  185. ) t4
  186. where a.HEATNO = p.HEATNO(+)
  187. and a.HEATNO = w.HEATNO(+)
  188. and a.HEATNO = t4.HEATNO(+)
  189. and a.HEATNO = u.HEATNO(+)
  190. and a.heatno = b.HEATNO(+)
  191. and a.heatno = I.HEATNO(+)
  192. --and t4.xh = t4.cnt
  193. order by OPTDATE";
  194. sqlStr = lgCommon.stringFormat(sqlStr,sqlConditionList);
  195. return sqlStr;
  196. }
  197. }
  198. }
  199. }