生产报告保存前校验回写
This commit is contained in:
parent
3f515edb8f
commit
e4e7412615
|
|
@ -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,16 +62,45 @@ 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) // 空值兜底
|
||||||
|
.stream()
|
||||||
|
.distinct() // 去重核心
|
||||||
|
.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()]));
|
||||||
|
|
||||||
|
|
||||||
|
for(PMORewriteParaVO para : paras) {
|
||||||
|
paraMapList.put(para.getCpmobid(), para);
|
||||||
|
if (!hidList.contains(para.getCpmohid())) {
|
||||||
|
hidList.add(para.getCpmohid());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
PMOAggVO[] aggvos = (new PMOAggVOQueryBP()).getPMOAggVOsByIds((String[])hidList.toArray(new String[0]));
|
PMOAggVO[] aggvos = (new PMOAggVOQueryBP()).getPMOAggVOsByIds((String[])hidList.toArray(new String[0]));
|
||||||
if (MMValueCheck.isEmpty(aggvos)) {
|
if (MMValueCheck.isEmpty(aggvos)) {
|
||||||
ExceptionUtils.wrappBusinessException(PMOConstLang.getMSG_REWRITE_WRNUM_AUTOERROR());
|
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)) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Set<String> originbidSet = new HashSet();
|
Set<String> originbidSet = new HashSet();
|
||||||
Set<String> bidSet = paraMapList.keySet();
|
Set<String> bidSet = paraMapList.keySet();
|
||||||
|
|
@ -78,6 +109,11 @@ public class PwrCheckRewriteAction implements ICommonAction {
|
||||||
|
|
||||||
for(PMOAggVO aggvo : aggvos) {
|
for(PMOAggVO aggvo : aggvos) {
|
||||||
PMOHeadVO headvo = aggvo.getParentVO();
|
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())) {
|
if (hidList.contains(headvo.getCpmohid())) {
|
||||||
headMap.put(headvo.getCpmohid(), headvo);
|
headMap.put(headvo.getCpmohid(), headvo);
|
||||||
}
|
}
|
||||||
|
|
@ -94,16 +130,17 @@ public class PwrCheckRewriteAction implements ICommonAction {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (MMMapUtil.isEmpty(itemMap)) {
|
if (MMMapUtil.isEmpty(itemMap)) {
|
||||||
return null;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
PMOItemVO[] items = (PMOItemVO[])itemMap.values().toArray(new PMOItemVO[0]);
|
PMOItemVO[] items = (PMOItemVO[])itemMap.values().toArray(new PMOItemVO[0]);
|
||||||
List<String> bids = (List<String>) map2.get("bids");
|
|
||||||
for(String para : bids) {
|
for(PMORewriteParaVO para : paras) {
|
||||||
if (!originbidSet.contains(para)) {
|
if (!originbidSet.contains(para.getCpmobid())) {
|
||||||
ExceptionUtils.wrappBusinessException(PMOConstLang.getMSG_PMO_DeleteLine());
|
ExceptionUtils.wrappBusinessException(PMOConstLang.getMSG_PMO_DeleteLine());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BDPKLockUtil.lockSuperVO(items);
|
BDPKLockUtil.lockSuperVO(items);
|
||||||
this.checkMOstatus(items, headMap);
|
this.checkMOstatus(items, headMap);
|
||||||
Set<String> cmaterials = new HashSet();
|
Set<String> cmaterials = new HashSet();
|
||||||
|
|
@ -231,6 +268,9 @@ public class PwrCheckRewriteAction implements ICommonAction {
|
||||||
Boolean l=false;
|
Boolean l=false;
|
||||||
for (Map<String,Object> map : hmateral) {
|
for (Map<String,Object> map : hmateral) {
|
||||||
String material =MaterialVO.CODE+","+MaterialVO.NAME+","+MaterialVO.OUTTOLERANCE;
|
String material =MaterialVO.CODE+","+MaterialVO.NAME+","+MaterialVO.OUTTOLERANCE;
|
||||||
|
if(map.get("naccoutnum") == null){
|
||||||
|
map.put("naccoutnum", 0);
|
||||||
|
}
|
||||||
// ÎïÁϳö¿âÈݲî % 0.0000
|
// ÎïÁϳö¿âÈݲî % 0.0000
|
||||||
Map<String, Object> goodsMap = MyHelper.transferFields(MaterialVO.getDefaultTableName(), material, MaterialVO.PK_MATERIAL, item.getCmaterialvid());
|
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";
|
String Outtolerance= null !=goodsMap.get("outtolerance") ? goodsMap.get("outtolerance").toString() : "0";
|
||||||
|
|
@ -258,76 +298,102 @@ public class PwrCheckRewriteAction implements ICommonAction {
|
||||||
}
|
}
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} 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
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
item.setFitemstatus(Integer.valueOf(PMOFItemStatusEnum.FINISH.getEnumValue().getValue()));
|
item.setFitemstatus(Integer.valueOf(PMOFItemStatusEnum.FINISH.getEnumValue().getValue()));
|
||||||
item.setTactendtime(new UFDateTime(AppBsContext.getInstance().getBusiDate().toPersisted()));
|
item.setTactendtime(new UFDateTime(AppBsContext.getInstance().getBusiDate().toPersisted()));
|
||||||
item.setStatus(1);
|
item.setStatus(1);
|
||||||
putplanfinishList.add(item.getCmoid());
|
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";
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
} 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("");
|
||||||
|
|
|
||||||
|
|
@ -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><!-- 生产订单工作台 -->
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue