生产报告保存前校验回写

This commit is contained in:
lihao 2025-12-02 13:55:38 +08:00
parent 3f515edb8f
commit e4e7412615
2 changed files with 284 additions and 218 deletions

View File

@ -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.entity.PMOPlanOutputVO;
import nc.vo.mmpac.pmo.pac0002.enumeration.PMOFItemStatusEnum; import nc.vo.mmpac.pmo.pac0002.enumeration.PMOFItemStatusEnum;
import nc.vo.mmpac.pmo.parameter.PMORewriteParaVO; import nc.vo.mmpac.pmo.parameter.PMORewriteParaVO;
import nc.vo.org.OrgVO;
import nc.vo.pub.BusinessException; import nc.vo.pub.BusinessException;
import nc.vo.pub.lang.UFBoolean; import nc.vo.pub.lang.UFBoolean;
import nc.vo.pub.lang.UFDateTime; import nc.vo.pub.lang.UFDateTime;
@ -50,6 +51,7 @@ import nccloud.framework.web.container.IRequest;
import nccloud.framework.web.json.JsonFactory; import nccloud.framework.web.json.JsonFactory;
import java.util.*; import java.util.*;
import java.util.stream.Collectors;
public class PwrCheckRewriteAction implements ICommonAction { public class PwrCheckRewriteAction implements ICommonAction {
@Override @Override
@ -60,274 +62,338 @@ public class PwrCheckRewriteAction implements ICommonAction {
try { try {
Map map2 = json.fromJson(read, Map.class); Map map2 = json.fromJson(read, Map.class);
List<PMORewriteParaVO> pmoRewriteParaVOS=new ArrayList<>();
Map<String, String> configParams = MyHelper.getConfigParams("xb-config", null);
MapList<String, PMORewriteParaVO> paraMapList = new MapList(); MapList<String, PMORewriteParaVO> paraMapList = new MapList();
List<String> hidList = new ArrayList(); List<String> hidList = (List<String>) map2.get("pmoid");
hidList.add((String) map2.get("Cpmohid")); // 直接用 Stream 去重后覆盖原变量默认保持顺序
hidList = Optional.ofNullable(hidList)
.orElseGet(ArrayList::new) // 空值兜底
PMOAggVO[] aggvos = (new PMOAggVOQueryBP()).getPMOAggVOsByIds((String[])hidList.toArray(new String[0])); .stream()
if (MMValueCheck.isEmpty(aggvos)) { .distinct() // 去重核心
ExceptionUtils.wrappBusinessException(PMOConstLang.getMSG_REWRITE_WRNUM_AUTOERROR()); .collect(Collectors.toList()); // 收集后覆盖原变量
List<Map<String,Object>> bidlists= (List<Map<String, Object>>) map2.get("pmobids");
for (Map<String,Object> 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<String> originbidSet = new HashSet();
Set<String> bidSet = paraMapList.keySet();
Map<String, PMOHeadVO> headMap = new HashMap();
Map<String, PMOItemVO> itemMap = new HashMap();
for(PMOAggVO aggvo : aggvos) { for(PMORewriteParaVO para : paras) {
PMOHeadVO headvo = aggvo.getParentVO(); paraMapList.put(para.getCpmobid(), para);
if (hidList.contains(headvo.getCpmohid())) { if (!hidList.contains(para.getCpmohid())) {
headMap.put(headvo.getCpmohid(), headvo); hidList.add(para.getCpmohid());
}
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 (MMMapUtil.isEmpty(itemMap)) { PMOAggVO[] aggvos = (new PMOAggVOQueryBP()).getPMOAggVOsByIds((String[])hidList.toArray(new String[0]));
return null; if (MMValueCheck.isEmpty(aggvos)) {
} ExceptionUtils.wrappBusinessException(PMOConstLang.getMSG_REWRITE_WRNUM_AUTOERROR());
PMOItemVO[] items = (PMOItemVO[])itemMap.values().toArray(new PMOItemVO[0]);
List<String> bids = (List<String>) map2.get("bids");
for(String para : bids) {
if (!originbidSet.contains(para)) {
ExceptionUtils.wrappBusinessException(PMOConstLang.getMSG_PMO_DeleteLine());
} }
} for (PMOAggVO aggvo : aggvos) {
BDPKLockUtil.lockSuperVO(items); String pkOrg = aggvo.getParentVO().getPk_org();
this.checkMOstatus(items, headMap); String orgCode = MyHelper.transferField(OrgVO.getDefaultTableName(), OrgVO.CODE, OrgVO.PK_ORG, pkOrg);
Set<String> cmaterials = new HashSet(); if (checkIfOrg(orgCode, configParams)) {
Set<String> ctrantypes = new HashSet();
Set<String> pk_orgs = new HashSet();
MapList<String, String> sortOrgMarMap = new MapList();
for(PMOItemVO item : items) { }
if (!cmaterials.contains(item.getCmaterialvid())) {
cmaterials.add(item.getCmaterialvid());
} }
PMOHeadVO head = (PMOHeadVO)headMap.get(item.getCpmohid()); Set<String> originbidSet = new HashSet();
if (!MMValueCheck.isEmpty(head) && !ctrantypes.contains(head.getCtrantypeid())) { Set<String> bidSet = paraMapList.keySet();
ctrantypes.add(head.getCtrantypeid()); Map<String, PMOHeadVO> headMap = new HashMap();
} Map<String, PMOItemVO> itemMap = new HashMap();
if (!pk_orgs.contains(item.getPk_org())) { for(PMOAggVO aggvo : aggvos) {
pk_orgs.add(item.getPk_org()); 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()); PMOItemVO[] items = aggvo.getChildrenVO();
} if (!MMArrayUtil.isEmpty(items)) {
for(PMOItemVO item : items) {
Map<String, UFDouble> prodtolerance = new HashMap(); originbidSet.add(item.getCmoid());
if (bidSet.contains(item.getCmoid())) {
for(Map.Entry<String, List<String>> entry : sortOrgMarMap.entrySet()) { itemMap.put(item.getCmoid(), item);
Map<String, UFDouble> tempdowntolerance = PMOBPCalUtil.getProdtolerance((String)entry.getKey(), (String[])((List)entry.getValue()).toArray(new String[0]));
if (MMMapUtil.isNotEmpty(tempdowntolerance)) {
prodtolerance.putAll(tempdowntolerance);
}
}
Map<String, UFDouble> intolerance = PMOBPCalUtil.getInStockControlScope((String[])cmaterials.toArray(new String[0]));
Map<String, UFBoolean> autodonepara = PMOBPService.getIPMOTransTypeQueryService().getBAutoFinishByTranTypeIDs((String[])ctrantypes.toArray(new String[0]));
Map<String, UFBoolean> bpara = MMBDFactoryParameter.getPAC012BatchParaBoolean((String[])pk_orgs.toArray(new String[0]));
this.checkWrts(paraMapList, items);
List<PMOPlanOutputVO> planoutputList = new ArrayList();
for(int i = 0; i < items.length; ++i) {
List<PMORewriteParaVO> 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 (isupd) {
planoutputList.add(planOutVO);
}
} }
} }
for(PMORewriteParaVO paravo : paraList) { if (MMMapUtil.isEmpty(itemMap)) {
UFDouble delNum = MMNumberUtil.toNotNullValue(paravo.getDelNum()); return 0;
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<PMOItemVO> filterList = new ArrayList();
List<String> 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)})});
} }
UFBoolean flag = UFBoolean.FALSE; PMOItemVO[] items = (PMOItemVO[])itemMap.values().toArray(new PMOItemVO[0]);
if (!MMMapUtil.isEmpty(bpara)) {
flag = (UFBoolean)bpara.get(item.getPk_org()); for(PMORewriteParaVO para : paras) {
if (null == flag) { if (!originbidSet.contains(para.getCpmobid())) {
flag = UFBoolean.FALSE; ExceptionUtils.wrappBusinessException(PMOConstLang.getMSG_PMO_DeleteLine());
} }
} }
if (flag.booleanValue()) { BDPKLockUtil.lockSuperVO(items);
UFDouble dpara = (UFDouble)intolerance.get(item.getCmaterialvid()); this.checkMOstatus(items, headMap);
UFDouble dparabl = UFDouble.ONE_DBL; Set<String> cmaterials = new HashSet();
if (!MMValueCheck.isEmpty(bpara)) { Set<String> ctrantypes = new HashSet();
dparabl = MMNumberUtil.add(new UFDouble[]{UFDouble.ONE_DBL, dpara.div((double)100.0F)}); Set<String> pk_orgs = new HashSet();
MapList<String, String> 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()}); PMOHeadVO head = (PMOHeadVO)headMap.get(item.getCpmohid());
if (MMNumberUtil.isLsEqual(item.getNwrnum(), MMNumberUtil.multiply(new UFDouble[]{totalputnum, dparabl}))) { if (!MMValueCheck.isEmpty(head) && !ctrantypes.contains(head.getCtrantypeid())) {
filterList.add(item); ctrantypes.add(head.getCtrantypeid());
} }
if (MMNumberUtil.isGtEqual(item.getNwrnum(), compareplanputnum) && !MMMapUtil.isEmpty(autodonepara)) { if (!pk_orgs.contains(item.getPk_org())) {
PMOHeadVO head = (PMOHeadVO)headMap.get(item.getCpmohid()); pk_orgs.add(item.getPk_org());
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<Map<String,Object>> hmateral = (List<Map<String,Object>>) dao.executeQuery(pickmsql, new MapListProcessor());
List<String> vrownos = new ArrayList();
List<Map<String,Object>> maps = new ArrayList();
Boolean l=false; sortOrgMarMap.put(item.getPk_org(), item.getCmaterialvid());
for (Map<String,Object> map : hmateral) { }
String material = MaterialVO.CODE+","+MaterialVO.NAME+","+MaterialVO.OUTTOLERANCE;
// 物料出库容差 % 0.0000 Map<String, UFDouble> prodtolerance = new HashMap();
Map<String, Object> goodsMap = MyHelper.transferFields(MaterialVO.getDefaultTableName(), material, MaterialVO.PK_MATERIAL, item.getCmaterialvid());
String Outtolerance= null !=goodsMap.get("outtolerance") ? goodsMap.get("outtolerance").toString() : "0"; for(Map.Entry<String, List<String>> entry : sortOrgMarMap.entrySet()) {
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) { Map<String, UFDouble> tempdowntolerance = PMOBPCalUtil.getProdtolerance((String)entry.getKey(), (String[])((List)entry.getValue()).toArray(new String[0]));
l=true; if (MMMapUtil.isNotEmpty(tempdowntolerance)) {
Map<String, Object> map1 =new HashMap<>(); prodtolerance.putAll(tempdowntolerance);
map1.put("vrowno",map.get("vrowno").toString()); }
map1.put("mrlname",goodsMap.get("name").toString()); }
map1.put("mrlcode",goodsMap.get("code").toString());
maps.add(map1); Map<String, UFDouble> intolerance = PMOBPCalUtil.getInStockControlScope((String[])cmaterials.toArray(new String[0]));
Map<String, UFBoolean> autodonepara = PMOBPService.getIPMOTransTypeQueryService().getBAutoFinishByTranTypeIDs((String[])ctrantypes.toArray(new String[0]));
Map<String, UFBoolean> bpara = MMBDFactoryParameter.getPAC012BatchParaBoolean((String[])pk_orgs.toArray(new String[0]));
this.checkWrts(paraMapList, items);
List<PMOPlanOutputVO> planoutputList = new ArrayList();
for(int i = 0; i < items.length; ++i) {
List<PMORewriteParaVO> 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<Map<String,Object>> pickms = (List<Map<String,Object>>) dao.executeQuery(pickm, new MapListProcessor());
String err="";
for (Map<String,Object> 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 { for(PMORewriteParaVO paravo : paraList) {
UFDouble divNum = MMNumberUtil.add(new UFDouble[]{item.getNzcgnum(), item.getNzwwnum()}); UFDouble delNum = MMNumberUtil.toNotNullValue(paravo.getDelNum());
divNum = MMNumberUtil.add(new UFDouble[]{divNum, item.getNzdbnum()}); if (MMNumberUtil.isNotNullAndNotZero(delNum)) {
UFDouble totalWRnum = MMNumberUtil.add(new UFDouble[]{divNum, item.getNwrnum()}); (new NumScaleUtil()).checkNumberScale(new UFDouble[]{delNum}, items[i].getCunitid());
if (!MMNumberUtil.isLsZero(item.getNwrnum())) { }
filterList.add(item);
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<PMOItemVO> filterList = new ArrayList();
List<String> 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()); UFDouble totalputnum = MMNumberUtil.add(new UFDouble[]{item.getNplanputnum(), item.getNrejectnum()});
UFBoolean autoFlag = (UFBoolean)autodonepara.get(head.getCtrantypeid()); if (MMNumberUtil.isLsEqual(item.getNwrnum(), MMNumberUtil.multiply(new UFDouble[]{totalputnum, dparabl}))) {
if (autoFlag.booleanValue()) { filterList.add(item);
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<Map<String,Object>> hmateral = (List<Map<String,Object>>) dao.executeQuery(pickmsql, new MapListProcessor());
List<String> vrownos = new ArrayList();
List<Map<String,Object>> maps = new ArrayList();
Boolean l=false; if (MMNumberUtil.isGtEqual(item.getNwrnum(), compareplanputnum) && !MMMapUtil.isEmpty(autodonepara)) {
for (Map<String,Object> map : hmateral) { PMOHeadVO head = (PMOHeadVO)headMap.get(item.getCpmohid());
String material =MaterialVO.CODE+","+MaterialVO.NAME+","+MaterialVO.OUTTOLERANCE; UFBoolean autoFlag = (UFBoolean)autodonepara.get(head.getCtrantypeid());
// 物料出库容差 % 0.0000 if (autoFlag.booleanValue()) {
Map<String, Object> goodsMap = MyHelper.transferFields(MaterialVO.getDefaultTableName(), material, MaterialVO.PK_MATERIAL, item.getCmaterialvid()); BaseDAO dao = new BaseDAO();
String Outtolerance= null !=goodsMap.get("outtolerance") ? goodsMap.get("outtolerance").toString() : "0"; // 查询备料计划 如果下游备料计划未出库数量计划出库-累计出库小于0生产订单自动完工取消 naccoutnum 累计出库数量 nplanoutnum计划出库
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) { 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";
UFDouble num1 = new UFDouble(map.get("nplanoutnum").toString()).sub(new UFDouble(String.valueOf(map.get("naccoutnum").toString()))).abs(); List<Map<String,Object>> hmateral = (List<Map<String,Object>>) dao.executeQuery(pickmsql, new MapListProcessor());
List<String> vrownos = new ArrayList();
List<Map<String,Object>> maps = new ArrayList();
l=true; Boolean l=false;
Map<String, Object> map1 =new HashMap<>(); for (Map<String,Object> map : hmateral) {
map1.put("vrowno",map.get("vrowno").toString()); String material =MaterialVO.CODE+","+MaterialVO.NAME+","+MaterialVO.OUTTOLERANCE;
map1.put("mrlname",goodsMap.get("name").toString()); if(map.get("naccoutnum") == null){
map1.put("mrlcode",goodsMap.get("code").toString()); map.put("naccoutnum", 0);
maps.add(map1); }
// 物料出库容差 % 0.0000
Map<String, Object> 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<String, Object> 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){
if(l){ // String pickm = " select vbillcode,cpickmid from mm_pickm where csourcebillrowid='" + item.getCmoid() + "' and dr=0";
// String pickm = " select vbillcode,cpickmid from mm_pickm where csourcebillrowid='" + item.getCmoid() + "' and dr=0"; // List<Map<String,Object>> pickms = (List<Map<String,Object>>) dao.executeQuery(pickm, new MapListProcessor());
// List<Map<String,Object>> pickms = (List<Map<String,Object>>) dao.executeQuery(pickm, new MapListProcessor()); String err="";
String err=""; for (Map<String,Object> vrowno : maps) {
for (Map<String,Object> vrowno : maps) { String pmobillcode= head.getVbillcode();
String pmobillcode= head.getVbillcode(); String pmovrowno= item.getVrowno();
String pmovrowno= item.getVrowno(); // String pickmbillcode= pickms.get(0).get("vbillcode").toString();
// String pickmbillcode= pickms.get(0).get("vbillcode").toString(); String pickmvrowno= vrowno.get("vrowno").toString();
String pickmvrowno= vrowno.get("vrowno").toString(); String mrlname= vrowno.get("mrlname").toString();
String mrlname= vrowno.get("mrlname").toString(); String mrlcode= vrowno.get("mrlcode").toString();
String mrlcode= vrowno.get("mrlcode").toString(); err=err+"生产订单"+pmobillcode+""+pmovrowno+"的备料计划行"+pickmvrowno+"物料【"+mrlcode+","+mrlname+"】检查不通过\n";
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<Map<String,Object>> hmateral = (List<Map<String,Object>>) dao.executeQuery(pickmsql, new MapListProcessor());
List<String> vrownos = new ArrayList();
List<Map<String,Object>> maps = new ArrayList();
Boolean l=false;
for (Map<String,Object> map : hmateral) {
String material =MaterialVO.CODE+","+MaterialVO.NAME+","+MaterialVO.OUTTOLERANCE;
// 物料出库容差 % 0.0000
if(map.get("naccoutnum") == null){
map.put("naccoutnum", 0);
}
Map<String, Object> 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<String, Object> 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<Map<String,Object>> pickms = (List<Map<String,Object>>) dao.executeQuery(pickm, new MapListProcessor());
String err="";
for (Map<String,Object> 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); item.setStatus(1);
putplanfinishList.add(item.getCmoid());
} }
} }
} }
} return 0;
return null;
} catch (BusinessException e) { } catch (BusinessException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
} }
private boolean checkIfOrg(String code, Map<String, String> 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<String, PMOHeadVO> headMap) { private void checkMOstatus(PMOItemVO[] items, Map<String, PMOHeadVO> headMap) {
if (!MMArrayUtil.isEmpty(items)) { if (!MMArrayUtil.isEmpty(items)) {
StringBuilder msg = new StringBuilder(""); StringBuilder msg = new StringBuilder("");

View File

@ -374,6 +374,7 @@
<action>mmpac.pwr.prodInSnQuery</action> <action>mmpac.pwr.prodInSnQuery</action>
<action>mmpac.pwr.prodInSn</action> <action>mmpac.pwr.prodInSn</action>
<action>mmpac.pwr.queryByCond</action> <action>mmpac.pwr.queryByCond</action>
<action>mmpac.pwr.checkRewrite</action>
</actions> </actions>
</authorize> </authorize>
<authorize><!-- 作业量维护 --> <authorize><!-- 作业量维护 -->
@ -402,7 +403,6 @@
<action>mmpac.applytask.opreqpushtotask</action> <action>mmpac.applytask.opreqpushtotask</action>
<action>mmpac.applytask.bodyAfterEdit</action> <action>mmpac.applytask.bodyAfterEdit</action>
<action>mmpac.applytask.queryByCond</action> <action>mmpac.applytask.queryByCond</action>
<action>mmpac.pwr.checkRewrite</action>
</actions> </actions>
</authorize> </authorize>
<authorize><!-- 生产订单工作台 --> <authorize><!-- 生产订单工作台 -->