2333c3fe93340ba3d60654077c5e22790d6d2642.svn-base 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. package cn.com.goldenwater.dcproj.controller.rsvryn;
  2. import cn.com.goldenwater.core.web.BaseController;
  3. import cn.com.goldenwater.core.web.BaseResponse;
  4. import cn.com.goldenwater.dcproj.model.AttRsBase;
  5. import cn.com.goldenwater.dcproj.model.BisInspRsvrynRgstr;
  6. import cn.com.goldenwater.dcproj.model.BisInspRsvrynRgstrChkInfo;
  7. import cn.com.goldenwater.dcproj.param.BisInspRsvrynRgstrChkInfoParam;
  8. import cn.com.goldenwater.dcproj.service.AttRsBaseService;
  9. import cn.com.goldenwater.dcproj.service.BisInspRsvrynRgstrChkInfoService;
  10. import cn.com.goldenwater.dcproj.service.BisInspRsvrynRgstrService;
  11. import cn.com.goldenwater.dcproj.utils.Constant;
  12. import cn.com.goldenwater.id.util.UuidUtil;
  13. import cn.com.goldenwater.target.CheckException;
  14. import io.swagger.annotations.Api;
  15. import io.swagger.annotations.ApiOperation;
  16. import io.swagger.annotations.ApiParam;
  17. import org.slf4j.Logger;
  18. import org.slf4j.LoggerFactory;
  19. import org.springframework.beans.factory.annotation.Autowired;
  20. import org.springframework.web.bind.annotation.*;
  21. import java.util.Date;
  22. import java.util.Optional;
  23. import static cn.com.goldenwater.dcproj.util.CheckUtil.notEmpty;
  24. /**
  25. * @author lune
  26. * @date 2021年4月14日
  27. */
  28. @Api(value = "督查水库登记表-水库检查情况", tags = "督查水库登记表-水库检查情况")
  29. @RestController
  30. @RequestMapping("/bis/insp/rsvryn/chk/info")
  31. public class BisInspRsvrynRgstrChkInfoController extends BaseController {
  32. private Logger logger = LoggerFactory.getLogger(getClass());
  33. @Autowired
  34. private BisInspRsvrynRgstrChkInfoService bisInspRsvrynRgstrChkInfoService;
  35. @Autowired
  36. private BisInspRsvrynRgstrService bisInspRsvrynRgstrService;
  37. @Autowired
  38. private AttRsBaseService attRsBaseService;
  39. @ApiOperation(value = "添加/修改督查水库登记表-水库检查情况-新")
  40. @RequestMapping(value = "", method = RequestMethod.POST)
  41. public BaseResponse<BisInspRsvrynRgstrChkInfo> insert(@ApiParam(name = "bisInspRsvrynRgstrChkInfo", value = "BisInspRsvrynRgstrChkInfo", required = true) @RequestBody BisInspRsvrynRgstrChkInfo bisInspRsvrynRgstrChkInfo) {
  42. String rgstrId = bisInspRsvrynRgstrChkInfo.getRgstrId();
  43. notEmpty(rgstrId, "rgstrId.no");
  44. // 更新登记表
  45. BisInspRsvrynRgstr rgstr = bisInspRsvrynRgstrService.get(rgstrId);
  46. Optional.ofNullable(rgstr).orElseThrow(() -> new CheckException("登记表ID错误,未获取到对应登记表信息"));
  47. if (!Constant.STRING_TWO.equals(rgstr.getState())) {
  48. BisInspRsvrynRgstr bisInspRsvrynRgstr = new BisInspRsvrynRgstr();
  49. bisInspRsvrynRgstr.setRgstrId(rgstrId);
  50. bisInspRsvrynRgstr.setChkInfoStat(bisInspRsvrynRgstrChkInfo.getStatus());
  51. bisInspRsvrynRgstr.setState(Constant.STRING_ONE);
  52. bisInspRsvrynRgstrService.update(bisInspRsvrynRgstr);
  53. }
  54. /*
  55. * if isSite(是否到现场) 1:是 2:否
  56. * 是:
  57. * 督查形式不是必查时,则修改水库基本信息表及登记表的“督查形式”为 抽查
  58. *
  59. * inspType(督查形式) 1:必查 2:抽查
  60. */
  61. if ("1".equals(bisInspRsvrynRgstrChkInfo.getIsSite())) {
  62. AttRsBase attRsBase = attRsBaseService.get(rgstr.getRsCode());
  63. Optional.ofNullable(attRsBase).ifPresent(base -> {
  64. if (!"1".equals(base.getInspType())) {
  65. base.setInspType("2");
  66. attRsBaseService.update(base);
  67. }
  68. });
  69. }
  70. BisInspRsvrynRgstrChkInfo oldChkInfo = bisInspRsvrynRgstrChkInfoService.get(rgstrId);
  71. if (oldChkInfo == null) {
  72. bisInspRsvrynRgstrChkInfo.setId(UuidUtil.uuid());
  73. bisInspRsvrynRgstrChkInfo.setIntm(new Date());
  74. bisInspRsvrynRgstrChkInfo.setUptm(new Date());
  75. bisInspRsvrynRgstrChkInfoService.insert(bisInspRsvrynRgstrChkInfo);
  76. } else {
  77. bisInspRsvrynRgstrChkInfo.setId(oldChkInfo.getId());
  78. bisInspRsvrynRgstrChkInfo.setUptm(new Date());
  79. bisInspRsvrynRgstrChkInfoService.update(bisInspRsvrynRgstrChkInfo);
  80. }
  81. return buildSuccessResponse(bisInspRsvrynRgstrChkInfo);
  82. }
  83. @ApiOperation(value = "根据ID删除督查水库登记表-水库检查情况-新")
  84. @RequestMapping(value = "/del/{id}", method = RequestMethod.GET)
  85. public BaseResponse delete(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
  86. int ret = bisInspRsvrynRgstrChkInfoService.delete(id);
  87. return buildSuccessResponse();
  88. }
  89. @ApiOperation(value = "根据ID获取督查水库登记表-水库检查情况-新(单表)")
  90. @RequestMapping(value = "/{id}", method = RequestMethod.GET)
  91. public BaseResponse<BisInspRsvrynRgstrChkInfo> get(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
  92. BisInspRsvrynRgstrChkInfo bisInspRsvrynRgstrChkInfo = bisInspRsvrynRgstrChkInfoService.get(id);
  93. return buildSuccessResponse(bisInspRsvrynRgstrChkInfo);
  94. }
  95. @ApiOperation(value = "根据ID获取督查水库登记表-水库检查情况-新(单表)")
  96. @RequestMapping(value = "getBy/{rgstrId}", method = RequestMethod.GET)
  97. public BaseResponse<BisInspRsvrynRgstrChkInfo> getBy(@ApiParam(name = "rgstrId", value = "rgstrId", required = true) @PathVariable String rgstrId) {
  98. BisInspRsvrynRgstrChkInfoParam param = new BisInspRsvrynRgstrChkInfoParam();
  99. param.setRgstrId(rgstrId);
  100. BisInspRsvrynRgstrChkInfo bisInspRsvrynRgstrChkInfo = bisInspRsvrynRgstrChkInfoService.getBy(param);
  101. if (bisInspRsvrynRgstrChkInfo == null) {
  102. bisInspRsvrynRgstrChkInfo = new BisInspRsvrynRgstrChkInfo();
  103. bisInspRsvrynRgstrChkInfo.setRgstrId(rgstrId);
  104. BisInspRsvrynRgstr rgstr = bisInspRsvrynRgstrService.get(rgstrId);
  105. Optional.ofNullable(rgstr).orElseThrow(() -> new CheckException("登记表ID错误,未获取到对应登记表信息"));
  106. AttRsBase base = attRsBaseService.get(rgstr.getRsCode());
  107. if (base != null) {
  108. bisInspRsvrynRgstrChkInfo.setInspYear(base.getInspYear());
  109. bisInspRsvrynRgstrChkInfo.setWcEvltOld(base.getWcEvltOld());
  110. }
  111. insert(bisInspRsvrynRgstrChkInfo);
  112. }
  113. return buildSuccessResponse(bisInspRsvrynRgstrChkInfo);
  114. }
  115. }