From 8c4261311fa70ee5b942ab7c867f8789a1f82073 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E8=B4=B5=E5=BC=BA?= Date: Wed, 16 Jul 2025 13:23:53 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=91=E7=A5=A8=E4=BF=A1=E6=81=AF=E4=BC=A0?= =?UTF-8?q?=E8=BE=93BIP=E6=96=B0=E5=A2=9E=E5=8F=91=E7=A5=A8=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B+=E5=8F=91=E7=A5=A8=E5=8F=B7=E7=A0=81=E6=8B=BC?= =?UTF-8?q?=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../recon/opplugin/YongyouBIPOperation.java | 74 +++++++++++++++++++ 1 file changed, 74 insertions(+) diff --git a/main/java/shkd/repc/recon/opplugin/YongyouBIPOperation.java b/main/java/shkd/repc/recon/opplugin/YongyouBIPOperation.java index 47a4804..e7c26a2 100644 --- a/main/java/shkd/repc/recon/opplugin/YongyouBIPOperation.java +++ b/main/java/shkd/repc/recon/opplugin/YongyouBIPOperation.java @@ -25,6 +25,10 @@ import okhttp3.*; import shkd.utils.DobeDWUtils; import java.math.BigDecimal; import java.math.RoundingMode; +import java.util.LinkedHashMap; +import java.util.LinkedHashSet; +import java.util.Map; +import java.util.Set; /** @@ -661,6 +665,8 @@ public class YongyouBIPOperation extends AbstractOperationServicePlugIn implemen Long commonTaxRateId = null; boolean hasDifferentTaxRates = false; + // 新增:用于存储发票类型和号码的映射关系 + Map> invoiceTypeToNumbersMap = new LinkedHashMap<>(); // 遍历发票 for (DynamicObject invoiceObj : invoiceEntry) { @@ -676,6 +682,14 @@ public class YongyouBIPOperation extends AbstractOperationServicePlugIn implemen DynamicObject invoice = invoiceBill.getDynamicObject("invoice"); if (invoice != null) { String invoiceName = invoice.getString("name"); + String invoiceNo = invoiceBill.getString("invoiceno"); + // 新增:收集发票类型和号码信息 + if (invoiceName != null && invoiceNo != null) { + // 专票在前处理:如果包含"专用"则放在前面,否则放在后面 + String typeKey = invoiceName.contains("专用") ? "1_" + invoiceName : "2_" + invoiceName; + invoiceTypeToNumbersMap.computeIfAbsent(typeKey, k -> new LinkedHashSet<>()).add(invoiceNo); + } + if (invoiceName != null && invoiceName.contains("专用")) { // 发票登记-发票明细————————只有一行 DynamicObjectCollection invoiceDetails = invoiceBill.getDynamicObjectCollection("invoiceentry"); @@ -741,6 +755,30 @@ public class YongyouBIPOperation extends AbstractOperationServicePlugIn implemen items.put("taxcodeid", "CN07"); } + // 新增:构建发票类型和号码的拼接字符串 + if (!invoiceTypeToNumbersMap.isEmpty()) { + StringBuilder def4Builder = new StringBuilder(); + + // 按照排序处理(专票在前) + invoiceTypeToNumbersMap.entrySet().stream() + .sorted(Map.Entry.comparingByKey()) + .forEach(entry -> { + String typeName = entry.getKey().substring(2); // 去掉排序前缀 + Set numbers = entry.getValue(); + + if (def4Builder.length() > 0) { + def4Builder.append(","); + } + def4Builder.append(typeName).append(":").append(String.join(",", numbers)); + }); + + // 截取200字符 + String def4Value = def4Builder.toString(); + if (def4Value.length() > 200) { + def4Value = def4Value.substring(0, 200); + } + items.put("def4", def4Value); + } if("unaudit".equals(eventName)){ //如果此时是反审核,则需要将金额置为负数 @@ -782,6 +820,9 @@ public class YongyouBIPOperation extends AbstractOperationServicePlugIn implemen Long commonTaxRateId = null; boolean hasDifferentTaxRates = false; + // 新增:用于存储发票类型和号码的映射关系 + Map> invoiceTypeToNumbersMap = new LinkedHashMap<>(); + // 遍历发票 for (DynamicObject invoiceObj : invoiceEntry) { DynamicObject invoiceBillF7 = invoiceObj.getDynamicObject("inventry_invoicebill"); @@ -795,6 +836,13 @@ public class YongyouBIPOperation extends AbstractOperationServicePlugIn implemen DynamicObject invoice = invoiceBill.getDynamicObject("invoice"); if (invoice != null) { String invoiceName = invoice.getString("name"); + String invoiceNo = invoiceBill.getString("invoiceno"); + // 新增:收集发票类型和号码信息 + if (invoiceName != null && invoiceNo != null) { + // 专票在前处理:如果包含"专用"则放在前面,否则放在后面 + String typeKey = invoiceName.contains("专用") ? "1_" + invoiceName : "2_" + invoiceName; + invoiceTypeToNumbersMap.computeIfAbsent(typeKey, k -> new LinkedHashSet<>()).add(invoiceNo); + } if (invoiceName != null && invoiceName.contains("专用")) { // 发票登记-发票明细————————只有一行 DynamicObjectCollection invoiceDetails = invoiceBill.getDynamicObjectCollection("invoiceentry"); @@ -860,6 +908,32 @@ public class YongyouBIPOperation extends AbstractOperationServicePlugIn implemen items.put("taxcodeid", "CN07"); } + // 新增:构建发票类型和号码的拼接字符串 + if (!invoiceTypeToNumbersMap.isEmpty()) { + StringBuilder def4Builder = new StringBuilder(); + + // 按照排序处理(专票在前) + invoiceTypeToNumbersMap.entrySet().stream() + .sorted(Map.Entry.comparingByKey()) + .forEach(entry -> { + String typeName = entry.getKey().substring(2); // 去掉排序前缀 + Set numbers = entry.getValue(); + + if (def4Builder.length() > 0) { + def4Builder.append(","); + } + def4Builder.append(typeName).append(":").append(String.join(",", numbers)); + }); + + // 截取200字符 + String def4Value = def4Builder.toString(); + if (def4Value.length() > 200) { + def4Value = def4Value.substring(0, 200); + } + items.put("def4", def4Value); + } + + if("unaudit".equals(eventName)){ //如果此时是反审核,则需要将金额置为负数 items.put("local_tax_de","-"+items.getString("local_tax_de"));