Просмотр исходного кода

1、调整app直播卡片问题处理

yys 2 недель назад
Родитель
Сommit
5cd01c5e8a

+ 11 - 3
fs-ipad-task/src/main/java/com/fs/app/service/IpadSendServer.java

@@ -796,8 +796,14 @@ public class IpadSendServer {
                 case "24":
                 case "24":
                     sendAppShortLink(vo, content, miniMap);
                     sendAppShortLink(vo, content, miniMap);
                     break;
                     break;
+                case "9":
+                    // APP看课链接
+                case "15":
+                    // APP文本
+                case "16":
+                    // APP语音
                 case "25":
                 case "25":
-                    // APP直播卡片走 OpenIM IM 发送,企微侧跳过
+                    // APP直播卡片走 OpenIM IM 发送,企微侧跳过,交给 SendAppMsg
                     content.setSendStatus(0);
                     content.setSendStatus(0);
                     content.setSendRemarks("APP待发送");
                     content.setSendRemarks("APP待发送");
                     break;
                     break;
@@ -1279,8 +1285,10 @@ public class IpadSendServer {
             log.info("不包含app课程:{}, LOGID: {}", qwUser.getQwUserName(), qwSopLogs.getId());
             log.info("不包含app课程:{}, LOGID: {}", qwUser.getQwUserName(), qwSopLogs.getId());
             return false;
             return false;
         }
         }
