package xin.glue.ui.G.G04; import java.sql.CallableStatement; import java.text.SimpleDateFormat; import java.util.Date; import org.apache.commons.lang.StringUtils; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.posdata.glue.biz.activity.PosActivity; import com.posdata.glue.biz.constants.PosBizControlConstants; 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; public class XinForceMoveSalb extends PosActivity { public String runActivity(PosContext context) { YardHandle yardhand = new YardHandle(getDao("mesdao")); String[]fromAddr = (String[])context.get("fromAddr"); String[]toAddr = (String[])context.get("toAddr"); String[]slabNo = (String[])context.get("fstSlab"); JSONObject hm = new JSONObject(); JSONArray hmList = new JSONArray(); if(fromAddr[0].equals("")||toAddr[0].equals("")||slabNo[0].equals("")){ context.put("MESSAGES", " 板坯号,地址不能为空 "); return PosBizControlConstants.SUCCESS; } String storelay = null; int lay = 0; if(yardhand.chekStorelay(toAddr[0])){ lay = yardhand.getStorelay(toAddr[0]); }else{ context.put("MESSAGES"," 垛位错误 或则已经放满,不能超过16块! "); return PosBizControlConstants.SUCCESS; } if(lay > 6){ context.put("MESSAGES", " 台车垛位层数最大不得超过6层,移库失败"); return PosBizControlConstants.SUCCESS; } PosParameter param1 = new PosParameter(); param1 = new PosParameter(); param1.setWhereClauseParameter(0, slabNo[0]); PosRowSet rowSet = getDao("mesdao").find("UIG040061_MOVEALBE_SLAB.select", param1); while(rowSet.hasNext()){ PosRow row = rowSet.next(); String slabStat = (String)row.getAttribute("SLAB_STAT"); String missionClf = (String)row.getAttribute("MISSNO_CLF"); String lstIngrCd = (String)row.getAttribute("LST_INGR_CD"); String slabIngrGrd = (String)row.getAttribute("SLAB_INGR_DEC_GRD"); String slabTotDecGrd = (String)row.getAttribute("SLAB_TOT_DEC_GRD"); if(slabStat.equals("3")){ context.put("MESSAGES", " 板坯状态已经结束! "); return PosBizControlConstants.SUCCESS; } if(!(missionClf == null)&&(missionClf.equals("3") || missionClf.equals("2"))){ context.put("MESSAGES", " 加回,轧回,吊销坯不能在此入库! "); return PosBizControlConstants.SUCCESS; } if(lstIngrCd == null){ context.put("MESSAGES", " 无成份实绩,不能入库! "); return PosBizControlConstants.SUCCESS; } System.out.println(toAddr[0].substring(0,1)); if((slabIngrGrd == null || (!slabIngrGrd.equals("1"))) && toAddr[0].substring(0,1).equals("Z")){ if(slabTotDecGrd == null || !(slabTotDecGrd.equals("1") ||slabTotDecGrd.equals("3") ||slabTotDecGrd.equals("4") ||slabTotDecGrd.equals("9"))){ context.put("MESSAGES", " 成份等级不合格,不能入库! "); return PosBizControlConstants.SUCCESS; } } if((StringUtils.isBlank(slabTotDecGrd))){ context.put("MESSAGES", " 板坯未进行综合判定,不能出库! "); return PosBizControlConstants.SUCCESS; } } hm.put("SLAB_NO", slabNo[0]); hm.put("LAYER", lay); hmList.add(hm); if(lay < 10){ storelay = "0" + lay; }else{ storelay = "" + lay; } int updateCnt = yardhand.clearFromAddrBySlabNo(slabNo[0]); int updateCnt2 = yardhand.setToAddr(slabNo[0],fromAddr[0],"",toAddr[0],storelay,"",""); int updateCnt3 = yardhand.setEntSlabComm(slabNo[0], toAddr[0], storelay,"2"); logger.logDebug("---------" + updateCnt + " updateCnt2= " + updateCnt2 + " uddateCnt3 = " + updateCnt3); String activityId = "",AppId = "",Exeejob = ""; int flag = 1; PosParameter param = new PosParameter(); PosGenericDao dao = getDao("mesdao"); //入热轧原料库 if( (fromAddr[0].substring(0,1).equals("L") || (fromAddr[0].substring(0,1).equals("H") && !fromAddr[0].equals("H516")) || fromAddr[0].substring(0,2).equals("A0") || fromAddr[0].substring(0,2).equals("C0"))//在库跺位 //出库跺位 && (toAddr[0].substring(0,1).equals("Z") || toAddr[0].substring(0,1).equals("T") || toAddr[0].equals("H516")) ){ activityId = "55A"; AppId = "板坯入热轧库"; Exeejob = "N"; flag = 0; //配重自动审核 CallableStatement cstm = null; try { cstm = this.getDao("mesdao").getCallableStatement("WEIGHT_CHECK.CAL"); cstm.setString(1, slabNo[0]); cstm.registerOutParameter(2, java.sql.Types.VARCHAR); cstm.execute(); //String err = cstm.getString(2); }catch(Exception ex){ ex.printStackTrace(); } finally{ if(cstm != null){ try{ cstm.close(); }catch(Exception e) { e.printStackTrace(); } } } } //退库 if( (fromAddr[0].substring(0,1).equals("T") || fromAddr[0].equals("H516") || fromAddr[0].substring(0,1).equals("Z")) && ((toAddr[0].substring(0,1).equals("L") || (toAddr[0].substring(0,1).equals("H") && !toAddr[0].substring(0,1).equals("H516")) || toAddr[0].substring(0,2).equals("A0") || toAddr[0].substring(0,2).equals("C0"))) ){ activityId = "55A"; AppId = "板坯退热轧库"; Exeejob = "D"; flag = 0; } if(flag == 0){ /*财务数据上抛*/ CallableStatement cstm = null; try { cstm = this.getDao("mesdao").getCallableStatement("UPLOAD_DATA.CAL"); cstm.setString(1, slabNo[0]); cstm.setString(2, activityId); cstm.setString(3, Exeejob); cstm.setString(4, AppId); cstm.setString(5, "3qrlzbp003_new"); 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(); } } } } //将数据发给1580系统 //Z跺位回台车发送O if( fromAddr[0].substring(0,1).equals("Z") && toAddr[0].substring(0,1).equals("T")){ Exeejob = "D"; } param = new PosParameter(); param.setWhereClauseParameter(0, Exeejob.equals("N")?"I":"O");//SLAB_NO param.setWhereClauseParameter(1, hmList.toString()); param.setWhereClauseParameter(2, new SimpleDateFormat("yyyyMMddHHmmss").format(new Date())); dao.update("UIG04COMM_MEWM02.insert", param); context.put("MESSAGES", " 移送成功! "); return PosBizControlConstants.SUCCESS; } }