|
@@ -10,16 +10,21 @@ import com.fs.common.annotation.Log;
|
|
|
import com.fs.common.core.controller.BaseController;
|
|
import com.fs.common.core.controller.BaseController;
|
|
|
import com.fs.common.core.domain.AjaxResult;
|
|
import com.fs.common.core.domain.AjaxResult;
|
|
|
import com.fs.common.core.domain.R;
|
|
import com.fs.common.core.domain.R;
|
|
|
|
|
+import com.fs.common.core.domain.model.LoginUser;
|
|
|
import com.fs.common.core.page.TableDataInfo;
|
|
import com.fs.common.core.page.TableDataInfo;
|
|
|
import com.fs.common.enums.BusinessType;
|
|
import com.fs.common.enums.BusinessType;
|
|
|
|
|
+import com.fs.common.utils.ServletUtils;
|
|
|
import com.fs.common.utils.StringUtils;
|
|
import com.fs.common.utils.StringUtils;
|
|
|
import com.fs.common.utils.poi.ExcelUtil;
|
|
import com.fs.common.utils.poi.ExcelUtil;
|
|
|
import com.fs.company.domain.CompanyVoiceRobotic;
|
|
import com.fs.company.domain.CompanyVoiceRobotic;
|
|
|
import com.fs.company.domain.CompanyVoiceRoboticCallees;
|
|
import com.fs.company.domain.CompanyVoiceRoboticCallees;
|
|
|
import com.fs.company.domain.CompanyVoiceRoboticWx;
|
|
import com.fs.company.domain.CompanyVoiceRoboticWx;
|
|
|
|
|
+import com.fs.company.service.ICompanyVoiceRoboticCallLogCallphoneService;
|
|
|
import com.fs.company.service.ICompanyVoiceRoboticCalleesService;
|
|
import com.fs.company.service.ICompanyVoiceRoboticCalleesService;
|
|
|
import com.fs.company.service.ICompanyVoiceRoboticService;
|
|
import com.fs.company.service.ICompanyVoiceRoboticService;
|
|
|
import com.fs.company.service.ICompanyVoiceRoboticWxService;
|
|
import com.fs.company.service.ICompanyVoiceRoboticWxService;
|
|
|
|
|
+import com.fs.company.vo.CalleeRoboticCallOutCountVO;
|
|
|
|
|
+import com.fs.framework.web.service.TokenService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
@@ -27,6 +32,8 @@ import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
import java.util.Arrays;
|
|
import java.util.Arrays;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
+import java.util.Map;
|
|
|
|
|
+import java.util.Objects;
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -47,6 +54,10 @@ public class CompanyVoiceRoboticController extends BaseController
|
|
|
private AiCallService aiCallService;
|
|
private AiCallService aiCallService;
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private ICompanyVoiceRoboticWxService companyVoiceRoboticWxService;
|
|
private ICompanyVoiceRoboticWxService companyVoiceRoboticWxService;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private TokenService tokenService;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private ICompanyVoiceRoboticCallLogCallphoneService companyVoiceRoboticCallLogCallphoneService;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 查询机器人外呼任务列表
|
|
* 查询机器人外呼任务列表
|
|
@@ -71,6 +82,22 @@ public class CompanyVoiceRoboticController extends BaseController
|
|
|
public TableDataInfo calleesList(Long id){
|
|
public TableDataInfo calleesList(Long id){
|
|
|
startPage();
|
|
startPage();
|
|
|
List<CompanyVoiceRoboticCallees> list = companyVoiceRoboticCalleesService.selectCompanyVoiceRoboticCalleesListByRoboticId(id);
|
|
List<CompanyVoiceRoboticCallees> list = companyVoiceRoboticCalleesService.selectCompanyVoiceRoboticCalleesListByRoboticId(id);
|
|
|
|
|
+ if (list != null && !list.isEmpty() && id != null) {
|
|
|
|
|
+ Long companyId = null;
|
|
|
|
|
+ LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
|
|
|
|
+ if (loginUser != null && loginUser.getUser() != null) {
|
|
|
|
|
+ companyId = loginUser.getUser().getCompanyId();
|
|
|
|
|
+ }
|
|
|
|
|
+ List<Long> calleeIds = list.stream().map(CompanyVoiceRoboticCallees::getId).filter(Objects::nonNull).distinct().collect(Collectors.toList());
|
|
|
|
|
+ if (!calleeIds.isEmpty()) {
|
|
|
|
|
+ Map<Long, Long> countMap = companyVoiceRoboticCallLogCallphoneService.countRoboticCallOutByCalleeIds(calleeIds, id, companyId).stream()
|
|
|
|
|
+ .collect(Collectors.toMap(CalleeRoboticCallOutCountVO::getCalleeId, CalleeRoboticCallOutCountVO::getCallCount, (a, b) -> a));
|
|
|
|
|
+ for (CompanyVoiceRoboticCallees row : list) {
|
|
|
|
|
+ long n = row.getId() == null ? 0L : countMap.getOrDefault(row.getId(), 0L);
|
|
|
|
|
+ row.setRoboticCallOutCount((int) n);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
return getDataTable(list);
|
|
return getDataTable(list);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -137,39 +164,42 @@ public class CompanyVoiceRoboticController extends BaseController
|
|
|
@DeleteMapping("/{ids}")
|
|
@DeleteMapping("/{ids}")
|
|
|
public AjaxResult remove(@PathVariable Long[] ids)
|
|
public AjaxResult remove(@PathVariable Long[] ids)
|
|
|
{
|
|
{
|
|
|
- return toAjax(companyVoiceRoboticService.deleteCompanyVoiceRoboticByIds(ids));
|
|
|
|
|
|
|
+ for (Long id : ids) {
|
|
|
|
|
+ companyVoiceRoboticService.updateDelFlag(id, 1);
|
|
|
|
|
+ }
|
|
|
|
|
+ return AjaxResult.success();
|
|
|
}
|
|
}
|
|
|
/**
|
|
/**
|
|
|
* 删除机器人外呼任务
|
|
* 删除机器人外呼任务
|
|
|
*/
|
|
*/
|
|
|
@GetMapping("/getTypes")
|
|
@GetMapping("/getTypes")
|
|
|
- public R getTypes(){
|
|
|
|
|
- List<GetairobotResult> getairobotlist = aiCallService.getairobotlist();
|
|
|
|
|
- List<EditDialogResult> editDialogResults = aiCallService.queryDialog();
|
|
|
|
|
|
|
+ public R getTypes(Long companyId){
|
|
|
|
|
+ List<GetairobotResult> getairobotlist = aiCallService.getairobotlist(companyId);
|
|
|
|
|
+ List<EditDialogResult> editDialogResults = aiCallService.queryDialog(companyId);
|
|
|
return R.ok().put("robot", getairobotlist).put("dialog", editDialogResults);
|
|
return R.ok().put("robot", getairobotlist).put("dialog", editDialogResults);
|
|
|
}
|
|
}
|
|
|
/**
|
|
/**
|
|
|
* 查询状态
|
|
* 查询状态
|
|
|
*/
|
|
*/
|
|
|
@GetMapping("/statusList")
|
|
@GetMapping("/statusList")
|
|
|
- public R statusList(String ids){
|
|
|
|
|
|
|
+ public R statusList(String ids, Long companyId){
|
|
|
List<String> list = Arrays.stream(ids.split(",")).filter(StringUtils::isNotEmpty).collect(Collectors.toList());
|
|
List<String> list = Arrays.stream(ids.split(",")).filter(StringUtils::isNotEmpty).collect(Collectors.toList());
|
|
|
- return R.ok().put("data", list.stream().map(e -> aiCallService.queryCallTaskInfo(TaskInfo.builder().taskID(e).build())).collect(Collectors.toMap(QueryCallTaskInfoResult::getTaskID, e -> e)));
|
|
|
|
|
|
|
+ return R.ok().put("data", list.stream().map(e -> aiCallService.queryCallTaskInfo(TaskInfo.builder().taskID(e).build(), companyId)).collect(Collectors.toMap(QueryCallTaskInfoResult::getTaskID, e -> e)));
|
|
|
}
|
|
}
|
|
|
/**
|
|
/**
|
|
|
* 启动任务
|
|
* 启动任务
|
|
|
*/
|
|
*/
|
|
|
@GetMapping("/startRobotic")
|
|
@GetMapping("/startRobotic")
|
|
|
- public R startRobotic(String taskId){
|
|
|
|
|
- aiCallService.startCallTask(TaskInfo.builder().taskID(taskId).build());
|
|
|
|
|
|
|
+ public R startRobotic(String taskId, Long companyId){
|
|
|
|
|
+ aiCallService.startCallTask(TaskInfo.builder().taskID(taskId).build(), companyId);
|
|
|
return R.ok();
|
|
return R.ok();
|
|
|
}
|
|
}
|
|
|
/**
|
|
/**
|
|
|
* 停止任务
|
|
* 停止任务
|
|
|
*/
|
|
*/
|
|
|
@GetMapping("/stopRobotic")
|
|
@GetMapping("/stopRobotic")
|
|
|
- public R stopRobotic(String taskId){
|
|
|
|
|
- aiCallService.stopCallTask(TaskInfo.builder().taskID(taskId).build());
|
|
|
|
|
|
|
+ public R stopRobotic(String taskId, Long companyId){
|
|
|
|
|
+ aiCallService.stopCallTask(TaskInfo.builder().taskID(taskId).build(), companyId);
|
|
|
return R.ok();
|
|
return R.ok();
|
|
|
}
|
|
}
|
|
|
/**
|
|
/**
|
|
@@ -197,4 +227,12 @@ public class CompanyVoiceRoboticController extends BaseController
|
|
|
companyVoiceRoboticService.dispenseWx(id);
|
|
companyVoiceRoboticService.dispenseWx(id);
|
|
|
return R.ok();
|
|
return R.ok();
|
|
|
}
|
|
}
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 启动任务
|
|
|
|
|
+ */
|
|
|
|
|
+ @GetMapping("/taskRun")
|
|
|
|
|
+ public R taskRun(Long id){
|
|
|
|
|
+ companyVoiceRoboticService.taskRun(id);
|
|
|
|
|
+ return R.ok();
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|