6088e893d870c8296527ad6d5ec25f70517c38e4.svn-base 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. package UIM.UIM06;
  2. import java.sql.Connection;
  3. import java.sql.PreparedStatement;
  4. import java.sql.ResultSet;
  5. import java.sql.SQLException;
  6. import java.util.List;
  7. import java.util.Map;
  8. import UIB.COM.XmlSqlParsersFactory;
  9. import UIM.Tools;
  10. import CoreFS.SA01.CoreIComponent;
  11. import CoreFS.SA06.CoreReturnObject;
  12. /**
  13. * 冷轧中间库钢卷入库管理
  14. *
  15. * @author zsx
  16. * @date 2017-07-31
  17. */
  18. public class UIM060030 extends CoreIComponent {
  19. public CoreReturnObject queryCoilsInStock(String productTime,String toproductTime,String coilNo,String flag) throws SQLException
  20. {
  21. String sql = XmlSqlParsersFactory.getSql("UIM060030_11.SELECT");
  22. return this.getDao("KgDao").ExcuteQuery(sql, new Object[]{productTime,toproductTime,coilNo});
  23. }
  24. public CoreReturnObject saveCoilYardN(String coilNo,String yardAddr,String entryShift,
  25. String entryGroup,String entryDtime,String reg_id) throws SQLException
  26. {
  27. CoreReturnObject cro = new CoreReturnObject();
  28. Connection con = null;//pSta.getConnection();
  29. //判断垛位是否存在
  30. String sqlYard = "select CLF_NO from c_tbk08_coil_yard "
  31. + "where CLF_NAME = substr(?,0,1) "
  32. + "and CLF_ROW = substr(?,3,2) "
  33. + "and CLF_COL = substr(?,7,2) "
  34. + "and CLF_FL = DECODE(substr(?,5,1),'A','1','B','2','C','3','1')";
  35. List yardList = this.getDao("KgDao")
  36. .ExcuteQueryReturnList(
  37. sqlYard,
  38. new Object[] { yardAddr, yardAddr, yardAddr,
  39. yardAddr });
  40. if(yardList.size() > 0){
  41. String chkcoil = "select COIL_NO from c_tbk08_coil_yard "
  42. + "where CLF_NAME = substr(?,0,1) "
  43. + "and CLF_ROW = substr(?,3,2) "
  44. + "and CLF_COL = substr(?,7,2) "
  45. + "and CLF_FL = DECODE(substr(?,5,1),'A','1','B','2','C','3','1') AND COIL_NO IS NOT NULL";
  46. List coilList = this.getDao("KgDao")
  47. .ExcuteQueryReturnList(
  48. chkcoil,
  49. new Object[] { yardAddr, yardAddr, yardAddr,
  50. yardAddr });
  51. String chkcoil2 = "select COIL_NO from C_TBL02_COIL_COMM where CUR_LOAD_LOC = ?";
  52. List coilList2 = this.getDao("KgDao")
  53. .ExcuteQueryReturnList(
  54. chkcoil2,
  55. new Object[] { yardAddr });
  56. if(coilList.size() > 0||coilList2.size()>0)
  57. {
  58. cro.setV_errCode(new Integer(-1));
  59. cro.setV_errMsg("垛位被占用!");
  60. }
  61. else
  62. {
  63. //查询钢卷入库信息
  64. String sqlEntry = "select COIL_NO from c_tbL02_coil_comm where OLD_SAMPL_NO = ? AND COIL_STAT = '2'";
  65. List listEntry = this.getDao("KgDao").ExcuteQueryReturnList(sqlEntry,new Object[]{coilNo});
  66. if(listEntry.size() == 0){
  67. cro.setV_errCode(new Integer(1));
  68. cro.setV_errMsg("此钢卷没有轧制完成,或者已经出库!");
  69. }
  70. else{
  71. //查询钢卷出库信息
  72. String sqlOut = "select CUR_LOAD_LOC from c_tbL02_coil_comm where OLD_SAMPL_NO = ?";
  73. List listOut = this.getDao("KgDao").ExcuteQueryReturnList(sqlOut, new Object[]{coilNo});
  74. if(listOut.size() > 0 && !Tools.isEmpty(((Map)(listOut.get(0))).get("CUR_LOAD_LOC"))){
  75. cro.setV_errCode(new Integer(2));
  76. cro.setV_errMsg("此钢卷已在垛位中存在!");
  77. }
  78. else{
  79. //将入库操作信息和垛位信息加入冷轧成品公共表
  80. String sqlucomm = "update c_tbL02_coil_comm set CUR_LOAD_LOC = ?," +
  81. " CUR_LOAD_LOC_DTIME = TO_CHAR(SYSDATE,'YYYYMMDDHH24MISS')," +
  82. " YARD_ENTRY_SHIFT = ?, YARD_ENTRY_GROUP = ?, YARD_ENTRY_REG = ?," +
  83. " YARD_ENTRY_DTIME = ?, " +
  84. " YARD_ENTRY_USE_TIME = TO_CHAR(SYSDATE,'YYYYMMDDHH24MISS')" +
  85. " where OLD_SAMPL_NO = ?";
  86. this.getDao("KgDao").ExcuteNonQuery(sqlucomm,
  87. new Object[]{yardAddr,entryShift,entryGroup,reg_id,entryDtime,coilNo});
  88. //入库完成后将入库记录加入移垛记录,便于跟踪钢卷移动记录
  89. long seq = 0;//移垛记录表主键
  90. String sqlqmaxseq = "select max(ROLL_SEQ) ROLL_SEQ from c_tbk08_coil_move";
  91. PreparedStatement pSta = this.getDao("KgDao").getPreparedStatement(sqlqmaxseq);
  92. ResultSet rs = pSta.executeQuery();
  93. con=pSta.getConnection();
  94. if(rs.next()){
  95. seq = rs.getLong("ROLL_SEQ")+1;
  96. }
  97. rs.close();
  98. pSta.close();
  99. con.close();
  100. // 入库类型
  101. String inType = "";
  102. String sqlType = "select T.IN_YARD_KIND from C_TBL02_COIL_COMM T where T.OLD_SAMPL_NO = ?";
  103. pSta = this.getDao("KgDao").getPreparedStatement(
  104. sqlType);
  105. pSta.setString(1, coilNo);
  106. rs = pSta.executeQuery();
  107. con=pSta.getConnection();
  108. if (rs.next()) {
  109. inType = rs.getString("IN_YARD_KIND");
  110. }
  111. rs.close();
  112. pSta.close();
  113. con.close();
  114. String sqlimove = "insert into c_tbk08_coil_move T(T.ROLL_SEQ,T.CUR_LOAD_LOC_F,T.CUR_LOAD_LOC_T,T.COIL_NO,T.REG_ID,T.REG_SHIFT,T.REG_GROUP,T.REG_DTIME,T.REG_USE_ID,T.REG_USE_DTIME,MOVE_TYPE)" +
  115. "VALUES(?,?,?,?,?,?,?,?,?,TO_CHAR(SYSDATE,'YYYYMMDDHH24MISS'),decode(?,'1','02','2','02','3','05','4','05','5','04','6','04','7','04'))";
  116. this.getDao("KgDao").ExcuteNonQuery(sqlimove, new Object[]{seq,"",yardAddr,coilNo,reg_id,entryShift,entryGroup,entryDtime,reg_id,inType});
  117. }
  118. }
  119. }
  120. }
  121. else{
  122. cro.setV_errCode(new Integer(3));
  123. cro.setV_errMsg("垛位不存在!");
  124. }
  125. return cro;
  126. }
  127. }