Bläddra i källkod

对接支撑接口开发

peicj 1 vecka sedan
förälder
incheckning
85d5708185

+ 151 - 2
ruoyi-admin/src/main/java/com/ruoyi/aicall/controller/ApiController.java

@@ -554,9 +554,19 @@ public class ApiController extends BaseController {
                 }
             }
         }
+        //去重,对同一个任务重复录入号码筛选
+        List<String> duplicateList = ccCallPhoneService.isDuplicateEntry(batchId, commonCallListModel.getPhoneList());
+        if (!CollectionUtils.isEmpty(duplicateList)) {
+            commonCallListModel.setPhoneList(commonCallListModel.getPhoneList().stream()
+                    .filter(p -> !duplicateList.contains(p.getPhoneNum()))
+                    .collect(Collectors.toList()));
+        }
+        if (CollectionUtils.isEmpty(commonCallListModel.getPhoneList())) {
+            throw new RuntimeException("过滤重复数据后无有效数据,重复号码:" + String.join(",", duplicateList));
+        }
 
         // 追加名单
-        Integer successCount = 0;
+        int successCount = 0;
         List<CcCallPhone> callPhoneList = new ArrayList<>();
         for (CommonPhoneModel commonPhoneModel : commonCallListModel.getPhoneList()) {
             String phoneNum = commonPhoneModel.getPhoneNum();
@@ -572,7 +582,7 @@ public class ApiController extends BaseController {
                 callPhoneList = new ArrayList<>();
             }
         }
-        if (callPhoneList.size() > 0) {
+        if (!callPhoneList.isEmpty()) {
             ccCallPhoneService.batchInsertCcCallPhone(callPhoneList);
         }
         log.info("成功追加" + successCount + "个名单");
@@ -1256,4 +1266,143 @@ public class ApiController extends BaseController {
         }
         return getDataTable(list);
     }
+
+    /**
+     * 通话记录查询接口(返回完整的数据表格式)
+     */
+    @PostMapping("/call/phone/records")
+    @ResponseBody
+    public TableDataInfo getcallPhoneRecords(HttpServletRequest req, @RequestBody ApiCallRecordQueryParams queryParams)
+    {
+        TableDataInfo tableDataInfo;
+        // 校验请求方ip是否合法
+        if (!ClientIpCheck.checkIp(req)) {
+            tableDataInfo = new TableDataInfo();
+            tableDataInfo.setTotal(0);
+            tableDataInfo.setCode(AjaxResult.Type.NO_AUTH.value());
+            tableDataInfo.setMsg("未授权,请联系系统管理员添加ip白名单!");
+            return tableDataInfo;
+        }
+        // 分页参数处理
+        if (null == queryParams.getPageNum()
+                && null == queryParams.getPageSize()) {
+            queryParams.setPageNum(1);
+            queryParams.setPageSize(200000);
+        }
+        if (null == queryParams.getPageNum()) {
+            queryParams.setPageNum(1);
+        }
+        if (null == queryParams.getPageSize()) {
+            queryParams.setPageSize(20);
+        }
+        // 类型(01:呼入, 02:AI外呼, 03:人工外呼)
+        String callType = queryParams.getCallType();
+        if (StringUtils.isBlank(callType)) {
+            tableDataInfo = new TableDataInfo();
+            tableDataInfo.setTotal(0);
+            tableDataInfo.setCode(AjaxResult.Type.INVALID_PARAM.value());
+            tableDataInfo.setMsg("callType不能为空!");
+            return tableDataInfo;
+        }
+        // 校验参数
+        if (StringUtils.isNotEmpty(queryParams.getCalloutTimeStart())
+                && !DateValidatorUtils.isYmdHms(queryParams.getCalloutTimeStart())) {
+            tableDataInfo = new TableDataInfo();
+            tableDataInfo.setTotal(0);
+            tableDataInfo.setCode(AjaxResult.Type.INVALID_PARAM.value());
+            tableDataInfo.setMsg("calloutTimeStart格式不正确,请使用'yyyy-MM-dd HH:mm:ss'格式!");
+            return tableDataInfo;
+        }
+        if (StringUtils.isNotEmpty(queryParams.getCalloutTimeEnd())
+                && !DateValidatorUtils.isYmdHms(queryParams.getCalloutTimeEnd())) {
+            tableDataInfo = new TableDataInfo();
+            tableDataInfo.setTotal(0);
+            tableDataInfo.setCode(AjaxResult.Type.INVALID_PARAM.value());
+            tableDataInfo.setMsg("calloutTimeStart格式不正确,请使用'yyyy-MM-dd HH:mm:ss'格式!");
+            return tableDataInfo;
+        }
+
+        // 01:呼入, 02:AI外呼, 03:人工外呼
+        if ("01".equals(callType)) {
+            return getInboundRecords(queryParams);
+        } else if ("02".equals(callType)) {
+            return getAiCallRecordsTable(queryParams);
+        } else if ("03".equals(callType)) {
+            return getOutboundRecordsTable(queryParams);
+        } else {
+            tableDataInfo = new TableDataInfo();
+            tableDataInfo.setTotal(0);
+            tableDataInfo.setCode(AjaxResult.Type.INVALID_PARAM.value());
+            tableDataInfo.setMsg("callType参数不合法,呼入请输入01,AI外呼请输入02,手工外呼请输入03!");
+            return tableDataInfo;
+        }
+    }
+    //ai外呼记录查询
+    private TableDataInfo getAiCallRecordsTable(ApiCallRecordQueryParams queryParams) {
+        Map<String, Object> params = new HashMap<>();
+        params.put("calloutTimeStart", queryParams.getCalloutTimeStart());
+        params.put("calloutTimeEnd", 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());
+        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);
+        list.forEach(callPhoneRecord -> {
+            if(StringUtils.isNotBlank(callPhoneRecord.getWavfile())){
+                if (callPhoneRecord.getWavfile().startsWith("/")) {
+                    callPhoneRecord.setWavfile("/recordings/files?filename=" + callPhoneRecord.getWavfile().substring(1));
+                }else{
+                    callPhoneRecord.setWavfile("/recordings/files?filename=" + callPhoneRecord.getWavfile());
+                }
+            }
+        });
+        return getDataTable(list);
+    }
+    //人工外呼记录查询
+    private TableDataInfo getOutboundRecordsTable(ApiCallRecordQueryParams queryParams) {
+        Map<String, Object> params = new HashMap<>();
+        params.put("calloutTimeStart", queryParams.getCalloutTimeStart());
+        params.put("calloutTimeEnd", 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);
+        list.forEach(callPhoneRecord -> {
+            if(StringUtils.isNotBlank(callPhoneRecord.getRecordFilename())){
+                if (callPhoneRecord.getRecordFilename().startsWith("/")) {
+                    callPhoneRecord.setRecordFilename("/recordings/files?filename=" + callPhoneRecord.getRecordFilename().substring(1));
+                }else{
+                    callPhoneRecord.setWavFileUrl("/recordings/files?filename=" + callPhoneRecord.getRecordFilename());
+                }
+            }
+
+        });
+        return getDataTable(list);
+    }
+
+
 }

