委外订单生成备料明细优化
This commit is contained in:
		
							parent
							
								
									842da0669f
								
							
						
					
					
						commit
						1f38628e81
					
				|  | @ -0,0 +1,176 @@ | |||
| // | ||||
| // Source code recreated from a .class file by IntelliJ IDEA | ||||
| // (powered by FernFlower decompiler) | ||||
| // | ||||
| 
 | ||||
| package nc.bs.mmpac.pickm.bp; | ||||
| 
 | ||||
| import nc.bs.mmpac.pickm.plugin.PickmPluginPoint; | ||||
| import nc.bs.mmpac.pickm.rule.*; | ||||
| import nc.bs.mmpac.pickm.rule.ic.PickmATPCheckRule; | ||||
| import nc.bs.mmpac.pickm.rule.ic.PickmAutoReserveRule; | ||||
| import nc.bs.mmpac.pickm.rule.sc.PickmSetDeftValueForScRule; | ||||
| import nc.bs.mmpac.pickm.rule.sc.PickmSetItemDeftValueForScRule; | ||||
| import nc.bs.mmpub.rule.MMAutoMaterialAssignRule; | ||||
| import nc.bs.pubapp.pub.rule.FieldLengthCheckRule; | ||||
| import nc.bs.pubapp.pub.rule.OrgDisabledCheckRule; | ||||
| import nc.bsutil.mmpac.pickm.PickmSagasUtil; | ||||
| import nc.impl.pubapp.bd.userdef.UserDefSaveRule; | ||||
| import nc.impl.pubapp.pattern.data.bill.template.BillInsertOperator; | ||||
| import nc.impl.pubapp.pattern.data.bill.template.InsertBPTemplate; | ||||
| import nc.impl.pubapp.pattern.data.bill.tool.BillTransferTool; | ||||
| import nc.impl.pubapp.pattern.rule.IRule; | ||||
| import nc.impl.pubapp.pattern.rule.processer.AroundProcesser; | ||||
| import nc.impl.pubapp.pattern.rule.template.IOperator; | ||||
| import nc.util.mmf.busi.rule.MMBillCodeCheckAndTrantypeRule; | ||||
| import nc.util.mmf.busi.rule.MMCreateBillcodeAndTrantypecodeRule; | ||||
| import nc.util.mmf.framework.base.MMValueCheck; | ||||
| import nc.vo.mmpac.pickm.entity.AggPickmVO; | ||||
| import nc.vo.mmpac.pickm.entity.PickmHeadVO; | ||||
| import nc.vo.mmpac.pickm.entity.PickmItemVO; | ||||
| import nc.vo.mmpac.pickm.enumeration.FsourcetypeEnum; | ||||
| 
 | ||||
| import java.util.ArrayList; | ||||
| import java.util.List; | ||||
| 
 | ||||
