|
|
@@ -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);
|