package xin.glue.ui.G.G04; import java.math.BigDecimal; import java.sql.CallableStatement; import java.sql.SQLException; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; import org.apache.commons.lang.StringUtils; 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.component.PosConstants; 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; /** * * @auth: wangxiaoyan * @date: 2009-2-17 * @desc: 板坯尺寸修改实绩 */ public class XinSaveCorrectSlab extends PosActivity { public String runActivity(PosContext context) { String SIZE_UPDT_CAUSE_CD = "01"; // RESIZE UPDATE String[] SLAB_THK = (String[])context.get("SLAB_THK"); String[] SLAB_WTH = (String[])context.get("SLAB_WTH"); String[] SLAB_LEN = (String[])context.get("SLAB_LEN"); String[] SLAB_WGT = (String[])context.get("SLAB_WGT"); String[] SIZE_DEC_FL = (String[])context.get("SLAB_SIZE_DEC_GRD"); String[] SIZE_UPDT_WKSHIFT = (String[])context.get("REG_SHIP"); String[] SIZE_UPDT_WKGROUP = (String[])context.get("REG_GROUP"); String[] SIZE_UPDT_EMP_NO = (String[])context.get("REG_ID"); String[] SCRAP_WGT = (String[])context.get("SCRAP_WGT"); String[] SLAB_NO = (String[])context.get("SLAB_NO"); //logger.logInfo("XinSaveCorrectSlab---> SIZE_UPDT_AFT_LEN:"+SIZE_UPDT_AFT_LEN[0] ); PosParameter param1 = new PosParameter(); param1.setWhereClauseParameter(0, SLAB_NO[0]); PosRowSet slabComVo = getDao("mesdao").find("UIG040070_04.select", param1); String OrdNo = null; String OrdSeq = null; String OrdFl = null; String CurProgCd = null; String BefProgCd = null; String BefOrdNo = null; String BefOrdSeq = null; String NonOrdResCd = ""; String NonOrdResDate = ""; String slabRt = null; String oldWTH = null; String oldLen = null; String oldThk = null; String StlGrd = null; String PlnOrdNo = null; String PlnSlabNo = null; if (slabComVo.hasNext()) { PosRow slabComROW = slabComVo.next(); OrdNo = (String)slabComROW.getAttribute("ORD_NO"); OrdSeq = (String)slabComROW.getAttribute("ORD_SEQ"); CurProgCd = (String)slabComROW.getAttribute("CUR_PROG_CD"); OrdFl = (String)slabComROW.getAttribute("ORD_FL"); slabRt = (String)slabComROW.getAttribute("SLAB_RT"); oldWTH = (String)slabComROW.getAttribute("SLAB_WTH"); oldLen = (String)slabComROW.getAttribute("SLAB_LEN"); oldThk = (String)slabComROW.getAttribute("SLAB_THK"); StlGrd = (String)slabComROW.getAttribute("LG_STL_GRD"); PlnSlabNo = (String)slabComROW.getAttribute("PLAN_SLAB_NO"); } if(CurProgCd.equals("RBB")){ context.put("MESSAGES", " 已经编入轧制计划,轧制吊销后才能修改! "); return PosBizControlConstants.SUCCESS; } if(SLAB_LEN == null || StringUtils.isBlank(SLAB_LEN[0]) || "0".equals(SLAB_LEN[0])){ context.put("MESSAGES", "长度为空或不允许将板坯长度改为0!"); return PosBizControlConstants.SUCCESS; } if(SLAB_WGT == null || StringUtils.isBlank(SLAB_WGT[0]) || "0".equals(SLAB_WGT[0])){ context.put("MESSAGES", " 理重为空或不允许将板坯理重改为0!"); return PosBizControlConstants.SUCCESS; } BefProgCd = CurProgCd; PosParameter param = new PosParameter(); PosRowSet rowset = null; PosRow row = null; PosGenericDao dao = getDao("mesdao"); String sql = "SELECT ORD_NO FROM TBF01_SPEC_SLAB T WHERE SLAB_MANA_NO = ?"; param = new PosParameter(); param.setWhereClauseParameter(0, PlnSlabNo); rowset = dao.findByQueryStatement(sql, param); if(rowset.hasNext()){ row = rowset.next(); PlnOrdNo = (String)row.getAttribute("ORD_NO"); } if(slabRt != null && (slabRt.equals("Z")||slabRt.equals("P"))){ if(PlnOrdNo != null && ("76".equals(PlnOrdNo.substring(0,2)) || "77".equals(PlnOrdNo.substring(0,2)) || "16".equals(PlnOrdNo.substring(0,2)))){ if("1".equals(OrdFl)) CurProgCd = "RGB"; else if("W/Q".equals(StlGrd.substring(0,3))) CurProgCd = "RRC"; else CurProgCd = "RGB"; }else CurProgCd = "RGB"; }else{ CurProgCd = "RRC"; //板坯充当待机 } /*String sql = "SELECT COILSTAT(T.SLAB_NO) STAT_FLAG FROM TBG02_SLAB_COMM T WHERE T.SLAB_NO = ?"; param = new PosParameter(); param.setWhereClauseParameter(0, SLAB_NO[0]); PosRowSet rowset = this.getDao("mesdao").findByQueryStatement(sql, param); if (rowset.hasNext())//查询库存信息 已出库板坯不允许改尺 { PosRow row = rowset.next(); String stat = (String)row.getAttribute("STAT_FLAG");// if("出库".equals(stat)){ context.put("MESSAGES", SLAB_NO[0] + "板坯已出炼钢库,不允许进行改尺操作,请核实"); return PosBizControlConstants.SUCCESS; } }*/ if (OrdFl.equals("1")) { NonOrdResCd = "3A"; DateFormat formatter = new SimpleDateFormat("yyyyMMddHHmmss"); NonOrdResDate = formatter.format(new Date()); } OrdFl = "2"; BefOrdNo = OrdNo; BefOrdSeq = OrdSeq; OrdNo = null; OrdSeq = null; if(SLAB_NO.length > 0){ //增加降级历史记录 20101227 wxy CallableStatement cstm = null; param = new PosParameter(); try{ cstm = this.getDao("mesdao").getCallableStatement("ORD_HIS_INSERT.call"); cstm.setString(1, "B"); cstm.setString(2, "S"); cstm.setString(3, ""); cstm.setString(4, "UIG040070"); cstm.setString(5, ""); cstm.setString(6, ""); cstm.setString(7, ""); cstm.setString(8, SLAB_NO[0]); cstm.setString(9, "TM"); cstm.setString(10, ""); cstm.setString(11, ""); cstm.setString(12, ""); cstm.setString(13, ""); cstm.execute(); }catch(Exception ex){ logger.logError(ex.getMessage(), ex); }finally{ if (cstm != null) { try { cstm.close(); } catch (SQLException e) { logger.logWarn(e.getMessage(), e); } } } //end 增加降级历史记录 //解决理重可能会出现空值的问题 if(StringUtils.isBlank(SLAB_WGT[0])){ SLAB_WGT[0] = Math.round(Double.parseDouble(SLAB_THK[0]) * Double.parseDouble(SLAB_WTH[0]) * Double.parseDouble(SLAB_LEN[0]) * 7.85 / 1000000) + ""; } param.setWhereClauseParameter(0, SIZE_UPDT_CAUSE_CD); param.setWhereClauseParameter(1, SLAB_THK[0]); param.setWhereClauseParameter(2, SLAB_WTH[0]); param.setWhereClauseParameter(3, SLAB_LEN[0]); param.setWhereClauseParameter(4, SLAB_WGT[0]); param.setWhereClauseParameter(5, SLAB_THK[0]); param.setWhereClauseParameter(6, SLAB_WTH[0]); param.setWhereClauseParameter(7, SLAB_LEN[0]); param.setWhereClauseParameter(8, SLAB_WGT[0]); param.setWhereClauseParameter(9, SIZE_UPDT_WKSHIFT[0]); param.setWhereClauseParameter(10, SIZE_UPDT_WKGROUP[0]); param.setWhereClauseParameter(11, SIZE_UPDT_EMP_NO[0]); param.setWhereClauseParameter(12, SCRAP_WGT[0]); param.setWhereClauseParameter(13, NonOrdResCd); param.setWhereClauseParameter(14, NonOrdResDate); param.setWhereClauseParameter(15, CurProgCd); param.setWhereClauseParameter(16, SIZE_DEC_FL[0]); param.setWhereClauseParameter(17, SLAB_NO[0]); /*在热轧原料区域当修改铸坯厚度和宽度信息时铸坯重量不变,长度变化时重量一定改变 * 在炼钢区域改任何规格都掉磅重*/ if(!SLAB_LEN[0].equals(oldLen)){ this.getDao("mesdao").update("UIG040070_SIZE_CORRECT_02.update", param); }else{ this.getDao("mesdao").update("UIG040070_SIZE_CORRECT_02_01.update", param); } /*if(SLAB_THK[0].equals("230")){//针对热轧料该规格做单独处理 if(!SLAB_WTH[0].equals(oldWTH)){//宽度发生变化的进行判断是否清除磅重 if(SLAB_LEN[0].equals(oldLen)){//定尺不变只改宽度则不删除磅重 this.getDao("mesdao").update("UIG040070_SIZE_CORRECT_02_01.update", param); }else{ this.getDao("mesdao").update("UIG040070_SIZE_CORRECT_02.update", param); } }else{ this.getDao("mesdao").update("UIG040070_SIZE_CORRECT_02.update", param); } }else{ this.getDao("mesdao").update("UIG040070_SIZE_CORRECT_02.update", param); }*/ /*//经计量部门与张卫协调后统一出库板坯修改定尺不改磅重 int flag = 0; PosRowSet rowset = null; PosRow row = null; PosParameter paramx = new PosParameter(); paramx.setWhereClauseParameter(0, SLAB_NO[0]); rowset = this.getDao("mesdao").findByQueryStatement("SELECT COILSTAT(?) KC FROM DUAL", paramx); if (rowset.hasNext()) { row = rowset.next(); String kc = (String)row.getAttribute("KC"); if("在库".equals(kc)) flag = 0; else flag = 1; } if(flag == 1)//不在库修改规格则不改磅重不改理重 this.getDao("mesdao").update("UIG040070_SIZE_CORRECT_02_01.update", param); else{ if(!SLAB_WTH[0].equals(oldWTH)){//宽度发生变化的进行判断是否清除磅重 if(SLAB_LEN[0].equals(oldLen)){//定尺不变只改宽度则不删除磅重 this.getDao("mesdao").update("UIG040070_SIZE_CORRECT_02_01.update", param); }else{ this.getDao("mesdao").update("UIG040070_SIZE_CORRECT_02.update", param); } }else{ this.getDao("mesdao").update("UIG040070_SIZE_CORRECT_02.update", param); } //this.getDao("mesdao").update("UIG040070_SIZE_CORRECT_02.update", param); } */ PosParameter paramz = new PosParameter(); paramz.setValueParamter(0, OrdFl); paramz.setValueParamter(1, SLAB_NO[0]); this.getDao("mesdao").update("UIG040070_SLAB_COMM_D.update",paramz); if (NonOrdResCd != null && !NonOrdResCd.equals("") ) { BigDecimal SlabWgt = new BigDecimal(SLAB_WGT[0]); SendProg_NIE012070(SLAB_NO[0],OrdNo,OrdSeq,BefOrdNo,BefOrdSeq,CurProgCd,BefProgCd,"TM",SlabWgt); SendProg_NIE012080(); } /*财务数据上抛*/ cstm = null; try { cstm = this.getDao("mesdao").getCallableStatement("UPLOAD_DATA.CAL"); cstm.setString(1, SLAB_NO[0]); cstm.setString(2, "11AA"); cstm.setString(3, "N"); cstm.setString(4, "板坯改尺"); cstm.setString(5, SIZE_UPDT_EMP_NO[0]); cstm.registerOutParameter(6, java.sql.Types.VARCHAR); cstm.execute(); String err = cstm.getString(6); if(!org.apache.commons.lang.StringUtils.isBlank(cstm.getString(6))){ context.put("MESSAGES","数据上传失败:" + err); return PosBizControlConstants.SUCCESS; } }catch(Exception ex){ ex.printStackTrace(); context.put("MESSAGES","Exception:" + ex.getMessage()); return PosBizControlConstants.SUCCESS; } finally{ if(cstm != null){ try{ cstm.close(); }catch(Exception e) { e.printStackTrace(); } } } } context.put("MESSAGES", " 修改成功! "); return PosBizControlConstants.SUCCESS; } public PosContext SendProg_NIE012070(String MatNo,String sOrdNo,String sOrdSeq,String sBefOrdNo,String sBefOrdSeq,String sProgCd,String BefProcCd,String sKind,BigDecimal nwgt ) { PosContext context = new PosContext(); PosMessage message = new PosMESMessageImpl(); String TcId = "NIE012070"; message.setTCID(TcId); message.setObject("MSG_ID",TcId); message.setObject("BEF_ORD_NO",sBefOrdNo); message.setObject("BEF_ORD_SEQ",sBefOrdSeq); message.setObject("ORD_NO",sOrdNo); message.setObject("ORD_SEQ",sOrdSeq); message.setObject("BEF_PROG_CD",BefProcCd); message.setObject("PROG_CD",sProgCd); message.setObject("MAT_TYPE",sKind); message.setObject("MAT_NO",MatNo); message.setObject("WGT", nwgt ); message.setObject("PGMID","slabSizeCorrect"); message.setObject("REG_ID","UIG040070"); message.setTCID(TcId); context.setMessage(message); // this.processComponent(PosConstants.CREATE_MESSAGE, context); // String transactionCode = context.getMessage().getTC(); String SERVICE_POSTFIX = "-service"; context.put(PosBizControlConstants.SERVICE_NAME, TcId + SERVICE_POSTFIX); // context.setMessage(message); PosBizControlIF controller = PosBizProvider.getController(); controller.doSubController(context,false); return null; } public void 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); context.setMessage(message); this.processComponent(PosConstants.CREATE_MESSAGE, context); String transactionCode = context.getMessage().getTC(); message.setTCID(TcId); 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); } }