Quellcode durchsuchen

解决系统管理员新增装置系统看不到的情况

sl vor 9 Monaten
Ursprung
Commit
d76ef12e54

+ 16 - 2
jeecg-module-interlock/src/main/java/org/jeecg/modules/base/mapper/InterlockBaseMapper.java

@@ -2,9 +2,11 @@ package org.jeecg.modules.base.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
 import org.jeecg.common.system.vo.SelectTreeModel;
 import org.jeecg.modules.base.entity.InterlockBase;
 import org.jeecg.modules.base.entity.InterlockBaseLimit;
+import org.jeecg.modules.interlockUser.entity.InterlockUser;
 
 import java.util.List;
 import java.util.Map;
@@ -49,10 +51,22 @@ public interface InterlockBaseMapper extends BaseMapper<InterlockBase> {
 	/**
 	 *   author: sl
 	 *   version: 1.0
-	 *   des: 联锁基础表-普通列表查询 添加用户权限
+	 *   des: 联锁基础表-普通列表查询 添加用户权限  普通用户权限
 	 *   date: 2024/7/30
 	 */
-	List<InterlockBaseLimit> listByUser(@Param("wiseUser") String wiseUser);
+	List<InterlockBaseLimit> listByPtUser(@Param("wiseUser") String wiseUser);
+
+	/**
+	 *   author: sl
+	 *   version: 1.0
+	 *   des: 联锁基础表-普通列表查询 添加用户权限  联锁管理员权限
+	 *   date: 2024/7/30
+	 */
+	List<InterlockBaseLimit> listByAdminUser();
+
+	//循环调用了,所以在此处获取用户是否是管理员
+	@Select("select * from interlock_user where username=#{wiseUser}")
+	InterlockUser getUserInfoByName(@Param("wiseUser") String wiseUser);
 
     List<InterlockBase> getListByPId(@Param("interlockId") String interlockId);
 }

+ 12 - 1
jeecg-module-interlock/src/main/java/org/jeecg/modules/base/mapper/xml/InterlockBaseMapper.xml

@@ -36,7 +36,8 @@
 		select * from interlock_base where interlock_type = '1' and pid = #{id}
 	</select>
 
-	<select id="listByUser" resultType="org.jeecg.modules.base.entity.InterlockBaseLimit">
+	<!--查询装置系统  普通用户权限-->
+	<select id="listByPtUser" resultType="org.jeecg.modules.base.entity.InterlockBaseLimit">
 		select DISTINCT b2.*, '' as limit_type from interlock_base b2
 		left join (select l2.* from interlock_system_limit l2 where l2.interlock_user_id in
 		(select u2.id from interlock_user u2 where u2.username=#{wiseUser})) qxnr2
@@ -50,6 +51,16 @@
 		where qxnr1.limit_type='0' or qxnr1.limit_type='1'
 	</select>
 
+	<!--查询装置系统  系统管理员权限-->
+	<select id="listByAdminUser" resultType="org.jeecg.modules.base.entity.InterlockBaseLimit">
+		select *, '' as limit_type from interlock_base
+		where interlock_type ='0'
+		union
+		select *, '0' as limit_type from interlock_base
+		where interlock_type='1'
+		ORDER BY create_by
+	</select>
+
     <select id="getListByPId" resultType="org.jeecg.modules.base.entity.InterlockBase">
 		select * from interlock_base where pid = #{interlockId}
 	</select>

+ 10 - 2
jeecg-module-interlock/src/main/java/org/jeecg/modules/base/service/impl/InterlockBaseServiceImpl.java

@@ -13,6 +13,8 @@ import org.jeecg.modules.base.mapper.InterlockBaseHyMapper;
 import org.jeecg.modules.base.mapper.InterlockBaseMapper;
 import org.jeecg.modules.base.service.IInterlockBaseHyService;
 import org.jeecg.modules.base.service.IInterlockBaseService;
+import org.jeecg.modules.interlockUser.entity.InterlockUser;
+import org.jeecg.modules.interlockUser.service.IInterlockUserService;
 import org.jeecg.modules.summary.constants.InterlockAllStatus;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -355,8 +357,14 @@ public class InterlockBaseServiceImpl extends ServiceImpl<InterlockBaseMapper, I
                 }
             }
         }
