Parcourir la source

新增部分接口

peicj il y a 1 jour
Parent
commit
4d8553af4c

+ 45 - 11
ruoyi-admin/src/main/java/com/ruoyi/aicall/controller/ApiController.java

@@ -17,10 +17,12 @@ import com.ruoyi.aicall.utils.DESUtil;
 import com.ruoyi.cc.domain.*;
 import com.ruoyi.cc.service.*;
 import com.ruoyi.cc.utils.DateValidatorUtils;
+import com.ruoyi.common.annotation.Log;
 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.enums.BusinessType;
 import com.ruoyi.common.utils.DateUtils;
 import com.ruoyi.common.utils.ShiroUtils;
 import com.ruoyi.common.utils.StringUtils;
@@ -31,6 +33,7 @@ import com.ruoyi.framework.shiro.util.AuthorizationUtils;
 import com.ruoyi.system.service.ISysUserService;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.RandomUtils;
+import org.apache.shiro.authz.annotation.RequiresPermissions;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
 import org.springframework.transaction.annotation.Transactional;
@@ -419,6 +422,34 @@ public class ApiController extends BaseController {
         return AjaxResult.success("success", apiCallTaskModel);
     }
 
+    /**
+     * 删除外呼任务
+     */
+    @PostMapping( "/removeTask")
+    @ResponseBody
+    @Transactional
+    public AjaxResult removeTask(@RequestBody Map<String, Long[]> paramMap)
+    {
+        Long[] batchIds= paramMap.get("batchIds");
+        if(batchIds==null){
+            return AjaxResult.error(AjaxResult.Type.INVALID_PARAM, "batchIds不能为空!", "");
+        }
+        for (Long batchId : batchIds) {
+            // 备份拨打记录数据
+            ccCallPhoneService.bakCallPhoneByBatchId(batchId);
+            // 删除拨打记录数据
+            ccCallPhoneService.delCallPhoneByBatchId(batchId);
+            // 备份任务数据
+            ccCallTaskService.bakCallTaskByBatchId(batchId);
+        }
+
+        // 删除任务数据
+        String batchIdsStr = Arrays.stream(batchIds)
+                .map(String::valueOf)
+                .collect(Collectors.joining(","));
+        return toAjax(ccCallTaskService.deleteCcCallTaskByBatchIds(batchIdsStr));
+    }
+
     /**
      * 启动任务接口
      * @param req
@@ -554,16 +585,6 @@ 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));
-        }
 
         // 追加名单
         int successCount = 0;
@@ -586,7 +607,7 @@ public class ApiController extends BaseController {
             ccCallPhoneService.batchInsertCcCallPhone(callPhoneList);
         }
         log.info("成功追加" + successCount + "个名单");
-        return AjaxResult.success("成功追加" + successCount + "个名单");
+        return AjaxResult.success("成功追加" + successCount + "个名单",callPhoneList);
     }
 
 
@@ -1560,4 +1581,17 @@ public class ApiController extends BaseController {
     public AjaxResult taskConnectSum(@RequestBody List<Long> batchIds){
         return AjaxResult.success(ccCallPhoneService.statByBatchIds(batchIds));
     }
+
+    /**
+     * 根据id集合查询自动外呼数据
+     */
+    @PostMapping( "/getCcCallPhoneByIds")
+    @ResponseBody
+    public AjaxResult getCcCallPhoneByIds(@RequestBody List<String> callPhoneIds)
+    {
+        if(callPhoneIds==null){
+            return AjaxResult.error(AjaxResult.Type.INVALID_PARAM, "callPhoneIds不能为空!", "");
+        }
+        return AjaxResult.success(ccCallPhoneService.selectCcCallPhoneListByIds(callPhoneIds));
+    }
 }

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

@@ -96,7 +96,7 @@ public interface CcCallPhoneMapper
 
     void delCallPhoneByBatchId(Long batchId);
 
