|
@@ -20,10 +20,7 @@ import com.fs.common.utils.*;
|
|
|
import com.fs.company.domain.*;
|
|
import com.fs.company.domain.*;
|
|
|
import com.fs.company.mapper.*;
|
|
import com.fs.company.mapper.*;
|
|
|
import com.fs.company.service.*;
|
|
import com.fs.company.service.*;
|
|
|
-import com.fs.company.vo.AddWxClientVo;
|
|
|
|
|
-import com.fs.company.vo.CompanyVoiceRoboticQwUserListVo;
|
|
|
|
|
-import com.fs.company.vo.RoboticWxAccountVo;
|
|
|
|
|
-import com.fs.company.vo.RoboticWxVo;
|
|
|
|
|
|
|
+import com.fs.company.vo.*;
|
|
|
import com.fs.crm.domain.CrmCustomer;
|
|
import com.fs.crm.domain.CrmCustomer;
|
|
|
import com.fs.crm.mapper.CrmCustomerMapper;
|
|
import com.fs.crm.mapper.CrmCustomerMapper;
|
|
|
import com.fs.crm.param.SmsSendBatchParam;
|
|
import com.fs.crm.param.SmsSendBatchParam;
|
|
@@ -172,20 +169,24 @@ public class CompanyVoiceRoboticServiceImpl extends ServiceImpl<CompanyVoiceRobo
|
|
|
List<CompanyVoiceRoboticCallLogCallphone> addLogs = new ArrayList<>();
|
|
List<CompanyVoiceRoboticCallLogCallphone> addLogs = new ArrayList<>();
|
|
|
// 构建三方接口请求数据
|
|
// 构建三方接口请求数据
|
|
|
CalltaskcreateaiCustomizeDomain param = new CalltaskcreateaiCustomizeDomain();
|
|
CalltaskcreateaiCustomizeDomain param = new CalltaskcreateaiCustomizeDomain();
|
|
|
|
|
+ param.setCIDGroupID(companyVoiceRobotic.getCidGroupId().toString());
|
|
|
param.setRobot(companyVoiceRobotic.getRobot());
|
|
param.setRobot(companyVoiceRobotic.getRobot());
|
|
|
param.setDialogID(companyVoiceRobotic.getDialogId());
|
|
param.setDialogID(companyVoiceRobotic.getDialogId());
|
|
|
param.setMode(companyVoiceRobotic.getMode());
|
|
param.setMode(companyVoiceRobotic.getMode());
|
|
|
// 保存外呼电话列表
|
|
// 保存外呼电话列表
|
|
|
- List<CompanyVoiceRoboticCallees> calleesList = customerList.stream().map(e -> {
|
|
|
|
|
- CompanyVoiceRoboticCallees entity = new CompanyVoiceRoboticCallees();
|
|
|
|
|
- entity.setUserId(e.getCustomerId());
|
|
|
|
|
- entity.setUserName(e.getCustomerName());
|
|
|
|
|
- entity.setPhone(e.getMobile());
|
|
|
|
|
- entity.setRoboticId(companyVoiceRobotic.getId());
|
|
|
|
|
- return entity;
|
|
|
|
|
- }).collect(Collectors.toList());
|
|
|
|
|
- companyVoiceRoboticCalleesMapper.deleteByRoboticId(companyVoiceRobotic.getId());
|
|
|
|
|
- companyVoiceRoboticCalleesMapper.insertCompanyVoiceRoboticCalleesList(calleesList);
|
|
|
|
|
|
|
+// List<CompanyVoiceRoboticCallees> calleesList = customerList.stream().map(e -> {
|
|
|
|
|
+// CompanyVoiceRoboticCallees entity = new CompanyVoiceRoboticCallees();
|
|
|
|
|
+// entity.setUserId(e.getCustomerId());
|
|
|
|
|
+// entity.setUserName(e.getCustomerName());
|
|
|
|
|
+// entity.setPhone(e.getMobile());
|
|
|
|
|
+// entity.setRoboticId(companyVoiceRobotic.getId());
|
|
|
|
|
+// return entity;
|
|
|
|
|
+// }).collect(Collectors.toList());
|
|
|
|
|
+// companyVoiceRoboticCalleesMapper.deleteByRoboticId(companyVoiceRobotic.getId());
|
|
|
|
|
+// companyVoiceRoboticCalleesMapper.insertCompanyVoiceRoboticCalleesList(calleesList);
|
|
|
|
|
+ CompanyVoiceRoboticCallees querP = new CompanyVoiceRoboticCallees();
|
|
|
|
|
+ querP.setRoboticId(companyVoiceRobotic.getId());
|
|
|
|
|
+ List<CompanyVoiceRoboticCallees> calleesList = companyVoiceRoboticCalleesMapper.selectCompanyVoiceRoboticCalleesList(querP);
|
|
|
// 外呼电话列表
|
|
// 外呼电话列表
|
|
|
List<CalleeDomain> mobileList = calleesList.stream().map(e -> CalleeDomain.builder().number(e.getPhone()).userData(e.getId().toString()).build()).collect(Collectors.toList());
|
|
List<CalleeDomain> mobileList = calleesList.stream().map(e -> CalleeDomain.builder().number(e.getPhone()).userData(e.getId().toString()).build()).collect(Collectors.toList());
|
|
|
param.setCallees(mobileList);
|
|
param.setCallees(mobileList);
|
|
@@ -293,7 +294,7 @@ public class CompanyVoiceRoboticServiceImpl extends ServiceImpl<CompanyVoiceRobo
|
|
|
@Synchronized
|
|
@Synchronized
|
|
|
public void sendMsgOne(Long roboticId,Long callerId){
|
|
public void sendMsgOne(Long roboticId,Long callerId){
|
|
|
try{
|
|
try{
|
|
|
- log.info("开始发送短信*************");
|
|
|
|
|
|
|
+ log.info("开始发送短信个人*************");
|
|
|
CompanyVoiceRobotic robotic = companyVoiceRoboticMapper.selectById(roboticId);
|
|
CompanyVoiceRobotic robotic = companyVoiceRoboticMapper.selectById(roboticId);
|
|
|
CompanyVoiceRoboticCallees callees = companyVoiceRoboticCalleesMapper.selectById(callerId);
|
|
CompanyVoiceRoboticCallees callees = companyVoiceRoboticCalleesMapper.selectById(callerId);
|
|
|
CompanyWxClient wxClient = companyWxClientMapper.selectOneByRoboticIdAndUserId(roboticId,callees.getUserId());
|
|
CompanyWxClient wxClient = companyWxClientMapper.selectOneByRoboticIdAndUserId(roboticId,callees.getUserId());
|
|
@@ -304,6 +305,9 @@ public class CompanyVoiceRoboticServiceImpl extends ServiceImpl<CompanyVoiceRobo
|
|
|
CompanySms sms=companySmsService.selectCompanySmsByCompanyId(wxAccount.getCompanyId());
|
|
CompanySms sms=companySmsService.selectCompanySmsByCompanyId(wxAccount.getCompanyId());
|
|
|
if(sms!=null){
|
|
if(sms!=null){
|
|
|
if(sms.getRemainSmsCount()>0){
|
|
if(sms.getRemainSmsCount()>0){
|
|
|
|
|
+// if(sms.getRemainSmsCount()<(param.getCustomerIds().length*2)){
|
|
|
|
|
+// return R.error("短信数量不足");
|
|
|
|
|
+// }
|
|
|
SmsSendBatchParam smsSendBatchParam=new SmsSendBatchParam();
|
|
SmsSendBatchParam smsSendBatchParam=new SmsSendBatchParam();
|
|
|
smsSendBatchParam.setSmsType(temp.getTempType());
|
|
smsSendBatchParam.setSmsType(temp.getTempType());
|
|
|
smsSendBatchParam.setCompanyId(wxAccount.getCompanyId());
|
|
smsSendBatchParam.setCompanyId(wxAccount.getCompanyId());
|
|
@@ -374,6 +378,74 @@ public class CompanyVoiceRoboticServiceImpl extends ServiceImpl<CompanyVoiceRobo
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+// public void sendMsgTask(Long roboticId) {
|
|
|
|
|
+// try {
|
|
|
|
|
+// //根据任务找到发送短信对象
|
|
|
|
|
+// List<SendMsgByTaskVO> list = companyVoiceRoboticCalleesMapper.getSendMsgTaskListByRoboticId(roboticId);
|
|
|
|
|
+// // 按 companyId 分组
|
|
|
|
|
+// Map<Long, List<SendMsgByTaskVO>> groupedByCompanyId = list.stream()
|
|
|
|
|
+// .collect(Collectors.groupingBy(SendMsgByTaskVO::getCompanyId));
|
|
|
|
|
+// // 遍历每个公司的任务列表
|
|
|
|
|
+// for (Map.Entry<Long, List<SendMsgByTaskVO>> entry : groupedByCompanyId.entrySet()) {
|
|
|
|
|
+// Long companyId = entry.getKey();
|
|
|
|
|
+// List<SendMsgByTaskVO> companyTasks = entry.getValue();
|
|
|
|
|
+// CompanySms sms = companySmsService.selectCompanySmsByCompanyId(companyId);
|
|
|
|
|
+// if(sms!=null){
|
|
|
|
|
+// if(sms.getRemainSmsCount()>0){
|
|
|
|
|
+// if(sms.getRemainSmsCount()<(companyTasks.size()*2)){
|
|
|
|
|
+// log.error("短信数量不足,请充值:task:{},companyId:{}",roboticId,companyId);
|
|
|
|
|
+// continue;
|
|
|
|
|
+// }
|
|
|
|
|
+// // 处理每个公司的任务
|
|
|
|
|
+// for (SendMsgByTaskVO item : companyTasks) {
|
|
|
|
|
+// // 处理逻辑
|
|
|
|
|
+// CompanySmsTemp temp = item.getCompanySmsTemp();
|
|
|
|
|
+// if (temp != null && temp.getStatus().equals(1) && temp.getIsAudit().equals(1)) {
|
|
|
|
|
+// SmsSendBatchParam smsSendBatchParam=new SmsSendBatchParam();
|
|
|
|
|
+// smsSendBatchParam.setSmsType(temp.getTempType());
|
|
|
|
|
+// smsSendBatchParam.setCompanyId(item.getCompanyId());
|
|
|
|
|
+// smsSendBatchParam.setCompanyUserId(item.getCompanyUserId());
|
|
|
|
|
+// smsSendBatchParam.setTempCode(temp.getTempCode());
|
|
|
|
|
+// Long[] ids=new Long[1];
|
|
|
|
|
+// ids[0]=item.getUserId();
|
|
|
|
|
+// smsSendBatchParam.setCustomerIds(ids);
|
|
|
|
|
+// smsSendBatchParam.setContent(temp.getContent());
|
|
|
|
|
+// smsSendBatchParam.setSenderName(item.getWxNickName());
|
|
|
|
|
+// JSONObject runParam = (JSONObject) JSON.toJSON(smsSendBatchParam);
|
|
|
|
|
+// runParam.put("temp",temp);
|
|
|
|
|
+// CompanyVoiceRoboticCallLogSendmsg addLog = CompanyVoiceRoboticCallLogSendmsg.initCallLog(
|
|
|
|
|
+// runParam.toJSONString(), item.getCalleesId(), roboticId,item.getCompanyId(),item.getCompanyUserId(),temp.getTempId());
|
|
|
|
|
+// addLog.setStatus(2);
|
|
|
|
|
+// try{
|
|
|
|
|
+// sendMsgBatch(temp,smsSendBatchParam);
|
|
|
|
|
+// } catch(Exception ex){
|
|
|
|
|
+// addLog.setStatus(3);
|
|
|
|
|
+// addLog.setResult(ex.getMessage());
|
|
|
|
|
+// log.error("sendMsgTask:",ex);
|
|
|
|
|
+// }
|
|
|
|
|
+// int smsContentLen = getSmsContentLen(smsSendBatchParam);
|
|
|
|
|
+// addLog.setContentLen(smsContentLen);
|
|
|
|
|
+// companyVoiceRoboticCallLogSendmsgService.asyncInsertCompanyVoiceRoboticCallLog(addLog);
|
|
|
|
|
+// } else {
|
|
|
|
|
+// log.error("模板未审核,不发送:task:{},calleesId :{} ,smsTemp:{}", roboticId, item.getCalleesId(), temp);
|
|
|
|
|
+// }
|
|
|
|
|
+// }
|
|
|
|
|
+// }
|
|
|
|
|
+// else {
|
|
|
|
|
+// log.error("剩余短信数量不足,请充值:task:{},companyId:{}",roboticId,companyId);
|
|
|
|
|
+// }
|
|
|
|
|
+// }
|
|
|
|
|
+// else{
|
|
|
|
|
+// log.error("sendMsgTask 请充值:task:{},companyId:{}",roboticId,companyId);
|
|
|
|
|
+// }
|
|
|
|
|
+// }
|
|
|
|
|
+// } catch (Exception ex) {
|
|
|
|
|
+// log.error("sendMsgTask异常,roboticId:{}\n", roboticId, ex);
|
|
|
|
|
+// throw new RuntimeException(ex);
|
|
|
|
|
+// }
|
|
|
|
|
+// }
|
|
|
|
|
+
|
|
|
public int getSmsContentLen(SmsSendBatchParam param){
|
|
public int getSmsContentLen(SmsSendBatchParam param){
|
|
|
CompanyUser companyUser=companyUserService.selectCompanyUserById(param.getCompanyUserId());
|
|
CompanyUser companyUser=companyUserService.selectCompanyUserById(param.getCompanyUserId());
|
|
|
|
|
|
|
@@ -400,7 +472,7 @@ public class CompanyVoiceRoboticServiceImpl extends ServiceImpl<CompanyVoiceRobo
|
|
|
* @param param
|
|
* @param param
|
|
|
*/
|
|
*/
|
|
|
public void sendMsgBatch(CompanySmsTemp temp, SmsSendBatchParam param){
|
|
public void sendMsgBatch(CompanySmsTemp temp, SmsSendBatchParam param){
|
|
|
- smsService.batchSmsOp(temp, param);
|
|
|
|
|
|
|
+ smsService.batchSmsOp4AiSend(temp, param);
|
|
|
}
|
|
}
|
|
|
/**
|
|
/**
|
|
|
* 修改机器人外呼任务
|
|
* 修改机器人外呼任务
|
|
@@ -708,4 +780,11 @@ public class CompanyVoiceRoboticServiceImpl extends ServiceImpl<CompanyVoiceRobo
|
|
|
companyVoiceRoboticWxService.updateById(companyVoiceRoboticWx);
|
|
companyVoiceRoboticWxService.updateById(companyVoiceRoboticWx);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void finishAddWxByCallees(Set<Long> roboticIds){
|
|
|
|
|
+ List<Long> notFinishAddWxRobotic = companyVoiceRoboticCalleesMapper.getNotFinishAddWxRobotic(roboticIds);
|
|
|
|
|
+ List<Long> collect = roboticIds.stream().filter(roboticId -> !notFinishAddWxRobotic.contains(roboticId)).collect(Collectors.toList());
|
|
|
|
|
+ companyVoiceRoboticMapper.finishAddWxRobotic(collect);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|