-//        if(wiseUser == null || wiseUser.equals("")) return Result.error("EIToken校验失败,请重新登录");
-        return interlockBaseMapper.listByUser(wiseUser);
+//        wiseUser = "admin";
+        //        if(wiseUser == null || wiseUser.equals("")) return Result.error("EIToken校验失败,请重新登录");
+        InterlockUser interlockUser = interlockBaseMapper.getUserInfoByName(wiseUser);
+        if(interlockUser.getRole().equals("0")){//如果当前用户是系统管理员
+            return interlockBaseMapper.listByAdminUser();
+        }else{
+            return interlockBaseMapper.listByPtUser(wiseUser);
+        }
     }
 
     @Override

+ 4 - 2
jeecg-module-interlock/src/main/java/org/jeecg/modules/detail/mapper/InterlockDetailMapper.java

@@ -42,8 +42,10 @@ public interface InterlockDetailMapper extends BaseMapper<InterlockDetail> {
     @Insert("INSERT INTO time_test_log (type, cost_time) VALUES (#{type}, #{cost_time})")
     void insertIntoTimeTestLog(@Param("type") String type, @Param("cost_time") Long costTime);
 
-    /**联锁总表-分页列表查询(各种逻辑状态) 添加权限*/
-    IPage<InterlockSummaryLimitVO> getPageByUser(Page<InterlockSummaryLimitVO> page, @Param("interlockSummaryLimitVO") InterlockSummaryLimitVO interlockSummaryLimitVO, @Param("wiseUser") String wiseUser);
+    /**联锁总表-分页列表查询(各种逻辑状态) 添加权限 普通用户权限*/
+    IPage<InterlockSummaryLimitVO> getPageByPtUser(Page<InterlockSummaryLimitVO> page, @Param("interlockSummaryLimitVO") InterlockSummaryLimitVO interlockSummaryLimitVO, @Param("wiseUser") String wiseUser);
 
+    /**联锁总表-分页列表查询(各种逻辑状态) 添加权限  系统管理员权限*/
+    IPage<InterlockSummaryLimitVO> getPageByAdminUser(Page<InterlockSummaryLimitVO> page, @Param("interlockSummaryLimitVO") InterlockSummaryLimitVO interlockSummaryLimitVO);
 
 }

+ 32 - 2
jeecg-module-interlock/src/main/java/org/jeecg/modules/detail/mapper/xml/InterlockDetailMapper.xml

@@ -102,8 +102,8 @@
     </select>
 
 
-    <!-- 联锁总表-分页列表查询(各种逻辑状态) 添加权限-->
-    <select id="getPageByUser" resultType="org.jeecg.modules.summary.vo.InterlockSummaryLimitVO">
+    <!-- 联锁总表-分页列表查询(各种逻辑状态) 添加权限   普通用户权限-->
+    <select id="getPageByPtUser" resultType="org.jeecg.modules.summary.vo.InterlockSummaryLimitVO">
         select d.id, d.summaryid, d.interlockname, d.interlock_condition, d.interlock_condition_tag, d.instrument_status, d.control_system_status,
         s.interlock_status, s.loop_health_level, d.bypass, s.interlock_apparatus_id, s.interlock_system_id,
         h1.interlock_status_name , h2.bypass_name ,
@@ -135,4 +135,34 @@
         order by s.create_time desc
     </select>
 
