package cn.com.goldenwater.dcproj.controller.rsvr; import cn.com.goldenwater.core.web.BaseController; import cn.com.goldenwater.core.web.BaseResponse; import cn.com.goldenwater.dcproj.constValue.BisInspEnum; import cn.com.goldenwater.dcproj.model.*; import cn.com.goldenwater.dcproj.param.BisInspRsvrRgstrChkInfoParam; import cn.com.goldenwater.dcproj.service.*; import cn.com.goldenwater.dcproj.utils.Constant; import cn.com.goldenwater.id.util.UuidUtil; import cn.com.goldenwater.target.CheckException; import com.github.pagehelper.PageInfo; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import java.util.Date; import java.util.List; import java.util.Optional; /** * @author lune * @date 2021年4月14日 */ @Api(value = "BIS 督查水库登记表-水库检查情况-新管理", tags = "BIS 督查水库登记表-水库检查情况-新管理") @RestController @RequestMapping("/bis/insp/rsvr/rgstr/chk/info") public class BisInspRsvrRgstrChkInfoController extends BaseController { private Logger logger = LoggerFactory.getLogger(getClass()); @Autowired private BisInspRsvrRgstrChkInfoService bisInspRsvrRgstrChkInfoService; @Autowired private BisInspRsvrRgstrService bisInspRsvrRgstrService; @Autowired private AttRsBaseService attRsBaseService; @Autowired private BisInspPblmService bisInspPblmService; @Autowired private ObjInspPblmsService objInspPblmsService; @ApiOperation(value = "添加/修改督查水库登记表-水库检查情况-新") @RequestMapping(value = "", method = RequestMethod.POST) public BaseResponse insert(@ApiParam(name = "bisInspRsvrRgstrChkInfo", value = "BisInspRsvrRgstrChkInfo", required = true) @RequestBody BisInspRsvrRgstrChkInfo bisInspRsvrRgstrChkInfo) { String rgstrId = bisInspRsvrRgstrChkInfo.getRgstrId(); BisInspRsvrRgstr bisInspRsvrRgstr = new BisInspRsvrRgstr(); bisInspRsvrRgstr.setRgstrId(rgstrId); bisInspRsvrRgstr.setChkInfoStat(bisInspRsvrRgstrChkInfo.getStatus()); BisInspRsvrRgstr rgstr = bisInspRsvrRgstrService.get(rgstrId); Optional.ofNullable(rgstr).orElseThrow(() -> new CheckException("登记表ID错误,未获取到对应登记表信息")); if (!Constant.STRING_TWO.equals(rgstr.getState())) { bisInspRsvrRgstr.setState(Constant.STRING_ONE); bisInspRsvrRgstrService.update(bisInspRsvrRgstr); } //如果工况总体评价 属于重大安全隐患则 添加一条问题到问题表 if (null != bisInspRsvrRgstrChkInfo.getWcEvltNow() && bisInspRsvrRgstrChkInfo.getWcEvltNow().equals("1")) { BisInspPblm bisInspPblm = new BisInspPblm(); bisInspPblm.setScore("0"); bisInspPblm.setVillType("0"); bisInspPblm.setObjId(rgstr.getObjId()); bisInspPblm.setRegid(rgstr.getRgstrId()); bisInspPblm.setObjType("1"); bisInspPblm.setInspPblmCate("0"); bisInspPblm.setPblmDesc(""); bisInspPblm.setIfCasePblm(""); bisInspPblm.setPblmStat("0"); bisInspPblm.setDataStat(""); bisInspPblm.setNm(rgstr.getRsvrNm()); bisInspPblm.setRecPers(getCurrentPersId()); bisInspPblm.setNote(""); bisInspPblm.setInspPblmName("重大安全隐患"); String pblmsTypeId = ""; switch (bisInspRsvrRgstrChkInfo.getMshTmp()) { case "1": pblmsTypeId = "10000000000000000000000000000724"; break; case "2": pblmsTypeId = "10000000000000000000000000000725"; break; case "3": pblmsTypeId = "10000000000000000000000000000726"; break; case "4": pblmsTypeId = "10000000000000000000000000000727"; break; default: pblmsTypeId = "10000000000000000000000000000727"; break; } bisInspPblm.setPblmsTypeId(pblmsTypeId); if (StringUtils.isNotBlank(bisInspPblm.getPblmsTypeId()) && !BisInspEnum.EMPWT.getValue().equals(bisInspPblm.getObjType())) { bisInspPblm.setPblmsTypeId(bisInspPblm.getPblmsTypeId().trim()); ObjInspPblms objInspPblms = objInspPblmsService.get(bisInspPblm.getPblmsTypeId()); if (objInspPblms != null) { bisInspPblm.setInspPblmCode(objInspPblms.getSn()); bisInspPblm.setInspPblmType(objInspPblms.getSort2()); bisInspPblm.setCheckPointBz(objInspPblms.getCheckPoint()); bisInspPblm.setPblmDescBz(objInspPblms.getPblmDesc()); bisInspPblm.setPblmNameBz(objInspPblms.getInspPblmsName()); bisInspPblm.setSnNumBz(objInspPblms.getSnNum()); bisInspPblm.setFileNo(objInspPblms.getAttach()); bisInspPblm.setFileNoNumber(objInspPblms.getSnNum()); bisInspPblm.setScore(objInspPblms.getScore()); } } bisInspPblmService.insertPblms(bisInspPblm); } /* * if isSite(是否到现场) 1:是 2:否 * 是: * 督查形式不是必查时,则修改水库基本信息表及登记表的“督查形式”为 抽查 * * inspType(督查形式) 1:必查 2:抽查 */ if ("1".equals(bisInspRsvrRgstrChkInfo.getIsSite())) { AttRsBase attRsBase = attRsBaseService.get(rgstr.getRsCode()); Optional.ofNullable(attRsBase).ifPresent(base -> { if (!"1".equals(base.getInspType())) { base.setInspType("2"); attRsBaseService.update(base); } }); } if (StringUtils.isBlank(bisInspRsvrRgstrChkInfo.getId())) { // 生成uuid String uuid = UuidUtil.uuid(); bisInspRsvrRgstrChkInfo.setId(uuid); bisInspRsvrRgstrChkInfo.setIntm(new Date()); bisInspRsvrRgstrChkInfoService.insert(bisInspRsvrRgstrChkInfo); } else { bisInspRsvrRgstrChkInfo.setUptm(new Date()); bisInspRsvrRgstrChkInfoService.update(bisInspRsvrRgstrChkInfo); } return buildSuccessResponse(bisInspRsvrRgstrChkInfo); } @ApiOperation(value = "根据ID删除督查水库登记表-水库检查情况-新") @RequestMapping(value = "/del/{id}", method = RequestMethod.GET) public BaseResponse delete(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) { int ret = bisInspRsvrRgstrChkInfoService.delete(id); return buildSuccessResponse(); } @ApiOperation(value = "根据ID获取督查水库登记表-水库检查情况-新(单表)") @RequestMapping(value = "/{id}", method = RequestMethod.GET) public BaseResponse get(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) { BisInspRsvrRgstrChkInfo bisInspRsvrRgstrChkInfo = bisInspRsvrRgstrChkInfoService.get(id); return buildSuccessResponse(bisInspRsvrRgstrChkInfo); } @ApiOperation(value = "根据ID获取督查水库登记表-水库检查情况-新(单表)") @RequestMapping(value = "getBy/{rgstrId}", method = RequestMethod.GET) public BaseResponse getBy(@ApiParam(name = "rgstrId", value = "rgstrId", required = true) @PathVariable String rgstrId) { BisInspRsvrRgstrChkInfoParam param = new BisInspRsvrRgstrChkInfoParam(); param.setRgstrId(rgstrId); BisInspRsvrRgstrChkInfo bisInspRsvrRgstrChkInfo = bisInspRsvrRgstrChkInfoService.getBy(param); if (bisInspRsvrRgstrChkInfo == null) { bisInspRsvrRgstrChkInfo = new BisInspRsvrRgstrChkInfo(); bisInspRsvrRgstrChkInfo.setRgstrId(rgstrId); BisInspRsvrRgstr rgstr = bisInspRsvrRgstrService.get(rgstrId); Optional.ofNullable(rgstr).orElseThrow(() -> new CheckException("登记表ID错误,未获取到对应登记表信息")); AttRsBase base = attRsBaseService.get(rgstr.getRsCode()); if (base != null) { bisInspRsvrRgstrChkInfo.setInspYear(base.getInspYear()); bisInspRsvrRgstrChkInfo.setWcEvltOld(base.getWcEvltOld()); } insert(bisInspRsvrRgstrChkInfo); } return buildSuccessResponse(bisInspRsvrRgstrChkInfo); } @ApiOperation(value = "获取督查水库登记表-水库检查情况-新(列表所有)") @RequestMapping(value = "/list", method = RequestMethod.POST) public BaseResponse> list(@ApiParam(name = "bisInspRsvrRgstrChkInfoParam", value = "bisInspRsvrRgstrChkInfoParam", required = true) @RequestBody BisInspRsvrRgstrChkInfoParam bisInspRsvrRgstrChkInfoParam) { List bisInspRsvrRgstrChkInfoList = bisInspRsvrRgstrChkInfoService.findList(bisInspRsvrRgstrChkInfoParam); return buildSuccessResponse(bisInspRsvrRgstrChkInfoList); } @ApiOperation(value = "获取督查水库登记表-水库检查情况-新(列表--分页)") @RequestMapping(value = "/page", method = RequestMethod.POST) public BaseResponse> page(@ApiParam(name = "bisInspRsvrRgstrChkInfoParam", value = "bisInspRsvrRgstrChkInfoParam", required = true) @RequestBody BisInspRsvrRgstrChkInfoParam bisInspRsvrRgstrChkInfoParam) { PageInfo bisInspRsvrRgstrChkInfoList = bisInspRsvrRgstrChkInfoService.findPageInfo(bisInspRsvrRgstrChkInfoParam); return buildSuccessResponse(bisInspRsvrRgstrChkInfoList); } }