forked from dyf/fys-Multi-tenant
全局控制
This commit is contained in:
@ -1,14 +1,17 @@
|
||||
package com.fuyuanshen.app.service.device.status.jbq;
|
||||
|
||||
import cn.hutool.json.JSONObject;
|
||||
import com.fuyuanshen.app.domain.dto.AppRealTimeStatusDto;
|
||||
import com.fuyuanshen.app.service.device.status.DeviceStatusRule;
|
||||
import com.fuyuanshen.app.service.device.status.constants.DeviceTypeConstants;
|
||||
import com.fuyuanshen.common.core.utils.StringUtils;
|
||||
import com.fuyuanshen.common.redis.utils.RedisUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import static com.fuyuanshen.common.core.constant.GlobalConstants.FUNCTION_ACCESS_KEY;
|
||||
|
||||
@ -30,21 +33,23 @@ public class AlarmStatusRule implements DeviceStatusRule {
|
||||
public Map<String, Object> getStatus(AppRealTimeStatusDto dto) {
|
||||
Map<String, Object> status = new HashMap<>();
|
||||
String functionAccess = RedisUtils.getCacheObject(
|
||||
|
||||
FUNCTION_ACCESS_KEY + dto.getDeviceImei());
|
||||
if(functionAccess==null){
|
||||
FUNCTION_ACCESS_KEY + dto.getBatchId());
|
||||
if(StringUtils.isBlank(functionAccess)){
|
||||
status.put("functionAccess", "OK");
|
||||
return status;
|
||||
}
|
||||
JSONObject jsonObj = new JSONObject(functionAccess);
|
||||
AtomicBoolean isActive = new AtomicBoolean(false);
|
||||
jsonObj.forEach((key, value) -> {
|
||||
if(value.equals("ACTIVE")){
|
||||
isActive.set(true);
|
||||
}
|
||||
});
|
||||
if(!isActive.get()){
|
||||
status.put("functionAccess", "OK");
|
||||
}else{
|
||||
status.put("functionAccess", "ACTIVE");
|
||||
}
|
||||
//
|
||||
|
||||
// String alarmStatus = RedisUtils.getCacheObject(
|
||||
// GLOBAL_REDIS_KEY + DEVICE_KEY_PREFIX + dto.getDeviceImei() + DEVICE_ALARM_KEY_PREFIX);
|
||||
//
|
||||
// if (StringUtils.isNotBlank(alarmStatus)) {
|
||||
// status.put("alarmStatus", alarmStatus);
|
||||
// }
|
||||
return status;
|
||||
}
|
||||
}
|
@ -36,14 +36,6 @@ public class BootLogoStatusRule implements DeviceStatusRule {
|
||||
}else{
|
||||
status.put("functionAccess", "ACTIVE");
|
||||
}
|
||||
// String location = RedisUtils.getCacheObject(
|
||||
// GLOBAL_REDIS_KEY + DEVICE_KEY_PREFIX + dto.getDeviceImei() + DEVICE_LOCATION_KEY_PREFIX);
|
||||
//
|
||||
// if (StringUtils.isNotBlank(location)) {
|
||||
// JSONObject jsonObject = JSONObject.parseObject(location);
|
||||
// status.put("latitude", jsonObject.getString("latitude"));
|
||||
// status.put("longitude", jsonObject.getString("longitude"));
|
||||
// }
|
||||
return status;
|
||||
}
|
||||
}
|
@ -40,9 +40,6 @@ public class LaserModeSettingsStatusRule implements DeviceStatusRule {
|
||||
}else{
|
||||
status.put("functionAccess", "ACTIVE");
|
||||
}
|
||||
// String onlineStatus = RedisUtils.getCacheObject(
|
||||
// GLOBAL_REDIS_KEY + DEVICE_KEY_PREFIX + dto.getDeviceImei() + DEVICE_ONLINE_STATUS_KEY_PREFIX);
|
||||
// status.put("onlineStatus", StringUtils.isNotBlank(onlineStatus) ? 1 : 0);
|
||||
return status;
|
||||
}
|
||||
}
|
@ -32,16 +32,11 @@ public class ModeStatusRule implements DeviceStatusRule {
|
||||
Map<String, Object> status = new HashMap<>();
|
||||
String functionAccess = RedisUtils.getCacheObject(
|
||||
FUNCTION_ACCESS_KEY + dto.getDeviceImei());
|
||||
status.put("functionAccess", functionAccess);
|
||||
// String deviceStatus = RedisUtils.getCacheObject(
|
||||
// GLOBAL_REDIS_KEY + DEVICE_KEY_PREFIX + dto.getDeviceImei() + DEVICE_STATUS_KEY_PREFIX);
|
||||
//
|
||||
// if (StringUtils.isNotBlank(deviceStatus)) {
|
||||
// JSONObject jsonObject = JSONObject.parseObject(deviceStatus);
|
||||
// status.put("battery", jsonObject.getString("batteryPercentage"));
|
||||
// } else {
|
||||
// status.put("battery", "0");
|
||||
// }
|
||||
if(functionAccess==null){
|
||||
status.put("functionAccess", "OK");
|
||||
}else{
|
||||
status.put("functionAccess", "ACTIVE");
|
||||
}
|
||||
return status;
|
||||
}
|
||||
}
|
@ -36,12 +36,6 @@ public class RegisterPersonInfoStatusRule implements DeviceStatusRule {
|
||||
}else{
|
||||
status.put("functionAccess", "ACTIVE");
|
||||
}
|
||||
// String alarmStatus = RedisUtils.getCacheObject(
|
||||
// GLOBAL_REDIS_KEY + DEVICE_KEY_PREFIX + dto.getDeviceImei() + DEVICE_ALARM_KEY_PREFIX);
|
||||
//
|
||||
// if (StringUtils.isNotBlank(alarmStatus)) {
|
||||
// status.put("alarmStatus", alarmStatus);
|
||||
// }
|
||||
return status;
|
||||
}
|
||||
}
|
@ -1,15 +1,17 @@
|
||||
package com.fuyuanshen.app.service.device.status.jbq;
|
||||
|
||||
import cn.hutool.json.JSONObject;
|
||||
import com.fuyuanshen.app.domain.dto.AppRealTimeStatusDto;
|
||||
import com.fuyuanshen.app.service.device.status.DeviceStatusRule;
|
||||
import com.fuyuanshen.app.service.device.status.constants.DeviceTypeConstants;
|
||||
import com.fuyuanshen.common.core.utils.StringUtils;
|
||||
import com.fuyuanshen.common.redis.utils.RedisUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import static com.fuyuanshen.common.core.constant.GlobalConstants.FUNCTION_ACCESS_KEY;
|
||||
|
||||
@ -30,19 +32,24 @@ public class SendMessageStatusRule implements DeviceStatusRule {
|
||||
@Override
|
||||
public Map<String, Object> getStatus(AppRealTimeStatusDto dto) {
|
||||
Map<String, Object> status = new HashMap<>();
|
||||
List<String> functionAccess = RedisUtils.getCacheObject(
|
||||
String functionAccess = RedisUtils.getCacheObject(
|
||||
FUNCTION_ACCESS_KEY + dto.getBatchId());
|
||||
if(functionAccess==null){
|
||||
if(StringUtils.isBlank(functionAccess)){
|
||||
status.put("functionAccess", "OK");
|
||||
return status;
|
||||
}
|
||||
JSONObject jsonObj = new JSONObject(functionAccess);
|
||||
AtomicBoolean isActive = new AtomicBoolean(false);
|
||||
jsonObj.forEach((key, value) -> {
|
||||
if(value.equals("ACTIVE")){
|
||||
isActive.set(true);
|
||||
}
|
||||
});
|
||||
if(!isActive.get()){
|
||||
status.put("functionAccess", "OK");
|
||||
}else{
|
||||
status.put("functionAccess", "ACTIVE");
|
||||
}
|
||||
// String alarmStatus = RedisUtils.getCacheObject(
|
||||
// GLOBAL_REDIS_KEY + DEVICE_KEY_PREFIX + dto.getDeviceImei() + DEVICE_ALARM_KEY_PREFIX);
|
||||
//
|
||||
// if (StringUtils.isNotBlank(alarmStatus)) {
|
||||
// status.put("alarmStatus", alarmStatus);
|
||||
// }
|
||||
return status;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user