-    List<String> isDuplicateEntry(@Param("batchId") Long batchId,@Param("phoneList")  List<CommonPhoneModel> phoneList);
-
     List<CcCallPhone> selectCcCallPhoneYlrzList(CcCallPhone ccCallPhone);
+
+    List<CcCallPhone> selectCcCallPhoneListByIds(List<String> callPhoneIds);
 }

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

@@ -3,7 +3,6 @@ package com.ruoyi.aicall.service;
 import com.ruoyi.aicall.domain.CcCallPhone;
 import com.ruoyi.aicall.domain.CcLlmAgentAccount;
 import com.ruoyi.aicall.model.CallTaskStatModel;
-import com.ruoyi.aicall.model.CommonPhoneModel;
 
 import java.util.List;
 
@@ -94,7 +93,7 @@ public interface ICcCallPhoneService
 
     void delCallPhoneByBatchId(Long batchId);
 
-    List<String> isDuplicateEntry(Long batchId, List<CommonPhoneModel> phoneList);
-
     List<CcCallPhone> selectCcCallPhoneYlrzList(CcCallPhone ccCallPhone);
+
+    List<CcCallPhone> selectCcCallPhoneListByIds(List<String> callPhoneIds);
 }

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

@@ -159,6 +159,11 @@ public class CcCallPhoneServiceImpl implements ICcCallPhoneService
         return ccCallPhoneMapper.selectCcCallPhoneYlrzList(ccCallPhone);
     }
 
