不合格检验单生成批次号、检验单数量带入调整
This commit is contained in:
		
							parent
							
								
									8839c46236
								
							
						
					
					
						commit
						728d0fabed
					
				|  | @ -14,17 +14,22 @@ import org.apache.commons.lang3.StringUtils; | ||||||
| import cn.hutool.core.bean.BeanUtil; | import cn.hutool.core.bean.BeanUtil; | ||||||
| import nc.bs.dao.BaseDAO; | import nc.bs.dao.BaseDAO; | ||||||
| import nc.bs.framework.common.InvocationInfoProxy; | import nc.bs.framework.common.InvocationInfoProxy; | ||||||
|  | import nc.bs.framework.common.NCLocator; | ||||||
| import nc.bs.pub.common.PfServiceScmUtil; | import nc.bs.pub.common.PfServiceScmUtil; | ||||||
| import nc.bs.trade.business.HYPubBO; | import nc.bs.trade.business.HYPubBO; | ||||||
| import nc.codeplatform.framework.service.ServiceSupport; | import nc.codeplatform.framework.service.ServiceSupport; | ||||||
|  | import nc.itf.ic.batch.IBatchGenerateForPU; | ||||||
| import nc.itf.pu.dhjyd.dhjydmaster.IDhjydMasterVOService; | import nc.itf.pu.dhjyd.dhjydmaster.IDhjydMasterVOService; | ||||||
|  | import nc.itf.scmf.ic.mbatchcode.IBatchcodeMaintainService; | ||||||
| import nc.jdbc.framework.processor.ColumnProcessor; | import nc.jdbc.framework.processor.ColumnProcessor; | ||||||
| import nc.jdbc.framework.processor.MapListProcessor; | import nc.jdbc.framework.processor.MapListProcessor; | ||||||
| import nc.jdbc.framework.processor.MapProcessor; | import nc.jdbc.framework.processor.MapProcessor; | ||||||
| import nc.pub.billcode.vo.BillCodeContext; | import nc.pub.billcode.vo.BillCodeContext; | ||||||
|  | import nc.vo.bd.meta.BatchOperateVO; | ||||||
| import nc.vo.pu.dhjyd.AggDhjydMasterVO; | import nc.vo.pu.dhjyd.AggDhjydMasterVO; | ||||||
| import nc.vo.pu.dhjyd.DhjydMasterVO; | import nc.vo.pu.dhjyd.DhjydMasterVO; | ||||||
| import nc.vo.pu.dhjyd.DhjydSlave0VO; | import nc.vo.pu.dhjyd.DhjydSlave0VO; | ||||||
|  | import nc.vo.pu.m23.rule.BatchCodeFieldMap; | ||||||
| import nc.vo.pub.BusinessException; | import nc.vo.pub.BusinessException; | ||||||
| import nc.vo.pub.ISuperVO; | import nc.vo.pub.ISuperVO; | ||||||
| import nc.vo.pub.SuperVO; | import nc.vo.pub.SuperVO; | ||||||
|  | @ -33,6 +38,7 @@ import nc.vo.pub.lang.UFDateTime; | ||||||
| import nc.vo.pub.lang.UFDouble; | import nc.vo.pub.lang.UFDouble; | ||||||
| import nc.vo.pub.pf.BillStatusEnum; | import nc.vo.pub.pf.BillStatusEnum; | ||||||
| import nc.vo.pubapp.pattern.pub.MathTool; | import nc.vo.pubapp.pattern.pub.MathTool; | ||||||
|  | import nc.vo.scmf.ic.mbatchcode.BatchcodeVO; | ||||||
| import nccloud.framework.core.exception.ExceptionUtils; | import nccloud.framework.core.exception.ExceptionUtils; | ||||||
| 
 | 
 | ||||||
