public JsonResult getPageList(QueryInspectionPageListRequest request) { | public JsonResult getPageList(QueryInspectionPageListRequest request) { | ||||
// log.info("进入查询巡检任务分页列表业务"); | // log.info("进入查询巡检任务分页列表业务"); | ||||
String userId = CurrentUserUtil.getUserId(); | |||||
String tenantId = CurrentUserUtil.getTenantId(); | |||||
User user = CurrentUserUtil.getUserInfo(); | |||||
String userId = user.getId(); | |||||
String tenantId = user.getTenantId(); | |||||
request.setTenantId(tenantId); | request.setTenantId(tenantId); | ||||
JsonResult result = this.check(tenantId, request); | JsonResult result = this.check(tenantId, request); | ||||
log.info("进入查询巡检任务分页列表业务:校验失败:{}", result.getMsg()); | log.info("进入查询巡检任务分页列表业务:校验失败:{}", result.getMsg()); | ||||
return result; | return result; | ||||
} | } | ||||
User user = userMapper.selectOne(new LambdaQueryWrapper<User>() | |||||
.eq(User::getTenantId, tenantId) | |||||
.eq(User::getId, userId) | |||||
.eq(User::getMark, 1)); | |||||
Dept dept = deptMapper.selectOne(new LambdaQueryWrapper<Dept>() | Dept dept = deptMapper.selectOne(new LambdaQueryWrapper<Dept>() | ||||
.eq(Dept::getTenantId, tenantId) | .eq(Dept::getTenantId, tenantId) | ||||
.eq(Dept::getId, user.getDeptId()) | .eq(Dept::getId, user.getDeptId()) |
} | } | ||||
return; | return; | ||||
} | } | ||||
if (user.getId().equals(inspectionVo.getCreateUser())) { | |||||
// 自己创建的任务 | |||||
inspectionVo.setEdit(true); | |||||
} else { | |||||
// 非本人创建,判断该用户是不是该部门管理员 | |||||
// 本部门主管编辑本部门任务 | |||||
// 查询部门管理员,若是部门管理员可修改,非部门管理员不能修改 | |||||
User userTmp = userMapper.selectOne(new LambdaQueryWrapper<User>() | |||||
.eq(User::getDeptId, user.getDeptId()) | |||||
.eq(User::getDataPermission, DataPermissionEnum.DEPT_AND_SUB_DEPT.getCode()) | |||||
.eq(User::getMark, MarkEnum.VALID.getCode())); | |||||
if (ObjectUtil.isNull(userTmp)) { | |||||
if (null != handler) { | |||||
handler.handler(user, dept, inspectionVo); | |||||
return; | |||||
} | |||||
} | |||||
if (!user.getId().equals(userTmp.getId())) { | |||||
if (null != handler) { | |||||
handler.handler(user, dept, inspectionVo); | |||||
return; | |||||
} | |||||
} | |||||
inspectionVo.setEdit(true); | |||||
} | |||||
inspectionVo.setEdit(true); | |||||
if (null != handler) { | if (null != handler) { | ||||
handler.handler(user, dept, inspectionVo); | handler.handler(user, dept, inspectionVo); | ||||
return; | return; |
} | } | ||||
return; | return; | ||||
} | } | ||||
if (DataPermissionEnum.ALL.getCode() == user.getDataPermission()) { | |||||
// 超级管理员不能执行任务操作 | |||||
inspectionVo.setExecute(false); | |||||
} else if (DataPermissionEnum.DEPT_AND_SUB_DEPT.getCode() == user.getDataPermission()) { | |||||
// 管理员可对本部门的任务执行此操作 | |||||
if (user.getDeptId().equals(inspectionVo.getDeptId())) { | |||||
if (1 == inspectionVo.getExecutionStatus()) { | |||||
inspectionVo.setExecute(true); | |||||
} | |||||
} | |||||
} else if (DataPermissionEnum.DEPT.getCode() == user.getDataPermission()) { | |||||
// 普通用户可对自己创建的任务执行此操作 | |||||
if (user.getId().equals(inspectionVo.getCreateUser())) { | |||||
inspectionVo.setExecute(true); | |||||
} | |||||
} | |||||
inspectionVo.setExecute(true); | |||||
if (null != handler) { | if (null != handler) { | ||||
handler.handler(user, dept, inspectionVo); | handler.handler(user, dept, inspectionVo); | ||||
} | } |
// log.info("进入查询报告分页列表业务"); | // log.info("进入查询报告分页列表业务"); | ||||
User user = CurrentUserUtil.getUserInfo(); | User user = CurrentUserUtil.getUserInfo(); | ||||
String tenantId = user.getTenantId(); | String tenantId = user.getTenantId(); | ||||
request.setTenantId(tenantId); | |||||
JsonResult result = this.check(tenantId, request); | JsonResult result = this.check(tenantId, request); | ||||
if (0 != result.getCode()) { | if (0 != result.getCode()) { | ||||
return result; | return result; | ||||
} | } | ||||
// 设置分页参数 | |||||
IPage<Report> page = new Page<>(request.getPage(), request.getLimit()); | |||||
// 用户只能查看自己生成的报告 或者是当前租户下自动生成的报告 | |||||
//request.setCreateUser(userId); | |||||
// 查询结果 | |||||
IPage<Report> pageData = reportMapper.selectPageList(page, request); | |||||
if (null == pageData || pageData.getTotal() == 0) { | |||||
log.info("获取任务分页列表为空"); | |||||
return JsonResult.success(pageData); | |||||
} | |||||
List<Report> reportList = pageData.getRecords(); | |||||
List<Report> reportsData = new ArrayList<>(); | |||||
List<String> deptIdList = new ArrayList<>(); | |||||
if (DataPermissionEnum.ALL.getCode() == user.getDataPermission()) { | if (DataPermissionEnum.ALL.getCode() == user.getDataPermission()) { | ||||
reportsData = this.getAllList(reportList); | |||||
// 查询该租户下所有部门的工单 | |||||
} else if (DataPermissionEnum.DEPT_AND_SUB_DEPT.getCode() == user.getDataPermission()) { | } else if (DataPermissionEnum.DEPT_AND_SUB_DEPT.getCode() == user.getDataPermission()) { | ||||
reportsData = this.getListByDepts(reportList, user); | |||||
deptIdList = deptMapper.selectAllChildListById(user.getDeptId()); | |||||
} else if (DataPermissionEnum.DEPT.getCode() == user.getDataPermission()) { | } else if (DataPermissionEnum.DEPT.getCode() == user.getDataPermission()) { | ||||
reportsData = this.getListByDept(reportList, user); | |||||
} | |||||
if(CollectionUtil.isEmpty(reportsData) || reportsData.size() == 0){ | |||||
return JsonResult.success("当前用户对应数据权限下查询报告数据为空"); | |||||
deptIdList.add(user.getDeptId()); | |||||
} | } | ||||
IPage<Report> reportIPage = pageData.setRecords(reportsData); | |||||
request.setTenantId(tenantId); | |||||
request.setDeptIdList(deptIdList); | |||||
// 设置分页参数 | |||||
IPage<Report> page = new Page<>(request.getPage(), request.getLimit()); | |||||
// 查询结果 | |||||
IPage<Report> pageData = reportMapper.selectPageList(page, request); | |||||
// 构造返回结果对象 | // 构造返回结果对象 | ||||
List<ReportPageListVo> reportPageListVoList = this.buildReportPageListVoList(reportsData); | |||||
List<ReportPageListVo> reportPageListVoList = this.buildReportPageListVoList(pageData.getRecords()); | |||||
// 重写返回结果对象 | // 重写返回结果对象 | ||||
IPage<ReportPageListVo> reportVoPageData = new Page<>(); | IPage<ReportPageListVo> reportVoPageData = new Page<>(); | ||||
reportVoPageData.setPages(reportIPage.getPages()); | |||||
reportVoPageData.setCurrent(reportIPage.getCurrent()); | |||||
reportVoPageData.setSize(reportIPage.getSize()); | |||||
reportVoPageData.setTotal(reportIPage.getTotal()); | |||||
reportVoPageData.setPages(pageData.getPages()); | |||||
reportVoPageData.setCurrent(pageData.getCurrent()); | |||||
reportVoPageData.setSize(pageData.getSize()); | |||||
reportVoPageData.setTotal(pageData.getTotal()); | |||||
reportVoPageData.setRecords(reportPageListVoList); | reportVoPageData.setRecords(reportPageListVoList); | ||||
return JsonResult.success(reportVoPageData); | return JsonResult.success(reportVoPageData); |
<if test="request.inspectionCode!= null and request.inspectionCode != ''"> and inspection_code like concat('%', #{request.inspectionCode}, '%') </if> | <if test="request.inspectionCode!= null and request.inspectionCode != ''"> and inspection_code like concat('%', #{request.inspectionCode}, '%') </if> | ||||
<if test="request.airportId != null and request.airportId != 0"> and airport_id = #{request.airportId} </if> | <if test="request.airportId != null and request.airportId != 0"> and airport_id = #{request.airportId} </if> | ||||
<if test="request.type != null and request.type != 0"> and type = #{request.type} </if> | <if test="request.type != null and request.type != 0"> and type = #{request.type} </if> | ||||
<if test="request.createUser != null and request.createUser != ''"> and create_user = #{request.createUser} </if> | |||||
<if test="request.deptIdList != null and request.deptIdList.size() > 0"> | |||||
and dept_id in | |||||
<foreach item="deptId" collection="request.deptIdList" open="(" separator="," close=")"> | |||||
#{deptId} | |||||
</foreach> | |||||
</if> | |||||
</where> | </where> | ||||
order by create_time desc | order by create_time desc | ||||
</select> | </select> |