Ver código fonte

Merge branch 'master' into 跨公司客户接替

Long 1 semana atrás
pai
commit
900814347e

+ 1 - 1
fs-admin/src/main/java/com/fs/qw/controller/QwSopController.java

@@ -52,6 +52,7 @@ public class QwSopController extends BaseController
     private FsUserCourseMapper fsUserCourseMapper;
     @Autowired
     private FsUserCourseVideoMapper fsUserCourseVideoMapper;
+
     /**
      * 查询企微sop列表
      */
@@ -133,7 +134,6 @@ public class QwSopController extends BaseController
         LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
         qwSop.setCreateBy(loginUser.getUser().getNickName());
         qwSop.setCreateTime(sdf.format(new Date()));
-
         return toAjax(qwSopService.insertQwSop(qwSop));
 
     }

+ 85 - 3
fs-company/src/main/java/com/fs/company/controller/qw/QwSopController.java

@@ -1,5 +1,6 @@
 package com.fs.company.controller.qw;
 
+import com.alibaba.fastjson.JSONObject;
 import com.fs.common.annotation.Log;
 import com.fs.common.annotation.RepeatSubmit;
 import com.fs.common.core.controller.BaseController;
@@ -17,21 +18,29 @@ import com.fs.framework.service.TokenService;
 import com.fs.his.vo.OptionsVO;
 import com.fs.qw.domain.QwSopUpdateStatus;
 import com.fs.qw.service.IQwUserService;
+import com.fs.qw.vo.QwUserVO;
 import com.fs.sop.domain.QwSop;
+import com.fs.sop.domain.QwSopTempContent;
+import com.fs.sop.domain.QwSopTempVoice;
 import com.fs.sop.params.QwSopAutoTime;
 import com.fs.sop.params.QwSopEditQwUserParam;
 import com.fs.sop.service.ICompanySopRoleService;
 import com.fs.sop.service.IQwSopService;
+import com.fs.sop.service.IQwSopTempContentService;
+import com.fs.sop.service.IQwSopTempVoiceService;
 import com.fs.sop.vo.SopVoiceListVo;
+import org.apache.commons.beanutils.ConvertUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
 
 import java.io.IOException;
 import java.text.SimpleDateFormat;
+import java.time.LocalDateTime;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
+import java.util.stream.Collectors;
 
 /**
  * 企微sopController
@@ -64,6 +73,13 @@ public class QwSopController extends BaseController
     @Autowired
     private IQwUserService iQwUserService;
 
+
+    @Autowired
+    private IQwSopTempContentService qwSopTempContentService;
+
+    @Autowired
+    private IQwSopTempVoiceService voiceService;
+
     /**
      * 查询企微sop列表
      */
@@ -228,7 +244,12 @@ public class QwSopController extends BaseController
         qwSop.setCompanyId(companyId);
         qwSop.setCreateBy(loginUser.getUser().getNickName());
         qwSop.setCreateTime(sdf.format(new Date()));
-
+        int count = qwSopService.insertQwSop(qwSop);
+        if(count > 0){
+            if(qwSop.getQwUserIds() != null){
+                updateTempVoiceInfo(qwSop);
+            }
+        }
         return toAjax(qwSopService.insertQwSop(qwSop));
 
     }
@@ -241,7 +262,14 @@ public class QwSopController extends BaseController
     @PutMapping
     public R edit(@RequestBody QwSop qwSop)
     {
-        return qwSopService.updateQwSop(qwSop);
+        R sop = qwSopService.updateQwSop(qwSop);
+        String code = sop.get("code").toString();
+        if(code.equals("200")){
+            if(qwSop != null && qwSop.getQwUserIds() != null){
+                updateTempVoiceInfo(qwSop);
+            }
+        }
+        return sop;
     }
 
 
@@ -267,6 +295,52 @@ public class QwSopController extends BaseController
         return toAjax(qwSopService.updateAutoSopTime(param));
     }
 
