70e994c1ad6f66e3467f6f097fd92d96739dd2ca.svn-base 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. package cn.com.goldenwater.dcproj.controller.wrwx;
  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.BisInspWrwxRgstr;
  7. import cn.com.goldenwater.dcproj.param.BisInspWrwxRgstrParam;
  8. import cn.com.goldenwater.dcproj.service.BisInspWrwxRgstrService;
  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/wrwx")
  33. public class BisInspWrwxRgstrController extends BaseController {
  34. private Logger logger = LoggerFactory.getLogger(getClass());
  35. @Autowired
  36. private BisInspWrwxRgstrService bisInspWrwxRgstrService;
  37. @Autowired
  38. private OlBisInspOrgService olBisInspOrgService;
  39. @ApiOperation(value = "添加或修改水资源管理及节水管理复核")
  40. @RequestMapping(value = "", method = RequestMethod.POST)
  41. public BaseResponse<BisInspWrwxRgstr> insert(@ApiParam(name = "bisInspWrwxRgstr", value = "BisInspWrwxRgstr", required = true)
  42. @RequestBody BisInspWrwxRgstr bisInspWrwxRgstr) {
  43. int ret = 0;
  44. if (StringUtils.isNotBlank(bisInspWrwxRgstr.getRgstrId())) {
  45. // rgstrId 不为 空 时,传给ID
  46. bisInspWrwxRgstr.setId(bisInspWrwxRgstr.getRgstrId());
  47. }
  48. if (StringUtils.isBlank(bisInspWrwxRgstr.getId())) {
  49. if (StringUtils.isNotBlank(bisInspWrwxRgstr.getObjId())) {
  50. BisInspWrwxRgstrParam param = new BisInspWrwxRgstrParam();
  51. param.setObjId(bisInspWrwxRgstr.getId());
  52. BisInspWrwxRgstr rgstr = bisInspWrwxRgstrService.getBy(param);
  53. // 如果没有注册表,添加
  54. if (null == rgstr) {
  55. ret = bisInspWrwxRgstrService.insert(bisInspWrwxRgstr);
  56. }
  57. }
  58. } else {
  59. bisInspWrwxRgstr.setUptm(new Date());
  60. ret = bisInspWrwxRgstrService.update(bisInspWrwxRgstr);
  61. }
  62. return buildSuccessResponse(bisInspWrwxRgstr);
  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 = bisInspWrwxRgstrService.delete(id);
  68. return buildSuccessResponse();
  69. }
  70. @ApiOperation(value = "根据ID获取水资源管理及节水管理复核(单表)")
  71. @RequestMapping(value = "/{id}", method = RequestMethod.GET)
  72. public BaseResponse<BisInspWrwxRgstr> get(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
  73. BisInspWrwxRgstr bisInspWrwxRgstr = bisInspWrwxRgstrService.get(id);
  74. return buildSuccessResponse(bisInspWrwxRgstr);
  75. }
  76. @ApiOperation(value = "节水载体复核表登记表(福建)(列表--分页)")
  77. @RequestMapping(value = "/findPage", method = RequestMethod.POST)
  78. public BaseResponse<PageInfo<BisInspWrwxRgstr>> page(@ApiParam(name = "bisInspWrwxRgstrParam", value = "bisInspWrwxRgstrParam", required = true)
  79. @RequestBody BisInspWrwxRgstrParam bisInspWrwxRgstrParam) {
  80. BisInspOrg defaultOrg = olBisInspOrgService.getDefaultOrg(getCurrentOrgId());
  81. bisInspWrwxRgstrParam.setProvince(AdLevelUtil.getAddvcd(defaultOrg.getRlcode()));
  82. if(null != bisInspWrwxRgstrParam.getAdCode()){
  83. bisInspWrwxRgstrParam.setAdCode(AdLevelUtil.getAddvcd(bisInspWrwxRgstrParam.getAdCode()));
  84. }
  85. if(StringUtils.isBlank(bisInspWrwxRgstrParam.getTabType())){
  86. bisInspWrwxRgstrParam.setTabType(CommonLabel.TAB_TYPE);
  87. }
  88. String nowTime=new SimpleDateFormat("yyyy-MM-dd").format(new Date());
  89. bisInspWrwxRgstrParam.setNowTime(nowTime);
  90. PageInfo<BisInspWrwxRgstr> rgstrPageInfo = bisInspWrwxRgstrService.findPageInfo(bisInspWrwxRgstrParam);
  91. return buildSuccessResponse(rgstrPageInfo);
  92. }
  93. }