فهرست منبع

Merge branch 'master' of http://1.14.104.71:10880/root/ylrz_his_scrm_java

caoliqin 1 هفته پیش
والد
کامیت
0a3c7ad386

+ 33 - 24
fs-admin/src/main/java/com/fs/his/controller/EasyCallController.java

@@ -10,6 +10,7 @@ import com.fs.system.domain.SysConfig;
 import com.fs.system.service.ISysConfigService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
@@ -30,6 +31,7 @@ import java.util.stream.Collectors;
 @Api(tags = "EasyCallCenter365外呼管理")
 @RestController
 @RequestMapping("/easyCall")
+@Slf4j
 public class EasyCallController extends BaseController {
 
     @Autowired
@@ -56,37 +58,44 @@ public class EasyCallController extends BaseController {
     @GetMapping("/gateway/getGatewayCompanyList")
     public R getGatewayCompanyList() {
         List<EasyCallGatewayVO> resList = new ArrayList<>();
-        List<EasyCallGatewayVO> list = easyCallService.getGatewayList(null);
-        // 如果原始列表为空,直接返回空列表
-        if (list == null || list.isEmpty()) {
-            return R.ok().put("data", resList);
-        }
-        SysConfig cidConf = iSysConfigService.selectConfigByConfigKey("cId.config");
-        if (null != cidConf && StringUtils.isNotBlank(cidConf.getConfigValue())) {
-            JSONObject jo = JSONObject.parseObject(cidConf.getConfigValue());
-            if (null != jo && jo.containsKey("showGatewayIds")) {
-                List<Long> gatewayIdList = jo.getJSONArray("showGatewayIds").toJavaList(Long.class);
-                if (gatewayIdList != null && !gatewayIdList.isEmpty()) {
-                    // 将配置中的网关ID列表转换为Set集合便于快速匹配
-                    Set<Long> gatewayIdSet = gatewayIdList.stream()
-                            .filter(id -> id != null)
-                            .collect(Collectors.toSet());
-                    // 过滤list,只保留id在配置集合中的网关
-                    resList = list.stream()
-                            .filter(gateway -> gateway.getId() != null && gatewayIdSet.contains(gateway.getId()))
-                            .collect(Collectors.toList());
+        try{
+            List<EasyCallGatewayVO> list = easyCallService.getGatewayList(null);
+            // 如果原始列表为空,直接返回空列表
+            if (list == null || list.isEmpty()) {
+                return R.ok().put("data", resList);
+            }
+            SysConfig cidConf = iSysConfigService.selectConfigByConfigKey("cId.config");
+            if (null != cidConf && StringUtils.isNotBlank(cidConf.getConfigValue())) {
+                JSONObject jo = JSONObject.parseObject(cidConf.getConfigValue());
+                if (null != jo && jo.containsKey("showGatewayIds") && jo.containsKey("enableGateWayLimit")) {
+                    Boolean enableGateWayLimit = jo.getBoolean("enableGateWayLimit");
+                    List<Long> gatewayIdList = jo.getJSONArray("showGatewayIds").toJavaList(Long.class);
+                    if (null != enableGateWayLimit && enableGateWayLimit && gatewayIdList != null && !gatewayIdList.isEmpty()) {
+                        // 将配置中的网关ID列表转换为Set集合便于快速匹配
+                        Set<Long> gatewayIdSet = gatewayIdList.stream()
+                                .filter(id -> id != null)
+                                .collect(Collectors.toSet());
+                        // 过滤list,只保留id在配置集合中的网关
+                        resList = list.stream()
+                                .filter(gateway -> gateway.getId() != null && gatewayIdSet.contains(gateway.getId()))
+                                .collect(Collectors.toList());
+                    } else {
+                        // 配置为空时返回原始列表
+                        resList = list;
+                    }
                 } else {
-                    // 配置为空时返回原始列表
+                    // 未配置showGatewayIds时返回原始列表
                     resList = list;
                 }
             } else {
-                // 未配置showGatewayIds时返回原始列表
+                // 未找到配置时返回原始列表
                 resList = list;
             }
-        } else {
-            // 未找到配置时返回原始列表
-            resList = list;
+        }catch (Exception e){
+            log.error("获取网关列表失败", e);
+            return R.ok().put("msg", e.getMessage());
         }
+
         return R.ok().put("data", resList);
     }
 }

+ 15 - 0
fs-admin/src/main/java/com/fs/his/task/Task.java

@@ -23,6 +23,7 @@ import com.fs.company.vo.QwIpadTotalVo;
 import com.fs.company.vo.RedPacketMoneyVO;
 import com.fs.course.dto.BatchSendCourseAllDTO;
 import com.fs.course.mapper.FsCourseRedPacketLogMapper;
+import com.fs.course.mapper.FsUserCompanyUserMapper;
 import com.fs.course.service.IFsCourseWatchLogService;
 import com.fs.course.service.ITencentCloudCosService;
 import com.fs.erp.domain.ErpDeliverys;
@@ -234,6 +235,10 @@ public class Task {
 
     @Autowired
     private IFsStoreOrderScrmService orderScrmService;
+
+    @Autowired
+    private FsUserCompanyUserMapper fsUserCompanyUserMapper;
+
     /**
      * 定时任务,处理ai禁止回复之后的消息
      */
@@ -1931,6 +1936,16 @@ public class Task {
         return futures;
     }
 
+    //处理看课用户大于等于15天的清理绑定关系
+    public void clearUserCourseBind(){
+        //获取相关信息
+        List<Long> userIds = fsCourseWatchLogService.selectWatchLogOutdatedInfo();
+        if(!userIds.isEmpty()){
+            //清理绑定关系
+            fsUserCompanyUserMapper.deleteByUserIds(userIds);
+        }
+    }
+
     /**
      * 等待所有任务完成
      * @param futures CompletableFuture列表

+ 15 - 0
fs-service/src/main/java/com/fs/course/mapper/FsCourseWatchLogMapper.java

@@ -909,4 +909,19 @@ public interface FsCourseWatchLogMapper extends BaseMapper<FsCourseWatchLog> {
      * 销售部门维度订单统计
      */
     List<AppSalesWatchLogReportVO> selectAppDeptOrderStats(FsCourseWatchLogStatisticsListParam param);
+
+    /**
+     * 获取过期数据
+     * **/
+    @Select("SELECT user_id FROM fs_course_watch_log \n" +
+            "WHERE send_type = 1 \n" +
+            "  AND create_time <= DATE_SUB(NOW(), INTERVAL 15 DAY)\n" +
+            "  AND (user_id, create_time) IN (\n" +
+            "    SELECT user_id, MAX(create_time) \n" +
+            "    FROM fs_course_watch_log \n" +
+            "    WHERE send_type = 1 \n" +
+            "      AND create_time <= DATE_SUB(NOW(), INTERVAL 15 DAY)\n" +
+            "    GROUP BY user_id\n" +
+            "  )")
+    List<Long> selectWatchLogOutdatedInfo();
 }

+ 6 - 0
fs-service/src/main/java/com/fs/course/mapper/FsUserCompanyUserMapper.java

@@ -110,4 +110,10 @@ public interface FsUserCompanyUserMapper extends BaseMapper<FsUserCompanyUser>{
      * @return
      */
     FsUserCompanyUser selectFsUserCompanyUserByUserId(@Param("userId") Long userId);
+
+    /**
+     * 批量清理用户绑定数据
+     * @param userIds 会员id
+     * **/
+    void deleteByUserIds(@Param("userIds") List<Long> userIds);
 }

+ 5 - 0
fs-service/src/main/java/com/fs/course/service/IFsCourseWatchLogService.java

@@ -203,4 +203,9 @@ public interface IFsCourseWatchLogService extends IService<FsCourseWatchLog> {
 
     List<AppSalesCourseStatisticsVO> selectAppSalesCourseStatisticsVO(FsCourseWatchLogStatisticsListParam param);
 
+    /**
+     * 获取15天过期未看课用户数据
+     * **/
+    List<Long> selectWatchLogOutdatedInfo();
+
 }

+ 5 - 0
fs-service/src/main/java/com/fs/course/service/impl/FsCourseWatchLogServiceImpl.java

@@ -2299,6 +2299,11 @@ public class FsCourseWatchLogServiceImpl extends ServiceImpl<FsCourseWatchLogMap
         return resultList;
     }
 
+    @Override
+    public List<Long> selectWatchLogOutdatedInfo() {
+        return baseMapper.selectWatchLogOutdatedInfo();
+    }
+
     private void setDefaultValues(AppSalesCourseStatisticsVO vo) {
         vo.setFinishedCount(vo.getFinishedCount() != null ? vo.getFinishedCount() : 0);
         vo.setNotWatchedCount(vo.getNotWatchedCount() != null ? vo.getNotWatchedCount() : 0);

+ 1 - 1
fs-service/src/main/java/com/fs/crm/service/impl/CrmCustomerAnalyzeServiceImpl.java

@@ -609,7 +609,7 @@ public class CrmCustomerAnalyzeServiceImpl extends ServiceImpl<CrmCustomerAnalyz
         List<String> dictValue = portraits.stream().map(SysDictData::getDictValue).collect(Collectors.toList());
 //        Map<String, String> portraitMap = portraits.stream().collect(Collectors.toMap(SysDictData::getDictValue, SysDictData::getDictLabel));
 
-        if (!crmCustomerAnalyze.getCustomerPortraitJson().isEmpty()){
+        if (crmCustomerAnalyze.getCustomerPortraitJson()!= null && !crmCustomerAnalyze.getCustomerPortraitJson().isEmpty()){
             Map<String, String> portraitList = JSON.parseObject(
                     crmCustomerAnalyze.getCustomerPortraitJson(),
                     new TypeReference<Map<String, String>>() {}

+ 8 - 1
fs-service/src/main/java/com/fs/crm/utils/CrmCustomerAiTagUtil.java

@@ -356,7 +356,7 @@ public class CrmCustomerAiTagUtil {
         HashMap<String, String> userInfo = new HashMap<String, String>();
         List<SysDictData> portraits = SpringUtils.getBean(SysDictDataMapper.class).selectDictDataByType(AI_PORTRAIT);
         List<String> dictValue = portraits.stream().map(SysDictData::getDictValue).collect(Collectors.toList());
-        if (!crmCustomerAnalyze.getCustomerPortraitJson().isEmpty()){
+        if (crmCustomerAnalyze.getCustomerPortraitJson()!= null && !crmCustomerAnalyze.getCustomerPortraitJson().isEmpty()){
             Map<String, String> portraitList = JSON.parseObject(
                     crmCustomerAnalyze.getCustomerPortraitJson(),
                     new cn.hutool.core.lang.TypeReference<Map<String, String>>() {}
@@ -403,6 +403,13 @@ public class CrmCustomerAiTagUtil {
         if (!maps.isEmpty()){
             CrmCustomerAnalyzeMapper bean = SpringUtils.getBean(CrmCustomerAnalyzeMapper.class);
             CrmCustomerAnalyze crmCustomerAnalyze = bean.selectLatestOne(Long.valueOf(customerId));
+            if (crmCustomerAnalyze == null){
+                CrmCustomerMapper customerMapper = SpringUtils.getBean(CrmCustomerMapper.class);
+                CrmCustomer crmCustomer = customerMapper.selectCrmCustomerById(Long.valueOf(customerId));
+                crmCustomerAnalyze = new CrmCustomerAnalyze();
+                crmCustomerAnalyze.setCustomerId(Long.valueOf(customerId));
+                crmCustomerAnalyze.setCustomerName(crmCustomer.getCustomerName());
+            }
             crmCustomerAnalyze.setAiChatRecord(JSONUtil.toJsonStr(maps));
             crmCustomerAnalyze.setCreateTime(new Date());
             bean.insertCrmCustomerAnalyze(crmCustomerAnalyze);

+ 6 - 0
fs-service/src/main/resources/mapper/course/FsUserCompanyUserMapper.xml

@@ -220,4 +220,10 @@
             LIMIT 1
     </select>
 
+    <delete id="deleteByUserIds">
+        DELETE FROM  fs_user_company_user WHERE  user_id IN
+        <foreach item="item" collection="userIds" open="(" close=")" separator=",">
+            #{item}
+        </foreach>
+    </delete>
 </mapper>