SqlCollectionCcm.cs 8.0 KB

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