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); | ||||
} | } |
import com.baomidou.mybatisplus.core.toolkit.Wrappers; | import com.baomidou.mybatisplus.core.toolkit.Wrappers; | ||||
import com.tuoheng.admin.constant.SystemConstant; | import com.tuoheng.admin.constant.SystemConstant; | ||||
import com.tuoheng.admin.entity.FlightData; | import com.tuoheng.admin.entity.FlightData; | ||||
import com.tuoheng.admin.entity.FlightDataHl; | |||||
import com.tuoheng.admin.entity.Inspection; | import com.tuoheng.admin.entity.Inspection; | ||||
import com.tuoheng.admin.entity.Report; | import com.tuoheng.admin.entity.Report; | ||||
import com.tuoheng.admin.enums.MarkEnum; | import com.tuoheng.admin.enums.MarkEnum; | ||||
@Autowired | @Autowired | ||||
private FlightDataMapper flightDataMapper; | private FlightDataMapper flightDataMapper; | ||||
@Autowired | |||||
private FlightDataHlMapper flightDataHlMapper; | |||||
@Autowired | @Autowired | ||||
private ReportMapper reportMapper; | private ReportMapper reportMapper; | ||||
log.info("坐标数据,flightDataCount:{}", flightDataCount); | log.info("坐标数据,flightDataCount:{}", flightDataCount); | ||||
if (flightDataCount > 0) { | if (flightDataCount > 0) { | ||||
int index = (int) Math.ceil((double) flightDataCount / 2); | int index = (int) Math.ceil((double) flightDataCount / 2); | ||||
FlightDataHl flightData = flightDataHlMapper.selectOne(new LambdaQueryWrapper<FlightDataHl>() | |||||
.eq(FlightDataHl::getInspectionId, inspection.getId()) | |||||
.eq(FlightDataHl::getTenantId, inspection.getTenantId()) | |||||
.eq(FlightDataHl::getMark, MarkEnum.VALID.getCode()) | |||||
.orderByDesc(FlightDataHl::getTime) | |||||
FlightData flightData = flightDataMapper.selectOne(new LambdaQueryWrapper<FlightData>() | |||||
.eq(FlightData::getInspectionId, inspection.getId()) | |||||
.eq(FlightData::getTenantId, inspection.getTenantId()) | |||||
.eq(FlightData::getMark, MarkEnum.VALID.getCode()) | |||||
.orderByDesc(FlightData::getTimestamp) | |||||
.last("limit " + index + ",1")); | .last("limit " + index + ",1")); | ||||
if (ObjectUtil.isNotNull(flightData)) { | if (ObjectUtil.isNotNull(flightData)) { | ||||
inspectionUpdate.setFlyHeight(flightData.getAlt()); | inspectionUpdate.setFlyHeight(flightData.getAlt()); |
// 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> |