d51de39613ba572715cb42c363d03190e9cf2c14.svn-base 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. package cn.com.goldenwater.dcproj.controller.samrmp;
  2. import cn.com.goldenwater.core.web.BaseController;
  3. import cn.com.goldenwater.core.web.BaseResponse;
  4. import cn.com.goldenwater.dcproj.model.BisInspSamrmpRgstr;
  5. import cn.com.goldenwater.dcproj.model.BisInspSamrmpRgstrSmrmp;
  6. import cn.com.goldenwater.dcproj.param.BisInspSamrmpRgstrSmrmpParam;
  7. import cn.com.goldenwater.dcproj.service.BisInspSamrmpRgstrService;
  8. import cn.com.goldenwater.dcproj.service.BisInspSamrmpRgstrSmrmpService;
  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.List;
  21. /**
  22. * @author lune
  23. * @date 2020-9-11
  24. */
  25. @Api(value = "BIS 中小河流治理项目抽查情况管理",tags="BIS 中小河流治理项目抽查情况管理")
  26. @RestController
  27. @RequestMapping("/bis/insp/samrmp/rgstr/smrmp")
  28. public class BisInspSamrmpRgstrSmrmpController extends BaseController {
  29. private Logger logger = LoggerFactory.getLogger(getClass());
  30. @Autowired
  31. private BisInspSamrmpRgstrSmrmpService bisInspSamrmpRgstrSmrmpService;
  32. @Autowired
  33. private BisInspSamrmpRgstrService bisInspSamrmpRgstrService;
  34. @ApiOperation(value = "添加/修改中小河流治理项目抽查情况")
  35. @RequestMapping(value = "", method = RequestMethod.POST)
  36. public BaseResponse<BisInspSamrmpRgstrSmrmp> insert(@ApiParam(name = "bisInspSamrmpRgstrSmrmp", value = "BisInspSamrmpRgstrSmrmp", required = true) @RequestBody BisInspSamrmpRgstrSmrmp bisInspSamrmpRgstrSmrmp) {
  37. if(StringUtils.isBlank(bisInspSamrmpRgstrSmrmp.getId())) {
  38. // 生成uuid
  39. String uuid = UuidUtil.uuid();
  40. bisInspSamrmpRgstrSmrmp.setId(uuid);
  41. bisInspSamrmpRgstrSmrmpService.insert(bisInspSamrmpRgstrSmrmp);
  42. }else{
  43. bisInspSamrmpRgstrSmrmpService.update(bisInspSamrmpRgstrSmrmp);
  44. }
  45. if (StringUtils.isNotBlank(bisInspSamrmpRgstrSmrmp.getRgstrId())) {
  46. BisInspSamrmpRgstr rgstr = bisInspSamrmpRgstrService.get(bisInspSamrmpRgstrSmrmp.getRgstrId());
  47. if (rgstr != null) {
  48. rgstr.setSmrmpState(bisInspSamrmpRgstrSmrmp.getStatus());
  49. if (!"2".equals(rgstr.getState())) {
  50. rgstr.setState("1");
  51. }
  52. bisInspSamrmpRgstrService.update(rgstr);
  53. }
  54. }
  55. return buildSuccessResponse(bisInspSamrmpRgstrSmrmp);
  56. }
  57. @ApiOperation(value = "根据ID删除中小河流治理项目抽查情况")
  58. @RequestMapping(value = "/del/{id}", method = RequestMethod.GET)
  59. public BaseResponse delete(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
  60. int ret = bisInspSamrmpRgstrSmrmpService.delete(id);
  61. return buildSuccessResponse();
  62. }
  63. @ApiOperation(value = "根据ID获取中小河流治理项目抽查情况(单表)")
  64. @RequestMapping(value = "/{id}", method = RequestMethod.GET)
  65. public BaseResponse<BisInspSamrmpRgstrSmrmp> get(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
  66. BisInspSamrmpRgstrSmrmp bisInspSamrmpRgstrSmrmp = bisInspSamrmpRgstrSmrmpService.get(id);
  67. return buildSuccessResponse(bisInspSamrmpRgstrSmrmp);
  68. }
  69. @ApiOperation(value = "获取中小河流治理项目抽查情况(列表所有)")
  70. @RequestMapping(value = "/list", method = RequestMethod.POST)
  71. public BaseResponse<List<BisInspSamrmpRgstrSmrmp>> list(@ApiParam(name = "bisInspSamrmpRgstrSmrmpParam", value = "bisInspSamrmpRgstrSmrmpParam", required = true) @RequestBody BisInspSamrmpRgstrSmrmpParam bisInspSamrmpRgstrSmrmpParam) {
  72. List<BisInspSamrmpRgstrSmrmp> bisInspSamrmpRgstrSmrmpList = bisInspSamrmpRgstrSmrmpService.findList(bisInspSamrmpRgstrSmrmpParam);
  73. return buildSuccessResponse(bisInspSamrmpRgstrSmrmpList);
  74. }
  75. @ApiOperation(value = "获取中小河流治理项目抽查情况(列表--分页)")
  76. @RequestMapping(value = "/page", method = RequestMethod.POST)
  77. public BaseResponse<PageInfo<BisInspSamrmpRgstrSmrmp>> page(@ApiParam(name = "bisInspSamrmpRgstrSmrmpParam", value = "bisInspSamrmpRgstrSmrmpParam", required = true) @RequestBody BisInspSamrmpRgstrSmrmpParam bisInspSamrmpRgstrSmrmpParam) {
  78. PageInfo<BisInspSamrmpRgstrSmrmp> bisInspSamrmpRgstrSmrmpList = bisInspSamrmpRgstrSmrmpService.findPageInfo(bisInspSamrmpRgstrSmrmpParam);
  79. return buildSuccessResponse(bisInspSamrmpRgstrSmrmpList);
  80. }
  81. @ApiOperation(value = "根据登记表id获取取水单位用水情况")
  82. @RequestMapping(value = "/getBy/{rgstrId}", method = RequestMethod.GET)
  83. public BaseResponse<BisInspSamrmpRgstrSmrmp> getBy(@ApiParam(name = "rgstrId", value = "rgstrId", required = true) @PathVariable String rgstrId, HttpServletRequest request) {
  84. if(StringUtils.isBlank(rgstrId)) {
  85. return buildFailResponse();
  86. }
  87. BisInspSamrmpRgstrSmrmpParam param = new BisInspSamrmpRgstrSmrmpParam();
  88. param.setRgstrId(rgstrId);
  89. BisInspSamrmpRgstrSmrmp info = this.bisInspSamrmpRgstrSmrmpService.getBy(param);
  90. return buildSuccessResponse(info);
  91. }
  92. }