| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446 |
- 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.Iterator;
- import java.util.List;
- import java.util.Map;
- import UIB.COM.ProduceFactory;
- import UIB.COM.XmlSqlParsersFactory;
- import UIM.UIM01.BEANS.ColdCoilComm;
- import CoreFS.SA01.CoreIComponent;
- import CoreFS.SA06.CoreReturnObject;
- /**
- * 冷轧中间库盘入盘出
- *
- * @author siy
- * @date 2010-08-27
- */
- public class UIM010190 extends CoreIComponent {
- /**
- * 查询钢卷信息
- *
- * @param coilNo
- * 酸轧卷号
- * @return CoreReturnObject
- * @throws SQLException
- */
- public CoreReturnObject queryCoilInfo(String coilNo) throws SQLException {
- CoreReturnObject cro = new CoreReturnObject();
- String sql = XmlSqlParsersFactory.getSql("UIM010190_01.SELECT");
- cro = this.getDao("KgDao").ExcuteQuery(sql, new Object[] { coilNo });
- return cro;
- }
- /**
- * 盘入盘出操作
- *
- * @param type
- * 盘入/盘出 0/1
- * @param coilNo
- * 钢卷号
- * @param curLoadLoc
- * 垛位
- * @param regId
- * 盘入人
- * @return
- * @throws SQLException
- */
- public CoreReturnObject save(Integer type, String coilNo,
- String curLoadLoc, String regId, String trnfShift, String trnfGroup,String wdlivno)
- throws SQLException {
- CoreReturnObject cro = new CoreReturnObject();
- // 判断是做盘入操作还是做盘出操作
- if (0 == type.intValue()) {
- // 盘入操作,首先要检查钢卷号是否存在系统。不存在的情况下给予提示
- ColdCoilComm coldCoil = findCoil(coilNo, 0);
- if (null != coldCoil && !isNull(coldCoil.getCoilNo())) {
- // 正常出库的卷暂时不允许发货
- if ("3".equals(coldCoil.getCoilStat())
- && ("DFF".equals(coldCoil.getCurProgCd()) || "CCC"
- .equals(coldCoil.getCurProgCd()))
- && !isNull(coldCoil.getTrnfDTime())) {
- // 抛出异常
- cro.setV_errCode(new Integer(1));
- cro.setV_errMsg("需要盘入库的钢卷属于正常出库,不能进行盘入操作!");
- } else {
- // 输入垛位为空或不存在此垛位
- if (!isNull(curLoadLoc) && hasYard(curLoadLoc)) {
- // 检查要盘入的垛位上是否存在钢卷
- String coilNoTmp = this.hasCoilOnYard(curLoadLoc);
- if (isNull(coilNoTmp)) {
- Map result = this.getDao("KgDao")
- .CoreBeginTranscation();
- try {
- // 插入移垛记录
- String insSql = XmlSqlParsersFactory
- .getSql("UIM010110_01.INSERT");
- this.getDao("KgDao").ExcuteNonQuery(
- insSql,
- new Object[] { "", curLoadLoc, coilNo,
- regId, trnfShift, trnfGroup,
- "04" });
- // 人工盘入库的卷改为余材
- String sqlComm = XmlSqlParsersFactory
- .getSql("UIM010190_01.UPDATE");
- this.getDao("KgDao").ExcuteNonQuery(
- sqlComm,
- new Object[] { curLoadLoc, regId,
- coilNo });
- // 更新原料公共_D表
- String sqlCommD = XmlSqlParsersFactory
- .getSql("UIM010190_02.UPDATE");
- this.getDao("KgDao").ExcuteNonQuery(sqlCommD,
- new Object[] { coilNo });
- // 将钢卷信息录入垛位表
- String sqlYard = XmlSqlParsersFactory
- .getSql("UIM010190_03.UPDATE");
- this.getDao("KgDao").ExcuteNonQuery(
- sqlYard,
- new Object[] { coilNo, curLoadLoc,
- curLoadLoc, curLoadLoc,
- curLoadLoc });
- this.getDao("KgDao").CoreCommit(result);
-
- //调用存货异动点存储过程
- ProduceFactory PD= new ProduceFactory();
- PD.ErpDataCover("CCOIL",coilNo,"14A","1","O",regId,"酸轧盘入");
-
- } catch (Exception ex) {
- this.getDao("KgDao").CoreRollBack(result);
- cro.setV_errCode(new Integer(-1));
- cro.setV_errMsg("系统忙,请稍后再操作!");
- }
- }
- } else {
- cro.setV_errCode(new Integer(2));
- cro.setV_errMsg("需要盘入库的钢卷垛位信息不正确,请输入正确的垛位后再进行相应操作!");
- }
- }
- } else {
- cro.setV_errCode(new Integer(3));
- cro.setV_errMsg("需要盘入库的钢卷在库存中,请确认后再进行相应操作!");
- }
- } else if(1 == type.intValue()){
- // 盘出操作,首先要检查钢卷号是否存在系统。不存在的情况下给予提示
- ColdCoilComm coldCoil = findCoil(coilNo, 1);
- if (null != coldCoil && !isNull(coldCoil.getCoilNo())) {
- if ("CCB".equals(coldCoil.getCurProgCd())
- || "DFB".equals(coldCoil.getCurProgCd())) {
- cro.setV_errCode(new Integer(4));
- cro.setV_errMsg("需要盘出库的钢卷已经下发连退或发运计划,请撤销计划后再进行相应操作!");
- } else {
- Map result = this.getDao("KgDao").CoreBeginTranscation();
- try {
- // 插入移垛记录
- String insSql = XmlSqlParsersFactory
- .getSql("UIM010110_01.INSERT");
- this.getDao("KgDao").ExcuteNonQuery(
- insSql,
- new Object[] { coldCoil.getCurLoadLoc(), "", coilNo,
- regId, trnfShift, trnfGroup,
- "15" });
- // 更新原料公共表
- String sqlComm = XmlSqlParsersFactory
- .getSql("UIM010190_04.UPDATE");
- this.getDao("KgDao").ExcuteNonQuery(sqlComm,
- new Object[] { regId, coilNo });
- // 更新原料公共_D表
- String sqlCommD = XmlSqlParsersFactory
- .getSql("UIM010190_05.UPDATE");
- this.getDao("KgDao").ExcuteNonQuery(
- sqlCommD.toString(), new Object[] { coilNo });
- // 更新垛位表
- String sqlYard = XmlSqlParsersFactory
- .getSql("UIM010190_06.UPDATE");
- this.getDao("KgDao").ExcuteNonQuery(sqlYard.toString(),
- new Object[] { coilNo });
- this.getDao("KgDao").CoreCommit(result);
-
- //调用存货异动点存储过程
- ProduceFactory PD= new ProduceFactory();
- PD.ErpDataCover("CCOIL",coilNo,"64A","1","O",regId,"酸轧盘出");
-
- } catch (Exception ex) {
- this.getDao("KgDao").CoreRollBack(result);
- cro.setV_errCode(new Integer(-1));
- cro.setV_errMsg("系统忙,请稍后再操作!");
- }
- }
- } else {
- cro.setV_errCode(new Integer(5));
- cro.setV_errMsg("需要盘出库的钢卷不在库存中,请确认后再进行相应操作!");
- }
- }
- else{
- // 废钢外卖盘出操作,首先要检查钢卷号是否存在系统。不存在的情况下给予提示
- DateFormat formatter = new SimpleDateFormat("yyyyMMdd");
- String currDate = formatter.format(new Date());
- String seqno="FG"+currDate;
- String dlivnoNEXT;
- dlivnoNEXT=dlivno(seqno);//生成废钢编号
- ColdCoilComm coldCoil = findCoil(coilNo, 1);
- if (null != coldCoil && !isNull(coldCoil.getCoilNo())) {
- if ("CCB".equals(coldCoil.getCurProgCd())
- || "DFB".equals(coldCoil.getCurProgCd())) {
- cro.setV_errCode(new Integer(4));
- cro.setV_errMsg("需要盘出库的钢卷已经下发连退或发运计划,请撤销计划后再进行相应操作!");
- } else {
- Map result = this.getDao("KgDao").CoreBeginTranscation();
- try {
- // 插入移垛记录
- String insSql = XmlSqlParsersFactory
- .getSql("UIM010110_01.INSERT");
- this.getDao("KgDao").ExcuteNonQuery(
- insSql,
- new Object[] { coldCoil.getCurLoadLoc(), "", coilNo,
- regId, trnfShift, trnfGroup,
- "15" });
- // 更新原料公共表
- String sqlComm = XmlSqlParsersFactory
- .getSql("UIM010190_07.UPDATE");
- this.getDao("KgDao").ExcuteNonQuery(sqlComm,
- new Object[] { regId,dlivnoNEXT, coilNo });
- // 更新原料公共_D表
- String sqlCommD = XmlSqlParsersFactory
- .getSql("UIM010190_05.UPDATE");
- this.getDao("KgDao").ExcuteNonQuery(
- sqlCommD.toString(), new Object[] { coilNo });
- // 更新垛位表
- String sqlYard = XmlSqlParsersFactory
- .getSql("UIM010190_06.UPDATE");
- this.getDao("KgDao").ExcuteNonQuery(sqlYard.toString(),
- new Object[] { coilNo });
- this.getDao("KgDao").CoreCommit(result);
- } catch (Exception ex) {
- this.getDao("KgDao").CoreRollBack(result);
- cro.setV_errCode(new Integer(-1));
- cro.setV_errMsg("系统忙,请稍后再操作!");
- }
- }
- } else {
- cro.setV_errCode(new Integer(5));
- cro.setV_errMsg("需要盘出库的钢卷不在库存中,请确认后再进行相应操作!");
- }
- }
- return cro;
- }
- /**
- * 查找钢卷号是否存在
- *
- * @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 {
- String sql = XmlSqlParsersFactory.getSql("UIM010190_03.SELECT");
- if (type == 0) {
- sql += " AND A.CUR_LOAD_LOC IS NULL";
- } else {
- sql += " AND A.COIL_STAT = '2'";
- }
- prepStat = this.getDao("KgDao").getPreparedStatement(sql);
- 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"));
- coldCoil.setCurLoadLoc(rs.getString("CUR_LOAD_LOC"));
- }
- } 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;
- }
- private String dlivno(String syddate) {
- String dlivno = "";
- StringBuffer sqlBuffer = new StringBuffer();
- sqlBuffer
- .append("SELECT MAX(A.WDLIVNO) WDLIVNO FROM C_TBL02_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();
- if (rs.next()) {
- String temp="";
- 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 curLoadLoc
- * 堆放位置
- * @return String
- */
- private String hasCoilOnYard(String curLoadLoc) {
- String coilNo = "";
- String sql = XmlSqlParsersFactory.getSql("UIM010190_04.SELECT");
- Connection conn = null;
- PreparedStatement prep = null;
- ResultSet rs = null;
- try {
- prep = this.getDao("KgDao").getPreparedStatement(sql);
- prep.setString(1, curLoadLoc);
- conn = prep.getConnection();
- rs = prep.executeQuery();
- 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 != conn) {
- conn.close();
- }
- } catch (Exception e) {
- }
- }
- return coilNo;
- }
- /**
- * 判断对象是否为空
- *
- * @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;
- String sql = XmlSqlParsersFactory.getSql("UIM010190_02.SELECT");
- Connection conn = null;
- PreparedStatement prep = null;
- ResultSet rs = null;
- try {
- prep = this.getDao("KgDao").getPreparedStatement(sql);
- prep.setString(1, curLoadLoc);
- conn = prep.getConnection();
- rs = prep.executeQuery();
- if (rs.next()) {
- b = true;
- }
- } catch (SQLException sqle) {
- } finally {
- try {
- if (null != rs) {
- rs.close();
- }
- if (null != prep) {
- prep.close();
- }
- if (null != conn) {
- conn.close();
- }
- } catch (Exception e) {
- }
- }
- return b;
- }
- }
|