From 84a2043b3edfc1b74516a89f0a3ffebeb6d7ba75 Mon Sep 17 00:00:00 2001 From: Gauthier LO Date: Thu, 18 Apr 2024 13:07:13 +0200 Subject: [PATCH] update : 3.6.3 --- db/views/all_invoices.sql | 37 +++++++++++++++++++ db/views/sales.sql | 11 +++++- .../admin/PurchaseOrderController.java | 5 ++- .../shippingInvoice/InvoiceController.java | 2 +- .../business/mapper/xml/ClientMapper.xml | 4 +- .../modules/business/mapper/xml/SkuMapper.xml | 4 +- .../service/impl/InvoiceServiceImpl.java | 14 +++---- .../src/main/resources/application-dev.yml | 2 +- 8 files changed, 64 insertions(+), 15 deletions(-) create mode 100644 db/views/all_invoices.sql diff --git a/db/views/all_invoices.sql b/db/views/all_invoices.sql new file mode 100644 index 000000000..b31c55c95 --- /dev/null +++ b/db/views/all_invoices.sql @@ -0,0 +1,37 @@ +CREATE VIEW all_invoices AS +WITH shipping AS ( + SELECT + s.id AS id, + s.create_by AS create_by, + s.create_time AS create_time, + s.client_id AS client_id, + s.currency_id AS currency_id, + s.invoice_number AS invoice_number, + IFNULL(s.total_amount + p.total_amount, s.total_amount) AS total_amount, + IFNULL(s.discount_amount + p.discount_amount, s.discount_amount) AS discount_amount, + IFNULL(s.final_amount + p.final_amount, s.final_amount) AS final_amount, + IFNULL(s.paid_amount + p.paid_amount, s.paid_amount) AS paid_amount, + IF(SUBSTRING(s.invoice_number,9,1) = '2', 'shipping', 'complete') AS 'type' + FROM shipping_invoice s + LEFT JOIN purchase_order p ON s.invoice_number = p.invoice_number + AND s.client_id = p.client_id +), + purchase AS ( + SELECT + p.id AS id, + p.create_by AS create_by, + p.create_time AS create_time, + p.client_id AS client_id, + p.currency_id AS currency_id, + p.invoice_number AS invoice_number, + p.total_amount AS total_amount, + p.discount_amount AS discount_amount, + p.final_amount AS final_amount, + p.paid_amount AS paid_amount, + IF(SUBSTRING(p.invoice_number,9,1) = '1', 'purchase', 'error') AS 'type' + FROM purchase_order p + WHERE p.invoice_number NOT IN (SELECT invoice_number FROM shipping_invoice) + ) +SELECT s.* FROM shipping s +UNION ALL SELECT p.* FROM purchase p +ORDER BY create_time DESC; \ No newline at end of file diff --git a/db/views/sales.sql b/db/views/sales.sql index 852a2ca21..64c32b3d5 100644 --- a/db/views/sales.sql +++ b/db/views/sales.sql @@ -17,4 +17,13 @@ SELECT poc.sku_id AS sku_id, SUM(poc.quantity) AS quantity FROM platform_order_content poc JOIN platform_order po ON poc.platform_order_id = po.id WHERE po.order_time BETWEEN DATE_SUB(CURDATE(), INTERVAL 28 DAY) AND CURDATE() -GROUP BY poc.sku_id; \ No newline at end of file +GROUP BY poc.sku_id; + +create view sales_42 as +select `poc`.`sku_id` AS `sku_id`, sum(`poc`.`quantity`) AS `quantity` +from (`wia_app`.`platform_order_content` `poc` + join `wia_app`.`platform_order` `po` + on ((`poc`.`platform_order_id` = `po`.`id`))) +where (`po`.`order_time` between (curdate() - interval 42 day) and curdate()) + and po.erp_status <> 5 +group by `poc`.`sku_id`; \ No newline at end of file diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/controller/admin/PurchaseOrderController.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/controller/admin/PurchaseOrderController.java index a9ffdd460..cb3c6f1dd 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/controller/admin/PurchaseOrderController.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/controller/admin/PurchaseOrderController.java @@ -586,8 +586,11 @@ public class PurchaseOrderController { Map skuQuantityMap = skuQuantities.stream() .collect(Collectors.toMap(SkuQuantity::getErpCode, SkuQuantity::getQuantity)); skuQuantityMap.forEach((s, integer) -> log.info("SKU: {} Quantity: {}", s, integer)); + Map skuQtyNotEmptyMap = skuQuantityMap.entrySet().stream() + .filter(entry -> entry.getValue() > 0) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); InvoiceMetaData metaData = purchaseOrderService.getMetaDataFromInvoiceNumbers(invoiceNumber); - boolean success = providerMabangService.addPurchaseOrderToMabang(skuQuantityMap, metaData, providersHistory); + boolean success = providerMabangService.addPurchaseOrderToMabang(skuQtyNotEmptyMap, metaData, providersHistory); return success ? invoiceNumber : "failed"; },throttlingExecutorService)) .collect(Collectors.toList()); diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/controller/admin/shippingInvoice/InvoiceController.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/controller/admin/shippingInvoice/InvoiceController.java index 302d4334b..e9a23a938 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/controller/admin/shippingInvoice/InvoiceController.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/controller/admin/shippingInvoice/InvoiceController.java @@ -704,7 +704,6 @@ public class InvoiceController { public byte[] downloadInventory(@RequestParam("invoiceCode") String invoiceCode, @RequestParam("internalCode") String internalCode, @RequestParam("invoiceEntity") String invoiceEntity) throws IOException { InvoiceMetaData metaData = new InvoiceMetaData("", invoiceCode, internalCode, invoiceEntity, ""); List skuOrderPages = skuService.getInventoryByInvoiceNumber(metaData.getInvoiceCode()); - System.out.println(skuOrderPages); return shippingInvoiceService.exportPurchaseInventoryToExcel(skuOrderPages, metaData); } @@ -797,6 +796,7 @@ public class InvoiceController { * @param completeClientIds list of clients to invoice complete fees * @return list of invoice infos */ + @Transactional @GetMapping(value = "/breakdown/makeInvoice") public Result makeBreakdownInvoice(@RequestParam(value = "shipping[]", required = false) List shippingClientIds, @RequestParam(value = "complete[]", required = false) List completeClientIds) throws IOException { diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/mapper/xml/ClientMapper.xml b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/mapper/xml/ClientMapper.xml index 2450ced08..6bda0f565 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/mapper/xml/ClientMapper.xml +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/mapper/xml/ClientMapper.xml @@ -61,8 +61,8 @@