Переглянути джерело

Merge remote-tracking branch 'origin/master'

zyy 2 тижнів тому
батько
коміт
509d62f86c

+ 1 - 1
fs-cid-workflow/src/main/java/com/fs/app/task/CidTask.java

@@ -27,7 +27,7 @@ public class CidTask {
     /**
      * 扫描当前分组下就绪任务,并开启执行
      */
-    @Scheduled(cron = "0 0/1 * * * ?")
+    @Scheduled(cron = "0/30 * * * * ?")
     public void runCidWorkflow() {
         cidWorkflowTaskService.runCidWorkflow();
     }

+ 2 - 16
fs-company/src/main/java/com/fs/company/controller/crm/CrmCustomerAnalyzeController.java

@@ -1,9 +1,6 @@
 package com.fs.company.controller.crm;
 
 import java.util.List;
-
-import com.fs.common.core.domain.R;
-import com.fs.crm.param.PolishingScriptParam;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
@@ -51,8 +48,8 @@ public class CrmCustomerAnalyzeController extends BaseController
     /**
      * 查询所有客户(根据客户分组取客户最新一条数据)
      */
-    @GetMapping("/listAll")
-    public TableDataInfo listAll(CrmCustomerAnalyze crmCustomerAnalyze)
+    @PostMapping("/listAll")
+    public TableDataInfo listAll(@RequestBody CrmCustomerAnalyze crmCustomerAnalyze)
     {
         startPage();
         List<CrmCustomerAnalyze> list = crmCustomerAnalyzeService.selectCrmCustomerAnalyzeListAll(crmCustomerAnalyze);
@@ -115,15 +112,4 @@ public class CrmCustomerAnalyzeController extends BaseController
     {
         return toAjax(crmCustomerAnalyzeService.deleteCrmCustomerAnalyzeByIds(ids));
     }
-
-    /**
-     * 话术润色
-     */
-    @PreAuthorize("@ss.hasPermi('crm:analyze:polishingScript')")
-    @PostMapping("/polishingScript")
-    public R polishingScript(@RequestBody PolishingScriptParam param)
-    {
-        return R.ok().put("data",crmCustomerAnalyzeService.polishingScript(param));
-    }
-
 }

+ 16 - 2
fs-company/src/main/java/com/fs/company/controller/crm/chat/CrmCustomerChatSessionController.java

@@ -2,10 +2,13 @@ package com.fs.company.controller.crm.chat;
 
 import com.fs.common.core.controller.BaseController;
 import com.fs.common.core.domain.AjaxResult;
+import com.fs.common.core.domain.R;
 import com.fs.common.core.page.TableDataInfo;
 import com.fs.common.utils.ServletUtils;
 import com.fs.crm.domain.CrmCustomerChatMessage;
 import com.fs.crm.domain.CrmCustomerChatSession;
+import com.fs.crm.param.PolishingScriptParam;
+import com.fs.crm.service.ICrmCustomerAnalyzeService;
 import com.fs.crm.service.ICrmCustomerChatMessageService;
 import com.fs.crm.service.ICrmCustomerChatSessionService;
 import com.fs.framework.security.LoginUser;
@@ -32,6 +35,8 @@ public class CrmCustomerChatSessionController extends BaseController {
     private TokenService tokenService;
     @Autowired
     private ICrmCustomerChatMessageService chatMessageService;
+    @Autowired
+    private ICrmCustomerAnalyzeService crmCustomerAnalyzeService;
 
     /**
      * 查询聊天会话列表
@@ -40,8 +45,9 @@ public class CrmCustomerChatSessionController extends BaseController {
     public TableDataInfo list(CrmCustomerChatSession chatSession) {
         LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
         chatSession.setUserId(loginUser.getUser().getUserId());
+        startPage();
         List<CrmCustomerChatSession> list = chatSessionService.selectChatSessionList(chatSession);
-        //根据会话查询对应的消息数据
+        //根据会话查询对应的消息数据,返回一个sessionId对应200条数据显示
         list.forEach(session -> {
             List<CrmCustomerChatMessage> messageList =chatMessageService.selectChatMessageBySessionIdLimit(session.getSessionId());
             session.setMessageList(messageList);
@@ -93,7 +99,6 @@ public class CrmCustomerChatSessionController extends BaseController {
             int result = chatSessionService.updateChatSessionTitle(sessionId, title);
             return result > 0 ? success("更新成功") : error("更新失败");
         } catch (Exception e) {
-            logger.error("更新会话标题失败", e);
             return error("更新失败:" + e.getMessage());
         }
     }
@@ -153,4 +158,13 @@ public class CrmCustomerChatSessionController extends BaseController {
     public AjaxResult removeBatch(@RequestBody Long[] sessionIds) {
         return toAjax(chatSessionService.deleteChatSessionByIds(sessionIds));
     }
+
+    /**
+     * 话术润色
+     */
+    @PostMapping("/polishingScript")
+    public R polishingScript(@RequestBody PolishingScriptParam param)
+    {
+        return R.ok().put("data",crmCustomerAnalyzeService.polishingScript(param));
+    }
 }

+ 1 - 1
fs-service/src/main/java/com/fs/company/mapper/CompanyWxClientMapper.java

@@ -84,5 +84,5 @@ public interface CompanyWxClientMapper extends BaseMapper<CompanyWxClient> {
 
     List<CompanyWxClient> getQwAddWxList(@Param("accountIdList") List<Long> accountIdList, @Param("isWeCom") Integer isWeCom);
 
-    List<CompanyWxClient4WorkFlowVO> getQwAddWxList4Workflow(@Param("accountIdList") List<Long> accountIdList, @Param("execStatus") Integer execStatus, @Param("execNodeType") Integer execNodeType);
+    List<CompanyWxClient4WorkFlowVO> getQwAddWxList4Workflow(@Param("accountIdList") List<Long> accountIdList, @Param("execStatus") Integer execStatus, @Param("execNodeType") Integer execNodeType, @Param("cidGroupNo") Integer cidGroupNo);
 }

+ 1 - 1
fs-service/src/main/java/com/fs/company/service/ICompanyWxClientService.java

@@ -75,5 +75,5 @@ public interface ICompanyWxClientService extends IService<CompanyWxClient> {
 
     List<CompanyWxClient> getQwAddWxList(List<Long> accountIdList,Integer isWeCom);
 
-    List<CompanyWxClient4WorkFlowVO> getQwAddWxList4Workflow(List<Long> accountIdList);
+    List<CompanyWxClient4WorkFlowVO> getQwAddWxList4Workflow(List<Long> accountIdList,Integer cidGroupNo);
 }

+ 2 - 2
fs-service/src/main/java/com/fs/company/service/impl/CompanyWxClientServiceImpl.java

@@ -253,7 +253,7 @@ public class CompanyWxClientServiceImpl extends ServiceImpl<CompanyWxClientMappe
      * @return
      */
     @Override
-    public  List<CompanyWxClient4WorkFlowVO> getQwAddWxList4Workflow(List<Long> accountIdList){
-        return baseMapper.getQwAddWxList4Workflow(accountIdList, ExecutionStatusEnum.WAITING.getValue(), NodeTypeEnum.AI_QW_ADD_WX_TASK.getValue());
+    public  List<CompanyWxClient4WorkFlowVO> getQwAddWxList4Workflow(List<Long> accountIdList,Integer cidGroupNo){
+        return baseMapper.getQwAddWxList4Workflow(accountIdList, ExecutionStatusEnum.WAITING.getValue(), NodeTypeEnum.AI_QW_ADD_WX_TASK.getValue(),cidGroupNo);
     }
 }

+ 1 - 0
fs-service/src/main/java/com/fs/company/vo/CompanyWxClient4WorkFlowVO.java

@@ -96,4 +96,5 @@ public class CompanyWxClient4WorkFlowVO extends BaseEntityTow {
     * 投流 id
     */
     private String traceId;
+    private String nodeKey;
 }

+ 1 - 1
fs-service/src/main/java/com/fs/crm/mapper/CrmCustomerChatMessageMapper.java

@@ -81,6 +81,6 @@ public interface CrmCustomerChatMessageMapper {
      * 根据会话 ID 查询消息分页列表
      * @param sessionId sessionId
      */
-    @Select("SELECT * FROM crm_customer_chat_message WHERE session_id = #{sessionId} ORDER BY create_time DESC LIMIT 50")
+    @Select("SELECT * FROM crm_customer_chat_message WHERE session_id = #{sessionId} ORDER BY create_time DESC LIMIT 200")
     List<CrmCustomerChatMessage> selectChatMessageBySessionIdLimit(@Param("sessionId") Long sessionId);
 }

+ 2 - 1
fs-service/src/main/java/com/fs/crm/service/ICrmCustomerAnalyzeService.java

@@ -3,6 +3,7 @@ package com.fs.crm.service;
 import java.util.List;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.fs.crm.domain.CrmCustomerAnalyze;
+import com.fs.crm.domain.CrmCustomerChatMessage;
 import com.fs.crm.param.PolishingScriptParam;
 
 /**
@@ -70,7 +71,7 @@ public interface ICrmCustomerAnalyzeService extends IService<CrmCustomerAnalyze>
 
     String aiCustomerFocus(Long customerId, String dataJson, Long logId);
 
-    String polishingScript(PolishingScriptParam param);
+    CrmCustomerChatMessage polishingScript(PolishingScriptParam param);
 
     String aiIntentionDegree(Long customerId, String dataJson, Long logId);
 

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

@@ -15,6 +15,7 @@ import com.fs.common.core.domain.R;
 import com.fs.common.core.domain.entity.SysDictData;
 import com.fs.common.utils.DateUtils;
 import com.fs.crm.domain.CrmCustomerAnalyze;
+import com.fs.crm.domain.CrmCustomerChatMessage;
 import com.fs.crm.mapper.CrmCustomerAnalyzeMapper;
 import com.fs.crm.param.PolishingScriptParam;
 import com.fs.crm.service.ICrmCustomerAnalyzeService;
@@ -365,9 +366,9 @@ public class CrmCustomerAnalyzeServiceImpl extends ServiceImpl<CrmCustomerAnalyz
     }
 
     @Override
-    public String polishingScript(PolishingScriptParam param) {
+    public CrmCustomerChatMessage polishingScript(PolishingScriptParam param) {
         Map<String, Object> requestParam = new HashMap<>();
-        requestParam.put("history", param.getContent());
+        requestParam.put("userContent", param.getContent());
         requestParam.put("modelType","话术润色");
         HashMap<String, Map<String, String>> userInfo = MapUtil.of("userInfo", param.getPortrait());
         requestParam.putAll(userInfo);
@@ -375,16 +376,30 @@ public class CrmCustomerAnalyzeServiceImpl extends ServiceImpl<CrmCustomerAnalyz
         // 设置其他参数
         requestParam.put("tagInfos", Collections.emptyList());
         requestParam.put("isRepository", "");
-        requestParam.put("userContent", "");
+        requestParam.put("history", "");
         requestParam.put("aiContent", "");
         requestParam.put("likeRatio", "");
         R aiResponse = CrmCustomerAiTagUtil.callAiService(requestParam, Long.valueOf(param.getChatId()),OTHER_KEY);
         System.out.println(aiResponse);
         String result = "";
+        CrmCustomerChatMessage crmCustomerChatMessage = new CrmCustomerChatMessage();
+//        Double runningTime;
+//        Long tokens;
         try {
 
             JsonNode rootS = mapper.readTree(JSONUtil.toJsonStr(aiResponse));
             JsonNode choices = rootS.path("data").path("choices");
+//            JsonNode responseData = rootS.path("data").path("responseData");
+//            if (responseData.isArray()) {
+//                for (JsonNode node : responseData) {
+//                    String nodeId = node.path("nodeId").asText();
+//                    String moduleName = node.path("moduleName").asText();
+//                    // 获取 runningTime
+//                    runningTime = node.path("runningTime").asDouble();
+//                    // 获取 tokens
+//                    tokens = node.path("tokens").asLong();
+//                }
+//            }
 
             if (choices.isArray() && choices.size() > 0) {
                 JsonNode contentNode = choices.get(0).path("message").path("content");
@@ -403,10 +418,10 @@ public class CrmCustomerAnalyzeServiceImpl extends ServiceImpl<CrmCustomerAnalyz
 
                             if (contentInnerNode.isTextual()) {
                                 String innerJsonStr = contentInnerNode.asText();
-//                                JsonNode innerJson = mapper.readTree(innerJsonStr);
-//                                JsonNode userInfo1 = innerJson.path("aiContent");
-//                               = userInfo1.asText();
-                                result = innerJsonStr;
+                                JsonNode innerJson = mapper.readTree(innerJsonStr);
+                                JsonNode userInfo1 = innerJson.path("aiContent");
+                                result = userInfo1.asText();
+                                crmCustomerChatMessage.setContentType(1);
                             }
                         }
                     }
@@ -415,8 +430,11 @@ public class CrmCustomerAnalyzeServiceImpl extends ServiceImpl<CrmCustomerAnalyz
 
         } catch (Exception e) {
             e.printStackTrace();
+            crmCustomerChatMessage.setContentType(0);
         }
-        return result;
+        crmCustomerChatMessage.setContent(result);
+        crmCustomerChatMessage.setModelName("话术润色");
+        return crmCustomerChatMessage;
     }
 
     @Override

+ 5 - 18
fs-service/src/main/java/com/fs/crm/service/impl/CrmCustomerChatSessionServiceImpl.java

@@ -4,7 +4,6 @@ import com.fs.common.utils.DateUtils;
 import com.fs.crm.domain.CrmCustomerChatSession;
 import com.fs.crm.mapper.CrmCustomerChatSessionMapper;
 import com.fs.crm.service.ICrmCustomerChatSessionService;
-import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -17,7 +16,6 @@ import java.util.List;
  * @author ylrz
  * @date 2026-03-30
  */
-@Slf4j
 @Service
 public class CrmCustomerChatSessionServiceImpl implements ICrmCustomerChatSessionService {
 
@@ -64,9 +62,7 @@ public class CrmCustomerChatSessionServiceImpl implements ICrmCustomerChatSessio
         if (chatSession.getIsPinned() == null) {
             chatSession.setIsPinned(0);
         }
-        int result = chatSessionMapper.insertChatSession(chatSession);
-        log.info("新增会话成功,sessionId: {}", chatSession.getSessionId());
-        return result;
+        return chatSessionMapper.insertChatSession(chatSession);
     }
 
     /**
@@ -78,9 +74,7 @@ public class CrmCustomerChatSessionServiceImpl implements ICrmCustomerChatSessio
     @Override
     public int updateChatSession(CrmCustomerChatSession chatSession) {
         chatSession.setUpdateTime(DateUtils.getNowDate());
-        int result = chatSessionMapper.updateChatSession(chatSession);
-        log.info("更新会话成功,sessionId: {}", chatSession.getSessionId());
-        return result;
+        return chatSessionMapper.updateChatSession(chatSession);
     }
 
     /**
@@ -94,11 +88,8 @@ public class CrmCustomerChatSessionServiceImpl implements ICrmCustomerChatSessio
     @Transactional(rollbackFor = Exception.class)
     public int updateChatSessionTitle(Long sessionId, String title) {
         try {
-            int result = chatSessionMapper.updateChatSessionTitle(sessionId, title);
-            log.info("更新会话标题成功,sessionId: {}, title: {}", sessionId, title);
-            return result;
+            return chatSessionMapper.updateChatSessionTitle(sessionId, title);
         } catch (Exception e) {
-            log.error("更新会话标题失败", e);
             throw new RuntimeException("更新会话标题失败:" + e.getMessage());
         }
     }
@@ -138,9 +129,7 @@ public class CrmCustomerChatSessionServiceImpl implements ICrmCustomerChatSessio
         if (sessionIds == null || sessionIds.length == 0) {
             return 0;
         }
-        int result = chatSessionMapper.deleteChatSessionByIds(sessionIds);
-        log.info("批量删除会话成功,删除数量:{}", sessionIds.length);
-        return result;
+        return chatSessionMapper.deleteChatSessionByIds(sessionIds);
     }
 
     /**
@@ -151,9 +140,7 @@ public class CrmCustomerChatSessionServiceImpl implements ICrmCustomerChatSessio
      */
     @Override
     public int deleteChatSessionById(Long sessionId) {
-        int result = chatSessionMapper.deleteChatSessionById(sessionId);
-        log.info("删除会话成功,sessionId: {}", sessionId);
-        return result;
+        return chatSessionMapper.deleteChatSessionById(sessionId);
     }
 
     @Override

+ 2 - 2
fs-service/src/main/resources/mapper/company/CompanyWxClientMapper.xml

@@ -197,12 +197,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </select>
     <select id="getQwAddWxList4Workflow" resultType="com.fs.company.vo.CompanyWxClient4WorkFlowVO">
 
-        SELECT t1.*,t3.workflow_instance_id,t3.current_node_key,t3.current_node_name,t3.current_node_type,t4.node_config,t2.callee_id FROM company_wx_client t1
+        SELECT t1.*,t3.workflow_instance_id,t3.current_node_key,t3.current_node_name,t3.current_node_type,t4.node_config,t2.callee_id,t4.node_key FROM company_wx_client t1
         inner join company_voice_robotic_business t2 on t1.id = t2.wx_client_id and t1.robotic_id = t2.robotic_id
         inner join company_ai_workflow_exec t3 on t3.business_key = t2.id
         inner join company_ai_workflow_node t4 on t3.current_node_key=t4.node_key
         where t1.is_add = 0 and t1.account_id is not null and t1.is_we_com = 2
-        and t3.current_node_type = #{execNodeType} And t3.status = #{execStatus}
+        and t3.current_node_type = #{execNodeType} And t3.status = #{execStatus} and t3.cid_group_no = #{cidGroupNo}
         <if test="accountIdList != null and !accountIdList.isEmpty()">
             and t1.account_id in <foreach collection="accountIdList" open="(" separator="," close=")" item="item">#{item}</foreach>
         </if>

+ 17 - 1
fs-wx-task/src/main/java/com/fs/app/service/WxTaskService.java

@@ -893,7 +893,7 @@ public class WxTaskService {
         log.info("==========执行申请企微加好友任务开始==========");
         try {
             // 获取需要添加微信的列表
-            List<CompanyWxClient4WorkFlowVO> list = companyWxClientService.getQwAddWxList4Workflow(accountIdList);
+            List<CompanyWxClient4WorkFlowVO> list = companyWxClientService.getQwAddWxList4Workflow(accountIdList,cidGroupNo);
             log.info("申请企微加好友任务需要添加微信的数量:{}", list.size());
             if (list.isEmpty()) {
                 return;
@@ -1054,6 +1054,13 @@ public class WxTaskService {
             log.info("ROBOTIC-ID:{},企微申请加好友任务申请成功", client.getRoboticId());
 
             asyncSaveCompanyVoiceRoboticCallLog(addLog);
+
+            //更新工作流的执行日志
+            CompanyAiWorkflowExecLog queryP = new CompanyAiWorkflowExecLog();
+            queryP.setWorkflowInstanceId(client.getWorkflowInstanceId());
+            queryP.setNodeKey(client.getNodeKey());
+            queryP.setStatus(ExecutionStatusEnum.WAITING.getValue());
+            companyAiWorkflowExecLogMapper.updateCompanyAiWorkflowExecLog(queryP);
             return addItem;
         } else {
             // 加微失败
@@ -1071,6 +1078,13 @@ public class WxTaskService {
                     client.getRoboticId(), runParam);
 
             asyncSaveCompanyVoiceRoboticCallLog(addLog);
+            //更新工作流的执行日志
+            CompanyAiWorkflowExecLog queryP = new CompanyAiWorkflowExecLog();
+
+            queryP.setWorkflowInstanceId(client.getWorkflowInstanceId());
+            queryP.setNodeKey(client.getNodeKey());
+            queryP.setStatus(ExecutionStatusEnum.FAILURE.getValue());
+            companyAiWorkflowExecLogMapper.updateCompanyAiWorkflowExecLog(queryP);
             return addItem;
         }
     }
@@ -1315,6 +1329,8 @@ public class WxTaskService {
             List<CompanyWxClient> updateList,
             Map<Long, CompanyWxClient4WorkFlowVO> clientMap) {
 
+        log.info("==========触发后续工作流步骤开始==========");
+
         for (CompanyWxClient client : updateList) {
             CompanyWxClient4WorkFlowVO vo = clientMap.get(client.getAccountId());
             IWorkflowNode node = workflowNodeFactory.createNode(