Commit 3facd96f authored by xinglei's avatar xinglei

*)修改融合终端接口

parent 8ff0bcd2
......@@ -20,8 +20,8 @@ public interface VoiceRecordFileMapper extends BaseMapper<VoiceRecordFile> {
@Param("telStartTimeStr") String telStartTimeStr,
@Param("telEndTimeStr") String telEndTimeStr,
@Param("fileType") String fileType,
@Param("tel") String tel,
@Param("workNum") String workNum,
@Param("caller") String caller,
@Param("called") String called,
@Param("sortParam") String sortParam,
@Param("sortRule") String sortRule);
......
......@@ -2,6 +2,8 @@ package com.yeejoin.amos.boot.module.jcs.api.service;
import com.alibaba.fastjson.JSONObject;
import java.util.Map;
/**
* @Author: xinglei
* @Description:
......@@ -27,7 +29,7 @@ public interface IFusionService {
* @param employeeID 设备号码
* @return
*/
JSONObject getGISByEmployeeID(String employeeID);
Map<String, String> getGISByEmployeeID(String employeeID);
/**
* 获取最新的一条通话记录
......@@ -35,12 +37,12 @@ public interface IFusionService {
* @param called 被呼号码
* @return
*/
JSONObject getCallRecordByNumber(String caller, String called);
Map<String, String> getCallRecordByNumber(String caller, String called);
/**
* 获取通话录音记录
* @param cid 呼叫ID
* @return
*/
JSONObject getCallRecordByCID(String cid);
Map<String, String> getCallRecordByCID(String cid);
}
......@@ -18,7 +18,7 @@ public interface IVoiceRecordFileService {
void publishRecord(VoiceRecordFileDto model);
Page<VoiceRecordFileDto> queryRecordListByQueryDto(Page<VoiceRecordFileDto> page, String telEndTimeStr, String telEndTimeStr1, String fileType, String tel, String workNum, String sortParam, String sortRule);
Page<VoiceRecordFileDto> queryRecordListByQueryDto(Page<VoiceRecordFileDto> page, String telEndTimeStr, String telEndTimeStr1, String fileType, String caller, String called, String sortParam, String sortRule);
VoiceRecordFileDto getRecordById(Long sequenceNbr);
......
......@@ -6,7 +6,8 @@
r.sequence_nbr AS sequenceNbr,
r.file_path AS filePath,
r.file_type AS fileType,
r.tel AS tel,
r.caller AS caller,
r.called AS called,
r.tel_start_time AS telStartTime,
r.tel_end_time AS telEndTime,
r.alert_id AS alertId,
......@@ -31,9 +32,13 @@
and r.tel_end_time <![CDATA[ <= ]]>
#{telEndTimeStr}
</if>
<if test="tel != null and tel != ''">
AND r.tel like
CONCAT(CONCAT('%',#{tel}),'%')
<if test="caller != null and caller != ''">
AND r.caller like
CONCAT(CONCAT('%',#{caller}),'%')
</if>
<if test="called != null and called != ''">
AND r.called like
CONCAT(CONCAT('%',#{called}),'%')
</if>
<if test="fileType != null and fileType != ''">
AND r.file_type = #{fileType}
......@@ -48,8 +53,6 @@
</choose>
</select>
<select id="getRecordById" resultType="com.yeejoin.amos.boot.module.jcs.api.dto.VoiceRecordFileDto">
SELECT
<include refid="componentField"/>
......@@ -58,7 +61,6 @@
LEFT JOIN jc_alert_called a ON a.sequence_nbr =
r.alert_id
WHERE r.sequence_nbr = #{sequenceNbr}
</select>
<select id="selectExportData" resultType="com.yeejoin.amos.boot.module.jcs.api.dto.VoiceRecordFileDto">
......
......@@ -123,7 +123,7 @@ public class VoiceRecordFileController extends BaseController {
}
Page<VoiceRecordFileDto> pageBean = voiceRecordFileServiceImpl.queryRecordListByQueryDto(page,
model.getTelStartTimeStr(),model.getTelEndTimeStr(),model.getFileType(),model.getCaller(),
model.getWorkNum(),sortParam,sortRule);
model.getCalled(),sortParam,sortRule);
Page<VoiceRecordFileDto> result = new Page<VoiceRecordFileDto>(pageNum,pageSize);
long totle = pageBean.getTotal();
result.setRecords(pageBean.getRecords());
......
package com.yeejoin.amos.boot.module.jcs.biz.service.impl;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.boot.core.utils.RestTemplateUtil;
import com.yeejoin.amos.boot.module.jcs.api.service.IFusionService;
......@@ -7,8 +8,12 @@ import org.springframework.stereotype.Service;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestClientException;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import java.util.HashMap;
import java.util.Map;
/**
* @Author: xl
* @Description:
......@@ -45,7 +50,7 @@ public class FusionServiceImpl implements IFusionService {
}
@Override
public JSONObject getGISByEmployeeID(String employeeID) {
public Map<String, String> getGISByEmployeeID(String employeeID) {
MultiValueMap<String, String> requestEntity = new LinkedMultiValueMap<String, String>();
requestEntity.add("employeeID", employeeID);
JSONObject jsonObject = null;
......@@ -55,11 +60,11 @@ public class FusionServiceImpl implements IFusionService {
e.printStackTrace();
throw new BadRequest("访问融合终端失败");
}
return jsonObject;
return getResult(jsonObject);
}
@Override
public JSONObject getCallRecordByNumber(String caller, String called) {
public Map<String, String> getCallRecordByNumber(String caller, String called) {
MultiValueMap<String, String> requestEntity = new LinkedMultiValueMap<String, String>();
requestEntity.add("caller", caller);
requestEntity.add("called", called);
......@@ -70,11 +75,11 @@ public class FusionServiceImpl implements IFusionService {
e.printStackTrace();
throw new BadRequest("访问融合终端失败");
}
return jsonObject;
return getResult(jsonObject);
}
@Override
public JSONObject getCallRecordByCID(String cid) {
public Map<String, String> getCallRecordByCID(String cid) {
MultiValueMap<String, String> requestEntity = new LinkedMultiValueMap<String, String>();
requestEntity.add("cid", cid);
JSONObject jsonObject = null;
......@@ -84,6 +89,15 @@ public class FusionServiceImpl implements IFusionService {
e.printStackTrace();
throw new BadRequest("访问融合终端失败");
}
return jsonObject;
return getResult(jsonObject);
}
public Map<String, String> getResult(JSONObject jsonObject) {
Map<String, String> map = new HashMap<>();
JSONArray data = jsonObject.getJSONArray("data");
if (!ValidationUtil.isEmpty(data)) {
map = (Map) data.get(0);
}
return map;
}
}
......@@ -11,21 +11,23 @@ import com.yeejoin.amos.boot.module.jcs.api.entity.VoiceRecordLog;
import com.yeejoin.amos.boot.module.jcs.api.enums.EmployeeEnum;
import com.yeejoin.amos.boot.module.jcs.api.enums.PropertyEnum;
import com.yeejoin.amos.boot.module.jcs.api.mapper.VoiceRecordFileMapper;
import com.yeejoin.amos.boot.module.jcs.api.service.IFusionService;
import com.yeejoin.amos.boot.module.jcs.api.service.IVoiceRecordFileService;
import com.yeejoin.amos.feign.systemctl.Systemctl;
import com.yeejoin.amos.feign.systemctl.model.DictionarieValueModel;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.typroject.tyboot.component.emq.EmqKeeper;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
/**
* 通话记录附件服务实现类
......@@ -47,7 +49,7 @@ public class VoiceRecordFileServiceImpl extends BaseService<VoiceRecordFileDto,
AlertCalledServiceImpl iAlertCalledService;
@Autowired
IFusionService fusionService;
FusionServiceImpl fusionService;
private volatile JSONArray ctiInfos;
......@@ -76,22 +78,24 @@ public class VoiceRecordFileServiceImpl extends BaseService<VoiceRecordFileDto,
@Override
public void publishRecord(final VoiceRecordFileDto model) {
JSONObject jsonObject = fusionService.getCallRecordByNumber(model.getCaller(), model.getCalled());
Map<String, String> map = getResult(jsonObject);
Map<String, String> dMap = fusionService.getCallRecordByNumber(model.getCaller(), model.getCalled());
// 保存到日志表中
VoiceRecordLog log = new VoiceRecordLog();
VoiceRecordFile voiceRecordFile = new VoiceRecordFile();
BeanUtils.copyProperties(model, voiceRecordFile);
log.setAlertId(model.getAlertId());
log.setConnectId(map.get("cid"));
log.setConnectId(dMap.get("cid"));
log.setIsDeal(false);
log.setDealTimes(0);
save(voiceRecordFile);
iVoiceRecordLogServiceImpl.save(log);
}
@Override
public Page<VoiceRecordFileDto> queryRecordListByQueryDto(Page<VoiceRecordFileDto> page, String telStartTimeStr, String telEndTimeStr, String fileType, String tel, String workNum, String sortParam, String sortRule) {
public Page<VoiceRecordFileDto> queryRecordListByQueryDto(Page<VoiceRecordFileDto> page, String telStartTimeStr, String telEndTimeStr, String fileType, String caller, String called, String sortParam, String sortRule) {
Page<List<VoiceRecordFileDto>> list = baseMapper.queryRecordListByQueryDto(page,
telStartTimeStr, telEndTimeStr, fileType, tel,
workNum, sortParam, sortRule);
telStartTimeStr, telEndTimeStr, fileType, caller,
called, sortParam, sortRule);
Page<VoiceRecordFileDto> page1 = new Page<>();
List<VoiceRecordFileDto> resultDtoList = JSONArray.parseArray(JSONArray.toJSONString(list.getRecords()), VoiceRecordFileDto.class);
page1.setCurrent(page.getCurrent());
......@@ -154,16 +158,6 @@ public class VoiceRecordFileServiceImpl extends BaseService<VoiceRecordFileDto,
return fusionDtos;
}
private Map<String, String> getResult(JSONObject jsonObject) {
Map<String, String> map = new HashMap<>();
JSONArray data = jsonObject.getJSONArray("data");
if (!ValidationUtil.isEmpty(data)) {
map = (Map) data.get(0);
}
return map;
}
/**
* 获取在线用户的employeeID集合
*
......@@ -199,9 +193,7 @@ public class VoiceRecordFileServiceImpl extends BaseService<VoiceRecordFileDto,
private FusionDto buildFusionDto(FusionDto fusionDto, List<String> employeeIDs, Boolean hasFusion) {
if (hasFusion) {
JSONObject jsonObject = fusionService.getGISByEmployeeID(fusionDto.getId());
Map<String, String> dMap = getResult(jsonObject);
JSONArray data = jsonObject.getJSONArray("data");
Map<String, String> dMap = fusionService.getGISByEmployeeID(fusionDto.getId());
fusionDto.setLatitude(dMap.get("latitude"));
fusionDto.setLongitude(dMap.get("longitude"));
fusionDto.setState(employeeIDs.contains(fusionDto.getId()) ? EmployeeEnum.在线.getValue() : EmployeeEnum.离线.getValue());
......
package com.yeejoin.amos.boot.module.jcs.biz.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
......@@ -20,6 +21,7 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import org.typroject.tyboot.component.emq.EmqKeeper;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import java.util.Date;
......@@ -44,86 +46,81 @@ public class VoiceRecordLogServiceImpl extends BaseService<VoiceRecordLogDto,Voi
AlertCalledServiceImpl iAlertCalledService;
@Autowired
FusionServiceImpl fusionService;
@Autowired
VoiceRecordFileServiceImpl voiceRecordFileService;
@Autowired
EmqKeeper emqKeeper;
public final static long ONE_Minute = 60 * 1000;
// @Value("${mqtt.topic.cti.push}")
// private String ctiMessage;
//
//
// @Value("${cti.user.name}")
// private String ctiUserName;
//
// @Value("${cti.user.pwd}")
// private String ctiUserPwd;
@Autowired
private VoiceRecordFileServiceImpl voiceRecordFileServiceImpl;
// @Autowired
// private jcsAuthServiceImpl jcsAuthServiceImpl;
@Scheduled(fixedDelay=ONE_Minute)
// @Scheduled(fixedDelay=ONE_Minute)
public void fixedDelayJob(){
// // 设置token
// jcsAuthServiceImpl.setRequestContext();
// // 首先查找未完成 且失败次数少于5 的 记录
// List<VoiceRecordLog> logList = this.list(new LambdaQueryWrapper<VoiceRecordLog>().eq(VoiceRecordLog::getIsDeal,false).lt(VoiceRecordLog::getDealTimes,5));
// if(logList != null && logList.size() >0) {
// logList.stream().forEach(l -> {
// // 保存录音 修改状态 发送mqtt 通知
// // 获取通话人信息
// Integer dealTimes = 1;
// if(l.getDealTimes() != null) {
// dealTimes += l.getDealTimes();
// }
// l.setDealTimes(dealTimes);
// JSONArray ctiInfos = ctiService.getCallInfo(l.getConnectId());
// 设置token
System.out.println(JSON.toJSONString(RequestContext.cloneRequestContext()));
// 首先查找未完成 且失败次数少于5 的 记录
List<VoiceRecordLog> logList = this.list(new LambdaQueryWrapper<VoiceRecordLog>().eq(VoiceRecordLog::getIsDeal,false).lt(VoiceRecordLog::getDealTimes,5));
if(logList != null && logList.size() >0) {
logList.stream().forEach(l -> {
// 保存录音 修改状态 发送mqtt 通知
// 获取通话人信息
Integer dealTimes = 1;
if(l.getDealTimes() != null) {
dealTimes += l.getDealTimes();
}
l.setDealTimes(dealTimes);
Map<String, String> map = fusionService.getCallRecordByCID(l.getConnectId());
// if(ctiInfos == null || ctiInfos.size() == 0) {
// this.updateById(l);
// return;
// }
// VoiceRecordFileDto model = new VoiceRecordFileDto();
// JSONObject recordInfo = ctiInfos.getJSONObject(0);
// model.setAlertId(l.getAlertId());
// model.setTel(recordInfo.getString("telephone"));
//
// Date telStartTime = null;
// Date telEndTime = null;
// try {
// telStartTime = DateUtils.longStr2Date(recordInfo.getString("connectTime"));
// telEndTime = DateUtils.longStr2Date(recordInfo.getString("hangupTime"));
// } catch (Exception e) {
// this.updateById(l);
// return;
// }
// int times = recordInfo.getIntValue("times");
// model.setTelTime(DateUtils.secondsToTimeStr(times));
// model.setTelStartTime(telStartTime);
// model.setTelEndTime(telEndTime);
// if(1 == recordInfo.getInteger("callType")) {
// model.setFileType("客户呼入");
// } else if(2 == recordInfo.getInteger("callType")) {
// model.setFileType("坐席呼出");
// }
//
// Map<String, String> downloadFile = null;
// try {
VoiceRecordFileDto model = new VoiceRecordFileDto();
model.setAlertId(l.getAlertId());
model.setCaller(map.get("caller"));
model.setCalled(map.get("called"));
Date telStartTime = null;
Date telEndTime = null;
try {
telStartTime = DateUtils.longStr2Date(map.get("createTime"));
telEndTime = DateUtils.longStr2Date(map.get("releaseTime"));
} catch (Exception e) {
this.updateById(l);
return;
}
model.setTelTime(DateUtils.secondsToTimeStr(Integer.valueOf(map.get("timeLength"))));
model.setTelStartTime(telStartTime);
model.setTelEndTime(telEndTime);
if(1 == Integer.valueOf(map.get("callType"))) {
model.setFileType("客户呼入");
} else if(2 == Integer.valueOf(map.get("callType"))) {
model.setFileType("坐席呼出");
}
Map<String, String> downloadFile = null;
try {
// JSONObject jsonObject = fusionService.getCallRecordByCID(l.getConnectId());
// Map<String, String> map = voiceRecordFileService.getResult(jsonObject);
// downloadFile = ctiService.downLoadRecordFile(recordInfo.getString("connectionid"));
// } catch (Exception e) {
// e.printStackTrace();
// this.updateById(l);
// return;
// }
// if(downloadFile.isEmpty()) {
// this.updateById(l);
// return;
// }
// for(Map.Entry<String,String> file : downloadFile.entrySet()) {
// model.setFilePath(file.getKey());
// }
} catch (Exception e) {
e.printStackTrace();
this.updateById(l);
return;
}
if(downloadFile.isEmpty()) {
this.updateById(l);
return;
}
for(Map.Entry<String,String> file : downloadFile.entrySet()) {
model.setFilePath(file.getKey());
}
// AlertCalledFormDto alertDto = iAlertCalledService.selectAlertCalledByIdNoCache(model.getAlertId());
// if(alertDto == null || alertDto.getAlertCalledDto() == null) {
// this.updateById(l);
......@@ -148,10 +145,10 @@ public class VoiceRecordLogServiceImpl extends BaseService<VoiceRecordLogDto,Voi
// }
// l.setIsDeal(true);
// this.updateById(l);
// });
// }
//
// System.out.println("执行通话记录任务");
});
}
System.out.println("执行通话记录任务");
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment