1. 发送设置低电压命令
This commit is contained in:
parent
45eed997ed
commit
89eea6a4a4
|
@ -56,6 +56,11 @@ public class IotConstants {
|
|||
*/
|
||||
public static final String COMMAND_SUB = "sub";
|
||||
|
||||
/**
|
||||
* 命令 发送低电压预警设置
|
||||
*/
|
||||
public static final String COMMAND_BAT = "bat";
|
||||
|
||||
/**
|
||||
* 命令 超出营运区(禁行区)断电,不进行轮动检测
|
||||
*/
|
||||
|
|
|
@ -5,15 +5,20 @@ import java.util.List;
|
|||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.ruoyi.common.constant.IotConstants;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.common.utils.onenet.Token;
|
||||
import com.ruoyi.system.domain.AsDevice;
|
||||
import com.ruoyi.system.mapper.AsDeviceMapper;
|
||||
import com.ruoyi.system.service.IAsDeviceService;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.ruoyi.system.mapper.EtModelMapper;
|
||||
import com.ruoyi.system.domain.EtModel;
|
||||
import com.ruoyi.system.service.IEtModelService;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
|
@ -23,6 +28,7 @@ import javax.annotation.Resource;
|
|||
* @author 邱贞招
|
||||
* @date 2024-05-13
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class EtModelServiceImpl implements IEtModelService
|
||||
{
|
||||
|
@ -74,11 +80,26 @@ public class EtModelServiceImpl implements IEtModelService
|
|||
* @param etModel 车辆型号
|
||||
* @return 结果
|
||||
*/
|
||||
@SneakyThrows
|
||||
@Override
|
||||
@Transactional
|
||||
public int insertEtModel(EtModel etModel)
|
||||
{
|
||||
etModel.setCreateTime(DateUtils.getNowDate());
|
||||
return etModelMapper.insertEtModel(etModel);
|
||||
int i = etModelMapper.insertEtModel(etModel);
|
||||
// 发送设置低电压命令
|
||||
Integer lowBatteryReminder = etModel.getLowBatteryReminder();
|
||||
if(ObjectUtil.isNotNull(lowBatteryReminder) && lowBatteryReminder > 0){
|
||||
AsDevice device = new AsDevice();
|
||||
device.setModelId(etModel.getModelId());
|
||||
List<AsDevice> asDevices = asDeviceService.selectAsDeviceList(device);
|
||||
for(AsDevice asDevice: asDevices){
|
||||
String lowVoltageCommand = IotConstants.COMMAND_BAT + lowBatteryReminder * 10 + "@";
|
||||
log.info("发送低电压命令:" + lowVoltageCommand);
|
||||
asDeviceService.sendCommand(asDevice.getMac(), Token.getToken(), lowVoltageCommand,"发送低电压播报");
|
||||
}
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -87,11 +108,26 @@ public class EtModelServiceImpl implements IEtModelService
|
|||
* @param etModel 车辆型号
|
||||
* @return 结果
|
||||
*/
|
||||
@SneakyThrows
|
||||
@Override
|
||||
@Transactional
|
||||
public int updateEtModel(EtModel etModel)
|
||||
{
|
||||
etModel.setUpdateTime(DateUtils.getNowDate());
|
||||
return etModelMapper.updateEtModel(etModel);
|
||||
int i = etModelMapper.updateEtModel(etModel);
|
||||
// 发送设置低电压命令
|
||||
Integer lowBatteryReminder = etModel.getLowBatteryReminder();
|
||||
if(ObjectUtil.isNotNull(lowBatteryReminder) && lowBatteryReminder > 0){
|
||||
AsDevice device = new AsDevice();
|
||||
device.setModelId(etModel.getModelId());
|
||||
List<AsDevice> asDevices = asDeviceService.selectAsDeviceList(device);
|
||||
for(AsDevice asDevice: asDevices){
|
||||
String lowVoltageCommand = IotConstants.COMMAND_BAT + lowBatteryReminder * 10 + "@";
|
||||
log.info("发送低电压命令:" + lowVoltageCommand);
|
||||
asDeviceService.sendCommand(asDevice.getMac(), Token.getToken(), lowVoltageCommand,"发送低电压播报");
|
||||
}
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue
Block a user