lmx 6 napja
szülő
commit
8e47bf4da8

+ 2 - 0
fs-service/src/main/java/com/fs/company/mapper/CompanyAiWorkflowExecMapper.java

@@ -114,4 +114,6 @@ public interface CompanyAiWorkflowExecMapper extends BaseMapper<CompanyAiWorkflo
     );
 
     WxContact selectWxContectByWorkflowInstanceId(@Param("workflowInstanceId") String workflowInstanceId);
+
+    Long selectWxClientIdByWorkflowInstanceId(@Param("workflowInstanceId") String workflowInstanceId);
 }

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

@@ -225,6 +225,7 @@ public class CompanyVoiceRoboticServiceImpl extends ServiceImpl<CompanyVoiceRobo
             client.setRoboticId(companyVoiceRobotic.getId());
             client.setCustomerId(Long.parseLong(e));
             client.setIsWeCom(isWeCom);
+            client.setCreateTime(new Date());
             return client;
         }).collect(Collectors.toList());
         companyWxClientServiceImpl.saveBatch(clients);
@@ -894,7 +895,7 @@ public class CompanyVoiceRoboticServiceImpl extends ServiceImpl<CompanyVoiceRobo
 //        redisCache2.deleteObject(EASYCALL_INTENT_RETRY_KEY + result.getUuid());
 
         // dialogue(对话内容)由对方异步写入,回调时可能尚未赋值,进入延迟重试队列等待
