package platform.modules.government.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.apache.tomcat.util.bcel.Const; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; 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.ShiroUtils; import platform.modules.build.dao.CompanyDao; import platform.modules.build.entity.Company; import platform.modules.build.entity.CompanyContact; import platform.modules.build.service.BuildInfoService; import platform.modules.build.service.CompanyContactService; import platform.modules.build.service.CompanyService; import platform.modules.company.dao.ProjectIntelligentDao; import platform.modules.company.dao.ProjectProvincesDao; import platform.modules.company.entity.ProjectApplicationCompanyInfo; import platform.modules.company.entity.ProjectIntelligent; import platform.modules.company.entity.ProjectProvinces; import platform.modules.company.service.MessageDetailService; import platform.modules.company.service.ProjectApplicationCompanyInfoService; import platform.modules.company.service.ProjectProvincesService; import platform.modules.government.dao.AttachmentDao; import platform.modules.government.dao.ProjectIntelligentDeclarationDao; import platform.modules.government.dao.ProjectProvincesDeclarationDao; import platform.modules.government.dao.ProjectServiceCategoryDao; import platform.modules.government.dto.ParamApplication; import platform.modules.government.dto.ProjectIntelligentDto; import platform.modules.government.dto.ProjectMessageDto; import platform.modules.government.dto.ProjectProvincesDto; import platform.modules.government.entity.*; import platform.modules.sys.dao.ApprovalDao; import platform.modules.sys.entity.*; import platform.modules.sys.service.*; import tk.mybatis.mapper.entity.Example; import java.util.*; @Service @Transactional public class ProjectIntelligentDeclarationService extends BaseService { @Autowired private ProjectIntelligentDeclarationDao projectIntelligentDeclarationDao; @Autowired private ProjectServiceTypeService projectServiceTypeService; @Autowired private ProjectIntelligentDao projectIntelligentDao; @Autowired private MessageService messageService; @Autowired private MessageDetailService messageDetailService; @Autowired private AttachmentDao attachmentDao; @Autowired private CompanyService companyService; @Autowired private StreetService streetService; @Autowired private GroupService groupService; @Autowired private UserGroupService userGroupService; @Autowired private UserService userService; @Autowired private ApprovalDao approvalDao; @Autowired private DepartmentService departmentService; @Autowired private DictionaryItemService dictionaryItemService; @Autowired private ApprovalService approvalService; @Autowired private AttachmentService attachmentService; @Autowired private CompanyContactService companyContactService; @Autowired private ProjectApplicationCompanyInfoService projectApplicationCompanyInfoService; @Autowired private ProjectServiceCategoryService projectServiceCategoryService; @Autowired private WaitToDoService waitToDoService; @Autowired private CompanyDao companyDao; public PageInfo findPageInfo(String projectName, String projectType, String projectSource, Integer pageNum, Integer pagesize) { PageHelper.startPage(pageNum, pagesize); List list = projectIntelligentDeclarationDao.findPageInfo(projectName, projectType, projectSource); List projectTypeList = dictionaryItemService.findListByTypeName(Constant.DictionaryType.PROJECT_SERVICE_SUPER_TYPE); for (DictionaryItem dictionaryItem : projectTypeList) { for (ProjectIntelligentDeclaration projectDeclaration : list) { if (StringUtils.isNotBlank(projectDeclaration.getProject_service_type())) { String name = projectServiceTypeService.findById(projectDeclaration.getProject_service_type()).get(0).getService_type_name(); projectDeclaration.setProject_service_type_name(name); } } } return new PageInfo(list); } public Integer save(ProjectIntelligentDeclaration projectIntelligentDeclaration) { this.insertAndGetId(projectIntelligentDeclaration); Integer id = projectIntelligentDeclaration.getId(); attachmentDao.deleteByBusiness(Constant.Attachment.PROJECT_INTELLIGENT_DEC, projectIntelligentDeclaration.getId()); attachmentDao.updateAttachment(Constant.Attachment.PROJECT_INTELLIGENT_DEC, projectIntelligentDeclaration.getId(), projectIntelligentDeclaration.getFileDown().getFile_id()); updateProjectServiceCategory(projectIntelligentDeclaration); return id; } public Integer update(ProjectIntelligentDeclaration projectIntelligentDeclaration) { this.updateSelective(projectIntelligentDeclaration); Integer id = projectIntelligentDeclaration.getId(); /*List attachments = attachmentService.selectByIdAndBusinessId(Constant.Attachment.PROJECT_INTELLIGENT_DEC, projectIntelligentDeclaration.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()); if (!fileDown.getFile_id().equals(projectIntelligentDeclaration.getFileDown().getFile_id())) {*/ attachmentDao.deleteByBusiness(Constant.Attachment.PROJECT_INTELLIGENT_DEC, projectIntelligentDeclaration.getId()); attachmentDao.updateAttachment(Constant.Attachment.PROJECT_INTELLIGENT_DEC, projectIntelligentDeclaration.getId(), projectIntelligentDeclaration.getFileDown().getFile_id()); /* } }*/ updateProjectServiceCategory(projectIntelligentDeclaration); return id; } public ProjectIntelligentDeclaration selectById(String id) { ProjectIntelligentDeclaration projectDeclaration = projectIntelligentDeclarationDao.selectById(id); //服务事项类别 List temp = projectServiceCategoryService.selectByProjectDeclarationId(id); List temp_new = new ArrayList<>(); for (ProjectServiceCategory category_c : temp) { if (null != category_c.getPid()) { for (ProjectServiceCategory category_f : temp) { if (Objects.equals(category_c.getPid(), category_f.getId())) { ProjectServiceCategory item = new ProjectServiceCategory(); item.setProject_type_name1(category_f.getProject_type_name()); item.setProject_type_name2(category_c.getProject_type_name()); item.setDepartment_id(category_c.getDepartment_id()); //item.setDepartment_name(departmentService.findById(category_c.getDepartment_id()).getName()); if (StringUtils.isNotBlank(category_c.getType())) { item.setType(category_c.getType()); item.setType_name(dictionaryItemService.findNameByTypeAndValue(Constant.DictionaryType.PROJECT_TYPE, category_c.getType())); } temp_new.add(item); } } } } projectDeclaration.setProjectServiceCategory(temp_new); //责任单位 if (StringUtils.isNotBlank(projectDeclaration.getDepartment_id())) { projectDeclaration.setDepartment_name(departmentService.findById(Integer.parseInt(projectDeclaration.getDepartment_id())).getName()); } else { projectDeclaration.setDepartment_name(""); } //服务事项 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_INTELLIGENT_DEC, projectDeclaration.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); } return projectDeclaration; } public PageInfo findPage(Integer pageNum, Integer pageSize, ParamApplication paramApplication, String type) { paramApplication.setApproval_type(Constant.DictionaryType.PROJECT_INTELLIGENT); if (Objects.equals("1", type)) { //待审批 paramApplication.setProjectIds(getProjectIdsByGroup());//新逻辑 } else if (Objects.equals("2", type)) { //已审批 paramApplication.setProjectIds(getProjectIdsy()); } else if (Objects.equals("3", type)) { //查看所有 paramApplication.setProjectIds(getProjectIdsc()); } PageHelper.startPage(pageNum, pageSize); List applicationDtoList = projectIntelligentDao.findPage(paramApplication); for (ProjectIntelligentDto app : applicationDtoList) { if (null != app.getApprove_status()) { String status_name = dictionaryItemService.findNameByTypeAndValue(Constant.DictionaryType.PROJECT_INTELLIGENT_APPROVE_STATUS, app.getApprove_status()); app.setApprove_status_desc(status_name); } if (null != app.getType()) { String type_name = dictionaryItemService.findNameByTypeAndValue(Constant.DictionaryType.PROJECT_TYPE, app.getType()); app.setType_name(type_name); } } return new PageInfo(applicationDtoList); } //获取项目申报id 查看所有 public List getProjectIdsc() { List result = new ArrayList<>(); Example example = new Example(ProjectIntelligent.class); Example.Criteria criteria = example.createCriteria(); criteria.orEqualTo("del_flag", "0");//不显示删除的 List company_ids = new ArrayList<>(); if (ShiroUtils.getUserType().equals(Constant.UserType.STREET)) { Example example1 = new Example(Company.class); Example.Criteria criteria1 = example1.createCriteria(); criteria1.andEqualTo("street_id", ShiroUtils.getStreetId()); List companyList = companyDao.selectByExample(example1); for (Company company : companyList) { company_ids.add(company.getId() + ""); } } if (ShiroUtils.getUserType().equals(Constant.UserType.STREET)) { criteria.andIn("company_id", company_ids); } List projectList = projectIntelligentDao.selectByExample(example); for (ProjectIntelligent project : projectList) { result.add(project.getId().toString()); } return result; } //获取项目申报id 已审批 public List getProjectIdsy() { int currentUserId = ShiroUtils.getUserId(); List approvalList = approvalDao.selectAllApproval(Constant.DictionaryType.PROJECT_INTELLIGENT); Set projectApplicationIds = new HashSet(); //if (Objects.equals(ShiroUtils.getUserType(), Constant.UserType.GOVERNMENT)) { if (!CollectionUtils.isEmpty(approvalList)) { for (Approval approval : approvalList) { String checkerIds = approval.getChecker() + ""; if (checkerIds != null && checkerIds != "") { if (Objects.equals(checkerIds, String.valueOf(currentUserId))) { projectApplicationIds.add(approval.getApply_id().toString()); } } } } //} List result = new ArrayList<>(projectApplicationIds); return result; } //根据用户组获取可查询到的项目 public List getProjectIdsByGroup() { List projectLists = new ArrayList<>(); Integer user_id = ShiroUtils.getUserId(); Integer department_id = ShiroUtils.getUserEntity().getDepartment_id(); Group group = null; List userGroups = null; List apply_status_list = new ArrayList<>(); List company_ids = new ArrayList<>(); if (ShiroUtils.getUserType().equals(Constant.UserType.STREET)) { Example example3 = new Example(Company.class); Example.Criteria criteria3 = example3.createCriteria(); criteria3.andEqualTo("del_flag", "0"); criteria3.andEqualTo("street_id", ShiroUtils.getStreetId()); List companies = companyDao.selectByExample(example3); if (!CollectionUtils.isEmpty(companies)) { for (Company company : companies) { company_ids.add(company.getId().toString()); } } else { company_ids.add(""); } group = groupService.findByName(Constant.QJZNZZJDSLZ, null); if (null == group) { return new ArrayList<>(); } userGroups = userGroupService.findByGroupId(group.getId()); if (null == userGroups) { apply_status_list.add(""); } for (UserGroup userGroup : userGroups) { if (Objects.equals(userGroup.getUser_id(), user_id)) { apply_status_list.add(Constant.ProjectIntelligentStatus.LOCAL_AUDIT); break; } } } else { //材料受理 group = groupService.findByName(Constant.QJZNZZCLSLZ, null); if (null == group) { apply_status_list.add(""); } userGroups = userGroupService.findByGroupId(group.getId()); if (null == userGroups) { apply_status_list.add(""); } for (UserGroup userGroup : userGroups) { if (Objects.equals(userGroup.getUser_id(), user_id)) { apply_status_list.add(Constant.ProjectIntelligentStatus.CENTRE_AUDIT); apply_status_list.add(Constant.ProjectIntelligentStatus.PAPER_MATERIAL); projectLists.addAll(projectIntelligentDao.findByProjectIdAndApproveStatus(apply_status_list, company_ids)); break; } } } if (apply_status_list.size() <= 0) { apply_status_list.add(""); } projectLists.addAll(projectIntelligentDao.findByProjectIdAndApproveStatus(apply_status_list, company_ids)); List result = new ArrayList<>(); for (ProjectIntelligent project : projectLists) { result.add(project.getId().toString()); } return result; } //通过 public Boolean pass(Integer projectId, String comment) throws ClientException, InterruptedException { Approval approval = approvalDao.getLatestApproval(projectId, Constant.DictionaryType.PROJECT_INTELLIGENT); Approval a = new Approval(); a.setApply_id(projectId); a.setType(Constant.DictionaryType.PROJECT_INTELLIGENT); if (null != userService.getUser(ShiroUtils.getUserId()).getDepartment_id()) { String departmentname = departmentService.selectById(userService.getUser(ShiroUtils.getUserId()).getDepartment_id()).getName(); a.setDepartment(departmentname); } a.setApproval_comment(comment); a.setChecker(ShiroUtils.getUserId()); a.setOper_type(Constant.OperType.APPROVED); a.setDeal_time(DateUtil.getTimeString(new Date())); ProjectIntelligent projectApplication = projectIntelligentDao.findApplyById(projectId); User companyAdmin = userService.findCompanyAdmin(projectApplication.getCompany_id()); //短信参数 Map params = new HashMap<>(); params.put("project_no", projectApplication.getApply_no()); params.put("apply_name", Constant.ProjectType.PROJECT_INTELLIGENT); String templateCode = Constant.SMS_TemplateCode.RPOJECT_APPROVAL_REMIND; if (Objects.equals(Constant.ProjectIntelligentStatus.LOCAL_AUDIT, approval.getAfter_approvalstatus())) { Integer streetid = ShiroUtils.getStreetId(); Street streetInfo = streetService.findById(streetid); a.setDepartment(streetInfo.getName()); //待属地审核--》待中心审核 a.setBefore_approvalstatus(Constant.ProjectIntelligentStatus.LOCAL_AUDIT); a.setAfter_approvalstatus(Constant.ProjectIntelligentStatus.CENTRE_AUDIT); Group group = groupService.findByNameOnly(Constant.QJZNZZCLSLZ); if (null == group) { throw new BaseException("操作失败,区级智能制造材料受理组没有该项目责任单位的审核人员,请联系管理员配置"); } List userGroups = userGroupService.findByGroupId(group.getId()); ProjectIntelligentDeclaration projectProvincesDeclaration = this.selectById(projectApplication.getDeclaration_id().toString()); List users = userService.findListByWhere(new User()); StringBuffer sb = new StringBuffer(""); Company company = companyService.findById(projectApplication.getCompany_id()); String projectName = projectProvincesDeclaration.getProject_name(); Message messages = new Message(); messages.setApply_id(projectId); messages.setBusiness_type(Constant.Message_Business_type.PROJECT_INTELLIGENT_APPLY); messages.setTitle("提醒中心审核"); waitToDoService.completeAllTODO(projectApplication.getId(), Constant.DictionaryType.PROJECT_INTELLIGENT); for (UserGroup userGroup : userGroups) { for (User user : users) { if (Objects.equals(user.getId(), userGroup.getUser_id())) { sb.append(userGroup.getUser_id() + ","); String message = user.getUser_name() + ",您好。“" + company.getCompany_name() + "企业”的“" + projectName + "项目”申请需要您审核。谢谢。"; messages.setContent(message); int[] streetArrInt = new int[1]; streetArrInt[0] = userGroup.getUser_id(); messageService.saveMessageAndPush(messages, streetArrInt, Constant.UserType.GOVERNMENT); waitToDoService.newTODO("区级智能制造审核", "/government/projectIntelligent/approve/" + projectApplication.getId(), Constant.WaitToDo_OperType.AUDIT, projectApplication.getId(), Constant.DictionaryType.PROJECT_INTELLIGENT, projectApplication.getApply_no(), userGroup.getUser_id().toString(), Constant.WaitToDo_IsSerial.IS_SERIAL, false); //发送短信 // AlibabaSMSUtil.sendSMSMessage( // user.getPhone(), templateCode, Constant.SINGNAMW, JSONObject.toJSONString(params)); } } } a.setNextchecker(sb.toString()); if (sb.length() == 0) { throw new BaseException("操作失败,区级智能制造材料受理组没有该项目责任单位的审核人员,请联系管理员配置"); } ProjectIntelligent pa = new ProjectIntelligent(); pa.setId(projectId); pa.setApprove_status(Constant.ProjectIntelligentStatus.CENTRE_AUDIT); pa.setApply_status(Constant.ProjectProvincesStatus_Company.IN_AUDIT); projectIntelligentDao.updateByPrimaryKeySelective(pa); approvalService.insertAndGetId(a); return true; } else if (Objects.equals(Constant.ProjectIntelligentStatus.CENTRE_AUDIT, approval.getAfter_approvalstatus())) { //属地通过或企业直接提交到中心,待中心审核--》待提交纸质档 a.setBefore_approvalstatus(Constant.ProjectIntelligentStatus.CENTRE_AUDIT); a.setAfter_approvalstatus(Constant.ProjectIntelligentStatus.PAPER_MATERIAL); Group group = groupService.findByNameOnly(Constant.QJZNZZCLSLZ); if (null == group) { throw new BaseException("操作失败,区级智能制造材料受理组没有该项目责任单位的审核人员,请联系管理员配置"); } List userGroups = userGroupService.findByGroupId(group.getId()); ProjectIntelligentDeclaration projectProvincesDeclaration = this.selectById(projectApplication.getDeclaration_id().toString()); List users = userService.findListByWhere(new User()); StringBuffer sb = new StringBuffer(""); Company company = companyService.findById(projectApplication.getCompany_id()); String projectName = projectProvincesDeclaration.getProject_name(); Message messages = new Message(); messages.setApply_id(projectId); messages.setBusiness_type(Constant.Message_Business_type.PROJECT_INTELLIGENT_APPLY); messages.setTitle("提醒中心审核"); waitToDoService.completeAllTODO(projectApplication.getId(), Constant.DictionaryType.PROJECT_INTELLIGENT); for (UserGroup userGroup : userGroups) { for (User user : users) { if (Objects.equals(user.getId(), userGroup.getUser_id())) { sb.append(userGroup.getUser_id() + ","); String message = user.getUser_name() + ",您好。“" + company.getCompany_name() + "企业”的“" + projectName + "项目”申请需要您审核。谢谢。"; messages.setContent(message); int[] streetArrInt = new int[1]; streetArrInt[0] = userGroup.getUser_id(); messageService.saveMessageAndPush(messages, streetArrInt, Constant.UserType.GOVERNMENT); waitToDoService.newTODO("区级智能制造审核", "/government/projectIntelligent/approve/" + projectApplication.getId(), Constant.WaitToDo_OperType.AUDIT, projectApplication.getId(), Constant.DictionaryType.PROJECT_INTELLIGENT, projectApplication.getApply_no(), userGroup.getUser_id().toString(), Constant.WaitToDo_IsSerial.IS_SERIAL, false); //发送短信 // AlibabaSMSUtil.sendSMSMessage( // user.getPhone(), templateCode, Constant.SINGNAMW, JSONObject.toJSONString(params)); } } } a.setNextchecker(sb.toString()); if (sb.length() == 0) { throw new BaseException("操作失败,区级智能制造材料受理组没有该项目责任单位的审核人员,请联系管理员配置"); } ProjectIntelligent pa = new ProjectIntelligent(); pa.setId(projectId); pa.setApprove_status(Constant.ProjectIntelligentStatus.PAPER_MATERIAL); pa.setApply_status(Constant.ProjectIntelligentStatus_Company.PAPER_MATERIAL); projectIntelligentDao.updateByPrimaryKeySelective(pa); approvalService.insertAndGetId(a); //给企业发消息 String message = company.getCompany_name() + ",您好。您提交的单号为"+ projectApplication.getApply_no() +"的智能制造申报申请,已到提交申报材料纸质档阶段,请打印申报的材料,前往苏州高新区企业服务中心(苏州高新区科技城科灵路37号科技金融广场一楼)进行核准。谢谢!"; messages.setContent(message); int[] streetArrInt = new int[1]; streetArrInt[0] = companyAdmin.getId(); messageService.saveMessageAndPush(messages, streetArrInt, Constant.UserType.COMPANY); //发送短信(提醒企业提交材料) String tempCode = Constant.SMS_TemplateCode.REMINSD_COMPNAY_PREPARE_MATERIALS; AlibabaSMSUtil.sendSMS( companyAdmin.getPhone(), tempCode, Constant.SINGNAMW, JSONObject.toJSONString(params)); return true; } else if (Objects.equals(Constant.ProjectIntelligentStatus.PAPER_MATERIAL, approval.getAfter_approvalstatus())) { //待提交申报材料纸质档--》待通过 ProjectIntelligentDeclaration projectIntelligentDeclaration = this.selectById(projectApplication.getDeclaration_id().toString()); ProjectIntelligent pa = new ProjectIntelligent(); pa.setId(projectId); a.setBefore_approvalstatus(Constant.ProjectIntelligentStatus.PAPER_MATERIAL); a.setAfter_approvalstatus(Constant.ProjectIntelligentStatus.SUCCESS); Company company = companyService.findById(projectApplication.getCompany_id()); String projectName = projectIntelligentDeclaration.getProject_name(); Message messages = new Message(); messages.setApply_id(projectId); messages.setBusiness_type(Constant.Message_Business_type.PROJECT_INTELLIGENT_APPLY); messages.setTitle("提醒企业审核通过"); waitToDoService.completeAllTODO(projectApplication.getId(), Constant.DictionaryType.PROJECT_INTELLIGENT); String message = projectApplication.getCreate_name() + ",您好。“" + company.getCompany_name() + "企业”的“" + projectName + "项目”申请已经审核通过。谢谢。"; messages.setContent(message); int[] streetArrInt = new int[1]; streetArrInt[0] = projectApplication.getCreate_by(); messageService.saveMessageAndPush(messages, streetArrInt, Constant.UserType.COMPANY); waitToDoService.completeAllTODO(projectApplication.getId(), Constant.DictionaryType.PROJECT_INTELLIGENT); waitToDoService.newTODO("区级智能制造审核", "/company/projectIntelligent/check/" + projectApplication.getId(), Constant.WaitToDo_OperType.CONFIRM_AND_NOTIFY, projectApplication.getId(), Constant.DictionaryType.PROJECT_INTELLIGENT, projectApplication.getApply_no(), companyAdmin.getId().toString(), Constant.WaitToDo_IsSerial.IS_SERIAL, false); pa.setApprove_status(Constant.ProjectIntelligentStatus.SUCCESS); pa.setApply_status(Constant.ProjectIntelligentStatus_Company.SUCCESS); projectIntelligentDao.updateByPrimaryKeySelective(pa); approvalService.insertAndGetId(a); //发送短信 String tempCode = Constant.SMS_TemplateCode.RPOJECT_MATTERS_PASS; AlibabaSMSUtil.sendSMS( companyAdmin.getPhone(), tempCode, Constant.SINGNAMW, JSONObject.toJSONString(params)); return true; } return false; } //退回 public boolean untread(Integer projectId, String comment) throws ClientException, InterruptedException { Approval approval = approvalDao.getLatestApproval(projectId, Constant.DictionaryType.PROJECT_INTELLIGENT); Approval a = new Approval(); a.setApply_id(projectId); a.setType(Constant.DictionaryType.PROJECT_INTELLIGENT); String departmentname = departmentService.selectById(userService.getUser(ShiroUtils.getUserId()).getDepartment_id()).getName(); a.setDepartment(departmentname); if(Objects.equals(ShiroUtils.getUserType(),Constant.UserType.STREET)){ Integer streetid = ShiroUtils.getStreetId(); Street streetInfo = streetService.findById(streetid); a.setDepartment(streetInfo.getName()); } a.setApproval_comment(comment); a.setChecker(ShiroUtils.getUserId()); a.setOper_type(Constant.OperType.REJECT); a.setDeal_time(DateUtil.getTimeString(new Date())); ProjectIntelligent projectApplication = projectIntelligentDao.findApplyById(projectId); User companyAdmin = userService.findCompanyAdmin(projectApplication.getCompany_id()); Message messages = new Message(); messages.setApply_id(projectApplication.getId()); messages.setBusiness_type(Constant.Message_Business_type.PROJECT_INTELLIGENT_APPLY); messages.setTitle("提醒企业"); String message = "您有单号为"+ projectApplication.getApply_no() +"的"+ Constant.ProjectType.PROJECT_INTELLIGENT +",经审核被退回,要求修改,详情请登录平台查看。退回原因:" + comment; messages.setContent(message); int[] streetArrInt = new int[1]; streetArrInt[0] = projectApplication.getCompany_id(); Map params = new HashMap<>(); params.put("project_no", projectApplication.getApply_no()); params.put("apply_name", Constant.ProjectType.PROJECT_INTELLIGENT); String templateCode = Constant.SMS_TemplateCode.RPOJECT_MATTERS_REJECT; if (Objects.equals(Constant.ProjectProvincesStatus.LOCAL_AUDIT, approval.getAfter_approvalstatus())) { //属地审核退回 a.setBefore_approvalstatus(Constant.ProjectIntelligentStatus.LOCAL_AUDIT); a.setAfter_approvalstatus(Constant.ProjectIntelligentStatus.REJECT_TO_COMPANY); a.setNextchecker(projectApplication.getCreate_by().toString()); ProjectIntelligent p = new ProjectIntelligent(); p.setId(projectId); p.setApply_status(Constant.ProjectIntelligentStatus_Company.REJECT_TO_COMPANY); p.setApprove_status(Constant.ProjectIntelligentStatus.REJECT_TO_COMPANY); projectIntelligentDao.updateByPrimaryKeySelective(p); approvalService.insertAndGetId(a); messageService.saveMessageAndPush(messages, streetArrInt, Constant.UserType.COMPANY); waitToDoService.completeAllTODO(projectApplication.getId(), Constant.DictionaryType.PROJECT_INTELLIGENT); waitToDoService.newTODO("智能制造编辑", "/projectIntelligent/edit/" + projectApplication.getId(), Constant.WaitToDo_OperType.EDIT, projectApplication.getId(), Constant.DictionaryType.PROJECT_INTELLIGENT, projectApplication.getApply_no(), companyAdmin.getId().toString(), Constant.WaitToDo_IsSerial.IS_SERIAL, false); //发送短信 AlibabaSMSUtil.sendSMS( companyAdmin.getPhone(), templateCode, Constant.SINGNAMW, JSONObject.toJSONString(params)); return true; } else if (Objects.equals(Constant.ProjectIntelligentStatus.CENTRE_AUDIT, approval.getAfter_approvalstatus())) { //中心审核退回 a.setBefore_approvalstatus(Constant.ProjectIntelligentStatus.CENTRE_AUDIT); a.setAfter_approvalstatus(Constant.ProjectIntelligentStatus.REJECT_TO_COMPANY); a.setNextchecker(projectApplication.getCreate_by().toString()); ProjectIntelligent p = new ProjectIntelligent(); p.setId(projectId); p.setApply_status(Constant.ProjectIntelligentStatus_Company.REJECT_TO_COMPANY); p.setApprove_status(Constant.ProjectIntelligentStatus.REJECT_TO_COMPANY); projectIntelligentDao.updateByPrimaryKeySelective(p); approvalService.insertAndGetId(a); messageService.saveMessageAndPushToUser(messages, streetArrInt, Constant.UserType.COMPANY); waitToDoService.completeAllTODO(projectApplication.getId(), Constant.DictionaryType.PROJECT_INTELLIGENT); waitToDoService.newTODO("智能制造编辑", "/projectIntelligent/edit/" + projectApplication.getId(), Constant.WaitToDo_OperType.EDIT, projectApplication.getId(), Constant.DictionaryType.PROJECT_INTELLIGENT, projectApplication.getApply_no(), companyAdmin.getId().toString(), Constant.WaitToDo_IsSerial.IS_SERIAL, false); //发送短信 AlibabaSMSUtil.sendSMS( companyAdmin.getPhone(), templateCode, Constant.SINGNAMW, JSONObject.toJSONString(params)); return true; } else if (Objects.equals(Constant.ProjectIntelligentStatus.PAPER_MATERIAL, approval.getAfter_approvalstatus())) { //待提交纸质材料有误 非退回 仅通知企业 a.setBefore_approvalstatus(Constant.ProjectIntelligentStatus.PAPER_MATERIAL); a.setAfter_approvalstatus(Constant.ProjectIntelligentStatus.PAPER_MATERIAL); List userss = userService.findListByWhere(new User()); StringBuffer sb = new StringBuffer(""); Group group = groupService.findByNameOnly(Constant.QJZNZZCLSLZ); if (null == group) { throw new BaseException("操作失败,项目申报材料受理组没有该项目责任单位的审核人员,请联系管理员配置"); } List userGroups = userGroupService.findByGroupId(group.getId()); for (UserGroup userGroup : userGroups) { for (User user : userss) { if (Objects.equals(user.getId(), userGroup.getUser_id())) { sb.append(userGroup.getUser_id() + ","); } } } a.setNextchecker(sb.toString()); ProjectIntelligent p = new ProjectIntelligent(); p.setId(projectId); p.setApply_status(Constant.ProjectIntelligentStatus_Company.PAPER_MATERIAL_ERROR); p.setApprove_status(Constant.ProjectIntelligentStatus.PAPER_MATERIAL); projectIntelligentDao.updateByPrimaryKeySelective(p); approvalService.insertAndGetId(a); message = "您好。您单号为"+ projectApplication.getApply_no() +"的"+ Constant.ProjectType.PROJECT_INTELLIGENT + ",申报材料纸质档有误,"+ comment +"," + "请根据意见修改并重新打印申报材料纸质档,交至高新区企业服务服务中心(苏州高新区科技城科灵路37号科技金融广场一楼)"; messages.setContent(message); messageService.saveMessageAndPush(messages, streetArrInt, Constant.UserType.COMPANY); waitToDoService.completeAllTODO(projectApplication.getId(), Constant.DictionaryType.PROJECT_INTELLIGENT); waitToDoService.newTODO("智能制造编辑", "/projectIntelligent/edit/" + projectApplication.getId(), Constant.WaitToDo_OperType.EDIT, projectApplication.getId(), Constant.DictionaryType.PROJECT_INTELLIGENT, projectApplication.getApply_no(), companyAdmin.getId().toString(), Constant.WaitToDo_IsSerial.IS_SERIAL, false); //发送短信 String tempCode = Constant.SMS_TemplateCode.DOCUMENTS_INCORRECT; AlibabaSMSUtil.sendSMS( companyAdmin.getPhone(), tempCode, Constant.SINGNAMW, JSONObject.toJSONString(params)); return true; } return false; } //拒绝 public boolean refuse(Integer projectId, String comment) throws ClientException, InterruptedException { Approval approval = approvalDao.getLatestApproval(projectId, Constant.DictionaryType.PROJECT_INTELLIGENT); Approval a = new Approval(); a.setApply_id(projectId); a.setType(Constant.DictionaryType.PROJECT_INTELLIGENT); String departmentname = departmentService.selectById(userService.getUser(ShiroUtils.getUserId()).getDepartment_id()).getName(); a.setDepartment(departmentname); if(Objects.equals(ShiroUtils.getUserType(),Constant.UserType.STREET)){ Integer streetid = ShiroUtils.getStreetId(); Street streetInfo = streetService.findById(streetid); a.setDepartment(streetInfo.getName()); } a.setApproval_comment(comment); a.setChecker(ShiroUtils.getUserId()); a.setOper_type(Constant.OperType.NOTAPPROVED); a.setDeal_time(DateUtil.getTimeString(new Date())); ProjectIntelligent projectApplication = projectIntelligentDao.findApplyById(projectId); User companyAdmin = userService.findCompanyAdmin(projectApplication.getCompany_id()); a.setAfter_approvalstatus(Constant.ProjectIntelligentStatus.FAILURE); a.setNextchecker(projectApplication.getCreate_by().toString()); ProjectIntelligent p = new ProjectIntelligent(); p.setId(projectId); p.setApply_status(Constant.ProjectIntelligentStatus_Company.FAILURE); p.setApprove_status(Constant.ProjectIntelligentStatus.FAILURE); projectIntelligentDao.updateByPrimaryKeySelective(p); a.setBefore_approvalstatus(Constant.ProjectIntelligentStatus.FAILURE); approvalService.insertAndGetId(a); ProjectIntelligentDeclaration projectDeclaration = this.findById(projectApplication.getDeclaration_id()); String projectName = projectDeclaration.getProject_name(); Company company = companyService.findById(projectApplication.getCompany_id()); Message messages = new Message(); messages.setApply_id(projectApplication.getId()); messages.setBusiness_type(Constant.Message_Business_type.PROJECT_INTELLIGENT_APPLY); messages.setTitle("提醒企业"); String message = company.getCompany_name() + ",您好。您提交的" + projectName + "审核不通过,请知悉。不通过原因:" + comment; messages.setContent(message); int[] streetArrInt = new int[1]; streetArrInt[0] = projectApplication.getCompany_id(); messageService.saveMessageAndPush(messages, streetArrInt, Constant.UserType.COMPANY); //发送短信 Map params = new HashMap<>(); params.put("project_no", projectApplication.getApply_no()); params.put("apply_name", Constant.ProjectType.PROJECT_INTELLIGENT); String templateCode = Constant.SMS_TemplateCode.RPOJECT_MATTERS_UNPASS; AlibabaSMSUtil.sendSMS( companyAdmin.getPhone(), templateCode, Constant.SINGNAMW, JSONObject.toJSONString(params)); return true; } //区级智能制造发送短信 public Boolean sendProjectSMS(ProjectIntelligent projectApplication) throws ClientException, InterruptedException { if (null != projectApplication) { String departmentname = departmentService.selectById(userService.getUser(ShiroUtils.getUserId()).getDepartment_id()).getName(); String status = projectApplication.getApply_status(); String statusName = ""; if (status.equals(Constant.ProjectApplyStatus.NOTAPPROVED)) { statusName = Constant.OperType.NOTAPPROVED; } else if (status.equals(Constant.ProjectApplyStatus.APPROVED)) { statusName = Constant.OperType.APPROVED; } else if (status.equals(Constant.ProjectApplyStatus.REJECT)) { statusName = Constant.OperType.REJECT; } if (StringUtils.isNotBlank(statusName)) { return sendProjectSMSToCompany(departmentname, projectApplication, statusName); } } return false; } public Boolean sendProjectSMSToCompany(String departmentname, ProjectIntelligent projectApplication, String status) throws ClientException, InterruptedException { String phone = ""; CompanyContact contact = companyContactService.findFirstByCompanyId(projectApplication.getCompany_id()); ProjectApplicationCompanyInfo companyInfo = projectApplicationCompanyInfoService.findByApplyIdAndType(projectApplication.getId(), Constant.DictionaryType.PROJECT_APPLICATION); if (null != companyInfo && null != companyInfo.getContact_phone()) { phone = companyInfo.getContact_phone(); } else if (null != contact) { phone = contact.getPhone(); } if (StringUtils.isNotBlank(phone)) { //${department_name}提醒您,您申请的${project_name}单据已审核 ${approve_status}。具体信息请登录PC端查看。感谢您的支持。 ProjectIntelligentDeclaration projectDeclaration = this.findById(projectApplication.getDeclaration_id()); String project_name = projectDeclaration.getProject_name(); String templateParam = "{\"department_name\":\"" + departmentname + "\",\"project_name\":\"" + project_name + "\",\"approve_status\":\"" + status + "\"}"; AlibabaSMSUtil.sendSMS(phone, Constant.SMS_TemplateCode.PROJECT_APPLICATION_NOTIFY, "企业提升发展服务平台", templateParam); return true; } else { return false; } } public PageInfo findFillingPageInfo(String projectName, String projectType, String projectSource, Integer pageNum, Integer pagesize) { PageHelper.startPage(pageNum, pagesize); List list = projectIntelligentDeclarationDao.findFillingPageInfo(projectName, projectType, projectSource); for (ProjectIntelligentDeclaration projectFillingDeclaration : list) { if (StringUtils.isNotBlank(projectFillingDeclaration.getProject_service_type())) { String name = projectServiceTypeService.findById(projectFillingDeclaration.getProject_service_type()).get(0).getService_type_name(); projectFillingDeclaration.setProject_service_type_name(name); } } return new PageInfo(list); } /** * 功能描述: 批量更新项目类别大类小类 * * @param: * @return: * @auther: huZhiHao * @date: 2018/8/14 17:02 */ public void updateProjectServiceCategory(ProjectIntelligentDeclaration projectIntelligentDeclaration) { projectServiceCategoryService.deleteByProjectDeclarationId(projectIntelligentDeclaration.getId()); List categoryList = projectIntelligentDeclaration.getProjectServiceCategory(); //将大类名称去重 List temp_list = new ArrayList<>(); for (ProjectServiceCategory projectServiceCategory : categoryList) { temp_list.add(projectServiceCategory.getProject_type_name1()); } Set no_repeat = new HashSet(temp_list); List category_f = new ArrayList<>(no_repeat); Integer project_declaration_id = projectIntelligentDeclaration.getId(); String project_service_type_id = projectIntelligentDeclaration.getProject_service_type(); if (category_f.size() >= 1 && !Objects.equals(category_f.get(0), "")) { for (String f_name : category_f) { List categoryList_c = new ArrayList<>(); //插入大类并获取id作为子类父id 我也不想循环啊-..-! ProjectServiceCategory projectServiceCategory = new ProjectServiceCategory(); projectServiceCategory.setPid(0); projectServiceCategory.setProject_declaration_id(project_declaration_id); //projectServiceCategory.setProject_service_type_id(Integer.parseInt(project_service_type_id)); projectServiceCategory.setProject_type_name(f_name); projectServiceCategory.setBusiness_type(Constant.DictionaryType.PROJECT_INTELLIGENT); projectServiceCategoryService.insertAndGetId(projectServiceCategory); Integer fid = projectServiceCategory.getId(); //装配子类 for (ProjectServiceCategory category : categoryList) { if (Objects.equals(f_name, category.getProject_type_name1())) { ProjectServiceCategory projectCategory = new ProjectServiceCategory(); projectCategory.setPid(fid); projectCategory.setProject_declaration_id(project_declaration_id); //projectCategory.setProject_service_type_id(Integer.parseInt(project_service_type_id)); projectCategory.setProject_type_name(category.getProject_type_name2()); projectCategory.setDepartment_id(category.getDepartment_id()); projectCategory.setType(category.getType()); projectCategory.setBusiness_type(Constant.DictionaryType.PROJECT_INTELLIGENT); categoryList_c.add(projectCategory); } } projectServiceCategoryService.insertBatch(categoryList_c); } } } }