|
|
@@ -127,11 +127,20 @@ public class CompanyVoiceRoboticServiceImpl extends ServiceImpl<CompanyVoiceRobo
|
|
|
return entity;
|
|
|
}).collect(Collectors.toList());
|
|
|
companyVoiceRoboticWxService.saveBatch(collect);
|
|
|
+ List<CompanyWxClient> clients = companyVoiceRobotic.getUserIds().stream().map(e -> {
|
|
|
+ CompanyWxClient client = new CompanyWxClient();
|
|
|
+ client.setRoboticId(companyVoiceRobotic.getId());
|
|
|
+ client.setCustomerId(Long.parseLong(e));
|
|
|
+ return client;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ companyWxClientServiceImpl.saveBatch(clients);
|
|
|
+
|
|
|
return i;
|
|
|
}
|
|
|
|
|
|
public CalltaskcreateaiCustomizeResult addTask(CompanyVoiceRobotic companyVoiceRobotic){
|
|
|
- List<CrmCustomer> customerList = crmCustomerService.selectCrmCustomerListByIds(String.join(",", companyVoiceRobotic.getUserIds()));
|
|
|
+ List<CompanyWxClient> companyWxClientList = companyWxClientServiceImpl.list(new QueryWrapper<CompanyWxClient>().eq("robotic_id", companyVoiceRobotic.getId()));
|
|
|
+ List<CrmCustomer> customerList = crmCustomerService.selectCrmCustomerListByIds(companyWxClientList.stream().map(e -> e.getCustomerId() + "").collect(Collectors.joining(",")));
|
|
|
if(customerList.isEmpty()){
|
|
|
throw new BaseException("拨打电话不能为空");
|
|
|
}
|
|
|
@@ -276,6 +285,8 @@ public class CompanyVoiceRoboticServiceImpl extends ServiceImpl<CompanyVoiceRobo
|
|
|
public void dispenseWx(Long roboticId){
|
|
|
// 任务详情
|
|
|
CompanyVoiceRobotic robotic = getById(roboticId);
|
|
|
+ List<CompanyWxClient> companyWxClientList = companyWxClientServiceImpl.list(new QueryWrapper<CompanyWxClient>().eq("robotic_id", roboticId));
|
|
|
+ Map<Long, CompanyWxClient> clientMap = PubFun.listToMapByGroupObject(companyWxClientList, CompanyWxClient::getCustomerId);
|
|
|
// 拨打电话列表
|
|
|
List<CompanyVoiceRoboticCallees> calleesList = companyVoiceRoboticCalleesMapper.selectByRoboticId(roboticId);
|
|
|
if(calleesList.isEmpty()) return;
|
|
|
@@ -291,16 +302,18 @@ public class CompanyVoiceRoboticServiceImpl extends ServiceImpl<CompanyVoiceRobo
|
|
|
Map<String, List<CrmCustomer>> customerMap = PubFun.listToMapByGroupList(customerList, CrmCustomer::getIntention);
|
|
|
Map<String, List<CompanyVoiceRoboticWx>> roboticWxMap = PubFun.listToMapByGroupList(roboticWxList, CompanyVoiceRoboticWx::getIntention);
|
|
|
// 循环客户
|
|
|
- List<CompanyWxClient> collect = customerMap.entrySet().stream().filter(e -> roboticWxMap.containsKey(e.getKey())).flatMap(map -> {
|
|
|
+ List<CompanyWxClient> collect = customerMap.entrySet().stream().flatMap(map -> {
|
|
|
String k = map.getKey();
|
|
|
List<CrmCustomer> v = map.getValue();
|
|
|
// 对应销售账号列表
|
|
|
List<CompanyVoiceRoboticWx> wxList = roboticWxMap.get(k);
|
|
|
// 组装任务数据
|
|
|
return v.stream().map(e -> {
|
|
|
- CompanyWxClient companyWxClient = new CompanyWxClient();
|
|
|
+ CompanyWxClient companyWxClient = clientMap.get(e.getCustomerId());
|
|
|
// 绑定销售
|
|
|
- bindCompany(companyWxClient, wxList);
|
|
|
+ if(roboticWxMap.containsKey(map.getKey())){
|
|
|
+ bindCompany(companyWxClient, wxList);
|
|
|
+ }
|
|
|
// 任务ID
|
|
|
companyWxClient.setRoboticId(roboticId);
|
|
|
// 客户名称
|
|
|
@@ -317,7 +330,7 @@ public class CompanyVoiceRoboticServiceImpl extends ServiceImpl<CompanyVoiceRobo
|
|
|
});
|
|
|
}).collect(Collectors.toList());
|
|
|
companyVoiceRoboticWxService.updateBatchById(roboticWxList);
|
|
|
- companyWxClientServiceImpl.saveBatch(collect);
|
|
|
+ companyWxClientServiceImpl.updateBatchById(collect);
|
|
|
robotic.setRunTaskFlow((StringUtils.isEmpty(robotic.getRunTaskFlow()) ? "" : robotic.getRunTaskFlow() + ",") + Constants.CELL_PHONE);
|
|
|
companyVoiceRoboticMapper.updateById(robotic);
|
|
|
redisCache.deleteObject(Constants.TASK_ID + robotic.getId());
|