SqlCollectionBof.cs 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392
  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. /// 存储bof报表相关sql
  12. /// </summary>
  13. public class SqlCollectionBof
  14. {
  15. /// <summary>
  16. /// 查询转炉炉前铁水信息
  17. /// </summary>
  18. /// <param name="sqlConditionList"></param>
  19. /// <returns></returns>
  20. public static string returnSqlOfBofForwardReport(ArrayList sqlConditionList)
  21. {
  22. string sqlStr = "";
  23. sqlStr = @"select distinct t.HEATNO, --炉次号
  24. t.IRONPOTID, --铁水编号
  25. t4.aim_grade_code PLANSTEEL, --钢种计划
  26. nvl(t.IRONPOTWGT, '0') IRONPOTWGT,--铁水重量
  27. t.IRONTEMPERATURE, --铁水温度
  28. case substr(t.SHIFTCODE, 2, 1) --班组
  29. when '1' then
  30. '甲'
  31. when '2' then
  32. '乙'
  33. when '3' then
  34. '丙'
  35. when '4' then
  36. '丁'
  37. end BB,
  38. case substr(t.SHIFTCODE, 1, 1) --班次
  39. when '1' then
  40. '早'
  41. when '2' then
  42. '中'
  43. when '3' then
  44. '夜'
  45. end BC,
  46. --入炉铁水信息
  47. max(case
  48. when t.MOLIRNSOURCE = t10.HEATNO then
  49. t10.Mn
  50. end) over(partition by t.MOLIRNSOURCE) R_MN,
  51. max(case
  52. when t.MOLIRNSOURCE = t10.HEATNO then
  53. t10.C
  54. end) over(partition by t.MOLIRNSOURCE) R_C,
  55. max(case
  56. when t.MOLIRNSOURCE = t10.HEATNO then
  57. t10.P
  58. end) over(partition by t.MOLIRNSOURCE) R_P,
  59. max(case
  60. when t.MOLIRNSOURCE = t10.HEATNO then
  61. t10.S
  62. end) over(partition by t.MOLIRNSOURCE) R_S,
  63. max(case
  64. when t.MOLIRNSOURCE = t10.HEATNO then
  65. t10.si
  66. end) over(partition by t.MOLIRNSOURCE) R_SI,
  67. --TSO试样
  68. max(case
  69. when t.HEATNO = t9.HEATNO and t9.xh = t9.cnt then
  70. t9.Mn
  71. end) over(partition by t.HEATNO) Z_MN,
  72. max(case
  73. when t.HEATNO = t9.HEATNO and t9.xh = t9.cnt then
  74. t9.C
  75. end) over(partition by t.HEATNO) Z_C,
  76. max(case
  77. when t.HEATNO = t9.HEATNO and t9.xh = t9.cnt then
  78. t9.P
  79. end) over(partition by t.HEATNO) Z_P,
  80. to_char(t.optdate, 'yyyy-MM-dd hh24:mi') OPTDISP --操作时间
  81. from (select *
  82. from stl_bof_optinfo
  83. where 1 = 1
  84. {0}
  85. union
  86. select *
  87. from J#stl_bof_optinfo
  88. where 1 = 1
  89. {0}
  90. ) t
  91. left join (select y.*
  92. from (select x.*,
  93. row_number() over(partition by x.heatno order by x.assaytypecode) xh
  94. from (select *
  95. from stl_chemelement
  96. where upper(substr(assaytypecode, 1, 1)) = 'C'
  97. {1}
  98. union
  99. select *
  100. from J#stl_chemelement
  101. where upper(substr(ASSAYTYPECODE, 1, 1)) = 'C'
  102. {1}
  103. ) x) y) t1 on t.heatno = t1.heatno
  104. left join (select y.*
  105. from (select x.*,
  106. count(1) over(partition by x.HEATNO) cnt,
  107. row_number() over(partition by x.HEATNO order by x.ASSAYTYPECODE asc, x.assaydate asc) xh,
  108. substr(x.assaytypecode, 1, 1) gw
  109. from (select *
  110. from STL_CHEMELEMENT
  111. where 1 = 1
  112. and upper(SUBSTR(CHECKNO, 12, 1)) = 'C'
  113. and upper(SUBSTR(CHECKNO, -1)) = 'S'
  114. {1}
  115. union
  116. select *
  117. from J#STL_CHEMELEMENT
  118. where 1 = 1
  119. {1}
  120. and upper(SUBSTR(CHECKNO, 12, 1)) = 'C'
  121. and upper(SUBSTR(CHECKNO, -1)) = 'S') x) y) t9 on t9.heatno = t.heatno
  122. left join (select *
  123. from stl_chemelement where 1 = 1 {2}
  124. union
  125. select * from J#stl_chemelement where 1 = 1 {2}) t10 on t10.heatno = t.MOLIRNSOURCE
  126. left join (select *
  127. from ppc_steel_heat where 1 = 1 {3}
  128. union
  129. select * from J#ppc_steel_heat where 1 = 1 {3}) t4 on t.heatno = t4.heatno
  130. order by OPTDISP";
  131. sqlStr = lgCommon.stringFormat(sqlStr,sqlConditionList);
  132. return sqlStr;
  133. }
  134. /// <summary>
  135. /// 返回转炉操作记录报表查询
  136. /// </summary>
  137. /// <param name="sqlConditionList"></param>
  138. /// <returns></returns>
  139. public static string returnSqlOfBofOperatioReport(ArrayList sqlConditionList)
  140. {
  141. string sqlStr = "";
  142. sqlStr = @"select distinct t.heatno,
  143. t4.aim_grade_code plansteel,
  144. t.stationcode,
  145. t.sage,
  146. t.gage,
  147. t.o2consume,
  148. nvl(t.ironpotwgt, '0') ironpotwgt,
  149. t.wsteelwgt,
  150. t.pigironwgt,
  151. t.brpstime,
  152. t.potwrapstate,
  153. t6.pfbalewgt - t6.baleleavewgt tappingwgt,
  154. decode(substr(t.shiftcode, 1, 1), '1', '早', '2', '中', '3', '晚') bc,
  155. decode(substr(t.shiftcode, 2, 1), '1', '甲', '2', '乙', '3', '丙', '4', '丁') bb,
  156. decode(blkredeffects, '0', '失败', '1', '成功', '2', '未投', '3', '一般') blkredeffects,
  157. t.subage,
  158. t.ironpotwgt,
  159. t.wsteelwgt,
  160. t.pigironwgt,
  161. t.changestarttime,
  162. t.openoxygentime,
  163. t.irontemperature,
  164. t.terminusc,
  165. t.terminuso2,
  166. t.b1temperature,
  167. t.b2temperature,
  168. nvl(t.n2consume, 0) + nvl(t.topn2consume, 0) n2sum,
  169. t.irontemperature,
  170. '0.9' o2press,
  171. nvl(t.b2time, 0) + nvl(t.b3time, 0) + nvl(t.b4time, 0) +
  172. nvl(t.b5time, 0) dctime,
  173. to_char(t.changestarttime, 'HH24:mi') changestarttime,
  174. to_char(t.openoxygentime, 'HH24:mi') openoxygentime,
  175. round(nvl(t.supplyoxygentime / 60, 0), 1) supplyoxygentime,
  176. round(t.supplyoxygentime, 1) supplyoxygentime_s,
  177. t4.plan_lines plan_lines,
  178. t.terminustept tappingtemperature,
  179. t.tappingtime,
  180. to_char(t.tappingstarttime, 'HH24:mi') tappingstarttime,
  181. max(case
  182. when t.heatno = t2.heatno
  183. and t2.xh = t2.cnt then
  184. t2.c
  185. end) over(partition by t.heatno) f_c,
  186. max(case
  187. when t.heatno = t2.heatno
  188. and t2.xh = t2.cnt then
  189. t2.mn
  190. end) over(partition by t.heatno) f_mn,
  191. max(case
  192. when t.heatno = t2.heatno
  193. and t2.xh = t2.cnt then
  194. t2.si
  195. end) over(partition by t.heatno) f_si,
  196. max(case
  197. when t.heatno = t2.heatno
  198. and t2.xh = t2.cnt then
  199. t2.s
  200. end) over(partition by t.heatno) f_s,
  201. max(case
  202. when t.heatno = t2.heatno
  203. and t2.xh = t2.cnt then
  204. t2.p
  205. end) over(partition by t.heatno) f_p,
  206. max(case
  207. when t.heatno = t2.heatno
  208. and t2.xh = t2.cnt then
  209. t2.als
  210. end) over(partition by t.heatno) f_als,
  211. max(case
  212. when t.molirnsource = t10.heatno then
  213. t10.mn
  214. end) over(partition by t.molirnsource) r_mn,
  215. max(case
  216. when t.molirnsource = t10.heatno then
  217. t10.c
  218. end) over(partition by t.molirnsource) r_c,
  219. max(case
  220. when t.molirnsource = t10.heatno then
  221. t10.p
  222. end) over(partition by t.molirnsource) r_p,
  223. max(case
  224. when t.molirnsource = t10.heatno then
  225. t10.s
  226. end) over(partition by t.molirnsource) r_s,
  227. max(case
  228. when t.molirnsource = t10.heatno then
  229. t10.si
  230. end) over(partition by t.molirnsource) r_si,
  231. max(case
  232. when t.heatno = t9.heatno
  233. and t9.xh = t9.cnt then
  234. t9.mn
  235. end) over(partition by t.heatno) z_mn,
  236. max(case
  237. when t.heatno = t9.heatno
  238. and t9.xh = t9.cnt then
  239. t9.c
  240. end) over(partition by t.heatno) z_c,
  241. max(case
  242. when t.heatno = t9.heatno
  243. and t9.xh = t9.cnt then
  244. t9.p
  245. end) over(partition by t.heatno) z_p,
  246. max(case
  247. when t.heatno = t9.heatno
  248. and t9.xh = t9.cnt then
  249. t9.s
  250. end) over(partition by t.heatno) z_s,
  251. max(case
  252. when t.heatno = t9.heatno
  253. and t9.xh = t9.cnt then
  254. t9.si
  255. end) over(partition by t.heatno) z_si,
  256. t4.cast_id ccmno,
  257. (t4.cast_id) || '-' || (t4.cast_seq) ccmno,
  258. t.memo,
  259. to_char(t.optdate, 'yyyy-MM-dd hh24:mi') optdisp
  260. from (select *
  261. from stl_bof_optinfo
  262. where 1 = 1
  263. {0}
  264. union all
  265. select *
  266. from j#stl_bof_optinfo
  267. where 1 = 1
  268. {0}) t
  269. left join (select y.*
  270. from (select x.*,
  271. row_number() over(partition by x.heatno order by x.assaytypecode) xh
  272. from (select *
  273. from stl_chemelement
  274. where upper(substr(assaytypecode, 1, 1)) = 'C'
  275. {1}
  276. union all
  277. select *
  278. from j#stl_chemelement
  279. where upper(substr(assaytypecode, 1, 1)) = 'C'
  280. {1}) x) y) t1 on t.heatno =
  281. t1.heatno
  282. left join (select y.*
  283. from (select x.*,
  284. count(1) over(partition by x.heatno) cnt,
  285. row_number() over(partition by x.heatno order by x.assaytypecode desc, x.assaydate desc) xh,
  286. substr(x.assaytypecode, 1, 1) gw
  287. from (select *
  288. from stl_chemelement
  289. where 1 = 1
  290. {1}
  291. and upper(substr(checkno, -1)) = 'S'
  292. and upper(substr(checkno, 12, 2)) = 'GP'
  293. union all
  294. select *
  295. from j#stl_chemelement
  296. where 1 = 1
  297. {1}
  298. and upper(substr(checkno, -1)) = 'S'
  299. and upper(substr(checkno, 12, 2)) = 'GP') x) y) t2 on t2.heatno =
  300. t.heatno
  301. left join (select y.*
  302. from (select x.*,
  303. count(1) over(partition by x.heatno) cnt,
  304. row_number() over(partition by x.heatno order by x.assaytypecode desc, x.assaydate desc) xh,
  305. substr(x.assaytypecode, 1, 1) gw
  306. from (select *
  307. from stl_chemelement
  308. where 1 = 1
  309. {1}
  310. and upper(substr(checkno, 12, 1)) = 'C'
  311. and upper(substr(checkno, -1)) = 'I'
  312. and upper(substr(checkno, 13, 1)) <> 'P'
  313. union all
  314. select *
  315. from j#stl_chemelement
  316. where 1 = 1
  317. {1}
  318. and upper(substr(checkno, 12, 1)) = 'C'
  319. and upper(substr(checkno, -1)) = 'I'
  320. and upper(substr(checkno, 13, 1)) <> 'P') x) y) t3 on t3.heatno =
  321. t.heatno
  322. left join (select y.*
  323. from (select x.*,
  324. count(1) over(partition by x.heatno) cnt,
  325. row_number() over(partition by x.heatno order by x.assaytypecode) xh,
  326. substr(x.assaytypecode, 1, 1) gw
  327. from (select *
  328. from stl_chemelement
  329. where 1 = 1
  330. {1}
  331. and upper(substr(checkno, 12, 1)) = 'C'
  332. and upper(substr(checkno, -1)) = 'S'
  333. union all
  334. select *
  335. from j#stl_chemelement
  336. where 1 = 1
  337. {1}
  338. and upper(substr(checkno, 12, 1)) = 'C'
  339. and upper(substr(checkno, -1)) = 'S') x) y) t9 on t9.heatno =
  340. t.heatno
  341. left join (select *
  342. from stl_chemelement where 1 = 1 {1}
  343. union all
  344. select * from j#stl_chemelement where 1 = 1 {1}) t10 on t10.heatno =
  345. t.molirnsource
  346. left join (select *
  347. from ppc_steel_heat where 1 = 1 {3}
  348. union all
  349. select * from j#ppc_steel_heat where 1 = 1 {3}) t4 on t.heatno =
  350. t4.heatno
  351. left join (select *
  352. from ppc_steel_heat where 1 = 1 {3}
  353. union all
  354. select * from j#ppc_steel_heat where 1 = 1 {3}) t5 on t.heatno =
  355. t5.heatno
  356. left join (select heatno,
  357. pfbalewgt,
  358. baleleavewgt,
  359. isrs,
  360. mwrapno,
  361. billetfixsize
  362. from stl_ccm_optinfo
  363. where 1 = 1
  364. {2}
  365. union all
  366. select heatno,
  367. pfbalewgt,
  368. baleleavewgt,
  369. isrs,
  370. mwrapno,
  371. billetfixsize
  372. from j#stl_ccm_optinfo
  373. where 1 = 1
  374. {2}) t6 on t.heatno = t6.heatno
  375. order by optdisp
  376. ";
  377. sqlStr = lgCommon.stringFormat(sqlStr,sqlConditionList);
  378. return sqlStr;
  379. }
  380. }
  381. }