SqlCollection.cs 60 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859
  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. public class SqlCollection
  11. {
  12. /// <summary>
  13. /// 返回2钢基础数据sql
  14. /// </summary>
  15. /// <returns></returns>
  16. public static string returnScm_Base_InfoByAllCondition(string sqlCondition)
  17. {
  18. string sqlStr = "select * from scm_base_info a where 1 = 1 {0}";
  19. sqlStr = string.Format(sqlStr, sqlCondition);
  20. return sqlStr;
  21. }
  22. public static string returnOfTbg02_Charge_Comm(string sqlCondition)
  23. {
  24. string sqlStr = "select * from tbg02_charge_comm@xg3q a where 1 = 1 {0}";
  25. sqlStr = string.Format(sqlStr, sqlCondition);
  26. return sqlStr;
  27. }
  28. public class LgResMgtSqlCollection
  29. {
  30. public static string returnStl_Mis_Importiron(string sqlConditon)
  31. {
  32. string sqlstr = "";
  33. sqlstr = string.Format("select * from stl_mis_importiron where 1 = 1 {0}", sqlConditon);
  34. return sqlstr;
  35. }
  36. public static string returnSqlForStl_Hmp_Tempsampling(string sqlConditon)
  37. {
  38. string sqlstr = "";
  39. sqlstr = string.Format("select * from stl_hmp_tempsampling where 1 = 1 {0}", sqlConditon);
  40. return sqlstr;
  41. }
  42. }
  43. /// <summary>
  44. /// Ccm 操作集合
  45. /// </summary>
  46. public class CcmSqlCollection
  47. {
  48. /// <summary>
  49. /// 连铸主控机操作报表
  50. /// </summary>
  51. /// <param name="sqlCondtion"></param>
  52. /// <returns></returns>
  53. public static string returnSqlOfCcmOption(string sqlCondtion)
  54. {
  55. string sqlstr = "";
  56. sqlstr = @"select a.heatno,
  57. /*a.mouldno,*/
  58. a.mouldnumid mouldno,
  59. a.plansteel,
  60. v.plan_lines,
  61. a.billetsection,
  62. a.billetsection2,
  63. case a.baleflowflag
  64. when 0 then
  65. '否'
  66. when 1 then
  67. '是'
  68. end baleflowflag,
  69. a.mouldstovenum,
  70. a.pfbaletempt,
  71. to_char(a.balepftime, 'HH24:mi') balepftime,
  72. to_char(a.balestarttime, 'HH24:mi') balestarttime,
  73. to_char(a.baleendtime, 'HH24:mi') baleendtime,
  74. round((a.baleendtime - a.balestarttime) * 24 * 60) 周期,
  75. a.pfbalewgt,
  76. a.baleleavewgt,
  77. a.stationcode, a.mwrapno, a.lmltempt,
  78. a.crystallizerid,a.crystallizerid2,a.crystallizerid3,a.crystallizerid4,
  79. a.crystallizertimes6, a.optpersonnel,
  80. a.memo,
  81. a.watermeterno,
  82. a.coveringslag,
  83. a.arpre_s1,
  84. a.arpre_s2,
  85. a.upwaterpre_s1,
  86. a.upwaterpre_s2,
  87. a.waterchage_s1,
  88. a.waterchage_s2,
  89. a.liqfluct_s1,
  90. a.liqfluct_s2,
  91. a.closesteel,
  92. a.steelstick_s1,
  93. a.steelstick_s2,
  94. a.biasflow_s1,
  95. a.biasflow_s2,
  96. a.baleisdown,
  97. a.rhythmfast,
  98. a.tempt_high,
  99. a.tempt_low,
  100. a.notice_s1,
  101. a.notice_s2,
  102. a.jjqslkn_s1,
  103. a.jjqslkw_s1,
  104. a.jjqslzz_s1,
  105. a.jjqslzy_s1,
  106. a.jjqswckn_s1,
  107. a.jjqswckw_s1,
  108. a.jjqswczz_s1,
  109. a.jjqswczy_s1,
  110. a.jjqslkn_s2,
  111. a.jjqslkw_s2,
  112. a.jjqslzz_s2,
  113. a.jjqslzy_s2,
  114. a.jjqswckn_s2,
  115. a.jjqswckw_s2,
  116. a.jjqswczz_s2,
  117. a.jjqswczy_s2,
  118. a.billetcondition,
  119. a.midwgt_min,
  120. a.width_s1,
  121. a.width_s2,a.isaddtop,a.tempt_max,a.tempt_min,a.lasu_max,a.lasu_min,a.lasu2_max,a.lasu2_min,
  122. a.S1_JJQ_WGT,a.S2_JJQ_WGT,a.s1_ld_wgt,a.s2_ld_wgt,a.s1_czld_wgt,a.s1_wqld_wgt,
  123. nvl(a.pfbalewgt, 0) - nvl(a.baleleavewgt, 0) jgwgt,
  124. to_char(a.baleleavetime, 'HH24:mi') baleleavetime,
  125. /*v.cast_id || '-' || v.cast_seq cast_id,*/
  126. a.heat_seq cast_id,
  127. a.s1billetlength len_1,
  128. a.s2billetlength len_2,
  129. a.crystallizertimes crystallizertimes1,
  130. a.crystallizertimes2,
  131. a.memo,
  132. a.shiftcode,
  133. to_char(a.optdate, 'yyyy-MM-dd') optdisp,
  134. a.tg_fac,
  135. a.sk_fac,
  136. a.potno,
  137. a.JCDJ,
  138. a.MWRAPTNO,
  139. a.S1_ALERT,
  140. a.S2_ALERT,
  141. a.RESIDUETHICKNESS,
  142. ROUND(NVL((SELECT SUM(TA.SLAB_WGT/1000) FROM TBG02_SLAB_COMM@XG3Q TA WHERE TA.SLAB_NO LIKE SUBSTR(A.HEATNO,1,9)||'%' AND (TA.MATRL_END_CAUSE_CD IS NULL OR TA.MATRL_END_CAUSE_CD NOT IN ('4','5'))),0),3) RKL,
  143. ROUND(NVL((SELECT SUM(TA.SLAB_WGT/1000) FROM TBG02_SLAB_COMM@XG3Q TA WHERE TA.SLAB_NO LIKE SUBSTR(A.HEATNO,1,9)||'%' AND (TA.MATRL_END_CAUSE_CD IS NULL OR TA.MATRL_END_CAUSE_CD NOT IN ('4','5'))),0),3) - (NVL(A.PFBALEWGT, 0) - NVL(A.BALELEAVEWGT, 0)) PCL,
  144. /*TO_CHAR((NVL((SELECT SUM(TA.SLAB_WGT/1000) FROM TBG02_SLAB_COMM@XG3Q TA WHERE TA.SLAB_NO LIKE SUBSTR(A.HEATNO,1,9)||'%' AND (TA.MATRL_END_CAUSE_CD IS NULL OR TA.MATRL_END_CAUSE_CD NOT IN ('4','5'))),0)/NVL(A.PFBALEWGT - A.BALELEAVEWGT, 9999)-1)*100,'fm9999990.00')||'%' PCBL,*/
  145. TO_CHAR((NVL((SELECT SUM(TA.SLAB_WGT/1000) FROM TBG02_SLAB_COMM@XG3Q TA WHERE TA.SLAB_NO LIKE SUBSTR(A.HEATNO,1,9)||'%' AND (TA.MATRL_END_CAUSE_CD IS NULL OR TA.MATRL_END_CAUSE_CD NOT IN ('4','5'))),0)/decode(A.PFBALEWGT - A.BALELEAVEWGT,null,9999,0,9999,A.PFBALEWGT - A.BALELEAVEWGT)-1)*100,'fm9999990.00')||'%' PCBL,
  146. SUM(ROUND(NVL((SELECT SUM(TA.SLAB_WGT/1000) FROM TBG02_SLAB_COMM@XG3Q TA WHERE TA.SLAB_NO LIKE SUBSTR(A.HEATNO,1,9)||'%' AND (TA.MATRL_END_CAUSE_CD IS NULL OR TA.MATRL_END_CAUSE_CD NOT IN ('4','5'))),0),3) - (NVL(A.PFBALEWGT, 0) - NVL(A.BALELEAVEWGT, 0)))
  147. OVER (PARTITION BY A.MOULDNUMID ORDER BY A.HEAT_SEQ) LJPCL,
  148. round(a.tempt_max - a.LMLTEMPT) overheat
  149. from (select *
  150. from stl_ccm_optinfo
  151. where 1 = 1
  152. {0}
  153. union
  154. select *
  155. from j#stl_ccm_optinfo
  156. where 1 = 1
  157. {0}) a,
  158. stl_ccm_mouldinfo u,
  159. (select *
  160. from ppc_steel_heat
  161. union
  162. select * from j#ppc_steel_heat) v
  163. --,(select heatno,min(SAMPLINGVALUE) min_temp,max(SAMPLINGVALUE) max_temp from (select HEATNO ,SAMPLINGVALUE from stl_tempsampling tt
  164. -- where DISPOSALTIME = '01' and substr(stationcode, 1, 1)='G' and samplingdate > sysdate-365
  165. --union select HEATNO ,SAMPLINGVALUE from J#stl_tempsampling aa
  166. --where DISPOSALTIME = '01' and substr(stationcode, 1, 1)='G' and samplingdate > sysdate-365 )group by heatno) t
  167. where a.mouldno = u.mouldno(+)
  168. and a.heatno = v.heatno(+)
  169. --and a.heatno = t.heatno(+)
  170. order by a.optdate";
  171. sqlstr = string.Format(sqlstr,sqlCondtion);
  172. return sqlstr;
  173. }
  174. /// <summary>
  175. /// 返回炼钢生产报表sql
  176. /// </summary>
  177. /// <param name="sqlConditionList"></param>
  178. /// <returns></returns>
  179. public static string ReturnSqlOfLgProdueceReport(ArrayList sqlConditionList)
  180. {
  181. string sqlStr = "";
  182. sqlStr = @"select distinct t.heatno,
  183. t.stationcode stationcode,
  184. to_char(t.optdate, 'YYYY-MM-DD') optdate,
  185. t.shiftcode,
  186. t.downgashoodtime||'' downgashoodtime,
  187. substr(t.shiftcode, 1, 1) bc,
  188. substr(t.shiftcode, 2, 1) bb,
  189. t4.aim_grade_code plansteel,
  190. case
  191. when substr(t4.fact_route, 9, 2) != 'E0' then
  192. '是'
  193. else
  194. '否'
  195. end fact_route,
  196. '' mnfc,
  197. nvl((select d.stdmin
  198. from scm_standard_chem_view d,
  199. (select *
  200. from scm_base_info d
  201. where d.sortcode = '1006'
  202. order by d.basecode) h
  203. where d.itemcode = h.basename
  204. and steel = t4.aim_grade_code
  205. and stdstyle = '1'
  206. and d.itemcode = 'MN'
  207. group by steel,
  208. stdstyle,
  209. itemcode,
  210. std,
  211. stdmin,
  212. stdmax,
  213. basename,
  214. basecode), 0) nkmn,
  215. case
  216. when substr(t4.fact_route, 9, 2) != 'E0' then
  217. nvl(max(case
  218. when t.heatno = t10.heatno
  219. and t10.xh = t10.cnt then
  220. t10.mn
  221. end) over(partition by t.heatno), 0) --精炼
  222. else nvl(max(case
  223. when t.heatno = t11.heatno
  224. and t11.xh = t11.cnt then
  225. t11.mn
  226. end) over(partition by t.heatno), 0) --连铸
  227. end lforccm,
  228. t.sage,
  229. t.gage,
  230. t.oggnumid,
  231. t.emolstltime,
  232. nvl(t.ironpotwgt, '0') ironpotwgt,
  233. t.wsteelwgt,
  234. t.pigironwgt,
  235. t.joinmarlwgt,
  236. t.rsteelwgt,
  237. t.rswgt,
  238. t.ironpotid,
  239. t.n2consume,
  240. t.arconsume,
  241. t.potdistinction,
  242. t.potwrapstate,
  243. nvl(t.n2consume, 0) + nvl(t.topn2consume, 0) n2sum,
  244. decode(substr(t.molirntype, 1, 1), '1', '半钢', decode(substr(t.molirntype, 1, 1), '2', '脱硫', decode(substr(t.molirntype, 1, 1), '3', '混铁炉', decode(substr(t.molirntype, 1, 1), '4', '直兑', '')))) molirntype,
  245. t.irontemperature,
  246. (select cast_id || '-' || cast_seq
  247. from ppc_steel_heat
  248. where heatno = t.heatno) mouldumid,
  249. to_char(t.changestarttime, 'HH24:MI') changestarttime,
  250. to_char(t.openoxygentime, 'HH24:MI') openoxygentime,
  251. floor(nvl(t.supplyoxygentime / 60, 0)) supplyoxygentime,
  252. t.supplyoxygentime supplyoxygentime_s,
  253. floor(nvl(t.b1time / 60, 0)) b1time_m,
  254. t.b1time b1time_s,
  255. t.o2consume,
  256. t.terminustept tappingtemperature,
  257. t.potno,
  258. t.tappingtime,
  259. to_char(t.tappingendtime, 'HH24:MI') tappingendtime,
  260. to_char(t.tappingstarttime, 'HH24:MI') tappingstarttime,
  261. t.molstltemperature,
  262. t.ccmplantempt,
  263. to_char(t.ccmplantempttime, 'HH24:MI') ccmplantempttime,
  264. round((t.psendtime - t.changestarttime) * 24 * 60) cycle,
  265. decode(substr(t4.plan_route, instr(t4.plan_route, 'E') + 1, 1), '0', '', substr(t4.plan_route, instr(t4.plan_route, 'E') + 1, 1)) lfsno,
  266. (t4.width || '*' || t4.thick) rolling,
  267. t4.cast_id ccmno,
  268. t5.si i_si,
  269. t5.mn i_mn,
  270. t5.p i_p,
  271. t5.s i_s,
  272. t5.c i_as,
  273. t.blowo2times downheattime,
  274. t6.pfbalewgt grosswgt,
  275. t6.baleleavewgt kongwgt,
  276. t6.pfbalewgt - t6.baleleavewgt tappingwgt,
  277. t7.arftempt casbeforetemperature,
  278. t7.arbtempt casaftertemperature,
  279. t.optdate optdisp,
  280. t.gasrecoverytime,
  281. decode(t8.isrs, '1', '精炼回炉', decode(t6.isrs, '1', '连铸回炉', '')) isrs,
  282. decode(t8.isrs, '1', decode(t6.isrs, '1', (select sum(weightofcvt)
  283. from (select weightofcvt,
  284. smeltingidofcvt
  285. from stl_es_taphole
  286. union
  287. select weightofcvt,
  288. smeltingidofcvt
  289. from stl_mis_taphole)
  290. where smeltingidofcvt =
  291. t.heatno), ''), '') isrswgt,
  292. nvl(t.ironpotwgt, '0') + nvl(t.wsteelwgt, '0') +
  293. nvl(t.pigironwgt, '0') + nvl(t.joinmarlwgt, '0') +
  294. nvl(t.rsteelwgt, '0') + nvl(t.rswgt, '0') joinstovewgt,
  295. decode((nvl(t.ironpotwgt, '0') + nvl(t.wsteelwgt, '0') +
  296. nvl(t.pigironwgt, '0') +
  297. nvl(t.joinmarlwgt, '0') +
  298. nvl(t.rsteelwgt, '0') + nvl(t.rswgt, '0')), 0, 0, round((t6.pfbalewgt -
  299. t6.baleleavewgt) /
  300. (nvl(t.ironpotwgt, '0') +
  301. nvl(t.wsteelwgt, '0') +
  302. nvl(t.pigironwgt, '0') +
  303. nvl(t.joinmarlwgt, '0') +
  304. nvl(t.rsteelwgt, '0') +
  305. nvl(t.rswgt, '0')) * 100, 2)) steelout,
  306. t8.ladlecoverage,
  307. t6.mwrapno,
  308. t8.eletricityconsume,
  309. t7.arftempt,
  310. round(((t8.reposebegintime - t8.arrivetime) * 24 * 60), 0) awaittime,
  311. t8.refinetime,
  312. t8.flexibleblowtime,
  313. t8.arrivetempt,
  314. t8.leavetempt,
  315. t7.blowartime,
  316. t6.billetfixsize,
  317. t9.billetnum,
  318. t9.billetwgt
  319. from (select *
  320. from stl_bof_optinfo
  321. where 1 = 1 {0}
  322. union all
  323. select * from j#stl_bof_optinfo where 1 = 1 {0}) t
  324. left join (select *
  325. from ppc_steel_heat where 1 = 1 {1}
  326. union all
  327. select * from j#ppc_steel_heat where 1 = 1 {1}) t4 on t.heatno =
  328. t4.heatno
  329. left join (select *
  330. from stl_chemelement where 1 = 1 {2}
  331. union all
  332. select * from j#stl_chemelement where 1 = 1 {2}) t5 on t5.heatno =
  333. t.molirnsource
  334. left join (select heatno,
  335. pfbalewgt,
  336. baleleavewgt,
  337. isrs,
  338. mwrapno,
  339. billetfixsize
  340. from stl_ccm_optinfo where 1 = 1 {3}
  341. union all
  342. select heatno,
  343. pfbalewgt,
  344. baleleavewgt,
  345. isrs,
  346. mwrapno,
  347. billetfixsize
  348. from j#stl_ccm_optinfo where 1 = 1 {3} ) t6 on t.heatno = t6.heatno
  349. left join (select heatno,
  350. arftempt,
  351. arbtempt,
  352. blowartime
  353. from stl_cas_optinfo where 1 = 1 {3}
  354. union all
  355. select heatno,
  356. arftempt,
  357. arbtempt,
  358. blowartime
  359. from j#stl_cas_optinfo where 1 = 1 {3}) t7 on t.heatno = t7.heatno
  360. left join (select heatno,
  361. max(isrs) isrs,
  362. max(eletricityconsume) eletricityconsume,
  363. max(ladlecoverage) ladlecoverage,
  364. max(reposebegintime) reposebegintime,
  365. max(arrivetime) arrivetime,
  366. max(refinetime) refinetime,
  367. max(flexibleblowtime) flexibleblowtime,
  368. max(arrivetempt) arrivetempt,
  369. max(leavetempt) leavetempt
  370. from (select heatno,
  371. isrs,
  372. eletricityconsume,
  373. ladlecoverage,
  374. reposebegintime,
  375. arrivetime,
  376. refinetime,
  377. flexibleblowtime,
  378. arrivetempt,
  379. leavetempt
  380. from stl_lfs_optinfo where 1 = 1 {3}
  381. union all
  382. select heatno,
  383. isrs,
  384. eletricityconsume,
  385. ladlecoverage,
  386. reposebegintime,
  387. arrivetime,
  388. refinetime,
  389. flexibleblowtime,
  390. arrivetempt,
  391. leavetempt
  392. from j#stl_lfs_optinfo where 1 = 1 {3})
  393. group by heatno) t8 on t.heatno = t8.heatno
  394. left join (select s.heatno,
  395. s.billetnum,
  396. s.billetwgt
  397. from (select t.heatno,
  398. count(1) billetnum,
  399. sum(nvl(t.weight, 0)) billetwgt
  400. from stl_incision t
  401. group by heatno,
  402. weight
  403. union all
  404. select t.heatno,
  405. count(1) billetnum,
  406. sum(nvl(t.weight, 0)) billetwgt
  407. from y#stl_incision t
  408. group by heatno,
  409. weight) s) t9 on t.heatno = t9.heatno
  410. left join (select y.* --LFS
  411. from (select x.*,
  412. count(1) over(partition by x.heatno) cnt,
  413. row_number() over(partition by x.heatno order by x.assaytypecode desc, x.assaydate desc) xh,
  414. substr(x.assaytypecode, 1, 1) gw
  415. from (select *
  416. from stl_chemelement
  417. where upper(substr(checkno, 12, 1)) = 'E'
  418. and upper(substr(checkno, -1)) = 'S'
  419. {2}
  420. union all
  421. select *
  422. from j#stl_chemelement
  423. where upper(substr(checkno, 12, 1)) = 'E'
  424. {2}
  425. and upper(substr(checkno, -1)) = 'S') x) y) t10 on t.heatno =
  426. t10.heatno
  427. left join (select y.* --CCM
  428. from (select x.*,
  429. count(1) over(partition by x.heatno) cnt,
  430. row_number() over(partition by x.heatno order by x.assaytypecode desc, x.assaydate desc) xh,
  431. substr(x.assaytypecode, 1, 1) gw
  432. from (select *
  433. from stl_chemelement
  434. where upper(substr(checkno, -1)) = 'S'
  435. and upper(substr(checkno, 12, 2)) = 'GP'
  436. {2}
  437. union all
  438. select *
  439. from j#stl_chemelement
  440. where upper(substr(checkno, -1)) = 'S'
  441. {2}
  442. and upper(substr(checkno, 12, 2)) = 'GP') x) y) t11 on t.heatno =
  443. t11.heatno
  444. order by t.optdate
  445. ";
  446. sqlStr = lgCommon.stringFormat(sqlStr,sqlConditionList);
  447. return sqlStr;
  448. }
  449. public static string returnSqlOfMidPackageAndSpeed(ArrayList sqlCondiotnList)
  450. {
  451. string sqlstr = "";
  452. sqlstr = @"select z.*
  453. from (select Distinct x.Heatno,
  454. x.STATIONCODE,
  455. x.DISPOSALTIME,
  456. x.MIDLADLETEMP,
  457. to_char(x.LASTFRESHTIME,'HH24:mi') LASTFRESHTIME,
  458. y.s1castspeed,
  459. y.s2castspeed,
  460. y.s3castspeed,
  461. y.s4castspeed,
  462. y.s5castspeed,
  463. row_number() over(partition by x.HEATNO order by x.LASTFRESHTIME) xh,
  464. count(*) over(partition by x.HEATNO order by x.HEATNO) intcount
  465. from (SELECT Heatno,
  466. STATIONCODE,
  467. DISPOSALTIME,
  468. MIDLADLETEMP,
  469. min(LASTFRESHTIME) LASTFRESHTIME
  470. FROM (select HEATNO,
  471. STATIONCODE,
  472. DISPOSALTIME,
  473. ROUND(greatest(midladletemp1, midladletemp2)) MIDLADLETEMP,
  474. LASTFRESHTIME from {0} b
  475. where 1 = 1
  476. {1}
  477. union
  478. select HEATNO,
  479. STATIONCODE,
  480. DISPOSALTIME,
  481. ROUND(greatest(midladletemp1, midladletemp2)) MIDLADLETEMP,
  482. LASTFRESHTIME
  483. from J#{0}
  484. where 1 = 1
  485. {1}) a
  486. group by heatno,
  487. stationcode,
  488. disposaltime,
  489. MIDLADLETEMP
  490. order by heatno) x
  491. left join (select HEATNO,
  492. STATIONCODE,
  493. DISPOSALTIME,
  494. s1castspeed,
  495. s2castspeed,
  496. s3castspeed,
  497. s4castspeed,
  498. s5castspeed,
  499. LASTFRESHTIME,
  500. ROUND(greatest(midladletemp1, midladletemp2)) MIDLADLETEMP
  501. from {0} b
  502. where 1 = 1
  503. {1}
  504. union
  505. select HEATNO,
  506. STATIONCODE,
  507. DISPOSALTIME,
  508. s1castspeed,
  509. s2castspeed,
  510. s3castspeed,
  511. s4castspeed,
  512. s5castspeed,
  513. LASTFRESHTIME,
  514. ROUND(greatest(midladletemp1, midladletemp2)) MIDLADLETEMP
  515. from J#{0}
  516. where 1 = 1
  517. {1}) y on x.heatno =
  518. y.heatno
  519. and x.stationcode =
  520. y.stationcode
  521. and x.disposaltime =
  522. y.disposaltime
  523. where x.LASTFRESHTIME = y.LASTFRESHTIME
  524. and x.MIDLADLETEMP = y.MIDLADLETEMP
  525. and x.MIDLADLETEMP > 1410
  526. order by heatno, LASTFRESHTIME) z
  527. where z.xh in (1, round(z.intcount / 4), round((z.intcount - 2) / 4) * 2,
  528. round((z.intcount - 2) / 4) * 3,
  529. round((z.intcount - 2) / 4) * 4, z.intcount)";
  530. sqlstr = lgCommon.stringFormat(sqlstr,sqlCondiotnList);
  531. return sqlstr;
  532. }
  533. /// <summary>
  534. /// 获取板坯铸机恒拉表sql
  535. /// </summary>
  536. /// <param name="sqlCondition"></param>
  537. /// <returns></returns>
  538. public static string returnSqlStrCastCcmSpeed(string sqlCondition)
  539. {
  540. string sqlStr = "";
  541. // sqlStr = @"select a.heatno, a.stationcode, a.fixedspeed,a.starttime, a.endtime,
  542. // round((nvl(a.endtime,null) - a.starttime )*86400 / 60, 2) fixedtime, a.castflow, to_char(a.optdate,'yyyy-mm-dd HH24:mi:ss') optdate, a.info1, a.info2,a.info3, a.info4,
  543. // a.info5, a.info6, a.info7 from stl_ccm_fixedcastspeed a where 1 = 1 {0}";
  544. // sqlStr = sqlStr + @" union all select a.heatno, a.stationcode, a.fixedspeed,a.starttime, a.endtime,
  545. // round((nvl(a.endtime,null) - a.starttime )*86400 / 60, 2) fixedtime , a.castflow, to_char(a.optdate,'yyyy-mm-dd HH24:mi:ss') optdate, a.info1, a.info2,a.info3, a.info4,
  546. // a.info5, a.info6, a.info7 from j#stl_ccm_fixedcastspeed a where 1 = 1 {0}";
  547. sqlStr = @"select a.heatno, a.stationcode, round(a.fixedspeed,2) fixedspeed,a.starttime, a.endtime,
  548. case when nvl(a.endtime, null)< nvl(nvl(b.baleendtime,b.baleleavetime),b.updatetime) then
  549. round((nvl(a.endtime, null) - a.starttime) * 86400 / 60, 2)
  550. else round((nvl(nvl(b.baleendtime,b.baleleavetime),b.updatetime) - a.starttime) * 86400 / 60, 2) end fixedtime, a.castflow, to_char(a.optdate,'yyyy-mm-dd HH24:mi:ss') optdate, a.info1, a.info2,a.info3, a.info4,
  551. a.info5, a.info6, a.info7 from stl_ccm_fixedcastspeed a,(select * From stl_ccm_optinfo union select * From j#stl_ccm_optinfo) b where 1 = 1 and a.starttime < nvl(nvl(b.baleendtime, b.baleleavetime), b.updatetime) and a.heatno=b.heatno(+) {0}";
  552. sqlStr = sqlStr + @" union all select a.heatno, a.stationcode, round(a.fixedspeed,2) fixedspeed,a.starttime, a.endtime,
  553. case when nvl(a.endtime, null)< nvl(nvl(b.baleendtime,b.baleleavetime),b.updatetime) then
  554. round((nvl(a.endtime, null) - a.starttime) * 86400 / 60, 2)
  555. else round((nvl(nvl(b.baleendtime,b.baleleavetime),b.updatetime) - a.starttime) * 86400 / 60, 2) end fixedtime , a.castflow, to_char(a.optdate,'yyyy-mm-dd HH24:mi:ss') optdate, a.info1, a.info2,a.info3, a.info4,
  556. a.info5, a.info6, a.info7 from j#stl_ccm_fixedcastspeed a,(select * From stl_ccm_optinfo union select * From j#stl_ccm_optinfo) b where 1 = 1 and a.starttime < nvl(nvl(b.baleendtime, b.baleleavetime), b.updatetime) and a.heatno=b.heatno(+) {0}";
  557. sqlStr = string.Format(sqlStr, sqlCondition);
  558. return sqlStr;
  559. }
  560. }
  561. /// <summary>
  562. ///
  563. /// </summary>
  564. public class RhsSqlCollection
  565. {
  566. /// <summary>
  567. ///
  568. /// </summary>
  569. /// <param name="sqlCondition"></param>
  570. /// <returns></returns>
  571. public static string returnSqlOfStl_Rhs_Oxygenblowing(string sqlCondition)
  572. {
  573. string sqlStr = "select * from stl_rhs_oxygenblowing where 1 = 1 {0}";
  574. sqlStr += "union all ";
  575. sqlStr += "select * from j#stl_rhs_oxygenblowing where 1 = 1 {0}";
  576. sqlStr = string.Format(sqlStr,sqlCondition);
  577. return sqlStr;
  578. }
  579. }
  580. public class LfsSqlCollection
  581. {
  582. /// <summary>
  583. /// lfs 操作记录表
  584. /// </summary>
  585. /// <param name="sqlCondiotnList"></param>
  586. /// <returns></returns>
  587. public static string returnSqlOfLfs_Operation(ArrayList sqlCondiotnList)
  588. {
  589. string sqlstr = "";
  590. sqlstr = @"select distinct to_char(a.OPTDATE, 'yyyy-MM-dd hh24:mi') OPTDATE,
  591. a.HEATNO,
  592. decode(a.DESLAGGFLAG,'0','否','1','是') SFDZ,
  593. a.LMLTEMPT,
  594. substr(a.STATIONCODE,2,1) ||'LF'||'-'||a.WSID STATIONCODE,
  595. b.MaxSPvalue,
  596. b.MinSPVALUE,
  597. b.AvgSPVALUE,
  598. a.LFSNO,
  599. a.PLANSTEEL,
  600. a.POTNO,
  601. a.POTWRAPSTATE,
  602. a.POTAGE,
  603. decode(substr(a.shiftcode, 1, 1),
  604. '1',
  605. '早',
  606. '2',
  607. '中',
  608. '3',
  609. '晚') BC,
  610. decode(substr(a.shiftcode, 2, 1),
  611. '1',
  612. '甲',
  613. '2',
  614. '乙',
  615. '3',
  616. '丙',
  617. '4',
  618. '丁') BB,
  619. nvl(u.PFBALEWGT,0)-nvl(u.BALELEAVEWGT,0) MOLSTLWGT,
  620. a.RESIDUETHICKNESS,
  621. to_char(a.ARRIVETIME, 'hh24:mi') ARRIVETIME,
  622. to_char(a.LEAVETIME, 'hh24:mi') LEAVETIME,
  623. a.ARRIVEWGT,
  624. a.LEAVEWGT,
  625. a.ARRIVEO2,
  626. a.LEAVEO2,
  627. '' WAL,
  628. '' WCA,
  629. '' SDDW,
  630. '' GLMB,
  631. to_char(a.beginblowar, 'hh24:mi') SELESTARTTIME,
  632. to_char(a.endblowar, 'hh24:mi') SELEENDTIME,
  633. a.SELETIME,
  634. a.ARRIVETEMPT,a.LEAVETEMPT,
  635. '' PPM,
  636. a.BLOWARPRESS,
  637. a.ARFLUX,
  638. '' WATERP,
  639. '' WATERFLOW,
  640. to_char(a.REPOSEBEGINTIME, 'hh24:mi') REPOSEBEGINTIME,
  641. a.REPOSETIME,
  642. a.FLEXIBLEBLOWTIME,
  643. v.PLAN_LINES,
  644. /*v.CAST_ID || '-' || v.cast_seq CAST_ID,*/
  645. u.heat_seq CAST_ID,
  646. a.LEAVETEMPT PFBALETEMPT,
  647. decode(a.DESLAGGFLAG,'0','否','1','是') IFSLAG,
  648. I.POTDISTINCTION POTDISTINCTION,
  649. round((a.endblowar - a.beginblowar) * 24 * 60) YLZQ,
  650. to_char(a.REPOSECLOSETIME,'hh24:mi') QDTIME,
  651. a.DISPOSALTIME,
  652. a.bzhatime,
  653. a.thermometer,
  654. a.sampler,
  655. a.reason18,
  656. a.modifier,
  657. a.memo,
  658. h.arbtempt castempt,
  659. a.refinetime,
  660. a.nb_wgt,a.v_wgt,a.cu_wgt,a.ni_wgt,a.b_wgt,a.mo_wgt,a.optpersonnel,
  661. /*max(case when a.HEATNO = w.HEATNO and w.xh = 1 then w.C end) over(partition by a.HEATNO) C_1,
  662. max(case when a.HEATNO = w.HEATNO and w.xh = 1 then w.SI end) over(partition by a.HEATNO) SI_1,
  663. max(case when a.HEATNO = w.HEATNO and w.xh = 1 then w.MN end) over(partition by a.HEATNO) MN_1,
  664. max(case when a.HEATNO = w.HEATNO and w.xh = 1 then w.P end) over(partition by a.HEATNO) P_1,
  665. max(case when a.HEATNO = w.HEATNO and w.xh = 1 then w.S end) over(partition by a.HEATNO) S_1,
  666. max(case when a.HEATNO = w.HEATNO and w.xh = 1 then w.ALS end) over(partition by a.HEATNO) ALS_1,
  667. max(case when a.HEATNO = w.HEATNO and w.xh = 1 then w.Alt end) over(partition by a.HEATNO) ALT_1,
  668. max(case when a.HEATNO = w.HEATNO and w.xh = 1 then w.Ca end) over(partition by a.HEATNO) CA_1,
  669. max(case when a.HEATNO = w.HEATNO and w.xh = 1 then w.Nb end) over(partition by a.HEATNO) NB_1,
  670. max(case when a.HEATNO = w.HEATNO and w.xh = 1 then w.V end) over(partition by a.HEATNO) V_1,
  671. max(case when a.HEATNO = w.HEATNO and w.xh = 1 then w.Cu end) over(partition by a.HEATNO) Cu_1,
  672. max(case when a.HEATNO = w.HEATNO and w.xh = 1 then w.Ni end) over(partition by a.HEATNO) NI_1,
  673. max(case when a.HEATNO = w.HEATNO and w.xh = 1 then w.Mo end) over(partition by a.HEATNO) MO_1, */
  674. max(case when a.HEATNO = n.HEATNO and n.xh = n.cnt then n.C end) over(partition by a.HEATNO) C_1,
  675. max(case when a.HEATNO = n.HEATNO and n.xh = n.cnt then n.si end) over(partition by a.HEATNO) SI_1,
  676. max(case when a.HEATNO = n.HEATNO and n.xh = n.cnt then n.MN end) over(partition by a.HEATNO) MN_1,
  677. max(case when a.HEATNO = n.HEATNO and n.xh = n.cnt then n.P end) over(partition by a.HEATNO) P_1,
  678. max(case when a.HEATNO = n.HEATNO and n.xh = n.cnt then n.S end) over(partition by a.HEATNO) S_1,
  679. max(case when a.HEATNO = n.HEATNO and n.xh = n.cnt then n.ALS end) over(partition by a.HEATNO) ALS_1,
  680. max(case when a.HEATNO = n.HEATNO and n.xh = n.cnt then n.Alt end) over(partition by a.HEATNO) ALT_1,
  681. max(case when a.HEATNO = n.HEATNO and n.xh = n.cnt then n.Ca end) over(partition by a.HEATNO) CA_1,
  682. max(case when a.HEATNO = n.HEATNO and n.xh = n.cnt then n.Nb end) over(partition by a.HEATNO) NB_1,
  683. max(case when a.HEATNO = n.HEATNO and n.xh = n.cnt then n.V end) over(partition by a.HEATNO) V_1,
  684. max(case when a.HEATNO = n.HEATNO and n.xh = n.cnt then n.Cu end) over(partition by a.HEATNO) Cu_1,
  685. max(case when a.HEATNO = n.HEATNO and n.xh = n.cnt then n.Ni end) over(partition by a.HEATNO) NI_1,
  686. max(case when a.HEATNO = n.HEATNO and n.xh = n.cnt then n.Mo end) over(partition by a.HEATNO) MO_1,
  687. max(case when a.HEATNO = w.HEATNO and w.xh = round(w.cnt / 2) then w.C end) over(partition by a.HEATNO) C_2,
  688. max(case when a.HEATNO = w.HEATNO and w.xh = round(w.cnt / 2) then w.SI end) over(partition by a.HEATNO) SI_2,
  689. max(case when a.HEATNO = w.HEATNO and w.xh = round(w.cnt / 2) then w.MN end) over(partition by a.HEATNO) MN_2,
  690. max(case when a.HEATNO = w.HEATNO and w.xh = round(w.cnt / 2) then w.P end) over(partition by a.HEATNO) P_2,
  691. max(case when a.HEATNO = w.HEATNO and w.xh = round(w.cnt / 2) then w.S end) over(partition by a.HEATNO) S_2,
  692. max(case when a.HEATNO = w.HEATNO and w.xh = round(w.cnt / 2) then w.ALS end) over(partition by a.HEATNO) ALS_2,
  693. max(case When a.HEATNO = w.HEATNO and w.xh = round(w.cnt / 2) then w.Alt end) over(partition by a.HEATNO) ALT_2,
  694. max(case when a.HEATNO = w.HEATNO and w.xh = round(w.cnt / 2) then w.Ca end) over(partition by a.HEATNO) CA_2,
  695. max(case when a.HEATNO = w.HEATNO and w.xh = w.cnt then w.C end) over(partition by a.HEATNO) C_3,
  696. max(case when a.HEATNO = w.HEATNO and w.xh = w.cnt then w.SI end) over(partition by a.HEATNO) SI_3,
  697. max(case when a.HEATNO = w.HEATNO and w.xh = w.cnt then w.MN end) over(partition by a.HEATNO) MN_3,
  698. max(case when a.HEATNO = w.HEATNO and w.xh = w.cnt then w.P end) over(partition by a.HEATNO) P_3,
  699. max(case when a.HEATNO = w.HEATNO and w.xh = w.cnt then w.S end) over(partition by a.HEATNO) S_3,
  700. max(case when a.HEATNO = w.HEATNO and w.xh = w.cnt then w.ALS end) over(partition by a.HEATNO) ALS_3,
  701. max(case when a.HEATNO = w.HEATNO and w.xh = w.cnt then w.ALT end) over(partition by a.HEATNO) ALT_3,
  702. max(case when a.HEATNO = w.HEATNO and w.xh = w.cnt then w.Ca end) over(partition by a.HEATNO) CA_3,
  703. max(case when a.heatno = t4.heatno and t4.xh = 1 then t4.c end) over(partition by a.heatno) C_4,
  704. max(case when a.heatno = t4.heatno and t4.xh = 1 then t4.SI end) over(partition by a.heatno) SI_4,
  705. max(case when a.heatno = t4.heatno and t4.xh = 1 then t4.MN end) over(partition by a.heatno) MN_4,
  706. max(case when a.heatno = t4.heatno and t4.xh = 1 then t4.P end) over(partition by a.heatno) P_4,
  707. max(case when a.heatno = t4.heatno and t4.xh = 1 then t4.S end) over(partition by a.heatno) S_4,
  708. max(case when a.heatno = t4.heatno and t4.xh = 1 then t4.ALS end) over(partition by a.heatno) ALS_4,
  709. max(case when a.heatno = t4.heatno and t4.xh = 1 then t4.NI end) over(partition by a.heatno) Ni_4,
  710. max(case when a.heatno = t4.heatno and t4.xh = 1 then t4.MO end) over(partition by a.heatno) Mo_4,
  711. max(case when a.heatno = t4.heatno and t4.xh = 1 then t4.NB end) over(partition by a.heatno) Nb_4,
  712. max(case when a.heatno = t4.heatno and t4.xh = 1 then t4.V end) over(partition by a.heatno) V_4,
  713. max(case when a.heatno = t4.heatno and t4.xh = 1 then t4.CR end) over(partition by a.heatno) Cr_4,
  714. max(case when a.heatno = t4.heatno and t4.xh = 1 then t4.CU end) over(partition by a.heatno) Cu_4,
  715. max(case when a.heatno = t4.heatno and t4.xh = 1 then t4.ALT end) over(partition by a.heatno) ALT_4,
  716. max(case when a.heatno = t4.heatno and t4.xh = 1 then t4.CA end) over(partition by a.heatno) CA_4,
  717. GetStandardVaule(a.HEATNO,t4.MN,t4.NI,t4.MO,t4.NB,t4.V,t4.ALS,t4.CR,t4.CU) CFFC
  718. from (select *
  719. from stl_LFS_OPTINFO
  720. where {0}
  721. union
  722. select * from J#stl_LFS_OPTINFO where {0}) a,
  723. (select y.*
  724. from (select x.*,
  725. count(1) over(partition by x.HEATNO) cnt,
  726. row_number() over(partition by x.HEATNO order by x.ASSAYTYPECODE) xh
  727. from (select *
  728. from stl_CHEMELEMENT
  729. where upper(SUBSTR(CHECKNO, 12, 1)) = 'E'
  730. and upper(SUBSTR(CHECKNO, -1)) = 'S'
  731. {1}
  732. union
  733. select *
  734. from J#stl_CHEMELEMENT
  735. where upper(SUBSTR(CHECKNO, 12, 1)) = 'E'
  736. and upper(SUBSTR(CHECKNO, -1)) = 'S'
  737. {1}) x) y
  738. where y.xh in (1, round(y.cnt / 2), y.cnt)) w,
  739. (select y.*
  740. from (select x.*,
  741. count(1) over(partition by x.HEATNO) cnt,
  742. row_number() over(partition by x.HEATNO order by x.ASSAYTYPECODE) xh
  743. from (select *
  744. from stl_CHEMELEMENT
  745. where upper(SUBSTR(CHECKNO, 12, 2)) = 'DQ'
  746. and upper(SUBSTR(CHECKNO, -1)) = 'S'
  747. {1}
  748. union
  749. select *
  750. from J#stl_CHEMELEMENT
  751. where upper(SUBSTR(CHECKNO, 12, 2)) = 'DQ'
  752. and upper(SUBSTR(CHECKNO, -1)) = 'S'
  753. {1}
  754. ) x) y
  755. where y.xh in (1, round(y.cnt / 2), y.cnt)) n,
  756. (select y.*
  757. from (select x.*,
  758. row_number() over(partition by x.HEATNO, substr(assaytypecode, 1, 1) order by x.ASSAYTYPECODE desc) xh,
  759. substr(assaytypecode, 1, 1) typecode
  760. from (select *
  761. from stl_CHEMELEMENT
  762. where upper(SUBSTR(CHECKNO, -1)) = 'S'
  763. and upper(SUBSTR(CHECKNO, 12, 2)) = 'GP'
  764. {2}
  765. union
  766. select *
  767. from J#stl_CHEMELEMENT
  768. where upper(SUBSTR(CHECKNO, -1)) = 'S'
  769. and upper(SUBSTR(CHECKNO, 12, 2)) = 'GP'
  770. {2}) x) y
  771. where y.xh = 1) t4,
  772. (select *
  773. from stl_CCM_OPTINFO
  774. where {3}
  775. union
  776. select * from J#stl_CCM_OPTINFO where {3}) u,
  777. (select HEATNO, maxSPvalue, MinSPVALUE, avgSPVALUE
  778. from (select max(SAMPLINGVALUE) maxSPvalue,
  779. min(SAMPLINGVALUE) MinSPVALUE,
  780. round(avg(SAMPLINGVALUE), 2) avgSPVALUE,
  781. HEATNO
  782. from stl_tempsampling where substr(samplingdepict,1,4)='中包温度'
  783. {4}
  784. group by HEATNO
  785. union
  786. select max(SAMPLINGVALUE) maxSPvalue,
  787. min(SAMPLINGVALUE) MinSPVALUE,
  788. round(avg(SAMPLINGVALUE), 2) avgSPVALUE,
  789. HEATNO
  790. from J#stl_tempsampling where substr(samplingdepict,1,4)='中包温度'
  791. {4}
  792. group by HEATNO)) b,
  793. (select *
  794. from stl_CAS_OPTINFO
  795. where {5}
  796. union
  797. select * from J#stl_CAS_OPTINFO where {5}) h,
  798. (select *
  799. from stl_BOF_OPTINFO
  800. where {6}
  801. union
  802. select * from J#stl_BOF_OPTINFO where {6}) I,
  803. (select *
  804. from ppc_steel_heat where 1 = 1 {7}
  805. union
  806. select * from J#ppc_steel_heat where 1 = 1 {7}) v
  807. where a.HEATNO = u.HEATNO(+)
  808. and a.Heatno = N.HEATNO(+)
  809. and a.HEATNO = w.HEATNO(+)
  810. and a.HEATNO = v.HEATNo(+)
  811. and a.HEATNO = t4.HEATNO(+)
  812. and a.heatno = h.heatno(+)
  813. and a.heatno = b.HEATNO(+)
  814. and a.heatno = I.HEATNO(+)
  815. order by OPTDATE";
  816. sqlstr = lgCommon.stringFormat(sqlstr, sqlCondiotnList);
  817. return sqlstr;
  818. }
  819. }
  820. }
  821. }