+    @Override
+    public List<CcCallPhone> selectCcCallPhoneListByIds(List<String> callPhoneIds) {
+        return ccCallPhoneMapper.selectCcCallPhoneListByIds(callPhoneIds);
+    }
+
     /**
      * 新增外呼号码
      * 
@@ -291,9 +296,4 @@ 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);
-    }
 }

+ 55 - 55
ruoyi-admin/src/main/java/com/ruoyi/web/core/config/EslPoolStarter.java

@@ -1,55 +1,55 @@
-package com.ruoyi.web.core.config;
-
-import com.ruoyi.cc.service.ICcParamsService;
-import link.thingscloud.freeswitch.esl.EslConnectionDetail;
-import link.thingscloud.freeswitch.esl.EslConnectionUtil;
-import link.thingscloud.freeswitch.esl.FreeswitchNodeInfo;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.boot.context.event.ApplicationReadyEvent;
-import org.springframework.context.ApplicationListener;
-import org.springframework.stereotype.Component;
-
-import java.util.ArrayList;
-import java.util.List;
-
-@Component
-public class EslPoolStarter implements ApplicationListener<ApplicationReadyEvent> {
-
-    protected final static Logger logger = LoggerFactory.getLogger(EslPoolStarter.class);
-    @Autowired
-    private ICcParamsService ccParamsService;
-
-    @Override
-    public void onApplicationEvent(ApplicationReadyEvent applicationReadyEvent) {
-        logger.info("try to create FreeSWITCH esl connection pool...");
-        List<String> eventSubscriptions = new ArrayList<>();
-
-         String eventsocketip = ccParamsService.getParamValueByCode(
-                 "event-socket-ip", "127.0.0.1");
-         String eventsocketport = ccParamsService.getParamValueByCode(
-                 "event-socket-port", "8021");
-         String eventsocketpass= ccParamsService.getParamValueByCode(
-                 "event-socket-pass", "ClueCon");
-         String eventsocketpoolsize= ccParamsService.getParamValueByCode(
-                 "event-socket-conn-pool-size", "3");
-
-        EslConnectionDetail.setEventSubscriptions(eventSubscriptions);
-        List<FreeswitchNodeInfo> nodeList = new ArrayList<>(8);
-		// read from application.properties
-        String host = eventsocketip;
-        int port = Integer.parseInt(eventsocketport);
-        String pass = eventsocketpass;
-        int poolSize = Integer.parseInt(eventsocketpoolsize);
-        FreeswitchNodeInfo nodeInfo = new FreeswitchNodeInfo();
-        nodeInfo.setHost(host);
-        nodeInfo.setPort(port);
-        nodeInfo.setPass(pass);
-        nodeInfo.setPoolSize(poolSize);
-        nodeList.add(nodeInfo);
-        EslConnectionUtil.initConnPool(nodeList);
-        EslConnectionUtil.setEslExecuteTime(18000);
-    }
-}
+//package com.ruoyi.web.core.config;
+//
+//import com.ruoyi.cc.service.ICcParamsService;
+//import link.thingscloud.freeswitch.esl.EslConnectionDetail;
+//import link.thingscloud.freeswitch.esl.EslConnectionUtil;
+//import link.thingscloud.freeswitch.esl.FreeswitchNodeInfo;
+//import org.slf4j.Logger;
+//import org.slf4j.LoggerFactory;
+//import org.springframework.beans.factory.annotation.Autowired;
+//import org.springframework.beans.factory.annotation.Value;
+//import org.springframework.boot.context.event.ApplicationReadyEvent;
+//import org.springframework.context.ApplicationListener;
+//import org.springframework.stereotype.Component;
+//
+//import java.util.ArrayList;
+//import java.util.List;
+//
+//@Component
+//public class EslPoolStarter implements ApplicationListener<ApplicationReadyEvent> {
+//
+//    protected final static Logger logger = LoggerFactory.getLogger(EslPoolStarter.class);
+//    @Autowired
+//    private ICcParamsService ccParamsService;
+//
+//    @Override
+//    public void onApplicationEvent(ApplicationReadyEvent applicationReadyEvent) {
+//        logger.info("try to create FreeSWITCH esl connection pool...");
+//        List<String> eventSubscriptions = new ArrayList<>();
+//
+//         String eventsocketip = ccParamsService.getParamValueByCode(
+//                 "event-socket-ip", "127.0.0.1");
+//         String eventsocketport = ccParamsService.getParamValueByCode(
+//                 "event-socket-port", "8021");
+//         String eventsocketpass= ccParamsService.getParamValueByCode(
+//                 "event-socket-pass", "ClueCon");
+//         String eventsocketpoolsize= ccParamsService.getParamValueByCode(
+//                 "event-socket-conn-pool-size", "3");
+//
+//        EslConnectionDetail.setEventSubscriptions(eventSubscriptions);
+//        List<FreeswitchNodeInfo> nodeList = new ArrayList<>(8);
+//		// read from application.properties
+//        String host = eventsocketip;
+//        int port = Integer.parseInt(eventsocketport);
+//        String pass = eventsocketpass;
+//        int poolSize = Integer.parseInt(eventsocketpoolsize);
+//        FreeswitchNodeInfo nodeInfo = new FreeswitchNodeInfo();
+//        nodeInfo.setHost(host);
+//        nodeInfo.setPort(port);
+//        nodeInfo.setPass(pass);
+//        nodeInfo.setPoolSize(poolSize);
+//        nodeList.add(nodeInfo);
+//        EslConnectionUtil.initConnPool(nodeList);
+//        EslConnectionUtil.setEslExecuteTime(18000);
+//    }
+//}

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

@@ -295,15 +295,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         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>
-
     <select id="selectCcCallPhoneYlrzList" parameterType="CcCallPhone" resultMap="CcCallPhoneResult">
         select ccp.*, cct.batch_name as batchName from cc_call_phone ccp left join cc_call_task cct on cct.batch_id = ccp.batch_id
         <where>
@@ -358,4 +349,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         </where>
         order by ccp.call_end_time desc
     </select>
+    <select id="selectCcCallPhoneListByIds" parameterType="java.util.List" resultMap="CcCallPhoneResult">
+        <include refid="selectCcCallPhoneVo"/>
+        where id in
+        <foreach item="id" collection="list" open="(" separator="," close=")">
+            #{id}
+        </foreach>
+    </select>
 </mapper>