电力电子负计划开发

This commit is contained in:
lihao 2026-02-03 16:38:36 +08:00
parent 9cd519a300
commit 5c25a7df9d
1 changed files with 506 additions and 225 deletions

View File

@ -94,24 +94,25 @@ public class PwrCheckRewriteAction implements ICommonAction {
if (MMValueCheck.isEmpty(aggvos)) {
ExceptionUtils.wrappBusinessException(PMOConstLang.getMSG_REWRITE_WRNUM_AUTOERROR());
}
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 (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)) {
//
// }
// }
Set<String> originbidSet = new HashSet();
Set<String> bidSet = paraMapList.keySet();
Map<String, PMOHeadVO> headMap = new HashMap();
Map<String, PMOItemVO> itemMap = new HashMap();
Map<String, PMOItemVO> itemMap2 = new HashMap();
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)) {
if (!checkIfOrg(orgCode, configParams,"planOrg")) {
continue;
}
if (hidList.contains(headvo.getCpmohid())) {
@ -123,276 +124,556 @@ public class PwrCheckRewriteAction implements ICommonAction {
for(PMOItemVO item : items) {
originbidSet.add(item.getCmoid());
if (bidSet.contains(item.getCmoid())) {
itemMap.put(item.getCmoid(), item);
if (checkIfOrg(orgCode, configParams,"xbOrg")){
itemMap.put(item.getCmoid(), item);
} else if (checkIfOrg(orgCode, configParams,"dldzOrg")) {
itemMap2.put(item.getCmoid(), item);
}
}
}
}
}
if (MMMapUtil.isEmpty(itemMap)) {
if (MMMapUtil.isEmpty(itemMap) && MMMapUtil.isEmpty(itemMap2)) {
return 0;
}
if (!MMMapUtil.isEmpty(itemMap)) {
PMOItemVO[] items = (PMOItemVO[])itemMap.values().toArray(new PMOItemVO[0]);
PMOItemVO[] items = (PMOItemVO[])itemMap.values().toArray(new PMOItemVO[0]);
for(PMORewriteParaVO para : paras) {
if (!originbidSet.contains(para.getCpmobid())) {
ExceptionUtils.wrappBusinessException(PMOConstLang.getMSG_PMO_DeleteLine());
}
}
BDPKLockUtil.lockSuperVO(items);
this.checkMOstatus(items, headMap);
Set<String> cmaterials = new HashSet();
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());
for(PMORewriteParaVO para : paras) {
if (!originbidSet.contains(para.getCpmobid())) {
ExceptionUtils.wrappBusinessException(PMOConstLang.getMSG_PMO_DeleteLine());
}
}
PMOHeadVO head = (PMOHeadVO)headMap.get(item.getCpmohid());
if (!MMValueCheck.isEmpty(head) && !ctrantypes.contains(head.getCtrantypeid())) {
ctrantypes.add(head.getCtrantypeid());
BDPKLockUtil.lockSuperVO(items);
this.checkMOstatus(items, headMap);
Set<String> cmaterials = new HashSet();
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());
if (!MMValueCheck.isEmpty(head) && !ctrantypes.contains(head.getCtrantypeid())) {
ctrantypes.add(head.getCtrantypeid());
}
if (!pk_orgs.contains(item.getPk_org())) {
pk_orgs.add(item.getPk_org());
}
sortOrgMarMap.put(item.getPk_org(), item.getCmaterialvid());
}
if (!pk_orgs.contains(item.getPk_org())) {
pk_orgs.add(item.getPk_org());
Map<String, UFDouble> prodtolerance = new HashMap();
for(Map.Entry<String, List<String>> entry : sortOrgMarMap.entrySet()) {
Map<String, UFDouble> tempdowntolerance = PMOBPCalUtil.getProdtolerance((String)entry.getKey(), (String[])((List)entry.getValue()).toArray(new String[0]));
if (MMMapUtil.isNotEmpty(tempdowntolerance)) {
prodtolerance.putAll(tempdowntolerance);
}
}
sortOrgMarMap.put(item.getPk_org(), item.getCmaterialvid());
}
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();
Map<String, UFDouble> prodtolerance = new HashMap();
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(Map.Entry<String, List<String>> entry : sortOrgMarMap.entrySet()) {
Map<String, UFDouble> tempdowntolerance = PMOBPCalUtil.getProdtolerance((String)entry.getKey(), (String[])((List)entry.getValue()).toArray(new String[0]));
if (MMMapUtil.isNotEmpty(tempdowntolerance)) {
prodtolerance.putAll(tempdowntolerance);
}
}
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());
}
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 (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) {
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<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;
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)});
}
UFDouble totalputnum = MMNumberUtil.add(new UFDouble[]{item.getNplanputnum(), item.getNrejectnum()});
if (MMNumberUtil.isLsEqual(item.getNwrnum(), MMNumberUtil.multiply(new UFDouble[]{totalputnum, dparabl}))) {
filterList.add(item);
}
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<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;
if(map.get("naccoutnum") == null){
map.put("naccoutnum", 0);
}
// 物料出库容差 % 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){
// 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;
}
item.setFitemstatus(Integer.valueOf(PMOFItemStatusEnum.FINISH.getEnumValue().getValue()));
item.setTactendtime(new UFDateTime(AppBsContext.getInstance().getBusiDate().toPersisted()));
item.setStatus(1);
putplanfinishList.add(item.getCmoid());
}
}
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<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;
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)});
}
UFDouble totalputnum = MMNumberUtil.add(new UFDouble[]{item.getNplanputnum(), item.getNrejectnum()});
if (MMNumberUtil.isLsEqual(item.getNwrnum(), MMNumberUtil.multiply(new UFDouble[]{totalputnum, dparabl}))) {
filterList.add(item);
}
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<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;
if(map.get("naccoutnum") == null){
map.put("naccoutnum", 0);
}
// 物料出库容差 % 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){
// 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;
}
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);
putplanfinishList.add(item.getCmoid());
}
}
} 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 (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)) {
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();
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);
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);
}
}
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(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";
}
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);
}
}
}
}
if( !MMMapUtil.isEmpty(itemMap2)){
PMOItemVO[] items2 = (PMOItemVO[])itemMap2.values().toArray(new PMOItemVO[0]);
for(PMORewriteParaVO para : paras) {
if (!originbidSet.contains(para.getCpmobid())) {
ExceptionUtils.wrappBusinessException(PMOConstLang.getMSG_PMO_DeleteLine());
}
}
BDPKLockUtil.lockSuperVO(items2);
this.checkMOstatus(items2, headMap);
Set<String> cmaterials = new HashSet();
Set<String> ctrantypes = new HashSet();
Set<String> pk_orgs = new HashSet();
MapList<String, String> sortOrgMarMap = new MapList();
for(PMOItemVO item : items2) {
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());
}
if (!pk_orgs.contains(item.getPk_org())) {
pk_orgs.add(item.getPk_org());
}
sortOrgMarMap.put(item.getPk_org(), item.getCmaterialvid());
}
Map<String, UFDouble> prodtolerance = new HashMap();
for(Map.Entry<String, List<String>> entry : sortOrgMarMap.entrySet()) {
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, items2);
List<PMOPlanOutputVO> planoutputList = new ArrayList();
for(int i = 0; i < items2.length; ++i) {
List<PMORewriteParaVO> paraList = paraMapList.get(items2[i].getCmoid());
PMOPlanOutputVO[] moPlanOutVOS = items2[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;
}
}
return err;
}
if (isupd) {
planoutputList.add(planOutVO);
}
}
}
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);
for(PMORewriteParaVO paravo : paraList) {
UFDouble delNum = MMNumberUtil.toNotNullValue(paravo.getDelNum());
if (MMNumberUtil.isNotNullAndNotZero(delNum)) {
(new NumScaleUtil()).checkNumberScale(new UFDouble[]{delNum}, items2[i].getCunitid());
}
UFDouble wrNum = MMNumberUtil.add(new UFDouble[]{delNum, MMNumberUtil.toNotNullValue(items2[i].getNwrnum())});
items2[i].setNwrnum(wrNum);
PMOBPCalUtil.fillReAssNumber("nplanputnum", "nplanputastnum", items2[i], "vchangerate", "nwrnum", "nwrastnum");
items2[i].setStatus(1);
}
}
List<PMOItemVO> filterList = new ArrayList();
List<String> putplanfinishList = new ArrayList();
for(PMOItemVO item : items2) {
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;
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)});
}
UFDouble totalputnum = MMNumberUtil.add(new UFDouble[]{item.getNplanputnum(), item.getNrejectnum()});
if (MMNumberUtil.isLsEqual(item.getNwrnum(), MMNumberUtil.multiply(new UFDouble[]{totalputnum, dparabl}))) {
filterList.add(item);
}
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";
String pickmsql = "select mm_pickm_b.cbmaterialvid,mm_pickm_b.naccoutnum,mm_pickm_b.nplanoutnum,mm_pickm.vbillcode from mm_pickm_b left join mm_pickm on mm_pickm.cpickmid=mm_pickm_b.cpickmid and mm_pickm.csourcebillrowid='" + item.getCmoid() + "' where mm_pickm_b.dr = 0 AND mm_pickm.dr=0";
List<Map<String,Object>> hmateral = (List<Map<String,Object>>) dao.executeQuery(pickmsql, new MapListProcessor());
List<Map<String,Object>> maps = new ArrayList();
String orgName = MyHelper.transferField(OrgVO.getDefaultTableName(), OrgVO.NAME, OrgVO.PK_ORG, head.getPk_org());
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) {
l=true;
Map<String, Object> map1 =new HashMap<>();
map1.put("vbillcode",map.get("vbillcode").toString());
maps.add(map1);
maps.add(map1);
}
}
if(l){
// 1. 初始化空字符串接收最终错误信息
String err = "";
// 2. 定义Set集合存储唯一的vbillcode天然过滤重复值
Set<String> uniqueVbillCodes = new HashSet<>();
// 3. 第一次遍历收集所有不重复的vbillcode增加非空判断避免空指针异常
for (Map<String, Object> vrowno : maps) {
Object vbillcodeObj = vrowno.get("vbillcode");
if (vbillcodeObj != null) { // 判空防止vbillcode为null时调用toString()报空指针
String vbillcode = vbillcodeObj.toString();
uniqueVbillCodes.add(vbillcode); // Set自动忽略重复值
}
}
// 4. 第二次遍历用StringBuilder拼接不重复的错误信息高效避免频繁创建String对象
if (!uniqueVbillCodes.isEmpty()) { // 无数据时不拼接保持err为空
StringBuilder errSb = new StringBuilder();
for (String uniqueCode : uniqueVbillCodes) {
errSb.append(orgName).append("备料计划").append(uniqueCode).append("存在需退料物资,请处理。");
}
err = errSb.toString(); // 转换为最终字符串
}
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());
}
}
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";
String pickmsql = "select mm_pickm_b.cbmaterialvid,mm_pickm_b.nplanoutnum,mm_pickm_b.naccoutnum,mm_pickm.vbillcode from mm_pickm_b left join mm_pickm on mm_pickm.cpickmid=mm_pickm_b.cpickmid and mm_pickm.csourcebillrowid='" + item.getCmoid() + "' where mm_pickm_b.dr = 0 AND mm_pickm.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();
String pkOrg = head.getPk_org();
String orgName = MyHelper.transferField(OrgVO.getDefaultTableName(), OrgVO.NAME, OrgVO.PK_ORG, pkOrg);
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) {
l=true;
Map<String, Object> map1 =new HashMap<>();
map1.put("vbillcode",map.get("vbillcode").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());
// 1. 初始化空字符串接收最终错误信息
String err = "";
// 2. 定义Set集合存储唯一的vbillcode天然过滤重复值
Set<String> uniqueVbillCodes = new HashSet<>();
// 3. 第一次遍历收集所有不重复的vbillcode增加非空判断避免空指针异常
for (Map<String, Object> vrowno : maps) {
Object vbillcodeObj = vrowno.get("vbillcode");
if (vbillcodeObj != null) { // 判空防止vbillcode为null时调用toString()报空指针
String vbillcode = vbillcodeObj.toString();
uniqueVbillCodes.add(vbillcode); // Set自动忽略重复值
}
}
// 4. 第二次遍历用StringBuilder拼接不重复的错误信息高效避免频繁创建String对象
if (!uniqueVbillCodes.isEmpty()) { // 无数据时不拼接保持err为空
StringBuilder errSb = new StringBuilder();
for (String uniqueCode : uniqueVbillCodes) {
errSb.append(orgName).append("备料计划").append(uniqueCode).append("存在需退料物资,请处理。");
}
err = errSb.toString(); // 转换为最终字符串
}
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);
}
}
}
}
return 0;
} catch (BusinessException e) {
throw new RuntimeException(e);
}
}
private boolean checkIfOrg(String code, Map<String, String> configParams) throws BusinessException {
String targetCode = configParams.get("xbOrg");
private boolean checkIfOrg(String code, Map<String, String> configParams, String planOrg) throws BusinessException {
String targetCode = configParams.get(planOrg);
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;
}
}
return true;
return false;
}
private void checkMOstatus(PMOItemVO[] items, Map<String, PMOHeadVO> headMap) {
if (!MMArrayUtil.isEmpty(items)) {