From 8fb7d5f5803763a133f03b789e95f0a799a20bff Mon Sep 17 00:00:00 2001
From: haungxing <1203316822@qq.com>
Date: Fri, 14 Apr 2023 11:11:23 +0800
Subject: [PATCH] =?UTF-8?q?#=20=E6=B6=88=E6=81=AF=E6=8E=A8=E9=80=81?=
=?UTF-8?q?=E8=8E=B7=E5=8F=96=E6=9C=AA=E8=AF=BB=E6=B6=88=E6=81=AFbug?=
=?UTF-8?q?=E5=A4=84=E7=90=86?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
hzims-service/message/pom.xml | 28 +---------------------
.../hnac/hzims/message/config/MessageStrategy.java | 24 +++++++++++++++++++
.../hnac/hzims/message/fegin/MessageClient.java | 13 +++++++---
.../hzims/message/mapper/MprNoAurhScopeMapper.java | 12 ++++++++++
.../message/schedule/MessagePushSchedule.java | 4 +++-
.../service/impl/MessagePushRecordServiceImpl.java | 5 +++-
6 files changed, 54 insertions(+), 32 deletions(-)
create mode 100644 hzims-service/message/src/main/java/com/hnac/hzims/message/config/MessageStrategy.java
create mode 100644 hzims-service/message/src/main/java/com/hnac/hzims/message/mapper/MprNoAurhScopeMapper.java
diff --git a/hzims-service/message/pom.xml b/hzims-service/message/pom.xml
index 7e4c91f..5e66ba4 100644
--- a/hzims-service/message/pom.xml
+++ b/hzims-service/message/pom.xml
@@ -21,37 +21,11 @@
blade-core-boot
- org.springblade
- blade-starter-redis
-
-
-
-
-
-
- org.springblade
- blade-starter-redis
-
-
- org.springframework.boot
- spring-boot-starter-data-redis
-
-
-
-
-
-
- org.springframework.boot
- spring-boot-starter-data-redis
-
-
- io.lettuce
lettuce-core
+ io.lettuce
-
-
org.springblade
blade-core-cloud
diff --git a/hzims-service/message/src/main/java/com/hnac/hzims/message/config/MessageStrategy.java b/hzims-service/message/src/main/java/com/hnac/hzims/message/config/MessageStrategy.java
new file mode 100644
index 0000000..5e258fc
--- /dev/null
+++ b/hzims-service/message/src/main/java/com/hnac/hzims/message/config/MessageStrategy.java
@@ -0,0 +1,24 @@
+package com.hnac.hzims.message.config;
+
+import lombok.Data;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.cloud.context.config.annotation.RefreshScope;
+import org.springframework.stereotype.Component;
+
+/**
+ * @ClassName MessageStrategy
+ * @description:
+ * @author: hx
+ * @create: 2023-04-14 10:27
+ * @Version 4.0
+ **/
+@Data
+@Component
+@ConfigurationProperties("hzims.push-strategy")
+public class MessageStrategy {
+
+ private Integer concentrateDuration;
+
+ private String concentrateUnit;
+
+}
diff --git a/hzims-service/message/src/main/java/com/hnac/hzims/message/fegin/MessageClient.java b/hzims-service/message/src/main/java/com/hnac/hzims/message/fegin/MessageClient.java
index 6c3894f..7537a48 100644
--- a/hzims-service/message/src/main/java/com/hnac/hzims/message/fegin/MessageClient.java
+++ b/hzims-service/message/src/main/java/com/hnac/hzims/message/fegin/MessageClient.java
@@ -7,8 +7,10 @@ import com.hnac.hzims.message.dto.MessagePushRecordDto;
import com.hnac.hzims.message.dto.PushDto;
import com.hnac.hzims.message.dto.SmsPushDto;
import com.hnac.hzims.message.entity.MessagePushRecordEntity;
+import com.hnac.hzims.message.entity.config.MessageTemplateEntity;
import com.hnac.hzims.message.service.IMessagePushRecordService;
import com.hnac.hzims.message.service.IMessageService;
+import com.hnac.hzims.message.service.IMessageTemplateService;
import com.hnac.hzims.message.service.impl.SmsMessageServiceImpl;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@@ -16,9 +18,7 @@ import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.BeanUtil;
import org.springblade.core.tool.utils.SpringUtil;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
@@ -31,6 +31,7 @@ import javax.validation.Valid;
public class MessageClient extends BladeController implements IMessageClient{
private final IMessagePushRecordService recordService;
+ private final IMessageTemplateService messageTemplateService;
@Override
@PostMapping(SEND_SMS_MESSAGE)
@@ -53,4 +54,10 @@ public class MessageClient extends BladeController implements IMessageClient{
return R.success("推送成功!");
}
+ @GetMapping(GET_TEMPLATE_BY_ID)
+ @Override
+ public R getMsgTemplateById(@RequestParam Long id) {
+ return R.data(messageTemplateService.getById(id));
+ }
+
}
diff --git a/hzims-service/message/src/main/java/com/hnac/hzims/message/mapper/MprNoAurhScopeMapper.java b/hzims-service/message/src/main/java/com/hnac/hzims/message/mapper/MprNoAurhScopeMapper.java
new file mode 100644
index 0000000..e491ee6
--- /dev/null
+++ b/hzims-service/message/src/main/java/com/hnac/hzims/message/mapper/MprNoAurhScopeMapper.java
@@ -0,0 +1,12 @@
+package com.hnac.hzims.message.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.hnac.hzims.message.entity.MessagePushRecordEntity;
+
+/**
+ * @author hx
+ * @description 消息记录-无数据权限mapper
+ */
+public interface MprNoAurhScopeMapper extends BaseMapper {
+
+}
diff --git a/hzims-service/message/src/main/java/com/hnac/hzims/message/schedule/MessagePushSchedule.java b/hzims-service/message/src/main/java/com/hnac/hzims/message/schedule/MessagePushSchedule.java
index 34efb6e..953f3b3 100644
--- a/hzims-service/message/src/main/java/com/hnac/hzims/message/schedule/MessagePushSchedule.java
+++ b/hzims-service/message/src/main/java/com/hnac/hzims/message/schedule/MessagePushSchedule.java
@@ -9,6 +9,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.hnac.hzims.common.utils.DateUtil;
import com.hnac.hzims.message.MessageConstants;
import com.hnac.hzims.message.config.MessageFactory;
+import com.hnac.hzims.message.config.MessageStrategy;
import com.hnac.hzims.message.entity.MessagePushRecordEntity;
import com.hnac.hzims.message.entity.config.MessageTemplateEntity;
import com.hnac.hzims.message.service.IMessagePushRecordService;
@@ -45,6 +46,7 @@ import static com.hnac.hzims.message.constants.XxlJobConstants.PUSH_SMS_MESSAGE_
public class MessagePushSchedule {
private final IMessageTemplateService templateService;
private final IMessagePushRecordService recordService;
+ private final MessageStrategy messageStrategy;
@XxlJob(PUSH_MESSAGE_BY_NOTICE)
public ReturnT pushSmsMessageByNotice(String params) {
@@ -52,7 +54,7 @@ public class MessagePushSchedule {
List templateList = templateService.list();
LocalDateTime now = LocalDateTime.now();
templateList.forEach(template -> {
- LocalDateTime endTime = DateUtil.plus(LocalDateTime.now(), template.getConcentratedDuration(), template.getConcentratedTimeUnit());
+ LocalDateTime endTime = DateUtil.plus(LocalDateTime.now(), messageStrategy.getConcentrateDuration(), messageStrategy.getConcentrateUnit());
endTime = DateUtil.plus(endTime, template.getAdvanceDuration(), template.getAdvanceTimeUnit());
LambdaQueryWrapper lqw = Wrappers.lambdaQuery()
.eq(MessagePushRecordEntity::getStatus, MessageConstants.NOT_PUSH)
diff --git a/hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/MessagePushRecordServiceImpl.java b/hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/MessagePushRecordServiceImpl.java
index b18aefd..ae77d04 100644
--- a/hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/MessagePushRecordServiceImpl.java
+++ b/hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/MessagePushRecordServiceImpl.java
@@ -16,6 +16,7 @@ import com.hnac.hzims.message.config.MessageFactory;
import com.hnac.hzims.message.entity.MessagePushRecordEntity;
import com.hnac.hzims.message.enums.PushStatEnum;
import com.hnac.hzims.message.mapper.MessagePushRecordMapper;
+import com.hnac.hzims.message.mapper.MprNoAurhScopeMapper;
import com.hnac.hzims.message.service.IMessagePushRecordService;
import com.hnac.hzims.message.service.IMessageService;
import com.hnac.hzims.message.vo.UnreadMessageVO;
@@ -50,6 +51,8 @@ import java.util.stream.Collectors;
@Slf4j
public class MessagePushRecordServiceImpl extends BaseServiceImpl implements IMessagePushRecordService {
+ private final MprNoAurhScopeMapper noAurhScopeMapper;
+
@Override
public List list(MessagePushRecordEntity request) {
return this.list(this.getQueryWrapper(request));
@@ -291,7 +294,7 @@ public class MessagePushRecordServiceImpl extends BaseServiceImpl> list = this.listMaps(query);
+ List