-        if (qwSopLogs.getSendStatus() != null && qwSopLogs.getSendStatus() != 3L) {
-            log.info("状态异常不发送APP:{}, LOGID: {}, sendStatus: {}", qwUser.getQwUserName(), qwSopLogs.getId(), qwSopLogs.getSendStatus());
+        // 待发送(3) 或 企微侧已发送(1,APP尚未发送):均允许发APP;不放宽到失败(0)/作废(5)
+        Long sendStatus = qwSopLogs.getSendStatus();
+        if (sendStatus == null || (sendStatus != 3L && sendStatus != 1L)) {
+            log.info("状态异常不发送APP:{}, LOGID: {}, sendStatus: {}", qwUser.getQwUserName(), qwSopLogs.getId(), sendStatus);
             return false;
             return false;
         }
         }
         if(redisCache.getCacheObject("qw:user:id:" + qwUser.getId()) != null){
         if(redisCache.getCacheObject("qw:user:id:" + qwUser.getId()) != null){

+ 3 - 1
fs-ipad-task/src/main/java/com/fs/app/task/SendAppMsg.java

@@ -223,7 +223,9 @@ public class SendAppMsg {
         // 循环待发送消息
         // 循环待发送消息
         for (QwSopLogs qwSopLogs : qwSopLogList) {
         for (QwSopLogs qwSopLogs : qwSopLogList) {
             long start2 = System.currentTimeMillis();
             long start2 = System.currentTimeMillis();
-            if (qwSopLogs.getSendStatus() != null && qwSopLogs.getSendStatus() != 3L) {
+            // 与查库条件一致:仅待发送(3)或企微已完成(1)的APP待发记录
+            Long sendStatus = qwSopLogs.getSendStatus();
+            if (sendStatus == null || (sendStatus != 3L && sendStatus != 1L)) {
                 continue;
                 continue;
             }
             }
             QwSopCourseFinishTempSetting setting = JSON.parseObject(qwSopLogs.getContentJson(), QwSopCourseFinishTempSetting.class);
             QwSopCourseFinishTempSetting setting = JSON.parseObject(qwSopLogs.getContentJson(), QwSopCourseFinishTempSetting.class);

+ 20 - 2
fs-ipad-task/src/main/java/com/fs/app/task/SendMsg.java

@@ -207,6 +207,14 @@ public class SendMsg {
                 }
                 }
             }
             }
             log.info("进入发送消息状态:{}", qwSopLogs.getId());
             log.info("进入发送消息状态:{}", qwSopLogs.getId());
+            // APP专属消息类型:由 SendAppMsg 处理,企微侧不占用待发送队列
+            List<String> appTypeList = Arrays.asList("9", "15", "16", "25");
+            boolean hasQwContent = setting.getSetting() != null && setting.getSetting().stream()
+                    .anyMatch(e -> e.getContentType() != null && !appTypeList.contains(e.getContentType()));
+            if (!hasQwContent) {
+                log.info("纯APP消息跳过企微发送,交给SendAppMsg:{}", qwSopLogs.getId());
+                continue;
+            }
             String key = "qw:logs:pad:send:id:" + qwSopLogs.getId();
             String key = "qw:logs:pad:send:id:" + qwSopLogs.getId();
             Long time = redisCache.getCacheObject(key);
             Long time = redisCache.getCacheObject(key);
             // 判断这个消息有没有进入过发送,如果进了就不要再发了,防止重复发送,,,,, TODO 千万不能动!!!!!
             // 判断这个消息有没有进入过发送,如果进了就不要再发了,防止重复发送,,,,, TODO 千万不能动!!!!!
@@ -220,6 +228,12 @@ public class SendMsg {
             // 循环发送消息里面的每一条消息
             // 循环发送消息里面的每一条消息
             for (QwSopCourseFinishTempSetting.Setting content : setting.getSetting()) {
             for (QwSopCourseFinishTempSetting.Setting content : setting.getSetting()) {
                 long start4 = System.currentTimeMillis();
                 long start4 = System.currentTimeMillis();
+                // APP内容不走企微pad发送,仅标记待APP发送
+                if (appTypeList.contains(content.getContentType())) {
+                    content.setSendStatus(0);
+                    content.setSendRemarks("APP待发送");
+                    continue;
+                }
                 //判断当前销售推送客户消息限制
                 //判断当前销售推送客户消息限制
                 Long qwUserId = qwUser.getId();//销售的Id
                 Long qwUserId = qwUser.getId();//销售的Id
                 Integer type = Integer.valueOf(content.getContentType());//发送消息的类型
                 Integer type = Integer.valueOf(content.getContentType());//发送消息的类型
@@ -313,12 +327,16 @@ public class SendMsg {
             updateQwSop.setId(qwSopLogs.getId());updateQwSop.setIsHaveApp(qwSopLogs.getIsHaveApp());
             updateQwSop.setId(qwSopLogs.getId());updateQwSop.setIsHaveApp(qwSopLogs.getIsHaveApp());
             updateQwSop.setAppSendStatus(qwSopLogs.getAppSendStatus());
             updateQwSop.setAppSendStatus(qwSopLogs.getAppSendStatus());
             updateQwSop.setAppSendRemark(qwSopLogs.getAppSendRemark());
             updateQwSop.setAppSendRemark(qwSopLogs.getAppSendRemark());
+            // 企微备注判定排除APP内容,避免APP待发送(status=0)把企微侧「全部失败」误判成「部分失败」
+            List<QwSopCourseFinishTempSetting.Setting> qwSettings = setting.getSetting().stream()
+                    .filter(e -> e.getContentType() != null && !appTypeList.contains(e.getContentType()))
+                    .collect(Collectors.toList());
             // 是否全部发送失败
             // 是否全部发送失败
-            if (setting.getSetting().stream().allMatch(e -> e.getSendStatus() == 2)) {
+            if (!qwSettings.isEmpty() && qwSettings.stream().allMatch(e -> e.getSendStatus() == 2)) {
                 updateQwSop.setReceivingStatus(0L);
                 updateQwSop.setReceivingStatus(0L);
                 updateQwSop.setSendStatus(0L);
                 updateQwSop.setSendStatus(0L);
                 updateQwSop.setRemark("全部发送失败");
                 updateQwSop.setRemark("全部发送失败");
-            } else if (setting.getSetting().stream().anyMatch(e -> e.getSendStatus() == 2)) {
+            } else if (qwSettings.stream().anyMatch(e -> e.getSendStatus() == 2)) {
                 updateQwSop.setReceivingStatus(1L);
                 updateQwSop.setReceivingStatus(1L);
                 updateQwSop.setSendStatus(1L);
                 updateQwSop.setSendStatus(1L);
                 updateQwSop.setRemark("部分发送失败");
                 updateQwSop.setRemark("部分发送失败");

+ 3 - 8
fs-service/src/main/java/com/fs/qw/service/impl/AsyncSopTestService.java

@@ -1,7 +1,6 @@
 package com.fs.qw.service.impl;
 package com.fs.qw.service.impl;
 
 
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.core.util.StrUtil;
-import com.alibaba.fastjson.JSON;
 import com.fasterxml.jackson.core.JsonProcessingException;
 import com.fasterxml.jackson.core.JsonProcessingException;
 import com.fs.common.utils.PubFun;
 import com.fs.common.utils.PubFun;
 import com.fs.common.utils.StringUtils;
 import com.fs.common.utils.StringUtils;
@@ -26,14 +25,12 @@ import com.fs.sop.params.DeleteQwSopParam;
 import com.fs.sop.params.QwSopTagsParam;
 import com.fs.sop.params.QwSopTagsParam;
 import com.fs.sop.params.SopUserLogsList;
 import com.fs.sop.params.SopUserLogsList;
 import com.fs.sop.service.IQwSopLogsService;
 import com.fs.sop.service.IQwSopLogsService;
+import com.fs.sop.service.IQwSopTempVoiceService;
 import com.fs.sop.service.ISopUserLogsService;
 import com.fs.sop.service.ISopUserLogsService;
-import com.fs.sop.vo.VoiceVo;
 import com.fs.voice.utils.StringUtil;
 import com.fs.voice.utils.StringUtil;
 import com.fs.wxUser.param.CompanyWxUserSopParam;
 import com.fs.wxUser.param.CompanyWxUserSopParam;
 import lombok.AllArgsConstructor;
 import lombok.AllArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import lombok.extern.slf4j.Slf4j;
-import org.apache.rocketmq.spring.core.RocketMQTemplate;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.scheduling.annotation.Async;
 import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 
 
@@ -59,7 +56,7 @@ public class AsyncSopTestService {
     private final ISopUserLogsService sopUserLogsService;
     private final ISopUserLogsService sopUserLogsService;
     private final QwExternalContactMapper qwExternalContactMapper;
     private final QwExternalContactMapper qwExternalContactMapper;
     private final QwSopTempMapper qwSopTempMapper;
     private final QwSopTempMapper qwSopTempMapper;
-    private final RocketMQTemplate rocketMQTemplate;
+    private final IQwSopTempVoiceService qwSopTempVoiceService;
     private final SopUserLogsMapper sopUserLogsMapper;
     private final SopUserLogsMapper sopUserLogsMapper;
     private final FsCourseSopAppLinkMapper fsCourseSopAppLinkMapper;
     private final FsCourseSopAppLinkMapper fsCourseSopAppLinkMapper;
     private final uniPush2Service push2Service;
     private final uniPush2Service push2Service;
@@ -244,9 +241,7 @@ public class AsyncSopTestService {
                 ));
                 ));
         List<List<Long>> companyUserIds = PubFun.listToNewList(qwFilterSopCustomersResults.stream().filter(e -> e.getCuCompanyId() != null && e.getCompanyId() != null).collect(Collectors.toList()), e -> Arrays.asList(e.getCuCompanyUserId(), e.getCuCompanyId()));
         List<List<Long>> companyUserIds = PubFun.listToNewList(qwFilterSopCustomersResults.stream().filter(e -> e.getCuCompanyId() != null && e.getCompanyId() != null).collect(Collectors.toList()), e -> Arrays.asList(e.getCuCompanyUserId(), e.getCuCompanyId()));
         try {
         try {
-            rocketMQTemplate.syncSend("voice-generation", JSON.toJSONString(VoiceVo.builder().type(1).id(ruleTimeVO.getId()).build()));
-//            new Thread(() -> HttpUtils.sendGet("http://118.24.209.192:8009/qw/voice/synchronousSop", "sopId=" + ruleTimeVO.getId())).start();
-//            qwSopTempVoiceService.synchronous(ruleTimeVO.getId(), companyUserIds);
+            qwSopTempVoiceService.synchronous(ruleTimeVO.getId(), companyUserIds);
         }catch (Exception e){
         }catch (Exception e){
             log.error("异步同步临时语音失败:",e);
             log.error("异步同步临时语音失败:",e);
         }
         }

+ 31 - 11
fs-service/src/main/java/com/fs/sop/service/impl/QwSopServiceImpl.java

@@ -1,6 +1,5 @@
 package com.fs.sop.service.impl;
 package com.fs.sop.service.impl;
 
 
-import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.fs.common.annotation.DataSource;
 import com.fs.common.annotation.DataSource;
 import com.fs.common.core.domain.R;
 import com.fs.common.core.domain.R;
@@ -36,7 +35,6 @@ import com.fs.sop.params.*;
 import com.fs.sop.service.*;
 import com.fs.sop.service.*;
 import com.fs.sop.vo.QwSopTask;
 import com.fs.sop.vo.QwSopTask;
 import com.fs.sop.vo.SopVoiceListVo;
 import com.fs.sop.vo.SopVoiceListVo;
-import com.fs.sop.vo.VoiceVo;
 import com.fs.store.param.h5.UserStatisticsCommonParam;
 import com.fs.store.param.h5.UserStatisticsCommonParam;
 import com.fs.store.vo.h5.*;
 import com.fs.store.vo.h5.*;
 import com.fs.voice.utils.StringUtil;
 import com.fs.voice.utils.StringUtil;
@@ -44,7 +42,6 @@ import com.fs.wxUser.mapper.CompanyWxUserMapper;
 import com.fs.wxUser.param.CompanyWxUserSopParam;
 import com.fs.wxUser.param.CompanyWxUserSopParam;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageHelper;
 import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.collections4.CollectionUtils;
-import org.apache.rocketmq.spring.core.RocketMQTemplate;
 import org.slf4j.Logger;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.BeanUtils;
@@ -127,9 +124,6 @@ public class QwSopServiceImpl implements IQwSopService
     @Autowired
     @Autowired
     private IQwSopTempRulesService qwSopTempRulesService;
     private IQwSopTempRulesService qwSopTempRulesService;
 
 
-    @Autowired
-    private RocketMQTemplate rocketMQTemplate;
-
     @Autowired
     @Autowired
     private IQwExternalContactService qwExternalContactService;
     private IQwExternalContactService qwExternalContactService;
 
 
@@ -230,7 +224,7 @@ public class QwSopServiceImpl implements IQwSopService
             if (i > 0) {
             if (i > 0) {
 
 
                     try {
                     try {
-                        rocketMQTemplate.syncSend("voice-generation", JSON.toJSONString(VoiceVo.builder().type(1).id(qwSop.getId()).build()));
+                        syncSopTempVoice(qwSop.getId());
                     }catch (Exception e){
                     }catch (Exception e){
                         log.error("修改模板-异步同步临时语音失败:",e);
                         log.error("修改模板-异步同步临时语音失败:",e);
                     }
                     }
@@ -716,9 +710,8 @@ public class QwSopServiceImpl implements IQwSopService
                                     ));
                                     ));
 
 
                             try {
                             try {
-                                rocketMQTemplate.syncSend("voice-generation", JSON.toJSONString(VoiceVo.builder().type(1).id(ruleTimeVO.getId()).build()));
-                                //            new Thread(() -> HttpUtils.sendGet("http://118.24.209.192:8009/qw/voice/synchronousSop", "sopId=" + ruleTimeVO.getId())).start();
-                                //            qwSopTempVoiceService.synchronous(ruleTimeVO.getId(), companyUserIds);
+                                List<List<Long>> companyUserIds = PubFun.listToNewList(qwFilterSopCustomersResults.stream().filter(e -> e.getCuCompanyId() != null && e.getCompanyId() != null).collect(Collectors.toList()), e -> Arrays.asList(e.getCuCompanyUserId(), e.getCuCompanyId()));
+                                qwSopTempVoiceService.synchronous(ruleTimeVO.getId(), companyUserIds);
                             }catch (Exception e){
                             }catch (Exception e){
                                 log.error("异步同步临时语音失败:",e);
                                 log.error("异步同步临时语音失败:",e);
                             }
                             }
@@ -956,7 +949,7 @@ public class QwSopServiceImpl implements IQwSopService
         }
         }
 
 
         try {
         try {
-            rocketMQTemplate.syncSend("voice-generation", JSON.toJSONString(VoiceVo.builder().type(1).id(sop.getId()).build()));
+            syncSopTempVoice(sop.getId());
         }catch (Exception e){
         }catch (Exception e){
             log.error("修改员工-异步同步临时语音失败:",e);
             log.error("修改员工-异步同步临时语音失败:",e);
         }
         }
@@ -1379,4 +1372,31 @@ public class QwSopServiceImpl implements IQwSopService
         return contact;
         return contact;
     }
     }
 
 
