9c252586d92f80dcc811ca45f8c7bda67dce3bdc.svn-base 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  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. /**
  12. * 冷轧中间库钢卷入库管理
  13. *
  14. * @author siy
  15. * @date 2010-08-10
  16. */
  17. public class UIM010120 extends CoreIComponent {
  18. /**
  19. * 查询钢卷在库信息
  20. *
  21. * @param clfName
  22. * @param clfRow
  23. * @param clfCol
  24. * @param clfFl
  25. * @return
  26. * @throws SQLException
  27. */
  28. public CoreReturnObject queryCoilStatus(String clfName, Integer clfRow,
  29. Integer clfCol, Integer clfFl) throws SQLException {
  30. CoreReturnObject cro = new CoreReturnObject();
  31. String sql = XmlSqlParsersFactory.getSql("UIM010120_01.SELECT");
  32. cro = this.getDao("KgDao").ExcuteQuery(sql,
  33. new Object[] { clfName, clfRow, clfCol, clfFl });
  34. return cro;
  35. }
  36. public CoreReturnObject queryCoilStatus2() throws SQLException {
  37. CoreReturnObject cro = new CoreReturnObject();
  38. String sql = XmlSqlParsersFactory.getSql("UIM010120_07.SELECT");
  39. cro = this.getDao("KgDao").ExcuteQuery(sql);
  40. return cro;
  41. }
  42. public CoreReturnObject queryCoilsInStock(String productTime,String toproductTime,String coilNo,String flag) throws SQLException
  43. {
  44. String sql = XmlSqlParsersFactory.getSql("UIM010120_11.SELECT");
  45. return this.getDao("KgDao").ExcuteQuery(sql, new Object[]{productTime,toproductTime,coilNo});
  46. }
  47. public CoreReturnObject saveCoilYardN(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. String sqlYard = "select CLF_NO from c_tbk08_coil_yard "
  56. + "where CLF_NAME = substr(?,0,1) "
  57. + "and CLF_ROW = substr(?,3,2) "
  58. + "and CLF_COL = substr(?,7,2) "
  59. + "and CLF_FL = DECODE(substr(?,5,1),'A','1','B','2','C','3','1')";
  60. List yardList = this.getDao("KgDao")
  61. .ExcuteQueryReturnList(
  62. sqlYard,
  63. new Object[] { yardAddr, yardAddr, yardAddr,
  64. yardAddr });
  65. if(yardList.size() > 0){
  66. String chkcoil = "select COIL_NO from c_tbk08_coil_yard "
  67. + "where CLF_NAME = substr(?,0,1) "
  68. + "and CLF_ROW = substr(?,3,2) "
  69. + "and CLF_COL = substr(?,7,2) "
  70. + "and CLF_FL = DECODE(substr(?,5,1),'A','1','B','2','C','3','1') AND COIL_NO IS NOT NULL";
  71. List coilList = this.getDao("KgDao")
  72. .ExcuteQueryReturnList(
  73. chkcoil,
  74. new Object[] { yardAddr, yardAddr, yardAddr,
  75. yardAddr });
  76. String chkcoil2 = "select COIL_NO from C_TBL02_COIL_COMM where CUR_LOAD_LOC = ?";
  77. List coilList2 = this.getDao("KgDao")
  78. .ExcuteQueryReturnList(
  79. chkcoil2,
  80. new Object[] { yardAddr });
  81. if(coilList.size() > 0||coilList2.size()>0)
  82. {
  83. cro.setV_errCode(new Integer(-1));
  84. cro.setV_errMsg("垛位被占用!");
  85. }
  86. else
  87. {
  88. //查询钢卷入库信息
  89. String sqlEntry = "select COIL_NO from c_tbL02_coil_comm where OLD_SAMPL_NO = ? AND COIL_STAT = '2'";
  90. List listEntry = this.getDao("KgDao").ExcuteQueryReturnList(sqlEntry,new Object[]{coilNo});
  91. if(listEntry.size() == 0){
  92. cro.setV_errCode(new Integer(1));
  93. cro.setV_errMsg("此钢卷没有轧制完成,或者已经出库!");
  94. }
  95. else{
  96. //查询钢卷出库信息
  97. String sqlOut = "select CUR_LOAD_LOC from c_tbL02_coil_comm where OLD_SAMPL_NO = ?";
  98. List listOut = this.getDao("KgDao").ExcuteQueryReturnList(sqlOut, new Object[]{coilNo});
  99. if(listOut.size() > 0 && !Tools.isEmpty(((Map)(listOut.get(0))).get("CUR_LOAD_LOC"))){
  100. cro.setV_errCode(new Integer(2));
  101. cro.setV_errMsg("此钢卷已在垛位中存在!");
  102. }
  103. else{
  104. //将入库操作信息和垛位信息加入冷轧成品公共表
  105. String sqlucomm = "update c_tbL02_coil_comm set CUR_LOAD_LOC = ?," +
  106. " CUR_LOAD_LOC_DTIME = TO_CHAR(SYSDATE,'YYYYMMDDHH24MISS')," +
  107. " YARD_ENTRY_SHIFT = ?, YARD_ENTRY_GROUP = ?, YARD_ENTRY_REG = ?," +
  108. " YARD_ENTRY_DTIME = ?, " +
  109. " YARD_ENTRY_USE_TIME = TO_CHAR(SYSDATE,'YYYYMMDDHH24MISS')" +
  110. " where OLD_SAMPL_NO = ?";
  111. this.getDao("KgDao").ExcuteNonQuery(sqlucomm,
  112. new Object[]{yardAddr,entryShift,entryGroup,reg_id,entryDtime,coilNo});
  113. //将钢卷信息加入垛位表
  114. // String sqluyard = "update c_tbk08_coil_yard set COIL_NO = ?, " +
  115. // "MOD_ID = ?, MOD_TIME = TO_CHAR(SYSDATE,'YYYYMMDDHH24MISS')" +
  116. // " where CLF_NO = C_PKG_UIM.GET_YARDNO_BYYARDFLAG(?)";
  117. // this.getDao("KgDao").ExcuteNonQuery(sqluyard,
  118. // new Object[]{coilNo,reg_id,yardAddr});
  119. //入库完成后将入库记录加入移垛记录,便于跟踪钢卷移动记录
  120. long seq = 0;//移垛记录表主键
  121. String sqlqmaxseq = "select max(ROLL_SEQ) ROLL_SEQ from c_tbk08_coil_move";
  122. PreparedStatement pSta = this.getDao("KgDao").getPreparedStatement(sqlqmaxseq);
  123. ResultSet rs = pSta.executeQuery();
  124. con=pSta.getConnection();
  125. if(rs.next()){
  126. seq = rs.getLong("ROLL_SEQ")+1;
  127. }
  128. rs.close();
  129. pSta.close();
  130. con.close();
  131. // 入库类型
  132. String inType = "";
  133. String sqlType = "select T.IN_YARD_KIND from C_TBL02_COIL_COMM T where T.OLD_SAMPL_NO = ?";
  134. pSta = this.getDao("KgDao").getPreparedStatement(
  135. sqlType);
  136. pSta.setString(1, coilNo);
  137. rs = pSta.executeQuery();
  138. con=pSta.getConnection();
  139. if (rs.next()) {
  140. inType = rs.getString("IN_YARD_KIND");
  141. }
  142. rs.close();
  143. pSta.close();
  144. con.close();
  145. 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)" +
  146. "VALUES(?,?,?,?,?,?,?,?,?,TO_CHAR(SYSDATE,'YYYYMMDDHH24MISS'),decode(?,'1','02','2','02','3','05','4','05','5','04','6','04','7','04'))";
  147. this.getDao("KgDao").ExcuteNonQuery(sqlimove, new Object[]{seq,"",yardAddr,coilNo,reg_id,entryShift,entryGroup,entryDtime,reg_id,inType});
  148. }
  149. }
  150. }
  151. }
  152. else{
  153. cro.setV_errCode(new Integer(3));
  154. cro.setV_errMsg("垛位不存在!");
  155. }
  156. return cro;
  157. }
  158. /**
  159. * 中间库钢卷入库
  160. *
  161. * @param coilNo
  162. * 钢卷号
  163. * @param yardAddr
  164. * 垛位
  165. * @param entryShift
  166. * 入库班次
  167. * @param entryGroup
  168. * 入库班组
  169. * @param entryDtime
  170. * 入库时间
  171. * @param reg_id
  172. * 操作人
  173. * @return CoreReturnObject
  174. * @throws SQLException
  175. */
  176. public CoreReturnObject saveCoilYard(String coilNo, String yardAddr,
  177. String entryShift, String entryGroup, String entryDtime,
  178. String reg_id) throws SQLException {
  179. CoreReturnObject cro = new CoreReturnObject();
  180. Connection con = null;
  181. // 查询钢卷入库信息
  182. String sqlEntry = XmlSqlParsersFactory.getSql("UIM010120_02.SELECT");
  183. List listEntry = this.getDao("KgDao").ExcuteQueryReturnList(sqlEntry,
  184. new Object[] { coilNo });
  185. if (listEntry.size() < 1) {
  186. cro.setV_errCode(new Integer(1));
  187. cro.setV_errMsg("此钢卷没有轧制完成,或者已经出库!");
  188. } else {
  189. // 查询钢卷出库信息
  190. String sqlOut = XmlSqlParsersFactory.getSql("UIM010120_03.SELECT");
  191. List listOut = this.getDao("KgDao").ExcuteQueryReturnList(sqlOut,
  192. new Object[] { coilNo });
  193. if (listOut.size() > 0) {
  194. cro.setV_errCode(new Integer(2));
  195. cro.setV_errMsg("此钢卷已在垛位中存在!");
  196. } else {
  197. // 查询垛位信息
  198. sqlOut = "select CLF_NO from c_tbk08_coil_yard "
  199. + "where CLF_NAME = substr(?,0,1) "
  200. + "and CLF_ROW = substr(?,3,2) "
  201. + "and CLF_COL = substr(?,7,2) "
  202. + "and CLF_FL = DECODE(substr(?,5,1),'A','1','B','2','C','3','1')";
  203. listOut = this.getDao("KgDao")
  204. .ExcuteQueryReturnList(
  205. sqlOut,
  206. new Object[] { yardAddr, yardAddr, yardAddr,
  207. yardAddr });
  208. if (listOut.size() == 0) {
  209. cro.setV_errCode(new Integer(3));
  210. cro.setV_errMsg("垛位不存在!");
  211. } else {
  212. Map result = this.getDao("KgDao").CoreBeginTranscation();
  213. ResultSet rs = null;
  214. PreparedStatement pSta = null;
  215. try {
  216. // 将入库操作信息和垛位信息加入酸轧公共表
  217. String sqlucomm = XmlSqlParsersFactory
  218. .getSql("UIM010120_01.UPDATE");
  219. this.getDao("KgDao")
  220. .ExcuteNonQuery(
  221. sqlucomm,
  222. new Object[] { yardAddr, entryShift,
  223. entryGroup, reg_id, entryDtime,
  224. coilNo });
  225. // 将钢卷信息加入垛位表
  226. String sqluyard = XmlSqlParsersFactory
  227. .getSql("UIM010120_02.UPDATE");
  228. this.getDao("KgDao").ExcuteNonQuery(
  229. sqluyard,
  230. new Object[] { coilNo, reg_id, yardAddr,
  231. yardAddr, yardAddr, yardAddr });
  232. // 入库完成后将入库记录加入移垛记录,便于跟踪钢卷移动记录
  233. long seq = 0;// 移垛记录表主键
  234. String sqlqmaxseq = XmlSqlParsersFactory
  235. .getSql("UIM010120_04.SELECT");
  236. pSta = this.getDao("KgDao")
  237. .getPreparedStatement(sqlqmaxseq);
  238. rs = pSta.executeQuery();
  239. con=pSta.getConnection();
  240. if (rs.next()) {
  241. seq = rs.getLong("ROLL_SEQ");
  242. }
  243. rs.close();
  244. pSta.close();
  245. con.close();
  246. // 入库类型
  247. String inType = "";
  248. String sqlType = "select T.IN_YARD_KIND from C_TBL02_COIL_COMM T where T.COIL_NO = ?";
  249. pSta = this.getDao("KgDao").getPreparedStatement(
  250. sqlType);
  251. pSta.setString(1, coilNo);
  252. rs = pSta.executeQuery();
  253. con=pSta.getConnection();
  254. if (rs.next()) {
  255. inType = rs.getString("IN_YARD_KIND");
  256. }
  257. rs.close();
  258. pSta.close();
  259. con.close();
  260. String sqlimove = XmlSqlParsersFactory
  261. .getSql("UIM010120_01.INSERT");
  262. this.getDao("KgDao").ExcuteNonQuery(
  263. sqlimove,
  264. new Object[] { seq + 1, "", yardAddr, coilNo,
  265. reg_id, entryShift, entryGroup,
  266. entryDtime, reg_id, inType });
  267. this.getDao("KgDao").CoreCommit(result);
  268. } catch (Exception ex) {
  269. this.getDao("KgDao").CoreRollBack(result);
  270. cro.setV_errCode(-1);
  271. cro.setV_errMsg(ex.getMessage());
  272. } finally {
  273. try{
  274. //添加了关闭rs/pSta
  275. if(rs != null){
  276. rs.close();
  277. }
  278. if(pSta != null){
  279. pSta.close();
  280. }
  281. if(con != null){
  282. con.close();
  283. }
  284. } catch (Exception e) {
  285. }
  286. }
  287. }
  288. }
  289. }
  290. return cro;
  291. }
  292. }