e91ebe717b0f753f7ee6bba45949ba8f63b73653.svn-base 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. package cn.com.goldenwater.dcproj.controller.rsfco;
  2. import cn.com.goldenwater.core.web.BaseController;
  3. import cn.com.goldenwater.core.web.BaseResponse;
  4. import cn.com.goldenwater.dcproj.model.BisInspRsfcoRgstr;
  5. import cn.com.goldenwater.dcproj.model.BisInspRsfcoRgstrBase;
  6. import cn.com.goldenwater.dcproj.param.BisInspRsfcoRgstrBaseParam;
  7. import cn.com.goldenwater.dcproj.service.BisInspRsfcoRgstrBaseService;
  8. import cn.com.goldenwater.dcproj.service.BisInspRsfcoRgstrService;
  9. import cn.com.goldenwater.id.util.UuidUtil;
  10. import com.github.pagehelper.PageInfo;
  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 javax.servlet.http.HttpServletRequest;
  20. import java.util.Date;
  21. import java.util.List;
  22. /**
  23. * @author lune
  24. * @date 2020-4-22
  25. */
  26. @Api(value = "BIS 水库防洪调度总体情况管理",tags="BIS 水库防洪调度总体情况管理")
  27. @RestController
  28. @RequestMapping("/bis/insp/rsfco/rgstr/base")
  29. public class BisInspRsfcoRgstrBaseController extends BaseController {
  30. private Logger logger = LoggerFactory.getLogger(getClass());
  31. @Autowired
  32. private BisInspRsfcoRgstrBaseService bisInspRsfcoRgstrBaseService;
  33. @Autowired
  34. private BisInspRsfcoRgstrService bisInspRsfcoRgstrService;
  35. @ApiOperation(value = "添加/修改水库防洪调度总体情况")
  36. @RequestMapping(value = "", method = RequestMethod.POST)
  37. public BaseResponse<BisInspRsfcoRgstrBase> insert(@ApiParam(name = "bisInspRsfcoRgstrBase", value = "BisInspRsfcoRgstrBase", required = true) @RequestBody BisInspRsfcoRgstrBase bisInspRsfcoRgstrBase) {
  38. Date date = new Date();
  39. bisInspRsfcoRgstrBase.setUptm(date);
  40. if(StringUtils.isBlank(bisInspRsfcoRgstrBase.getId())) {
  41. BisInspRsfcoRgstrBaseParam baseParam = new BisInspRsfcoRgstrBaseParam();
  42. baseParam.setRgstrId(bisInspRsfcoRgstrBase.getRgstrId());
  43. List<BisInspRsfcoRgstrBase> baseList = bisInspRsfcoRgstrBaseService.findList(baseParam);
  44. if (baseList != null && !baseList.isEmpty()) {
  45. bisInspRsfcoRgstrBase.setId(baseList.get(0).getId());
  46. bisInspRsfcoRgstrBaseService.update(bisInspRsfcoRgstrBase);
  47. } else {
  48. String uuid = UuidUtil.uuid(); // 生成uuid
  49. bisInspRsfcoRgstrBase.setId(uuid);
  50. bisInspRsfcoRgstrBase.setIntm(date);
  51. bisInspRsfcoRgstrBaseService.insert(bisInspRsfcoRgstrBase);
  52. }
  53. }else{
  54. bisInspRsfcoRgstrBaseService.update(bisInspRsfcoRgstrBase);
  55. }
  56. if (StringUtils.isNotBlank(bisInspRsfcoRgstrBase.getRgstrId())) {
  57. BisInspRsfcoRgstr rgstr = bisInspRsfcoRgstrService.get(bisInspRsfcoRgstrBase.getRgstrId());
  58. if (rgstr != null){
  59. rgstr.setPresState(bisInspRsfcoRgstrBase.getStatus());
  60. if (!"2".equals(rgstr.getState())) {
  61. rgstr.setState("1");
  62. }
  63. bisInspRsfcoRgstrService.update(rgstr);
  64. }
  65. }
  66. return buildSuccessResponse(bisInspRsfcoRgstrBase);
  67. }
  68. @ApiOperation(value = "根据ID删除水库防洪调度总体情况")
  69. @RequestMapping(value = "/del/{id}", method = RequestMethod.GET)
  70. public BaseResponse delete(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
  71. int ret = bisInspRsfcoRgstrBaseService.delete(id);
  72. return buildSuccessResponse();
  73. }
  74. @ApiOperation(value = "根据ID获取水库防洪调度总体情况(单表)")
  75. @RequestMapping(value = "/{id}", method = RequestMethod.GET)
  76. public BaseResponse<BisInspRsfcoRgstrBase> get(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
  77. BisInspRsfcoRgstrBase bisInspRsfcoRgstrBase = bisInspRsfcoRgstrBaseService.get(id);
  78. return buildSuccessResponse(bisInspRsfcoRgstrBase);
  79. }
  80. @ApiOperation(value = "获取水库防洪调度总体情况(列表所有)")
  81. @RequestMapping(value = "/list", method = RequestMethod.POST)
  82. public BaseResponse<List<BisInspRsfcoRgstrBase>> list(@ApiParam(name = "bisInspRsfcoRgstrBaseParam", value = "bisInspRsfcoRgstrBaseParam", required = true) @RequestBody BisInspRsfcoRgstrBaseParam bisInspRsfcoRgstrBaseParam) {
  83. List<BisInspRsfcoRgstrBase> bisInspRsfcoRgstrBaseList = bisInspRsfcoRgstrBaseService.findList(bisInspRsfcoRgstrBaseParam);
  84. return buildSuccessResponse(bisInspRsfcoRgstrBaseList);
  85. }
  86. @ApiOperation(value = "获取水库防洪调度总体情况(列表--分页)")
  87. @RequestMapping(value = "/page", method = RequestMethod.POST)
  88. public BaseResponse<PageInfo<BisInspRsfcoRgstrBase>> page(@ApiParam(name = "bisInspRsfcoRgstrBaseParam", value = "bisInspRsfcoRgstrBaseParam", required = true) @RequestBody BisInspRsfcoRgstrBaseParam bisInspRsfcoRgstrBaseParam) {
  89. PageInfo<BisInspRsfcoRgstrBase> bisInspRsfcoRgstrBaseList = bisInspRsfcoRgstrBaseService.findPageInfo(bisInspRsfcoRgstrBaseParam);
  90. return buildSuccessResponse(bisInspRsfcoRgstrBaseList);
  91. }
  92. @ApiOperation(value = "根据登记表id获获取取水许可审批监管情况")
  93. @RequestMapping(value = "/getBy/{rgstrId}", method = RequestMethod.GET)
  94. public BaseResponse<BisInspRsfcoRgstrBase> getBy(@ApiParam(name = "rgstrId", value = "rgstrId", required = true) @PathVariable String rgstrId, HttpServletRequest request) {
  95. if(StringUtils.isBlank(rgstrId)) {
  96. return buildFailResponse();
  97. }
  98. BisInspRsfcoRgstrBaseParam param = new BisInspRsfcoRgstrBaseParam();
  99. param.setRgstrId(rgstrId);
  100. BisInspRsfcoRgstrBase info = this.bisInspRsfcoRgstrBaseService.getBy(param);
  101. return buildSuccessResponse(info);
  102. }
  103. }