commit
This commit is contained in:
@ -49,7 +49,7 @@ public class ReceiverMessageHandler implements MessageHandler {
|
|||||||
if(StringUtils.isNotBlank(deviceImei)){
|
if(StringUtils.isNotBlank(deviceImei)){
|
||||||
//在线状态
|
//在线状态
|
||||||
String deviceOnlineStatusRedisKey = GlobalConstants.GLOBAL_REDIS_KEY+ DEVICE_KEY_PREFIX+ deviceImei + DeviceRedisKeyConstants.DEVICE_ONLINE_STATUS_KEY_PREFIX ;
|
String deviceOnlineStatusRedisKey = GlobalConstants.GLOBAL_REDIS_KEY+ DEVICE_KEY_PREFIX+ deviceImei + DeviceRedisKeyConstants.DEVICE_ONLINE_STATUS_KEY_PREFIX ;
|
||||||
RedisUtils.setCacheObject(deviceOnlineStatusRedisKey, "1", Duration.ofSeconds(60*15));
|
RedisUtils.setCacheObject(deviceOnlineStatusRedisKey, "1", Duration.ofSeconds(62));
|
||||||
}
|
}
|
||||||
|
|
||||||
String state = payloadDict.getStr("state");
|
String state = payloadDict.getStr("state");
|
||||||
|
@ -19,6 +19,7 @@ import com.fuyuanshen.common.satoken.utils.AppLoginHelper;
|
|||||||
import com.fuyuanshen.equipment.domain.Device;
|
import com.fuyuanshen.equipment.domain.Device;
|
||||||
import com.fuyuanshen.equipment.domain.DeviceType;
|
import com.fuyuanshen.equipment.domain.DeviceType;
|
||||||
import com.fuyuanshen.equipment.domain.dto.AppDeviceSendMsgBo;
|
import com.fuyuanshen.equipment.domain.dto.AppDeviceSendMsgBo;
|
||||||
|
import com.fuyuanshen.equipment.mapper.DeviceLogMapper;
|
||||||
import com.fuyuanshen.equipment.mapper.DeviceMapper;
|
import com.fuyuanshen.equipment.mapper.DeviceMapper;
|
||||||
import com.fuyuanshen.equipment.mapper.DeviceTypeMapper;
|
import com.fuyuanshen.equipment.mapper.DeviceTypeMapper;
|
||||||
import com.fuyuanshen.global.mqtt.config.MqttGateway;
|
import com.fuyuanshen.global.mqtt.config.MqttGateway;
|
||||||
@ -50,6 +51,7 @@ public class DeviceBJQBizService {
|
|||||||
private final AppPersonnelInfoMapper appPersonnelInfoMapper;
|
private final AppPersonnelInfoMapper appPersonnelInfoMapper;
|
||||||
private final DeviceTypeMapper deviceTypeMapper;
|
private final DeviceTypeMapper deviceTypeMapper;
|
||||||
private final MqttGateway mqttGateway;
|
private final MqttGateway mqttGateway;
|
||||||
|
private final DeviceLogMapper deviceLogMapper;
|
||||||
|
|
||||||
public int sendMessage(AppDeviceSendMsgBo bo) {
|
public int sendMessage(AppDeviceSendMsgBo bo) {
|
||||||
List<Long> deviceIds = bo.getDeviceIds();
|
List<Long> deviceIds = bo.getDeviceIds();
|
||||||
@ -93,15 +95,43 @@ public class DeviceBJQBizService {
|
|||||||
.eq("binding_user_id", AppLoginHelper.getUserId())
|
.eq("binding_user_id", AppLoginHelper.getUserId())
|
||||||
.set("send_msg", bo.getSendMsg());
|
.set("send_msg", bo.getSendMsg());
|
||||||
deviceMapper.update(updateWrapper);
|
deviceMapper.update(updateWrapper);
|
||||||
|
recordDeviceLog(deviceId, device.getDeviceName(), "发送信息", bo.getSendMsg(), AppLoginHelper.getUserId());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.info("发送信息设备发送信息失败:{}" ,deviceId);
|
log.info("发送信息设备发送信息失败:{}" ,deviceId);
|
||||||
throw new ServiceException("发送指令失败");
|
throw new ServiceException("发送指令失败");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 记录设备操作日志
|
||||||
|
* @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 AppDeviceDetailVo getInfo(Long id) {
|
public AppDeviceDetailVo getInfo(Long id) {
|
||||||
Device device = deviceMapper.selectById(id);
|
Device device = deviceMapper.selectById(id);
|
||||||
if (device == null) {
|
if (device == null) {
|
||||||
@ -203,7 +233,7 @@ public class DeviceBJQBizService {
|
|||||||
map.put("instruct", intData);
|
map.put("instruct", intData);
|
||||||
mqttGateway.sendMsgToMqtt(MqttConstants.GLOBAL_PUB_KEY + deviceObj.getDeviceImei(), 1, JSON.toJSONString(map));
|
mqttGateway.sendMsgToMqtt(MqttConstants.GLOBAL_PUB_KEY + deviceObj.getDeviceImei(), 1, JSON.toJSONString(map));
|
||||||
log.info("发送点阵数据到设备消息=>topic:{},payload:{}", MqttConstants.GLOBAL_PUB_KEY + deviceObj.getDeviceImei(), bo);
|
log.info("发送点阵数据到设备消息=>topic:{},payload:{}", MqttConstants.GLOBAL_PUB_KEY + deviceObj.getDeviceImei(), bo);
|
||||||
|
recordDeviceLog(deviceId, deviceObj.getDeviceName(), "人员信息登记", JSON.toJSONString(bo), AppLoginHelper.getUserId());
|
||||||
if (ObjectUtils.length(appPersonnelInfoVos) == 0) {
|
if (ObjectUtils.length(appPersonnelInfoVos) == 0) {
|
||||||
AppPersonnelInfo appPersonnelInfo = MapstructUtils.convert(bo, AppPersonnelInfo.class);
|
AppPersonnelInfo appPersonnelInfo = MapstructUtils.convert(bo, AppPersonnelInfo.class);
|
||||||
return appPersonnelInfoMapper.insertOrUpdate(appPersonnelInfo);
|
return appPersonnelInfoMapper.insertOrUpdate(appPersonnelInfo);
|
||||||
@ -216,8 +246,6 @@ public class DeviceBJQBizService {
|
|||||||
.set("code", bo.getCode());
|
.set("code", bo.getCode());
|
||||||
return appPersonnelInfoMapper.update(null, uw) > 0;
|
return appPersonnelInfoMapper.update(null, uw) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void uploadDeviceLogo(AppDeviceLogoUploadDto bo) {
|
public void uploadDeviceLogo(AppDeviceLogoUploadDto bo) {
|
||||||
@ -255,6 +283,8 @@ public class DeviceBJQBizService {
|
|||||||
map.put("instruct", intData);
|
map.put("instruct", intData);
|
||||||
mqttGateway.sendMsgToMqtt(MqttConstants.GLOBAL_PUB_KEY+device.getDeviceImei(), 1 , JSON.toJSONString(map));
|
mqttGateway.sendMsgToMqtt(MqttConstants.GLOBAL_PUB_KEY+device.getDeviceImei(), 1 , JSON.toJSONString(map));
|
||||||
log.info("发送点阵数据到设备消息=>topic:{},payload:{}", MqttConstants.GLOBAL_PUB_KEY+device.getDeviceImei(),JSON.toJSONString(map));
|
log.info("发送点阵数据到设备消息=>topic:{},payload:{}", MqttConstants.GLOBAL_PUB_KEY+device.getDeviceImei(),JSON.toJSONString(map));
|
||||||
|
|
||||||
|
recordDeviceLog(device.getId(), device.getDeviceName(), "上传开机画面", "上传开机画面", AppLoginHelper.getUserId());
|
||||||
} catch (Exception e){
|
} catch (Exception e){
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
throw new ServiceException("发送指令失败");
|
throw new ServiceException("发送指令失败");
|
||||||
|
Reference in New Issue
Block a user