package com.gkhy.safePlatform.doublePrevention.controller;
|
|
import com.gkhy.safePlatform.account.rpc.apimodel.AccountAuthService;
|
import com.gkhy.safePlatform.account.rpc.apimodel.model.resp.UserRPCRespDTO;
|
import com.gkhy.safePlatform.commons.co.ContextCacheUser;
|
import com.gkhy.safePlatform.commons.enums.ResultCodes;
|
import com.gkhy.safePlatform.commons.vo.ResultVO;
|
import com.gkhy.safePlatform.doublePrevention.entity.PreventDangerManage;
|
import com.gkhy.safePlatform.doublePrevention.entity.PreventRiskAnaUnit;
|
import com.gkhy.safePlatform.doublePrevention.entity.dto.req.*;
|
import com.gkhy.safePlatform.doublePrevention.entity.dto.resp.PreventDangerManageQueryRespDTO;
|
import com.gkhy.safePlatform.doublePrevention.service.RectifyService;
|
import org.apache.dubbo.config.annotation.DubboReference;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.security.core.Authentication;
|
import org.springframework.web.bind.annotation.*;
|
|
import java.security.Principal;
|
import java.time.LocalDate;
|
import java.time.LocalDateTime;
|
import java.time.ZoneId;
|
import java.util.Date;
|
|
@RestController
|
@RequestMapping("prevent/dangerManage")
|
public class PreventDangerManageController {
|
|
@DubboReference(check = false)
|
private AccountAuthService accountAuthService;
|
|
@Autowired
|
private RectifyService rectifyService;
|
|
/**
|
* 隐患治理清单-分页查询
|
*/
|
@PostMapping("/select/getDangerManagePage")
|
public ResultVO<PreventDangerManage> getDangerManagePage(Authentication authentication, @RequestBody PreventDangerManageQueryReqDTO manageQueryReqDTO) {
|
//获取用户信息
|
ContextCacheUser currentUser = (ContextCacheUser)authentication.getPrincipal();
|
return rectifyService.getDangerManagePage(currentUser.getUid(), manageQueryReqDTO);
|
}
|
|
/**
|
* 隐患治理清单-列表
|
*/
|
@PostMapping("/select/listDangerManage")
|
public ResultVO<PreventDangerManage> listDangerManage(Authentication authentication) {
|
//获取用户信息
|
ContextCacheUser currentUser = (ContextCacheUser)authentication.getPrincipal();
|
return rectifyService.listDangerManage(currentUser.getUid());
|
}
|
|
/**
|
* 隐患治理清单-新增
|
*/
|
@PostMapping("/insert/saveDangerManage")
|
public ResultVO<PreventDangerManage> saveDangerManage(Authentication authentication, @RequestBody PreventDangerManageSaveReqDTO manageSaveReqDTO) {
|
//获取用户信息
|
ContextCacheUser currentUser = (ContextCacheUser)authentication.getPrincipal();
|
return rectifyService.saveDangerManage(currentUser.getUid(), manageSaveReqDTO);
|
}
|
|
/**
|
* 隐患治理清单-修改
|
*/
|
@PostMapping("/update/updateDangerManage")
|
public ResultVO<PreventDangerManage> updateDangerManage(Authentication authentication, @RequestBody PreventDangerManageUpdateReqDTO manageUpdateReqDTO) {
|
//获取用户信息
|
ContextCacheUser currentUser = (ContextCacheUser)authentication.getPrincipal();
|
return rectifyService.updateDangerManage(currentUser.getUid(), manageUpdateReqDTO);
|
}
|
|
/**
|
* 隐患治理清单-删除
|
*/
|
@PostMapping("/delete/deleteDangerManage")
|
public ResultVO<PreventDangerManage> deleteDangerManage(Authentication authentication, @RequestBody PreventDangerManageDeleteReqDTO manageDeleteReqDTO) {
|
//获取用户信息
|
ContextCacheUser currentUser = (ContextCacheUser)authentication.getPrincipal();
|
return rectifyService.deleteDangerManage(currentUser.getUid(), manageDeleteReqDTO);
|
}
|
|
/**
|
* 隐患管理-手工上报-配置
|
*/
|
@PostMapping("/update/updateReport")
|
public ResultVO<PreventRiskAnaUnit> updateDangerManagerReport(Authentication authentication, @RequestBody PreventHandReportConfigReqDTO preventHandReportConfigReqDTO) {
|
//获取用户信息
|
ContextCacheUser currentUser = (ContextCacheUser)authentication.getPrincipal();
|
return rectifyService.updateDangerManagerReport(currentUser.getUid(), preventHandReportConfigReqDTO);
|
}
|
|
/**
|
* 隐患管理-关闭隐患单
|
*/
|
@PostMapping("/update/closeDanger")
|
public ResultVO<PreventRiskAnaUnit> closeDanger(Authentication authentication, @RequestBody PreventCloseDangerReqDTO closeDangerReqDTO) {
|
//获取用户信息
|
ContextCacheUser currentUser = (ContextCacheUser)authentication.getPrincipal();
|
return rectifyService.closeDanger(currentUser.getUid(), closeDangerReqDTO);
|
}
|
|
@GetMapping("/count/byCreateDate")
|
public ResultVO getDangerCountByCreateDate(String date){
|
ResultVO resultVO = new ResultVO<>();
|
LocalDate localDate = null;
|
if(date == null || date.isEmpty()){
|
resultVO.setCode(ResultCodes.CLIENT_PARAM_ERROR.getCode());
|
resultVO.setMsg(ResultCodes.CLIENT_PARAM_ERROR.getDesc());
|
return resultVO;
|
}
|
try {
|
localDate = LocalDate.parse(date);
|
} catch (Exception e) {
|
resultVO.setCode(ResultCodes.CLIENT_PARAM_ERROR.getCode());
|
resultVO.setMsg(ResultCodes.CLIENT_PARAM_ERROR.getDesc());
|
return resultVO;
|
}
|
return rectifyService.countDangerByDate(localDate);
|
}
|
|
@GetMapping("/find/serialCode")
|
public ResultVO findDangerManageBySerialCode(String serialCode){
|
ResultVO<PreventDangerManageQueryRespDTO> resultVO = new ResultVO<>();
|
resultVO.setCode(ResultCodes.OK.getCode());
|
if(serialCode == null || serialCode.length() < 13){
|
return resultVO;
|
}
|
resultVO = rectifyService.findByDangerSerialCode(serialCode);
|
return resultVO;
|
}
|
|
}
|