Browse Source

价格导入

master
常熟吴彦祖 5 days ago
parent
commit
75e1600bc7
  1. 16
      src/main/java/com/xujie/modules/order/service/Impl/PODetailServiceImpl.java
  2. 3
      src/main/java/com/xujie/modules/order/support/PoImportStatusSupport.java
  3. 39
      src/main/java/com/xujie/modules/order/task/SupplierNewProductHistoryTask.java
  4. 2
      src/main/resources/application.yml

16
src/main/java/com/xujie/modules/order/service/Impl/PODetailServiceImpl.java

@ -2800,7 +2800,8 @@ public class PODetailServiceImpl extends ServiceImpl<PODetailMapper, PODetail> i
* PO 导入专用保存:Excel 能对上的列原样入库,不复用 createPoOrderInternal / saveModelInternal。 * PO 导入专用保存:Excel 能对上的列原样入库,不复用 createPoOrderInternal / saveModelInternal。
* 系统只生成:order_no、item_no=1、order_ref1=PO_No、order_ref2 自增、po_header_id、site、页面 customer。 * 系统只生成:order_no、item_no=1、order_ref1=PO_No、order_ref2 自增、po_header_id、site、页面 customer。
* 数量按映射后状态回填,不信任 Excel A_Qty: * 数量按映射后状态回填,不信任 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 列,不按价格表回填。 * base_price 使用 Excel 列,不按价格表回填。
* *
* @param vo 预览映射后的单行数据,part_no 来自 Item 原样拷贝,supplier_no 来自 Vendor Name * @param vo 预览映射后的单行数据,part_no 来自 Item 原样拷贝,supplier_no 来自 Vendor Name
@ -2943,7 +2944,8 @@ public class PODetailServiceImpl extends ServiceImpl<PODetailMapper, PODetail> i
/** /**
* 导入数量按映射后状态回填,忽略 Excel A_Qty 及验货数量列。 * 导入数量按映射后状态回填,忽略 Excel A_Qty 及验货数量列。
* 完全发货:发货/待验/已验/验货完成数量都等于订单 qty;其它状态这四列都为 0。
* 完全发货:发货/待验/已验/验货通过数量都等于订单 qty;
* 验货完成:已申请验货、已验货和验货通过数量等于订单 qty,发货数量为 0;其它状态均为 0。
* *
* @param vo 即将落库的明细,必须已有 qty * @param vo 即将落库的明细,必须已有 qty
* @param status 已映射的系统状态 * @param status 已映射的系统状态
@ -2961,6 +2963,16 @@ public class PODetailServiceImpl extends ServiceImpl<PODetailMapper, PODetail> i
vo.setInspectApproveQty(BigDecimal.valueOf(qty)); vo.setInspectApproveQty(BigDecimal.valueOf(qty));
return; 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.setShipQty(BigDecimal.ZERO);
vo.setToInspectQty(BigDecimal.ZERO); vo.setToInspectQty(BigDecimal.ZERO);
vo.setInspectQty(0d); vo.setInspectQty(0d);

3
src/main/java/com/xujie/modules/order/support/PoImportStatusSupport.java

@ -27,6 +27,7 @@ public final class PoImportStatusSupport {
putAlias(map, "Cancelled", "已取消"); putAlias(map, "Cancelled", "已取消");
putAlias(map, "Canceled", "已取消"); putAlias(map, "Canceled", "已取消");
putAlias(map, "Shipped", "完全发货"); putAlias(map, "Shipped", "完全发货");
putAlias(map, "Inspection Pass", "验货完成");
// 映射目标自身 // 映射目标自身
putAlias(map, "草稿", "草稿"); putAlias(map, "草稿", "草稿");
putAlias(map, "已下达", "已下达"); putAlias(map, "已下达", "已下达");
@ -79,7 +80,7 @@ public final class PoImportStatusSupport {
public static String buildMismatchMessage(String raw) { public static String buildMismatchMessage(String raw) {
String text = raw == null ? "" : raw.trim(); 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<String, String> map, String alias, String status) { private static void putAlias(Map<String, String> map, String alias, String status) {

39
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<String, Object> 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"));
}
}

2
src/main/resources/application.yml

@ -96,6 +96,8 @@ xujie:
task: task:
data: data:
site: 1 site: 1
# 20:15 Asia/Shanghai; task.enabled follows the existing global task switch.
supplierNewProductHistory: "0 15 20 * * ?"
query: query:
maxNums: 1000 maxNums: 1000

Loading…
Cancel
Save