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.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.Workbook; 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.ExportExcel; import platform.common.util.ShiroUtils; 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.ProjectApplicationDao; import platform.modules.company.dao.ProjectMaterialDao; import platform.modules.company.dto.ProjectApplicationSearchCondition; import platform.modules.company.entity.*; import platform.modules.company.service.ProjectApplicationCompanyInfoService; import platform.modules.company.service.ProjectApplicationService; import platform.modules.company.service.ProjectFillingService; import platform.modules.company.service.ProjectMaterialService; import platform.modules.government.dao.AttachmentDao; import platform.modules.government.dao.ProjectDao; import platform.modules.government.dao.ProjectDeclarationDao; import platform.modules.government.dto.*; import platform.modules.government.entity.*; import platform.modules.home.request.FindRequest; import platform.modules.home.response.FindResponseProject; import platform.modules.sys.dao.ApprovalDao; import platform.modules.sys.entity.*; import platform.modules.sys.report.OrderExports; import platform.modules.sys.service.*; import tk.mybatis.mapper.entity.Example; import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; import java.io.InputStream; import java.text.ParseException; import java.text.SimpleDateFormat; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.*; import java.util.concurrent.*; @Service @Transactional public class ProjectDeclarationService extends BaseService { @Resource private ProjectDeclarationDao projectDeclarationDao; @Autowired private NoticesService noticesService; @Autowired private NoticesAcceptService noticesAcceptService; @Autowired private MessageService messageService; @Resource private AttachmentDao attachmentDao; @Autowired private StreetService streetService; @Autowired private BuildInfoService buildInfoService; @Autowired private CompanyService companyService; @Autowired private GroupService groupService; @Autowired private UserGroupService userGroupService; @Autowired private UserService userService; @Autowired private ProjectApplicationDao projectApplicationDao; @Autowired private ProjectApplicationService projectApplicationService; @Resource private ProjectDao projectDao; @Resource private ApprovalDao approvalDao; @Autowired private DepartmentService departmentService; @Autowired private DictionaryItemService dictionaryItemService; @Autowired private ApprovalService approvalService; @Resource private ProjectMaterialDao projectMaterialDao; @Autowired private ProjectMaterialService projectMaterialDaoService; @Autowired private AttachmentService attachmentService; @Autowired private ProjectTypeService projectTypeService; @Autowired private CompanyContactService companyContactService; @Autowired private ProjectApplicationCompanyInfoService projectApplicationCompanyInfoService; @Autowired private WaitToDoService waitToDoService; @Autowired private ProjectFillingService projectFillingService; @Autowired private ProjectService projectService; public PageInfo findPageInfo(String projectName, Integer pageNum, Integer pagesize, String startTime1, String startTime2, String endTime1, String endTime2) { PageHelper.startPage(pageNum, pagesize); List list = projectDeclarationDao.findPageInfo(projectName, startTime1, startTime2, endTime1, endTime2); for (ProjectDeclaration projectDeclaration : list) { if (Objects.equals(projectDeclaration.getStatus(), "0")) { projectDeclaration.setStatus_name("待发布"); } else { try { String end = projectDeclaration.getApply_enddate(); if (end.length() <= 10) end += " 23:59:59"; SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Date endtime = sdf.parse(end); String start = projectDeclaration.getApply_startdate(); if (start.length() <= 10) start += " 00:00:00"; Date starttime = sdf.parse(start); Date now = new Date(); if (now.after(endtime)) { projectDeclaration.setStatus_name("失效"); } else if (now.before(starttime)) { projectDeclaration.setStatus_name("未开始"); } else { projectDeclaration.setStatus_name("申请中"); } } catch (Exception e) { projectDeclaration.setStatus_name("申请中"); } } } return new PageInfo(list); } public Integer save(ProjectDeclaration projectDeclaration) { //String apply_date_range = projectDeclaration.getApply_date_range(); /*if (apply_date_range != null && apply_date_range != "") { if (apply_date_range.contains(" 至 ")) { String[] dateRange = apply_date_range.split(" 至 "); if (dateRange[0] == null || dateRange[0] == "" || dateRange[0] == "null") { projectDeclaration.setApply_startdate(""); } else { projectDeclaration.setApply_startdate(dateRange[0]); } if (dateRange[1] == null || dateRange[1] == "" || dateRange[1] == "null") { projectDeclaration.setApply_enddate(""); } else { projectDeclaration.setApply_enddate(dateRange[1]); } } else { projectDeclaration.setApply_startdate(""); projectDeclaration.setApply_enddate(""); } } else { projectDeclaration.setApply_startdate(""); projectDeclaration.setApply_enddate(""); }*/ this.insertAndGetId(projectDeclaration); Integer activityId = projectDeclaration.getId(); attachmentDao.deleteByBusiness(Constant.Attachment.PROJECT_DECLARATION, projectDeclaration.getId()); attachmentDao.updateAttachment(Constant.Attachment.PROJECT_DECLARATION, projectDeclaration.getId(), projectDeclaration.getFileDown().getFile_id()); pushNotices(projectDeclaration); if (projectDeclaration.getStatus().equals(Constant.ProjectDeclarationStatus.RELEASE)) { //所有企业 List companies = companyService.findCompanyList(); String companyids = ""; for (Company company : companies) { companyids += company.getId() + ","; } //所有街道 List streets = streetService.findList(); String streetids = ""; for (Street street : streets) { streetids += street.getId() + ","; } //中心窗口 StringBuffer governmentids = new StringBuffer(""); Group group = groupService.findByName(Constant.XMSBCLSLZ, null); if (null == group) { throw new BaseException("操作失败,项目申报审核组没有该项目责任单位的审核人员,请联系管理员配置"); } List userGroups = userGroupService.findByGroupId(group.getId()); for (UserGroup userGroup : userGroups) { governmentids.append(userGroup.getUser_id() + ","); } //处室 group = groupService.findByName(Constant.XMSBCLSHZ, null); if (null == group) { throw new BaseException("操作失败,项目申报审核组没有该项目责任单位的审核人员,请联系管理员配置"); } userGroups = userGroupService.findByGroupId(group.getId()); for (UserGroup userGroup : userGroups) { governmentids.append(userGroup.getUser_id() + ","); } //财政 group = groupService.findByName(Constant.XMSBCZSHZ, null); if (null == group) { throw new BaseException("操作失败,项目申报审核组没有该项目责任单位的审核人员,请联系管理员配置"); } userGroups = userGroupService.findByGroupId(group.getId()); for (UserGroup userGroup : userGroups) { governmentids.append(userGroup.getUser_id() + ","); } Message messages = new Message(); messages.setApply_id(activityId); messages.setTitle(projectDeclaration.getProject_name() + "准备申报"); String projectName = projectDeclaration.getProject_name(); String s = projectDeclaration.getApply_startdate(); String e = projectDeclaration.getApply_enddate(); try { SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd"); Date date1 = sdf1.parse(s); Date date2 = sdf1.parse(e); SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy年MM月dd日"); s = sdf2.format(date1); e = sdf2.format(date2); } catch (ParseException e1) { e1.printStackTrace(); } String message = projectName + "自" + s + "开始可以进行申报,申报截止日期为" + e; messages.setContent(message); messages.setBusiness_type(Constant.Message_Business_type.PROJECT_APPLY); if (!StringUtils.isEmpty(streetids)) { String[] streetArr = streetids.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.STREET); } if (!StringUtils.isEmpty(companyids)) { String[] companyArr = companyids.split(","); Set set = new HashSet<>(); for (int i = 0; i < companyArr.length; i++) { set.add(companyArr[i]); } String[] companyArrs = (String[]) set.toArray(new String[set.size()]); int[] companyArrInt = new int[companyArrs.length]; for (int i = 0; i < companyArrs.length; i++) { companyArrInt[i] = Integer.parseInt(companyArrs[i]); } messageService.saveMessageAndPush(messages, companyArrInt, Constant.UserType.COMPANY); } if (!StringUtils.isEmpty(governmentids.toString())) { String[] governmentArr = governmentids.toString().split(","); Set set = new HashSet<>(); for (int i = 0; i < governmentArr.length; i++) { set.add(governmentArr[i]); } String[] governmentArrs = (String[]) set.toArray(new String[set.size()]); int[] governmentArrInt = new int[governmentArrs.length]; for (int i = 0; i < governmentArrs.length; i++) { governmentArrInt[i] = Integer.parseInt(governmentArrs[i]); } messageService.saveMessageAndPush(messages, governmentArrInt, Constant.UserType.GOVERNMENT); } } return activityId; } public Integer update(ProjectDeclaration projectDeclaration) { String apply_date_range = projectDeclaration.getApply_date_range(); /*if (apply_date_range != null && apply_date_range != "") { if (apply_date_range.contains(" 至 ")) { String[] dateRange = apply_date_range.split(" 至 "); if (dateRange[0] == null || dateRange[0] == "" || dateRange[0] == "null") { projectDeclaration.setApply_startdate(""); } else { projectDeclaration.setApply_startdate(dateRange[0]); } if (dateRange[1] == null || dateRange[1] == "" || dateRange[1] == "null") { projectDeclaration.setApply_enddate(""); } else { projectDeclaration.setApply_enddate(dateRange[1]); } } else { projectDeclaration.setApply_startdate(""); projectDeclaration.setApply_enddate(""); } } else { projectDeclaration.setApply_startdate(""); projectDeclaration.setApply_enddate(""); }*/ this.updateSelective(projectDeclaration); Integer activityId = projectDeclaration.getId(); attachmentDao.deleteByBusiness(Constant.Attachment.PROJECT_DECLARATION, projectDeclaration.getId()); attachmentDao.updateAttachment(Constant.Attachment.PROJECT_DECLARATION, projectDeclaration.getId(), projectDeclaration.getFileDown().getFile_id()); pushNotices(projectDeclaration); if (projectDeclaration.getStatus().equals(Constant.ProjectDeclarationStatus.RELEASE)) { //所有企业 List companies = companyService.findCompanyList(); String companyids = ""; for (Company company : companies) { companyids += company.getId() + ","; } //所有街道 List streets = streetService.findList(); String streetids = ""; for (Street street : streets) { streetids += street.getId() + ","; } //中心窗口 StringBuffer governmentids = new StringBuffer(""); Group group = groupService.findByName(Constant.XMSBCLSLZ, null); if (null == group) { throw new BaseException("操作失败,项目申报审核组没有该项目责任单位的审核人员,请联系管理员配置"); } List userGroups = userGroupService.findByGroupId(group.getId()); for (UserGroup userGroup : userGroups) { governmentids.append(userGroup.getUser_id() + ","); } //处室 group = groupService.findByName(Constant.XMSBCLSHZ, null); if (null == group) { throw new BaseException("操作失败,项目申报审核组没有该项目责任单位的审核人员,请联系管理员配置"); } userGroups = userGroupService.findByGroupId(group.getId()); for (UserGroup userGroup : userGroups) { governmentids.append(userGroup.getUser_id() + ","); } //财政 group = groupService.findByName(Constant.XMSBCZSHZ, null); if (null == group) { throw new BaseException("操作失败,项目申报审核组没有该项目责任单位的审核人员,请联系管理员配置"); } userGroups = userGroupService.findByGroupId(group.getId()); for (UserGroup userGroup : userGroups) { governmentids.append(userGroup.getUser_id() + ","); } Message messages = new Message(); messages.setApply_id(activityId); messages.setTitle(projectDeclaration.getProject_name() + "准备申报"); String projectName = projectDeclaration.getProject_name(); String s = projectDeclaration.getApply_startdate(); String e = projectDeclaration.getApply_enddate(); try { SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd"); Date date1 = sdf1.parse(s); Date date2 = sdf1.parse(e); SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy年MM月dd日"); s = sdf2.format(date1); e = sdf2.format(date2); } catch (ParseException e1) { e1.printStackTrace(); } String message = projectName + "自" + s + "开始可以进行申报,申报截止日期为" + e; messages.setContent(message); messages.setBusiness_type(Constant.Message_Business_type.PROJECT_APPLY); if (!StringUtils.isEmpty(streetids)) { String[] streetArr = streetids.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.STREET); } if (!StringUtils.isEmpty(companyids)) { String[] companyArr = companyids.split(","); Set set = new HashSet<>(); for (int i = 0; i < companyArr.length; i++) { set.add(companyArr[i]); } String[] companyArrs = (String[]) set.toArray(new String[set.size()]); int[] companyArrInt = new int[companyArrs.length]; for (int i = 0; i < companyArrs.length; i++) { companyArrInt[i] = Integer.parseInt(companyArrs[i]); } messageService.saveMessageAndPush(messages, companyArrInt, Constant.UserType.COMPANY); } if (!StringUtils.isEmpty(governmentids.toString())) { String[] governmentArr = governmentids.toString().split(","); Set set = new HashSet<>(); for (int i = 0; i < governmentArr.length; i++) { set.add(governmentArr[i]); } String[] governmentArrs = (String[]) set.toArray(new String[set.size()]); int[] governmentArrInt = new int[governmentArrs.length]; for (int i = 0; i < governmentArrs.length; i++) { governmentArrInt[i] = Integer.parseInt(governmentArrs[i]); } messageService.saveMessageAndPush(messages, governmentArrInt, Constant.UserType.GOVERNMENT); } } return activityId; } public ProjectDeclaration selectById(String id) { ProjectDeclaration projectDeclaration = projectDeclarationDao.selectById(id); //发布单位 if (StringUtils.isNotBlank(projectDeclaration.getRelease_departments())) { String[] deptIds = projectDeclaration.getRelease_departments().split(","); List release_departmentsIds = new ArrayList(); String release_departmentsNames = ""; for (int i = 0; i < deptIds.length; i++) { Department dept = departmentService.findById(Integer.valueOf(deptIds[i])); if (null != dept) { release_departmentsIds.add(Integer.valueOf(deptIds[i])); release_departmentsNames += dept.getName() + ","; } } projectDeclaration.setRelease_departmentsIds(release_departmentsIds); if (StringUtils.isNotBlank(release_departmentsNames)) { String names = release_departmentsNames.substring(0, release_departmentsNames.length() - 1); projectDeclaration.setRelease_departments_name(names); } } //责任单位 if (null != projectDeclaration.getDepartment_id()) { Department dept = departmentService.findById(projectDeclaration.getDepartment_id()); if (null != dept) { projectDeclaration.setDepartment_name(dept.getName()); } } //项目大类 String superType = projectDeclaration.getProject_super_type(); if (StringUtils.isNotBlank(superType)) { DictionaryItem superTypeItem = dictionaryItemService.findByTypeAndValue(Constant.DictionaryType.PROJECT_APPLICATION_SUPER_TYPE, superType); if (null != superTypeItem) { projectDeclaration.setProject_super_type_name(superTypeItem.getName()); } } //项目来源 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_DECLARATION, 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); } try { projectDeclaration = getPushNames(projectDeclaration); } catch (Exception e) { e.printStackTrace(); } return projectDeclaration; } public void push(Integer id) { ProjectDeclaration projectDeclaration = projectDeclarationDao.selectById(id.toString()); pushNotices(projectDeclaration); } @Transactional public void pushNotices(ProjectDeclaration projectDeclaration) { if (null != projectDeclaration.getNew_push_company_ids()) { try { updatePushDetails(projectDeclaration, projectDeclaration.getNew_push_street_ids(), projectDeclaration.getNew_push_build_ids(), projectDeclaration.getNew_push_company_ids()); } catch (Exception e) { e.printStackTrace(); } String company_ids = projectDeclaration.getNew_push_company_ids(); projectDeclaration.setPush_company_ids(company_ids); } if (Objects.equals(projectDeclaration.getStatus(), "1") && projectDeclaration.getPush_company_ids() != null && !projectDeclaration.getPush_company_ids().isEmpty()) { Notices notice = new Notices(); if (Objects.equals(projectDeclaration.getApp_notice(), "1")) { notice.setNotice_type("1"); if (Objects.equals(projectDeclaration.getMes_notice(), "1")) { notice.setNotice_type("3"); } } else { if (Objects.equals(projectDeclaration.getMes_notice(), "1")) { notice.setNotice_type("2"); } } notice.setMessage_content(""); notice.setRecorde_id(projectDeclaration.getId().toString()); noticesService.insertAndGetId(notice); Integer noticesId = notice.getId(); String companyIds = projectDeclaration.getPush_company_ids(); String[] companyIdsArr = companyIds.split(","); List ids = new ArrayList(); if (companyIdsArr.length > 0) { for (String id : companyIdsArr) { NoticesAccept noticesAccept = new NoticesAccept(); noticesAccept.setNotice_id(noticesId); noticesAccept.setRead_statu(0); noticesAccept.setUser_type(Constant.UserType.COMPANY); noticesAccept.setRecorde_type(2); noticesAccept.setRecorde_id(projectDeclaration.getId()); noticesAccept.setUser_id(Integer.parseInt(id)); noticesAccept.setUser_type(3); noticesAcceptService.insertAndGetId(noticesAccept); } } } } //查询推送单位名称 public ProjectDeclaration getPushNames(ProjectDeclaration projectDeclaration) throws Exception { String pushNames = ""; if (StringUtils.isNotBlank(projectDeclaration.getPush_street_ids())) { List streetNames = new ArrayList(); String[] streetIds = projectDeclaration.getPush_street_ids().split(","); for (int i = 0; i < streetIds.length; i++) { String name = streetService.getStreetName(Integer.valueOf(streetIds[i])); streetNames.add(name); } projectDeclaration.setPush_street_names(String.join(",", streetNames)); pushNames += String.join(",", streetNames); } if (StringUtils.isNotBlank(projectDeclaration.getPush_build_ids())) { List buildNames = new ArrayList(); String[] buildIds = projectDeclaration.getPush_build_ids().split(","); for (int i = 0; i < buildIds.length; i++) { String name = buildInfoService.getBuildName(Integer.valueOf(buildIds[i])); buildNames.add(name); } projectDeclaration.setPush_build_names(String.join(",", buildNames)); pushNames += " ; " + String.join(",", buildNames); } if (StringUtils.isNotBlank(projectDeclaration.getPush_company_ids())) { List companyNames = new ArrayList(); String[] companyIds = projectDeclaration.getPush_company_ids().split(","); for (int i = 0; i < companyIds.length; i++) { String name = companyService.getCompanyName(Integer.valueOf(companyIds[i])); companyNames.add(name); } projectDeclaration.setPush_company_names(String.join(",", companyNames)); pushNames += " ; " + String.join(",", companyNames); } projectDeclaration.setPush_names(pushNames); return projectDeclaration; } /** * 更新通知推送单位 */ public Boolean updatePushDetails(ProjectDeclaration projectDeclaration, String street_ids, String build_ids, String company_ids) throws Exception { String alreadyPushStreets = projectDeclaration.getPush_street_ids() == null ? "" : projectDeclaration.getPush_build_ids(); String alreadyPushBuilds = projectDeclaration.getPush_build_ids() == null ? "" : projectDeclaration.getPush_build_ids(); String alreadyPushCompanys = projectDeclaration.getPush_company_ids() == null ? "" : projectDeclaration.getPush_company_ids(); if (StringUtils.isNotBlank(street_ids)) { String[] idsArr = street_ids.split(","); if (idsArr.length > 0) { for (int i = 0; i < idsArr.length; i++) { if (!alreadyPushStreets.contains(idsArr[i])) { alreadyPushStreets += "," + idsArr[i]; } } } else { alreadyPushStreets = street_ids; } } if (StringUtils.isNotBlank(build_ids)) { String[] idsArr = build_ids.split(","); if (idsArr.length > 0) { for (int i = 0; i < idsArr.length; i++) { if (!alreadyPushBuilds.contains(idsArr[i])) { alreadyPushBuilds += "," + idsArr[i]; } } } else { alreadyPushBuilds = build_ids; } } if (StringUtils.isNotBlank(company_ids)) { String[] idsArr = company_ids.split(","); if (idsArr.length > 0) { for (int i = 0; i < idsArr.length; i++) { if (!alreadyPushCompanys.contains(idsArr[i])) { alreadyPushCompanys += "," + idsArr[i]; } } } else { alreadyPushCompanys = company_ids; } } projectDeclaration.setPush_build_ids(alreadyPushBuilds.substring(0, alreadyPushBuilds.length())); projectDeclaration.setPush_build_ids(alreadyPushBuilds.substring(0, alreadyPushBuilds.length())); projectDeclaration.setPush_company_ids(alreadyPushCompanys.substring(0, alreadyPushCompanys.length())); return this.updateSelective(projectDeclaration) > 0; } //根据小组名称获取组内用户 public String findUserIdByGroupName(String groupName) { Group group = groupService.findByName(groupName, null); List userGroups = userGroupService.findByGroupId(group.getId()); StringBuffer sb = new StringBuffer(""); for (UserGroup userGroup : userGroups) { sb.append(userGroup.getUser_id() + ","); } return sb.toString(); } //根据用户获取所在部门 public String findUserDepartment(String userIds) { int currentUserId = ShiroUtils.getUserId(); String[] userIdArr = userIds.split(","); List list = Arrays.asList(userIdArr); if (ShiroUtils.getUserType().equals(Constant.UserType.GOVERNMENT)) { if (list.contains(String.valueOf(currentUserId))) { Integer departmentId = userService.findDepartmentIdByUserId(currentUserId); if (null != departmentId) { return departmentId.toString(); } } } return null; } public void getProjectApproval(Integer id) { int currentUserId = ShiroUtils.getUserId(); Example example = new Example(Project.class); Example.Criteria criteria = example.createCriteria(); criteria.andEqualTo("id", id); List projectList = projectDao.selectByExample(example); if (!CollectionUtils.isEmpty(projectList)) { projectList.get(0).getDepartment_id(); projectList.get(0).getDepartment_name(); } //材料受理 String sl = findUserIdByGroupName(Constant.XMSBCLSLZ); //材料审核 String sh = findUserIdByGroupName(Constant.XMSBCLSHZ); } //获取项目申报id 待审批 public List getProjectIdsd() { /* boolean flag = false;*/ int currentUserId = ShiroUtils.getUserId(); /*Group group = groupService.findByName(Constant.XMSBFZR, null); List userGroups = userGroupService.findByGroupId(group.getId()); for (UserGroup userGroup : userGroups) { if (Objects.equals(userGroup.getUser_id(), currentUserId)) { flag = true; } }*/ List approvalList = approvalDao.selectAllApprovalDistinct(Constant.DictionaryType.PROJECT_APPLICATION); Set projectApplicationIds = new HashSet(); if (Objects.equals(ShiroUtils.getUserType(), Constant.UserType.GOVERNMENT)) { if (!CollectionUtils.isEmpty(approvalList)) { for (Approval approval : approvalList) { String nextCheckerIds = approval.getNextchecker(); if (nextCheckerIds != null && nextCheckerIds != "") { String[] userIdArr = nextCheckerIds.split(","); List list = Arrays.asList(userIdArr); if (list.contains(String.valueOf(currentUserId))) { projectApplicationIds.add(approval.getApply_id().toString()); } } } } } /*if (flag) { Example example = new Example(ProjectApplication.class); Example.Criteria criteria = example.createCriteria(); criteria.andEqualTo("approve_status", Constant.ProjectApplicationStatus.NOTIFY); //criteria.orEqualTo("approve_status", Constant.ProjectApplicationStatus.APPROVED); List projectList = projectApplicationDao.selectByExample(example); for (ProjectApplication project : projectList) { projectApplicationIds.add(project.getId().toString()); } }*/ List result = new ArrayList<>(projectApplicationIds); return result; } //获取项目申报id 已审批 public List getProjectIdsy() { int currentUserId = ShiroUtils.getUserId(); List approvalList = approvalDao.selectAllApproval(Constant.DictionaryType.PROJECT_APPLICATION); 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; } //获取项目申报id 待通知 public List getProjectIdsn() { /*int currentUserId = ShiroUtils.getUserId(); List approvalList = approvalDao.selectAllApprovalDistinct(); 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 != "") { String[] userIdArr = checkerIds.split(","); List list = Arrays.asList(userIdArr); if (list.contains(String.valueOf(currentUserId))) { projectApplicationIds.add(approval.getApply_id().toString()); } } } } }*/ List result = new ArrayList<>(); Example example = new Example(ProjectApplication.class); Example.Criteria criteria = example.createCriteria(); criteria.andEqualTo("approve_status", Constant.ProjectApplicationStatus.NOTIFY); //criteria.orEqualTo("approve_status", Constant.ProjectApplicationStatus.APPROVED); List projectList = projectApplicationDao.selectByExample(example); for (ProjectApplication project : projectList) { result.add(project.getId().toString()); } return result; } //获取项目申报id 查看所有 public List getProjectIdsc() { List result = new ArrayList<>(); Example example = new Example(ProjectApplication.class); Example.Criteria criteria = example.createCriteria(); criteria.andEqualTo("approve_status", Constant.ProjectApplicationStatus.NOTIFY);//待通知 criteria.orEqualTo("approve_status", Constant.ProjectApplicationStatus.LOCAL_AUDIT); //属地初审 criteria.orEqualTo("approve_status", Constant.ProjectApplicationStatus.CENTRE_AUDIT);//材料审核 criteria.orEqualTo("approve_status", Constant.ProjectApplicationStatus.DEPARTMENT_AUDIT);//处室(中心)审批 criteria.orEqualTo("approve_status", Constant.ProjectApplicationStatus.FINANCE_AUDIT);//财政审批 criteria.orEqualTo("approve_status", Constant.ProjectApplicationStatus.UPLOAD_REPORT);//待上传报告 criteria.orEqualTo("approve_status", Constant.ProjectApplicationStatus.APPROVED);//通过 criteria.orEqualTo("approve_status", Constant.ProjectApplicationStatus.REJECT_TO_COMPANY);//退回至企业 criteria.orEqualTo("approve_status", Constant.ProjectApplicationStatus.REJECT_TO_DEPARTMENT);//退回至处室 criteria.orEqualTo("approve_status", Constant.ProjectApplicationStatus.NOTAPPROVED);//不通过 criteria.orEqualTo("approve_status", Constant.ProjectApplicationStatus.UPLOAD_CS);//待财政上传 criteria.orEqualTo("approve_status", Constant.ProjectApplicationStatus.UPLOAD_CZ);//待处室上传 criteria.orEqualTo("approve_status", Constant.ProjectApplicationStatus.COMMIT_FILE);//待中心窗口上传 criteria.orEqualTo("del_flag", "0");//不显示删除的 List projectList = projectApplicationDao.selectByExample(example); for (ProjectApplication project : projectList) { result.add(project.getId().toString()); } return result; } //根据用户组获取可查询到的项目 public List getProjectIdsByGroup() { List projectLists = new ArrayList<>(); Integer user_id = ShiroUtils.getUserId(); Department department = departmentService.findById(ShiroUtils.getUserEntity().getDepartment_id()); Integer departmentId = 21;//中心窗口 if (!department.getParent_id().equals(departmentId)) departmentId = department.getId(); Example example = new Example(Project.class); Example.Criteria criteria = example.createCriteria(); criteria.andEqualTo("del_flag", "0"); criteria.andEqualTo("department_id", departmentId); List projectList = projectDao.selectByExample(example); List project_ids = new ArrayList<>(); if (CollectionUtils.isEmpty(projectList)) return project_ids; for (Project project : projectList) { project_ids.add(project.getId() + ""); } Group group; List userGroups; List apply_status_list = new ArrayList<>(); if (ShiroUtils.getUserType() == Constant.UserType.STREET) { group = groupService.findByName(Constant.XMSBJDSLZ, 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.ProjectProvincesStatus.LOCAL_AUDIT); break; } } } else { //材料受理 group = groupService.findByName(Constant.XMSBCLSLZ, null); userGroups = userGroupService.findByGroupId(group.getId()); for (UserGroup userGroup : userGroups) { if (Objects.equals(userGroup.getUser_id(), user_id)) { apply_status_list.add(Constant.ProjectApplicationStatus.CENTRE_AUDIT); apply_status_list.add(Constant.ProjectApplicationStatus.COMMIT_FILE); projectLists.addAll(projectApplicationDao.findByProjectIdAndApproveStatus(new ArrayList<>(), apply_status_list, null)); break; } } //材料审核 group = groupService.findByName(Constant.XMSBCLSHZ, null); userGroups = userGroupService.findByGroupId(group.getId()); for (UserGroup userGroup : userGroups) { if (Objects.equals(userGroup.getUser_id(), user_id)) { apply_status_list.add(Constant.ProjectApplicationStatus.DEPARTMENT_AUDIT); apply_status_list.add(Constant.ProjectApplicationStatus.UPLOAD_REPORT); apply_status_list.add(Constant.ProjectApplicationStatus.UPLOAD_CZ); break; } } //项目申报财政审核组 group = groupService.findByName(Constant.XMSBCZSHZ, null); userGroups = userGroupService.findByGroupId(group.getId()); for (UserGroup userGroup : userGroups) { if (Objects.equals(userGroup.getUser_id(), user_id)) { apply_status_list.add(Constant.ProjectApplicationStatus.FINANCE_AUDIT); apply_status_list.add(Constant.ProjectApplicationStatus.UPLOAD_REPORT); apply_status_list.add(Constant.ProjectApplicationStatus.UPLOAD_CS); break; } } //项目申报负责人 group = groupService.findByName(Constant.XMSBFZR, null); userGroups = userGroupService.findByGroupId(group.getId()); for (UserGroup userGroup : userGroups) { if (Objects.equals(userGroup.getUser_id(), user_id)) { apply_status_list.add(Constant.ProjectApplicationStatus.NOTIFY); projectLists.addAll(projectApplicationDao.findByProjectIdAndApproveStatus(new ArrayList<>(), apply_status_list, null)); break; } } } if (apply_status_list.size() <= 0) { apply_status_list.add(""); } projectLists.addAll(projectApplicationDao.findByProjectIdAndApproveStatus(project_ids, apply_status_list, null)); List result = new ArrayList<>(); for (ProjectApplication project : projectLists) { result.add(project.getId().toString()); } return result; } //待审核分页 public PageInfo findPage(Integer pageNum, Integer pageSize, ParamApplication paramApplication, String type) { paramApplication.setApproval_type(Constant.DictionaryType.PROJECT_APPLICATION); if (Objects.equals("1", type)) { //paramApplication.setProjectIds(getProjectIdsd()); //原逻辑 paramApplication.setProjectIds(getProjectIdsByGroup());//新逻辑 } else if (Objects.equals("2", type)) { paramApplication.setProjectIds(getProjectIdsy()); } /*else if (Objects.equals("3", type)) { paramApplication.setProjectIds(getProjectIdsn()); }*/ else if (Objects.equals("4", type)) { paramApplication.setProjectIds(getProjectIdsc()); } String year = paramApplication.getProject_year(); if (year != null && !year.equals("")) { paramApplication.setProject_year_date(year + "-01-01 00:00:00"); } PageHelper.startPage(pageNum, pageSize); List applicationDtoList = projectApplicationDao.findPage(paramApplication); for (ApplicationDto app : applicationDtoList) { if (null != app.getProject_type()) { ProjectType projectType = projectTypeService.findById(Integer.parseInt(app.getProject_type())); //String type_name = dictionaryItemService.findNameByTypeAndValue(Constant.DictionaryType.PROJECT_APPLICATION_TYPE, app.getProject_type()); app.setProject_type(projectType.getType_name()); } if (null != app.getApprove_status()) { String status_name = dictionaryItemService.findNameByTypeAndValue(Constant.DictionaryType.PROJECT_APPROVE_STATUS, app.getApprove_status()); app.setStatedesc(status_name); } } return new PageInfo<>(applicationDtoList); } //待审核分页 public List findList(ParamApplication paramApplication, String type) { paramApplication.setApproval_type(Constant.DictionaryType.PROJECT_APPLICATION); if (Objects.equals("1", type)) { //paramApplication.setProjectIds(getProjectIdsd()); //原逻辑 paramApplication.setProjectIds(getProjectIdsByGroup());//新逻辑 } else if (Objects.equals("2", type)) { paramApplication.setProjectIds(getProjectIdsy()); } /*else if (Objects.equals("3", type)) { paramApplication.setProjectIds(getProjectIdsn()); }*/ else if (Objects.equals("4", type)) { paramApplication.setProjectIds(getProjectIdsc()); } String year = paramApplication.getProject_year(); if (year != null && !year.equals("")) { paramApplication.setProject_year_date(year + "-01-01 00:00:00"); } List applicationDtoList = projectApplicationDao.findPage(paramApplication); for (ApplicationDto app : applicationDtoList) { if (null != app.getProject_type()) { ProjectType projectType = projectTypeService.findById(Integer.parseInt(app.getProject_type())); //String type_name = dictionaryItemService.findNameByTypeAndValue(Constant.DictionaryType.PROJECT_APPLICATION_TYPE, app.getProject_type()); app.setProject_type(projectType.getType_name()); } if (null != app.getApprove_status()) { String status_name = dictionaryItemService.findNameByTypeAndValue(Constant.DictionaryType.PROJECT_APPROVE_STATUS, app.getApprove_status()); app.setStatedesc(status_name); } } return applicationDtoList; } //通过 public Boolean pass(Integer projectId, String comment) throws ClientException, InterruptedException { ProjectApplication projectApplication = projectApplicationDao.selectById(projectId.toString()); Project project = new Project(); project.setId(projectApplication.getProject_id()); project = projectDao.selectOne(project); //判断年份 ProjectDeclaration declaration = findById(projectApplication.getDeclaration_id()); DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); int year = LocalDateTime.parse(declaration.getApply_startdate(), formatter).getYear(); if (year == 2019) return refactorPass(projectId, comment); Approval approval = approvalDao.getLatestApproval(projectId, Constant.DictionaryType.PROJECT_APPLICATION); Approval a = new Approval(); a.setApply_id(projectId); a.setType(Constant.DictionaryType.PROJECT_APPLICATION); 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())); //短信所需参数 Map params = new HashMap<>(); params.put("project_no", projectApplication.getApply_no()); params.put("apply_name", Constant.ProjectType.PROJECT_APPLICATION); Company company = companyService.findById(projectApplication.getCompany_id()); User companyAdmin = userService.findCompanyAdmin(company.getId()); if (Objects.equals(Constant.ProjectApplicationStatus.CENTRE_AUDIT, approval.getAfter_approvalstatus())) { //材料审核通过,进如处室(中心)审批 a.setBefore_approvalstatus(Constant.ProjectApplicationStatus.CENTRE_AUDIT); a.setAfter_approvalstatus(Constant.ProjectApplicationStatus.DEPARTMENT_AUDIT); Integer departmentid = declaration.getDepartment_id(); Group group = groupService.findByName(Constant.XMSBCLSHZ, null); if (null == group) { throw new BaseException("操作失败,项目申报材料审核组没有该项目责任单位的审核人员,请联系管理员配置"); } List userGroups = userGroupService.findByGroupId(group.getId()); List users = userService.findUserBydepartmentIdWithoutApprovalLevel(departmentid.toString()); StringBuffer sb = new StringBuffer(""); // Company company = companyService.findById(projectApplication.getCompany_id()); ProjectDeclaration projectDeclaration = this.findById(projectApplication.getDeclaration_id()); String projectName = projectDeclaration.getProject_name(); Message messages = new Message(); messages.setApply_id(projectId); messages.setBusiness_type(Constant.Message_Business_type.PROJECT_APPLY); messages.setTitle("提醒处室审核"); waitToDoService.completeAllTODO(projectApplication.getId(), Constant.DictionaryType.PROJECT_APPLICATION); for (UserGroup userGroup : userGroups) { for (User user : users) { if (Objects.equals(user.getId(), userGroup.getUser_id())) { sb.append(userGroup.getUser_id() + ","); //User u = userService.findById(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("项目申报审核", "/projectDeclaration/approve/" + projectApplication.getId(), Constant.WaitToDo_OperType.AUDIT, projectApplication.getId(), Constant.DictionaryType.PROJECT_APPLICATION, projectApplication.getApply_no(), userGroup.getUser_id().toString(), Constant.WaitToDo_IsSerial.IS_SERIAL, false); //发送短信 // String tempCode = Constant.SMS_TemplateCode.RPOJECT_APPLICATION_AUDIT; // AlibabaSMSUtil.sendSMSMessage( // user.getPhone(), tempCode, Constant.SINGNAMW, JSONObject.toJSONString(params)); } } } a.setNextchecker(sb.toString()); if (null == sb || sb.length() == 0) { throw new BaseException("操作失败,项目申报材料审核组没有该项目责任单位的审核人员,请联系管理员配置"); } ProjectApplication pa = new ProjectApplication(); pa.setId(projectId); pa.setApprove_status(Constant.ProjectApplicationStatus.DEPARTMENT_AUDIT); projectApplicationDao.updateByPrimaryKeySelective(pa); approvalService.insertAndGetId(a); return true; } else if (Objects.equals(Constant.ProjectApplicationStatus.DEPARTMENT_AUDIT, approval.getAfter_approvalstatus())) { //处室通过,进去中心窗口提交 a.setBefore_approvalstatus(Constant.ProjectApplicationStatus.DEPARTMENT_AUDIT); a.setAfter_approvalstatus(Constant.ProjectApplicationStatus.COMMIT_FILE); ProjectDeclaration projectDeclaration = this.findById(projectApplication.getDeclaration_id()); String projectName = projectDeclaration.getProject_name(); if (project.getIs_technical()) { //技改类发送通知 Message messages1 = new Message(); messages1.setApply_id(projectId); messages1.setBusiness_type(Constant.Message_Business_type.PROJECT_APPLY); messages1.setTitle("提醒企业准备材料"); String message = company.getCompany_name() + ",您好。您提交的单号为" + projectApplication.getApply_no() + "的区级工业经济扶持项目申请," + "审核流程已过半,请提前准备好申报的纸质材料,等待审核通过谢谢!"; messages1.setContent(message); int[] streetArrInt = new int[1]; streetArrInt[0] = projectApplication.getCompany_id(); messageService.saveMessageAndPush(messages1, streetArrInt, Constant.UserType.COMPANY); //发送短信(提醒企业准备材料) String tempCode = Constant.SMS_TemplateCode.REMINSD_COMPNAY_PREPARE_MATERIALS; AlibabaSMSUtil.sendSMS( companyAdmin.getPhone(), tempCode, Constant.SINGNAMW, JSONObject.toJSONString(params)); } Message messages = new Message(); messages.setApply_id(projectId); messages.setBusiness_type(Constant.Message_Business_type.PROJECT_APPLY); messages.setTitle("提醒中心补充材料"); Group group = groupService.findByName(Constant.XMSBCLSLZ, null); if (null == group) { throw new BaseException("操作失败,项目申报财政审核组没有该项目责任单位的审核人员,请联系管理员配置"); } List userGroups = userGroupService.findByGroupId(group.getId()); StringBuffer sb = new StringBuffer(""); waitToDoService.completeAllTODO(projectApplication.getId(), Constant.DictionaryType.PROJECT_APPLICATION); for (UserGroup userGroup : userGroups) { sb.append(userGroup.getUser_id() + ","); User user = userService.findById(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("项目申报审核", "/projectDeclaration/approve/" + projectApplication.getId(), Constant.WaitToDo_OperType.AUDIT, projectApplication.getId(), Constant.DictionaryType.PROJECT_APPLICATION, projectApplication.getApply_no(), userGroup.getUser_id().toString(), Constant.WaitToDo_IsSerial.IS_SERIAL, false); //发送短信 // String tempCode = Constant.SMS_TemplateCode.RPOJECT_APPLICATION_AUDIT; // AlibabaSMSUtil.sendSMSMessage( // user.getPhone(), tempCode, Constant.SINGNAMW, JSONObject.toJSONString(params)); } a.setNextchecker(sb.toString()); if (sb.length() == 0) { throw new BaseException("操作失败,项目申报财政审核组没有该项目责任单位的审核人员,请联系管理员配置"); } ProjectApplication pa = new ProjectApplication(); pa.setId(projectId); pa.setApprove_status(Constant.ProjectApplicationStatus.COMMIT_FILE); projectApplicationDao.updateByPrimaryKeySelective(pa); approvalService.insertAndGetId(a); return true; } else if (Objects.equals(Constant.ProjectApplicationStatus.COMMIT_FILE, approval.getAfter_approvalstatus())) { //中心窗口提交完成 进入财政审批 a.setBefore_approvalstatus(Constant.ProjectApplicationStatus.COMMIT_FILE); a.setAfter_approvalstatus(Constant.ProjectApplicationStatus.FINANCE_AUDIT); Integer departmentid = project.getDepartment_id(); Group group = groupService.findByName(Constant.XMSBCZSHZ, null); if (null == group) { throw new BaseException("操作失败,项目申报材料受理组没有该项目责任单位的审核人员,请联系管理员配置"); } List userGroups = userGroupService.findByGroupId(group.getId()); List users = userService.findUserBydepartmentIdWithoutApprovalLevel(departmentid.toString()); StringBuffer sb = new StringBuffer(""); ProjectDeclaration projectDeclaration = this.findById(projectApplication.getDeclaration_id()); String projectName = projectDeclaration.getProject_name(); Message messages = new Message(); messages.setApply_id(projectId); messages.setBusiness_type(Constant.Message_Business_type.PROJECT_APPLY); messages.setTitle("提醒财政审核"); waitToDoService.completeAllTODO(projectApplication.getId(), Constant.DictionaryType.PROJECT_APPLICATION); for (UserGroup userGroup : userGroups) { for (User user : users) { if (Objects.equals(user.getId(), userGroup.getUser_id())) { sb.append(userGroup.getUser_id() + ","); //User user = userService.findById(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("项目申报审核", "/projectDeclaration/approve/" + projectApplication.getId(), Constant.WaitToDo_OperType.AUDIT, projectApplication.getId(), Constant.DictionaryType.PROJECT_APPLICATION, projectApplication.getApply_no(), userGroup.getUser_id().toString(), Constant.WaitToDo_IsSerial.IS_SERIAL, false); //发送短信 // String tempCode = Constant.SMS_TemplateCode.RPOJECT_APPLICATION_AUDIT; // AlibabaSMSUtil.sendSMSMessage( // user.getPhone(), tempCode, Constant.SINGNAMW, JSONObject.toJSONString(params)); } } } a.setNextchecker(sb.toString()); if (sb.length() == 0) { throw new BaseException("操作失败,项目申报材料受理组没有该项目责任单位的审核人员,请联系管理员配置"); } ProjectApplication pa = new ProjectApplication(); pa.setId(projectId); pa.setApprove_status(Constant.ProjectApplicationStatus.FINANCE_AUDIT); projectApplicationDao.updateByPrimaryKeySelective(pa); approvalService.insertAndGetId(a); return true; } else if (Objects.equals(Constant.ProjectApplicationStatus.FINANCE_AUDIT, approval.getAfter_approvalstatus())) { //财政审核通过 a.setBefore_approvalstatus(Constant.ProjectApplicationStatus.FINANCE_AUDIT); ProjectApplication pa = new ProjectApplication(); pa.setId(projectId); if (project.getIs_technical()) { //技改类等待上传 a.setAfter_approvalstatus(Constant.ProjectApplicationStatus.UPLOAD_REPORT); pa.setApprove_status(Constant.ProjectApplicationStatus.UPLOAD_REPORT); Integer departmentid = project.getDepartment_id(); Group group = groupService.findByName(Constant.XMSBCLSHZ, null); List userGroups = userGroupService.findByGroupId(group.getId()); List users = userService.findUserBydepartmentIdWithoutApprovalLevel(departmentid.toString()); StringBuffer sb = new StringBuffer(""); ProjectDeclaration projectDeclaration = this.findById(projectApplication.getDeclaration_id()); String projectName = projectDeclaration.getProject_name(); Message messages = new Message(); messages.setApply_id(projectId); messages.setBusiness_type(Constant.Message_Business_type.PROJECT_APPLY); waitToDoService.completeAllTODO(projectApplication.getId(), Constant.DictionaryType.PROJECT_APPLICATION); for (UserGroup userGroup : userGroups) { for (User user : users) { if (Objects.equals(user.getId(), userGroup.getUser_id())) { sb.append(userGroup.getUser_id()).append(","); User userss = userService.findById(userGroup.getUser_id()); messages.setTitle("提醒处室补充材料"); String message = userss.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("项目申报上传材料", "/projectDeclaration/approve/" + projectApplication.getId(), Constant.WaitToDo_OperType.AUDIT, projectApplication.getId(), Constant.DictionaryType.PROJECT_APPLICATION, projectApplication.getApply_no(), userGroup.getUser_id().toString(), Constant.WaitToDo_IsSerial.IS_SERIAL, false); //发送短信(提醒处室补充材料) // Map paramMap = new HashMap<>(); // paramMap.put("company_name", company.getCompany_name()); // paramMap.put("project_name", projectName); // String tempCode = Constant.SMS_TemplateCode.RPOJECT_APPLICATION_REPORT; // AlibabaSMSUtil.sendSMS( // user.getPhone(), tempCode, Constant.SINGNAMW, JSONObject.toJSONString(paramMap)); } } } Group groups = groupService.findByName(Constant.XMSBCZSHZ, null); if (null == group) { throw new BaseException("操作失败,项目申报财政审核组或项目申报材料审核组没有该项目责任单位的审核人员,请联系管理员配置"); } List userGroupss = userGroupService.findByGroupId(groups.getId()); for (UserGroup userGroup : userGroupss) { sb.append(userGroup.getUser_id() + ","); User user = userService.findById(userGroup.getUser_id()); messages.setTitle("提醒财政补充材料"); 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("项目申报上传材料", "/projectDeclaration/approve/" + projectApplication.getId(), Constant.WaitToDo_OperType.AUDIT, projectApplication.getId(), Constant.DictionaryType.PROJECT_APPLICATION, projectApplication.getApply_no(), userGroup.getUser_id().toString(), Constant.WaitToDo_IsSerial.IS_SERIAL, false); //发送短信(提醒财政补充材料) // Map paramMap = new HashMap<>(); // paramMap.put("company_name", company.getCompany_name()); // paramMap.put("project_name", projectName); // String tempCode = Constant.SMS_TemplateCode.RPOJECT_APPLICATION_REPORT; // AlibabaSMSUtil.sendSMS( // user.getPhone(), tempCode, Constant.SINGNAMW, JSONObject.toJSONString(params)); } a.setNextchecker(sb.toString()); } else { // Company company = companyService.findById(projectApplication.getCompany_id()); ProjectDeclaration projectDeclaration = this.findById(projectApplication.getDeclaration_id()); String projectName = projectDeclaration.getProject_name(); Message messages = new Message(); messages.setApply_id(projectId); messages.setBusiness_type(Constant.Message_Business_type.PROJECT_APPLY); messages.setTitle("提醒中心负责人"); a.setAfter_approvalstatus(Constant.ProjectApplicationStatus.NOTIFY); pa.setApprove_status(Constant.ProjectApplicationStatus.NOTIFY); Group group = groupService.findByName(Constant.XMSBFZR, null); if (null == group) { throw new BaseException("操作失败,项目申报财政审核组或项目申报材料审核组没有该项目责任单位的审核人员,请联系管理员配置"); } List userGroups = userGroupService.findByGroupId(group.getId()); StringBuffer sb = new StringBuffer(""); waitToDoService.completeAllTODO(projectApplication.getId(), Constant.DictionaryType.PROJECT_APPLICATION); for (UserGroup userGroup : userGroups) { sb.append(userGroup.getUser_id() + ","); User user = userService.findById(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("项目申报审核", "/projectDeclaration/approve/" + projectApplication.getId(), Constant.WaitToDo_OperType.AUDIT, projectApplication.getId(), Constant.DictionaryType.PROJECT_APPLICATION, projectApplication.getApply_no(), userGroup.getUser_id().toString(), Constant.WaitToDo_IsSerial.IS_SERIAL, false); //发送短信 // String tempCode = Constant.SMS_TemplateCode.RPOJECT_APPLICATION_AUDIT; // AlibabaSMSUtil.sendSMSMessage( // user.getPhone(), tempCode, Constant.SINGNAMW, JSONObject.toJSONString(params)); } a.setNextchecker(sb.toString()); if (null == sb || sb.length() == 0) { throw new BaseException("操作失败,项目申报财政审核组或项目申报材料审核组没有该项目责任单位的审核人员,请联系管理员配置"); } } projectApplicationDao.updateByPrimaryKeySelective(pa); approvalService.insertAndGetId(a); //发送短信 // String tempCode = Constant.SMS_TemplateCode.RPOJECT_APPLICATION_FINANCIAL_PREARE_MATERIALS; // AlibabaSMSUtil.sendSMS( // companyAdmin.getPhone(), tempCode, Constant.SINGNAMW, JSONObject.toJSONString(params)); return true; } return false; } /** * 2019审核流程 * * @param projectId * @param comment */ private boolean refactorPass(Integer projectId, String comment) { Approval approval = approvalDao.getLatestApproval(projectId, Constant.DictionaryType.PROJECT_APPLICATION); Approval a = new Approval(); a.setApply_id(projectId); a.setType(Constant.DictionaryType.PROJECT_APPLICATION); 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())); ProjectApplication projectApplication = projectApplicationDao.selectById(projectId.toString()); Project project = projectService.findById(projectApplication.getProject_id()); Integer responsibleUnit = project.getDepartment_id(); ProjectDeclaration declaration = findById(projectApplication.getDeclaration_id()); String projectName = declaration.getProject_name(); //短信所需参数 Map params = new HashMap<>(); params.put("project_no", projectApplication.getApply_no()); Company company = companyService.findById(projectApplication.getCompany_id()); User companyAdmin = userService.findCompanyAdmin(company.getId()); if (Objects.equals(Constant.ProjectApplicationStatus.CENTRE_AUDIT, approval.getAfter_approvalstatus())) { //材料审核通过,进如处室(中心)审批 a.setBefore_approvalstatus(Constant.ProjectApplicationStatus.CENTRE_AUDIT); a.setAfter_approvalstatus(Constant.ProjectApplicationStatus.DEPARTMENT_AUDIT); Group group = groupService.findByName(Constant.XMSBCLSHZ, null); if (null == group) { throw new BaseException("操作失败,项目申报材料审核组没有该项目责任单位的审核人员,请联系管理员配置"); } List userGroups = userGroupService.findByGroupId(group.getId()); List users = userService.findUserBydepartmentIdWithoutApprovalLevel(responsibleUnit.toString()); StringBuffer sb = new StringBuffer(""); Message messages = new Message(); messages.setApply_id(projectId); messages.setBusiness_type(Constant.Message_Business_type.PROJECT_APPLY); messages.setTitle("提醒处室审核"); waitToDoService.completeAllTODO(projectApplication.getId(), Constant.DictionaryType.PROJECT_APPLICATION); for (UserGroup userGroup : userGroups) { for (User user : users) { if (Objects.equals(user.getId(), userGroup.getUser_id())) { sb.append(userGroup.getUser_id() + ","); //User u = userService.findById(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("项目申报审核", "/projectDeclaration/approve/" + projectApplication.getId(), Constant.WaitToDo_OperType.AUDIT, projectApplication.getId(), Constant.DictionaryType.PROJECT_APPLICATION, projectApplication.getApply_no(), userGroup.getUser_id().toString(), Constant.WaitToDo_IsSerial.IS_SERIAL, false); } } } a.setNextchecker(sb.toString()); if (null == sb || sb.length() == 0) { throw new BaseException("操作失败,项目申报材料审核组没有该项目责任单位的审核人员,请联系管理员配置"); } ProjectApplication pa = new ProjectApplication(); pa.setId(projectId); pa.setApprove_status(Constant.ProjectApplicationStatus.DEPARTMENT_AUDIT); projectApplicationDao.updateByPrimaryKeySelective(pa); approvalService.insertAndGetId(a); return true; } else if (Objects.equals(Constant.ProjectApplicationStatus.DEPARTMENT_AUDIT, approval.getAfter_approvalstatus())) { //处室通过,审核结束 a.setBefore_approvalstatus(Constant.ProjectApplicationStatus.DEPARTMENT_AUDIT); a.setAfter_approvalstatus(Constant.ProjectApplicationStatus.APPROVED); ProjectApplication pa = new ProjectApplication(); pa.setId(projectId); pa.setApprove_status(Constant.ProjectApplicationStatus.APPROVED); pa.setApply_status(Constant.ProjectApplyStatus.APPROVED); projectApplicationDao.updateByPrimaryKeySelective(pa); approvalService.insertAndGetId(a); ExecutorService threadPool = new ThreadPoolExecutor( 1, 2, 1L, TimeUnit.SECONDS, new LinkedBlockingDeque<>(), Executors.defaultThreadFactory(), new ThreadPoolExecutor.AbortPolicy()); try { threadPool.execute(() -> { Message messages = new Message(); messages.setApply_id(projectId); messages.setBusiness_type(Constant.Message_Business_type.PROJECT_APPLY); messages.setTitle("项目申报审核通过"); String message = "您单号为 " + projectApplication.getApply_no() + " 的区级工业经济扶持项目申请,已审核通过," + "请将纸质材料(需与审核通过的电子档一致)交与属地经济主管部门。"; messages.setContent(message); int[] streetArrInt = new int[1]; streetArrInt[0] = companyAdmin.getId(); messageService.saveMessageAndPush(messages, streetArrInt, Constant.UserType.GOVERNMENT); String tempCode = Constant.SMS_TemplateCode.RPOJECT_APPLICATION_PREARE_MATERIALS; try { AlibabaSMSUtil.sendSMS( companyAdmin.getPhone(), tempCode, Constant.SINGNAMW, JSONObject.toJSONString(params)); } catch (ClientException | InterruptedException e) { e.printStackTrace(); } }); } catch (Exception e) { e.printStackTrace(); } finally { threadPool.shutdown(); } return true; } return false; } //退回 public boolean untread(Integer projectId, String comment) { Boolean flag = false; Approval approval = approvalDao.getLatestApproval(projectId, Constant.DictionaryType.PROJECT_APPLICATION); Approval a = new Approval(); a.setApply_id(projectId); a.setType(Constant.DictionaryType.PROJECT_APPLICATION); 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.REJECT); a.setDeal_time(DateUtil.getTimeString(new Date())); ProjectApplication projectApplication = projectApplicationDao.selectById(projectId.toString()); Project project = new Project(); project.setId(projectApplication.getProject_id()); project = projectDao.selectOne(project); if (Objects.equals(Constant.ProjectApplicationStatus.CENTRE_AUDIT, approval.getAfter_approvalstatus())) { //材料审核退回,退回至企业 a.setBefore_approvalstatus(Constant.ProjectApplicationStatus.CENTRE_AUDIT); a.setAfter_approvalstatus(Constant.ProjectApplicationStatus.REJECT_TO_COMPANY); a.setNextchecker(projectApplication.getCreate_by().toString()); ProjectApplication p = new ProjectApplication(); p.setId(projectId); p.setApply_status(Constant.ProjectApplyStatus.REJECT); p.setApprove_status(Constant.ProjectApplicationStatus.REJECT_TO_COMPANY); projectApplicationDao.updateByPrimaryKeySelective(p); approvalService.insertAndGetId(a); ProjectDeclaration 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_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); List users = userService.findUsersByCompanyId(projectApplication.getCompany_id()); waitToDoService.completeAllTODO(projectApplication.getId(), Constant.DictionaryType.PROJECT_APPLICATION); for (User user : users) { waitToDoService.newTODO("项目申报编辑", "/projectDeclaration/approve/" + projectApplication.getId(), Constant.WaitToDo_OperType.EDIT, projectApplication.getId(), Constant.DictionaryType.PROJECT_APPLICATION, projectApplication.getApply_no(), user.getId().toString(), Constant.WaitToDo_IsSerial.IS_SERIAL, false); } flag = true; } else if (Objects.equals(Constant.ProjectApplicationStatus.DEPARTMENT_AUDIT, approval.getAfter_approvalstatus())) { //处室(中心)审核退回,退回至企业 a.setBefore_approvalstatus(Constant.ProjectApplicationStatus.DEPARTMENT_AUDIT); a.setAfter_approvalstatus(Constant.ProjectApplicationStatus.REJECT_TO_COMPANY); a.setNextchecker(projectApplication.getCreate_by().toString()); ProjectApplication p = new ProjectApplication(); p.setId(projectId); p.setApply_status(Constant.ProjectApplyStatus.REJECT); p.setApprove_status(Constant.ProjectApplicationStatus.REJECT_TO_COMPANY); projectApplicationDao.updateByPrimaryKeySelective(p); approvalService.insertAndGetId(a); ProjectDeclaration 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_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); List users = userService.findUsersByCompanyId(projectApplication.getCompany_id()); waitToDoService.completeAllTODO(projectApplication.getId(), Constant.DictionaryType.PROJECT_APPLICATION); for (User user : users) { waitToDoService.newTODO("项目申报编辑", "/projectDeclaration/approve/" + projectApplication.getId(), Constant.WaitToDo_OperType.EDIT, projectApplication.getId(), Constant.DictionaryType.PROJECT_APPLICATION, projectApplication.getApply_no(), user.getId().toString(), Constant.WaitToDo_IsSerial.IS_SERIAL, false); } flag = true; } /*else if (Objects.equals(Constant.ProjectApplicationStatus.COMMIT_FILE, approval.getAfter_approvalstatus())) { //中心窗口提交专家审核意见,退回中心(处室) a.setBefore_approvalstatus(Constant.ProjectApplicationStatus.COMMIT_FILE); a.setAfter_approvalstatus(Constant.ProjectApplicationStatus.DEPARTMENT_AUDIT); Integer departmentid = project.getDepartment_id(); Group group = groupService.findByName(Constant.XMSBCLSHZ, null); List userGroups = userGroupService.findByGroupId(group.getId()); List users = userService.findUserBydepartmentIdWithoutApprovalLevel(departmentid.toString()); StringBuffer sb = new StringBuffer(""); for (UserGroup userGroup : userGroups) { for (User user : users) { if (Objects.equals(user.getId(), userGroup.getUser_id())) { sb.append(userGroup.getUser_id() + ","); } } } a.setNextchecker(sb.toString()); ProjectApplication p = new ProjectApplication(); p.setId(projectId); //p.setApply_status(Constant.ProjectApplyStatus.REJECT); p.setApprove_status(Constant.ProjectApplicationStatus.REJECT_TO_DEPARTMENT); projectApplicationDao.updateByPrimaryKeySelective(p); approvalService.insertAndGetId(a); }*/ else if (Objects.equals(Constant.ProjectApplicationStatus.FINANCE_AUDIT, approval.getAfter_approvalstatus())) { //财政审核退回,退回至处室 a.setBefore_approvalstatus(Constant.ProjectApplicationStatus.FINANCE_AUDIT); a.setAfter_approvalstatus(Constant.ProjectApplicationStatus.DEPARTMENT_AUDIT); Integer departmentid = project.getDepartment_id(); Group group = groupService.findByName(Constant.XMSBCLSHZ, null); List userGroups = userGroupService.findByGroupId(group.getId()); List users = userService.findUserBydepartmentIdWithoutApprovalLevel(departmentid.toString()); StringBuffer sb = new StringBuffer(""); ProjectDeclaration 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_APPLY); messages.setTitle("提醒企业"); waitToDoService.completeAllTODO(projectApplication.getId(), Constant.DictionaryType.PROJECT_APPLICATION); for (UserGroup userGroup : userGroups) { for (User user : users) { if (Objects.equals(user.getId(), userGroup.getUser_id())) { sb.append(userGroup.getUser_id() + ","); 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.GOVERNMENT); waitToDoService.newTODO("项目申报编辑", "/projectDeclaration/approve/" + projectApplication.getId(), Constant.WaitToDo_OperType.EDIT, projectApplication.getId(), Constant.DictionaryType.PROJECT_APPLICATION, projectApplication.getApply_no(), user.getId().toString(), Constant.WaitToDo_IsSerial.IS_SERIAL, false); } } } a.setNextchecker(sb.toString()); ProjectApplication p = new ProjectApplication(); p.setId(projectId); p.setApply_status(Constant.ProjectApplyStatus.REJECT); p.setApprove_status(Constant.ProjectApplicationStatus.DEPARTMENT_AUDIT); projectApplicationDao.updateByPrimaryKeySelective(p); approvalService.insertAndGetId(a); flag = true; } //发送短信给企业 Map params = new HashMap<>(); params.put("project_no", projectApplication.getApply_no()); params.put("apply_name", Constant.ProjectType.PROJECT_APPLICATION); String templateCode = Constant.SMS_TemplateCode.RPOJECT_MATTERS_REJECT; try { User user = userService.findCompanyAdmin(projectApplication.getCompany_id()); AlibabaSMSUtil.sendSMS( user.getPhone(), templateCode, Constant.SINGNAMW, JSONObject.toJSONString(params)); } catch (ClientException | InterruptedException e) { e.printStackTrace(); } return flag; } //不通过 public boolean reject(Integer projectId, String comment) { Approval approval = approvalDao.getLatestApproval(projectId, Constant.DictionaryType.PROJECT_APPLICATION); Approval a = new Approval(); a.setApply_id(projectId); a.setType(Constant.DictionaryType.PROJECT_APPLICATION); 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.NOTAPPROVED); a.setDeal_time(DateUtil.getTimeString(new Date())); ProjectApplication projectApplication = projectApplicationDao.selectById(projectId.toString()); a.setAfter_approvalstatus(Constant.ProjectApplicationStatus.NOTAPPROVED); a.setNextchecker(projectApplication.getCreate_by().toString()); ProjectApplication p = new ProjectApplication(); p.setId(projectId); p.setApply_status(Constant.ProjectApplyStatus.NOTAPPROVED); p.setApprove_status(Constant.ProjectApplicationStatus.NOTAPPROVED); projectApplicationDao.updateByPrimaryKeySelective(p); if (Objects.equals(Constant.ProjectApplicationStatus.CENTRE_AUDIT, approval.getAfter_approvalstatus())) { //材料审核退回,退回至企业 a.setBefore_approvalstatus(Constant.ProjectApplicationStatus.CENTRE_AUDIT); } else if (Objects.equals(Constant.ProjectApplicationStatus.DEPARTMENT_AUDIT, approval.getAfter_approvalstatus())) { //处室(中心)审核退回,退回至企业 a.setBefore_approvalstatus(Constant.ProjectApplicationStatus.DEPARTMENT_AUDIT); } else if (Objects.equals(Constant.ProjectApplicationStatus.FINANCE_AUDIT, approval.getAfter_approvalstatus())) { //财政审核退回,退回至处室中心 a.setBefore_approvalstatus(Constant.ProjectApplicationStatus.FINANCE_AUDIT); } approvalService.insertAndGetId(a); ProjectDeclaration 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_APPLY); messages.setTitle("提醒企业"); String message = company.getCompany_name() + ",您好。您提交的" + projectName + "审核不通过,请知悉。"; 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_APPLICATION); String templateCode = Constant.SMS_TemplateCode.RPOJECT_MATTERS_UNPASS; try { User user = userService.findCompanyAdmin(projectApplication.getCompany_id()); AlibabaSMSUtil.sendSMS( user.getPhone(), templateCode, Constant.SINGNAMW, JSONObject.toJSONString(params)); } catch (ClientException | InterruptedException e) { e.printStackTrace(); } return true; } //通知 public boolean notify(Integer projectId, String payment) throws ClientException, InterruptedException { Approval approval = approvalDao.getLatestApproval(projectId, Constant.DictionaryType.PROJECT_APPLICATION); Approval a = new Approval(); a.setApply_id(projectId); a.setDeal_time(DateUtil.getTimeString(new Date())); a.setType(Constant.DictionaryType.PROJECT_APPLICATION); String departmentname = departmentService.selectById(userService.getUser(ShiroUtils.getUserId()).getDepartment_id()).getName(); a.setDepartment(departmentname); a.setChecker(ShiroUtils.getUserId()); a.setOper_type(Constant.OperType.APPROVED); ProjectApplication projectApplication = projectApplicationDao.selectById(projectId.toString()); a.setAfter_approvalstatus(Constant.ProjectApplicationStatus.APPROVED); //a.setNextchecker(projectApplication.getCreate_by().toString()); ProjectApplication p = new ProjectApplication(); p.setId(projectId); p.setProject_payment(payment); p.setApply_status(Constant.ProjectApplyStatus.APPROVED); p.setApprove_status(Constant.ProjectApplicationStatus.APPROVED); projectApplicationDao.updateByPrimaryKeySelective(p); a.setBefore_approvalstatus(Constant.ProjectApplicationStatus.NOTIFY); approvalService.insertAndGetId(a); ProjectDeclaration projectDeclaration = this.findById(projectApplication.getDeclaration_id()); String projectName = projectDeclaration.getProject_name(); Message messages = new Message(); messages.setApply_id(projectId); messages.setTitle("企业项目审批完成通知"); Company company = companyService.findById(projectApplication.getCompany_id()); messages.setContent(company.getCompany_name() + ",您好。您的" + projectName + "项目申请成功,发放" + payment + "万元人民币,请开收据,提交纸质材料。谢谢。"); messages.setBusiness_type(Constant.Message_Business_type.PROJECT_APPLY); int[] streetArrInt = new int[1]; streetArrInt[0] = projectApplication.getCompany_id(); messageService.saveMessageAndPush(messages, streetArrInt, Constant.UserType.COMPANY); //发送短信 Map params = new HashMap<>(); User companyAdmin = userService.findCompanyAdmin(company.getId()); String tempCode = Constant.SMS_TemplateCode.REMINSD_COMPNAY_PRINT_MATERIALS; params.put("project_no", projectApplication.getApply_no()); params.put("apply_name", Constant.ProjectType.PROJECT_APPLICATION); AlibabaSMSUtil.sendSMS( companyAdmin.getPhone(), tempCode, Constant.SINGNAMW, JSONObject.toJSONString(params)); return true; } //发送短信,通知审核 public Boolean sendProjectMessage(ProjectApplication projectApplication) throws ClientException { String phone = ""; Map params = new HashMap<>(); if (projectApplication != null) { 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(); } params.put("project_id", projectApplication.getApply_no()); String templatCode = Constant.SMS_TemplateCode.RPOJECT_APPLICATION_AUDIT; if (StringUtils.isNotBlank(phone)) { AlibabaSMSUtil.sendSMSMessage(phone, templatCode, Constant.SINGNAMW, JSONObject.toJSONString(params)); return true; } } return false; } //发送短信 public Boolean sendProjectSMS(ProjectApplication 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, ProjectApplication 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端查看。感谢您的支持。 String project_name = projectApplication.getProject_name(); String templateParam = "{\"department_name\":\"" + departmentname + "\",\"project_name\":\"" + project_name + "\",\"approve_status\":\"" + status + "\"}"; AlibabaSMSUtil.sendSMS(phone, Constant.SMS_TemplateCode.PROJECT_APPLICATION_NOTIFY, Constant.SINGNAMW, templateParam); return true; } else { return false; } } //部门上传数据 public void departmentUpload(ParamFile paramFile) { attachmentDao.deleteByBusiness(Constant.Attachment.PROJECT_CS, paramFile.getPid()); attachmentDao.updateAttachment(Constant.Attachment.PROJECT_CS, paramFile.getPid(), paramFile.getFileDown().getFile_id()); ProjectMaterial projectMaterial = new ProjectMaterial(); projectMaterial.setApply_id(paramFile.getPid()); projectMaterial.setTemplate_id(paramFile.getFileDown().getFile_id()); projectMaterial.setMaterial_type(1); Example example = new Example(ProjectMaterial.class); Example.Criteria criteria = example.createCriteria(); criteria.andEqualTo("apply_id", paramFile.getPid()); criteria.andEqualTo("material_type", "1"); List list = projectMaterialDao.selectByExample(example); if (CollectionUtils.isEmpty(list)) { projectMaterialDaoService.saveMaterial(projectMaterial); } else { projectMaterial.setId(list.get(0).getId()); projectMaterialDaoService.updateMaterial(projectMaterial); } //判断两种文件是否全 validateUploadedFile(paramFile.getPid()); } //财政上传数据 public void financeUpload(ParamFile paramFile) { attachmentDao.deleteByBusiness(Constant.Attachment.PROJECT_CZ, paramFile.getPid()); attachmentDao.updateAttachment(Constant.Attachment.PROJECT_CZ, paramFile.getPid(), paramFile.getFileDown().getFile_id()); ProjectMaterial projectMaterial = new ProjectMaterial(); projectMaterial.setApply_id(paramFile.getPid()); projectMaterial.setTemplate_id(paramFile.getFileDown().getFile_id()); projectMaterial.setMaterial_type(2); Example example = new Example(ProjectMaterial.class); Example.Criteria criteria = example.createCriteria(); criteria.andEqualTo("apply_id", paramFile.getPid()); criteria.andEqualTo("material_type", "2"); List list = projectMaterialDao.selectByExample(example); if (CollectionUtils.isEmpty(list)) { projectMaterialDaoService.saveMaterial(projectMaterial); } else { projectMaterial.setId(list.get(0).getId()); projectMaterialDaoService.updateMaterial(projectMaterial); } //判断两种文件是否全 validateUploadedFile(paramFile.getPid()); } //中心上传数据 public void centreUpload(ParamFile paramFile) { attachmentDao.deleteByBusiness(Constant.Attachment.PROJECT_ZX, paramFile.getPid()); attachmentDao.updateAttachment(Constant.Attachment.PROJECT_ZX, paramFile.getPid(), paramFile.getFileDown().getFile_id()); ProjectMaterial projectMaterial = new ProjectMaterial(); projectMaterial.setApply_id(paramFile.getPid()); projectMaterial.setTemplate_id(paramFile.getFileDown().getFile_id()); projectMaterial.setMaterial_type(3); Example example = new Example(ProjectMaterial.class); Example.Criteria criteria = example.createCriteria(); criteria.andEqualTo("apply_id", paramFile.getPid()); criteria.andEqualTo("material_type", "3"); List list = projectMaterialDao.selectByExample(example); if (CollectionUtils.isEmpty(list)) { projectMaterialDaoService.saveMaterial(projectMaterial); } else { projectMaterial.setId(list.get(0).getId()); projectMaterialDaoService.updateMaterial(projectMaterial); } Approval a = new Approval(); a.setApply_id(paramFile.getPid()); a.setDeal_time(DateUtil.getTimeString(new Date())); a.setType(Constant.DictionaryType.PROJECT_APPLICATION); String departmentname = departmentService.selectById(userService.getUser(ShiroUtils.getUserId()).getDepartment_id()).getName(); a.setDepartment(departmentname); a.setChecker(ShiroUtils.getUserId()); a.setOper_type(Constant.OperType.APPROVED); a.setBefore_approvalstatus(Constant.ProjectApplicationStatus.COMMIT_FILE); a.setAfter_approvalstatus(Constant.ProjectApplicationStatus.FINANCE_AUDIT); Group group = groupService.findByName(Constant.XMSBCZSHZ, null); if (null == group) { throw new BaseException("操作失败,项目申报财政审核组没有该项目责任单位的审核人员,请联系管理员配置"); } List userGroups = userGroupService.findByGroupId(group.getId()); StringBuffer sb = new StringBuffer(""); ProjectApplication projectApplication = projectApplicationDao.selectById(paramFile.getPid().toString()); Company company = companyService.findById(projectApplication.getCompany_id()); ProjectDeclaration projectDeclaration = this.findById(projectApplication.getDeclaration_id()); String projectName = projectDeclaration.getProject_name(); Message messages = new Message(); messages.setApply_id(paramFile.getPid()); messages.setBusiness_type(Constant.Message_Business_type.PROJECT_APPLY); messages.setTitle("提醒财政审核"); waitToDoService.completeAllTODO(projectApplication.getId(), Constant.DictionaryType.PROJECT_APPLICATION); for (UserGroup userGroup : userGroups) { sb.append(userGroup.getUser_id() + ","); User user = userService.findById(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("项目申报审核", "/projectDeclaration/approve/" + projectApplication.getId(), Constant.WaitToDo_OperType.AUDIT, projectApplication.getId(), Constant.DictionaryType.PROJECT_APPLICATION, projectApplication.getApply_no(), user.getId().toString(), Constant.WaitToDo_IsSerial.IS_SERIAL, false); } a.setNextchecker(sb.toString()); if (null == sb || sb.length() == 0) { throw new BaseException("操作失败,项目申报财政审核组没有该项目责任单位的审核人员,请联系管理员配置"); } approvalService.insertAndGetId(a); ProjectApplication pa = new ProjectApplication(); pa.setId(paramFile.getPid()); pa.setApprove_status(Constant.ProjectApplicationStatus.FINANCE_AUDIT); projectApplicationDao.updateByPrimaryKeySelective(pa); } private void validateUploadedFile(Integer id) { Example example1 = new Example(ProjectMaterial.class); Example example2 = new Example(ProjectMaterial.class); Example.Criteria criteria1 = example1.createCriteria(); Example.Criteria criteria2 = example2.createCriteria(); criteria1.andEqualTo("apply_id", id); criteria1.andEqualTo("material_type", "1"); criteria2.andEqualTo("apply_id", id); criteria2.andEqualTo("material_type", "2"); List list1 = projectMaterialDao.selectByExample(example1); List list2 = projectMaterialDao.selectByExample(example2); if (!CollectionUtils.isEmpty(list1) && !CollectionUtils.isEmpty(list2)) { Approval a = new Approval(); a.setApply_id(id); a.setDeal_time(DateUtil.getTimeString(new Date())); a.setType(Constant.DictionaryType.PROJECT_APPLICATION); String departmentname = departmentService.selectById(userService.getUser(ShiroUtils.getUserId()).getDepartment_id()).getName(); a.setDepartment(departmentname); a.setChecker(ShiroUtils.getUserId()); a.setOper_type(Constant.OperType.APPROVED); a.setBefore_approvalstatus(Constant.ProjectApplicationStatus.UPLOAD_REPORT); a.setAfter_approvalstatus(Constant.ProjectApplicationStatus.NOTIFY); Group group = groupService.findByName(Constant.XMSBFZR, null); if (null == group) { throw new BaseException("操作失败,项目申报审核组没有该项目责任单位的审核人员,请联系管理员配置"); } List userGroups = userGroupService.findByGroupId(group.getId()); StringBuffer sb = new StringBuffer(""); ProjectApplication projectApplication = projectApplicationDao.selectById(id.toString()); Company company = companyService.findById(projectApplication.getCompany_id()); ProjectDeclaration projectDeclaration = this.findById(projectApplication.getDeclaration_id()); String projectName = projectDeclaration.getProject_name(); Message messages = new Message(); messages.setApply_id(id); messages.setBusiness_type(Constant.Message_Business_type.PROJECT_APPLY); messages.setTitle("提醒中心负责人"); waitToDoService.completeAllTODO(projectApplication.getId(), Constant.DictionaryType.PROJECT_APPLICATION); for (UserGroup userGroup : userGroups) { sb.append(userGroup.getUser_id() + ","); User user = userService.findById(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("项目申报审核", "/projectDeclaration/approve/" + projectApplication.getId(), Constant.WaitToDo_OperType.AUDIT, projectApplication.getId(), Constant.DictionaryType.PROJECT_APPLICATION, projectApplication.getApply_no(), user.getId().toString(), Constant.WaitToDo_IsSerial.IS_SERIAL, false); } a.setNextchecker(sb.toString()); if (null == sb || sb.length() == 0) { throw new BaseException("操作失败,项目申报审核组没有该项目责任单位的审核人员,请联系管理员配置"); } approvalService.insertAndGetId(a); ProjectApplication pa = new ProjectApplication(); pa.setId(id); pa.setApprove_status(Constant.ProjectApplicationStatus.NOTIFY); projectApplicationDao.updateByPrimaryKeySelective(pa); } else if (CollectionUtils.isEmpty(list1) && !CollectionUtils.isEmpty(list2)) { Approval a = new Approval(); a.setApply_id(id); a.setDeal_time(DateUtil.getTimeString(new Date())); a.setType(Constant.DictionaryType.PROJECT_APPLICATION); String departmentname = departmentService.selectById(userService.getUser(ShiroUtils.getUserId()).getDepartment_id()).getName(); a.setDepartment(departmentname); a.setChecker(ShiroUtils.getUserId()); a.setOper_type(Constant.OperType.APPROVED); a.setBefore_approvalstatus(Constant.ProjectApplicationStatus.UPLOAD_REPORT); a.setAfter_approvalstatus(Constant.ProjectApplicationStatus.UPLOAD_CZ); ProjectApplication projectApplication = projectApplicationDao.selectById(id.toString()); Project project = new Project(); project.setId(projectApplication.getProject_id()); project = projectDao.selectOne(project); Integer departmentid = project.getDepartment_id(); Group group = groupService.findByName(Constant.XMSBCLSHZ, null); List userGroups = userGroupService.findByGroupId(group.getId()); List users = userService.findUserBydepartmentIdWithoutApprovalLevel(departmentid.toString()); StringBuffer sb = new StringBuffer(""); waitToDoService.completeAllTODO(projectApplication.getId(), Constant.DictionaryType.PROJECT_APPLICATION); for (UserGroup userGroup : userGroups) { for (User user : users) { if (Objects.equals(user.getId(), userGroup.getUser_id())) { sb.append(userGroup.getUser_id() + ","); waitToDoService.newTODO("项目申报审核", "/projectDeclaration/approve/" + projectApplication.getId(), Constant.WaitToDo_OperType.AUDIT, projectApplication.getId(), Constant.DictionaryType.PROJECT_APPLICATION, projectApplication.getApply_no(), user.getId().toString(), Constant.WaitToDo_IsSerial.IS_SERIAL, false); } } } a.setNextchecker(sb.toString()); approvalService.insertAndGetId(a); ProjectApplication pa = new ProjectApplication(); pa.setId(id); pa.setApprove_status(Constant.ProjectApplicationStatus.UPLOAD_CZ); projectApplicationDao.updateByPrimaryKeySelective(pa); } else if (!CollectionUtils.isEmpty(list1) && CollectionUtils.isEmpty(list2)) { Approval a = new Approval(); a.setApply_id(id); a.setDeal_time(DateUtil.getTimeString(new Date())); a.setType(Constant.DictionaryType.PROJECT_APPLICATION); ProjectApplication projectApplication = projectApplicationDao.selectById(id.toString()); String departmentname = departmentService.selectById(userService.getUser(ShiroUtils.getUserId()).getDepartment_id()).getName(); a.setDepartment(departmentname); a.setChecker(ShiroUtils.getUserId()); a.setOper_type(Constant.OperType.APPROVED); a.setBefore_approvalstatus(Constant.ProjectApplicationStatus.UPLOAD_REPORT); a.setAfter_approvalstatus(Constant.ProjectApplicationStatus.UPLOAD_CS); StringBuffer sb = new StringBuffer(""); Group groups = groupService.findByName(Constant.XMSBCZSHZ, null); List userGroupss = userGroupService.findByGroupId(groups.getId()); waitToDoService.completeAllTODO(projectApplication.getId(), Constant.DictionaryType.PROJECT_APPLICATION); for (UserGroup userGroup : userGroupss) { sb.append(userGroup.getUser_id() + ","); waitToDoService.newTODO("项目申报审核", "/projectDeclaration/approve/" + projectApplication.getId(), Constant.WaitToDo_OperType.AUDIT, projectApplication.getId(), Constant.DictionaryType.PROJECT_APPLICATION, projectApplication.getApply_no(), userGroup.getUser_id().toString(), Constant.WaitToDo_IsSerial.IS_SERIAL, false); } a.setNextchecker(sb.toString()); approvalService.insertAndGetId(a); ProjectApplication pa = new ProjectApplication(); pa.setId(id); pa.setApprove_status(Constant.ProjectApplicationStatus.UPLOAD_CS); projectApplicationDao.updateByPrimaryKeySelective(pa); } } public ModelMap getMaterial(Integer id, ModelMap modelMap) { Example example = new Example(ProjectMaterial.class); Example.Criteria criteria = example.createCriteria(); criteria.andEqualTo("apply_id", id); criteria.andEqualTo("del_flag", 0); List list = projectMaterialDao.selectByExample(example); //modelMap.addAttribute("approveMaterials", list); List attachments = attachmentDao.selectByIdAndBusinessId(Constant.Attachment.PROJECT_CS, id, null); List attachments2 = attachmentDao.selectByIdAndBusinessId(Constant.Attachment.PROJECT_CZ, id, null); List attachments3 = attachmentDao.selectByIdAndBusinessId(Constant.Attachment.PROJECT_ZX, id, null); attachments.addAll(attachments2); attachments.addAll(attachments3); FileDown fd = new FileDown(); fd.setFile_name(""); fd.setDownload_uri(""); fd.setFile_url(""); fd.setFile_id(null); modelMap.addAttribute("czMaterials", fd); modelMap.addAttribute("csMaterials", fd); modelMap.addAttribute("zxMaterials", fd); for (ProjectMaterial projectMaterial : list) { if (Objects.equals(1, projectMaterial.getMaterial_type())) { for (Attachment attachment : attachments) { if (Objects.equals(attachment.getId(), projectMaterial.getTemplate_id())) { FileDown fileDown = new FileDown(attachment.getId(), attachment.getFile_name(), attachment.getFile_url(), attachment.getDownload_uri()); modelMap.addAttribute("csMaterials", fileDown); } } } if (Objects.equals(2, projectMaterial.getMaterial_type())) { for (Attachment attachment : attachments) { if (Objects.equals(attachment.getId(), projectMaterial.getTemplate_id())) { FileDown fileDown = new FileDown(attachment.getId(), attachment.getFile_name(), attachment.getFile_url(), attachment.getDownload_uri()); modelMap.addAttribute("czMaterials", fileDown); } } } if (Objects.equals(3, projectMaterial.getMaterial_type())) { for (Attachment attachment : attachments) { if (Objects.equals(attachment.getId(), projectMaterial.getTemplate_id())) { FileDown fileDown = new FileDown(attachment.getId(), attachment.getFile_name(), attachment.getFile_url(), attachment.getDownload_uri()); modelMap.addAttribute("zxMaterials", fileDown); } } } } return modelMap; } public boolean isFina() { //Group group = groupService.findByName(Constant.XMSBCLSHZ, null); Group group = groupService.findByName(Constant.XMSBCZSHZ, null); if (group == null) { return false; } List userGroups = userGroupService.findByGroupId(group.getId()); //Department department = departmentService.findByName(Constant.QCZC, null); //List users = userService.findUserBydepartmentId(department.getId().toString()); StringBuffer sb = new StringBuffer(""); for (UserGroup userGroup : userGroups) { //for (User user : users) { //if (Objects.equals(user.getId(), userGroup.getUser_id())) { if (String.valueOf(ShiroUtils.getUserId()).equals(String.valueOf(userGroup.getUser_id()))) { return true; } //} //} } return false; } public PageInfo findByCompany(String projectName, Integer pageNum, Integer pagesize, String startTime1, String startTime2, String endTime1, String endTime2) { PageHelper.startPage(pageNum, pagesize); FindRequest request = new FindRequest(); request.setUser_type(Constant.UserType.COMPANY); request.setCompany_id(ShiroUtils.getCompanyId()); List list = projectDeclarationDao.findByCondition(projectName, startTime1, startTime2, endTime1, endTime2, request, new ProjectDeclaration()); for (ProjectDeclaration projectDeclaration : list) { if (Objects.equals(projectDeclaration.getStatus(), "0")) { projectDeclaration.setStatus_name("待发布"); } else { try { String end = projectDeclaration.getApply_enddate(); if (end.length() <= 10) end += " 23:59:59"; SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Date endtime = sdf.parse(end); Date now = new Date(); if (now.before(endtime)) { projectDeclaration.setStatus_name("申请中"); projectDeclaration.setCanApply(true); } else { projectDeclaration.setStatus_name("失效"); projectDeclaration.setCanApply(false); } } catch (Exception e) { projectDeclaration.setStatus_name("申请中"); } } } return new PageInfo(list); } public ModelMap getDictInfo(ModelMap modelMap) { //项目大类 List projectSuperTypeList = dictionaryItemService.findListByTypeName(Constant.DictionaryType.PROJECT_APPLICATION_SUPER_TYPE); modelMap.put("projectSuperTypeList", projectSuperTypeList); //项目来源 List projectSourceList = dictionaryItemService.findListByTypeName(Constant.DictionaryType.PROJECT_SOURCE); modelMap.put("projectSourceList", projectSourceList); //责任单位 Department department = new Department(); department.setDel_flag(false); department.setUser_type(ShiroUtils.getUserEntity().getUser_type()); department.setUser_type(Constant.UserType.GOVERNMENT); modelMap.addAttribute("departmentList", departmentService.findListByWhere(department)); return modelMap; } //可以在线申报的项目 public PageInfo findActive(String projectName, Integer pageNum, Integer pagesize, String startTime1, String startTime2, String endTime1, String endTime2) { PageHelper.startPage(pageNum, pagesize); FindRequest request = new FindRequest(); request.setIsActive(true); ProjectDeclaration decl = new ProjectDeclaration(); decl.setIs_online_application("1"); List list = projectDeclarationDao.findByCondition(projectName, startTime1, startTime2, endTime1, endTime2, request, decl); for (ProjectDeclaration projectDeclaration : list) { if (Objects.equals(projectDeclaration.getStatus(), "0")) { projectDeclaration.setStatus_name("待发布"); } else { try { String end = projectDeclaration.getApply_enddate(); if (end.length() <= 10) end += " 23:59:59"; SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Date endtime = sdf.parse(end); Date now = new Date(); if (now.before(endtime)) { projectDeclaration.setStatus_name("申请中"); projectDeclaration.setCanApply(true); } else { projectDeclaration.setStatus_name("失效"); projectDeclaration.setCanApply(false); } } catch (Exception e) { projectDeclaration.setStatus_name("申请中"); } } } return new PageInfo(list); } public FindResponseProject findProejctsOnHome(FindRequest request) { FindResponseProject response = new FindResponseProject(); PageHelper.startPage(request.getPage_no(), request.getPage_size()); List contents; //报表填报 if (request.getId() == 77) { contents = projectFillingService.findUnionProjectsOnHome(request); } else {//项目申报、省市申报 contents = projectDeclarationDao.findUnionProjectsOnHome(request); } if (contents.size() > 0) { for (ProjectDeclaration project : contents) { if (null != project.getProject_source()) { String sourceName = dictionaryItemService.findNameByTypeAndValue(Constant.DictionaryType.PROJECT_SOURCE, project.getProject_source()); project.setProject_source_name(sourceName); } } } PageInfo pageInfo = new PageInfo<>(contents); response.setProjects(contents); response.setCounts((int) pageInfo.getTotal()); response.setPage_no(request.getPage_no()); return response; } PageInfo findOrderTrackingPage(Integer pageNum, Integer pagesize, String businessType, String typeId, String number, String companyName, String startDate, String endDate) { PageHelper.startPage(pageNum, pagesize); List list = projectApplicationDao.findOrderTrackingPage(businessType, typeId, number, companyName, startDate, endDate); return new PageInfo(list); } /** * 功能描述:单据追踪导出 * * @param: * @return: * @auther: huZhiHao * @date: 2018/9/26 15:26 */ public void exportOrder(HttpServletResponse response, String businessType, String typeId, String number, String companyName, String startDate, String endDate) throws Exception { List list = projectApplicationDao.findOrderTrackingPage(businessType, typeId, number, companyName, startDate, endDate); String fileName = "单据追踪.xlsx"; List applyList = new ArrayList<>(); for (OrderTrackingDto orderTrackingDto : list) { OrderExports orderExports = new OrderExports(); orderExports.setBusinessName(orderTrackingDto.getBusinessName()); orderExports.setTypeName(orderTrackingDto.getTypeName()); orderExports.setNumber(orderTrackingDto.getNumber()); orderExports.setCompanyName(orderTrackingDto.getCompanyName()); orderExports.setStatus(orderTrackingDto.getStatus()); applyList.add(orderExports); } new ExportExcel("单据追踪", OrderExports.class).setDataList(applyList).write(response, fileName).dispose(); } /** * 项目申报详情 * * @param request * @return */ public PageInfo findProjectList(FindRequest request) { PageHelper.startPage(request.getPage_no(), request.getPage_size()); List contents = projectDeclarationDao.findUnionProjectsOnHome(request); return new PageInfo<>(contents); } public void importData(InputStream inputStream, Workbook wb) throws Exception { Row row = null; Cell cell = null; Sheet sheet = (Sheet) wb.getSheetAt(0); int tatalRows = sheet.getPhysicalNumberOfRows(); if (tatalRows == 2) { throw new Exception("请添加数据"); } String year = ""; String street = ""; String companyName = ""; String projectType = ""; String projectName = ""; String projectName_ = ""; List projectApplicationImportDtoList = new ArrayList<>(); //从3行读取数据 for (int r = 2; r < tatalRows; r++) { //获取行数据 row = sheet.getRow(r); cell = row.getCell(0); year = getCellValue(cell, r, "年度") == "" ? year : getCellValue(cell, r, "年度"); cell = row.getCell(1); street = getCellValue(cell, r, "属地") == "" ? street : getCellValue(cell, r, "属地"); cell = row.getCell(2); companyName = getCellValue(cell, r, "企业名称"); cell = row.getCell(3); projectType = getCellValue(cell, r, "项目大类"); cell = row.getCell(4); projectName = getCellValue(cell, r, "项目小类"); cell = row.getCell(5); projectName_ = getCellValue(cell, r, "申报项目名称"); if (companyName == "" || projectType == "" || projectName == "") { continue; } ProjectApplicationImportDto projectApplicationImportDto = new ProjectApplicationImportDto(); projectApplicationImportDto.setProjectYear(year); projectApplicationImportDto.setStreetName(street); projectApplicationImportDto.setCompanyName(companyName); projectApplicationImportDto.setSuperTypeName(projectType); projectApplicationImportDto.setTypeName(projectName); projectApplicationImportDto.setProjectName(projectName_); projectApplicationImportDtoList.add(projectApplicationImportDto); } updateApplication(projectApplicationImportDtoList); } /** * 获取单元格值 */ private static String getCellValue(Cell cell, int index, String thead) throws Exception { String value = null; if (cell != null) { cell.setCellType(Cell.CELL_TYPE_STRING); value = cell.getStringCellValue(); if (StringUtils.isNotBlank(value)) { return value; } } return value; //throw new Exception("第"+(index+1)+"行"+thead+"不能为空"); } private void updateApplication(List projectApplicationImportDtoList) { // Example example = new Example(ProjectApplication.class); // Example.Criteria criteria = example.createCriteria(); // criteria.andEqualTo("del_flag", 0); // example.setOrderByClause("create_time desc"); // List applys = projectApplicationService.selectByExample(example); List projectApplicationList = projectApplicationService.importList(); for (ProjectApplicationImportDto projectApplication : projectApplicationList) { for (ProjectApplicationImportDto projectApplicationImportDto : projectApplicationImportDtoList) { if ( Objects.equals(projectApplicationImportDto.getProjectYear(), projectApplication.getProjectYear()) && Objects.equals(projectApplicationImportDto.getCompanyName(), projectApplication.getCompanyName()) && projectApplicationImportDto.getSuperTypeName().contains(projectApplication.getSuperTypeName()) && projectApplicationImportDto.getTypeName().contains(projectApplication.getTypeName()) ) { ProjectApplication projectApp = new ProjectApplication(); projectApp.setId(Integer.valueOf(projectApplication.getId())); projectApp.setPass("通过"); projectApplicationService.updateSelective(projectApp); break; } } } } }