Commit 8ff0bcd2 authored by xinglei's avatar xinglei

*)增加调用融合终端接口

parent f63d2e82
......@@ -103,13 +103,11 @@ public class RestTemplateUtil {
return restTemplate;
}
private static AsyncRestTemplate asyncRestInit() {
return new AsyncRestTemplate();
}
private static RestTemplate getRestInstance() {
public static RestTemplate getRestInstance() {
return RestSingle.INSTANCE;
}
......
......@@ -319,5 +319,7 @@ public interface EquipFeignClient {
@RequestMapping(value = "/car/{id}", method = RequestMethod.GET)
ResponseModel<Map<String, Object>> selectOneById( @PathVariable Long id);
@RequestMapping(value = "/car/all/fusion", method = RequestMethod.GET)
ResponseModel<List> getCarFusionList();
}
package com.yeejoin.amos.boot.module.jcs.api.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @Author: xl
* @Description: 融合终端车辆Dto
* @Date: 2021/11/25 11:35
*/
@Data
public class FusionDto {
@ApiModelProperty(value = "ID")
private String id;
@ApiModelProperty(value = "名称")
private String name;
@ApiModelProperty(value = "状态【0:在线;1:离线】")
private String state;
@ApiModelProperty(value = "经度")
private String latitude;
@ApiModelProperty(value = "纬度")
private String longitude;
@ApiModelProperty(value = "车牌号")
private String carNum;
}
package com.yeejoin.amos.boot.module.jcs.api.dto;
import com.yeejoin.amos.boot.biz.common.dto.BaseDto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
/**
* 通话记录附件
*
* @author system_generator
* @date 2021-08-03
*/
@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel(value="VoiceRecordFileDto", description="通话记录附件")
public class VoiceRecordFileDto extends BaseDto {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "文件地址")
private String filePath;
@ApiModelProperty(value = "通话类型")
private String fileType;
@ApiModelProperty(value = "通话开始时间")
private Date telStartTime;
@ApiModelProperty(value = "通话结束时间")
private Date telEndTime;
@ApiModelProperty(value = "所属者id")
private Long sourceId;
@ApiModelProperty(value = "警情id")
private Long alertId;
@ApiModelProperty(value = "警情阶段")
private String alertStage;
@ApiModelProperty(value = "警情阶段code")
private String alertStageCode;
@ApiModelProperty(value = "通话时长")
private String telTime;
@ApiModelProperty(value = "通话记录id")
private String connectId;
@ApiModelProperty(value = "关联工单编号")
private String workNum;
@ApiModelProperty(value = "通话开始时间str")
private String telStartTimeStr;
@ApiModelProperty(value = "通话结束时间str")
private String telEndTimeStr;
@ApiModelProperty(value = "主呼号码")
private String caller;
@ApiModelProperty(value = "被呼号码")
private String called;
}
package com.yeejoin.amos.boot.module.jcs.api.dto;
import com.yeejoin.amos.boot.biz.common.dto.BaseDto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 通话记录记录表
*
* @author system_generator
* @date 2021-11-09
*/
@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel(value="VoiceRecordLogDto", description="通话记录记录表")
public class VoiceRecordLogDto extends BaseDto {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "警情id")
private Long alertId;
@ApiModelProperty(value = "cti通话id")
private String connectId;
@ApiModelProperty(value = "是否处理")
private Boolean isDeal;
@ApiModelProperty(value = "处理次数")
private Integer dealTimes;
}
package com.yeejoin.amos.boot.module.jcs.api.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.yeejoin.amos.boot.biz.common.entity.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.util.Date;
/**
* 通话记录附件
*
* @author system_generator
* @date 2021-08-03
*/
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("jc_voice_record_file")
public class VoiceRecordFile extends BaseEntity {
private static final long serialVersionUID = 1L;
/**
* 文件地址
*/
@TableField("file_path")
private String filePath;
/**
* 通话类型
*/
@TableField("file_type")
private String fileType;
/**
* 主呼号码
*/
@TableField("caller")
private String caller;
/**
* 被呼号码
*/
@TableField("called")
private String called;
/**
* 通话开始时间
*/
@TableField("tel_start_time")
private Date telStartTime;
/**
* 通话结束时间
*/
@TableField("tel_end_time")
private Date telEndTime;
/**
* 所属者id
*/
@TableField("source_id")
private Long sourceId;
/**
* 警情id
*/
@TableField("alert_id")
private Long alertId;
/**
* 警情阶段
*/
@TableField("alert_stage")
private String alertStage;
/**
* 警情阶段code
*/
@TableField("alert_stage_code")
private String alertStageCode;
/**
* 通话时长
*/
@TableField("tel_time")
private String telTime;
}
package com.yeejoin.amos.boot.module.jcs.api.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.yeejoin.amos.boot.biz.common.entity.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* 通话记录记录表
*
* @author system_generator
* @date 2021-11-09
*/
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("jc_voice_record_log")
public class VoiceRecordLog extends BaseEntity {
private static final long serialVersionUID = 1L;
/**
* 警情id
*/
@TableField("alert_id")
private Long alertId;
/**
* cti通话id
*/
@TableField("connect_id")
private String connectId;
/**
* 是否处理
*/
@TableField("is_deal")
private Boolean isDeal;
/**
* 处理次数
*/
@TableField("deal_times")
private Integer dealTimes;
}
package com.yeejoin.amos.boot.module.jcs.api.enums;
/**
* 状态枚举
*
* @author xl
*/
public enum EmployeeEnum {
在线("在线", "0"),
离线("离线", "1");
private String key;
private String value;
EmployeeEnum(String key, String value) {
this.key = key;
this.value = value;
}
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}
package com.yeejoin.amos.boot.module.jcs.api.enums;
/**
* 装备指标枚举
*
* @author xl
*/
public enum PropertyEnum {
GIS("GIS", "FAS_Car_GIS"),
VIDEO("摄像头", "FAS_Car_Video");
private String key;
private String value;
PropertyEnum(String key, String value) {
this.key = key;
this.value = value;
}
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}
package com.yeejoin.amos.boot.module.jcs.api.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.jcs.api.dto.VoiceRecordFileDto;
import com.yeejoin.amos.boot.module.jcs.api.entity.VoiceRecordFile;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 通话记录附件 Mapper 接口
*
* @author system_generator
* @date 2021-08-03
*/
public interface VoiceRecordFileMapper extends BaseMapper<VoiceRecordFile> {
Page<List<VoiceRecordFileDto>> queryRecordListByQueryDto(Page<VoiceRecordFileDto> page,
@Param("telStartTimeStr") String telStartTimeStr,
@Param("telEndTimeStr") String telEndTimeStr,
@Param("fileType") String fileType,
@Param("tel") String tel,
@Param("workNum") String workNum,
@Param("sortParam") String sortParam,
@Param("sortRule") String sortRule);
VoiceRecordFileDto getRecordById(@Param("sequenceNbr") Long sequenceNbr);
List<VoiceRecordFileDto> selectExportData(@Param("ids") List<String> ids);
}
package com.yeejoin.amos.boot.module.jcs.api.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.boot.module.jcs.api.entity.VoiceRecordLog;
/**
* 通话记录记录表 Mapper 接口
*
* @author system_generator
* @date 2021-11-09
*/
public interface VoiceRecordLogMapper extends BaseMapper<VoiceRecordLog> {
}
package com.yeejoin.amos.boot.module.jcs.api.service;
import com.alibaba.fastjson.JSONObject;
/**
* @Author: xinglei
* @Description:
* @Date: 2021/11/25 10:18
*/
public interface IFusionService {
/**
* 查询所有在线成员信息
* @return
*/
JSONObject getAllOnlineUser();
/**
* 获取用户详细信息
* @param employeeID 设备号码
* @return
*/
JSONObject getEmployeeByEID(String employeeID);
/**
* 获取设备的最后一次位置信息
* @param employeeID 设备号码
* @return
*/
JSONObject getGISByEmployeeID(String employeeID);
/**
* 获取最新的一条通话记录
* @param caller 主呼号码
* @param called 被呼号码
* @return
*/
JSONObject getCallRecordByNumber(String caller, String called);
/**
* 获取通话录音记录
* @param cid 呼叫ID
* @return
*/
JSONObject getCallRecordByCID(String cid);
}
package com.yeejoin.amos.boot.module.jcs.api.service;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.jcs.api.dto.FusionDto;
import com.yeejoin.amos.boot.module.jcs.api.dto.VoiceRecordFileDto;
import java.util.List;
/**
* 通话记录附件接口类
*
* @author system_generator
* @date 2021-08-03
*/
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);
VoiceRecordFileDto getRecordById(Long sequenceNbr);
List<VoiceRecordFileDto> selectExportData(String exportId);
List<FusionDto> getCarList(Boolean hasFusion);
List<FusionDto> getSinglePawnList(Boolean hasFusion);
}
package com.yeejoin.amos.boot.module.jcs.api.service;
/**
* 通话记录记录表接口类
*
* @author system_generator
* @date 2021-11-09
*/
public interface IVoiceRecordLogService {
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yeejoin.amos.boot.module.jcs.api.mapper.VoiceRecordFileMapper">
<sql id="componentField">
r.sequence_nbr AS sequenceNbr,
r.file_path AS filePath,
r.file_type AS fileType,
r.tel AS tel,
r.tel_start_time AS telStartTime,
r.tel_end_time AS telEndTime,
r.alert_id AS alertId,
r.alert_stage AS alertStage,
r.alert_stage_code AS alertStageCode,
r.tel_time AS telTime
</sql>
<select id="queryRecordListByQueryDto" resultType="java.util.Map">
SELECT
<include refid="componentField"/>
FROM
jc_voice_record_file r
LEFT JOIN jc_alert_called a ON a.sequence_nbr =
r.alert_id
WHERE r.is_delete = 0
<if test="telStartTimeStr != null ">
and #{telStartTimeStr} <![CDATA[ <= ]]>
r.tel_start_time
</if>
<if test="telEndTimeStr != null ">
and r.tel_end_time <![CDATA[ <= ]]>
#{telEndTimeStr}
</if>
<if test="tel != null and tel != ''">
AND r.tel like
CONCAT(CONCAT('%',#{tel}),'%')
</if>
<if test="fileType != null and fileType != ''">
AND r.file_type = #{fileType}
</if>
<choose>
<when test="sortParam != null and sortParam != '' and sortRule != null and sortRule != '' ">
ORDER BY ${sortParam} ${sortRule}
</when>
<otherwise>
ORDER BY r.tel_start_time desc
</otherwise>
</choose>
</select>
<select id="getRecordById" resultType="com.yeejoin.amos.boot.module.jcs.api.dto.VoiceRecordFileDto">
SELECT
<include refid="componentField"/>
FROM
jc_voice_record_file r
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">
select
<include refid="componentField"/>
FROM
jc_voice_record_file r
LEFT JOIN jc_alert_called a ON a.sequence_nbr = r.alert_id
where r.is_delete = 0
<if test="ids != null and ids.size() > 0">
and r.sequence_nbr in
<foreach item="item" collection="ids" separator="," open="(" close=")" index=""> #{item}
</foreach>
</if>
</select>
</mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yeejoin.amos.boot.module.jcs.api.mapper.VoiceRecordLogMapper">
</mapper>
package com.yeejoin.amos.boot.module.jcs.biz.controller;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.boot.biz.common.utils.RedisKey;
import com.yeejoin.amos.boot.module.jcs.api.dto.FusionDto;
import com.yeejoin.amos.boot.module.jcs.api.dto.VoiceRecordFileDto;
import com.yeejoin.amos.boot.module.jcs.api.entity.VoiceRecordFile;
import com.yeejoin.amos.boot.module.jcs.biz.service.impl.AlertCalledServiceImpl;
import com.yeejoin.amos.boot.module.jcs.biz.service.impl.FusionServiceImpl;
import com.yeejoin.amos.boot.module.jcs.biz.service.impl.VoiceRecordFileServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.util.ArrayList;
import java.util.List;
/**
* 融合终端Controller
*
* @author xl
* @date 2021-11-25
*/
@RestController
@Api(tags = "融合终端Api")
@RequestMapping(value = "/fusion")
public class FusionController extends BaseController {
@Autowired
FusionServiceImpl fusionService;
@Autowired
VoiceRecordFileServiceImpl voiceRecordFileService;
/**
* 查询用户详情
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET",value = "查询用户详情", notes = "查询用户详情")
@GetMapping(value = "/getEmployeeByEID")
public ResponseModel<JSONObject> getEmployeeByEID(@RequestParam(value = "employeeId", required = true) String employeeId) {
JSONObject jsonObject = fusionService.getEmployeeByEID(employeeId);
return ResponseHelper.buildResponse(jsonObject);
}
/**
* 查询车辆
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET",value = "获取车辆信息", notes = "获取车辆信息")
@GetMapping(value = "/getCarList")
public ResponseModel<List> getCarList(@RequestParam(value = "hasFusion", required = false) Boolean hasFusion) {
List<FusionDto> carList = voiceRecordFileService.getCarList(hasFusion);
return ResponseHelper.buildResponse(carList);
}
/**
* 查询单兵
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET",value = "获取单兵信息", notes = "获取单兵信息")
@GetMapping(value = "/getSinglePawnList")
public ResponseModel<List> getSinglePawnList(@RequestParam(value = "hasFusion", required = false) Boolean hasFusion) {
List<FusionDto> singlePawnList = voiceRecordFileService.getSinglePawnList(hasFusion);
return ResponseHelper.buildResponse(singlePawnList);
}
}
package com.yeejoin.amos.boot.module.jcs.biz.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.boot.biz.common.utils.RedisKey;
import com.yeejoin.amos.boot.module.jcs.api.dto.VoiceRecordFileDto;
import com.yeejoin.amos.boot.module.jcs.api.entity.VoiceRecordFile;
import com.yeejoin.amos.boot.module.jcs.biz.service.impl.AlertCalledServiceImpl;
import com.yeejoin.amos.boot.module.jcs.biz.service.impl.VoiceRecordFileServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.util.ArrayList;
import java.util.List;
/**
* 通话记录附件
*
* @author system_generator
* @date 2021-08-03
*/
@RestController
@Api(tags = "通话记录附件Api")
@RequestMapping(value = "/voice-record-file")
public class VoiceRecordFileController extends BaseController {
@Autowired
VoiceRecordFileServiceImpl voiceRecordFileServiceImpl;
@Autowired
AlertCalledServiceImpl iAlertCalledService;
/**
* 根据警情id 查找通话记录信息
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET",value = "根据警情id 查找通话记录信息", notes = "根据警情id 查找通话记录信息")
@GetMapping(value = "/list/alert/{alertId}")
public ResponseModel<List<VoiceRecordFileDto>> selectForListByAlertId(@PathVariable Long alertId) {
LambdaQueryWrapper<VoiceRecordFile> queryWrapper = new LambdaQueryWrapper<VoiceRecordFile>();
queryWrapper.eq(VoiceRecordFile::getAlertId, alertId).orderByDesc(VoiceRecordFile::getRecDate);
List<VoiceRecordFile> list = voiceRecordFileServiceImpl.list(queryWrapper);
List<VoiceRecordFileDto> dtoList = new ArrayList<VoiceRecordFileDto>(list.size());
list.stream().forEach(voiceRecord -> {
// 创建新的对象实例
VoiceRecordFileDto target = new VoiceRecordFileDto();
// 把原对象数据拷贝到新对象
BeanUtils.copyProperties(voiceRecord, target);
dtoList.add(target);
});
return ResponseHelper.buildResponse(dtoList);
}
/**
* 根据警情id 查找通话记录信息
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET",value = "根据id获取通话记录信息", notes = "根据id获取通话记录信息")
@GetMapping(value = "/{sequenceNbr}")
public ResponseModel<VoiceRecordFileDto> getRecordById(@PathVariable Long sequenceNbr) {
VoiceRecordFileDto record = voiceRecordFileServiceImpl.getRecordById(sequenceNbr);
return ResponseHelper.buildResponse(record);
}
/**
* 新增-通话记录
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@PostMapping(value = "/saveRecord")
@ApiOperation(httpMethod = "POST", value = "新增通话记录附件", notes = "新增通话记录附件")
public ResponseModel<Boolean> saveRecord(@RequestBody VoiceRecordFileDto model) {
if (ValidationUtil.isEmpty(model.getCaller())
|| ValidationUtil.isEmpty(model.getCalled())){
throw new BadRequest("参数校验失败.");
}
voiceRecordFileServiceImpl.publishRecord(model);
return ResponseHelper.buildResponse(true);
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "查询通话记录", notes = "查询通话记录")
@GetMapping("/selectRecord")
public ResponseModel<Page<VoiceRecordFileDto>> queryVoiceCodeByPager(VoiceRecordFileDto model,
@RequestParam(value = "pageNum") int pageNum, @RequestParam(value = "pageSize") int pageSize, String sort ) {
Page<VoiceRecordFileDto> page = new Page<VoiceRecordFileDto>();
page.setCurrent(pageNum);
page.setSize(pageSize);
String sortParam = "";
String sortRule = "";
if(sort!=null) { // 排序失效
String[] date= sort.split(",");
if(date[1].equals("ascend")) {
sortParam = RedisKey.humpToLine(date[0]);
sortRule = "asc";
}else {
sortParam =RedisKey.humpToLine(date[0]);
sortRule = "desc";
}
}else {
sortParam = "call_time";
sortRule = "desc";
}
Page<VoiceRecordFileDto> pageBean = voiceRecordFileServiceImpl.queryRecordListByQueryDto(page,
model.getTelStartTimeStr(),model.getTelEndTimeStr(),model.getFileType(),model.getCaller(),
model.getWorkNum(),sortParam,sortRule);
Page<VoiceRecordFileDto> result = new Page<VoiceRecordFileDto>(pageNum,pageSize);
long totle = pageBean.getTotal();
result.setRecords(pageBean.getRecords());
result.setTotal(totle);
return ResponseHelper.buildResponse(result);
}
}
package com.yeejoin.amos.boot.module.jcs.biz.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.boot.core.utils.RestTemplateUtil;
import com.yeejoin.amos.boot.module.jcs.api.service.IFusionService;
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.restful.exception.instance.BadRequest;
/**
* @Author: xl
* @Description:
* @Date: 2021/11/25 10:23
*/
@Service
public class FusionServiceImpl implements IFusionService {
private static final String voiceURL = "http://11.11.16.17/IFCInterface";
@Override
public JSONObject getAllOnlineUser() {
JSONObject jsonObject = null;
try {
jsonObject = RestTemplateUtil.getRestInstance().getForObject(String.format("%s/GetAllOnlineUser", voiceURL), JSONObject.class);
} catch (RestClientException e) {
e.printStackTrace();
throw new BadRequest("访问融合终端失败");
}
return jsonObject;
}
@Override
public JSONObject getEmployeeByEID(String employeeID) {
String url = String.format("%s/api/userManage/getEmployeeByEID?employeeId=%s", voiceURL, employeeID);
JSONObject jsonObject = null;
try {
jsonObject = RestTemplateUtil.getRestInstance().getForObject(url, JSONObject.class);
} catch (RestClientException e) {
e.printStackTrace();
throw new BadRequest("访问融合终端失败");
}
return jsonObject;
}
@Override
public JSONObject getGISByEmployeeID(String employeeID) {
MultiValueMap<String, String> requestEntity = new LinkedMultiValueMap<String, String>();
requestEntity.add("employeeID", employeeID);
JSONObject jsonObject = null;
try {
jsonObject = RestTemplateUtil.getRestInstance().postForObject(String.format("%s/GetGISByEmployeeID", voiceURL), requestEntity, JSONObject.class);
} catch (RestClientException e) {
e.printStackTrace();
throw new BadRequest("访问融合终端失败");
}
return jsonObject;
}
@Override
public JSONObject getCallRecordByNumber(String caller, String called) {
MultiValueMap<String, String> requestEntity = new LinkedMultiValueMap<String, String>();
requestEntity.add("caller", caller);
requestEntity.add("called", called);
JSONObject jsonObject = null;
try {
jsonObject = RestTemplateUtil.getRestInstance().postForObject(String.format("%s/GetCallRecordByNumber", voiceURL), requestEntity, JSONObject.class);
} catch (RestClientException e) {
e.printStackTrace();
throw new BadRequest("访问融合终端失败");
}
return jsonObject;
}
@Override
public JSONObject getCallRecordByCID(String cid) {
MultiValueMap<String, String> requestEntity = new LinkedMultiValueMap<String, String>();
requestEntity.add("cid", cid);
JSONObject jsonObject = null;
try {
jsonObject = RestTemplateUtil.getRestInstance().postForObject(String.format("%s/GetCallRecordByCID", voiceURL), requestEntity, JSONObject.class);
} catch (RestClientException e) {
e.printStackTrace();
throw new BadRequest("访问融合终端失败");
}
return jsonObject;
}
}
package com.yeejoin.amos.boot.module.jcs.biz.service.impl;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.common.api.feign.EquipFeignClient;
import com.yeejoin.amos.boot.module.jcs.api.dto.FusionDto;
import com.yeejoin.amos.boot.module.jcs.api.dto.VoiceRecordFileDto;
import com.yeejoin.amos.boot.module.jcs.api.entity.VoiceRecordFile;
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.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.*;
/**
* 通话记录附件服务实现类
*
* @author system_generator
* @date 2021-08-03
*/
@Service
public class VoiceRecordFileServiceImpl extends BaseService<VoiceRecordFileDto, VoiceRecordFile, VoiceRecordFileMapper> implements IVoiceRecordFileService {
private final String SINGLE_PAWN = "FUSION_TERMINAL_SINGLE_PAWN";
@Autowired
private VoiceRecordFileServiceImpl voiceRecordFileServiceImpl;
private final Logger logger = LogManager.getLogger(VoiceRecordFileServiceImpl.class);
@Autowired
AlertCalledServiceImpl iAlertCalledService;
@Autowired
IFusionService fusionService;
private volatile JSONArray ctiInfos;
@Autowired
EmqKeeper emqKeeper;
@Autowired
VoiceRecordLogServiceImpl iVoiceRecordLogServiceImpl;
@Autowired
EquipFeignClient equipFeignClient;
/**
* 分页查询
*/
public Page<VoiceRecordFileDto> queryForVoiceRecordFilePage(Page<VoiceRecordFileDto> page) {
return this.queryForPage(page, null, false);
}
/**
* 列表查询 示例
*/
public List<VoiceRecordFileDto> queryForVoiceRecordFileList() {
return this.queryForList("", false);
}
@Override
public void publishRecord(final VoiceRecordFileDto model) {
JSONObject jsonObject = fusionService.getCallRecordByNumber(model.getCaller(), model.getCalled());
Map<String, String> map = getResult(jsonObject);
// 保存到日志表中
VoiceRecordLog log = new VoiceRecordLog();
log.setAlertId(model.getAlertId());
log.setConnectId(map.get("cid"));
log.setIsDeal(false);
log.setDealTimes(0);
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) {
Page<List<VoiceRecordFileDto>> list = baseMapper.queryRecordListByQueryDto(page,
telStartTimeStr, telEndTimeStr, fileType, tel,
workNum, sortParam, sortRule);
Page<VoiceRecordFileDto> page1 = new Page<>();
List<VoiceRecordFileDto> resultDtoList = JSONArray.parseArray(JSONArray.toJSONString(list.getRecords()), VoiceRecordFileDto.class);
page1.setCurrent(page.getCurrent());
page1.setSize(page.getSize());
page1.setTotal(list.getTotal());
page1.setRecords(resultDtoList);
return page1;
}
@Override
public VoiceRecordFileDto getRecordById(Long sequenceNbr) {
VoiceRecordFileDto record = baseMapper.getRecordById(sequenceNbr);
return record;
}
@Override
public List<VoiceRecordFileDto> selectExportData(String exportId) {
List<String> ids = null;
if (StringUtils.isNotEmpty(exportId)) {
String[] idStr = exportId.split(",");
ids = Arrays.asList(idStr);
}
return baseMapper.selectExportData(ids);
}
@Override
public List<FusionDto> getCarList(Boolean hasFusion) {
List<FusionDto> fusionDtos = new ArrayList<>();
List carList = equipFeignClient.getCarFusionList().getResult();
List<String> employeeIDs = getAllOnlineUser();
if (!ValidationUtil.isEmpty(carList)) {
carList.forEach(x -> {
FusionDto fusionDto = new FusionDto();
Map map = (Map) x;
fusionDto.setName(String.valueOf(map.get("name")));
fusionDto.setCarNum(String.valueOf(map.get("carNum")));
buildFusionDtoAndId(fusionDto, employeeIDs, hasFusion, map);
fusionDtos.add(fusionDto);
});
}
return fusionDtos;
}
@Override
public List<FusionDto> getSinglePawnList(Boolean hasFusion) {
List<DictionarieValueModel> result = Systemctl.dictionarieClient.dictValues(SINGLE_PAWN).getResult();
List<FusionDto> fusionDtos = new ArrayList<>();
List<String> employeeIDs = getAllOnlineUser();
result.forEach(model -> {
FusionDto fusionDto = new FusionDto();
String employeeID = model.getDictDataKey();
fusionDto.setId(employeeID);
fusionDto.setName(model.getDictDataValue());
fusionDtos.add(buildFusionDto(fusionDto, employeeIDs, hasFusion));
});
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集合
*
* @return
*/
private List<String> getAllOnlineUser() {
JSONObject jsonObject = fusionService.getAllOnlineUser();
List<String> employeeIDs = new ArrayList<>();
if (!ValidationUtil.isEmpty(jsonObject)) {
JSONArray onlines = jsonObject.getJSONArray("Onlines");
onlines.forEach(x -> {
Map<String, String> obj = (Map) x;
employeeIDs.add(obj.get("employeeID"));
});
}
return employeeIDs;
}
private FusionDto buildFusionDtoAndId(FusionDto fusionDto, List<String> employeeIDs, Boolean hasFusion, Map map){
List carPropertyList = (List) map.get("carPropertyList");
carPropertyList.forEach(carProperty -> {
Map carPropertyMap = (Map) carProperty;
Object nameKey = carPropertyMap.get("nameKey");
if (hasFusion && PropertyEnum.GIS.getValue().equals(nameKey)){
fusionDto.setId(String.valueOf(carPropertyMap.get("value")));
} else if (!hasFusion && PropertyEnum.VIDEO.getValue().equals(nameKey)) {
fusionDto.setId(String.valueOf(carPropertyMap.get("value")));
}
});
buildFusionDto(fusionDto, employeeIDs, hasFusion);
return fusionDto;
}
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");
fusionDto.setLatitude(dMap.get("latitude"));
fusionDto.setLongitude(dMap.get("longitude"));
fusionDto.setState(employeeIDs.contains(fusionDto.getId()) ? EmployeeEnum.在线.getValue() : EmployeeEnum.离线.getValue());
}
return fusionDto;
}
}
\ No newline at end of file
package com.yeejoin.amos.boot.module.jcs.biz.service.impl;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yeejoin.amos.boot.biz.common.utils.DateUtils;
import com.yeejoin.amos.boot.biz.common.utils.RedisKey;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.boot.module.jcs.api.dto.AlertCalledFormDto;
import com.yeejoin.amos.boot.module.jcs.api.dto.VoiceRecordFileDto;
import com.yeejoin.amos.boot.module.jcs.api.dto.VoiceRecordLogDto;
import com.yeejoin.amos.boot.module.jcs.api.entity.VoiceRecordLog;
import com.yeejoin.amos.boot.module.jcs.api.mapper.VoiceRecordLogMapper;
import com.yeejoin.amos.boot.module.jcs.api.service.IVoiceRecordLogService;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.eclipse.paho.client.mqttv3.MqttException;
import org.springframework.beans.factory.annotation.Autowired;
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.rdbms.service.BaseService;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* 通话记录记录表服务实现类
*
* @author system_generator
* @date 2021-11-09
*/
@Service
public class VoiceRecordLogServiceImpl extends BaseService<VoiceRecordLogDto,VoiceRecordLog,VoiceRecordLogMapper> implements IVoiceRecordLogService {
private final Logger logger = LogManager.getLogger(VoiceRecordFileServiceImpl.class);
@Autowired
RedisUtils redisUtils;
@Autowired
AlertCalledServiceImpl iAlertCalledService;
@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)
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());
// 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 {
// 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());
// }
// AlertCalledFormDto alertDto = iAlertCalledService.selectAlertCalledByIdNoCache(model.getAlertId());
// if(alertDto == null || alertDto.getAlertCalledDto() == null) {
// this.updateById(l);
// return;
// }
// model.setAlertStage(alertDto.getAlertCalledDto().getAlertStage());
// model.setAlertStageCode(alertDto.getAlertCalledDto().getAlertStageCode());
// model.setSourceId(-1l);
// voiceRecordFileServiceImpl.createWithModel(model);
// JSONObject json = new JSONObject();
// json.put("alertId",model.getAlertId());
// try {
// emqKeeper.getMqttClient().publish(ctiMessage, json.toJSONString().getBytes(), 2, false);
// try {
// redisUtils.del(RedisKey.jcs_ALERTCALLED_ID+model.getAlertId());
// } catch (Exception e) {
// e.printStackTrace();
// logger.error("删除redis失败:" + e.getMessage());
// }
// } catch (MqttException e) {
// logger.error("推送失败");
// }
// l.setIsDeal(true);
// this.updateById(l);
// });
// }
//
// 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