Jelajahi Sumber

转人工代码

lmx 1 Minggu lalu
induk
melakukan
c3bf10dc69

+ 64 - 3
fs-company/src/main/java/com/fs/company/controller/company/CompanyVoiceRoboticCallLogCallphoneController.java

@@ -5,16 +5,20 @@ import com.fs.common.core.controller.BaseController;
 import com.fs.common.core.domain.AjaxResult;
 import com.fs.common.core.domain.AjaxResult;
 import com.fs.common.core.page.TableDataInfo;
 import com.fs.common.core.page.TableDataInfo;
 import com.fs.common.enums.BusinessType;
 import com.fs.common.enums.BusinessType;
+import com.fs.common.utils.ServletUtils;
 import com.fs.common.utils.poi.ExcelUtil;
 import com.fs.common.utils.poi.ExcelUtil;
+import com.fs.common.utils.SecurityUtils;
 import com.fs.company.domain.CompanyVoiceRoboticCallLogCallphone;
 import com.fs.company.domain.CompanyVoiceRoboticCallLogCallphone;
 import com.fs.company.service.ICompanyVoiceRoboticCallLogCallphoneService;
 import com.fs.company.service.ICompanyVoiceRoboticCallLogCallphoneService;
+import com.fs.crm.domain.CrmCustomer;
+import com.fs.crm.service.ICrmCustomerService;
 import com.fs.company.vo.CompanyVoiceRoboticCallLogCallPhoneVO;
 import com.fs.company.vo.CompanyVoiceRoboticCallLogCallPhoneVO;
 import com.fs.company.vo.CompanyVoiceRoboticCallLogCount;
 import com.fs.company.vo.CompanyVoiceRoboticCallLogCount;
+import com.fs.framework.security.LoginUser;
+import com.fs.framework.service.TokenService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.security.access.prepost.PreAuthorize;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 
 import java.util.ArrayList;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.List;
@@ -32,6 +36,10 @@ public class CompanyVoiceRoboticCallLogCallphoneController extends BaseControlle
     @Autowired
     @Autowired
     private ICompanyVoiceRoboticCallLogCallphoneService companyVoiceRoboticCallLogCallphoneService;
     private ICompanyVoiceRoboticCallLogCallphoneService companyVoiceRoboticCallLogCallphoneService;
 
 
+    @Autowired
+    private ICrmCustomerService crmCustomerService;
+    @Autowired
+    private TokenService tokenService;
     /**
     /**
      * 查询调用日志_ai打电话列表
      * 查询调用日志_ai打电话列表
      */
      */
@@ -91,6 +99,59 @@ public class CompanyVoiceRoboticCallLogCallphoneController extends BaseControlle
         return AjaxResult.success(companyVoiceRoboticCallLogCount);
         return AjaxResult.success(companyVoiceRoboticCallLogCount);
     }
     }
 
 
+    /**
+     * 查询转人工接听记录列表
+     */
+    @PreAuthorize("@ss.hasPermi('company:handleManualAnswered:query')")
+    @GetMapping("/manualAnsweredList")
+    public TableDataInfo manualAnsweredList(CompanyVoiceRoboticCallLogCallphone companyVoiceRoboticCallLogCallphone)
+    {
+        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
+        companyVoiceRoboticCallLogCallphone.setCompanyId(loginUser.getCompany().getCompanyId());
+        companyVoiceRoboticCallLogCallphone.setManualAnswered(1);
+        startPage();
+        List<CompanyVoiceRoboticCallLogCallphone> list = companyVoiceRoboticCallLogCallphoneService.selectManualAnsweredList(companyVoiceRoboticCallLogCallphone);
+        return getDataTable(list);
+    }
+
+    /**
+     * 根据外呼记录ID查询CRM客户信息(处理数据弹窗用)
+     */
+    @PreAuthorize("@ss.hasPermi('company:handleManualAnswered:handle')")
+    @GetMapping("/getCrmCustomerByLogId")
+    public AjaxResult getCrmCustomerByLogId(@RequestParam("callphoneLogId") Long callphoneLogId)
+    {
+        CrmCustomer crmCustomer = crmCustomerService.selectCrmCustomerByCallphoneLogId(callphoneLogId);
+        return AjaxResult.success(crmCustomer);
+    }
+
+    /**
+     * 确认信息(仅标记外呼记录为已处理,不更新客户信息)
+     */
+    @PreAuthorize("@ss.hasPermi('company:handleManualAnswered:handle')")
+    @Log(title = "转人工接听确认信息", businessType = BusinessType.UPDATE)
+    @PostMapping("/confirmManualAnswered")
+    public AjaxResult confirmManualAnswered(@RequestBody CompanyVoiceRoboticCallLogCallphone param)
+    {
+        return toAjax(companyVoiceRoboticCallLogCallphoneService.markHandleFlag(param.getLogId()));
+    }
+
+    /**
+     * 处理数据(标记外呼记录为已处理 + 更新CRM客户信息)
+     */
+    @PreAuthorize("@ss.hasPermi('company:handleManualAnswered:handle')")
+    @Log(title = "转人工接听处理数据", businessType = BusinessType.UPDATE)
+    @PostMapping("/submitManualAnswered")
+    public AjaxResult submitManualAnswered(@RequestBody CrmCustomer param)
+    {
+        // 1. 标记外呼记录为已处理
+        if (param.getLastEffectiveCallphoneLogId() != null) {
+            companyVoiceRoboticCallLogCallphoneService.markHandleFlag(param.getLastEffectiveCallphoneLogId());
+        }
+        // 2. 更新CRM客户信息
+        return toAjax(crmCustomerService.updateCrmCustomer(param));
+    }
+
     /**
     /**
      * 导出调用日志_ai打电话列表
      * 导出调用日志_ai打电话列表
      */
      */

