5873ac2180d8f60743ea2a6f0afa7f1d878c5f0e.svn-base 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. package cn.com.goldenwater.dcproj.controller.rsvr;
  2. import cn.com.goldenwater.dcproj.model.BisInspRsvrProject;
  3. import cn.com.goldenwater.dcproj.param.BisInspRsvrProjectParam;
  4. import cn.com.goldenwater.dcproj.service.BisInspRsvrProjectService;
  5. import cn.com.goldenwater.core.web.BaseController;
  6. import cn.com.goldenwater.core.web.BaseResponse;
  7. import cn.com.goldenwater.dcproj.service.BisInspRsvrRgstrService;
  8. import cn.com.goldenwater.id.util.UuidUtil;
  9. import io.swagger.annotations.Api;
  10. import io.swagger.annotations.ApiOperation;
  11. import io.swagger.annotations.ApiParam;
  12. import org.apache.commons.lang3.StringUtils;
  13. import org.slf4j.Logger;
  14. import org.slf4j.LoggerFactory;
  15. import org.springframework.beans.factory.annotation.Autowired;
  16. import org.springframework.util.Assert;
  17. import org.springframework.web.bind.annotation.PathVariable;
  18. import org.springframework.web.bind.annotation.RequestBody;
  19. import org.springframework.web.bind.annotation.RequestMapping;
  20. import org.springframework.web.bind.annotation.RequestMethod;
  21. import org.springframework.web.bind.annotation.RestController;
  22. import java.util.Date;
  23. import java.util.List;
  24. /**
  25. * @author lune
  26. * @date 2019-5-9
  27. */
  28. @Api(value = "APP 水库工程实体管理", tags = "APP 水库工程实体管理")
  29. @RestController
  30. @RequestMapping("/dc/rever/project")
  31. public class BisInspRsvrProjectController extends BaseController {
  32. private Logger logger = LoggerFactory.getLogger(getClass());
  33. @Autowired
  34. private BisInspRsvrProjectService bisInspRsvrProjectService;
  35. @Autowired
  36. private BisInspRsvrRgstrService bisInspRsvrRgstrService;
  37. @ApiOperation(value = "水库工程实体管理")
  38. @RequestMapping(value = "", method = RequestMethod.POST)
  39. public BaseResponse insert(@ApiParam(name = "bisInspRsvrProject", value = "BisInspRsvrProject", required = true) @RequestBody BisInspRsvrProject bisInspRsvrProject) {
  40. //登记表不能为空判断
  41. if(StringUtils.isBlank(bisInspRsvrProject.getRgstrId())){
  42. return buildFailResponse(30001,"登记表ID不能为空");
  43. }
  44. bisInspRsvrProject.setCreateTime(new Date());
  45. if (StringUtils.isNotBlank(bisInspRsvrProject.getId())) {
  46. bisInspRsvrProject.setUpdateTime(new Date());
  47. bisInspRsvrProjectService.update(bisInspRsvrProject);
  48. } else {
  49. BisInspRsvrProjectParam benefitsParam = new BisInspRsvrProjectParam();
  50. benefitsParam.setRgstrId(bisInspRsvrProject.getRgstrId());
  51. List<BisInspRsvrProject> list = bisInspRsvrProjectService.findList(benefitsParam);
  52. if (list.size()>0) {
  53. bisInspRsvrProject.setId(list.get(0).getId());
  54. bisInspRsvrProject.setUpdateTime(new Date());
  55. bisInspRsvrProjectService.update(bisInspRsvrProject);
  56. } else {
  57. String uuid = UuidUtil.uuid();
  58. bisInspRsvrProject.setId(uuid);
  59. bisInspRsvrProjectService.insert(bisInspRsvrProject);
  60. }
  61. }
  62. bisInspRsvrRgstrService.updateRsvr(bisInspRsvrProject.getRgstrId(), bisInspRsvrProject.getStatus(), "project");
  63. return buildSuccessResponse(bisInspRsvrProject);
  64. }
  65. @ApiOperation(value = "水库安全鉴定及除险加固情况")
  66. @RequestMapping(value = "/insert", method = RequestMethod.POST)
  67. public BaseResponse<BisInspRsvrProject> insertRein(@ApiParam(name = "bisInspRsvrProject", value = "BisInspRsvrProject", required = true) @RequestBody BisInspRsvrProject bisInspRsvrProject) {
  68. if (StringUtils.isNotBlank(bisInspRsvrProject.getId())) {
  69. bisInspRsvrProject.setUpdateTime(new Date());
  70. if ("2".equals(bisInspRsvrProject.getIfDamSafe())) {
  71. bisInspRsvrProject.setIfDamSafeReq("");
  72. bisInspRsvrProject.setIfDamSafeRul("");
  73. bisInspRsvrProject.setIfDamSafeDepRul("");
  74. bisInspRsvrProject.setIfDamSafeThr("");
  75. int a = bisInspRsvrProjectService.updateProject(bisInspRsvrProject);
  76. }
  77. if ("2".equals(bisInspRsvrProject.getIfDamSafeReq() )) {
  78. bisInspRsvrProject.setIfDamSafeRul("");
  79. bisInspRsvrProject.setIfDamSafeDepRul("");
  80. bisInspRsvrProject.setIfDamSafeThr("");
  81. int a = bisInspRsvrProjectService.updateProject(bisInspRsvrProject);
  82. } else {
  83. bisInspRsvrProjectService.update(bisInspRsvrProject);
  84. }
  85. } else {
  86. if(StringUtils.isNotBlank(bisInspRsvrProject.getRgstrId())){
  87. BisInspRsvrProjectParam rsvrProjectParam=new BisInspRsvrProjectParam();
  88. rsvrProjectParam.setRgstrId(bisInspRsvrProject.getRgstrId());
  89. BisInspRsvrProject inspRsvrProject=bisInspRsvrProjectService.getBy(rsvrProjectParam);
  90. if(inspRsvrProject!=null){
  91. bisInspRsvrProjectService.update(bisInspRsvrProject);
  92. }else{
  93. bisInspRsvrProject.setId(UuidUtil.uuid());
  94. bisInspRsvrProjectService.insert(bisInspRsvrProject);
  95. }
  96. }else {
  97. bisInspRsvrProject.setCreateTime(new Date());
  98. String uuid = UuidUtil.uuid();
  99. bisInspRsvrProject.setId(uuid);
  100. bisInspRsvrProjectService.insert(bisInspRsvrProject);
  101. }
  102. }
  103. bisInspRsvrRgstrService.updateRsvr(bisInspRsvrProject.getRgstrId(), bisInspRsvrProject.getStatus(), "rein");
  104. return buildSuccessResponse(bisInspRsvrProject);
  105. }
  106. @ApiOperation(value = "更新水库工程实体管理信息")
  107. @RequestMapping(value = "/update", method = RequestMethod.POST)
  108. public BaseResponse update(@ApiParam(name = "bisInspRsvrProject", value = "BisInspRsvrProject", required = true) @RequestBody BisInspRsvrProject bisInspRsvrProject) {
  109. Assert.notNull(bisInspRsvrProject.getId(), "主键id为必填参数");
  110. int ret = bisInspRsvrProjectService.update(bisInspRsvrProject);
  111. return buildSuccessResponse();
  112. }
  113. @ApiOperation(value = "根据工程实体主键ID获取水库工程实体(单表)")
  114. @RequestMapping(value = "/{id}", method = RequestMethod.GET)
  115. public BaseResponse<BisInspRsvrProject> get(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
  116. BisInspRsvrProject bisInspRsvrProject = bisInspRsvrProjectService.get(id);
  117. return buildSuccessResponse(bisInspRsvrProject);
  118. }
  119. @ApiOperation(value = "根据督查表主键主键ID获取水库工程实体(单表)")
  120. @RequestMapping(value = "/getBy/{rgstrId}", method = RequestMethod.GET)
  121. public BaseResponse<BisInspRsvrProject> getBy(@ApiParam(name = "rgstrId", value = "rgstrId", required = true) @PathVariable String rgstrId) {
  122. BisInspRsvrProjectParam rsvrProjectParam = new BisInspRsvrProjectParam();
  123. rsvrProjectParam.setRgstrId(rgstrId);
  124. BisInspRsvrProject bisInspRsvrProject = bisInspRsvrProjectService.getBy(rsvrProjectParam);
  125. return buildSuccessResponse(bisInspRsvrProject);
  126. }
  127. }