package platform.modules.company.service; import com.alibaba.fastjson.JSONObject; import com.aliyuncs.exceptions.ClientException; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.ui.ModelMap; import org.springframework.util.CollectionUtils; import platform.common.Constant; import platform.common.base.model.DictionaryItem; import platform.common.base.service.BaseService; import platform.common.base.service.DictionaryItemService; import platform.common.exception.BaseException; import platform.common.util.AlibabaSMSUtil; import platform.common.util.DateUtil; import platform.common.util.GenerateNoUtil; import platform.common.util.ShiroUtils; import platform.modules.build.entity.Company; import platform.modules.build.service.CompanyService; import platform.modules.company.dao.ProjectMattersDao; import platform.modules.company.dto.ProjectMattersSearchCondition; import platform.modules.company.dto.ProjectProvincesSearchCondition; import platform.modules.company.entity.*; import platform.modules.government.dao.AttachmentDao; import platform.modules.government.dao.ProjectMattersDeclarationDao; import platform.modules.government.dto.BusinessSearchDto; import platform.modules.government.dto.SearchCondition; import platform.modules.government.dto.StaticSearchCondition; import platform.modules.government.dto.StatisticView; import platform.modules.government.entity.*; import platform.modules.government.service.*; import platform.modules.sys.entity.*; import platform.modules.sys.service.*; import tk.mybatis.mapper.entity.Example; import java.text.SimpleDateFormat; import java.util.*; @Service @Transactional public class ProjectMattersService extends BaseService { @Autowired private ProjectMattersDao projectMattersDao; @Autowired private AttachmentDao attachmentDao; @Autowired private DictionaryItemService dictionaryItemService; @Autowired private ProjectApplicationCompanyInfoService projectApplicationCompanyInfoService; @Autowired private ApprovalService approvalService; @Autowired private AttachmentService attachmentService; @Autowired private GroupService groupService; @Autowired private UserGroupService userGroupService; @Autowired private ProjectProvincesDeclarationService projectProvincesDeclarationService; @Autowired private CompanyService companyService; @Autowired private CompanyOprationsInfoService companyOprationsInfoService; @Autowired private ProjectApplicationOperationsInfoService projectApplicationOperationsInfoService; @Autowired private UserService userService; @Autowired private ProjectServiceCategoryService projectServiceCategoryService; @Autowired private MessageService messageService; @Autowired private WaitToDoService waitToDoService; @Autowired private StreetService streetService; @Autowired private DepartmentService departmentService; @Autowired private ProjectMattersDeclarationDao projectMattersDeclarationDao; @Autowired private ProjectServiceTypeService projectServiceTypeService; @Autowired private ProjectMattersDeclarationService projectMattersDeclarationService; public PageInfo findPage(Integer pageNum, Integer pageSize, String keyword, ProjectMattersSearchCondition searchCondition) { searchCondition.setCompany_id(ShiroUtils.getCompanyId()); PageHelper.startPage(pageNum, pageSize); List applys = projectMattersDao.findByCondition(searchCondition); for (ProjectMatters projectApply : applys) { getFullInfo(projectApply); } return new PageInfo(applys); } private void getFullInfo(ProjectMatters projectApply) { //服务项目大类 String superType = projectApply.getService_super_type(); if (StringUtils.isNotBlank(superType)) { if (projectApply.getCategory_id() != null) { ProjectServiceCategory projectServiceCategory = projectServiceCategoryService.findById(projectApply.getCategory_id()); if (null != projectServiceCategory) { projectApply.setSuper_type_name(projectServiceCategory.getProject_type_name()); } } } //项目来源 String source = projectApply.getProject_source(); if (StringUtils.isNotBlank(source)) { DictionaryItem sourceItem = dictionaryItemService.findByTypeAndValue(Constant.DictionaryType.PROJECT_SOURCE, source); if (null != sourceItem) { projectApply.setProject_source_name(sourceItem.getName()); } } //单据状态 String applyStatus = projectApply.getApply_status(); if (null != applyStatus) { DictionaryItem sourceItem = dictionaryItemService.findByTypeAndValue(Constant.DictionaryType.PROJECT_MATTERS_APPLY_STATUS, applyStatus); if (null != sourceItem) { projectApply.setApply_status_name(sourceItem.getName()); } if (projectApply.getApply_status().equals(Constant.ProjectMattersStatus_Company.PENDING_SUBMIT) || projectApply.getApply_status().equals(Constant.ProjectMattersStatus_Company.REJECT_TO_COMPANY)) { projectApply.setCanEdit(true); projectApply.setCanDelete(true); } } //获取项目名称 if (null != projectApply.getDeclaration_id()) { Integer declarationId = projectApply.getDeclaration_id(); if (declarationId > 0) { ProjectMattersDeclaration dec = projectMattersDeclarationService.findById(declarationId); if (null != dec) { projectApply.setProject_name(dec.getProject_name()); if (Objects.equals("1", dec.getIs_comprehensive())) { projectApply.setIs_comprehensive(true); } else { projectApply.setIs_comprehensive(false); } //项目来源 DictionaryItem sourceItem = dictionaryItemService.findByTypeAndValue(Constant.DictionaryType.PROJECT_SOURCE, dec.getProject_source()); if (null != sourceItem) { projectApply.setProject_source_name(sourceItem.getName()); } } } } } public void getDictInfo(ModelMap modelMap) { //项目大类 // List superTypeList = dictionaryItemService.findListByTypeName(Constant.DictionaryType.PROJECT_SERVICE_SUPER_TYPE); // modelMap.put("superTypeList", superTypeList); //项目来源 List projectSourceList = dictionaryItemService.findListByTypeName(Constant.DictionaryType.PROJECT_SOURCE); modelMap.put("projectSourceList", projectSourceList); // 单据状态 List projectStatusList = dictionaryItemService.findListByTypeName(Constant.DictionaryType.PROJECT_MATTERS_APPROVE_STATUS); modelMap.put("projectApprovalList", projectStatusList); //查询行业类型 List industryTypeList = dictionaryItemService.findListByTypeName(Constant.DictionaryType.INDUSTRY_TYPE); modelMap.put("industryTypeList", industryTypeList); //查询币种单位数据 List currencyList = dictionaryItemService.findListByTypeName(Constant.DictionaryType.CURRENCY_UNIT); modelMap.put("currencyList", currencyList); } //根据id获取项目填报信息 public ModelMap getApplyInfo(Integer apply_id, ModelMap modelMap) { ProjectMatters projectApply = findById(apply_id); ProjectMattersDeclaration projectMattersDeclaration = projectMattersDeclarationService.selectById(projectApply.getDeclaration_id() + ""); projectApply.setService_type_name(projectMattersDeclaration.getProject_service_type_name()); if (null != projectApply.getCategory_id()) { ProjectServiceCategory projectServiceCategory = projectServiceCategoryService.findById(projectApply.getCategory_id()); if (projectServiceCategory != null) { projectApply.setCategory_id_name(projectServiceCategory.getProject_type_name()); } } if (null != projectApply.getProject_id()) { ProjectServiceCategory projectServiceCategory = projectServiceCategoryService.findById(projectApply.getProject_id()); if (projectServiceCategory != null) { projectApply.setProject_id_name(projectServiceCategory.getProject_type_name()); } } modelMap.put("projectApply", projectApply); //服务项目大类 List projectServiceList = projectServiceCategoryService.findProjectServiceList( Constant.DictionaryType.PROJECT_MATTERS, projectApply.getDeclaration_id()); modelMap.put("superTypeList", projectServiceList); //获取相应大类的小类 List projectNameList = projectServiceCategoryService.findProjectNameList( projectApply.getDeclaration_id(), projectApply.getCategory_id()); if (CollectionUtils.isEmpty(projectNameList) && !CollectionUtils.isEmpty(projectServiceList)) { projectNameList = projectServiceCategoryService.findProjectNameList( projectApply.getDeclaration_id(), projectServiceList.get(0).getId()); } modelMap.put("projectNameList", projectNameList); getFullInfo(projectApply); //文件(申报材料) List projectMaterialList = new ArrayList<>(); List attachments = attachmentService.selectByIdAndBusinessId(Constant.Attachment.PROJECT_MATTERS, projectApply.getId(), null); ProjectMaterial material = new ProjectMaterial(); if (null != attachments && attachments.size() > 0) { FileDown fileDown = new FileDown(attachments.get(0).getId(), attachments.get(0).getFile_name(), attachments.get(0).getFile_url(), attachments.get(0).getDownload_uri()); projectApply.setFileDown(fileDown); material.setFileDown(fileDown); projectMaterialList.add(material); } else { projectApply.setFileDown(new FileDown()); } modelMap.put("applyMaterials", projectMaterialList); modelMap.put("projectApply", projectApply); //企业信息 ProjectApplicationCompanyInfo companyInfo = projectApplicationCompanyInfoService.findByApplyIdAndType(apply_id, Constant.DictionaryType.PROJECT_MATTERS); if (companyInfo == null) { companyInfo = projectApplicationCompanyInfoService.getCompanyInfoByCompanyId(projectApply.getCompany_id()); } else { if (!Objects.equals(companyInfo.getIndustry_code(), "Empty")) { companyInfo.setIndustry_code(companyInfo.getIndustry_code()); companyInfo.setIndustry_name(dictionaryItemService.findNameByTypeAndValue(Constant.DictionaryType.INDUSTRY_TYPE, companyInfo.getIndustry_code())); } } modelMap.put("companyInfo", companyInfo); //经营数据 modelMap.put("operationsInfo", getOperationsInfo(null, projectApply)); //项目填报流程 List approvalList = approvalService.getProjectMattersApprovalList(apply_id); modelMap.put("approvalList", approvalList); //流程信息 return modelMap; } //项目填报保存 public Boolean saveProjectApply(ProjectMatters apply) throws ClientException, InterruptedException { ProjectMattersDeclaration declaration = projectMattersDeclarationService.findById(apply.getDeclaration_id()); apply.setCompany_id(ShiroUtils.getCompanyId()); String no = GenerateNoUtil.generateProjectApplyNo(Constant.ProjectNoHeader.PROJECT_MATTERS); apply.setApply_no(no); if (apply.getIsDraft().equals(Constant.IsDraft.DRAFT)) { //保存草稿 apply.setApply_status(Constant.ProjectMattersStatus_Company.PENDING_SUBMIT); } else if (apply.getIsDraft().equals(Constant.IsDraft.NOT_DRAFT)) { //提交申请 if (declaration != null && declaration.getIs_street_audit().equals("1")) { apply.setApply_status(Constant.ProjectMattersStatus_Company.IN_AUDIT); apply.setApprove_status(Constant.ProjectMattersStatus.LOCAL_AUDIT); } else { apply.setApply_status(Constant.ProjectMattersStatus_Company.IN_AUDIT); apply.setApprove_status(Constant.ProjectMattersStatus.CENTRE_AUDIT); } //申请日期 apply.setApply_date(DateUtil.getTimeStringShort(new Date())); //提交申请,同步数据至企业信息表和企业经营数据表 copyCompanyData(apply); } Boolean flag = this.insertAndGetId(apply) > 0; if (flag) { //保存企业基本信息 if (null != apply.getCompanyInfo()) { ProjectApplicationCompanyInfo companyInfo = apply.getCompanyInfo(); companyInfo.setApply_type(Constant.DictionaryType.PROJECT_MATTERS); companyInfo.setApply_id(apply.getId()); projectApplicationCompanyInfoService.saveSelective(companyInfo); } //保存经营信息 if (null != apply.getOperationsInfo() && apply.getOperationsInfo().size() > 0) { List operationsInfoList = apply.getOperationsInfo(); for (ProjectApplicationOperationsInfo info : operationsInfoList) { info.setApply_id(apply.getId()); info.setApply_type(Constant.DictionaryType.PROJECT_MATTERS); projectApplicationOperationsInfoService.saveSelective(info); } } //保存材料 if (null != apply.getFileDown() && null != apply.getFileDown().getFile_id()) { attachmentDao.updateAttachment(Constant.Attachment.PROJECT_MATTERS, apply.getId(), apply.getFileDown().getFile_id()); } //草稿 if (apply.getIsDraft().equals(Constant.IsDraft.NOT_DRAFT)) { //直接提交申请,添加流程信息 Approval approval = new Approval(); approval.setApply_id(apply.getId()); approval.setApproval_round(1); // approval.setAfter_approvalstatus(apply.getApprove_status()); String centerCheckers; if (declaration != null && declaration.getIs_street_audit().equals("1")) { centerCheckers = getStreetChecker(); approval.setAfter_approvalstatus(Constant.ProjectMattersStatus.LOCAL_AUDIT); } else { centerCheckers = getNestChecker(Constant.FWSXZX, Constant.UserType.GOVERNMENT); approval.setAfter_approvalstatus(Constant.ProjectMattersStatus.CENTRE_AUDIT); if (StringUtils.isBlank(centerCheckers)) { throw new BaseException("服务事项填报材料受理组不存在审核人,请联系政府管理员配置。"); } } approval.setNextchecker(centerCheckers); approval.setChecker(ShiroUtils.getUserId()); approval.setType(Constant.DictionaryType.PROJECT_MATTERS); approval.setOper_type(Constant.OperType.SUBMIT); approval.setDepartment(ShiroUtils.getUserEntity().getCompany_name()); approvalService.insertAndGetId(approval); //发送消息 saveMessage(apply); //发送短信 Map params = new HashMap<>(); params.put("project_no", no); params.put("apply_name", Constant.ProjectType.PROJECT_MATTERS); String tempateCode = Constant.SMS_TemplateCode.RPOJECT_APPLY_SUBMIT; String paramStr = JSONObject.toJSONString(params); User companyAdmin = userService.findCompanyAdmin(apply.getCompany_id()); AlibabaSMSUtil.sendSMS( companyAdmin.getPhone(), tempateCode, Constant.SINGNAMW, paramStr); } } return flag; } //项目填报更新 public void updateProjectApply(ProjectMatters apply) throws ClientException, InterruptedException { ProjectMattersDeclaration declaration = projectMattersDeclarationService.findById(apply.getDeclaration_id()); // //更新项目类别 // ProjectServiceCategory category = projectServiceCategoryService.findById(apply.getProject_id()); // if (category != null){ // apply.setProject_type_name(category.getProject_type_name()); // } if (apply.getIsDraft().equals(Constant.IsDraft.NOT_DRAFT)) { User user = userService.findById(ShiroUtils.getUserId()); apply.setCompany_id(user.getCompany_id()); //提交申请 if (declaration != null && declaration.getIs_street_audit().equals("1")) { apply.setApply_status(Constant.ProjectMattersStatus_Company.IN_AUDIT); apply.setApprove_status(Constant.ProjectMattersStatus.LOCAL_AUDIT); } else { apply.setApply_status(Constant.ProjectMattersStatus_Company.IN_AUDIT); apply.setApprove_status(Constant.ProjectMattersStatus.CENTRE_AUDIT); } //申请日期 if (StringUtils.isBlank(apply.getApply_date())) { apply.setApply_date(DateUtil.getTimeStringShort(new Date())); }//申请单号 if (StringUtils.isBlank(apply.getApply_no())) { String no = GenerateNoUtil.generateProjectApplyNo(Constant.ProjectNoHeader.PROJECT_MATTERS); apply.setApply_no(no); } //提交申请,同步数据至企业信息表和企业经营数据表 copyCompanyData(apply); saveMessage(apply); } if (this.updateSelective(apply) > 0) { //保存企业基本信息 if (null != apply.getCompanyInfo()) { projectApplicationCompanyInfoService.updateSelective(apply.getCompanyInfo()); } //保存经营信息 if (null != apply.getOperationsInfo() && apply.getOperationsInfo().size() > 0) { List operationsInfoList = apply.getOperationsInfo(); for (ProjectApplicationOperationsInfo info : operationsInfoList) { projectApplicationOperationsInfoService.updateSelective(info); } } //保存材料 if (null != apply.getFileDown() && null != apply.getFileDown().getFile_id()) { List attachments = attachmentDao.selectByIdAndBusinessId(Constant.Attachment.PROJECT_PROVINCES, apply.getId(), apply.getFileDown().getFile_id()); if (attachments.size() == 0) { //size为0,则是重新上传的文件,更新附件 attachmentDao.deleteByBusiness(Constant.Attachment.PROJECT_MATTERS, apply.getId()); attachmentDao.updateAttachment(Constant.Attachment.PROJECT_MATTERS, apply.getId(), apply.getFileDown().getFile_id()); } } if (apply.getIsDraft().equals(Constant.IsDraft.NOT_DRAFT)) { Approval latestApproval = approvalService.getLatestApproval(apply.getId(), Constant.DictionaryType.PROJECT_MATTERS); //直接提交申请,添加流程信息 Approval approval = new Approval(); approval.setApply_id(apply.getId()); approval.setAfter_approvalstatus(apply.getApprove_status()); String centerCheckers = getCenterChecker(); if (StringUtils.isBlank(centerCheckers)) { throw new BaseException("项目填报材料受理组不存在审核人,请联系政府管理员配置。"); } approval.setNextchecker(centerCheckers); approval.setChecker(ShiroUtils.getUserId()); approval.setType(Constant.DictionaryType.PROJECT_MATTERS); approval.setDepartment(ShiroUtils.getUserEntity().getCompany_name()); if (null == latestApproval) { //还没提交 approval.setOper_type(Constant.OperType.SUBMIT); approval.setApproval_round(1); } else { //退回编辑 approval.setBefore_approvalstatus(latestApproval.getAfter_approvalstatus()); approval.setOper_type(Constant.OperType.EDIT); approval.setApproval_round(latestApproval.getApproval_round() == null ? 1 : latestApproval.getApproval_round() + 1); } approvalService.insertAndGetId(approval); } //发送短信 Map params = new HashMap<>(); params.put("project_no", apply.getApply_no()); params.put("apply_name", Constant.ProjectType.PROJECT_MATTERS); String tempateCode = Constant.SMS_TemplateCode.RPOJECT_APPLY_SUBMIT; String paramStr = JSONObject.toJSONString(params); User companyAdmin = userService.findCompanyAdmin(apply.getCompany_id()); AlibabaSMSUtil.sendSMS( companyAdmin.getPhone(), tempateCode, Constant.SINGNAMW, paramStr); } } public String getCenterChecker() { //根据工作组名称查出工作组 Group group = groupService.findByNameAndUserType(Constant.SSSBZX, null, Constant.UserType.GOVERNMENT, null); //如果不为空 if (null != group) { //根据工作组id查出UserGroup List list = userGroupService.findByGroupId(group.getId()); if (null == list || list.size() == 0) { return null; } StringBuffer sb = new StringBuffer(""); for (UserGroup userGroup : list) { Integer userId = userGroup.getUser_id(); sb.append(userId + ","); } return sb.toString(); } return null; } public String getNestChecker(String groupName, Integer userType) { //根据工作组名称查出工作组 Group group = groupService.findByNameAndUserType(groupName, null, userType, null); //如果不为空 if (null != group) { //根据工作组id查出UserGroup List list = userGroupService.findByGroupId(group.getId()); if (null == list || list.size() == 0) { return null; } StringBuffer sb = new StringBuffer(""); for (UserGroup userGroup : list) { Integer userId = userGroup.getUser_id(); sb.append(userId + ","); } return sb.toString(); } return null; } public String getStreetChecker() { User currUser = ShiroUtils.getUserEntity(); StringBuffer sb = new StringBuffer(""); List userList = userService.findUsersByStreetId(currUser.getStreet_id()); //Group group = groupService.findByName(Constant.FWSXJD, null); Group group = groupService.findByNameAndUserType(Constant.FWSXJD, null, Constant.UserType.STREET, ShiroUtils.getStreetId()); if (null == group) { throw new BaseException("操作失败,服务事项街道没有该项目责任单位的审核人员,请联系管理员配置"); } List userGroups = userGroupService.findByGroupId(group.getId()); if (userList != null && userList.size() > 0) { for (User user : userList) { for (UserGroup userGroup : userGroups) { if (Objects.equals(userGroup.getUser_id(), user.getId())) { Integer userId = user.getId(); sb.append(userId + ","); } } } } return sb.toString(); } public ProjectFilling initFilling(Integer declarationId) { ProjectFilling projectApply = new ProjectFilling(); ProjectProvincesDeclaration dec = projectProvincesDeclarationService.selectById(String.valueOf(declarationId)); if (null != dec) { projectApply.setService_type_name(dec.getProject_service_type_name()); } return projectApply; } //是否已经填报过 /*public Boolean isExistFilling(ProjectFilling apply) { List existFilling = projectProvincesDao.findExistFilling(apply); if (null != existFilling && existFilling.size() > 0) { return true; } return false; }*/ /** * 获取对应项目填报的填报企业数 * * @param id * @return */ /* public Integer getQuantityByDeclarationId(String id) { Example example = new Example(ProjectFilling.class); Example.Criteria criteria = example.createCriteria(); criteria.andEqualTo("del_flag", "0"); criteria.andEqualTo("declaration_id", id); criteria.andNotEqualTo("apply_status", Constant.ProjectFillingStatus_Company.PENDING_SUBMIT); List list = this.selectByExample(example); if (CollectionUtils.isEmpty(list)) { return 0; } return list.size(); }*/ public PageInfo findPageById(Integer pageNum, Integer pageSize, String id) { PageHelper.startPage(pageNum, pageSize); String streetId = ""; if (Objects.equals(ShiroUtils.getUserType(), Constant.UserType.STREET)) { streetId = ShiroUtils.getStreetId() + ""; } List applys = projectMattersDao.findPageById(id, streetId); for (ProjectMatters projectApply : applys) { getFullInfo(projectApply); } return new PageInfo(applys); } public PageInfo findPageByIdAndApproveStatus(Integer pageNum, Integer pageSize, String id, String approve_status) { PageHelper.startPage(pageNum, pageSize); String streetId = ""; if (Objects.equals(ShiroUtils.getUserType(), Constant.UserType.STREET)) { streetId = ShiroUtils.getStreetId() + ""; } List applys = projectMattersDao.findPageByIdAndApproveStatus(id, streetId, approve_status); for (ProjectMatters projectApply : applys) { getFullInfo(projectApply); } return new PageInfo(applys); } public List findListById(String id) { String streetId = ""; if (Objects.equals(ShiroUtils.getUserType(), Constant.UserType.STREET)) { streetId = ShiroUtils.getStreetId() + ""; } List applys = projectMattersDao.findPageById(id, streetId); for (ProjectMatters projectApply : applys) { getFullInfo(projectApply); } return applys; } public List findListByIdAndApproveStatus(String id, String approve_status) { String streetId = ""; if (Objects.equals(ShiroUtils.getUserType(), Constant.UserType.STREET)) { streetId = ShiroUtils.getStreetId() + ""; } List applys = projectMattersDao.findPageByIdAndApproveStatus(id, streetId, approve_status); for (ProjectMatters projectApply : applys) { getFullInfo(projectApply); } return applys; } public List selectByDeclarationIdAndCompanyId(Integer did, Integer cid) { Example example = new Example(ProjectMatters.class); Example.Criteria criteria = example.createCriteria(); criteria.andEqualTo("declaration_id", did); criteria.andEqualTo("company_id", cid); //倒序 example.orderBy("create_time").desc(); return this.selectByExample(example); } private void copyCompanyData(ProjectMatters apply) { //同步企业基本信息 ProjectApplicationCompanyInfo companyInfo = apply.getCompanyInfo(); Company preCompanyInfo = companyService.findById(companyInfo.getCompany_id()); if (StringUtils.isNotBlank(companyInfo.getCompany_name())) { preCompanyInfo.setCompany_name(companyInfo.getCompany_name()); } if (StringUtils.isNotBlank(companyInfo.getRegistration_address())) { preCompanyInfo.setRegistration_address(companyInfo.getRegistration_address()); } if (null != companyInfo.getCurrency_unit()) { preCompanyInfo.setCurrency_unit(companyInfo.getCurrency_unit()); } if (null != companyInfo.getRegistration_capital()) { preCompanyInfo.setRegistration_capital(companyInfo.getRegistration_capital()); } if (StringUtils.isNotBlank(companyInfo.getLegal_representative())) { preCompanyInfo.setLegal_representative(companyInfo.getLegal_representative()); } if (StringUtils.isNotBlank(companyInfo.getLr_position())) { preCompanyInfo.setLr_position(companyInfo.getLr_position()); } companyService.updateSelective(preCompanyInfo); //同步企业营业收入 // List operationsInfo = apply.getOperationsInfo(); // for (ProjectApplicationOperationsInfo info : operationsInfo) { // if (null != info.getOperation_income()) { // CompanyOprationsInfo preInfo = companyOprationsInfoService.findCompanyOprationsByCidAndYear(companyInfo.getCompany_id(), String.valueOf(com.feilong.core.date.DateUtil.getYear(new Date())), Constant.DictionaryType.PROJECT_MATTERS); // if (null != preInfo) { // preInfo.setOperation_income(Double.parseDouble(info.getOperation_income())); // companyOprationsInfoService.updateSelective(preInfo); // } // } // } } public ProjectMattersDeclaration selectById(ProjectMatters projectMatters) { ProjectMattersDeclaration projectDeclaration = projectMattersDeclarationDao.selectById(projectMatters.getDeclaration_id().toString()); //责任单位 if (null != projectDeclaration.getDepartment_id() && !projectDeclaration.getDepartment_id().equals("")) { Department dept = departmentService.findById(Integer.parseInt(projectDeclaration.getDepartment_id())); if (null != dept) { projectDeclaration.setDepartment_name(dept.getName()); } } // //项目大类 // String superType = projectDeclaration.getProject_service_type(); // if (StringUtils.isNotBlank(superType)) { // DictionaryItem superTypeItem = dictionaryItemService.findByTypeAndValue(Constant.DictionaryType.PROJECT_SERVICE_SUPER_TYPE, superType); // if (null != superTypeItem) { // projectDeclaration.setProject_type_name(superTypeItem.getName()); // } // } //服务事项 String serviceType = projectDeclaration.getProject_service_type(); if (StringUtils.isNotBlank(serviceType)) { List projectServiceTypeList = projectServiceTypeService.findById(serviceType); if (!CollectionUtils.isEmpty(projectServiceTypeList)) { projectDeclaration.setProject_service_type_name(projectServiceTypeList.get(0).getService_type_name()); } } //项目来源 String source = projectDeclaration.getProject_source(); if (StringUtils.isNotBlank(source)) { DictionaryItem sourceItem = dictionaryItemService.findByTypeAndValue(Constant.DictionaryType.PROJECT_SOURCE, source); if (null != sourceItem) { projectDeclaration.setProject_source_name(sourceItem.getName()); } } //文件 List attachments = attachmentService.selectByIdAndBusinessId(Constant.Attachment.PROJECT_MATTERS, projectMatters.getId(), null); if (null != attachments && attachments.size() > 0) { FileDown fileDown = new FileDown(attachments.get(0).getId(), attachments.get(0).getFile_name(), attachments.get(0).getFile_url(), attachments.get(0).getDownload_uri()); projectDeclaration.setFileDown(fileDown); } // String companyIds = projectDeclaration.getPush_company_ids(); // String[] companyIdsArr = companyIds.split(","); // projectDeclaration.setTotal(companyIdsArr.length); // projectDeclaration.setCount(getQuantityByDeclarationId(projectDeclaration.getId().toString())); // try { // projectDeclaration = getPushNames(projectDeclaration); // } catch (Exception e) { // e.printStackTrace(); // } return projectDeclaration; } /** * 获取省市申报列表 * * @param pageNum * @param pageSize * @param keyword * @param searchCondition * @return */ public PageInfo findProvincesPage(Integer pageNum, Integer pageSize, String keyword, ProjectProvincesSearchCondition searchCondition) { if (ShiroUtils.getUserType().equals(Constant.UserType.COMPANY)) { Integer companyId = ShiroUtils.getCompanyId(); if (null != companyId) { searchCondition.setCompanyId(companyId); } } if (ShiroUtils.getUserType().equals(Constant.UserType.STREET)) { Integer streetId = ShiroUtils.getStreetId(); if (null != streetId) { searchCondition.setStreetId(streetId); } } //倒序 PageHelper.startPage(pageNum, pageSize); List projectProvincesList = projectMattersDao.findProvincesList(searchCondition); for (ProjectMatters projectApply : projectProvincesList) { getFullInfo(projectApply); } return new PageInfo(projectProvincesList); } /** * 已经申请的取项目申报的新数据,新增申请时根据Companyid查询 * * @param companyId * @param apply * @return */ public List getOperationsInfo(Integer companyId, ProjectMatters apply) { if (null != apply) { ProjectApplication projectApplication = new ProjectApplication(); projectApplication.setId(apply.getId()); //已经申请的取新数据 List infos = projectApplicationOperationsInfoService.findOperationsInfoByApply(projectApplication, Constant.DictionaryType.PROJECT_MATTERS); return infos; } else { List operationsInfo = new ArrayList(); int year = com.feilong.core.date.DateUtil.getYear(new Date()); for (int i = 1; i <= 3; i++) { int dataYear = year - i; ProjectApplicationOperationsInfo info = new ProjectApplicationOperationsInfo(); info.setCid(companyId); info.setYear(String.valueOf(dataYear)); //企业在数据填报处已经填报的经营信息,带出来 CompanyOprationsInfo beforeInfo = companyOprationsInfoService.findCompanyOprationsByCidAndYear(companyId, String.valueOf(dataYear), Constant.DictionaryType.PROJECT_MATTERS); if (null != beforeInfo) { info.setCurrOperationInfoId(beforeInfo.getId()); if (beforeInfo.getOperation_income() != null) { info.setOperation_income(beforeInfo.getOperation_income().toString()); } } operationsInfo.add(info); } return operationsInfo; } } private void saveMessage(ProjectMatters apply) { Message messages = new Message(); messages.setApply_id(apply.getId()); messages.setTitle("企业提交服务事项"); ProjectMattersDeclaration declaration = projectMattersDeclarationService.findById(apply.getDeclaration_id()); String projectName = declaration.getProject_name(); SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy年MM月dd日"); String now = sdf2.format(new Date()); String message = ShiroUtils.getUserName() + ",您好。您于“" + now + "”提交的“" + projectName + "服务事项”的申请已提交,进入审核流程。"; messages.setContent(message); messages.setBusiness_type(Constant.Message_Business_type.PROJECT_MATTERS_APPLY); String[] streetArr = ShiroUtils.getCompanyId().toString().split(","); Set set = new HashSet<>(); for (int i = 0; i < streetArr.length; i++) { set.add(streetArr[i]); } String[] streetArrs = (String[]) set.toArray(new String[set.size()]); int[] streetArrInt = new int[streetArrs.length]; for (int i = 0; i < streetArrs.length; i++) { streetArrInt[i] = Integer.parseInt(streetArrs[i]); } messageService.saveMessageAndPush(messages, streetArrInt, Constant.UserType.COMPANY); Company company = companyService.findById(ShiroUtils.getCompanyId()); waitToDoService.completeAllTODO(apply.getId(), Constant.DictionaryType.PROJECT_MATTERS); Message messages1 = new Message(); messages1.setApply_id(apply.getId()); messages1.setBusiness_type(Constant.Message_Business_type.PROJECT_MATTERS_APPLY); if (declaration.getIs_street_audit().equals("1")) { messages1.setTitle("提醒街道审核"); List users = userService.findUsersByStreetId(ShiroUtils.getStreetId()); List pusers = userService.findUsersByPermission("S_PROJECT_APPROVE"); for (User user : users) { for (User puser : pusers) { if (Objects.equals(user.getId(), puser.getId())) { String message1 = puser.getNick_name() + ",您好。“" + company.getCompany_name() + "企业”的“" + projectName + "服务事项”申请需要您审核。谢谢。"; messages1.setContent(message1); int[] streetArrInt1 = new int[1]; streetArrInt1[0] = user.getId(); messageService.saveMessageAndPush(messages1, streetArrInt1, Constant.UserType.STREET); waitToDoService.newTODO("服务事项审核", "/government/projectMatters/approve/" + apply.getId(), Constant.WaitToDo_OperType.AUDIT, apply.getId(), Constant.DictionaryType.PROJECT_MATTERS, apply.getApply_no(), user.getId().toString(), Constant.WaitToDo_IsSerial.IS_SERIAL, false); } } } } else { messages1.setTitle("提醒中心审核"); Group group = groupService.findByNameOnly(Constant.FWSXZX); if (null == group) { throw new BaseException("操作失败,项目填报材料审核组没有该项目责任单位的审核人员,请联系管理员配置"); } List userGroups = userGroupService.findByGroupId(group.getId()); List users = userService.findListByWhere(new User()); for (UserGroup userGroup : userGroups) { User user = userService.findById(userGroup.getUser_id()); String message1 = user.getUser_name() + ",您好。“" + company.getCompany_name() + "企业”的“" + projectName + "服务事项”申请需要您审核。谢谢。"; messages1.setContent(message1); int[] streetArrInt1 = new int[1]; streetArrInt1[0] = userGroup.getUser_id(); messageService.saveMessageAndPush(messages1, streetArrInt1, Constant.UserType.GOVERNMENT); waitToDoService.newTODO("服务事项审核", "/government/projectMatters/approve/" + apply.getId(), Constant.WaitToDo_OperType.AUDIT, apply.getId(), Constant.DictionaryType.PROJECT_MATTERS, apply.getApply_no(), user.getId().toString(), Constant.WaitToDo_IsSerial.IS_SERIAL, false); } } } /** * 获取服务事项 * * @param id * @return */ public ProjectMattersDeclaration findMattersDeclaration(Integer id) { ProjectMattersDeclaration declaration = projectMattersDeclarationService.findByProjectServerTypeId(id); if (declaration != null) { //项目来源 String source = declaration.getProject_source(); if (StringUtils.isNotBlank(source)) { DictionaryItem sourceItem = dictionaryItemService.findByTypeAndValue(Constant.DictionaryType.PROJECT_SOURCE, source); if (null != sourceItem) { declaration.setProject_source_name(sourceItem.getName()); } } //发布部门 String departmentId = declaration.getDepartment_id(); if (StringUtils.isNotBlank(departmentId)) { Department department = departmentService.findById(Integer.parseInt(departmentId)); declaration.setDepartment_name(department.getName()); } //附件 List attachments = attachmentService.selectByIdAndBusinessId(Constant.Attachment.PROJECT_MATTERS_DEC, declaration.getId(), null); if (null != attachments && attachments.size() > 0) { FileDown fileDown = new FileDown(attachments.get(0).getId(), attachments.get(0).getFile_name(), attachments.get(0).getFile_url(), attachments.get(0).getDownload_uri()); declaration.setFileDown(fileDown); } } return declaration; } @Transactional(readOnly = true) public Integer getMattersNum() { Example example = new Example(ProjectMatters.class); Example.Criteria criteria = example.createCriteria(); criteria.andEqualTo("del_flag", "0"); criteria.andNotEqualTo("apply_status", 0); return this.selectByExample(example).size(); } @Transactional(readOnly = true) public List getMattersAcceptVolume(BusinessSearchDto businessSearchDto) { Example example = new Example(ProjectMatters.class); Example.Criteria criteria = example.createCriteria(); criteria.andEqualTo("del_flag", "0"); criteria.andNotEqualTo("apply_status", 0); if (businessSearchDto.getWeek()) { criteria.andBetween("create_time", DateUtil.getTimesWeekmorning(), DateUtil.getTimesWeeknight()); } if (businessSearchDto.getMonth()) { criteria.andBetween("create_time", DateUtil.getTimesMonthmorning(), DateUtil.getTimesMonthnight()); } return this.selectByExample(example); } public Integer getMattersDecNum(Integer departmentId) { Example example = new Example(ProjectMattersDeclaration.class); Example.Criteria criteria = example.createCriteria(); criteria.andEqualTo("del_flag", 0); // criteria.andNotEqualTo("apply_status", 0); criteria.andEqualTo("department_id", departmentId); return projectMattersDeclarationService.selectByExample(example).size(); } public Integer getProjectServiceTypeNum(Integer type) { Example example = new Example(ProjectServiceType.class); Example.Criteria criteria = example.createCriteria(); // criteria.andEqualTo("del_flag", 0); // criteria.andEqualTo("status", 1); criteria.andEqualTo("service_super_type", type); return projectServiceTypeService.selectByExample(example).size(); } /** * 功能描述:获取服务事项申请单据占比饼图 * * @param: * @return: * @auther: huZhiHao * @date: 2018/9/18 17:11 */ public List getAnalysisType(StaticSearchCondition searchCondition) { List list = new ArrayList<>(); List applys = projectMattersDao.findAll(searchCondition); List typeList = projectServiceTypeService.findAllWithProvincesDec(); for (ProjectServiceType type : typeList) { StatisticView statisticView = new StatisticView(); statisticView.setName(type.getService_type_name()); int count = 0; for (ProjectMatters project : applys) { if (Objects.equals(project.getDeclaration_id(), type.getDeclaration_id())) { count++; } } statisticView.setY(count); list.add(statisticView); } return list; } /** * 功能描述:获取服务事项申请结果数量饼图 * * @param: * @return: * @auther: huZhiHao * @date: 2018/9/18 17:11 */ public List getAnalysisResult(StaticSearchCondition searchCondition) { int pass = 0, refuse = 0, processing = 0; List applys = projectMattersDao.findAll(searchCondition); for (ProjectMatters project : applys) { //通过 if (Objects.equals(Constant.ProjectMattersStatus_Company.SUCCESS, project.getApply_status())) { pass++; //不通过 } else if (Objects.equals(Constant.ProjectMattersStatus_Company.FAILURE, project.getApply_status())) { refuse++; //审核中 } else if (Objects.equals(Constant.ProjectMattersStatus_Company.IN_AUDIT, project.getApply_status())) { processing++; } } StatisticView passEntity = new StatisticView(); passEntity.setName("通过"); passEntity.setY(pass); StatisticView refuseEntity = new StatisticView(); refuseEntity.setName("不通过"); refuseEntity.setY(refuse); StatisticView processingEntity = new StatisticView(); processingEntity.setName("审核中"); processingEntity.setY(processing); List list = new ArrayList<>(); list.add(passEntity); list.add(refuseEntity); list.add(processingEntity); return list; } /** * 功能描述:获取服务事项申请趋势折线图 * * @param: * @return: * @auther: huZhiHao * @date: 2018/9/18 17:11 */ public StatisticView getAnalysisTrend(StaticSearchCondition condition) { Calendar date = Calendar.getInstance(); int year = date.get(Calendar.YEAR); Integer startYear = condition.getStartYear(); Integer endYear = condition.getEndYear(); if (startYear == null && endYear == null) { startYear = year - 2; endYear = year; } else { startYear = startYear == null ? year : startYear; endYear = endYear == null ? year : endYear; } StatisticView result = new StatisticView(); List statisticViewList = new ArrayList<>(); List categories = new ArrayList<>(); List typeList = projectServiceTypeService.findAllWithProvincesDec(); for (ProjectServiceType type : typeList) { List data = new ArrayList<>(); List applys = projectMattersDao.findAll(new StaticSearchCondition()); StatisticView statisticView = new StatisticView(); statisticView.setName(type.getService_type_name()); for (int i = startYear; i <= endYear; i++) { categories.add(i + ""); int count = 0; for (ProjectMatters project : applys) { if (Objects.equals(project.getDeclaration_id(), type.getDeclaration_id())) { if (Objects.equals(project.getApply_date().split("-")[0], i + "")) { count++; } } } data.add(new Double(count)); } result.setCategories(categories); statisticView.setData(data); statisticViewList.add(statisticView); } result.setStatisticViewList(statisticViewList); return result; } public List findListByCondition(SearchCondition searchCondition) { return projectMattersDao.findListByCondition(searchCondition); } }