From 039abee6b27058ca46b1e1e82aa0b5407a5dad44 Mon Sep 17 00:00:00 2001 From: liujie <1793218484@qq.com> Date: 星期一, 28 七月 2025 15:25:26 +0800 Subject: [PATCH] 优化 和修改bug --- springcloud_k8s_panzhihuazhihuishequ/service_westcommittee/src/main/java/com/panzhihua/westcommittee/scheduled/ComplaintTasks.java | 453 ++++++++++++++++++++++++-------------------------------- 1 files changed, 193 insertions(+), 260 deletions(-) diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_westcommittee/src/main/java/com/panzhihua/westcommittee/scheduled/ComplaintTasks.java b/springcloud_k8s_panzhihuazhihuishequ/service_westcommittee/src/main/java/com/panzhihua/westcommittee/scheduled/ComplaintTasks.java index bd8c4a0..0e02cf1 100644 --- a/springcloud_k8s_panzhihuazhihuishequ/service_westcommittee/src/main/java/com/panzhihua/westcommittee/scheduled/ComplaintTasks.java +++ b/springcloud_k8s_panzhihuazhihuishequ/service_westcommittee/src/main/java/com/panzhihua/westcommittee/scheduled/ComplaintTasks.java @@ -1,6 +1,7 @@ package com.panzhihua.westcommittee.scheduled; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.panzhihua.common.exceptions.ServiceException; import com.panzhihua.common.model.vos.LoginUserInfoVO; import com.panzhihua.common.model.vos.R; @@ -28,54 +29,49 @@ private final ComplaintAuditRecordMapper complaintAuditRecordMapper; private final IWorkOrderItemConfigService workOrderItemConfigService; private final ISystemUserService systemUserService;; - private final UserService userService; - private final IMessageNotificationService messageNotificationService; + private final IDepartmentService departmentService; private final IComplaintCommentService complaintCommentService; /** * 诉求超时处理(每天凌晨两点执行) */ - @Scheduled(cron = "0 0 2 * * ?") + @Scheduled(fixedRate = 600000) public void complaintTimeout() { WorkOrderItemConfig config = workOrderItemConfigService.getById(1); - Integer demandProcessingTime = config.getDemandProcessingTime(); // 超时未处理短信发送及告会上一级督办 - timeOutHandle(config,demandProcessingTime); + timeOutHandle(config); - // 临期提醒 - reminderHandle(config, demandProcessingTime); - - // 诉求超时提醒 - List<Complaint> complaintList = complaintService.list(new LambdaQueryWrapper<Complaint>() - .le(Complaint::getClosingTime, new Date()) - .eq(Complaint::getStatus, 0)); - List<MessageNotification> messageNotificationList = new ArrayList<>(); - complaintList.forEach(complaint -> { - complaint.setStatus(2); - complaint.setCompletionTime(new Date()); - - - // 代办信息 - R<LoginUserInfoVO> uR = userService.getUserInfoByUserId(String.valueOf(complaint.getCreateBy())); - if (!R.isOk(uR)){ - log.error("未查询到用户信息"); - } - LoginUserInfoVO data = uR.getData(); - MessageNotification messageNotification = new MessageNotification(); - messageNotification.setTitle(complaint.getDescriptionTitle()); - messageNotification.setUndertakerUserId(String.valueOf(complaint.getSuperiorId())); - messageNotification.setUndertakerType(1); - messageNotification.setPhone(data.getPhone()); - messageNotification.setResponseTime(complaint.getClosingTime()); - messageNotification.setPromptType(1); - messageNotification.setReadStatus(0); - messageNotification.setCreateTime(new Date()); - messageNotificationList.add(messageNotification); - }); - complaintService.updateBatchById(complaintList); - messageNotificationService.saveBatch(messageNotificationList); +// // 诉求超时提醒 +// List<Complaint> complaintList = complaintService.list(new LambdaQueryWrapper<Complaint>() +// .le(Complaint::getClosingTime, new Date()) +// .eq(Complaint::getStatus, 0)); +// List<MessageNotification> messageNotificationList = new ArrayList<>(); +// complaintList.forEach(complaint -> { +// complaint.setStatus(2); +// complaint.setCompletionTime(new Date()); +// +// +// // 代办信息 +// R<LoginUserInfoVO> uR = userService.getUserInfoByUserId(String.valueOf(complaint.getCreateBy())); +// if (!R.isOk(uR)){ +// log.error("未查询到用户信息"); +// } +// LoginUserInfoVO data = uR.getData(); +// MessageNotification messageNotification = new MessageNotification(); +// messageNotification.setTitle(complaint.getDescriptionTitle()); +// messageNotification.setUndertakerUserId(String.valueOf(complaint.getSuperiorId())); +// messageNotification.setUndertakerType(1); +// messageNotification.setPhone(data.getPhone()); +// messageNotification.setResponseTime(complaint.getClosingTime()); +// messageNotification.setPromptType(1); +// messageNotification.setReadStatus(0); +// messageNotification.setCreateTime(new Date()); +// messageNotificationList.add(messageNotification); +// }); +// complaintService.updateBatchById(complaintList); +// messageNotificationService.saveBatch(messageNotificationList); } @@ -100,266 +96,203 @@ // 诉求超时处理 - private void timeOutHandle(WorkOrderItemConfig config,Integer demandProcessingTime) { + private void timeOutHandle(WorkOrderItemConfig config) { List<ComplaintTimeout> complaintTimeoutList = complaintAuditRecordMapper.getComplaintTimeout( - config.getCityHandlingTime() + demandProcessingTime, - config.getDistrictHandlingTime() + demandProcessingTime, - config.getStreetHandlingTime() + demandProcessingTime, - config.getCommunityHandlingTime() + demandProcessingTime, - config.getPartyMemberHandlingTime() + demandProcessingTime); + config.getDistrictHandlingTime() , + config.getStreetHandlingTime(), + config.getCommunityHandlingTime() + ); + if(!complaintTimeoutList.isEmpty()) { + // 当前不在发送 + complaintService.update(new LambdaUpdateWrapper<Complaint>().in(Complaint::getId, complaintTimeoutList.stream().map(ComplaintTimeout::getComplaintId).collect(Collectors.toList())).set(Complaint::getNowLevelSms, 1)); + } Map<Integer, List<ComplaintTimeout>> timeOutMap = complaintTimeoutList.stream() - .collect(Collectors.groupingBy(ComplaintTimeout::getReportType)); - - // 市超时 - List<ComplaintTimeout> cityTimeOutList = timeOutMap.get(1); - if (!CollectionUtils.isEmpty(cityTimeOutList)){ - - List<SystemUser> cityUserList = systemUserService.list(new LambdaQueryWrapper<SystemUser>() - .eq(SystemUser::getAccountLevel, 1) - .eq(SystemUser::getStatus, 1)); - List<String> cityPhoneList = cityUserList.stream().map(SystemUser::getPhone).collect(Collectors.toList()); - - cityTimeOutList.forEach(complaintTimeout -> { - // 发送短信 - AliSmsUtil.sendTimeoutMessage(cityPhoneList,complaintTimeout.getTitle()); - }); - } + .collect(Collectors.groupingBy(ComplaintTimeout::getNowLevel)); // 区县超时 List<ComplaintTimeout> districtTimeOutList = timeOutMap.get(2); if (!CollectionUtils.isEmpty(districtTimeOutList)){ - districtTimeOutList.forEach(complaintTimeout -> { - - List<SystemUser> districtUserList = systemUserService.list(new LambdaQueryWrapper<SystemUser>() - .eq(SystemUser::getAccountLevel, 2) - .eq(SystemUser::getDistrictsCode, complaintTimeout.getSuperiorId()) - .eq(SystemUser::getStatus, 1)); - List<String> districtPhoneList = districtUserList.stream().map(SystemUser::getPhone).collect(Collectors.toList()); - + // 没有分配的 需要发给层级管理员和纪委 + List<ComplaintTimeout> collect = districtTimeOutList.stream().filter(e -> e.getAssignStatus() == 0).collect(Collectors.toList()); + // 查询状态正常 是区纪委和管理员 + List<SystemUser> districtUserList = systemUserService.list(new LambdaQueryWrapper<SystemUser>() + .eq(SystemUser::getAccountLevel, 2) + .in(SystemUser::getSystemRoleId,1,2) + .eq(SystemUser::getStatus, 1)); + List<String> districtPhoneList = districtUserList.stream().filter(e->e.getSystemRoleId()==1).map(SystemUser::getPhone).collect(Collectors.toList()); + List<String> districtPhoneList1 = districtUserList.stream().filter(e->e.getSystemRoleId()==2).map(SystemUser::getPhone).collect(Collectors.toList()); + collect.forEach(complaintTimeout -> { // 发送短信 - AliSmsUtil.sendTimeoutMessage(districtPhoneList,complaintTimeout.getTitle()); + if(!districtPhoneList.isEmpty() && !complaintTimeout.getProblemType().equals("检举控告")){ + AliSmsUtil.sendTimeoutMessageAdmin(districtPhoneList,complaintTimeout.getSerialNumber()); + } + if(!districtPhoneList1.isEmpty()){ + AliSmsUtil.sendTimeoutMessage(districtPhoneList1,complaintTimeout.getSerialNumber()); + } }); + + + // 分配了 查询是否有管理员 没有找层级管理员 + List<ComplaintTimeout> collect1 = districtTimeOutList.stream().filter(e -> e.getAssignStatus() == 1).collect(Collectors.toList()); + if(!collect1.isEmpty()){ + // 分配的单位id + List<Integer> deptIds = collect1.stream().map(ComplaintTimeout::getAssignPersonId).collect(Collectors.toList()); + // 这些单位的管理员 + List<SystemUser> list = systemUserService.list(new LambdaQueryWrapper<SystemUser>().in(SystemUser::getOneDepartmentId, deptIds).in(SystemUser::getSystemRoleId,1,2).eq(SystemUser::getStatus,1)); + collect1.forEach(complaintTimeout -> { + // 当前单位的管理员 + List<SystemUser> systemUsers = list.stream().filter(e -> e.getOneDepartmentId().equals(complaintTimeout.getAssignPersonId())).collect(Collectors.toList()); + if(!systemUsers.isEmpty()){ + // 找出当前单位的管理员 纪委 + List<String> districtPhoneList2 = systemUsers.stream().filter(e->e.getSystemRoleId()==1).map(SystemUser::getPhone).collect(Collectors.toList()); + List<String> districtPhoneList3 = systemUsers.stream().filter(e->e.getSystemRoleId()==2).map(SystemUser::getPhone).collect(Collectors.toList()); + // 发送短信 + if(!districtPhoneList2.isEmpty() && !complaintTimeout.getProblemType().equals("检举控告")){ + AliSmsUtil.sendTimeoutMessageAdmin(districtPhoneList2,complaintTimeout.getSerialNumber()); + } + if(!districtPhoneList3.isEmpty()){ + AliSmsUtil.sendTimeoutMessage(districtPhoneList3,complaintTimeout.getSerialNumber()); + } + }else { + // 发送短信 + if(!districtPhoneList.isEmpty() && !complaintTimeout.getProblemType().equals("检举控告")){ + AliSmsUtil.sendTimeoutMessageAdmin(districtPhoneList,complaintTimeout.getSerialNumber()); + } + if(!districtPhoneList1.isEmpty()){ + AliSmsUtil.sendTimeoutMessage(districtPhoneList1,complaintTimeout.getSerialNumber()); + } + } + }); + } + } // 街道超时 List<ComplaintTimeout> streetTimeOutList = timeOutMap.get(3); if (!CollectionUtils.isEmpty(streetTimeOutList)){ - streetTimeOutList.forEach(complaintTimeout -> { - List<SystemUser> streetUserList = systemUserService.list(new LambdaQueryWrapper<SystemUser>() - .eq(SystemUser::getAccountLevel, 3) - .eq(SystemUser::getStreetId, complaintTimeout.getSuperiorId()) - .eq(SystemUser::getStatus, 1)); - List<String> streetPhoneList = streetUserList.stream().map(SystemUser::getPhone).collect(Collectors.toList()); + // 没有分配的 需要发给层级管理员和纪委 + List<ComplaintTimeout> collect = streetTimeOutList.stream().filter(e -> e.getAssignStatus() == 0).collect(Collectors.toList()); - // 发送短信 - AliSmsUtil.sendTimeoutMessage(streetPhoneList,complaintTimeout.getTitle()); - }); - } - - // 社区超时 - List<ComplaintTimeout> communityTimeOutList = timeOutMap.get(4); - if (!CollectionUtils.isEmpty(communityTimeOutList)){ - communityTimeOutList.forEach(complaintTimeout -> { - List<SystemUser> communityUserList = systemUserService.list(new LambdaQueryWrapper<SystemUser>() - .eq(SystemUser::getAccountLevel, 4) - .eq(SystemUser::getCommunityId, complaintTimeout.getSuperiorId()) - .eq(SystemUser::getStatus, 1)); - List<String> communityPhoneList = communityUserList.stream().map(SystemUser::getPhone).collect(Collectors.toList()); - - // 发送短信 - AliSmsUtil.sendTimeoutMessage(communityPhoneList,complaintTimeout.getTitle()); - }); - } - - // 党员超时 - List<ComplaintTimeout> partyMemberTimeOutList = timeOutMap.get(5); - if (!CollectionUtils.isEmpty(partyMemberTimeOutList)){ - partyMemberTimeOutList.forEach(complaintTimeout -> { - R<LoginUserInfoVO> uR = userService.getUserInfoByUserId(String.valueOf(complaintTimeout.getCreateBy())); - if (!R.isOk(uR)){ - throw new ServiceException("获取用户信息失败"); - } - LoginUserInfoVO data = uR.getData(); - AliSmsUtil.sendTimeoutMessage(Collections.singletonList(data.getPhone()),complaintTimeout.getTitle()); - }); - } - } - - // 临期提醒 - private void reminderHandle(WorkOrderItemConfig config,Integer demandProcessingTime) { - - List<ComplaintTimeout> complaintTimeoutList = complaintAuditRecordMapper.getComplaintTimeout( - demandProcessingTime - config.getCityDeadlineReminder(), - demandProcessingTime - config.getDistrictDeadlineReminder(), - demandProcessingTime - config.getStreetDeadlineReminder(), - demandProcessingTime - config.getCommunityDeadlineReminder(), - demandProcessingTime - config.getPartyMemberDeadlineReminder()); - - - Map<Integer, List<ComplaintTimeout>> timeOutMap = complaintTimeoutList.stream() - .collect(Collectors.groupingBy(ComplaintTimeout::getReportType)); - - // 市超时 - List<ComplaintTimeout> cityTimeOutList = timeOutMap.get(1); - if (!CollectionUtils.isEmpty(cityTimeOutList)){ - - List<SystemUser> cityUserList = systemUserService.list(new LambdaQueryWrapper<SystemUser>() - .eq(SystemUser::getAccountLevel, 1) + List<SystemUser> streetUserList = systemUserService.list(new LambdaQueryWrapper<SystemUser>() + .eq(SystemUser::getAccountLevel, 3) + .in(SystemUser::getSystemRoleId,1,2) .eq(SystemUser::getStatus, 1)); - List<String> cityPhoneList = cityUserList.stream().map(SystemUser::getPhone).collect(Collectors.toList()); - - cityTimeOutList.forEach(complaintTimeout -> { - // 发送短信 - Date closingTime = complaintTimeout.getClosingTime(); - int daysRemaining = DateUtils.retrieveRemainingDays(closingTime); - AliSmsUtil.sendExpireMessage(cityPhoneList,complaintTimeout.getTitle(),closingTime, daysRemaining); - // 代办信息 - List<MessageNotification> messageNotificationList = new ArrayList<>(); - for (String phone : cityPhoneList) { - MessageNotification messageNotification = new MessageNotification(); - messageNotification.setTitle(complaintTimeout.getTitle()); - messageNotification.setUndertakerUserId(String.valueOf(complaintTimeout.getSuperiorId())); - messageNotification.setUndertakerType(1); - messageNotification.setPhone(phone); - messageNotification.setResponseTime(complaintTimeout.getClosingTime()); - messageNotification.setPromptType(1); - messageNotification.setReadStatus(0); - messageNotification.setCreateTime(new Date()); + collect.forEach(complaintTimeout -> { + List<String> streetPhoneList = streetUserList.stream().filter(e->e.getSystemRoleId()==1 && e.getStreetId().equals(complaintTimeout.getSuperiorId().toString())).map(SystemUser::getPhone).collect(Collectors.toList()); + List<String> streetPhoneList1 = streetUserList.stream().filter(e->e.getSystemRoleId()==2 && e.getStreetId().equals(complaintTimeout.getSuperiorId().toString())).map(SystemUser::getPhone).collect(Collectors.toList()); + // 发送短信 + if(!streetPhoneList.isEmpty() && !complaintTimeout.getProblemType().equals("检举控告")){ + AliSmsUtil.sendTimeoutMessageAdmin(streetPhoneList,complaintTimeout.getSerialNumber()); } - messageNotificationService.saveBatch(messageNotificationList); - - }); - } - - // 区县超时 - List<ComplaintTimeout> districtTimeOutList = timeOutMap.get(2); - if (!CollectionUtils.isEmpty(districtTimeOutList)){ - districtTimeOutList.forEach(complaintTimeout -> { - - List<SystemUser> districtUserList = systemUserService.list(new LambdaQueryWrapper<SystemUser>() - .eq(SystemUser::getAccountLevel, 2) - .eq(SystemUser::getDistrictsCode, complaintTimeout.getSuperiorId()) - .eq(SystemUser::getStatus, 1)); - List<String> districtPhoneList = districtUserList.stream().map(SystemUser::getPhone).collect(Collectors.toList()); - - // 发送短信 - Date closingTime = complaintTimeout.getClosingTime(); - int daysRemaining = DateUtils.retrieveRemainingDays(closingTime); - AliSmsUtil.sendExpireMessage(districtPhoneList,complaintTimeout.getTitle(),closingTime, daysRemaining); - - - // 代办信息 - List<MessageNotification> messageNotificationList = new ArrayList<>(); - for (String phone : districtPhoneList) { - MessageNotification messageNotification = new MessageNotification(); - messageNotification.setTitle(complaintTimeout.getTitle()); - messageNotification.setUndertakerUserId(String.valueOf(complaintTimeout.getSuperiorId())); - messageNotification.setUndertakerType(1); - messageNotification.setPhone(phone); - messageNotification.setResponseTime(complaintTimeout.getClosingTime()); - messageNotification.setPromptType(1); - messageNotification.setReadStatus(0); - messageNotification.setCreateTime(new Date()); + if(!streetPhoneList1.isEmpty()){ + AliSmsUtil.sendTimeoutMessage(streetPhoneList1,complaintTimeout.getSerialNumber()); } - messageNotificationService.saveBatch(messageNotificationList); }); - } - // 街道超时 - List<ComplaintTimeout> streetTimeOutList = timeOutMap.get(3); - if (!CollectionUtils.isEmpty(streetTimeOutList)){ - streetTimeOutList.forEach(complaintTimeout -> { - List<SystemUser> streetUserList = systemUserService.list(new LambdaQueryWrapper<SystemUser>() - .eq(SystemUser::getAccountLevel, 3) - .eq(SystemUser::getStreetId, complaintTimeout.getSuperiorId()) - .eq(SystemUser::getStatus, 1)); - List<String> streetPhoneList = streetUserList.stream().map(SystemUser::getPhone).collect(Collectors.toList()); - // 发送短信 - Date closingTime = complaintTimeout.getClosingTime(); - int daysRemaining = DateUtils.retrieveRemainingDays(closingTime); - AliSmsUtil.sendExpireMessage(streetPhoneList,complaintTimeout.getTitle(),closingTime, daysRemaining); + // 分配了 + List<ComplaintTimeout> collect1 = streetTimeOutList.stream().filter(e -> e.getAssignStatus() == 1).collect(Collectors.toList()); + if(!collect1.isEmpty()){ + List<Integer> deptIds = collect1.stream().map(ComplaintTimeout::getAssignPersonId).collect(Collectors.toList()); + List<SystemUser> list = systemUserService.list(new LambdaQueryWrapper<SystemUser>().in(SystemUser::getOneDepartmentId, deptIds).in(SystemUser::getSystemRoleId,1,2).eq(SystemUser::getStatus,1)); + collect1.forEach(complaintTimeout -> { + List<SystemUser> systemUsers = list.stream().filter(e -> e.getOneDepartmentId().equals(complaintTimeout.getAssignPersonId())).collect(Collectors.toList()); + if(!systemUsers.isEmpty()){ + List<String> streetPhoneList2 = systemUsers.stream().filter(e->e.getSystemRoleId()==1).map(SystemUser::getPhone).collect(Collectors.toList()); + List<String> streetPhoneList3 = systemUsers.stream().filter(e->e.getSystemRoleId()==2).map(SystemUser::getPhone).collect(Collectors.toList()); + // 发送短信 + if(!streetPhoneList2.isEmpty() && !complaintTimeout.getProblemType().equals("检举控告")){ + AliSmsUtil.sendTimeoutMessageAdmin(streetPhoneList2,complaintTimeout.getSerialNumber()); + } + if(!streetPhoneList3.isEmpty()){ + AliSmsUtil.sendTimeoutMessage(streetPhoneList3,complaintTimeout.getSerialNumber()); + } + }else { + List<String> streetPhoneList = streetUserList.stream().filter(e->e.getSystemRoleId()==1 && e.getStreetId().equals(complaintTimeout.getSuperiorId().toString())).map(SystemUser::getPhone).collect(Collectors.toList()); + List<String> streetPhoneList1 = streetUserList.stream().filter(e->e.getSystemRoleId()==2 && e.getStreetId().equals(complaintTimeout.getSuperiorId().toString())).map(SystemUser::getPhone).collect(Collectors.toList()); + // 发送短信 + if(!streetPhoneList.isEmpty() && !complaintTimeout.getProblemType().equals("检举控告")){ + AliSmsUtil.sendTimeoutMessageAdmin(streetPhoneList,complaintTimeout.getSerialNumber()); + } + if(!streetPhoneList1.isEmpty()){ + AliSmsUtil.sendTimeoutMessage(streetPhoneList1,complaintTimeout.getSerialNumber()); + } + } + }); + } - // 代办信息 - List<MessageNotification> messageNotificationList = new ArrayList<>(); - for (String phone : streetPhoneList) { - MessageNotification messageNotification = new MessageNotification(); - messageNotification.setTitle(complaintTimeout.getTitle()); - messageNotification.setUndertakerUserId(String.valueOf(complaintTimeout.getSuperiorId())); - messageNotification.setUndertakerType(1); - messageNotification.setPhone(phone); - messageNotification.setResponseTime(complaintTimeout.getClosingTime()); - messageNotification.setPromptType(1); - messageNotification.setReadStatus(0); - messageNotification.setCreateTime(new Date()); - } - messageNotificationService.saveBatch(messageNotificationList); - }); + + } // 社区超时 List<ComplaintTimeout> communityTimeOutList = timeOutMap.get(4); if (!CollectionUtils.isEmpty(communityTimeOutList)){ - communityTimeOutList.forEach(complaintTimeout -> { - List<SystemUser> communityUserList = systemUserService.list(new LambdaQueryWrapper<SystemUser>() - .eq(SystemUser::getAccountLevel, 4) - .eq(SystemUser::getCommunityId, complaintTimeout.getSuperiorId()) - .eq(SystemUser::getStatus, 1)); - List<String> communityPhoneList = communityUserList.stream().map(SystemUser::getPhone).collect(Collectors.toList()); + List<ComplaintTimeout> collect = communityTimeOutList.stream().filter(e -> e.getAssignStatus() == 0).collect(Collectors.toList()); + + + + List<SystemUser> communityUserList = systemUserService.list(new LambdaQueryWrapper<SystemUser>() + .eq(SystemUser::getAccountLevel, 4) + .in(SystemUser::getSystemRoleId,1,2) + .eq(SystemUser::getStatus, 1)); + collect.forEach(complaintTimeout -> { + List<String> communityPhoneList = communityUserList.stream().filter(e->e.getSystemRoleId()==1 && e.getCommunityId().equals(complaintTimeout.getSuperiorId())).map(SystemUser::getPhone).collect(Collectors.toList()); + List<String> communityPhoneList1 = communityUserList.stream().filter(e->e.getSystemRoleId()==2 && e.getCommunityId().equals(complaintTimeout.getSuperiorId())).map(SystemUser::getPhone).collect(Collectors.toList()); // 发送短信 - Date closingTime = complaintTimeout.getClosingTime(); - int daysRemaining = DateUtils.retrieveRemainingDays(closingTime); - AliSmsUtil.sendExpireMessage(communityPhoneList,complaintTimeout.getTitle(),closingTime, daysRemaining); - - // 代办信息 - List<MessageNotification> messageNotificationList = new ArrayList<>(); - for (String phone : communityPhoneList) { - MessageNotification messageNotification = new MessageNotification(); - messageNotification.setTitle(complaintTimeout.getTitle()); - messageNotification.setUndertakerUserId(String.valueOf(complaintTimeout.getSuperiorId())); - messageNotification.setUndertakerType(1); - messageNotification.setPhone(phone); - messageNotification.setResponseTime(complaintTimeout.getClosingTime()); - messageNotification.setPromptType(1); - messageNotification.setReadStatus(0); - messageNotification.setCreateTime(new Date()); + if(!communityPhoneList.isEmpty() && !complaintTimeout.getProblemType().equals("检举控告")){ + AliSmsUtil.sendTimeoutMessageAdmin(communityPhoneList, complaintTimeout.getSerialNumber()); } - messageNotificationService.saveBatch(messageNotificationList); + if(!communityPhoneList1.isEmpty()){ + AliSmsUtil.sendTimeoutMessage(communityPhoneList1,complaintTimeout.getSerialNumber()); + } }); + + + // 分配了 + List<ComplaintTimeout> collect1 = communityTimeOutList.stream().filter(e -> e.getAssignStatus() == 1).collect(Collectors.toList()); + if(!collect1.isEmpty()){ + List<Integer> deptIds = collect1.stream().map(ComplaintTimeout::getAssignPersonId).collect(Collectors.toList()); + List<SystemUser> list = systemUserService.list(new LambdaQueryWrapper<SystemUser>().in(SystemUser::getOneDepartmentId, deptIds).in(SystemUser::getSystemRoleId,1,2).eq(SystemUser::getStatus,1)); + collect1.forEach(complaintTimeout -> { + List<SystemUser> systemUsers = list.stream().filter(e -> e.getOneDepartmentId().equals(complaintTimeout.getAssignPersonId())).collect(Collectors.toList()); + if(!systemUsers.isEmpty()){ + List<String> communityPhoneList2 = systemUsers.stream().filter(e->e.getSystemRoleId()==1).map(SystemUser::getPhone).collect(Collectors.toList()); + List<String> communityPhoneList3 = systemUsers.stream().filter(e->e.getSystemRoleId()==2).map(SystemUser::getPhone).collect(Collectors.toList()); + // 发送短信 + if(!communityPhoneList2.isEmpty() && !complaintTimeout.getProblemType().equals("检举控告")){ + AliSmsUtil.sendTimeoutMessageAdmin(communityPhoneList2, complaintTimeout.getSerialNumber()); + } + if(!communityPhoneList3.isEmpty()){ + AliSmsUtil.sendTimeoutMessage(communityPhoneList3,complaintTimeout.getSerialNumber()); + } + }else { + List<String> communityPhoneList = communityUserList.stream().filter(e->e.getSystemRoleId()==1 && e.getCommunityId().equals(complaintTimeout.getSuperiorId())).map(SystemUser::getPhone).collect(Collectors.toList()); + List<String> communityPhoneList1 = communityUserList.stream().filter(e->e.getSystemRoleId()==2 && e.getCommunityId().equals(complaintTimeout.getSuperiorId())).map(SystemUser::getPhone).collect(Collectors.toList()); + // 发送短信 + if(!communityPhoneList.isEmpty() && !complaintTimeout.getProblemType().equals("检举控告")){ + AliSmsUtil.sendTimeoutMessageAdmin(communityPhoneList, complaintTimeout.getSerialNumber()); + } + if(!communityPhoneList1.isEmpty()){ + AliSmsUtil.sendTimeoutMessage(communityPhoneList1,complaintTimeout.getSerialNumber()); + } + } + }); + } } - // 党员超时 - List<ComplaintTimeout> partyMemberTimeOutList = timeOutMap.get(5); - if (!CollectionUtils.isEmpty(partyMemberTimeOutList)){ - partyMemberTimeOutList.forEach(complaintTimeout -> { - R<LoginUserInfoVO> uR = userService.getUserInfoByUserId(String.valueOf(complaintTimeout.getCreateBy())); - if (!R.isOk(uR)){ - throw new ServiceException("获取用户信息失败"); - } - LoginUserInfoVO data = uR.getData(); - // 发送短信 - Date closingTime = complaintTimeout.getClosingTime(); - int daysRemaining = DateUtils.retrieveRemainingDays(closingTime); - AliSmsUtil.sendExpireMessage(Collections.singletonList(data.getPhone()),complaintTimeout.getTitle(),closingTime, daysRemaining); - // 代办信息 - MessageNotification messageNotification = new MessageNotification(); - messageNotification.setTitle(complaintTimeout.getTitle()); - messageNotification.setUndertakerUserId(String.valueOf(complaintTimeout.getSuperiorId())); - messageNotification.setUndertakerType(1); - messageNotification.setPhone(data.getPhone()); - messageNotification.setResponseTime(complaintTimeout.getClosingTime()); - messageNotification.setPromptType(1); - messageNotification.setReadStatus(0); - messageNotification.setCreateTime(new Date()); - messageNotificationService.save(messageNotification); - }); - } + + + + + } + } -- Gitblit v1.7.1