From 15a71ada8f34d31285400e9502182c62d2996708 Mon Sep 17 00:00:00 2001
From: gongchunyi <deslre0381@gmail.com>
Date: 星期三, 14 一月 2026 15:22:25 +0800
Subject: [PATCH] fix: 取消直接连表,物料属性单查字典项过滤后当参数传递

---
 inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsProductDeviationWarningServiceImpl.java |   29 +++++++++++---
 inspect-server/src/main/resources/mapper/InsProductDeviationWarningMapper.xml                          |   24 +++++++----
 inspect-server/src/main/java/com/ruoyi/inspect/mapper/InsProductDeviationWarningMapper.java            |    7 ++-
 ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysDictDataMapper.java                              |   28 +++++++-------
 4 files changed, 57 insertions(+), 31 deletions(-)

diff --git a/inspect-server/src/main/java/com/ruoyi/inspect/mapper/InsProductDeviationWarningMapper.java b/inspect-server/src/main/java/com/ruoyi/inspect/mapper/InsProductDeviationWarningMapper.java
index ad8eed7..62fa5b9 100644
--- a/inspect-server/src/main/java/com/ruoyi/inspect/mapper/InsProductDeviationWarningMapper.java
+++ b/inspect-server/src/main/java/com/ruoyi/inspect/mapper/InsProductDeviationWarningMapper.java
@@ -8,20 +8,23 @@
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.apache.ibatis.annotations.Param;
 
+import java.util.List;
+
 /**
  * <p>
  * 妫�楠岄」鍋忓樊棰勮涓昏〃 Mapper 鎺ュ彛
  * </p>
  *
- * @author 
+ * @author
  * @since 2025-03-28 02:18:02
  */
 public interface InsProductDeviationWarningMapper extends BaseMapper<InsProductDeviationWarning> {
 
     /**
      * 鏌ョ湅棰勮鍒楄〃
+     *
      * @param page
      * @return
      */
-    IPage<InsProductDeviationWarningDto> selectDeviationWarningPage(@Param("page") Page page, @Param("ew") QueryWrapper<InsProductDeviationWarningDto> ew);
+    IPage<InsProductDeviationWarningDto> selectDeviationWarningPage(@Param("page") Page page, @Param("ew") QueryWrapper<InsProductDeviationWarningDto> ew, @Param("dictValues") List<String> dictValues);
 }
diff --git a/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsProductDeviationWarningServiceImpl.java b/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsProductDeviationWarningServiceImpl.java
index 89f9ab8..2e10d16 100644
--- a/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsProductDeviationWarningServiceImpl.java
+++ b/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsProductDeviationWarningServiceImpl.java
@@ -1,14 +1,23 @@
 package com.ruoyi.inspect.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.ruoyi.common.utils.QueryWrappers;
-import com.ruoyi.inspect.dto.InsProductDeviationWarningDto;
-import com.ruoyi.inspect.pojo.InsProductDeviationWarning;
-import com.ruoyi.inspect.mapper.InsProductDeviationWarningMapper;
-import com.ruoyi.inspect.service.InsProductDeviationWarningService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ruoyi.common.core.domain.entity.SysDictData;
+import com.ruoyi.common.utils.QueryWrappers;
+import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.inspect.dto.InsProductDeviationWarningDto;
+import com.ruoyi.inspect.mapper.InsProductDeviationWarningMapper;
+import com.ruoyi.inspect.pojo.InsProductDeviationWarning;
+import com.ruoyi.inspect.service.InsProductDeviationWarningService;
+import com.ruoyi.system.mapper.SysDictDataMapper;
+import com.ruoyi.system.service.ISysDictDataService;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+
+import java.util.*;
+import java.util.stream.Collectors;
 
 /**
  * <p>
@@ -21,14 +30,22 @@
 @Service
 public class InsProductDeviationWarningServiceImpl extends ServiceImpl<InsProductDeviationWarningMapper, InsProductDeviationWarning> implements InsProductDeviationWarningService {
 
+    @Autowired
+    private SysDictDataMapper sysDictDataMapper;
+
     /**
      * 鏌ョ湅棰勮鍒楄〃
+     *
      * @param page
      * @param deviationWarningDto
      * @return
      */
     @Override
     public IPage<InsProductDeviationWarningDto> selectDeviationWarningPage(Page page, InsProductDeviationWarningDto deviationWarningDto) {
-        return baseMapper.selectDeviationWarningPage(page, QueryWrappers.queryWrappers(deviationWarningDto));
+        List<SysDictData> sysDictDataList = sysDictDataMapper.selectDictDataByType("material_prop_type");
+        List<String> list = Arrays.asList("03Package", "04Dlan");
+        List<String> dictValues = sysDictDataList.stream().map(SysDictData::getDictValue).filter(dictValue -> !list.contains(dictValue)).collect(Collectors.toList());
+
+        return baseMapper.selectDeviationWarningPage(page, QueryWrappers.queryWrappers(deviationWarningDto), dictValues);
     }
 }
diff --git a/inspect-server/src/main/resources/mapper/InsProductDeviationWarningMapper.xml b/inspect-server/src/main/resources/mapper/InsProductDeviationWarningMapper.xml
index 42ac779..e83094e 100644
--- a/inspect-server/src/main/resources/mapper/InsProductDeviationWarningMapper.xml
+++ b/inspect-server/src/main/resources/mapper/InsProductDeviationWarningMapper.xml
@@ -31,21 +31,27 @@
         LEFT JOIN ins_product ip ON ip.id = ipdw.ins_product_id
         LEFT JOIN structure_item_parameter sip ON sip.id = ip.structure_item_parameter_id
         LEFT JOIN ins_order io ON io.id = isa.ins_order_id
