69adf98c4cd2ac85f0c469e6a4f9094cebda1bee.svn-base 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  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 wl
  15. * @date 2015-09-18
  16. */
  17. public class UIM010202 extends CoreIComponent {
  18. /**
  19. * 查询待入库钢卷
  20. * @param productTime 生产时间 yyyymmdd
  21. * @param coilNo 钢卷号
  22. * @return CoreReturnObject
  23. * @throws SQLException
  24. */
  25. public CoreReturnObject queryCoilsInTblStock(String coilNo) throws SQLException
  26. {
  27. String sql = XmlSqlParsersFactory.getSql("UIM010202_01.SELECT");
  28. return this.getDao("KgDao").ExcuteQuery(sql, new Object[]{coilNo});
  29. }
  30. public CoreReturnObject queryCoilsInTblbuffer() throws SQLException
  31. {
  32. String sql = XmlSqlParsersFactory.getSql("UIM010202_02.SELECT");
  33. return this.getDao("KgDao").ExcuteQuery(sql, new Object[]{});
  34. }
  35. /**
  36. * 成品库钢卷入库
  37. * @param coilNo 钢卷号
  38. * @param yardAddr 垛位
  39. * @param entryShift 入库班次
  40. * @param entryGroup 入库班组
  41. * @param entryDtime 入库时间
  42. * @param reg_id 操作人
  43. * @return CoreReturnObject
  44. * @throws SQLException
  45. */
  46. public CoreReturnObject saveCoilYard(String coilNo,String yardAddr,String entryShift,
  47. String entryGroup,String entryDtime,String reg_id) throws SQLException
  48. {
  49. CoreReturnObject cro = new CoreReturnObject();
  50. Connection con=null;
  51. String sqlYard;
  52. List yardList;
  53. if(!"2".equals(yardAddr.substring(0, 1))){
  54. //判断垛位是否存在
  55. sqlYard = "select 1 from c_tbk08_coil_yard t where t.clf_no = C_PKG_UIM.GET_FINALYARDNO_BYYARDFLAG(?)";
  56. yardList = this.getDao("KgDao").ExcuteQueryReturnList(sqlYard, new Object[]{yardAddr});
  57. }
  58. else
  59. {
  60. sqlYard= "select coil_no from c_tbk08_coil_yard "
  61. + "where CLF_NAME = substr(?,0,1) "
  62. + "and CLF_ROW = substr(?,3,2) "
  63. + "and CLF_COL = substr(?,7,3) "
  64. + "and CLF_FL = DECODE(substr(?,5,1),'A','1','B','2','C','3','1')"; //判断垛位是否存在
  65. yardList = this.getDao("KgDao").ExcuteQueryReturnList(sqlYard, new Object[]{yardAddr,yardAddr,yardAddr,yardAddr});
  66. }
  67. //List yardList = this.getDao("KgDao").ExcuteQueryReturnList(sqlYard, new Object[]{yardAddr});
  68. if(yardList.size() > 0){
  69. //查询钢卷入库信息
  70. String sqlEntry = "select COIL_NO from c_tbl02_coil_comm where OLD_SAMPL_NO = ? AND COIL_STAT = '3'";
  71. List listEntry = this.getDao("KgDao").ExcuteQueryReturnList(sqlEntry,new Object[]{coilNo});
  72. if(listEntry.size() == 0){
  73. cro.setV_errCode(new Integer(1));
  74. cro.setV_errMsg("此钢卷没有轧制完成,或者已经出库!");
  75. }
  76. else{
  77. //查询钢卷出库信息
  78. String sqlOut = "select CUR_LOAD_LOC from c_tbl02_coil_comm where OLD_SAMPL_NO = ?";
  79. List listOut = this.getDao("KgDao").ExcuteQueryReturnList(sqlOut, new Object[]{coilNo});
  80. if(listOut.size() > 0 && !Tools.isEmpty(((Map)(listOut.get(0))).get("CUR_LOAD_LOC"))){
  81. cro.setV_errCode(new Integer(2));
  82. cro.setV_errMsg("此钢卷已在垛位中存在!");
  83. }
  84. else{
  85. //将入库操作信息和垛位信息加入冷轧成品公共表
  86. if("2".equals(yardAddr.substring(0, 1))){
  87. if(yardList.size() > 0 && !Tools.isEmpty(((Map)(yardList.get(0))).get("coil_no"))){
  88. cro.setV_errCode(new Integer(2));
  89. cro.setV_errMsg("此垛位已存在钢卷!");
  90. }
  91. else{
  92. //将钢卷信息加入垛位表
  93. String sqluyard = "update c_tbk08_coil_yard set COIL_NO = ?, " +
  94. "MOD_ID = ?, MOD_TIME = TO_CHAR(SYSDATE,'YYYYMMDDHH24MISS')"
  95. + "where CLF_NAME = substr(?,0,1) "
  96. + "and CLF_ROW = substr(?,3,2) "
  97. + "and CLF_COL = substr(?,7,3) "
  98. + "and CLF_FL = DECODE(substr(?,5,1),'A','1','B','2','C','3','1')";
  99. this.getDao("KgDao").ExcuteNonQuery(sqluyard,
  100. new Object[]{coilNo,reg_id,yardAddr,yardAddr,yardAddr,yardAddr});
  101. String sqlucomm1 = "update c_tbl02_coil_comm set CUR_LOAD_LOC = ?," +
  102. " CUR_LOAD_LOC_DTIME = TO_CHAR(SYSDATE,'YYYYMMDDHH24MISS')," +
  103. " YARD_ENTRY_SHIFT = ?, YARD_ENTRY_GROUP = ?, YARD_ENTRY_REG = ?," +
  104. " YARD_ENTRY_DTIME = ?,COIL_STAT='2', " +
  105. " YARD_ENTRY_USE_TIME = TO_CHAR(SYSDATE,'YYYYMMDDHH24MISS')" +
  106. " where OLD_SAMPL_NO = ?";
  107. this.getDao("KgDao").ExcuteNonQuery(sqlucomm1,
  108. new Object[]{yardAddr,entryShift,entryGroup,reg_id,entryDtime,coilNo});
  109. }
  110. }
  111. else{
  112. String sqlucomm = "update c_tbl02_coil_comm set CUR_LOAD_LOC = ?," +
  113. " CUR_LOAD_LOC_DTIME = TO_CHAR(SYSDATE,'YYYYMMDDHH24MISS')," +
  114. " YARD_ENTRY_SHIFT = ?, YARD_ENTRY_GROUP = ?, YARD_ENTRY_REG = ?," +
  115. " YARD_ENTRY_DTIME = ?,COIL_STAT='2', " +
  116. " YARD_ENTRY_USE_TIME = TO_CHAR(SYSDATE,'YYYYMMDDHH24MISS')" +
  117. " where OLD_SAMPL_NO = ?";
  118. this.getDao("KgDao").ExcuteNonQuery(sqlucomm,
  119. new Object[]{yardAddr,entryShift,entryGroup,reg_id,entryDtime,coilNo});
  120. }
  121. //入库完成后将入库记录加入移垛记录,便于跟踪钢卷移动记录
  122. long seq = 0;//移垛记录表主键
  123. String sqlqmaxseq = "select max(ROLL_SEQ) ROLL_SEQ from c_tbk08_coil_move";
  124. PreparedStatement pSta = this.getDao("KgDao").getPreparedStatement(sqlqmaxseq);
  125. ResultSet rs = pSta.executeQuery();
  126. con=pSta.getConnection();
  127. if(rs.next()){
  128. seq = rs.getLong("ROLL_SEQ")+1;
  129. }
  130. rs.close();
  131. pSta.close();
  132. con.close();
  133. // 入库类型
  134. String inType = "";
  135. String sqlType = "select T.IN_YARD_KIND from C_TBL02_COIL_COMM T where T.OLD_SAMPL_NO = ?";
  136. pSta = this.getDao("KgDao").getPreparedStatement(
  137. sqlType);
  138. pSta.setString(1, coilNo);
  139. rs = pSta.executeQuery();
  140. con=pSta.getConnection();
  141. if (rs.next()) {
  142. inType = rs.getString("IN_YARD_KIND");
  143. }
  144. rs.close();
  145. pSta.close();
  146. con.close();
  147. 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)" +
  148. "VALUES(?,?,?,?,?,?,?,?,?,TO_CHAR(SYSDATE,'YYYYMMDDHH24MISS'),decode(?,'1','02','2','02','3','05','4','05','5','04','6','04','7','04'))";
  149. this.getDao("KgDao").ExcuteNonQuery(sqlimove, new Object[]{seq,"",yardAddr,coilNo,reg_id,entryShift,entryGroup,entryDtime,reg_id,inType});
  150. }
  151. }
  152. }
  153. else{
  154. cro.setV_errCode(new Integer(3));
  155. cro.setV_errMsg("垛位不存在!");
  156. }
  157. return cro;
  158. }
  159. public CoreReturnObject saveCoilHc(String coilNo,String outShift,
  160. String outGroup,String outDtime,String reg_id) throws SQLException
  161. {
  162. // 根据钢卷号查询垛位编号
  163. String sql1 = "select clf_no from c_tbk08_coil_yard where coil_no = '"
  164. + coilNo + "'";
  165. ResultSet rs = this.getDao("KgDao").ExceuteQueryForResultSet(sql1);
  166. long yardNo = 0;
  167. // 如果钢卷在原料库中,查询出相应的垛位编号
  168. if (rs.next()) {
  169. yardNo = Long.parseLong(rs.getObject("clf_no").toString());
  170. //20131014系统连接异常优化
  171. this.getDao("KgDao").closeRs(rs);
  172. // 根据垛位编号清除钢卷信息
  173. String sql2 = "update c_tbk08_coil_yard set coil_no = '' where clf_no = ?";
  174. this.getDao("KgDao").ExcuteNonQuery(sql2, new Object[] { yardNo });
  175. }
  176. CoreReturnObject cro = new CoreReturnObject();
  177. //判断垛位是否存在
  178. String updCommStr = XmlSqlParsersFactory
  179. .getSql("UIM010202_01.update");
  180. this.getDao("KgDao").ExcuteNonQuery(
  181. updCommStr,
  182. new Object[] { outShift, outGroup, outDtime,
  183. reg_id,coilNo });
  184. return cro;
  185. }
  186. //select coil_no from c_tbk08_coil_yard where clf_name || clf_row || clf_col || clf_fl = '?'
  187. }