+ 3 - 1
ruoyi-admin/src/main/java/com/ruoyi/aicall/mapper/CcCallPhoneMapper.java

@@ -2,8 +2,8 @@ package com.ruoyi.aicall.mapper;
 
 import com.ruoyi.aicall.domain.CcCallPhone;
 import com.ruoyi.aicall.model.CallTaskStatModel;
+import com.ruoyi.aicall.model.CommonPhoneModel;
 import org.apache.ibatis.annotations.Param;
-import org.apache.ibatis.annotations.Select;
 
 import java.util.List;
 
@@ -89,4 +89,6 @@ public interface CcCallPhoneMapper
     void bakCallPhoneByBatchId(Long batchId);
 
     void delCallPhoneByBatchId(Long batchId);
+
+    List<String> isDuplicateEntry(@Param("batchId") Long batchId,@Param("phoneList")  List<CommonPhoneModel> phoneList);
 }

+ 3 - 1
ruoyi-admin/src/main/java/com/ruoyi/aicall/service/ICcCallPhoneService.java

@@ -2,8 +2,8 @@ package com.ruoyi.aicall.service;
 
 import com.ruoyi.aicall.domain.CcCallPhone;
 import com.ruoyi.aicall.domain.CcLlmAgentAccount;
-import com.ruoyi.aicall.model.CallPhoneExportVo;
 import com.ruoyi.aicall.model.CallTaskStatModel;
+import com.ruoyi.aicall.model.CommonPhoneModel;
 
 import java.util.List;
 
@@ -87,4 +87,6 @@ public interface ICcCallPhoneService
     void bakCallPhoneByBatchId(Long batchId);
 
     void delCallPhoneByBatchId(Long batchId);
+
+    List<String> isDuplicateEntry(Long batchId, List<CommonPhoneModel> phoneList);
 }

+ 6 - 0
ruoyi-admin/src/main/java/com/ruoyi/aicall/service/impl/CcCallPhoneServiceImpl.java

@@ -9,6 +9,7 @@ import com.ruoyi.aicall.domain.CcLlmAgentAccount;
 import com.ruoyi.aicall.llm.ILlmCapability;
 import com.ruoyi.aicall.llm.model.AccountBaseEntity;
 import com.ruoyi.aicall.model.CallTaskStatModel;
