hby100j功能语音管理
This commit is contained in:
@ -4,6 +4,7 @@ import cn.dev33.satoken.annotation.SaIgnore;
|
|||||||
import com.fuyuanshen.app.domain.bo.AppBusinessFileBo;
|
import com.fuyuanshen.app.domain.bo.AppBusinessFileBo;
|
||||||
import com.fuyuanshen.app.domain.dto.AppAudioFileDto;
|
import com.fuyuanshen.app.domain.dto.AppAudioFileDto;
|
||||||
import com.fuyuanshen.app.domain.dto.AppFileDto;
|
import com.fuyuanshen.app.domain.dto.AppFileDto;
|
||||||
|
import com.fuyuanshen.app.domain.dto.AppFileRenameDto;
|
||||||
import com.fuyuanshen.app.domain.dto.TextToSpeechRequest;
|
import com.fuyuanshen.app.domain.dto.TextToSpeechRequest;
|
||||||
import com.fuyuanshen.app.domain.vo.AppFileVo;
|
import com.fuyuanshen.app.domain.vo.AppFileVo;
|
||||||
import com.fuyuanshen.app.service.AudioProcessService;
|
import com.fuyuanshen.app.service.AudioProcessService;
|
||||||
@ -78,7 +79,7 @@ public class AppVideoController extends BaseController {
|
|||||||
* 支持MP3、WAV、PCM格式
|
* 支持MP3、WAV、PCM格式
|
||||||
*/
|
*/
|
||||||
@PostMapping("/uploadAudioToOss")
|
@PostMapping("/uploadAudioToOss")
|
||||||
public R<String> uploadAudioToOss(@RequestParam("file") @ModelAttribute AppAudioFileDto bo) {
|
public R<String> uploadAudioToOss(@ModelAttribute AppAudioFileDto bo) {
|
||||||
try {
|
try {
|
||||||
String result = audioProcessService.uploadAudioToOss(bo);
|
String result = audioProcessService.uploadAudioToOss(bo);
|
||||||
return R.ok(result);
|
return R.ok(result);
|
||||||
@ -120,4 +121,20 @@ public class AppVideoController extends BaseController {
|
|||||||
public R<List<AppFileVo>> queryAudioFileList(Long deviceId) {
|
public R<List<AppFileVo>> queryAudioFileList(Long deviceId) {
|
||||||
return R.ok(audioProcessService.queryAudioFileList(deviceId));
|
return R.ok(audioProcessService.queryAudioFileList(deviceId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除语音文件
|
||||||
|
*/
|
||||||
|
@GetMapping("/deleteAudioFile")
|
||||||
|
public R<Void> deleteAudioFile(Long fileId,Long deviceId) {
|
||||||
|
return audioProcessService.deleteAudioFile(fileId,deviceId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文件重命名
|
||||||
|
*/
|
||||||
|
@PostMapping("/renameAudioFile")
|
||||||
|
public R<Void> renameAudioFile(@RequestBody AppFileRenameDto bo) {
|
||||||
|
return audioProcessService.renameAudioFile(bo);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,66 @@
|
|||||||
|
package com.fuyuanshen.app.controller.device.bjq;
|
||||||
|
|
||||||
|
import com.fuyuanshen.app.domain.bo.AppPersonnelInfoBo;
|
||||||
|
import com.fuyuanshen.app.domain.dto.AppDeviceLogoUploadDto;
|
||||||
|
import com.fuyuanshen.app.domain.dto.DeviceInstructDto;
|
||||||
|
import com.fuyuanshen.app.domain.vo.AppDeviceDetailVo;
|
||||||
|
import com.fuyuanshen.app.domain.vo.AppDeviceHBY100JDetailVo;
|
||||||
|
import com.fuyuanshen.common.core.domain.R;
|
||||||
|
import com.fuyuanshen.common.core.validate.AddGroup;
|
||||||
|
import com.fuyuanshen.common.ratelimiter.annotation.FunctionAccessAnnotation;
|
||||||
|
import com.fuyuanshen.common.ratelimiter.annotation.FunctionAccessBatcAnnotation;
|
||||||
|
import com.fuyuanshen.common.web.core.BaseController;
|
||||||
|
import com.fuyuanshen.equipment.domain.dto.AppDeviceSendMsgBo;
|
||||||
|
import com.fuyuanshen.web.service.device.DeviceBJQBizService;
|
||||||
|
import com.fuyuanshen.web.service.device.DeviceHBY100JBizService;
|
||||||
|
import jakarta.validation.constraints.NotNull;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* HBY100J设备控制类
|
||||||
|
*/
|
||||||
|
@Validated
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/app/hby100/device")
|
||||||
|
public class AppDeviceHBY100JController extends BaseController {
|
||||||
|
|
||||||
|
private final DeviceHBY100JBizService deviceHBY100JBizService;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取设备详细信息
|
||||||
|
*
|
||||||
|
* @param id 主键
|
||||||
|
*/
|
||||||
|
@GetMapping("/{id}")
|
||||||
|
public R<AppDeviceHBY100JDetailVo> getInfo(@NotNull(message = "主键不能为空")
|
||||||
|
@PathVariable Long id) {
|
||||||
|
return R.ok(deviceHBY100JBizService.getInfo(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新语音
|
||||||
|
*/
|
||||||
|
@PostMapping("/updateVoice")
|
||||||
|
public R<Void> updateVoice(Long id) {
|
||||||
|
deviceHBY100JBizService.updateVoice(id);
|
||||||
|
return R.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 强制报警
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
@PostMapping("/forceAlarmActivation")
|
||||||
|
public R<Void> forceAlarmActivation(@RequestBody AppDeviceSendMsgBo bo) {
|
||||||
|
deviceHBY100JBizService.forceAlarmActivation(bo);
|
||||||
|
return R.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,24 @@
|
|||||||
|
package com.fuyuanshen.app.domain.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class AppFileRenameDto {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文件id
|
||||||
|
*/
|
||||||
|
private Long fileId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备id
|
||||||
|
*/
|
||||||
|
private Long deviceId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文件名称
|
||||||
|
*/
|
||||||
|
private String fileName;
|
||||||
|
|
||||||
|
}
|
||||||
@ -1,9 +1,14 @@
|
|||||||
package com.fuyuanshen.app.service;
|
package com.fuyuanshen.app.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||||
|
import com.fuyuanshen.app.domain.AppBusinessFile;
|
||||||
import com.fuyuanshen.app.domain.bo.AppBusinessFileBo;
|
import com.fuyuanshen.app.domain.bo.AppBusinessFileBo;
|
||||||
import com.fuyuanshen.app.domain.dto.AppAudioFileDto;
|
import com.fuyuanshen.app.domain.dto.AppAudioFileDto;
|
||||||
|
import com.fuyuanshen.app.domain.dto.AppFileRenameDto;
|
||||||
import com.fuyuanshen.app.domain.vo.AppFileVo;
|
import com.fuyuanshen.app.domain.vo.AppFileVo;
|
||||||
import com.fuyuanshen.app.http.HttpTtsClient;
|
import com.fuyuanshen.app.http.HttpTtsClient;
|
||||||
|
import com.fuyuanshen.app.mapper.AppBusinessFileMapper;
|
||||||
|
import com.fuyuanshen.common.core.domain.R;
|
||||||
import com.fuyuanshen.common.satoken.utils.AppLoginHelper;
|
import com.fuyuanshen.common.satoken.utils.AppLoginHelper;
|
||||||
import com.fuyuanshen.equipment.utils.AlibabaTTSUtil;
|
import com.fuyuanshen.equipment.utils.AlibabaTTSUtil;
|
||||||
import com.fuyuanshen.equipment.utils.AudioProcessUtil;
|
import com.fuyuanshen.equipment.utils.AudioProcessUtil;
|
||||||
@ -55,6 +60,7 @@ public class AudioProcessService {
|
|||||||
private final FileHashUtil fileHashUtil;
|
private final FileHashUtil fileHashUtil;
|
||||||
private final ISysOssService ossService;
|
private final ISysOssService ossService;
|
||||||
private final IAppBusinessFileService appBusinessFileService;
|
private final IAppBusinessFileService appBusinessFileService;
|
||||||
|
private final AppBusinessFileMapper appBusinessFileMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 处理上传的音频文件
|
* 处理上传的音频文件
|
||||||
@ -192,6 +198,28 @@ public class AudioProcessService {
|
|||||||
return file.getAbsolutePath();
|
return file.getAbsolutePath();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String saveByteArrayToFile(InputStream inputStream, String filename) throws IOException {
|
||||||
|
// 确定保存路径(可以是临时目录或指定目录)
|
||||||
|
String directory = System.getProperty("java.io.tmpdir"); // 使用系统临时目录
|
||||||
|
File dir = new File(directory);
|
||||||
|
if (!dir.exists()) {
|
||||||
|
dir.mkdirs();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 创建完整文件路径
|
||||||
|
File file = new File(dir, filename);
|
||||||
|
|
||||||
|
// 从输入流读取数据并写入文件
|
||||||
|
try (FileOutputStream fos = new FileOutputStream(file);
|
||||||
|
InputStream is = inputStream) {
|
||||||
|
byte[] buffer = new byte[8192]; // 8KB缓冲区
|
||||||
|
int bytesRead;
|
||||||
|
while ((bytesRead = is.read(buffer)) != -1) {
|
||||||
|
fos.write(buffer, 0, bytesRead);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return file.getAbsolutePath();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -328,7 +356,8 @@ public class AudioProcessService {
|
|||||||
validateAudioFileForRestful(file);
|
validateAudioFileForRestful(file);
|
||||||
// 上传文件
|
// 上传文件
|
||||||
// SysOssVo upload = sysOssService.upload(file);
|
// SysOssVo upload = sysOssService.upload(file);
|
||||||
|
String filename = file.getOriginalFilename();
|
||||||
|
String savedPath = null;
|
||||||
try {
|
try {
|
||||||
String fileHash = fileHashUtil.hash(file);
|
String fileHash = fileHashUtil.hash(file);
|
||||||
SysOssVo upload = ossService.updateHash(file, fileHash);
|
SysOssVo upload = ossService.updateHash(file, fileHash);
|
||||||
@ -336,19 +365,30 @@ public class AudioProcessService {
|
|||||||
if (upload.getUrl() != null && upload.getUrl().startsWith("http://")) {
|
if (upload.getUrl() != null && upload.getUrl().startsWith("http://")) {
|
||||||
upload.setUrl(upload.getUrl().replaceFirst("^http://", "https://"));
|
upload.setUrl(upload.getUrl().replaceFirst("^http://", "https://"));
|
||||||
}
|
}
|
||||||
|
String fileSuffix = filename.substring(filename.lastIndexOf('.')).toLowerCase();
|
||||||
AppBusinessFileBo appBusinessFileBo = new AppBusinessFileBo();
|
AppBusinessFileBo appBusinessFileBo = new AppBusinessFileBo();
|
||||||
appBusinessFileBo.setFileId(upload.getOssId());
|
appBusinessFileBo.setFileId(upload.getOssId());
|
||||||
appBusinessFileBo.setBusinessId(bo.getDeviceId());
|
appBusinessFileBo.setBusinessId(bo.getDeviceId());
|
||||||
appBusinessFileBo.setFileType(3L);
|
appBusinessFileBo.setFileType(3L);
|
||||||
appBusinessFileBo.setCreateBy(AppLoginHelper.getUserId());
|
appBusinessFileBo.setCreateBy(AppLoginHelper.getUserId());
|
||||||
|
savedPath = saveByteArrayToFile(file.getInputStream(), generateRandomFileName(fileSuffix));
|
||||||
|
if (savedPath != null) {
|
||||||
|
log.info("MP3文件已保存: {}", savedPath);
|
||||||
|
Integer mp3Duration = Mp3Duration.getMp3Duration(savedPath);
|
||||||
|
log.info("MP3文件时长: {} 秒", mp3Duration);
|
||||||
|
appBusinessFileBo.setDuration(mp3Duration);
|
||||||
|
}
|
||||||
appBusinessFileService.insertByBo(appBusinessFileBo);
|
appBusinessFileService.insertByBo(appBusinessFileBo);
|
||||||
if (upload != null) {
|
if (upload != null) {
|
||||||
return upload.getUrl();
|
return upload.getUrl();
|
||||||
}
|
}
|
||||||
} catch (Exception e){
|
} catch (Exception e){
|
||||||
log.error("上传音频文件失败", e);
|
log.error("上传音频文件失败", e);
|
||||||
|
}finally {
|
||||||
|
log.info("删除临时文件: {}", savedPath);
|
||||||
|
if(savedPath != null){
|
||||||
|
deleteTempFile(new File(savedPath));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
@ -366,9 +406,13 @@ public class AudioProcessService {
|
|||||||
if (originalFilename == null) {
|
if (originalFilename == null) {
|
||||||
throw new IllegalArgumentException("文件名不能为空");
|
throw new IllegalArgumentException("文件名不能为空");
|
||||||
}
|
}
|
||||||
|
List<String> SUPPORTED_FORMATS = Arrays.asList(
|
||||||
|
".wav", ".mp3", ".pcm"
|
||||||
|
);
|
||||||
|
|
||||||
|
String ext = originalFilename.substring(originalFilename.lastIndexOf('.')).toLowerCase();
|
||||||
// 检查文件扩展名
|
// 检查文件扩展名
|
||||||
if (!isSupportedFormat(originalFilename)) {
|
if (!SUPPORTED_FORMATS.contains(ext)) {
|
||||||
throw new IllegalArgumentException("只允许上传MP3、WAV、PCM格式的音频文件");
|
throw new IllegalArgumentException("只允许上传MP3、WAV、PCM格式的音频文件");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -476,4 +520,21 @@ public class AudioProcessService {
|
|||||||
List<AppFileVo> appFileVos = appBusinessFileService.queryAppFileList(bo);
|
List<AppFileVo> appFileVos = appBusinessFileService.queryAppFileList(bo);
|
||||||
return appFileVos;
|
return appFileVos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public R<Void> deleteAudioFile(Long fileId,Long deviceId) {
|
||||||
|
UpdateWrapper<AppBusinessFile> updateWrapper = new UpdateWrapper<>();
|
||||||
|
updateWrapper.eq("file_id",fileId);
|
||||||
|
updateWrapper.eq("business_id",deviceId);
|
||||||
|
appBusinessFileMapper.delete(updateWrapper);
|
||||||
|
return R.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
public R<Void> renameAudioFile(AppFileRenameDto bo) {
|
||||||
|
UpdateWrapper<AppBusinessFile> updateWrapper = new UpdateWrapper<>();
|
||||||
|
updateWrapper.eq("file_id",bo.getFileId());
|
||||||
|
updateWrapper.eq("business_id",bo.getDeviceId());
|
||||||
|
updateWrapper.set("re_name",bo.getFileName());
|
||||||
|
appBusinessFileMapper.update(updateWrapper);
|
||||||
|
return R.ok();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -0,0 +1,193 @@
|
|||||||
|
package com.fuyuanshen.web.service.device;
|
||||||
|
|
||||||
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
|
import com.alibaba.fastjson2.JSON;
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||||
|
import com.fuyuanshen.app.domain.AppBusinessFile;
|
||||||
|
import com.fuyuanshen.app.domain.AppPersonnelInfo;
|
||||||
|
import com.fuyuanshen.app.domain.AppPersonnelInfoRecords;
|
||||||
|
import com.fuyuanshen.app.domain.bo.AppBusinessFileBo;
|
||||||
|
import com.fuyuanshen.app.domain.bo.AppPersonnelInfoBo;
|
||||||
|
import com.fuyuanshen.app.domain.dto.AppDeviceLogoUploadDto;
|
||||||
|
import com.fuyuanshen.app.domain.dto.DeviceInstructDto;
|
||||||
|
import com.fuyuanshen.app.domain.vo.AppBusinessFileVo;
|
||||||
|
import com.fuyuanshen.app.domain.vo.AppDeviceDetailVo;
|
||||||
|
import com.fuyuanshen.app.domain.vo.AppDeviceHBY100JDetailVo;
|
||||||
|
import com.fuyuanshen.app.domain.vo.AppPersonnelInfoVo;
|
||||||
|
import com.fuyuanshen.app.mapper.AppBusinessFileMapper;
|
||||||
|
import com.fuyuanshen.app.mapper.AppPersonnelInfoMapper;
|
||||||
|
import com.fuyuanshen.app.mapper.AppPersonnelInfoRecordsMapper;
|
||||||
|
import com.fuyuanshen.app.service.IAppBusinessFileService;
|
||||||
|
import com.fuyuanshen.common.core.constant.GlobalConstants;
|
||||||
|
import com.fuyuanshen.common.core.exception.ServiceException;
|
||||||
|
import com.fuyuanshen.common.core.utils.*;
|
||||||
|
import com.fuyuanshen.common.redis.utils.RedisUtils;
|
||||||
|
import com.fuyuanshen.common.satoken.utils.AppLoginHelper;
|
||||||
|
import com.fuyuanshen.equipment.domain.Device;
|
||||||
|
import com.fuyuanshen.equipment.domain.DeviceType;
|
||||||
|
import com.fuyuanshen.equipment.domain.dto.AppDeviceSendMsgBo;
|
||||||
|
import com.fuyuanshen.equipment.enums.LightModeEnum;
|
||||||
|
import com.fuyuanshen.equipment.mapper.DeviceLogMapper;
|
||||||
|
import com.fuyuanshen.equipment.mapper.DeviceMapper;
|
||||||
|
import com.fuyuanshen.equipment.mapper.DeviceTypeMapper;
|
||||||
|
import com.fuyuanshen.global.mqtt.config.MqttGateway;
|
||||||
|
import com.fuyuanshen.global.mqtt.constants.DeviceRedisKeyConstants;
|
||||||
|
import com.fuyuanshen.global.mqtt.constants.MqttConstants;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.core.io.ClassPathResource;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.time.Duration;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
import static com.fuyuanshen.common.core.constant.GlobalConstants.GLOBAL_REDIS_KEY;
|
||||||
|
import static com.fuyuanshen.common.core.utils.Bitmap80x12Generator.buildArr;
|
||||||
|
import static com.fuyuanshen.common.core.utils.Bitmap80x12Generator.generateFixedBitmapData;
|
||||||
|
import static com.fuyuanshen.common.core.utils.ImageToCArrayConverter.convertHexToDecimal;
|
||||||
|
import static com.fuyuanshen.global.mqtt.constants.DeviceRedisKeyConstants.*;
|
||||||
|
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class DeviceHBY100JBizService {
|
||||||
|
|
||||||
|
private final DeviceMapper deviceMapper;
|
||||||
|
private final DeviceTypeMapper deviceTypeMapper;
|
||||||
|
private final MqttGateway mqttGateway;
|
||||||
|
private final DeviceLogMapper deviceLogMapper;
|
||||||
|
private final IAppBusinessFileService appBusinessFileService;
|
||||||
|
private final AppBusinessFileMapper appBusinessFileMapper;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 记录设备操作日志
|
||||||
|
*
|
||||||
|
* @param deviceId 设备ID
|
||||||
|
* @param content 日志内容
|
||||||
|
* @param operator 操作人
|
||||||
|
*/
|
||||||
|
private void recordDeviceLog(Long deviceId, String deviceName, String deviceAction, String content, Long operator) {
|
||||||
|
try {
|
||||||
|
// 创建设备日志实体
|
||||||
|
com.fuyuanshen.equipment.domain.DeviceLog deviceLog = new com.fuyuanshen.equipment.domain.DeviceLog();
|
||||||
|
deviceLog.setDeviceId(deviceId);
|
||||||
|
deviceLog.setDeviceAction(deviceAction);
|
||||||
|
deviceLog.setContent(content);
|
||||||
|
deviceLog.setCreateBy(operator);
|
||||||
|
deviceLog.setDeviceName(deviceName);
|
||||||
|
deviceLog.setCreateTime(new Date());
|
||||||
|
|
||||||
|
// 插入日志记录
|
||||||
|
deviceLogMapper.insert(deviceLog);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("记录设备操作日志失败: {}", e.getMessage(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public AppDeviceHBY100JDetailVo getInfo(Long id) {
|
||||||
|
Device device = deviceMapper.selectById(id);
|
||||||
|
if (device == null) {
|
||||||
|
throw new RuntimeException("请先将设备入库!!!");
|
||||||
|
}
|
||||||
|
|
||||||
|
AppDeviceHBY100JDetailVo vo = new AppDeviceHBY100JDetailVo();
|
||||||
|
vo.setDeviceId(device.getId());
|
||||||
|
vo.setDeviceName(device.getDeviceName());
|
||||||
|
vo.setDevicePic(device.getDevicePic());
|
||||||
|
vo.setDeviceImei(device.getDeviceImei());
|
||||||
|
vo.setDeviceMac(device.getDeviceMac());
|
||||||
|
DeviceType deviceType = deviceTypeMapper.selectById(device.getDeviceType());
|
||||||
|
if (deviceType != null) {
|
||||||
|
vo.setCommunicationMode(Integer.valueOf(deviceType.getCommunicationMode()));
|
||||||
|
vo.setTypeName(deviceType.getTypeName());
|
||||||
|
}
|
||||||
|
vo.setBluetoothName(device.getBluetoothName());
|
||||||
|
|
||||||
|
// 设备在线状态
|
||||||
|
String onlineStatus = RedisUtils.getCacheObject(GLOBAL_REDIS_KEY + DEVICE_KEY_PREFIX + device.getDeviceImei() + DeviceRedisKeyConstants.DEVICE_ONLINE_STATUS_KEY_PREFIX);
|
||||||
|
// 设备在线状态
|
||||||
|
if ("1".equals(onlineStatus)) {
|
||||||
|
vo.setOnlineStatus(1);
|
||||||
|
} else if ("2".equals(onlineStatus)) {
|
||||||
|
vo.setOnlineStatus(2);
|
||||||
|
} else {
|
||||||
|
vo.setOnlineStatus(0);
|
||||||
|
}
|
||||||
|
String deviceStatus = RedisUtils.getCacheObject(GLOBAL_REDIS_KEY + DEVICE_KEY_PREFIX + device.getDeviceImei() + DeviceRedisKeyConstants.DEVICE_STATUS_KEY_PREFIX);
|
||||||
|
// 获取电量
|
||||||
|
if (StringUtils.isNotBlank(deviceStatus)) {
|
||||||
|
JSONObject jsonObject = JSONObject.parseObject(deviceStatus);
|
||||||
|
vo.setBatteryPercentage(jsonObject.getString("batteryPercentage"));
|
||||||
|
vo.setChargeState(jsonObject.getString("chargeState"));
|
||||||
|
} else {
|
||||||
|
vo.setBatteryPercentage("0");
|
||||||
|
}
|
||||||
|
|
||||||
|
String lightModeStatus = RedisUtils.getCacheObject(GLOBAL_REDIS_KEY + DEVICE_KEY_PREFIX + device.getDeviceImei() + DeviceRedisKeyConstants.DEVICE_LIGHT_MODE_KEY_PREFIX);
|
||||||
|
|
||||||
|
|
||||||
|
String lightBrightnessStatus = RedisUtils.getCacheObject(GLOBAL_REDIS_KEY + DEVICE_KEY_PREFIX + device.getDeviceImei() + DeviceRedisKeyConstants.DEVICE_LIGHT_BRIGHTNESS_KEY_PREFIX);
|
||||||
|
if (StringUtils.isNotBlank(lightBrightnessStatus)) {
|
||||||
|
vo.setLightBrightness(lightBrightnessStatus);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取经度纬度
|
||||||
|
String locationKey = GlobalConstants.GLOBAL_REDIS_KEY + DEVICE_KEY_PREFIX + device.getDeviceImei() + DeviceRedisKeyConstants.DEVICE_LOCATION_KEY_PREFIX;
|
||||||
|
String locationInfo = RedisUtils.getCacheObject(locationKey);
|
||||||
|
if (StringUtils.isNotBlank(locationInfo)) {
|
||||||
|
JSONObject jsonObject = JSONObject.parseObject(locationInfo);
|
||||||
|
vo.setLongitude(jsonObject.get("longitude").toString());
|
||||||
|
vo.setLatitude(jsonObject.get("latitude").toString());
|
||||||
|
vo.setAddress((String) jsonObject.get("address"));
|
||||||
|
}
|
||||||
|
|
||||||
|
String alarmStatus = RedisUtils.getCacheObject(GLOBAL_REDIS_KEY + DEVICE_KEY_PREFIX + device.getDeviceImei() + DEVICE_ALARM_KEY_PREFIX);
|
||||||
|
if (StringUtils.isNotBlank(alarmStatus)) {
|
||||||
|
vo.setAlarmStatus(alarmStatus);
|
||||||
|
}
|
||||||
|
|
||||||
|
String lightBrightness = RedisUtils.getCacheObject(GLOBAL_REDIS_KEY + DEVICE_KEY_PREFIX + device.getDeviceImei() + DEVICE_LIGHT_BRIGHTNESS_KEY_PREFIX);
|
||||||
|
if (StringUtils.isNotBlank(lightBrightness)) {
|
||||||
|
vo.setLightBrightness(lightBrightness);
|
||||||
|
}
|
||||||
|
|
||||||
|
return vo;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private boolean getDeviceStatus(String deviceImei) {
|
||||||
|
String deviceOnlineStatusRedisKey = GlobalConstants.GLOBAL_REDIS_KEY + DEVICE_KEY_PREFIX + deviceImei + DeviceRedisKeyConstants.DEVICE_ONLINE_STATUS_KEY_PREFIX;
|
||||||
|
return RedisUtils.getCacheObject(deviceOnlineStatusRedisKey) == null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void forceAlarmActivation(AppDeviceSendMsgBo bo) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateVoice(Long id) {
|
||||||
|
AppBusinessFileVo appBusinessFileVo = appBusinessFileMapper.selectVoById(id);
|
||||||
|
if(appBusinessFileVo == null){
|
||||||
|
throw new ServiceException("文件不存在");
|
||||||
|
}
|
||||||
|
|
||||||
|
UpdateWrapper<AppBusinessFile> updateWrapper = new UpdateWrapper<>();
|
||||||
|
updateWrapper.eq("business_id", appBusinessFileVo.getBusinessId());
|
||||||
|
updateWrapper.set("use_status", 0);
|
||||||
|
appBusinessFileMapper.update(updateWrapper);
|
||||||
|
|
||||||
|
AppBusinessFileBo bo = new AppBusinessFileBo();
|
||||||
|
bo.setId(id);
|
||||||
|
bo.setUseStatus(1);
|
||||||
|
appBusinessFileService.updateByBo(bo);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -51,4 +51,9 @@ public class AppBusinessFile extends TenantEntity {
|
|||||||
* 文件时长
|
* 文件时长
|
||||||
*/
|
*/
|
||||||
private Integer duration;
|
private Integer duration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 重命名
|
||||||
|
*/
|
||||||
|
private String reName;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -51,4 +51,9 @@ public class AppBusinessFileBo extends BaseEntity {
|
|||||||
private List<Long> ids;
|
private List<Long> ids;
|
||||||
|
|
||||||
private Integer duration;
|
private Integer duration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否使用语音播报(0-否,1-是)
|
||||||
|
*/
|
||||||
|
private Integer useStatus;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,101 @@
|
|||||||
|
package com.fuyuanshen.app.domain.vo;
|
||||||
|
|
||||||
|
import cn.idev.excel.annotation.ExcelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class AppDeviceHBY100JDetailVo implements Serializable {
|
||||||
|
@Serial
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备ID
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "设备ID")
|
||||||
|
private Long deviceId;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备名称
|
||||||
|
*/
|
||||||
|
private String deviceName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备IMEI
|
||||||
|
*/
|
||||||
|
private String deviceImei;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备MAC
|
||||||
|
*/
|
||||||
|
private String deviceMac;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通讯方式 0:4G;1:蓝牙,2 4G&蓝牙
|
||||||
|
*/
|
||||||
|
private Integer communicationMode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备图片
|
||||||
|
*/
|
||||||
|
private String devicePic;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备类型
|
||||||
|
*/
|
||||||
|
private String typeName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 蓝牙名称
|
||||||
|
*/
|
||||||
|
private String bluetoothName;
|
||||||
|
|
||||||
|
//电量百分比
|
||||||
|
private String batteryPercentage;
|
||||||
|
|
||||||
|
//充电状态(0没有充电,1正在充电,2为已充满)
|
||||||
|
private String chargeState;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 在线状态(0离线,1在线)
|
||||||
|
*/
|
||||||
|
private Integer onlineStatus;
|
||||||
|
|
||||||
|
// 经度
|
||||||
|
private String longitude;
|
||||||
|
|
||||||
|
// 纬度
|
||||||
|
private String latitude;
|
||||||
|
|
||||||
|
// 逆解析地址
|
||||||
|
private String address;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 告警状态(0解除告警,1告警)
|
||||||
|
*/
|
||||||
|
private String alarmStatus;
|
||||||
|
|
||||||
|
// 亮度
|
||||||
|
private String lightBrightness;
|
||||||
|
|
||||||
|
// "voice_resource": 音频资源链接
|
||||||
|
private String voiceResource;
|
||||||
|
|
||||||
|
// 报警模式 0公安,1 消防,2应急,3交警,4 市政,5 铁路,6 医疗,7 部队,8 水利
|
||||||
|
private String alarmMode;
|
||||||
|
|
||||||
|
// 强制报警开关: 0 关闭, 1开启
|
||||||
|
private String voiceStrobeAlarm;
|
||||||
|
|
||||||
|
// 警示灯LED亮度调节 红色
|
||||||
|
private String red;
|
||||||
|
|
||||||
|
// 警示灯LED亮度调节 蓝色
|
||||||
|
private String blue;
|
||||||
|
|
||||||
|
// 警示灯LED亮度调节 黄色
|
||||||
|
private String yellow;
|
||||||
|
}
|
||||||
@ -29,4 +29,9 @@ public class AppFileVo {
|
|||||||
private String fileUrl;
|
private String fileUrl;
|
||||||
|
|
||||||
private Integer duration;
|
private Integer duration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 扩展文件名称
|
||||||
|
*/
|
||||||
|
private String fileNameExt;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,7 +5,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<mapper namespace="com.fuyuanshen.app.mapper.AppBusinessFileMapper">
|
<mapper namespace="com.fuyuanshen.app.mapper.AppBusinessFileMapper">
|
||||||
|
|
||||||
<select id="queryAppFileList" resultType="com.fuyuanshen.app.domain.vo.AppFileVo">
|
<select id="queryAppFileList" resultType="com.fuyuanshen.app.domain.vo.AppFileVo">
|
||||||
select a.id,a.business_id,a.file_id,a.file_type,b.file_name,b.url fileUrl,a.duration from app_business_file a left join sys_oss b on a.file_id = b.oss_id
|
select a.id,a.business_id,a.file_id,a.file_type,b.file_name,b.url fileUrl,a.duration,
|
||||||
|
CASE
|
||||||
|
WHEN a.re_name IS NULL THEN
|
||||||
|
SUBSTRING_INDEX(COALESCE(a.re_name, b.original_name), '.', 1)
|
||||||
|
ELSE
|
||||||
|
a.re_name
|
||||||
|
END AS fileNameExt
|
||||||
|
from app_business_file a left join sys_oss b on a.file_id = b.oss_id
|
||||||
where 1=1
|
where 1=1
|
||||||
<if test="businessId != null">
|
<if test="businessId != null">
|
||||||
and a.business_id = #{businessId}
|
and a.business_id = #{businessId}
|
||||||
|
|||||||
@ -0,0 +1,16 @@
|
|||||||
|
package com.fuyuanshen.equipment.domain.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 绑定设备参数
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class Hby100jForceAlarmBo {
|
||||||
|
|
||||||
|
private Long deviceId;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user