SqlCollectionCcm.cs 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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. using Core.Mes.Client.Common;
  9. namespace Core.LgMes.Client.lgServiceMgt.LgSqlCollection.LgReportSql
  10. {
  11. /// <summary>
  12. /// ccm sql 集合
  13. /// </summary>
  14. public class SqlCollectionCcm
  15. {
  16. /// <summary>
  17. /// 板坯铸机典拉表 20140325 ym
  18. /// </summary>
  19. /// <param name="sqlConditionList"></param>
  20. /// <returns></returns>
  21. public static string ReturnSqlOfCcmDlReport(ArrayList sqlConditionList)
  22. {
  23. string strSql = "select RQ \"日期\", BC \"班次\", BB \"班别\", HEATNO \"炉号\", PLANSTEEL \"钢种\", "
  24. + "BJZCX \"班浇注次序\", ZBCX \"中包次序\", trim(to_char(JZDW, '990.0')) \"浇注吨位\", SFYL \"是否引流\", "
  25. + "to_char(balestarttime, 'HH24:mi') \"大包开浇时间\", "
  26. + "to_char(baleendtime, 'HH24:mi') \"大包关闭时间\", "
  27. + " substr(stationcode,2,1) CCM_ID, "
  28. + "trim(to_char(round((case when cast_no = cast_no_next then balestarttime_next else baleendtime end - balestarttime)*24*60, 1), '990.0')) "
  29. + "\"浇注周期\", "
  30. + "temp_min \"最低_1\", temp_max \"最高_1\", wc \"温差\", "
  31. + "round(spd_min, 2) \"最低_2\", round(spd_max, 2) \"最高_2\", round(bd, 2) \"波动\", "
  32. + "S \"S\", Als \"Als\", N \"N\", MEMO \"备注\" ";
  33. strSql = strSql + @" from (select to_char(case
  34. when a.BALESTARTTIME is not null then
  35. a.BALESTARTTIME
  36. else
  37. a.OPTDATE
  38. end,
  39. 'yyyy-MM-dd') RQ,
  40. case substr(a.SHIFTCODE, 1, 1)
  41. when '1' then
  42. '早'
  43. when '2' then
  44. '中'
  45. when '3' then
  46. '夜'
  47. end BC,
  48. case substr(a.SHIFTCODE, 2, 1)
  49. when '1' then
  50. '甲'
  51. when '2' then
  52. '乙'
  53. when '3' then
  54. '丙'
  55. when '4' then
  56. '丁'
  57. end BB,
  58. a.HEATNO,
  59. a.STATIONCODE,
  60. a.PLANSTEEL,
  61. row_number() over(partition by to_char(case
  62. when a.BALESTARTTIME is not null then
  63. a.BALESTARTTIME
  64. else
  65. a.OPTDATE
  66. end, 'yyyy-MM-dd'), a.SHIFTCODE order by a.BALESTARTTIME) BJZCX,
  67. row_number() over(partition by b.CAST_NO order by a.BALESTARTTIME) ZBCX,
  68. round(nvl(a.PFBALEWGT, 0) - nvl(a.BALELEAVEWGT, 0), 1) JZDW,
  69. case nvl(a.BALEFLOWFLAG, 0)
  70. when 1 then
  71. '×'
  72. end SFYL,
  73. a.BALESTARTTIME,
  74. a.BALEENDTIME,
  75. nvl(b.CAST_NO, a.MOULDNO) CAST_NO,
  76. lead(a.BALESTARTTIME, 1, a.BALEENDTIME) over(order by a.BALESTARTTIME) BALESTARTTIME_NEXT,
  77. lead(b.CAST_NO, 1, a.MOULDNO) over(order by a.BALESTARTTIME) CAST_NO_NEXT,
  78. round(c.TEMP_MIN) TEMP_MIN,
  79. round(c.TEMP_MAX) TEMP_MAX,
  80. round((c.TEMP_MAX - c.TEMP_MIN)) WC,
  81. c.SPD_MIN,
  82. c.SPD_MAX,
  83. (c.SPD_MAX - c.SPD_MIN) BD,
  84. trim(to_char(d.S, '0.000')) S,
  85. trim(to_char(d.Als, '0.000')) Als,
  86. trim(to_char(d.N, '0.0000')) N,
  87. a.MEMO
  88. from (select *
  89. from STL_CCM_OPTINFO
  90. where 1 = 1 {0}
  91. union all
  92. select *
  93. from J#STL_CCM_OPTINFO
  94. where 1 = 1 {0}) a,
  95. (select *
  96. from ppc_STEEL_HEAT
  97. where 1 = 1 {1}) b,
  98. (select distinct x.HEATNO,
  99. min(case
  100. when nvl(x.MIDLADLETEMP, 0) between {2} and {3} then
  101. nvl(x.MIDLADLETEMP, 0)
  102. end) over(partition by x.HEATNO) TEMP_MIN,
  103. max(case
  104. when nvl(x.MIDLADLETEMP, 0) between {2} and {3} then
  105. nvl(x.MIDLADLETEMP, 0)
  106. end) over(partition by x.HEATNO) TEMP_MAX,
  107. min(LEAST(x.S1CASTSPEED,X.S2CASTSPEED)) over(partition by x.HEATNO) SPD_MIN,
  108. max(GREATEST(x.S1CASTSPEED,x.S2CASTSPEED)) over(partition by x.HEATNO) SPD_MAX
  109. from (select *
  110. from {4}
  111. where 1 = 1 {5}
  112. union all
  113. select *
  114. from J#{4}
  115. where 1 = 1 {5}) x) c,
  116. (select y.*
  117. from (select x.*,
  118. row_number() over(partition by x.HEATNO order by x.ASSAYDATE) xh
  119. from (select *
  120. from STL_CHEMELEMENT
  121. where (upper(substr(ASSAYTYPECODE, 1, 2)) = 'CP' or
  122. upper(substr(STATIONCODE, 1, 1)) = 'G')
  123. {6}
  124. union all
  125. select *
  126. from J#STL_CHEMELEMENT
  127. where (upper(substr(ASSAYTYPECODE, 1, 2)) = 'CP' or
  128. upper(substr(STATIONCODE, 1, 1)) = 'G')
  129. {6}) x) y
  130. where y.xh = 1) d
  131. where a.HEATNO = b.HEATNO(+)
  132. and a.HEATNO = c.HEATNO(+)
  133. and a.HEATNO = d.HEATNO(+)
  134. order by a.BALESTARTTIME)
  135. where RQ between {7} and {8}";
  136. strSql = lgCommon.stringFormat(strSql,sqlConditionList);
  137. return strSql;
  138. }
  139. /// <summary>
  140. /// 获取炉号的最小和最大给定拉速
  141. /// </summary>
  142. /// <param name="sqlWhere"></param>
  143. /// <returns></returns>
  144. public static string returnSqlForMinSpeedAndMaxSpeedForHeatNo(string sqlWhere)
  145. {
  146. string sqlstr = "";
  147. sqlstr = sqlstr + " select heatno,min(fixedspeed) min_fixedspeed,max(fixedspeed) maxfixedspeed from ( "
  148. + " select a.heatno,a.fixedspeed from j#stl_ccm_fixedcastspeed a "
  149. + " where 1 = 1 {0} union all "
  150. + " select a.heatno,a.fixedspeed from stl_ccm_fixedcastspeed a where 1 = 1 {0} ) group by heatno";
  151. sqlstr = string.Format(sqlstr, sqlWhere);
  152. return sqlstr;
  153. }
  154. }
  155. }