package xin.glue.ui.G.G02; import java.math.BigDecimal; import java.sql.CallableStatement; import java.sql.SQLException; import com.posdata.glue.PosException; 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; public class PosUpdateCutSchedu extends PosActivity { public String runActivity(PosContext context) { logger.logInfo("PosUpdateCutSchedu start"); CallableStatement cstm = null; PosGenericDao dao = this.getDao("mesdao"); String P_RTN_MSG = ""; String[] rowStatus = (String[]) context.get("rowStatus"); String[] CHK = (String[]) context.get("CHK"); String[] SLAB_NO = (String[]) context.get("SLAB_NO"); String[] sMoveFl = (String[])context.get("MoveFl"); String[] ChargeNo = (String[])context.get("NxtChargeNo"); //获取移动之前 后一炉次的切割计划信息 String[] orlPlanChargeNo = new String[40]; String[] orlPlanSlabNo = null; String[] orlCastNo = null; BigDecimal[] orlCastChargeSeq = null; BigDecimal[] orlCastChargeCnt = null; String[] orlStlGrd = null; String[] orlSpecAbbsym = null; BigDecimal[] orlSlabThk = null; BigDecimal[] orlSlabWth = null; BigDecimal[] orlSlabLen = null; String[] orlHcrClf = null; String oralInsCharge = null; if(sMoveFl[0].equals("I")){ oralInsCharge = "3" + SLAB_NO[0].substring(1, 10); }else if(sMoveFl[0].equals("D")){ oralInsCharge = "3" + ChargeNo[0].substring(1, 10); }else{ context.put("MESSAGES", "ERRORS"); return PosBizControlConstants.SUCCESS; } logger.logInfo("NxtChargeNo --" + oralInsCharge); PosParameter para = new PosParameter(); para.setWhereClauseParameter(0, oralInsCharge); PosRowSet orlChargeRowSet = getDao("mesdao").find("UIG020061_ORAL_CHARGE_NO.select", para); if(!(orlChargeRowSet.hasNext())){ context.put("MESSAGES"," 移动炉号有错!"); return PosBizControlConstants.SUCCESS; } String fst = SLAB_NO[0].substring(0, 10) + "010"; String scd = ChargeNo[0] + "010"; para = new PosParameter(); para.setWhereClauseParameter(0, fst); para.setWhereClauseParameter(1, scd); PosRowSet rowset = getDao("mesdao").find("UIG020061_REPLACE_CHECK.select", para); if(!(rowset.hasNext())){ context.put("MESSAGES","ERROR"); return PosBizControlConstants.SUCCESS; } String sSlabCnt = null; String sSlabNo[] = new String[9]; String sChargeNo = null; String sReturnCd = null; String sReturnMsg = null; String orlChargeNo = null; sChargeNo = ChargeNo[0]; int tempTag = 0; if(rowStatus.length > 9){ context.put("MESSAGES","ERRORS"); return "SUCCESS"; } for(int i = 0 ; i < rowStatus.length ; i++){ if(CHK[i].equals("N"))continue; if(SLAB_NO[i] == null && SLAB_NO[i].equals("")){ return "SUCCESS"; } sSlabNo[i] = SLAB_NO[i]; tempTag++; orlChargeNo = SLAB_NO[i].substring(0,10); } sSlabCnt = tempTag + ""; for(int i = 0 ; i < sSlabNo.length ; i++){ if(sSlabNo[i]== null)sSlabNo[i] = ""; } System.out.println(sMoveFl[0] + "----" + sSlabCnt + "----" +sChargeNo); System.out.println(sSlabNo[0] + "----" + sSlabNo[1] + "----" +sSlabNo[2]); System.out.println(sSlabNo[3] + "----" + sSlabNo[4] + "----" +sSlabNo[5]); System.out.println(sSlabNo[6] + "----" + sSlabNo[7] + "----" +sSlabNo[8]); try{ cstm = dao.getCallableStatement("NIG020061_01.CALLSTATEMENT"); cstm.setString(1, sMoveFl[0]); cstm.setString(2, sSlabCnt); cstm.setString(3, sSlabNo[0]); cstm.setString(4, sSlabNo[1]); cstm.setString(5, sSlabNo[2]); cstm.setString(6, sSlabNo[3]); cstm.setString(7, sSlabNo[4]); cstm.setString(8, sSlabNo[5]); cstm.setString(9, sSlabNo[6]); cstm.setString(10, sSlabNo[7]); cstm.setString(11, sSlabNo[8]); cstm.setString(12, sChargeNo); cstm.registerOutParameter(13, java.sql.Types.VARCHAR); cstm.registerOutParameter(14, java.sql.Types.VARCHAR); cstm.execute(); sReturnCd = cstm.getString(13); sReturnMsg = cstm.getString(14); System.out.println("------------> " + sReturnCd + "-----------" + sReturnMsg); }catch(Exception ex){ logger.logError(ex.getMessage(), ex); }finally { if (cstm != null) { try { cstm.close(); } catch (SQLException e) { logger.logWarn(e.getMessage(), e); } } } if(sMoveFl[0].equals("I")){ PosParameter param = new PosParameter(); // 移动的板坯块数 插入到前一炉最后 int moveSlabCnt = getDao("mesdao").insert("UIG020061_SLAB_CUT_INS_01.insert", param); //后一炉次切割信息修改 getDao("mesdao").insert("UIG020061_SLAB_CUT_INS_02.insert", param); for(int i = 0 ; i < moveSlabCnt ; i++){ PosRow orlCharRow = orlChargeRowSet.next(); param = new PosParameter(); param.setValueParamter(0, (String)orlCharRow.getAttribute("CHARGE_MANA_NO")); param.setValueParamter(1, "3" + ((String)orlCharRow.getAttribute("SLAB_MANA_NO")).substring(1, 13)); param.setValueParamter(2, (String)orlCharRow.getAttribute("CAST_MANA_NO")); param.setValueParamter(3, (BigDecimal)orlCharRow.getAttribute("CAST_EDT_CHARGE_CNT")); param.setValueParamter(4, (BigDecimal)orlCharRow.getAttribute("CAST_CHARGE_SEQ")); param.setValueParamter(5, (String)orlCharRow.getAttribute("STL_GRD")); param.setValueParamter(6, (String)orlCharRow.getAttribute("SPEC_ABBSYM")); param.setValueParamter(7, (BigDecimal)orlCharRow.getAttribute("SLAB_THK")); param.setValueParamter(8, (BigDecimal)orlCharRow.getAttribute("SLAB_WTH")); param.setValueParamter(9, (BigDecimal)orlCharRow.getAttribute("SLAB_LEN")); param.setValueParamter(10, (String)orlCharRow.getAttribute("HCR_CLF")); getDao("mesdao").insert("UIG020061_SLAB_CUT_INS_03.insert", param); } }else if(sMoveFl[0].equals("D")){ PosParameter param = new PosParameter(); // 移动的板坯块数 插入到后一炉最前面 int nxtChgSlabCnt = 0; BigDecimal updtSlabCnt = null; int moveSlabCnt = getDao("mesdao").insert("UIG020061_SLAB_CUT_INS_01.insert", param); BigDecimal istSlabCnt = new BigDecimal(moveSlabCnt); param = new PosParameter(); PosRowSet slabCntRowSet = getDao("mesdao").find("UIG020061_MOVE_SLAB_CNT.select", param); if(slabCntRowSet.hasNext()){ PosRow slabCnt = slabCntRowSet.next(); nxtChgSlabCnt = ((BigDecimal)slabCnt.getAttribute("SLAB_CNT")).intValue(); logger.logInfo("-----------------BegDecimal to int slabCnt" + nxtChgSlabCnt); }else{ logger.logError(" ERRORS ------移动板坯数据错误!"); } updtSlabCnt = new BigDecimal(nxtChgSlabCnt - moveSlabCnt); logger.logInfo("---------updtSlabCnt" + updtSlabCnt + "--------istSlabCnt" + istSlabCnt); param = new PosParameter(); param.setValueParamter(0, updtSlabCnt); getDao("mesdao").insert("UIG020061_SLAB_CUT_INS_04.insert", param); param = new PosParameter(); param.setValueParamter(0, istSlabCnt); getDao("mesdao").insert("UIG020061_SLAB_CUT_INS_05.insert", param); } if(sReturnCd.equals("YY")){ String befProg = ""; BigDecimal wgt = null; PosParameter param = new PosParameter(); param.setWhereClauseParameter(0, orlChargeNo); PosRowSet rowSet = getDao("mesdao").find("UIG020061_CHARGE_COMM.select",param); if(rowSet.hasNext()){ PosRow row = rowSet.next(); befProg = (String)row.getAttribute("CUR_PROG_CD"); wgt = (BigDecimal)row.getAttribute("CHARGE_WGT"); } SendProg_NIE012070(orlChargeNo,befProg,wgt); befProg = ""; wgt = null; param = new PosParameter(); param.setWhereClauseParameter(0, orlChargeNo); rowSet = getDao("mesdao").find("UIG020061_CHARGE_COMM.select",param); if(rowSet.hasNext()){ PosRow row = rowSet.next(); befProg = (String)row.getAttribute("CUR_PROG_CD"); wgt = (BigDecimal)row.getAttribute("CHARGE_WGT"); } SendProg_NIE012070(sChargeNo,befProg,wgt); SendProg_NIE012080(); } context.put("MESSAGES",sReturnCd); return PosBizControlConstants.SUCCESS; } public PosContext SendProg_NIE012070(String ChargeNo,String BefProg,Number wgt ) { logger.logInfo("XinSaveBofResult wgt:"+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","JBB"); message.setObject("PROG_CD","JBF"); message.setObject("MAT_TYPE","CH"); message.setObject("MAT_NO",ChargeNo); message.setObject("WGT", wgt ); message.setObject("PGMID","XinSaveBoFResult"); message.setObject("REG_ID","LEVEL2"); message.setTCID(TcId); context.setMessage(message); // this.processComponent(PosConstants.CREATE_MESSAGE, context); // String transactionCode = context.getMessage().getTC(); String serviceName = "NIE012070"; 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---> 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; } }