ac4097ccadec0d7f303890fe7d36e79a0653f1a6.svn-base 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. package UIM;
  2. import java.sql.PreparedStatement;
  3. import java.sql.ResultSet;
  4. import java.sql.SQLException;
  5. import java.util.ArrayList;
  6. import java.util.Iterator;
  7. import java.util.List;
  8. import java.util.Map;
  9. import UIB.COM.XmlSqlParsersFactory;
  10. import CoreFS.SA01.CoreIComponent;
  11. import CoreFS.SA06.CoreReturnObject;
  12. /**
  13. * 冷轧原料库库存数据移动
  14. *
  15. * @author siy
  16. * @date 2010-08-27
  17. */
  18. public class UIM010100 extends CoreIComponent {
  19. /**
  20. * 查询钢卷位置
  21. *
  22. * @param coilNo
  23. * 热轧卷号
  24. * @return CoreReturnObject
  25. * @throws SQLException
  26. */
  27. public CoreReturnObject queryLoadLoc(String coilNo) throws SQLException {
  28. CoreReturnObject cro = new CoreReturnObject();
  29. StringBuffer sqlBuffer = new StringBuffer();
  30. sqlBuffer.append("select k.cur_load_loc from c_tbk02_coil_comm k,\n");
  31. sqlBuffer.append("c_tbk08_coil_yard y,c_tbk08_coil_yard_area a \n");
  32. sqlBuffer.append("where k.COIL_NO = y.COIL_NO \n");
  33. sqlBuffer.append("and y.AREA_NO = a.AREA_NO \n");
  34. sqlBuffer.append("and a.AREA_TYPE = 1 \n");
  35. sqlBuffer.append("and k.coil_no = ?");
  36. List list = this.getDao("KgDao").ExcuteQueryReturnList(
  37. sqlBuffer.toString(), new Object[] { coilNo });// .ExcuteQuery(sql);
  38. String curLoadLoc = "";
  39. Iterator it = list.iterator();
  40. while (it.hasNext()) {
  41. Map map = (Map) it.next();
  42. curLoadLoc = map.get("cur_load_loc").toString();
  43. }
  44. // System.out.println(count);
  45. cro.setResult(curLoadLoc);
  46. return cro;
  47. }
  48. /**
  49. * 查询区域中的垛位及钢卷
  50. *
  51. * @param areaType
  52. * @return
  53. * @throws SQLException
  54. */
  55. public CoreReturnObject queryYardCoils(String areaType) throws SQLException {
  56. CoreReturnObject cro = new CoreReturnObject();
  57. StringBuffer sqlBuffer = new StringBuffer();
  58. sqlBuffer.append(" select 'FALSE' chk\n");
  59. sqlBuffer
  60. .append(" ,y.CLF_NAME||'-'||trim(to_char(y.CLF_COL,'00'))||decode(y.CLF_FL,1,'A',2,'B',3,'C')||'-'||trim(to_char(y.CLF_ROW,'00')) cur_load_loc\n");
  61. sqlBuffer.append(" ,k.coil_no\n");
  62. sqlBuffer.append(" from c_tbk08_coil_yard y,c_tbk02_coil_comm k\n");
  63. sqlBuffer
  64. .append(" where y.CLF_NAME||'-'||trim(to_char(y.CLF_COL,'00'))||decode(y.CLF_FL,1,'A',2,'B',3,'C')||'-'||trim(to_char(y.CLF_ROW,'00')) = k.CUR_LOAD_LOC(+)\n");
  65. sqlBuffer.append(" and y.AREA_NO = ? and y.CLF_NAME NOT IN('6','7')\n");
  66. sqlBuffer.append(" order by y.CLF_COL,y.CLF_ROW,y.CLF_FL\n");
  67. cro = this.getDao("KgDao").ExcuteQuery(sqlBuffer.toString(),
  68. new Object[] { areaType });
  69. return cro;
  70. }
  71. /*
  72. * 酸洗库存数据查询 20171129*/
  73. public CoreReturnObject queryYardCoilsSx(String areaType) throws SQLException {
  74. CoreReturnObject cro = new CoreReturnObject();
  75. StringBuffer sqlBuffer = new StringBuffer();
  76. sqlBuffer.append(" select 'FALSE' chk\n");
  77. sqlBuffer
  78. .append(" ,y.CLF_NAME||'-'||trim(to_char(y.CLF_COL,'00'))||decode(y.CLF_FL,1,'A',2,'B',3,'C')||'-'||trim(to_char(y.CLF_ROW,'00')) cur_load_loc\n");
  79. sqlBuffer.append(" ,k.coil_no\n");
  80. sqlBuffer.append(" from c_tbk08_coil_yard y,c_tbk02_coil_comm k\n");
  81. sqlBuffer
  82. .append(" where y.CLF_NAME||'-'||trim(to_char(y.CLF_COL,'00'))||decode(y.CLF_FL,1,'A',2,'B',3,'C')||'-'||trim(to_char(y.CLF_ROW,'00')) = k.CUR_LOAD_LOC(+)\n");
  83. sqlBuffer.append(" and y.AREA_NO = ? and y.CLF_NAME='6'\n");
  84. sqlBuffer.append(" order by y.CLF_COL,y.CLF_ROW,y.CLF_FL\n");
  85. cro = this.getDao("KgDao").ExcuteQuery(sqlBuffer.toString(),
  86. new Object[] { areaType });
  87. return cro;
  88. }
  89. /**
  90. * 钢卷移垛
  91. *
  92. * @param moveList
  93. * 移垛钢卷垛位信息
  94. * @param regId
  95. * 移垛人
  96. * @param moveOrder
  97. * 移垛班次
  98. * @param moveGroup
  99. * 移垛班组
  100. * @param moveDate
  101. * 移垛时间
  102. * @return
  103. * @throws SQLException
  104. */
  105. public CoreReturnObject moveColdCoil(ArrayList<String[]> moveList,
  106. String regId, String moveOrder, String moveGroup, String moveDate)
  107. throws SQLException {
  108. CoreReturnObject cro = new CoreReturnObject();
  109. StringBuffer sqlBuffer = null;
  110. Map result = this.getDao("KgDao").CoreBeginTranscation();
  111. try {
  112. for (int i = 0; i < moveList.size(); i++) {
  113. String[] moveCoil = moveList.get(i);
  114. // 更新钢卷公共表
  115. sqlBuffer = new StringBuffer();
  116. sqlBuffer.append("\n");
  117. sqlBuffer
  118. .append("UPDATE C_TBK02_COIL_COMM K SET K.CUR_LOAD_LOC = ?\n");
  119. sqlBuffer
  120. .append(",K.CUR_LOAD_LOC_DTIME = TO_CHAR(SYSDATE,'YYYYMMDDHH24MISS') WHERE K.COIL_NO = ?\n");
  121. this.getDao("KgDao").ExcuteNonQuery(sqlBuffer.toString(),
  122. new Object[] { moveCoil[1], moveCoil[2] });
  123. // 更新垛位表
  124. sqlBuffer = new StringBuffer();
  125. sqlBuffer
  126. .append("UPDATE C_TBK08_COIL_YARD Y SET Y.COIL_NO = ?,Y.MOD_ID = ?\n");
  127. sqlBuffer
  128. .append(" , Y.MOD_TIME = TO_CHAR(SYSDATE,'YYYYMMDDHH24MISS')\n");
  129. sqlBuffer
  130. .append(" WHERE Y.CLF_NAME = SUBSTR(?,0,1) AND CLF_COL = SUBSTR(?,3,2)\n");
  131. sqlBuffer.append(" AND CLF_ROW = SUBSTR(?,7,2) \n");
  132. sqlBuffer
  133. .append(" AND CLF_FL = DECODE(SUBSTR(?,5,1),'A','1','B','2','C','3','1')\n");
  134. this.getDao("KgDao").ExcuteNonQuery(
  135. sqlBuffer.toString(),
  136. new Object[] { "", regId, moveCoil[0], moveCoil[0],
  137. moveCoil[0], moveCoil[0] });
  138. this.getDao("KgDao").ExcuteNonQuery(
  139. sqlBuffer.toString(),
  140. new Object[] { moveCoil[2], regId, moveCoil[1],
  141. moveCoil[1], moveCoil[1], moveCoil[1] });
  142. // 如果钢卷已退回热轧,需要同步更新热轧成品卷垛位
  143. int hCoilCount = 0;
  144. String sql = XmlSqlParsersFactory.getSql("UIM010100_01.SELECT");
  145. List list = this.getDao("KgDao").ExcuteQueryReturnList(sql,
  146. new Object[] { moveCoil[2] });
  147. Iterator it = list.iterator();
  148. if (it.hasNext()) {
  149. Map map = (Map) it.next();
  150. try {
  151. hCoilCount = Integer.parseInt(map.get("COUNT")
  152. .toString());
  153. } catch (Exception ex) {
  154. }
  155. }
  156. if (hCoilCount > 0) {
  157. sql = XmlSqlParsersFactory.getSql("UIM010100_01.UPDATE");
  158. this.getDao("KgDao").ExcuteNonQuery(sql,
  159. new Object[] { moveCoil[1], moveCoil[2] });
  160. }
  161. // 移垛完成后将移垛记录加入移垛记录表,便于跟踪钢卷移动记录
  162. sqlBuffer = new StringBuffer();
  163. sqlBuffer.append("INSERT INTO C_TBK08_COIL_MOVE (ROLL_SEQ\n");
  164. sqlBuffer
  165. .append(" ,CUR_LOAD_LOC_F,CUR_LOAD_LOC_T,COIL_NO,REG_ID\n");
  166. sqlBuffer
  167. .append(" ,REG_SHIFT,REG_GROUP,REG_DTIME,REG_USE_DTIME,MOVE_TYPE)\n");
  168. sqlBuffer
  169. .append(" VALUES((SELECT MAX(ROLL_SEQ)+1 ROLL_SEQ FROM C_TBK08_COIL_MOVE),?,?,?,?,?,?,?,TO_CHAR(SYSDATE,'YYYYMMDDHH24MISS'),'00')\n");
  170. this.getDao("KgDao").ExcuteNonQuery(
  171. sqlBuffer.toString(),
  172. new Object[] { moveCoil[0], moveCoil[1],
  173. moveCoil[2], regId, moveOrder, moveGroup,
  174. moveDate });
  175. }
  176. this.getDao("KgDao").CoreCommit(result);
  177. } catch (Exception e) {
  178. e.printStackTrace();
  179. this.getDao("KgDao").CoreRollBack(result);
  180. }
  181. return cro;
  182. }
  183. }