1c9aa493862fbb23ca7249117961d5cdefbe8b59.svn-base 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  1. package cn.com.goldenwater.dcproj.controller.vill2020;
  2. import cn.com.goldenwater.core.web.BaseController;
  3. import cn.com.goldenwater.core.web.BaseResponse;
  4. import cn.com.goldenwater.dcproj.constValue.BisInspEnum;
  5. import cn.com.goldenwater.dcproj.constValue.CommonLabel;
  6. import cn.com.goldenwater.dcproj.dao.AttAdXBaseDao;
  7. import cn.com.goldenwater.dcproj.dao.BisInspAllObjDao;
  8. import cn.com.goldenwater.dcproj.dao.BisInspPblmDao;
  9. import cn.com.goldenwater.dcproj.dto.AttCountryDto;
  10. import cn.com.goldenwater.dcproj.dto.BisNewDcuserRelVillDto;
  11. import cn.com.goldenwater.dcproj.dto.BisNewVillRgstrDto;
  12. import cn.com.goldenwater.dcproj.dto.VillAddDto;
  13. import cn.com.goldenwater.dcproj.model.*;
  14. import cn.com.goldenwater.dcproj.param.*;
  15. import cn.com.goldenwater.dcproj.service.*;
  16. import cn.com.goldenwater.dcproj.utils.GeoUtil;
  17. import cn.com.goldenwater.id.util.UuidUtil;
  18. import cn.com.goldenwater.util.common.SqlUtils;
  19. import com.github.pagehelper.PageInfo;
  20. import io.swagger.annotations.Api;
  21. import io.swagger.annotations.ApiOperation;
  22. import io.swagger.annotations.ApiParam;
  23. import org.apache.commons.lang3.StringUtils;
  24. import org.slf4j.Logger;
  25. import org.slf4j.LoggerFactory;
  26. import org.springframework.beans.factory.annotation.Autowired;
  27. import org.springframework.transaction.annotation.Transactional;
  28. import org.springframework.web.bind.annotation.*;
  29. import java.text.SimpleDateFormat;
  30. import java.util.*;
  31. /**
  32. * @author lune
  33. * @date 2020-3-27
  34. */
  35. @Api(value = "BIS 2020农村饮水工程登记表管理", tags = "BIS 2020农村饮水工程登记表管理")
  36. @RestController
  37. @RequestMapping("/bis/new/vill/rgstr")
  38. public class BisNewVillRgstrController extends BaseController {
  39. private Logger logger = LoggerFactory.getLogger(getClass());
  40. @Autowired
  41. private BisNewVillRgstrService bisNewVillRgstrService;
  42. @Autowired
  43. private AttAdXBaseDao attAdXBaseDao;
  44. @Autowired
  45. private AttAdXBaseService attAdXBaseService;
  46. @Autowired
  47. private BisInspAllObjService bisInspAllObjService;
  48. @Autowired
  49. private BisNewCountryFeeService bisNewCountryFeeService;
  50. @Autowired
  51. private BisNewDcuserRelVillService bisNewDcuserRelVillService;
  52. @Autowired
  53. private BisNewWateruserInfoService bisNewWateruserInfoService;
  54. @Autowired
  55. private BisInspAllObjDao inspAllObjDao;
  56. @Autowired
  57. private BisInspPblmDao bisInspPblmDao;
  58. @ApiOperation(value = "添加/修改2020农村饮水工程登记表")
  59. @RequestMapping(value = "", method = RequestMethod.POST)
  60. public BaseResponse<BisNewVillRgstr> insert(@ApiParam(name = "bisNewVillRgstr", value = "BisNewVillRgstr", required = true) @RequestBody BisNewVillRgstr bisNewVillRgstr) {
  61. bisNewVillRgstr.setUptm(new Date());
  62. if (bisNewVillRgstr.getLgtd() != null &&
  63. bisNewVillRgstr.getLttd() != null) {
  64. if (bisNewVillRgstr.getLgtd().intValue() != 0 && bisNewVillRgstr.getLttd().intValue() != 0) {
  65. Map<String, Double> map = GeoUtil.gcj02towgs84(bisNewVillRgstr.getLgtd(), bisNewVillRgstr.getLttd());
  66. bisNewVillRgstr.setLgtdpc(map.get("long"));
  67. bisNewVillRgstr.setLttdpc(map.get("lat"));
  68. }
  69. }
  70. if (StringUtils.isBlank(bisNewVillRgstr.getId())) {
  71. String uuid = UuidUtil.uuid();
  72. bisNewVillRgstr.setId(uuid);
  73. bisNewVillRgstrService.insert(bisNewVillRgstr);
  74. } else {
  75. bisNewVillRgstrService.update(bisNewVillRgstr);
  76. }
  77. return buildSuccessResponse(bisNewVillRgstr);
  78. }
  79. @ApiOperation(value = "根据ID删除2020农饮督查对象,id未objId")
  80. @RequestMapping(value = "/del/{objId}", method = RequestMethod.GET)
  81. @Transactional
  82. public BaseResponse delete(@ApiParam(name = "objId", value = "objId", required = true) @PathVariable String objId) {
  83. bisInspAllObjService.delete(objId);
  84. BisNewVillRgstrParam villRgstrParam = new BisNewVillRgstrParam();
  85. villRgstrParam.setObjId(objId);
  86. BisNewVillRgstr villRgstr = bisNewVillRgstrService.getBy(villRgstrParam);
  87. bisNewVillRgstrService.deleteBy(villRgstrParam);
  88. BisNewDcuserRelVillParam newDcuserRelVillParam = new BisNewDcuserRelVillParam();
  89. newDcuserRelVillParam.setRegstrId(villRgstr.getId());
  90. bisNewDcuserRelVillService.deleteBy(newDcuserRelVillParam);
  91. BisNewWateruserInfoParam newWateruserInfoParam = new BisNewWateruserInfoParam();
  92. newWateruserInfoParam.setRegstrId(villRgstr.getId());
  93. bisNewWateruserInfoService.deleteBy(newWateruserInfoParam);
  94. BisNewCountryFeeParam newCountryFeeParam = new BisNewCountryFeeParam();
  95. newCountryFeeParam.setRegstrId(villRgstr.getId());
  96. bisNewCountryFeeService.deleteBy(newCountryFeeParam);
  97. BisInspPblmParam bisInspPblmParam = new BisInspPblmParam();
  98. bisInspPblmParam.setRegid(objId);
  99. bisInspPblmParam.setRegid(villRgstr.getId());
  100. bisInspPblmDao.deleteBy(bisInspPblmParam);
  101. return buildSuccessResponse();
  102. }
  103. @ApiOperation(value = "2020农村饮水批量添加督查对象")
  104. @RequestMapping(value = "/addBatch", method = RequestMethod.POST)
  105. public BaseResponse<Object> addBatch(@ApiParam(name = "villAddDtoList", value = "villAddDtoList", required = true) @RequestBody List<VillAddDto> villAddDtoList) {
  106. for (VillAddDto villAddDto : villAddDtoList) {
  107. if (StringUtils.isNotBlank(villAddDto.getObjId())) {
  108. BisInspAllObjParam inspAllObjParam = new BisInspAllObjParam();
  109. inspAllObjParam.setId(villAddDto.getId());
  110. inspAllObjParam.setCode(villAddDto.getAdCode());
  111. BisInspAllObj bisInspAllObjExt = bisInspAllObjService.getBy(inspAllObjParam);
  112. if (bisInspAllObjExt != null) {
  113. continue;
  114. }
  115. }
  116. AttAdXBase attAdXBase = attAdXBaseService.get(villAddDto.getAdCode());
  117. BisInspAllObj bisInspAllObj = new BisInspAllObj();
  118. bisInspAllObj.setId(villAddDto.getId());
  119. bisInspAllObj.setNm(attAdXBase.getAdName());
  120. bisInspAllObj.setPtype(BisInspEnum.VILL2020.getValue());
  121. String objId = UuidUtil.uuid();
  122. bisInspAllObj.setObjId(objId);
  123. bisInspAllObj.setCode(villAddDto.getAdCode());
  124. bisInspAllObj.setLttdpc(attAdXBase.getLttdpc());
  125. bisInspAllObj.setLgtdpc(attAdXBase.getLgtdpc());
  126. bisInspAllObj.setLgtd(attAdXBase.getLgtd());
  127. bisInspAllObj.setLttd(attAdXBase.getLttd());
  128. bisInspAllObjService.insert(bisInspAllObj);
  129. BisNewVillRgstr bisNewVillRgstr = new BisNewVillRgstr();
  130. bisNewVillRgstr.setId(UuidUtil.uuid());
  131. bisNewVillRgstr.setPersId(getCurrentPersId());
  132. bisNewVillRgstr.setIsPkx(attAdXBase.getIsPoveryt());
  133. bisNewVillRgstr.setObjId(objId);
  134. bisNewVillRgstr.setRegsNm(attAdXBase.getAdName());
  135. bisNewVillRgstr.setState("0");
  136. bisNewVillRgstr.setLttdpc(attAdXBase.getLttdpc());
  137. bisNewVillRgstr.setLgtdpc(attAdXBase.getLgtdpc());
  138. bisNewVillRgstr.setLgtd(attAdXBase.getLgtd());
  139. bisNewVillRgstr.setLttd(attAdXBase.getLttd());
  140. bisNewVillRgstr.setAdFullName(attAdXBase.getAdFullName());
  141. bisNewVillRgstr.setAdCode(attAdXBase.getAdCode());
  142. bisNewVillRgstr.setUptm(new Date());
  143. bisNewVillRgstr.setIntm(new Date());
  144. bisNewVillRgstr.setWaterPriceIsMade("0");
  145. bisNewVillRgstrService.insert(bisNewVillRgstr);
  146. }
  147. return buildSuccessResponse(villAddDtoList);
  148. }
  149. @ApiOperation(value = "根据ID获取2020农村饮水工程登记表(单表)")
  150. @RequestMapping(value = "/{id}", method = RequestMethod.GET)
  151. public BaseResponse<BisNewVillRgstr> get(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
  152. BisNewVillRgstr bisNewVillRgstr = bisNewVillRgstrService.get(id);
  153. if (bisNewVillRgstr != null) {
  154. BisInspAllObjParam inspAllObjParam = new BisInspAllObjParam();
  155. inspAllObjParam.setObjId(bisNewVillRgstr.getObjId());
  156. BisInspAllObj allObj = inspAllObjDao.getBy(inspAllObjParam);
  157. String planId = allObj.getId();
  158. bisNewVillRgstr.setPlanId(planId);
  159. }
  160. return buildSuccessResponse(bisNewVillRgstr);
  161. }
  162. @ApiOperation(value = "获取2020农村饮水工程登记表(列表所有)")
  163. @RequestMapping(value = "/list", method = RequestMethod.POST)
  164. public BaseResponse<List<BisNewVillRgstr>> list(@ApiParam(name = "bisNewVillRgstrParam", value = "bisNewVillRgstrParam", required = true) @RequestBody BisNewVillRgstrParam bisNewVillRgstrParam) {
  165. List<BisNewVillRgstr> bisNewVillRgstrList = bisNewVillRgstrService.findList(bisNewVillRgstrParam);
  166. return buildSuccessResponse(bisNewVillRgstrList);
  167. }
  168. @ApiOperation(value = "获取2020农村饮水工程登记表(列表--分页)")
  169. @RequestMapping(value = "/page", method = RequestMethod.POST)
  170. public BaseResponse<PageInfo<BisNewVillRgstr>> page(@ApiParam(name = "bisNewVillRgstrParam", value = "bisNewVillRgstrParam", required = true) @RequestBody BisNewVillRgstrParam bisNewVillRgstrParam) {
  171. PageInfo<BisNewVillRgstr> bisNewVillRgstrList = bisNewVillRgstrService.findPageInfo(bisNewVillRgstrParam);
  172. return buildSuccessResponse(bisNewVillRgstrList);
  173. }
  174. @ApiOperation(value = "添加行政村县下镇(乡)--村树节点,code为县code")
  175. @RequestMapping(value = "/findCheckTree/{code}/{regstrId}", method = RequestMethod.GET)
  176. public BaseResponse<List<AttCountryDto>> findCheckTree(
  177. @ApiParam(name = "code", value = "code", required = true) @PathVariable String code,
  178. @ApiParam(name = "regstrId", value = "regstrId", required = true) @PathVariable String regstrId) {
  179. if (code.length() == 12) {
  180. code = code.substring(0, 6);
  181. }
  182. List<AttCountryDto> zhenDtoList = attAdXBaseDao.findXZCZhenList(code);
  183. List<AttCountryDto> countryDtoList = attAdXBaseDao.findXZCCunList(code, regstrId, BisInspEnum.VILL2020.getValue());
  184. for (AttCountryDto attCountryDto : zhenDtoList) {
  185. String adCode = attCountryDto.getAdCode().replace("000", "");
  186. List<AttCountryDto> childList = new ArrayList<>();
  187. for (AttCountryDto countryDto : countryDtoList) {
  188. if (countryDto.getAdCode().startsWith(adCode)) {
  189. childList.add(countryDto);
  190. }
  191. }
  192. attCountryDto.setAttCountryDtoList(childList);
  193. }
  194. return buildSuccessResponse(zhenDtoList);
  195. }
  196. @ApiOperation(value = "获取督查中县-镇(乡)--村树节点")
  197. @RequestMapping(value = "/findTree/{code}/{regstrId}", method = RequestMethod.GET)
  198. public BaseResponse<List<BisNewDcuserRelVillDto>> findTree(
  199. @ApiParam(name = "code", value = "code", required = true) @PathVariable String code,
  200. @ApiParam(name = "regstrId", value = "regstrId", required = true) @PathVariable String regstrId) {
  201. //获取镇,乡
  202. if (code.length() == 12) {
  203. code = code.substring(0, 6);
  204. }
  205. List<BisNewDcuserRelVillDto> attAdXBaseList = attAdXBaseService.findZhenList(code, regstrId, BisInspEnum.VILL2020.getValue());
  206. return buildSuccessResponse(attAdXBaseList);
  207. }
  208. @ApiOperation(value = "获取县-镇(乡)--村用水户和饮水工程列表")
  209. @RequestMapping(value = "/findNode/{code}/{regstrId}", method = RequestMethod.GET)
  210. public BaseResponse<Object> findNode(
  211. @ApiParam(name = "code", value = "code", required = true) @PathVariable String code,
  212. @ApiParam(name = "regstrId", value = "regstrId", required = true) @PathVariable String regstrId) {
  213. //获取镇,乡
  214. Map<String, Object> map = new HashMap<>();
  215. BisNewWateruserInfoParam wateruserInfoParam = new BisNewWateruserInfoParam();
  216. wateruserInfoParam.setRegstrId(regstrId);
  217. if (code.length() == 12 && code.endsWith("000")) {
  218. code = code.substring(0, 9);
  219. }
  220. wateruserInfoParam.setAdCode(code);
  221. List<BisNewWateruserInfo> wateruserInfos = bisNewWateruserInfoService.findList(wateruserInfoParam);
  222. BisNewCountryFeeParam countryFeeParam = new BisNewCountryFeeParam();
  223. countryFeeParam.setAdCode(code);
  224. countryFeeParam.setRegstrId(regstrId);
  225. List<BisNewCountryFee> countryFeeList = bisNewCountryFeeService.findList(countryFeeParam);
  226. map.put("waterUsers", wateruserInfos);
  227. map.put("countryPro", countryFeeList);
  228. return buildSuccessResponse(map);
  229. }
  230. @ApiOperation(value = "查询未被督查的县")
  231. @RequestMapping(value = "/pageNotAddRegstr", method = RequestMethod.POST)
  232. public BaseResponse<PageInfo<AttCountryDto>> pageNotAddRegstr(@ApiParam(name = "commonParam", value = "commonParam", required = true) @RequestBody CommonParam commonParam) {
  233. String adCode = commonParam.getAdCode();
  234. if (StringUtils.isNotBlank(adCode)) {
  235. if (adCode.endsWith("00000000")) {
  236. adCode = adCode.substring(0, 8);
  237. adCode = adCode + "__000000";
  238. }
  239. if (adCode.endsWith("0000000000")) {
  240. adCode = adCode.substring(0, 10);
  241. adCode = adCode + "____000000";
  242. }
  243. commonParam.setAdCode(adCode);
  244. }
  245. PageInfo<AttCountryDto> bisNewVillRgstrList = bisNewVillRgstrService.pageNotAddRegstr(commonParam);
  246. return buildSuccessResponse(bisNewVillRgstrList);
  247. }
  248. @ApiOperation(value = "问题栏目:问题列表根据当前登录用户id获取需要督查问题列表")
  249. @RequestMapping(value = "/list/{persId}", method = RequestMethod.POST)
  250. public BaseResponse<PageInfo<BisInspPblm>> list(@ApiParam(name = "persId", value = "persId", required = true) @PathVariable String persId
  251. , @RequestBody(required = false) PlbmParam pblmParam) {
  252. pblmParam.setPresId(persId);
  253. pblmParam.setProvince(olBisInspOrgService.getProvince(getCurrentOrgId()));
  254. PageInfo<BisInspPblm> inspPblmList = bisNewVillRgstrService.findPageList(pblmParam);
  255. return buildSuccessResponse(inspPblmList);
  256. }
  257. @Autowired
  258. private OlBisInspOrgService olBisInspOrgService;
  259. @ApiOperation(value = "获取登记表数据pc端")
  260. @RequestMapping(value = "/findPageByType", method = RequestMethod.POST)
  261. public BaseResponse<PageInfo<BisNewVillRgstrDto>> findPageByType(@RequestBody(required = false) TypeParam typeParam) {
  262. typeParam.setPresId(getCurrentPersId());
  263. if (StringUtils.isBlank(typeParam.getTabType())) {
  264. typeParam.setTabType(CommonLabel.TAB_TYPE);
  265. }
  266. String nowTime = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
  267. typeParam.setNowTime(nowTime);
  268. typeParam.setProvince(olBisInspOrgService.getProvince(getCurrentOrgId()));
  269. typeParam.setInIdsSql(SqlUtils.getinIdsSql(getCurrentPersId(), typeParam.getProvince()));
  270. PageInfo<BisNewVillRgstrDto> villRgstrDtoPageInfo = bisNewVillRgstrService.findPageByType(typeParam);
  271. return buildSuccessResponse(villRgstrDtoPageInfo);
  272. }
  273. }