Browse Source

1.通过手机号返回大模型停水信息bug修改 2.新增查询客服接口 3.新增通过sessionId获取通话记录并关联创哥表的字段 4.更新通话记录,额外

王苗苗 1 tuần trước cách đây
mục cha
commit
c6196fab63

+ 22 - 0
slibra-admin/src/main/java/com/slibra/web/controller/business/TCallRecordController.java

@@ -1,7 +1,11 @@
 package com.slibra.web.controller.business;
 
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 import javax.servlet.http.HttpServletResponse;
+
+import com.slibra.common.core.domain.R;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
@@ -103,4 +107,22 @@ public class TCallRecordController extends BaseController
     {
         return toAjax(tCallRecordService.deleteTCallRecordByIds(ids));
     }
+
+
+    //2024年11月18日10:44:02  新增接口,通过sessionId返回对应的通话记录信息,并且关联曹永创的contents[当前通话记录]字段
+    @GetMapping(value = "/getCallBySessionId")
+    public R<TCallRecord> getCallBySessionId(String sessionId)
+    {
+        return R.ok(tCallRecordService.getCallBySessionId(sessionId));
+    }
+
+    /**
+     * 获取客服列表接口【只返回用户的ID和姓名】
+     * @return
+     */
+    @GetMapping(value = "/getAgentList")
+    public R<List<HashMap<String, Object>>> getAgentList()
+    {
+        return R.ok(tCallRecordService.getAgentList());
+    }
 }

+ 4 - 0
slibra-system/src/main/java/com/slibra/business/domain/TCallRecord.java

@@ -96,4 +96,8 @@ public class TCallRecord extends BaseEntity
     @Excel(name = "乐观锁")
     private Long revision;
 
+
+    //2024年11月18日10:45:25 新增的返回的字段[当前通话记录]
+    private String currentCallRecords;
+
 }

+ 9 - 0
slibra-system/src/main/java/com/slibra/business/mapper/TCallRecordMapper.java

@@ -1,6 +1,9 @@
 package com.slibra.business.mapper;
 
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
+
 import com.slibra.business.domain.TCallRecord;
 
 /**
@@ -58,4 +61,10 @@ public interface TCallRecordMapper
      * @return 结果
      */
     public int deleteTCallRecordByIds(Long[] ids);
+
+    String getBusinessTypeBySessionId(String sessionId);
+
+    String getContentsBySessionId(String sessionId);
+
+    List<HashMap<String, Object>> getAgentList();
 }

+ 7 - 0
slibra-system/src/main/java/com/slibra/business/service/ITCallRecordService.java

@@ -1,6 +1,9 @@
 package com.slibra.business.service;
 
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
+
 import com.slibra.business.domain.TCallRecord;
 
 /**
@@ -58,4 +61,8 @@ public interface ITCallRecordService
      * @return 结果
      */
     public int deleteTCallRecordById(Long id);
+
+    TCallRecord getCallBySessionId(String sessionId);
+
+    List<HashMap<String, Object>> getAgentList();
 }

+ 6 - 1
slibra-system/src/main/java/com/slibra/business/service/impl/FrontServiceImpl.java

