1eb6ac22e2f81348ea3db050c8ecb08a9127ecb7.svn-base 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  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.ArrayList;
  7. import java.util.Iterator;
  8. import java.util.List;
  9. import java.util.Map;
  10. import UIB.COM.ProduceFactory;
  11. import UIB.COM.XmlSqlParsersFactory;
  12. import CoreFS.SA01.CoreIComponent;
  13. import CoreFS.SA06.CoreReturnObject;
  14. /**
  15. * 冷轧原料库出库管理
  16. *
  17. * @author siy
  18. * @date 2010-08-19
  19. */
  20. public class UIM010092 extends CoreIComponent {
  21. // /**
  22. // * 查询酸轧计划
  23. // *
  24. // * @param ordNo
  25. // * 合同号
  26. // * @param ordSeq
  27. // * 订单号
  28. // * @param coilNo
  29. // * 热轧卷号
  30. // * @return CoreReturnObject
  31. // * @throws SQLException
  32. // */
  33. // public CoreReturnObject queryMillPlan(String coilNo) throws SQLException
  34. // {
  35. // CoreReturnObject cro = new CoreReturnObject();
  36. //
  37. // StringBuffer sqlBuffer = new StringBuffer();
  38. //
  39. // sqlBuffer.append("SELECT \n");
  40. // sqlBuffer.append("a.ROLL_MANA_NO --轧制单元号\n");
  41. // sqlBuffer.append(",a.ROLL_COIL_SEQ --单元内序号\n");
  42. // sqlBuffer.append(",a.COIL_EDT_SEQ --轧制序号\n");
  43. // sqlBuffer.append(",a.C_COIL_NO --冷卷号 \n");
  44. // sqlBuffer.append(",a.COIL_NO --热卷号 \n");
  45. // sqlBuffer.append(",a.SPEC_STL_GRD --酸轧牌号 \n");
  46. // sqlBuffer.append(",a.STL_GRD --热轧牌号 \n");
  47. // sqlBuffer.append(",a.STL_GRP_CD --钢号组 \n");
  48. // sqlBuffer.append(",a.COIL_THK --热卷厚度 \n");
  49. // sqlBuffer.append(",a.COIL_WTH --热卷宽度 \n");
  50. // sqlBuffer.append(",a.COIL_WGT --热卷重量 \n");
  51. // sqlBuffer.append(",b.CUR_LOAD_LOC --堆放位置 \n");
  52. // sqlBuffer.append(",a.ORD_NO --合同号 \n");
  53. // sqlBuffer.append(",a.ORD_SEQ --订单号 \n");
  54. // sqlBuffer.append(",a.ORD_THK --订单厚度 \n");
  55. // sqlBuffer.append(",a.ORD_WTH --订单宽度 \n");
  56. // sqlBuffer.append(",a.ORD_WGT --订单重量 \n");
  57. // sqlBuffer.append(",a.ORD_WGT_MIN --订单下限 \n");
  58. // sqlBuffer.append(",a.ORD_WGT_MAX --订单上限 \n");
  59. // sqlBuffer.append(",a.ORD_INDIA --订单内径 \n");
  60. // sqlBuffer.append(",a.ORD_OUTDIA --订单外径 \n");
  61. // sqlBuffer.append("FROM c_tbf03_spec_mill a, \n");
  62. // sqlBuffer.append("c_tbk02_coil_comm b \n");
  63. // sqlBuffer.append("WHERE a.COIL_NO = b.COIL_NO \n");
  64. // sqlBuffer.append("and a.STATUS_CD = 'A' \n");
  65. // sqlBuffer.append("and b.COIL_NO like ?||'%' \n");
  66. // sqlBuffer.append("ORDER BY a.ROLL_MANA_NO,a.ROLL_COIL_SEQ \n");
  67. //
  68. // cro = this.getDao("KgDao").ExcuteQuery(sqlBuffer.toString(),
  69. // new Object[] { coilNo });
  70. //
  71. // return cro;
  72. // }
  73. /**
  74. * 查询退回出库卷信息
  75. *
  76. * @param coilNo
  77. * 热轧卷号
  78. * @return CoreReturnObject
  79. */
  80. public CoreReturnObject queryOutCoil(String ordNo, String ordSeq,
  81. String coilNo) throws SQLException {
  82. CoreReturnObject cro = new CoreReturnObject();
  83. String sql = XmlSqlParsersFactory.getSql("UIM010090_01.SELECT");
  84. cro = this.getDao("KgDao").ExcuteQuery(sql,
  85. new Object[] { ordNo, ordSeq, coilNo });
  86. return cro;
  87. }
  88. /**
  89. * 原料库出库
  90. *
  91. * @param coilNo
  92. * @param regID
  93. * @param trnfShift
  94. * @param trnfGroup
  95. * @param trnfDtime
  96. * @param trnfType
  97. * @return
  98. * @throws SQLException
  99. */
  100. public CoreReturnObject saveCoilOut(String coilNo, String regID,
  101. String trnfShift, String trnfGroup, String trnfDtime,
  102. Integer trnfType) throws SQLException {
  103. CoreReturnObject cro = new CoreReturnObject();
  104. boolean crs = false;
  105. if (trnfType.intValue() == 9) {// 退帐面
  106. crs = returnCoil(coilNo, regID, trnfShift,
  107. trnfGroup, trnfDtime);
  108. } else {// 退实物
  109. // 清除原料库垛位表钢卷信息并将原料公共表钢卷垛位信息置为出库
  110. crs = cleanCoil(coilNo, regID, trnfShift,
  111. trnfGroup, trnfDtime);
  112. //调用存货异动点存储过程 20220408退账面不发送退回信息
  113. //ProduceFactory PD= new ProduceFactory();
  114. //PD.ErpDataCover("HCOIL",coilNo,"55A","0","N",regID,"热轧转出退回");
  115. //PD.ErpDataCover("CORICOIL",coilNo,"55A","0","O",regID,"酸轧原料退库");
  116. returnch(coilNo);
  117. }
  118. return cro;
  119. }
  120. /**
  121. * 清空钢卷库存信息
  122. *
  123. * @param outType
  124. * 出库类型
  125. * @param coilNo
  126. * 钢卷号
  127. * @param regId
  128. * 出库人
  129. * @param trnfShift
  130. * 出库班次
  131. * @param trnfGroup
  132. * 出库班组
  133. * @param tranTime
  134. * 出库时间
  135. * @return boolean
  136. */
  137. private boolean cleanCoil(String coilNo, String regId,
  138. String trnfShift, String trnfGroup, String trnfTime)
  139. throws SQLException {
  140. Map result = this.getDao("KgDao").CoreBeginTranscation();
  141. try {
  142. // 根据钢卷号查询垛位编号
  143. String sql1 = "select clf_no from c_tbk08_coil_yard where coil_no = '"
  144. + coilNo + "'";
  145. ResultSet rs = this.getDao("KgDao").ExceuteQueryForResultSet(sql1);
  146. long yardNo = 0;
  147. // 如果钢卷在原料库中,查询出相应的垛位编号
  148. if (rs.next()) {
  149. yardNo = Long.parseLong(rs.getObject("clf_no").toString());
  150. } else {
  151. return false;
  152. }
  153. //20131014系统连接异常优化
  154. this.getDao("KgDao").closeRs(rs);
  155. // 根据垛位编号清除钢卷信息
  156. String sql2 = "update c_tbk08_coil_yard set coil_no = '' where clf_no = ?";
  157. this.getDao("KgDao").ExcuteNonQuery(sql2, new Object[] { yardNo });
  158. // 修改原料公共表钢卷操作信息
  159. String sql3 = XmlSqlParsersFactory.getSql("UIM010092_01.UPDATE");
  160. this.getDao("KgDao").ExcuteNonQuery(
  161. sql3,
  162. new Object[] { coilNo });
  163. // 修改原料表钢卷操作信息
  164. String sql4 = XmlSqlParsersFactory.getSql("UIM010092_02.UPDATE");
  165. this.getDao("KgDao").ExcuteNonQuery(sql4,
  166. new Object[] { trnfShift, trnfGroup, regId, trnfTime,
  167. coilNo });
  168. this.getDao("KgDao").CoreCommit(result);
  169. } catch (Exception ex) {
  170. this.getDao("KgDao").CoreRollBack(result);
  171. ex.printStackTrace();
  172. return false;
  173. }
  174. return true;
  175. }
  176. /**
  177. * 退帐面回热轧
  178. *
  179. * @param outType
  180. * @param coilNo
  181. * @param regId
  182. * @param trnfShift
  183. * @param trnfGroup
  184. * @param trnfTime
  185. * @return
  186. * @throws SQLException
  187. */
  188. private boolean returnCoil(String coilNo, String regId,
  189. String trnfShift, String trnfGroup, String trnfTime)
  190. throws SQLException {
  191. Map result = this.getDao("KgDao").CoreBeginTranscation();
  192. try {
  193. // 根据钢卷号查询垛位编号
  194. String sql1 = "select cur_load_loc from c_tbk02_coil_comm where coil_no = '"
  195. + coilNo + "'";
  196. ResultSet rs = this.getDao("KgDao").ExceuteQueryForResultSet(sql1);
  197. String curLoadLoc = "";
  198. // 查询垛位
  199. if (rs.next()) {
  200. curLoadLoc = rs.getObject("CUR_LOAD_LOC").toString();
  201. } else {
  202. return false;
  203. }
  204. //20131014系统连接异常优化
  205. this.getDao("KgDao").closeRs(rs);
  206. // 修改原料公共表钢卷操作信息
  207. String sql2 = XmlSqlParsersFactory.getSql("UIM010090_02.UPDATE");
  208. this.getDao("KgDao").ExcuteNonQuery(
  209. sql2,
  210. new Object[] { trnfShift, trnfGroup, regId, trnfTime,
  211. coilNo });
  212. // 修改原料_D表钢卷操作信息
  213. String sql4 = XmlSqlParsersFactory.getSql("UIM010090_04.UPDATE");
  214. this.getDao("KgDao").ExcuteNonQuery(sql4,
  215. new Object[] { coilNo });
  216. // 修改热轧公共表钢卷操作信息
  217. String sql3 = XmlSqlParsersFactory.getSql("UIM010090_03.UPDATE");
  218. this.getDao("KgDao").ExcuteNonQuery(sql3,
  219. new Object[] { curLoadLoc, coilNo });
  220. this.getDao("KgDao").CoreCommit(result);
  221. } catch (Exception ex) {
  222. this.getDao("KgDao").CoreRollBack(result);
  223. ex.printStackTrace();
  224. return false;
  225. }
  226. return true;
  227. }
  228. public CoreReturnObject deletereturn(String coilNo,String regId,
  229. String trnfShift, String trnfGroup, String trnfTime)
  230. throws SQLException {
  231. CoreReturnObject cro = new CoreReturnObject();
  232. Map result = this.getDao("KgDao").CoreBeginTranscation();
  233. try {
  234. String sql = " select * from TBH02_COIL_COMM A WHERE A.OLD_SAMPL_NO= '"
  235. + coilNo + "' AND A.ORD_FL='1' AND A.ORD_NO IS NOT NULL ";
  236. ResultSet rs = this.getDao("KgDao").ExceuteQueryForResultSet(sql);
  237. if (rs.next()) {
  238. this.getDao("KgDao").closeRs(rs);
  239. cro.setV_errCode(new Integer(-1));
  240. cro.setV_errMsg("钢卷已经在热轧进行了充当,无法撤销!");
  241. return cro;
  242. }
  243. else {
  244. this.getDao("KgDao").closeRs(rs);
  245. // 撤销退回的卷入冷轧库
  246. String sql1 = XmlSqlParsersFactory
  247. .getSql("UIM010090_05.UPDATE");
  248. this.getDao("KgDao").ExcuteNonQuery(sql1,
  249. new Object[] {trnfShift, trnfGroup,regId,trnfTime,coilNo});
  250. // 修改热轧库存数据为移送完成并且钢卷出库
  251. String sql2 = XmlSqlParsersFactory
  252. .getSql("UIM010090_06.UPDATE");
  253. this.getDao("KgDao").ExcuteNonQuery(sql2,
  254. new Object[] { coilNo });
  255. }
  256. this.getDao("KgDao").CoreCommit(result);
  257. } catch (SQLException ex) {
  258. this.getDao("KgDao").CoreRollBack(result);
  259. throw ex;
  260. }
  261. return cro;
  262. }
  263. public CoreReturnObject returnch(String coil_no)
  264. throws SQLException {
  265. CoreReturnObject cro = new CoreReturnObject();
  266. Connection conn = null;
  267. try {
  268. conn = this.getDao("KgDao").getConnection();
  269. conn.setAutoCommit(false);
  270. //发送优特钢
  271. String sql6 = "{call CK_RZ_COMM.RETURN_ZY(?)}";
  272. this.getDao("KgDao").ExcuteProcedure(sql6,new String[] {coil_no},
  273. new String[0]);
  274. conn.commit();
  275. } catch (SQLException ex) {
  276. throw ex;
  277. }
  278. finally {
  279. if (conn != null && !conn.isClosed()) {
  280. conn.close();
  281. }
  282. }
  283. return cro;
  284. }
  285. }