Browse Source

2024/1/4 小程序实验室查询过滤

chaiyunlong 2 years ago
parent
commit
548c37b401

+ 8 - 0
zd-api/zd-laboratory-api/src/main/java/com/zd/laboratory/api/feign/RemoteSubQueryService.java

@@ -38,6 +38,14 @@ public interface RemoteSubQueryService {
     @PostMapping("/subject/manger/V2/list")
     R<Object> querySubCListVO(@RequestBody Map<String,Object> appSubQuery);
 
+
+    /**
+     * 查询实验室控制数据列表- 数据权限(包括负责人)
+     */
+    @ApiOperation("查询实验室控制数据列表- 数据权限(包括负责人)")
+    @PostMapping("/subject/manger/V2/applist")
+    R<Object> querySubAppListVO(@RequestBody Map<String,Object> appSubQuery);
+
     /**
      * 查询实验室控制数据列表- 数据权限(包括负责人)
      */

+ 5 - 0
zd-api/zd-laboratory-api/src/main/java/com/zd/laboratory/api/feign/fallback/RemoteSubQueryFallbackFactory.java

@@ -40,6 +40,11 @@ public class RemoteSubQueryFallbackFactory implements FallbackFactory<RemoteSubQ
                 return R.fail("查询实验室数据列表失败:" + cause.getMessage());
             }
 
+            @Override
+            public R <Object> querySubAppListVO(Map <String, Object> appSubQuery) {
+                return R.fail("查询实验室数据列表失败:" + cause.getMessage());
+            }
+
             /**
              * 查询管理实验室和预案执行数量
              */

+ 1 - 1
zd-modules/zd-base/src/main/java/com/zd/base/app/controller/LaboratoryApi.java

@@ -71,7 +71,7 @@ public class LaboratoryApi {
             }
         }catch (Exception e){}
 
-        return remoteSubQueryService.querySubCListVO(map);
+        return remoteSubQueryService.querySubAppListVO(map);
     }
 
 

+ 15 - 0
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/controller/LabSubMangerV2Controller.java

@@ -64,6 +64,21 @@ public class LabSubMangerV2Controller extends BaseController {
         return ResultData.success(subDiyVOList);
     }
 
