12af71dc06c5479ddba8d7f3094de4001ced9758.svn-base 4.3 KB

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