From 7f01d6099649778dee9fc053b7ff8e573cb0b7c5 Mon Sep 17 00:00:00 2001
From: zf <27208084@qq.com>
Date: Wed, 1 Nov 2023 15:45:43 +0800
Subject: [PATCH] 修复库存为0时,无法预警的问题,跳转连接修复

---
 huaheng-wms-core/src/main/java/org/jeecg/modules/wms/inventory/inventoryLevel/mapper/xml/InventoryLevelAlarmMapper.xml | 32 ++++++++++++++------------------
 huaheng-wms-core/src/main/java/org/jeecg/modules/wms/monitor/job/InventoryLevelAlarmTask.java                          |  4 ++--
 2 files changed, 16 insertions(+), 20 deletions(-)

diff --git a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/inventory/inventoryLevel/mapper/xml/InventoryLevelAlarmMapper.xml b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/inventory/inventoryLevel/mapper/xml/InventoryLevelAlarmMapper.xml
index 4e5ea2f..0d7e36a 100644
--- a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/inventory/inventoryLevel/mapper/xml/InventoryLevelAlarmMapper.xml
+++ b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/inventory/inventoryLevel/mapper/xml/InventoryLevelAlarmMapper.xml
@@ -4,31 +4,27 @@
 
     <select id="queryLevelAlarm"
             resultType="org.jeecg.modules.wms.inventory.inventoryLevel.entity.InventoryLevelAlarm">
-        select t.* from (
-            SELECT w.*, sum(qty) as qtySum FROM inventory_detail i inner join material_warning w
-            on i.material_code = w.material_code
-            WHERE i.inventory_status='good' and i.material_code IN ( SELECT material_code FROM material_warning
-                <where>
-                    <if test="materialCode != null and materialCode != ''">
-                        and material_code = #{materialCode}
-                    </if>
-                    <if test="materialName != null and materialName != ''">
-                        <bind name="materialNameLike" value="'%'+materialName+'%'"/>
-                        and material_name like #{materialNameLike}
-                    </if>
-                </where>
-             )
-            group by material_code
-        ) t
+        select w.*, i.qtySum from (
+        SELECT material_code, sum(qty) as qtySum FROM inventory_detail
+        WHERE inventory_status='good' and material_code IN ( SELECT material_code FROM material_warning)
+        group by material_code
+        ) i right join material_warning w on i.material_code = w.material_code
         <where>
+            <if test="materialCode != null and materialCode != ''">
+                and w.material_code = #{materialCode}
+            </if>
+            <if test="materialName != null and materialName != ''">
+                <bind name="materialNameLike" value="'%'+materialName+'%'"/>
+                and w.material_name like #{materialNameLike}
+            </if>
             <if test="alarmStatus != null and alarmStatus == 'noAlarm'">
                 and qtySum between lower and upper
             </if>
             <if test="alarmStatus != null and alarmStatus == 'isAlarm'">
-                and qtySum &lt;= lower or qtySum &gt;= upper
+                and (qtySum &lt;= lower or qtySum &gt;= upper or qtySum is null)
             </if>
             <if test="alarmStatus != null and alarmStatus == 'lowerAlarm'">
-                and qtySum &lt;= lower
+                and (qtySum &lt;= lower or qtySum is null)
             </if>
             <if test="alarmStatus != null and alarmStatus == 'upperAlarm'">
                 and qtySum &gt;= upper
diff --git a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/monitor/job/InventoryLevelAlarmTask.java b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/monitor/job/InventoryLevelAlarmTask.java
index 0dd8c5a..f6bb7b5 100644
--- a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/monitor/job/InventoryLevelAlarmTask.java
+++ b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/monitor/job/InventoryLevelAlarmTask.java
@@ -65,8 +65,8 @@ public class InventoryLevelAlarmTask implements Job {
 
         List<String> list = alarmList.stream().map(InventoryLevelAlarm::toString).collect(Collectors.toList());
         String msg = String.join("\n", list);
-        msg = msg + "<a href='/wms/#/system/inventory/inventoryLevel'>库存水位详情</a>&nbsp;&nbsp;&nbsp;&nbsp;" +
-                "<a href='/wms/#/system/config/MaterialWarningList'>预警配置</a>";
+        msg = msg + "<a href='/wms/index.html#/system/inventory/inventoryLevel'>库存水位详情</a>";
+//                "&nbsp;&nbsp;&nbsp;&nbsp;<a href='/wms/index.html#/system/config/MaterialWarningList'>预警配置</a>";
 
         List<SysUser> userList;
         try {
--
libgit2 0.22.2