From 6af58fd3147c168fbdd7dd3ee08b4c4875c9ca7b Mon Sep 17 00:00:00 2001 From: 25655 <2565550274@qq.com> Date: Sat, 1 Mar 2025 12:03:57 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=201.=E9=94=80=E5=94=AE=E5=87=BA?= =?UTF-8?q?=E5=BA=93=E5=8D=95=E6=8F=90=E4=BA=A4=EF=BC=8C=E5=AE=A2=E6=88=B7?= =?UTF-8?q?=E6=9C=89=E4=BF=A1=E4=BF=9D=E9=80=BE=E6=9C=9F=E6=88=96=E8=80=85?= =?UTF-8?q?=E6=AC=A0=E6=9D=A1=E6=B2=A1=E6=A0=B8=E9=94=80=E4=B8=8D=E8=83=BD?= =?UTF-8?q?=E6=8F=90=E4=BA=A4=EF=BC=8C=E8=8E=B7=E5=8F=96=E5=88=B0=E9=80=BE?= =?UTF-8?q?=E6=9C=9F=E9=87=91=E9=A2=9D=E5=92=8C=E6=AC=A0=E6=9D=A1=E9=87=91?= =?UTF-8?q?=E9=A2=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DeliverNoticeSubmitValidator.java | 69 ++++++++++++------- 1 file changed, 43 insertions(+), 26 deletions(-) diff --git a/src/main/java/com/yem/wm/im/delivernotice/validator/DeliverNoticeSubmitValidator.java b/src/main/java/com/yem/wm/im/delivernotice/validator/DeliverNoticeSubmitValidator.java index 345878f1..d205a343 100644 --- a/src/main/java/com/yem/wm/im/delivernotice/validator/DeliverNoticeSubmitValidator.java +++ b/src/main/java/com/yem/wm/im/delivernotice/validator/DeliverNoticeSubmitValidator.java @@ -24,7 +24,7 @@ public class DeliverNoticeSubmitValidator extends AbstractValidator { @Override public void validate() { ExtendedDataEntity[] dataEntities = this.getDataEntities(); - for(ExtendedDataEntity dataEntitie : dataEntities){ + for (ExtendedDataEntity dataEntitie : dataEntities) { // arrearsAmtValidator(dataEntitie); if (specialApplicationShipment(dataEntitie)) continue; hasArrearsValidator(dataEntitie); @@ -36,6 +36,7 @@ public class DeliverNoticeSubmitValidator extends AbstractValidator { /** * 最后一笔出库的时候,判断出库金额是否和合同金额相等 + * * @param dataEntitie */ private void checkAmountAligned(ExtendedDataEntity dataEntitie) { @@ -147,10 +148,10 @@ public class DeliverNoticeSubmitValidator extends AbstractValidator { /** * 校验当前客户是否有信保逾期 * 信保限额申请单分录的应收款日期1小于当前时间并且有欠款金额 + * * @param entry */ - private void creditInsuranceOverdueVerification(ExtendedDataEntity entry) - { + private void creditInsuranceOverdueVerification(ExtendedDataEntity entry) { DynamicObject dataEntity = entry.getDataEntity(); dataEntity = BusinessDataServiceHelper.loadSingle(dataEntity.getPkValue(), dataEntity.getDynamicObjectType().getName()); DynamicObject customer = dataEntity.getDynamicObject("yem_customer"); @@ -161,9 +162,11 @@ public class DeliverNoticeSubmitValidator extends AbstractValidator { DynamicObject method = TotalUtil.getSettlementMethod(shippingdetails); DynamicObject company = dataEntity.getDynamicObject("yem_company.yem_erporg"); String swiftCode = TotalUtil.getSwiftCode(shippingdetails); + BigDecimal yemArrearsamtapply = shippingdetails.getBigDecimal("yem_arrearsamtapply"); DynamicObject creditLine = TotalUtil.getCsrCreditLine(customer, method, company, swiftCode); if (creditLine == null) return; DynamicObjectCollection collection = creditLine.getDynamicObjectCollection("yem_im_info"); + BigDecimal amountoweds = BigDecimal.ZERO; for (DynamicObject dynamicObject : collection) { // 应收款日期1 Date paydate = dynamicObject.getDate("yem_paydate1"); @@ -171,9 +174,22 @@ public class DeliverNoticeSubmitValidator extends AbstractValidator { Date now = new Date(); if (paydate == null) continue; if (amountowed.compareTo(BigDecimal.ZERO) > 0 && paydate.before(now)) { - this.addErrorMessage(entry, String.format("客户 %s 信保逾期,请确认!", customer.getString("name"))); + amountoweds = amountowed.add(amountoweds); } } + String string = ""; + if (amountoweds.compareTo(BigDecimal.ZERO) > 0 || yemArrearsamtapply.compareTo(BigDecimal.ZERO) > 0) { + string = "客户" + customer.getString("name") + "信保逾期,"; + } + if (amountoweds.compareTo(BigDecimal.ZERO) > 0) { + string = string + "欠款金额:" + amountoweds; + } else if (yemArrearsamtapply.compareTo(BigDecimal.ZERO) > 0) { + string = string + "欠条金额:" + yemArrearsamtapply; + } + if (!string.isEmpty()) { + string = string+",请确认!"; + } + this.addErrorMessage(entry ,string); } @@ -184,22 +200,22 @@ public class DeliverNoticeSubmitValidator extends AbstractValidator { * return * @time 2023/11/9 14:57 */ - public void arrearsAmtValidator(ExtendedDataEntity dataEntitie){ + public void arrearsAmtValidator(ExtendedDataEntity dataEntitie) { DynamicObject dataEntity = dataEntitie.getDataEntity(); long id = dataEntity.getLong("id"); String coreBillType = dataEntity.getString("yem_corebilltype"); long coreBillId = dataEntity.getLong("yem_corebillid"); - if(YEM.isNotEmpty(coreBillType) && YEM.isNotEmpty(coreBillId)){ - DynamicObject saleOrder = BusinessDataServiceHelper.loadSingle(coreBillId,coreBillType); + if (YEM.isNotEmpty(coreBillType) && YEM.isNotEmpty(coreBillId)) { + DynamicObject saleOrder = BusinessDataServiceHelper.loadSingle(coreBillId, coreBillType); BigDecimal rapRate = PaymentControlUtil.getRapRate(saleOrder); BigDecimal collection = PaymentControlUtil.getCollection(coreBillId);//A 合同的所有收款 - BigDecimal contractPayment = PaymentControlUtil.getAdvancePayment(PaymentControlUtil.getContractPayment(saleOrder),rapRate);//B 合同的预收款 - BigDecimal deliverPayment = PaymentControlUtil.getBalancePayment(PaymentControlUtil.getDeliverPayment(id, coreBillType, coreBillId),rapRate);//C 提交、审核的历史发货尾款 - BigDecimal translateDeliverPayment = PaymentControlUtil.getBalancePayment(PaymentControlUtil.getTranslateDeliverPayment(dataEntity),rapRate);//D 本次发货尾款 + BigDecimal contractPayment = PaymentControlUtil.getAdvancePayment(PaymentControlUtil.getContractPayment(saleOrder), rapRate);//B 合同的预收款 + BigDecimal deliverPayment = PaymentControlUtil.getBalancePayment(PaymentControlUtil.getDeliverPayment(id, coreBillType, coreBillId), rapRate);//C 提交、审核的历史发货尾款 + BigDecimal translateDeliverPayment = PaymentControlUtil.getBalancePayment(PaymentControlUtil.getTranslateDeliverPayment(dataEntity), rapRate);//D 本次发货尾款 BigDecimal arrearsAmt = collection.subtract(contractPayment).subtract(deliverPayment).subtract(translateDeliverPayment).setScale(2, RoundingMode.HALF_UP); - if(arrearsAmt.compareTo(BigDecimal.ZERO) < 0){ + if (arrearsAmt.compareTo(BigDecimal.ZERO) < 0) { BigDecimal fAbs = arrearsAmt.abs().setScale(2, RoundingMode.HALF_UP); - this.addErrorMessage(dataEntitie,String.format("截止当前,本发货通知单存在欠款,欠款金额为%s,不允许提交,请收款齐全后重试!",fAbs)); + this.addErrorMessage(dataEntitie, String.format("截止当前,本发货通知单存在欠款,欠款金额为%s,不允许提交,请收款齐全后重试!", fAbs)); } } } @@ -213,7 +229,7 @@ public class DeliverNoticeSubmitValidator extends AbstractValidator { * @time 2023/11/13 15:13 */ - public void isStorageTrans(ExtendedDataEntity dataEntitie){ + public void isStorageTrans(ExtendedDataEntity dataEntitie) { DynamicObject dataEntity = dataEntitie.getDataEntity(); List entryIds = new ArrayList(); DynamicObjectCollection materialInfos = dataEntity.getDynamicObjectCollection("yem_es_materialinfo"); @@ -223,20 +239,20 @@ public class DeliverNoticeSubmitValidator extends AbstractValidator { entryIds.add(sourceEntryId); } - Map> allMap = new HashMap<>(); + Map> allMap = new HashMap<>(); DynamicObject[] shippingDetails = BusinessDataServiceHelper.load("yem_shippingdetails", "yem_es_materialinfo.yem_storageqty,yem_es_materialinfo.yem_deliveryqty", new QFilter[]{new QFilter("yem_es_materialinfo.id", QCP.in, entryIds)}); - for(DynamicObject shippingDetail : shippingDetails){ + for (DynamicObject shippingDetail : shippingDetails) { DynamicObjectCollection shippingMaterialInfos = shippingDetail.getDynamicObjectCollection("yem_es_materialinfo"); - for(DynamicObject shippingMaterialInfo : shippingMaterialInfos){ + for (DynamicObject shippingMaterialInfo : shippingMaterialInfos) { long materialInfoId = shippingMaterialInfo.getLong("id"); - if(entryIds.contains(materialInfoId)){ + if (entryIds.contains(materialInfoId)) { HashMap map = new HashMap<>(); BigDecimal storageQty = shippingMaterialInfo.getBigDecimal("yem_storageqty"); BigDecimal deliveryQty = shippingMaterialInfo.getBigDecimal("yem_deliveryqty"); - map.put("storageQty",storageQty); - map.put("deliveryQty",deliveryQty); - allMap.put(materialInfoId,map); + map.put("storageQty", storageQty); + map.put("deliveryQty", deliveryQty); + allMap.put(materialInfoId, map); } } } @@ -244,11 +260,11 @@ public class DeliverNoticeSubmitValidator extends AbstractValidator { DynamicObject materialInfo = materialInfos.get(i); long sourceEntryId = materialInfo.getLong("yem_sourceentryid"); Map map = allMap.get(sourceEntryId); - if(YEM.isNotEmpty(map)){ + if (YEM.isNotEmpty(map)) { BigDecimal storageQty = map.get("storageQty"); BigDecimal deliveryQty = map.get("deliveryQty"); - if(deliveryQty.compareTo(storageQty) > 0){ - this.addErrorMessage(dataEntitie,String.format("发货通知单明细信息第%s行还未进行储运,请下推订舱通知单后,在提交发货通知单!",i + 1)); + if (deliveryQty.compareTo(storageQty) > 0) { + this.addErrorMessage(dataEntitie, String.format("发货通知单明细信息第%s行还未进行储运,请下推订舱通知单后,在提交发货通知单!", i + 1)); } } } @@ -256,10 +272,10 @@ public class DeliverNoticeSubmitValidator extends AbstractValidator { /** * 1、销售出库对应的合同(非本次发运明细单)--欠条是否有核销掉 + * * @param dataEntities */ - private void hasArrearsValidator(ExtendedDataEntity dataEntities) - { + private void hasArrearsValidator(ExtendedDataEntity dataEntities) { // 销售出库单 DynamicObject dataEntity = dataEntities.getDataEntity(); long shipDetailId = dataEntity.getLong("yem_sourcebillid"); @@ -298,12 +314,13 @@ public class DeliverNoticeSubmitValidator extends AbstractValidator { } } if (totalArrearsAmt.compareTo(BigDecimal.ZERO) > 0) { - this.addErrorMessage(dataEntities, String.format("合同 %s 下还有未核销的欠条:%s,未核销金额为 %s,请核销后再提交!", contractnum, Arrays.toString(billno.toArray()),totalArrearsAmt.setScale(2, RoundingMode.HALF_UP))); + this.addErrorMessage(dataEntities, String.format("合同 %s 下还有未核销的欠条:%s,未核销金额为 %s,请核销后再提交!", contractnum, Arrays.toString(billno.toArray()), totalArrearsAmt.setScale(2, RoundingMode.HALF_UP))); } } /** * 销售出库提交时,如果有已审核的发货特殊申请,不需要校验是否信保预期,是否由未核销掉的欠条,否则需要核销; + * * @param dataEntitie * @return */