| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296 |
- package UIE.NIE01;
- import java.text.DateFormat;
- import java.text.SimpleDateFormat;
- import java.util.ArrayList;
- import java.util.Date;
- import org.springframework.jdbc.support.rowset.SqlRowSet;
- import UIB.COM.XmlSqlParsersFactory;
- import CoreFS.SA01.CoreIComponent;
- import CoreFS.SA06.CoreReturnObject;
- public class ReArrangeOrdSts extends CoreIComponent {
-
-
- String V_TABLE_ID = "" ;
- String V_TABLE_MODE = "" ;
- String V_ERR_DESC = "" ;
- String V_RTN_NAME = "" ;
-
- String V_PROC_CD = "" ;
- String V_STL_GRD = "" ;
- String V_PROD_END_GP = "" ;
- String P_PROD_END_GP = "" ;
- String V_PROD_END_DATE = "" ;
- String P_PROD_END_DATE = "" ;
- String V_SHIP_END_DATE = "" ;
- String V_ORD_PROG_CD = "" ;
- String V_PROD_HOLD_CD = "" ;
-
- long V_TOT_WGT = 0 ;
- long V_INS_WGT = 0 ;
- long V_WRK_WGT = 0 ;
- long V_EST_WGT = 0 ;
- long V_END_WGT = 0 ;
- long V_ORD_PRC_WGT = 0 ;
- long V_PROD_END_WGT = 0 ;
- long V_ORD_REM_WGT = 0 ;
- long V_SHIP_END_WGT = 0 ;
- long V_ORD_WGT = 0 ;
- long V_WGT_ACVAL_MAX = 0 ;
-
- String P_ORD_NO;
- String P_ORD_SEQ;
- String P_PGMID;
- String P_REG_ID;
-
- String sqlstr;
- CoreReturnObject cro ;
- SqlRowSet srs;
- ArrayList<String> paramArray ;
-
- public ReArrangeOrdSts(String P_ORD_NO,String P_ORD_SEQ,String P_PGMID,String P_REG_ID){
- this.P_ORD_NO = P_ORD_NO;
- this.P_ORD_SEQ = P_ORD_SEQ;
- this.P_PGMID = P_PGMID;
- this.P_REG_ID = P_REG_ID;
- }
- public void reArrangeOrdStsUpdt() throws Exception{
- try{
- if (P_ORD_NO == null || "".equals(P_ORD_NO) ||
- P_ORD_SEQ == null || "".equals(P_ORD_SEQ)){
- throw new Exception ("ORD_NO OR ORD_SEQ IS NULL");
- }
-
- DateFormat formatter = new SimpleDateFormat("yyyyMMdd");
- String currDate = formatter.format(new Date());
-
- //SELECT PK CHECK FROM TBE02_ORD_PRC
- sqlstr = XmlSqlParsersFactory.getSql("NIE042030_OrdNoCk.select");
- cro = this.getDao("KgDao").ExecutequeryForRowSet(sqlstr,new Object[]{P_ORD_NO,P_ORD_SEQ});
- srs = (SqlRowSet)cro.getResult();
-
- if (srs.next()) {
-
- V_ORD_WGT = Long.parseLong((srs.getObject("ORD_WGT")==null? "0":srs.getObject("ORD_WGT")).toString());
- V_WGT_ACVAL_MAX = Long.parseLong((srs.getObject("WGT_ACVAL_MAX")==null? "0":srs.getObject("WGT_ACVAL_MAX")).toString());
-
- V_ORD_PROG_CD = (String)(srs.getObject("ORD_PROG_CD")==null?"":srs.getObject("ORD_PROG_CD"));
- V_STL_GRD = (String)(srs.getObject("STL_GRD")==null?"":srs.getObject("STL_GRD"));
- P_PROD_END_GP = (String)(srs.getObject("PROD_END_GP")==null?"":srs.getObject("PROD_END_GP"));
- P_PROD_END_DATE = (String)(srs.getObject("PROD_END_DATE")==null?"":srs.getObject("PROD_END_DATE"));
- V_PROD_HOLD_CD = (String)(srs.getObject("PROD_HOLD_CD")==null?"":srs.getObject("PROD_HOLD_CD"));
- V_SHIP_END_DATE = (String)(srs.getObject("SHIP_END_DATE")==null?"":srs.getObject("SHIP_END_DATE"));
- V_PROD_END_DATE = (String)(srs.getObject("PROD_END_DATE")==null?"":srs.getObject("PROD_END_DATE"));
-
- V_ORD_REM_WGT = V_ORD_WGT;
-
- if (V_WGT_ACVAL_MAX == 0) {
- V_WGT_ACVAL_MAX = V_ORD_WGT;
- }
-
- } else {
- //Error Display
- throw new Exception("ReArrangeOrdSts..Not Found NIE012100_OrdNoCk..");
- }
-
- V_ORD_PRC_WGT = 0;
- V_PROD_END_WGT = 0;
- V_SHIP_END_WGT = 0;
-
- //TABLE TBE02_ORD_PRC_DET INITIALIZE
- sqlstr = XmlSqlParsersFactory.getSql("NIE042030_INIT.update");
- cro = this.getDao("KgDao").ExcuteNonQuery(sqlstr,new Object[]{P_ORD_NO,P_ORD_SEQ});
-
- //SELECT CHARGE/SLAB/COIL PROGRESS WEIGHT
- sqlstr = XmlSqlParsersFactory.getSql("NIE042030_ProgWgt.select");
- paramArray = new ArrayList<String>();
- paramArray.add(P_ORD_NO);
- paramArray.add(P_ORD_SEQ);
- paramArray.add(P_ORD_NO);
- paramArray.add(P_ORD_SEQ);
- paramArray.add(P_ORD_NO);
- paramArray.add(P_ORD_SEQ);
- paramArray.add(P_ORD_NO);
- paramArray.add(P_ORD_SEQ);
- paramArray.add(P_ORD_NO);
- paramArray.add(P_ORD_SEQ);
- paramArray.add(P_ORD_NO);
- paramArray.add(P_ORD_SEQ);
- paramArray.add(P_ORD_NO);
- paramArray.add(P_ORD_SEQ);
- cro = this.getDao("KgDao").ExecutequeryForRowSet(sqlstr,paramArray.toArray());
- srs = (SqlRowSet)cro.getResult();
-
- while(srs.next()){
-
- V_PROC_CD = (String)srs.getObject("PROG_CD");
- V_INS_WGT = Long.parseLong((srs.getObject("INS_WGT")==null? "0":srs.getObject("INS_WGT")).toString());
- V_WRK_WGT = Long.parseLong((srs.getObject("WRK_WGT")==null? "0":srs.getObject("WRK_WGT")).toString());
- V_EST_WGT = Long.parseLong((srs.getObject("EST_WGT")==null? "0":srs.getObject("EST_WGT")).toString());
- V_END_WGT = Long.parseLong((srs.getObject("END_WGT")==null? "0":srs.getObject("END_WGT")).toString());
-
- //SELECT PK CHECK FROM TBE02_ORD_PRC_DET
- sqlstr = XmlSqlParsersFactory.getSql("NIE042030_OrdPrcDetPk.select");
- cro = this.getDao("KgDao").ExecutequeryForRowSet(sqlstr,new Object[]{P_ORD_NO,P_ORD_SEQ,V_PROC_CD.substring(0, 2)});
- srs = (SqlRowSet)cro.getResult();
- if(!srs.next()){
- sqlstr = XmlSqlParsersFactory.getSql("NIE042030_OrdPrcDet.insert");
- cro = this.getDao("KgDao").ExcuteNonQuery(sqlstr,new Object[]{P_ORD_NO,P_ORD_SEQ,V_PROC_CD.substring(0, 2)});
- }
-
- //PRODUCT PROGRESS / END WEIGHT
- if (V_PROC_CD.substring(0, 2).equals("SF")) {
-
- V_PROD_END_WGT = V_INS_WGT + V_WRK_WGT;
- V_SHIP_END_WGT = V_END_WGT;
-
- //V_ORD_PRC_WGT = V_ORD_PRC_WGT + V_INS_WGT + V_WRK_WGT;
- V_TOT_WGT = V_INS_WGT + V_WRK_WGT + V_END_WGT;
- //V_ORD_REM_WGT = V_ORD_WGT - (V_ORD_PRC_WGT + V_SHIP_END_WGT);
-
- } else {
-
- V_ORD_PRC_WGT = V_ORD_PRC_WGT + V_INS_WGT +
- V_WRK_WGT + V_EST_WGT + V_END_WGT;
- V_TOT_WGT = V_INS_WGT + V_WRK_WGT + V_EST_WGT + V_END_WGT;
- //V_ORD_REM_WGT = V_ORD_WGT - (V_ORD_PRC_WGT + V_PROD_END_WGT + V_SHIP_END_WGT);
-
- }
-
- sqlstr = XmlSqlParsersFactory.getSql("NIE042030_OrdPrcDet.update");
- paramArray = new ArrayList<String> ();
- paramArray.add(String.valueOf(V_TOT_WGT));
- paramArray.add(String.valueOf(V_INS_WGT));
- paramArray.add(String.valueOf(V_WRK_WGT));
- paramArray.add(String.valueOf(V_EST_WGT));
- paramArray.add(String.valueOf(V_END_WGT));
- paramArray.add(P_PGMID);
- paramArray.add(P_ORD_NO);
- paramArray.add(P_ORD_SEQ);
- paramArray.add(V_PROC_CD.substring(0, 2));
- cro = this.getDao("KgDao").ExcuteNonQuery(sqlstr,paramArray.toArray());
-
- // if (UpdCnt1 == 0) {
- //
- // V_TABLE_ID = "TBE02_ORD_PRC_DET";
- // V_TABLE_MODE = "U";
- // V_ERR_DESC = "TBE02_ORD_PRC_DET UPDATE COUNT IS ZERO";
- // V_RTN_NAME = "ReArrangeOrdSts TBE02_ORD_PRC_DET UPDATE1 " + P_ORD_NO + P_ORD_SEQ + V_PROC_CD.substring(0, 2);
- //
- // LogGpError.logMessageToDB("ReArrangeOrdSts", V_TABLE_ID, V_TABLE_MODE, V_ERR_DESC, V_RTN_NAME);
- // throw new PosException(V_RTN_NAME);
- // }
- }//while end
-
- //V_ORD_REM_WGT 订单剩余重量
- //V_ORD_WGT 订单重量
- //V_ORD_PRC_WGT 订单进程重量(生产进程)
- //V_PROD_END_WGT 生产结束重量
- //V_SHIP_END_WGT 发货完成重量
- V_ORD_REM_WGT = V_ORD_WGT - (V_ORD_PRC_WGT + V_PROD_END_WGT + V_SHIP_END_WGT);
-
- //================================================王黎添加 2009年8月12日 start================================================================
- //如果没有人工指定时对订单状态进行整理
- if(("".equals(P_PROD_END_GP) || P_PROD_END_GP == null) && (!"Y".equals(V_PROD_HOLD_CD) && !"R".equals(V_PROD_HOLD_CD)))
- {
- //如果订单重量小于或者等于发货完成重量
- if(V_WGT_ACVAL_MAX <= V_SHIP_END_WGT)
- {
- V_ORD_PROG_CD = "G"; //发货完成
- //TL 091229 发货完成的时候,自动给出发货结束时间
- if(V_SHIP_END_DATE == null || V_SHIP_END_DATE.equals("")){
- V_SHIP_END_DATE = currDate;
- }
- }
- //如果订单重量大于发货重量,小于发货重量+生产完成重量
- else if(V_WGT_ACVAL_MAX > V_SHIP_END_WGT && V_WGT_ACVAL_MAX <= (V_PROD_END_WGT+V_SHIP_END_WGT))
- {
- V_ORD_PROG_CD = "F"; //生产完成
- //TL 091229 生产完成的时候,自动给出生产结束时间
- if(V_PROD_END_DATE == null || V_PROD_END_DATE.equals("")){
- V_PROD_END_DATE = currDate;
- }
- }
- //如果订单重量大于生产完成重量+发货完成重量,并且小于等于生产进行重量+生产完成重量+发货完成重量
- else if(V_WGT_ACVAL_MAX > (V_PROD_END_WGT+V_SHIP_END_WGT) && V_WGT_ACVAL_MAX <= (V_ORD_PRC_WGT + V_PROD_END_WGT + V_SHIP_END_WGT))
- {
- V_ORD_PROG_CD = "E"; //生产进行
- V_PROD_END_DATE = "";
- V_SHIP_END_DATE = "";
- }
- //如果订单重量大于生产进行重量+生产完成重量+发货完成重量,并且生产进行重量+生产完成重量+发货完成重量不等于0
- else if(V_WGT_ACVAL_MAX > (V_ORD_PRC_WGT + V_PROD_END_WGT + V_SHIP_END_WGT) && (V_ORD_PRC_WGT + V_PROD_END_WGT + V_SHIP_END_WGT)!=0)
- {
- V_ORD_PROG_CD = "E"; //生产进行
- V_PROD_END_DATE = "";
- V_SHIP_END_DATE = "";
- }
- else if((V_ORD_PRC_WGT + V_PROD_END_WGT + V_SHIP_END_WGT) == 0)//如果订单重量=订单剩余重量
- {
- if (V_STL_GRD == null || "".equals(V_STL_GRD)) //如果牌号为空
- {
- if (!V_ORD_PROG_CD.equals("C")) //如果不为待设计待机
- {
- V_ORD_PROG_CD = "A";//品质设计待机
- }
- else
- {
-
- }
- }
- else if (V_ORD_PROG_CD.compareTo("D") >= 0)
- {
- V_ORD_PROG_CD = "D";//订单投入确定
- }
- }
- }
- else//如果人工指定了订单关闭,生产完成,发货结束则不更改订单的状态,保持原状!
- {
- V_PROD_END_GP = P_PROD_END_GP;
- //V_PROD_END_DATE = P_PROD_END_DATE;
- }
-
- //UPDATE FROM TBE02_ORD_PRC
- sqlstr = XmlSqlParsersFactory.getSql("NIE042030_OrdPrc.update");
- paramArray = new ArrayList<String> ();
- paramArray.add(V_ORD_PROG_CD);
- paramArray.add(V_PROD_END_GP);
- paramArray.add(V_PROD_END_DATE);
- paramArray.add(String.valueOf(V_ORD_PRC_WGT));
- paramArray.add(String.valueOf(V_ORD_REM_WGT));
- paramArray.add(String.valueOf(V_PROD_END_WGT));
- paramArray.add(String.valueOf(V_SHIP_END_WGT));
- paramArray.add(V_SHIP_END_DATE);
- paramArray.add(P_REG_ID);
- paramArray.add(P_PGMID);
- paramArray.add(P_ORD_NO);
- paramArray.add(P_ORD_SEQ);
- cro = this.getDao("KgDao").ExcuteNonQuery(sqlstr,paramArray.toArray());
-
- // if (UpdCnt2 == 0) {
- //
- // V_TABLE_ID = "TBE02_ORD_PRC";
- // V_TABLE_MODE = "U";
- // V_ERR_DESC = "TBE02_ORD_PRC UPDATE COUNT IS ZERO";
- // V_RTN_NAME = "ReArrangeOrdSts TBE02_ORD_PRC UPDATE2 " + P_ORD_NO + P_ORD_SEQ;
- //
- // LogGpError.logMessageToDB("ReArrangeOrdSts", V_TABLE_ID, V_TABLE_MODE, V_ERR_DESC, V_RTN_NAME);
- // throw new PosException(V_RTN_NAME);
- // }
-
- //DELETE TBE02_ORD_PRC_DET TOT_WGT = 0
- sqlstr = XmlSqlParsersFactory.getSql("NIE042030_ORDPRCDET.delete");
- cro = this.getDao("KgDao").ExcuteNonQuery(sqlstr);
- }catch(Exception ex){
- throw ex;
- }
- }
- // public static void main(String args[]){
- // String ssqlstr = XmlSqlParsersFactory.getSql("NIE042030_OrdNoCk.select");
- // System.out.print(ssqlstr);
- // }
- }
|