Jelajahi Sumber

固定营期

三七 5 hari lalu
induk
melakukan
a41387bc1e

+ 56 - 32
fs-service/src/main/java/com/fs/qw/service/impl/QwExternalContactServiceImpl.java

@@ -191,9 +191,6 @@ public class QwExternalContactServiceImpl extends ServiceImpl<QwExternalContactM
     @Autowired
     private QwTagMapper qwTagMapper;
 
-    @Autowired
-    private QwExternalContactServiceImpl qwExternalContactService;
-
 
     org.slf4j.Logger logger = LoggerFactory.getLogger(getClass());
 
@@ -417,7 +414,7 @@ public class QwExternalContactServiceImpl extends ServiceImpl<QwExternalContactM
 
             // 获取组公共信息(每组只需查一次)
             QwExternalContact sample = group.get(0);
-            QwUser qwUser = qwExternalContactService.getQwUserByRedis(sample.getCorpId(), sample.getUserId());
+            QwUser qwUser = this.getQwUserByRedis(sample.getCorpId(), sample.getUserId());
             if (qwUser == null) {
                 logger.error("无企微员工信息: {}|{}", sample.getUserId(), sample.getCorpId());
                 return;
@@ -3248,8 +3245,18 @@ public class QwExternalContactServiceImpl extends ServiceImpl<QwExternalContactM
             if (i == 1) {
                 return;
             }
-            // 判断 SOP 任务的开始时间
-            qwSopRuleTimeToolsCheck(sopStartLocalDate,currentDate,dateFormatter,userLogs,logsInfo,userLogsParamByDate,qwAutoSopTimeParam,timeFormatter,localTime);
+
+            if (Integer.valueOf(1).equals(ruleTimeVO.getIsFixed())){
+
+                qwSopRuleTimeToolsCheckByIsFixed(sopStartLocalDate,dateFormatter,userLogs,logsInfo,userLogsParamByDate);
+
+            }else {
+                // 判断 SOP 任务的开始时间
+                qwSopRuleTimeToolsCheck(sopStartLocalDate,currentDate,dateFormatter,userLogs,logsInfo,userLogsParamByDate,qwAutoSopTimeParam,timeFormatter,localTime);
+
+            }
+
+
         });
     }
 
@@ -3859,8 +3866,17 @@ public class QwExternalContactServiceImpl extends ServiceImpl<QwExternalContactM
                             logsInfo.setExternalUserName(qwExternalContact.getName());
                             logsInfo.setSopId(ruleTimeVO.getId());
 
-                            //检查营期
-                            qwSopRuleTimeToolsCheck(sopStartLocalDate,currentDate,dateFormatter,userLogs,logsInfo,userLogsParamByDate,qwAutoSopTimeParam,timeFormatter,localTime);
+
+                            //如果是固定营期
+                            if (Integer.valueOf(1).equals(ruleTimeVO.getIsFixed())){
+
+                                qwSopRuleTimeToolsCheckByIsFixed(sopStartLocalDate,dateFormatter,userLogs,logsInfo,userLogsParamByDate);
+
+                            }else {
+                                //检查营期
+                                qwSopRuleTimeToolsCheck(sopStartLocalDate,currentDate,dateFormatter,userLogs,logsInfo,userLogsParamByDate,qwAutoSopTimeParam,timeFormatter,localTime);
+                            }
+
 
                         }
 
@@ -3875,30 +3891,6 @@ public class QwExternalContactServiceImpl extends ServiceImpl<QwExternalContactM
                         });
                     }
 