+ 2 - 1
fs-company/src/main/java/com/fs/company/controller/company/EasyCallController.java

@@ -107,7 +107,8 @@ public class EasyCallController extends BaseController {
 
 
         List<EasyCallVoiceCodeVO> result = ccTtsAliyuns.stream()
         List<EasyCallVoiceCodeVO> result = ccTtsAliyuns.stream()
                 .filter(item ->
                 .filter(item ->
-                        ttsIds.stream().anyMatch(id -> id.intValue() == item.getId())
+            // ttsIds.stream().anyMatch(id -> id.intValue() == item.getId())
+                        item.getPriority() == 1 || (item.getPriority() == 0 && ttsIds.contains(item.getId()))
                 )
                 )
                 .map(item -> {
                 .map(item -> {
                     EasyCallVoiceCodeVO vo = new EasyCallVoiceCodeVO();
                     EasyCallVoiceCodeVO vo = new EasyCallVoiceCodeVO();

+ 14 - 11
fs-service/src/main/java/com/fs/company/mapper/CompanyVoiceRoboticCallLogCallphoneMapper.java

@@ -15,10 +15,10 @@ import java.util.List;
  * @author fs
  * @author fs
  * @date 2026-01-15
  * @date 2026-01-15
  */
  */
-public interface CompanyVoiceRoboticCallLogCallphoneMapper extends BaseMapper<CompanyVoiceRoboticCallLogCallphone>{
+public interface CompanyVoiceRoboticCallLogCallphoneMapper extends BaseMapper<CompanyVoiceRoboticCallLogCallphone> {
     /**
     /**
      * 查询调用日志_ai打电话
      * 查询调用日志_ai打电话
-     * 
+     *
      * @param logId 调用日志_ai打电话主键
      * @param logId 调用日志_ai打电话主键
      * @return 调用日志_ai打电话
      * @return 调用日志_ai打电话
      */
      */
@@ -26,7 +26,7 @@ public interface CompanyVoiceRoboticCallLogCallphoneMapper extends BaseMapper<Co
 
 
     /**
     /**
      * 查询调用日志_ai打电话列表
      * 查询调用日志_ai打电话列表
-     * 
+     *
      * @param companyVoiceRoboticCallLogCallphone 调用日志_ai打电话
      * @param companyVoiceRoboticCallLogCallphone 调用日志_ai打电话
      * @return 调用日志_ai打电话集合
      * @return 调用日志_ai打电话集合
      */
      */
@@ -34,7 +34,7 @@ public interface CompanyVoiceRoboticCallLogCallphoneMapper extends BaseMapper<Co
 
 
     /**
     /**
      * 新增调用日志_ai打电话
      * 新增调用日志_ai打电话
-     * 
+     *
      * @param companyVoiceRoboticCallLogCallphone 调用日志_ai打电话
      * @param companyVoiceRoboticCallLogCallphone 调用日志_ai打电话
      * @return 结果
      * @return 结果
      */
      */
@@ -42,7 +42,7 @@ public interface CompanyVoiceRoboticCallLogCallphoneMapper extends BaseMapper<Co
 
 
     /**
     /**
      * 修改调用日志_ai打电话
      * 修改调用日志_ai打电话
-     * 
+     *
      * @param companyVoiceRoboticCallLogCallphone 调用日志_ai打电话
      * @param companyVoiceRoboticCallLogCallphone 调用日志_ai打电话
      * @return 结果
      * @return 结果
      */
      */
@@ -50,7 +50,7 @@ public interface CompanyVoiceRoboticCallLogCallphoneMapper extends BaseMapper<Co
 
 
     /**
     /**
      * 删除调用日志_ai打电话
      * 删除调用日志_ai打电话
-     * 
+     *
      * @param logId 调用日志_ai打电话主键
      * @param logId 调用日志_ai打电话主键
      * @return 结果
      * @return 结果
      */
      */
@@ -58,7 +58,7 @@ public interface CompanyVoiceRoboticCallLogCallphoneMapper extends BaseMapper<Co
 
 
     /**
     /**
      * 批量删除调用日志_ai打电话
      * 批量删除调用日志_ai打电话
-     * 
+     *
      * @param logIds 需要删除的数据主键集合
      * @param logIds 需要删除的数据主键集合
      * @return 结果
      * @return 结果
      */
      */
@@ -66,19 +66,20 @@ public interface CompanyVoiceRoboticCallLogCallphoneMapper extends BaseMapper<Co
 
 
     CompanyVoiceRoboticCallLogCallphone selectNoResultLogByCallees(CompanyVoiceRoboticCallees callees);
     CompanyVoiceRoboticCallLogCallphone selectNoResultLogByCallees(CompanyVoiceRoboticCallees callees);
 
 
-    CompanyVoiceRoboticCallLogCallphone selectLogByRoboticIdAndCallerId(@Param("roboticId") Long roboticId,@Param("callerId") Long callerId);
+    CompanyVoiceRoboticCallLogCallphone selectLogByRoboticIdAndCallerId(@Param("roboticId") Long roboticId, @Param("callerId") Long callerId);
 
 
-    List<CompanyVoiceRoboticCallLogCallphone>  selectCompanyVoiceRoboticCallLogCallphoneListData(CompanyVoiceRoboticCallLogCallphone companyVoiceRoboticCallLogCallphone);
+    List<CompanyVoiceRoboticCallLogCallphone> selectCompanyVoiceRoboticCallLogCallphoneListData(CompanyVoiceRoboticCallLogCallphone companyVoiceRoboticCallLogCallphone);
 
 
     CompanyVoiceRoboticCallLogCallphone selectCallLogByCallbackUuid(@Param("uuid") String uuid);
     CompanyVoiceRoboticCallLogCallphone selectCallLogByCallbackUuid(@Param("uuid") String uuid);
 
 
     /**
     /**
      * 根据业务ID查询当天的通话次数
      * 根据业务ID查询当天的通话次数
+     *
      * @param businessId 业务ID (bes.id)
      * @param businessId 业务ID (bes.id)
-     * @param companyId 公司ID
+     * @param companyId  公司ID
      * @return 当天通话次数,如果没有记录返回0
      * @return 当天通话次数,如果没有记录返回0
      */
      */
-    int countTodayCallsByBusinessId(@Param("businessId") Long businessId,@Param("companyId") Long companyId);
+    int countTodayCallsByBusinessId(@Param("businessId") Long businessId, @Param("companyId") Long companyId);
 
 
     List<CompanyVoiceRoboticCallLogCallphone> selectCompanyVoiceRoboticCallPhoneLogGroupList(CompanyVoiceRoboticCallLogCallphone companyVoiceRoboticCallLogCallphone);
     List<CompanyVoiceRoboticCallLogCallphone> selectCompanyVoiceRoboticCallPhoneLogGroupList(CompanyVoiceRoboticCallLogCallphone companyVoiceRoboticCallLogCallphone);
 
 
@@ -93,4 +94,6 @@ public interface CompanyVoiceRoboticCallLogCallphoneMapper extends BaseMapper<Co
      * @return 公司ID
      * @return 公司ID
      */
      */
     Long selectCompanyIdByBusinessId(@Param("businessId") Long businessId);
     Long selectCompanyIdByBusinessId(@Param("businessId") Long businessId);
+
+    List<CompanyVoiceRoboticCallLogCallphone> selectManualAnsweredList(CompanyVoiceRoboticCallLogCallphone companyVoiceRoboticCallLogCallphone);
 }
 }

+ 10 - 0
fs-service/src/main/java/com/fs/company/service/ICompanyVoiceRoboticCallLogCallphoneService.java

@@ -82,4 +82,14 @@ public interface ICompanyVoiceRoboticCallLogCallphoneService extends IService<Co
     CompanyVoiceRoboticCallLogCount selectCompanyVoiceRoboticCallPhoneLogCount();
     CompanyVoiceRoboticCallLogCount selectCompanyVoiceRoboticCallPhoneLogCount();
 
 
     List<CompanyVoiceRoboticCallLogCallPhoneVO> listByRoboticId(CompanyVoiceRoboticCallLogCallphone companyVoiceRoboticCallLogCallphone);
     List<CompanyVoiceRoboticCallLogCallPhoneVO> listByRoboticId(CompanyVoiceRoboticCallLogCallphone companyVoiceRoboticCallLogCallphone);
+
+    List<CompanyVoiceRoboticCallLogCallphone> selectManualAnsweredList(CompanyVoiceRoboticCallLogCallphone companyVoiceRoboticCallLogCallphone);
+
+    /**
+     * 标记外呼记录为已处理(handleFlag=1)
+     *
+     * @param logId 外呼记录主键
+     * @return 影响行数
+     */
+    int markHandleFlag(Long logId);
 }
 }

+ 13 - 0
fs-service/src/main/java/com/fs/company/service/impl/CompanyVoiceRoboticCallLogCallphoneServiceImpl.java

@@ -537,4 +537,17 @@ public class CompanyVoiceRoboticCallLogCallphoneServiceImpl extends ServiceImpl<
     public boolean isPositiveInteger(String str) {
     public boolean isPositiveInteger(String str) {
         return str != null && str.matches("[1-9]\\d*");
         return str != null && str.matches("[1-9]\\d*");
     }
     }
+
+    @Override
+    public List<CompanyVoiceRoboticCallLogCallphone> selectManualAnsweredList(CompanyVoiceRoboticCallLogCallphone companyVoiceRoboticCallLogCallphone) {
+        return baseMapper.selectManualAnsweredList(companyVoiceRoboticCallLogCallphone);
+    }
+
+    @Override
+    public int markHandleFlag(Long logId) {
+        CompanyVoiceRoboticCallLogCallphone updateObj = new CompanyVoiceRoboticCallLogCallphone();
+        updateObj.setLogId(logId);
+        updateObj.setHandleFlag(1);
+        return baseMapper.updateCompanyVoiceRoboticCallLogCallphone(updateObj);
+    }
 }
 }

+ 2 - 2
fs-service/src/main/java/com/fs/crm/domain/CrmCustomer.java

@@ -192,9 +192,9 @@ public class CrmCustomer extends BaseEntity
     private Integer effectiveCustomer;
     private Integer effectiveCustomer;
     //    AI外呼备注
     //    AI外呼备注
     private String aiCallRemark;
     private String aiCallRemark;
-    //    最后一次设置有效时录音
+    //    最后一次设置录音
     private String effectiveRecordPath;
     private String effectiveRecordPath;
-    //    最后一次设置有效时外呼记录id
+    //    最后一次设置外呼记录id
     private Long lastEffectiveCallphoneLogId;
     private Long lastEffectiveCallphoneLogId;
 
 
 }
 }

