8f8303fdfa3a4bf11b45d736f70cfba23261637f.svn-base 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. package cn.com.goldenwater.dcproj.controller.vill;
  2. import cn.com.goldenwater.dcproj.model.BisInspVillRgstr;
  3. import cn.com.goldenwater.dcproj.param.BisInspVillRgstrParam;
  4. import cn.com.goldenwater.dcproj.service.BisInspVillRgstrService;
  5. import cn.com.goldenwater.core.web.BaseController;
  6. import cn.com.goldenwater.core.web.BaseResponse;
  7. import com.alibaba.fastjson.JSONObject;
  8. import com.github.pagehelper.PageInfo;
  9. import io.swagger.annotations.Api;
  10. import io.swagger.annotations.ApiOperation;
  11. import io.swagger.annotations.ApiParam;
  12. import org.slf4j.Logger;
  13. import org.slf4j.LoggerFactory;
  14. import org.springframework.beans.factory.annotation.Autowired;
  15. import org.springframework.web.bind.annotation.PathVariable;
  16. import org.springframework.web.bind.annotation.RequestBody;
  17. import org.springframework.web.bind.annotation.RequestMapping;
  18. import org.springframework.web.bind.annotation.RequestMethod;
  19. import org.springframework.web.bind.annotation.RequestParam;
  20. import org.springframework.web.bind.annotation.RestController;
  21. import java.util.ArrayList;
  22. import java.util.List;
  23. /**
  24. * @author zhengdafei
  25. * @date 2019-2-19
  26. */
  27. @Api(value = "", tags = "农村饮水工程登记")
  28. @RestController
  29. @RequestMapping("/dc/insp/villRgstr")
  30. public class BisInspVillRgstrController extends BaseController {
  31. private Logger logger = LoggerFactory.getLogger(getClass());
  32. @Autowired
  33. private BisInspVillRgstrService bisInspVillRgstrService;
  34. @ApiOperation(value = "添加")
  35. @RequestMapping(value = "/insert", method = RequestMethod.POST)
  36. public BaseResponse<JSONObject> insert(@ApiParam(name = "bisInspVillRgstr", value = "BisInspVillRgstr", required = true) @RequestBody BisInspVillRgstr bisInspVillRgstr) {
  37. String uuid = "";
  38. JSONObject json = new JSONObject();
  39. try {
  40. bisInspVillRgstr.setOrgId(getCurrentOrgId());
  41. uuid = bisInspVillRgstrService.add(bisInspVillRgstr);
  42. json.put("id", uuid);
  43. } catch (Exception e) {
  44. e.printStackTrace();
  45. logger.error(e.getMessage());
  46. return buildFailResponse(e.getMessage());
  47. }
  48. return buildSuccessResponse(json);
  49. }
  50. @ApiOperation(value = "根据ID删除")
  51. @RequestMapping(value = "/{id}", method = RequestMethod.POST)
  52. public BaseResponse delete(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
  53. int ret = bisInspVillRgstrService.delete(id);
  54. JSONObject json = new JSONObject();
  55. json.put("id", id);
  56. return buildSuccessResponse(json);
  57. }
  58. @ApiOperation(value = "更新信息")
  59. @RequestMapping(value = "/update", method = RequestMethod.POST)
  60. public BaseResponse update(@ApiParam(name = "bisInspVillRgstr", value = "BisInspVillRgstr", required = true) @RequestBody BisInspVillRgstr bisInspVillRgstr) {
  61. String ret = "";
  62. try {
  63. ret = bisInspVillRgstrService.modify(bisInspVillRgstr);
  64. } catch (Exception e) {
  65. e.printStackTrace();
  66. logger.error(e.getMessage());
  67. return buildFailResponse(e.getMessage());
  68. }
  69. return buildSuccessResponse(bisInspVillRgstr);
  70. }
  71. @ApiOperation(value = "根据ID获取(单表)")
  72. @RequestMapping(value = "/{id}", method = RequestMethod.GET)
  73. public BaseResponse<BisInspVillRgstr> get(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
  74. BisInspVillRgstr bisInspVillRgstr = bisInspVillRgstrService.get(id);
  75. if (bisInspVillRgstr == null) {
  76. bisInspVillRgstr = new BisInspVillRgstr();
  77. }
  78. return buildSuccessResponse(bisInspVillRgstr);
  79. }
  80. @ApiOperation(value = "获取列表(分页)")
  81. @RequestMapping(value = "/queryListByPage", method = {RequestMethod.GET, RequestMethod.POST})
  82. public BaseResponse<PageInfo<BisInspVillRgstr>> queryListByPage(@RequestBody BisInspVillRgstrParam param) {
  83. PageInfo<BisInspVillRgstr> list = new PageInfo<>();
  84. try {
  85. param.setOrgId(getCurrentOrgId());
  86. list = bisInspVillRgstrService.queryListByPage(param);
  87. } catch (Exception e) {
  88. e.printStackTrace();
  89. logger.error(e.getMessage());
  90. return buildFailResponse(e.getMessage());
  91. }
  92. return buildSuccessResponse(list);
  93. }
  94. @ApiOperation(value = "获取列表")
  95. @RequestMapping(value = "/queryList", method = {RequestMethod.GET, RequestMethod.POST})
  96. public BaseResponse<List<BisInspVillRgstr>> queryList(@RequestBody BisInspVillRgstrParam param) {
  97. List<BisInspVillRgstr> list = new ArrayList<>();
  98. try {
  99. param.setOrgId(getCurrentOrgId());
  100. list = bisInspVillRgstrService.queryList(param);
  101. } catch (Exception e) {
  102. e.printStackTrace();
  103. logger.error(e.getMessage());
  104. return buildFailResponse(e.getMessage());
  105. }
  106. return buildSuccessResponse(list);
  107. }
  108. @ApiOperation(value = "根据人员id获取农村饮用水列表")
  109. @RequestMapping(value = "/findListByPersId", method = {RequestMethod.GET, RequestMethod.POST})
  110. public BaseResponse<List<BisInspVillRgstr>> findListByPersId(@RequestParam("persId") String persId) {
  111. List<BisInspVillRgstr> list = new ArrayList<>();
  112. try {
  113. list = bisInspVillRgstrService.findListByPersId(persId,getCurrentOrgId());
  114. } catch (Exception e) {
  115. e.printStackTrace();
  116. logger.error(e.getMessage());
  117. return buildFailResponse(e.getMessage());
  118. }
  119. return buildSuccessResponse(list);
  120. }
  121. @ApiOperation(value = "根据督查对象ID获取登记表ID")
  122. @RequestMapping(value = "/getEngId", method = {RequestMethod.GET, RequestMethod.POST})
  123. public BaseResponse<JSONObject> findTCList(@RequestParam("objId") String objId, @RequestParam(value = "persId", required = false) String persId) {
  124. String engId = "";
  125. JSONObject json = new JSONObject();
  126. try {
  127. engId = bisInspVillRgstrService.getEngId(objId, persId);
  128. json.put("engId", engId);
  129. } catch (Exception e) {
  130. e.printStackTrace();
  131. logger.error(e.getMessage());
  132. return buildFailResponse(e.getMessage());
  133. }
  134. return buildSuccessResponse(json);
  135. }
  136. }