From be3659167ebc85d3ad4bf0311ed2051c0da0281d Mon Sep 17 00:00:00 2001
From: zss <zss@example.com>
Date: 星期二, 23 七月 2024 10:31:36 +0800
Subject: [PATCH] 班次权限

---
 performance-server/src/main/java/com/yuanchu/mom/mapper/PerformanceShiftMapper.java            |    2 +
 inspect-server/src/main/java/com/yuanchu/mom/mapper/InsSampleMapper.java                       |    2 
 inspect-server/src/main/resources/mapper/InsSampleMapper.xml                                   |   61 +++++++++++++++++++++++++++++-
 system-run/src/main/java/com/yuanchu/mom/backup/MysqlDataBackup.java                           |    2 
 performance-server/src/main/resources/mapper/PerformanceShiftMapper.xml                        |   26 +++++++++---
 inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsOrderPlanServiceImpl.java         |    3 +
 performance-server/src/main/java/com/yuanchu/mom/service/impl/PerformanceShiftServiceImpl.java |   23 +++++++++++
 7 files changed, 107 insertions(+), 12 deletions(-)

diff --git a/inspect-server/src/main/java/com/yuanchu/mom/mapper/InsSampleMapper.java b/inspect-server/src/main/java/com/yuanchu/mom/mapper/InsSampleMapper.java
index d776bbd..011666d 100644
--- a/inspect-server/src/main/java/com/yuanchu/mom/mapper/InsSampleMapper.java
+++ b/inspect-server/src/main/java/com/yuanchu/mom/mapper/InsSampleMapper.java
@@ -27,7 +27,7 @@
 
     IPage<InsOrderPlanVO> findInsSampleAndOrder(Page page, QueryWrapper<InsOrderPlanDTO> ew, Integer userId,String sonLaboratory);
 
-    IPage<InsOrderPlanTaskSwitchVo> inspectionOrderDetailsTaskSwitching(Page page, QueryWrapper<InsOrderPlanDTO> ew, Integer userId);
+    IPage<InsOrderPlanTaskSwitchVo> inspectionOrderDetailsTaskSwitching(Page page, QueryWrapper<InsOrderPlanDTO> ew, Integer userId,String sonLaboratory);
 
     List<SampleProductDto> selectSampleProductListByOrderId(Integer id);
 
diff --git a/inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsOrderPlanServiceImpl.java b/inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsOrderPlanServiceImpl.java
index a4fd33f..9bab7c6 100644
--- a/inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsOrderPlanServiceImpl.java
+++ b/inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsOrderPlanServiceImpl.java
@@ -158,7 +158,8 @@
         if (ObjectUtil.isNotEmpty(insOrderPlanDTO.getUserId())) {
             insOrderPlanDTO.setUserId(userId.longValue());
         }
-        IPage<InsOrderPlanTaskSwitchVo> insOrderPage = insSampleMapper.inspectionOrderDetailsTaskSwitching(page, QueryWrappers.queryWrappers(insOrderPlanDTO), userId);
+        String sonLaboratory = insOrderPlanDTO.getSonLaboratory();//璇曢獙瀹�
+        IPage<InsOrderPlanTaskSwitchVo> insOrderPage = insSampleMapper.inspectionOrderDetailsTaskSwitching(page, QueryWrappers.queryWrappers(insOrderPlanDTO), userId,sonLaboratory);
         map.put("body", insOrderPage);
         return map;
     }
