556a01050829e96402473d7a2bafc790c1fe7895.svn-base 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. package cn.com.goldenwater.dcproj.controller.swhs;
  2. import cn.com.goldenwater.dcproj.model.BisInspSwhsRgstr;
  3. import cn.com.goldenwater.dcproj.model.BisInspSwhsRgstrMeasures;
  4. import cn.com.goldenwater.dcproj.param.BisInspSwhsRgstrMeasuresParam;
  5. import cn.com.goldenwater.dcproj.service.BisInspSwhsRgstrMeasuresService;
  6. import cn.com.goldenwater.core.web.BaseController;
  7. import cn.com.goldenwater.core.web.BaseResponse;
  8. import cn.com.goldenwater.dcproj.service.BisInspSwhsRgstrService;
  9. import cn.com.goldenwater.id.util.UuidUtil;
  10. import io.swagger.annotations.Api;
  11. import io.swagger.annotations.ApiOperation;
  12. import io.swagger.annotations.ApiParam;
  13. import org.apache.commons.lang3.StringUtils;
  14. import com.github.pagehelper.PageInfo;
  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.PathVariable;
  19. import org.springframework.web.bind.annotation.RequestBody;
  20. import org.springframework.web.bind.annotation.RequestMapping;
  21. import org.springframework.web.bind.annotation.RequestMethod;
  22. import org.springframework.web.bind.annotation.RestController;
  23. import javax.servlet.http.HttpServletRequest;
  24. import java.util.Date;
  25. import java.util.List;
  26. /**
  27. * @author lune
  28. * @date 2019-8-7
  29. */
  30. @Api(value = "BIS 重要饮用水水源管理情况检查表管理",tags="BIS 重要饮用水水源管理情况检查表管理")
  31. @RestController
  32. @RequestMapping("/bis/insp/swhs/rgstr/measures")
  33. public class BisInspSwhsRgstrMeasuresController extends BaseController {
  34. private Logger logger = LoggerFactory.getLogger(getClass());
  35. @Autowired
  36. private BisInspSwhsRgstrMeasuresService bisInspSwhsRgstrMeasuresService;
  37. @Autowired
  38. private BisInspSwhsRgstrService swhsRgstrService;
  39. @ApiOperation(value = "添加/修改保护措施监管情况")
  40. @RequestMapping(value = "", method = RequestMethod.POST)
  41. public BaseResponse<BisInspSwhsRgstrMeasures> insert(@ApiParam(name = "bisInspSwhsRgstrMeasures", value = "BisInspSwhsRgstrMeasures", required = true) @RequestBody BisInspSwhsRgstrMeasures bisInspSwhsRgstrMeasures) {
  42. if(StringUtils.isBlank(bisInspSwhsRgstrMeasures.getId())) {
  43. BisInspSwhsRgstrMeasuresParam param = new BisInspSwhsRgstrMeasuresParam();
  44. param.setRgstrId(bisInspSwhsRgstrMeasures.getRgstrId());
  45. List<BisInspSwhsRgstrMeasures> list = bisInspSwhsRgstrMeasuresService.findList(param);
  46. if (list.size() > 0 ){
  47. return buildFailResponse();
  48. }
  49. bisInspSwhsRgstrMeasures.setInTm(new Date());
  50. bisInspSwhsRgstrMeasures.setUpTm(new Date());
  51. String uuid = UuidUtil.uuid(); // 生成uuid
  52. bisInspSwhsRgstrMeasures.setId(uuid);
  53. bisInspSwhsRgstrMeasuresService.insert(bisInspSwhsRgstrMeasures);
  54. }else{
  55. bisInspSwhsRgstrMeasures.setUpTm(new Date());
  56. bisInspSwhsRgstrMeasuresService.update(bisInspSwhsRgstrMeasures);
  57. }
  58. if (StringUtils.isNotBlank(bisInspSwhsRgstrMeasures.getRgstrId())) {
  59. BisInspSwhsRgstr rgstr = swhsRgstrService.get(bisInspSwhsRgstrMeasures.getRgstrId());
  60. if (rgstr != null) {
  61. rgstr.setMeasuresStat(bisInspSwhsRgstrMeasures.getDataStat());
  62. if (!"2".equals(rgstr.getState())) {
  63. rgstr.setState("1");
  64. }
  65. swhsRgstrService.update(rgstr);
  66. }
  67. }
  68. return buildSuccessResponse(bisInspSwhsRgstrMeasures);
  69. }
  70. @ApiOperation(value = "根据ID删除保护措施监管情况")
  71. @RequestMapping(value = "/del/{id}", method = RequestMethod.GET)
  72. public BaseResponse delete(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
  73. int ret = bisInspSwhsRgstrMeasuresService.delete(id);
  74. return buildSuccessResponse();
  75. }
  76. @ApiOperation(value = "根据ID获取保护措施监管情况(单表)")
  77. @RequestMapping(value = "/{id}", method = RequestMethod.GET)
  78. public BaseResponse<BisInspSwhsRgstrMeasures> get(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
  79. BisInspSwhsRgstrMeasures bisInspSwhsRgstrMeasures = bisInspSwhsRgstrMeasuresService.get(id);
  80. return buildSuccessResponse(bisInspSwhsRgstrMeasures);
  81. }
  82. @ApiOperation(value = "获取保护措施监管情况(列表所有)")
  83. @RequestMapping(value = "/list", method = RequestMethod.POST)
  84. public BaseResponse<List<BisInspSwhsRgstrMeasures>> list(@ApiParam(name = "bisInspSwhsRgstrMeasuresParam", value = "bisInspSwhsRgstrMeasuresParam", required = true) @RequestBody BisInspSwhsRgstrMeasuresParam bisInspSwhsRgstrMeasuresParam) {
  85. List<BisInspSwhsRgstrMeasures> bisInspSwhsRgstrMeasuresList = bisInspSwhsRgstrMeasuresService.findList(bisInspSwhsRgstrMeasuresParam);
  86. return buildSuccessResponse(bisInspSwhsRgstrMeasuresList);
  87. }
  88. @ApiOperation(value = "获取保护措施监管情况(列表--分页)")
  89. @RequestMapping(value = "/page", method = RequestMethod.POST)
  90. public BaseResponse<PageInfo<BisInspSwhsRgstrMeasures>> page(@ApiParam(name = "bisInspSwhsRgstrMeasuresParam", value = "bisInspSwhsRgstrMeasuresParam", required = true) @RequestBody BisInspSwhsRgstrMeasuresParam bisInspSwhsRgstrMeasuresParam) {
  91. PageInfo<BisInspSwhsRgstrMeasures> bisInspSwhsRgstrMeasuresList = bisInspSwhsRgstrMeasuresService.findPageInfo(bisInspSwhsRgstrMeasuresParam);
  92. return buildSuccessResponse(bisInspSwhsRgstrMeasuresList);
  93. }
  94. @ApiOperation(value = "根据注册表id获取安全保证信息")
  95. @RequestMapping(value = "/getBy/{rgstrId}", method = RequestMethod.GET)
  96. public BaseResponse<BisInspSwhsRgstrMeasures> getBy(@ApiParam(name = "rgstrId", value = "rgstrId", required = true) @PathVariable String rgstrId,HttpServletRequest request) {
  97. if (StringUtils.isBlank(rgstrId)) {
  98. return buildFailResponse();
  99. }
  100. BisInspSwhsRgstrMeasuresParam param = new BisInspSwhsRgstrMeasuresParam();
  101. param.setRgstrId(rgstrId);
  102. BisInspSwhsRgstrMeasures swhsRgstrSafety = this.bisInspSwhsRgstrMeasuresService.getBy(param);
  103. return buildSuccessResponse(swhsRgstrSafety);
  104. }
  105. @ApiOperation(value = "根据数据库中请求log数据进行恢复数据")
  106. @RequestMapping(value = "/reData", method = RequestMethod.GET)
  107. public BaseResponse<String> reData() {
  108. boolean a = bisInspSwhsRgstrMeasuresService.reData();
  109. return buildSuccessResponse("恢复成功!");
  110. }
  111. }