package xin.glue.ui.G.G02; import java.math.BigDecimal; import com.posdata.glue.biz.activity.PosActivity; import com.posdata.glue.biz.constants.PosBizControlConstants; import com.posdata.glue.biz.control.PosBizControlIF; import com.posdata.glue.biz.control.PosBizProvider; import com.posdata.glue.context.PosContext; import com.posdata.glue.dao.PosGenericDao; import com.posdata.glue.dao.vo.PosParameter; import com.posdata.glue.dao.vo.PosRow; import com.posdata.glue.dao.vo.PosRowSet; import com.posdata.glue.msg.PosMESMessageImpl; import com.posdata.glue.msg.PosMessage; /** * RH实绩查询后,按CHARGE_NO执行插入或更新操作 * * @author 梅贵平 * @date 2008-9-1 */ public class PosSaveRhResult extends PosActivity { public String runActivity(PosContext context) { String[]rowStutsFlag = (String[]) context.get("rowStutsFlag");//标记是否更新或插入BOF实绩(原料实绩除外) PosGenericDao dao = this.getDao("mesdao");// 获得数据访问对象 /* * rowStutsFlag若存在,即可以:若按CHARGE_NO查询出TBG02_BOF_RESULT中无该记录(即count为0), * 则执行插入语句, 否则执行更新语句 */ if(rowStutsFlag!=null&& rowStutsFlag.length>0) { String sql = "SELECT CHARGE_NO FROM TBG02_RH_RESULT WHERE CHARGE_NO = ?"; String[] CHARGE_NO = (String[]) context.get("CHARGE_NO"); String[] PLAN_CHARGE_NO = (String[]) context.get("PLAN_CHARGE_NO"); PosParameter posparam = new PosParameter(); posparam.setWhereClauseParameter(0, CHARGE_NO[0]); PosRowSet rowset = dao.findByQueryStatement(sql, posparam); int count = rowset.count(); PosParameter param = new PosParameter(); String[] XIN_DATE = (String[])context.get("XIN_DATE");//统计日 String[] RH_NO = (String[])context.get("RH_NO"); //RH炉号 String[] WKSHIFT = (String[])context.get("WKSHIFT");//班次 String[] WKGROUP = (String[])context.get("WKGROUP");//组 String[] EMP_ID = (String[])context.get("EMP_ID");//作业人 String[] ARRV_WGT = (String[])context.get("ARRV_WGT");//到达总重量 String[] RH_TREAT_WGT = (String[])context.get("RH_TREAT_WGT");//RH处理重量 String[] STEAM_USE_WGT= (String[])context.get("STEAM_USE_WGT");//蒸汽使用量 String[] AR_WGT = (String[])context.get("AR_WGT");//Ar 用量 String[] O2_WGT = (String[])context.get("O2_WGT");//O2 用量 String[] N2_WGT = (String[])context.get("N2_WGT");//N2 用量 String[] RH_DEP_TEMP = (String[])context.get("RH_DEP_TEMP");//出发温度 String PlanChNo = null; if (PLAN_CHARGE_NO[0] == null || PLAN_CHARGE_NO[0].equals("")) { PlanChNo = '3'+CHARGE_NO[0].substring(1,10); } else { PlanChNo = PLAN_CHARGE_NO[0]; } PosParameter paramA = new PosParameter(); paramA.setWhereClauseParameter(0, PlanChNo); PosRowSet L2Send = this.getDao("mesdao").find("UIG020020_L2_SEND_CHARGE.select", paramA); if(!L2Send.hasNext()){ return PosBizControlConstants.SUCCESS; } //若按CHARGE_NO查询出TBG02_RH_RESULT中无该记录(即count为0),则执行插入语句 否则执行更新语句 if(count==0) { param.setValueParamter(0, CHARGE_NO[0]); param.setValueParamter(1, XIN_DATE[0]); param.setValueParamter(2, RH_NO[0]); param.setValueParamter(3, WKSHIFT[0]); param.setValueParamter(4, WKGROUP[0]); param.setValueParamter(5, EMP_ID[0]); param.setValueParamter(6, ARRV_WGT[0]); param.setValueParamter(7, RH_TREAT_WGT[0]); param.setValueParamter(8, STEAM_USE_WGT[0]); param.setValueParamter(9, AR_WGT[0]); param.setValueParamter(10, O2_WGT[0]); param.setValueParamter(11, N2_WGT[0]); param.setValueParamter(12, RH_DEP_TEMP[0]); param.setValueParamter(13, PLAN_CHARGE_NO[0]); dao.insert("UIG020040_01.insert", param); String STATUS_CD = null; paramA = new PosParameter(); paramA.setWhereClauseParameter(0, PlanChNo); PosRowSet specChVo = this.getDao("mesdao").find("NIG020200_SPEC_CHARGE.select", paramA); if (specChVo.hasNext()) { PosRow specChROW = specChVo.next(); STATUS_CD = (String) specChROW.getAttribute("STATUS_CD"); } if (STATUS_CD == null || (STATUS_CD != null && (STATUS_CD.equals("A") || STATUS_CD.equals("B")))) { //PosParameter param5 = new PosParameter(); //String sProgCd = "JRF"; //param5.setValueParamter(0, sProgCd); //param5.setValueParamter(1, "B"); //param5.setValueParamter(2, PlanChNo); PosParameter param6 = new PosParameter(); param6.setValueParamter(0, "B"); param6.setValueParamter(1, PlanChNo); this.getDao("mesdao").update("NIG020200_SPEC_PROG_02.update", param6); this.getDao("mesdao").update("NIG020200_SPEC_CHARGE_IDX.update", param6); if(STATUS_CD == null||(STATUS_CD != null&& STATUS_CD.equals("A"))){ getDao("mesdao").update("NIG020610_SPEC_SLAB.update", param6); PosParameter param7 = new PosParameter(); param7.setWhereClauseParameter(0, PlanChNo); PosRowSet specslabVo = this.getDao("mesdao").find( "NIG020210_SPEC_SLAB.select", param7); while (specslabVo.hasNext()) { PosRow specslabROW = specslabVo.next(); Number SlabEdtSeq = (Number) specslabROW .getAttribute("SLAB_EDT_SEQ"); PosParameter param8 = new PosParameter(); param8.setValueParamter(0, "B"); param8.setValueParamter(1, SlabEdtSeq); this.getDao("mesdao").update( "NIG020610_SPEC_SLAB_D.update", param8); } } } } else { param.setWhereClauseParameter(0, XIN_DATE[0]); param.setWhereClauseParameter(1, RH_NO[0]); param.setWhereClauseParameter(2, WKSHIFT[0]); param.setWhereClauseParameter(3, WKGROUP[0]); param.setWhereClauseParameter(4, EMP_ID[0]); param.setWhereClauseParameter(5, ARRV_WGT[0]); param.setWhereClauseParameter(6, RH_TREAT_WGT[0]); param.setWhereClauseParameter(7, STEAM_USE_WGT[0]); param.setWhereClauseParameter(8, AR_WGT[0]); param.setWhereClauseParameter(9, O2_WGT[0]); param.setWhereClauseParameter(10, N2_WGT[0]); param.setWhereClauseParameter(11, RH_DEP_TEMP[0]); param.setWhereClauseParameter(12, PLAN_CHARGE_NO[0]); param.setWhereClauseParameter(13, CHARGE_NO[0]); dao.update("UIG020040_01.update", param); } BigDecimal TapWgt = null; if(RH_TREAT_WGT[0] == null || RH_TREAT_WGT[0].equals("")) { TapWgt = new BigDecimal(0); } else { TapWgt = new BigDecimal(RH_TREAT_WGT[0]) ; } saveMaster(CHARGE_NO[0],PlanChNo,TapWgt,RH_NO[0]); } //对 铁合金记录执行更新或录入 String []rowStuts4 =(String[]) context.get("rowStuts4");//UIG020040页面铁合金表传过来的值 if(rowStuts4!=null)//判断是否需对铁合金记录执行更新或录入 { String[]MAINRAW_CD = (String[])context.get("MAINRAW_CD");//铁合金CODE //String[]MAINRAW_CD_DESC = (String[])context.get("MAINRAW_CD_DESC");//铁合金CODE内容 String[]MAINRAW_WGT = (String[])context.get("MAINRAW_WGT");//铁合金用量 String[]CHARGE_NO = (String[])context.get("CHARGE_NO");//炉次号 for(int i=0; i < rowStuts4.length; i++) { PosParameter param1 = new PosParameter(); param1.setWhereClauseParameter(0, CHARGE_NO[0]); param1.setWhereClauseParameter(1, MAINRAW_CD[i]); PosRowSet scrapVo = this.getDao("mesdao").find("NIG020330_02.select", param1); if (scrapVo.hasNext()) { PosParameter param2 = new PosParameter(); param2.setValueParamter(0, MAINRAW_WGT[i] ); param2.setValueParamter(1, CHARGE_NO[0] ); param2.setValueParamter(2, MAINRAW_CD[i] ); this.getDao("mesdao").update("NIG020330_01.update", param2); } else { PosParameter param2 = new PosParameter(); param2.setValueParamter(0, CHARGE_NO[0] ); param2.setValueParamter(1, MAINRAW_CD[i] ); param2.setValueParamter(2, MAINRAW_WGT[i]); this.getDao("mesdao").update("NIG020330_01.insert", param2); } } } // 辅料数据更新或插入 String []rowStuts5 =(String[]) context.get("rowStuts5"); if(rowStuts5!=null) { String[]MAINRAW_CD = (String[])context.get("MAINRAW_CD"); //String[]MAINRAW_CD_DESC = (String[])context.get("MAINRAW_CD_DESC"); String[]MAINRAW_WGT = (String[])context.get("MAINRAW_WGT"); String[]CHARGE_NO = (String[])context.get("CHARGE_NO"); for(int i=0; i < rowStuts5.length; i++) { PosParameter param1 = new PosParameter(); param1.setWhereClauseParameter(0, CHARGE_NO[0]); param1.setWhereClauseParameter(1, MAINRAW_CD[i]); PosRowSet scrapVo = this.getDao("mesdao").find("NIG020330_02.select", param1); if (scrapVo.hasNext()) { PosParameter param2 = new PosParameter(); param2.setValueParamter(0, MAINRAW_WGT[i] ); param2.setValueParamter(1, CHARGE_NO[0] ); param2.setValueParamter(2, MAINRAW_CD[i] ); this.getDao("mesdao").update("NIG020330_01.update", param2); } else { PosParameter param2 = new PosParameter(); param2.setValueParamter(0, CHARGE_NO[0] ); param2.setValueParamter(1, MAINRAW_CD[i] ); param2.setValueParamter(2, MAINRAW_WGT[i]); this.getDao("mesdao").update("NIG020330_01.insert", param2); } } } return PosBizControlConstants.SUCCESS; } public void saveMaster(String ChargeNo,String PlanChNo,BigDecimal wgt,String rhNo) { String PRODNM_CD = null; String STL_GRD = null; String LINE_PROC_CD = null; String HCR_CLF = null; String SPEC_ABBSYM = null; String CAST_MANA_NO = null; Number CAST_CHARGE_SEQ = null; String CHARGE_MANA_NO = null; Number CAST_EDT_CHARGE_CNT = null; PosParameter paramA = new PosParameter(); paramA.setWhereClauseParameter(0, PlanChNo); PosRowSet specChVo = this.getDao("mesdao").find("NIG020200_SPEC_CHARGE.select", paramA); if (specChVo.hasNext()) { PosRow specChROW = specChVo.next(); PRODNM_CD = (String)specChROW.getAttribute("PRODNM_CD"); STL_GRD = (String)specChROW.getAttribute("STL_GRD"); LINE_PROC_CD = (String)specChROW.getAttribute("LINE_PROC_CD"); HCR_CLF = (String)specChROW.getAttribute("HCR_CLF"); SPEC_ABBSYM = (String)specChROW.getAttribute("SPEC_ABBSYM"); CAST_MANA_NO = (String)specChROW.getAttribute("CAST_MANA_NO"); CAST_CHARGE_SEQ = (Number)specChROW.getAttribute("CAST_CHARGE_SEQ"); CHARGE_MANA_NO = (String)specChROW.getAttribute("CHARGE_MANA_NO"); CAST_EDT_CHARGE_CNT = (Number)specChROW.getAttribute("CAST_EDT_CHARGE_CNT"); } PosParameter param8 = new PosParameter(); param8.setWhereClauseParameter(0, ChargeNo); PosRowSet chComVo = this.getDao("mesdao").find("UIG020020_CH_COM.select", param8); String BefProg = null; String CurrProg = null; String ChargeStat = null; Number TapWgt = null; if (chComVo.hasNext()) { PosRow chComROW = chComVo.next(); CurrProg = (String)chComROW.getAttribute("CUR_PROG_CD"); BefProg = (String)chComROW.getAttribute("BEF_PROG_CD"); ChargeStat = (String)chComROW.getAttribute("CHARGE_STAT"); TapWgt = (Number)chComROW.getAttribute("BOF_TAPPING_WGT"); if (ChargeStat != null && ChargeStat.equals("2")) { if (CurrProg != null) { if (CurrProg.equals("JLF")) { CurrProg = "JRF"; BefProg = "JLF"; } else if (CurrProg.equals("JRF")) { CurrProg = "JRF"; } else if (!CurrProg.equals("JJB")) { BefProg = CurrProg; CurrProg = "JRF"; } } else { CurrProg = "JRF"; BefProg = "JBB"; } PosParameter param9 = new PosParameter(); param9.setValueParamter(0, CurrProg ); param9.setValueParamter(1, "UIG020040"); param9.setValueParamter(2, TapWgt); param9.setValueParamter(3, wgt); param9.setValueParamter(4, rhNo); param9.setValueParamter(5, ChargeNo ); this.getDao("mesdao").update("UIG020040_CH_COM.update", param9); } } else { PosParameter param10 = new PosParameter(); param10.setValueParamter(0, ChargeNo ); param10.setValueParamter(1, CHARGE_MANA_NO ); param10.setValueParamter(2, STL_GRD ); param10.setValueParamter(3, PRODNM_CD ); param10.setValueParamter(4, LINE_PROC_CD ); param10.setValueParamter(5, HCR_CLF ); param10.setValueParamter(6, SPEC_ABBSYM ); param10.setValueParamter(7, CAST_MANA_NO ); param10.setValueParamter(8, CAST_CHARGE_SEQ); param10.setValueParamter(9, CAST_EDT_CHARGE_CNT); param10.setValueParamter(10, "JRF"); param10.setValueParamter(11, "UIG020040"); param10.setValueParamter(12, null); param10.setValueParamter(13, wgt); param10.setValueParamter(14, rhNo); this.getDao("mesdao").update("UIG020020_CH_COM.insert", param10); PosParameter param9 = new PosParameter(); param9.setWhereClauseParameter(0, ChargeNo); PosRowSet specSlabVo = this.getDao("mesdao").find("NIG020200_SPEC_SLAB.select", param9); while(specSlabVo.hasNext()) { PosRow SlabSpecROW = specSlabVo.next(); Number sSlabEdtSeq= (Number)SlabSpecROW.getAttribute("SLAB_EDT_SEQ"); String sPlanSlabNo= (String)SlabSpecROW.getAttribute("SLAB_MANA_NO"); String sStlGrd = (String)SlabSpecROW.getAttribute("STL_GRD"); Number sSlabThk = (Number)SlabSpecROW.getAttribute("SLAB_THK"); Number sSlabWth = (Number)SlabSpecROW.getAttribute("SLAB_WTH"); Number sSlabLen = (Number)SlabSpecROW.getAttribute("SLAB_LEN"); Number sSlabWgt = (Number)SlabSpecROW.getAttribute("SLAB_WGT"); String sProdNmCd = (String)SlabSpecROW.getAttribute("PRODNM_CD"); String sOrdFl = (String)SlabSpecROW.getAttribute("ORD_FL"); String sOrdNo = (String)SlabSpecROW.getAttribute("ORD_NO"); String sOrdSeq = (String)SlabSpecROW.getAttribute("ORD_SEQ"); String sHcrClf = (String)SlabSpecROW.getAttribute("HCR_CLF"); String sSpecAbbsym= (String)SlabSpecROW.getAttribute("SPEC_ABBSYM"); Number ORD_THK = (Number)SlabSpecROW.getAttribute("ORD_THK"); Number ORD_WTH = (Number)SlabSpecROW.getAttribute("ORD_WTH"); Number ORD_LEN = (Number)SlabSpecROW.getAttribute("ORD_LEN"); Number ORD_WGT = (Number)SlabSpecROW.getAttribute("ORD_WGT"); Number COIL_INDIA = (Number)SlabSpecROW.getAttribute("COIL_INDIA"); Number COIL_OUTDIA= (Number)SlabSpecROW.getAttribute("COIL_OUTDIA"); String sSlabSeq = sPlanSlabNo.substring(10,13); String sSlabNo = ChargeNo+sSlabSeq; PosParameter param1 = new PosParameter(); param1.setWhereClauseParameter(0, sSlabNo); PosRowSet CreatSlabVo = getDao("mesdao").find("NIG020200_CREATE_SLAB.select", param1); if (!CreatSlabVo.hasNext() ) { PosParameter param2 = new PosParameter(); param2.setValueParamter(0, sSlabNo ); param2.setValueParamter(1, sPlanSlabNo ); param2.setValueParamter(2, sStlGrd ); param2.setValueParamter(3, sSlabThk ); param2.setValueParamter(4, sSlabWth ); param2.setValueParamter(5, sSlabLen ); param2.setValueParamter(6, sSlabWgt ); param2.setValueParamter(7, sProdNmCd ); param2.setValueParamter(8, sOrdFl ); param2.setValueParamter(9, sOrdNo ); param2.setValueParamter(10, sOrdSeq ); param2.setValueParamter(11, sHcrClf ); param2.setValueParamter(12, sSpecAbbsym ); param2.setValueParamter(13, sOrdFl ); param2.setValueParamter(14, sOrdNo ); param2.setValueParamter(15, sOrdSeq ); param2.setValueParamter(16, ORD_THK ); param2.setValueParamter(17, ORD_WTH ); param2.setValueParamter(18, ORD_LEN ); param2.setValueParamter(19, COIL_INDIA ); param2.setValueParamter(20, COIL_OUTDIA ); param2.setValueParamter(21, ORD_WGT ); getDao("mesdao").update("NIG020200_CREATE_SLAB.insert",param2); PosParameter param3 = new PosParameter(); param3.setWhereClauseParameter(0, sSlabEdtSeq); PosRowSet CreatSlabDVo = getDao("mesdao").find("NIG020200_SPEC_SLAB_D.select", param3); while( CreatSlabDVo.hasNext()) { PosRow CreatSlabDROW = CreatSlabDVo.next(); String S_SLAB_CUT_SEQ = (String)CreatSlabDROW.getAttribute("SLAB_CUT_SEQ"); Number S_SLAB_THK = (Number)CreatSlabDROW.getAttribute("SLAB_THK"); Number S_SLAB_WTH = (Number)CreatSlabDROW.getAttribute("SLAB_WTH"); Number S_SLAB_LEN = (Number)CreatSlabDROW.getAttribute("SLAB_LEN"); //Number S_SLAB_WGT = (Number)CreatSlabDROW.getAttribute("SLAB_WGT"); Number S_ORD_THK = (Number)CreatSlabDROW.getAttribute("ORD_THK"); Number S_ORD_WTH = (Number)CreatSlabDROW.getAttribute("ORD_WTH"); Number S_ORD_LEN = (Number)CreatSlabDROW.getAttribute("ORD_LEN"); Number S_ORD_WGT = (Number)CreatSlabDROW.getAttribute("ORD_WGT"); Number S_COIL_INDIA = (Number)CreatSlabDROW.getAttribute("COIL_INDIA"); Number S_COIL_OUTDIA = (Number)CreatSlabDROW.getAttribute("COIL_OUTDIA"); String S_ORD_NO = (String)CreatSlabDROW.getAttribute("ORD_NO"); String S_ORD_SEQ = (String)CreatSlabDROW.getAttribute("ORD_SEQ"); String S_ORD_FL = (String)CreatSlabDROW.getAttribute("ORD_FL"); PosParameter param5 = new PosParameter(); param5.setWhereClauseParameter(0, sSlabNo); PosRowSet SalbDVo = getDao("mesdao").find("NIG020200_CREATE_SLAB_D.select", param5); if (!SalbDVo.hasNext()) { PosParameter param4 = new PosParameter(); param4.setValueParamter(0, sSlabNo ); param4.setValueParamter(1, S_SLAB_CUT_SEQ ); param4.setValueParamter(2, S_SLAB_THK ); param4.setValueParamter(3, S_SLAB_WTH ); param4.setValueParamter(4, S_SLAB_LEN ); param4.setValueParamter(5, S_ORD_THK ); param4.setValueParamter(6, S_ORD_WTH ); param4.setValueParamter(7, S_ORD_LEN ); param4.setValueParamter(8, S_ORD_WGT ); param4.setValueParamter(9, S_COIL_INDIA ); param4.setValueParamter(10, S_COIL_OUTDIA ); param4.setValueParamter(11, S_ORD_NO ); param4.setValueParamter(12, S_ORD_SEQ ); param4.setValueParamter(13, S_ORD_FL ); getDao("mesdao").update("NIG020200_CREATE_SLAB_D.insert",param4); } } } } } SendProg_NIE012070(PlanChNo,BefProg,wgt); SendProg_NIE012080(); } public PosContext SendProg_NIE012070(String ChargeNo,String BefProg,BigDecimal wgt ) { // BigDecimal wgt = new BigDecimal(); PosContext context = new PosContext(); PosMessage message = new PosMESMessageImpl(); String TcId = "NIE012070"; message.setTCID(TcId); message.setObject("MSG_ID",TcId); message.setObject("BEF_ORD_NO",null); message.setObject("BEF_ORD_SEQ",null); message.setObject("ORD_NO",null); message.setObject("ORD_SEQ",null); message.setObject("BEF_PROG_CD",BefProg); message.setObject("PROG_CD","JRF"); message.setObject("MAT_TYPE","CH"); message.setObject("MAT_NO",ChargeNo); message.setObject("WGT", wgt ); message.setObject("PGMID","UIG020030"); message.setObject("REG_ID","UIG020030"); message.setTCID(TcId); context.setMessage(message); String serviceName = "NIE012070"; String SERVICE_POSTFIX = "-service"; context.put(PosBizControlConstants.SERVICE_NAME, serviceName + SERVICE_POSTFIX); PosBizControlIF controller = PosBizProvider.getController(); controller.doSubController(context,false); logger.logInfo("XinSaveBofResult---> NIE012070 TC SendProgress end" ); return null; } public PosContext SendProg_NIE012080() { logger.logInfo("XinSaveBofResult SendProg_NIE012080 " ); PosContext context = new PosContext(); PosMessage message = new PosMESMessageImpl(); String TcId = "NIE012080"; message.setTCID(TcId); message.setObject("MSG_ID",TcId); message.setObject("AA",null); message.setTCID(TcId); context.setMessage(message); // this.processComponent(PosConstants.CREATE_MESSAGE, context); // String transactionCode = context.getMessage().getTC(); String serviceName = "NIE012080"; String SERVICE_POSTFIX = "-service"; context.put(PosBizControlConstants.SERVICE_NAME, serviceName + SERVICE_POSTFIX); // context.setMessage(message); PosBizControlIF controller = PosBizProvider.getController(); controller.doSubController(context,false); logger.logInfo("XinSaveBofResult---> NIE012080 TC SendProgress end" ); return null; } }