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.SafeCheckWork;
|
import com.gkhy.safePlatform.safeCheck.model.dto.req.*;
|
import com.gkhy.safePlatform.safeCheck.model.dto.resp.SafeCheckPointPageRespDTO;
|
import com.gkhy.safePlatform.safeCheck.model.dto.resp.SafeCheckPointRespDTO;
|
import com.gkhy.safePlatform.safeCheck.model.dto.resp.SafeCheckTaskUnitPageRespDTO;
|
import com.gkhy.safePlatform.safeCheck.model.dto.resp.SafeCheckTaskUnitRespDTO;
|
import com.gkhy.safePlatform.safeCheck.service.SafeCheckTaskManagerService;
|
import com.gkhy.safePlatform.safeCheck.service.baseService.SafeCheckWorkService;
|
import org.omg.CORBA.PUBLIC_MEMBER;
|
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.security.core.Authentication;
|
import org.springframework.web.bind.annotation.*;
|
|
import java.util.HashMap;
|
|
@RestController
|
@RequestMapping("/SafeCheckTaskUnit")
|
public class SafeCheckTaskUnitController {
|
|
@Autowired
|
private SafeCheckTaskManagerService safeCheckTaskManagerService;
|
|
@Autowired
|
private SafeCheckWorkService safeCheckWorkService;
|
|
/**
|
* @description 新建一个任务单元
|
*/
|
@RequestMapping("/insert/saveTaskUnit")
|
public ResultVO<String> saveTaskUnit(Authentication authentication, @RequestBody SafeCheckTaskUnitReqDTO safeCheckTaskUnitReqDTO){
|
ContextCacheUser currentUser = (ContextCacheUser)authentication.getPrincipal();
|
safeCheckTaskManagerService.saveTaskUnit(currentUser,safeCheckTaskUnitReqDTO);
|
return new ResultVO<>("200","巡检任务单元新建成功");
|
}
|
|
/***
|
* @description 根据任务单元id删除任务单元
|
*/
|
@PostMapping("/delete/deleteTaskUnit")
|
public ResultVO<String> deleteTaskUnit(Authentication authentication,@RequestBody SafeCheckTaskUnitReqDTO safeCheckTaskUnitReqDTO){
|
Long id = safeCheckTaskUnitReqDTO.getId();
|
ContextCacheUser currentUser = (ContextCacheUser)authentication.getPrincipal();
|
safeCheckTaskManagerService.deleteTaskUnit(currentUser, id);
|
ResultVO resultVO = new ResultVO<>("200","删除巡检任务单元成功");
|
return resultVO;
|
}
|
|
/**
|
* @description 根据巡检点的id和任务单元id删除巡检链中的巡检点
|
*/
|
@PostMapping("/delete/deleteTaskUnitPoint")
|
public ResultVO<String> deleteTaskUnitPoint(Authentication authentication,@RequestBody SafeCheckUnitAndQuotaReqDTO safeCheckUnitAndQuotaReqDTO){
|
HashMap<String, Object> taskUnitAndPointId = new HashMap<>();
|
taskUnitAndPointId.put("taskUnitId",safeCheckUnitAndQuotaReqDTO.getUnitId());
|
taskUnitAndPointId.put("id",safeCheckUnitAndQuotaReqDTO.getId());
|
ContextCacheUser currentUser = (ContextCacheUser)authentication.getPrincipal();
|
safeCheckTaskManagerService.deleteTaskUnitPoint(currentUser, taskUnitAndPointId);
|
ResultVO resultVO = new ResultVO<>("200","删除巡检点成功");
|
return resultVO;
|
}
|
|
/**
|
* @description 根据巡检任务单元的id及巡检单元与巡检指标关联表的id对巡检点信息内容进行修改
|
*/
|
@PostMapping("/update/updateTaskUnitPointById")
|
public ResultVO<String> updateTaskUnitPointById(Authentication authentication, @RequestBody SafeCheckUnitAndQuotaReqDTO safeCheckUnitAndQuotaReqDTO){
|
ContextCacheUser currentUser = (ContextCacheUser)authentication.getPrincipal();
|
safeCheckTaskManagerService.updateTaskUnitPointById(currentUser,safeCheckUnitAndQuotaReqDTO);
|
ResultVO resultVO = new ResultVO<>("200","修改巡检点信息成功");
|
return resultVO;
|
}
|
|
|
/**
|
* @description 往巡检链中新增一个巡检点
|
*/
|
@RequestMapping("/insert/saveTaskUnitPoint")
|
public ResultVO<String> saveTaskUnitPoint(Authentication authentication, @RequestBody SafeCheckUnitAndQuotaReqDTO safeCheckUnitAndQuotaReqDTO){
|
ContextCacheUser currentUser = (ContextCacheUser)authentication.getPrincipal();
|
safeCheckTaskManagerService.saveTaskUnitPoint(currentUser,safeCheckUnitAndQuotaReqDTO);
|
return new ResultVO<>("200","巡检点新增成功");
|
}
|
|
|
|
/**
|
* @description 根据id更新巡检任务单元状态
|
*/
|
@PostMapping("/update/updateTaskUnitStatusById")
|
public ResultVO<String> updateTaskUnitStatusById(Authentication authentication, @RequestBody SafeCheckTaskUnitReqDTO safeCheckTaskUnitReqDTO){
|
ContextCacheUser currentUser = (ContextCacheUser)authentication.getPrincipal();
|
String TaskUnitStatus = safeCheckTaskManagerService.updateTaskUnitStatusById(currentUser, safeCheckTaskUnitReqDTO);
|
ResultVO resultVO = new ResultVO<>("200",TaskUnitStatus+"巡检任务单元成功");
|
return resultVO;
|
}
|
|
|
/**
|
* @description 根据id更新巡检任务单元信息
|
*/
|
@PostMapping("/update/updateTaskUnitMainById")
|
public ResultVO<String> updateTaskUnitMainById(Authentication authentication, @RequestBody SafeCheckTaskUnitReqDTO safeCheckTaskUnitReqDTO){
|
ContextCacheUser currentUser = (ContextCacheUser)authentication.getPrincipal();
|
safeCheckTaskManagerService.updateTaskUnitMainById(currentUser, safeCheckTaskUnitReqDTO);
|
ResultVO resultVO = new ResultVO<>("200","更新巡检任务单元成功");
|
return resultVO;
|
}
|
|
|
|
|
/**
|
* @description 根据任务单元id查询任务单元
|
*/
|
@PostMapping("/select/getTaskUnitById")
|
public ResultVO<SafeCheckTaskUnitRespDTO> getTaskUnitById(@RequestBody SafeCheckTaskUnitReqDTO safeCheckTaskUnitReqDTO){
|
Long id = safeCheckTaskUnitReqDTO.getId();
|
SafeCheckTaskUnitRespDTO taskUnitRespDTO = safeCheckTaskManagerService.getTaskUnitById(id);
|
ResultVO resultVO = new ResultVO<>(ResultCodes.OK,taskUnitRespDTO);
|
return resultVO;
|
}
|
|
/**
|
* @description 查询所有巡检任务单元数据并进行分页(包含条件查询)
|
*/
|
@PostMapping("/select/listTaskUnitByPage")
|
public ResultVO<IPage<SafeCheckTaskUnitPageRespDTO>> listTaskUnitByPage(Authentication authentication,@RequestBody SafeCheckTaskUnitPageReqDTO safeCheckTaskUnitPageReqDTO){
|
ContextCacheUser currentUser = (ContextCacheUser)authentication.getPrincipal();
|
Integer pageIndex = safeCheckTaskUnitPageReqDTO.getPageIndex();
|
Integer pageSize = safeCheckTaskUnitPageReqDTO.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 = safeCheckTaskManagerService.listTaskUnitByPage(pageInfo, safeCheckTaskUnitPageReqDTO,currentUser);
|
return new ResultVO<>(ResultCodes.OK,iPage);
|
}
|
}
|