+    /**
+     * 查询实验室控制数据列表- 数据权限(包括负责人) 小程序我的实验室
+     */
+    @ApiOperation("查询实验室控制数据列表- 数据权限(包括负责人)")
+    @PostMapping("/applist")
+    public ResultData<List<SubDiyVO>> querySubAppListVO(@RequestBody LabSubListQuery labSubListQuery) {
+        LabSubject subject = new LabSubject();
+        BeanUtils.copyProperties(labSubListQuery, subject);
+        if (labSubListQuery.getLevel() != null) {
+            subject.setLevel(Long.parseLong(labSubListQuery.getLevel() + ""));
+        }
+        List<SubDiyVO> subDiyVOList = subQueryManager.queryAppSubs(subject, SubQueryConfig.subQueryConfigList);
+        return ResultData.success(subDiyVOList);
+    }
+
     @PostMapping("/list/ids")
     public ResultData<List<LabSubject>> listByIds(@RequestBody List<Long> ids) {
         List<LabSubject> list = subjectService.getByIds(ids);

+ 14 - 0
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/domain/LabSubject.java

@@ -257,6 +257,12 @@ public class LabSubject extends BaseEntity implements QCInterface {
     private List<Long> deptIds;
 
     /**
+     * 登录人id
+     */
+    @ApiModelProperty("登录人id")
+    private Long loginUserId;
+
+    /**
      * type = 5 实验室信息和安全检查二维码
      *
      * @param code = 实验室id + - + 实验室房间号
@@ -649,4 +655,12 @@ public class LabSubject extends BaseEntity implements QCInterface {
     public void setHardwareType(Integer hardwareType) {
         this.hardwareType = hardwareType;
     }
+
+    public Long getLoginUserId() {
+        return loginUserId;
+    }
+
+    public void setLoginUserId(Long loginUserId) {
+        this.loginUserId = loginUserId;
+    }
 }

+ 8 - 0
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/mapper/LabSubjectMapper.java

@@ -100,6 +100,14 @@ public interface LabSubjectMapper {
      * @param labSubject 实验室
      * @return 实验室集合
      */
+    public List<LabSubjectVO> selectLabAppSubjectVOList(LabSubject labSubject);
+
+    /**
+     * 查询实验室列表VO-数据权限
+     *
+     * @param labSubject 实验室
+     * @return 实验室集合
+     */
     public List<LabSubjectVO> selectLabSubjectVOListByPc(LabSubject labSubject);
 
     /**

+ 39 - 0
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/service/impl/SubQueryManager.java

@@ -5,6 +5,7 @@ import cn.hutool.core.date.StopWatch;
 import cn.hutool.core.util.StrUtil;
 import com.zd.common.core.exception.ServiceException;
 import com.zd.common.core.redis.RedisService;
+import com.zd.common.core.security.TokenService;
 import com.zd.common.core.utils.DictUtils;
 import com.zd.laboratory.api.entity.SubAddrr;
 import com.zd.laboratory.api.vo.LabSubClassVO;
@@ -52,6 +53,9 @@ public class SubQueryManager {
     @Autowired
     private LabHazardSubjectRelationMapper labHazardSubjectRelationMapper;
 
+    @Autowired
+    private TokenService tokenService;
+
 
     /**
      * 查询实验室:根据配置条件 通过实验室ID查询
@@ -119,6 +123,41 @@ public class SubQueryManager {
     }
 
     /**
+     * 这种方式一般应用与数据权限
+     * @param labSubject
+     * @param subQueryConfig
+     * @return
+     */
+    public  List<SubDiyVO> queryAppSubs(LabSubject labSubject, SubQueryConfig subQueryConfig) {
+        List<LabSubjectVO> labSubjectVOS = null;
+        //数据和业务权限
+        if(SubQueryConfig.mode.data_business.equals(subQueryConfig.getQueryMode()))
+        {
+            labSubject.setLoginUserId(tokenService.getLoginUser().getUserid());
+            labSubjectVOS = labSubjectService.selectLabSubjectListAUTH(labSubject);
+        }
+        else if(SubQueryConfig.mode.data.equals(subQueryConfig.getQueryMode()))
+        {
+            labSubject.setLoginUserId(tokenService.getLoginUser().getUserid());
+            labSubjectVOS = labSubjectService.selectLabSubjectListDataScope(labSubject);
+        }
+        else if(SubQueryConfig.mode.business.equals(subQueryConfig.getQueryMode()))
+        {
+            //没有需求需要实现。。。
+            throw new ServiceException("查询参数错误!!!");
+        }else if(SubQueryConfig.mode.none.equals(subQueryConfig.getQueryMode()))
+        {
+            labSubject.setLoginUserId(tokenService.getLoginUser().getUserid());
+            labSubjectVOS = subjectMapper.selectLabAppSubjectVOList(labSubject);
+        }else
+        {
+            throw new ServiceException("查询参数错误!!!");
+        }
+        return querySubs(subQueryConfig,labSubjectVOS);
+
+    }
+
+    /**
      * 根据配置查询实验室额外信息
      * @param subQueryConfig 配置
      * @param labSubjects 实验室基础数据

+ 93 - 0
zd-modules/zd-modules-laboratory/src/main/resources/mapper/laboratory/LabSubjectMapper.xml

@@ -394,6 +394,9 @@
                 and (t.name like concat('%', #{searchValue}, '%')
                 or t.room like concat('%', #{searchValue}, '%'))
             </if>
+            <if test="loginUserId != null ">
+                (t.`admin_id` = #{loginUserId} or find_in_set(#{loginUserId},t.`safe_user_id`))
+            </if>
             <if test="name != null  and name != ''">and t.name like concat('%', #{name}, '%')</if>
             <if test="adminName != null  and adminName != ''">and su.nick_name like concat('%', #{adminName}, '%')</if>
 
@@ -419,6 +422,96 @@
         order by t.diy_order desc , t.create_time desc
     </select>
 
+    <select id="selectLabAppSubjectVOList" parameterType="com.zd.laboratory.domain.LabSubject"
+            resultMap="LabSubjectResultVO">
+        select t.id,
+        t.name,
+        bfl.floor_id,
+        t.room,
+        t.dept_id,
+        IFNULL(su.user_id, -1)                                                     admin_id,
+        t.is_del,
+        t.create_time,
+        t.user_id,
+        t.create_by,
+        t.update_time,
+        t.update_by,
+        t.sub_dept,
+        bfl.id                                                                     layout_id,
+        t.build_id,
+        t.remark,
+        t.level,
+        t.diy_order,
+        cf.classified_name                                                         levelName,
+        cf.classified_color                                                        fiedColor,
+        t.type_id,
+        (SELECT ct.type_name FROM lab_safe_classtype ct WHERE ct.id = t.`type_id`) typeName,
+        t.mold_id,
+        (select lm.mold_name from lab_mold lm where t.mold_id = lm.id) as          moldName,
+        t.check_out,
+        t.check_in,
+        t.safe_user_id,
+        t.safe_signs,
+        t.hazard_category,
+        t.risk_measure,
+        t.outfire,
+        t.qr_code,
+        su.nick_name                                                   as          admin_name,
+        su.phonenumber                                                 as          adminPhone,
+        sd.dept_name                                                   as          dept_name,
+        t.skipped,
+        t.check_count,
+        t.sign_time,
+        t.inspect_check_in,
+        t.inspect_skipped,
+        t.inspect_check_count,
+        t.inspect_sign_time,
+        t.hardware_type,
+        (select i.id from xxp_card_info i where i.subJect_id=t.id LIMIT 1)         xxpCardInfoId,
+        CONCAT(su.nick_name, '@', su.phonenumber)                      AS          adminNameAndPhone,
+
+        (select b.name from lab_build_floor b where b.id = t.build_id)          buildName,
+        (select b.name from lab_build_floor b where b.id = t.floor_id)                floorName,
+        (SELECT l.room_num FROM lab_build_floor_layout l WHERE l.sub_id = t.id)         roomName
+
+        from lab_subject t
+        left join sys_user su on su.user_id = t.admin_id AND su.`del_flag` = 0
+        left join sys_dept sd on sd.dept_id = t.dept_id
+        left join lab_safe_classified cf on cf.id = t.level
+        LEFT JOIN lab_build_floor_layout bfl ON t.`id` = bfl.`sub_id`
+        <where>
+            <if test="searchValue != null ">
+                and (t.name like concat('%', #{searchValue}, '%')
+                or t.room like concat('%', #{searchValue}, '%'))
+            </if>
+            <if test="loginUserId != null ">
+                (t.`admin_id` = #{loginUserId} or find_in_set(#{loginUserId},t.`safe_user_id`))
+            </if>
+            <if test="name != null  and name != ''">and t.name like concat('%', #{name}, '%')</if>
+            <if test="adminName != null  and adminName != ''">and su.nick_name like concat('%', #{adminName}, '%')</if>
+
+            <if test="buildId != null ">and t.build_id = #{buildId}</if>
+            <if test="deptId != null ">and t.dept_id = #{deptId}</if>
+            <if test="id != null ">and t.id = #{id}</if>
+            <if test="subIds != null and subIds != ''">and find_in_set(t.id, #{subIds})</if>
+
+            <if test="adminId != null ">and t.admin_id = #{adminId}</if>
+            <if test="level != null ">and t.level = #{level}</if>
+            <if test="typeId != null ">and t.type_id = #{typeId}</if>
+            <if test="subDept != null and subDept != ''">and t.sub_dept = #{subDept}</if>
+            <if test="ids!=null and ids.size()>0">
+                and t.id in
+                <foreach item="id" collection="ids" open="(" separator="," close=")">
+                    #{id}
+                </foreach>
+            </if>
+
+            <!-- 数据范围过滤 -->
+            ${params.dataScope}
+        </where>
+        order by t.diy_order desc , t.create_time desc
+    </select>
+
     <select id="selectLabSubjectVOListByPc" parameterType="com.zd.laboratory.domain.LabSubject"
             resultType="com.zd.laboratory.domain.vo.LabSubjectVO">
         select t.id,