f8adf71ec2ffb3a6005b0023d30fc180922d382f.svn-base 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. package cn.com.goldenwater.dcproj.controller.vill;
  2. import cn.com.goldenwater.dcproj.dto.BisInspVlgdrinkProjManageDcdxDto;
  3. import cn.com.goldenwater.dcproj.dto.VillRgstrDto;
  4. import cn.com.goldenwater.dcproj.model.BisInspVlgdrinkProjManage;
  5. import cn.com.goldenwater.dcproj.param.BisInspVlgdrinkProjManageParam;
  6. import cn.com.goldenwater.dcproj.param.GetVillPageByNodeIdParam;
  7. import cn.com.goldenwater.dcproj.service.BisInspVlgdrinkProjManageService;
  8. import cn.com.goldenwater.core.web.BaseController;
  9. import cn.com.goldenwater.core.web.BaseResponse;
  10. import cn.com.goldenwater.dcproj.target.VerifyBean;
  11. import com.alibaba.fastjson.JSONObject;
  12. import com.github.pagehelper.PageInfo;
  13. import io.swagger.annotations.Api;
  14. import io.swagger.annotations.ApiOperation;
  15. import io.swagger.annotations.ApiParam;
  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.util.ArrayList;
  25. import java.util.List;
  26. /**
  27. * @author zhengdafei
  28. * @date 2019-2-19
  29. */
  30. @Api(value = "", tags = "农村饮水工程运行管理情况")
  31. @RestController
  32. @RequestMapping("/dc/insp/vlgdrinkProjManage")
  33. public class BisInspVlgdrinkProjManageController extends BaseController {
  34. private Logger logger = LoggerFactory.getLogger(getClass());
  35. @Autowired
  36. private BisInspVlgdrinkProjManageService bisInspVlgdrinkProjManageService;
  37. @ApiOperation(value = "添加")
  38. @RequestMapping(value = "/insert", method = RequestMethod.POST)
  39. public BaseResponse<JSONObject> insert(@ApiParam(name = "bisInspVlgdrinkProjManage", value = "BisInspVlgdrinkProjManage", required = true) @RequestBody BisInspVlgdrinkProjManage bisInspVlgdrinkProjManage) {
  40. String uuid = "";
  41. JSONObject json = new JSONObject();
  42. try {
  43. BisInspVlgdrinkProjManageParam param = new BisInspVlgdrinkProjManageParam();
  44. param.setEngId(bisInspVlgdrinkProjManage.getEngId());
  45. param.setCwsCode(bisInspVlgdrinkProjManage.getCwsCode());
  46. List<BisInspVlgdrinkProjManage> list = bisInspVlgdrinkProjManageService.queryList(param);
  47. if (list != null && list.size() == 1) {
  48. BisInspVlgdrinkProjManage bisInspVlgdrinkProjManageUpdate = list.get(0);
  49. this.update(bisInspVlgdrinkProjManageUpdate);
  50. json.put("id", bisInspVlgdrinkProjManageUpdate.getRunId());
  51. } else {
  52. uuid = bisInspVlgdrinkProjManageService.add(bisInspVlgdrinkProjManage);
  53. json.put("id", uuid);
  54. }
  55. } catch (Exception e) {
  56. e.printStackTrace();
  57. logger.error(e.getMessage());
  58. return buildFailResponse(e.getMessage());
  59. }
  60. return buildSuccessResponse(json);
  61. }
  62. @ApiOperation(value = "根据ID删除")
  63. @RequestMapping(value = "/{id}", method = RequestMethod.POST)
  64. public BaseResponse delete(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
  65. int ret = bisInspVlgdrinkProjManageService.delete(id);
  66. JSONObject json = new JSONObject();
  67. json.put("id", id);
  68. return buildSuccessResponse(json);
  69. }
  70. @ApiOperation(value = "更新信息")
  71. @RequestMapping(value = "/update", method = RequestMethod.POST)
  72. public BaseResponse update(@ApiParam(name = "bisInspVlgdrinkProjManage", value = "BisInspVlgdrinkProjManage", required = true) @RequestBody BisInspVlgdrinkProjManage bisInspVlgdrinkProjManage) {
  73. try {
  74. int ret = bisInspVlgdrinkProjManageService.modify(bisInspVlgdrinkProjManage);
  75. } catch (Exception e) {
  76. e.printStackTrace();
  77. logger.error(e.getMessage());
  78. return buildFailResponse(e.getMessage());
  79. }
  80. return buildSuccessResponse(bisInspVlgdrinkProjManage);
  81. }
  82. @ApiOperation(value = "根据ID获取(单表)")
  83. @RequestMapping(value = "/{id}", method = RequestMethod.GET)
  84. public BaseResponse<BisInspVlgdrinkProjManage> get(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
  85. BisInspVlgdrinkProjManage bisInspVlgdrinkProjManage = bisInspVlgdrinkProjManageService.get(id);
  86. if (bisInspVlgdrinkProjManage == null) {
  87. bisInspVlgdrinkProjManage = new BisInspVlgdrinkProjManage();
  88. }
  89. return buildSuccessResponse(bisInspVlgdrinkProjManage);
  90. }
  91. @ApiOperation(value = "获取列表(分页)")
  92. @RequestMapping(value = "/queryListByPage", method = {RequestMethod.GET, RequestMethod.POST})
  93. public BaseResponse<PageInfo<BisInspVlgdrinkProjManage>> queryListByPage(@RequestBody BisInspVlgdrinkProjManageParam param) {
  94. PageInfo<BisInspVlgdrinkProjManage> list = new PageInfo<>();
  95. try {
  96. list = bisInspVlgdrinkProjManageService.queryListByPage(param);
  97. } catch (Exception e) {
  98. e.printStackTrace();
  99. logger.error(e.getMessage());
  100. return buildFailResponse(e.getMessage());
  101. }
  102. return buildSuccessResponse(list);
  103. }
  104. @ApiOperation(value = "获取列表")
  105. @RequestMapping(value = "/queryList", method = {RequestMethod.GET, RequestMethod.POST})
  106. public BaseResponse<List<BisInspVlgdrinkProjManage>> queryList(@RequestBody BisInspVlgdrinkProjManageParam param) {
  107. List<BisInspVlgdrinkProjManage> list = new ArrayList<>();
  108. try {
  109. list = bisInspVlgdrinkProjManageService.queryList(param);
  110. } catch (Exception e) {
  111. e.printStackTrace();
  112. logger.error(e.getMessage());
  113. return buildFailResponse(e.getMessage());
  114. }
  115. return buildSuccessResponse(list);
  116. }
  117. @ApiOperation(value = "根据行政区划编码和人员id获取列表(不分页)")
  118. @RequestMapping(value = "/getListByCodeAndPerId", method = RequestMethod.POST)
  119. public BaseResponse<List<BisInspVlgdrinkProjManage>> getListByCodeAndPerId(@RequestBody VillRgstrDto villRgstrDto) {
  120. List<BisInspVlgdrinkProjManage> list = new ArrayList<>();
  121. try {
  122. list = bisInspVlgdrinkProjManageService.getListByCodeAndPerId(villRgstrDto);
  123. } catch (Exception e) {
  124. e.printStackTrace();
  125. logger.error(e.getMessage());
  126. return buildFailResponse(e.getMessage());
  127. }
  128. return buildSuccessResponse(list);
  129. }
  130. @ApiOperation(value = "根据行政区划编码和人员id获取列表(分页)")
  131. @RequestMapping(value = "/getPageByCodeAndPerId", method = RequestMethod.POST)
  132. public BaseResponse<PageInfo<BisInspVlgdrinkProjManage>> getPageByCodeAndPerId(@RequestBody VillRgstrDto villRgstrDto) {
  133. try {
  134. PageInfo<BisInspVlgdrinkProjManage> list = bisInspVlgdrinkProjManageService.getPageByCodeAndPerId(villRgstrDto);
  135. return buildSuccessResponse(list);
  136. } catch (Exception e) {
  137. e.printStackTrace();
  138. logger.error(e.getMessage());
  139. return buildFailResponse(e.getMessage());
  140. }
  141. }
  142. @ApiOperation(value = "获取单条")
  143. @RequestMapping(value = "/getBy", method = RequestMethod.POST)
  144. public BaseResponse<BisInspVlgdrinkProjManage> getPageByCodeAndPerId(@RequestBody BisInspVlgdrinkProjManageParam param) {
  145. try {
  146. if (param == null) {
  147. return buildFailResponse("参数不能为空");
  148. }
  149. BisInspVlgdrinkProjManage list = bisInspVlgdrinkProjManageService.getBy(param);
  150. return buildSuccessResponse(list);
  151. } catch (Exception e) {
  152. e.printStackTrace();
  153. logger.error(e.getMessage());
  154. return buildFailResponse(e.getMessage());
  155. }
  156. }
  157. @VerifyBean
  158. @ApiOperation(value = "根据节点id以及其他条件获取列表(分页,行政区只到县,还有用户填报的所在地)")
  159. @RequestMapping(value = "/getPageByNodeId", method = RequestMethod.POST)
  160. public BaseResponse<PageInfo<BisInspVlgdrinkProjManageDcdxDto>> getPageByNodeId(@RequestBody GetVillPageByNodeIdParam p) throws Exception {
  161. PageInfo<BisInspVlgdrinkProjManageDcdxDto> list = bisInspVlgdrinkProjManageService.getPageByNodeId(p);
  162. return buildSuccessResponse(list);
  163. }
  164. }