feat(ic): 精密-材料出库新增--批次号赋值
This commit is contained in:
		
							parent
							
								
									7c09815b56
								
							
						
					
					
						commit
						8180857112
					
				|  | @ -108,6 +108,7 @@ public class InsertBP implements IInsertBP<MaterialOutVO>, | ||||||
| 
 | 
 | ||||||
|         //2025年6月13日09点38分 -- 物料档案基本页签启用项目辅助属性+库存组织未启用项目,采购入库单保存时(包含接口导入)清除行项目,材料出库单保存时(包含接口导入)清除行项目 |         //2025年6月13日09点38分 -- 物料档案基本页签启用项目辅助属性+库存组织未启用项目,采购入库单保存时(包含接口导入)清除行项目,材料出库单保存时(包含接口导入)清除行项目 | ||||||
|         processor.addBeforeRule(new MaterialOutProjectRule()); |         processor.addBeforeRule(new MaterialOutProjectRule()); | ||||||
|  |         processor.addBeforeRule(new MaterialOutBatchCodeRule()); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     @Override |     @Override | ||||||
|  |  | ||||||
|  | @ -0,0 +1,129 @@ | ||||||
|  | package nc.bs.ic.m4d.insert.rule; | ||||||
|  | 
 | ||||||
|  | import nc.bs.framework.common.InvocationInfoProxy; | ||||||
|  | import nc.bs.framework.common.NCLocator; | ||||||
|  | import nc.bs.ic.pub.base.ICRule; | ||||||
|  | import nc.bs.logging.Log; | ||||||
|  | import nc.bs.trade.business.HYPubBO; | ||||||
|  | import nc.bs.uapbd.util.MyHelper; | ||||||
|  | import nc.itf.mmpac.pickm.IPickmQueryService; | ||||||
|  | import nc.itf.uap.IUAPQueryBS; | ||||||
|  | import nc.util.mmf.framework.base.MMValueCheck; | ||||||
|  | import nc.vo.bd.material.MaterialVO; | ||||||
|  | import nc.vo.ic.m4d.entity.MaterialOutBodyVO; | ||||||
|  | import nc.vo.ic.m4d.entity.MaterialOutHeadVO; | ||||||
|  | import nc.vo.ic.m4d.entity.MaterialOutVO; | ||||||
|  | import nc.vo.mmpac.pickm.entity.AggPickmVO; | ||||||
|  | import nc.vo.mmpac.pickm.entity.PickmHeadVO; | ||||||
|  | import nc.vo.org.StockOrgVO; | ||||||
|  | import nc.vo.pub.BusinessException; | ||||||
|  | import nc.vo.pubapp.pattern.exception.ExceptionUtils; | ||||||
|  | import nc.vo.pubapp.pattern.pub.SqlBuilder; | ||||||
|  | import nc.vo.scmf.ic.mbatchcode.BatchcodeVO; | ||||||
|  | import nccloud.baseapp.core.log.NCCForUAPLogger; | ||||||
|  | 
 | ||||||
|  | import java.util.Collection; | ||||||
|  | import java.util.HashMap; | ||||||
|  | import java.util.Map; | ||||||
|  | 
 | ||||||
