package platform.modules.government.service; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; import platform.common.Constant; import platform.common.base.model.DictionaryItem; import platform.common.base.service.DictionaryItemService; import platform.modules.build.entity.Company; import platform.modules.build.service.CompanyService; import platform.modules.company.entity.*; import platform.modules.company.service.*; import platform.modules.government.dto.AffairsTrackingDto; import platform.modules.government.dto.CheckTrackingNum; import platform.modules.government.dto.SearchCondition; import platform.modules.government.dto.SelectDto; import platform.modules.government.entity.ProjectServiceType; import platform.modules.government.entity.ProjectType; import platform.modules.government.entity.User; import platform.modules.sys.entity.Approval; import platform.modules.sys.entity.Department; import platform.modules.sys.service.ApprovalService; import platform.modules.sys.service.DepartmentService; import java.util.ArrayList; import java.util.List; import org.springframework.ui.ModelMap; import platform.modules.government.dto.OrderTrackingDto; import javax.servlet.http.HttpServletResponse; import java.util.Objects; /** * 功能描述: 政务事务跟踪 * * @param: * @return: * @auther: huZhiHao * @date: 2018/9/21 15:03 */ @Service public class AffairsTrackingService { @Autowired private DepartmentService departmentService; @Autowired private UserService userService; @Autowired private ApprovalService approvalService; @Autowired private StockLandService stockLandService; @Autowired private ProjectApplicationService projectApplicationService; @Autowired private ProjectProvincesService projectProvincesService; @Autowired private ProjectMattersService projectMattersService; @Autowired private ProjectFillingService projectFillingService; @Autowired private CompanyService companyService; @Autowired private DictionaryItemService dictionaryItemService; @Autowired private ProjectIntelligentService projectIntelligentService; @Autowired private ProjectDeclarationService projectDeclarationService; @Autowired private ProjectTypeService projectTypeService; @Autowired private ProjectServiceTypeService projectServiceTypeService; public PageInfo getDepartmentTrack(Integer pageNum, Integer pageSize) { List trackingDtoList = new ArrayList<>(); // PageHelper.startPage(pageNum, Integer.MAX_VALUE); List departmentList = departmentService.findDepartment(); if (departmentList != null && departmentList.size() > 0) { for (Department department : departmentList) { List userList = userService.getAllDepartmentUsers(department.getId()); if (userList != null && userList.size() > 0) { AffairsTrackingDto trackingDto = approvalService.getDepartmentTrack(userList); trackingDto.setDepartmentName(department.getName()); trackingDto.setPersonNum(userList.size()); trackingDto.setDeaprtmentId(department.getId()); trackingDtoList.add(trackingDto); } } } // PageInfo departmentPageInfo = new PageInfo<>(departmentList); PageInfo affairsTrackingDtoPageInfo = new PageInfo<>(trackingDtoList); affairsTrackingDtoPageInfo.setPageSize(pageSize); affairsTrackingDtoPageInfo.setPageNum(pageNum); affairsTrackingDtoPageInfo.setList(trackingDtoList); return affairsTrackingDtoPageInfo; } /** * 按部门获取数据 * @param departmentId * @return */ public AffairsTrackingDto getTableView(Integer departmentId) { Department department = departmentService.selectById(departmentId); List userList = userService.getAllDepartmentUsers(department.getId()); AffairsTrackingDto trackingDto = new AffairsTrackingDto(); trackingDto.setDepartmentName(department.getName()); trackingDto.setDeaprtmentId(department.getId()); if (userList != null && userList.size() > 0) { trackingDto = approvalService.getDepartmentTrack(userList); trackingDto.setDepartmentName(department.getName()); trackingDto.setDeaprtmentId(department.getId()); trackingDto.setPersonNum(userList.size()); } else { trackingDto.setDepartmentName(department.getName()); trackingDto.setDeaprtmentId(department.getId()); trackingDto.setPersonNum(0); trackingDto.setTotalHandelNum(0); trackingDto.setFillingHandleNum(0); trackingDto.setProjectHandleNum(0); trackingDto.setStocklandHandleNum(0); trackingDto.setMattersHandleNum(0); trackingDto.setProvincesHandleNum(0); } return trackingDto; } public PageInfo getTrackByUser(Integer pageNum, Integer pagesize, SearchCondition searchCondition) { List checkTrackingNumList = new ArrayList<>(); //按审核人查询 List userList; if (searchCondition.getCheckName() != null && !"".equals(searchCondition.getCheckName())) { userList = userService.getUserByName(searchCondition.getCheckName()); if (userList != null && userList.size() > 0) { for (User user : userList) { CheckTrackingNum trackingDto = approvalService.getTrackByUser(user.getId()); trackingDto.setCheckName(user.getUser_name()); trackingDto.setUserId(user.getId()); checkTrackingNumList.add(trackingDto); } } } else { PageHelper.startPage(pageNum, pagesize); userList = userService.getAllDepartmentUsers(searchCondition.getDepartmentId()); if (userList != null && userList.size() > 0) { for (User user : userList) { searchCondition.setCheckName(user.getUser_name()); searchCondition.setUserId(user.getId()); CheckTrackingNum trackingDto = approvalService.getTrackByUser(user.getId()); trackingDto.setCheckName(user.getUser_name()); trackingDto.setUserId(user.getId()); checkTrackingNumList.add(trackingDto); } } } PageInfo pageInfo = new PageInfo<>(checkTrackingNumList); pageInfo.setTotal(userList.size()); pageInfo.setPageNum(pageNum); pageInfo.setPageSize(pagesize); return pageInfo; } public PageInfo getDocumentByUser (Integer pageNum, Integer pagesize, SearchCondition searchCondition){ Integer userId = searchCondition.getUserId(); User user = userService.findById(userId); searchCondition.setCheckName(user.getUser_name()); //搜索条件查询 String businessType = searchCondition.getBusinessType(); if (businessType != null && !"".equals(businessType)){ if (Objects.equals("1", businessType)) { searchCondition.setBusinessName(Constant.DictionaryType.PROJECT_APPLICATION); } else if (Objects.equals("2", businessType)) { searchCondition.setBusinessName(Constant.DictionaryType.PROJECT_PROVINCES); } else if (Objects.equals("3", businessType)) { searchCondition.setBusinessName(Constant.DictionaryType.PROJECT_FILLING); } else if (Objects.equals("4", businessType)) { searchCondition.setBusinessName(Constant.DictionaryType.PROJECT_MATTERS); } else if (Objects.equals("5", businessType)) { searchCondition.setBusinessName(Constant.DictionaryType.STOCKLAND); } } PageHelper.startPage(pageNum, pagesize); List checkTrackingNumList = approvalService.getSearchDocumentByUser(searchCondition); // PageHelper.startPage(pageNum, pagesize); // List approvalList = approvalService.getDocumentByUser(searchCondition); // if (approvalList != null && approvalList.size() > 0) { // for (Approval approval : approvalList) { // int applyId = approval.getApply_id(); // CheckTrackingNum checkTrackingNum = new CheckTrackingNum(); // checkTrackingNum.setCheckName(user.getUser_name()); // checkTrackingNum.setApplyId(applyId); // //存量用地 // if (approval.getType().equals(Constant.DictionaryType.STOCKLAND)) { // checkTrackingNum.setAffairsType(Constant.DictionaryType.STOCKLAND); // checkTrackingNum.setBusinessType(5); // StockLand stockLand = stockLandService.findById(applyId); // if (stockLand != null) { // checkTrackingNum.setApplyNo(stockLand.getApply_no()); // Company company = companyService.findById(stockLand.getCompany_id()); // checkTrackingNum.setCompany(company.getCompany_name()); // //单据状态 // DictionaryItem dictionaryItem = dictionaryItemService.findByTypeAndValue(Constant.DictionaryType.STOCKLAND_APPROVE_STATUS, stockLand.getApprove_status()); // if (dictionaryItem != null) { // checkTrackingNum.setApplyStatus(dictionaryItem.getName()); // } // } // checkTrackingNum.setApproveTime(approval.getDeal_time()); // } // //区级工业经济扶持 // if (approval.getType().equals(Constant.DictionaryType.PROJECT_APPLICATION)) { // checkTrackingNum.setAffairsType(Constant.DictionaryType.PROJECT_APPLICATION); // checkTrackingNum.setBusinessType(1); // ProjectApplication application = projectApplicationService.findById(approval.getApply_id()); // if (application != null) { // checkTrackingNum.setApplyNo(application.getApply_no()); // Company company = companyService.findById(application.getCompany_id()); // checkTrackingNum.setCompany(company.getCompany_name()); // //单据状态 // DictionaryItem dictionaryItem = dictionaryItemService.findByTypeAndValue(Constant.DictionaryType.PROJECT_APPROVE_STATUS, application.getApprove_status()); // if (dictionaryItem != null) { // checkTrackingNum.setApplyStatus(dictionaryItem.getName()); // } // } // checkTrackingNum.setApproveTime(approval.getDeal_time()); // } // //省市申报 // if (approval.getType().equals(Constant.DictionaryType.PROJECT_PROVINCES)) { // checkTrackingNum.setAffairsType(Constant.DictionaryType.PROJECT_PROVINCES); // checkTrackingNum.setBusinessType(2); // ProjectProvinces projectProvinces = projectProvincesService.findById(approval.getApply_id()); // if (projectProvinces != null) { // Company company = companyService.findById(projectProvinces.getCompany_id()); // checkTrackingNum.setCompany(company.getCompany_name()); // //单据状态 // DictionaryItem dictionaryItem = dictionaryItemService.findByTypeAndValue(Constant.DictionaryType.PROJECT_PROVINCES_APPROVE_STATUS, projectProvinces.getApprove_status()); // if (dictionaryItem != null) { // checkTrackingNum.setApplyStatus(dictionaryItem.getName()); // } // } // checkTrackingNum.setApproveTime(approval.getDeal_time()); // } // //服务事项 // if (approval.getType().equals(Constant.DictionaryType.PROJECT_MATTERS)) { // checkTrackingNum.setAffairsType(Constant.DictionaryType.PROJECT_MATTERS); // checkTrackingNum.setBusinessType(4); // ProjectMatters projectMatters = projectMattersService.findById(approval.getApply_id()); // if (projectMatters != null) { // Company company = companyService.findById(projectMatters.getCompany_id()); // checkTrackingNum.setCompany(company.getCompany_name()); // //单据状态 // DictionaryItem dictionaryItem = dictionaryItemService.findByTypeAndValue(Constant.DictionaryType.PROJECT_MATTERS_APPROVE_STATUS, projectMatters.getApprove_status()); // if (dictionaryItem != null) { // checkTrackingNum.setApplyStatus(dictionaryItem.getName()); // } // } // checkTrackingNum.setApproveTime(approval.getDeal_time()); // } // //报表填报 // if (approval.getType().equals(Constant.DictionaryType.PROJECT_FILLING)) { // checkTrackingNum.setAffairsType(Constant.DictionaryType.PROJECT_FILLING); // checkTrackingNum.setBusinessType(3); // ProjectFilling projectFilling = projectFillingService.findById(approval.getApply_id()); // if (projectFilling != null) { // Company company = companyService.findById(projectFilling.getCompany_id()); // checkTrackingNum.setCompany(company.getCompany_name()); // //单据状态 // DictionaryItem dictionaryItem = dictionaryItemService.findByTypeAndValue(Constant.DictionaryType.PROJECT_FILLING_APPROVE_STATUS, projectFilling.getApprove_status()); // if (dictionaryItem != null) { // checkTrackingNum.setApplyStatus(dictionaryItem.getName()); // } // } // checkTrackingNum.setApproveTime(approval.getDeal_time()); // } // checkTrackingNumList.add(checkTrackingNum); // } // } // PageInfo approvalPageInfo = new PageInfo<>(approvalList); PageInfo checkTrackingNumPageInfo = new PageInfo<>(checkTrackingNumList); // checkTrackingNumPageInfo.setTotal(approvalPageInfo.getTotal()); // checkTrackingNumPageInfo.setList(checkTrackingNumList); // checkTrackingNumPageInfo.setPageNum(approvalPageInfo.getPageNum()); // checkTrackingNumPageInfo.setPageSize(approvalPageInfo.getPageSize()); // checkTrackingNumPageInfo.setPages(approvalPageInfo.getPages()); return checkTrackingNumPageInfo; } /** * 功能描述: 单据跟踪 * * @param: * @return: * @auther: huZhiHao * @date: 2018/9/25 17:55 */ public PageInfo findOrderTrackingPage (Integer pageNum, Integer pagesize, String businessType, String typeId, String number, String companyName, String startDate, String endDate){ return projectDeclarationService.findOrderTrackingPage(pageNum, pagesize, businessType, typeId, number, companyName, startDate, endDate); } /** * 功能描述:跳转到详情 * * @param: * @return: * @auther: huZhiHao * @date: 2018/9/26 14:49 */ public String getOrderDetail(ModelMap modelMap, Integer id, String type) { if (Objects.equals("1", type)) { projectApplicationService.getApplyInfo(id, modelMap); projectApplicationService.getDictInfo(modelMap); projectDeclarationService.getMaterial(id, modelMap); return "project/apply_view"; } else if (Objects.equals("2", type)) { projectProvincesService.getApplyInfo(id, modelMap); projectProvincesService.getDictInfo(modelMap); return "project_provinces/approve_check"; } else if (Objects.equals("3", type)) { projectFillingService.getApplyInfo(id, modelMap); projectFillingService.getDictInfo(modelMap); return "project_filling/approve_check"; } else if (Objects.equals("4", type)) { projectMattersService.getApplyInfo(id, modelMap); projectMattersService.getDictInfo(modelMap); return "project_matters/approve_check"; } else if (Objects.equals("5", type)) { stockLandService.getApplyInfo(id, modelMap); stockLandService.getDictInfo(modelMap); return "stock_land/apply_check"; } return null; } /** * 功能描述: 导出excel * * @param: * @return: * @auther: huZhiHao * @date: 2018/9/26 16:31 */ public void exportOrder(HttpServletResponse response, String businessType, String typeId, String number, String companyName, String startDate, String endDate) throws Exception { projectDeclarationService.exportOrder(response, businessType, typeId, number, companyName, startDate, endDate); } /** * 功能描述: 根据政务类型获取申请类别 * * @param: * @return: * @auther: huZhiHao * @date: 2018/9/26 16:38 */ public List getOrderType(String businessType) { List selectList = new ArrayList<>(); if (Objects.equals("1", businessType)) { List projectTypeList = projectTypeService.selectAllProjectType(); if (!CollectionUtils.isEmpty(projectTypeList)) { for (ProjectType projectType : projectTypeList) { SelectDto selectDto = new SelectDto(); selectDto.setName(projectType.getType_name()); selectDto.setId(projectType.getId()); selectList.add(selectDto); } } } else if (Objects.equals("2", businessType)) { List list = projectServiceTypeService.findBySuperType("1"); if (!CollectionUtils.isEmpty(list)) { for (ProjectServiceType projectServiceType : list) { SelectDto selectDto = new SelectDto(); selectDto.setName(projectServiceType.getService_type_name()); selectDto.setId(projectServiceType.getId()); selectList.add(selectDto); } } } else if (Objects.equals("3", businessType)) { List list = projectServiceTypeService.findBySuperType("2"); if (!CollectionUtils.isEmpty(list)) { for (ProjectServiceType projectServiceType : list) { SelectDto selectDto = new SelectDto(); selectDto.setName(projectServiceType.getService_type_name()); selectDto.setId(projectServiceType.getId()); selectList.add(selectDto); } } } else if (Objects.equals("4", businessType)) { List list = projectServiceTypeService.findBySuperType("3"); if (!CollectionUtils.isEmpty(list)) { for (ProjectServiceType projectServiceType : list) { SelectDto selectDto = new SelectDto(); selectDto.setName(projectServiceType.getService_type_name()); selectDto.setId(projectServiceType.getId()); selectList.add(selectDto); } } } else if (Objects.equals("5", businessType)) { List list = dictionaryItemService.findListByTypeName(Constant.DictionaryType.STOCKLAND); if (!CollectionUtils.isEmpty(list)) { for (DictionaryItem dictionaryItem : list) { SelectDto selectDto = new SelectDto(); selectDto.setName(dictionaryItem.getName()); selectDto.setId(Integer.parseInt(dictionaryItem.getValue())); selectList.add(selectDto); } } } return selectList; } public List getApprovalStatus(String businessType) { List dictionaryItems = new ArrayList<>(); if (Objects.equals("1", businessType)) { dictionaryItems = dictionaryItemService.findListByTypeName(Constant.DictionaryType.PROJECT_APPROVE_STATUS); } else if (Objects.equals("2", businessType)) { dictionaryItems = dictionaryItemService.findListByTypeName(Constant.DictionaryType.PROJECT_PROVINCES_APPROVE_STATUS); } else if (Objects.equals("3", businessType)) { dictionaryItems = dictionaryItemService.findListByTypeName(Constant.DictionaryType.PROJECT_FILLING_APPROVE_STATUS); } else if (Objects.equals("4", businessType)) { dictionaryItems = dictionaryItemService.findListByTypeName(Constant.DictionaryType.PROJECT_MATTERS_APPROVE_STATUS); } else if (Objects.equals("5", businessType)) { dictionaryItems = dictionaryItemService.findListByTypeName(Constant.DictionaryType.STOCKLAND_APPROVE_STATUS); } return dictionaryItems; } }