更新,推送为主
This commit is contained in:
parent
82c547d778
commit
7c3496ec22
|
@ -5,6 +5,7 @@ import java.util.List;
|
|||
import java.util.Objects;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
|
||||
import com.ruoyi.bst.device.service.DeviceAssembler;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.support.TransactionTemplate;
|
||||
|
@ -78,6 +79,9 @@ public class DeviceIotServiceImpl implements DeviceIotService {
|
|||
@Autowired
|
||||
private OperLogService operLogService;
|
||||
|
||||
@Autowired
|
||||
private DeviceAssembler deviceAssembler;
|
||||
|
||||
private final static Integer SUB_FAST = 5; // 上报频率(快)
|
||||
private final static Integer SUB_SLOW = 300; // 上报频率(慢)
|
||||
private final static Integer SUB_X_SLOW = 50; // 上报频率(X开头硬件)
|
||||
|
@ -280,22 +284,25 @@ public class DeviceIotServiceImpl implements DeviceIotService {
|
|||
}
|
||||
|
||||
// 获取物联网信息
|
||||
List<IotDeviceInfo> iotList = iotService.getDeviceInfo(deviceList);
|
||||
if (CollectionUtils.isEmptyElement(iotList)) {
|
||||
return;
|
||||
}
|
||||
// List<IotDeviceInfo> iotList = iotService.getDeviceInfo(deviceList);
|
||||
// if (CollectionUtils.isEmptyElement(iotList)) {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// // 更新设备信息
|
||||
// for (DeviceVO device : deviceList) {
|
||||
// if (device == null || StringUtils.isBlank(device.getMac())) {
|
||||
// continue;
|
||||
// }
|
||||
// IotDeviceInfo iot = iotList.stream()
|
||||
// .filter(item -> Objects.equals(item.getMac(), device.getMac()))
|
||||
// .findFirst().orElse(null);
|
||||
// DeviceUtil.setIotInfo(device, iot);
|
||||
// this.updateIot(device);
|
||||
// }
|
||||
|
||||
// 更新设备信息
|
||||
for (DeviceVO device : deviceList) {
|
||||
if (device == null || StringUtils.isBlank(device.getMac())) {
|
||||
continue;
|
||||
}
|
||||
IotDeviceInfo iot = iotList.stream()
|
||||
.filter(item -> Objects.equals(item.getMac(), device.getMac()))
|
||||
.findFirst().orElse(null);
|
||||
DeviceUtil.setIotInfo(device, iot);
|
||||
this.updateIot(device);
|
||||
}
|
||||
// 拼接物联网信息
|
||||
deviceAssembler.assembleIot(deviceList);
|
||||
|
||||
// 异步发送命令,强制设备上报数据
|
||||
if (onlineType != null) {
|
||||
|
@ -432,7 +439,7 @@ public class DeviceIotServiceImpl implements DeviceIotService {
|
|||
try {
|
||||
// 获取设备最新信息
|
||||
DeviceVO device = deviceMapper.selectDeviceById(deviceId);
|
||||
this.refresh(device, null);
|
||||
deviceAssembler.assembleIot(device);
|
||||
this.monitor(device);
|
||||
} catch (Exception e) {
|
||||
log.error("监控设备id={}出错:{}", deviceId, e.getMessage());
|
||||
|
@ -472,7 +479,7 @@ public class DeviceIotServiceImpl implements DeviceIotService {
|
|||
@Override
|
||||
public void monitor(String mac) {
|
||||
DeviceVO device = deviceService.selectByMac(mac);
|
||||
this.refresh(device, null);
|
||||
deviceAssembler.assembleIot(device);
|
||||
this.monitor(device);
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ import java.util.Collections;
|
|||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import com.ruoyi.bst.device.service.DeviceAssembler;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
@ -112,6 +113,9 @@ public class OrderConverterImpl implements OrderConverter{
|
|||
@Autowired
|
||||
private ModelAssembler modelAssembler;
|
||||
|
||||
@Autowired
|
||||
private DeviceAssembler deviceAssembler;
|
||||
|
||||
@Override
|
||||
public OrderPrePriceVO toOrderPrePriceVO(OrderCalcPrePriceDTO dto) {
|
||||
if (dto == null) {
|
||||
|
@ -364,7 +368,7 @@ public class OrderConverterImpl implements OrderConverter{
|
|||
if (orderDevice != null) {
|
||||
// 获取当前设备信息
|
||||
DeviceVO device = deviceService.selectDeviceById(orderDevice.getDeviceId());
|
||||
deviceIotService.refresh(device, null);
|
||||
deviceAssembler.assembleIot(device);
|
||||
bo.setDevice(device);
|
||||
}
|
||||
|
||||
|
@ -448,7 +452,7 @@ public class OrderConverterImpl implements OrderConverter{
|
|||
|
||||
// 查询旧设备
|
||||
DeviceVO oldDevice = deviceService.selectDeviceById(oldOrderDevice.getDeviceId());
|
||||
deviceIotService.refresh(oldDevice, null);
|
||||
deviceAssembler.assembleIot(oldDevice);
|
||||
ServiceUtil.assertion(oldDevice == null, "ID为%s的旧设备不存在", oldOrderDevice.getDeviceId());
|
||||
bo.setOldDevice(oldDevice);
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ import java.util.List;
|
|||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import com.ruoyi.bst.device.service.DeviceAssembler;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.support.TransactionTemplate;
|
||||
|
@ -159,6 +160,9 @@ public class OrderServiceImpl implements OrderService {
|
|||
@Autowired
|
||||
private RedisCache redisCache;
|
||||
|
||||
@Autowired
|
||||
private DeviceAssembler deviceAssembler;
|
||||
|
||||
/**
|
||||
* 查询订单
|
||||
*
|
||||
|
@ -478,8 +482,6 @@ public class OrderServiceImpl implements OrderService {
|
|||
|
||||
/**
|
||||
* 设置日志参数
|
||||
* @param lon 手机定位经度
|
||||
* @param lat 手机定位纬度
|
||||
* @param device 设备信息
|
||||
*/
|
||||
private void setLogParam(DeviceVO device) {
|
||||
|
@ -652,7 +654,7 @@ public class OrderServiceImpl implements OrderService {
|
|||
|
||||
// 设备信息
|
||||
DeviceVO device = deviceService.selectDeviceById(order.getDeviceId());
|
||||
deviceIotService.refresh(device, null);
|
||||
deviceAssembler.assembleIot(device);
|
||||
if (device == null) {
|
||||
return null;
|
||||
}
|
||||
|
@ -710,7 +712,7 @@ public class OrderServiceImpl implements OrderService {
|
|||
// 查询设备
|
||||
DeviceVO device = deviceService.selectDeviceById(orderDevice.getDeviceId());
|
||||
ServiceUtil.assertion(device == null, "ID为%s的设备不存在", orderDevice.getDeviceId());
|
||||
deviceIotService.refresh(device, null);
|
||||
deviceAssembler.assembleIot(device);
|
||||
// 设置日志参数
|
||||
this.setLogParam(device);
|
||||
// 异步使用手机定位更新设备定位
|
||||
|
@ -736,7 +738,7 @@ public class OrderServiceImpl implements OrderService {
|
|||
// 查询设备
|
||||
DeviceVO device = deviceService.selectDeviceById(orderDevice.getDeviceId());
|
||||
ServiceUtil.assertion(device == null, "ID为%s的设备不存在", orderDevice.getDeviceId());
|
||||
deviceIotService.refresh(device, null);
|
||||
deviceAssembler.assembleIot(device);
|
||||
// 设置日志参数
|
||||
this.setLogParam(device);
|
||||
// 异步使用手机定位更新设备定位
|
||||
|
|
Loading…
Reference in New Issue
Block a user