-        LEFT JOIN structure_test_object sto ON sip.sample LIKE CONCAT('%"', sto.specimen_name, '"%')
+        LEFT JOIN structure_test_object sto
+        ON sip.sample LIKE CONCAT('%"', sto.specimen_name, '"%')
         LEFT JOIN ifs_inventory_quantity ifs ON ifs.id = io.ifs_inventory_id
-        LEFT JOIN sys_dict_data dict
-        ON dict.dict_type = 'material_prop_type'
-        AND dict.dict_value = ifs.material_prop
-        AND dict.dict_value NOT IN ('04Dlan', '03Package')
-        WHERE
-        sto.object_type != 3 -- 杩囨护鏉′欢锛氭帓闄� object_type 涓� 3 鐨勮褰�
+        WHERE sto.object_type != 3
+        <if test="dictValues != null and dictValues.size() > 0">
+            AND ifs.material_prop IN
+            <foreach collection="dictValues" item="value" open="(" separator="," close=")">
+                #{value}
+            </foreach>
+        </if>
+        <if test="dictValues == null or dictValues.size() == 0">
+            AND 1 = 0
+        </if>
+        <if test="ew.sqlFirst != null">
+            ${ew.sqlFirst}
+        </if>
         <if test="ew.customSqlSegment != null and ew.customSqlSegment != ''">
             AND ${ew.customSqlSegment}
         </if>
-        AND (ifs.material_prop IS NULL OR dict.dict_value IS NOT NULL)
         ) t
         ORDER BY t.detection_time DESC
-
     </select>
 
 </mapper>
diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysDictDataMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysDictDataMapper.java
index a341f1e..3b67fc0 100644
--- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysDictDataMapper.java
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysDictDataMapper.java
@@ -1,19 +1,19 @@
 package com.ruoyi.system.mapper;
 
 import java.util.List;
+
 import org.apache.ibatis.annotations.Param;
 import com.ruoyi.common.core.domain.entity.SysDictData;
 
 /**
  * 瀛楀吀琛� 鏁版嵁灞�
- * 
+ *
  * @author ruoyi
  */
-public interface SysDictDataMapper
-{
+public interface SysDictDataMapper {
     /**
      * 鏍规嵁鏉′欢鍒嗛〉鏌ヨ瀛楀吀鏁版嵁
-     * 
+     *
      * @param dictData 瀛楀吀鏁版嵁淇℃伅
      * @return 瀛楀吀鏁版嵁闆嗗悎淇℃伅
      */
@@ -21,7 +21,7 @@
 
     /**
      * 鏍规嵁瀛楀吀绫诲瀷鏌ヨ瀛楀吀鏁版嵁
-     * 
+     *
      * @param dictType 瀛楀吀绫诲瀷
      * @return 瀛楀吀鏁版嵁闆嗗悎淇℃伅
      */
@@ -29,8 +29,8 @@
 
     /**
      * 鏍规嵁瀛楀吀绫诲瀷鍜屽瓧鍏搁敭鍊兼煡璇㈠瓧鍏告暟鎹俊鎭�
-     * 
-     * @param dictType 瀛楀吀绫诲瀷
+     *
+     * @param dictType  瀛楀吀绫诲瀷
      * @param dictValue 瀛楀吀閿��
      * @return 瀛楀吀鏍囩
      */
@@ -38,7 +38,7 @@
 
     /**
      * 鏍规嵁瀛楀吀鏁版嵁ID鏌ヨ淇℃伅
-     * 
+     *
      * @param dictCode 瀛楀吀鏁版嵁ID
      * @return 瀛楀吀鏁版嵁
      */
@@ -46,7 +46,7 @@
 
     /**
      * 鏌ヨ瀛楀吀鏁版嵁
-     * 
+     *
      * @param dictType 瀛楀吀绫诲瀷
      * @return 瀛楀吀鏁版嵁
      */
@@ -54,7 +54,7 @@
 
     /**
      * 閫氳繃瀛楀吀ID鍒犻櫎瀛楀吀鏁版嵁淇℃伅
-     * 
+     *
      * @param dictCode 瀛楀吀鏁版嵁ID
      * @return 缁撴灉
      */
@@ -62,7 +62,7 @@
 
     /**
      * 鎵归噺鍒犻櫎瀛楀吀鏁版嵁淇℃伅
-     * 
+     *
      * @param dictCodes 闇�瑕佸垹闄ょ殑瀛楀吀鏁版嵁ID
      * @return 缁撴灉
      */
@@ -70,7 +70,7 @@
 
     /**
      * 鏂板瀛楀吀鏁版嵁淇℃伅
-     * 
+     *
      * @param dictData 瀛楀吀鏁版嵁淇℃伅
      * @return 缁撴灉
      */
@@ -78,7 +78,7 @@
 
     /**
      * 淇敼瀛楀吀鏁版嵁淇℃伅
-     * 
+     *
      * @param dictData 瀛楀吀鏁版嵁淇℃伅
      * @return 缁撴灉
      */
@@ -86,7 +86,7 @@
 
     /**
      * 鍚屾淇敼瀛楀吀绫诲瀷
-     * 
+     *
      * @param oldDictType 鏃у瓧鍏哥被鍨�
      * @param newDictType 鏂版棫瀛楀吀绫诲瀷
      * @return 缁撴灉

--
Gitblit v1.9.3