From 19d7d42342d9598b9005b1ff5bc2f3fdb82a7c25 Mon Sep 17 00:00:00 2001 From: 86156 <823267011@qq.com> Date: Wed, 3 Dec 2025 16:29:00 +0800 Subject: [PATCH] =?UTF-8?q?bug=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- klp-ui/src/views/wms/cost/dashboard/index.vue | 15 +++-- klp-ui/src/views/wms/cost/stockpile/index.vue | 7 +++ .../impl/WmsCostCoilDailyServiceImpl.java | 11 ++-- .../mapper/klp/WmsCostCoilDailyMapper.xml | 63 ++++++++++++++----- 4 files changed, 73 insertions(+), 23 deletions(-) diff --git a/klp-ui/src/views/wms/cost/dashboard/index.vue b/klp-ui/src/views/wms/cost/dashboard/index.vue index 10f4c2aa..9b0d4303 100644 --- a/klp-ui/src/views/wms/cost/dashboard/index.vue +++ b/klp-ui/src/views/wms/cost/dashboard/index.vue @@ -3,8 +3,13 @@
-
今日总成本
-
{{ formatMoney(todayCost) }}
+
总囤积成本
+
{{ formatMoney(totalStockpileCost) }}
+
+
+
+
当日囤积成本
+
{{ formatMoney(todayStockpileCost) }}
@@ -112,7 +117,8 @@ export default { name: 'CostDashboard', data() { return { - todayCost: 0, + totalStockpileCost: 0, + todayStockpileCost: 0, totalCoils: 0, totalNetWeight: 0, totalGrossWeight: 0, @@ -150,7 +156,8 @@ export default { try { const res = await getCostOverview() if (res.code === 200 && res.data) { - this.todayCost = res.data.totalCost || 0 + this.totalStockpileCost = res.data.totalCost || 0 + this.todayStockpileCost = res.data.todayCost || 0 this.totalCoils = res.data.totalCoils || 0 this.totalNetWeight = res.data.totalNetWeight || 0 this.totalGrossWeight = res.data.totalGrossWeight || 0 diff --git a/klp-ui/src/views/wms/cost/stockpile/index.vue b/klp-ui/src/views/wms/cost/stockpile/index.vue index 3bae30cd..b918df3e 100644 --- a/klp-ui/src/views/wms/cost/stockpile/index.vue +++ b/klp-ui/src/views/wms/cost/stockpile/index.vue @@ -53,6 +53,11 @@
{{ formatMoney(totalCost) }}
+
+
当日囤积成本
+
{{ formatMoney(todayCost) }}
+
+
平均在库天数
{{ avgStorageDays }}
@@ -182,6 +187,7 @@ export default { totalNetWeight: 0, totalGrossWeight: 0, totalCost: 0, + todayCost: 0, avgStorageDays: 0, coilList: [], queryParams: { @@ -216,6 +222,7 @@ export default { this.totalNetWeight = summary.totalNetWeight || 0 this.totalGrossWeight = summary.totalGrossWeight || 0 this.totalCost = summary.totalCost || 0 + this.todayCost = summary.todayCost || 0 this.avgStorageDays = summary.avgStorageDays || 0 } } catch (error) { diff --git a/klp-wms/src/main/java/com/klp/service/impl/WmsCostCoilDailyServiceImpl.java b/klp-wms/src/main/java/com/klp/service/impl/WmsCostCoilDailyServiceImpl.java index 2403de65..41b193a1 100644 --- a/klp-wms/src/main/java/com/klp/service/impl/WmsCostCoilDailyServiceImpl.java +++ b/klp-wms/src/main/java/com/klp/service/impl/WmsCostCoilDailyServiceImpl.java @@ -791,8 +791,8 @@ public class WmsCostCoilDailyServiceImpl implements IWmsCostCoilDailyService { summary.put("totalGrossWeight", BigDecimal.ZERO.setScale(3, RoundingMode.HALF_UP)); summary.put("totalCost", BigDecimal.ZERO.setScale(2, RoundingMode.HALF_UP)); summary.put("avgStorageDays", BigDecimal.ZERO.setScale(2, RoundingMode.HALF_UP)); + summary.put("todayCost", BigDecimal.ZERO.setScale(2, RoundingMode.HALF_UP)); } - // 兼容前端字段命名 summary.putIfAbsent("totalCoils", total); @@ -813,6 +813,7 @@ public class WmsCostCoilDailyServiceImpl implements IWmsCostCoilDailyService { if (db == null || db.isEmpty()) { result.put("totalCost", BigDecimal.ZERO.setScale(2, RoundingMode.HALF_UP)); + result.put("todayCost", BigDecimal.ZERO.setScale(2, RoundingMode.HALF_UP)); result.put("totalNetWeight", BigDecimal.ZERO.setScale(3, RoundingMode.HALF_UP)); result.put("totalGrossWeight", BigDecimal.ZERO.setScale(3, RoundingMode.HALF_UP)); result.put("avgStorageDays", BigDecimal.ZERO.setScale(2, RoundingMode.HALF_UP)); @@ -821,16 +822,18 @@ public class WmsCostCoilDailyServiceImpl implements IWmsCostCoilDailyService { } BigDecimal totalCost = toBigDecimal(db.get("totalCost"), 2); + BigDecimal todayCost = toBigDecimal(db.get("todayCost"), 2); BigDecimal totalNetWeight = toBigDecimal(db.get("totalNetWeight"), 3); BigDecimal totalGrossWeight = toBigDecimal(db.get("totalGrossWeight"), 3); BigDecimal avgStorageDays = toBigDecimal(db.get("avgStorageDays"), 2); - Number totalCoils = db.get("totalCoils") instanceof Number ? (Number) db.get("totalCoils") : 0; - + LocalDate calcDate = LocalDate.now(); + Long totalCoils = baseMapper.countStockpileByEnterCoilNo(calcDate,null); result.put("totalCost", totalCost); + result.put("todayCost", todayCost); result.put("totalNetWeight", totalNetWeight); result.put("totalGrossWeight", totalGrossWeight); result.put("avgStorageDays", avgStorageDays); - result.put("totalCoils", totalCoils.intValue()); + result.put("totalCoils", totalCoils); return result; } diff --git a/klp-wms/src/main/resources/mapper/klp/WmsCostCoilDailyMapper.xml b/klp-wms/src/main/resources/mapper/klp/WmsCostCoilDailyMapper.xml index 5f7fcd0e..36e76516 100644 --- a/klp-wms/src/main/resources/mapper/klp/WmsCostCoilDailyMapper.xml +++ b/klp-wms/src/main/resources/mapper/klp/WmsCostCoilDailyMapper.xml @@ -108,7 +108,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" SUM(t.daily_cost_amount) AS totalDailyCost FROM ( SELECT - m.coil_id, IFNULL(m.net_weight, 0) AS net_weight_ton, IFNULL(m.gross_weight, 0) AS gross_weight_ton, (DATEDIFF(CURDATE(), IFNULL(m.create_time, CURDATE())) + 1) AS storage_days, @@ -116,8 +115,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" WHEN cs.unit_cost IS NULL THEN 0 ELSE ( CASE - WHEN IFNULL(m.gross_weight, 0) > 0 THEN m.gross_weight - ELSE IFNULL(m.net_weight, 0) + WHEN IFNULL(m.net_weight, 0) > 0 THEN m.net_weight + ELSE IFNULL(m.gross_weight, 0) END ) * cs.unit_cost END AS daily_cost_amount, @@ -125,8 +124,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" WHEN cs.unit_cost IS NULL THEN 0 ELSE ( CASE - WHEN IFNULL(m.gross_weight, 0) > 0 THEN m.gross_weight - ELSE IFNULL(m.net_weight, 0) + WHEN IFNULL(m.net_weight, 0) = 0 AND IFNULL(m.gross_weight, 0) > 0 THEN m.gross_weight + ELSE IFNULL(m.net_weight, 0) END ) * cs.unit_cost * (DATEDIFF(CURDATE(), IFNULL(m.create_time, CURDATE())) + 1) END AS total_cost_amount @@ -137,6 +136,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" AND (cs.expire_date IS NULL OR DATE(m.create_time) <= cs.expire_date) WHERE m.data_type = 1 AND m.del_flag = 0 + and m.status = 0 AND m.export_time IS NULL AND m.warehouse_id = #{warehouseId} @@ -171,7 +171,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" WHEN cs.unit_cost IS NULL THEN 0 ELSE ( CASE - WHEN IFNULL(m.gross_weight, 0) > 0 THEN m.gross_weight + WHEN IFNULL(m.net_weight, 0) = 0 AND IFNULL(m.gross_weight, 0) > 0 THEN m.gross_weight ELSE IFNULL(m.net_weight, 0) END ) * cs.unit_cost * (DATEDIFF(CURDATE(), IFNULL(m.create_time, CURDATE())) + 1) @@ -210,7 +210,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" WHEN cs.unit_cost IS NULL THEN 0 ELSE ( CASE - WHEN IFNULL(m.gross_weight, 0) > 0 THEN m.gross_weight + WHEN IFNULL(m.net_weight, 0) = 0 AND IFNULL(m.gross_weight, 0) > 0 THEN m.gross_weight ELSE IFNULL(m.net_weight, 0) END ) * cs.unit_cost * (DATEDIFF(CURDATE(), IFNULL(m.create_time, CURDATE())) + 1) @@ -310,6 +310,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" FROM wms_material_coil m WHERE m.data_type = 1 AND m.del_flag = 0 + and m.status = 0 AND m.export_time IS NULL AND m.enter_coil_no LIKE CONCAT(#{enterCoilNo}, '%') @@ -324,7 +325,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" SUM(t.net_weight_ton) AS totalNetWeight, SUM(t.gross_weight_ton) AS totalGrossWeight, SUM(t.cost_amount) AS totalCost, - AVG(t.storage_days) AS avgStorageDays + AVG(t.storage_days) AS avgStorageDays, + SUM(t.today_cost_amount) AS todayCost FROM ( SELECT IFNULL(m.net_weight, 0) AS net_weight_ton, @@ -333,11 +335,25 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" WHEN cs.unit_cost IS NULL THEN 0 ELSE ( CASE - WHEN IFNULL(m.gross_weight, 0) > 0 THEN m.gross_weight - ELSE IFNULL(m.net_weight, 0) + WHEN IFNULL(m.net_weight, 0) > 0 THEN m.net_weight + ELSE IFNULL(m.gross_weight, 0) END ) * cs.unit_cost * (DATEDIFF(CURDATE(), IFNULL(m.create_time, CURDATE())) + 1) END AS cost_amount, + CASE + WHEN m.status = 0 THEN ( + CASE + WHEN cs.unit_cost IS NULL THEN 0 + ELSE ( + CASE + WHEN IFNULL(m.net_weight, 0) > 0 THEN m.net_weight + ELSE IFNULL(m.gross_weight, 0) + END + ) * cs.unit_cost + END + ) + ELSE 0 + END AS today_cost_amount, (DATEDIFF(CURDATE(), IFNULL(m.create_time, CURDATE())) + 1) AS storage_days FROM wms_material_coil m LEFT JOIN wms_cost_standard_config cs @@ -346,6 +362,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" AND (cs.expire_date IS NULL OR DATE(m.create_time) <= cs.expire_date) WHERE m.data_type = 1 AND m.del_flag = 0 + and m.status = 0 AND m.export_time IS NULL AND m.enter_coil_no LIKE CONCAT(#{enterCoilNo}, '%') @@ -359,7 +376,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" SUM(t.net_weight_ton) AS totalNetWeight, SUM(t.gross_weight_ton) AS totalGrossWeight, AVG(t.storage_days) AS avgStorageDays, - SUM(t.cost_amount) AS totalCost + SUM(t.cost_amount) AS totalCost, + SUM(t.today_cost_amount) AS todayCost FROM ( SELECT IFNULL(m.net_weight, 0) AS net_weight_ton, @@ -369,11 +387,25 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" WHEN cs.unit_cost IS NULL THEN 0 ELSE ( CASE - WHEN IFNULL(m.gross_weight, 0) > 0 THEN m.gross_weight - ELSE IFNULL(m.net_weight, 0) + WHEN IFNULL(m.net_weight, 0) > 0 THEN m.gross_weight + ELSE IFNULL(m.gross_weight, 0) END ) * cs.unit_cost * (DATEDIFF(CURDATE(), IFNULL(m.create_time, CURDATE())) + 1) - END AS cost_amount + END AS cost_amount, + CASE + WHEN m.status = 0 THEN ( + CASE + WHEN cs.unit_cost IS NULL THEN 0 + ELSE ( + CASE + WHEN IFNULL(m.net_weight, 0) > 0 THEN m.net_weight + ELSE IFNULL(m.gross_weight, 0) + END + ) * cs.unit_cost + END + ) + ELSE 0 + END AS today_cost_amount FROM wms_material_coil m LEFT JOIN wms_cost_standard_config cs ON cs.status = 1 @@ -381,6 +413,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" AND (cs.expire_date IS NULL OR DATE(m.create_time) <= cs.expire_date) WHERE m.data_type = 1 AND m.del_flag = 0 + AND m.status = 0 AND m.export_time IS NULL ) t @@ -418,7 +451,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ELSE 'net' END AS weight_basis, CASE - WHEN IFNULL(m.gross_weight, 0) > 0 THEN IFNULL(m.gross_weight, 0) + WHEN IFNULL(m.net_weight, 0) = 0 AND IFNULL(m.gross_weight, 0) > 0 THEN m.gross_weight ELSE IFNULL(m.net_weight, 0) END AS charge_weight_ton, DATE(m.create_time) AS start_date,