浏览代码

cid处理报错

lmx 1 周之前
父节点
当前提交
50d645eb47
共有 1 个文件被更改,包括 33 次插入24 次删除
  1. 33 24
      fs-admin/src/main/java/com/fs/his/controller/EasyCallController.java

+ 33 - 24
fs-admin/src/main/java/com/fs/his/controller/EasyCallController.java

@@ -10,6 +10,7 @@ import com.fs.system.domain.SysConfig;
 import com.fs.system.service.ISysConfigService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
@@ -30,6 +31,7 @@ import java.util.stream.Collectors;
 @Api(tags = "EasyCallCenter365外呼管理")
 @RestController
 @RequestMapping("/easyCall")
+@Slf4j
 public class EasyCallController extends BaseController {
 
     @Autowired
@@ -56,37 +58,44 @@ public class EasyCallController extends BaseController {
     @GetMapping("/gateway/getGatewayCompanyList")
     public R getGatewayCompanyList() {
         List<EasyCallGatewayVO> resList = new ArrayList<>();
-        List<EasyCallGatewayVO> list = easyCallService.getGatewayList(null);
-        // 如果原始列表为空,直接返回空列表
-        if (list == null || list.isEmpty()) {
-            return R.ok().put("data", resList);
-        }
-        SysConfig cidConf = iSysConfigService.selectConfigByConfigKey("cId.config");
-        if (null != cidConf && StringUtils.isNotBlank(cidConf.getConfigValue())) {
-            JSONObject jo = JSONObject.parseObject(cidConf.getConfigValue());
-            if (null != jo && jo.containsKey("showGatewayIds")) {
-                List<Long> gatewayIdList = jo.getJSONArray("showGatewayIds").toJavaList(Long.class);
-                if (gatewayIdList != null && !gatewayIdList.isEmpty()) {
-                    // 将配置中的网关ID列表转换为Set集合便于快速匹配
-                    Set<Long> gatewayIdSet = gatewayIdList.stream()
-                            .filter(id -> id != null)
-                            .collect(Collectors.toSet());
-                    // 过滤list,只保留id在配置集合中的网关
-                    resList = list.stream()
-                            .filter(gateway -> gateway.getId() != null && gatewayIdSet.contains(gateway.getId()))
-                            .collect(Collectors.toList());
+        try{
+            List<EasyCallGatewayVO> list = easyCallService.getGatewayList(null);
+            // 如果原始列表为空,直接返回空列表
+            if (list == null || list.isEmpty()) {
+                return R.ok().put("data", resList);
+            }
+            SysConfig cidConf = iSysConfigService.selectConfigByConfigKey("cId.config");
+            if (null != cidConf && StringUtils.isNotBlank(cidConf.getConfigValue())) {
+                JSONObject jo = JSONObject.parseObject(cidConf.getConfigValue());
+                if (null != jo && jo.containsKey("showGatewayIds") && jo.containsKey("enableGateWayLimit")) {
+                    Boolean enableGateWayLimit = jo.getBoolean("enableGateWayLimit");
+                    List<Long> gatewayIdList = jo.getJSONArray("showGatewayIds").toJavaList(Long.class);
+                    if (null != enableGateWayLimit && enableGateWayLimit && gatewayIdList != null && !gatewayIdList.isEmpty()) {
+                        // 将配置中的网关ID列表转换为Set集合便于快速匹配
+                        Set<Long> gatewayIdSet = gatewayIdList.stream()
+                                .filter(id -> id != null)
+                                .collect(Collectors.toSet());
+                        // 过滤list,只保留id在配置集合中的网关
+                        resList = list.stream()
+                                .filter(gateway -> gateway.getId() != null && gatewayIdSet.contains(gateway.getId()))
+                                .collect(Collectors.toList());
+                    } else {
+                        // 配置为空时返回原始列表
+                        resList = list;
+                    }
                 } else {
-                    // 配置为空时返回原始列表
+                    // 未配置showGatewayIds时返回原始列表
                     resList = list;
                 }
             } else {
-                // 未配置showGatewayIds时返回原始列表
+                // 未找到配置时返回原始列表
                 resList = list;
             }
-        } else {
-            // 未找到配置时返回原始列表
-            resList = list;
+        }catch (Exception e){
+            log.error("获取网关列表失败", e);
+            return R.ok().put("msg", e);
         }
+
         return R.ok().put("data", resList);
     }
 }