package UIM; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.text.DateFormat; import java.text.DecimalFormat; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import UIB.COM.XmlSqlParsersFactory; import UIM.UIM01.BEANS.ColdCoilComm; import CoreFS.SA01.CoreIComponent; import CoreFS.SA06.CoreReturnObject; public class UIM010260 extends CoreIComponent { public CoreReturnObject queryCoilInfo(String coilNo) throws SQLException { CoreReturnObject cro = new CoreReturnObject(); StringBuffer sqlBuffer = new StringBuffer(); sqlBuffer.append("SELECT A.OLD_SAMPL_NO COIL_NO, \n"); sqlBuffer.append("A.SPEC_STL_GRD, \n"); sqlBuffer .append("to_char(A.COIL_THK, 'FM990.099') || '*' || A.COIL_WTH T_W, \n"); sqlBuffer .append("to_char(A.INSTR_COIL_THK, 'FM990.099') || '*' || A.INSTR_COIL_WTH IT_IW, \n"); sqlBuffer.append("A.ORD_NO, \n"); sqlBuffer.append("A.ORD_SEQ, \n"); sqlBuffer.append("A.COIL_LEN, \n"); sqlBuffer.append("A.ACT_WGT, \n"); sqlBuffer.append("A.CAL_WGT, \n"); sqlBuffer .append("DECODE(a.CUR_PROG_CD,'DDB','成品库入库待机','DRC','连退卷充当待机', 'DBA','重卷指示待机', 'DBB','重卷作业待机','DCA','包装指示待机','DCB','包装作业待机','DED','综合判定待机','DFA', '发货指示待机','DFB','运送待机(发货待机)','DFF','运送完成(发货完成)') \n"); sqlBuffer.append(" CUR_PROG_CD, \n"); sqlBuffer .append("DECODE(A.TOT_DEC_GRD,'1','合格','2','不合格','3','次品','4','废品','','待判定') \n"); sqlBuffer.append(" TOT_DEC_GRD, \n"); sqlBuffer .append("DECODE(A.ORD_FL, '1', '订单材', '2', '余材', '', '未判') \n"); sqlBuffer.append(" ORD_FL, \n"); sqlBuffer .append("/*DECODE(A.COIL_STAT,'1','未入库','2','在库','3','出库/结束',null)*/ (CASE \n"); sqlBuffer.append("WHEN A.COIL_STAT='1' THEN '未入库'\n"); sqlBuffer .append("WHEN A.COIL_STAT='2' AND A.CUR_LOAD_LOC IS NULL THEN '未入库'\n"); sqlBuffer .append("WHEN A.COIL_STAT='2' AND A.CUR_LOAD_LOC IS NOT NULL THEN '在库'\n"); sqlBuffer.append("WHEN A.COIL_STAT='3' THEN '出库/结束'\n"); sqlBuffer.append(" END)\n"); sqlBuffer.append(" COIL_STAT, \n"); sqlBuffer.append("A.CUR_LOAD_LOC, \n"); sqlBuffer .append("(SELECT USERNAME FROM CORE_APP_USER U WHERE U.USERID = A.COIL_IN_REG) \n"); sqlBuffer.append(" COIL_IN_REG, \n"); sqlBuffer .append("C_PKG_UIM.GET_STDTIMESTR(A.COIL_IN_DTIME) COIL_IN_DTIME, \n"); sqlBuffer .append("(SELECT USERNAME FROM CORE_APP_USER U WHERE U.USERID = A.COIL_OUT_REG) \n"); sqlBuffer.append(" COIL_OUT_REG, \n"); sqlBuffer .append("C_PKG_UIM.GET_STDTIMESTR(A.COIL_OUT_DTIME) COIL_OUT_DTIME \n"); sqlBuffer.append("FROM C_TBC02_COIL_COMM A \n"); sqlBuffer.append("WHERE A.OLD_SAMPL_NO = ? \n"); cro = this.getDao("KgDao").ExcuteQuery(sqlBuffer.toString(), new Object[] { coilNo }); return cro; } /** * 盘入盘出操作 * * @param type * 盘入/盘出 0/1 * @param coilNo * 钢卷号 * @param curLoadLoc * 垛位 * @param regId * 盘入人 * @param coilInDtime * 盘入时间 * @return * @throws SQLException */ public CoreReturnObject save(Integer type, String coilNo, String curLoadLoc, String regId, String regShift, String regGroup, String coilInDtime,String wdlivno) throws Exception { CoreReturnObject cro = new CoreReturnObject(); Connection conn = null; PreparedStatement pSta = null; StringBuffer updCommBuffer = null; try { conn = this.getDao("KgDao").getConnection(); conn.setAutoCommit(false); // 20140403 if (coilNo == "" || coilNo == null) { throw new Exception("钢卷号为空!"); } else if (regId == "" || regId == null) { throw new Exception("操作人编号为空!"); } else if (coilInDtime == "" || coilInDtime == null) { throw new Exception("操作时间为空!"); } // 查询是是否有这一钢卷的数据 String[] coldCoil = null; coldCoil = coilInfo(coilNo); if (coldCoil == null || coldCoil[0] == "") { throw new Exception("系统查无此卷!"); } String coilInDtimeS = coilInDtime.substring(0, 8); // 盘入 if (type == 0) { if (curLoadLoc == null || curLoadLoc.equals("")) { throw new Exception("垛位为空!"); } // 状态为2的钢卷不能盘入 if (coldCoil[1].equals("2")) { throw new Exception("钢卷为在库状态,如无堆放位置请从入库界面录入!"); } // 是否是正常出库 if (coldCoil[1].equals("3") && coldCoil[3].equals("DFF")) { throw new Exception("这一钢卷属于正常出库,不能进行盘入操作!"); } if (!coldCoil[6].equals("") && !coldCoil[6].equals("C")) { throw new Exception("这一钢卷已经在库中了!"); } String opType = "5";// 盘库类型 if (curLoadLoc != null && !curLoadLoc.equals("")) { if (curLoadLoc.startsWith("4")) { opType = "6"; } else if (curLoadLoc.startsWith("5")) { opType = "7"; } } // 人工盘入库的卷改为余材 ,修改C_TBC02_COIL_COMM信息 updCommBuffer = new StringBuffer(); updCommBuffer.append("UPDATE C_TBC02_COIL_COMM A \n"); updCommBuffer.append(" SET A.CUR_LOAD_LOC = ?,\n"); updCommBuffer.append(" A.COIL_IN_REG = ?,\n"); updCommBuffer.append(" A.CUR_PROG_CD = 'DRC',\n"); updCommBuffer .append(" A.COIL_STAT = '2', A.ORD_FL= '2',A.ORD_NO = '', A.ORD_SEQ = '',\n"); updCommBuffer.append("A.COIL_IN_DTIME = ?, \n"); updCommBuffer.append("A.YARD_ENTRY_DTIME = ?, \n"); updCommBuffer.append("A.IN_YARD_KIND = '" + opType + "', \n"); updCommBuffer.append("A.YARD_ENTRY_REG= ?, \n"); updCommBuffer.append("A.YARD_ENTRY_SHIFT = ? ,\n"); updCommBuffer.append("A.YARD_ENTRY_GROUP = ?, \n"); updCommBuffer .append("A.YARD_ENTRY_USE_TIME =TO_CHAR(SYSDATE,'YYYYMMDDHH24MISS') \n"); updCommBuffer.append("WHERE A.OLD_SAMPL_NO = ? \n"); pSta = conn.prepareStatement(updCommBuffer.toString()); pSta.setString(1, curLoadLoc); pSta.setString(2, regId); pSta.setString(3, coilInDtime); pSta.setString(4, coilInDtimeS); pSta.setString(5, regId); pSta.setString(6, regShift); pSta.setString(7, regGroup); pSta.setString(8, coilNo); pSta.executeUpdate(); pSta.close(); // 人工盘入库的卷改为余材 ,修改C_TBC02_COIL_COMM_D信息 updCommBuffer = new StringBuffer(); updCommBuffer.append("UPDATE C_TBC02_COIL_COMM_D A \n"); updCommBuffer.append(" SET A.ORD_FL= '2',\n"); updCommBuffer.append(" A.ORD_NO = '',\n"); updCommBuffer.append(" A.ORD_SEQ = ''\n"); updCommBuffer.append("WHERE A.L_COIL_NO= ? \n"); pSta = conn.prepareStatement(updCommBuffer.toString()); pSta.setString(1, coilNo); pSta.executeUpdate(); pSta.close(); // 修改垛位表信息C_TBK08_COIL_YARD // 移垛表增加记录 updCommBuffer = new StringBuffer(); updCommBuffer.append("INSERT INTO C_TBK08_COIL_MOVE \n"); updCommBuffer .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"); updCommBuffer.append("VALUES \n"); updCommBuffer.append("( \n"); updCommBuffer .append("(SELECT MAX(ROLL_SEQ)+1 ROLL_SEQ FROM C_TBK08_COIL_MOVE) \n"); updCommBuffer.append(",?,?,?,?,?,?,?,?,?,'04' \n"); updCommBuffer.append(")"); pSta = conn.prepareStatement(updCommBuffer.toString()); pSta.setString(1, ""); pSta.setString(2, curLoadLoc); pSta.setString(3, coilNo); pSta.setString(4, regId); pSta.setString(5, regId); pSta.setString(6, regShift); pSta.setString(7, regGroup); pSta.setString(8, coilInDtime); pSta.setString(9, coilInDtime); pSta.executeUpdate(); pSta.close(); } else if(type == 1){ // 是否是余材 if (!coldCoil[1].equals("2")) { throw new Exception("此钢卷还未入库."); } else if (coldCoil[7].equals("DBB") || coldCoil[7].equals("DFB")) { throw new Exception("已下发重卷计划或发运计划的钢卷不能进行盘出操作!"); } // 人工盘出库的卷信息修正 updCommBuffer = new StringBuffer(); updCommBuffer.append("UPDATE C_TBC02_COIL_COMM A \n"); updCommBuffer .append("SET A.OUT_YARD_KIND = decode(substr(A.CUR_LOAD_LOC,1,1),'4','6','5','7','5'), \n"); updCommBuffer.append(" A.CUR_LOAD_LOC = '',\n"); updCommBuffer.append(" A.COIL_OUT_REG = ?,\n"); updCommBuffer.append(" A.CUR_PROG_CD = 'DRC',\n"); updCommBuffer .append(" A.COIL_STAT = '3', A.ORD_FL= '2',A.ORD_NO = '', A.ORD_SEQ = '',\n"); updCommBuffer.append("A.COIL_OUT_DTIME = ?, \n"); updCommBuffer.append("A.TRNF_DTIME = ?, \n"); updCommBuffer.append("A.TRNF_REG = ?, \n"); updCommBuffer.append("A.TRNF_SHIFT = ?, \n"); updCommBuffer.append("A.TRNF_GROUP = ?, \n"); updCommBuffer .append("A.TRNF_USE_TIME = TO_CHAR(SYSDATE,'YYYYMMDDHH24MISS') \n"); updCommBuffer.append("WHERE A.OLD_SAMPL_NO = ? \n"); pSta = conn.prepareStatement(updCommBuffer.toString()); pSta.setString(1, regId); pSta.setString(2, coilInDtime); pSta.setString(3, coilInDtimeS); pSta.setString(4, regId); pSta.setString(5, regShift); pSta.setString(6, regGroup); pSta.setString(7, coilNo); pSta.executeUpdate(); pSta.close(); // 人工盘入库的卷改为余材 ,修改C_TBC02_COIL_COMM_D信息 updCommBuffer = new StringBuffer(); updCommBuffer.append("UPDATE C_TBC02_COIL_COMM_D A \n"); updCommBuffer.append(" SET A.ORD_FL= '2',\n"); updCommBuffer.append(" A.ORD_NO = '',\n"); updCommBuffer.append(" A.ORD_SEQ = ''\n"); updCommBuffer.append("WHERE A.L_COIL_NO= ? \n"); pSta = conn.prepareStatement(updCommBuffer.toString()); pSta.setString(1, coilNo); pSta.executeUpdate(); pSta.close(); // 移垛表增加记录 updCommBuffer = new StringBuffer(); updCommBuffer.append("INSERT INTO C_TBK08_COIL_MOVE \n"); updCommBuffer.append("( \n"); updCommBuffer .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"); updCommBuffer.append("VALUES \n"); updCommBuffer.append("( \n"); updCommBuffer.append("(SELECT MAX(ROLL_SEQ)+1 ROLL_SEQ FROM C_TBK08_COIL_MOVE), \n"); updCommBuffer.append("?,?,?,?,?,?,?,?,?,'15' \n"); updCommBuffer.append(") \n"); pSta = conn.prepareStatement(updCommBuffer.toString()); pSta.setString(1,coldCoil[6]); pSta.setString(2,""); pSta.setString(3,coilNo); pSta.setString(4,regId); pSta.setString(5,regId); pSta.setString(6,regShift); pSta.setString(7,regGroup); pSta.setString(8,coilInDtime); pSta.setString(9,coilInDtime); pSta.executeUpdate(); pSta.close(); } else{//废钢外卖 DateFormat formatter = new SimpleDateFormat("yyyyMMdd"); String currDate = formatter.format(new Date()); String seqno="FG"+currDate; String dlivnoNEXT; dlivnoNEXT=dlivno(seqno);//生成废钢编号 // 是否是余材 if (!coldCoil[1].equals("2")) { throw new Exception("此钢卷还未入库."); } else if (coldCoil[7].equals("DBB") || coldCoil[7].equals("DFB")) { throw new Exception("已下发重卷计划或发运计划的钢卷不能进行盘出操作!"); } // 人工盘出库的卷信息修正 updCommBuffer = new StringBuffer(); updCommBuffer.append("UPDATE C_TBC02_COIL_COMM A \n"); updCommBuffer .append("SET A.OUT_YARD_KIND = '8', \n");//出库类型废钢外卖 updCommBuffer.append(" A.CUR_LOAD_LOC = '',\n"); updCommBuffer.append(" A.COIL_OUT_REG = ?,\n"); updCommBuffer.append(" A.CUR_PROG_CD = 'DRC',\n"); updCommBuffer .append(" A.COIL_STAT = '3', A.ORD_FL= '2',A.ORD_NO = '', A.ORD_SEQ = '',\n"); updCommBuffer.append("A.COIL_OUT_DTIME = ?, \n"); updCommBuffer.append("A.TRNF_DTIME = ?, \n"); updCommBuffer.append("A.TRNF_REG = ?, \n"); updCommBuffer.append("A.TRNF_SHIFT = ?, \n"); updCommBuffer.append("A.TRNF_GROUP = ?, \n"); updCommBuffer.append("A.wdlivno = ?, \n"); updCommBuffer .append("A.TRNF_USE_TIME = TO_CHAR(SYSDATE,'YYYYMMDDHH24MISS') \n"); updCommBuffer.append("WHERE A.OLD_SAMPL_NO = ? \n"); pSta = conn.prepareStatement(updCommBuffer.toString()); pSta.setString(1, regId); pSta.setString(2, coilInDtime); pSta.setString(3, coilInDtimeS); pSta.setString(4, regId); pSta.setString(5, regShift); pSta.setString(6, regGroup); pSta.setString(7, dlivnoNEXT); pSta.setString(8, coilNo); pSta.executeUpdate(); pSta.close(); // 人工盘入库的卷改为余材 ,修改C_TBC02_COIL_COMM_D信息 updCommBuffer = new StringBuffer(); updCommBuffer.append("UPDATE C_TBC02_COIL_COMM_D A \n"); updCommBuffer.append(" SET A.ORD_FL= '2',\n"); updCommBuffer.append(" A.ORD_NO = '',\n"); updCommBuffer.append(" A.ORD_SEQ = ''\n"); updCommBuffer.append("WHERE A.L_COIL_NO= ? \n"); pSta = conn.prepareStatement(updCommBuffer.toString()); pSta.setString(1, coilNo); pSta.executeUpdate(); pSta.close(); // 移垛表增加记录 updCommBuffer = new StringBuffer(); updCommBuffer.append("INSERT INTO C_TBK08_COIL_MOVE \n"); updCommBuffer.append("( \n"); updCommBuffer .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"); updCommBuffer.append("VALUES \n"); updCommBuffer.append("( \n"); updCommBuffer.append("(SELECT MAX(ROLL_SEQ)+1 ROLL_SEQ FROM C_TBK08_COIL_MOVE), \n"); updCommBuffer.append("?,?,?,?,?,?,?,?,?,'15' \n"); updCommBuffer.append(") \n"); pSta = conn.prepareStatement(updCommBuffer.toString()); pSta.setString(1,coldCoil[6]); pSta.setString(2,""); pSta.setString(3,coilNo); pSta.setString(4,regId); pSta.setString(5,regId); pSta.setString(6,regShift); pSta.setString(7,regGroup); pSta.setString(8,coilInDtime); pSta.setString(9,coilInDtime); pSta.executeUpdate(); pSta.close(); } conn.commit(); } catch (SQLException ex) { if (conn != null) { conn.rollback(); } cro.setV_errCode(-1); cro.setV_errMsg("请检查钢卷信息后重新操作!"); } finally { try{ //添加了若出现异常情况关闭pStas if (pSta != null) { pSta.close(); } if (conn != null && !conn.isClosed()) { conn.close(); } } catch (Exception e) { } } return cro; } /** * 钢卷信息查询 FLZ-11-8-30 * * @param coilNo * 卷号 * @return null-查不到. 0 COIL_NO/ 1 COIL_STAT /2 SLAB_NO /3 CUR_PROG_CD /4 * TRNF_DTIME /5 A.ORD_FL /6 A.CUR_LOAD_LOC/7 CUR_PROG_CD */ private String[] coilInfo(String coilNo) throws Exception { String[] STRreturn = null; StringBuffer sqlBuffer = new StringBuffer(); sqlBuffer.append("SELECT A.OLD_SAMPL_NO COIL_NO, A.COIL_STAT,\n"); sqlBuffer.append("A.SLAB_NO,a.CUR_PROG_CD, a.TRNF_DTIME,\n"); sqlBuffer.append("A.ORD_FL,A.CUR_LOAD_LOC,A.CUR_PROG_CD \n"); sqlBuffer.append("FROM C_TBC02_COIL_COMM A\n"); sqlBuffer.append("WHERE A.OLD_SAMPL_NO = ?\n"); List list = this.getDao("KgDao").ExcuteQueryReturnList( sqlBuffer.toString(), new Object[] { coilNo }); if (list.size() > 0) { Map map = (Map) list.get(0); STRreturn = new String[] { map.get("COIL_NO") == null ? "" : map.get("COIL_NO") .toString(), // 0 map.get("COIL_STAT") == null ? "" : map.get("COIL_STAT") .toString(),// 1 map.get("SLAB_NO") == null ? "" : map.get("SLAB_NO") .toString(),// 2 map.get("CUR_PROG_CD") == null ? "" : map .get("CUR_PROG_CD").toString(),// 3 map.get("TRNF_DTIME") == null ? "" : map.get("TRNF_DTIME") .toString(),// 4 map.get("ORD_FL") == null ? "" : map.get("ORD_FL") .toString(),// 5 map.get("CUR_LOAD_LOC") == null ? "" : map.get( "CUR_LOAD_LOC").toString(),// 6 map.get("CUR_PROG_CD") == null ? "" : map .get("CUR_PROG_CD").toString() // 7 }; } return STRreturn; } /** * 查找钢卷号是否存在 * * @param coilNo * @param type * 0盘入 1盘出 * @return */ private ColdCoilComm findCoil(String coilNo, int type) { PreparedStatement prepStat = null; ColdCoilComm coldCoil = null; ResultSet rs = null; Connection conn = null; try { StringBuffer sqlBuffer = new StringBuffer(); sqlBuffer.append("SELECT A.OLD_SAMPL_NO COIL_NO, A.COIL_STAT,\n"); sqlBuffer.append("A.SLAB_NO,a.CUR_PROG_CD, a.TRNF_DTIME\n"); sqlBuffer.append("FROM C_TBC02_COIL_COMM A\n"); sqlBuffer.append("WHERE A.OLD_SAMPL_NO = ?\n"); if (type == 0) { sqlBuffer.append("AND A.CUR_LOAD_LOC IS NULL\n"); } else { sqlBuffer.append("AND A.COIL_STAT = '2'\n"); } prepStat = this.getDao("KgDao").getPreparedStatement( sqlBuffer.toString()); prepStat.setString(1, coilNo); conn = prepStat.getConnection(); rs = prepStat.executeQuery(); if (rs.next()) { coldCoil = new ColdCoilComm(); coldCoil.setCoilNo(rs.getString("COIL_NO")); coldCoil.setCoilStat(rs.getString("COIL_STAT")); coldCoil.setCurProgCd(rs.getString("CUR_PROG_CD")); coldCoil.setSlabNo(rs.getString("SLAB_NO")); coldCoil.setTrnfDTime(rs.getString("TRNF_DTIME")); } } catch (SQLException sqle) { } finally { try { if (null != rs) { rs.close(); } if (null != prepStat) { prepStat.close(); } if (null != conn) { conn.close(); } } catch (Exception e) { } } return coldCoil; // PreparedStatement prepStat = null; // ColdCoilComm coldCoil = null; // ResultSet rs = null; // // try { // StringBuffer sqlBuffer = new StringBuffer(); // sqlBuffer.append("SELECT A.COIL_NO,A.COIL_STAT,\n"); // sqlBuffer.append(" A.SLAB_NO,a.CUR_PROG_CD,\n"); // sqlBuffer.append(" a.TRNF_DTIME FROM C_TBC02_COIL_COMM A \n"); // sqlBuffer.append(" WHERE COIL_NO = ? \n"); // String tmp = 0 == type ? "<>" : "="; // sqlBuffer.append(" AND A.COIL_STAT " + tmp + " '2'\n"); // // prepStat = this.getDao("KgDao").getPreparedStatement( // sqlBuffer.toString()); // prepStat.setString(1, coilNo); // // rs = prepStat.executeQuery(); // if (rs.next()) { // coldCoil = new ColdCoilComm(); // coldCoil.setCoilNo(rs.getString("COIL_NO")); // coldCoil.setCoilStat(rs.getString("COIL_STAT")); // coldCoil.setCurProgCd(rs.getString("CUR_PROG_CD")); // coldCoil.setSlabNo(rs.getString("SLAB_NO")); // coldCoil.setTrnfDTime(rs.getString("TRNF_DTIME")); // } // } // catch (SQLException sqle) { // } // finally { // try { // if (null != rs) { // rs.close(); // } // if (null != prepStat) { // prepStat.close(); // } // } catch (Exception e) { // // } // } // // return coldCoil; } /** * 判断原料库垛位上是否存在有钢卷 * * @param curLoadLoc * 堆放位置 * @return String */ private String hasCoilOnYard(String curLoadLoc) { String coilNo = ""; StringBuffer sqlBuffer = new StringBuffer(); sqlBuffer .append("SELECT A.COIL_NO FROM C_TBK08_COIL_YARD A, C_TBK08_COIL_YARD_AREA B\n"); sqlBuffer.append(" WHERE A.AREA_NO = B.AREA_NO\n"); sqlBuffer.append(" AND B.AREA_TYPE = '3'\n"); sqlBuffer .append("AND a.CLF_NO = c_Pkg_Uim.GET_FINALYARDNO_BYYARDFLAG(?)\n"); PreparedStatement prep = null; ResultSet rs = null; Connection con=null; try { prep = this.getDao("KgDao").getPreparedStatement( sqlBuffer.toString()); prep.setString(1, curLoadLoc); rs = prep.executeQuery(); con=prep.getConnection(); if (rs.next()) { coilNo = rs.getString("COIL_NO"); } } catch (SQLException sqle) { } finally { try { if (null != rs) { rs.close(); } if (null != prep) { prep.close(); } if(null!=con){ con.close(); } } catch (Exception e) { } } return coilNo; } private String dlivno(String syddate) { String dlivno = ""; StringBuffer sqlBuffer = new StringBuffer(); sqlBuffer .append("SELECT MAX(A.WDLIVNO) WDLIVNO FROM C_TBC02_COIL_COMM A WHERE\n"); sqlBuffer.append(" A.WDLIVNO LIKE ?||'%'"); PreparedStatement prep = null; ResultSet rs = null; Connection con=null; try { prep = this.getDao("KgDao").getPreparedStatement( sqlBuffer.toString()); prep.setString(1, syddate); rs = prep.executeQuery(); con =prep.getConnection(); String temp=""; if(rs.next()){ if("".equals(rs.getString("WDLIVNO"))||rs.getString("WDLIVNO")==null) { dlivno=syddate+"01"; }else{ temp = rs.getString("WDLIVNO").substring(10); int aa=Integer.parseInt(temp) + 1; temp = new DecimalFormat("00").format(aa); dlivno = syddate+temp; } } else{ dlivno=syddate+"01"; } } catch (SQLException sqle) { } finally { try { if (null != rs) { rs.close(); } if (null != prep) { prep.close(); } if(null!=con){ con.close(); } } catch (Exception e) { } } return dlivno; } /** * 判断对象是否为空 * * @param obj * @return boolean */ private boolean isNull(Object obj) { boolean isNull = true; if (null != obj && !"".equals(obj)) { isNull = false; } return isNull; } /** * 查询垛位是否存在 * * @param curLoadLoc * @return */ private boolean hasYard(String curLoadLoc) { boolean b = false; StringBuffer sqlBuffer = new StringBuffer(); sqlBuffer .append("SELECT A.CLF_NO FROM C_TBK08_COIL_YARD A, C_TBK08_COIL_YARD_AREA B\n"); sqlBuffer.append("WHERE A.AREA_NO = B.AREA_NO\n"); sqlBuffer.append(" AND B.AREA_TYPE = '3'\n"); sqlBuffer .append("AND A.CLF_NO = c_Pkg_Uim.GET_FINALYARDNO_BYYARDFLAG(?) \n"); PreparedStatement prep = null; ResultSet rs = null; Connection con =null; try { prep = this.getDao("KgDao").getPreparedStatement( sqlBuffer.toString()); prep.setString(1, curLoadLoc); rs = prep.executeQuery(); con=prep.getConnection(); if (rs.next()) { b = true; } } catch (SQLException sqle) { } finally { try { if (null != rs) { rs.close(); } if (null != prep) { prep.close(); } if (null != con) { con.close(); } } catch (Exception e) { } } return b; } }