From 9a0c616954efe6c7ae4048a3d721a0c0dad9d991 Mon Sep 17 00:00:00 2001 From: mzr Date: Thu, 4 Sep 2025 15:48:25 +0800 Subject: [PATCH] =?UTF-8?q?=E5=80=9F=E6=96=99=E7=B1=BB=E5=9E=8B=E7=9A=84?= =?UTF-8?q?=E5=85=B6=E5=AE=83=E5=85=A5=E5=BA=93=E8=B7=B3=E8=BF=87=E6=89=B9?= =?UTF-8?q?=E6=AC=A1=E5=8F=B7=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nc/impl/ic/batch/BatchCheckImpl.java | 276 ++++++++++++++++++ 1 file changed, 276 insertions(+) create mode 100644 ic/src/private/nc/impl/ic/batch/BatchCheckImpl.java diff --git a/ic/src/private/nc/impl/ic/batch/BatchCheckImpl.java b/ic/src/private/nc/impl/ic/batch/BatchCheckImpl.java new file mode 100644 index 0000000..9a64be1 --- /dev/null +++ b/ic/src/private/nc/impl/ic/batch/BatchCheckImpl.java @@ -0,0 +1,276 @@ +// +// Source code recreated from a .class file by IntelliJ IDEA +// (powered by FernFlower decompiler) +// + +package nc.impl.ic.batch; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import nc.bs.ic.pub.env.ICBSContext; +import nc.impl.pubapp.env.BSContext; +import nc.itf.ic.batch.IBatchCheck; +import nc.itf.scmpub.reference.uap.bd.material.MaterialPubService; +import nc.pubitf.para.SysInitQuery; +import nc.vo.bd.material.MaterialVO; +import nc.vo.ic.general.define.ICBillBodyVO; +import nc.vo.ic.general.define.ICBillHeadVO; +import nc.vo.ic.general.define.ICBillVO; +import nc.vo.ic.material.define.InvCalBodyVO; +import nc.vo.ic.material.define.InvCalbodyKey; +import nc.vo.ic.pub.lang.BatchRes; +import nc.vo.ic.pub.lang.ResBase; +import nc.vo.ic.pub.util.NCBaseTypeUtils; +import nc.vo.ic.pub.util.StringUtil; +import nc.vo.ic.pub.util.ValueCheckUtil; +import nc.vo.ml.NCLangRes4VoTransl; +import nc.vo.pub.BusinessException; +import nc.vo.pub.lang.UFBoolean; +import nc.vo.pub.lang.UFDate; +import nc.vo.pubapp.pattern.data.ValueUtils; +import nc.vo.pubapp.pattern.exception.ExceptionUtils; +import nc.vo.pubapp.pattern.pub.AssertUtils; +import nccloud.commons.lang.ArrayUtils; + +public class BatchCheckImpl implements IBatchCheck { + public BatchCheckImpl() { + } + + public void checkBatchAttribute(ICBillVO[] bills) throws BusinessException { + try { + if (ArrayUtils.isEmpty(bills)) { + return; + } + + Set keySet = new HashSet(); + List keys = new ArrayList(); + + for(ICBillVO bill : bills) { + for(ICBillBodyVO body : bill.getBodys()) { + if (body.getDproducedate() != null && body.getDvalidate() != null && body.getDproducedate().compareTo(body.getDvalidate()) > 0) { + ExceptionUtils.wrappException(new BusinessException(NCLangRes4VoTransl.getNCLangRes().getStrByID("4008028_0", "04008028-0067", (String)null, new String[]{"" + body.getVbatchcode()}))); + } + + String var10001 = bill.getHead().getPk_org(); + if (!keySet.contains(var10001 + body.getCmaterialvid()) && body.getStatus() != 3 && body.getNnum() != null) { + keys.add(new InvCalbodyKey(bill.getHead().getPk_org(), body.getCmaterialvid())); + var10001 = bill.getHead().getPk_org(); + keySet.add(var10001 + body.getCmaterialvid()); + } + } + } + + if (ValueCheckUtil.isNullORZeroLength(keys)) { + return; + } + + Map invInfoMap = (new ICBSContext()).getInvInfo().getInvCalBodyVOs((InvCalbodyKey[])keys.toArray(new InvCalbodyKey[keys.size()])); + Map cInvInfoMap = this.changeRet(invInfoMap); + + for(ICBillVO bill : bills) { + StringBuilder errStr = new StringBuilder(); + List errRowNos = new ArrayList(); + this.checkBatchcode(bill, cInvInfoMap, errStr, errRowNos, true); + if (!StringUtil.isSEmptyOrNull(errStr.toString())) { + List cpickmbids = this.getCPickMBids(bill, errRowNos); + BSContext.getInstance().setSession("ICSessionContainSrcBid", cpickmbids); + throw new BusinessException(errStr.toString()); + } + } + } catch (Exception e) { + ExceptionUtils.marsh(e); + } + + } + + private Map changeRet(Map invInfoMap) { + Map cInvInfoMap = new HashMap(); + + for(InvCalBodyVO vo : invInfoMap.values()) { + cInvInfoMap.put(vo.getPk_org() + vo.getPk_material(), vo); + } + + return cInvInfoMap; + } + + public void checkBatchAttribute(ICBillVO bill) throws BusinessException { + try { + if (bill == null || bill.getBodys() == null) { + return; + } + + String pk_org = bill.getHead().getPk_org(); + List cmaterialVIDs = new ArrayList(); + + for(ICBillBodyVO body : bill.getBodys()) { + if (body.getStatus() != 3 && !cmaterialVIDs.contains(body.getCmaterialvid()) && body.getNnum() != null) { + cmaterialVIDs.add(body.getCmaterialvid()); + } + } + + Map materialVOs = this.fetchMaterialInfo(pk_org, cmaterialVIDs); + StringBuilder errStr = new StringBuilder(); + List errRowNos = new ArrayList(); + this.checkBatchcode(bill, materialVOs, errStr, errRowNos, true); + if (!StringUtil.isSEmptyOrNull(errStr.toString())) { + List cpickmbids = this.getCPickMBids(bill, errRowNos); + BSContext.getInstance().setSession("ICSessionContainSrcBid", cpickmbids); + throw new BusinessException(errStr.toString()); + } + } catch (BusinessException ex) { + ExceptionUtils.marsh(ex); + } + + } + + public void checkBatchAttributeFor4555(ICBillVO bill) throws BusinessException { + try { + if (bill == null || bill.getBodys() == null) { + return; + } + + String pk_org = bill.getHead().getPk_org(); + List cmaterialVIDs = new ArrayList(); + + for(ICBillBodyVO body : bill.getBodys()) { + if (body.getStatus() != 3 && !cmaterialVIDs.contains(body.getCmaterialvid()) && !NCBaseTypeUtils.isNullOrZero(body.getNnum())) { + cmaterialVIDs.add(body.getCmaterialvid()); + } + } + + Map materialVOs = this.fetchMaterialInfo(pk_org, cmaterialVIDs); + StringBuilder errStr = new StringBuilder(); + List errRowNos = new ArrayList(); + this.checkBatchcode(bill, materialVOs, errStr, errRowNos, false); + if (!StringUtil.isSEmptyOrNull(errStr.toString())) { + List cpickmbids = this.getCPickMBids(bill, errRowNos); + BSContext.getInstance().setSession("ICSessionContainSrcBid", cpickmbids); + throw new BusinessException(errStr.toString()); + } + } catch (BusinessException ex) { + ExceptionUtils.marsh(ex); + } + + } + + private void checkBatchcode(ICBillVO bill, Map materialVOs, StringBuilder errStr, List errRowNos, boolean checkQualFlag) { + for(ICBillBodyVO body : bill.getBodys()) { + if (body.getStatus() != 3 && body.getNnum() != null && !StringUtil.isSEmptyOrNull(body.getCmaterialvid())) { + String var10001 = bill.getHead().getPk_org(); + InvCalBodyVO materialVO = (InvCalBodyVO)materialVOs.get(var10001 + body.getCmaterialvid()); + AssertUtils.assertValue(materialVO != null, BatchRes.getMaterialStockErr()); + ICBillHeadVO head = bill.getHead(); + boolean isError = this.checkWholeMngInv(materialVO, body, errStr, errRowNos, checkQualFlag, head); + if (!isError) { + this.checkNonWholeMngInv(materialVO, body, errStr, errRowNos); + } + } + } + + } + + private void checkNonWholeMngInv(InvCalBodyVO materialVO, ICBillBodyVO body, StringBuilder errStr, List errRowNos) { + if (materialVO == null || materialVO.getWholemanaflag() == null || !materialVO.getWholemanaflag().equals(UFBoolean.TRUE)) { + if (!StringUtil.isSEmptyOrNull(body.getPk_batchcode()) || !StringUtil.isSEmptyOrNull(body.getVbatchcode())) { + this.showErr(body, errStr, errRowNos, BatchRes.getNonWholeMngErr()); + } + + } + } + + private boolean checkValidate(ICBillBodyVO body, int qualityUnit, int qualityNum, StringBuilder errStr, List errRowNos) { + if (body.getDproducedate() != null && body.getDvalidate() != null) { + UFDate dproduceDate = body.getDproducedate(); + UFDate dvalidateDate = body.getDvalidate(); + if (dproduceDate != null && dvalidateDate != null && dvalidateDate.before(dproduceDate)) { + } + + return false; + } else { + String cmaterialvid = body.getCmaterialvid(); + MaterialVO matVO = MaterialPubService.queryMaterialBaseInfoByPk(cmaterialvid, new String[]{"name", "code"}); + String var10000 = matVO.getCode(); + String matInfo = var10000 + " " + matVO.getName(); + this.showErr(body, errStr, errRowNos, BatchRes.getBatchEmptyErr(matInfo)); + return true; + } + } + + private boolean checkWholeMngInv(InvCalBodyVO materialVO, ICBillBodyVO body, StringBuilder errStr, List errRowNos, boolean checkQualFlag, ICBillHeadVO head) { + if (materialVO != null && materialVO.getWholemanaflag() != null && materialVO.getWholemanaflag().equals(UFBoolean.TRUE)) { + if (this.isBatchEmpty(body, head)) { + String cmaterialvid = body.getCmaterialvid(); + MaterialVO matVO = MaterialPubService.queryMaterialBaseInfoByPk(cmaterialvid, new String[]{"name", "code"}); + String var10000 = matVO.getCode(); + String matInfo = var10000 + " " + matVO.getName(); + this.showErr(body, errStr, errRowNos, BatchRes.getBatchEmptyErr(matInfo)); + return true; + } + + if (checkQualFlag && ValueUtils.getUFBoolean(materialVO.getQualitymanflag()).equals(UFBoolean.TRUE)) { + return this.checkValidate(body, materialVO.getQualityunit(), materialVO.getQualitynum(), errStr, errRowNos); + } + } + + return false; + } + + private Map fetchMaterialInfo(String pk_org, List cmaterialVIDs) { + Map retMap = new HashMap(); + ICBSContext context = new ICBSContext(); + InvCalBodyVO[] stockVOs = context.getInvInfo().getInvCalBodyVO(pk_org, (String[])cmaterialVIDs.toArray(new String[cmaterialVIDs.size()])); + if (stockVOs != null && stockVOs.length != 0) { + for(InvCalBodyVO vo : stockVOs) { + retMap.put(vo.getPk_org() + vo.getPk_material(), vo); + } + + return retMap; + } else { + return retMap; + } + } + + private List getCPickMBids(ICBillVO bill, List errRowNos) { + if (errRowNos != null && errRowNos.size() != 0) { + List cpickmbids = new ArrayList(); + + for(String rowNo : errRowNos) { + for(ICBillBodyVO body : bill.getChildrenVO()) { + if (rowNo.equals(body.getCrowno())) { + String cpickmbid = (String)body.getAttributeValue("cpickmbid"); + cpickmbids.add(cpickmbid); + } + } + } + + return cpickmbids; + } else { + return null; + } + } + + private boolean isBatchEmpty(ICBillBodyVO body, ICBillHeadVO head) { + boolean isBatchEmpty = StringUtil.isSEmptyOrNull(body.getVbatchcode()); + // 借料类型的其它入库跳过批次号校验 + String typeCode = ""; + try { + typeCode = SysInitQuery.getParaString(head.getPk_org(), "ICIN_TYPE"); + } catch (BusinessException e) { + throw new RuntimeException(e); + } + if (!"".equals(typeCode) && typeCode.equals(head.getVtrantypecode())) { + isBatchEmpty = false; + } + boolean isNumNotEmpty = body.getNnum() != null && !NCBaseTypeUtils.isNullOrZero(body.getNnum()); + return isBatchEmpty && isNumNotEmpty; + } + + private void showErr(ICBillBodyVO body, StringBuilder errStrSum, List errRowNos, String str) { + errStrSum.append(str).append("\n").append(ResBase.getCrowno()).append(":").append(body.getCrowno()).append("\n"); + errRowNos.add(body.getCrowno()); + } +}