fix:消息重复发送

This commit is contained in:
xiang
2025-12-18 19:21:42 +08:00
parent f3637a80f2
commit 5b9ac21ecf
2 changed files with 20 additions and 4 deletions

View File

@@ -9,4 +9,7 @@ public class RedisKeyConstant {
public static final String JNTYZX_ORDER_CREATE_KEY = "jntyzx:order:create:orderId:";
public static final String JNTUZX_ORDER_PEEK_KEY = "jntyzx:order:peek:user:";
public static final String JNTYZX_VENUE_MSG_628_KEY = "jntyzx:venue:msg:628";
public static final String JNTYZX_VENUE_MSG_8210_KEY = "jntyzx:venue:msg:8210";
}

View File

@@ -1,6 +1,8 @@
package com.xiang.xservice.application.script.jntyzx.schedule;
import com.google.common.collect.Maps;
import com.xiang.xmc.service.cache.service.IRedisService;
import com.xiang.xservice.application.script.jntyzx.constants.RedisKeyConstant;
import com.xiang.xservice.application.script.jntyzx.entity.pojo.VenueInfoDO;
import com.xiang.xservice.application.script.jntyzx.entity.resp.query.SitePositionList;
import com.xiang.xservice.application.script.jntyzx.service.DingTalkScriptVenueService;
@@ -15,10 +17,12 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.time.LocalTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.TimeUnit;
/**
* @Author: xiang
@@ -32,6 +36,7 @@ public class VenueQuerySchedule {
private final IVenueService venueService;
private final DingTalkScriptVenueService dingTalkScriptVenueService;
private final ISysConfigService sysConfigService;
private final IRedisService redisService;
@Scheduled(cron = "0 30 8 * * ?")
public void venueQueryTask() {
@@ -61,12 +66,20 @@ public class VenueQuerySchedule {
if (MapUtils.isNotEmpty(map1)) {
StringBuffer sb1 = new StringBuffer("查询江体小程序场地信息【18:00-20:00】\n");
buildMsg2(map1, sb1);
dingTalkScriptVenueService.sendScriptMsg(sb1.toString());
String s = (String) redisService.get(RedisKeyConstant.JNTYZX_VENUE_MSG_628_KEY);
if (StringUtils.isBlank(s)) {
dingTalkScriptVenueService.sendScriptMsg(sb1.toString());
redisService.set(RedisKeyConstant.JNTYZX_VENUE_MSG_628_KEY, "true", 30, TimeUnit.MINUTES);
}
}
if (MapUtils.isNotEmpty(map2)) {
StringBuffer sb2 = new StringBuffer("查询江体小程序场地信息【20:00-22:00】\n");
buildMsg2(map2, sb2);
dingTalkScriptVenueService.sendScriptMsg(sb2.toString());
String s = (String) redisService.get(RedisKeyConstant.JNTYZX_VENUE_MSG_8210_KEY);
if (StringUtils.isBlank(s)) {
dingTalkScriptVenueService.sendScriptMsg(sb2.toString());
redisService.set(RedisKeyConstant.JNTYZX_VENUE_MSG_8210_KEY, "true", 30, TimeUnit.MINUTES);
}
}
}
@@ -176,12 +189,12 @@ public class VenueQuerySchedule {
putIntoMap(item, map2);
}
});
if (MapUtils.isNotEmpty(map1)) {
if (MapUtils.isNotEmpty(map1) && LocalTime.now().isBefore(LocalTime.of(18, 0, 0))) {
StringBuffer sb1 = new StringBuffer("查询江体小程序场地信息【18:00-20:00】\n");
buildMsg(map1, sb1);
dingTalkScriptVenueService.sendScriptMsg(sb1.toString());
}
if (MapUtils.isNotEmpty(map1)) {
if (MapUtils.isNotEmpty(map2) && LocalTime.now().isBefore(LocalTime.of(20, 0, 0))) {
StringBuffer sb2 = new StringBuffer("查询江体小程序场地信息【20:00-22:00】\n");
buildMsg(map2, sb2);
dingTalkScriptVenueService.sendScriptMsg(sb2.toString());