+ 8 - 0
fs-service/src/main/java/com/fs/crm/mapper/CrmCustomerMapper.java

@@ -1091,4 +1091,12 @@ public interface CrmCustomerMapper extends BaseMapper<CrmCustomer> {
             " order by c.customer_id desc "+
             " order by c.customer_id desc "+
             "</script>"})
             "</script>"})
     List<CrmCustomerAllListQueryVO> selectCrmCustomerAllListQuery(@Param("maps") CrmCustomerAllListQueryParam param);
     List<CrmCustomerAllListQueryVO> selectCrmCustomerAllListQuery(@Param("maps") CrmCustomerAllListQueryParam param);
+
+    /**
+     * 根据外呼记录ID查询CRM客户(空壳,SQL待补充)
+     *
+     * @param callphoneLogId 外呼通话记录主键
+     * @return CRM客户
+     */
+    CrmCustomer selectCrmCustomerByCallphoneLogId(@Param("callphoneLogId") Long callphoneLogId);
 }
 }

+ 8 - 0
fs-service/src/main/java/com/fs/crm/service/ICrmCustomerService.java

@@ -169,4 +169,12 @@ public interface ICrmCustomerService
     List<CrmMyCustomerListQueryVO> selectCrmMyAssistListQuery(CrmMyCustomerListQueryParam param);
     List<CrmMyCustomerListQueryVO> selectCrmMyAssistListQuery(CrmMyCustomerListQueryParam param);
 
 
     List<CrmCustomerAllListQueryVO> selectCrmCustomerAllListQuery(CrmCustomerAllListQueryParam param);
     List<CrmCustomerAllListQueryVO> selectCrmCustomerAllListQuery(CrmCustomerAllListQueryParam param);
