14c7842f0177f97eb14b88399e96552a5c1ade16.svn-base 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. package cn.com.goldenwater.dcproj.controller.rsvr;
  2. import cn.com.goldenwater.core.web.BaseController;
  3. import cn.com.goldenwater.core.web.BaseResponse;
  4. import cn.com.goldenwater.dcproj.model.BisInspSafeExtApp;
  5. import cn.com.goldenwater.dcproj.model.BisInspSafeExtManage;
  6. import cn.com.goldenwater.dcproj.param.BisInspSafeExtManageParam;
  7. import cn.com.goldenwater.dcproj.service.BisInspRsvrRgstrService;
  8. import cn.com.goldenwater.dcproj.service.BisInspSafeExtManageService;
  9. import cn.com.goldenwater.dcproj.utils.Builder;
  10. import cn.com.goldenwater.id.util.UuidUtil;
  11. import io.swagger.annotations.Api;
  12. import io.swagger.annotations.ApiOperation;
  13. import io.swagger.annotations.ApiParam;
  14. import org.apache.commons.lang3.StringUtils;
  15. import org.slf4j.Logger;
  16. import org.slf4j.LoggerFactory;
  17. import org.springframework.beans.factory.annotation.Autowired;
  18. import org.springframework.web.bind.annotation.*;
  19. import java.util.Date;
  20. /**
  21. * @author lune
  22. * @date 2019-2-18
  23. */
  24. @Api(value = "APP 水库安全运行管理情况", tags = "APP 水库安全运行管理情况")
  25. @RestController
  26. @RequestMapping("/dc/insp/safeExtManage")
  27. public class BisInspSafeExtManageController extends BaseController {
  28. private Logger logger = LoggerFactory.getLogger(getClass());
  29. @Autowired
  30. private BisInspSafeExtManageService bisInspSafeExtManageService;
  31. @Autowired
  32. private BisInspRsvrRgstrService bisInspRsvrRgstrService;
  33. @ApiOperation(value = "添加安全运行管理")
  34. @RequestMapping(value = "", method = RequestMethod.POST)
  35. public BaseResponse<BisInspSafeExtManage> insert(@ApiParam(name = "bisInspSafeExtManage", value = "BisInspSafeExtManage", required = true) @RequestBody BisInspSafeExtManage bisInspSafeExtManage) {
  36. BisInspSafeExtManage safeExtManage = bisInspSafeExtManageService.getBy(Builder
  37. .of(BisInspSafeExtManageParam::new)
  38. .with(BisInspSafeExtManageParam::setRgstrId, bisInspSafeExtManage.getRgstrId())
  39. .build()
  40. );
  41. if (safeExtManage == null) {
  42. bisInspSafeExtManageService.insert(bisInspSafeExtManage);
  43. } else {
  44. bisInspSafeExtManageService.update(bisInspSafeExtManage);
  45. }
  46. bisInspRsvrRgstrService.updateRsvr(bisInspSafeExtManage.getRgstrId(), bisInspSafeExtManage.getStatus(), "safe");
  47. return buildSuccessResponse(bisInspSafeExtManage);
  48. }
  49. @ApiOperation(value = "添加安全运行管理")
  50. @RequestMapping(value = "/insert", method = RequestMethod.POST)
  51. public BaseResponse<BisInspSafeExtManage> insertDam(@ApiParam(name = "bisInspSafeExtManage", value = "BisInspSafeExtManage", required = true) @RequestBody BisInspSafeExtManage bisInspSafeExtManage) {
  52. bisInspSafeExtManage.setUpdateTime(new Date());
  53. BisInspSafeExtManageParam safeExtManageParam = new BisInspSafeExtManageParam();
  54. safeExtManageParam.setRgstrId(bisInspSafeExtManage.getRgstrId());
  55. BisInspSafeExtManage safeExtManage = bisInspSafeExtManageService.getBy(safeExtManageParam);
  56. if (safeExtManage == null) {
  57. String uuid = UuidUtil.uuid();
  58. bisInspSafeExtManage.setMngrnId(uuid);
  59. bisInspSafeExtManage.setCreateTime(new Date());
  60. bisInspSafeExtManageService.insert(bisInspSafeExtManage);
  61. } else {
  62. bisInspSafeExtManage.setMngrnId(safeExtManage.getMngrnId());
  63. bisInspSafeExtManageService.update(bisInspSafeExtManage);
  64. }
  65. bisInspRsvrRgstrService.updateRsvr(bisInspSafeExtManage.getRgstrId(), bisInspSafeExtManage.getStatus(), "dam");
  66. return buildSuccessResponse(bisInspSafeExtManage);
  67. }
  68. @ApiOperation(value = "根据ID删除安全运行管理")
  69. @RequestMapping(value = "/delete/{id}", method = RequestMethod.GET)
  70. public BaseResponse delete(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
  71. int ret = bisInspSafeExtManageService.delete(id);
  72. return buildSuccessResponse();
  73. }
  74. @ApiOperation(value = "根据督查登记表获取安全运行管理信息")
  75. @RequestMapping(value = "/get/{rgstrId}", method = RequestMethod.GET)
  76. public BaseResponse<BisInspSafeExtManage> getByRgstrId(@ApiParam(name = "rgstrId", value = "rgstrId", required = true) @PathVariable String rgstrId) {
  77. BisInspSafeExtManageParam safeExtManageParam = new BisInspSafeExtManageParam();
  78. safeExtManageParam.setRgstrId(rgstrId);
  79. BisInspSafeExtManage bisInspSafeExtManage = bisInspSafeExtManageService.getBy(safeExtManageParam);
  80. return buildSuccessResponse(bisInspSafeExtManage);
  81. }
  82. @ApiOperation(value = "根据安全运行管理id获取精简版数据,手机专用接口")
  83. @RequestMapping(value = "/getApp/{id}", method = RequestMethod.GET)
  84. public BaseResponse<BisInspSafeExtApp> getApp(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
  85. BisInspSafeExtApp bisInspSafeExtManage = bisInspSafeExtManageService.getApp(id);
  86. return buildSuccessResponse(bisInspSafeExtManage);
  87. }
  88. @ApiOperation(value = "更新安全运行管理信息")
  89. @RequestMapping(value = "/update", method = RequestMethod.POST)
  90. public BaseResponse update(@ApiParam(name = "bisInspSafeExtManage", value = "BisInspSafeExtManage", required = true) @RequestBody BisInspSafeExtManage bisInspSafeExtManage) {
  91. bisInspSafeExtManage.setUpdateTime(new Date());
  92. if (StringUtils.isBlank(bisInspSafeExtManage.getMngrnId())) {
  93. if (StringUtils.isNotBlank(bisInspSafeExtManage.getRgstrId())) {
  94. BisInspSafeExtManageParam safeExtManageParam = new BisInspSafeExtManageParam();
  95. safeExtManageParam.setRgstrId(bisInspSafeExtManage.getRgstrId());
  96. BisInspSafeExtManage bisInspSafeExtManageReg = bisInspSafeExtManageService.getBy(safeExtManageParam);
  97. if (bisInspSafeExtManageReg != null) {
  98. bisInspSafeExtManageReg.setMngrnId(bisInspSafeExtManageReg.getMngrnId());
  99. }
  100. }
  101. }
  102. int ret = bisInspSafeExtManageService.update(bisInspSafeExtManage);
  103. bisInspRsvrRgstrService.updateRsvr(bisInspSafeExtManage.getRgstrId(), bisInspSafeExtManage.getStatus(), "safe");
  104. return buildSuccessResponse(bisInspSafeExtManage);
  105. }
  106. @ApiOperation(value = "根据ID获取安全运行管理(单表)")
  107. @RequestMapping(value = "/{id}", method = RequestMethod.GET)
  108. public BaseResponse<BisInspSafeExtManage> get(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
  109. BisInspSafeExtManage bisInspSafeExtManage = bisInspSafeExtManageService.get(id);
  110. return buildSuccessResponse(bisInspSafeExtManage);
  111. }
  112. }