@@ -75,9 +75,14 @@ public class FrontServiceImpl implements IFrontService {
         if(BusinessEnum.AiChatReqEnum.water_info.getCode().equals(method)){
 //            return this.cutOffWaterMapper.getCutOffWaterByUserPhone(phone);
             //通过手机号获取对应的小区的名字,一个手机号只能查询到一个
+            //2024年11月18日10:21:42 因为TUserInfo存储的主要是户号相关信息,所以一个手机号是可以对应多条记录的
             List<TUserInfo> tUserInfos = this.userInfoMapper.selectTUserInfoList(TUserInfo.builder().phone(phone).build());
             if(!CollectionUtils.isEmpty(tUserInfos)){
-                return this.cutOffWaterMapper.getCutOffWaterByNeighbourhoodName(tUserInfos.get(0).getNeighbourhoodName());
+                List<TCutOffWater> cutOffWaters = new ArrayList<>();
+                for (TUserInfo tUserInfo : tUserInfos) {
+                    cutOffWaters.addAll(this.cutOffWaterMapper.getCutOffWaterByNeighbourhoodName(tUserInfo.getNeighbourhoodName()));
+                }
+                return cutOffWaters;
             }
         }
         //基于用户输入的小区信息,查询停水信息

+ 41 - 0
slibra-system/src/main/java/com/slibra/business/service/impl/TCallRecordServiceImpl.java

@@ -1,12 +1,22 @@
 package com.slibra.business.service.impl;
 
+import java.util.Collections;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
+
+import com.slibra.common.exception.ServiceException;
 import com.slibra.common.utils.DateUtils;
+import com.slibra.common.utils.SecurityUtils;
+import com.slibra.common.utils.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import com.slibra.business.mapper.TCallRecordMapper;
 import com.slibra.business.domain.TCallRecord;
 import com.slibra.business.service.ITCallRecordService;
+import org.springframework.util.CollectionUtils;
 
 /**
  * 通话记录Service业务层处理
@@ -17,6 +27,7 @@ import com.slibra.business.service.ITCallRecordService;
 @Service
 public class TCallRecordServiceImpl implements ITCallRecordService 
 {
+    private static final Logger log = LoggerFactory.getLogger(TCallRecordServiceImpl.class);
     @Autowired
     private TCallRecordMapper tCallRecordMapper;
 
@@ -67,6 +78,19 @@ public class TCallRecordServiceImpl implements ITCallRecordService
     public int updateTCallRecord(TCallRecord tCallRecord)
     {
         tCallRecord.setUpdateTime(DateUtils.getNowDate());
+        //2024年11月18日10:23:18 由于前端不方便穿ID和name,这里由后台来操作
+        try {
+            tCallRecord.setUserId(SecurityUtils.getUserId());
+            tCallRecord.setUserName(SecurityUtils.getUsername());
+        } catch (Exception e) {
+            log.error("××××××跟新通话记录的时候,获取用户信息失败!");
+        }
+        //额外再查询曹永创的botrecords表,通过session获取intent,更新【业务类型】字段
+        String sessionId = tCallRecord.getSessionId();
+        if(StringUtils.isBlank(sessionId))
+            log.error("更新通话记录的时候,由于获取不到sessionId,导致无法更新曹永创的字段bussinessType【业务类型】");
+        else
+            tCallRecord.setBussinessType(this.tCallRecordMapper.getBusinessTypeBySessionId(sessionId));
         return tCallRecordMapper.updateTCallRecord(tCallRecord);
     }
 
@@ -93,4 +117,21 @@ public class TCallRecordServiceImpl implements ITCallRecordService
     {
         return tCallRecordMapper.deleteTCallRecordById(id);
     }
+
+    @Override
+    public TCallRecord getCallBySessionId(String sessionId) {
+        if(StringUtils.isBlank(sessionId))
+            throw new ServiceException("请输入sessionId");
+        List<TCallRecord> tCallRecords = this.tCallRecordMapper.selectTCallRecordList(TCallRecord.builder().sessionId(sessionId).build());
+        if(!CollectionUtils.isEmpty(tCallRecords)){
+            TCallRecord tCallRecord = tCallRecords.get(0);
+            tCallRecord.setCurrentCallRecords(this.tCallRecordMapper.getContentsBySessionId(sessionId));//[当前通话记录]
+        }
+        return null;
+    }
+
+    @Override
+    public List<HashMap<String, Object>> getAgentList() {
+        return this.tCallRecordMapper.getAgentList();
+    }
 }

+ 32 - 0
slibra-system/src/main/resources/mapper/business/TCallRecordMapper.xml

@@ -158,4 +158,36 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         </where>
         and del_flag = 0 order by id desc
     </select>
+
+
+    <select id="getBusinessTypeBySessionId" resultType="string">
+        SELECT
+            intent
+        FROM
+            botrecords
+        WHERE
+            `session` = #{sessionId}
+            LIMIT 1
+    </select>
+
+    <select id="getContentsBySessionId" resultType="string">
+        SELECT
+            contents
+        FROM
+            botrecords
+        WHERE
+            `session` = #{sessionId}
+            LIMIT 1
+    </select>
+
+    <select id="getAgentList" resultType="java.util.HashMap">
+        SELECT
+            user_id id,
+            user_name `name`
+        FROM
+            sys_user
+        WHERE
+            agent_num IS NOT NULL
+          AND agent_num != ''
+    </select>
 </mapper>