From 75e1600bc7db8e06cbbd164d074f2072f75990fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B8=B8=E7=86=9F=E5=90=B4=E5=BD=A6=E7=A5=96?= Date: Fri, 13 Nov 2026 15:02:16 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=B7=E6=A0=BC=E5=AF=BC=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/Impl/PODetailServiceImpl.java | 16 +++++++- .../order/support/PoImportStatusSupport.java | 3 +- .../task/SupplierNewProductHistoryTask.java | 39 +++++++++++++++++++ src/main/resources/application.yml | 2 + 4 files changed, 57 insertions(+), 3 deletions(-) create mode 100644 src/main/java/com/xujie/modules/order/task/SupplierNewProductHistoryTask.java diff --git a/src/main/java/com/xujie/modules/order/service/Impl/PODetailServiceImpl.java b/src/main/java/com/xujie/modules/order/service/Impl/PODetailServiceImpl.java index 9b2e68c..67741ac 100644 --- a/src/main/java/com/xujie/modules/order/service/Impl/PODetailServiceImpl.java +++ b/src/main/java/com/xujie/modules/order/service/Impl/PODetailServiceImpl.java @@ -2800,7 +2800,8 @@ public class PODetailServiceImpl extends ServiceImpl i * PO 导入专用保存:Excel 能对上的列原样入库,不复用 createPoOrderInternal / saveModelInternal。 * 系统只生成:order_no、item_no=1、order_ref1=PO_No、order_ref2 自增、po_header_id、site、页面 customer。 * 数量按映射后状态回填,不信任 Excel A_Qty: - * 完全发货时 c_ship_qty / to_inspect_qty / inspect_qty / inspect_approve_qty 都等于 qty,其余状态这四列都为 0。 + * 完全发货时 c_ship_qty / to_inspect_qty / inspect_qty / inspect_approve_qty 都等于 qty; + * 验货完成时 to_inspect_qty / inspect_qty / inspect_approve_qty 等于 qty、c_ship_qty 为 0;其余状态为 0。 * base_price 使用 Excel 列,不按价格表回填。 * * @param vo 预览映射后的单行数据,part_no 来自 Item 原样拷贝,supplier_no 来自 Vendor Name @@ -2943,7 +2944,8 @@ public class PODetailServiceImpl extends ServiceImpl i /** * 导入数量按映射后状态回填,忽略 Excel A_Qty 及验货数量列。 - * 完全发货:发货/待验/已验/验货完成数量都等于订单 qty;其它状态这四列都为 0。 + * 完全发货:发货/待验/已验/验货通过数量都等于订单 qty; + * 验货完成:已申请验货、已验货和验货通过数量等于订单 qty,发货数量为 0;其它状态均为 0。 * * @param vo 即将落库的明细,必须已有 qty * @param status 已映射的系统状态 @@ -2961,6 +2963,16 @@ public class PODetailServiceImpl extends ServiceImpl i vo.setInspectApproveQty(BigDecimal.valueOf(qty)); return; } + if ("验货完成".equals(status)) { + if (qty == null) { + throw new IllegalArgumentException("验货完成状态导入时 PO Qty 不能为空"); + } + vo.setShipQty(BigDecimal.ZERO); + vo.setToInspectQty(BigDecimal.valueOf(qty)); + vo.setInspectQty(qty); + vo.setInspectApproveQty(BigDecimal.valueOf(qty)); + return; + } vo.setShipQty(BigDecimal.ZERO); vo.setToInspectQty(BigDecimal.ZERO); vo.setInspectQty(0d); diff --git a/src/main/java/com/xujie/modules/order/support/PoImportStatusSupport.java b/src/main/java/com/xujie/modules/order/support/PoImportStatusSupport.java index 8e9921f..9db1261 100644 --- a/src/main/java/com/xujie/modules/order/support/PoImportStatusSupport.java +++ b/src/main/java/com/xujie/modules/order/support/PoImportStatusSupport.java @@ -27,6 +27,7 @@ public final class PoImportStatusSupport { putAlias(map, "Cancelled", "已取消"); putAlias(map, "Canceled", "已取消"); putAlias(map, "Shipped", "完全发货"); + putAlias(map, "Inspection Pass", "验货完成"); // 映射目标自身 putAlias(map, "草稿", "草稿"); putAlias(map, "已下达", "已下达"); @@ -79,7 +80,7 @@ public final class PoImportStatusSupport { public static String buildMismatchMessage(String raw) { String text = raw == null ? "" : raw.trim(); - return "状态不匹配: " + text + "(仅支持 Inquiry→草稿、Confirmed→已下达、Cancelled→已取消、Shipped→完全发货)"; + return "状态不匹配: " + text + "(支持 Inquiry→草稿、Confirmed→已下达、Cancelled→已取消、Shipped→完全发货、Inspection Pass→验货完成)"; } private static void putAlias(Map map, String alias, String status) { diff --git a/src/main/java/com/xujie/modules/order/task/SupplierNewProductHistoryTask.java b/src/main/java/com/xujie/modules/order/task/SupplierNewProductHistoryTask.java new file mode 100644 index 0000000..2f44cfd --- /dev/null +++ b/src/main/java/com/xujie/modules/order/task/SupplierNewProductHistoryTask.java @@ -0,0 +1,39 @@ +package com.xujie.modules.order.task; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Component; + +import java.util.Map; + +/** Runs the supplier/base-part first-order refresh in SQL Server. */ +@Component +public class SupplierNewProductHistoryTask { + + private static final Logger log = LoggerFactory.getLogger(SupplierNewProductHistoryTask.class); + + private final JdbcTemplate jdbcTemplate; + private final boolean taskEnabled; + + public SupplierNewProductHistoryTask( + JdbcTemplate jdbcTemplate, + @Value("${task.enabled}") boolean taskEnabled) { + this.jdbcTemplate = jdbcTemplate; + this.taskEnabled = taskEnabled; + } + + @Scheduled(cron = "${task.data.supplierNewProductHistory}", zone = "Asia/Shanghai") + public void refresh() { + if (!taskEnabled) { + return; + } + + Map result = jdbcTemplate.queryForMap( + "EXEC dbo.usp_refresh_supplier_new_product_history"); + log.info("Supplier new product history refresh: executed={}, candidates={}, inserted={}", + result.get("executed"), result.get("candidate_count"), result.get("inserted_count")); + } +} diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 1ca9187..b6c3765 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -96,6 +96,8 @@ xujie: task: data: site: 1 + # 20:15 Asia/Shanghai; task.enabled follows the existing global task switch. + supplierNewProductHistory: "0 15 20 * * ?" query: maxNums: 1000