springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/pom.xml
@@ -123,6 +123,12 @@ <artifactId>javase</artifactId> <version>3.3.3</version> </dependency> <!--sms--> <dependency> <groupId>com.aliyun</groupId> <artifactId>dysmsapi20170525</artifactId> <version>3.1.0</version> </dependency> </dependencies> springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/config/AliSmsConfig.java
New file @@ -0,0 +1,46 @@ package com.panzhihua.sangeshenbian.config; import lombok.Data; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.stereotype.Component; @Component @ConfigurationProperties(prefix = "sms") @Data public class AliSmsConfig { private String accessKeyId; private String accessKeySecret; /** * 签名 */ private String signName; /** * 诉求超时提醒模板编码 */ private String timeoutTemplateCode; /** * 诉求临期提醒模板代码 */ private String expireTemplateCode; /** * 连接超时ms */ private String connectTimeout = "30000"; /** * 读超时ms */ private String readTimeout = "30000"; /** * 调试状态 */ private boolean debug = false; } springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/dao/ComplaintAuditRecordMapper.java
@@ -1,7 +1,11 @@ package com.panzhihua.sangeshenbian.dao; import com.panzhihua.sangeshenbian.model.dto.ComplaintTimeout; import com.panzhihua.sangeshenbian.model.entity.ComplaintAuditRecord; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.apache.ibatis.annotations.Param; import java.util.List; /** * <p> @@ -13,4 +17,10 @@ */ public interface ComplaintAuditRecordMapper extends BaseMapper<ComplaintAuditRecord> { public List<ComplaintTimeout> getComplaintTimeout(@Param("cityDay") Integer cityDay, @Param("districtDay") Integer districtDay, @Param("streetDay") Integer streetDay, @Param("communityDay") Integer communityDay, @Param("partyMemberDay") Integer partyMemberDay); } springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/model/dto/ComplaintTimeout.java
New file @@ -0,0 +1,15 @@ package com.panzhihua.sangeshenbian.model.dto; import lombok.Data; import java.util.Date; @Data public class ComplaintTimeout { private Long complaintId; private String title; private Long createBy; private Integer reportType; private Integer superiorId; private Date closingTime; } springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/model/entity/MessageNotification.java
@@ -9,6 +9,7 @@ import lombok.Data; import java.time.LocalDateTime; import java.util.Date; /** * @author zhibing.pu @@ -71,7 +72,7 @@ */ @TableField("response_time") @ApiModelProperty("需求应处理时间") private LocalDateTime responseTime; private Date responseTime; /** * 提示类型(1=临期提醒,2=超时提醒) */ @@ -89,5 +90,5 @@ */ @TableField("create_time") @ApiModelProperty("创建时间") private LocalDateTime createTime; private Date createTime; } 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 lombok.RequiredArgsConstructor; //import org.springframework.scheduling.annotation.Scheduled; //import org.springframework.stereotype.Component; // //@Component //@RequiredArgsConstructor //public class ComplaintTasks { // private final IComplaintService complaintService; // // /** // * 诉求超时处理 // */ // @Scheduled(fixedRate = 60000) // public void complaintTimeout() { // complaintService.list(); // } //} package com.panzhihua.sangeshenbian.scheduled; 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(cron = "0 0 2 * * ?") public void complaintTimeout() { 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); }); } } } springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/service/impl/ComplaintServiceImpl.java
@@ -596,7 +596,7 @@ if (accountLevel == 1) { throw new ServiceException("市级账号,无法上报!"); } reportType = accountLevel + 1; reportType = accountLevel - 1; // 使用基本类型比较并补充默认分支 if (accountLevel == ReportTypeEnum.COMMUNITY.getCode()) { @@ -630,13 +630,13 @@ record1.setComplaintId(complaint.getId()); record1.setLatestFlag(true); record1.setAuditType(2); record1.setAuditStatus(2); record1.setAuditStatus(0); record1.setCreateBy(loginUserInfoVO.getUserId()); record1.setCreateTime(new Date(System.currentTimeMillis())); record1.setUpdateBy(loginUserInfoVO.getUserId()); record1.setUpdateTime(new Date(System.currentTimeMillis())); record1.setReporter(loginUserInfoVO.getNickName()); record1.setReportType(systemUser.getAccountLevel()); record1.setReportType(Objects.isNull(systemUser) ? 5 : systemUser.getAccountLevel()); record1.setSuperiorId(currentId); record1.setSort(count + 1); complaintAuditRecordService.save(record1); @@ -645,13 +645,13 @@ record2.setComplaintId(complaint.getId()); record2.setLatestFlag(true); record2.setAuditType(2); record2.setAuditStatus(2); record2.setAuditStatus(0); record2.setCreateBy(loginUserInfoVO.getUserId()); record2.setCreateTime(new Date(System.currentTimeMillis())); record2.setUpdateBy(loginUserInfoVO.getUserId()); record2.setUpdateTime(new Date(System.currentTimeMillis())); record2.setReporter(loginUserInfoVO.getNickName()); record2.setReportType(systemUser.getAccountLevel() - 1); record2.setReportType(reportType); record2.setSuperiorId(superiorId); record2.setSort(count + 2); complaintAuditRecordService.save(record2); @@ -743,7 +743,8 @@ // 使用基本类型比较并补充默认分支 List<DispatchVO> dispatchVOList = new ArrayList<>(); if (accountLevel == ReportTypeEnum.STREET.getCode()) { List<ComAct> list = comActService.list(); String streetId = adminUser.getStreetId(); List<ComAct> list = comActService.list(new LambdaQueryWrapper<ComAct>().eq(ComAct::getStreetId, streetId).eq(ComAct::getState, 0)); for (ComAct comAct : list) { DispatchVO dispatchVO = new DispatchVO(); dispatchVO.setId(comAct.getCommunityId().toString()); @@ -751,7 +752,8 @@ dispatchVOList.add(dispatchVO); } } else if (accountLevel == ReportTypeEnum.DISTRICT.getCode()) { List<ComStreet> list = comStreetService.list(); String districtsCode = adminUser.getDistrictsCode(); List<ComStreet> list = comStreetService.list(new LambdaQueryWrapper<ComStreet>().eq(ComStreet::getAreaCode, districtsCode)); for (ComStreet street : list) { DispatchVO dispatchVO = new DispatchVO(); dispatchVO.setId(street.getStreetId().toString()); springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/utils/AliSmsUtil.java
New file @@ -0,0 +1,143 @@ package com.panzhihua.sangeshenbian.utils; import cn.hutool.core.date.DateUtil; import com.alibaba.fastjson.JSON; import com.aliyun.dysmsapi20170525.Client; import com.aliyun.dysmsapi20170525.models.SendBatchSmsRequest; import com.aliyun.dysmsapi20170525.models.SendBatchSmsResponse; import com.aliyun.dysmsapi20170525.models.SendSmsRequest; import com.aliyun.dysmsapi20170525.models.SendSmsResponse; import com.aliyun.teaopenapi.models.Config; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import java.util.Collections; import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; @Slf4j public class AliSmsUtil { private static final String ACCESS_KEY_ID = "LTAI5t8EwfjWRWs7tJGimAQG"; private static final String ACCESS_KEY_SECRET = "UjuTDcXO14dSQ7STg8Pf3idjLqwx1M"; private static final String SIGN_NAME = "花城e十"; private static final String TIME_OUT_TEMPLATE_CODE = "SMS_479120493"; private static final String EXPIRE_TEMPLATE_CODE = "SMS_479510160"; /** * 发送诉求超时提醒短信 * @param phoneList * @param title */ public static void sendTimeoutMessage(List<String> phoneList, String title) { Map<String, String> param = new HashMap<>(3); param.put("title", title); sendBatchSms(phoneList, SIGN_NAME, TIME_OUT_TEMPLATE_CODE, param); } /** * 发送诉求临期短信 * @param phoneList * @param title * @param closingTime * @param days */ public static void sendExpireMessage(List<String> phoneList, String title, Date closingTime, Integer days) { Map<String, String> param = new HashMap<>(3); param.put("title", title); param.put("time", DateUtil.format(closingTime, "yyyy-MM-dd HH:mm:ss")); param.put("times", String.valueOf(days)); sendBatchSms(phoneList, SIGN_NAME, EXPIRE_TEMPLATE_CODE, param); } /** * 阿里发送短信 * * @param phone * @param signName * @param templateCode * @param param * @return */ private boolean sendSms(String phone, String signName, String templateCode, Map<String, String> param) { // 可自助调整超时时间 System.setProperty("sun.net.client.defaultConnectTimeout", "30000"); System.setProperty("sun.net.client.defaultReadTimeout", "30000"); try { // 初始化请求客户端 Client client = createClient(); // 构造请求对象,请填入请求参数值 SendSmsRequest sendSmsRequest = new SendSmsRequest() .setPhoneNumbers(phone) .setSignName(signName) .setTemplateCode(templateCode) .setTemplateParam(JSON.toJSONString(param)); //if (aliSmsConfig.isDebug()) { // log.info("短信 DEBUG code= {}", param); // return true; //} // 获取响应对象 SendSmsResponse sendSmsResponse = client.sendSms(sendSmsRequest); // hint 此处可能会抛出异常,注意catch if (StringUtils.equalsIgnoreCase("ok", sendSmsResponse.getBody().getCode())) { return true; } else { log.error("{}短信发送失败:{}", phone, sendSmsResponse.getBody().getMessage()); } } catch (Exception e) { log.error("{}短信发送失败:{}", phone, e.getMessage(),e); throw new RuntimeException("短信发送失败", e); } return false; } private static boolean sendBatchSms(List<String> phones, String signName, String templateCode, Map<String, String> param) { // 可自助调整超时时间 System.setProperty("sun.net.client.defaultConnectTimeout", "30000"); System.setProperty("sun.net.client.defaultReadTimeout", "30000"); try { // 初始化请求客户端 Client client = createClient(); // 构造请求对象,请填入请求参数值 SendBatchSmsRequest request = new SendBatchSmsRequest() .setPhoneNumberJson(JSON.toJSONString(phones)) // 手机号数组JSON .setSignNameJson(JSON.toJSONString(Collections.nCopies(phones.size(), SIGN_NAME))) .setTemplateCode(templateCode) .setTemplateParamJson(JSON.toJSONString(Collections.nCopies(phones.size(), param))); // 参数数组JSON //if (aliSmsConfig.isDebug()) { // log.info("短信 DEBUG code= {}", param); // return true; //} // 获取响应对象 SendBatchSmsResponse sendBatchSmsResponse = client.sendBatchSms(request); // hint 此处可能会抛出异常,注意catch if (StringUtils.equalsIgnoreCase("ok", sendBatchSmsResponse.getBody().getCode())) { return true; } else { log.error("{}短信发送失败:{}", JSON.toJSONString(phones), sendBatchSmsResponse.getBody().getMessage()); } } catch (Exception e) { log.error("{}短信发送失败:{}", JSON.toJSONString(phones), e.getMessage(),e); throw new RuntimeException("短信发送失败", e); } return false; } public static Client createClient() throws Exception { Config config = new Config() // 配置 AccessKey ID .setAccessKeyId(ACCESS_KEY_ID) // 配置 AccessKey Secret .setAccessKeySecret(ACCESS_KEY_SECRET); // 配置 Endpoint config.endpoint = "dysmsapi.aliyuncs.com"; return new Client(config); } } springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/resources/mapper/ComplaintAuditRecordMapper.xml
@@ -2,4 +2,27 @@ <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="com.panzhihua.sangeshenbian.dao.ComplaintAuditRecordMapper"> <select id="getComplaintTimeout" resultType="com.panzhihua.sangeshenbian.model.dto.ComplaintTimeout"> SELECT sc.id complaintId, sc.description_title title, sc.create_by, scar.report_type, scar.superior_id, sc.create_time, sc.closingTime FROM sgsb_complaint_audit_record scar LEFT JOIN sgsb_complaint sc ON scar.complaint_id = sc.id WHERE scar.latest_flag = 1 AND sc.create_time <![CDATA[ < ]]> NOW() - INTERVAL CASE scar.report_type WHEN 1 THEN ${cityDay} WHEN 2 THEN ${districtDay} WHEN 3 THEN ${streetDay} WHEN 4 THEN ${communityDay} WHEN 5 THEN ${partyMemberDay} END DAY </select> </mapper> springcloud_k8s_panzhihuazhihuishequ/zuul/src/main/java/com/panzhihua/zuul/config/SwaggerConfig.java
@@ -29,7 +29,7 @@ private String[] ids = new String[] {"huacheng-appletsbackstage", "huacheng-applets", "huacheng-communitybackstage", "huacheng-shopbackstage", "huacheng-gridbackstage", "huacheng-gridapp","huacheng-union-applets"}; "huacheng-gridbackstage", "huacheng-gridapp","huacheng-union-applets","huacheng-sangeshenbian"}; public SwaggerConfig(RouteLocator routeLocator) { this.routeLocator = routeLocator; springcloud_k8s_panzhihuazhihuishequ/zuul/src/main/java/com/panzhihua/zuul/filters/JWTAuthenticationTokenFilter.java
@@ -212,7 +212,7 @@ String hexStr = AES.parseByte2HexStr(encrypt); safeboxRequestWrapper.addHeader(TokenConstant.TOKEN_USERINFO, hexStr); } } else if(21 == type){ }else if(21 == type){ //三个身边 String key = SecurityConstants.ROLE_USER + "sangeshenbian:" + userId; Boolean aBoolean = stringRedisTemplate.hasKey(key); @@ -253,7 +253,7 @@ safeboxRequestWrapper.addHeader(TokenConstant.TOKEN_USERINFO, hexStr); } }else { } else { String key = SecurityConstants.ROLE_USER + userId; Boolean aBoolean = stringRedisTemplate.hasKey(key); if (aBoolean) { @@ -270,32 +270,34 @@ valueOperations.set(key, JSONArray.toJSONString(authorities), 24, TimeUnit.HOURS); } } } UsernamePasswordAuthenticationToken authentication = new UsernamePasswordAuthenticationToken(userId, userId, authorities);// 主要使用权限 账户 密码 不重要 SecurityContextHolder.getContext().setAuthentication(authentication); safeboxRequestWrapper.addHeader(TokenConstant.TOKEN_LOGOUT, tokenHeader); // 登录用户的所有信息 String userKey = UserConstants.LOGIN_USER_INFO + userId; Boolean hasKeyLoginUserInfo = stringRedisTemplate.hasKey(userKey); if (hasKeyLoginUserInfo) { String userInfo = valueOperations.get(userKey); byte[] encrypt = AES.encrypt(userInfo, Constants.AES_KEY); String hexStr = AES.parseByte2HexStr(encrypt); safeboxRequestWrapper.addHeader(TokenConstant.TOKEN_USERINFO, hexStr); } else { R<LoginUserInfoVO> r = userService.getUserInfoByUserId(userId); if (!R.isOk(r)) { ResultUtil.responseJson(response, R.fail(HttpStatus.ERROR, "登录用户信息查询失败")); return; UsernamePasswordAuthenticationToken authentication = new UsernamePasswordAuthenticationToken(userId, userId, authorities);// 主要使用权限 账户 密码 不重要 SecurityContextHolder.getContext().setAuthentication(authentication); safeboxRequestWrapper.addHeader(TokenConstant.TOKEN_LOGOUT, tokenHeader); // 登录用户的所有信息 String userKey = UserConstants.LOGIN_USER_INFO + userId; Boolean hasKeyLoginUserInfo = stringRedisTemplate.hasKey(userKey); if (hasKeyLoginUserInfo) { String userInfo = valueOperations.get(userKey); byte[] encrypt = AES.encrypt(userInfo, Constants.AES_KEY); String hexStr = AES.parseByte2HexStr(encrypt); safeboxRequestWrapper.addHeader(TokenConstant.TOKEN_USERINFO, hexStr); } else { R<LoginUserInfoVO> r = userService.getUserInfoByUserId(userId); if (!R.isOk(r)) { ResultUtil.responseJson(response, R.fail(HttpStatus.ERROR, "登录用户信息查询失败")); return; } LoginUserInfoVO data = r.getData(); String userInfo = JSONObject.toJSONString(data); valueOperations.set(userKey, userInfo, 24, TimeUnit.HOURS); byte[] encrypt = AES.encrypt(userInfo, Constants.AES_KEY); String hexStr = AES.parseByte2HexStr(encrypt); safeboxRequestWrapper.addHeader(TokenConstant.TOKEN_USERINFO, hexStr); } LoginUserInfoVO data = r.getData(); String userInfo = JSONObject.toJSONString(data); valueOperations.set(userKey, userInfo, 24, TimeUnit.HOURS); byte[] encrypt = AES.encrypt(userInfo, Constants.AES_KEY); String hexStr = AES.parseByte2HexStr(encrypt); safeboxRequestWrapper.addHeader(TokenConstant.TOKEN_USERINFO, hexStr); } } else { // 小程序无需登录也可访问地址列表 List<String> noLoginUrl = new ArrayList<>();