AffairsTrackingService.java 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452
  1. package platform.modules.government.service;
  2. import com.github.pagehelper.PageHelper;
  3. import com.github.pagehelper.PageInfo;
  4. import org.springframework.beans.factory.annotation.Autowired;
  5. import org.springframework.stereotype.Service;
  6. import org.springframework.util.CollectionUtils;
  7. import platform.common.Constant;
  8. import platform.common.base.model.DictionaryItem;
  9. import platform.common.base.service.DictionaryItemService;
  10. import platform.modules.build.entity.Company;
  11. import platform.modules.build.service.CompanyService;
  12. import platform.modules.company.entity.*;
  13. import platform.modules.company.service.*;
  14. import platform.modules.government.dto.AffairsTrackingDto;
  15. import platform.modules.government.dto.CheckTrackingNum;
  16. import platform.modules.government.dto.SearchCondition;
  17. import platform.modules.government.dto.SelectDto;
  18. import platform.modules.government.entity.ProjectServiceType;
  19. import platform.modules.government.entity.ProjectType;
  20. import platform.modules.government.entity.User;
  21. import platform.modules.sys.entity.Approval;
  22. import platform.modules.sys.entity.Department;
  23. import platform.modules.sys.service.ApprovalService;
  24. import platform.modules.sys.service.DepartmentService;
  25. import java.util.ArrayList;
  26. import java.util.List;
  27. import org.springframework.ui.ModelMap;
  28. import platform.modules.government.dto.OrderTrackingDto;
  29. import javax.servlet.http.HttpServletResponse;
  30. import java.util.Objects;
  31. /**
  32. * 功能描述: 政务事务跟踪
  33. *
  34. * @param:
  35. * @return:
  36. * @auther: huZhiHao
  37. * @date: 2018/9/21 15:03
  38. */
  39. @Service
  40. public class AffairsTrackingService {
  41. @Autowired
  42. private DepartmentService departmentService;
  43. @Autowired
  44. private UserService userService;
  45. @Autowired
  46. private ApprovalService approvalService;
  47. @Autowired
  48. private StockLandService stockLandService;
  49. @Autowired
  50. private ProjectApplicationService projectApplicationService;
  51. @Autowired
  52. private ProjectProvincesService projectProvincesService;
  53. @Autowired
  54. private ProjectMattersService projectMattersService;
  55. @Autowired
  56. private ProjectFillingService projectFillingService;
  57. @Autowired
  58. private CompanyService companyService;
  59. @Autowired
  60. private DictionaryItemService dictionaryItemService;
  61. @Autowired
  62. private ProjectIntelligentService projectIntelligentService;
  63. @Autowired
  64. private ProjectDeclarationService projectDeclarationService;
  65. @Autowired
  66. private ProjectTypeService projectTypeService;
  67. @Autowired
  68. private ProjectServiceTypeService projectServiceTypeService;
  69. public PageInfo<AffairsTrackingDto> getDepartmentTrack(Integer pageNum, Integer pageSize) {
  70. List<AffairsTrackingDto> trackingDtoList = new ArrayList<>();
  71. // PageHelper.startPage(pageNum, Integer.MAX_VALUE);
  72. List<Department> departmentList = departmentService.findDepartment();
  73. if (departmentList != null && departmentList.size() > 0) {
  74. for (Department department : departmentList) {
  75. List<User> userList = userService.getAllDepartmentUsers(department.getId());
  76. if (userList != null && userList.size() > 0) {
  77. AffairsTrackingDto trackingDto = approvalService.getDepartmentTrack(userList);
  78. trackingDto.setDepartmentName(department.getName());
  79. trackingDto.setPersonNum(userList.size());
  80. trackingDto.setDeaprtmentId(department.getId());
  81. trackingDtoList.add(trackingDto);
  82. }
  83. }
  84. }
  85. // PageInfo<Department> departmentPageInfo = new PageInfo<>(departmentList);
  86. PageInfo<AffairsTrackingDto> affairsTrackingDtoPageInfo = new PageInfo<>(trackingDtoList);
  87. affairsTrackingDtoPageInfo.setPageSize(pageSize);
  88. affairsTrackingDtoPageInfo.setPageNum(pageNum);
  89. affairsTrackingDtoPageInfo.setList(trackingDtoList);
  90. return affairsTrackingDtoPageInfo;
  91. }
  92. /**
  93. * 按部门获取数据
  94. * @param departmentId
  95. * @return
  96. */
  97. public AffairsTrackingDto getTableView(Integer departmentId) {
  98. Department department = departmentService.selectById(departmentId);
  99. List<User> userList = userService.getAllDepartmentUsers(department.getId());
  100. AffairsTrackingDto trackingDto = new AffairsTrackingDto();
  101. trackingDto.setDepartmentName(department.getName());
  102. trackingDto.setDeaprtmentId(department.getId());
  103. if (userList != null && userList.size() > 0) {
  104. trackingDto = approvalService.getDepartmentTrack(userList);
  105. trackingDto.setDepartmentName(department.getName());
  106. trackingDto.setDeaprtmentId(department.getId());
  107. trackingDto.setPersonNum(userList.size());
  108. }
  109. else {
  110. trackingDto.setDepartmentName(department.getName());
  111. trackingDto.setDeaprtmentId(department.getId());
  112. trackingDto.setPersonNum(0);
  113. trackingDto.setTotalHandelNum(0);
  114. trackingDto.setFillingHandleNum(0);
  115. trackingDto.setProjectHandleNum(0);
  116. trackingDto.setStocklandHandleNum(0);
  117. trackingDto.setMattersHandleNum(0);
  118. trackingDto.setProvincesHandleNum(0);
  119. }
  120. return trackingDto;
  121. }
  122. public PageInfo<CheckTrackingNum> getTrackByUser(Integer pageNum, Integer pagesize, SearchCondition searchCondition) {
  123. List<CheckTrackingNum> checkTrackingNumList = new ArrayList<>();
  124. //按审核人查询
  125. List<User> userList;
  126. if (searchCondition.getCheckName() != null && !"".equals(searchCondition.getCheckName())) {
  127. userList = userService.getUserByName(searchCondition.getCheckName());
  128. if (userList != null && userList.size() > 0) {
  129. for (User user : userList) {
  130. CheckTrackingNum trackingDto = approvalService.getTrackByUser(user.getId());
  131. trackingDto.setCheckName(user.getUser_name());
  132. trackingDto.setUserId(user.getId());
  133. checkTrackingNumList.add(trackingDto);
  134. }
  135. }
  136. } else {
  137. PageHelper.startPage(pageNum, pagesize);
  138. userList = userService.getAllDepartmentUsers(searchCondition.getDepartmentId());
  139. if (userList != null && userList.size() > 0) {
  140. for (User user : userList) {
  141. searchCondition.setCheckName(user.getUser_name());
  142. searchCondition.setUserId(user.getId());
  143. CheckTrackingNum trackingDto = approvalService.getTrackByUser(user.getId());
  144. trackingDto.setCheckName(user.getUser_name());
  145. trackingDto.setUserId(user.getId());
  146. checkTrackingNumList.add(trackingDto);
  147. }
  148. }
  149. }
  150. PageInfo<CheckTrackingNum> pageInfo = new PageInfo<>(checkTrackingNumList);
  151. pageInfo.setTotal(userList.size());
  152. pageInfo.setPageNum(pageNum);
  153. pageInfo.setPageSize(pagesize);
  154. return pageInfo;
  155. }
  156. public PageInfo<CheckTrackingNum> getDocumentByUser (Integer pageNum, Integer pagesize, SearchCondition searchCondition){
  157. Integer userId = searchCondition.getUserId();
  158. User user = userService.findById(userId);
  159. searchCondition.setCheckName(user.getUser_name());
  160. //搜索条件查询
  161. String businessType = searchCondition.getBusinessType();
  162. if (businessType != null && !"".equals(businessType)){
  163. if (Objects.equals("1", businessType)) {
  164. searchCondition.setBusinessName(Constant.DictionaryType.PROJECT_APPLICATION);
  165. } else if (Objects.equals("2", businessType)) {
  166. searchCondition.setBusinessName(Constant.DictionaryType.PROJECT_PROVINCES);
  167. } else if (Objects.equals("3", businessType)) {
  168. searchCondition.setBusinessName(Constant.DictionaryType.PROJECT_FILLING);
  169. } else if (Objects.equals("4", businessType)) {
  170. searchCondition.setBusinessName(Constant.DictionaryType.PROJECT_MATTERS);
  171. } else if (Objects.equals("5", businessType)) {
  172. searchCondition.setBusinessName(Constant.DictionaryType.STOCKLAND);
  173. }
  174. }
  175. PageHelper.startPage(pageNum, pagesize);
  176. List<CheckTrackingNum> checkTrackingNumList = approvalService.getSearchDocumentByUser(searchCondition);
  177. // PageHelper.startPage(pageNum, pagesize);
  178. // List<Approval> approvalList = approvalService.getDocumentByUser(searchCondition);
  179. // if (approvalList != null && approvalList.size() > 0) {
  180. // for (Approval approval : approvalList) {
  181. // int applyId = approval.getApply_id();
  182. // CheckTrackingNum checkTrackingNum = new CheckTrackingNum();
  183. // checkTrackingNum.setCheckName(user.getUser_name());
  184. // checkTrackingNum.setApplyId(applyId);
  185. // //存量用地
  186. // if (approval.getType().equals(Constant.DictionaryType.STOCKLAND)) {
  187. // checkTrackingNum.setAffairsType(Constant.DictionaryType.STOCKLAND);
  188. // checkTrackingNum.setBusinessType(5);
  189. // StockLand stockLand = stockLandService.findById(applyId);
  190. // if (stockLand != null) {
  191. // checkTrackingNum.setApplyNo(stockLand.getApply_no());
  192. // Company company = companyService.findById(stockLand.getCompany_id());
  193. // checkTrackingNum.setCompany(company.getCompany_name());
  194. // //单据状态
  195. // DictionaryItem dictionaryItem = dictionaryItemService.findByTypeAndValue(Constant.DictionaryType.STOCKLAND_APPROVE_STATUS, stockLand.getApprove_status());
  196. // if (dictionaryItem != null) {
  197. // checkTrackingNum.setApplyStatus(dictionaryItem.getName());
  198. // }
  199. // }
  200. // checkTrackingNum.setApproveTime(approval.getDeal_time());
  201. // }
  202. // //区级工业经济扶持
  203. // if (approval.getType().equals(Constant.DictionaryType.PROJECT_APPLICATION)) {
  204. // checkTrackingNum.setAffairsType(Constant.DictionaryType.PROJECT_APPLICATION);
  205. // checkTrackingNum.setBusinessType(1);
  206. // ProjectApplication application = projectApplicationService.findById(approval.getApply_id());
  207. // if (application != null) {
  208. // checkTrackingNum.setApplyNo(application.getApply_no());
  209. // Company company = companyService.findById(application.getCompany_id());
  210. // checkTrackingNum.setCompany(company.getCompany_name());
  211. // //单据状态
  212. // DictionaryItem dictionaryItem = dictionaryItemService.findByTypeAndValue(Constant.DictionaryType.PROJECT_APPROVE_STATUS, application.getApprove_status());
  213. // if (dictionaryItem != null) {
  214. // checkTrackingNum.setApplyStatus(dictionaryItem.getName());
  215. // }
  216. // }
  217. // checkTrackingNum.setApproveTime(approval.getDeal_time());
  218. // }
  219. // //省市申报
  220. // if (approval.getType().equals(Constant.DictionaryType.PROJECT_PROVINCES)) {
  221. // checkTrackingNum.setAffairsType(Constant.DictionaryType.PROJECT_PROVINCES);
  222. // checkTrackingNum.setBusinessType(2);
  223. // ProjectProvinces projectProvinces = projectProvincesService.findById(approval.getApply_id());
  224. // if (projectProvinces != null) {
  225. // Company company = companyService.findById(projectProvinces.getCompany_id());
  226. // checkTrackingNum.setCompany(company.getCompany_name());
  227. // //单据状态
  228. // DictionaryItem dictionaryItem = dictionaryItemService.findByTypeAndValue(Constant.DictionaryType.PROJECT_PROVINCES_APPROVE_STATUS, projectProvinces.getApprove_status());
  229. // if (dictionaryItem != null) {
  230. // checkTrackingNum.setApplyStatus(dictionaryItem.getName());
  231. // }
  232. // }
  233. // checkTrackingNum.setApproveTime(approval.getDeal_time());
  234. // }
  235. // //服务事项
  236. // if (approval.getType().equals(Constant.DictionaryType.PROJECT_MATTERS)) {
  237. // checkTrackingNum.setAffairsType(Constant.DictionaryType.PROJECT_MATTERS);
  238. // checkTrackingNum.setBusinessType(4);
  239. // ProjectMatters projectMatters = projectMattersService.findById(approval.getApply_id());
  240. // if (projectMatters != null) {
  241. // Company company = companyService.findById(projectMatters.getCompany_id());
  242. // checkTrackingNum.setCompany(company.getCompany_name());
  243. // //单据状态
  244. // DictionaryItem dictionaryItem = dictionaryItemService.findByTypeAndValue(Constant.DictionaryType.PROJECT_MATTERS_APPROVE_STATUS, projectMatters.getApprove_status());
  245. // if (dictionaryItem != null) {
  246. // checkTrackingNum.setApplyStatus(dictionaryItem.getName());
  247. // }
  248. // }
  249. // checkTrackingNum.setApproveTime(approval.getDeal_time());
  250. // }
  251. // //报表填报
  252. // if (approval.getType().equals(Constant.DictionaryType.PROJECT_FILLING)) {
  253. // checkTrackingNum.setAffairsType(Constant.DictionaryType.PROJECT_FILLING);
  254. // checkTrackingNum.setBusinessType(3);
  255. // ProjectFilling projectFilling = projectFillingService.findById(approval.getApply_id());
  256. // if (projectFilling != null) {
  257. // Company company = companyService.findById(projectFilling.getCompany_id());
  258. // checkTrackingNum.setCompany(company.getCompany_name());
  259. // //单据状态
  260. // DictionaryItem dictionaryItem = dictionaryItemService.findByTypeAndValue(Constant.DictionaryType.PROJECT_FILLING_APPROVE_STATUS, projectFilling.getApprove_status());
  261. // if (dictionaryItem != null) {
  262. // checkTrackingNum.setApplyStatus(dictionaryItem.getName());
  263. // }
  264. // }
  265. // checkTrackingNum.setApproveTime(approval.getDeal_time());
  266. // }
  267. // checkTrackingNumList.add(checkTrackingNum);
  268. // }
  269. // }
  270. // PageInfo<Approval> approvalPageInfo = new PageInfo<>(approvalList);
  271. PageInfo<CheckTrackingNum> checkTrackingNumPageInfo = new PageInfo<>(checkTrackingNumList);
  272. // checkTrackingNumPageInfo.setTotal(approvalPageInfo.getTotal());
  273. // checkTrackingNumPageInfo.setList(checkTrackingNumList);
  274. // checkTrackingNumPageInfo.setPageNum(approvalPageInfo.getPageNum());
  275. // checkTrackingNumPageInfo.setPageSize(approvalPageInfo.getPageSize());
  276. // checkTrackingNumPageInfo.setPages(approvalPageInfo.getPages());
  277. return checkTrackingNumPageInfo;
  278. }
  279. /**
  280. * 功能描述: 单据跟踪
  281. *
  282. * @param:
  283. * @return:
  284. * @auther: huZhiHao
  285. * @date: 2018/9/25 17:55
  286. */
  287. public PageInfo<OrderTrackingDto> findOrderTrackingPage (Integer pageNum, Integer pagesize, String
  288. businessType, String typeId, String number, String companyName, String startDate, String endDate){
  289. return projectDeclarationService.findOrderTrackingPage(pageNum, pagesize, businessType, typeId, number, companyName, startDate, endDate);
  290. }
  291. /**
  292. * 功能描述:跳转到详情
  293. *
  294. * @param:
  295. * @return:
  296. * @auther: huZhiHao
  297. * @date: 2018/9/26 14:49
  298. */
  299. public String getOrderDetail(ModelMap modelMap, Integer id, String type) {
  300. if (Objects.equals("1", type)) {
  301. projectApplicationService.getApplyInfo(id, modelMap);
  302. projectApplicationService.getDictInfo(modelMap);
  303. projectDeclarationService.getMaterial(id, modelMap);
  304. return "project/apply_view";
  305. } else if (Objects.equals("2", type)) {
  306. projectProvincesService.getApplyInfo(id, modelMap);
  307. projectProvincesService.getDictInfo(modelMap);
  308. return "project_provinces/approve_check";
  309. } else if (Objects.equals("3", type)) {
  310. projectFillingService.getApplyInfo(id, modelMap);
  311. projectFillingService.getDictInfo(modelMap);
  312. return "project_filling/approve_check";
  313. } else if (Objects.equals("4", type)) {
  314. projectMattersService.getApplyInfo(id, modelMap);
  315. projectMattersService.getDictInfo(modelMap);
  316. return "project_matters/approve_check";
  317. } else if (Objects.equals("5", type)) {
  318. stockLandService.getApplyInfo(id, modelMap);
  319. stockLandService.getDictInfo(modelMap);
  320. return "stock_land/apply_check";
  321. }
  322. return null;
  323. }
  324. /**
  325. * 功能描述: 导出excel
  326. *
  327. * @param:
  328. * @return:
  329. * @auther: huZhiHao
  330. * @date: 2018/9/26 16:31
  331. */
  332. public void exportOrder(HttpServletResponse response, String businessType, String typeId, String number, String
  333. companyName, String startDate, String endDate) throws Exception {
  334. projectDeclarationService.exportOrder(response, businessType, typeId, number, companyName, startDate, endDate);
  335. }
  336. /**
  337. * 功能描述: 根据政务类型获取申请类别
  338. *
  339. * @param:
  340. * @return:
  341. * @auther: huZhiHao
  342. * @date: 2018/9/26 16:38
  343. */
  344. public List<SelectDto> getOrderType(String businessType) {
  345. List<SelectDto> selectList = new ArrayList<>();
  346. if (Objects.equals("1", businessType)) {
  347. List<ProjectType> projectTypeList = projectTypeService.selectAllProjectType();
  348. if (!CollectionUtils.isEmpty(projectTypeList)) {
  349. for (ProjectType projectType : projectTypeList) {
  350. SelectDto selectDto = new SelectDto();
  351. selectDto.setName(projectType.getType_name());
  352. selectDto.setId(projectType.getId());
  353. selectList.add(selectDto);
  354. }
  355. }
  356. } else if (Objects.equals("2", businessType)) {
  357. List<ProjectServiceType> list = projectServiceTypeService.findBySuperType("1");
  358. if (!CollectionUtils.isEmpty(list)) {
  359. for (ProjectServiceType projectServiceType : list) {
  360. SelectDto selectDto = new SelectDto();
  361. selectDto.setName(projectServiceType.getService_type_name());
  362. selectDto.setId(projectServiceType.getId());
  363. selectList.add(selectDto);
  364. }
  365. }
  366. } else if (Objects.equals("3", businessType)) {
  367. List<ProjectServiceType> list = projectServiceTypeService.findBySuperType("2");
  368. if (!CollectionUtils.isEmpty(list)) {
  369. for (ProjectServiceType projectServiceType : list) {
  370. SelectDto selectDto = new SelectDto();
  371. selectDto.setName(projectServiceType.getService_type_name());
  372. selectDto.setId(projectServiceType.getId());
  373. selectList.add(selectDto);
  374. }
  375. }
  376. } else if (Objects.equals("4", businessType)) {
  377. List<ProjectServiceType> list = projectServiceTypeService.findBySuperType("3");
  378. if (!CollectionUtils.isEmpty(list)) {
  379. for (ProjectServiceType projectServiceType : list) {
  380. SelectDto selectDto = new SelectDto();
  381. selectDto.setName(projectServiceType.getService_type_name());
  382. selectDto.setId(projectServiceType.getId());
  383. selectList.add(selectDto);
  384. }
  385. }
  386. } else if (Objects.equals("5", businessType)) {
  387. List<DictionaryItem> list = dictionaryItemService.findListByTypeName(Constant.DictionaryType.STOCKLAND);
  388. if (!CollectionUtils.isEmpty(list)) {
  389. for (DictionaryItem dictionaryItem : list) {
  390. SelectDto selectDto = new SelectDto();
  391. selectDto.setName(dictionaryItem.getName());
  392. selectDto.setId(Integer.parseInt(dictionaryItem.getValue()));
  393. selectList.add(selectDto);
  394. }
  395. }
  396. }
  397. return selectList;
  398. }
  399. public List<DictionaryItem> getApprovalStatus(String businessType) {
  400. List<DictionaryItem> dictionaryItems = new ArrayList<>();
  401. if (Objects.equals("1", businessType)) {
  402. dictionaryItems = dictionaryItemService.findListByTypeName(Constant.DictionaryType.PROJECT_APPROVE_STATUS);
  403. } else if (Objects.equals("2", businessType)) {
  404. dictionaryItems = dictionaryItemService.findListByTypeName(Constant.DictionaryType.PROJECT_PROVINCES_APPROVE_STATUS);
  405. } else if (Objects.equals("3", businessType)) {
  406. dictionaryItems = dictionaryItemService.findListByTypeName(Constant.DictionaryType.PROJECT_FILLING_APPROVE_STATUS);
  407. } else if (Objects.equals("4", businessType)) {
  408. dictionaryItems = dictionaryItemService.findListByTypeName(Constant.DictionaryType.PROJECT_MATTERS_APPROVE_STATUS);
  409. } else if (Objects.equals("5", businessType)) {
  410. dictionaryItems = dictionaryItemService.findListByTypeName(Constant.DictionaryType.STOCKLAND_APPROVE_STATUS);
  411. }
  412. return dictionaryItems;
  413. }
  414. }