| public class PickmInsertForScBP { | ||||
|     public PickmInsertForScBP() { | ||||
|     } | ||||
| 
 | ||||
|     public void savePickmForSc(PickmHeadVO[] headVOs) { | ||||
|         if (!MMValueCheck.isEmpty(headVOs)) { | ||||
|             List<AggPickmVO> aggPickmVOList = new ArrayList(); | ||||
|             AggPickmVO aggPickmVO = null; | ||||
| 
 | ||||
|             for(PickmHeadVO headVO : headVOs) { | ||||
|                 headVO.setFsourcetype(FsourcetypeEnum.WWBILL_STATE.toInteger()); | ||||
|                 aggPickmVO = new AggPickmVO(); | ||||
|                 aggPickmVO.setParent(headVO); | ||||
|                 aggPickmVOList.add(aggPickmVO); | ||||
|             } | ||||
| 
 | ||||
|             AggPickmVO[] retVOs = this.savePickmForSc((AggPickmVO[])aggPickmVOList.toArray(new AggPickmVO[0])); | ||||
|             IRule<AggPickmVO> pickmAutoApproveRule = new PickmAutoApproveAfterSaveRule(); | ||||
|             pickmAutoApproveRule.process(retVOs); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     public void savePickmForSc2(AggPickmVO[] vos) { | ||||
|         if (!MMValueCheck.isEmpty(vos)) { | ||||
|             AggPickmVO[] retVOs = this.savePickmForSc(vos); | ||||
|             IRule<AggPickmVO> pickmAutoApproveRule = new PickmAutoApproveAfterSaveRule(); | ||||
|             pickmAutoApproveRule.process(retVOs); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     private void addAfterRule(AroundProcesser<AggPickmVO> processor) { | ||||
|         IRule<AggPickmVO> billCodeCheckRule = new MMBillCodeCheckAndTrantypeRule("55A3", "vbillcode", "pk_group", "pk_org", "vbusitype"); | ||||
|         processor.addAfterRule(billCodeCheckRule); | ||||
|         IRule<AggPickmVO> atpCheckRule = new PickmATPCheckRule(false, (AggPickmVO[])null); | ||||
|         processor.addAfterRule(atpCheckRule); | ||||
|         IRule<AggPickmVO> autoReserveRule = new PickmAutoReserveRule(); | ||||
|         processor.addAfterRule(autoReserveRule); | ||||
|     } | ||||
| 
 | ||||
|     private void addBeforeRule(AroundProcesser<AggPickmVO> processor) { | ||||
|         IRule<AggPickmVO> orgRule = new OrgDisabledCheckRule("pk_org", "FACTORYTYPE000000000"); | ||||
|         processor.addBeforeRule(orgRule); | ||||
|         IRule<AggPickmVO> getMakeDateRule = new PickmMakeDateRule(); | ||||
|         processor.addBeforeRule(getMakeDateRule); | ||||
|         IRule<AggPickmVO> setForScRule = new PickmSetDeftValueForScRule(); | ||||
|         processor.addBeforeRule(setForScRule); | ||||
| 
 | ||||
|         IRule<AggPickmVO> billcodeRule = new MMCreateBillcodeAndTrantypecodeRule("55A3", "vbillcode", "pk_group", "pk_org", "vbusitype"); | ||||
|         processor.addBeforeRule(billcodeRule); | ||||
|         IRule<AggPickmVO> createSubItemRule = new PickmCreateSubItemRule(false); | ||||
|         processor.addBeforeRule(createSubItemRule); | ||||
|         IRule<AggPickmVO> setItemForScRule = new PickmSetItemDeftValueForScRule(); | ||||
|         processor.addBeforeRule(setItemForScRule); | ||||
|         IRule<AggPickmVO> sameRule = new PickmCheckSameStockRule(); | ||||
|         processor.addBeforeRule(sameRule); | ||||
| 
 | ||||
|         IRule<AggPickmVO> checkSameRow = new PickmRowNoRule(); | ||||
|         processor.addBeforeRule(checkSameRow); | ||||
|         IRule<AggPickmVO> lengthCheckRule = new FieldLengthCheckRule(); | ||||
|         processor.addBeforeRule(lengthCheckRule); | ||||
|         IRule<AggPickmVO> autoHMaterialAssignRule = new MMAutoMaterialAssignRule("cmaterialvid", (String)null, new String[]{"pk_org"}, (String[])null); | ||||
|         processor.addBeforeFinalRule(autoHMaterialAssignRule); | ||||
|         IRule<AggPickmVO> autobMaterialAssignRule = new MMAutoMaterialAssignRule((String)null, "cbmaterialvid", new String[]{"pk_org"}, new String[]{"cdeliverorgid", "csupplyorgid"}); | ||||
|         processor.addBeforeFinalRule(autobMaterialAssignRule); | ||||
|         IRule<AggPickmVO> marperRule = new PickmCheckMaterialPermissionRule(); | ||||
|         processor.addBeforeRule(marperRule); | ||||
|         IRule<AggPickmVO> bmarperRule = new PickmCheckItemMaterialPermissionRule(); | ||||
|         processor.addBeforeRule(bmarperRule); | ||||
|         IRule<AggPickmVO> pickmSaveRule = new PickmSaveRule(); | ||||
|         processor.addBeforeRule(pickmSaveRule); | ||||
|         IRule<AggPickmVO> atpCheckRule = new PickmATPCheckRule(true, (AggPickmVO[])null); | ||||
|         processor.addBeforeRule(atpCheckRule); | ||||
|         IRule<AggPickmVO> userDefSaveRule = new UserDefSaveRule(new String[]{"vdef", "vbdef"}, new Class[]{PickmHeadVO.class, PickmItemVO.class}); | ||||
|         processor.addBeforeRule(userDefSaveRule); | ||||
|     } | ||||
| 
 | ||||
|     private AggPickmVO[] savePickmForSc(AggPickmVO[] vos) { | ||||
|         if (MMValueCheck.isEmpty(vos)) { | ||||
|             return null; | ||||
|         } else { | ||||
|             new BillTransferTool(vos); | ||||
|             InsertBPTemplate<AggPickmVO> bp = new InsertBPTemplate(PickmPluginPoint.INSERTFORSC); | ||||
|             this.addBeforeRule(bp.getAroundProcesser()); | ||||
|             this.addAfterRule(bp.getAroundProcesser()); | ||||
|             bp.getAroundProcesser().before(vos); | ||||
|             IOperator<AggPickmVO> operator = new BillInsertOperator(); | ||||
|             AggPickmVO[] aggvos = (AggPickmVO[])operator.operate(vos); | ||||
|             PickmSagasUtil.addSagaAndCompensate4Insert(aggvos); | ||||
|             bp.getAroundProcesser().after(aggvos); | ||||
|             return aggvos; | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     public void savePickmForScSagasCheck(PickmHeadVO[] headVOs) { | ||||
|         if (!MMValueCheck.isEmpty(headVOs)) { | ||||
|             List<AggPickmVO> aggPickmVOList = new ArrayList(); | ||||
|             AggPickmVO aggPickmVO = null; | ||||
| 
 | ||||
|             for(PickmHeadVO headVO : headVOs) { | ||||
|                 headVO.setFsourcetype(FsourcetypeEnum.WWBILL_STATE.toInteger()); | ||||
|                 aggPickmVO = new AggPickmVO(); | ||||
|                 aggPickmVO.setParent(headVO); | ||||
|                 aggPickmVOList.add(aggPickmVO); | ||||
|             } | ||||
| 
 | ||||
|             new BillTransferTool((AggPickmVO[])aggPickmVOList.toArray(new AggPickmVO[0])); | ||||
|             InsertBPTemplate<AggPickmVO> bp = new InsertBPTemplate(PickmPluginPoint.INSERTFORSC); | ||||
|             this.addBeforeRuleSagasCheck(bp.getAroundProcesser()); | ||||
|             bp.getAroundProcesser().before((AggPickmVO[])aggPickmVOList.toArray(new AggPickmVO[0])); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     private void addBeforeRuleSagasCheck(AroundProcesser<AggPickmVO> processor) { | ||||
|         IRule<AggPickmVO> orgRule = new OrgDisabledCheckRule("pk_org", "FACTORYTYPE000000000"); | ||||
|         processor.addBeforeRule(orgRule); | ||||
|         IRule<AggPickmVO> getMakeDateRule = new PickmMakeDateRule(); | ||||
|         processor.addBeforeRule(getMakeDateRule); | ||||
|         IRule<AggPickmVO> setForScRule = new PickmSetDeftValueForScRule(); | ||||
|         processor.addBeforeRule(setForScRule); | ||||
|         IRule<AggPickmVO> createSubItemRule = new PickmCreateSubItemRule(false); | ||||
|         processor.addBeforeRule(createSubItemRule); | ||||
|         IRule<AggPickmVO> setItemForScRule = new PickmSetItemDeftValueForScRule(); | ||||
|         processor.addBeforeRule(setItemForScRule); | ||||
|         IRule<AggPickmVO> sameRule = new PickmCheckSameStockRule(); | ||||
|         processor.addBeforeRule(sameRule); | ||||
|         IRule<AggPickmVO> checkSameRow = new PickmRowNoRule(); | ||||
|         processor.addBeforeRule(checkSameRow); | ||||
|         IRule<AggPickmVO> lengthCheckRule = new FieldLengthCheckRule(); | ||||
|         processor.addBeforeRule(lengthCheckRule); | ||||
|         IRule<AggPickmVO> marperRule = new PickmCheckMaterialPermissionRule(); | ||||
|         processor.addBeforeRule(marperRule); | ||||
|         IRule<AggPickmVO> bmarperRule = new PickmCheckItemMaterialPermissionRule(); | ||||
|         processor.addBeforeRule(bmarperRule); | ||||
|         IRule<AggPickmVO> pickmSaveRule = new PickmSaveRule(); | ||||
|         processor.addBeforeRule(pickmSaveRule); | ||||
|         IRule<AggPickmVO> atpCheckRule = new PickmATPCheckRule(true, (AggPickmVO[])null); | ||||
|         processor.addBeforeRule(atpCheckRule); | ||||
|         IRule<AggPickmVO> userDefSaveRule = new UserDefSaveRule(new String[]{"vdef", "vbdef"}, new Class[]{PickmHeadVO.class, PickmItemVO.class}); | ||||
|         processor.addBeforeRule(userDefSaveRule); | ||||
|     } | ||||
| } | ||||
|  | @ -0,0 +1,110 @@ | |||
| // | ||||
| // Source code recreated from a .class file by IntelliJ IDEA | ||||
| // (powered by FernFlower decompiler) | ||||
| // | ||||
| 
 | ||||
| package nc.impl.sc.m61.action.maintain.rule; | ||||
| 
 | ||||
| 
 | ||||
| import nc.bs.framework.common.NCLocator; | ||||
| import nc.impl.pubapp.pattern.rule.IRule; | ||||
| import nc.itf.mmpac.pickm.IPickmMaintainService; | ||||
| import nc.itf.sc.m61.compenstate.IScOrderSagasCompensate; | ||||
| import nc.itf.sc.reference.mm.PubMMPACService; | ||||
| import nc.itf.scmpub.reference.uap.pf.PfServiceScmUtil; | ||||
| import nc.vo.mmpac.pickm.entity.AggPickmVO; | ||||
| import nc.vo.mmpac.pickm.entity.PickmHeadVO; | ||||
| import nc.vo.pub.BusinessException; | ||||
| import nc.vo.pubapp.pattern.exception.ExceptionUtils; | ||||
| import nc.vo.sc.m61.entity.SCOrderItemVO; | ||||
| import nc.vo.sc.m61.entity.SCOrderVO; | ||||
| import nc.vo.scmpub.res.billtype.MMBillType; | ||||
| import nc.vo.scmpub.res.billtype.SCBillType; | ||||
| import nc.vo.scmpub.util.ArrayUtil; | ||||
| import nccloud.commons.lang.ArrayUtils; | ||||
| import nccloud.pubitf.sc.pub.util.ScSagasUtil; | ||||
| 
 | ||||
| import java.io.Serializable; | ||||
| import java.util.ArrayList; | ||||
| import java.util.HashMap; | ||||
| import java.util.List; | ||||
| import java.util.Map; | ||||
| 
 | ||||
| public class SCOrderPushMoRule implements IRule<SCOrderVO> { | ||||
|     public SCOrderPushMoRule() { | ||||
|     } | ||||
| 
 | ||||
|     public void process(SCOrderVO[] vos) { | ||||
|         if (!ArrayUtils.isEmpty(vos)) { | ||||
|             try { | ||||
|                 // 分组处理逻辑 | ||||
|                 List<SCOrderVO> specialList = new ArrayList<>(); | ||||
|                 List<SCOrderVO> normalList = new ArrayList<>(); | ||||
|                 for (SCOrderVO vo : vos) { | ||||
|                     // 假设通过 getBilltype() 获取单据类型,请根据实际字段调整 | ||||
|                     if ("61-Cxx-01".equals(vo.getParentVO().getVtrantypecode()) ){ | ||||
|                         specialList.add(vo); | ||||
|                     } else { | ||||
|                         normalList.add(vo); | ||||
|                     } | ||||
|                 } | ||||
| 
 | ||||
|                 List<PickmHeadVO> headList = new ArrayList<>(); | ||||
|                 // 特殊类型处理 | ||||
|                 if (!specialList.isEmpty()) { | ||||
|                     AggPickmVO[] specialPickVos = (AggPickmVO[]) PfServiceScmUtil.exeVOChangeByBillItfDef( | ||||
|                             "61-Cxx-01", // 特殊类型编码 | ||||
|                             MMBillType.PickMo.getCode(), | ||||
|                             vos); | ||||
|                     IPickmMaintainService ipickmMaintainService = NCLocator.getInstance().lookup(IPickmMaintainService.class); | ||||
|                     ipickmMaintainService.insert(specialPickVos); | ||||
|                 } | ||||
| 
 | ||||
|                 // 常规处理 | ||||
|                 if (!normalList.isEmpty()) { | ||||
|                     AggPickmVO[] normalPickVos = (AggPickmVO[]) PfServiceScmUtil.exeVOChangeByBillItfDef( | ||||
|                             SCBillType.Order.getCode(), | ||||
|                             MMBillType.PickMo.getCode(), | ||||
|                             normalList.toArray(new SCOrderVO[0])); | ||||
|                     for(AggPickmVO vo : normalPickVos) { | ||||
|                         PickmHeadVO head = (PickmHeadVO)vo.getParent(); | ||||
|                         headList.add(head); | ||||
|                     } | ||||
|                 } | ||||
|                 if (headList.size() > 0) { | ||||
|                     this.addSagaAndCompensate(vos); | ||||
|                     PubMMPACService.pushMMPac((PickmHeadVO[])headList.toArray(new PickmHeadVO[headList.size()])); | ||||
|                 } | ||||
|             } catch (BusinessException e) { | ||||
|                 ExceptionUtils.wrappException(e); | ||||
|             } | ||||
| 
 | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     private void addSagaAndCompensate(SCOrderVO[] vos) { | ||||
|         ScSagasUtil.frozenAndAddSaga(vos, "pickMo", SCBillType.Order.getCode()); | ||||
|         if (!ArrayUtil.isEmpty(vos)) { | ||||
|             Map<String, Serializable> map = new HashMap(); | ||||
|             map.put("opertaion", "pickMo"); | ||||
|             List<String> bids = new ArrayList(); | ||||
| 
 | ||||
|             for(SCOrderVO scOrderVO : vos) { | ||||
|                 SCOrderItemVO[] itemVOs = scOrderVO.getChildrenVO(); | ||||
| 
 | ||||
|                 for(SCOrderItemVO bvo : itemVOs) { | ||||
|                     bids.add(bvo.getPk_order_b()); | ||||
|                 } | ||||
|             } | ||||
| 
 | ||||
|             map.put("pk_order_b", bids.toArray(new String[0])); | ||||
| 
 | ||||
|             try { | ||||
|                 ScSagasUtil.compensate(IScOrderSagasCompensate.class, map); | ||||
|             } catch (BusinessException e) { | ||||
|                 ExceptionUtils.wrappException(e); | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|     } | ||||
| } | ||||
		Loading…
	
		Reference in New Issue