2f01df59e359f396453b2fff20d1b1393784632d.svn-base 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. package cn.com.goldenwater.dcproj.controller.wrws;
  2. import cn.com.goldenwater.core.web.BaseController;
  3. import cn.com.goldenwater.core.web.BaseResponse;
  4. import cn.com.goldenwater.dcproj.constValue.CommonLabel;
  5. import cn.com.goldenwater.dcproj.model.BisInspOrg;
  6. import cn.com.goldenwater.dcproj.model.BisInspWrwsRgstr;
  7. import cn.com.goldenwater.dcproj.param.BisInspWrwsRgstrParam;
  8. import cn.com.goldenwater.dcproj.service.BisInspWrwsRgstrService;
  9. import cn.com.goldenwater.dcproj.service.OlBisInspOrgService;
  10. import cn.com.goldenwater.dcproj.utils.AdLevelUtil;
  11. import com.github.pagehelper.PageInfo;
  12. import io.swagger.annotations.Api;
  13. import io.swagger.annotations.ApiOperation;
  14. import io.swagger.annotations.ApiParam;
  15. import org.apache.commons.lang3.StringUtils;
  16. import org.slf4j.Logger;
  17. import org.slf4j.LoggerFactory;
  18. import org.springframework.beans.factory.annotation.Autowired;
  19. import org.springframework.web.bind.annotation.PathVariable;
  20. import org.springframework.web.bind.annotation.RequestBody;
  21. import org.springframework.web.bind.annotation.RequestMapping;
  22. import org.springframework.web.bind.annotation.RequestMethod;
  23. import org.springframework.web.bind.annotation.RestController;
  24. import java.text.SimpleDateFormat;
  25. import java.util.Date;
  26. /**
  27. * @author lhc
  28. * @date 2020-9-23
  29. */
  30. @Api(value = "水资源管理及节水管理复核管理", tags = "水资源管理及节水管理复核管理")
  31. @RestController
  32. @RequestMapping("/bis/insp/wrws")
  33. public class BisInspWrwsRgstrController extends BaseController {
  34. private Logger logger = LoggerFactory.getLogger(getClass());
  35. @Autowired
  36. private BisInspWrwsRgstrService bisInspWrwsRgstrService;
  37. @Autowired
  38. private OlBisInspOrgService olBisInspOrgService;
  39. @ApiOperation(value = "添加或修改水资源管理及节水管理复核")
  40. @RequestMapping(value = "", method = RequestMethod.POST)
  41. public BaseResponse<BisInspWrwsRgstr> insert(@ApiParam(name = "bisInspWrwsRgstr", value = "BisInspWrwsRgstr", required = true)
  42. @RequestBody BisInspWrwsRgstr bisInspWrwsRgstr) {
  43. int ret = 0;
  44. if (StringUtils.isNotBlank(bisInspWrwsRgstr.getRgstrId())) {
  45. // rgstrId 不为 空 时,传给ID
  46. bisInspWrwsRgstr.setId(bisInspWrwsRgstr.getRgstrId());
  47. }
  48. if (StringUtils.isBlank(bisInspWrwsRgstr.getId())) {
  49. if (StringUtils.isNotBlank(bisInspWrwsRgstr.getObjId())) {
  50. BisInspWrwsRgstrParam param = new BisInspWrwsRgstrParam();
  51. param.setObjId(bisInspWrwsRgstr.getId());
  52. BisInspWrwsRgstr rgstr = bisInspWrwsRgstrService.getBy(param);
  53. // 如果没有注册表,添加
  54. if (null == rgstr) {
  55. ret = bisInspWrwsRgstrService.insert(bisInspWrwsRgstr);
  56. }
  57. }
  58. } else {
  59. bisInspWrwsRgstr.setUptm(new Date());
  60. ret = bisInspWrwsRgstrService.update(bisInspWrwsRgstr);
  61. }
  62. return buildSuccessResponse(bisInspWrwsRgstr);
  63. }
  64. @ApiOperation(value = "根据ID删除水资源管理及节水管理复核")
  65. @RequestMapping(value = "delete/{id}", method = RequestMethod.POST)
  66. public BaseResponse delete(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
  67. int ret = bisInspWrwsRgstrService.delete(id);
  68. return buildSuccessResponse();
  69. }
  70. @ApiOperation(value = "根据ID获取水资源管理及节水管理复核(单表)")
  71. @RequestMapping(value = "/{id}", method = RequestMethod.GET)
  72. public BaseResponse<BisInspWrwsRgstr> get(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
  73. BisInspWrwsRgstr bisInspWrwsRgstr = bisInspWrwsRgstrService.get(id);
  74. return buildSuccessResponse(bisInspWrwsRgstr);
  75. }
  76. @ApiOperation(value = "节水载体复核表登记表(福建)(列表--分页)")
  77. @RequestMapping(value = "/findPage", method = RequestMethod.POST)
  78. public BaseResponse<PageInfo<BisInspWrwsRgstr>> page(@ApiParam(name = "bisInspWrwsRgstrParam", value = "bisInspWrwsRgstrParam", required = true)
  79. @RequestBody BisInspWrwsRgstrParam bisInspWrwsRgstrParam) {
  80. BisInspOrg defaultOrg = olBisInspOrgService.getDefaultOrg(getCurrentOrgId());
  81. bisInspWrwsRgstrParam.setProvince(AdLevelUtil.getAddvcd(defaultOrg.getRlcode()));
  82. if(null != bisInspWrwsRgstrParam.getAdCode()){
  83. bisInspWrwsRgstrParam.setAdCode(AdLevelUtil.getAddvcd(bisInspWrwsRgstrParam.getAdCode()));
  84. }
  85. if(StringUtils.isBlank(bisInspWrwsRgstrParam.getTabType())){
  86. bisInspWrwsRgstrParam.setTabType(CommonLabel.TAB_TYPE);
  87. }
  88. String nowTime=new SimpleDateFormat("yyyy-MM-dd").format(new Date());
  89. bisInspWrwsRgstrParam.setNowTime(nowTime);
  90. PageInfo<BisInspWrwsRgstr> rgstrPageInfo = bisInspWrwsRgstrService.findPageInfo(bisInspWrwsRgstrParam);
  91. return buildSuccessResponse(rgstrPageInfo);
  92. }
  93. }