8428be98ad930270c25d063af16ef0c767ba55a3.svn-base 14 KB

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