From e2a8a7f155aac4656aa4f8312b24e905741f90ca Mon Sep 17 00:00:00 2001 From: zhangzhiguo <421587375@qq.com> Date: Tue, 18 Nov 2025 15:18:57 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B7=A5=E7=A8=8B=E5=8F=91=E7=A5=A8=E5=8F=96?= =?UTF-8?q?=E6=B6=88=E4=BE=9B=E5=BA=94=E5=95=86=E5=AD=98=E5=9C=A8=E6=80=A7?= =?UTF-8?q?=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../form/CustomInvoiceDataHandleHelper.java | 148 ++++++++--------- .../InvoiceNameRecognitionBillPlugin.java | 151 +++++++++--------- 2 files changed, 150 insertions(+), 149 deletions(-) diff --git a/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/CustomInvoiceDataHandleHelper.java b/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/CustomInvoiceDataHandleHelper.java index 4d6e776..9210500 100644 --- a/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/CustomInvoiceDataHandleHelper.java +++ b/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/CustomInvoiceDataHandleHelper.java @@ -185,83 +185,83 @@ public class CustomInvoiceDataHandleHelper extends InvoiceDataHandleHelper { DynamicObject seller = StringUtils.equals(dt.getName(), "ec_in_invoice") ? BusinessDataServiceHelper.loadSingle("bd_supplier", "", new QFilter[]{sellerFilter}) : BusinessDataServiceHelper.loadSingle("bos_org", "", new QFilter[]{sellerFilter}); if (seller == null) { - throw new KDBizException(String.format(ResManager.loadKDString("发票【%1$s】:销售方【%2$s】不存在。", "InvoiceDataHandleHelper_6", "ec-ecbd-common", new Object[0]), invoiceVO.getInvoiceCode(), sellerName)); + //throw new KDBizException(String.format(ResManager.loadKDString("发票【%1$s】:销售方【%2$s】不存在。", "InvoiceDataHandleHelper_6", "ec-ecbd-common", new Object[0]), invoiceVO.getInvoiceCode(), sellerName)); } else { invoice.set("seller", seller); - invoice.set("invoicestatus", invoiceVO.getInvoiceStatus()); - invoice.set("billstatus", BillStatusEnum.AUDIT.getValue()); - invoice.set("org_id", orgID); - List detailEntries = invoiceVO.getItems(); - if (detailEntries != null && !detailEntries.isEmpty()) { - DynamicObjectCollection invoiceEntries = invoice.getDynamicObjectCollection("entryentity"); - DynamicObjectType entryDt = (new DynamicObject(dt)).getDynamicObjectCollection("entryentity").getDynamicObjectType(); - - for(InvoiceItemVO item : detailEntries) { - DynamicObject entry = new DynamicObject(entryDt); - entry.set("name", item.getGoodsName()); - entry.set("model", item.getSpecModel()); - String unitName = item.getUnit(); - if (unitName != null && !unitName.isEmpty()) { - QFilter unitFilter = (new QFilter("name", "=", unitName)).or("number", "=", unitName).or("number", "=", unitName.toLowerCase()).or("number", "=", unitName.toUpperCase()); - QFilter validFilter = (new QFilter("enable", "=", DefaultEnum.YES.getValue().charAt(0))).and("status", "=", BillStatusEnum.AUDIT.getValue().charAt(0)); - DynamicObject unit = BusinessDataServiceHelper.loadSingle("bd_measureunits", "name", new QFilter[]{unitFilter, validFilter}); - if (unit != null) { - entry.set("unit", unit); - } - } - - entry.set("qty", item.getNum()); - BigDecimal price = item.getUnitPrice(); - entry.set("price", item.getUnitPrice()); - entry.set("amount", item.getDetailAmount()); - BigDecimal ofTaxPrice = price; - BigDecimal tax = item.getTaxRate(); - if (tax != null) { - BigDecimal taxRateHundred = tax.multiply(BigDecimal.TEN.multiply(BigDecimal.TEN)); - QFilter taxFilter = new QFilter("taxrate", "=", taxRateHundred); - DynamicObject[] taxRate = BusinessDataServiceHelper.load("bd_taxrate", "name", new QFilter[]{taxFilter}); - if (taxRate != null && taxRate.length > 0) { - entry.set("taxrate", taxRate[0]); - } - - if (price != null) { - ofTaxPrice = price.multiply(BigDecimal.ONE.add(tax)); - } - } - - entry.set("oftaxprice", ofTaxPrice); - entry.set("tax", item.getTaxAmount()); - entry.set("oftaxamount", item.getDetailAmount().add(item.getTaxAmount() == null ? BigDecimal.ZERO : item.getTaxAmount())); - invoiceEntries.add(entry); - } - } - - String snapshotUrl = invoiceVO.getSnapshotUrl(); - if (!StringUtils.isBlank(snapshotUrl)) { - DynamicObjectCollection pictureEntries = invoice.getDynamicObjectCollection("pictureentry"); - DynamicObjectType pictureEntryDt = (new DynamicObject(dt)).getDynamicObjectCollection("pictureentry").getDynamicObjectType(); - DynamicObject item = new DynamicObject(pictureEntryDt); - item.set("filename", invoiceVO.getInvoiceNo()); - item.set("imageurl", snapshotUrl); - item.set("uploaddate", date); - pictureEntries.add(item); - } - - invoice.set("creator_id", userID); - invoice.set("modifier_id", userID); - invoice.set("auditor_id", userID); - invoice.set("createtime", date); - invoice.set("modifytime", date); - invoice.set("auditdate", date); - CodeRuleInfo codeRuleInfo = CodeRuleServiceHelper.getCodeRule(dt.getName(), invoice, String.valueOf(RequestContext.get().getOrgId())); - if (null != codeRuleInfo) { - invoice.set("billno", CodeRuleServiceHelper.getNumber(codeRuleInfo, invoice)); - } else { - invoice.set("billno", invoiceVO.getSerialNo()); - } - - return invoice; } + invoice.set("invoicestatus", invoiceVO.getInvoiceStatus()); + invoice.set("billstatus", BillStatusEnum.AUDIT.getValue()); + invoice.set("org_id", orgID); + List detailEntries = invoiceVO.getItems(); + if (detailEntries != null && !detailEntries.isEmpty()) { + DynamicObjectCollection invoiceEntries = invoice.getDynamicObjectCollection("entryentity"); + DynamicObjectType entryDt = (new DynamicObject(dt)).getDynamicObjectCollection("entryentity").getDynamicObjectType(); + + for(InvoiceItemVO item : detailEntries) { + DynamicObject entry = new DynamicObject(entryDt); + entry.set("name", item.getGoodsName()); + entry.set("model", item.getSpecModel()); + String unitName = item.getUnit(); + if (unitName != null && !unitName.isEmpty()) { + QFilter unitFilter = (new QFilter("name", "=", unitName)).or("number", "=", unitName).or("number", "=", unitName.toLowerCase()).or("number", "=", unitName.toUpperCase()); + QFilter validFilter = (new QFilter("enable", "=", DefaultEnum.YES.getValue().charAt(0))).and("status", "=", BillStatusEnum.AUDIT.getValue().charAt(0)); + DynamicObject unit = BusinessDataServiceHelper.loadSingle("bd_measureunits", "name", new QFilter[]{unitFilter, validFilter}); + if (unit != null) { + entry.set("unit", unit); + } + } + + entry.set("qty", item.getNum()); + BigDecimal price = item.getUnitPrice(); + entry.set("price", item.getUnitPrice()); + entry.set("amount", item.getDetailAmount()); + BigDecimal ofTaxPrice = price; + BigDecimal tax = item.getTaxRate(); + if (tax != null) { + BigDecimal taxRateHundred = tax.multiply(BigDecimal.TEN.multiply(BigDecimal.TEN)); + QFilter taxFilter = new QFilter("taxrate", "=", taxRateHundred); + DynamicObject[] taxRate = BusinessDataServiceHelper.load("bd_taxrate", "name", new QFilter[]{taxFilter}); + if (taxRate != null && taxRate.length > 0) { + entry.set("taxrate", taxRate[0]); + } + + if (price != null) { + ofTaxPrice = price.multiply(BigDecimal.ONE.add(tax)); + } + } + + entry.set("oftaxprice", ofTaxPrice); + entry.set("tax", item.getTaxAmount()); + entry.set("oftaxamount", item.getDetailAmount().add(item.getTaxAmount() == null ? BigDecimal.ZERO : item.getTaxAmount())); + invoiceEntries.add(entry); + } + } + + String snapshotUrl = invoiceVO.getSnapshotUrl(); + if (!StringUtils.isBlank(snapshotUrl)) { + DynamicObjectCollection pictureEntries = invoice.getDynamicObjectCollection("pictureentry"); + DynamicObjectType pictureEntryDt = (new DynamicObject(dt)).getDynamicObjectCollection("pictureentry").getDynamicObjectType(); + DynamicObject item = new DynamicObject(pictureEntryDt); + item.set("filename", invoiceVO.getInvoiceNo()); + item.set("imageurl", snapshotUrl); + item.set("uploaddate", date); + pictureEntries.add(item); + } + + invoice.set("creator_id", userID); + invoice.set("modifier_id", userID); + invoice.set("auditor_id", userID); + invoice.set("createtime", date); + invoice.set("modifytime", date); + invoice.set("auditdate", date); + CodeRuleInfo codeRuleInfo = CodeRuleServiceHelper.getCodeRule(dt.getName(), invoice, String.valueOf(RequestContext.get().getOrgId())); + if (null != codeRuleInfo) { + invoice.set("billno", CodeRuleServiceHelper.getNumber(codeRuleInfo, invoice)); + } else { + invoice.set("billno", invoiceVO.getSerialNo()); + } + + return invoice; } } diff --git a/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/InvoiceNameRecognitionBillPlugin.java b/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/InvoiceNameRecognitionBillPlugin.java index c1d476b..30d619f 100644 --- a/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/InvoiceNameRecognitionBillPlugin.java +++ b/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/InvoiceNameRecognitionBillPlugin.java @@ -108,84 +108,85 @@ public class InvoiceNameRecognitionBillPlugin extends InvoiceDataHandleHelper { DynamicObject seller = StringUtils.equals(dt.getName(), "ec_in_invoice") ? BusinessDataServiceHelper.loadSingle("bd_supplier", "", new QFilter[]{sellerFilter}) : BusinessDataServiceHelper.loadSingle("bos_org", "", new QFilter[]{sellerFilter}); if (seller == null) { - throw new KDBizException(String.format(ResManager.loadKDString("发票【%1$s】:销售方【%2$s】不存在。", "InvoiceDataHandleHelper_6", "ec-ecbd-common", new Object[0]), invoiceVO.getInvoiceCode(), sellerName)); + //throw new KDBizException(String.format(ResManager.loadKDString("发票【%1$s】:销售方【%2$s】不存在。", "InvoiceDataHandleHelper_6", "ec-ecbd-common", new Object[0]), invoiceVO.getInvoiceCode(), sellerName)); } else { invoice.set("seller", seller); - invoice.set("invoicestatus", invoiceVO.getInvoiceStatus()); - invoice.set("billstatus", BillStatusEnum.AUDIT.getValue()); - invoice.set("org_id", orgID); - //处理发票明细 - List detailEntries = invoiceVO.getItems(); - if (detailEntries != null && !detailEntries.isEmpty()) { - DynamicObjectCollection invoiceEntries = invoice.getDynamicObjectCollection("entryentity"); - DynamicObjectType entryDt = (new DynamicObject(dt)).getDynamicObjectCollection("entryentity").getDynamicObjectType(); - - for(InvoiceItemVO item : detailEntries) { - DynamicObject entry = new DynamicObject(entryDt); - entry.set("name", item.getGoodsName()); - entry.set("model", item.getSpecModel()); - String unitName = item.getUnit(); - if (unitName != null && !unitName.isEmpty()) { - QFilter unitFilter = (new QFilter("name", "=", unitName)).or("number", "=", unitName).or("number", "=", unitName.toLowerCase()).or("number", "=", unitName.toUpperCase()); - QFilter validFilter = (new QFilter("enable", "=", DefaultEnum.YES.getValue().charAt(0))).and("status", "=", BillStatusEnum.AUDIT.getValue().charAt(0)); - DynamicObject unit = BusinessDataServiceHelper.loadSingle("bd_measureunits", "name", new QFilter[]{unitFilter, validFilter}); - if (unit != null) { - entry.set("unit", unit); - } - } - - entry.set("qty", item.getNum()); - BigDecimal price = item.getUnitPrice(); - entry.set("price", item.getUnitPrice()); - entry.set("amount", item.getDetailAmount()); - BigDecimal ofTaxPrice = price; - BigDecimal tax = item.getTaxRate(); - if (tax != null) { - BigDecimal taxRateHundred = tax.multiply(BigDecimal.TEN.multiply(BigDecimal.TEN)); - QFilter taxFilter = new QFilter("taxrate", "=", taxRateHundred); - DynamicObject[] taxRate = BusinessDataServiceHelper.load("bd_taxrate", "name", new QFilter[]{taxFilter}); - if (taxRate != null && taxRate.length > 0) { - entry.set("taxrate", taxRate[0]); - } - - if (price != null) { - ofTaxPrice = price.multiply(BigDecimal.ONE.add(tax)); - } - } - - entry.set("oftaxprice", ofTaxPrice); - entry.set("tax", item.getTaxAmount()); - entry.set("oftaxamount", item.getDetailAmount().add(item.getTaxAmount() == null ? BigDecimal.ZERO : item.getTaxAmount())); - invoiceEntries.add(entry); - } - } - - String snapshotUrl = invoiceVO.getSnapshotUrl(); - if (!StringUtils.isBlank(snapshotUrl)) { - DynamicObjectCollection pictureEntries = invoice.getDynamicObjectCollection("pictureentry"); - DynamicObjectType pictureEntryDt = (new DynamicObject(dt)).getDynamicObjectCollection("pictureentry").getDynamicObjectType(); - DynamicObject item = new DynamicObject(pictureEntryDt); - item.set("filename", invoiceVO.getInvoiceNo()); - item.set("imageurl", snapshotUrl); - item.set("uploaddate", date); - pictureEntries.add(item); - } - - invoice.set("creator_id", userID); - invoice.set("modifier_id", userID); - invoice.set("auditor_id", userID); - invoice.set("createtime", date); - invoice.set("modifytime", date); - invoice.set("auditdate", date); - CodeRuleInfo codeRuleInfo = CodeRuleServiceHelper.getCodeRule(dt.getName(), invoice, String.valueOf(RequestContext.get().getOrgId())); - if (null != codeRuleInfo) { - invoice.set("billno", CodeRuleServiceHelper.getNumber(codeRuleInfo, invoice)); - } else { - invoice.set("billno", invoiceVO.getSerialNo()); - } - - return invoice; } + + invoice.set("invoicestatus", invoiceVO.getInvoiceStatus()); + invoice.set("billstatus", BillStatusEnum.AUDIT.getValue()); + invoice.set("org_id", orgID); + //处理发票明细 + List detailEntries = invoiceVO.getItems(); + if (detailEntries != null && !detailEntries.isEmpty()) { + DynamicObjectCollection invoiceEntries = invoice.getDynamicObjectCollection("entryentity"); + DynamicObjectType entryDt = (new DynamicObject(dt)).getDynamicObjectCollection("entryentity").getDynamicObjectType(); + + for(InvoiceItemVO item : detailEntries) { + DynamicObject entry = new DynamicObject(entryDt); + entry.set("name", item.getGoodsName()); + entry.set("model", item.getSpecModel()); + String unitName = item.getUnit(); + if (unitName != null && !unitName.isEmpty()) { + QFilter unitFilter = (new QFilter("name", "=", unitName)).or("number", "=", unitName).or("number", "=", unitName.toLowerCase()).or("number", "=", unitName.toUpperCase()); + QFilter validFilter = (new QFilter("enable", "=", DefaultEnum.YES.getValue().charAt(0))).and("status", "=", BillStatusEnum.AUDIT.getValue().charAt(0)); + DynamicObject unit = BusinessDataServiceHelper.loadSingle("bd_measureunits", "name", new QFilter[]{unitFilter, validFilter}); + if (unit != null) { + entry.set("unit", unit); + } + } + + entry.set("qty", item.getNum()); + BigDecimal price = item.getUnitPrice(); + entry.set("price", item.getUnitPrice()); + entry.set("amount", item.getDetailAmount()); + BigDecimal ofTaxPrice = price; + BigDecimal tax = item.getTaxRate(); + if (tax != null) { + BigDecimal taxRateHundred = tax.multiply(BigDecimal.TEN.multiply(BigDecimal.TEN)); + QFilter taxFilter = new QFilter("taxrate", "=", taxRateHundred); + DynamicObject[] taxRate = BusinessDataServiceHelper.load("bd_taxrate", "name", new QFilter[]{taxFilter}); + if (taxRate != null && taxRate.length > 0) { + entry.set("taxrate", taxRate[0]); + } + + if (price != null) { + ofTaxPrice = price.multiply(BigDecimal.ONE.add(tax)); + } + } + + entry.set("oftaxprice", ofTaxPrice); + entry.set("tax", item.getTaxAmount()); + entry.set("oftaxamount", item.getDetailAmount().add(item.getTaxAmount() == null ? BigDecimal.ZERO : item.getTaxAmount())); + invoiceEntries.add(entry); + } + } + + String snapshotUrl = invoiceVO.getSnapshotUrl(); + if (!StringUtils.isBlank(snapshotUrl)) { + DynamicObjectCollection pictureEntries = invoice.getDynamicObjectCollection("pictureentry"); + DynamicObjectType pictureEntryDt = (new DynamicObject(dt)).getDynamicObjectCollection("pictureentry").getDynamicObjectType(); + DynamicObject item = new DynamicObject(pictureEntryDt); + item.set("filename", invoiceVO.getInvoiceNo()); + item.set("imageurl", snapshotUrl); + item.set("uploaddate", date); + pictureEntries.add(item); + } + + invoice.set("creator_id", userID); + invoice.set("modifier_id", userID); + invoice.set("auditor_id", userID); + invoice.set("createtime", date); + invoice.set("modifytime", date); + invoice.set("auditdate", date); + CodeRuleInfo codeRuleInfo = CodeRuleServiceHelper.getCodeRule(dt.getName(), invoice, String.valueOf(RequestContext.get().getOrgId())); + if (null != codeRuleInfo) { + invoice.set("billno", CodeRuleServiceHelper.getNumber(codeRuleInfo, invoice)); + } else { + invoice.set("billno", invoiceVO.getSerialNo()); + } + + return invoice; } } }