422faf07f5b9f3bb703cc2da2c0d11c8bf4efdec.svn-base 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. package cn.com.goldenwater.dcproj.controller.svwt;
  2. import cn.com.goldenwater.dcproj.constValue.CommonLabel;
  3. import cn.com.goldenwater.dcproj.dto.BisInspRgstrDto;
  4. import cn.com.goldenwater.dcproj.model.AttWuntBase;
  5. import cn.com.goldenwater.dcproj.model.BisInspAllObj;
  6. import cn.com.goldenwater.dcproj.model.BisInspSvwtWuntRgstr;
  7. import cn.com.goldenwater.dcproj.param.BisInspAllObjParam;
  8. import cn.com.goldenwater.dcproj.param.BisInspSvwtWuntRgstrParam;
  9. import cn.com.goldenwater.dcproj.service.AttWuntBaseService;
  10. import cn.com.goldenwater.dcproj.service.BisInspAllObjService;
  11. import cn.com.goldenwater.dcproj.service.BisInspSvwtWuntRgstrService;
  12. import cn.com.goldenwater.core.web.BaseController;
  13. import cn.com.goldenwater.core.web.BaseResponse;
  14. import cn.com.goldenwater.dcproj.service.OlBisInspOrgService;
  15. import cn.com.goldenwater.dcproj.target.Authority;
  16. import cn.com.goldenwater.dcproj.utils.BeanUtil;
  17. import cn.com.goldenwater.id.util.UuidUtil;
  18. import cn.com.goldenwater.util.common.SqlUtils;
  19. import io.swagger.annotations.Api;
  20. import io.swagger.annotations.ApiOperation;
  21. import io.swagger.annotations.ApiParam;
  22. import org.apache.commons.lang3.StringUtils;
  23. import com.github.pagehelper.PageInfo;
  24. import org.slf4j.Logger;
  25. import org.slf4j.LoggerFactory;
  26. import org.springframework.beans.factory.annotation.Autowired;
  27. import org.springframework.web.bind.annotation.PathVariable;
  28. import org.springframework.web.bind.annotation.RequestBody;
  29. import org.springframework.web.bind.annotation.RequestMapping;
  30. import org.springframework.web.bind.annotation.RequestMethod;
  31. import org.springframework.web.bind.annotation.RestController;
  32. import javax.servlet.http.HttpServletResponse;
  33. import java.text.SimpleDateFormat;
  34. import java.util.Date;
  35. import java.util.List;
  36. import cn.com.goldenwater.dcproj.param.TypeParam;
  37. /**
  38. * @author lune
  39. * @date 2019-9-18
  40. */
  41. @Api(value = "BIS 用水单位督查登记表管理", tags = "BIS 用水单位督查登记表管理")
  42. @RestController
  43. @RequestMapping("/bis/insp/svwt/wunt/rgstr")
  44. public class BisInspSvwtWuntRgstrController extends BaseController {
  45. private Logger logger = LoggerFactory.getLogger(getClass());
  46. @Autowired
  47. private BisInspSvwtWuntRgstrService bisInspSvwtWuntRgstrService;
  48. @Autowired
  49. private AttWuntBaseService wuntBaseService;
  50. @Autowired
  51. private BisInspAllObjService objService;
  52. @Autowired
  53. private OlBisInspOrgService olBisInspOrgService;
  54. @ApiOperation(value = "添加/修改用水单位督查登记表")
  55. @RequestMapping(value = "", method = RequestMethod.POST)
  56. public BaseResponse<BisInspSvwtWuntRgstr> insert(@ApiParam(name = "bisInspSvwtWuntRgstr", value = "BisInspSvwtWuntRgstr", required = true) @RequestBody BisInspSvwtWuntRgstr bisInspSvwtWuntRgstr) {
  57. bisInspSvwtWuntRgstr.setProvince(olBisInspOrgService.getProvince(getCurrentOrgId()));
  58. if (StringUtils.isBlank(bisInspSvwtWuntRgstr.getId())) {
  59. String uuid = UuidUtil.uuid(); // 生成uuid
  60. bisInspSvwtWuntRgstr.setId(uuid);
  61. bisInspSvwtWuntRgstrService.insert(bisInspSvwtWuntRgstr);
  62. } else {
  63. bisInspSvwtWuntRgstrService.update(bisInspSvwtWuntRgstr);
  64. if (StringUtils.isNotBlank(bisInspSvwtWuntRgstr.getObjId())) {
  65. BisInspAllObjParam param = new BisInspAllObjParam();
  66. param.setObjId(bisInspSvwtWuntRgstr.getObjId());
  67. BisInspAllObj obj = objService.getBy(param);
  68. obj.setNm(bisInspSvwtWuntRgstr.getUtName());
  69. objService.update(obj);
  70. if (StringUtils.isNotBlank(obj.getCode())) {
  71. AttWuntBase base = wuntBaseService.get(obj.getCode());
  72. if (base != null) {
  73. String id = base.getId();
  74. BeanUtil.copyObject1(bisInspSvwtWuntRgstr, base);
  75. base.setId(id);
  76. wuntBaseService.update(base);
  77. }
  78. }
  79. }
  80. }
  81. return buildSuccessResponse(bisInspSvwtWuntRgstr);
  82. }
  83. @ApiOperation(value = "根据ID删除用水单位督查登记表")
  84. @RequestMapping(value = "/del/{id}", method = RequestMethod.GET)
  85. public BaseResponse delete(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
  86. int ret = bisInspSvwtWuntRgstrService.delete(id);
  87. return buildSuccessResponse();
  88. }
  89. @ApiOperation(value = "根据ID获取用水单位督查登记表(单表)")
  90. @RequestMapping(value = "/{id}", method = RequestMethod.GET)
  91. public BaseResponse<BisInspSvwtWuntRgstr> get(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
  92. BisInspSvwtWuntRgstr bisInspSvwtWuntRgstr = bisInspSvwtWuntRgstrService.get(id);
  93. return buildSuccessResponse(bisInspSvwtWuntRgstr);
  94. }
  95. @ApiOperation(value = "获取用水单位督查登记表(列表所有)")
  96. @RequestMapping(value = "/list", method = RequestMethod.POST)
  97. public BaseResponse<List<BisInspSvwtWuntRgstr>> list(@ApiParam(name = "bisInspSvwtWuntRgstrParam", value = "bisInspSvwtWuntRgstrParam", required = true) @RequestBody BisInspSvwtWuntRgstrParam bisInspSvwtWuntRgstrParam) {
  98. bisInspSvwtWuntRgstrParam.setProvince(olBisInspOrgService.getProvince(getCurrentOrgId()));
  99. List<BisInspSvwtWuntRgstr> bisInspSvwtWuntRgstrList = bisInspSvwtWuntRgstrService.findList(bisInspSvwtWuntRgstrParam);
  100. return buildSuccessResponse(bisInspSvwtWuntRgstrList);
  101. }
  102. @ApiOperation(value = "获取用水单位督查登记表(列表--分页)")
  103. @RequestMapping(value = "/page", method = RequestMethod.POST)
  104. public BaseResponse<PageInfo<BisInspSvwtWuntRgstr>> page(@ApiParam(name = "bisInspSvwtWuntRgstrParam", value = "bisInspSvwtWuntRgstrParam", required = true) @RequestBody BisInspSvwtWuntRgstrParam bisInspSvwtWuntRgstrParam) {
  105. bisInspSvwtWuntRgstrParam.setProvince(olBisInspOrgService.getProvince(getCurrentOrgId()));
  106. PageInfo<BisInspSvwtWuntRgstr> bisInspSvwtWuntRgstrList = bisInspSvwtWuntRgstrService.findPageInfo(bisInspSvwtWuntRgstrParam);
  107. return buildSuccessResponse(bisInspSvwtWuntRgstrList);
  108. }
  109. @Authority
  110. @ApiOperation(value = "获取督查对象")
  111. @RequestMapping(value = "/findSvwtWuntPage", method = RequestMethod.POST)
  112. public BaseResponse<PageInfo<BisInspRgstrDto>> findSvwtWuntPage(@RequestBody TypeParam param, HttpServletResponse response) {
  113. param.setProvince(olBisInspOrgService.getProvince(getCurrentOrgId()));
  114. param.setOrgId(getCurrentOrgId());
  115. if (StringUtils.isBlank(param.getTabType())) {
  116. param.setTabType(CommonLabel.TAB_TYPE);
  117. }
  118. String nowTime = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
  119. param.setNowTime(nowTime);
  120. param.setInIdsSql(SqlUtils.getinIdsSql(getCurrentPersId(), param.getProvince()));
  121. PageInfo<BisInspRgstrDto> pageInfo = bisInspSvwtWuntRgstrService.findSvwtWuntPage(param, response);
  122. return buildSuccessResponse(pageInfo);
  123. }
  124. @Authority
  125. @ApiOperation(value = "获取督查对象")
  126. @RequestMapping(value = "/findSvwtWuntList", method = {RequestMethod.POST, RequestMethod.GET})
  127. public BaseResponse<List<BisInspRgstrDto>> findSvwtWuntList(TypeParam param) {
  128. param.setProvince(olBisInspOrgService.getProvince(getCurrentOrgId()));
  129. param.setOrgId(getCurrentOrgId());
  130. if (StringUtils.isBlank(param.getTabType())) {
  131. param.setTabType(CommonLabel.TAB_TYPE);
  132. }
  133. String nowTime = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
  134. param.setNowTime(nowTime);
  135. param.setInIdsSql(SqlUtils.getinIdsSql(getCurrentPersId(), param.getProvince()));
  136. List<BisInspRgstrDto> pageInfo = bisInspSvwtWuntRgstrService.findSvwtWuntList(param);
  137. return buildSuccessResponse(pageInfo);
  138. }
  139. }