Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 05cb75e652 | |||
| 5813425be9 | |||
| 539caa4b5f |
@ -131,8 +131,8 @@ public class AppVideoController extends BaseController {
|
|||||||
* 删除语音文件
|
* 删除语音文件
|
||||||
*/
|
*/
|
||||||
@GetMapping("/deleteAudioFile")
|
@GetMapping("/deleteAudioFile")
|
||||||
public R<Void> deleteAudioFile(Long fileId,Long deviceId) {
|
public R<Void> deleteAudioFile(Long id) {
|
||||||
return audioProcessService.deleteAudioFile(fileId,deviceId);
|
return audioProcessService.deleteAudioFile(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -6,6 +6,8 @@ import org.springframework.web.multipart.MultipartFile;
|
|||||||
@Data
|
@Data
|
||||||
public class AppFileRenameDto {
|
public class AppFileRenameDto {
|
||||||
|
|
||||||
|
private Long id;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 文件id
|
* 文件id
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -414,19 +414,18 @@ public class AudioProcessService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Long getUserId(String source,Long deviceId){
|
private Long getUserId(String source,Long deviceId){
|
||||||
Long userId = null;
|
|
||||||
if("app".equals( source)){
|
if("app".equals( source)){
|
||||||
userId = AppLoginHelper.getUserId();
|
return AppLoginHelper.getUserId();
|
||||||
} else if ("web".equals( source)){
|
} else if ("web".equals( source)){
|
||||||
AppDeviceBindRecordBo appDeviceBindRecordBo = new AppDeviceBindRecordBo();
|
// AppDeviceBindRecordBo appDeviceBindRecordBo = new AppDeviceBindRecordBo();
|
||||||
appDeviceBindRecordBo.setDeviceId(deviceId);
|
// appDeviceBindRecordBo.setDeviceId(deviceId);
|
||||||
appDeviceBindRecordBo.setCommunicationMode(0);
|
//// appDeviceBindRecordBo.setCommunicationMode(0);
|
||||||
List<AppDeviceBindRecordVo> appDeviceBindRecordVos = appDeviceBindRecordService.queryList(appDeviceBindRecordBo);
|
// List<AppDeviceBindRecordVo> appDeviceBindRecordVos = appDeviceBindRecordService.queryList(appDeviceBindRecordBo);
|
||||||
if (appDeviceBindRecordVos != null && !appDeviceBindRecordVos.isEmpty()){
|
// if (appDeviceBindRecordVos != null && !appDeviceBindRecordVos.isEmpty()){
|
||||||
userId = appDeviceBindRecordVos.get(0).getBindingUserId();
|
// userId = appDeviceBindRecordVos.get(0).getBindingUserId();
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
}
|
return 0L;
|
||||||
return userId;
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* 校验音频文件格式
|
* 校验音频文件格式
|
||||||
@ -450,8 +449,9 @@ public class AudioProcessService {
|
|||||||
throw new IllegalArgumentException("只允许上传MP3、WAV、PCM格式的音频文件");
|
throw new IllegalArgumentException("只允许上传MP3、WAV、PCM格式的音频文件");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
long fileSize = 256 * 1024;
|
||||||
// 检查文件大小
|
// 检查文件大小
|
||||||
if (file.getSize() > MAX_AUDIO_SIZE) {
|
if (file.getSize() > fileSize) {
|
||||||
throw new IllegalArgumentException("音频大小不能超过5MB");
|
throw new IllegalArgumentException("音频大小不能超过5MB");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -571,26 +571,29 @@ public class AudioProcessService {
|
|||||||
if(deviceId == null){
|
if(deviceId == null){
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
Long userId = getUserId(source, deviceId);
|
Long userId = getUserId(source, deviceId);
|
||||||
AppBusinessFileBo bo = new AppBusinessFileBo();
|
AppBusinessFileBo bo = new AppBusinessFileBo();
|
||||||
bo.setBusinessId(deviceId);
|
bo.setBusinessId(deviceId);
|
||||||
bo.setCreateBy(userId);
|
|
||||||
bo.setFileType(3L);
|
bo.setFileType(3L);
|
||||||
|
if("web".equals(source)){
|
||||||
|
bo.setCreateBy(null);
|
||||||
|
}else{
|
||||||
|
bo.setCreateBy(userId);
|
||||||
|
}
|
||||||
return appBusinessFileService.queryAppFileList(bo);
|
return appBusinessFileService.queryAppFileList(bo);
|
||||||
}
|
}
|
||||||
|
|
||||||
public R<Void> deleteAudioFile(Long fileId,Long deviceId) {
|
public R<Void> deleteAudioFile(Long id) {
|
||||||
UpdateWrapper<AppBusinessFile> updateWrapper = new UpdateWrapper<>();
|
UpdateWrapper<AppBusinessFile> updateWrapper = new UpdateWrapper<>();
|
||||||
updateWrapper.eq("file_id",fileId);
|
updateWrapper.eq("id",id);
|
||||||
updateWrapper.eq("business_id",deviceId);
|
|
||||||
appBusinessFileMapper.delete(updateWrapper);
|
appBusinessFileMapper.delete(updateWrapper);
|
||||||
return R.ok();
|
return R.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
public R<Void> renameAudioFile(AppFileRenameDto bo) {
|
public R<Void> renameAudioFile(AppFileRenameDto bo) {
|
||||||
UpdateWrapper<AppBusinessFile> updateWrapper = new UpdateWrapper<>();
|
UpdateWrapper<AppBusinessFile> updateWrapper = new UpdateWrapper<>();
|
||||||
updateWrapper.eq("file_id",bo.getFileId());
|
updateWrapper.eq("id",bo.getId());
|
||||||
updateWrapper.eq("business_id",bo.getDeviceId());
|
|
||||||
updateWrapper.set("re_name",bo.getFileName());
|
updateWrapper.set("re_name",bo.getFileName());
|
||||||
appBusinessFileMapper.update(updateWrapper);
|
appBusinessFileMapper.update(updateWrapper);
|
||||||
return R.ok();
|
return R.ok();
|
||||||
|
|||||||
@ -123,8 +123,8 @@ public class WebVideoController extends BaseController {
|
|||||||
* 删除语音文件
|
* 删除语音文件
|
||||||
*/
|
*/
|
||||||
@GetMapping("/deleteAudioFile")
|
@GetMapping("/deleteAudioFile")
|
||||||
public R<Void> deleteAudioFile(Long fileId,Long deviceId) {
|
public R<Void> deleteAudioFile(Long id) {
|
||||||
return audioProcessService.deleteAudioFile(fileId,deviceId);
|
return audioProcessService.deleteAudioFile(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -38,6 +38,7 @@ public class WebDeviceHBY100JController extends BaseController {
|
|||||||
*/
|
*/
|
||||||
@PostMapping("/updateVoice")
|
@PostMapping("/updateVoice")
|
||||||
public R<Void> updateVoice(@RequestBody HBY100JUpdateVoiceDto dto) {
|
public R<Void> updateVoice(@RequestBody HBY100JUpdateVoiceDto dto) {
|
||||||
|
dto.setCommunicationMode(0);
|
||||||
deviceHBY100JBizService.updateVoice(dto);
|
deviceHBY100JBizService.updateVoice(dto);
|
||||||
return R.ok();
|
return R.ok();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,4 +7,8 @@ public class HBY100JUpdateVoiceDto {
|
|||||||
|
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通讯方式 0:4G;1:蓝牙
|
||||||
|
*/
|
||||||
|
private Integer communicationMode;
|
||||||
}
|
}
|
||||||
@ -271,12 +271,12 @@ public class DeviceBizService {
|
|||||||
if (type == 0) {
|
if (type == 0) {
|
||||||
QueryWrapper<AppDeviceBindRecord> bindRecordQueryWrapper = new QueryWrapper<>();
|
QueryWrapper<AppDeviceBindRecord> bindRecordQueryWrapper = new QueryWrapper<>();
|
||||||
bindRecordQueryWrapper.eq("device_id", device.getId());
|
bindRecordQueryWrapper.eq("device_id", device.getId());
|
||||||
bindRecordQueryWrapper.eq("binding_user_id", userId);
|
// bindRecordQueryWrapper.eq("binding_user_id", userId);
|
||||||
Long count = appDeviceBindRecordMapper.selectCount(bindRecordQueryWrapper);
|
Long count = appDeviceBindRecordMapper.selectCount(bindRecordQueryWrapper);
|
||||||
if (count == 0) {
|
if (count == 0) {
|
||||||
throw new RuntimeException("请先绑定设备!!!");
|
throw new RuntimeException("请先绑定设备!!!");
|
||||||
}
|
}
|
||||||
if (count < 2) {
|
if (count <= 1) {
|
||||||
UpdateWrapper<Device> deviceUpdateWrapper = new UpdateWrapper<>();
|
UpdateWrapper<Device> deviceUpdateWrapper = new UpdateWrapper<>();
|
||||||
deviceUpdateWrapper.eq("id", device.getId())
|
deviceUpdateWrapper.eq("id", device.getId())
|
||||||
.set("binding_user_id", null)
|
.set("binding_user_id", null)
|
||||||
|
|||||||
@ -166,7 +166,7 @@ public class DeviceHBY100JBizService {
|
|||||||
if(StringUtils.isNotBlank(voicePlayStatus)){
|
if(StringUtils.isNotBlank(voicePlayStatus)){
|
||||||
FuncType6VoicePlayRequest funcType6VoicePlayRequest = JSONObject.parseObject(voicePlayStatus, FuncType6VoicePlayRequest.class);
|
FuncType6VoicePlayRequest funcType6VoicePlayRequest = JSONObject.parseObject(voicePlayStatus, FuncType6VoicePlayRequest.class);
|
||||||
if(funcType6VoicePlayRequest.getData() != null){
|
if(funcType6VoicePlayRequest.getData() != null){
|
||||||
vo.setVolume(funcType6VoicePlayRequest.getData().getVoiceBroadcast());
|
vo.setVoiceBroadcast(funcType6VoicePlayRequest.getData().getVoiceBroadcast());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -285,8 +285,8 @@ public class DeviceHBY100JBizService {
|
|||||||
if (getDeviceStatus(deviceObj.getDeviceImei())) {
|
if (getDeviceStatus(deviceObj.getDeviceImei())) {
|
||||||
throw new ServiceException(deviceObj.getDeviceName() + ",设备已断开连接");
|
throw new ServiceException(deviceObj.getDeviceName() + ",设备已断开连接");
|
||||||
}
|
}
|
||||||
|
|
||||||
AppLoginUser loginUser = AppLoginHelper.getLoginUser();
|
AppLoginUser loginUser = AppLoginHelper.getLoginUser();
|
||||||
|
if(dto.getCommunicationMode()!=null && dto.getCommunicationMode()==0){
|
||||||
SysOssVo sysOssVo = sysOssMapper.selectVoById(appBusinessFileVo.getFileId());
|
SysOssVo sysOssVo = sysOssMapper.selectVoById(appBusinessFileVo.getFileId());
|
||||||
FuncType5UpdateVoiceRequest request = new FuncType5UpdateVoiceRequest();
|
FuncType5UpdateVoiceRequest request = new FuncType5UpdateVoiceRequest();
|
||||||
request.setRequestId(GenerateIdUtil.generateNumericId());
|
request.setRequestId(GenerateIdUtil.generateNumericId());
|
||||||
@ -300,6 +300,7 @@ public class DeviceHBY100JBizService {
|
|||||||
log.info("HBY100J更新语音,参数:{}", request);
|
log.info("HBY100J更新语音,参数:{}", request);
|
||||||
|
|
||||||
mqttGateway.sendMsgToMqtt(buildMqttTopic(deviceObj.getDeviceImei()), 1, JSON.toJSONString(request));
|
mqttGateway.sendMsgToMqtt(buildMqttTopic(deviceObj.getDeviceImei()), 1, JSON.toJSONString(request));
|
||||||
|
}
|
||||||
|
|
||||||
UpdateWrapper<AppBusinessFile> updateWrapper = new UpdateWrapper<>();
|
UpdateWrapper<AppBusinessFile> updateWrapper = new UpdateWrapper<>();
|
||||||
updateWrapper.eq("business_id", appBusinessFileVo.getBusinessId());
|
updateWrapper.eq("business_id", appBusinessFileVo.getBusinessId());
|
||||||
|
|||||||
@ -17,4 +17,5 @@ import java.util.List;
|
|||||||
public interface AppBusinessFileMapper extends BaseMapperPlus<AppBusinessFile, AppBusinessFileVo> {
|
public interface AppBusinessFileMapper extends BaseMapperPlus<AppBusinessFile, AppBusinessFileVo> {
|
||||||
|
|
||||||
List<AppFileVo> queryAppFileList(AppBusinessFileBo bo);
|
List<AppFileVo> queryAppFileList(AppBusinessFileBo bo);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -23,8 +23,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<if test="fileType != null">
|
<if test="fileType != null">
|
||||||
and a.file_type = #{fileType}
|
and a.file_type = #{fileType}
|
||||||
</if>
|
</if>
|
||||||
<if test="createBy != null">
|
<if test="createBy != null ">
|
||||||
and a.create_by = #{createBy}
|
and (a.create_by = #{createBy} or a.create_by = 0)
|
||||||
</if>
|
</if>
|
||||||
order by a.create_time desc
|
order by a.create_time desc
|
||||||
</select>
|
</select>
|
||||||
|
|||||||
@ -213,11 +213,11 @@ public class SysOssServiceImpl implements ISysOssService, OssService {
|
|||||||
try {
|
try {
|
||||||
byte[] imageData = file.getBytes();
|
byte[] imageData = file.getBytes();
|
||||||
// 检查是否需要压缩
|
// 检查是否需要压缩
|
||||||
if (ImageCompressUtil.needCompress(imageData)) {
|
// if (ImageCompressUtil.needCompress(imageData)) {
|
||||||
// 压缩到100KB以内
|
// // 压缩到100KB以内
|
||||||
imageData = ImageCompressUtil.compressImage(imageData);
|
// imageData = ImageCompressUtil.compressImage(imageData);
|
||||||
// 使用压缩后的数据
|
// // 使用压缩后的数据
|
||||||
}
|
// }
|
||||||
uploadResult = storage.uploadSuffix(imageData, suffix, file.getContentType());
|
uploadResult = storage.uploadSuffix(imageData, suffix, file.getContentType());
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new ServiceException(e.getMessage());
|
throw new ServiceException(e.getMessage());
|
||||||
|
|||||||
Reference in New Issue
Block a user