|  | /** | ||||||
|  |  * 精密-材料出库新增--批次号赋值 | ||||||
|  |  * | ||||||
|  |  * @author mzr | ||||||
|  |  * @date 2025/10/26 | ||||||
|  |  */ | ||||||
|  | public class MaterialOutBatchCodeRule extends ICRule<MaterialOutVO> { | ||||||
|  |     private static final String LOG_INFO_NAME = "jmqylog"; | ||||||
|  |     private static final Log logger = Log.getInstance(LOG_INFO_NAME); | ||||||
|  |     private Map<String, String> configParams; | ||||||
|  |     private IUAPQueryBS queryBS = null; | ||||||
|  | 
 | ||||||
|  |     public final IUAPQueryBS getQueryBS() { | ||||||
|  |         if (null == queryBS) { | ||||||
|  |             queryBS = NCLocator.getInstance().lookup(IUAPQueryBS.class); | ||||||
|  |         } | ||||||
|  |         return queryBS; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     @Override | ||||||
|  |     public void process(MaterialOutVO[] vos) { | ||||||
|  |         if (MMValueCheck.isEmpty(vos)) { | ||||||
|  |             return; | ||||||
|  |         } | ||||||
|  |         try { | ||||||
|  |             configParams = MyHelper.getConfigParams("jm-config", null); | ||||||
|  |             if (configParams.isEmpty()) { | ||||||
|  |                 throw new BusinessException("精密的启源接口缺少配置"); | ||||||
|  |             } | ||||||
|  |             String configMaterialCode = configParams.get("noItemCode"); | ||||||
|  |             if (configMaterialCode == null || configMaterialCode.isEmpty()) { | ||||||
|  |                 return; | ||||||
|  |             } | ||||||
|  |             HYPubBO hyPub = new HYPubBO(); | ||||||
|  |             for (MaterialOutVO vo : vos) { | ||||||
|  |                 MaterialOutHeadVO headVO = vo.getHead(); | ||||||
|  |                 MaterialOutBodyVO[] bodys = vo.getBodys(); | ||||||
|  |                 String pk_org = (String) headVO.getAttributeValue("pk_org"); | ||||||
|  |                 String vtrantypecode = headVO.getVtrantypecode(); | ||||||
|  |                 String orgCode = MyHelper.transferField(StockOrgVO.getDefaultTableName(), StockOrgVO.CODE, StockOrgVO.PK_STOCKORG, pk_org); | ||||||
|  |                 if ("C038".equals(orgCode)) { | ||||||
|  |                     if ("4D-Cxx-58".equals(vtrantypecode)) { | ||||||
|  |                         IPickmQueryService service = NCLocator.getInstance().lookup(IPickmQueryService.class); | ||||||
|  |                         // 批次号赋值 | ||||||
|  |                         for (MaterialOutBodyVO body : bodys) { | ||||||
|  |                             // 备料计划表头主键 | ||||||
|  |                             String cpickmhid = body.getCpickmhid(); | ||||||
|  |                             String cmaterialvid = body.getCmaterialvid(); | ||||||
|  |                             String condition = "pk_material = '" + cmaterialvid + "'"; | ||||||
|  |                             String materialCode = hyPub.findColValue(MaterialVO.getDefaultTableName(), MaterialVO.CODE, condition) + ""; | ||||||
|  |                             if (!configMaterialCode.equals(materialCode)) { | ||||||
|  |                                 continue; | ||||||
|  |                             } | ||||||
|  |                             if (MMValueCheck.isNotEmpty(cpickmhid)) { | ||||||
|  |                                 AggPickmVO aggVO = service.querySingleBillByPk(cpickmhid); | ||||||
|  |                                 if (aggVO == null) { | ||||||
|  |                                     continue; | ||||||
|  |                                 } | ||||||
|  |                                 PickmHeadVO pickmHeadVO = aggVO.getParentVO(); | ||||||
|  |                                 // 来源生产订单明细 | ||||||
|  |                                 String vsourcemorowid = pickmHeadVO.getVsourcemorowid(); | ||||||
|  |                                 NCCForUAPLogger.debug("来源生产订单明细:" + vsourcemorowid); | ||||||
|  |                                 if (vsourcemorowid != null && !vsourcemorowid.isEmpty()) { | ||||||
|  |                                     body.setVbatchcode(vsourcemorowid);// 批次号 | ||||||
|  |                                     Map<String, String> batchMap = getBatchCodeVO(cmaterialvid, vsourcemorowid); | ||||||
|  |                                     String pkBatchcode = batchMap.get(vsourcemorowid); | ||||||
|  |                                     body.setPk_batchcode(pkBatchcode);// 批次档案id | ||||||
|  |                                 } | ||||||
|  |                             } | ||||||
|  | 
 | ||||||
|  |                         } | ||||||
|  |                     } | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |         } catch (BusinessException e) { | ||||||
|  |             logger.error("MaterialOutBatchCodeRule-exp:" + e.getMessage(), e); | ||||||
|  |             ExceptionUtils.wrappException(e); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public Map<String, String> getBatchCodeVO(String cbmaterialvid, String vbatchcode) | ||||||
|  |             throws BusinessException { | ||||||
|  |         Map<String, String> resMap = new HashMap<>(); | ||||||
|  |         SqlBuilder sb = new SqlBuilder(); | ||||||
|  |         sb.append("pk_group", InvocationInfoProxy.getInstance().getGroupId()); | ||||||
|  |         sb.append(" and "); | ||||||
|  |         sb.append("nvl(dr,0)", 0); | ||||||
|  |         sb.append(" and "); | ||||||
|  |         sb.append("cmaterialvid", cbmaterialvid); | ||||||
|  |         sb.append(" and "); | ||||||
|  |         sb.append("vbatchcode", vbatchcode); | ||||||
|  |         Collection<BatchcodeVO> vos = this.getQueryBS().retrieveByClause(BatchcodeVO.class, sb.toString()); | ||||||
|  |         for (BatchcodeVO vo : vos) { | ||||||
|  |             String pk_batchcode = vo.getPk_batchcode(); | ||||||
|  |             String vbatchcode1 = vo.getVbatchcode(); | ||||||
|  |             resMap.put(vbatchcode1, pk_batchcode); | ||||||
|  |         } | ||||||
|  |         return resMap; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  | } | ||||||
		Loading…
	
		Reference in New Issue