xiongchao 3 gadi atpakaļ
vecāks
revīzija
436b0b375a

+ 5 - 0
platform-dao/src/main/java/com/platform/dao/dto/sb/SbInfoDTO.java

@@ -213,6 +213,11 @@ public class SbInfoDTO extends BaseDTO implements Serializable {
      * 维修人员
      */
     private String repairUser;
+    /**
+     * 维修人员
+     */
+    @Transient
+    private String repairUserSearch;
     /**
      * 使用公司
      */

+ 13 - 0
platform-dao/src/main/resources/mapper/sb/SbInfoMapper.xml

@@ -266,6 +266,19 @@ user.real_name as saveUserName
         <if test="nextCheckDateEnd != null">
             and sb.next_check_date <![CDATA[ <= ]]> #{nextCheckDateEnd}
         </if>
+        <if test="repairUser != null">
+            and sb.repair_user = #{repairUser}
+        </if>
+        <if test="repairUserSecond != null">
+            and sb.repair_user_second = #{repairUserSecond}
+        </if>
+        <if test="repairUserSearch != null">
+            and (
+            sb.repair_user = #{repairUserSearch}
+            or
+            sb.repair_user_second = #{repairUserSearch}
+            )
+        </if>
         <if test="status != null">
             and sb.status = #{status}
         </if>

+ 13 - 0
platform-rest/src/main/java/com/platform/rest/controller/sb/SbInfoController.java

@@ -211,6 +211,19 @@ public class SbInfoController {
         return new R<>(sbInfoService.selectVOPage(sbInfoDTO, pageNum, pageSize));
     }
 
+    /**
+     * 获取分页根据角色
+     *
+     * @param pageNum   当前页码
+     * @param pageSize  每页条数
+     * @param sbInfoDTO 设备基础信息DTO
+     * @return R
+     */
+    @GetMapping("/page/role")
+    public R<AbstractPageResultBean<SbInfoVO>> queryByRole(SbInfoDTO sbInfoDTO, @RequestParam(defaultValue = "1") int pageNum, @RequestParam(defaultValue = "20") int pageSize) {
+        return new R<>(sbInfoService.selectVOPageByRole(sbInfoDTO, pageNum, pageSize));
+    }
+
     /**
      * 获取大屏数据分页
      *

+ 9 - 0
platform-service/src/main/java/com/platform/service/sb/SbInfoService.java

@@ -93,6 +93,15 @@ public interface SbInfoService extends IBaseService<SbInfo, SbInfoDTO> {
      */
     MyVOPage<SbInfoVO> selectVOPage(SbInfoDTO dto, int pageNum, int pageSize);
 
+    /**
+     * 分页查询
+     *
+     * @param dto      :
+     * @param pageNum  :
+     * @param pageSize :
+     * @return :
+     */
+    MyVOPage<SbInfoVO> selectVOPageByRole(SbInfoDTO dto, int pageNum, int pageSize);
     /**
      * 分页查询
      *

+ 71 - 0
platform-service/src/main/java/com/platform/service/sb/impl/SbInfoServiceImpl.java

@@ -788,6 +788,77 @@ public class SbInfoServiceImpl extends BaseServiceImpl<SbInfoMapper, SbInfo, SbI
         return new MyVOPage<>(sbList);
     }
 
+    /**
+     * 根据登录用户的身份来查询列表
+     * 1:使用人员,看到自己的
+     * 2:维修员,看到自己维修的
+     * 3:维修主管,看到全部的
+     *
+     * @param model
+     * @param pageNum  :
+     * @param pageSize :
+     * @return
+     */
+    @Override
+    public MyVOPage<SbInfoVO> selectVOPageByRole(SbInfoDTO model, int pageNum, int pageSize) {
+
+        UserInfo userInfo = SecurityUtils.getUserInfo();
+        List<String> roleCodes = userInfo.getRoleCodes();
+        int roleType = 1;// 默认使用人员
+        if(roleCodes.contains(SysRoleCodeEnum.MM.name())){
+            roleType = 3;
+        }else if(roleCodes.contains(SysRoleCodeEnum.Maintenance.name())){
+            roleType = 2;
+        }else if(roleCodes.contains(SysRoleCodeEnum.Opreator.name())){
+            roleType = 1;
+        }
+
+        // 选择该用户的设备
+        if (roleType == 1) {
+            model.setSaveUser(userInfo.getUserId());
+        }
+        // 设备的第一维修人员或者第二维修人
+        if (roleType == 2) {
+            model.setRepairUserSearch(userInfo.getUserId());
+        }
+
+        PageHelper.startPage(pageNum, pageSize);
+        List<SbInfoVO> sbList = mapper.selectVOList(model);
+        if(SbInfoChildEnum.IS_PARENT.getValue().equals(model.getIsChild()) && !CollectionUtils.isEmpty(sbList)){
+            for(SbInfoVO vo: sbList){
+                if(SbInfoChildEnum.IS_PARENT.getValue().equals(vo.getIsChild())){
+                    SbInfoDTO infoDTO = new SbInfoDTO();
+                    infoDTO.setParentId(vo.getId());
+                    List<SbInfoVO> childVOList = mapper.selectVOList(infoDTO);
+                    if(!CollectionUtils.isEmpty(childVOList)){
+                        vo.setChildren(childVOList);
+                    }
+                }
+            }
+        }
+
+        List<SysUser> userList = sysUserMapper.selectAll();
+        for(SbInfoVO vo:sbList){
+            if (vo.getRepairUser() != null) {
+                userList.forEach(sysUser -> {
+                    if (sysUser.getUserId().equals(vo.getRepairUser())) {
+                        vo.setRepairUserName(sysUser.getRealName());
+                        return;
+                    }
+                });
+            }
+            if (vo.getRepairUserSecond() != null) {
+                userList.forEach(sysUser -> {
+                    if (sysUser.getUserId().equals(vo.getRepairUserSecond())) {
+                        vo.setRepairUserNameSecond(sysUser.getRealName());
+                        return;
+                    }
+                });
+            }
+        }
+        return new MyVOPage<>(sbList);
+    }
+
     /**
      * 系统管理员查询全部:查看保养条目的
      *