diff --git a/inspect-server/src/main/resources/mapper/InsSampleMapper.xml b/inspect-server/src/main/resources/mapper/InsSampleMapper.xml
index b2f30cf..7d48c25 100644
--- a/inspect-server/src/main/resources/mapper/InsSampleMapper.xml
+++ b/inspect-server/src/main/resources/mapper/InsSampleMapper.xml
@@ -93,8 +93,8 @@
     <select id="inspectionOrderDetailsTaskSwitching" resultType="com.yuanchu.mom.vo.InsOrderPlanTaskSwitchVo">
         select * from(
         SELECT
-        a.*,ios.ins_state,ios.verify_tell,isu2.order_user_id,(ios.verify_user = #{userId}) verify_user
-        FROM
+        a.*,ios.ins_state,ios.verify_tell,isu2.order_user_id,<!--(ios.verify_user = #{userId})--> verify_user
+        <!--FROM
         (
         SELECT
         io.id,
@@ -128,7 +128,64 @@
         a.user_id DESC,
         a.type DESC,
         a.id
+        ) b-->
+        FROM
+        (
+        SELECT
+        io.id,
+        io.entrust_code,
+        io.type,
+        io.appointed,
+        io.send_time,
+        group_concat(distinct isa.sample,' ') sample,
+        isu.user_id,
+        user.name userName,
+        ip.son_laboratory,
+        io.ins_time
+        FROM
+        ins_order io
+        LEFT JOIN ins_sample isa ON isa.ins_order_id = io.id
+        LEFT JOIN ( <!--SELECT * FROM ins_sample_user GROUP BY ins_sample_id, user_id -->
+        SELECT *
+        FROM ins_sample_user u
+        WHERE son_laboratory=#{sonLaboratory} and (ins_sample_id, id) IN (
+        SELECT ins_sample_id, MAX(id)
+        FROM ins_sample_user
+        WHERE son_laboratory=#{sonLaboratory}
+        GROUP BY ins_sample_id
+        )
+        ORDER BY ins_sample_id, id
+        ) isu ON isu.ins_sample_id = io.id
+        LEFT JOIN ins_product ip ON ip.ins_sample_id = isa.id
+        LEFT JOIN user  ON isu.user_id = user.id
+        WHERE
+        io.state = 1
+        # AND io.ins_state != 5
+        and send_time is not null
+        <if test="userId !=null and userId!=''">
+            and (isu.user_id = #{userId} OR isu.user_id is NULL )
+        </if>
+        OR isu.user_id is NULL
+
+        GROUP BY
+        ip.son_laboratory,
+        io.id
+        ) a
+        LEFT JOIN ins_order_state ios ON ios.ins_order_id = a.id AND ios.laboratory = a.son_laboratory
+        left join (SELECT td.user_id order_user_id, td.ins_sample_id FROM ins_sample_user td,(SELECT max(id) id FROM
+        ins_sample_user where son_laboratory=#{sonLaboratory} GROUP BY ins_sample_id) md where td.id = md.id
+        <if test="userId !=null and userId!=''">
+            and user_id = #{userId} OR user_id is NULL
+        </if>
+        OR user_id is NULL
+        ) isu2 on
+        isu2.ins_sample_id = a.id
+        ORDER BY
+        <!--a.user_id DESC,-->
+        a.type DESC,
+        a.id
         ) b
+        where ins_state is not null)A
         <if test="ew.customSqlSegment != null and ew.customSqlSegment != ''">
             ${ew.customSqlSegment}
         </if>
diff --git a/performance-server/src/main/java/com/yuanchu/mom/mapper/PerformanceShiftMapper.java b/performance-server/src/main/java/com/yuanchu/mom/mapper/PerformanceShiftMapper.java
index 39157fe..f7fbfa0 100644
--- a/performance-server/src/main/java/com/yuanchu/mom/mapper/PerformanceShiftMapper.java
+++ b/performance-server/src/main/java/com/yuanchu/mom/mapper/PerformanceShiftMapper.java
@@ -36,4 +36,6 @@
     List<Map<String, Object>> performanceShiftYearList(String time, String userName, String laboratory);
 
     List<PerformanceShiftMapDto> performanceShiftList(String time, String userName, String laboratory);
+
+    String seldepLimsId(int depLimsId);
 }
diff --git a/performance-server/src/main/java/com/yuanchu/mom/service/impl/PerformanceShiftServiceImpl.java b/performance-server/src/main/java/com/yuanchu/mom/service/impl/PerformanceShiftServiceImpl.java
index db37821..91d2ce3 100644
--- a/performance-server/src/main/java/com/yuanchu/mom/service/impl/PerformanceShiftServiceImpl.java
+++ b/performance-server/src/main/java/com/yuanchu/mom/service/impl/PerformanceShiftServiceImpl.java
@@ -6,11 +6,14 @@
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.yuanchu.mom.common.GetLook;
 import com.yuanchu.mom.dto.PerformanceShiftAddDto;
 import com.yuanchu.mom.dto.PerformanceShiftMapDto;
 import com.yuanchu.mom.mapper.PerformanceShiftMapper;
+import com.yuanchu.mom.mapper.UserMapper;
 import com.yuanchu.mom.pojo.Enums;
 import com.yuanchu.mom.pojo.PerformanceShift;
+import com.yuanchu.mom.pojo.User;
 import com.yuanchu.mom.service.EnumService;
 import com.yuanchu.mom.service.PerformanceShiftService;
 import com.yuanchu.mom.utils.JackSonUtil;
@@ -41,6 +44,12 @@
 
     @Autowired
     private EnumService enumService;
+
+    @Autowired
+    GetLook getLook;
+
+    @Autowired
+    UserMapper userMapper;
 
     @Transactional(rollbackFor = Exception.class)
     @Override
@@ -94,6 +103,20 @@
 
     @Override
     public Map<String, Object> performanceShiftPage(Page<Object> page, String time, String userName, String laboratory) {
+        //鏌ヨ褰撳墠鐧诲綍浜哄憳鐨勬灦鏋�
+        Integer userId = getLook.selectPowerByMethodAndUserId(null).get("userId");
+        //鍒ゆ柇鍏ㄩ儴,涓汉,缁勭粐鐨勬潈闄�
+        User user = userMapper.selectById(userId);//褰撳墠鐧诲綍鐨勪汉
+        //鑾峰彇褰撳墠浜烘墍灞炲疄楠屽id
+        String departLimsId = user.getDepartLimsId();
+        if (com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isNotEmpty(departLimsId) && !departLimsId.equals("")) {
+            String[] split = departLimsId.split(",");
+            //鏌ヨ瀵瑰簲鏋舵瀯鍚嶇О(閫氫俊瀹為獙瀹�,鐢靛姏瀹為獙瀹�,妫�娴嬪姙)
+            String departLims = baseMapper.seldepLimsId(Integer.parseInt(split[split.length - 1]));
+            if (departLims.contains("瀹為獙瀹�")) {
+                laboratory = departLims;
+            }
+        }
         IPage<PerformanceShiftMapDto> mapIPage = baseMapper.performanceShiftPage(page, time, userName, laboratory);
         List<Enums> shiftType = enumService.selectEnumByCategory("鐝绫诲瀷");
         List<Map<String, Object>> mapYearIPage = baseMapper.performanceShiftYearPage(time, userName, laboratory);
diff --git a/performance-server/src/main/resources/mapper/PerformanceShiftMapper.xml b/performance-server/src/main/resources/mapper/PerformanceShiftMapper.xml
index 31d6551..1ada6d1 100644
--- a/performance-server/src/main/resources/mapper/PerformanceShiftMapper.xml
+++ b/performance-server/src/main/resources/mapper/PerformanceShiftMapper.xml
@@ -11,21 +11,27 @@
 
     <select id="performanceShiftPage" resultMap="performanceShiftPageMap">
         SELECT
-        if(u.department is not null and u.department != '', CONCAT(u.name, '锛�', u.department, '锛�'), u.name) name,
-        GROUP_CONCAT(s.work_time, '锛�', s.shift, '锛�', s.id order by s.work_time SEPARATOR ';') AS shift_time, u.id user_id
+        if(u2.department is not null and u2.department != '', CONCAT(u2.name, '锛�', u2.department, '锛�'), u2.name) name,
+        GROUP_CONCAT(s.work_time, '锛�', s.shift, '锛�', s.id order by s.work_time SEPARATOR ';') AS shift_time, u2.id user_id
         FROM performance_shift s
-        LEFT JOIN user u on u.id = s.user_id
+        LEFT JOIN (SELECT u.* from
+        user u
+        left join department_lims dl on FIND_IN_SET(dl.id,u.depart_lims_id)
+        where state=1
+        <if test="laboratory != null and laboratory != ''">
+          and   dl.name=#{laboratory}
+        </if>
+         ) u2    on u2.id = s.user_id
         <where>
+            name is not null
             <if test="time != null and time != ''">
                 and DATE_FORMAT(s.work_time, '%Y-%m') = DATE_FORMAT(#{time}, '%Y-%m' )
             </if>
             <if test="userName != null and userName != ''">
-                and u.name like concat('%', #{userName}, '%')
-            </if>
-            <if test="laboratory != null and laboratory != ''">
+                and u2.name like concat('%', #{userName}, '%')
             </if>
         </where>
-        GROUP BY u.id
+        GROUP BY u2.id
         order by s.create_time
     </select>
 
@@ -108,4 +114,10 @@
         GROUP BY u.id
         order by s.create_time
     </select>
+
+    <select id="seldepLimsId" resultType="java.lang.String">
+        select name
+        from department_lims
+        where id = #{depLimsId}
+    </select>
 </mapper>
diff --git a/system-run/src/main/java/com/yuanchu/mom/backup/MysqlDataBackup.java b/system-run/src/main/java/com/yuanchu/mom/backup/MysqlDataBackup.java
index 2d3b8bd..57d55d0 100644
--- a/system-run/src/main/java/com/yuanchu/mom/backup/MysqlDataBackup.java
+++ b/system-run/src/main/java/com/yuanchu/mom/backup/MysqlDataBackup.java
@@ -203,7 +203,7 @@
      * 瀹氭椂浠诲姟,姣忎釜鏈�1鍙风殑00:00:00
      * 缁欐瘡涓汉閮借繘琛屾帓鐝�(榛樿鏃╃彮)
      */
-    //@Scheduled(cron = "0 0 0 1 *?")
+    @Scheduled(cron = "0 0 0 1 * ?")
     //@Scheduled(cron = "0/20 * * * * ?")
     private void timerCreateSchedule(){
         System.out.println("寮�濮嬬粰姣忎釜浜鸿繘琛屾帓鐝�,榛樿鏃╃彮======start");

--
Gitblit v1.9.3