lmx 3 weken geleden
bovenliggende
commit
aff2d81261

+ 1 - 1
fs-ai-call-task/src/main/java/com/fs/FsAiCallTaskApplication.java

@@ -13,7 +13,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
 @SpringBootApplication(exclude = { DataSourceAutoConfiguration.class })
 @EnableTransactionManagement
 @EnableAsync
-//@EnableScheduling
+@EnableScheduling
 public class FsAiCallTaskApplication
 {
     public static void main(String[] args){

+ 4 - 5
fs-ai-call-task/src/main/java/com/fs/app/service/CallTaskService.java

@@ -46,17 +46,16 @@ public class CallTaskService {
         keys.parallelStream().forEach(key -> {
             try {
                 //doExec
-                CompletableFuture.runAsync(()->{
+                CompletableFuture.runAsync(() -> {
                     try {
                         ExecutionContext context = redisCache2.getCacheObject(key);
-                        context.setVariable("callRedisKey",key);
-                        context.setVariable("callSource","callTaskTimer");
-                        companyWorkflowEngine.timeDoExecute(context.getWorkflowInstanceId(),context.getCurrentNodeKey(),context.getVariables());
+                        context.setVariable("callRedisKey", key);
+                        context.setVariable("callSource", "callTaskTimer");
+                        companyWorkflowEngine.timeDoExecute(context.getWorkflowInstanceId(), context.getCurrentNodeKey(), context.getVariables());
                     } catch (Exception e) {
                         log.error("处理工作流延时任务异常 - key: {}", key, e);
                     }
                 }, cidExcutor);
-
             } catch (Exception ex) {
                 log.error("处理工作流延时任务异常 - key: {}", key, ex);
             }

+ 55 - 51
fs-service/src/main/java/com/fs/company/service/impl/CompanyVoiceRoboticCallLogCallphoneServiceImpl.java

@@ -151,20 +151,20 @@ public class CompanyVoiceRoboticCallLogCallphoneServiceImpl extends ServiceImpl<
     @Async("callLogExcutor")
     public void asyncHandleCalleeCallBackResult(PushIIntentionResult result, CompanyVoiceRoboticCallees callees) {
         try {
-            String runTaskFlow = callees.getRunTaskFlow();
-            if(StringUtils.isBlank(runTaskFlow)){
-                runTaskFlow = Constants.CELL_PHONE;
-            }else{
-                if (!runTaskFlow.contains(Constants.CELL_PHONE)) {
-                    runTaskFlow = runTaskFlow + "," + Constants.CELL_PHONE;
-                }
-            }
-            if(!runTaskFlow.equals(callees.getRunTaskFlow())){
-                CompanyVoiceRoboticCallees updateCallees = new CompanyVoiceRoboticCallees();
-                updateCallees.setId(callees.getId());
-                updateCallees.setRunTaskFlow(runTaskFlow);
-                companyVoiceRoboticCalleesMapper.updateById(updateCallees);
-            }
+//            String runTaskFlow = callees.getRunTaskFlow();
+//            if(StringUtils.isBlank(runTaskFlow)){
+//                runTaskFlow = Constants.CELL_PHONE;
+//            }else{
+//                if (!runTaskFlow.contains(Constants.CELL_PHONE)) {
+//                    runTaskFlow = runTaskFlow + "," + Constants.CELL_PHONE;
+//                }
+//            }
+//            if(!runTaskFlow.equals(callees.getRunTaskFlow())){
+//                CompanyVoiceRoboticCallees updateCallees = new CompanyVoiceRoboticCallees();
+//                updateCallees.setId(callees.getId());
+//                updateCallees.setRunTaskFlow(runTaskFlow);
+//                companyVoiceRoboticCalleesMapper.updateById(updateCallees);
+//            }
             String json= configService.selectConfigByKey("cid.config");
             if(StringUtils.isBlank( json)){
                 log.error("未配置cid.config");
@@ -173,44 +173,48 @@ public class CompanyVoiceRoboticCallLogCallphoneServiceImpl extends ServiceImpl<
 
             Notify notify = result.getNotify();
             String uuid = notify.getUuid();
-            getDialogMapDomain getDialogMap = getDialogMapDomain.builder()
-                    .uuid(uuid)
-                    .build();
-            CompanyVoiceRoboticCallLogCallphone companyVoiceRoboticCallLog = companyVoiceRoboticCallLogCallphoneMapper.selectNoResultLogByCallees(callees);
-
-            companyVoiceRoboticCallLog.setStatus(2);
-            companyVoiceRoboticCallLog.setResult(JSON.toJSONString(result));
-
-            CompanyWxClient companyWxClient = companyWxClientServiceImpl.getOne(new QueryWrapper<CompanyWxClient>().eq("robotic_id", callees.getRoboticId()).eq("customer_id", callees.getUserId()));
-            CompanyVoiceRoboticWx roboticWx = companyVoiceRoboticWxServiceImpl.getById(companyWxClient.getRoboticWxId());
-            CompanyWxAccount companyWxAccount = companyWxAccountMapper.selectCompanyWxAccountById(roboticWx.getAccountId());
-            companyVoiceRoboticCallLog.setCompanyUserId(companyWxAccount.getCompanyUserId());
-
-            // 调用接口查询通话其他信息
-            TaskInfo dialogMap = aiCallService.getDialogMapNew(getDialogMap, companyVoiceRoboticCallLog.getCompanyId());
-            // 写入其他记录
-            JSONObject telData = dialogMap.getTelData();
-            companyVoiceRoboticCallLog.setRecordPath((String) telData.getOrDefault("recordPath", ""));
-            companyVoiceRoboticCallLog.setContentList(telData.containsKey("contentList")?telData.getJSONArray("contentList").toJSONString() : "");
-            companyVoiceRoboticCallLog.setCallerNum((String) telData.getOrDefault("callerNum", ""));
-            companyVoiceRoboticCallLog.setCalleeNum((String) telData.getOrDefault("calleeNum", ""));
-            companyVoiceRoboticCallLog.setUuid((String) telData.getOrDefault("uuid", ""));
-            Long createTime =  telData.getLong("createTime");
-            companyVoiceRoboticCallLog.setCallCreateTime(createTime);
-            Long answerTime =  telData.getLong("answerTime");
-            companyVoiceRoboticCallLog.setCallAnswerTime(answerTime);
-            companyVoiceRoboticCallLog.setIntention((String) telData.getOrDefault("intention", ""));
-            companyVoiceRoboticCallLog.setCallTime( telData.getLong("duration"));
-            BigDecimal callCharge = cidConfigVO.getCallCharge();
-            //
-            if(null == callCharge){
-                callCharge = DEFAULT_CALL_CHARGE;
+
+
+            if(StringUtils.isNotBlank(uuid)){
+                getDialogMapDomain getDialogMap = getDialogMapDomain.builder()
+                        .uuid(uuid)
+                        .build();
+                CompanyVoiceRoboticCallLogCallphone companyVoiceRoboticCallLog = companyVoiceRoboticCallLogCallphoneMapper.selectNoResultLogByCallees(callees);
+
+                companyVoiceRoboticCallLog.setStatus(2);
+                companyVoiceRoboticCallLog.setResult(JSON.toJSONString(result));
+
+                CompanyWxClient companyWxClient = companyWxClientServiceImpl.getOne(new QueryWrapper<CompanyWxClient>().eq("robotic_id", callees.getRoboticId()).eq("customer_id", callees.getUserId()));
+                CompanyVoiceRoboticWx roboticWx = companyVoiceRoboticWxServiceImpl.getById(companyWxClient.getRoboticWxId());
+                CompanyWxAccount companyWxAccount = companyWxAccountMapper.selectCompanyWxAccountById(roboticWx.getAccountId());
+                companyVoiceRoboticCallLog.setCompanyUserId(companyWxAccount.getCompanyUserId());
+                // 调用接口查询通话其他信息
+                TaskInfo dialogMap = aiCallService.getDialogMapNew(getDialogMap, companyVoiceRoboticCallLog.getCompanyId());
+                // 写入其他记录
+                JSONObject telData = dialogMap.getTelData();
+                companyVoiceRoboticCallLog.setRecordPath((String) telData.getOrDefault("recordPath", ""));
+                companyVoiceRoboticCallLog.setContentList(telData.containsKey("contentList")?telData.getJSONArray("contentList").toJSONString() : "");
+                companyVoiceRoboticCallLog.setCallerNum((String) telData.getOrDefault("callerNum", ""));
+                companyVoiceRoboticCallLog.setCalleeNum((String) telData.getOrDefault("calleeNum", ""));
+                companyVoiceRoboticCallLog.setUuid((String) telData.getOrDefault("uuid", ""));
+                Long createTime =  telData.getLong("createTime");
+                companyVoiceRoboticCallLog.setCallCreateTime(createTime);
+                Long answerTime =  telData.getLong("answerTime");
+                companyVoiceRoboticCallLog.setCallAnswerTime(answerTime);
+                companyVoiceRoboticCallLog.setIntention((String) telData.getOrDefault("intention", ""));
+                companyVoiceRoboticCallLog.setCallTime( telData.getLong("duration"));
+                BigDecimal callCharge = cidConfigVO.getCallCharge();
+                //
+                if(null == callCharge){
+                    callCharge = DEFAULT_CALL_CHARGE;
+                }
+                //向上取整分钟数
+                BigDecimal divide = new BigDecimal(companyVoiceRoboticCallLog.getCallTime()).divide(ONE_MINUTES_SECOND, 0, RoundingMode.CEILING);
+                BigDecimal multiply = divide.multiply(callCharge);
+                companyVoiceRoboticCallLog.setCost(multiply);
+                baseMapper.updateCompanyVoiceRoboticCallLogCallphone(companyVoiceRoboticCallLog);
             }
-            //向上取整分钟数
-            BigDecimal divide = new BigDecimal(companyVoiceRoboticCallLog.getCallTime()).divide(ONE_MINUTES_SECOND, 0, RoundingMode.CEILING);
-            BigDecimal multiply = divide.multiply(callCharge);
-            companyVoiceRoboticCallLog.setCost(multiply);
-            baseMapper.updateCompanyVoiceRoboticCallLogCallphone(companyVoiceRoboticCallLog);
+
         } catch (Exception ex) {
             log.error("处理回调结果异常:{}", result, ex);
         }

+ 16 - 7
fs-service/src/main/java/com/fs/company/service/impl/CompanyVoiceRoboticServiceImpl.java

@@ -33,6 +33,7 @@ import lombok.Synchronized;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Service;
 
 import java.util.*;
@@ -626,11 +627,13 @@ public class CompanyVoiceRoboticServiceImpl extends ServiceImpl<CompanyVoiceRobo
         return companyVoiceRoboticMapper.qwUserListCompany(companyVoiceRobotic);
     }
 
+    //todo 这个回调方法可优化成异步返回 防止同步阻塞造成多次回调
     @Override
+    @Async
     public void callerResult(PushIIntentionResult result) {
         log.info("进入外呼回调:{}", JSON.toJSONString(result));
         Notify notify = result.getNotify();
-        if(notify == null) return;
+        if(notify == null || StringUtils.isBlank(notify.getUuid())) return;
         if("pushDialogContent".equals(notify.getType())) pushDialogContent(result);
         if("billing".equals(notify.getType())) pushBilling(result);
 //        // 是否全部回调完毕
@@ -645,7 +648,9 @@ public class CompanyVoiceRoboticServiceImpl extends ServiceImpl<CompanyVoiceRobo
                 param.put("callSource","callBack");
                 CompletableFuture.runAsync(()->{
                     companyWorkflowEngine.resumeFromBlockingNode(userData.getString("workflowInstanceId"),userData.getString("nodeKey"),param);
-                },cidWorkFlowExecutor);
+                },cidWorkFlowExecutor).thenRun(()->{
+                    redisCache2.deleteObject(WORKFLOW_CALL_ONE_REDIS_KEY + notify.getUserData());
+                });
             }
             redisCache2.deleteObject(notify.getUserData());
         }
@@ -710,13 +715,17 @@ public class CompanyVoiceRoboticServiceImpl extends ServiceImpl<CompanyVoiceRobo
     }
     public CompanyVoiceRoboticCallees getResultCalleeInfo(Notify notify){
         String cacheString = (String) redisCache2.getCacheObject(WORKFLOW_CALL_ONE_REDIS_KEY + notify.getUserData());
-        JSONObject parse = JSONObject.parseObject(cacheString,JSONObject.class);
-        CompanyVoiceRoboticCallees callee = companyVoiceRoboticCalleesMapper.selectCompanyVoiceRoboticCalleesById(parse.getLong("callerId"));
-        if(callee == null){
-            log.error("回调错误,未找到拨打手机号记录:{}", notify);
+        if(StringUtils.isNotBlank(cacheString)){
+            JSONObject parse = JSONObject.parseObject(cacheString,JSONObject.class);
+            CompanyVoiceRoboticCallees callee = companyVoiceRoboticCalleesMapper.selectCompanyVoiceRoboticCalleesById(parse.getLong("callerId"));
+            if(callee == null){
+                log.error("回调错误,未找到拨打手机号记录:{}", notify);
+                throw new BaseException("回调错误");
+            }
+            return callee;
+        }else{
             throw new BaseException("回调错误");
         }
-        return callee;
     }
 
     @Override

+ 4 - 0
fs-service/src/main/java/com/fs/company/service/impl/CompanyWorkflowServiceImpl.java

@@ -76,6 +76,8 @@ public class CompanyWorkflowServiceImpl implements ICompanyWorkflowService {
             workflow.setCreateTime(now);
             workflow.setStartNodeKey(param.getStartNodeKey());
             workflow.setEndNodeKey(param.getEndNodeKey());
+            workflow.setCompanyId(param.getCompanyId());
+            workflow.setCompanyUserId(param.getCompanyUserId());
             companyWorkflowMapper.insertCompanyWorkflow(workflow);
             workflowId = workflow.getWorkflowId();
         } else {
@@ -89,6 +91,8 @@ public class CompanyWorkflowServiceImpl implements ICompanyWorkflowService {
             workflow.setStartNodeKey(param.getStartNodeKey());
             workflow.setEndNodeKey(param.getEndNodeKey());
             workflow.setUpdateTime(now);
+            workflow.setCompanyId(param.getCompanyId());
+            workflow.setCompanyUserId(param.getCompanyUserId());
             companyWorkflowMapper.updateCompanyWorkflow(workflow);
             // 删除旧的节点和连线
             companyWorkflowNodeMapper.deleteCompanyWorkflowNodeByWorkflowId(workflowId);

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

@@ -8,6 +8,7 @@ import com.fs.common.core.domain.R;
 import com.fs.common.core.redis.RedisCacheT;
 import com.fs.common.utils.DateUtils;
 import com.fs.company.domain.*;
+import com.fs.company.mapper.CompanyAiWorkflowExecLogMapper;
 import com.fs.company.mapper.CompanyAiWorkflowExecMapper;
 import com.fs.company.mapper.CompanyWxAccountMapper;
 import com.fs.company.mapper.CompanyWxClientMapper;
@@ -93,6 +94,8 @@ public class CompanyWxServiceImpl extends ServiceImpl<CompanyWxAccountMapper, Co
     private CompanyAiWorkflowExecMapper companyAiWorkflowExecMapper;
     @Autowired
     private CompanyWorkflowEngine companyWorkflowEngine;
+    @Autowired
+    private CompanyAiWorkflowExecLogMapper companyAiWorkflowExecLogMapper;
 
 
 
@@ -547,9 +550,19 @@ public class CompanyWxServiceImpl extends ServiceImpl<CompanyWxAccountMapper, Co
             // 查找等待中的加微工作流实例
             CompanyAiWorkflowExec waitingExec = companyAiWorkflowExecMapper.selectWaitingAddWxWorkflowByWxClientId(
                     wxClientId,
-                    ExecutionStatusEnum.WAITING.getValue(),
+                    ExecutionStatusEnum.PAUSED.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());
+            List<CompanyAiWorkflowExecLog> companyAiWorkflowExecLogs = companyAiWorkflowExecLogMapper.selectCompanyAiWorkflowExecLogList(queryP);
+            companyAiWorkflowExecLogs.forEach(log -> {
+                log.setStatus(ExecutionStatusEnum.SUCCESS.getValue());
+                companyAiWorkflowExecLogMapper.updateById(log);
+                }
+            );
             if (waitingExec == null) {
                 log.info("未找到等待中的加微工作流实例 - wxClientId: {}", wxClientId);
                 return;

+ 45 - 15
fs-service/src/main/java/com/fs/company/service/impl/call/node/AbstractWorkflowNode.java

@@ -2,6 +2,7 @@ package com.fs.company.service.impl.call.node;
 
 import com.fasterxml.jackson.core.JsonProcessingException;
 import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fs.common.core.domain.R;
 import com.fs.common.core.redis.RedisCache;
 import com.fs.common.exception.CustomException;
 import com.fs.common.utils.StringUtils;
@@ -14,9 +15,12 @@ import com.fs.company.vo.ExecutionResult;
 import com.fs.enums.ExecutionStatusEnum;
 import com.fs.enums.NodeTypeEnum;
 import lombok.extern.slf4j.Slf4j;
+import org.redisson.api.RLock;
+import org.redisson.api.RedissonClient;
 
 import java.time.LocalDateTime;
 import java.util.*;
+import java.util.concurrent.TimeUnit;
 
 /**
  * @author MixLiu
@@ -36,6 +40,8 @@ public abstract class AbstractWorkflowNode implements IWorkflowNode {
     public static final RedisCache redisCache = SpringUtils.getBean(RedisCache.class);
     public static final WorkflowNodeFactory workflowNodeFactory = SpringUtils.getBean(WorkflowNodeFactory.class);
     public static final ObjectMapper objectMapper = new ObjectMapper();
+    public static final RedissonClient redissonClient = SpringUtils.getBean(RedissonClient.class);
+    protected static final String NODE_EXEC_LOCK_PREFIX = "node_exec_lock_";
 
     protected String nodeKey;
     protected String nodeName;
@@ -53,13 +59,20 @@ public abstract class AbstractWorkflowNode implements IWorkflowNode {
         // 记录执行开始时间
         long startTime = System.currentTimeMillis();
         ExecutionResult result = null;
+        RLock lock = null;
         try {
+            String lockKey = NODE_EXEC_LOCK_PREFIX + context.getWorkflowInstanceId();
+            lock = redissonClient.getLock(lockKey);
+            boolean isLocked;
+            isLocked = lock.tryLock(3, 30, TimeUnit.SECONDS);
+            if (!isLocked) {
+                log.info("实例节点正在执行,上锁失败 - workflowInstanceId: {}", context.getWorkflowInstanceId());
+                return handleExecutionError(new CustomException("实例节点正在执行"), context);
+            }
             // 执行前的通用处理
             preExecute(context);
-
             // 执行具体的业务逻辑
             result = doExecute(context);
-
             // 记录执行时间
             long executionTime = System.currentTimeMillis() - startTime;
             context.setVariable("execution_time_" + nodeKey, executionTime);
@@ -69,13 +82,27 @@ public abstract class AbstractWorkflowNode implements IWorkflowNode {
             return handleExecutionError(e, context);
         } finally {
             postExecute(context, result);
+            if (lock != null && lock.isHeldByCurrentThread()) {
+                lock.unlock();
+            }
         }
     }
 
     @Override
     public ExecutionResult continueExecute(ExecutionContext context) {
+        RLock lock = null;
         try {
+            String lockKey = NODE_EXEC_LOCK_PREFIX + context.getWorkflowInstanceId();
+            lock = redissonClient.getLock(lockKey);
+            boolean isLocked;
+            isLocked = lock.tryLock(3, 30, TimeUnit.SECONDS);
+            if (!isLocked) {
+                return handleExecutionError(new CustomException("实例节点正在执行"), context);
+            }
             CompanyAiWorkflowExec companyAiWorkflowExec = companyAiWorkflowExecMapper.selectByWorkflowInstanceId(context.getWorkflowInstanceId());
+            if (!context.getCurrentNodeKey().equals(companyAiWorkflowExec.getCurrentNodeKey())) {
+                return handleExecutionError(new CustomException("节点不符,当前节点: " + companyAiWorkflowExec.getCurrentNodeKey()), context);
+            }
             log.info("收到继续执行请求 - workflowInstanceId: {}, nodeKey: {}, 当前状态: {}",
                     context.getWorkflowInstanceId(), nodeKey, companyAiWorkflowExec.getStatus());
             CompanyWorkflowNode node = companyWorkflowNodeMapper.selectNodeByNodeKey(nodeKey);
@@ -92,19 +119,22 @@ public abstract class AbstractWorkflowNode implements IWorkflowNode {
         } catch (Exception e) {
             return handleExecutionError(e, context);
         } finally {
-            //更新流程日志信息
-            CompanyAiWorkflowExecLog companyAiWorkflowExecLog = new CompanyAiWorkflowExecLog();
-            companyAiWorkflowExecLog.setWorkflowInstanceId(context.getWorkflowInstanceId());
-            companyAiWorkflowExecLog.setNodeKey(nodeKey);
-            companyAiWorkflowExecLog.setStatus(ExecutionStatusEnum.PAUSED.getValue());
-            List<CompanyAiWorkflowExecLog> companyAiWorkflowExecLogs = companyAiWorkflowExecLogMapper.selectCompanyAiWorkflowExecLogList(companyAiWorkflowExecLog);
-            if (null != companyAiWorkflowExecLogs && !companyAiWorkflowExecLogs.isEmpty()) {
-                CompanyAiWorkflowExecLog fExecLog = companyAiWorkflowExecLogs.get(0);
-                fExecLog.setStatus(ExecutionStatusEnum.SUCCESS.getValue());
-                fExecLog.setEndTime(new Date());
-                long durationInMillis = fExecLog.getEndTime().getTime() - fExecLog.getStartTime().getTime();
-                fExecLog.setDuration(durationInMillis);
-                companyAiWorkflowExecLogMapper.updateById(fExecLog);
+            if (lock != null && lock.isHeldByCurrentThread()) {
+                //更新流程日志信息
+                CompanyAiWorkflowExecLog companyAiWorkflowExecLog = new CompanyAiWorkflowExecLog();
+                companyAiWorkflowExecLog.setWorkflowInstanceId(context.getWorkflowInstanceId());
+                companyAiWorkflowExecLog.setNodeKey(nodeKey);
+                companyAiWorkflowExecLog.setStatus(ExecutionStatusEnum.PAUSED.getValue());
+                List<CompanyAiWorkflowExecLog> companyAiWorkflowExecLogs = companyAiWorkflowExecLogMapper.selectCompanyAiWorkflowExecLogList(companyAiWorkflowExecLog);
+                if (null != companyAiWorkflowExecLogs && !companyAiWorkflowExecLogs.isEmpty()) {
+                    CompanyAiWorkflowExecLog fExecLog = companyAiWorkflowExecLogs.get(0);
+                    fExecLog.setStatus(ExecutionStatusEnum.SUCCESS.getValue());
+                    fExecLog.setEndTime(new Date());
+                    long durationInMillis = fExecLog.getEndTime().getTime() - fExecLog.getStartTime().getTime();
+                    fExecLog.setDuration(durationInMillis);
+                    companyAiWorkflowExecLogMapper.updateById(fExecLog);
+                }
+                lock.unlock();
             }
         }
     }

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

@@ -73,7 +73,7 @@ public class AiAddWxTaskNode extends AbstractWorkflowNode {
             List<CompanyWorkflowEdge> cList = edges.stream().filter(a ->
                             StringUtils.isNotBlank(a.getConditionExpr()) && JSONObject.parseArray(a.getConditionExpr(), AiCallWorkflowConditionVo.class).get(0).isAdd())
                     .collect(Collectors.toList());
-            if(null != cList && !cList.isEmpty()){
+            if(null != cList && !cList.isEmpty() && nodeKey.equals(exec.getCurrentNodeKey())){
                 super.runNextNode(context, cList.get(0));
             }
             // 加微成功,设置为等待状态,等待下一次回调

+ 2 - 2
fs-service/src/main/java/com/fs/company/service/impl/call/node/AiCallTaskNode.java

@@ -64,7 +64,7 @@ public class AiCallTaskNode extends AbstractWorkflowNode {
                 //拨通
                 if (condition.isCallConnected() && callRes.getCallTime() != null && callRes.getCallTime() > 0) {
                     //如果含有意向度过滤
-                    if (null != condition.getIntention()) {
+                    if (StringUtils.isNotBlank(condition.getIntention())) {
                         if (condition.getIntention().equals(callRes.getIntention())) {
                             super.runNextNode(context, edge);
                         }
@@ -75,7 +75,7 @@ public class AiCallTaskNode extends AbstractWorkflowNode {
                 //未拨通
                 else if (!condition.isCallConnected() && (callRes.getCallTime() == null || Long.valueOf(0).equals(callRes.getCallTime()) || callRes.getCallAnswerTime() == null)) {
                     //延时操作
-                    if (null != condition.getCallTime()) {
+                    if (null != condition.getCallTime() && condition.getCallTime() > 0) {
                         //计算延时分片分钟
                         long l = System.currentTimeMillis() + condition.getCallTime() * 60 * 1000;
                         ExecutionContext nextContext = context.clone();

+ 1 - 0
fs-service/src/main/java/com/fs/company/service/impl/call/node/AiSendMsgTaskNode.java

@@ -56,6 +56,7 @@ public class AiSendMsgTaskNode extends AbstractWorkflowNode {
     @Override
     protected ExecutionResult doExecute(ExecutionContext context) {
         try {
+            Thread.sleep(1000L);
             // 获取业务数据
             CompanyVoiceRoboticBusiness business = super.getRoboticBusiness(context.getWorkflowInstanceId());
             if (business == null) {

+ 10 - 0
fs-service/src/main/java/com/fs/company/service/impl/call/node/EndNode.java

@@ -1,9 +1,11 @@
 package com.fs.company.service.impl.call.node;
 
 import com.fs.common.utils.spring.SpringUtils;
+import com.fs.company.domain.CompanyAiWorkflowExecLog;
 import com.fs.company.mapper.CompanyWorkflowNodeMapper;
 import com.fs.company.param.ExecutionContext;
 import com.fs.company.vo.ExecutionResult;
+import com.fs.enums.ExecutionStatusEnum;
 import com.fs.enums.NodeTypeEnum;
 
 import java.util.Map;
@@ -33,4 +35,12 @@ public class EndNode extends AbstractWorkflowNode {
     public NodeTypeEnum getType() {
         return NodeTypeEnum.END;
     }
+
+    /**
+     * 执行后的后处理
+     */
+    @Override
+    protected void postExecute(ExecutionContext context, ExecutionResult result) {
+      super.postExecute(context, result);
+    }
 }

+ 4 - 0
fs-service/src/main/resources/mapper/company/CompanyWorkflowMapper.xml

@@ -131,6 +131,7 @@
             <if test="companyUserId != null">company_user_id,</if>
             <if test="startNodeKey != null">start_node_key,</if>
             <if test="endNodeKey != null">end_node_key,</if>
+            <if test="companyId != null">company_id,</if>
         </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="workflowName != null and workflowName != ''">#{workflowName},</if>
@@ -145,6 +146,7 @@
             <if test="companyUserId != null">#{companyUserId},</if>
             <if test="startNodeKey != null">#{startNodeKey},</if>
             <if test="endNodeKey != null">#{endNodeKey},</if>
+            <if test="companyId != null">#{companyId},</if>
         </trim>
     </insert>
     <insert id="insertCompanyWorkflowCompanyUser">
@@ -187,6 +189,8 @@
             <if test="remark != null">remark = #{remark},</if>
             <if test="startNodeKey != null">start_node_key = #{startNodeKey},</if>
             <if test="endNodeKey != null">end_node_key = #{endNodeKey},</if>
+            <if test="companyId != null">company_id = #{companyId},</if>
+            <if test="companyUserId != null">company_user_id = #{companyUserId},</if>
         </trim>
         where workflow_id = #{workflowId}
     </update>

+ 1 - 1
fs-user-app/src/main/java/com/fs/framework/aspectj/lock/DistributeLockAspect.java

@@ -5,7 +5,7 @@ import org.aspectj.lang.annotation.Around;
 import org.aspectj.lang.annotation.Aspect;
 import org.aspectj.lang.reflect.MethodSignature;
 import org.redisson.api.RLock;
-import org.redisson.api.RedissonClient;
+import org.redisson.api.;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.core.StandardReflectionParameterNameDiscoverer;

+ 1 - 1
fs-wx-task/src/main/java/com/fs/FsWxTaskApplication.java

@@ -13,7 +13,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
 @SpringBootApplication(exclude = { DataSourceAutoConfiguration.class })
 @EnableTransactionManagement
 @EnableAsync
-//@EnableScheduling
+@EnableScheduling
 public class FsWxTaskApplication
 {
     public static void main(String[] args){

+ 19 - 5
fs-wx-task/src/main/java/com/fs/app/task/WxTask.java

@@ -2,9 +2,12 @@ package com.fs.app.task;
 
 import com.fs.app.service.WxTaskService;
 import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Component;
 
+import java.util.Collections;
+
 /**
  * 企业微信SOP定时任务管理类
  * 负责处理各种定时任务,包括SOP规则检查、消息发送、数据清理等
@@ -16,13 +19,17 @@ import org.springframework.stereotype.Component;
 @Slf4j
 public class WxTask {
 
+    @Autowired
     private WxTaskService taskService;
 
     @Scheduled(cron = "0 0/30 * * * ?")
     public void addWx() {
         taskService.addWx(null);
     }
-
+    @Scheduled(cron = "0 0/3 * * * ?")
+    public void addWx4Workflow() {
+        taskService.addWx4Workflow(null);
+    }
     @Scheduled(cron = "0 0 0 * * ?")
     public void initAccountNum() {
         taskService.initAccountNum();
@@ -37,10 +44,10 @@ public class WxTask {
     public void cellRun() {
         taskService.cellRun();
     }
-    @Scheduled(cron = "0 0/1 * * * ?")
-    public void callNextTask(){
-        taskService.callNextTask();
-    }
+//    @Scheduled(cron = "0 0/1 * * * ?")
+//    public void callNextTask(){
+//        taskService.callNextTask();
+//    }
 
     /**
      * 工作流加微超时检测
@@ -51,4 +58,11 @@ public class WxTask {
         taskService.checkWorkflowAddWxTimeout();
     }
 
+    @Scheduled(cron = "0 0/1 * * * ?")
+    public void cidWorkflowAddWxRun(){
+        taskService.cidWorkflowAddWxRun();
+    }
+
+
+
 }