55dde7a4926636dc2518e640af8b2b0d084f9552.svn-base 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. package UIM;
  2. import java.sql.Connection;
  3. import java.sql.PreparedStatement;
  4. import java.sql.ResultSet;
  5. import java.sql.SQLException;
  6. import java.util.Map;
  7. import java.util.List;
  8. import UIM.Tools;
  9. import UIB.COM.XmlSqlParsersFactory;
  10. import CoreFS.SA01.CoreIComponent;
  11. import CoreFS.SA06.CoreReturnObject;
  12. /**
  13. * 冷轧成品库钢卷入库管理
  14. * @author siy
  15. * @date 2011-08-03
  16. */
  17. public class UIM010200 extends CoreIComponent {
  18. /**
  19. * 查询待入库钢卷
  20. * @param productTime 生产时间 yyyymmdd
  21. * @param coilNo 钢卷号
  22. * @return CoreReturnObject
  23. * @throws SQLException
  24. */
  25. public CoreReturnObject queryCoilsInStock(String productTime,String toproductTime,String coilNo,String flag) throws SQLException
  26. {
  27. String sql = XmlSqlParsersFactory.getSql("UIM010200_01.SELECT");
  28. if(flag.equals("1")){
  29. sql += " AND LINE_TP = 'L'";
  30. }
  31. else if(flag.equals("2")){
  32. sql += " AND LINE_TP = 'C'";
  33. }
  34. return this.getDao("KgDao").ExcuteQuery(sql, new Object[]{productTime,toproductTime,coilNo});
  35. }
  36. /**
  37. * 成品库钢卷入库
  38. * @param coilNo 钢卷号
  39. * @param yardAddr 垛位
  40. * @param entryShift 入库班次
  41. * @param entryGroup 入库班组
  42. * @param entryDtime 入库时间
  43. * @param reg_id 操作人
  44. * @return CoreReturnObject
  45. * @throws SQLException
  46. */
  47. public CoreReturnObject saveCoilYard(String coilNo,String yardAddr,String entryShift,
  48. String entryGroup,String entryDtime,String reg_id) throws SQLException
  49. {
  50. CoreReturnObject cro = new CoreReturnObject();
  51. Connection con = null;//pSta.getConnection();
  52. //判断垛位是否存在
  53. String sqlYard = "select 1 from c_tbk08_coil_yard t where t.clf_no = C_PKG_UIM.GET_FINALYARDNO_BYYARDFLAG(?)";
  54. List yardList = this.getDao("KgDao").ExcuteQueryReturnList(sqlYard, new Object[]{yardAddr});
  55. if(yardList.size() > 0){
  56. //查询钢卷入库信息
  57. String sqlEntry = "select COIL_NO from c_tbc02_coil_comm where OLD_SAMPL_NO = ? AND COIL_STAT = '2'";
  58. List listEntry = this.getDao("KgDao").ExcuteQueryReturnList(sqlEntry,new Object[]{coilNo});
  59. if(listEntry.size() == 0){
  60. cro.setV_errCode(new Integer(1));
  61. cro.setV_errMsg("此钢卷没有轧制完成,或者已经出库!");
  62. }
  63. else{
  64. //查询钢卷出库信息
  65. String sqlOut = "select CUR_LOAD_LOC from c_tbc02_coil_comm where OLD_SAMPL_NO = ?";
  66. List listOut = this.getDao("KgDao").ExcuteQueryReturnList(sqlOut, new Object[]{coilNo});
  67. if(listOut.size() > 0 && !Tools.isEmpty(((Map)(listOut.get(0))).get("CUR_LOAD_LOC"))){
  68. cro.setV_errCode(new Integer(2));
  69. cro.setV_errMsg("此钢卷已在垛位中存在!");
  70. }
  71. else{
  72. //将入库操作信息和垛位信息加入冷轧成品公共表
  73. String sqlucomm = "update c_tbc02_coil_comm set CUR_LOAD_LOC = ?," +
  74. " CUR_LOAD_LOC_DTIME = TO_CHAR(SYSDATE,'YYYYMMDDHH24MISS')," +
  75. " YARD_ENTRY_SHIFT = ?, YARD_ENTRY_GROUP = ?, YARD_ENTRY_REG = ?," +
  76. " YARD_ENTRY_DTIME = ?, " +
  77. " YARD_ENTRY_USE_TIME = TO_CHAR(SYSDATE,'YYYYMMDDHH24MISS')" +
  78. " where OLD_SAMPL_NO = ?";
  79. this.getDao("KgDao").ExcuteNonQuery(sqlucomm,
  80. new Object[]{yardAddr,entryShift,entryGroup,reg_id,entryDtime,coilNo});
  81. //将钢卷信息加入垛位表
  82. // String sqluyard = "update c_tbk08_coil_yard set COIL_NO = ?, " +
  83. // "MOD_ID = ?, MOD_TIME = TO_CHAR(SYSDATE,'YYYYMMDDHH24MISS')" +
  84. // " where CLF_NO = C_PKG_UIM.GET_YARDNO_BYYARDFLAG(?)";
  85. // this.getDao("KgDao").ExcuteNonQuery(sqluyard,
  86. // new Object[]{coilNo,reg_id,yardAddr});
  87. //入库完成后将入库记录加入移垛记录,便于跟踪钢卷移动记录
  88. long seq = 0;//移垛记录表主键
  89. String sqlqmaxseq = "select max(ROLL_SEQ) ROLL_SEQ from c_tbk08_coil_move";
  90. PreparedStatement pSta = this.getDao("KgDao").getPreparedStatement(sqlqmaxseq);
  91. ResultSet rs = pSta.executeQuery();
  92. con=pSta.getConnection();
  93. if(rs.next()){
  94. seq = rs.getLong("ROLL_SEQ")+1;
  95. }
  96. rs.close();
  97. pSta.close();
  98. con.close();
  99. // 入库类型
  100. String inType = "";
  101. String sqlType = "select T.IN_YARD_KIND from C_TBC02_COIL_COMM T where T.OLD_SAMPL_NO = ?";
  102. pSta = this.getDao("KgDao").getPreparedStatement(
  103. sqlType);
  104. pSta.setString(1, coilNo);
  105. rs = pSta.executeQuery();
  106. con=pSta.getConnection();
  107. if (rs.next()) {
  108. inType = rs.getString("IN_YARD_KIND");
  109. }
  110. rs.close();
  111. pSta.close();
  112. con.close();
  113. 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)" +
  114. "VALUES(?,?,?,?,?,?,?,?,?,TO_CHAR(SYSDATE,'YYYYMMDDHH24MISS'),decode(?,'1','02','2','02','3','05','4','05','5','04','6','04','7','04'))";
  115. this.getDao("KgDao").ExcuteNonQuery(sqlimove, new Object[]{seq,"",yardAddr,coilNo,reg_id,entryShift,entryGroup,entryDtime,reg_id,inType});
  116. }
  117. }
  118. }
  119. else{
  120. cro.setV_errCode(new Integer(3));
  121. cro.setV_errMsg("垛位不存在!");
  122. }
  123. return cro;
  124. }
  125. //select coil_no from c_tbk08_coil_yard where clf_name || clf_row || clf_col || clf_fl = '?'
  126. }