+    /**
+     * 无 RocketMQ 时直调同步临时语音
+     */
+    private void syncSopTempVoice(String sopId) {
+        QwSop qwSop = qwSopMapper.selectQwSopById(sopId);
+        if (qwSop == null) {
+            return;
+        }
+        QwSopTagsParam qwSopTagsParam = new QwSopTagsParam();
+        if (!StringUtil.strIsNullOrEmpty(qwSop.getQwUserIds())) {
+            qwSopTagsParam.setUserIdsSelectList(Arrays.asList(qwSop.getQwUserIds().split(",")));
+        }
+        qwSopTagsParam.setFilterType(qwSop.getFilterType());
+        if (!StringUtil.strIsNullOrEmpty(qwSop.getTags())) {
+            qwSopTagsParam.setTagsIdsSelectList(Arrays.asList(qwSop.getTags().split(",")));
+        }
+        if (!StringUtil.strIsNullOrEmpty(qwSop.getExcludeTags())) {
+            qwSopTagsParam.setOutTagsIdsSelectList(Arrays.asList(qwSop.getExcludeTags().split(",")));
+        }
+        qwSopTagsParam.setCropId(qwSop.getCorpId());
+        List<QwFilterSopCustomersResult> results = qwSopMapper.selectFilterQwSopCustomers(qwSopTagsParam);
+        List<List<Long>> companyUserIds = PubFun.listToNewList(
+                results.stream().filter(e -> e.getCuCompanyId() != null && e.getCompanyId() != null).collect(Collectors.toList()),
+                e -> Arrays.asList(e.getCuCompanyUserId(), e.getCuCompanyId()));
+        qwSopTempVoiceService.synchronous(sopId, companyUserIds);
+    }
+
 }
 }

+ 1 - 1
fs-service/src/main/resources/mapper/sop/QwSopLogsMapper.xml

@@ -895,7 +895,7 @@
           AND ql.send_type > 1
           AND ql.send_type > 1
           AND ql.is_have_app = 1
           AND ql.is_have_app = 1
           AND ql.app_send_status = 0
           AND ql.app_send_status = 0
-          AND ql.send_status = 3
+          AND ql.send_status IN (1, 3)
         <![CDATA[
         <![CDATA[
           AND ql.send_time <= now()
           AND ql.send_time <= now()
         ]]>
         ]]>