diff --git a/mmpac/src/client/nccloud/web/mmpac/pwr/action/PwrCheckRewriteAction.java b/mmpac/src/client/nccloud/web/mmpac/pwr/action/PwrCheckRewriteAction.java index 97ad02d9..eb90102e 100644 --- a/mmpac/src/client/nccloud/web/mmpac/pwr/action/PwrCheckRewriteAction.java +++ b/mmpac/src/client/nccloud/web/mmpac/pwr/action/PwrCheckRewriteAction.java @@ -35,6 +35,7 @@ import nc.vo.mmpac.pmo.pac0002.entity.PMOItemVO; import nc.vo.mmpac.pmo.pac0002.entity.PMOPlanOutputVO; import nc.vo.mmpac.pmo.pac0002.enumeration.PMOFItemStatusEnum; import nc.vo.mmpac.pmo.parameter.PMORewriteParaVO; +import nc.vo.org.OrgVO; import nc.vo.pub.BusinessException; import nc.vo.pub.lang.UFBoolean; import nc.vo.pub.lang.UFDateTime; @@ -50,6 +51,7 @@ import nccloud.framework.web.container.IRequest; import nccloud.framework.web.json.JsonFactory; import java.util.*; +import java.util.stream.Collectors; public class PwrCheckRewriteAction implements ICommonAction { @Override @@ -60,274 +62,338 @@ public class PwrCheckRewriteAction implements ICommonAction { try { Map map2 = json.fromJson(read, Map.class); - + List pmoRewriteParaVOS=new ArrayList<>(); + Map configParams = MyHelper.getConfigParams("xb-config", null); MapList paraMapList = new MapList(); - List hidList = new ArrayList(); - hidList.add((String) map2.get("Cpmohid")); - - - PMOAggVO[] aggvos = (new PMOAggVOQueryBP()).getPMOAggVOsByIds((String[])hidList.toArray(new String[0])); - if (MMValueCheck.isEmpty(aggvos)) { - ExceptionUtils.wrappBusinessException(PMOConstLang.getMSG_REWRITE_WRNUM_AUTOERROR()); + List hidList = (List) map2.get("pmoid"); +// 直接用 Stream 去重后覆盖原变量(默认保持顺序) + hidList = Optional.ofNullable(hidList) + .orElseGet(ArrayList::new) // 空值兜底 + .stream() + .distinct() // 去重核心 + .collect(Collectors.toList()); // 收集后覆盖原变量 + List> bidlists= (List>) map2.get("pmobids"); + for (Map bmap : bidlists) { + PMORewriteParaVO pmoRewriteParaVO=new PMORewriteParaVO(); + pmoRewriteParaVO.setCpmobid(bmap.get("bid").toString()); + pmoRewriteParaVO.setCpmohid(hidList.get(0)); + pmoRewriteParaVO.setDelNum(new UFDouble(bmap.get("nbwrastnum").toString())); + pmoRewriteParaVOS.add(pmoRewriteParaVO); } + PMORewriteParaVO[] paras = PMOBPUtil.transferParam(pmoRewriteParaVOS.toArray(new PMORewriteParaVO[pmoRewriteParaVOS.size()])); - Set originbidSet = new HashSet(); - Set bidSet = paraMapList.keySet(); - Map headMap = new HashMap(); - Map itemMap = new HashMap(); - for(PMOAggVO aggvo : aggvos) { - PMOHeadVO headvo = aggvo.getParentVO(); - if (hidList.contains(headvo.getCpmohid())) { - headMap.put(headvo.getCpmohid(), headvo); - } - - PMOItemVO[] items = aggvo.getChildrenVO(); - if (!MMArrayUtil.isEmpty(items)) { - for(PMOItemVO item : items) { - originbidSet.add(item.getCmoid()); - if (bidSet.contains(item.getCmoid())) { - itemMap.put(item.getCmoid(), item); - } + for(PMORewriteParaVO para : paras) { + paraMapList.put(para.getCpmobid(), para); + if (!hidList.contains(para.getCpmohid())) { + hidList.add(para.getCpmohid()); } } - } - if (MMMapUtil.isEmpty(itemMap)) { - return null; - } - - PMOItemVO[] items = (PMOItemVO[])itemMap.values().toArray(new PMOItemVO[0]); - List bids = (List) map2.get("bids"); - for(String para : bids) { - if (!originbidSet.contains(para)) { - ExceptionUtils.wrappBusinessException(PMOConstLang.getMSG_PMO_DeleteLine()); + PMOAggVO[] aggvos = (new PMOAggVOQueryBP()).getPMOAggVOsByIds((String[])hidList.toArray(new String[0])); + if (MMValueCheck.isEmpty(aggvos)) { + ExceptionUtils.wrappBusinessException(PMOConstLang.getMSG_REWRITE_WRNUM_AUTOERROR()); } - } - BDPKLockUtil.lockSuperVO(items); - this.checkMOstatus(items, headMap); - Set cmaterials = new HashSet(); - Set ctrantypes = new HashSet(); - Set pk_orgs = new HashSet(); - MapList sortOrgMarMap = new MapList(); + for (PMOAggVO aggvo : aggvos) { + String pkOrg = aggvo.getParentVO().getPk_org(); + String orgCode = MyHelper.transferField(OrgVO.getDefaultTableName(), OrgVO.CODE, OrgVO.PK_ORG, pkOrg); + if (checkIfOrg(orgCode, configParams)) { - for(PMOItemVO item : items) { - if (!cmaterials.contains(item.getCmaterialvid())) { - cmaterials.add(item.getCmaterialvid()); + } } - PMOHeadVO head = (PMOHeadVO)headMap.get(item.getCpmohid()); - if (!MMValueCheck.isEmpty(head) && !ctrantypes.contains(head.getCtrantypeid())) { - ctrantypes.add(head.getCtrantypeid()); - } + Set originbidSet = new HashSet(); + Set bidSet = paraMapList.keySet(); + Map headMap = new HashMap(); + Map itemMap = new HashMap(); - if (!pk_orgs.contains(item.getPk_org())) { - pk_orgs.add(item.getPk_org()); - } + for(PMOAggVO aggvo : aggvos) { + PMOHeadVO headvo = aggvo.getParentVO(); + String pkOrg = aggvo.getParentVO().getPk_org(); + String orgCode = MyHelper.transferField(OrgVO.getDefaultTableName(), OrgVO.CODE, OrgVO.PK_ORG, pkOrg); + if (checkIfOrg(orgCode, configParams)) { + continue; + } + if (hidList.contains(headvo.getCpmohid())) { + headMap.put(headvo.getCpmohid(), headvo); + } - sortOrgMarMap.put(item.getPk_org(), item.getCmaterialvid()); - } - - Map prodtolerance = new HashMap(); - - for(Map.Entry> entry : sortOrgMarMap.entrySet()) { - Map tempdowntolerance = PMOBPCalUtil.getProdtolerance((String)entry.getKey(), (String[])((List)entry.getValue()).toArray(new String[0])); - if (MMMapUtil.isNotEmpty(tempdowntolerance)) { - prodtolerance.putAll(tempdowntolerance); - } - } - - Map intolerance = PMOBPCalUtil.getInStockControlScope((String[])cmaterials.toArray(new String[0])); - Map autodonepara = PMOBPService.getIPMOTransTypeQueryService().getBAutoFinishByTranTypeIDs((String[])ctrantypes.toArray(new String[0])); - Map bpara = MMBDFactoryParameter.getPAC012BatchParaBoolean((String[])pk_orgs.toArray(new String[0])); - this.checkWrts(paraMapList, items); - List planoutputList = new ArrayList(); - - for(int i = 0; i < items.length; ++i) { - List paraList = paraMapList.get(items[i].getCmoid()); - PMOPlanOutputVO[] moPlanOutVOS = items[i].getPlanoutputs(); - if (!MMArrayUtil.isEmpty(moPlanOutVOS)) { - for(PMOPlanOutputVO planOutVO : moPlanOutVOS) { - boolean isupd = false; - - for(PMORewriteParaVO paravo : paraList) { - if (!MMMapUtil.isEmpty(paravo.getPoutMap())) { - UFDouble delNum = MMNumberUtil.toNotNullValue((UFDouble)paravo.getPoutMap().get(planOutVO.getCplanoutputid())); - if (MMNumberUtil.isNotNullAndNotZero(delNum)) { - (new NumScaleUtil()).checkNumberScale(new UFDouble[]{delNum}, planOutVO.getCunitid()); - } - - if (MMNumberUtil.isNotNullAndNotZero(delNum)) { - UFDouble wrNum = MMNumberUtil.add(new UFDouble[]{delNum, MMNumberUtil.toNotNullValue(planOutVO.getNwrnum())}); - planOutVO.setNwrnum(wrNum); - planOutVO.setStatus(1); - PMOBPCalUtil.fillReAssNumber("nplanoutputnum", "nastplanoutputnum", planOutVO, "vchangerate", "nwrnum", "nwrastnum"); - isupd = true; - } + PMOItemVO[] items = aggvo.getChildrenVO(); + if (!MMArrayUtil.isEmpty(items)) { + for(PMOItemVO item : items) { + originbidSet.add(item.getCmoid()); + if (bidSet.contains(item.getCmoid())) { + itemMap.put(item.getCmoid(), item); } } - - if (isupd) { - planoutputList.add(planOutVO); - } } } - for(PMORewriteParaVO paravo : paraList) { - UFDouble delNum = MMNumberUtil.toNotNullValue(paravo.getDelNum()); - if (MMNumberUtil.isNotNullAndNotZero(delNum)) { - (new NumScaleUtil()).checkNumberScale(new UFDouble[]{delNum}, items[i].getCunitid()); - } - - UFDouble wrNum = MMNumberUtil.add(new UFDouble[]{delNum, MMNumberUtil.toNotNullValue(items[i].getNwrnum())}); - items[i].setNwrnum(wrNum); - PMOBPCalUtil.fillReAssNumber("nplanputnum", "nplanputastnum", items[i], "vchangerate", "nwrnum", "nwrastnum"); - items[i].setStatus(1); - } - } - - List filterList = new ArrayList(); - List putplanfinishList = new ArrayList(); - - for(PMOItemVO item : items) { - String var10001 = item.getPk_org(); - UFDouble downPara = (UFDouble)prodtolerance.get(var10001 + "#" + item.getCmaterialvid()); - UFDouble compareplanputnum = item.getNplanputnum(); - if (MMNumberUtil.isGtZero(downPara)) { - compareplanputnum = MMNumberUtil.multiply(new UFDouble[]{item.getNplanputnum(), MMNumberUtil.sub(UFDouble.ONE_DBL, new UFDouble[]{downPara.div((double)100.0F)})}); + if (MMMapUtil.isEmpty(itemMap)) { + return 0; } - UFBoolean flag = UFBoolean.FALSE; - if (!MMMapUtil.isEmpty(bpara)) { - flag = (UFBoolean)bpara.get(item.getPk_org()); - if (null == flag) { - flag = UFBoolean.FALSE; + PMOItemVO[] items = (PMOItemVO[])itemMap.values().toArray(new PMOItemVO[0]); + + for(PMORewriteParaVO para : paras) { + if (!originbidSet.contains(para.getCpmobid())) { + ExceptionUtils.wrappBusinessException(PMOConstLang.getMSG_PMO_DeleteLine()); } } - if (flag.booleanValue()) { - UFDouble dpara = (UFDouble)intolerance.get(item.getCmaterialvid()); - UFDouble dparabl = UFDouble.ONE_DBL; - if (!MMValueCheck.isEmpty(bpara)) { - dparabl = MMNumberUtil.add(new UFDouble[]{UFDouble.ONE_DBL, dpara.div((double)100.0F)}); + BDPKLockUtil.lockSuperVO(items); + this.checkMOstatus(items, headMap); + Set cmaterials = new HashSet(); + Set ctrantypes = new HashSet(); + Set pk_orgs = new HashSet(); + MapList sortOrgMarMap = new MapList(); + + for(PMOItemVO item : items) { + if (!cmaterials.contains(item.getCmaterialvid())) { + cmaterials.add(item.getCmaterialvid()); } - UFDouble totalputnum = MMNumberUtil.add(new UFDouble[]{item.getNplanputnum(), item.getNrejectnum()}); - if (MMNumberUtil.isLsEqual(item.getNwrnum(), MMNumberUtil.multiply(new UFDouble[]{totalputnum, dparabl}))) { - filterList.add(item); + PMOHeadVO head = (PMOHeadVO)headMap.get(item.getCpmohid()); + if (!MMValueCheck.isEmpty(head) && !ctrantypes.contains(head.getCtrantypeid())) { + ctrantypes.add(head.getCtrantypeid()); } - if (MMNumberUtil.isGtEqual(item.getNwrnum(), compareplanputnum) && !MMMapUtil.isEmpty(autodonepara)) { - PMOHeadVO head = (PMOHeadVO)headMap.get(item.getCpmohid()); - UFBoolean autoFlag = (UFBoolean)autodonepara.get(head.getCtrantypeid()); - if (autoFlag.booleanValue()) { - BaseDAO dao = new BaseDAO(); - // 查询备料计划 如果下游备料计划未出库数量(计划出库-累计出库)小于0,生产订单自动完工取消 naccoutnum 累计出库数量 nplanoutnum计划出库 - String pickmsql = "select cbmaterialvid,vrowno,nplanoutnum,naccoutnum from mm_pickm_b where cpickmid in ( select cpickmid from mm_pickm where csourcebillrowid='" + item.getCmoid() + "' and dr=0) and dr = 0"; - List> hmateral = (List>) dao.executeQuery(pickmsql, new MapListProcessor()); - List vrownos = new ArrayList(); - List> maps = new ArrayList(); + if (!pk_orgs.contains(item.getPk_org())) { + pk_orgs.add(item.getPk_org()); + } - Boolean l=false; - for (Map map : hmateral) { - String material = MaterialVO.CODE+","+MaterialVO.NAME+","+MaterialVO.OUTTOLERANCE; - // 物料出库容差 % 0.0000 - Map goodsMap = MyHelper.transferFields(MaterialVO.getDefaultTableName(), material, MaterialVO.PK_MATERIAL, item.getCmaterialvid()); - String Outtolerance= null !=goodsMap.get("outtolerance") ? goodsMap.get("outtolerance").toString() : "0"; - if(null != map.get("nplanoutnum") && null != map.get("naccoutnum") && (new UFDouble(String.valueOf(map.get("nplanoutnum").toString())).sub(new UFDouble(String.valueOf(map.get("naccoutnum").toString()))).abs()).compareTo(new UFDouble(String.valueOf(map.get("nplanoutnum").toString())).multiply(new UFDouble(String.valueOf(Outtolerance.toString())))) > 0) { - l=true; - Map map1 =new HashMap<>(); - map1.put("vrowno",map.get("vrowno").toString()); - map1.put("mrlname",goodsMap.get("name").toString()); - map1.put("mrlcode",goodsMap.get("code").toString()); - maps.add(map1); + sortOrgMarMap.put(item.getPk_org(), item.getCmaterialvid()); + } + + Map prodtolerance = new HashMap(); + + for(Map.Entry> entry : sortOrgMarMap.entrySet()) { + Map tempdowntolerance = PMOBPCalUtil.getProdtolerance((String)entry.getKey(), (String[])((List)entry.getValue()).toArray(new String[0])); + if (MMMapUtil.isNotEmpty(tempdowntolerance)) { + prodtolerance.putAll(tempdowntolerance); + } + } + + Map intolerance = PMOBPCalUtil.getInStockControlScope((String[])cmaterials.toArray(new String[0])); + Map autodonepara = PMOBPService.getIPMOTransTypeQueryService().getBAutoFinishByTranTypeIDs((String[])ctrantypes.toArray(new String[0])); + Map bpara = MMBDFactoryParameter.getPAC012BatchParaBoolean((String[])pk_orgs.toArray(new String[0])); + this.checkWrts(paraMapList, items); + List planoutputList = new ArrayList(); + + for(int i = 0; i < items.length; ++i) { + List paraList = paraMapList.get(items[i].getCmoid()); + PMOPlanOutputVO[] moPlanOutVOS = items[i].getPlanoutputs(); + if (!MMArrayUtil.isEmpty(moPlanOutVOS)) { + for(PMOPlanOutputVO planOutVO : moPlanOutVOS) { + boolean isupd = false; + + for(PMORewriteParaVO paravo : paraList) { + if (!MMMapUtil.isEmpty(paravo.getPoutMap())) { + UFDouble delNum = MMNumberUtil.toNotNullValue((UFDouble)paravo.getPoutMap().get(planOutVO.getCplanoutputid())); + if (MMNumberUtil.isNotNullAndNotZero(delNum)) { + (new NumScaleUtil()).checkNumberScale(new UFDouble[]{delNum}, planOutVO.getCunitid()); + } + + if (MMNumberUtil.isNotNullAndNotZero(delNum)) { + UFDouble wrNum = MMNumberUtil.add(new UFDouble[]{delNum, MMNumberUtil.toNotNullValue(planOutVO.getNwrnum())}); + planOutVO.setNwrnum(wrNum); + planOutVO.setStatus(1); + PMOBPCalUtil.fillReAssNumber("nplanoutputnum", "nastplanoutputnum", planOutVO, "vchangerate", "nwrnum", "nwrastnum"); + isupd = true; + } } } - if(l){ - // String pickm = " select vbillcode,cpickmid from mm_pickm where csourcebillrowid='" + item.getCmoid() + "' and dr=0"; - // List> pickms = (List>) dao.executeQuery(pickm, new MapListProcessor()); - String err=""; - for (Map vrowno : maps) { - String pmobillcode= head.getVbillcode(); - String pmovrowno= item.getVrowno(); - // String pickmbillcode= pickms.get(0).get("vbillcode").toString(); - String pickmvrowno= vrowno.get("vrowno").toString(); - String mrlname= vrowno.get("mrlname").toString(); - String mrlcode= vrowno.get("mrlcode").toString(); - err=err+"生产订单"+pmobillcode+"行"+pmovrowno+"的备料计划行"+pickmvrowno+"物料【"+mrlcode+","+mrlname+"】检查不通过\n"; - } - return err; - } + if (isupd) { + planoutputList.add(planOutVO); + } } } - } else { - UFDouble divNum = MMNumberUtil.add(new UFDouble[]{item.getNzcgnum(), item.getNzwwnum()}); - divNum = MMNumberUtil.add(new UFDouble[]{divNum, item.getNzdbnum()}); - UFDouble totalWRnum = MMNumberUtil.add(new UFDouble[]{divNum, item.getNwrnum()}); - if (!MMNumberUtil.isLsZero(item.getNwrnum())) { - filterList.add(item); + for(PMORewriteParaVO paravo : paraList) { + UFDouble delNum = MMNumberUtil.toNotNullValue(paravo.getDelNum()); + if (MMNumberUtil.isNotNullAndNotZero(delNum)) { + (new NumScaleUtil()).checkNumberScale(new UFDouble[]{delNum}, items[i].getCunitid()); + } + + UFDouble wrNum = MMNumberUtil.add(new UFDouble[]{delNum, MMNumberUtil.toNotNullValue(items[i].getNwrnum())}); + items[i].setNwrnum(wrNum); + PMOBPCalUtil.fillReAssNumber("nplanputnum", "nplanputastnum", items[i], "vchangerate", "nwrnum", "nwrastnum"); + items[i].setStatus(1); + } + } + + List filterList = new ArrayList(); + List putplanfinishList = new ArrayList(); + + for(PMOItemVO item : items) { + String var10001 = item.getPk_org(); + UFDouble downPara = (UFDouble)prodtolerance.get(var10001 + "#" + item.getCmaterialvid()); + UFDouble compareplanputnum = item.getNplanputnum(); + if (MMNumberUtil.isGtZero(downPara)) { + compareplanputnum = MMNumberUtil.multiply(new UFDouble[]{item.getNplanputnum(), MMNumberUtil.sub(UFDouble.ONE_DBL, new UFDouble[]{downPara.div((double)100.0F)})}); } - if (totalWRnum.doubleValue() >= compareplanputnum.doubleValue() && !MMMapUtil.isEmpty(autodonepara)) { + UFBoolean flag = UFBoolean.FALSE; + if (!MMMapUtil.isEmpty(bpara)) { + flag = (UFBoolean)bpara.get(item.getPk_org()); + if (null == flag) { + flag = UFBoolean.FALSE; + } + } + if (flag.booleanValue()) { + UFDouble dpara = (UFDouble)intolerance.get(item.getCmaterialvid()); + UFDouble dparabl = UFDouble.ONE_DBL; + if (!MMValueCheck.isEmpty(bpara)) { + dparabl = MMNumberUtil.add(new UFDouble[]{UFDouble.ONE_DBL, dpara.div((double)100.0F)}); + } - PMOHeadVO head = (PMOHeadVO)headMap.get(item.getCpmohid()); - UFBoolean autoFlag = (UFBoolean)autodonepara.get(head.getCtrantypeid()); - if (autoFlag.booleanValue()) { - BaseDAO dao = new BaseDAO(); - // 查询备料计划 如果下游备料计划未出库数量(计划出库-累计出库)小于0,生产订单自动完工取消 naccoutnum 累计出库数量 nplanoutnum计划出库 - String pickmsql = "select cbmaterialvid,vrowno,nplanoutnum,naccoutnum from mm_pickm_b where cpickmid in ( select cpickmid from mm_pickm where csourcebillrowid='" + item.getCmoid() + "' and dr=0) and dr = 0"; - List> hmateral = (List>) dao.executeQuery(pickmsql, new MapListProcessor()); - List vrownos = new ArrayList(); - List> maps = new ArrayList(); + UFDouble totalputnum = MMNumberUtil.add(new UFDouble[]{item.getNplanputnum(), item.getNrejectnum()}); + if (MMNumberUtil.isLsEqual(item.getNwrnum(), MMNumberUtil.multiply(new UFDouble[]{totalputnum, dparabl}))) { + filterList.add(item); + } - Boolean l=false; - for (Map map : hmateral) { - String material =MaterialVO.CODE+","+MaterialVO.NAME+","+MaterialVO.OUTTOLERANCE; - // 物料出库容差 % 0.0000 - Map goodsMap = MyHelper.transferFields(MaterialVO.getDefaultTableName(), material, MaterialVO.PK_MATERIAL, item.getCmaterialvid()); - String Outtolerance= null !=goodsMap.get("outtolerance") ? goodsMap.get("outtolerance").toString() : "0"; - if(null != map.get("nplanoutnum") && null != map.get("naccoutnum") && (new UFDouble(map.get("nplanoutnum").toString()).sub(new UFDouble(String.valueOf(map.get("naccoutnum").toString()))).abs()).compareTo(new UFDouble(String.valueOf(map.get("nplanoutnum").toString())).multiply(new UFDouble(String.valueOf(Outtolerance.toString())))) > 0) { - UFDouble num1 = new UFDouble(map.get("nplanoutnum").toString()).sub(new UFDouble(String.valueOf(map.get("naccoutnum").toString()))).abs(); + if (MMNumberUtil.isGtEqual(item.getNwrnum(), compareplanputnum) && !MMMapUtil.isEmpty(autodonepara)) { + PMOHeadVO head = (PMOHeadVO)headMap.get(item.getCpmohid()); + UFBoolean autoFlag = (UFBoolean)autodonepara.get(head.getCtrantypeid()); + if (autoFlag.booleanValue()) { + BaseDAO dao = new BaseDAO(); + // 查询备料计划 如果下游备料计划未出库数量(计划出库-累计出库)小于0,生产订单自动完工取消 naccoutnum 累计出库数量 nplanoutnum计划出库 + String pickmsql = "select cbmaterialvid,vrowno,nplanoutnum,naccoutnum from mm_pickm_b where cpickmid in ( select cpickmid from mm_pickm where csourcebillrowid='" + item.getCmoid() + "' and dr=0) and dr = 0"; + List> hmateral = (List>) dao.executeQuery(pickmsql, new MapListProcessor()); + List vrownos = new ArrayList(); + List> maps = new ArrayList(); - l=true; - Map map1 =new HashMap<>(); - map1.put("vrowno",map.get("vrowno").toString()); - map1.put("mrlname",goodsMap.get("name").toString()); - map1.put("mrlcode",goodsMap.get("code").toString()); - maps.add(map1); + Boolean l=false; + for (Map map : hmateral) { + String material =MaterialVO.CODE+","+MaterialVO.NAME+","+MaterialVO.OUTTOLERANCE; + if(map.get("naccoutnum") == null){ + map.put("naccoutnum", 0); + } + // 物料出库容差 % 0.0000 + Map goodsMap = MyHelper.transferFields(MaterialVO.getDefaultTableName(), material, MaterialVO.PK_MATERIAL, item.getCmaterialvid()); + String Outtolerance= null !=goodsMap.get("outtolerance") ? goodsMap.get("outtolerance").toString() : "0"; + if(null != map.get("nplanoutnum") && null != map.get("naccoutnum") && (new UFDouble(String.valueOf(map.get("nplanoutnum").toString())).sub(new UFDouble(String.valueOf(map.get("naccoutnum").toString()))).abs()).compareTo(new UFDouble(String.valueOf(map.get("nplanoutnum").toString())).multiply(new UFDouble(String.valueOf(Outtolerance.toString())))) > 0) { + l=true; + Map map1 =new HashMap<>(); + map1.put("vrowno",map.get("vrowno").toString()); + map1.put("mrlname",goodsMap.get("name").toString()); + map1.put("mrlcode",goodsMap.get("code").toString()); + maps.add(map1); + } } - } - if(l){ - // String pickm = " select vbillcode,cpickmid from mm_pickm where csourcebillrowid='" + item.getCmoid() + "' and dr=0"; - // List> pickms = (List>) dao.executeQuery(pickm, new MapListProcessor()); - String err=""; - for (Map vrowno : maps) { - String pmobillcode= head.getVbillcode(); - String pmovrowno= item.getVrowno(); - // String pickmbillcode= pickms.get(0).get("vbillcode").toString(); - String pickmvrowno= vrowno.get("vrowno").toString(); - String mrlname= vrowno.get("mrlname").toString(); - String mrlcode= vrowno.get("mrlcode").toString(); - err=err+"生产订单"+pmobillcode+"行"+pmovrowno+"的备料计划行"+pickmvrowno+"物料【"+mrlcode+","+mrlname+"】检查不通过\n"; + if(l){ + // String pickm = " select vbillcode,cpickmid from mm_pickm where csourcebillrowid='" + item.getCmoid() + "' and dr=0"; + // List> pickms = (List>) dao.executeQuery(pickm, new MapListProcessor()); + String err=""; + for (Map vrowno : maps) { + String pmobillcode= head.getVbillcode(); + String pmovrowno= item.getVrowno(); + // String pickmbillcode= pickms.get(0).get("vbillcode").toString(); + String pickmvrowno= vrowno.get("vrowno").toString(); + String mrlname= vrowno.get("mrlname").toString(); + String mrlcode= vrowno.get("mrlcode").toString(); + err=err+"生产订单"+pmobillcode+"行"+pmovrowno+"的备料计划行"+pickmvrowno+"物料【"+mrlcode+","+mrlname+"】检查不通过\n"; + } + return err; } - return err; + item.setFitemstatus(Integer.valueOf(PMOFItemStatusEnum.FINISH.getEnumValue().getValue())); + item.setTactendtime(new UFDateTime(AppBsContext.getInstance().getBusiDate().toPersisted())); + item.setStatus(1); + putplanfinishList.add(item.getCmoid()); } - item.setFitemstatus(Integer.valueOf(PMOFItemStatusEnum.FINISH.getEnumValue().getValue())); - item.setTactendtime(new UFDateTime(AppBsContext.getInstance().getBusiDate().toPersisted())); + } + + if (MMNumberUtil.isLs(item.getNwrnum(), compareplanputnum) && item.getFitemstatus().equals(Integer.valueOf(PMOFItemStatusEnum.FINISH.getEnumValue().getValue()))) { + item.setFitemstatus(Integer.valueOf(PMOFItemStatusEnum.PUT.getEnumValue().getValue())); + item.setTactendtime((UFDateTime)null); + item.setStatus(1); + } + } else { + UFDouble divNum = MMNumberUtil.add(new UFDouble[]{item.getNzcgnum(), item.getNzwwnum()}); + divNum = MMNumberUtil.add(new UFDouble[]{divNum, item.getNzdbnum()}); + UFDouble totalWRnum = MMNumberUtil.add(new UFDouble[]{divNum, item.getNwrnum()}); + if (!MMNumberUtil.isLsZero(item.getNwrnum())) { + filterList.add(item); + } + + if (totalWRnum.doubleValue() >= compareplanputnum.doubleValue() && !MMMapUtil.isEmpty(autodonepara)) { + + + PMOHeadVO head = (PMOHeadVO)headMap.get(item.getCpmohid()); + UFBoolean autoFlag = (UFBoolean)autodonepara.get(head.getCtrantypeid()); + if (autoFlag.booleanValue()) { + BaseDAO dao = new BaseDAO(); + // 查询备料计划 如果下游备料计划未出库数量(计划出库-累计出库)小于0,生产订单自动完工取消 naccoutnum 累计出库数量 nplanoutnum计划出库 + String pickmsql = "select cbmaterialvid,vrowno,nplanoutnum,naccoutnum from mm_pickm_b where cpickmid in ( select cpickmid from mm_pickm where csourcebillrowid='" + item.getCmoid() + "' and dr=0) and dr = 0"; + List> hmateral = (List>) dao.executeQuery(pickmsql, new MapListProcessor()); + List vrownos = new ArrayList(); + List> maps = new ArrayList(); + + Boolean l=false; + for (Map map : hmateral) { + String material =MaterialVO.CODE+","+MaterialVO.NAME+","+MaterialVO.OUTTOLERANCE; + // 物料出库容差 % 0.0000 + if(map.get("naccoutnum") == null){ + map.put("naccoutnum", 0); + } + Map goodsMap = MyHelper.transferFields(MaterialVO.getDefaultTableName(), material, MaterialVO.PK_MATERIAL, item.getCmaterialvid()); + String Outtolerance= null !=goodsMap.get("outtolerance") ? goodsMap.get("outtolerance").toString() : "0"; + if(null != map.get("nplanoutnum") && null != map.get("naccoutnum") && (new UFDouble(map.get("nplanoutnum").toString()).sub(new UFDouble(String.valueOf(map.get("naccoutnum").toString()))).abs()).compareTo(new UFDouble(String.valueOf(map.get("nplanoutnum").toString())).multiply(new UFDouble(String.valueOf(Outtolerance.toString())))) > 0) { + UFDouble num1 = new UFDouble(map.get("nplanoutnum").toString()).sub(new UFDouble(String.valueOf(map.get("naccoutnum").toString()))).abs(); + + l=true; + Map map1 =new HashMap<>(); + map1.put("vrowno",map.get("vrowno").toString()); + map1.put("mrlname",goodsMap.get("name").toString()); + map1.put("mrlcode",goodsMap.get("code").toString()); + maps.add(map1); + } + } + if(l){ + // String pickm = " select vbillcode,cpickmid from mm_pickm where csourcebillrowid='" + item.getCmoid() + "' and dr=0"; + // List> pickms = (List>) dao.executeQuery(pickm, new MapListProcessor()); + String err=""; + for (Map vrowno : maps) { + String pmobillcode= head.getVbillcode(); + String pmovrowno= item.getVrowno(); + // String pickmbillcode= pickms.get(0).get("vbillcode").toString(); + String pickmvrowno= vrowno.get("vrowno").toString(); + String mrlname= vrowno.get("mrlname").toString(); + String mrlcode= vrowno.get("mrlcode").toString(); + err=err+"生产订单"+pmobillcode+"行"+pmovrowno+"的备料计划行"+pickmvrowno+"物料【"+mrlcode+","+mrlname+"】检查不通过\n"; + } + return err; + } + } + } + + if (totalWRnum.doubleValue() < compareplanputnum.doubleValue() && item.getFitemstatus().equals(Integer.valueOf(PMOFItemStatusEnum.FINISH.getEnumValue().getValue()))) { + item.setFitemstatus(Integer.valueOf(PMOFItemStatusEnum.PUT.getEnumValue().getValue())); + item.setTactendtime((UFDateTime)null); item.setStatus(1); - putplanfinishList.add(item.getCmoid()); } } } - } - return null; + return 0; } catch (BusinessException e) { throw new RuntimeException(e); } } + private boolean checkIfOrg(String code, Map configParams) throws BusinessException { + String targetCode = configParams.get("xbOrg"); + if (targetCode == null || nc.vo.am.common.util.StringUtils.isEmpty(targetCode)) { + throw new BusinessException("未配置组织参数"); + } + String[] orgItem = targetCode.split(","); + for (String orgCode : orgItem) { + if (!orgCode.isEmpty() && orgCode.equals(code)) { + return false; + } + } + return true; + } private void checkMOstatus(PMOItemVO[] items, Map headMap) { if (!MMArrayUtil.isEmpty(items)) { StringBuilder msg = new StringBuilder(""); diff --git a/mmpac/src/client/yyconfig/modules/mmpac/config/authorize/mmpac_authorize.xml b/mmpac/src/client/yyconfig/modules/mmpac/config/authorize/mmpac_authorize.xml index 5179faca..20e71aef 100644 --- a/mmpac/src/client/yyconfig/modules/mmpac/config/authorize/mmpac_authorize.xml +++ b/mmpac/src/client/yyconfig/modules/mmpac/config/authorize/mmpac_authorize.xml @@ -374,6 +374,7 @@ mmpac.pwr.prodInSnQuery mmpac.pwr.prodInSn mmpac.pwr.queryByCond + mmpac.pwr.checkRewrite @@ -402,7 +403,6 @@ mmpac.applytask.opreqpushtotask mmpac.applytask.bodyAfterEdit mmpac.applytask.queryByCond - mmpac.pwr.checkRewrite