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> list = noAurhScopeMapper.selectMaps(query); return list.stream().map(map -> { UnreadMessageVO unreadMessageVO = Func.toBean(map, UnreadMessageVO.class); unreadMessageVO.setBusinessName(DictCache.getValue("businessClassify", unreadMessageVO.getBusinessClassify()));