package com.gkhy.safePlatform.safeCheck.controller; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.gkhy.safePlatform.commons.co.ContextCacheUser; import com.gkhy.safePlatform.commons.enums.E; import com.gkhy.safePlatform.commons.enums.ResultCodes; import com.gkhy.safePlatform.commons.exception.AusinessException; import com.gkhy.safePlatform.commons.vo.ResultVO; import com.gkhy.safePlatform.safeCheck.entity.SafeCheckTask; import com.gkhy.safePlatform.safeCheck.model.dto.req.SafeCheckPageGeneralReqDTO; import com.gkhy.safePlatform.safeCheck.model.dto.req.SafeCheckTaskAndQuotaPageReqDTO; import com.gkhy.safePlatform.safeCheck.model.dto.req.SafeCheckTaskPageReqDTO; import com.gkhy.safePlatform.safeCheck.model.dto.resp.*; import com.gkhy.safePlatform.safeCheck.service.SafeCheckTaskResultManagerService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.core.Authentication; import org.springframework.web.bind.annotation.*; @RestController @RequestMapping("/SafeCheckTask") public class SafeCheckTaskController { @Autowired private SafeCheckTaskResultManagerService safeCheckTaskResultManagerService; /** * @description 查询所有巡检任务数据并进行分页(包含条件查询) */ @PostMapping("/select/listTaskByPage") public ResultVO> listTaskUnitByPage(Authentication authentication,@RequestBody SafeCheckTaskPageReqDTO safeCheckTaskPageReqDTO){ ContextCacheUser currentUser = (ContextCacheUser)authentication.getPrincipal(); Integer pageIndex = safeCheckTaskPageReqDTO.getPageIndex(); Integer pageSize = safeCheckTaskPageReqDTO.getPageSize(); if (pageIndex == 0 || pageSize == 0){ throw new AusinessException(E.DATA_PARAM_NULL,"当前页码或当前页显示数不能为0"); } Page pageInfo = new Page(pageIndex, pageSize); pageInfo = safeCheckTaskResultManagerService.listTaskByPage(pageInfo, safeCheckTaskPageReqDTO,currentUser); return new ResultVO<>(ResultCodes.OK,pageInfo); } /** * @description 根据任务id查询该任务下所有的巡检点检查结果 现在不用了 */ // @PostMapping("/select/listTaskAndQuotaByPage") public ResultVO> listTaskAndQuotaByPage(Authentication authentication,@RequestBody SafeCheckTaskAndQuotaPageReqDTO taskPageReqDTO){ Integer pageIndex = taskPageReqDTO.getPageIndex(); Integer pageSize = taskPageReqDTO.getPageSize(); if (pageIndex == 0 || pageSize == 0){ throw new AusinessException(E.DATA_PARAM_NULL,"当前页码或当前页显示数不能为0"); } Page pageInfo = new Page(pageIndex, pageSize); pageInfo = safeCheckTaskResultManagerService.listTaskAndQuotaByPage(pageInfo,taskPageReqDTO); return new ResultVO<>(ResultCodes.OK,pageInfo); } /** * @description 根据任务id查询该任务下主内容及所有巡检链信息 */ @PostMapping("/select/listTaskMainAndQuota") public ResultVO listTaskMainAndQuota(Authentication authentication, @RequestBody SafeCheckTaskAndQuotaPageReqDTO taskPageReqDTO){ Long taskId = taskPageReqDTO.getId(); SafeCheckTaskMainAndQuotaRespDTO taskMainAndQuota = safeCheckTaskResultManagerService.listTaskMainAndQuota(taskId); return new ResultVO<>(ResultCodes.OK,taskMainAndQuota); } /** * @description 查询所有巡检任务数据并进行分页(只查询已完成,巡检中) 对任务状态进行分组 对结束时间由近到远 */ @PostMapping("/select/listTaskByPageAndStatusAndTime") public ResultVO> listTaskByPageGrByStatusOrByTime(Authentication authentication, @RequestBody SafeCheckPageGeneralReqDTO pageGeneralReqDTO){ ContextCacheUser currentUser = (ContextCacheUser)authentication.getPrincipal(); Integer pageIndex = pageGeneralReqDTO.getPageIndex(); Integer pageSize = pageGeneralReqDTO.getPageSize(); if (pageIndex == 0 || pageSize == 0){ throw new AusinessException(E.DATA_PARAM_NULL,"当前页码或当前页显示数不能为0"); } Page pageInfo = new Page(pageIndex, pageSize); IPage iPage = safeCheckTaskResultManagerService.listTaskByPageGrByStatusOrByTime(pageInfo,currentUser); return new ResultVO<>(ResultCodes.OK,iPage); } /** * @description 根据任务id查询所关联的巡检链巡检结果 结果先按region分组 然后按照指标分组 然后按照巡检点分组 */ @PostMapping("/select/listTaskQuotaGbRegionGbQuotaGbPoint") public ResultVO listTaskQuotaGbRegionGbQuotaGbPoint(Authentication authentication , @RequestBody SafeCheckTask safeCheckTask){ ContextCacheUser currentUser = (ContextCacheUser)authentication.getPrincipal(); Long taskId = safeCheckTask.getId(); if (taskId == null){ return new ResultVO<>("200","任务id不能为空"); } SafeCheckTaskQuotaResultClassifyAndSummarizeRespDTO taskQuotaResults = safeCheckTaskResultManagerService.listTaskQuotaGbRegionGbQuotaGbPoint(currentUser,taskId); ResultVO resultVO = new ResultVO<>(ResultCodes.OK,taskQuotaResults); return resultVO; } /** * @description 获取当前0点-当前时间异常的任务和没有检查的任务 */ @GetMapping("/select/listTaskByNoCheckTaskAndAbnormalTask") public ResultVO listTaskByNoCheckTaskAndAbnormalTask(Authentication authentication){ ContextCacheUser currentUser = (ContextCacheUser)authentication.getPrincipal(); SafeCheckTaskByNoCheckTaskAndAbnormalTaskRepsDTO taskByCondition = safeCheckTaskResultManagerService.listTaskByNoCheckTaskAndAbnormalTask(currentUser); ResultVO resultVO = new ResultVO<>(ResultCodes.OK,taskByCondition); return resultVO; } }