+    <!-- 联锁总表-分页列表查询(各种逻辑状态) 添加权限  系统管理员权限-->
+    <select id="getPageByAdminUser" resultType="org.jeecg.modules.summary.vo.InterlockSummaryLimitVO">
+        select d.id, d.summaryid, d.interlockname, d.interlock_condition, d.interlock_condition_tag, d.instrument_status, d.control_system_status,
+        s.interlock_status, s.loop_health_level, d.bypass, s.interlock_apparatus_id, s.interlock_system_id,
+        h1.interlock_status_name , h2.bypass_name ,
+        h3.instrument_status_name , h4.control_system_status_name,
+        h.instrument_status_normal, h.bypass_yes, h.interlock_status_ty, h.control_system_status_normal,
+        '0' as limit_type, h.interlock_name as interlock_system_name, h5.interlock_name as interlock_apparatus_name
+        from interlock_detail d
+        left join interlock_summary s on d.summaryid = s.id
+        left join interlock_base_hy h1 on h1.interlock_status = s.interlock_status and h1.interlock_system_id = s.interlock_system_id
+        left join interlock_base_hy h2 on h2.bypass = d.bypass and h2.interlock_system_id = s.interlock_system_id
+        left join interlock_base_hy h3 on h3.instrument_status = d.instrument_status and h3.interlock_system_id = s.interlock_system_id
+        left join interlock_base_hy h4 on h4.control_system_status = d.control_system_status and h4.interlock_system_id = s.interlock_system_id
+        left join interlock_base h on h.id = s.interlock_system_id
+        left join interlock_base h5 on h5.id = s.interlock_apparatus_id
+        <where>
+            <if test="interlockSummaryLimitVO.interlockApparatusId != null and interlockSummaryLimitVO.interlockApparatusId != ''"> and s.interlock_apparatus_id = #{interlockSummaryLimitVO.interlockApparatusId}</if>
+            <if test="interlockSummaryLimitVO.interlockSystemId != null and interlockSummaryLimitVO.interlockSystemId != ''"> and s.interlock_system_id = #{interlockSummaryLimitVO.interlockSystemId}</if>
+            <if test="interlockSummaryLimitVO.interlockname != null and interlockSummaryLimitVO.interlockname != ''"> and d.interlockname like concat('%', #{interlockSummaryLimitVO.interlockname}, '%')</if>
+            <if test="interlockSummaryLimitVO.interlockConditionTag != null and interlockSummaryLimitVO.interlockConditionTag != ''"> and d.interlock_condition_tag like concat('%', #{interlockSummaryLimitVO.interlockConditionTag}, '%')</if>
+            <if test="interlockSummaryLimitVO.instrumentStatus != null and interlockSummaryLimitVO.instrumentStatus != ''"> and d.instrument_status = #{interlockSummaryLimitVO.instrumentStatus}</if>
+            <if test="interlockSummaryLimitVO.controlSystemStatus != null and interlockSummaryLimitVO.controlSystemStatus != ''"> and d.control_system_status = #{interlockSummaryLimitVO.controlSystemStatus}</if>
+            <if test="interlockSummaryLimitVO.interlockStatus != null and interlockSummaryLimitVO.interlockStatus != ''"> and s.interlock_status = #{interlockSummaryLimitVO.interlockStatus}</if>
+            <if test="interlockSummaryLimitVO.loopHealthLevel != null and interlockSummaryLimitVO.loopHealthLevel != ''"> and s.loop_health_level = #{interlockSummaryLimitVO.loopHealthLevel}</if>
+            <if test="interlockSummaryLimitVO.bypass != null and interlockSummaryLimitVO.bypass != ''"> and d.bypass = #{interlockSummaryLimitVO.bypass}</if>
+        </where>
+        order by s.create_time desc
+    </select>
+
 </mapper>

+ 13 - 1
jeecg-module-interlock/src/main/java/org/jeecg/modules/detail/service/impl/InterlockDetailServiceImpl.java

@@ -9,6 +9,8 @@ import org.jeecg.modules.detail.entity.InterlockDetail;
 import org.jeecg.modules.detail.mapper.InterlockDetailMapper;
 import org.jeecg.modules.detail.service.IInterlockDetailService;
 import org.jeecg.modules.detail.vo.InterlockDetailQueryVO;
+import org.jeecg.modules.interlockUser.entity.InterlockUser;
+import org.jeecg.modules.interlockUser.service.IInterlockUserService;
 import org.jeecg.modules.summary.vo.InterlockSummaryLimitVO;
 import org.jeecg.modules.summary.vo.InterlockSummaryVO;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -37,6 +39,10 @@ public class InterlockDetailServiceImpl extends ServiceImpl<InterlockDetailMappe
     @SuppressWarnings("all")
     private InterlockBaseMapper interlockBaseMapper;
 
+    @Autowired
+    @SuppressWarnings("all")
+    private IInterlockUserService interlockUserService;
+
     /**联锁详细信息表分页列表查询*/
     public IPage<InterlockDetailQueryVO> getPage2(Page<InterlockDetailQueryVO> page, InterlockDetailQueryDTO dto){
         return interlockDetailMapper.getPage2(page, dto);
@@ -131,7 +137,13 @@ public class InterlockDetailServiceImpl extends ServiceImpl<InterlockDetailMappe
                 }
             }
         }
-        return interlockDetailMapper.getPageByUser(page, interlockSummaryLimitVO, wiseUser);
+//        wiseUser = "admin";
+        InterlockUser interlockUser = interlockUserService.getInterlockUserByUserName(wiseUser);
+        if(interlockUser.getRole().equals("0")){//如果当前用户是系统管理员
+            return interlockDetailMapper.getPageByAdminUser(page, interlockSummaryLimitVO);
+        }else{
+            return interlockDetailMapper.getPageByPtUser(page, interlockSummaryLimitVO, wiseUser);
+        }
     }
 
 }