+
+    /**
+     * 根据外呼记录ID查询CRM客户
+     *
+     * @param callphoneLogId 外呼通话记录主键
+     * @return CRM客户
+     */
+    CrmCustomer selectCrmCustomerByCallphoneLogId(Long callphoneLogId);
 }
 }

+ 5 - 0
fs-service/src/main/java/com/fs/crm/service/impl/CrmCustomerServiceImpl.java

@@ -1097,4 +1097,9 @@ public class CrmCustomerServiceImpl extends ServiceImpl<CrmCustomerMapper, CrmCu
         return crmCustomerMapper.selectCrmCustomerAllListQuery(param);
         return crmCustomerMapper.selectCrmCustomerAllListQuery(param);
     }
     }
 
 
+    @Override
+    public CrmCustomer selectCrmCustomerByCallphoneLogId(Long callphoneLogId) {
+        return crmCustomerMapper.selectCrmCustomerByCallphoneLogId(callphoneLogId);
+    }
+
 }
 }

+ 23 - 0
fs-service/src/main/resources/mapper/company/CompanyVoiceRoboticCallLogCallphoneMapper.xml

@@ -143,6 +143,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="callType != null">call_type = #{callType},</if>
             <if test="callType != null">call_type = #{callType},</if>
             <if test="isWarning != null">is_warning = #{isWarning},</if>
             <if test="isWarning != null">is_warning = #{isWarning},</if>
             <if test="violationNum != null">violation_num = #{violationNum},</if>
             <if test="violationNum != null">violation_num = #{violationNum},</if>
