Browse Source

状态未变更,发送消息

yh 3 weeks ago
parent
commit
4378bbe3f3

+ 9 - 3
fs-service/src/main/java/com/fs/erp/service/impl/DfOrderServiceImpl.java

@@ -944,6 +944,12 @@ public class DfOrderServiceImpl implements IErpOrderService {
                                             redisCache.setCacheObject(todayRedisKey, "1", (int) secondsUntilTomorrow, java.util.concurrent.TimeUnit.SECONDS);
                                             log.info("设置今天Redis发送标识 - orderId: {}, todayRedisKey: {}, 过期时间(秒): {}", orderId, todayRedisKey, secondsUntilTomorrow);
 
+                                            // 设置今天变更已发送的标识
+                                            String isSendKey = "ai:express:isSend:" + orderId + ":" + todayDate;
+                                            if (isStateChanged){
+                                                redisCache.setCacheObject(isSendKey, "1", (int) secondsUntilTomorrow, java.util.concurrent.TimeUnit.SECONDS);
+                                            }
+
                                             // 设置已签收的发送标识
                                             if ("301".equals(stateEx)){
                                                 redisCache.sAdd(signedKey, orderId.toString());
@@ -1279,8 +1285,8 @@ public class DfOrderServiceImpl implements IErpOrderService {
         // 4. 检查Redis中是否今天已经发送过
         String todayDate = cn.hutool.core.date.DateUtil.today();
         String todayRedisKey = "ai:express:sent:" + orderId + ":" + todayDate;
-
-        Object sentValue = redisCache.getCacheObject(todayRedisKey);
+        String isSendKey = "ai:express:isSend:" + orderId + ":" + todayDate;
+        Object sentValue = redisCache.getCacheObject(isSendKey);
 
         log.info("Redis发送检查 - orderId: {}, todayDate: {}, todayRedisKey: {}, 今天是否已发送: {}",
                 orderId, todayDate, todayRedisKey, sentValue != null);
@@ -1291,7 +1297,7 @@ public class DfOrderServiceImpl implements IErpOrderService {
             return;
         } else {
             // 状态没有变化,检查今天是否已发送过发货信息
-            if (sentValue != null && ("0".equals(stateEx) || "1".equals(stateEx) || "2".equals(stateEx))) {
+            if (sentValue != null) {
                 log.info("物流状态未变化且今天已发送过,跳过AI消息发送 - orderId: {}", orderId);
                 return;
             } else {