-        if (isDialogueEmpty(callPhoneRes.getDialogue())) {
+        if (isDialogueEmpty(callPhoneRes.getDialogue()) && !"未接通".equals(callPhoneRes.getIntent())) {
             String retryKey = EASYCALL_DIALOGUE_RETRY_KEY + result.getUuid();
             Integer retryCount = redisCache2.getCacheObject(retryKey);
             if (retryCount == null) {
@@ -936,7 +937,7 @@ public class CompanyVoiceRoboticServiceImpl extends ServiceImpl<CompanyVoiceRobo
             log.error("easyCall dialogue重试时仍未查询到外呼结果, uuid={}", result.getUuid());
             return;
         }
-        if (isDialogueEmpty(callPhoneRes.getDialogue())) {
+        if (isDialogueEmpty(callPhoneRes.getDialogue()) && !"未接通".equals(callPhoneRes.getIntent())) {
             // dialogue 仍为空,继续判断是否还有剩余重试次数
             String retryKey = EASYCALL_DIALOGUE_RETRY_KEY + result.getUuid();
             Integer retryCount = redisCache2.getCacheObject(retryKey);

+ 57 - 0
fs-service/src/main/java/com/fs/company/service/impl/CompanyWorkflowEngineImpl.java

@@ -71,6 +71,9 @@ public class CompanyWorkflowEngineImpl implements CompanyWorkflowEngine {
     @Autowired
     CompanyWxAccountMapper companyWxAccountMapper;
 
+    @Autowired
+    CompanyWxClientMapper companyWxClientMapper;
+
     /**
      * 初始化工作流
      * 创建工作流实例并保存初始状态
@@ -632,6 +635,60 @@ public class CompanyWorkflowEngineImpl implements CompanyWorkflowEngine {
             companyWxAccount.setRemark( remark);
             companyWxAccountMapper.updateCompanyWxAccount(companyWxAccount);
         }
+
+        // 加载当前执行记录
+        CompanyAiWorkflowExec currentExec = currentExecutionMapper.selectByWorkflowInstanceId(workflowInstanceId);
+
+        if (currentExec == null) {
+            throw new CustomException("工作流实例不存在: " + workflowInstanceId);
+        }
+        //更新加微结果到wxClient表
+        updateWxClientSuccessByWorkflowInstanceId(workflowInstanceId);
+        // 验证当前节点是否匹配
+        if (!nodeKey.equals(currentExec.getCurrentNodeKey())) {
+            log.error("节点不匹配 - 期望: {}, 实际: {}", nodeKey, currentExec.getCurrentNodeKey());
+            return;
+        }
+
+        // 检查当前工作流是否处于暂停状态
+        if (!Integer.valueOf(ExecutionStatusEnum.PAUSED.getValue()).equals(currentExec.getStatus()) &&
+                !Integer.valueOf(ExecutionStatusEnum.WAITING.getValue()).equals(currentExec.getStatus())) {
+            log.error("工作流未处于暂停状态,无法唤醒::{} " , workflowInstanceId);
+        }
+
+        // 反序列化执行上下文并合并新的输入数据
+        ExecutionContext context = deserializeContext(currentExec);
+
+        // 加载工作流定义
+        CompanyWorkflow definition = loadCompanyWorkflow(currentExec.getWorkflowId());
+
+        // 创建节点实例
+        IWorkflowNode node = createNode(definition, nodeKey);
+        if (node == null) {
+            throw new CustomException("节点不存在: " + nodeKey);
+        }
+
+        // 继续执行节点逻辑
+        ExecutionResult result = node.continueExecute(context);
+
+    }
+
+    /**
+     * 更新加微结果到wxClient表
+     * @param workflowInstanceId
+     */
+    public void updateWxClientSuccessByWorkflowInstanceId(String workflowInstanceId){
+        Long id = currentExecutionMapper.selectWxClientIdByWorkflowInstanceId(workflowInstanceId);
+        CompanyWxClient client = companyWxClientMapper.selectCompanyWxClientById(id);
+        if(null != client && !Integer.valueOf(1).equals(client.getIsAdd())){
+            //更新wxClient表
+            CompanyWxClient companyWxClient = new CompanyWxClient();
+            companyWxClient.setId(id);
+            companyWxClient.setIsAdd(1);
+            companyWxClient.setSuccessAddTime(LocalDateTime.now());
+            companyWxClientMapper.updateCompanyWxClient(companyWxClient);
+        }
+
     }
 
 }

+ 2 - 2
fs-service/src/main/java/com/fs/wxwork/service/WxIpadService.java

@@ -41,12 +41,12 @@ public class WxIpadService {
 
     public void sendTxt(WxTxtVo vo){
         String url = getUrl(vo.getServerId());
-        ResponseResult<Void> result = WxHttpUtil.postWithType(url, vo, new TypeReference<ResponseResult<Void>>() {
+        ResponseResult<Void> result = WxHttpUtil.postWithType(url+"/app/common/sendMsg", vo, new TypeReference<ResponseResult<Void>>() {
         }, vo.getServerId());
     }
     public void addWx(AddWxActionParam vo){
         String url = getUrl(vo.getServerId());
-        ResponseResult<Void> result = WxHttpUtil.postWithType(url, vo, new TypeReference<ResponseResult<Void>>() {
+        ResponseResult<Void> result = WxHttpUtil.postWithType(url+"/app/common/addWxAction", vo, new TypeReference<ResponseResult<Void>>() {
         }, vo.getServerId());
     }
 }

+ 9 - 1
fs-service/src/main/resources/mapper/company/CompanyAiWorkflowExecMapper.xml

@@ -265,7 +265,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             t3.user_id as crmUserId,
             t3.user_name as remark,
             t3.phone as phone,
-            t2.wx_client_id as accountId,
+            t2.wx_client_id as wxClientId,
             t4.account_id as accountId,
             t4.company_id as companyId,
             t4.company_user_id as companyUserId
@@ -277,4 +277,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         WHERE
             t1.workflow_instance_id = #{workflowInstanceId}
     </select>
+
+    <select id="selectWxClientIdByWorkflowInstanceId" resultType="java.lang.Long" >
+        select
+            t2.wx_client_id
+        from company_ai_workflow_exec t1
+                 inner join company_voice_robotic_business t2 on t1.business_key = t2.id
+        where t1.workflow_instance_id = #{workflowInstanceId}
+    </select>
 </mapper>

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

@@ -132,6 +132,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="dialogId != null">dialog_id = #{dialogId},</if>
             <if test="accountId != null">account_id = #{accountId},</if>
             <if test="companyUserId != null">company_user_id = #{companyUserId},</if>
+            <if test="successAddTime != null">success_add_time = #{successAddTime},</if>
         </trim>
         where id = #{id}
     </update>