+import com.ruoyi.aicall.model.CommonPhoneModel;
 import com.ruoyi.cc.utils.LlmAccountParser;
 import com.ruoyi.common.utils.DateUtils;
 import com.ruoyi.common.utils.StringUtils;
@@ -224,4 +225,9 @@ public class CcCallPhoneServiceImpl implements ICcCallPhoneService
     public void delCallPhoneByBatchId(Long batchId) {
         ccCallPhoneMapper.delCallPhoneByBatchId(batchId);
     }
+
+    @Override
+    public List<String> isDuplicateEntry(Long batchId, List<CommonPhoneModel> phoneList) {
+        return ccCallPhoneMapper.isDuplicateEntry(batchId,phoneList);
+    }
 }

+ 8 - 0
ruoyi-admin/src/main/java/com/ruoyi/cc/service/impl/CcOutboundCdrServiceImpl.java

@@ -49,6 +49,14 @@ public class CcOutboundCdrServiceImpl implements ICcOutboundCdrService
         if (null == params) {
             params = new HashMap<>();
         }
+        if (null != params.get("calloutTimeStart")
+                && !"".equals(params.get("calloutTimeStart"))) {
+            params.put("calloutTimeStart", DateUtils.dateTime("yyyy-MM-dd HH:mm:ss", (String)params.get("calloutTimeStart")).getTime());
+        }
+        if (null != params.get("calloutTimeEnd")
+                && !"".equals(params.get("calloutTimeEnd"))) {
+            params.put("calloutTimeEnd", DateUtils.dateTime("yyyy-MM-dd HH:mm:ss", (String)params.get("calloutTimeEnd")).getTime());
+        }
         if (null != params.get("startTimeStart")
                 && !"".equals(params.get("startTimeStart"))) {
             params.put("startTimeStart", DateUtils.dateTime("yyyy-MM-dd HH:mm:ss", (String)params.get("startTimeStart")).getTime());

+ 9 - 0
ruoyi-admin/src/main/resources/mapper/aicall/CcCallPhoneMapper.xml

@@ -282,4 +282,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <delete id="delCallPhoneByBatchId" parameterType="Long">
         delete from cc_call_phone where batch_id = #{batchId}
     </delete>
+
+    <select id="isDuplicateEntry" resultType="java.lang.String">
+        SELECT DISTINCT telephone FROM cc_call_phone
+        WHERE batch_id = #{batchId} AND callstatus = 0
+          AND telephone IN
+        <foreach collection="phoneList" item="phone" open="(" separator="," close=")">
+            #{phone.phoneNum}
+        </foreach>
+    </select>
 </mapper>

+ 4 - 4
ruoyi-admin/src/main/resources/mapper/cc/CcOutboundCdrMapper.xml

@@ -31,11 +31,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="caller != null  and caller != ''"> and caller = #{caller}</if>
             <if test="opnum != null  and opnum != ''"> and opnum = #{opnum}</if>
             <if test="callee != null  and callee != ''"> and callee = #{callee}</if>
-            <if test="params.startTimeStart != null and params.startTimeStart != ''"><!-- 开始时间检索 -->
-                AND start_time &gt;= #{params.startTimeStart}
+            <if test="params.calloutTimeStart != null and params.calloutTimeStart != ''"><!-- 开始时间检索 -->
+                AND start_time &gt;= #{params.calloutTimeStart}
             </if>
-            <if test="params.startTimeEnd != null and params.startTimeEnd != ''"><!-- 结束时间检索 -->
-                AND start_time &lt;= #{params.startTimeEnd}
+            <if test="params.calloutTimeEnd != null and params.calloutTimeEnd != ''"><!-- 结束时间检索 -->
+                AND start_time &lt;= #{params.calloutTimeEnd}
             </if>
             <if test="params.answeredTimeStart != null and params.answeredTimeStart != ''"><!-- 开始时间检索 -->
                 AND answered_time &gt;= #{params.answeredTimeStart}

+ 1 - 0
ruoyi-framework/src/main/java/com/ruoyi/framework/config/ShiroConfig.java

@@ -317,6 +317,7 @@ public class ShiroConfig
         filterChainDefinitionMap.put("/aicall/api/getCustCommunicationInfo", "anon");
         filterChainDefinitionMap.put("/aicall/api/add/custcallrecord", "anon");
         filterChainDefinitionMap.put("/aicall/api/outboundcdrList", "anon");
+        filterChainDefinitionMap.put("/aicall/api/call/phone/records", "anon");
 
 
         // 匿名访问不鉴权注解列表