Explorar o código

通过sessionId获取通话记录的时候,额外返回一些其他的统计信息

王苗苗 hai 1 semana
pai
achega
c075a9ea98

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

@@ -1,6 +1,8 @@
 package com.slibra.business.domain;
 
 import java.util.Date;
+import java.util.List;
+
 import com.fasterxml.jackson.annotation.JsonFormat;
 import lombok.AllArgsConstructor;
 import lombok.Builder;
@@ -100,4 +102,14 @@ public class TCallRecord extends BaseEntity
     //2024年11月18日10:45:25 新增的返回的字段[当前通话记录]
     private String currentCallRecords;
 
+    //2024年11月18日16:25:26 新增一些统计相关的信息 【户号水费小区名称  拨打次数  历史通话记录  停水信息】
+    private int counts;//拨打次数
+
+    private List<TUserInfo> userInfos;//户号水费小区名称
+
+    private List<TCallRecord> callRecords;//历史通话记录
+
+    private List<TCutOffWater> cutOffWaters;//正在进行的停水信息
+
+
 }

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

@@ -5,6 +5,7 @@ import java.util.List;
 import java.util.Map;
 
 import com.slibra.business.domain.TCallRecord;
+import org.apache.ibatis.annotations.Param;
 
 /**
  * 通话记录Mapper接口
@@ -67,4 +68,8 @@ public interface TCallRecordMapper
     String getContentsBySessionId(String sessionId);
 
     List<HashMap<String, Object>> getAgentList();
+
+    int getCallCountsByPhone(String phone);
+
+    List<TCallRecord> selectHistoriesByPhone(@Param("phone") String phone, @Param("id") Long id);
 }

+ 36 - 3
slibra-system/src/main/java/com/slibra/business/service/impl/TCallRecordServiceImpl.java

@@ -1,10 +1,15 @@
 package com.slibra.business.service.impl;
 
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Objects;
 
 import com.alibaba.fastjson2.JSON;
+import com.slibra.business.domain.TCutOffWater;
+import com.slibra.business.domain.TUserInfo;
+import com.slibra.business.mapper.TCutOffWaterMapper;
+import com.slibra.business.mapper.TUserInfoMapper;
 import com.slibra.business.res.Ele;
 import com.slibra.common.exception.ServiceException;
 import com.slibra.common.utils.DateUtils;
@@ -36,6 +41,12 @@ public class TCallRecordServiceImpl implements ITCallRecordService
     @Autowired
     private TCallRecordMapper tCallRecordMapper;
 
+    @Autowired
+    private TUserInfoMapper tUserInfoMapper;
+
+    @Autowired
+    private TCutOffWaterMapper cutOffWaterMapper;
+
     @Value("${ALIYUN_AK_ID}")
     private String accessKeyId;
 
@@ -139,10 +150,32 @@ public class TCallRecordServiceImpl implements ITCallRecordService
         if(!CollectionUtils.isEmpty(tCallRecords)){
             TCallRecord tCallRecord = tCallRecords.get(0);
             tCallRecord.setCurrentCallRecords(this.tCallRecordMapper.getContentsBySessionId(sessionId));//[当前通话记录]
+            this.addExtra(tCallRecord);
+            return tCallRecord;
         }
         return null;
     }
 
+    private void addExtra(TCallRecord tCallRecord) {
+        String phone = tCallRecord.getPhone();
+        //获取历史通话记录(不包含本次)
+        List<TCallRecord> histories = this.tCallRecordMapper.selectHistoriesByPhone(phone, tCallRecord.getId());
+        /*tCallRecord.setCounts(this.tCallRecordMapper.getCallCountsByPhone(phone));*/
+        //户号水费小区名称
+        List<TUserInfo> tUserInfos = this.tUserInfoMapper.selectTUserInfoList(TUserInfo.builder().phone(phone).build());
+        tCallRecord.setUserInfos(tUserInfos);
+        tCallRecord.setCallRecords(histories);
+        tCallRecord.setCounts(histories.size());
+        //正在进行的停水信息
+        if(!CollectionUtils.isEmpty(tUserInfos)){
+            List<TCutOffWater> cutOffWaters = new ArrayList<>();
+            for (TUserInfo tUserInfo : tUserInfos) {
+                cutOffWaters.addAll(this.cutOffWaterMapper.getCutOffWaterByNeighbourhoodName(tUserInfo.getNeighbourhoodName()));
+            }
+            tCallRecord.setCutOffWaters(cutOffWaters);
+        }
+    }
+
     @Override
     public List<HashMap<String, Object>> getAgentList() {
         return this.tCallRecordMapper.getAgentList();
@@ -154,12 +187,12 @@ public class TCallRecordServiceImpl implements ITCallRecordService
         TCallRecord tCallRecord = this.tCallRecordMapper.selectTCallRecordById(id);
         if(Objects.isNull(tCallRecord))
             throw new ServiceException("请输入正确的ID");
-        String url = tCallRecord.getUrl();
-        if(StringUtils.isBlank(url))
-            throw new ServiceException("此次通话记录,未记录录音文件,无法转换");
         Long hasParsed = tCallRecord.getHasParsed();
         if(!Objects.isNull(hasParsed) && 1== hasParsed)
             throw new ServiceException("此次通话记录已经做过转换了,无需重复转换");
+        String url = tCallRecord.getUrl();
+        if(StringUtils.isBlank(url))
+            throw new ServiceException("此次通话记录,未记录录音文件,无法转换");
         /*final String accessKeyId = "LTAI5tQ2HmiHCygZkt5BYrYR";
         final String accessKeySecret = "KhmxTd14SUcXafpFk5yofA43FoeM99";
         final String appKey = "OKt6jogp6fRjHQVp";*/

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

@@ -190,4 +190,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             agent_num IS NOT NULL
           AND agent_num != ''
     </select>
+
+    <select id="getCallCountsByPhone" resultType="int">
+        SELECT
+            COUNT(*)
+        FROM
+            t_call_record
+        WHERE
+            phone = #{phone}
+    </select>
+
+    <select id="selectHistoriesByPhone" resultMap="TCallRecordResult">
+        <include refid="selectTCallRecordVo"/>
+        where phone = #{phone} and del_flag = 0 and id != #{id}
+    </select>
 </mapper>