be2acebb3ab57f1edac1571ac85c28ea55837834.svn-base 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692
  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.text.DateFormat;
  7. import java.text.DecimalFormat;
  8. import java.text.SimpleDateFormat;
  9. import java.util.ArrayList;
  10. import java.util.Date;
  11. import java.util.HashMap;
  12. import java.util.Iterator;
  13. import java.util.List;
  14. import java.util.Map;
  15. import UIB.COM.XmlSqlParsersFactory;
  16. import UIM.UIM01.BEANS.ColdCoilComm;
  17. import CoreFS.SA01.CoreIComponent;
  18. import CoreFS.SA06.CoreReturnObject;
  19. public class UIM010260 extends CoreIComponent {
  20. public CoreReturnObject queryCoilInfo(String coilNo) throws SQLException {
  21. CoreReturnObject cro = new CoreReturnObject();
  22. StringBuffer sqlBuffer = new StringBuffer();
  23. sqlBuffer.append("SELECT A.OLD_SAMPL_NO COIL_NO, \n");
  24. sqlBuffer.append("A.SPEC_STL_GRD, \n");
  25. sqlBuffer
  26. .append("to_char(A.COIL_THK, 'FM990.099') || '*' || A.COIL_WTH T_W, \n");
  27. sqlBuffer
  28. .append("to_char(A.INSTR_COIL_THK, 'FM990.099') || '*' || A.INSTR_COIL_WTH IT_IW, \n");
  29. sqlBuffer.append("A.ORD_NO, \n");
  30. sqlBuffer.append("A.ORD_SEQ, \n");
  31. sqlBuffer.append("A.COIL_LEN, \n");
  32. sqlBuffer.append("A.ACT_WGT, \n");
  33. sqlBuffer.append("A.CAL_WGT, \n");
  34. sqlBuffer
  35. .append("DECODE(a.CUR_PROG_CD,'DDB','成品库入库待机','DRC','连退卷充当待机', 'DBA','重卷指示待机', 'DBB','重卷作业待机','DCA','包装指示待机','DCB','包装作业待机','DED','综合判定待机','DFA', '发货指示待机','DFB','运送待机(发货待机)','DFF','运送完成(发货完成)') \n");
  36. sqlBuffer.append(" CUR_PROG_CD, \n");
  37. sqlBuffer
  38. .append("DECODE(A.TOT_DEC_GRD,'1','合格','2','不合格','3','次品','4','废品','','待判定') \n");
  39. sqlBuffer.append(" TOT_DEC_GRD, \n");
  40. sqlBuffer
  41. .append("DECODE(A.ORD_FL, '1', '订单材', '2', '余材', '', '未判') \n");
  42. sqlBuffer.append(" ORD_FL, \n");
  43. sqlBuffer
  44. .append("/*DECODE(A.COIL_STAT,'1','未入库','2','在库','3','出库/结束',null)*/ (CASE \n");
  45. sqlBuffer.append("WHEN A.COIL_STAT='1' THEN '未入库'\n");
  46. sqlBuffer
  47. .append("WHEN A.COIL_STAT='2' AND A.CUR_LOAD_LOC IS NULL THEN '未入库'\n");
  48. sqlBuffer
  49. .append("WHEN A.COIL_STAT='2' AND A.CUR_LOAD_LOC IS NOT NULL THEN '在库'\n");
  50. sqlBuffer.append("WHEN A.COIL_STAT='3' THEN '出库/结束'\n");
  51. sqlBuffer.append(" END)\n");
  52. sqlBuffer.append(" COIL_STAT, \n");
  53. sqlBuffer.append("A.CUR_LOAD_LOC, \n");
  54. sqlBuffer
  55. .append("(SELECT USERNAME FROM CORE_APP_USER U WHERE U.USERID = A.COIL_IN_REG) \n");
  56. sqlBuffer.append(" COIL_IN_REG, \n");
  57. sqlBuffer
  58. .append("C_PKG_UIM.GET_STDTIMESTR(A.COIL_IN_DTIME) COIL_IN_DTIME, \n");
  59. sqlBuffer
  60. .append("(SELECT USERNAME FROM CORE_APP_USER U WHERE U.USERID = A.COIL_OUT_REG) \n");
  61. sqlBuffer.append(" COIL_OUT_REG, \n");
  62. sqlBuffer
  63. .append("C_PKG_UIM.GET_STDTIMESTR(A.COIL_OUT_DTIME) COIL_OUT_DTIME \n");
  64. sqlBuffer.append("FROM C_TBC02_COIL_COMM A \n");
  65. sqlBuffer.append("WHERE A.OLD_SAMPL_NO = ? \n");
  66. cro = this.getDao("KgDao").ExcuteQuery(sqlBuffer.toString(),
  67. new Object[] { coilNo });
  68. return cro;
  69. }
  70. /**
  71. * 盘入盘出操作
  72. *
  73. * @param type
  74. * 盘入/盘出 0/1
  75. * @param coilNo
  76. * 钢卷号
  77. * @param curLoadLoc
  78. * 垛位
  79. * @param regId
  80. * 盘入人
  81. * @param coilInDtime
  82. * 盘入时间
  83. * @return
  84. * @throws SQLException
  85. */
  86. public CoreReturnObject save(Integer type, String coilNo,
  87. String curLoadLoc, String regId, String regShift, String regGroup,
  88. String coilInDtime,String wdlivno) throws Exception {
  89. CoreReturnObject cro = new CoreReturnObject();
  90. Connection conn = null;
  91. PreparedStatement pSta = null;
  92. StringBuffer updCommBuffer = null;
  93. try {
  94. conn = this.getDao("KgDao").getConnection();
  95. conn.setAutoCommit(false);
  96. // 20140403
  97. if (coilNo == "" || coilNo == null) {
  98. throw new Exception("钢卷号为空!");
  99. } else if (regId == "" || regId == null) {
  100. throw new Exception("操作人编号为空!");
  101. } else if (coilInDtime == "" || coilInDtime == null) {
  102. throw new Exception("操作时间为空!");
  103. }
  104. // 查询是是否有这一钢卷的数据
  105. String[] coldCoil = null;
  106. coldCoil = coilInfo(coilNo);
  107. if (coldCoil == null || coldCoil[0] == "") {
  108. throw new Exception("系统查无此卷!");
  109. }
  110. String coilInDtimeS = coilInDtime.substring(0, 8);
  111. // 盘入
  112. if (type == 0) {
  113. if (curLoadLoc == null || curLoadLoc.equals("")) {
  114. throw new Exception("垛位为空!");
  115. }
  116. // 状态为2的钢卷不能盘入
  117. if (coldCoil[1].equals("2")) {
  118. throw new Exception("钢卷为在库状态,如无堆放位置请从入库界面录入!");
  119. }
  120. // 是否是正常出库
  121. if (coldCoil[1].equals("3") && coldCoil[3].equals("DFF")) {
  122. throw new Exception("这一钢卷属于正常出库,不能进行盘入操作!");
  123. }
  124. if (!coldCoil[6].equals("") && !coldCoil[6].equals("C")) {
  125. throw new Exception("这一钢卷已经在库中了!");
  126. }
  127. String opType = "5";// 盘库类型
  128. if (curLoadLoc != null && !curLoadLoc.equals("")) {
  129. if (curLoadLoc.startsWith("4")) {
  130. opType = "6";
  131. } else if (curLoadLoc.startsWith("5")) {
  132. opType = "7";
  133. }
  134. }
  135. // 人工盘入库的卷改为余材 ,修改C_TBC02_COIL_COMM信息
  136. updCommBuffer = new StringBuffer();
  137. updCommBuffer.append("UPDATE C_TBC02_COIL_COMM A \n");
  138. updCommBuffer.append(" SET A.CUR_LOAD_LOC = ?,\n");
  139. updCommBuffer.append(" A.COIL_IN_REG = ?,\n");
  140. updCommBuffer.append(" A.CUR_PROG_CD = 'DRC',\n");
  141. updCommBuffer
  142. .append(" A.COIL_STAT = '2', A.ORD_FL= '2',A.ORD_NO = '', A.ORD_SEQ = '',\n");
  143. updCommBuffer.append("A.COIL_IN_DTIME = ?, \n");
  144. updCommBuffer.append("A.YARD_ENTRY_DTIME = ?, \n");
  145. updCommBuffer.append("A.IN_YARD_KIND = '" + opType + "', \n");
  146. updCommBuffer.append("A.YARD_ENTRY_REG= ?, \n");
  147. updCommBuffer.append("A.YARD_ENTRY_SHIFT = ? ,\n");
  148. updCommBuffer.append("A.YARD_ENTRY_GROUP = ?, \n");
  149. updCommBuffer
  150. .append("A.YARD_ENTRY_USE_TIME =TO_CHAR(SYSDATE,'YYYYMMDDHH24MISS') \n");
  151. updCommBuffer.append("WHERE A.OLD_SAMPL_NO = ? \n");
  152. pSta = conn.prepareStatement(updCommBuffer.toString());
  153. pSta.setString(1, curLoadLoc);
  154. pSta.setString(2, regId);
  155. pSta.setString(3, coilInDtime);
  156. pSta.setString(4, coilInDtimeS);
  157. pSta.setString(5, regId);
  158. pSta.setString(6, regShift);
  159. pSta.setString(7, regGroup);
  160. pSta.setString(8, coilNo);
  161. pSta.executeUpdate();
  162. pSta.close();
  163. // 人工盘入库的卷改为余材 ,修改C_TBC02_COIL_COMM_D信息
  164. updCommBuffer = new StringBuffer();
  165. updCommBuffer.append("UPDATE C_TBC02_COIL_COMM_D A \n");
  166. updCommBuffer.append(" SET A.ORD_FL= '2',\n");
  167. updCommBuffer.append(" A.ORD_NO = '',\n");
  168. updCommBuffer.append(" A.ORD_SEQ = ''\n");
  169. updCommBuffer.append("WHERE A.L_COIL_NO= ? \n");
  170. pSta = conn.prepareStatement(updCommBuffer.toString());
  171. pSta.setString(1, coilNo);
  172. pSta.executeUpdate();
  173. pSta.close();
  174. // 修改垛位表信息C_TBK08_COIL_YARD
  175. // 移垛表增加记录
  176. updCommBuffer = new StringBuffer();
  177. updCommBuffer.append("INSERT INTO C_TBK08_COIL_MOVE \n");
  178. updCommBuffer
  179. .append("(ROLL_SEQ,CUR_LOAD_LOC_F,CUR_LOAD_LOC_T,COIL_NO,REG_USE_ID,REG_ID,REG_SHIFT,REG_GROUP,REG_DTIME,REG_USE_DTIME,MOVE_TYPE) \n");
  180. updCommBuffer.append("VALUES \n");
  181. updCommBuffer.append("( \n");
  182. updCommBuffer
  183. .append("(SELECT MAX(ROLL_SEQ)+1 ROLL_SEQ FROM C_TBK08_COIL_MOVE) \n");
  184. updCommBuffer.append(",?,?,?,?,?,?,?,?,?,'04' \n");
  185. updCommBuffer.append(")");
  186. pSta = conn.prepareStatement(updCommBuffer.toString());
  187. pSta.setString(1, "");
  188. pSta.setString(2, curLoadLoc);
  189. pSta.setString(3, coilNo);
  190. pSta.setString(4, regId);
  191. pSta.setString(5, regId);
  192. pSta.setString(6, regShift);
  193. pSta.setString(7, regGroup);
  194. pSta.setString(8, coilInDtime);
  195. pSta.setString(9, coilInDtime);
  196. pSta.executeUpdate();
  197. pSta.close();
  198. } else if(type == 1){
  199. // 是否是余材
  200. if (!coldCoil[1].equals("2")) {
  201. throw new Exception("此钢卷还未入库.");
  202. } else if (coldCoil[7].equals("DBB")
  203. || coldCoil[7].equals("DFB")) {
  204. throw new Exception("已下发重卷计划或发运计划的钢卷不能进行盘出操作!");
  205. }
  206. // 人工盘出库的卷信息修正
  207. updCommBuffer = new StringBuffer();
  208. updCommBuffer.append("UPDATE C_TBC02_COIL_COMM A \n");
  209. updCommBuffer
  210. .append("SET A.OUT_YARD_KIND = decode(substr(A.CUR_LOAD_LOC,1,1),'4','6','5','7','5'), \n");
  211. updCommBuffer.append(" A.CUR_LOAD_LOC = '',\n");
  212. updCommBuffer.append(" A.COIL_OUT_REG = ?,\n");
  213. updCommBuffer.append(" A.CUR_PROG_CD = 'DRC',\n");
  214. updCommBuffer
  215. .append(" A.COIL_STAT = '3', A.ORD_FL= '2',A.ORD_NO = '', A.ORD_SEQ = '',\n");
  216. updCommBuffer.append("A.COIL_OUT_DTIME = ?, \n");
  217. updCommBuffer.append("A.TRNF_DTIME = ?, \n");
  218. updCommBuffer.append("A.TRNF_REG = ?, \n");
  219. updCommBuffer.append("A.TRNF_SHIFT = ?, \n");
  220. updCommBuffer.append("A.TRNF_GROUP = ?, \n");
  221. updCommBuffer
  222. .append("A.TRNF_USE_TIME = TO_CHAR(SYSDATE,'YYYYMMDDHH24MISS') \n");
  223. updCommBuffer.append("WHERE A.OLD_SAMPL_NO = ? \n");
  224. pSta = conn.prepareStatement(updCommBuffer.toString());
  225. pSta.setString(1, regId);
  226. pSta.setString(2, coilInDtime);
  227. pSta.setString(3, coilInDtimeS);
  228. pSta.setString(4, regId);
  229. pSta.setString(5, regShift);
  230. pSta.setString(6, regGroup);
  231. pSta.setString(7, coilNo);
  232. pSta.executeUpdate();
  233. pSta.close();
  234. // 人工盘入库的卷改为余材 ,修改C_TBC02_COIL_COMM_D信息
  235. updCommBuffer = new StringBuffer();
  236. updCommBuffer.append("UPDATE C_TBC02_COIL_COMM_D A \n");
  237. updCommBuffer.append(" SET A.ORD_FL= '2',\n");
  238. updCommBuffer.append(" A.ORD_NO = '',\n");
  239. updCommBuffer.append(" A.ORD_SEQ = ''\n");
  240. updCommBuffer.append("WHERE A.L_COIL_NO= ? \n");
  241. pSta = conn.prepareStatement(updCommBuffer.toString());
  242. pSta.setString(1, coilNo);
  243. pSta.executeUpdate();
  244. pSta.close();
  245. // 移垛表增加记录
  246. updCommBuffer = new StringBuffer();
  247. updCommBuffer.append("INSERT INTO C_TBK08_COIL_MOVE \n");
  248. updCommBuffer.append("( \n");
  249. updCommBuffer
  250. .append("ROLL_SEQ,CUR_LOAD_LOC_F,CUR_LOAD_LOC_T,COIL_NO,REG_USE_ID,REG_ID,REG_SHIFT,REG_GROUP,REG_DTIME,REG_USE_DTIME,MOVE_TYPE) \n");
  251. updCommBuffer.append("VALUES \n");
  252. updCommBuffer.append("( \n");
  253. updCommBuffer.append("(SELECT MAX(ROLL_SEQ)+1 ROLL_SEQ FROM C_TBK08_COIL_MOVE), \n");
  254. updCommBuffer.append("?,?,?,?,?,?,?,?,?,'15' \n");
  255. updCommBuffer.append(") \n");
  256. pSta = conn.prepareStatement(updCommBuffer.toString());
  257. pSta.setString(1,coldCoil[6]);
  258. pSta.setString(2,"");
  259. pSta.setString(3,coilNo);
  260. pSta.setString(4,regId);
  261. pSta.setString(5,regId);
  262. pSta.setString(6,regShift);
  263. pSta.setString(7,regGroup);
  264. pSta.setString(8,coilInDtime);
  265. pSta.setString(9,coilInDtime);
  266. pSta.executeUpdate();
  267. pSta.close();
  268. }
  269. else{//废钢外卖
  270. DateFormat formatter = new SimpleDateFormat("yyyyMMdd");
  271. String currDate = formatter.format(new Date());
  272. String seqno="FG"+currDate;
  273. String dlivnoNEXT;
  274. dlivnoNEXT=dlivno(seqno);//生成废钢编号
  275. // 是否是余材
  276. if (!coldCoil[1].equals("2")) {
  277. throw new Exception("此钢卷还未入库.");
  278. } else if (coldCoil[7].equals("DBB")
  279. || coldCoil[7].equals("DFB")) {
  280. throw new Exception("已下发重卷计划或发运计划的钢卷不能进行盘出操作!");
  281. }
  282. // 人工盘出库的卷信息修正
  283. updCommBuffer = new StringBuffer();
  284. updCommBuffer.append("UPDATE C_TBC02_COIL_COMM A \n");
  285. updCommBuffer
  286. .append("SET A.OUT_YARD_KIND = '8', \n");//出库类型废钢外卖
  287. updCommBuffer.append(" A.CUR_LOAD_LOC = '',\n");
  288. updCommBuffer.append(" A.COIL_OUT_REG = ?,\n");
  289. updCommBuffer.append(" A.CUR_PROG_CD = 'DRC',\n");
  290. updCommBuffer
  291. .append(" A.COIL_STAT = '3', A.ORD_FL= '2',A.ORD_NO = '', A.ORD_SEQ = '',\n");
  292. updCommBuffer.append("A.COIL_OUT_DTIME = ?, \n");
  293. updCommBuffer.append("A.TRNF_DTIME = ?, \n");
  294. updCommBuffer.append("A.TRNF_REG = ?, \n");
  295. updCommBuffer.append("A.TRNF_SHIFT = ?, \n");
  296. updCommBuffer.append("A.TRNF_GROUP = ?, \n");
  297. updCommBuffer.append("A.wdlivno = ?, \n");
  298. updCommBuffer
  299. .append("A.TRNF_USE_TIME = TO_CHAR(SYSDATE,'YYYYMMDDHH24MISS') \n");
  300. updCommBuffer.append("WHERE A.OLD_SAMPL_NO = ? \n");
  301. pSta = conn.prepareStatement(updCommBuffer.toString());
  302. pSta.setString(1, regId);
  303. pSta.setString(2, coilInDtime);
  304. pSta.setString(3, coilInDtimeS);
  305. pSta.setString(4, regId);
  306. pSta.setString(5, regShift);
  307. pSta.setString(6, regGroup);
  308. pSta.setString(7, dlivnoNEXT);
  309. pSta.setString(8, coilNo);
  310. pSta.executeUpdate();
  311. pSta.close();
  312. // 人工盘入库的卷改为余材 ,修改C_TBC02_COIL_COMM_D信息
  313. updCommBuffer = new StringBuffer();
  314. updCommBuffer.append("UPDATE C_TBC02_COIL_COMM_D A \n");
  315. updCommBuffer.append(" SET A.ORD_FL= '2',\n");
  316. updCommBuffer.append(" A.ORD_NO = '',\n");
  317. updCommBuffer.append(" A.ORD_SEQ = ''\n");
  318. updCommBuffer.append("WHERE A.L_COIL_NO= ? \n");
  319. pSta = conn.prepareStatement(updCommBuffer.toString());
  320. pSta.setString(1, coilNo);
  321. pSta.executeUpdate();
  322. pSta.close();
  323. // 移垛表增加记录
  324. updCommBuffer = new StringBuffer();
  325. updCommBuffer.append("INSERT INTO C_TBK08_COIL_MOVE \n");
  326. updCommBuffer.append("( \n");
  327. updCommBuffer
  328. .append("ROLL_SEQ,CUR_LOAD_LOC_F,CUR_LOAD_LOC_T,COIL_NO,REG_USE_ID,REG_ID,REG_SHIFT,REG_GROUP,REG_DTIME,REG_USE_DTIME,MOVE_TYPE) \n");
  329. updCommBuffer.append("VALUES \n");
  330. updCommBuffer.append("( \n");
  331. updCommBuffer.append("(SELECT MAX(ROLL_SEQ)+1 ROLL_SEQ FROM C_TBK08_COIL_MOVE), \n");
  332. updCommBuffer.append("?,?,?,?,?,?,?,?,?,'15' \n");
  333. updCommBuffer.append(") \n");
  334. pSta = conn.prepareStatement(updCommBuffer.toString());
  335. pSta.setString(1,coldCoil[6]);
  336. pSta.setString(2,"");
  337. pSta.setString(3,coilNo);
  338. pSta.setString(4,regId);
  339. pSta.setString(5,regId);
  340. pSta.setString(6,regShift);
  341. pSta.setString(7,regGroup);
  342. pSta.setString(8,coilInDtime);
  343. pSta.setString(9,coilInDtime);
  344. pSta.executeUpdate();
  345. pSta.close();
  346. }
  347. conn.commit();
  348. } catch (SQLException ex) {
  349. if (conn != null) {
  350. conn.rollback();
  351. }
  352. cro.setV_errCode(-1);
  353. cro.setV_errMsg("请检查钢卷信息后重新操作!");
  354. } finally {
  355. try{
  356. //添加了若出现异常情况关闭pStas
  357. if (pSta != null) {
  358. pSta.close();
  359. }
  360. if (conn != null && !conn.isClosed()) {
  361. conn.close();
  362. }
  363. } catch (Exception e) {
  364. }
  365. }
  366. return cro;
  367. }
  368. /**
  369. * 钢卷信息查询 FLZ-11-8-30
  370. *
  371. * @param coilNo
  372. * 卷号
  373. * @return null-查不到. 0 COIL_NO/ 1 COIL_STAT /2 SLAB_NO /3 CUR_PROG_CD /4
  374. * TRNF_DTIME /5 A.ORD_FL /6 A.CUR_LOAD_LOC/7 CUR_PROG_CD
  375. */
  376. private String[] coilInfo(String coilNo) throws Exception {
  377. String[] STRreturn = null;
  378. StringBuffer sqlBuffer = new StringBuffer();
  379. sqlBuffer.append("SELECT A.OLD_SAMPL_NO COIL_NO, A.COIL_STAT,\n");
  380. sqlBuffer.append("A.SLAB_NO,a.CUR_PROG_CD, a.TRNF_DTIME,\n");
  381. sqlBuffer.append("A.ORD_FL,A.CUR_LOAD_LOC,A.CUR_PROG_CD \n");
  382. sqlBuffer.append("FROM C_TBC02_COIL_COMM A\n");
  383. sqlBuffer.append("WHERE A.OLD_SAMPL_NO = ?\n");
  384. List list = this.getDao("KgDao").ExcuteQueryReturnList(
  385. sqlBuffer.toString(), new Object[] { coilNo });
  386. if (list.size() > 0) {
  387. Map map = (Map) list.get(0);
  388. STRreturn = new String[] {
  389. map.get("COIL_NO") == null ? "" : map.get("COIL_NO")
  390. .toString(), // 0
  391. map.get("COIL_STAT") == null ? "" : map.get("COIL_STAT")
  392. .toString(),// 1
  393. map.get("SLAB_NO") == null ? "" : map.get("SLAB_NO")
  394. .toString(),// 2
  395. map.get("CUR_PROG_CD") == null ? "" : map
  396. .get("CUR_PROG_CD").toString(),// 3
  397. map.get("TRNF_DTIME") == null ? "" : map.get("TRNF_DTIME")
  398. .toString(),// 4
  399. map.get("ORD_FL") == null ? "" : map.get("ORD_FL")
  400. .toString(),// 5
  401. map.get("CUR_LOAD_LOC") == null ? "" : map.get(
  402. "CUR_LOAD_LOC").toString(),// 6
  403. map.get("CUR_PROG_CD") == null ? "" : map
  404. .get("CUR_PROG_CD").toString() // 7
  405. };
  406. }
  407. return STRreturn;
  408. }
  409. /**
  410. * 查找钢卷号是否存在
  411. *
  412. * @param coilNo
  413. * @param type
  414. * 0盘入 1盘出
  415. * @return
  416. */
  417. private ColdCoilComm findCoil(String coilNo, int type) {
  418. PreparedStatement prepStat = null;
  419. ColdCoilComm coldCoil = null;
  420. ResultSet rs = null;
  421. Connection conn = null;
  422. try {
  423. StringBuffer sqlBuffer = new StringBuffer();
  424. sqlBuffer.append("SELECT A.OLD_SAMPL_NO COIL_NO, A.COIL_STAT,\n");
  425. sqlBuffer.append("A.SLAB_NO,a.CUR_PROG_CD, a.TRNF_DTIME\n");
  426. sqlBuffer.append("FROM C_TBC02_COIL_COMM A\n");
  427. sqlBuffer.append("WHERE A.OLD_SAMPL_NO = ?\n");
  428. if (type == 0) {
  429. sqlBuffer.append("AND A.CUR_LOAD_LOC IS NULL\n");
  430. } else {
  431. sqlBuffer.append("AND A.COIL_STAT = '2'\n");
  432. }
  433. prepStat = this.getDao("KgDao").getPreparedStatement(
  434. sqlBuffer.toString());
  435. prepStat.setString(1, coilNo);
  436. conn = prepStat.getConnection();
  437. rs = prepStat.executeQuery();
  438. if (rs.next()) {
  439. coldCoil = new ColdCoilComm();
  440. coldCoil.setCoilNo(rs.getString("COIL_NO"));
  441. coldCoil.setCoilStat(rs.getString("COIL_STAT"));
  442. coldCoil.setCurProgCd(rs.getString("CUR_PROG_CD"));
  443. coldCoil.setSlabNo(rs.getString("SLAB_NO"));
  444. coldCoil.setTrnfDTime(rs.getString("TRNF_DTIME"));
  445. }
  446. } catch (SQLException sqle) {
  447. } finally {
  448. try {
  449. if (null != rs) {
  450. rs.close();
  451. }
  452. if (null != prepStat) {
  453. prepStat.close();
  454. }
  455. if (null != conn) {
  456. conn.close();
  457. }
  458. } catch (Exception e) {
  459. }
  460. }
  461. return coldCoil;
  462. // PreparedStatement prepStat = null;
  463. // ColdCoilComm coldCoil = null;
  464. // ResultSet rs = null;
  465. //
  466. // try {
  467. // StringBuffer sqlBuffer = new StringBuffer();
  468. // sqlBuffer.append("SELECT A.COIL_NO,A.COIL_STAT,\n");
  469. // sqlBuffer.append(" A.SLAB_NO,a.CUR_PROG_CD,\n");
  470. // sqlBuffer.append(" a.TRNF_DTIME FROM C_TBC02_COIL_COMM A \n");
  471. // sqlBuffer.append(" WHERE COIL_NO = ? \n");
  472. // String tmp = 0 == type ? "<>" : "=";
  473. // sqlBuffer.append(" AND A.COIL_STAT " + tmp + " '2'\n");
  474. //
  475. // prepStat = this.getDao("KgDao").getPreparedStatement(
  476. // sqlBuffer.toString());
  477. // prepStat.setString(1, coilNo);
  478. //
  479. // rs = prepStat.executeQuery();
  480. // if (rs.next()) {
  481. // coldCoil = new ColdCoilComm();
  482. // coldCoil.setCoilNo(rs.getString("COIL_NO"));
  483. // coldCoil.setCoilStat(rs.getString("COIL_STAT"));
  484. // coldCoil.setCurProgCd(rs.getString("CUR_PROG_CD"));
  485. // coldCoil.setSlabNo(rs.getString("SLAB_NO"));
  486. // coldCoil.setTrnfDTime(rs.getString("TRNF_DTIME"));
  487. // }
  488. // }
  489. // catch (SQLException sqle) {
  490. // }
  491. // finally {
  492. // try {
  493. // if (null != rs) {
  494. // rs.close();
  495. // }
  496. // if (null != prepStat) {
  497. // prepStat.close();
  498. // }
  499. // } catch (Exception e) {
  500. //
  501. // }
  502. // }
  503. //
  504. // return coldCoil;
  505. }
  506. /**
  507. * 判断原料库垛位上是否存在有钢卷
  508. *
  509. * @param curLoadLoc
  510. * 堆放位置
  511. * @return String
  512. */
  513. private String hasCoilOnYard(String curLoadLoc) {
  514. String coilNo = "";
  515. StringBuffer sqlBuffer = new StringBuffer();
  516. sqlBuffer
  517. .append("SELECT A.COIL_NO FROM C_TBK08_COIL_YARD A, C_TBK08_COIL_YARD_AREA B\n");
  518. sqlBuffer.append(" WHERE A.AREA_NO = B.AREA_NO\n");
  519. sqlBuffer.append(" AND B.AREA_TYPE = '3'\n");
  520. sqlBuffer
  521. .append("AND a.CLF_NO = c_Pkg_Uim.GET_FINALYARDNO_BYYARDFLAG(?)\n");
  522. PreparedStatement prep = null;
  523. ResultSet rs = null;
  524. Connection con=null;
  525. try {
  526. prep = this.getDao("KgDao").getPreparedStatement(
  527. sqlBuffer.toString());
  528. prep.setString(1, curLoadLoc);
  529. rs = prep.executeQuery();
  530. con=prep.getConnection();
  531. if (rs.next()) {
  532. coilNo = rs.getString("COIL_NO");
  533. }
  534. } catch (SQLException sqle) {
  535. } finally {
  536. try {
  537. if (null != rs) {
  538. rs.close();
  539. }
  540. if (null != prep) {
  541. prep.close();
  542. }
  543. if(null!=con){
  544. con.close();
  545. }
  546. } catch (Exception e) {
  547. }
  548. }
  549. return coilNo;
  550. }
  551. private String dlivno(String syddate) {
  552. String dlivno = "";
  553. StringBuffer sqlBuffer = new StringBuffer();
  554. sqlBuffer
  555. .append("SELECT MAX(A.WDLIVNO) WDLIVNO FROM C_TBC02_COIL_COMM A WHERE\n");
  556. sqlBuffer.append(" A.WDLIVNO LIKE ?||'%'");
  557. PreparedStatement prep = null;
  558. ResultSet rs = null;
  559. Connection con=null;
  560. try {
  561. prep = this.getDao("KgDao").getPreparedStatement(
  562. sqlBuffer.toString());
  563. prep.setString(1, syddate);
  564. rs = prep.executeQuery();
  565. con =prep.getConnection();
  566. String temp="";
  567. if(rs.next()){
  568. if("".equals(rs.getString("WDLIVNO"))||rs.getString("WDLIVNO")==null)
  569. {
  570. dlivno=syddate+"01";
  571. }else{
  572. temp = rs.getString("WDLIVNO").substring(10);
  573. int aa=Integer.parseInt(temp) + 1;
  574. temp = new DecimalFormat("00").format(aa);
  575. dlivno = syddate+temp;
  576. }
  577. }
  578. else{
  579. dlivno=syddate+"01";
  580. }
  581. } catch (SQLException sqle) {
  582. } finally {
  583. try {
  584. if (null != rs) {
  585. rs.close();
  586. }
  587. if (null != prep) {
  588. prep.close();
  589. }
  590. if(null!=con){
  591. con.close();
  592. }
  593. } catch (Exception e) {
  594. }
  595. }
  596. return dlivno;
  597. }
  598. /**
  599. * 判断对象是否为空
  600. *
  601. * @param obj
  602. * @return boolean
  603. */
  604. private boolean isNull(Object obj) {
  605. boolean isNull = true;
  606. if (null != obj && !"".equals(obj)) {
  607. isNull = false;
  608. }
  609. return isNull;
  610. }
  611. /**
  612. * 查询垛位是否存在
  613. *
  614. * @param curLoadLoc
  615. * @return
  616. */
  617. private boolean hasYard(String curLoadLoc) {
  618. boolean b = false;
  619. StringBuffer sqlBuffer = new StringBuffer();
  620. sqlBuffer
  621. .append("SELECT A.CLF_NO FROM C_TBK08_COIL_YARD A, C_TBK08_COIL_YARD_AREA B\n");
  622. sqlBuffer.append("WHERE A.AREA_NO = B.AREA_NO\n");
  623. sqlBuffer.append(" AND B.AREA_TYPE = '3'\n");
  624. sqlBuffer
  625. .append("AND A.CLF_NO = c_Pkg_Uim.GET_FINALYARDNO_BYYARDFLAG(?) \n");
  626. PreparedStatement prep = null;
  627. ResultSet rs = null;
  628. Connection con =null;
  629. try {
  630. prep = this.getDao("KgDao").getPreparedStatement(
  631. sqlBuffer.toString());
  632. prep.setString(1, curLoadLoc);
  633. rs = prep.executeQuery();
  634. con=prep.getConnection();
  635. if (rs.next()) {
  636. b = true;
  637. }
  638. } catch (SQLException sqle) {
  639. } finally {
  640. try {
  641. if (null != rs) {
  642. rs.close();
  643. }
  644. if (null != prep) {
  645. prep.close();
  646. }
  647. if (null != con) {
  648. con.close();
  649. }
  650. } catch (Exception e) {
  651. }
  652. }
  653. return b;
  654. }
  655. }