Commit 4ea504da authored by 赵啸非's avatar 赵啸非

设备添加产品编码字段,并添加同步更新产品编码字段

parent cb90eb4c
...@@ -273,7 +273,7 @@ export default { ...@@ -273,7 +273,7 @@ export default {
onSubmit() { onSubmit() {
let { path, query } = this.$route; let { path, query } = this.$route;
let data = this.decode(this.form); let data = this.decode(this.form);
delete this.form["deviceStatusList"] //delete this.form["deviceStatusList"]
this.$router.push({ this.$router.push({
path: path, path: path,
query: Object.assign({}, query, data), query: Object.assign({}, query, data),
......
...@@ -319,6 +319,7 @@ export default { ...@@ -319,6 +319,7 @@ export default {
}, },
changeStat(val, enabled) { changeStat(val, enabled) {
return;
//去除其它条件 //去除其它条件
delete this.query["productId"] delete this.query["productId"]
delete this.query["deviceName"] delete this.query["deviceName"]
...@@ -524,6 +525,12 @@ export default { ...@@ -524,6 +525,12 @@ export default {
type: "select", type: "select",
label: "设备类型", label: "设备类型",
}, },
{
name: "deviceStatus",
type: "select",
label: "设备状态",
},
], ],
columns: [ columns: [
{ {
......
...@@ -44,16 +44,21 @@ public class DeviceStatTaskImpl implements ITaskExcuteService { ...@@ -44,16 +44,21 @@ public class DeviceStatTaskImpl implements ITaskExcuteService {
//获取所有在线设备 //获取所有在线设备
List<DeviceEntity> deviceList = deviceService.find(new DeviceQuery().deviceStatus(DeviceStatusEnum.在线.getValue())); List<DeviceEntity> deviceList = deviceService.find(new DeviceQuery().deviceStatus(DeviceStatusEnum.在线.getValue()));
//更新离线 //更新离线
List<DeviceEntity> deviceOfflineList = deviceList.stream().map(item -> { List<DeviceEntity> deviceOfflineList = deviceList.parallelStream().map(item -> {
if(ObjectUtils.isEmpty(item.getDeviceCode())) return null;
boolean exists = cacheService.exists(RedisKey.KEY_DEVICE_ONLINE_CACHE + item.getDeviceCode()); boolean exists = cacheService.exists(RedisKey.KEY_DEVICE_ONLINE_CACHE + item.getDeviceCode());
log.info("deviceCode:{},exists:{}",item.getDeviceCode(),exists);
if (!exists) { if (!exists) {
item.setDeviceStatus(DeviceStatusEnum.离线.getValue()); item.setDeviceStatus(DeviceStatusEnum.离线.getValue());
item.setOfflineTime(new Date()); item.setOfflineTime(new Date());
return item;
} }
return item; return null;
}).filter(f -> f.getDeviceStatus().equals(DeviceStatusEnum.离线.getValue())).collect(Collectors.toList()); }).filter(f -> f!=null).collect(Collectors.toList());
if (!ObjectUtils.isEmpty(deviceOfflineList)) { if (!ObjectUtils.isEmpty(deviceOfflineList)) {
log.info("修正设备数量:size:{}",deviceOfflineList.size());
deviceService.update(deviceOfflineList); deviceService.update(deviceOfflineList);
deviceOfflineList.forEach(deviceEntity -> { deviceOfflineList.forEach(deviceEntity -> {
PlatformEntity platformEntity = platformService.get(deviceEntity.getPlatformId()); PlatformEntity platformEntity = platformService.get(deviceEntity.getPlatformId());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment