10 Commits

Author SHA1 Message Date
7fcbb81317 snailjob配置 2026-04-27 13:17:02 +08:00
05cb75e652 修复bug3 2026-04-01 17:52:11 +08:00
5813425be9 修复bug2 2026-04-01 17:42:14 +08:00
539caa4b5f 修复bug 2026-03-27 10:34:38 +08:00
1111e03bf4 修复bug2 2026-03-20 16:37:32 +08:00
83752b2f11 修复bug 2026-03-19 13:25:11 +08:00
f37cb405cc 提交代码9 2026-03-19 09:49:08 +08:00
cc2713618a 提交代码8 2026-03-18 15:29:42 +08:00
47d40cf9d2 提交代码7 2026-03-06 17:58:39 +08:00
83b97841ef 提交代码6 2026-03-05 17:49:55 +08:00
28 changed files with 506 additions and 273 deletions

View File

@ -8,6 +8,7 @@ import com.fuyuanshen.app.domain.dto.TextToSpeechRequest;
import com.fuyuanshen.app.service.AudioProcessService; import com.fuyuanshen.app.service.AudioProcessService;
import com.fuyuanshen.app.service.VideoProcessService; import com.fuyuanshen.app.service.VideoProcessService;
import com.fuyuanshen.common.core.domain.R; import com.fuyuanshen.common.core.domain.R;
import com.fuyuanshen.common.core.utils.StringUtils;
import com.fuyuanshen.common.idempotent.annotation.RepeatSubmit; import com.fuyuanshen.common.idempotent.annotation.RepeatSubmit;
import com.fuyuanshen.common.web.core.BaseController; import com.fuyuanshen.common.web.core.BaseController;
import com.fuyuanshen.equipment.domain.vo.AppFileVo; import com.fuyuanshen.equipment.domain.vo.AppFileVo;
@ -80,6 +81,7 @@ public class AppVideoController extends BaseController {
@PostMapping("/uploadAudioToOss") @PostMapping("/uploadAudioToOss")
public R<String> uploadAudioToOss(@ModelAttribute AppAudioFileDto bo) { public R<String> uploadAudioToOss(@ModelAttribute AppAudioFileDto bo) {
try { try {
bo.setSource("app");
String result = audioProcessService.uploadAudioToOss(bo); String result = audioProcessService.uploadAudioToOss(bo);
return R.ok(result); return R.ok(result);
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
@ -100,11 +102,15 @@ public class AppVideoController extends BaseController {
if (request.getDeviceId() == null) { if (request.getDeviceId() == null) {
return R.fail("设备ID不能为空"); return R.fail("设备ID不能为空");
} }
if (StringUtils.isBlank(request.getText())) {
return R.fail("文本不能为空");
}
String result = audioProcessService.textToSpeech( String result = audioProcessService.textToSpeech(
request.getDeviceId(), request.getDeviceId(),
request.getText(), request.getText(),
request.getFileSuffix() request.getFileSuffix(),
"app"
); );
return R.ok(result); return R.ok(result);
} catch (Exception e) { } catch (Exception e) {
@ -118,15 +124,15 @@ public class AppVideoController extends BaseController {
*/ */
@GetMapping("/queryAudioFileList") @GetMapping("/queryAudioFileList")
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,"app"));
} }
/** /**
* 删除语音文件 * 删除语音文件
*/ */
@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);
} }
/** /**

View File

@ -14,4 +14,8 @@ public class AppAudioFileDto {
private MultipartFile file; private MultipartFile file;
/**
* 数据来源 1:app 2:web 3:其他
*/
private String source;
} }

View File

@ -6,6 +6,8 @@ import org.springframework.web.multipart.MultipartFile;
@Data @Data
public class AppFileRenameDto { public class AppFileRenameDto {
private Long id;
/** /**
* 文件id * 文件id
*/ */

View File

@ -1,8 +1,10 @@
package com.fuyuanshen.app.service; package com.fuyuanshen.app.service;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.fuyuanshen.app.domain.bo.AppDeviceBindRecordBo;
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.dto.AppFileRenameDto;
import com.fuyuanshen.app.domain.vo.AppDeviceBindRecordVo;
import com.fuyuanshen.app.http.HttpTtsClient; import com.fuyuanshen.app.http.HttpTtsClient;
import com.fuyuanshen.common.core.domain.R; import com.fuyuanshen.common.core.domain.R;
import com.fuyuanshen.common.satoken.utils.AppLoginHelper; import com.fuyuanshen.common.satoken.utils.AppLoginHelper;
@ -65,6 +67,7 @@ public class AudioProcessService {
private final ISysOssService ossService; private final ISysOssService ossService;
private final IAppBusinessFileService appBusinessFileService; private final IAppBusinessFileService appBusinessFileService;
private final AppBusinessFileMapper appBusinessFileMapper; private final AppBusinessFileMapper appBusinessFileMapper;
private final IAppDeviceBindRecordService appDeviceBindRecordService;
// String accessKeyId = "LTAI5t66moCkhNC32TDJ5ReP"; // String accessKeyId = "LTAI5t66moCkhNC32TDJ5ReP";
// String accessKeySecret = "2F3sdoBJ08bYvJcuDgSkLnJwGXsvYH"; // String accessKeySecret = "2F3sdoBJ08bYvJcuDgSkLnJwGXsvYH";
@ -385,7 +388,8 @@ public class AudioProcessService {
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()); Long userId = getUserId(bo.getSource(), bo.getDeviceId());
appBusinessFileBo.setCreateBy(userId);
savedPath = saveByteArrayToFile(file.getInputStream(), generateRandomFileName(fileSuffix)); savedPath = saveByteArrayToFile(file.getInputStream(), generateRandomFileName(fileSuffix));
if (savedPath != null) { if (savedPath != null) {
log.info("MP3文件已保存: {}", savedPath); log.info("MP3文件已保存: {}", savedPath);
@ -409,6 +413,20 @@ public class AudioProcessService {
return null; return null;
} }
private Long getUserId(String source,Long deviceId){
if("app".equals( source)){
return AppLoginHelper.getUserId();
} else if ("web".equals( source)){
// AppDeviceBindRecordBo appDeviceBindRecordBo = new AppDeviceBindRecordBo();
// appDeviceBindRecordBo.setDeviceId(deviceId);
//// appDeviceBindRecordBo.setCommunicationMode(0);
// List<AppDeviceBindRecordVo> appDeviceBindRecordVos = appDeviceBindRecordService.queryList(appDeviceBindRecordBo);
// if (appDeviceBindRecordVos != null && !appDeviceBindRecordVos.isEmpty()){
// userId = appDeviceBindRecordVos.get(0).getBindingUserId();
// }
}
return 0L;
}
/** /**
* 校验音频文件格式 * 校验音频文件格式
*/ */
@ -431,9 +449,10 @@ 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("音频大小不能超过256kb");
} }
} }
@ -448,7 +467,7 @@ public class AudioProcessService {
return SUPPORTED_FORMATS.contains(ext); return SUPPORTED_FORMATS.contains(ext);
} }
public String textToSpeech(Long deviceId,String text, String fileSuffix) { public String textToSpeech(Long deviceId,String text, String fileSuffix,String source) {
//支持PCM/WAV/MP3格式 //支持PCM/WAV/MP3格式
if (fileSuffix == null || fileSuffix.isEmpty()) { if (fileSuffix == null || fileSuffix.isEmpty()) {
fileSuffix = "mp3"; fileSuffix = "mp3";
@ -485,7 +504,7 @@ public class AudioProcessService {
String fileName = generateRandomFileName(fileSuffix); String fileName = generateRandomFileName(fileSuffix);
savedMp3VolumePath = directory + "/" + fileName; savedMp3VolumePath = directory + "/" + fileName;
log.info("保存MP3文件: {}", savedMp3VolumePath); log.info("保存MP3文件: {}", savedMp3VolumePath);
FfmpegVolumeUtil.increaseMp3Volume(savedPath, savedMp3VolumePath, 12); FfmpegVolumeUtil.increaseMp3Volume(savedPath, savedMp3VolumePath, 8);
File file = new File(savedMp3VolumePath); File file = new File(savedMp3VolumePath);
String fileHash = fileHashUtil.getFileHash(file,"SHA-256"); String fileHash = fileHashUtil.getFileHash(file,"SHA-256");
@ -499,7 +518,8 @@ public class AudioProcessService {
appBusinessFileBo.setFileId(upload.getOssId()); appBusinessFileBo.setFileId(upload.getOssId());
appBusinessFileBo.setBusinessId(deviceId); appBusinessFileBo.setBusinessId(deviceId);
appBusinessFileBo.setFileType(3L); appBusinessFileBo.setFileType(3L);
appBusinessFileBo.setCreateBy(AppLoginHelper.getUserId()); Long userId = getUserId(source, deviceId);
appBusinessFileBo.setCreateBy(userId);
appBusinessFileService.insertByBo(appBusinessFileBo); appBusinessFileService.insertByBo(appBusinessFileBo);
if (upload != null) { if (upload != null) {
return upload.getUrl(); return upload.getUrl();
@ -544,33 +564,36 @@ public class AudioProcessService {
extension = "." + extension; extension = "." + extension;
} }
return timestamp + "_" + String.format("%04d", randomNum) + "_" + uuidPart + extension; return timestamp+extension;
} }
public List<AppFileVo> queryAudioFileList(Long deviceId) { public List<AppFileVo> queryAudioFileList(Long deviceId,String source) {
if(deviceId == null){ if(deviceId == null){
return null; return null;
} }
Long userId = LoginHelper.getUserId();
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();

View File

@ -109,6 +109,15 @@ public class RegisEquipReceiverMessageHandler implements MessageHandler {
Device device = deviceMapper.selectDeviceByImei(imei); Device device = deviceMapper.selectDeviceByImei(imei);
if (device != null) { if (device != null) {
log.warn("Device already exists for IMEI: {}", imei); log.warn("Device already exists for IMEI: {}", imei);
String redisKey = GlobalConstants.GLOBAL_REDIS_KEY + DEVICE_KEY_PREFIX +
imei + ":regis";
Object value = RedisUtils.getCacheObject(redisKey);
if (value != null) {
log.warn("regis/imei发送次数频率过快: {}", imei);
return;
}
// sendSuccessMessage(imei);
RedisUtils.setCacheObject(redisKey, payload.toString(), Duration.ofSeconds(10));
return; return;
} }
@ -130,13 +139,17 @@ public class RegisEquipReceiverMessageHandler implements MessageHandler {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
sendSuccessMessage(imei);
}
private void sendSuccessMessage(String imei) {
// 解析原始JSON数据 // 解析原始JSON数据
JSONObject originalData = new JSONObject(); JSONObject originalData = new JSONObject();
originalData.put("code", 200); originalData.put("code", 200);
// 发送到MQTT // 发送到MQTT
String topic = "regis/" + imei; String topic = "regis/" + imei;
mqttGateway.sendMsgToMqtt(topic, originalData.toString()); mqttGateway.sendMsgToMqtt(topic, originalData.toString());
} }

View File

@ -38,18 +38,18 @@ public class BjqActiveReportingDeviceDataRule implements MqttMessageRule {
@Override @Override
public void execute(MqttRuleContext context) { public void execute(MqttRuleContext context) {
try { try {
// Object[] convertArr = context.getConvertArr(); Object[] convertArr = context.getConvertArr();
// // Latitude, longitude // Latitude, longitude
// //主灯档位,激光灯档位,电量百分比,充电状态,电池剩余续航时间 //主灯档位,激光灯档位,电量百分比,充电状态,电池剩余续航时间
// String mainLightMode = convertArr[1].toString(); String mainLightMode = convertArr[1].toString();
// String laserLightMode = convertArr[2].toString(); String laserLightMode = convertArr[2].toString();
// String batteryPercentage = convertArr[3].toString(); String batteryPercentage = convertArr[3].toString();
// String chargeState = convertArr[4].toString(); String chargeState = convertArr[4].toString();
// String batteryRemainingTime = convertArr[5].toString(); String batteryRemainingTime = convertArr[5].toString();
//
// // 发送设备状态和位置信息到Redis // 发送设备状态和位置信息到Redis
// asyncSendDeviceDataToRedisWithFuture(context.getDeviceImei(), mainLightMode, laserLightMode, asyncSendDeviceDataToRedisWithFuture(context.getDeviceImei(), mainLightMode, laserLightMode,
// batteryPercentage, chargeState, batteryRemainingTime); batteryPercentage, chargeState, batteryRemainingTime);
} catch (Exception e) { } catch (Exception e) {
log.error("处理上报数据命令时出错", e); log.error("处理上报数据命令时出错", e);
} }

View File

@ -44,37 +44,37 @@ public class BjqBootLogoRule implements MqttMessageRule {
public void execute(MqttRuleContext context) { public void execute(MqttRuleContext context) {
String functionAccess = FUNCTION_ACCESS_KEY + context.getDeviceImei(); String functionAccess = FUNCTION_ACCESS_KEY + context.getDeviceImei();
try { try {
// Byte val2 = (Byte) context.getConvertArr()[1]; Byte val2 = (Byte) context.getConvertArr()[1];
// if (val2 == 100) { if (val2 == 100) {
// RedisUtils.setCacheObject(functionAccess, FunctionAccessStatus.OK.getCode(), Duration.ofSeconds(20)); RedisUtils.setCacheObject(functionAccess, FunctionAccessStatus.OK.getCode(), Duration.ofSeconds(20));
// return; return;
// } }
//
// String data = RedisUtils.getCacheObject(GLOBAL_REDIS_KEY+ DEVICE_KEY_PREFIX + context.getDeviceImei() +DEVICE_BOOT_LOGO_KEY_PREFIX); String data = RedisUtils.getCacheObject(GLOBAL_REDIS_KEY+ DEVICE_KEY_PREFIX + context.getDeviceImei() +DEVICE_BOOT_LOGO_KEY_PREFIX);
// if (StringUtils.isEmpty(data)) { if (StringUtils.isEmpty(data)) {
// return; return;
// } }
//
// byte[] arr = ImageToCArrayConverter.convertStringToByteArray(data); byte[] arr = ImageToCArrayConverter.convertStringToByteArray(data);
// byte[] specificChunk = ImageToCArrayConverter.getChunk(arr, (val2 - 1), 512); byte[] specificChunk = ImageToCArrayConverter.getChunk(arr, (val2 - 1), 512);
// log.info("第{}块数据大小: {} 字节", val2, specificChunk.length); log.info("第{}块数据大小: {} 字节", val2, specificChunk.length);
//
// ArrayList<Integer> intData = new ArrayList<>(); ArrayList<Integer> intData = new ArrayList<>();
// intData.add(3); intData.add(3);
// intData.add((int) val2); intData.add((int) val2);
// ImageToCArrayConverter.buildArr(convertHexToDecimal(specificChunk), intData); ImageToCArrayConverter.buildArr(convertHexToDecimal(specificChunk), intData);
// intData.add(0); intData.add(0);
// intData.add(0); intData.add(0);
// intData.add(0); intData.add(0);
// intData.add(0); intData.add(0);
//
// Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
// map.put("instruct", intData); map.put("instruct", intData);
//
// mqttGateway.sendMsgToMqtt(MqttConstants.GLOBAL_PUB_KEY + context.getDeviceImei(), 1, JsonUtils.toJsonString(map)); mqttGateway.sendMsgToMqtt(MqttConstants.GLOBAL_PUB_KEY + context.getDeviceImei(), 1, JsonUtils.toJsonString(map));
// log.info("发送开机LOGO点阵数据到设备消息=>topic:{},payload:{}", log.info("发送开机LOGO点阵数据到设备消息=>topic:{},payload:{}",
// MqttConstants.GLOBAL_PUB_KEY + context.getDeviceImei(), MqttConstants.GLOBAL_PUB_KEY + context.getDeviceImei(),
// JsonUtils.toJsonString(map)); JsonUtils.toJsonString(map));
} catch (Exception e) { } catch (Exception e) {
log.error("处理开机LOGO时出错", e); log.error("处理开机LOGO时出错", e);

View File

@ -34,15 +34,15 @@ public class BjqLaserModeSettingsRule implements MqttMessageRule {
public void execute(MqttRuleContext context) { public void execute(MqttRuleContext context) {
String functionAccess = FUNCTION_ACCESS_KEY + context.getDeviceImei(); String functionAccess = FUNCTION_ACCESS_KEY + context.getDeviceImei();
try { try {
// Object[] convertArr = context.getConvertArr(); Object[] convertArr = context.getConvertArr();
//
// String mode = convertArr[1].toString(); String mode = convertArr[1].toString();
// if(StringUtils.isNotBlank(mode)){ if(StringUtils.isNotBlank(mode)){
// // 发送设备状态和位置信息到Redis // 发送设备状态和位置信息到Redis
// syncSendDeviceDataToRedisWithFuture(context.getDeviceImei(),mode); syncSendDeviceDataToRedisWithFuture(context.getDeviceImei(),mode);
// } }
//
// RedisUtils.setCacheObject(functionAccess, FunctionAccessStatus.OK.getCode(), Duration.ofSeconds(30)); RedisUtils.setCacheObject(functionAccess, FunctionAccessStatus.OK.getCode(), Duration.ofSeconds(30));
} catch (Exception e) { } catch (Exception e) {
log.error("处理激光模式命令时出错", e); log.error("处理激光模式命令时出错", e);
RedisUtils.setCacheObject(functionAccess, FunctionAccessStatus.FAILED.getCode(), Duration.ofSeconds(30)); RedisUtils.setCacheObject(functionAccess, FunctionAccessStatus.FAILED.getCode(), Duration.ofSeconds(30));

View File

@ -34,15 +34,15 @@ public class BjqLightBrightnessRule implements MqttMessageRule {
public void execute(MqttRuleContext context) { public void execute(MqttRuleContext context) {
String functionAccess = FUNCTION_ACCESS_KEY + context.getDeviceImei(); String functionAccess = FUNCTION_ACCESS_KEY + context.getDeviceImei();
try { try {
// Object[] convertArr = context.getConvertArr(); Object[] convertArr = context.getConvertArr();
//
// String convertValue = convertArr[1].toString(); String convertValue = convertArr[1].toString();
// // 将设备状态信息存储到Redis中 // 将设备状态信息存储到Redis中
// String deviceRedisKey = GlobalConstants.GLOBAL_REDIS_KEY+DeviceRedisKeyConstants.DEVICE_KEY_PREFIX + context.getDeviceImei() + DEVICE_LIGHT_BRIGHTNESS_KEY_PREFIX; String deviceRedisKey = GlobalConstants.GLOBAL_REDIS_KEY+DeviceRedisKeyConstants.DEVICE_KEY_PREFIX + context.getDeviceImei() + DEVICE_LIGHT_BRIGHTNESS_KEY_PREFIX;
//
// // 存储到Redis // 存储到Redis
// RedisUtils.setCacheObject(deviceRedisKey, convertValue); RedisUtils.setCacheObject(deviceRedisKey, convertValue);
// RedisUtils.setCacheObject(functionAccess, FunctionAccessStatus.OK.getCode(), Duration.ofSeconds(20)); RedisUtils.setCacheObject(functionAccess, FunctionAccessStatus.OK.getCode(), Duration.ofSeconds(20));
} catch (Exception e) { } catch (Exception e) {
log.error("处理灯光亮度命令时出错", e); log.error("处理灯光亮度命令时出错", e);
RedisUtils.setCacheObject(functionAccess, FunctionAccessStatus.FAILED.getCode(), Duration.ofSeconds(20)); RedisUtils.setCacheObject(functionAccess, FunctionAccessStatus.FAILED.getCode(), Duration.ofSeconds(20));

View File

@ -52,26 +52,26 @@ public class BjqLocationDataRule implements MqttMessageRule {
public void execute(MqttRuleContext context) { public void execute(MqttRuleContext context) {
String functionAccess = FUNCTION_ACCESS_KEY + context.getDeviceImei(); String functionAccess = FUNCTION_ACCESS_KEY + context.getDeviceImei();
try { try {
// Object[] convertArr = context.getConvertArr(); Object[] convertArr = context.getConvertArr();
// // Latitude, longitude // Latitude, longitude
// String latitude = convertArr[1].toString(); String latitude = convertArr[1].toString();
// String longitude = convertArr[2].toString(); String longitude = convertArr[2].toString();
// // 判断 latitude 和 longitude 是否都为 0 // 判断 latitude 和 longitude 是否都为 0
// if ("0".equals(latitude) && "0".equals(longitude)) { if ("0".equals(latitude) && "0".equals(longitude)) {
// log.info("位置信息为0不存储到Redis: device={}, lat={}, lon={}", context.getDeviceImei(), latitude, longitude); log.info("位置信息为0不存储到Redis: device={}, lat={}, lon={}", context.getDeviceImei(), latitude, longitude);
// return; return;
// } }
// // 异步发送经纬度到Redis // 异步发送经纬度到Redis
// asyncSendLocationToRedisWithFuture(context.getDeviceImei(), latitude, longitude); asyncSendLocationToRedisWithFuture(context.getDeviceImei(), latitude, longitude);
// // 异步保存数据 // 异步保存数据
// asyncSaveLocationToMySQLWithFuture(context.getDeviceImei(), latitude, longitude); asyncSaveLocationToMySQLWithFuture(context.getDeviceImei(), latitude, longitude);
//
// Map<String, Object> map = buildLocationDataMap(latitude, longitude); Map<String, Object> map = buildLocationDataMap(latitude, longitude);
// mqttGateway.sendMsgToMqtt(MqttConstants.GLOBAL_PUB_KEY + context.getDeviceImei(), 1, JsonUtils.toJsonString(map)); mqttGateway.sendMsgToMqtt(MqttConstants.GLOBAL_PUB_KEY + context.getDeviceImei(), 1, JsonUtils.toJsonString(map));
// log.info("发送定位数据到设备=>topic:{},payload:{}", log.info("发送定位数据到设备=>topic:{},payload:{}",
// MqttConstants.GLOBAL_PUB_KEY + context.getDeviceImei(), MqttConstants.GLOBAL_PUB_KEY + context.getDeviceImei(),
// JsonUtils.toJsonString(map)); JsonUtils.toJsonString(map));
// RedisUtils.setCacheObject(functionAccess, FunctionAccessStatus.OK.getCode(), Duration.ofSeconds(20)); RedisUtils.setCacheObject(functionAccess, FunctionAccessStatus.OK.getCode(), Duration.ofSeconds(20));
} catch (Exception e) { } catch (Exception e) {
log.error("处理定位数据命令时出错", e); log.error("处理定位数据命令时出错", e);
RedisUtils.setCacheObject(functionAccess, FunctionAccessStatus.FAILED.getCode(), Duration.ofSeconds(20)); RedisUtils.setCacheObject(functionAccess, FunctionAccessStatus.FAILED.getCode(), Duration.ofSeconds(20));

View File

@ -52,45 +52,45 @@ public class BjqModeRule implements MqttMessageRule {
try { try {
log.info("处理灯光模式命令"); log.info("处理灯光模式命令");
log.info("MQTT消息负载字典{}", context.getPayloadDict()); log.info("MQTT消息负载字典{}", context.getPayloadDict());
// Object[] convertArr = context.getConvertArr(); Object[] convertArr = context.getConvertArr();
//
// String mainLightMode = convertArr[1].toString(); String mainLightMode = convertArr[1].toString();
// String batteryRemainingTime = convertArr[2].toString(); String batteryRemainingTime = convertArr[2].toString();
// if (StringUtils.isNotBlank(mainLightMode)) { if (StringUtils.isNotBlank(mainLightMode)) {
// log.info("设备离线mainLightMode{}", mainLightMode); log.info("设备离线mainLightMode{}", mainLightMode);
// if ("0".equals(mainLightMode)) { if ("0".equals(mainLightMode)) {
//
// // 设备离线 // 设备离线
// String deviceOnlineStatusRedisKey = GlobalConstants.GLOBAL_REDIS_KEY + DEVICE_KEY_PREFIX + context.getDeviceImei() + DeviceRedisKeyConstants.DEVICE_ONLINE_STATUS_KEY_PREFIX; String deviceOnlineStatusRedisKey = GlobalConstants.GLOBAL_REDIS_KEY + DEVICE_KEY_PREFIX + context.getDeviceImei() + DeviceRedisKeyConstants.DEVICE_ONLINE_STATUS_KEY_PREFIX;
// RedisUtils.setCacheObject(deviceOnlineStatusRedisKey, "0"); RedisUtils.setCacheObject(deviceOnlineStatusRedisKey, "0");
//
// String sendMessageIng = GLOBAL_REDIS_KEY + DEVICE_KEY_PREFIX + context.getDeviceImei() + ":messageSending"; String sendMessageIng = GLOBAL_REDIS_KEY + DEVICE_KEY_PREFIX + context.getDeviceImei() + ":messageSending";
// String messageSendingValue = RedisUtils.getCacheObject(sendMessageIng); String messageSendingValue = RedisUtils.getCacheObject(sendMessageIng);
// if ("1".equals(messageSendingValue)) { if ("1".equals(messageSendingValue)) {
// // 设置为故障状态 // 设置为故障状态
// RedisUtils.setCacheObject(deviceOnlineStatusRedisKey, "2"); RedisUtils.setCacheObject(deviceOnlineStatusRedisKey, "2");
// UpdateWrapper<Device> updateWrapper = new UpdateWrapper<>(); UpdateWrapper<Device> updateWrapper = new UpdateWrapper<>();
// updateWrapper.eq("device_imei", context.getDeviceImei()); updateWrapper.eq("device_imei", context.getDeviceImei());
// updateWrapper.set("online_status", 2); updateWrapper.set("online_status", 2);
// deviceService.update(updateWrapper); deviceService.update(updateWrapper);
// RedisUtils.deleteObject(sendMessageIng); RedisUtils.deleteObject(sendMessageIng);
//
// // 解除告警 // 解除告警
// String deviceRedisKey = GlobalConstants.GLOBAL_REDIS_KEY + DeviceRedisKeyConstants.DEVICE_KEY_PREFIX + context.getDeviceImei() + DEVICE_ALARM_KEY_PREFIX; String deviceRedisKey = GlobalConstants.GLOBAL_REDIS_KEY + DeviceRedisKeyConstants.DEVICE_KEY_PREFIX + context.getDeviceImei() + DEVICE_ALARM_KEY_PREFIX;
// if (RedisUtils.getCacheObject(deviceRedisKey) != null) { if (RedisUtils.getCacheObject(deviceRedisKey) != null) {
// RedisUtils.deleteObject(deviceRedisKey); RedisUtils.deleteObject(deviceRedisKey);
// } }
// cancelAlarm(context.getDeviceImei()); cancelAlarm(context.getDeviceImei());
// } }
// } }
// // 发送设备状态和位置信息到Redis // 发送设备状态和位置信息到Redis
// syncSendDeviceDataToRedisWithFuture(context.getDeviceImei(), mainLightMode); syncSendDeviceDataToRedisWithFuture(context.getDeviceImei(), mainLightMode);
// String deviceRedisKey = GlobalConstants.GLOBAL_REDIS_KEY + DeviceRedisKeyConstants.DEVICE_KEY_PREFIX + context.getDeviceImei() + DEVICE_LIGHT_BRIGHTNESS_KEY_PREFIX; String deviceRedisKey = GlobalConstants.GLOBAL_REDIS_KEY + DeviceRedisKeyConstants.DEVICE_KEY_PREFIX + context.getDeviceImei() + DEVICE_LIGHT_BRIGHTNESS_KEY_PREFIX;
//
// // 存储到Redis // 存储到Redis
// RedisUtils.setCacheObject(deviceRedisKey, batteryRemainingTime); RedisUtils.setCacheObject(deviceRedisKey, batteryRemainingTime);
// } }
// RedisUtils.setCacheObject(functionAccess, FunctionAccessStatus.OK.getCode(), Duration.ofSeconds(20)); RedisUtils.setCacheObject(functionAccess, FunctionAccessStatus.OK.getCode(), Duration.ofSeconds(20));
} catch (Exception e) { } catch (Exception e) {
log.error("处理灯光模式命令时出错", e); log.error("处理灯光模式命令时出错", e);
RedisUtils.setCacheObject(functionAccess, FunctionAccessStatus.FAILED.getCode(), Duration.ofSeconds(20)); RedisUtils.setCacheObject(functionAccess, FunctionAccessStatus.FAILED.getCode(), Duration.ofSeconds(20));

View File

@ -45,47 +45,47 @@ public class BjqSendMessageRule implements MqttMessageRule {
try { try {
// Byte val2 = (Byte) context.getConvertArr()[1]; // Byte val2 = (Byte) context.getConvertArr()[1];
// String val2Str = context.getConvertArr()[1].toString(); String val2Str = context.getConvertArr()[1].toString();
// int val2 = Integer.parseInt(val2Str); int val2 = Integer.parseInt(val2Str);
// System.out.println("收到设备信息命令:"+val2); System.out.println("收到设备信息命令:"+val2);
// if (val2 == 100) { if (val2 == 100) {
// RedisUtils.setCacheObject(functionAccess, FunctionAccessStatus.OK.getCode(), Duration.ofSeconds(20)); RedisUtils.setCacheObject(functionAccess, FunctionAccessStatus.OK.getCode(), Duration.ofSeconds(20));
// return; return;
// } }
//
// if(val2==200){ if(val2==200){
// String sendMessageIng = GLOBAL_REDIS_KEY+ DEVICE_KEY_PREFIX + context.getDeviceImei() + ":messageSending"; String sendMessageIng = GLOBAL_REDIS_KEY+ DEVICE_KEY_PREFIX + context.getDeviceImei() + ":messageSending";
// RedisUtils.deleteObject(sendMessageIng); RedisUtils.deleteObject(sendMessageIng);
// return; return;
// } }
//
//
// String data = RedisUtils.getCacheObject(GLOBAL_REDIS_KEY+ DEVICE_KEY_PREFIX + context.getDeviceImei() + ":app_send_message_data"); String data = RedisUtils.getCacheObject(GLOBAL_REDIS_KEY+ DEVICE_KEY_PREFIX + context.getDeviceImei() + ":app_send_message_data");
// if (StringUtils.isEmpty(data)) { if (StringUtils.isEmpty(data)) {
// return; return;
// } }
//
// byte[] arr = ImageToCArrayConverter.convertStringToByteArray(data); byte[] arr = ImageToCArrayConverter.convertStringToByteArray(data);
// byte[] specificChunk = ImageToCArrayConverter.getChunk(arr, (val2 - 1), 512); byte[] specificChunk = ImageToCArrayConverter.getChunk(arr, (val2 - 1), 512);
// log.info("第{}块数据大小: {} 字节", val2, specificChunk.length); log.info("第{}块数据大小: {} 字节", val2, specificChunk.length);
//// System.out.println("第" + val2 + "块数据: " + Arrays.toString(specificChunk)); // System.out.println("第" + val2 + "块数据: " + Arrays.toString(specificChunk));
//
// ArrayList<Integer> intData = new ArrayList<>(); ArrayList<Integer> intData = new ArrayList<>();
// intData.add(6); intData.add(6);
// intData.add(val2); intData.add(val2);
// ImageToCArrayConverter.buildArr(convertHexToDecimal(specificChunk), intData); ImageToCArrayConverter.buildArr(convertHexToDecimal(specificChunk), intData);
// intData.add(0); intData.add(0);
// intData.add(0); intData.add(0);
// intData.add(0); intData.add(0);
// intData.add(0); intData.add(0);
//
// Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
// map.put("instruct", intData); map.put("instruct", intData);
//
// mqttGateway.sendMsgToMqtt(MqttConstants.GLOBAL_PUB_KEY + context.getDeviceImei(), 1, JsonUtils.toJsonString(map)); mqttGateway.sendMsgToMqtt(MqttConstants.GLOBAL_PUB_KEY + context.getDeviceImei(), 1, JsonUtils.toJsonString(map));
// log.info("发送设备信息数据到设备消息=>topic:{},payload:{}", log.info("发送设备信息数据到设备消息=>topic:{},payload:{}",
// MqttConstants.GLOBAL_PUB_KEY + context.getDeviceImei(), MqttConstants.GLOBAL_PUB_KEY + context.getDeviceImei(),
// JsonUtils.toJsonString(map)); JsonUtils.toJsonString(map));
} catch (Exception e) { } catch (Exception e) {
log.error("处理发送设备信息时出错", e); log.error("处理发送设备信息时出错", e);

View File

@ -1,46 +1,46 @@
//package com.fuyuanshen.global.mqtt.rule.hby100j; package com.fuyuanshen.global.mqtt.rule.hby100j;
//
//import com.alibaba.fastjson2.JSONObject; import com.alibaba.fastjson2.JSONObject;
//import com.fuyuanshen.common.core.constant.GlobalConstants; import com.fuyuanshen.common.core.constant.GlobalConstants;
//import com.fuyuanshen.common.redis.utils.RedisUtils; import com.fuyuanshen.common.redis.utils.RedisUtils;
//import com.fuyuanshen.global.mqtt.base.NewMqttMessageRule; import com.fuyuanshen.global.mqtt.base.NewMqttMessageRule;
//import com.fuyuanshen.global.mqtt.base.NewMqttRuleContext; import com.fuyuanshen.global.mqtt.base.NewMqttRuleContext;
//import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
//import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
//
//import java.util.Map; import java.util.Map;
//
//import static com.fuyuanshen.global.mqtt.constants.DeviceRedisKeyConstants.DEVICE_KEY_PREFIX; import static com.fuyuanshen.global.mqtt.constants.DeviceRedisKeyConstants.DEVICE_KEY_PREFIX;
//
///** /**
// * 设备复位 * 设备复位
// */ */
//@Slf4j @Slf4j
//@Component @Component
//public class FuncType1Rest implements NewMqttMessageRule { public class FuncType1Rest implements NewMqttMessageRule {
//
// @Override @Override
// public String getCommandType() { public String getCommandType() {
// return "HBY100_1"; return "HBY100_1";
// } }
//
// @Override @Override
// public void execute(NewMqttRuleContext context) { public void execute(NewMqttRuleContext context) {
// log.info("开始处理设备复位,消息负载:{}", context.getPayloadDict()); log.info("开始处理设备复位,消息负载:{}", context.getPayloadDict());
//
// try { try {
// // 构建强制声光报警开关的Redis键 // 构建强制声光报警开关的Redis键
//// String redisKey = GlobalConstants.GLOBAL_REDIS_KEY + DEVICE_KEY_PREFIX + String redisKey = GlobalConstants.GLOBAL_REDIS_KEY + DEVICE_KEY_PREFIX +
//// context.getDeviceImei() + ":force_audio_visual_alarm_switch"; context.getDeviceImei() + ":rest";
////
//// Map<String, Object> payloadDict = context.getPayloadDict(); Map<String, Object> payloadDict = context.getPayloadDict();
//// if (payloadDict != null) { if (payloadDict != null) {
//// // 存储强制声光报警开关状态到Redis // 存储强制声光报警开关状态到Redis
//// RedisUtils.setCacheObject(redisKey, JSONObject.toJSONString(payloadDict)); RedisUtils.setCacheObject(redisKey, JSONObject.toJSONString(payloadDict));
//// } }
// log.info("设备复位设备ID{}", context.getDeviceImei()); log.info("设备复位设备ID{}", context.getDeviceImei());
// } catch (Exception e) { } catch (Exception e) {
// log.error("处理设备复位失败", e); log.error("处理设备复位失败", e);
// } }
// } }
//} }

View File

@ -29,13 +29,13 @@ public class FuncType5UpdateVoice implements NewMqttMessageRule {
log.info("HBY100J更新语音消息负载{}", context.getPayloadDict()); log.info("HBY100J更新语音消息负载{}", context.getPayloadDict());
try { try {
// String redisKey = GlobalConstants.GLOBAL_REDIS_KEY + DEVICE_KEY_PREFIX + String redisKey = GlobalConstants.GLOBAL_REDIS_KEY + DEVICE_KEY_PREFIX +
// context.getDeviceImei() + ":updateVoice"; context.getDeviceImei() + ":updateVoice";
//
// Map<String, Object> payloadDict = context.getPayloadDict(); Map<String, Object> payloadDict = context.getPayloadDict();
// if (payloadDict != null) { if (payloadDict != null) {
// RedisUtils.setCacheObject(redisKey, JSONObject.toJSONString(payloadDict)); RedisUtils.setCacheObject(redisKey, JSONObject.toJSONString(payloadDict));
// } }
} catch (Exception e) { } catch (Exception e) {
log.error("HBY100J更新语音失败", e); log.error("HBY100J更新语音失败", e);
} }

View File

@ -29,13 +29,13 @@ public class FuncType6VoicePlay implements NewMqttMessageRule {
log.info("HBY100J语音播报开启/关闭,消息负载:{}", context.getPayloadDict()); log.info("HBY100J语音播报开启/关闭,消息负载:{}", context.getPayloadDict());
try { try {
// String redisKey = GlobalConstants.GLOBAL_REDIS_KEY + DEVICE_KEY_PREFIX + String redisKey = GlobalConstants.GLOBAL_REDIS_KEY + DEVICE_KEY_PREFIX +
// context.getDeviceImei() + ":VoicePlay"; context.getDeviceImei() + ":voicePlay";
//
// Map<String, Object> payloadDict = context.getPayloadDict(); Map<String, Object> payloadDict = context.getPayloadDict();
// if (payloadDict != null) { if (payloadDict != null) {
// RedisUtils.setCacheObject(redisKey, JSONObject.toJSONString(payloadDict)); RedisUtils.setCacheObject(redisKey, JSONObject.toJSONString(payloadDict));
// } }
} catch (Exception e) { } catch (Exception e) {
log.error("HBY100J语音播报开启/关闭失败", e); log.error("HBY100J语音播报开启/关闭失败", e);
} }

View File

@ -0,0 +1,137 @@
package com.fuyuanshen.web.controller.device;
import com.fuyuanshen.app.domain.dto.AppAudioFileDto;
import com.fuyuanshen.app.domain.dto.AppFileRenameDto;
import com.fuyuanshen.app.domain.dto.TextToSpeechRequest;
import com.fuyuanshen.app.service.AudioProcessService;
import com.fuyuanshen.app.service.VideoProcessService;
import com.fuyuanshen.common.core.domain.R;
import com.fuyuanshen.common.idempotent.annotation.RepeatSubmit;
import com.fuyuanshen.common.web.core.BaseController;
import com.fuyuanshen.equipment.domain.vo.AppFileVo;
import lombok.RequiredArgsConstructor;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.util.List;
import java.util.concurrent.TimeUnit;
/**
* APP 视频处理控制器
*/
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/api/video")
public class WebVideoController extends BaseController {
private final VideoProcessService videoProcessService;
private final AudioProcessService audioProcessService;
/**
* 上传视频转码code默认1RGB565 2BGR565
*/
@PostMapping(value = "/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
@RepeatSubmit(interval = 2, timeUnit = TimeUnit.SECONDS,message = "请勿重复提交!")
public R<List<String>> uploadVideo(@RequestParam("file") MultipartFile file, @RequestParam(defaultValue = "1") int code) {
return R.ok(videoProcessService.processVideo(file, code));
}
/**
* 上传音频文件并转码
*/
@PostMapping(value = "/audio", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
@RepeatSubmit(interval = 2, timeUnit = TimeUnit.SECONDS,message = "请勿重复提交!")
public R<List<String>> uploadAudio(@RequestParam("file") MultipartFile file) {
return R.ok(audioProcessService.processAudio(file));
}
/**
* 文字转音频TTS服务
*/
@GetMapping("/audioTTS")
@RepeatSubmit(interval = 2, timeUnit = TimeUnit.SECONDS,message = "请勿重复提交!")
public R<List<String>> uploadAudioTTS(@RequestParam String text) throws IOException {
return R.ok(audioProcessService.generateStandardPcmData(text));
}
/**
* 提取文本内容只支持txt/docx
*/
@PostMapping(value = "/extract", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
@RepeatSubmit(interval = 2, timeUnit = TimeUnit.SECONDS,message = "请勿重复提交!")
public R<String> extract(@RequestParam("file") MultipartFile file) throws Exception {
return R.ok("Success",audioProcessService.extract(file));
}
/**
* 上传音频文件进行处理
* 支持MP3、WAV、PCM格式
*/
@PostMapping("/uploadAudioToOss")
public R<String> uploadAudioToOss(@ModelAttribute AppAudioFileDto bo) {
try {
bo.setSource("web");
String result = audioProcessService.uploadAudioToOss(bo);
return R.ok(result);
} catch (IllegalArgumentException e) {
return R.fail("文件格式错误: " + e.getMessage());
} catch (Exception e) {
return R.fail("上传处理失败: " + e.getMessage());
}
}
/**
* 文本转语音
* 支持MP3、WAV、PCM格式
*/
@PostMapping("/ttsToOss")
public R<String> textToSpeech(@RequestBody TextToSpeechRequest request) {
try {
if (request.getDeviceId() == null) {
return R.fail("设备ID不能为空");
}
String result = audioProcessService.textToSpeech(
request.getDeviceId(),
request.getText(),
request.getFileSuffix(),
"web"
);
return R.ok(result);
} catch (Exception e) {
return R.fail("文本转语音失败: " + e.getMessage());
}
}
/**
* 查询语音文件列表
*/
@GetMapping("/queryAudioFileList")
public R<List<AppFileVo>> queryAudioFileList(Long deviceId) {
return R.ok(audioProcessService.queryAudioFileList(deviceId,"web"));
}
/**
* 删除语音文件
*/
@GetMapping("/deleteAudioFile")
public R<Void> deleteAudioFile(Long id) {
return audioProcessService.deleteAudioFile(id);
}
/**
* 文件重命名
*/
@PostMapping("/renameAudioFile")
public R<Void> renameAudioFile(@RequestBody AppFileRenameDto bo) {
return audioProcessService.renameAudioFile(bo);
}
}

View File

@ -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();
} }

View File

@ -7,4 +7,8 @@ public class HBY100JUpdateVoiceDto {
private Long id; private Long id;
/**
* 通讯方式 0:4G;1:蓝牙
*/
private Integer communicationMode;
} }

View File

@ -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)

View File

@ -5,11 +5,14 @@ import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.fuyuanshen.app.domain.vo.AppDeviceHBY100JDetailVo; import com.fuyuanshen.app.domain.vo.AppDeviceHBY100JDetailVo;
import com.fuyuanshen.app.mapper.AppDeviceShareMapper;
import com.fuyuanshen.common.core.constant.GlobalConstants; import com.fuyuanshen.common.core.constant.GlobalConstants;
import com.fuyuanshen.common.core.domain.model.AppLoginUser;
import com.fuyuanshen.common.core.domain.model.LoginUser; import com.fuyuanshen.common.core.domain.model.LoginUser;
import com.fuyuanshen.common.core.exception.ServiceException; import com.fuyuanshen.common.core.exception.ServiceException;
import com.fuyuanshen.common.core.utils.StringUtils; import com.fuyuanshen.common.core.utils.StringUtils;
import com.fuyuanshen.common.redis.utils.RedisUtils; import com.fuyuanshen.common.redis.utils.RedisUtils;
import com.fuyuanshen.common.satoken.utils.AppLoginHelper;
import com.fuyuanshen.common.satoken.utils.LoginHelper; import com.fuyuanshen.common.satoken.utils.LoginHelper;
import com.fuyuanshen.equipment.domain.AppBusinessFile; import com.fuyuanshen.equipment.domain.AppBusinessFile;
import com.fuyuanshen.equipment.domain.Device; import com.fuyuanshen.equipment.domain.Device;
@ -52,9 +55,12 @@ public class DeviceHBY100JBizService {
private final IAppBusinessFileService appBusinessFileService; private final IAppBusinessFileService appBusinessFileService;
private final AppBusinessFileMapper appBusinessFileMapper; private final AppBusinessFileMapper appBusinessFileMapper;
private final SysOssMapper sysOssMapper; private final SysOssMapper sysOssMapper;
private final AppDeviceShareMapper appDeviceShareMapper;
private static final String DEVICE_TYPE = "HBY100/"; private static final String DEVICE_TYPE = "HBY100/";
private static final Long pcUserId = 0L;
/** /**
* 记录设备操作日志 * 记录设备操作日志
* *
@ -153,6 +159,17 @@ public class DeviceHBY100JBizService {
vo.setAlarmMode(sirenAlarm.getMode()); vo.setAlarmMode(sirenAlarm.getMode());
} }
} }
String voicePlayRedisKey = GlobalConstants.GLOBAL_REDIS_KEY + DEVICE_KEY_PREFIX +
device.getDeviceImei() + ":voicePlay";
String voicePlayStatus = RedisUtils.getCacheObject(voicePlayRedisKey);
if(StringUtils.isNotBlank(voicePlayStatus)){
FuncType6VoicePlayRequest funcType6VoicePlayRequest = JSONObject.parseObject(voicePlayStatus, FuncType6VoicePlayRequest.class);
if(funcType6VoicePlayRequest.getData() != null){
vo.setVoiceBroadcast(funcType6VoicePlayRequest.getData().getVoiceBroadcast());
}
}
String strobeModeRedisKey = GlobalConstants.GLOBAL_REDIS_KEY + DEVICE_KEY_PREFIX + String strobeModeRedisKey = GlobalConstants.GLOBAL_REDIS_KEY + DEVICE_KEY_PREFIX +
device.getDeviceImei() + ":strobeMode"; device.getDeviceImei() + ":strobeMode";
String strobeModeStatus = RedisUtils.getCacheObject(strobeModeRedisKey); String strobeModeStatus = RedisUtils.getCacheObject(strobeModeRedisKey);
@ -234,7 +251,7 @@ public class DeviceHBY100JBizService {
if (deviceIds == null || deviceIds.isEmpty()) { if (deviceIds == null || deviceIds.isEmpty()) {
throw new ServiceException("请选择设备"); throw new ServiceException("请选择设备");
} }
LoginUser loginUser = LoginHelper.getLoginUser(); AppLoginUser loginUser = AppLoginHelper.getLoginUser();
bo.getDeviceIds().forEach(deviceId -> { bo.getDeviceIds().forEach(deviceId -> {
Device deviceObj = deviceMapper.selectById(deviceId); Device deviceObj = deviceMapper.selectById(deviceId);
if (getDeviceStatus(deviceObj.getDeviceImei())) { if (getDeviceStatus(deviceObj.getDeviceImei())) {
@ -252,9 +269,9 @@ public class DeviceHBY100JBizService {
request.setData(data); request.setData(data);
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));
Long userId = loginUser == null ? pcUserId : loginUser.getUserId();
recordDeviceLog(deviceId, deviceObj.getDeviceName(), "强制报警激活", "强制报警激活", userId);
// recordDeviceLog(deviceId, deviceObj.getDeviceName(), "强制报警激活", "强制报警激活", loginUser.getUserId());
}); });
} }
@ -268,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();
LoginUser loginUser = LoginHelper.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());
@ -283,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());
@ -293,6 +311,8 @@ public class DeviceHBY100JBizService {
updateWrapper2.eq("id", appBusinessFileVo.getId()); updateWrapper2.eq("id", appBusinessFileVo.getId());
updateWrapper2.set("use_status", 1); updateWrapper2.set("use_status", 1);
appBusinessFileMapper.update(updateWrapper2); appBusinessFileMapper.update(updateWrapper2);
Long userId = loginUser == null ? pcUserId : loginUser.getUserId();
recordDeviceLog(deviceObj.getId(), deviceObj.getDeviceName(), "更新语音", "更新语音", userId);
} }
private String buildMqttTopic(String deviceImei) { private String buildMqttTopic(String deviceImei) {
@ -305,6 +325,7 @@ 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();
FuncType10StrobeModeRequest request = new FuncType10StrobeModeRequest(); FuncType10StrobeModeRequest request = new FuncType10StrobeModeRequest();
request.setRequestId(GenerateIdUtil.generateNumericId()); request.setRequestId(GenerateIdUtil.generateNumericId());
request.setImei(deviceObj.getDeviceImei()); request.setImei(deviceObj.getDeviceImei());
@ -316,6 +337,9 @@ public class DeviceHBY100JBizService {
request.setData(data); request.setData(data);
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));
String content = params.getEnable() != null && params.getEnable() == 1 ? "爆闪模式开启" : "爆闪模式关闭";
Long userId = loginUser == null ? pcUserId : loginUser.getUserId();
recordDeviceLog(deviceObj.getId(), deviceObj.getDeviceName(), content, content, userId);
} }
public void lightAdjustment(HBY100JLightAdjustmentDto params) { public void lightAdjustment(HBY100JLightAdjustmentDto params) {
@ -327,6 +351,7 @@ 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();
FuncType13BrightnessRequest request = new FuncType13BrightnessRequest(); FuncType13BrightnessRequest request = new FuncType13BrightnessRequest();
request.setRequestId(GenerateIdUtil.generateNumericId()); request.setRequestId(GenerateIdUtil.generateNumericId());
request.setImei(deviceObj.getDeviceImei()); request.setImei(deviceObj.getDeviceImei());
@ -339,6 +364,8 @@ public class DeviceHBY100JBizService {
request.setData(data); request.setData(data);
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));
Long userId = loginUser == null ? pcUserId : loginUser.getUserId();
recordDeviceLog(deviceObj.getId(), deviceObj.getDeviceName(), "灯光调节", "灯光调节", userId);
} }
public void strobeFrequency(HBY100JStrobeFrequencyDto params) { public void strobeFrequency(HBY100JStrobeFrequencyDto params) {
@ -349,6 +376,7 @@ 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();
FuncType11FrequencyRequest request = new FuncType11FrequencyRequest(); FuncType11FrequencyRequest request = new FuncType11FrequencyRequest();
request.setRequestId(GenerateIdUtil.generateNumericId()); request.setRequestId(GenerateIdUtil.generateNumericId());
request.setImei(deviceObj.getDeviceImei()); request.setImei(deviceObj.getDeviceImei());
@ -359,6 +387,8 @@ public class DeviceHBY100JBizService {
request.setData(data); request.setData(data);
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));
Long userId = loginUser == null ? pcUserId : loginUser.getUserId();
recordDeviceLog(deviceObj.getId(), deviceObj.getDeviceName(), "爆闪频率", "爆闪频率", userId);
} }
public void updateVolume(HBY100JUpdateVolumeDto params) { public void updateVolume(HBY100JUpdateVolumeDto params) {
@ -369,6 +399,7 @@ 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();
FuncType9UpdateVolumeRequest request = new FuncType9UpdateVolumeRequest(); FuncType9UpdateVolumeRequest request = new FuncType9UpdateVolumeRequest();
request.setRequestId(GenerateIdUtil.generateNumericId()); request.setRequestId(GenerateIdUtil.generateNumericId());
request.setImei(deviceObj.getDeviceImei()); request.setImei(deviceObj.getDeviceImei());
@ -379,6 +410,8 @@ public class DeviceHBY100JBizService {
request.setData(data); request.setData(data);
log.info("HBY100J更新音量下发设备参数{}", JSON.toJSONString(request)); log.info("HBY100J更新音量下发设备参数{}", JSON.toJSONString(request));
mqttGateway.sendMsgToMqtt(buildMqttTopic(deviceObj.getDeviceImei()), 1, JSON.toJSONString(request)); mqttGateway.sendMsgToMqtt(buildMqttTopic(deviceObj.getDeviceImei()), 1, JSON.toJSONString(request));
Long userId = loginUser == null ? pcUserId : loginUser.getUserId();
recordDeviceLog(deviceObj.getId(), deviceObj.getDeviceName(), "更新音量", "更新音量", userId);
} }
public void voiceBroadcast(HBY100JVoiceBroadcastDto params) { public void voiceBroadcast(HBY100JVoiceBroadcastDto params) {
@ -389,6 +422,7 @@ 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();
FuncType6VoicePlayRequest request = new FuncType6VoicePlayRequest(); FuncType6VoicePlayRequest request = new FuncType6VoicePlayRequest();
request.setRequestId(GenerateIdUtil.generateNumericId()); request.setRequestId(GenerateIdUtil.generateNumericId());
request.setImei(deviceObj.getDeviceImei()); request.setImei(deviceObj.getDeviceImei());
@ -399,5 +433,9 @@ public class DeviceHBY100JBizService {
request.setData(data); request.setData(data);
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));
Long userId = loginUser == null ? pcUserId : loginUser.getUserId();
recordDeviceLog(deviceObj.getId(), deviceObj.getDeviceName(), "语音播报", "语音播报", userId);
} }
} }

View File

@ -16,7 +16,7 @@ spring.boot.admin.client:
--- # snail-job 配置 --- # snail-job 配置
snail-job: snail-job:
enabled: false enabled: true
# 需要在 SnailJob 后台组管理创建对应名称的组,然后创建任务的时候选择对应的组,才能正确分派任务 # 需要在 SnailJob 后台组管理创建对应名称的组,然后创建任务的时候选择对应的组,才能正确分派任务
group: "fys_group" group: "fys_group"
# SnailJob 接入验证令牌 详见 script/sql/ry_job.sql `sj_group_config`表 # SnailJob 接入验证令牌 详见 script/sql/ry_job.sql `sj_group_config`表

View File

@ -4,7 +4,7 @@ spring:
driver-class-name: com.mysql.cj.jdbc.Driver driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/ry-vue?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true url: jdbc:mysql://localhost:3306/ry-vue?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
username: root username: root
password: root password: Jq_123456#
hikari: hikari:
connection-timeout: 30000 connection-timeout: 30000
validation-timeout: 5000 validation-timeout: 5000

View File

@ -2,9 +2,9 @@ spring:
datasource: datasource:
type: com.zaxxer.hikari.HikariDataSource type: com.zaxxer.hikari.HikariDataSource
driver-class-name: com.mysql.cj.jdbc.Driver driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/ry-vue?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true url: jdbc:mysql://localhost:3306/fys-vue?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
username: root username: root
password: root password: Jq_123456#
hikari: hikari:
connection-timeout: 30000 connection-timeout: 30000
validation-timeout: 5000 validation-timeout: 5000
@ -29,7 +29,7 @@ snail-job:
--- # 监控中心配置 --- # 监控中心配置
spring.boot.admin.client: spring.boot.admin.client:
# 增加客户端开关 # 增加客户端开关
enabled: true enabled: false
url: http://localhost:9090/admin url: http://localhost:9090/admin
instance: instance:
service-host-type: IP service-host-type: IP

View File

@ -46,6 +46,9 @@ public class AppDeviceBindRecordBo extends BaseEntity {
* 绑定时间 * 绑定时间
*/ */
private Date bindingTime; private Date bindingTime;
/**
* 通讯方式 0:4G;1:蓝牙,2 4G&蓝牙
*/
private Integer communicationMode;
} }

View File

@ -76,6 +76,7 @@ public class AppDeviceBindRecordServiceImpl implements IAppDeviceBindRecordServi
lqw.eq(bo.getDeviceId() != null, AppDeviceBindRecord::getDeviceId, bo.getDeviceId()); lqw.eq(bo.getDeviceId() != null, AppDeviceBindRecord::getDeviceId, bo.getDeviceId());
lqw.eq(bo.getBindingUserId() != null, AppDeviceBindRecord::getBindingUserId, bo.getBindingUserId()); lqw.eq(bo.getBindingUserId() != null, AppDeviceBindRecord::getBindingUserId, bo.getBindingUserId());
lqw.eq(bo.getBindingTime() != null, AppDeviceBindRecord::getBindingTime, bo.getBindingTime()); lqw.eq(bo.getBindingTime() != null, AppDeviceBindRecord::getBindingTime, bo.getBindingTime());
lqw.eq(bo.getCommunicationMode() != null, AppDeviceBindRecord::getCommunicationMode, bo.getCommunicationMode());
return lqw; return lqw;
} }

View File

@ -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);
} }

View File

@ -24,7 +24,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
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>

View File

@ -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());