From e7211274dde4b671afe98394f5ec14148b7b48eb Mon Sep 17 00:00:00 2001
From: chenrui <1187576398@qq.com>
Date: 星期一, 07 四月 2025 15:11:55 +0800
Subject: [PATCH] 成品下单检验项目人员分配

---
 ruoyi-system/src/main/java/com/ruoyi/system/service/impl/UserServiceImpl.java        |    3 ++-
 inspect-server/src/main/java/com/ruoyi/inspect/mapper/InsProductMapper.java          |    9 +++++++++
 ruoyi-system/src/main/resources/mapper/system/UserMapper.xml                         |    6 ++----
 inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderServiceImpl.java |   13 +++++++++++--
 inspect-server/src/main/java/com/ruoyi/inspect/pojo/InsProduct.java                  |    3 +++
 inspect-server/src/main/resources/mapper/InsProductMapper.xml                        |    8 ++++++++
 6 files changed, 35 insertions(+), 7 deletions(-)

diff --git a/inspect-server/src/main/java/com/ruoyi/inspect/mapper/InsProductMapper.java b/inspect-server/src/main/java/com/ruoyi/inspect/mapper/InsProductMapper.java
index 66334f8..eec4fa9 100644
--- a/inspect-server/src/main/java/com/ruoyi/inspect/mapper/InsProductMapper.java
+++ b/inspect-server/src/main/java/com/ruoyi/inspect/mapper/InsProductMapper.java
@@ -67,6 +67,15 @@
      * @return
      */
     List<InsProduct> selectProductByOrderId(Integer orderId);
+
+    /**
+     * 鎵归噺淇敼妫�楠岄」鐩楠屼汉鍛業D
+     * 
+     * @param insProductIds
+     * @param userId
+     * @return
+     */
+    int batchUpdateInsProductCheckUserId(@Param("insProductIds") List <Integer> insProductIds, @Param("checkUserId") Integer userId);
 }
 
 
diff --git a/inspect-server/src/main/java/com/ruoyi/inspect/pojo/InsProduct.java b/inspect-server/src/main/java/com/ruoyi/inspect/pojo/InsProduct.java
index ba9cb6a..bda04df 100644
--- a/inspect-server/src/main/java/com/ruoyi/inspect/pojo/InsProduct.java
+++ b/inspect-server/src/main/java/com/ruoyi/inspect/pojo/InsProduct.java
@@ -211,4 +211,7 @@
     @ApiModelProperty(value = "鑷叧鑱�(缁戝畾id)")
     private Integer bindingProductId;
 
+    @ApiModelProperty(value = "妫�楠屼汉鍛業D")
+    private Integer checkUserId;
+
 }
diff --git a/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderServiceImpl.java b/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderServiceImpl.java
index aed6e35..7b2c20d 100644
--- a/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderServiceImpl.java
+++ b/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderServiceImpl.java
@@ -12,6 +12,7 @@
 import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
@@ -43,6 +44,7 @@
 import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.CollectionUtils;
 
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
@@ -120,7 +122,6 @@
                 .in(InsProduct::getInsSampleId, ids)
                 .eq(InsProduct::getState, 1)
                 .select(InsProduct::getSonLaboratory).groupBy(InsProduct::getSonLaboratory));
-
         // 鎵归噺娣诲姞妫�楠屼换鍔$姸鎬佽〃
         List<InsOrderState> insOrderStateList = insProducts.stream().map(insProduct -> {
             InsOrderState insOrderState = new InsOrderState();
@@ -188,6 +189,14 @@
 
             return auxiliaryOutputWorkingHours;
         }).collect(Collectors.toList());
+
+        // 鍒濇鍒嗛厤妫�楠屼汉锛屽悇涓楠岄」榛樿璁㈠崟鐨勬楠屼汉
+        List<Integer> insProductIds  = insProductList.stream().map(insproduct -> {
+            return insproduct.getId();
+        }).collect(Collectors.toList());
+        if(!CollectionUtils.isEmpty(insProductIds)){
+            insProductMapper.batchUpdateInsProductCheckUserId(insProductIds, userId);
+        }
         auxiliaryOutputWorkingHoursTemporaryService.saveBatch(outputWorkingHours);
 
         return 1;
@@ -491,7 +500,7 @@
             }
             // 鐢熸垚缂栧彿
             String no = numberGenerator.generateNumberWithPrefix(3,
-                    "JCZX/ZB-" + code + LimsDateUtil.resetDate(LocalDateTime.now()),
+                    "JCZX/SP-" + code + LimsDateUtil.resetDate(LocalDateTime.now()),
                     InsOrder::getEntrustCode);
             // 鍒ゆ柇鏄惁鏄搴︽楠�, 鏄搴︽楠屽彇娑堝師鏉愭枡瀛e害妫�楠屼笅鍗�
             if (InsOrderTypeConstants.QUARTERLY_TEST.equals(order.getOrderType())) {
diff --git a/inspect-server/src/main/resources/mapper/InsProductMapper.xml b/inspect-server/src/main/resources/mapper/InsProductMapper.xml
index 908cc0e..b2e6807 100644
--- a/inspect-server/src/main/resources/mapper/InsProductMapper.xml
+++ b/inspect-server/src/main/resources/mapper/InsProductMapper.xml
@@ -149,4 +149,12 @@
                  left join ins_sample is2 on is2.id = ip.ins_sample_id
         where is2.ins_order_id = #{orderId}
     </select>
+
+    <update id="batchUpdateInsProductCheckUserId">
+        UPDATE ins_product SET check_user_id = #{checkUserId}
+        WHERE ID IN
+        <foreach collection="insProductIds" open="(" close=")" item="item" separator=",">
+            #{item}
+        </foreach>
+    </update>
 </mapper>
diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/UserServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/UserServiceImpl.java
index 71fe3b3..bd66fa2 100644
--- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/UserServiceImpl.java
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/UserServiceImpl.java
@@ -38,7 +38,8 @@
 
             switch (type) {
                 case "1":
-                    return baseMapper.selectQualityUserList();
+                    List<User> userList = baseMapper.selectQualityUserList();
+                    return userList;
                 case "2":
                     return baseMapper.selectDepartmentLimsUserList(SecurityUtils.getUserId().intValue());
             }
diff --git a/ruoyi-system/src/main/resources/mapper/system/UserMapper.xml b/ruoyi-system/src/main/resources/mapper/system/UserMapper.xml
index 59a87d0..a75855c 100644
--- a/ruoyi-system/src/main/resources/mapper/system/UserMapper.xml
+++ b/ruoyi-system/src/main/resources/mapper/system/UserMapper.xml
@@ -77,10 +77,8 @@
                u1.name_en,
                u1.depart_lims_id
         from user u1
-                 left join sys_user_role sur on sur.user_id = u1.id
-        where sur.role_id not in (1, 15, 16, 17)
-          and u1.status = '0'
-        group by u1.id
+        WHERE u1.id IN (SELECT user_id FROM sys_user_role sur where sur.role_id not in (1, 15, 16, 17))
+        and u1.status = '0'
     </select>
 
     <!-- 鑾峰彇褰撳墠鐧诲綍鐢ㄦ埛閮ㄩ棬涓嬬殑鎵�鏈夌敤鎴� -->

--
Gitblit v1.9.3