| public class DhjydMasterVOServiceImpl extends ServiceSupport implements IDhjydMasterVOService { | public class DhjydMasterVOServiceImpl extends ServiceSupport implements IDhjydMasterVOService { | ||||||
|  | @ -232,7 +238,10 @@ public class DhjydMasterVOServiceImpl extends ServiceSupport implements IDhjydMa | ||||||
| 		String pk = getVOPrimaryKey(vo); | 		String pk = getVOPrimaryKey(vo); | ||||||
| 		setDefaultVal(vo); | 		setDefaultVal(vo); | ||||||
| 		if (StringUtils.isEmpty(pk)) { | 		if (StringUtils.isEmpty(pk)) { | ||||||
| 			return dao.insert(vo); // ²åÈë | 			AggDhjydMasterVO[] vos = dao.insert(vo); | ||||||
|  | 			addBatchcodeFromBill(vos); | ||||||
|  | 			// return dao.insert(vo); // 插入 | ||||||
|  | 			return vos; | ||||||
| 		} else { | 		} else { | ||||||
| 			return dao.update(vo); // 更新 | 			return dao.update(vo); // 更新 | ||||||
| 		} | 		} | ||||||
|  | @ -664,11 +673,9 @@ public class DhjydMasterVOServiceImpl extends ServiceSupport implements IDhjydMa | ||||||
| 					testResMap.put(map.getOrDefault("code", "") + "", map.getOrDefault("pk_defdoc", "") + ""); | 					testResMap.put(map.getOrDefault("code", "") + "", map.getOrDefault("pk_defdoc", "") + ""); | ||||||
| 				} | 				} | ||||||
| 			} | 			} | ||||||
| 			String def2 = oldVo.getDef2();// ÊýÁ¿ | 			UFDouble qualifiednum = oldVo.getQualifiednum(); // 数量 | ||||||
| 			// UFDouble nunqualifiednum = oldVo.getNunqualifiednum(); |  | ||||||
| 			String vbatch = (oldVo.getVbatch() != null) ? oldVo.getVbatch() : "";// 批次号 | 			String vbatch = (oldVo.getVbatch() != null) ? oldVo.getVbatch() : "";// 批次号 | ||||||
| 			oldVo.setDef2("0"); | 			oldVo.setQualifiednum(UFDouble.ZERO_DBL); | ||||||
| 			// oldVo.setNunqualifiednum(UFDouble.ZERO_DBL); |  | ||||||
| 			DhjydSlave0VO vo0 = new DhjydSlave0VO(); | 			DhjydSlave0VO vo0 = new DhjydSlave0VO(); | ||||||
| 			DhjydSlave0VO vo1 = new DhjydSlave0VO(); | 			DhjydSlave0VO vo1 = new DhjydSlave0VO(); | ||||||
| 			DhjydSlave0VO vo2 = new DhjydSlave0VO(); | 			DhjydSlave0VO vo2 = new DhjydSlave0VO(); | ||||||
|  | @ -679,9 +686,8 @@ public class DhjydMasterVOServiceImpl extends ServiceSupport implements IDhjydMa | ||||||
| 			// 第1行 合格 第2行 回用 第3行 不合格 | 			// 第1行 合格 第2行 回用 第3行 不合格 | ||||||
| 			if ("01".equals(def1Code)) { | 			if ("01".equals(def1Code)) { | ||||||
| 				// 合格 | 				// 合格 | ||||||
| 				// vo0.setQualifiednum(qualifiednum); | 				vo0.setQualifiednum(qualifiednum); | ||||||
| 				vo0.setDef2(def2); | 				// vo0.setVbatch(vbatch + vbatchStr[0]); | ||||||
| 				vo0.setVbatch(vbatch + vbatchStr[0]); |  | ||||||
| 				newVOs[0] = vo0; | 				newVOs[0] = vo0; | ||||||
| 
 | 
 | ||||||
| 				// 回用 | 				// 回用 | ||||||
|  | @ -698,9 +704,9 @@ public class DhjydMasterVOServiceImpl extends ServiceSupport implements IDhjydMa | ||||||
| 				// mainVO.setNnum(qualifiednum); | 				// mainVO.setNnum(qualifiednum); | ||||||
| 			} else if ("02".equals(def1Code)) { | 			} else if ("02".equals(def1Code)) { | ||||||
| 				// 合格 | 				// 合格 | ||||||
| 				vo0.setDef2(def2); | 				vo0.setQualifiednum(qualifiednum); | ||||||
| 				vo0.setAttributeValue("def1", testResMap.get("01")); | 				vo0.setAttributeValue("def1", testResMap.get("01")); | ||||||
| 				vo0.setVbatch(vbatch + vbatchStr[0]); | 				// vo0.setVbatch(vbatch + vbatchStr[0]); | ||||||
| 				newVOs[0] = vo0; | 				newVOs[0] = vo0; | ||||||
| 
 | 
 | ||||||
| 				// 回用 | 				// 回用 | ||||||
|  | @ -715,10 +721,10 @@ public class DhjydMasterVOServiceImpl extends ServiceSupport implements IDhjydMa | ||||||
| 				// mainVO.setNnum(qualifiednum); | 				// mainVO.setNnum(qualifiednum); | ||||||
| 			} else if ("03".equals(def1Code)) { | 			} else if ("03".equals(def1Code)) { | ||||||
| 				// 合格 | 				// 合格 | ||||||
| 				vo0.setDef2(def2); | 				vo0.setQualifiednum(qualifiednum); | ||||||
| 				// 设置检验结果的值 | 				// 设置检验结果的值 | ||||||
| 				vo0.setAttributeValue("def1", testResMap.get("01")); | 				vo0.setAttributeValue("def1", testResMap.get("01")); | ||||||
| 				vo0.setVbatch(vbatch + vbatchStr[0]); | 				// vo0.setVbatch(vbatch + vbatchStr[0]); | ||||||
| 				newVOs[0] = vo0; | 				newVOs[0] = vo0; | ||||||
| 
 | 
 | ||||||
| 				// 回用 | 				// 回用 | ||||||
|  | @ -791,6 +797,62 @@ public class DhjydMasterVOServiceImpl extends ServiceSupport implements IDhjydMa | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | 	@Override | ||||||
|  | 	public void addBatchcodeFromBill(AggDhjydMasterVO[] vos) throws BusinessException { | ||||||
|  | 		if (ArrayUtils.isEmpty(vos)) { | ||||||
|  | 			return; | ||||||
|  | 		} | ||||||
|  | 		for (AggDhjydMasterVO vo : vos) { | ||||||
|  | 			ISuperVO mainVo = vo.getParent(); | ||||||
|  | 			// 判断是否为不合格检验单,不是则直接跳过 | ||||||
|  | 			if (!"DHJY-Cxx-02".equals(mainVo.getAttributeValue("transtype"))) { | ||||||
|  | 				continue; | ||||||
|  | 			} | ||||||
|  | 			DhjydSlave0VO[] dhjydSlave0VOs = (DhjydSlave0VO[]) vo.getChildren(DhjydSlave0VO.class); | ||||||
|  | 			for (int i = 0; i < dhjydSlave0VOs.length; i++) { | ||||||
|  | 				DhjydSlave0VO dhjydSlave0VO = dhjydSlave0VOs[i]; | ||||||
|  | 				// 新批次号 | ||||||
|  | 				String vbatch = dhjydSlave0VO.getVbatch(); | ||||||
|  | 				// 旧批次号 | ||||||
|  | 				String vbatch1 = vbatch; | ||||||
|  | 				if (vbatch.contains("回用")) { | ||||||
|  | 					vbatch1 = vbatch.replace("-回用", ""); | ||||||
|  | 				} else if (vbatch.contains("不合格")) { | ||||||
|  | 					vbatch1 = vbatch.replace("-不合格", ""); | ||||||
|  | 				} else { | ||||||
|  | 					continue; | ||||||
|  | 				} | ||||||
|  | 
 | ||||||
|  | 				// 根据批次号编码查询 | ||||||
|  | 				IBatchcodeMaintainService batchcodeMaintainService = (IBatchcodeMaintainService) NCLocator.getInstance() | ||||||
|  | 						.lookup(IBatchcodeMaintainService.class); | ||||||
|  | 				String whereSql = " vbatchcode = '[vbatchcode]' "; | ||||||
|  | 				whereSql = whereSql.replace("[vbatchcode]", vbatch1); | ||||||
|  | 				// whereSql = whereSql.replace("[vbatchcode]", "2024"); | ||||||
|  | 				// 获取旧批次号的实体 | ||||||
|  | 				BatchcodeVO[] batchcodes = (BatchcodeVO[]) batchcodeMaintainService.selectByWhereSql(whereSql, | ||||||
|  | 						BatchcodeVO.class); | ||||||
|  | 				// 新批次号 | ||||||
|  | 				for (int j = 0; j < batchcodes.length; j++) { | ||||||
|  | 					BatchcodeVO batchcodeVO = batchcodes[j]; | ||||||
|  | 					batchcodeVO.setPk_batchcode(null); | ||||||
|  | 					batchcodeVO.setVbatchcode(vbatch); | ||||||
|  | 					batchcodeVO.setStatus(VOStatus.NEW); | ||||||
|  | 				} | ||||||
|  | 				// 新增新的批次号 | ||||||
|  | 				if ((batchcodes != null) && (batchcodes.length > 0)) { | ||||||
|  | 					IBatchcodeMaintainService maintainService = NCLocator.getInstance() | ||||||
|  | 							.lookup(IBatchcodeMaintainService.class); | ||||||
|  | 					BatchOperateVO operateVO = new BatchOperateVO(); | ||||||
|  | 					operateVO.setAddObjs(batchcodes); | ||||||
|  | 					maintainService.batchSave(operateVO); | ||||||
|  | 					// return (BatchcodeVO[]) operateVO.getAddObjs(); | ||||||
|  | 				} | ||||||
|  | 
 | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
| 	@Override | 	@Override | ||||||
| 	public AggDhjydMasterVO[] callbackSAVEBASE(AggDhjydMasterVO... vos) throws BusinessException { | 	public AggDhjydMasterVO[] callbackSAVEBASE(AggDhjydMasterVO... vos) throws BusinessException { | ||||||
| 		if (ArrayUtils.isEmpty(vos)) { | 		if (ArrayUtils.isEmpty(vos)) { | ||||||
|  |  | ||||||
|  | @ -3,48 +3,44 @@ package nc.bs.pub.action; | ||||||
| import java.util.Arrays; | import java.util.Arrays; | ||||||
| 
 | 
 | ||||||
| import nc.bs.framework.common.NCLocator; | import nc.bs.framework.common.NCLocator; | ||||||
| import nc.bs.pub.compiler.IWorkFlowRet; |  | ||||||
| import nc.vo.pub.BusinessException; |  | ||||||
| import nc.vo.pub.compiler.PfParameterVO; |  | ||||||
| import nc.vo.pub.VOStatus; |  | ||||||
| import nc.vo.uap.pf.PFBusinessException; |  | ||||||
| import nc.vo.pubapp.pattern.model.entity.bill.AbstractBill; |  | ||||||
| import nc.vo.pubapp.pattern.model.meta.entity.bill.IBillMeta; |  | ||||||
| import nc.vo.pub.CircularlyAccessibleValueObject; |  | ||||||
| import nccloud.commons.lang.StringUtils; |  | ||||||
| import nc.codeplatform.framework.service.AbstractPfScriptAction; | import nc.codeplatform.framework.service.AbstractPfScriptAction; | ||||||
| import nc.vo.pu.dhjyd.AggDhjydMasterVO; |  | ||||||
| import nc.itf.pu.dhjyd.dhjydmaster.IDhjydMasterVOService; | import nc.itf.pu.dhjyd.dhjydmaster.IDhjydMasterVOService; | ||||||
|  | import nc.vo.pu.dhjyd.AggDhjydMasterVO; | ||||||
|  | import nc.vo.pub.BusinessException; | ||||||
|  | import nc.vo.pub.VOStatus; | ||||||
|  | import nc.vo.pub.compiler.PfParameterVO; | ||||||
|  | import nc.vo.uap.pf.PFBusinessException; | ||||||
|  | import nccloud.commons.lang.StringUtils; | ||||||
| 
 | 
 | ||||||
| public class N_DHJY_SAVE extends AbstractPfScriptAction<AggDhjydMasterVO>{ | public class N_DHJY_SAVE extends AbstractPfScriptAction<AggDhjydMasterVO> { | ||||||
| 	 | 
 | ||||||
| 	public N_DHJY_SAVE(){ | 	public N_DHJY_SAVE() { | ||||||
| 		super(); | 		super(); | ||||||
| 	} | 	} | ||||||
| 	 | 
 | ||||||
| 	@Override | 	@Override | ||||||
| 	protected Object process(PfParameterVO paraVO) throws BusinessException { | 	protected Object process(PfParameterVO paraVO) throws BusinessException { | ||||||
| 		try { | 		try { | ||||||
| 			IDhjydMasterVOService service = NCLocator.getInstance().lookup(IDhjydMasterVOService.class); | 			IDhjydMasterVOService service = NCLocator.getInstance().lookup(IDhjydMasterVOService.class); | ||||||
| 			AggDhjydMasterVO[] vos = (AggDhjydMasterVO[])this.getVos(); | 			AggDhjydMasterVO[] vos = (AggDhjydMasterVO[]) this.getVos(); | ||||||
| 			Arrays.stream(vos).forEach(v-> v.getParent().setStatus(VOStatus.UPDATED)); | 			Arrays.stream(vos).forEach(v -> v.getParent().setStatus(VOStatus.UPDATED)); | ||||||
| 			 | 
 | ||||||
| 			 |  | ||||||
| 			vos = service.callbackSAVE(vos); | 			vos = service.callbackSAVE(vos); | ||||||
| 			 | 
 | ||||||
| 			return vos; | 			return vos; | ||||||
| 		}catch(Exception ex) { | 		} catch (Exception ex) { | ||||||
| 			if (ex instanceof BusinessException) { | 			if (ex instanceof BusinessException) { | ||||||
| 		        throw (BusinessException) ex; | 				throw (BusinessException) ex; | ||||||
| 		      } | 			} | ||||||
| 	        throw new PFBusinessException(ex.getMessage(), ex); | 			throw new PFBusinessException(ex.getMessage(), ex); | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 	 | 
 | ||||||
| 	protected void before(PfParameterVO paraVO)  throws BusinessException{ | 	protected void before(PfParameterVO paraVO) throws BusinessException { | ||||||
| 		AggDhjydMasterVO vo = (AggDhjydMasterVO)this.getVo(); | 		AggDhjydMasterVO vo = (AggDhjydMasterVO) this.getVo(); | ||||||
| 		if(StringUtils.isEmpty(vo.getPrimaryKey())){ | 		if (StringUtils.isEmpty(vo.getPrimaryKey())) { | ||||||
| 			throw new BusinessException("当前单据未执行保存动作脚本,如果配置了业务流程定义,请检查动作驱动配置!"); | 			throw new BusinessException("当前单据未执行保存动作脚本,如果配置了业务流程定义,请检查动作驱动配置!"); | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|  | 
 | ||||||
| } | } | ||||||
|  | @ -3,12 +3,11 @@ package nc.itf.pu.dhjyd.dhjydmaster; | ||||||
| 
 | 
 | ||||||
| import java.util.Map; | import java.util.Map; | ||||||
| 
 | 
 | ||||||
| import nc.vo.pub.BusinessException; | import nc.pub.billcode.vo.BillCodeContext; | ||||||
| import nc.vo.pub.SuperVO; |  | ||||||
| 
 |  | ||||||
| import nc.vo.pu.dhjyd.AggDhjydMasterVO; | import nc.vo.pu.dhjyd.AggDhjydMasterVO; | ||||||
| import nc.vo.pu.dhjyd.DhjydMasterVO; | import nc.vo.pu.dhjyd.DhjydMasterVO; | ||||||
| import nc.pub.billcode.vo.BillCodeContext; | import nc.vo.pub.BusinessException; | ||||||
|  | import nc.vo.pub.SuperVO; | ||||||
| 
 | 
 | ||||||
| public interface IDhjydMasterVOService { | public interface IDhjydMasterVOService { | ||||||
| 
 | 
 | ||||||
|  | @ -295,4 +294,10 @@ public interface IDhjydMasterVOService { | ||||||
| 	 */ | 	 */ | ||||||
| 	public void afterAuditUnPass(AggDhjydMasterVO[] vos) throws BusinessException; | 	public void afterAuditUnPass(AggDhjydMasterVO[] vos) throws BusinessException; | ||||||
| 
 | 
 | ||||||
|  | 	/** | ||||||
|  | 	 * 不合格检验单生成批次号 | ||||||
|  | 	 *  | ||||||
|  | 	 */ | ||||||
|  | 	void addBatchcodeFromBill(AggDhjydMasterVO[] vos) throws BusinessException; | ||||||
|  | 
 | ||||||
| } | } | ||||||
		Loading…
	
		Reference in New Issue