7e72037043349c771402a6c564e8c61aff092d18.svn-base 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. package cn.com.goldenwater.dcproj.controller.waga;
  2. import cn.com.goldenwater.core.web.BaseController;
  3. import cn.com.goldenwater.core.web.BaseResponse;
  4. import cn.com.goldenwater.dcproj.model.AttWagaRgstr;
  5. import cn.com.goldenwater.dcproj.model.BisInspWagaBase;
  6. import cn.com.goldenwater.dcproj.param.BisInspWagaBaseParam;
  7. import cn.com.goldenwater.dcproj.service.AttWagaRgstrService;
  8. import cn.com.goldenwater.dcproj.service.BisInspWagaBaseService;
  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 java.util.Date;
  20. import java.util.List;
  21. /**
  22. * @author lune
  23. * @date 2020-4-15
  24. */
  25. @Api(value = "BIS 水闸督查基本情况管理", tags = "BIS 水闸督查基本情况管理")
  26. @RestController
  27. @RequestMapping("/bis/insp/waga/base")
  28. public class BisInspWagaBaseController extends BaseController {
  29. private Logger logger = LoggerFactory.getLogger(getClass());
  30. @Autowired
  31. private BisInspWagaBaseService bisInspWagaBaseService;
  32. @Autowired
  33. private AttWagaRgstrService attWagaRgstrService;
  34. @ApiOperation(value = "添加/修改水闸督查基本情况")
  35. @RequestMapping(value = "", method = RequestMethod.POST)
  36. public BaseResponse<BisInspWagaBase> insert(
  37. @ApiParam(name = "bisInspWagaBase", value = "BisInspWagaBase", required = true)
  38. @RequestBody BisInspWagaBase bisInspWagaBase) {
  39. Date date = new Date();
  40. if (StringUtils.isNotBlank(bisInspWagaBase.getRgstrId())) {
  41. bisInspWagaBase.setRecPersId(getCurrentPersId());
  42. String oeseStat = attWagaRgstrService.getOeseState(bisInspWagaBase);
  43. bisInspWagaBase.setOeseInfo(oeseStat);
  44. }
  45. // 判断水闸督查基本情况 是否存在
  46. BisInspWagaBase biwb = new BisInspWagaBase();
  47. biwb.setRgstrId(bisInspWagaBase.getRgstrId());
  48. List<BisInspWagaBase> bisInspWagaBaseList = bisInspWagaBaseService.getBy(biwb);
  49. // 不存在: 新建
  50. if (null == bisInspWagaBaseList || bisInspWagaBaseList.size() == 0) {
  51. // 生成uuid
  52. String uuid = UuidUtil.uuid();
  53. bisInspWagaBase.setId(uuid);
  54. bisInspWagaBase.setIntm(date);
  55. bisInspWagaBase.setUptm(date);
  56. bisInspWagaBaseService.insert(bisInspWagaBase);
  57. } else {
  58. // 存在: 更新时间
  59. bisInspWagaBase.setUptm(date);
  60. bisInspWagaBaseService.update(bisInspWagaBase);
  61. }
  62. attWagaRgstrService.addState(bisInspWagaBase.getRgstrId(), bisInspWagaBase.getDataStat(), "base");
  63. return buildSuccessResponse(bisInspWagaBase);
  64. }
  65. @ApiOperation(value = "根据ID删除水闸督查基本情况")
  66. @RequestMapping(value = "/del/{id}", method = RequestMethod.GET)
  67. public BaseResponse delete(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
  68. int ret = bisInspWagaBaseService.delete(id);
  69. return buildSuccessResponse();
  70. }
  71. @ApiOperation(value = "根据ID获取水闸督查基本情况(单表)")
  72. @RequestMapping(value = "/{id}", method = RequestMethod.GET)
  73. public BaseResponse<BisInspWagaBase> get(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
  74. BisInspWagaBase biwb = new BisInspWagaBase();
  75. biwb.setRgstrId(id);
  76. List<BisInspWagaBase> bisInspWagaBase = bisInspWagaBaseService.getBy(biwb);
  77. return buildSuccessResponse(bisInspWagaBase.get(0));
  78. }
  79. @ApiOperation(value = "获取水闸督查基本情况(列表所有)")
  80. @RequestMapping(value = "/list", method = RequestMethod.POST)
  81. public BaseResponse<List<BisInspWagaBase>> list(@ApiParam(name = "bisInspWagaBaseParam", value = "bisInspWagaBaseParam", required = true) @RequestBody BisInspWagaBaseParam bisInspWagaBaseParam) {
  82. List<BisInspWagaBase> bisInspWagaBaseList = bisInspWagaBaseService.findList(bisInspWagaBaseParam);
  83. return buildSuccessResponse(bisInspWagaBaseList);
  84. }
  85. @ApiOperation(value = "获取水闸督查基本情况(列表--分页)")
  86. @RequestMapping(value = "/page", method = RequestMethod.POST)
  87. public BaseResponse<PageInfo<BisInspWagaBase>> page(@ApiParam(name = "bisInspWagaBaseParam", value = "bisInspWagaBaseParam", required = true) @RequestBody BisInspWagaBaseParam bisInspWagaBaseParam) {
  88. PageInfo<BisInspWagaBase> bisInspWagaBaseList = bisInspWagaBaseService.findPageInfo(bisInspWagaBaseParam);
  89. return buildSuccessResponse(bisInspWagaBaseList);
  90. }
  91. @ApiOperation(value = "根据督查表rgstrId获取水闸督查日常管理和维修养护情况(单表)")
  92. @RequestMapping(value = "/getBy/{rgstrId}", method = RequestMethod.GET)
  93. public BaseResponse<BisInspWagaBase> getBy(@ApiParam(name = "rgstrId", value = "rgstrId", required = true) @PathVariable String rgstrId) {
  94. BisInspWagaBaseParam bisInspWagaBaseParam = new BisInspWagaBaseParam();
  95. bisInspWagaBaseParam.setRgstrId(rgstrId);
  96. BisInspWagaBase bisInspWagaProenInfo = bisInspWagaBaseService.getBy(bisInspWagaBaseParam);
  97. return buildSuccessResponse(bisInspWagaProenInfo);
  98. }
  99. }