lmx пре 4 дана
родитељ
комит
b9cb3713b2

+ 3 - 0
fs-service/src/main/java/com/fs/company/mapper/CompanyVoiceRoboticCalleesMapper.java

@@ -5,6 +5,7 @@ import com.fs.company.domain.CompanyVoiceRoboticCallees;
 import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
+import java.util.Set;
 
 /**
  * 任务外呼电话Mapper接口
@@ -72,4 +73,6 @@ public interface CompanyVoiceRoboticCalleesMapper extends BaseMapper<CompanyVoic
     CompanyVoiceRoboticCallees selectDataByCalleesId(@Param("calleesId")Long calleesId);
 
     CompanyVoiceRoboticCallees getCalleesByUserIdAndTaskId(@Param("userId") Long userId,@Param("taskId") Long taskId);
+
+    List<CompanyVoiceRoboticCallees> selectCalleesListByRoboticIdsAndUserIds(@Param("userIds") Set<Long> userIds, @Param("taskIds") Set<Long> taskIds);
 }

+ 13 - 0
fs-service/src/main/resources/mapper/company/CompanyVoiceRoboticCalleesMapper.xml

@@ -99,4 +99,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <select id="getCalleesByUserIdAndTaskId" resultType="CompanyVoiceRoboticCallees" >
         select * from company_voice_robotic_callees where user_id = #{userId} and robotic_id = #{taskId}
     </select>
+
+    <select id="selectCalleesListByRoboticIdsAndUserIds" resultType="CompanyVoiceRoboticCallees">
+        select * from company_voice_robotic_callees
+        where
+        robotic_id in
+        <foreach item="id" collection="taskIds" open="(" separator="," close=")">
+            #{id}
+        </foreach>
+        and user_id in
+        <foreach item="id" collection="userIds" open="(" separator="," close=")">
+            #{id}
+        </foreach>
+    </select>
 </mapper>

+ 34 - 0
fs-wx-task/src/main/java/com/fs/app/service/WxTaskService.java

@@ -130,6 +130,40 @@ public class WxTaskService {
         });
         if(!addList.isEmpty()){
             companyWxClientService.updateBatchById(addList);
+            //根据加微成功的用户,判定是否加入延时执行下一步任务
+            Set<Long> roboticIdSet = addList.stream().map(e -> e.getRoboticId()).collect(Collectors.toSet());
+            Set<Long> userIdSet = addList.stream().map(e -> e.getCustomerId()).collect(Collectors.toSet());
+
+            //找到任务
+            List<CompanyVoiceRobotic> companyVoiceRobotics = companyVoiceRoboticMapper.selectBatchIds(roboticIdSet);
+            Map<Long, CompanyVoiceRobotic> roboticsMp = companyVoiceRobotics.stream().collect(Collectors.toMap(CompanyVoiceRobotic::getId, Function.identity(), (existing, replacement) -> existing));
+            //找到callees数据
+            List<CompanyVoiceRoboticCallees> companyVoiceRoboticCallees = companyVoiceRoboticCalleesMapper.selectCalleesListByRoboticIdsAndUserIds(userIdSet,roboticIdSet);
+            Map<String, CompanyVoiceRoboticCallees> calleesMp = companyVoiceRoboticCallees.stream().collect(Collectors.toMap(e->e.getUserId()+ "-" +e.getRoboticId(), Function.identity(), (existing, replacement) -> existing));
+
+            long l = System.currentTimeMillis();
+
+            //根据加微成功
+            for (CompanyWxClient client : addList) {
+                CompanyVoiceRobotic clientRobotic = roboticsMp.getOrDefault(client.getRoboticId(), null);
+                if(null ==  clientRobotic){
+                    log.error("ROBOTIC-ID:{},CLIENT-ID:{},没有找到任务", client.getRoboticId(), client.getId());
+                    continue;
+                }
+                CompanyVoiceRoboticCallees callees = calleesMp.getOrDefault(client.getCustomerId() + "-" + client.getRoboticId(), null);
+                if(null ==  callees){
+                    log.error("ROBOTIC-ID:{},CLIENT-ID:{},没有找到任务", client.getRoboticId(), client.getId());
+                    continue;
+                }
+                Integer addWxTime = clientRobotic.getAddWxTime();
+                if(null == addWxTime){
+                    log.error("ROBOTIC-ID:{},CLIENT-ID:{},没有设置加微后置等待时间", client.getRoboticId(), client.getId());
+                }
+                long endT = System.currentTimeMillis() + addWxTime * 60 * 1000;
+                StringBuilder sb = new StringBuilder(Constants.CID_NEXT_TASK_ID).append(callees.getRoboticId()).append(":").append(callees.getId());
+                redisCache.setCacheObject(sb.toString(), String.valueOf(endT),addWxTime + 5, TimeUnit.MINUTES);
+            }
+
         }
         if(!addAccountList.isEmpty()){
             companyWxAccountService.updateBatchById(addAccountList);