debug
This commit is contained in:
parent
765a795e36
commit
5162eb39c2
|
@ -71,11 +71,12 @@ public interface IotService {
|
||||||
IotDeviceDetail getDeviceDetail(String deviceName);
|
IotDeviceDetail getDeviceDetail(String deviceName);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设备电量充值
|
* 设置剩余时长
|
||||||
|
*
|
||||||
* @param deviceName 设备名称
|
* @param deviceName 设备名称
|
||||||
* @param num 充值度数(度)
|
* @param seconds 时长(秒)
|
||||||
*/
|
*/
|
||||||
boolean recharge(String deviceName, BigDecimal num);
|
boolean setTime(String deviceName, BigDecimal seconds);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新设备信息
|
* 更新设备信息
|
||||||
|
|
|
@ -168,21 +168,22 @@ public class IotServiceImpl implements IotService {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 充值设备
|
* 设置剩余时长
|
||||||
|
*
|
||||||
* @param deviceName 设备名称
|
* @param deviceName 设备名称
|
||||||
* @param num 充值度数(度)
|
* @param seconds 时长(秒)
|
||||||
* @return 是否成功
|
* @return 是否成功
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public boolean recharge(String deviceName, BigDecimal num) {
|
public boolean setTime(String deviceName, BigDecimal seconds) {
|
||||||
if (num == null || BigDecimal.ZERO.compareTo(num) > 0) {
|
if (seconds == null || BigDecimal.ZERO.compareTo(seconds) > 0) {
|
||||||
log.error("充值设备参数错误:读数不允许为空或者小于0");
|
log.error("设置剩余时长参数错误:读数不允许为空或者小于0");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
CommandResponse response = sendCommand(deviceName, IotConstants.COMMAND_RECHARGE + num.multiply(new BigDecimal(60)) + IotConstants.COMMAND_SEPARATOR);
|
CommandResponse response = sendCommand(deviceName, IotConstants.COMMAND_RECHARGE + seconds + IotConstants.COMMAND_SEPARATOR);
|
||||||
if (!Objects.equals(HttpStatus.IOT_SUCCESS, response.getCode())) {
|
if (!Objects.equals(HttpStatus.IOT_SUCCESS, response.getCode())) {
|
||||||
log.error("充值设备发生异常:" + response.getMsg());
|
log.error("设置剩余时长发生异常:" + response.getMsg());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -280,8 +280,12 @@ public class SmDeviceServiceImpl implements ISmDeviceService
|
||||||
changeStatus(deviceId, DeviceStatus.USING);
|
changeStatus(deviceId, DeviceStatus.USING);
|
||||||
|
|
||||||
// 物联网设备增加时长
|
// 物联网设备增加时长
|
||||||
boolean rechargeResult = iotService.recharge(device.getMac(), num);
|
SmDeviceVo newDevice = selectSmDeviceByDeviceId(deviceId);
|
||||||
|
long seconds = Duration.between(LocalDateTime.now(), newDevice.getExpireTime()).getSeconds();
|
||||||
|
if (seconds > 0) {
|
||||||
|
boolean rechargeResult = iotService.setTime(device.getMac(), new BigDecimal(seconds));
|
||||||
ServiceUtil.assertion(!rechargeResult, "设备充值失败");
|
ServiceUtil.assertion(!rechargeResult, "设备充值失败");
|
||||||
|
}
|
||||||
|
|
||||||
return Boolean.TRUE;
|
return Boolean.TRUE;
|
||||||
});
|
});
|
||||||
|
@ -539,7 +543,9 @@ public class SmDeviceServiceImpl implements ISmDeviceService
|
||||||
form.setStatus(DeviceStatus.NORMAL.getStatus());
|
form.setStatus(DeviceStatus.NORMAL.getStatus());
|
||||||
smDeviceMapper.updateSmDevice(form);
|
smDeviceMapper.updateSmDevice(form);
|
||||||
|
|
||||||
// TODO 物联网设备归零
|
// 物联网设备归零
|
||||||
|
boolean b = iotService.setTime(device.getMac(), BigDecimal.ONE);
|
||||||
|
ServiceUtil.assertion(!b, "操作设备发生异常");
|
||||||
|
|
||||||
// 归零记录
|
// 归零记录
|
||||||
scheduledExecutorService.schedule(() -> {
|
scheduledExecutorService.schedule(() -> {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user