From c3b061861f1895ff1b85ea360160316d31d06ee4 Mon Sep 17 00:00:00 2001 From: lihao Date: Sat, 21 Jun 2025 16:06:59 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../GatheringbillEditSaveBatchBSAction.java | 84 ++++++++++++++----- .../GatheringbillSaveBatchBSAction.java | 76 ++++++++++++----- 2 files changed, 118 insertions(+), 42 deletions(-) diff --git a/arap/src/private/nc/bs/arap/actions/GatheringbillEditSaveBatchBSAction.java b/arap/src/private/nc/bs/arap/actions/GatheringbillEditSaveBatchBSAction.java index c06d122..91e4e15 100644 --- a/arap/src/private/nc/bs/arap/actions/GatheringbillEditSaveBatchBSAction.java +++ b/arap/src/private/nc/bs/arap/actions/GatheringbillEditSaveBatchBSAction.java @@ -13,6 +13,7 @@ import nc.bs.arap.validator.CrossRuleCheckValidator; import nc.bs.dao.BaseDAO; import nc.bs.dao.DAOException; import nc.bs.trade.business.HYSuperDMO; +import nc.jdbc.framework.processor.MapListProcessor; import nc.jdbc.framework.processor.MapProcessor; import nc.vo.arap.basebill.BaseBillVO; import nc.vo.arap.gathering.GatheringBillItemVO; @@ -23,9 +24,11 @@ import nc.vo.pub.BusinessException; import nc.vo.pub.CircularlyAccessibleValueObject; import nc.vo.pub.lang.UFDouble; +import java.math.BigDecimal; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import java.util.Map; @@ -69,45 +72,80 @@ public class GatheringbillEditSaveBatchBSAction extends BillUpdateBatchBSAction if(!"30".equals(srcBilltype)){ continue; } + String def3 = ((GatheringBillItemVO)bill.getChildrenVO()[0]).getSrc_billid(); // 收款单对应的销售订单id if (StringUtil.isEmpty(def3) || "N".equals(def3) || "~".equals(def3)) { // 无绑定的销售订单则下一次循环 continue; } + List def3List = new ArrayList<>(); + for (int j=0;j 1) { + for (int j = 0; j < def3List.size(); j++) { + sb.append("'").append(def3List.get(j)).append("'"); + if (j < def3List.size() - 1) { + sb.append(","); + } + } + + result = sb.toString(); + } else { + result = "'" + (String) def3List.get(0) + "'"; + } // 计算收款单金额差值 UFDouble changeMoney = money.sub(oriMoney); // 根据销售订单id去查询销售订单 BaseDAO dao = new BaseDAO(); - List defMap = checkOrgCtrl(); - if (defMap.isEmpty() ) { - return ; - } - String sql1="SELECT org_salesorg.CODE ,so_saleorder.dbilldate, so_saleorder.pk_org, so_saleorder.vbillcode,so_saleorder.nreceivedmny,so_saleorder.ntotalorigmny FROM so_saleorder LEFT JOIN org_salesorg ON org_salesorg.PK_SALESORG = so_saleorder.PK_ORG where so_saleorder.dr = 0 and so_saleorder.csaleorderid = '" +def3+"'"; - Map saleMap = (Map)dao.executeQuery(sql1, new MapProcessor()); - String code = saleMap.get("code").toString(); - LocalDateTime dbilldate = LocalDateTime.parse(saleMap.get("dbilldate").toString(), - DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); - LocalDateTime targetDate = LocalDateTime.parse("2025-06-27 00:00:00", - DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); +// List defMap = checkOrgCtrl(); +// if (defMap.isEmpty() ) { +// return ; +// } + String sql1="SELECT org_salesorg.CODE ,so_saleorder.dbilldate, so_saleorder.pk_org, so_saleorder.vbillcode,so_saleorder.nreceivedmny,so_saleorder.ntotalorigmny FROM so_saleorder LEFT JOIN org_salesorg ON org_salesorg.PK_SALESORG = so_saleorder.PK_ORG where so_saleorder.dr = 0 and so_saleorder.csaleorderid in (" + result + ") "; + ArrayList> saleMap = (ArrayList>)dao.executeQuery(sql1, new MapListProcessor()); - if (defMap.contains(code) && dbilldate.isBefore(targetDate)) { - return; - } - // 销售订单价税合计 +// List saleMap = (List)dao.executeQuery(sql1, new MapProcessor()); +// String code = saleMap.get("code").toString(); +// LocalDateTime dbilldate = LocalDateTime.parse(saleMap.get("dbilldate").toString(), +// DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); +// LocalDateTime targetDate = LocalDateTime.parse("2025-06-27 00:00:00", +// DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); +// +// if (!defMap.isEmpty()&& defMap.contains(code) && dbilldate.isBefore(targetDate)) { +// return; +// } +// Map saleMap = (Map)dao.executeQuery(sql, new MapProcessor()); + //销售订单价税合计 UFDouble ntotalorigmny = UFDouble.ZERO_DBL; - // 销售订单实际收款金额 + //销售订单实际收款金额 UFDouble nreceivedmny = UFDouble.ZERO_DBL; - String vbillcode = ""; + StringBuilder vbillcodeBuilder = new StringBuilder(); if(saleMap != null) { - nreceivedmny = new UFDouble( - saleMap.get("nreceivedmny") == null ? "0" : saleMap.get("nreceivedmny").toString()); - ntotalorigmny = new UFDouble( - saleMap.get("ntotalorigmny") == null ? "0" : saleMap.get("ntotalorigmny").toString()); - vbillcode = saleMap.get("vbillcode") == null ? "" : saleMap.get("vbillcode").toString(); + for (Map map : saleMap) { + // 累加 nreceivedmny + String nreceivedmnyStr = map.get("nreceivedmny") == null ? "0" : map.get("nreceivedmny").toString(); + nreceivedmny.add(new UFDouble(nreceivedmnyStr)) ; + + // 累加 ntotalorigmny + BigDecimal ntotalorigmnyStr = map.get("ntotalorigmny") == null ? BigDecimal.ZERO : (BigDecimal) map.get("ntotalorigmny"); + UFDouble ufd= new UFDouble(ntotalorigmnyStr); + ntotalorigmny= ntotalorigmny.add(ufd); + // 拼接 vbillcode + String vbillcodeStr = map.get("vbillcode") == null ? "" : map.get("vbillcode").toString(); + if (!vbillcodeStr.isEmpty()) { + if (vbillcodeBuilder.length() > 0) { + vbillcodeBuilder.append(", "); + } + vbillcodeBuilder.append(vbillcodeStr); + } + } } if (money.compareTo(ntotalorigmny) > 0) { UFDouble moreMoney = money.sub(ntotalorigmny); - throw new BusinessException("【该笔收款税收合计" + money + "已超销售订单 [" + vbillcode + "] " + moreMoney + "元,无法传输!请检查订单累计收款金额!】"); + throw new BusinessException("【该笔收款税收合计" + money + "已超销售订单 [" + vbillcodeBuilder + "] " + moreMoney + "元,无法传输!请检查订单累计收款金额!】"); } } diff --git a/arap/src/private/nc/bs/arap/actions/GatheringbillSaveBatchBSAction.java b/arap/src/private/nc/bs/arap/actions/GatheringbillSaveBatchBSAction.java index cde0bf2..ed32417 100644 --- a/arap/src/private/nc/bs/arap/actions/GatheringbillSaveBatchBSAction.java +++ b/arap/src/private/nc/bs/arap/actions/GatheringbillSaveBatchBSAction.java @@ -14,6 +14,7 @@ import nc.bs.arap.validator.CrossRuleCheckValidator; import nc.bs.dao.BaseDAO; import nc.bs.dao.DAOException; import nc.bs.trade.business.HYSuperDMO; +import nc.jdbc.framework.processor.MapListProcessor; import nc.jdbc.framework.processor.MapProcessor; import nc.vo.arap.basebill.BaseBillVO; import nc.vo.arap.gathering.GatheringBillItemVO; @@ -23,6 +24,7 @@ import nc.vo.pub.AggregatedValueObject; import nc.vo.pub.BusinessException; import nc.vo.pub.lang.UFDouble; +import java.math.BigDecimal; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.ArrayList; @@ -82,6 +84,24 @@ public class GatheringbillSaveBatchBSAction extends BillInsertBatchBSAction { if(!"30".equals(srcBilltype)){ continue; } + List def3List = new ArrayList<>(); + for (int i=0;i 1) { + for (int i = 0; i < def3List.size(); i++) { + sb.append("'").append(def3List.get(i)).append("'"); + if (i < def3List.size() - 1) { + sb.append(","); + } + } + + result = sb.toString(); + } else { + result = "'" + (String) def3List.get(0) + "'"; + } String def3 = ((GatheringBillItemVO)bill.getChildrenVO()[0]).getSrc_billid(); // 收款单对应的销售订单id if(StringUtil.isEmpty(def3) || "N".equals(def3) || "~".equals(def3)){ //无绑定的销售订单则下一次循环 @@ -94,35 +114,53 @@ public class GatheringbillSaveBatchBSAction extends BillInsertBatchBSAction { - List defMap = checkOrgCtrl(); - if (defMap.isEmpty() ) { - return ; - } - String sql1="SELECT org_salesorg.CODE ,so_saleorder.dbilldate, so_saleorder.pk_org, so_saleorder.vbillcode,so_saleorder.nreceivedmny,so_saleorder.ntotalorigmny FROM so_saleorder LEFT JOIN org_salesorg ON org_salesorg.PK_SALESORG = so_saleorder.PK_ORG where so_saleorder.dr = 0 and so_saleorder.csaleorderid = '" +def3+"'"; - Map saleMap = (Map)dao.executeQuery(sql1, new MapProcessor()); - String code = saleMap.get("code").toString(); - LocalDateTime dbilldate = LocalDateTime.parse(saleMap.get("dbilldate").toString(), - DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); - LocalDateTime targetDate = LocalDateTime.parse("2025-06-27 00:00:00", - DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); +// List defMap = checkOrgCtrl(); +// if (defMap.isEmpty() ) { +// return ; +// } +// String sql1="SELECT org_salesorg.CODE ,so_saleorder.dbilldate, so_saleorder.pk_org, so_saleorder.vbillcode,so_saleorder.nreceivedmny,so_saleorder.ntotalorigmny FROM so_saleorder LEFT JOIN org_salesorg ON org_salesorg.PK_SALESORG = so_saleorder.PK_ORG where so_saleorder.dr = 0 and so_saleorder.csaleorderid = '" +def3+"'"; + String sql1="SELECT org_salesorg.CODE ,so_saleorder.dbilldate, so_saleorder.pk_org, so_saleorder.vbillcode,so_saleorder.nreceivedmny,so_saleorder.ntotalorigmny FROM so_saleorder LEFT JOIN org_salesorg ON org_salesorg.PK_SALESORG = so_saleorder.PK_ORG where so_saleorder.dr = 0 and so_saleorder.csaleorderid in (" + result + ") "; + ArrayList> saleMap = (ArrayList>)dao.executeQuery(sql1, new MapListProcessor()); - if (defMap.contains(code) && dbilldate.isBefore(targetDate)) { - return; - } +// List saleMap = (List)dao.executeQuery(sql1, new MapProcessor()); +// String code = saleMap.get("code").toString(); +// LocalDateTime dbilldate = LocalDateTime.parse(saleMap.get("dbilldate").toString(), +// DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); +// LocalDateTime targetDate = LocalDateTime.parse("2025-06-27 00:00:00", +// DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); +// +// if (!defMap.isEmpty()&& defMap.contains(code) && dbilldate.isBefore(targetDate)) { +// return; +// } // Map saleMap = (Map)dao.executeQuery(sql, new MapProcessor()); //销售订单价税合计 UFDouble ntotalorigmny = UFDouble.ZERO_DBL; //销售订单实际收款金额 UFDouble nreceivedmny = UFDouble.ZERO_DBL; - String vbillcode = ""; + StringBuilder vbillcodeBuilder = new StringBuilder(); if(saleMap != null) { - nreceivedmny = new UFDouble(saleMap.get("nreceivedmny") == null ? "0" : saleMap.get("nreceivedmny").toString()); - ntotalorigmny = new UFDouble(saleMap.get("ntotalorigmny") == null ? "0" : saleMap.get("ntotalorigmny").toString()); - vbillcode = saleMap.get("vbillcode") == null ? "" : saleMap.get("vbillcode").toString(); + for (Map map : saleMap) { + // 累加 nreceivedmny + String nreceivedmnyStr = map.get("nreceivedmny") == null ? "0" : map.get("nreceivedmny").toString(); + nreceivedmny.add(new UFDouble(nreceivedmnyStr)) ; + + // 累加 ntotalorigmny + BigDecimal ntotalorigmnyStr = map.get("ntotalorigmny") == null ? BigDecimal.ZERO : (BigDecimal) map.get("ntotalorigmny"); + UFDouble ufd= new UFDouble(ntotalorigmnyStr); + ntotalorigmny= ntotalorigmny.add(ufd); + // 拼接 vbillcode + String vbillcodeStr = map.get("vbillcode") == null ? "" : map.get("vbillcode").toString(); + if (!vbillcodeStr.isEmpty()) { + if (vbillcodeBuilder.length() > 0) { + vbillcodeBuilder.append(", "); + } + vbillcodeBuilder.append(vbillcodeStr); + } + } } if (money.compareTo(ntotalorigmny) > 0) { UFDouble moreMoney = money.sub(ntotalorigmny); - throw new BusinessException("【该笔收款税收合计" + money + "已超销售订单 [" + vbillcode + "] " + moreMoney + "元,无法传输!请检查订单累计收款金额!】"); + throw new BusinessException("【该笔收款税收合计" + money + "已超销售订单 [" + vbillcodeBuilder + "] " + moreMoney + "元,无法传输!请检查订单累计收款金额!】"); } } }