+    /**
+     * 修改qwSop任务,新增或者删除qwUser
+     * @param qwSop
+     */
+    private void updateTempVoiceInfo(QwSop qwSop) {
+        try {
+            String tempId = qwSop.getTempId();
+            String[] split = qwSop.getQwUserIds().split(",");
+            Long[] qwUserIds = (Long[]) ConvertUtils.convert(split, Long.class);
+
+            List<QwSopTempContent> qwSopTempContentList = qwSopTempContentService.selectQwSopTempContentByTempId(tempId);
+            if(qwSopTempContentList != null && !qwSopTempContentList.isEmpty()){
+                for (QwSopTempContent qwSopTemp : qwSopTempContentList) {
+                    if(qwSopTemp != null && qwSopTemp.getContent() != null){
+                        String content = qwSopTemp.getContent();
+                        JSONObject jsonObject = JSONObject.parseObject(content);
+                        String voiceTxt = jsonObject.getString("value");
+                        String contentType = jsonObject.getString("contentType");
+                        if("7".equals(contentType)){
+                            List<QwUserVO> qwUserVoS = qwUserService.selectQwUserVOByIds(qwUserIds);
+                            if(qwUserVoS != null && !qwUserVoS.isEmpty()){
+                                List<Long> companyUserIdList = qwUserVoS.stream().map(QwUserVO::getCompanyUserId).collect(Collectors.toList());
+                                for (Long companyUserId : companyUserIdList) {
+                                    QwSopTempVoice qwSopTempVoice = voiceService.selectQwSopTempVoiceByCompanyUserIdAndVoiceTxt(companyUserId,voiceTxt);
+                                    if(qwSopTempVoice == null){
+                                        if(companyUserId != null && voiceTxt != null){
+                                            QwSopTempVoice tempVoice = new QwSopTempVoice();
+                                            tempVoice.setVoiceTxt(voiceTxt);
+                                            tempVoice.setCompanyUserId(companyUserId);
+                                            tempVoice.setRecordType(0);
+                                            tempVoice.setCreateTime(LocalDateTime.now());
+                                            tempVoice.setTempId(tempId);
+                                            voiceService.insertQwSopTempVoice(tempVoice);
+                                        }
+                                    }
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        } catch (Exception e) {
+            logger.error("修改企微sop任务,新增或者删除qwUser异常:" + e.getMessage());
+        }
+    }
+
     /**
      * 删除企微sop
      */
@@ -307,7 +381,15 @@ public class QwSopController extends BaseController
     @PreAuthorize("@ss.hasPermi('qw:sop:updateSopQwUser')")
     public R updateSopQwUser(@RequestBody QwSopEditQwUserParam param)
     {
-        return qwSopService.updateSopQwUser(param);
+        R sop = qwSopService.updateSopQwUser(param);
+        String code = sop.get("code").toString();
+        if(code.equals("200")){
+            QwSop qwSop = qwSopService.selectQwSopById(param.getId());
+            if(qwSop != null && qwSop.getQwUserIds() != null){
+                updateTempVoiceInfo(qwSop);
+            }
+        }
+        return sop;
     }
 
     /**

+ 8 - 6
fs-qw-voice/src/main/java/com/fs/app/mq/RocketMQConsumerService.java

@@ -77,12 +77,14 @@ public class RocketMQConsumerService implements RocketMQListener<String> {
                                             Long companyUserId = qwUserVO.getCompanyUserId();
                                             QwSopTempVoice qwSopTempVoice = qwSopTempVoiceService.selectQwSopTempVoiceByCompanyUserIdAndVoiceTxt(companyUserId,text);
                                             if(qwSopTempVoice == null){
-                                                QwSopTempVoice sopTempVoice = new QwSopTempVoice();
-                                                sopTempVoice.setCompanyUserId(companyUserId);
-                                                sopTempVoice.setVoiceTxt(text);
-                                                sopTempVoice.setTempId(tempId);
-                                                sopTempVoice.setRecordType(0);
-                                                qwSopTempVoiceService.insertQwSopTempVoice(sopTempVoice);
+                                                if(companyUserId != null && text != null){
+                                                    QwSopTempVoice sopTempVoice = new QwSopTempVoice();
+                                                    sopTempVoice.setCompanyUserId(companyUserId);
+                                                    sopTempVoice.setVoiceTxt(text);
+                                                    sopTempVoice.setTempId(tempId);
+                                                    sopTempVoice.setRecordType(0);
+                                                    qwSopTempVoiceService.insertQwSopTempVoice(sopTempVoice);
+                                                }
                                             }
                                         }
                                     }

+ 7 - 5
fs-service/src/main/java/com/fs/qw/service/AsyncQwAiChatSopService.java

@@ -317,11 +317,13 @@ public class AsyncQwAiChatSopService {
             setting.setVoiceUrl(qwSopTempVoice.getVoiceUrl());
             setting.setVoiceDuration(String.valueOf(qwSopTempVoice.getDuration()));
         } else if (qwSopTempVoice == null) {
-            qwSopTempVoice = new QwSopTempVoice();
-            qwSopTempVoice.setCompanyUserId(companyUserId);
-            qwSopTempVoice.setVoiceTxt(setting.getValue());
-            qwSopTempVoice.setRecordType(0);
-            sopTempVoiceService.insertQwSopTempVoice(qwSopTempVoice);
+            if(companyUserId != null && setting.getValue() != null){
+                qwSopTempVoice = new QwSopTempVoice();
+                qwSopTempVoice.setCompanyUserId(companyUserId);
+                qwSopTempVoice.setVoiceTxt(setting.getValue());
+                qwSopTempVoice.setRecordType(0);
+                sopTempVoiceService.insertQwSopTempVoice(qwSopTempVoice);
+            }
         }
     }
 

+ 17 - 9
fs-service/src/main/java/com/fs/qw/service/impl/QwExternalContactServiceImpl.java

@@ -2175,19 +2175,27 @@ public class QwExternalContactServiceImpl extends ServiceImpl<QwExternalContactM
 
     @Override
     public QwUser getQwUserByRedisForId(String qwUserId) {
-        String key =(String)redisCache.getCacheObject("qwUserRdById:"+qwUserId);
-        if (ObjectUtils.isNotEmpty(key)&& !StringUtil.strIsNullOrEmpty(key)){
-            return JSON.parseObject(key, QwUser.class);
-        }
-        logger.error("qwUserId:{}",qwUserId);
-        if (ObjectUtils.isEmpty(qwUserId)||qwUserId.equals("null")){
-            return null;
+
+        String redisKey = "qwUserRdById:" + qwUserId;
+
+        // 直接从Redis获取JSON字符串
+        String cachedJson = (String) redisCache.getCacheObject(redisKey);
+        if (!StringUtil.strIsNullOrEmpty(cachedJson)) {
+            try {
+                return JSON.parseObject(cachedJson, QwUser.class);
+            } catch (Exception e) {
+                // 解析失败时删除缓存,重新查询
+                redisCache.deleteObject(redisKey);
+            }
         }
+
         QwUser qwUser = qwUserMapper.selectQwUserById(Long.valueOf(qwUserId));
-        if (qwUser==null){
+        if (qwUser == null) {
             return null;
         }
-        redisCache.setCacheObject("qwUserRdById:"+qwUser.getId() ,JSON.toJSONString(qwUser),1, TimeUnit.HOURS);
+
+        // 存储时确保是JSON字符串
+        redisCache.setCacheObject(redisKey, JSON.toJSONString(qwUser), 1, TimeUnit.HOURS);
         return qwUser;
     }
     ;

+ 8 - 6
fs-service/src/main/java/com/fs/sop/service/impl/QwSopTempServiceImpl.java

@@ -260,12 +260,14 @@ public class QwSopTempServiceImpl implements IQwSopTempService
                                                 Long companyUserId = qwUserVO.getCompanyUserId();
                                                 QwSopTempVoice qwSopTempVoice = qwSopTempVoiceService.selectQwSopTempVoiceByCompanyUserIdAndVoiceTxt(companyUserId,text);
                                                 if(qwSopTempVoice == null){
-                                                    QwSopTempVoice sopTempVoice = new QwSopTempVoice();
-                                                    sopTempVoice.setCompanyUserId(companyUserId);
-                                                    sopTempVoice.setVoiceTxt(text);
-                                                    sopTempVoice.setTempId(tempId);
-                                                    sopTempVoice.setRecordType(0);
-                                                    qwSopTempVoiceService.insertQwSopTempVoice(sopTempVoice);
+                                                    if(companyUserId != null && text != null){
+                                                        QwSopTempVoice sopTempVoice = new QwSopTempVoice();
+                                                        sopTempVoice.setCompanyUserId(companyUserId);
+                                                        sopTempVoice.setVoiceTxt(text);
+                                                        sopTempVoice.setTempId(tempId);
+                                                        sopTempVoice.setRecordType(0);
+                                                        qwSopTempVoiceService.insertQwSopTempVoice(sopTempVoice);
+                                                    }
                                                 }
                                             }
                                         }

+ 7 - 5
fs-service/src/main/java/com/fs/sop/service/impl/SopUserLogsInfoServiceImpl.java

@@ -971,11 +971,13 @@ public class SopUserLogsInfoServiceImpl implements ISopUserLogsInfoService {
             st.setVoiceUrl(qwSopTempVoice.getVoiceUrl());
             st.setVoiceDuration(String.valueOf(qwSopTempVoice.getDuration()));
         } else if (qwSopTempVoice == null) {
-            qwSopTempVoice = new QwSopTempVoice();
-            qwSopTempVoice.setCompanyUserId(Long.valueOf(companyUserId));
-            qwSopTempVoice.setVoiceTxt(st.getValue());
-            qwSopTempVoice.setRecordType(0);
-            sopTempVoiceService.insertQwSopTempVoice(qwSopTempVoice);
+            if(st.getValue() != null){
+                qwSopTempVoice = new QwSopTempVoice();
+                qwSopTempVoice.setCompanyUserId(Long.valueOf(companyUserId));
+                qwSopTempVoice.setVoiceTxt(st.getValue());
+                qwSopTempVoice.setRecordType(0);
+                sopTempVoiceService.insertQwSopTempVoice(qwSopTempVoice);
+            }
         }
     }
 

+ 159 - 0
fs-service/src/main/resources/application-druid-cqtyt-test.yml

@@ -0,0 +1,159 @@
+# 数据源配置
+spring:
+    profiles:
+        include: config-druid-cqtyt,common
+    # redis 配置
+    redis:
+        # 地址
+        host: 127.0.0.1
+        # 端口,默认为6379
+        port: 6379
+        # 数据库索引
+        database: 0
+        # 密码
+#        password: Ylrz_c123232014^$
+        # 连接超时时间
+        timeout: 20s
+        lettuce:
+            pool:
+                # 连接池中的最小空闲连接
+                min-idle: 0
+                # 连接池中的最大空闲连接
+                max-idle: 8
+                # 连接池的最大数据库连接数
+                max-active: 8
+                # #连接池最大阻塞等待时间(使用负值表示没有限制)
+                max-wait: -1ms
+    datasource:
+        #        clickhouse:
+        #            type: com.alibaba.druid.pool.DruidDataSource
+        #            driverClassName: com.clickhouse.jdbc.ClickHouseDriver
+        #            url: jdbc:clickhouse://cc-2vc8zzo26w0l7m2l6.public.clickhouse.ads.aliyuncs.com/sop?compress=0&use_server_time_zone=true&use_client_time_zone=false&timezone=Asia/Shanghai
+        #            username: rt_2024
+        #            password: Yzx_19860213
+        #            initialSize: 10
+        #            maxActive: 100
+        #            minIdle: 10
+        #            maxWait: 6000
+        mysql:
+            type: com.alibaba.druid.pool.DruidDataSource
+            driverClassName: com.mysql.cj.jdbc.Driver
+            druid:
+                # 主库数据源
+                master:
+                    url: jdbc:mysql://182.92.245.10:2345/fs_his?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
+                    username: tat_root01
+                    password: Ylrz_c123232014^$
+                # 从库数据源
+                slave:
+                    # 从数据源开关/默认关闭
+                    enabled: false
+                    url:
+                    username:
+                    password:
+                # 初始连接数
+                initialSize: 5
+                # 最小连接池数量
+                minIdle: 10
+                # 最大连接池数量
+                maxActive: 20
+                # 配置获取连接等待超时的时间
+                maxWait: 60000
+                # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
+                timeBetweenEvictionRunsMillis: 60000
+                # 配置一个连接在池中最小生存的时间,单位是毫秒
+                minEvictableIdleTimeMillis: 300000
+                # 配置一个连接在池中最大生存的时间,单位是毫秒
+                maxEvictableIdleTimeMillis: 900000
+                # 配置检测连接是否有效
+                validationQuery: SELECT 1 FROM DUAL
+                testWhileIdle: true
+                testOnBorrow: false
+                testOnReturn: false
+                webStatFilter:
+                    enabled: true
+                statViewServlet:
+                    enabled: true
+                    # 设置白名单,不填则允许所有访问
+                    allow:
+                    url-pattern: /druid/*
+                    # 控制台管理用户名和密码
+                    login-username: fs
+                    login-password: 123456
+                filter:
+                    stat:
+                        enabled: true
+                        # 慢SQL记录
+                        log-slow-sql: true
+                        slow-sql-millis: 1000
+                        merge-sql: true
+                    wall:
+                        config:
+                            multi-statement-allow: true
+        sop:
+            type: com.alibaba.druid.pool.DruidDataSource
+            driverClassName: com.mysql.cj.jdbc.Driver
+            druid:
+                # 主库数据源
+                master:
+                    url: jdbc:mysql://182.92.245.10:2345/fs_his_sop?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
+                    username: tat_root01
+                    password: Ylrz_c123232014^$
+                read:
+                    url: jdbc:mysql://182.92.245.10:2345/fs_his_sop?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
+                    username: tat_root01
+                    password: Ylrz_c123232014^$
+                # 初始连接数
+                initialSize: 5
+                # 最小连接池数量
+                minIdle: 10
+                # 最大连接池数量
+                maxActive: 20
+                # 配置获取连接等待超时的时间
+                maxWait: 60000
+                # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
+                timeBetweenEvictionRunsMillis: 60000
+                # 配置一个连接在池中最小生存的时间,单位是毫秒
+                minEvictableIdleTimeMillis: 300000
+                # 配置一个连接在池中最大生存的时间,单位是毫秒
+                maxEvictableIdleTimeMillis: 900000
+                # 配置检测连接是否有效
+                validationQuery: SELECT 1 FROM DUAL
+                testWhileIdle: true
+                testOnBorrow: false
+                testOnReturn: false
+                webStatFilter:
+                    enabled: true
+                statViewServlet:
+                    enabled: true
+                    # 设置白名单,不填则允许所有访问
+                    allow:
+                    url-pattern: /druid/*
+                    # 控制台管理用户名和密码
+                    login-username: fs
+                    login-password: 123456
+                filter:
+                    stat:
+                        enabled: true
+                        # 慢SQL记录
+                        log-slow-sql: true
+                        slow-sql-millis: 1000
+                        merge-sql: true
+                    wall:
+                        config:
+                            multi-statement-allow: true
+rocketmq:
+    name-server: rmq-1243b25nj.rocketmq.gz.public.tencenttdmq.com:8080 # RocketMQ NameServer 地址
+    producer:
+        group: my-producer-group
+        access-key: ak1243b25nj17d4b2dc1a03 # 替换为实际的 accessKey
+        secret-key: sk08a7ea1f9f4b0237 # 替换为实际的 secretKey
+    consumer:
+        group: test-group
+        access-key: ak1243b25nj17d4b2dc1a03 # 替换为实际的 accessKey
+        secret-key: sk08a7ea1f9f4b0237 # 替换为实际的 secretKey
+openIM:
+    secret: openIM123
+    userID: imAdmin
+#是否为新商户,新商户不走mpOpenId
+isNewWxMerchant: true