Commit 34994fb4 authored by xinglei's avatar xinglei

*)增加修改接口

parent dde28218
...@@ -16,8 +16,6 @@ import java.util.List; ...@@ -16,8 +16,6 @@ import java.util.List;
*/ */
public interface IVoiceRecordFileService { public interface IVoiceRecordFileService {
void publishRecord(VoiceRecordFileDto model);
Page<VoiceRecordFileDto> queryRecordListByQueryDto(Page<VoiceRecordFileDto> page, String telEndTimeStr, String telEndTimeStr1, String fileType, String caller, String called, 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); VoiceRecordFileDto getRecordById(Long sequenceNbr);
...@@ -27,4 +25,6 @@ public interface IVoiceRecordFileService { ...@@ -27,4 +25,6 @@ public interface IVoiceRecordFileService {
List<FusionDto> getCarList(Boolean hasFusion); List<FusionDto> getCarList(Boolean hasFusion);
List<FusionDto> getSinglePawnList(Boolean hasFusion); List<FusionDto> getSinglePawnList(Boolean hasFusion);
List <VoiceRecordFileDto> listByAlertId(Long alertId);
} }
package com.yeejoin.amos.boot.module.jcs.biz.controller; 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.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.controller.BaseController; import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.boot.biz.common.utils.RedisKey; 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.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.AlertCalledServiceImpl;
import com.yeejoin.amos.boot.module.jcs.biz.service.impl.VoiceRecordFileServiceImpl; import com.yeejoin.amos.boot.module.jcs.biz.service.impl.VoiceRecordFileServiceImpl;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.typroject.tyboot.core.foundation.enumeration.UserType; import org.typroject.tyboot.core.foundation.enumeration.UserType;
...@@ -20,7 +17,6 @@ import org.typroject.tyboot.core.restful.exception.instance.BadRequest; ...@@ -20,7 +17,6 @@ import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import org.typroject.tyboot.core.restful.utils.ResponseHelper; import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel; import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.util.ArrayList;
import java.util.List; import java.util.List;
/** /**
...@@ -35,7 +31,7 @@ import java.util.List; ...@@ -35,7 +31,7 @@ import java.util.List;
public class VoiceRecordFileController extends BaseController { public class VoiceRecordFileController extends BaseController {
@Autowired @Autowired
VoiceRecordFileServiceImpl voiceRecordFileServiceImpl; VoiceRecordFileServiceImpl voiceRecordFileService;
@Autowired @Autowired
AlertCalledServiceImpl iAlertCalledService; AlertCalledServiceImpl iAlertCalledService;
...@@ -49,18 +45,7 @@ public class VoiceRecordFileController extends BaseController { ...@@ -49,18 +45,7 @@ public class VoiceRecordFileController extends BaseController {
@ApiOperation(httpMethod = "GET",value = "根据警情id 查找通话记录信息", notes = "根据警情id 查找通话记录信息") @ApiOperation(httpMethod = "GET",value = "根据警情id 查找通话记录信息", notes = "根据警情id 查找通话记录信息")
@GetMapping(value = "/list/alert/{alertId}") @GetMapping(value = "/list/alert/{alertId}")
public ResponseModel<List<VoiceRecordFileDto>> selectForListByAlertId(@PathVariable Long alertId) { public ResponseModel<List<VoiceRecordFileDto>> selectForListByAlertId(@PathVariable Long alertId) {
LambdaQueryWrapper<VoiceRecordFile> queryWrapper = new LambdaQueryWrapper<VoiceRecordFile>(); return ResponseHelper.buildResponse(voiceRecordFileService.listByAlertId(alertId));
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);
} }
/** /**
...@@ -73,7 +58,7 @@ public class VoiceRecordFileController extends BaseController { ...@@ -73,7 +58,7 @@ public class VoiceRecordFileController extends BaseController {
@GetMapping(value = "/{sequenceNbr}") @GetMapping(value = "/{sequenceNbr}")
public ResponseModel<VoiceRecordFileDto> getRecordById(@PathVariable Long sequenceNbr) { public ResponseModel<VoiceRecordFileDto> getRecordById(@PathVariable Long sequenceNbr) {
VoiceRecordFileDto record = voiceRecordFileServiceImpl.getRecordById(sequenceNbr); VoiceRecordFileDto record = voiceRecordFileService.getRecordById(sequenceNbr);
return ResponseHelper.buildResponse(record); return ResponseHelper.buildResponse(record);
} }
...@@ -85,13 +70,22 @@ public class VoiceRecordFileController extends BaseController { ...@@ -85,13 +70,22 @@ public class VoiceRecordFileController extends BaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@PostMapping(value = "/saveRecord") @PostMapping(value = "/saveRecord")
@ApiOperation(httpMethod = "POST", value = "新增通话记录附件", notes = "新增通话记录附件") @ApiOperation(httpMethod = "POST", value = "新增通话记录附件", notes = "新增通话记录附件")
public ResponseModel<Boolean> saveRecord(@RequestBody VoiceRecordFileDto model) { public ResponseModel<VoiceRecordFileDto> saveRecord(@RequestBody VoiceRecordFileDto model) {
if (ValidationUtil.isEmpty(model.getCaller()) if (ValidationUtil.isEmpty(model.getCaller())
|| ValidationUtil.isEmpty(model.getCalled())){ || ValidationUtil.isEmpty(model.getCalled())){
throw new BadRequest("参数校验失败."); throw new BadRequest("参数校验失败.");
} }
voiceRecordFileServiceImpl.publishRecord(model); return ResponseHelper.buildResponse(voiceRecordFileService.saveRecord(model));
return ResponseHelper.buildResponse(true); }
@TycloudOperation(ApiLevel = UserType.AGENCY)
@RequestMapping(value = "/{sequenceNbr}", method = RequestMethod.PUT)
@ApiOperation(httpMethod = "PUT", value = "更新通话记录附件", notes = "更新通话记录附件")
public ResponseModel<VoiceRecordFileDto> updateRecord(
@RequestBody VoiceRecordFileDto model,
@PathVariable(value = "sequenceNbr") Long sequenceNbr) {
model.setSequenceNbr(sequenceNbr);
return ResponseHelper.buildResponse(voiceRecordFileService.updateRecord(model));
} }
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
...@@ -117,7 +111,7 @@ public class VoiceRecordFileController extends BaseController { ...@@ -117,7 +111,7 @@ public class VoiceRecordFileController extends BaseController {
sortParam = "call_time"; sortParam = "call_time";
sortRule = "desc"; sortRule = "desc";
} }
Page<VoiceRecordFileDto> pageBean = voiceRecordFileServiceImpl.queryRecordListByQueryDto(page, Page<VoiceRecordFileDto> pageBean = voiceRecordFileService.queryRecordListByQueryDto(page,
model.getTelStartTimeStr(),model.getTelEndTimeStr(),model.getFileType(),model.getCaller(), model.getTelStartTimeStr(),model.getTelEndTimeStr(),model.getFileType(),model.getCaller(),
model.getCalled(),sortParam,sortRule); model.getCalled(),sortParam,sortRule);
Page<VoiceRecordFileDto> result = new Page<VoiceRecordFileDto>(pageNum,pageSize); Page<VoiceRecordFileDto> result = new Page<VoiceRecordFileDto>(pageNum,pageSize);
......
...@@ -2,6 +2,7 @@ package com.yeejoin.amos.boot.module.jcs.biz.service.impl; ...@@ -2,6 +2,7 @@ package com.yeejoin.amos.boot.module.jcs.biz.service.impl;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.common.api.feign.EquipFeignClient; 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.FusionDto;
...@@ -24,6 +25,7 @@ import org.springframework.util.Assert; ...@@ -24,6 +25,7 @@ import org.springframework.util.Assert;
import org.typroject.tyboot.component.emq.EmqKeeper; import org.typroject.tyboot.component.emq.EmqKeeper;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil; import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.rdbms.service.BaseService; import org.typroject.tyboot.core.rdbms.service.BaseService;
import org.typroject.tyboot.core.restful.exception.instance.DataNotFound;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
...@@ -77,28 +79,25 @@ public class VoiceRecordFileServiceImpl extends BaseService<VoiceRecordFileDto, ...@@ -77,28 +79,25 @@ public class VoiceRecordFileServiceImpl extends BaseService<VoiceRecordFileDto,
return this.queryForList("", false); return this.queryForList("", false);
} }
@Override public VoiceRecordFileDto saveRecord(final VoiceRecordFileDto model) {
public void publishRecord(final VoiceRecordFileDto model) {
Map<String, String> dMap = fusionService.getCallRecordByNumber(model.getCaller(), model.getCalled()); Map<String, String> dMap = fusionService.getCallRecordByNumber(model.getCaller(), model.getCalled());
// 保存到日志表中 // 保存到日志表中
VoiceRecordLog log = new VoiceRecordLog(); VoiceRecordLog log = new VoiceRecordLog();
VoiceRecordFile voiceRecordFile = new VoiceRecordFile();
BeanUtils.copyProperties(model, voiceRecordFile);
log.setAlertId(model.getAlertId()); log.setAlertId(model.getAlertId());
String cid = dMap.get("cid"); String cid = dMap.get("cid");
Assert.notNull(cid, "CID不能为空"); Assert.notNull(cid, "CID不能为空");
Map<String, String> callRecord = fusionService.getCallRecordByCID(cid); Map<String, String> callRecord = fusionService.getCallRecordByCID(cid);
voiceRecordFile.setConnectId(cid); model.setConnectId(cid);
log.setConnectId(cid); log.setConnectId(cid);
log.setIsDeal(false); log.setIsDeal(false);
log.setDealTimes(0); log.setDealTimes(0);
if (!ValidationUtil.isEmpty(callRecord)){ if (!ValidationUtil.isEmpty(callRecord)) {
voiceRecordFile.setFilePath(String.format("/%s/%s", callRecord.get("subPath"), callRecord.get("recordName").replace("wav", "mp3"))); model.setFilePath(String.format("/%s/%s", callRecord.get("subPath"), callRecord.get("recordName").replace("wav", "mp3")));
logger.info(String.format("音频地址:【%s】", String.format("/%s/%s", callRecord.get("subPath"), callRecord.get("recordName")))); logger.info(String.format("音频地址:【%s】", String.format("/%s/%s", callRecord.get("subPath"), callRecord.get("recordName"))));
} else { // 无录音地址记录日志 } else { // 无录音地址记录日志
iVoiceRecordLogServiceImpl.save(log); iVoiceRecordLogServiceImpl.save(log);
} }
save(voiceRecordFile); return this.createWithModel(model);
} }
@Override @Override
...@@ -118,9 +117,7 @@ public class VoiceRecordFileServiceImpl extends BaseService<VoiceRecordFileDto, ...@@ -118,9 +117,7 @@ public class VoiceRecordFileServiceImpl extends BaseService<VoiceRecordFileDto,
@Override @Override
public VoiceRecordFileDto getRecordById(Long sequenceNbr) { public VoiceRecordFileDto getRecordById(Long sequenceNbr) {
VoiceRecordFileDto record = baseMapper.getRecordById(sequenceNbr); VoiceRecordFileDto record = baseMapper.getRecordById(sequenceNbr);
Map<String, String> callRecord = fusionService.getCallRecordByCID(record.getConnectId()); return buildFilePath(record);
record.setFilePath(String.format("/%s/%s", callRecord.get("subPath"), callRecord.get("recordName")));
return record;
} }
@Override @Override
...@@ -169,6 +166,31 @@ public class VoiceRecordFileServiceImpl extends BaseService<VoiceRecordFileDto, ...@@ -169,6 +166,31 @@ public class VoiceRecordFileServiceImpl extends BaseService<VoiceRecordFileDto,
return fusionDtos; return fusionDtos;
} }
@Override
public List<VoiceRecordFileDto> listByAlertId(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<>();
list.stream().forEach(voiceRecord -> {
// 创建新的对象实例
VoiceRecordFileDto target = new VoiceRecordFileDto();
// 把原对象数据拷贝到新对象
BeanUtils.copyProperties(voiceRecord, target);
buildFilePath(target);
dtoList.add(target);
});
return dtoList;
}
public VoiceRecordFileDto updateRecord(VoiceRecordFileDto model) {
VoiceRecordFileDto oldModel = this.queryBySeq(model.getSequenceNbr());
if (ValidationUtil.isEmpty(oldModel))
throw new DataNotFound("找不到指定的数据.");
oldModel.setAlertId(model.getAlertId());
return this.updateWithModel(oldModel);
}
/** /**
* 获取在线用户的employeeID集合 * 获取在线用户的employeeID集合
* *
...@@ -176,7 +198,7 @@ public class VoiceRecordFileServiceImpl extends BaseService<VoiceRecordFileDto, ...@@ -176,7 +198,7 @@ public class VoiceRecordFileServiceImpl extends BaseService<VoiceRecordFileDto,
*/ */
private List<String> getAllOnlineUser(Boolean hasFusion) { private List<String> getAllOnlineUser(Boolean hasFusion) {
List<String> employeeIDs = new ArrayList<>(); List<String> employeeIDs = new ArrayList<>();
if (hasFusion){ if (hasFusion) {
JSONObject jsonObject = fusionService.getAllOnlineUser(); JSONObject jsonObject = fusionService.getAllOnlineUser();
if (!ValidationUtil.isEmpty(jsonObject)) { if (!ValidationUtil.isEmpty(jsonObject)) {
JSONArray onlines = jsonObject.getJSONArray("Onlines"); JSONArray onlines = jsonObject.getJSONArray("Onlines");
...@@ -189,12 +211,12 @@ public class VoiceRecordFileServiceImpl extends BaseService<VoiceRecordFileDto, ...@@ -189,12 +211,12 @@ public class VoiceRecordFileServiceImpl extends BaseService<VoiceRecordFileDto,
return employeeIDs; return employeeIDs;
} }
private FusionDto buildFusionDtoAndId(FusionDto fusionDto, List<String> employeeIDs, Boolean hasFusion, Map map){ private FusionDto buildFusionDtoAndId(FusionDto fusionDto, List<String> employeeIDs, Boolean hasFusion, Map map) {
List carPropertyList = (List) map.get("carPropertyList"); List carPropertyList = (List) map.get("carPropertyList");
carPropertyList.forEach(carProperty -> { carPropertyList.forEach(carProperty -> {
Map carPropertyMap = (Map) carProperty; Map carPropertyMap = (Map) carProperty;
Object nameKey = carPropertyMap.get("nameKey"); Object nameKey = carPropertyMap.get("nameKey");
if (hasFusion && PropertyEnum.GIS.getValue().equals(nameKey)){ if (hasFusion && PropertyEnum.GIS.getValue().equals(nameKey)) {
fusionDto.setId(String.valueOf(carPropertyMap.get("value"))); fusionDto.setId(String.valueOf(carPropertyMap.get("value")));
} else if (!hasFusion && PropertyEnum.VIDEO.getValue().equals(nameKey)) { } else if (!hasFusion && PropertyEnum.VIDEO.getValue().equals(nameKey)) {
fusionDto.setId(String.valueOf(carPropertyMap.get("value"))); fusionDto.setId(String.valueOf(carPropertyMap.get("value")));
...@@ -213,4 +235,10 @@ public class VoiceRecordFileServiceImpl extends BaseService<VoiceRecordFileDto, ...@@ -213,4 +235,10 @@ public class VoiceRecordFileServiceImpl extends BaseService<VoiceRecordFileDto,
} }
return fusionDto; return fusionDto;
} }
private VoiceRecordFileDto buildFilePath(VoiceRecordFileDto record) {
Map<String, String> callRecord = fusionService.getCallRecordByCID(record.getConnectId());
record.setFilePath(String.format("/%s/%s", callRecord.get("subPath"), callRecord.get("recordName")));
return record;
}
} }
\ 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