+            <if test="manualAnswered != null">manual_answered = #{manualAnswered},</if>
+            <if test="handleFlag != null">handle_flag = #{handleFlag},</if>
+            <if test="answeredExtNum != null">answered_ext_num = #{answeredExtNum},</if>
+            <if test="manualAnsweredTime != null">manual_answered_time = #{manualAnsweredTime},</if>
+            <if test="manualAnsweredTimeLen != null">manual_answered_time_len = #{manualAnsweredTimeLen},</if>
         </trim>
         </trim>
         where log_id = #{logId}
         where log_id = #{logId}
     </update>
     </update>
@@ -284,5 +289,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         SELECT company_id FROM company_voice_robotic vr INNER JOIN company_voice_robotic_business rb ON vr.id = rb.robotic_id WHERE rb.id = 20 LIMIT 1
         SELECT company_id FROM company_voice_robotic vr INNER JOIN company_voice_robotic_business rb ON vr.id = rb.robotic_id WHERE rb.id = 20 LIMIT 1
     </select>
     </select>
 
 
+    <select id="selectManualAnsweredList" parameterType="com.fs.company.domain.CompanyVoiceRoboticCallLogCallphone" resultType="CompanyVoiceRoboticCallLogCallphone">
+        select
+        t1.*,
+        t2.company_name as companyName,
+        t3.nick_name as companyUserName,
+        cvr.name as roboticName
+        from company_voice_robotic_call_log_callphone t1
+        left join company t2 on t1.company_id = t2.company_id
+        left join company_user t3 on t3.user_id = t1.company_user_id
+        left join company_voice_robotic cvr on cvr.id = t1.robotic_id
+        <where>
+            t1.manual_answered = 1
+            <if test="companyId != null">and t1.company_id = #{companyId}</if>
+            <if test="roboticId != null">and t1.robotic_id = #{roboticId}</if>
+            <if test="answeredExtNum != null and answeredExtNum != ''">and t1.answered_ext_num = #{answeredExtNum}</if>
+        </where>
+        order by t1.handle_flag asc, t1.create_time desc
+    </select>
 
 
 </mapper>
 </mapper>

+ 17 - 0
fs-service/src/main/resources/mapper/crm/CrmCustomerMapper.xml

@@ -565,4 +565,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         where
         where
             customer_id = #{customerId};
             customer_id = #{customerId};
     </select>
     </select>
+
+    <select id="selectCrmCustomerByCallphoneLogId" parameterType="Long" resultMap="CrmCustomerResult">
+        SELECT
+        t3.customer_id,
+        t3.customer_name,
+        t3.mobile,
+        t3.effective_customer,
+        t3.ai_call_remark,
+        t1.record_path as effectiveRecordPath,
+        t1.log_id as lastEffectiveCallphoneLogId
+        FROM
+        company_voice_robotic_call_log_callphone t1
+        INNER JOIN company_voice_robotic_callees t2 ON t1.caller_id = t2.id
+        INNER JOIN crm_customer t3 ON t3.customer_id = t2.user_id
+        WHERE
+        t1.log_id = #{callphoneLogId}
+    </select>
 </mapper>
 </mapper>