c411544c124cac274461bc0075787678b0381509.svn-base 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. package cn.com.goldenwater.dcproj.controller.tac;
  2. import cn.com.goldenwater.core.web.BaseController;
  3. import cn.com.goldenwater.core.web.BaseResponse;
  4. import cn.com.goldenwater.dcproj.dto.TacInspYearBatchObjDto;
  5. import cn.com.goldenwater.dcproj.dto.TacObjDto;
  6. import cn.com.goldenwater.dcproj.model.AttAdBase;
  7. import cn.com.goldenwater.dcproj.model.BisInspAllNode;
  8. import cn.com.goldenwater.dcproj.model.TacAttPawpBase;
  9. import cn.com.goldenwater.dcproj.model.TacInspYearBatchObj;
  10. import cn.com.goldenwater.dcproj.param.TacInspYearBatchObjParam;
  11. import cn.com.goldenwater.dcproj.service.AttAdBaseService;
  12. import cn.com.goldenwater.dcproj.service.OlBisInspOrgService;
  13. import cn.com.goldenwater.dcproj.service.TacInspYearBatchObjService;
  14. import cn.com.goldenwater.dcproj.utils.AdLevelUtil;
  15. import cn.com.goldenwater.id.util.UuidUtil;
  16. import com.github.pagehelper.PageInfo;
  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 org.slf4j.Logger;
  22. import org.slf4j.LoggerFactory;
  23. import org.springframework.beans.factory.annotation.Autowired;
  24. import org.springframework.web.bind.annotation.PathVariable;
  25. import org.springframework.web.bind.annotation.RequestBody;
  26. import org.springframework.web.bind.annotation.RequestMapping;
  27. import org.springframework.web.bind.annotation.RequestMethod;
  28. import org.springframework.web.bind.annotation.RestController;
  29. import java.util.ArrayList;
  30. import java.util.HashSet;
  31. import java.util.List;
  32. import java.util.Set;
  33. /**
  34. * @author lune
  35. * @date 2019-9-6
  36. */
  37. @Api(value = "TAC 稽察对象名录表管理", tags = "TAC 稽察对象名录表管理")
  38. @RestController
  39. @RequestMapping("/tac/insp/year/batch/obj")
  40. public class TacInspYearBatchObjController extends BaseController {
  41. private Logger logger = LoggerFactory.getLogger(getClass());
  42. @Autowired
  43. private TacInspYearBatchObjService tacInspYearBatchObjService;
  44. @Autowired
  45. private OlBisInspOrgService olBisInspOrgService;
  46. @ApiOperation(value = "添加/修改稽察对象名录表")
  47. @RequestMapping(value = "", method = RequestMethod.POST)
  48. public BaseResponse<TacInspYearBatchObj> insert(@ApiParam(name = "tacInspYearBatchObj", value = "TacInspYearBatchObj", required = true) @RequestBody TacInspYearBatchObj tacInspYearBatchObj) {
  49. tacInspYearBatchObj.setProvince(olBisInspOrgService.getRlProvince(getCurrentOrgId()));
  50. if (StringUtils.isBlank(tacInspYearBatchObj.getId())) {
  51. String uuid = UuidUtil.uuid(); // 生成uuid
  52. tacInspYearBatchObj.setId(uuid);
  53. tacInspYearBatchObjService.insert(tacInspYearBatchObj);
  54. } else {
  55. tacInspYearBatchObjService.update(tacInspYearBatchObj);
  56. }
  57. return buildSuccessResponse(tacInspYearBatchObj);
  58. }
  59. @ApiOperation(value = "根据ID删除稽察对象名录表")
  60. @RequestMapping(value = "/del/{id}", method = RequestMethod.GET)
  61. public BaseResponse delete(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
  62. int ret = tacInspYearBatchObjService.delete(id);
  63. return buildSuccessResponse();
  64. }
  65. @ApiOperation(value = "根据ID获取稽察对象名录表(单表)")
  66. @RequestMapping(value = "/{id}", method = RequestMethod.GET)
  67. public BaseResponse<TacInspYearBatchObj> get(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
  68. TacInspYearBatchObj tacInspYearBatchObj = tacInspYearBatchObjService.get(id);
  69. return buildSuccessResponse(tacInspYearBatchObj);
  70. }
  71. @ApiOperation(value = "获取稽察对象名录表(列表所有)")
  72. @RequestMapping(value = "/list", method = RequestMethod.POST)
  73. public BaseResponse<List<TacInspYearBatchObj>> list(@ApiParam(name = "tacInspYearBatchObjParam", value = "tacInspYearBatchObjParam", required = true) @RequestBody TacInspYearBatchObjParam tacInspYearBatchObjParam) {
  74. tacInspYearBatchObjParam.setProvince(olBisInspOrgService.getRlProvince(getCurrentOrgId()));
  75. List<TacInspYearBatchObj> tacInspYearBatchObjList = tacInspYearBatchObjService.findList(tacInspYearBatchObjParam);
  76. return buildSuccessResponse(tacInspYearBatchObjList);
  77. }
  78. @ApiOperation(value = "获取稽察批次下包含对象名录列表")
  79. @RequestMapping(value = "/objsListByBatch", method = RequestMethod.POST)
  80. public BaseResponse<List<TacInspYearBatchObjDto>> objslistbybatch(@ApiParam(name = "tacInspYearBatchObjParam", value = "tacInspYearBatchObjParam", required = true) @RequestBody TacInspYearBatchObjParam tacInspYearBatchObjParam) {
  81. tacInspYearBatchObjParam.setProvince(olBisInspOrgService.getRlProvince(getCurrentOrgId()));
  82. List<TacInspYearBatchObjDto> tacInspYearBatchAreaList = tacInspYearBatchObjService.objslistbybatch(tacInspYearBatchObjParam);
  83. return buildSuccessResponse(tacInspYearBatchAreaList);
  84. }
  85. @ApiOperation(value = "获取稽察对象名录表(列表--分页)")
  86. @RequestMapping(value = "/page", method = RequestMethod.POST)
  87. public BaseResponse<PageInfo<TacInspYearBatchObj>> page(@ApiParam(name = "tacInspYearBatchObjParam", value = "tacInspYearBatchObjParam", required = true) @RequestBody TacInspYearBatchObjParam tacInspYearBatchObjParam) {
  88. tacInspYearBatchObjParam.setProvince(olBisInspOrgService.getRlProvince(getCurrentOrgId()));
  89. PageInfo<TacInspYearBatchObj> tacInspYearBatchObjList = tacInspYearBatchObjService.findPageInfo(tacInspYearBatchObjParam);
  90. return buildSuccessResponse(tacInspYearBatchObjList);
  91. }
  92. @ApiOperation(value = "获取稽察对象名录列表list")
  93. @RequestMapping(value = "/getObjList", method = RequestMethod.POST)
  94. public BaseResponse<List<TacInspYearBatchObjDto>> getObjList(@RequestBody TacInspYearBatchObjParam tacInspYearBatchObjParam) {
  95. tacInspYearBatchObjParam.setProvince(olBisInspOrgService.getRlProvince(getCurrentOrgId()));
  96. List<TacInspYearBatchObjDto> list = tacInspYearBatchObjService.getObjList(tacInspYearBatchObjParam);
  97. return buildSuccessResponse(list);
  98. }
  99. @ApiOperation(value = "获取稽察对象名录列表分页列表")
  100. @RequestMapping(value = "/getObjPage", method = RequestMethod.POST)
  101. public BaseResponse<PageInfo<TacInspYearBatchObjDto>> getObjPage(@RequestBody TacInspYearBatchObjParam tacInspYearBatchObjParam) {
  102. tacInspYearBatchObjParam.setProvince(olBisInspOrgService.getRlProvince(getCurrentOrgId()));
  103. PageInfo<TacInspYearBatchObjDto> pageInfo = tacInspYearBatchObjService.getObjPage(tacInspYearBatchObjParam);
  104. return buildSuccessResponse(pageInfo);
  105. }
  106. @ApiOperation(value = "添加督查对象")
  107. @RequestMapping(value = "/inesrtBatchObj", method = RequestMethod.POST)
  108. public BaseResponse inesrtBatchObj(@RequestBody TacObjDto dto) {
  109. if (dto == null) {
  110. return buildFailResponse();
  111. }
  112. dto.setProvince(olBisInspOrgService.getRlProvince(getCurrentOrgId()));
  113. int a = tacInspYearBatchObjService.insertBatchObj(dto);
  114. return buildSuccessResponse();
  115. }
  116. @ApiOperation("根据督查对象删除对象所有信息")
  117. @RequestMapping(value = "/cleanObjById", method = RequestMethod.POST)
  118. public BaseResponse cleanObjById(@RequestBody TacInspYearBatchObjParam tacInspYearBatchObjParam) {
  119. if (StringUtils.isBlank(tacInspYearBatchObjParam.getOjbId())) {
  120. return buildFailResponse(10009, "删除失败");
  121. }
  122. tacInspYearBatchObjParam.setProvince(olBisInspOrgService.getRlProvince(getCurrentOrgId()));
  123. int a = tacInspYearBatchObjService.cleanObjById(tacInspYearBatchObjParam);
  124. return buildSuccessResponse();
  125. }
  126. @ApiOperation("获取不在组下面的基础信息")
  127. @RequestMapping(value = "/getBaseNotInGroupByGroupId", method = RequestMethod.POST)
  128. public BaseResponse<List<TacAttPawpBase>> getBaseNotInGroupByGroupId(@RequestBody TacInspYearBatchObjParam param) {
  129. param.setProvince(olBisInspOrgService.getRlProvince(getCurrentOrgId()));
  130. List<TacAttPawpBase> list = tacInspYearBatchObjService.getBaseNotInGroupByGroupId(param);
  131. return buildSuccessResponse(list);
  132. }
  133. @ApiOperation("获取不在组下面的基础信息")
  134. @RequestMapping(value = "/getBaseNotInGroupPageByGroupId", method = RequestMethod.POST)
  135. public BaseResponse<PageInfo<TacAttPawpBase>> getBaseNotInGroupPageByGroupId(@RequestBody TacInspYearBatchObjParam param) {
  136. param.setProvince(olBisInspOrgService.getRlProvince(getCurrentOrgId()));
  137. PageInfo<TacAttPawpBase> pageInfo = tacInspYearBatchObjService.getBaseNotInGroupPageByGroupId(param);
  138. return buildSuccessResponse(pageInfo);
  139. }
  140. @ApiOperation("获取左侧机构数")
  141. @RequestMapping(value = "/getObjTreeList", method = RequestMethod.POST)
  142. public BaseResponse getObjTreeList(@RequestBody TacInspYearBatchObjParam param) {
  143. if (StringUtils.isBlank(param.getPersId())) {
  144. return buildFailResponse(17001, "人员id不能为空");
  145. }
  146. param.setProvince(olBisInspOrgService.getRlProvince(getCurrentOrgId()));
  147. BisInspAllNode node = tacInspYearBatchObjService.getObjTreeList(param);
  148. return buildSuccessResponse(node);
  149. }
  150. @Autowired
  151. private AttAdBaseService xBaseService;
  152. @ApiOperation("获取左侧机构数")
  153. @RequestMapping(value = "/getObjTreeListV2", method = RequestMethod.POST)
  154. public BaseResponse getObjTreeListV2(@RequestBody TacInspYearBatchObjParam param) {
  155. if (StringUtils.isBlank(param.getPersId())) {
  156. return buildFailResponse(17001, "人员id不能为空");
  157. }
  158. param.setProvince(olBisInspOrgService.getRlProvince(getCurrentOrgId()));
  159. BisInspAllNode node = tacInspYearBatchObjService.getObjTreeList(param);
  160. //获取所有省 ,市,县的行政区数据 前两位
  161. List<AttAdBase> attAdBases = xBaseService.getAllChildByCode(AdLevelUtil.getAddvcd(param.getProvince()));
  162. if (node != null) {
  163. //年度
  164. List<BisInspAllNode> nodeList = node.getChildren();
  165. //批次
  166. List<BisInspAllNode> piciList = new ArrayList<>();
  167. //市级
  168. List<BisInspAllNode> cityList = new ArrayList<>();
  169. if (nodeList == null) {
  170. return buildSuccessResponse(node);
  171. }
  172. for (BisInspAllNode n : nodeList) {
  173. piciList.addAll(n.getChildren());
  174. }
  175. for (BisInspAllNode n : piciList) {
  176. cityList.addAll(n.getChildren());
  177. }
  178. //市级分组
  179. for (BisInspAllNode n : cityList) {
  180. List<BisInspAllNode> leafList = n.getChildren();
  181. Set<String> adCodes = new HashSet<>();
  182. List<BisInspAllNode> xianList = new ArrayList<>();
  183. //获取县级单位
  184. for (BisInspAllNode inspAllNode : leafList) {
  185. if (inspAllNode.getAdCode().contains(",")) {
  186. String[] array = inspAllNode.getAdCode().split(",");
  187. for (String str : array) {
  188. adCodes.add(str);
  189. }
  190. } else {
  191. adCodes.add(inspAllNode.getAdCode());
  192. }
  193. }
  194. //构建县级单位和子模块
  195. for (String str : adCodes) {
  196. BisInspAllNode inspAllNode = new BisInspAllNode();
  197. List<BisInspAllNode> newleafList = new ArrayList<>();
  198. inspAllNode.setPid(n.getId());
  199. String cityId = UuidUtil.uuid();
  200. inspAllNode.setId(cityId);
  201. AttAdBase xBase = null;
  202. for (AttAdBase ad : attAdBases) {
  203. if (ad.getAdCode().equals(str)) {
  204. xBase = ad;
  205. break;
  206. }
  207. }
  208. if (xBase == null) {
  209. xBaseService.get(str);
  210. }
  211. inspAllNode.setPnm(xBase.getAdName());
  212. for (BisInspAllNode leaf : leafList) {
  213. if (leaf.getAdCode().equals(str)) {
  214. leaf.setPid(cityId);
  215. leaf.setAdName(xBase.getAdName());
  216. newleafList.add(leaf);
  217. }
  218. }
  219. inspAllNode.setAdCode(str);
  220. if (!newleafList.isEmpty()) {
  221. inspAllNode.setChildren(newleafList);
  222. }
  223. xianList.add(inspAllNode);
  224. }
  225. n.setChildren(xianList);
  226. }
  227. }
  228. return buildSuccessResponse(node);
  229. }
  230. @ApiOperation("稽察一张图获取项目接口")
  231. @RequestMapping(value = "/getObjListByPersId", method = RequestMethod.POST)
  232. public BaseResponse<List<TacInspYearBatchObjDto>> getObjListByPersId(@RequestBody TacInspYearBatchObjParam param) {
  233. if (StringUtils.isBlank(param.getPersId())) {
  234. return buildFailResponse(17001, "人员id不能为空");
  235. }
  236. param.setProvince(olBisInspOrgService.getRlProvince(getCurrentOrgId()));
  237. List<TacInspYearBatchObjDto> list = tacInspYearBatchObjService.getObjListByPersId(param);
  238. return buildSuccessResponse(list);
  239. }
  240. @ApiOperation("稽察一张图获取项目接口分页")
  241. @RequestMapping(value = "/getObjPageByPersId", method = RequestMethod.POST)
  242. public BaseResponse<PageInfo<TacInspYearBatchObjDto>> getObjPageByPersId(@RequestBody TacInspYearBatchObjParam param) {
  243. if (StringUtils.isBlank(param.getPersId())) {
  244. return buildFailResponse(17001, "人员id不能为空");
  245. }
  246. param.setProvince(olBisInspOrgService.getRlProvince(getCurrentOrgId()));
  247. PageInfo<TacInspYearBatchObjDto> pageInfo = tacInspYearBatchObjService.getObjPageByPersId(param);
  248. return buildSuccessResponse(pageInfo);
  249. }
  250. }