From 08f1b1f1804a8bd833d42f257908d80e88387b55 Mon Sep 17 00:00:00 2001
From: mitao <2763622819@qq.com>
Date: 星期五, 14 三月 2025 11:27:47 +0800
Subject: [PATCH] 3.5增加登录验证、修改密码、人员列表调整

---
 springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/scheduled/ComplaintTasks.java |  335 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 331 insertions(+), 4 deletions(-)

diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/scheduled/ComplaintTasks.java b/springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/scheduled/ComplaintTasks.java
index 49e134e..4f7db17 100644
--- a/springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/scheduled/ComplaintTasks.java
+++ b/springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/scheduled/ComplaintTasks.java
@@ -1,20 +1,347 @@
 package com.panzhihua.sangeshenbian.scheduled;
 
-import com.panzhihua.sangeshenbian.service.IComplaintService;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.panzhihua.common.exceptions.ServiceException;
+import com.panzhihua.common.model.vos.LoginUserInfoVO;
+import com.panzhihua.common.model.vos.R;
+import com.panzhihua.common.service.sangeshenbian.SystemUserService;
+import com.panzhihua.common.service.user.UserService;
+import com.panzhihua.common.utlis.DateUtils;
+import com.panzhihua.sangeshenbian.dao.ComplaintAuditRecordMapper;
+import com.panzhihua.sangeshenbian.model.dto.ComplaintTimeout;
+import com.panzhihua.sangeshenbian.model.entity.Complaint;
+import com.panzhihua.sangeshenbian.model.entity.MessageNotification;
+import com.panzhihua.sangeshenbian.model.entity.SystemUser;
+import com.panzhihua.sangeshenbian.model.entity.WorkOrderItemConfig;
+import com.panzhihua.sangeshenbian.service.*;
+import com.panzhihua.sangeshenbian.utils.AliSmsUtil;
 import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Component;
+import org.springframework.util.CollectionUtils;
+
+import java.util.*;
+import java.util.stream.Collectors;
 
 @Component
 @RequiredArgsConstructor
+@Slf4j
 public class ComplaintTasks {
     private final IComplaintService complaintService;
+    private final ComplaintAuditRecordMapper complaintAuditRecordMapper;
+    private final IWorkOrderItemConfigService workOrderItemConfigService;
+    private final ISystemUserService systemUserService;;
+    private final UserService userService;
+    private final IMessageNotificationService messageNotificationService;
 
     /**
-     * 诉求超时处理
+     * 诉求超时处理(每天凌晨两点执行)
      */
-    @Scheduled(fixedRate = 60000)
+    @Scheduled(cron = "0 0 2 * * ?")
     public void complaintTimeout() {
-        complaintService.list();
+
+        WorkOrderItemConfig config = workOrderItemConfigService.getById(1);
+        Integer demandProcessingTime = config.getDemandProcessingTime();
+
+        // 超时未处理短信发送及告会上一级督办
+        timeOutHandle(config,demandProcessingTime);
+
+        // 临期提醒
+        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);
+    }
+
+    // 诉求超时处理
+    private void timeOutHandle(WorkOrderItemConfig config,Integer demandProcessingTime) {
+
+        List<ComplaintTimeout> complaintTimeoutList = complaintAuditRecordMapper.getComplaintTimeout(
+                config.getCityHandlingTime() + demandProcessingTime,
+                config.getDistrictHandlingTime() + demandProcessingTime,
+                config.getStreetHandlingTime() + demandProcessingTime,
+                config.getCommunityHandlingTime() + demandProcessingTime,
+                config.getPartyMemberHandlingTime() + demandProcessingTime);
+
+
+
+        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());
+            });
+        }
+
+        // 区县超时
+        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());
+
+                // 发送短信
+                AliSmsUtil.sendTimeoutMessage(districtPhoneList,complaintTimeout.getTitle());
+            });
+        }
+
+        // 街道超时
+        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());
+
+
+                // 发送短信
+                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)
+                    .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());
+                }
+                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());
+                }
+                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<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());
+
+                // 发送短信
+                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());
+                }
+                messageNotificationService.saveBatch(messageNotificationList);
+            });
+        }
+
+        // 党员超时
+        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