浏览代码

cid优化调整

lmx 2 周之前
父节点
当前提交
811ff1f806

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

@@ -431,7 +431,8 @@ public class CompanyWorkflowEngineImpl implements CompanyWorkflowEngine {
             }
 
             // 检查当前工作流是否处于暂停状态
-            if (!Integer.valueOf(ExecutionStatusEnum.PAUSED.getValue()).equals(currentExec.getStatus())) {
+            if (!Integer.valueOf(ExecutionStatusEnum.PAUSED.getValue()).equals(currentExec.getStatus()) &&
+                !Integer.valueOf(ExecutionStatusEnum.WAITING.getValue()).equals(currentExec.getStatus())) {
                 throw new CustomException("工作流未处于暂停状态,无法唤醒: " + workflowInstanceId);
             }
 

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

@@ -541,6 +541,9 @@ public class CompanyWxServiceImpl extends ServiceImpl<CompanyWxAccountMapper, Co
         });
     }
 
+    public void mockInterface(Long wxClientId){
+        triggerWorkflowOnAddWxSuccess(wxClientId);
+    }
     /**
      * 加微成功后触发工作流继续执行
      * @param wxClientId 加微客户ID
@@ -550,13 +553,13 @@ public class CompanyWxServiceImpl extends ServiceImpl<CompanyWxAccountMapper, Co
             // 查找等待中的加微工作流实例
             CompanyAiWorkflowExec waitingExec = companyAiWorkflowExecMapper.selectWaitingAddWxWorkflowByWxClientId(
                     wxClientId,
-                    ExecutionStatusEnum.PAUSED.getValue(),
+                    ExecutionStatusEnum.WAITING.getValue(),
                     NodeTypeEnum.AI_ADD_WX_TASK.getValue());
             //查询工作流加微执行日志是否未更新状态
             CompanyAiWorkflowExecLog queryP = new CompanyAiWorkflowExecLog();
             queryP.setWorkflowInstanceId(waitingExec.getWorkflowInstanceId());
             queryP.setNodeType(NodeTypeEnum.AI_ADD_WX_TASK.getValue());
-            queryP.setStatus(ExecutionStatusEnum.PAUSED.getValue());
+            queryP.setStatus(ExecutionStatusEnum.WAITING.getValue());
             List<CompanyAiWorkflowExecLog> companyAiWorkflowExecLogs = companyAiWorkflowExecLogMapper.selectCompanyAiWorkflowExecLogList(queryP);
             companyAiWorkflowExecLogs.forEach(log -> {
                 log.setStatus(ExecutionStatusEnum.SUCCESS.getValue());

+ 22 - 16
fs-service/src/main/java/com/fs/company/service/impl/call/node/AiAddWxTaskNode.java

@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.fs.common.constant.Constants;
 import com.fs.common.core.redis.RedisCacheT;
+import com.fs.common.exception.CustomException;
 import com.fs.common.utils.StringUtils;
 import com.fs.common.utils.spring.SpringUtils;
 import com.fs.company.domain.*;
@@ -81,23 +82,24 @@ public class AiAddWxTaskNode extends AbstractWorkflowNode {
 //            super.asyncWorkflowForBlockingNode(context.getWorkflowInstanceId(), context.getCurrentNodeKey(),
 //                    context, ExecutionStatusEnum.WAITING);
 //            return ExecutionResult.waiting().nextNodeKey("").build();
-        } else {
-            List<CompanyWorkflowEdge> cList = edges.stream().filter(a ->
-                            StringUtils.isNotBlank(a.getConditionExpr()) && !JSONObject.parseArray(a.getConditionExpr(), AiCallWorkflowConditionVo.class).get(0).isAdd())
-                    .collect(Collectors.toList());
-            // 加微失败,根据条件判断走哪条边
-            CompanyWorkflowEdge edge = cList.get(0);
-                AiCallWorkflowConditionVo condition = JSONObject.parseObject(edge.getConditionExpr(), AiCallWorkflowConditionVo.class);
-                // 匹配失败条件
-                if (!condition.isAdd()) {
-                    log.info("加微失败,执行失败分支 - workflowInstanceId: {}", context.getWorkflowInstanceId());
-                    super.runNextNode(context, edge);
-                    return null;
-                }
-
-            log.error("加微失败但未找到失败分支 - workflowInstanceId: {}", context.getWorkflowInstanceId());
-            return null;
         }
+//        else {
+//            List<CompanyWorkflowEdge> cList = edges.stream().filter(a ->
+//                            StringUtils.isNotBlank(a.getConditionExpr()) && !JSONObject.parseArray(a.getConditionExpr(), AiCallWorkflowConditionVo.class).get(0).isAdd())
+//                    .collect(Collectors.toList());
+//            // 加微失败,根据条件判断走哪条边
+//            CompanyWorkflowEdge edge = cList.get(0);
+//                AiCallWorkflowConditionVo condition = JSONObject.parseObject(edge.getConditionExpr(), AiCallWorkflowConditionVo.class);
+//                // 匹配失败条件
+//                if (!condition.isAdd()) {
+//                    log.info("加微失败,执行失败分支 - workflowInstanceId: {}", context.getWorkflowInstanceId());
+//                    super.runNextNode(context, edge);
+//                    return null;
+//                }
+//
+//            log.error("加微失败但未找到失败分支 - workflowInstanceId: {}", context.getWorkflowInstanceId());
+//            return null;
+//        }
         return null;
     }
 
@@ -117,6 +119,10 @@ public class AiAddWxTaskNode extends AbstractWorkflowNode {
             CompanyWorkflowNode node = context.getVariable("currentNode", CompanyWorkflowNode.class)==null? getNodeByKey(nodeKey):context.getVariable("currentNode", CompanyWorkflowNode.class);
             String nodeConfig = node.getNodeConfig();
             AiAddWxConfigVO addWxConfig = JSONObject.parseObject(nodeConfig, AiAddWxConfigVO.class);
+
+            if(null == addWxConfig.getDialogId()){
+               throw new CustomException("加微节点未配置加微话术,执行失败");
+            }
             CompanyVoiceRoboticBusiness roboticBusiness = getRoboticBusiness(context.getWorkflowInstanceId());
             CompanyWxClient update = new CompanyWxClient();
             update.setDialogId(addWxConfig.getDialogId());

+ 19 - 6
fs-wx-task/src/main/java/com/fs/app/controller/CommonController.java

@@ -4,10 +4,13 @@ package com.fs.app.controller;
 import com.fs.app.service.WxTaskService;
 import com.fs.common.core.domain.R;
 import com.fs.company.service.ICompanyWxAccountService;
+import com.fs.company.service.impl.CompanyWxServiceImpl;
 import io.swagger.annotations.Api;
 import lombok.AllArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
@@ -18,19 +21,19 @@ import java.util.Collections;
 @Api("公共接口")
 @RestController
 @AllArgsConstructor
-@RequestMapping(value="/app/common")
+@RequestMapping(value = "/app/common")
 public class CommonController {
 
     private final WxTaskService taskService;
     private final ICompanyWxAccountService companyWxAccountService;
 
     @GetMapping("initAccountNum")
-    public void initAccountNum(){
+    public void initAccountNum() {
         taskService.initAccountNum();
     }
 
     @GetMapping("initAccountMsg")
-    public void initAccountMsg(){
+    public void initAccountMsg() {
         taskService.initAccountMsg();
     }
 
@@ -38,16 +41,19 @@ public class CommonController {
     public void addWx(Long accountId) {
         taskService.addWx(Collections.singletonList(accountId));
     }
+
     @GetMapping("isCheckContact")
-    public void isCheckContact(String formUser, Long accountId){
+    public void isCheckContact(String formUser, Long accountId) {
         companyWxAccountService.isCheckContact(formUser, accountId);
     }
+
     @GetMapping("cellRun")
-    public void cellRun(){
+    public void cellRun() {
         taskService.cellRun();
     }
+
     @GetMapping("callNextTask")
-    public void callNextTask(){
+    public void callNextTask() {
         taskService.callNextTask();
     }
 
@@ -62,6 +68,13 @@ public class CommonController {
     }
 
 
+    @Autowired
+    CompanyWxServiceImpl ccompanyWxService;
+
+    @GetMapping("mockAddWxSuccess/{clientId}")
+    public void mockAddWxSuccess(@PathVariable("clientId") Long clientId) {
+        ccompanyWxService.mockInterface(clientId);
+    }
 
 
 }