lmx 4 周之前
父節點
當前提交
2f0526ad2f

+ 46 - 5
fs-company/src/main/java/com/fs/company/controller/company/CompanyInboundCallManageController.java

@@ -1,5 +1,6 @@
 package com.fs.company.controller.company;
 
+import com.alibaba.fastjson.JSONObject;
 import com.fs.aicall.domain.CcLlmAgentAccount;
 import com.fs.aicall.service.ICompanyBindAiModelService;
 import com.fs.common.annotation.Log;
@@ -12,6 +13,8 @@ import com.fs.common.utils.StringUtils;
 import com.fs.company.domain.CompanyInboundBind;
 import com.fs.company.domain.EasyCallInboundCdrVO;
 import com.fs.company.mapper.CompanyInboundBindMapper;
+import com.fs.company.mapper.CompanyMapper;
+import com.fs.company.mapper.CompanyVoiceCloneRefMapper;
 import com.fs.company.mapper.EasyCallInboundLlmMapper;
 import com.fs.company.service.ICompanyInboundCallManageService;
 import com.fs.company.vo.easycall.EasyCallBizGroupVO;
@@ -22,14 +25,12 @@ import com.fs.company.vo.easycall.EasyCallLlmAccountVO;
 import com.fs.company.vo.easycall.EasyCallVoiceCodeVO;
 import com.fs.framework.security.LoginUser;
 import com.fs.framework.service.TokenService;
+import com.fs.system.service.ISysConfigService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
 
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 import java.util.stream.Collectors;
 
 /**
@@ -55,6 +56,13 @@ public class CompanyInboundCallManageController extends BaseController {
 
     @Autowired
     private ICompanyBindAiModelService companyBindAiModelService;
+    @Autowired
+    private CompanyVoiceCloneRefMapper companyVoiceCloneRefMapper;
+    @Autowired
+    private ISysConfigService configService;
+
+    @Autowired
+    CompanyMapper companyMapper;
 
     /**
      * 查询呼入大模型配置列表
@@ -213,8 +221,23 @@ public class CompanyInboundCallManageController extends BaseController {
      */
     @GetMapping("/voiceList")
     public AjaxResult getVoiceList(@RequestParam("voiceSource") String voiceSource) {
+        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
+        Long companyId = loginUser.getUser().getCompanyId();
+        List<Long> ttsIds = companyVoiceCloneRefMapper.selectByCompanyIdAndCompanyUserId(companyId, loginUser.getCompany().getUserId());
         List<EasyCallVoiceCodeVO> list = inboundLlmMapper.selectVoiceListBySource(voiceSource);
-        return AjaxResult.success(list);
+        List<EasyCallVoiceCodeVO> result = list.stream()
+                .filter(item ->
+                        item.getPriority() == 1 || (item.getPriority() == 0 && ttsIds.contains(item.getId()))
+                )
+                .map(item -> {
+                    EasyCallVoiceCodeVO vo = new EasyCallVoiceCodeVO();
+                    vo.setVoiceCode(item.getVoiceCode());
+                    vo.setVoiceName(item.getVoiceName());
+                    vo.setVoiceSource(item.getVoiceSource());
+                    return vo;
+                })
+                .collect(Collectors.toList());
+        return AjaxResult.success(result);
     }
 
     /**
@@ -231,7 +254,25 @@ public class CompanyInboundCallManageController extends BaseController {
      */
     @GetMapping("/gatewayList")
     public AjaxResult getGatewayList() {
+        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
+        Long companyId = loginUser.getUser().getCompanyId();
+        String gateWayList = companyMapper.getGateWayList(companyId);
+        String json = configService.selectConfigByKey("cId.config");
         List<EasyCallGatewayVO> list = inboundLlmMapper.selectOutboundGatewayList();
+        if (null != companyId && null != list && !list.isEmpty()) {
+            if(StringUtils.isNotBlank(gateWayList)){
+                List<Long> collect = Arrays.stream(gateWayList.split(",")).map(item -> Long.valueOf(item.trim())).collect(Collectors.toList());
+                list = list.stream().filter(item -> collect.contains(item.getId())).collect(Collectors.toList());
+            }else{
+                if (StringUtils.isNotBlank(json)) {
+                    JSONObject obj = JSONObject.parseObject(json);
+                    if(null != obj && obj.containsKey("showGatewayIds")){
+                        List<Long> showGatewayIds = obj.getJSONArray("showGatewayIds").stream().map(item -> Long.valueOf(item.toString())).collect(Collectors.toList());
+                        list = list.stream().filter(item -> showGatewayIds.contains(item.getId())).collect(Collectors.toList());
+                    }
+                }
+            }
+        }
         return AjaxResult.success(list);
     }
 

+ 3 - 4
fs-service/src/main/java/com/fs/company/vo/easycall/EasyCallVoiceCodeVO.java

@@ -7,14 +7,13 @@ import lombok.Data;
  */
 @Data
 public class EasyCallVoiceCodeVO {
+    /** 主键id */
+    private Integer id;
     /** 音色编号 */
     private String voiceCode;
     /** 音色名称 */
     private String voiceName;
     /** 声音源:aliyun_tts */
     private String voiceSource;
-    /**
-     * 音色模型
-     */
-    private String ttsModels;
+    private Integer priority;
 }

+ 4 - 3
fs-service/src/main/resources/mapper/company/EasyCallInboundLlmMapper.xml

@@ -28,9 +28,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </resultMap>
 
     <resultMap id="VoiceCodeResult" type="com.fs.company.vo.easycall.EasyCallVoiceCodeVO">
+        <id property="id" column="id"/>
         <result property="voiceCode" column="voice_code"/>
         <result property="voiceName" column="voice_name"/>
         <result property="voiceSource" column="voice_source"/>
+        <result property="priority" column="priority"/>
     </resultMap>
 
     <resultMap id="BizGroupResult" type="com.fs.company.vo.easycall.EasyCallBizGroupVO">
@@ -61,7 +63,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
     <select id="selectInboundLlmList" parameterType="com.fs.company.vo.easycall.EasyCallInboundLlmVO" resultMap="InboundLlmResult">
         <include refid="selectInboundLlmVo"/>
-        <where>
+        where fs_tenant_id is null
             <if test="llmAccountId != null">and llm_account_id = #{llmAccountId}</if>
             <if test="callee != null and callee != ''">and callee = #{callee}</if>
             <if test="inboundAlias != null and inboundAlias != ''">and inbound_alias = #{inboundAlias}</if>
@@ -79,7 +81,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
                     </foreach>
                 </if>
             </if>
-        </where>
         order by id desc
     </select>
 
@@ -205,7 +206,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
     <!-- 根据音色来源查询音色列表 -->
     <select id="selectVoiceListBySource" parameterType="String" resultMap="VoiceCodeResult">
-        select voice_code, voice_name, voice_source
+        select id,voice_code, voice_name, voice_source,priority
         from cc_tts_aliyun
         where voice_source = #{voiceSource}
         and voice_enabled = 1