|
@@ -6,7 +6,10 @@ 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.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.SecurityUtils;
|
|
|
import com.fs.common.utils.poi.ExcelUtil;
|
|
import com.fs.common.utils.poi.ExcelUtil;
|
|
|
|
|
+import com.fs.aicall.domain.TaskInfo;
|
|
|
|
|
+import com.fs.aicall.service.AiCallService;
|
|
|
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;
|
|
@@ -17,7 +20,8 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
-import java.util.List;
|
|
|
|
|
|
|
+import java.util.*;
|
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 机器人外呼任务Controller(SaaS管理端)
|
|
* 机器人外呼任务Controller(SaaS管理端)
|
|
@@ -38,6 +42,9 @@ public class CompanyVoiceRoboticController extends BaseController {
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private ICompanyVoiceRoboticWxService companyVoiceRoboticWxService;
|
|
private ICompanyVoiceRoboticWxService companyVoiceRoboticWxService;
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private AiCallService aiCallService;
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 查询机器人外呼任务列表(分页)
|
|
* 查询机器人外呼任务列表(分页)
|
|
|
*/
|
|
*/
|
|
@@ -114,7 +121,7 @@ public class CompanyVoiceRoboticController extends BaseController {
|
|
|
/**
|
|
/**
|
|
|
* 新增机器人外呼任务
|
|
* 新增机器人外呼任务
|
|
|
*/
|
|
*/
|
|
|
- @PreAuthorize("@ss.hasPermi('company:companyVoiceRobotic:add')")
|
|
|
|
|
|
|
+ @PreAuthorize("@ss.hasPermi('system:companyVoiceRobotic:add')")
|
|
|
@Log(title = "机器人外呼任务", businessType = BusinessType.INSERT)
|
|
@Log(title = "机器人外呼任务", businessType = BusinessType.INSERT)
|
|
|
@PostMapping
|
|
@PostMapping
|
|
|
public AjaxResult add(@RequestBody CompanyVoiceRobotic companyVoiceRobotic) {
|
|
public AjaxResult add(@RequestBody CompanyVoiceRobotic companyVoiceRobotic) {
|
|
@@ -134,7 +141,7 @@ public class CompanyVoiceRoboticController extends BaseController {
|
|
|
/**
|
|
/**
|
|
|
* 删除机器人外呼任务
|
|
* 删除机器人外呼任务
|
|
|
*/
|
|
*/
|
|
|
- @PreAuthorize("@ss.hasPermi('company:companyVoiceRobotic:remove')")
|
|
|
|
|
|
|
+ @PreAuthorize("@ss.hasPermi('system:companyVoiceRobotic:remove')")
|
|
|
@Log(title = "机器人外呼任务", businessType = BusinessType.DELETE)
|
|
@Log(title = "机器人外呼任务", businessType = BusinessType.DELETE)
|
|
|
@DeleteMapping("/{ids}")
|
|
@DeleteMapping("/{ids}")
|
|
|
public AjaxResult remove(@PathVariable Long[] ids) {
|
|
public AjaxResult remove(@PathVariable Long[] ids) {
|
|
@@ -149,4 +156,92 @@ public class CompanyVoiceRoboticController extends BaseController {
|
|
|
public R companyUserList() {
|
|
public R companyUserList() {
|
|
|
return R.ok().put("data", companyVoiceRoboticService.qwUserList());
|
|
return R.ok().put("data", companyVoiceRoboticService.qwUserList());
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 启动任务(管理端适配:总后台无 LoginUser.company,通过 SecurityUtils 获取 tenantId)
|
|
|
|
|
+ */
|
|
|
|
|
+ @GetMapping("/taskRun")
|
|
|
|
|
+ public R taskRun(Long id) {
|
|
|
|
|
+ Long tenantId = SecurityUtils.getTenantId();
|
|
|
|
|
+ companyVoiceRoboticService.taskRun(id, tenantId);
|
|
|
|
|
+ return R.ok();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 查询任务执行记录
|
|
|
|
|
+ */
|
|
|
|
|
+ @GetMapping("/execRecords")
|
|
|
|
|
+ public R getExecRecords(@RequestParam Long roboticId,
|
|
|
|
|
+ @RequestParam(defaultValue = "1") Integer pageNum,
|
|
|
|
|
+ @RequestParam(defaultValue = "10") Integer pageSize,
|
|
|
|
|
+ @RequestParam(required = false) String customerName,
|
|
|
|
|
+ @RequestParam(required = false) String customerPhone,
|
|
|
|
|
+ @RequestParam Boolean onlyCallNode) {
|
|
|
|
|
+ return R.ok(companyVoiceRoboticService.getExecRecords(roboticId, pageNum, pageSize,
|
|
|
|
|
+ customerName, customerPhone, onlyCallNode, null));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 查询外呼任务运行状态(管理端适配:通过 taskId 查 companyId 后调用 AiCallService)
|
|
|
|
|
+ */
|
|
|
|
|
+ @GetMapping("/statusList")
|
|
|
|
|
+ public R statusList(String ids) {
|
|
|
|
|
+ if (aiCallService == null) {
|
|
|
|
|
+ return R.error("管理后台暂不支持查询外呼状态");
|
|
|
|
|
+ }
|
|
|
|
|
+ List<String> taskIdList = Arrays.stream(ids.split(","))
|
|
|
|
|
+ .filter(s -> s != null && !s.isEmpty())
|
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
+ Map<String, Object> resultMap = new HashMap<>();
|
|
|
|
|
+ for (String taskId : taskIdList) {
|
|
|
|
|
+ Long companyId = getCompanyIdByTaskId(taskId);
|
|
|
|
|
+ if (companyId != null) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ resultMap.put(taskId, aiCallService.queryCallTaskInfo(
|
|
|
|
|
+ TaskInfo.builder().taskID(taskId).build(), companyId));
|
|
|
|
|
+ } catch (Exception ignored) {
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return R.ok().put("data", resultMap);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 开启外呼任务(管理端适配)
|
|
|
|
|
+ */
|
|
|
|
|
+ @GetMapping("/startRobotic")
|
|
|
|
|
+ public R startRobotic(String taskId) {
|
|
|
|
|
+ if (aiCallService == null) {
|
|
|
|
|
+ return R.error("管理后台暂不支持开启外呼任务");
|
|
|
|
|
+ }
|
|
|
|
|
+ Long companyId = getCompanyIdByTaskId(taskId);
|
|
|
|
|
+ if (companyId == null) {
|
|
|
|
|
+ return R.error("未找到任务对应的公司");
|
|
|
|
|
+ }
|
|
|
|
|
+ aiCallService.startCallTask(TaskInfo.builder().taskID(taskId).build(), companyId);
|
|
|
|
|
+ return R.ok();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 停止外呼任务(管理端适配)
|
|
|
|
|
+ */
|
|
|
|
|
+ @GetMapping("/stopRobotic")
|
|
|
|
|
+ public R stopRobotic(String taskId) {
|
|
|
|
|
+ if (aiCallService == null) {
|
|
|
|
|
+ return R.error("管理后台暂不支持停止外呼任务");
|
|
|
|
|
+ }
|
|
|
|
|
+ Long companyId = getCompanyIdByTaskId(taskId);
|
|
|
|
|
+ if (companyId == null) {
|
|
|
|
|
+ return R.error("未找到任务对应的公司");
|
|
|
|
|
+ }
|
|
|
|
|
+ aiCallService.stopCallTask(TaskInfo.builder().taskID(taskId).build(), companyId);
|
|
|
|
|
+ return R.ok();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 通过 taskId 查询对应的 companyId
|
|
|
|
|
+ */
|
|
|
|
|
+ private Long getCompanyIdByTaskId(String taskId) {
|
|
|
|
|
+ return companyVoiceRoboticService.getCompanyIdByTaskId(taskId);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|