|
|
@@ -13,20 +13,20 @@ import com.ruoyi.aicall.service.ICcCallTaskService;
|
|
|
import com.ruoyi.aicall.service.ICcLlmAgentAccountService;
|
|
|
import com.ruoyi.aicall.service.ICcTtsAliyunService;
|
|
|
import com.ruoyi.aicall.utils.ClientIpCheck;
|
|
|
-import com.ruoyi.cc.domain.CcBizGroup;
|
|
|
-import com.ruoyi.cc.domain.CcGateways;
|
|
|
-import com.ruoyi.cc.service.ICcBizGroupService;
|
|
|
-import com.ruoyi.cc.service.ICcGatewaysService;
|
|
|
-import com.ruoyi.cc.service.ICcParamsService;
|
|
|
+import com.ruoyi.cc.domain.*;
|
|
|
+import com.ruoyi.cc.service.*;
|
|
|
import com.ruoyi.cc.utils.DateValidatorUtils;
|
|
|
import com.ruoyi.common.core.controller.BaseController;
|
|
|
import com.ruoyi.common.core.domain.AjaxResult;
|
|
|
+import com.ruoyi.common.core.domain.entity.SysUser;
|
|
|
import com.ruoyi.common.core.page.TableDataInfo;
|
|
|
import com.ruoyi.common.utils.DateUtils;
|
|
|
+import com.ruoyi.common.utils.ShiroUtils;
|
|
|
import com.ruoyi.common.utils.StringUtils;
|
|
|
import com.ruoyi.common.utils.bean.BeanUtils;
|
|
|
import com.ruoyi.common.utils.uuid.UuidGenerator;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.lang3.RandomUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
@@ -45,6 +45,10 @@ public class ApiController extends BaseController {
|
|
|
@Autowired
|
|
|
private ICcCallPhoneService ccCallPhoneService;
|
|
|
@Autowired
|
|
|
+ private ICcInboundCdrService inboundCdrService;
|
|
|
+ @Autowired
|
|
|
+ private ICcOutboundCdrService outboundCdrService;
|
|
|
+ @Autowired
|
|
|
private ICcParamsService paramsService;
|
|
|
@Autowired
|
|
|
private ICcGatewaysService ccGatewaysService;
|
|
|
@@ -56,6 +60,10 @@ public class ApiController extends BaseController {
|
|
|
private ICcCallTaskService ccCallTaskService;
|
|
|
@Autowired
|
|
|
private ICcTtsAliyunService ccTtsAliyunService;
|
|
|
+ @Autowired
|
|
|
+ private ICcExtNumService ccExtNumService;
|
|
|
+ @Autowired
|
|
|
+ private ICcParamsService ccParamsService;
|
|
|
|
|
|
/**
|
|
|
* 获取外呼网关列表接口
|
|
|
@@ -118,7 +126,7 @@ public class ApiController extends BaseController {
|
|
|
JSONObject obj = new JSONObject();
|
|
|
obj.put("voiceName", ttsAliyun.getVoiceName());
|
|
|
obj.put("voiceCode", ttsAliyun.getVoiceCode());
|
|
|
- obj.put("voiceSource", "aliyun_tts");
|
|
|
+ obj.put("voiceSource", ttsAliyun.getVoiceSource());
|
|
|
result.add(obj);
|
|
|
}
|
|
|
return AjaxResult.success(result);
|
|
|
@@ -133,10 +141,10 @@ public class ApiController extends BaseController {
|
|
|
@GetMapping("/busigroup/list")
|
|
|
@ResponseBody
|
|
|
public AjaxResult getBusigroupList(HttpServletRequest req){
|
|
|
- // 校验客户端ip是否在白名单内
|
|
|
- if (!ClientIpCheck.checkIp(req)) {
|
|
|
- return AjaxResult.error(AjaxResult.Type.NO_AUTH, "未授权,请联系系统管理员添加ip白名单!", "");
|
|
|
- }
|
|
|
+// // 校验客户端ip是否在白名单内
|
|
|
+// if (!ClientIpCheck.checkIp(req)) {
|
|
|
+// return AjaxResult.error(AjaxResult.Type.NO_AUTH, "未授权,请联系系统管理员添加ip白名单!", "");
|
|
|
+// }
|
|
|
// 获取技能组列表
|
|
|
List<CcBizGroup> list = ccBizGroupService.selectCcBizGroupList(new CcBizGroup());
|
|
|
return AjaxResult.success(list);
|
|
|
@@ -216,6 +224,42 @@ public class ApiController extends BaseController {
|
|
|
return tableDataInfo;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 根据uuid查询
|
|
|
+ * @param req
|
|
|
+ * @param uuid
|
|
|
+ * @param callType
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @GetMapping("/record/uuid")
|
|
|
+ @ResponseBody
|
|
|
+ public AjaxResult getRecordByUuid(HttpServletRequest req, @RequestParam String uuid, @RequestParam String callType)
|
|
|
+ {
|
|
|
+ // 校验客户端ip是否在白名单内
|
|
|
+ if (!ClientIpCheck.checkIp(req)) {
|
|
|
+ return AjaxResult.error(AjaxResult.Type.NO_AUTH, "未授权,请联系系统管理员添加ip白名单!", "");
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(callType)) {
|
|
|
+ return AjaxResult.error(AjaxResult.Type.INVALID_PARAM, "callType不能为空!", "");
|
|
|
+
|
|
|
+ }
|
|
|
+ // 01:呼入, 02:AI外呼, 03:人工外呼
|
|
|
+ ApiCallRecordQueryParams queryParams = new ApiCallRecordQueryParams().setUuid(uuid).setCallType(callType);
|
|
|
+ TableDataInfo tableDataInfo = new TableDataInfo();
|
|
|
+ if ("01".equals(callType)) {
|
|
|
+ tableDataInfo = getInboundRecords(queryParams);
|
|
|
+ } else if ("02".equals(callType)) {
|
|
|
+ tableDataInfo = getAiCallRecords(queryParams);
|
|
|
+ } else if ("03".equals(callType)) {
|
|
|
+ tableDataInfo = getOutboundRecords(queryParams);
|
|
|
+ }
|
|
|
+ if (null != tableDataInfo.getRows() && tableDataInfo.getRows().size() > 0) {
|
|
|
+ return AjaxResult.success(tableDataInfo.getRows().get(0));
|
|
|
+ } else {
|
|
|
+ return AjaxResult.success();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 通话记录查询接口(支持按时间、坐席、号码、呼入/呼出类型筛选)
|
|
|
* @param req
|
|
|
@@ -236,6 +280,11 @@ public class ApiController extends BaseController {
|
|
|
return tableDataInfo;
|
|
|
}
|
|
|
// 分页参数处理
|
|
|
+ if (null == queryParams.getPageNum()
|
|
|
+ && null == queryParams.getPageSize()) {
|
|
|
+ queryParams.setPageNum(1);
|
|
|
+ queryParams.setPageSize(200000);
|
|
|
+ }
|
|
|
if (null == queryParams.getPageNum()) {
|
|
|
queryParams.setPageNum(1);
|
|
|
}
|
|
|
@@ -269,12 +318,13 @@ public class ApiController extends BaseController {
|
|
|
return tableDataInfo;
|
|
|
}
|
|
|
|
|
|
+ // 01:呼入, 02:AI外呼, 03:人工外呼
|
|
|
if ("01".equals(callType)) {
|
|
|
- // TODO
|
|
|
+ return getInboundRecords(queryParams);
|
|
|
} else if ("02".equals(callType)) {
|
|
|
return getAiCallRecords(queryParams);
|
|
|
} else if ("03".equals(callType)) {
|
|
|
- // TODO
|
|
|
+ return getOutboundRecords(queryParams);
|
|
|
} else {
|
|
|
tableDataInfo = new TableDataInfo();
|
|
|
tableDataInfo.setTotal(0);
|
|
|
@@ -282,7 +332,6 @@ public class ApiController extends BaseController {
|
|
|
tableDataInfo.setMsg("callType参数不合法,呼入请输入01,AI外呼请输入02,手工外呼请输入03!");
|
|
|
return tableDataInfo;
|
|
|
}
|
|
|
- return null;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -438,7 +487,7 @@ public class ApiController extends BaseController {
|
|
|
continue;
|
|
|
}
|
|
|
JSONObject bizJson = new JSONObject();
|
|
|
- CcCallPhone callPhone = buildCcCallPhone(ccCallTask.getBatchId(), phoneNum, bizJson);
|
|
|
+ CcCallPhone callPhone = buildCcCallPhone(ccCallTask, phoneNum, bizJson);
|
|
|
callPhoneList.add(callPhone);
|
|
|
successCount ++;
|
|
|
if (callPhoneList.size() >= 200) {
|
|
|
@@ -496,7 +545,7 @@ public class ApiController extends BaseController {
|
|
|
if (StringUtils.isBlank(phoneNum)) {
|
|
|
continue;
|
|
|
}
|
|
|
- CcCallPhone callPhone = buildCcCallPhone(ccCallTask.getBatchId(), phoneNum, commonPhoneModel.getBizJson());
|
|
|
+ CcCallPhone callPhone = buildCcCallPhone(ccCallTask, phoneNum, commonPhoneModel.getBizJson());
|
|
|
callPhone.setTtsText(commonPhoneModel.getNoticeContent());
|
|
|
callPhoneList.add(callPhone);
|
|
|
successCount ++;
|
|
|
@@ -532,7 +581,7 @@ public class ApiController extends BaseController {
|
|
|
|
|
|
// 追加名单
|
|
|
JSONObject bizJson = new JSONObject();
|
|
|
- CcCallPhone callPhone = buildCcCallPhone(ccCallTask.getBatchId(), phoneNum, bizJson);
|
|
|
+ CcCallPhone callPhone = buildCcCallPhone(ccCallTask, phoneNum, bizJson);
|
|
|
callPhone.setTtsText(noticeCallModel.getNoticeContent());
|
|
|
ccCallPhoneService.insertCcCallPhone(callPhone);
|
|
|
|
|
|
@@ -545,11 +594,11 @@ public class ApiController extends BaseController {
|
|
|
return AjaxResult.success();
|
|
|
}
|
|
|
|
|
|
- private CcCallPhone buildCcCallPhone(Long batchId, String phoneNum, JSONObject bizJson) {
|
|
|
+ private CcCallPhone buildCcCallPhone(CcCallTask ccCallTask, String phoneNum, JSONObject bizJson) {
|
|
|
CcCallPhone callPhone = new CcCallPhone();
|
|
|
callPhone.setId(UuidGenerator.GetOneUuid());
|
|
|
callPhone.setGroupId("1");
|
|
|
- callPhone.setBatchId(batchId);
|
|
|
+ callPhone.setBatchId(ccCallTask.getBatchId());
|
|
|
callPhone.setCreatetime(new Date().getTime());
|
|
|
callPhone.setCallstatus(0);
|
|
|
callPhone.setCalloutTime(0L);
|
|
|
@@ -575,10 +624,159 @@ public class ApiController extends BaseController {
|
|
|
bizJson.put("tailNum", phoneNum);
|
|
|
}
|
|
|
callPhone.setCustName(bizJson.getString("custName"));
|
|
|
+ if (null == callPhone.getCustName()) {
|
|
|
+ callPhone.setCustName("");
|
|
|
+ }
|
|
|
+ callPhone.setBizJson(JSONObject.toJSONString(bizJson));
|
|
|
+ if (ccCallTask.getTaskType() == 1) {
|
|
|
+ callPhone.setIntent("");
|
|
|
+ } else {
|
|
|
+ callPhone.setIntent("-");
|
|
|
+ }
|
|
|
return callPhone;
|
|
|
}
|
|
|
|
|
|
|
|
|
+
|
|
|
+ private TableDataInfo getOutboundRecords(ApiCallRecordQueryParams queryParams) {
|
|
|
+
|
|
|
+ Map<String, Object> params = new HashMap<>();
|
|
|
+ params.put("inboundTimeStart", queryParams.getCalloutTimeStart());
|
|
|
+ params.put("inboundTimeEnd", queryParams.getCalloutTimeEnd());
|
|
|
+ if (null != queryParams.getTimeLenStart()) {
|
|
|
+ params.put("timeLenSecondStart", queryParams.getTimeLenStart().toString());
|
|
|
+ }
|
|
|
+ if (null != queryParams.getTimeLenEnd()) {
|
|
|
+ params.put("timeLenSecondEnd", queryParams.getTimeLenEnd().toString());
|
|
|
+ }
|
|
|
+
|
|
|
+ startPage(queryParams.getPageNum(), queryParams.getPageSize());
|
|
|
+ CcOutboundCdr outboundCdr = new CcOutboundCdr();
|
|
|
+ outboundCdr.setUuid(queryParams.getUuid());
|
|
|
+ outboundCdr.setCaller(queryParams.getTelephone());
|
|
|
+ outboundCdr.setOpnum(queryParams.getExtnum());
|
|
|
+ outboundCdr.setParams(params);
|
|
|
+ List<CcOutboundCdr> list = outboundCdrService.selectCcOutboundCdrList(outboundCdr);
|
|
|
+ TableDataInfo tableData = getDataTable(list);
|
|
|
+ List<CcOutboundCdr> records = (List<CcOutboundCdr>) tableData.getRows();
|
|
|
+ List<ApiCallRecordQueryResult> apiRecords = new ArrayList<>();
|
|
|
+ for (CcOutboundCdr data: records) {
|
|
|
+ ApiCallRecordQueryResult apiData = new ApiCallRecordQueryResult();
|
|
|
+ if (data.getRecordFilename().startsWith("/")) {
|
|
|
+ data.setRecordFilename(data.getRecordFilename().substring(1));
|
|
|
+ }
|
|
|
+ data.setWavFileUrl("/recordings/files?filename=" + data.getRecordFilename());
|
|
|
+ apiData.setUuid(data.getUuid());
|
|
|
+ apiData.setTelephone(data.getCallee());
|
|
|
+ apiData.setCalloutTime(DateUtils.format(new Date(data.getStartTime()), "yyyy-MM-dd HH:mm:ss"));
|
|
|
+ if (data.getAnsweredTime() > 0) {
|
|
|
+ apiData.setAnsweredTime(DateUtils.format(new Date(data.getAnsweredTime()), "yyyy-MM-dd HH:mm:ss"));
|
|
|
+ } else {
|
|
|
+ apiData.setAnsweredTime("");
|
|
|
+ }
|
|
|
+ if (data.getEndTime() > 0) {
|
|
|
+ apiData.setCallEndTime(DateUtils.format(new Date(data.getEndTime()), "yyyy-MM-dd HH:mm:ss"));
|
|
|
+ } else {
|
|
|
+ apiData.setCallEndTime("");
|
|
|
+ }
|
|
|
+ apiData.setHangupCause(data.getHangupCause());
|
|
|
+ if (data.getTimeLen() > 0) {
|
|
|
+ apiData.setWavFileUrl(data.getWavFileUrl());
|
|
|
+ } else {
|
|
|
+ apiData.setWavFileUrl("");
|
|
|
+ }
|
|
|
+ apiData.setDialogue(new JSONArray());
|
|
|
+ apiData.setTimeLen(Long.valueOf(data.getTimeLen()/1000).intValue());
|
|
|
+ apiRecords.add(apiData);
|
|
|
+ }
|
|
|
+ tableData.setRows(records);
|
|
|
+ TableDataInfo tableDataInfo = new TableDataInfo();
|
|
|
+ tableDataInfo.setCode(tableData.getCode());
|
|
|
+ tableDataInfo.setRows(apiRecords);
|
|
|
+ tableDataInfo.setTotal(tableData.getTotal());
|
|
|
+ tableDataInfo.setMsg(tableData.getMsg());
|
|
|
+ return tableDataInfo;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private TableDataInfo getInboundRecords(ApiCallRecordQueryParams queryParams) {
|
|
|
+
|
|
|
+ Map<String, Object> params = new HashMap<>();
|
|
|
+ params.put("inboundTimeStart", queryParams.getCalloutTimeStart());
|
|
|
+ params.put("inboundTimeEnd", queryParams.getCalloutTimeEnd());
|
|
|
+ if (null != queryParams.getTimeLenStart()) {
|
|
|
+ params.put("timeLenSecondStart", queryParams.getTimeLenStart().toString());
|
|
|
+ }
|
|
|
+ if (null != queryParams.getTimeLenEnd()) {
|
|
|
+ params.put("timeLenSecondEnd", queryParams.getTimeLenEnd().toString());
|
|
|
+ }
|
|
|
+
|
|
|
+ startPage(queryParams.getPageNum(), queryParams.getPageSize());
|
|
|
+ CcInboundCdr inboundCdr = new CcInboundCdr();
|
|
|
+ inboundCdr.setUuid(queryParams.getUuid());
|
|
|
+ inboundCdr.setCaller(queryParams.getTelephone());
|
|
|
+ inboundCdr.setOpnum(queryParams.getExtnum());
|
|
|
+ inboundCdr.setParams(params);
|
|
|
+ List<CcInboundCdr> list = inboundCdrService.selectCcInboundCdrList(inboundCdr);
|
|
|
+ TableDataInfo tableData = getDataTable(list);
|
|
|
+ List<CcInboundCdr> records = (List<CcInboundCdr>) tableData.getRows();
|
|
|
+ List<ApiCallRecordQueryResult> apiRecords = new ArrayList<>();
|
|
|
+ for (CcInboundCdr data: records) {
|
|
|
+ ApiCallRecordQueryResult apiData = new ApiCallRecordQueryResult();
|
|
|
+ if (data.getWavFile().startsWith("/")) {
|
|
|
+ data.setWavFile(data.getWavFile().substring(1));
|
|
|
+ }
|
|
|
+ data.setWavFileUrl("/recordings/files?filename=" + data.getWavFile());
|
|
|
+ apiData.setUuid(data.getUuid());
|
|
|
+ apiData.setTelephone(data.getCaller());
|
|
|
+ apiData.setCalloutTime(DateUtils.format(new Date(data.getInboundTime()), "yyyy-MM-dd HH:mm:ss"));
|
|
|
+ if (data.getAnsweredTime() > 0) {
|
|
|
+ apiData.setAnsweredTime(DateUtils.format(new Date(data.getAnsweredTime()), "yyyy-MM-dd HH:mm:ss"));
|
|
|
+ } else {
|
|
|
+ apiData.setAnsweredTime("");
|
|
|
+ }
|
|
|
+ if (data.getHangupTime() > 0) {
|
|
|
+ apiData.setCallEndTime(DateUtils.format(new Date(data.getHangupTime()), "yyyy-MM-dd HH:mm:ss"));
|
|
|
+ } else {
|
|
|
+ apiData.setCallEndTime("");
|
|
|
+ }
|
|
|
+ apiData.setHangupCause("");
|
|
|
+ if (data.getTimeLen() > 0) {
|
|
|
+ apiData.setWavFileUrl(data.getWavFileUrl());
|
|
|
+ } else {
|
|
|
+ apiData.setWavFileUrl("");
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(data.getChatContent())) {
|
|
|
+ JSONArray dialogue = new JSONArray();
|
|
|
+ JSONArray.parseArray(data.getChatContent()).forEach(obj -> {
|
|
|
+ JSONObject json = (JSONObject) obj;
|
|
|
+ if ("assistant".equals(json.getString("role"))
|
|
|
+ || "user".equals(json.getString("role"))) {
|
|
|
+ JSONObject content = new JSONObject();
|
|
|
+ content.put("role", json.getString("role"));
|
|
|
+ content.put("content", json.getString("content"));
|
|
|
+ dialogue.add(content);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ apiData.setDialogue(dialogue);
|
|
|
+ } else {
|
|
|
+ apiData.setDialogue(new JSONArray());
|
|
|
+ }
|
|
|
+ apiData.setTimeLen(Long.valueOf(data.getTimeLen()/1000).intValue());
|
|
|
+ apiData.setManualAnsweredTime(data.getManualAnsweredTime());
|
|
|
+ apiData.setManualAnsweredTimeLen(data.getManualAnsweredTimeLen());
|
|
|
+ apiRecords.add(apiData);
|
|
|
+ }
|
|
|
+ tableData.setRows(records);
|
|
|
+ TableDataInfo tableDataInfo = new TableDataInfo();
|
|
|
+ tableDataInfo.setCode(tableData.getCode());
|
|
|
+ tableDataInfo.setRows(apiRecords);
|
|
|
+ tableDataInfo.setTotal(tableData.getTotal());
|
|
|
+ tableDataInfo.setMsg(tableData.getMsg());
|
|
|
+ return tableDataInfo;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
private TableDataInfo getAiCallRecords(ApiCallRecordQueryParams queryParams) {
|
|
|
|
|
|
Map<String, Object> params = new HashMap<>();
|
|
|
@@ -593,6 +791,14 @@ public class ApiController extends BaseController {
|
|
|
|
|
|
startPage(queryParams.getPageNum(), queryParams.getPageSize());
|
|
|
CcCallPhone ccCallPhone = new CcCallPhone();
|
|
|
+ if (null != queryParams.getBatchId() && queryParams.getBatchId() > 0) {
|
|
|
+ ccCallPhone.setBatchId(queryParams.getBatchId());
|
|
|
+ }
|
|
|
+ ccCallPhone.setUuid(queryParams.getUuid());
|
|
|
+ ccCallPhone.setTelephone(queryParams.getTelephone());
|
|
|
+ ccCallPhone.setAcdOpnum(queryParams.getExtnum());
|
|
|
+ ccCallPhone.setCallstatus(queryParams.getCallstatus());
|
|
|
+ ccCallPhone.setCallerNumber(queryParams.getCallerNumber());
|
|
|
ccCallPhone.setParams(params);
|
|
|
List<CcCallPhone> list = ccCallPhoneService.selectCcCallPhoneList(ccCallPhone);
|
|
|
TableDataInfo tableData = getDataTable(list);
|
|
|
@@ -640,6 +846,11 @@ public class ApiController extends BaseController {
|
|
|
apiData.setDialogue(new JSONArray());
|
|
|
}
|
|
|
apiData.setTimeLen(Long.valueOf(data.getTimeLen()/1000).intValue());
|
|
|
+ apiData.setSessionId(data.getId());
|
|
|
+ apiData.setCallstatus(data.getCallstatus());
|
|
|
+ apiData.setCallerNumber(data.getCallerNumber());
|
|
|
+ apiData.setManualAnsweredTime(data.getManualAnsweredTime());
|
|
|
+ apiData.setManualAnsweredTimeLen(data.getManualAnsweredTimeLen());
|
|
|
apiRecords.add(apiData);
|
|
|
}
|
|
|
tableData.setRows(records);
|
|
|
@@ -701,8 +912,10 @@ public class ApiController extends BaseController {
|
|
|
if (StringUtils.isBlank(voiceCode) || StringUtils.isBlank(voiceSource)) {
|
|
|
return false;
|
|
|
}
|
|
|
- // voiceSource仅支持aliyun_tts
|
|
|
- if (!"aliyun_tts".equals(voiceSource)) {
|
|
|
+ // voiceSource仅支持aliyun_tts 、 aliyun_tts_flow 和 doubao_vcl_tts
|
|
|
+ if (!"aliyun_tts".equals(voiceSource)
|
|
|
+ && !"aliyun_tts_flow".equals(voiceSource)
|
|
|
+ && !"doubao_vcl_tts".equals(voiceSource)) {
|
|
|
return false;
|
|
|
}
|
|
|
// voiceCode必须是存在的
|
|
|
@@ -712,4 +925,139 @@ public class ApiController extends BaseController {
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 行稳数智追加名单【不自动启动任务,需要在任务管理页面手动启动任务】
|
|
|
+ * @param req
|
|
|
+ * @param localCallModel
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @PostMapping("/local/addCall")
|
|
|
+ @ResponseBody
|
|
|
+ public AjaxResult addLocalCall(HttpServletRequest req, @RequestBody LocalCallModel localCallModel) {
|
|
|
+// if (!ClientIpCheck.checkIp(req)) {
|
|
|
+// return AjaxResult.error(AjaxResult.Type.NO_AUTH, "未授权,请联系系统管理员添加ip白名单", "");
|
|
|
+// }
|
|
|
+ // 获取任务
|
|
|
+ String batchName = localCallModel.getBatchName();
|
|
|
+ if (StringUtils.isEmpty(batchName)) {
|
|
|
+ batchName = paramsService.getParamValueByCode("testNoticeCallTaskName", "test");
|
|
|
+ }
|
|
|
+ CcCallTask ccCallTask = callTaskService.selectCcCallTaskByBatchName(batchName, 1);
|
|
|
+
|
|
|
+ log.info("接收到名单localCallModel:{}", JSONObject.toJSONString(localCallModel));
|
|
|
+ log.info("batchName:{}", batchName);
|
|
|
+ log.info("ccCallTask:{}", JSONObject.toJSONString(ccCallTask));
|
|
|
+
|
|
|
+ // 追加名单
|
|
|
+ String phoneNum = localCallModel.getPhone();
|
|
|
+ JSONObject bizJson = new JSONObject();
|
|
|
+ bizJson.put("caller", localCallModel.getCaller());
|
|
|
+ bizJson.put("welcomeMessage", localCallModel.getWelcomeMessage());
|
|
|
+ bizJson.put("questionChainId", localCallModel.getQuestionChainId());
|
|
|
+ CcCallPhone callPhone = buildCcCallPhone(ccCallTask, phoneNum, bizJson);
|
|
|
+ ccCallPhoneService.insertCcCallPhone(callPhone);
|
|
|
+
|
|
|
+ // 暂时关闭自动启动逻辑(后续改成自动启停逻辑)
|
|
|
+// // 如果停止超过5分钟,则自动启动
|
|
|
+// if (ccCallTask.getIfcall() == 0
|
|
|
+// && (System.currentTimeMillis() - ccCallTask.getStopTime()) >= 5*60*1000L) {
|
|
|
+// ccCallTask.setIfcall(1);
|
|
|
+// ccCallTask.setExecuting(0L);
|
|
|
+// ccCallTask.setStopTime(0L);
|
|
|
+// callTaskService.updateCcCallTask(ccCallTask);
|
|
|
+// }
|
|
|
+
|
|
|
+ JSONObject res = new JSONObject();
|
|
|
+ res.put("sessionId", callPhone.getId().toString());
|
|
|
+ log.info("名单处理完成:{}", JSONObject.toJSONString(callPhone));
|
|
|
+
|
|
|
+ return AjaxResult.success(res);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 自动绑定并获取分机信息
|
|
|
+ * @param req
|
|
|
+ * @param loginUser
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @GetMapping("/phoneBar/extnum/bind")
|
|
|
+ @ResponseBody
|
|
|
+ public AjaxResult getExtNumByUserName(HttpServletRequest req, @RequestParam String loginUser) {
|
|
|
+
|
|
|
+ // 获取分机号
|
|
|
+ CcExtNum ccExtNum = ccExtNumService.selectCcExtNumByUserCode(loginUser);
|
|
|
+ if (null != ccExtNum) {
|
|
|
+ return AjaxResult.success("success", ccExtNum);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 如果没有获取到分机,则自动绑定分机
|
|
|
+ List<CcExtNum> ccExtNumList = ccExtNumService.selectUnBindCcExtNumList();
|
|
|
+ if (CollectionUtils.isEmpty(ccExtNumList)) {
|
|
|
+ log.error("没有可用分机,无法分配分机-:{}", loginUser);
|
|
|
+ return AjaxResult.error("没有可用分机,无法分配分机");
|
|
|
+ }
|
|
|
+ ccExtNum = ccExtNumList.get(RandomUtils.nextInt(0, ccExtNumList.size()));
|
|
|
+ ccExtNum.setUserCode(loginUser);
|
|
|
+ ccExtNumService.updateCcExtNum(ccExtNum);
|
|
|
+ return AjaxResult.success("success", ccExtNum);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取电话工具条的网关列表
|
|
|
+ * @param req
|
|
|
+ * @param extNum
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @GetMapping("/phoneBar/params")
|
|
|
+ @ResponseBody
|
|
|
+ public AjaxResult getPhoneBaseParams(HttpServletRequest req, @RequestParam String extNum) {
|
|
|
+
|
|
|
+ // 获取分机号
|
|
|
+ CcExtNum ccExtNum = ccExtNumService.selectCcExtNumByExtNum(Long.valueOf(extNum));
|
|
|
+
|
|
|
+ String extnum = ccExtNum.getExtNum().toString();
|
|
|
+ String opnum = ccExtNum.getUserCode();
|
|
|
+ String groupId = "1";
|
|
|
+ String skillLevel = "9";
|
|
|
+ String projectId = "1";
|
|
|
+ String loginToken = ccExtNumService.createToken(extnum, opnum, groupId, skillLevel, projectId);
|
|
|
+ // 网关用途 0 dropped; 1 phonebar; 2 outbound tasks; 3. Unlimited
|
|
|
+ Map<String, Object> params = new HashMap<>();
|
|
|
+ params.put("purposes", Arrays.asList(1,3));
|
|
|
+ List<CcGateways> gatewaysList = ccGatewaysService.selectCcGatewaysList(new CcGateways().setParams(params));
|
|
|
+ List<JSONObject> gatewayList = new ArrayList<>();
|
|
|
+ for (CcGateways ccGateways: gatewaysList) {
|
|
|
+ JSONObject configGateway = new JSONObject();
|
|
|
+ configGateway.put("uuid", ccGateways.getId().toString());
|
|
|
+ configGateway.put("updateTime", ccGateways.getUpdateTime());
|
|
|
+ configGateway.put("gatewayAddr", ccGateways.getGwAddr());
|
|
|
+ configGateway.put("callerNumber", ccGateways.getCaller());
|
|
|
+ configGateway.put("calleePrefix", ccGateways.getCalleePrefix());
|
|
|
+ configGateway.put("callProfile", ccGateways.getProfileName());
|
|
|
+ configGateway.put("priority", ccGateways.getPriority());
|
|
|
+ configGateway.put("concurrency", ccGateways.getMaxConcurrency());
|
|
|
+ configGateway.put("register", ccGateways.getRegister());
|
|
|
+ configGateway.put("authUsername", ccGateways.getAuthUsername());
|
|
|
+ configGateway.put("audioCodec", ccGateways.getCodec());
|
|
|
+ gatewayList.add(configGateway);
|
|
|
+ }
|
|
|
+ JSONObject callConfig = new JSONObject();
|
|
|
+
|
|
|
+ String scriptServer = ccParamsService.getParamValueByCode("call-center-server-ip-addr", "");
|
|
|
+ String scriptPort = ccParamsService.getParamValueByCode("call-center-websocket-port", "");
|
|
|
+
|
|
|
+ callConfig.put("scriptServer", scriptServer);
|
|
|
+ callConfig.put("scriptPort", scriptPort);
|
|
|
+ callConfig.put("loginToken", loginToken);
|
|
|
+ callConfig.put("gatewayList", gatewayList);
|
|
|
+
|
|
|
+ return AjaxResult.success(callConfig);
|
|
|
+
|
|
|
+ }
|
|
|
}
|