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.entity.SafeCheckTaskAndQuota; import com.gkhy.safePlatform.safeCheck.model.dto.req.*; import com.gkhy.safePlatform.safeCheck.model.dto.resp.ExcepOrderHandledDataByIdRespDTO; import com.gkhy.safePlatform.safeCheck.model.dto.resp.ListUserExcepOrderByPageRespDTO; import com.gkhy.safePlatform.safeCheck.model.dto.resp.SafeCheckTaskDataByConditionMobileRespDTO; import com.gkhy.safePlatform.safeCheck.model.dto.resp.SafeCheckTaskMobilePageRespDTO; import com.gkhy.safePlatform.safeCheck.service.SafeCheckTaskMobileManagerService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.core.Authentication; import org.springframework.web.bind.annotation.*; /** * @description 手机端的接口 */ @RestController @RequestMapping("/SafeCheckMobileTerminal") public class SafeCheckMobileTerminalController { @Autowired private SafeCheckTaskMobileManagerService safeCheckTaskMobileManagerService; /** * @description 查询用户所属的班组,用户上班时间的任务信息 */ @PostMapping("/select/listUserTaskByPage") public ResultVO> listUserTaskByPage(Authentication authentication,@RequestBody SafeCheckMobilePageReqDTO safeCheckMobilePageReqDTO){ ContextCacheUser currentUser = (ContextCacheUser)authentication.getPrincipal(); Integer pageIndex = safeCheckMobilePageReqDTO.getPageIndex(); Integer pageSize = safeCheckMobilePageReqDTO.getPageSize(); if (pageIndex == 0 || pageSize == 0){ throw new AusinessException(E.DATA_PARAM_NULL,"当前页码或当前页显示数不能为0"); } Page pageInfo = new Page(pageIndex, pageSize); //连表查询后再统计总数 // pageInfo.setOptimizeCountSql(false); IPage iPage = safeCheckTaskMobileManagerService.listUserTaskByPage(currentUser,pageInfo, safeCheckMobilePageReqDTO); return new ResultVO<>(ResultCodes.OK,iPage); } /** * @description 根据部门,班组和状态作为条件查询任务以及任务相关的巡检点 */ @PostMapping("/select/listTaskDataByCondition") public ResultVO> listTaskDataByCondition(Authentication authentication, @RequestBody ListTaskDataByConditionReqDTO reqDTO) { ContextCacheUser currentUser = (ContextCacheUser)authentication.getPrincipal(); Integer pageIndex = reqDTO.getPageIndex(); Integer pageSize = reqDTO.getPageSize(); if (pageIndex == 0 || pageSize == 0){ throw new AusinessException(E.DATA_PARAM_NULL,"当前页码或当前页显示数不能为0"); } Page pageInfo = new Page(pageIndex, pageSize); //连表查询后再统计总数 // pageInfo.setOptimizeCountSql(false); IPage iPage = safeCheckTaskMobileManagerService.listTaskDataByCondition(currentUser,pageInfo, reqDTO); return new ResultVO<>(ResultCodes.OK,iPage); } /** * @description 用户认领任务 */ @PostMapping("/update/updateTaskClaimById") public ResultVO updateTaskClaimById(Authentication authentication, @RequestBody SafeCheckTask safeCheckTask){ ContextCacheUser currentUser = (ContextCacheUser)authentication.getPrincipal(); Long taskId = safeCheckTask.getId(); safeCheckTaskMobileManagerService.updateTaskClaimById(currentUser, taskId); ResultVO resultVO = new ResultVO<>("200","任务认领成功"); return resultVO; } /** * @description 用户单个提交巡检点巡检结果 */ @PostMapping("/update/updateTaskAndQuotaResultById") public ResultVO updateTaskAndQuotaResultById(Authentication authentication, @RequestBody SafeCheckTaskAndQuotaSubmitReqDTO safeCheckTaskAndQuotaSubmitReqDTO){ ContextCacheUser currentUser = (ContextCacheUser)authentication.getPrincipal(); safeCheckTaskMobileManagerService.updateTaskAndQuotaResultById(currentUser,safeCheckTaskAndQuotaSubmitReqDTO); ResultVO resultVO = new ResultVO<>("200","巡检点巡检结果提交成功"); return resultVO; } /** * @description 最终提交 */ @PostMapping("/update/updateTaskResultById") public ResultVO updateTaskResultById(Authentication authentication, @RequestBody SafeCheckTaskAndQuota safeCheckTaskAndQuota){ ContextCacheUser currentUser = (ContextCacheUser)authentication.getPrincipal(); Long taskId = safeCheckTaskAndQuota.getTaskId(); safeCheckTaskMobileManagerService.updateTaskResultById(currentUser,taskId); ResultVO resultVO = new ResultVO<>("200","所有巡检点已完成巡检并提交"); return resultVO; } /** * @description 查询用户工单列表 */ @PostMapping("/select/listUserExcepOrderByPage") public ResultVO> listUserExcepOrderByPage(Authentication authentication, @RequestBody SafeCheckExcepOrderPageReqDTO excepOrderPageReqDTO){ ContextCacheUser currentUser = (ContextCacheUser)authentication.getPrincipal(); Integer pageIndex = excepOrderPageReqDTO.getPageIndex(); Integer pageSize = excepOrderPageReqDTO.getPageSize(); if (pageIndex == 0 || pageSize == 0){ throw new AusinessException(E.DATA_PARAM_NULL,"当前页码或当前页显示数不能为0"); } Page pageInfo = new Page(pageIndex, pageSize); IPage iPage = safeCheckTaskMobileManagerService.listUserExcepOrderByPage(currentUser,pageInfo); return new ResultVO<>(ResultCodes.OK,iPage); } /** * 根据id响应回执 */ @PostMapping("/update/ExcepOrderhandleStatusById") public ResultVO updateExcepOrderhandleStatusById(Authentication authentication, @RequestBody ExcepOrderhandleStatusByIdReqDTO reqDTO){ ContextCacheUser currentUser = (ContextCacheUser)authentication.getPrincipal(); safeCheckTaskMobileManagerService.updateExcepOrderhandleStatusById(currentUser,reqDTO); ResultVO resultVO = new ResultVO<>("200","响应回执提交成功"); return resultVO; } /** * @description 根据id处理后填报(可以多次更新) */ @PostMapping("/update/ExcepOrderHandledAfterStatusById") public ResultVO updateExcepOrderHandledAfterStatusById(Authentication authentication, @RequestBody ExcepOrderHandledAfterStatusByIdReqDTO reqDTO){ ContextCacheUser currentUser = (ContextCacheUser)authentication.getPrincipal(); safeCheckTaskMobileManagerService.updateExcepOrderHandledAfterStatusById(currentUser,reqDTO); ResultVO resultVO = new ResultVO<>("200","反馈填写成功"); return resultVO; } /** * @description 根据id获取反馈填报信息内容 */ @PostMapping("/select/getExcepOrderHandledDataById") public ResultVO getExcepOrderHandledDataById(@RequestBody ExcepOrderHandledDataByIdReqDTO reqDTO){ ExcepOrderHandledDataByIdRespDTO dataByIdRespDTO = safeCheckTaskMobileManagerService.getExcepOrderHandledDataById(reqDTO); return new ResultVO<>(ResultCodes.OK,dataByIdRespDTO); } }