-//                    if (!runRuleTime.isEmpty() && !qwSopRuleTimeVOS.isEmpty()){
-//
-//                        //剔除掉 销售的其他任务里的,这个人的信息ps:可能没有
-//                        Set<String> qwSopRuleTimeVOIds = qwSopRuleTimeVOS.stream()
-//                                .map(QwSopRuleTimeVO::getId)
-//                                .filter(Objects::nonNull)       // 过滤掉 null
-//                                .map(String::trim)              // 去除前后空格
-//                                .collect(Collectors.toSet());
-//
-//                        if (!qwSopRuleTimeVOIds.isEmpty()){
-//
-//                            //在 qwSopRuleTimeVOS 中过滤掉包含在 runRuleTimeIds 中的 id
-//                            List<QwSopRuleTimeVO> notOverlapList = runRuleTime.stream()
-//                                    .filter(item -> item.getId() != null &&!qwSopRuleTimeVOIds.contains(item.getId().trim()))
-//                                    .collect(Collectors.toList());
-//
-//                            notOverlapList.forEach(notSop->{
-//                                logger.info("删除这个客户在这个销售的其他不符合的sop"+notSop.getId()+"标签:"+tagArr+"id:"+qwExternalContact.getQwUserId()+"排除的标签:"+qwSopRuleTimeVOIds);
-//
-//                                deleteBySopIdToContactIdTools(notSop.getId(),qwExternalContact.getUserId(),qwExternalContact.getCorpId(),qwExternalContact.getId());
-//
-//                            });
-//                        }
-//                    }
                 }else {
                     //没匹配上任意一个(即这个剩下的标签匹配不上任意的sop),但是销售有任务-以防万一-删除这个客户在这个销售的sop
                     if (!runRuleTime.isEmpty()){
@@ -3918,6 +3910,38 @@ public class QwExternalContactServiceImpl extends ServiceImpl<QwExternalContactM
 
     };
 
+
+    //固定营期  以 SOP 任务的开始时间为营期
+    private void qwSopRuleTimeToolsCheckByIsFixed(LocalDate sopStartLocalDate,DateTimeFormatter dateFormatter,
+                                                  SopUserLogs userLogs,SopUserLogsInfo logsInfo,
+                                                  SopUserLogsParamByDate userLogsParamByDate){
+
+        String sopStartLocalDateStr = sopStartLocalDate.format(dateFormatter);
+
+        userLogs.setStartTime(sopStartLocalDateStr);
+        // 查询开始时间营期表
+        String unionSopStartId = sopUserLogsService.selectSopUserLogsByUnionSopId(userLogs);
+
+        // 如果营期表里有,则加入;否则创建新营期
+        if (!StringUtil.strIsNullOrEmpty(unionSopStartId)) {
+            logsInfo.setUserLogsId(unionSopStartId);
+            // 查询这个人是否已在该营期里
+            handleInsertSopUserLogsInfo(logsInfo);
+        }
+        else {
+            // 没有营期记录就先插入
+            userLogsParamByDate.setStartTime(sopStartLocalDateStr);
+
+            sopUserLogsService.insertSopUserLogsByDate(userLogsParamByDate);
+
+            // 再次查询 拿营期主键
+            String unionSopStartIdNew = sopUserLogsService.selectSopUserLogsByUnionSopId(userLogs);
+            logsInfo.setUserLogsId(unionSopStartIdNew);
+
+            // 查询是否在营期里,如果没有再插入
+            handleInsertSopUserLogsInfo(logsInfo);
+        }
+    }
     /**
      * 新客对话
      */

+ 2 - 1
fs-service/src/main/java/com/fs/sop/service/impl/QwSopTempServiceImpl.java

@@ -30,6 +30,7 @@ import com.fs.sop.vo.QwSopTempRedPackageVo;
 import com.fs.sop.vo.VoiceVo;
 import com.fs.system.domain.SysConfig;
 import com.fs.system.service.ISysConfigService;
+import io.netty.util.internal.StringUtil;
 import lombok.AllArgsConstructor;
 import org.apache.commons.collections4.CollectionUtils;
 import org.apache.rocketmq.spring.core.RocketMQTemplate;
@@ -412,7 +413,7 @@ public class QwSopTempServiceImpl implements IQwSopTempService
                 content.setIsBindUrl(1);
                 List<QwSopTempContent> qwSopTempContents = new ArrayList<>() ;
                 qwSopTempContents.add(content);
-                if (sorts.get() == 0 && temp.getModeContent()!=null&&!temp.getModeContent().isEmpty()) {
+                if (sorts.get() == 0 && !StringUtil.isNullOrEmpty(temp.getModeContent())) {
                     QwSopTempContent content2 = new QwSopTempContent();
                     content2.setTempId(temp.getId());
                     content2.setContentType(3);

+ 151 - 0
fs-service/src/main/resources/application-druid-jzzx-test.yml

@@ -0,0 +1,151 @@
+# 数据源配置
+spring:
+    profiles:
+        include: config-druid-jzzx,common
+    # redis 配置
+    redis:
+        # 地址
+        host: 127.0.0.1
+        # 端口,默认为6379
+        port: 6379
+        # 数据库索引
+        database: 0
+        # 密码
+        password:
+#        password: Ylrztek250218!3@.
+        # 连接超时时间
+        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://1.95.34.221:2345/fs_his?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
+                    username: root
+                    password: Ylrztek250218!3@.
+                # 从库数据源
+                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://1.95.34.221:2345/sop?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
+                    username: root
+                    password: Ylrztek250218!3@.
+                # 初始连接数
+                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

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

@@ -31,6 +31,7 @@
         <result property="stopTime"    column="stop_time"    />
         <result property="isRating"    column="is_rating"    />
         <result property="courseDay"    column="course_day"    />
+        <result property="isFixed"    column="is_fixed"    />
         <result property="chatId"    column="chat_id"    />
         <result property="openCommentStatus"    column="open_comment_status"    />
         <result property="isSampSend"    column="is_samp_send"    />