fix: udw
This commit is contained in:
@@ -1,8 +1,13 @@
|
||||
package org.nl.acs.udw;
|
||||
|
||||
/**
|
||||
* @author 20220102CG\noblelift
|
||||
*/
|
||||
public class UdwConfig {
|
||||
|
||||
//历史记录最大数量
|
||||
/**
|
||||
* 历史记录最大数量
|
||||
*/
|
||||
public static int max_history_length = 10;
|
||||
|
||||
public UdwConfig() {
|
||||
|
||||
@@ -4,6 +4,9 @@ import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author 20220102CG\noblelift
|
||||
*/
|
||||
@Data
|
||||
public class UnifiedData {
|
||||
private Object value;
|
||||
|
||||
@@ -2,16 +2,54 @@ package org.nl.acs.udw;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author 20220102CG\noblelift
|
||||
*/
|
||||
public interface UnifiedDataAccessor {
|
||||
/**
|
||||
* 获取所有key
|
||||
*
|
||||
* @return List<String>
|
||||
*/
|
||||
List<String> getAllKey();
|
||||
|
||||
/**
|
||||
* 获取值
|
||||
*
|
||||
* @param key key
|
||||
* @return Object
|
||||
*/
|
||||
Object getValue(String key);
|
||||
|
||||
/**
|
||||
* 设置值
|
||||
*
|
||||
* @param key key
|
||||
* @param value value
|
||||
*/
|
||||
void setValue(String key, Object value);
|
||||
|
||||
/**
|
||||
* 获取统一数据
|
||||
*
|
||||
* @param key key
|
||||
* @return UnifiedData
|
||||
*/
|
||||
UnifiedData getUnifiedData(String key);
|
||||
|
||||
/**
|
||||
* 获取历史数据
|
||||
*
|
||||
* @param key key
|
||||
* @return List<UnifiedData>
|
||||
*/
|
||||
List<UnifiedData> getHistoryUnifiedData(String key);
|
||||
|
||||
/**
|
||||
* 设置值
|
||||
*
|
||||
* @param key key
|
||||
* @param value value
|
||||
*/
|
||||
void setValueWithPersistence(String key, Object value);
|
||||
}
|
||||
|
||||
@@ -3,6 +3,9 @@ package org.nl.acs.udw;
|
||||
import org.nl.acs.udw.service.impl.UnifiedDataAccessorImpl;
|
||||
import org.nl.acs.udw.service.impl.UnifiedDataAppServiceImpl;
|
||||
|
||||
/**
|
||||
* @author 20220102CG\noblelift
|
||||
*/
|
||||
public class UnifiedDataAccessorFactory {
|
||||
public UnifiedDataAccessorFactory() {
|
||||
}
|
||||
|
||||
@@ -5,6 +5,9 @@ import org.nl.acs.udw.service.impl.UnifiedDataUnit;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author 20220102CG\noblelift
|
||||
*/
|
||||
public interface UnifiedDataAppService {
|
||||
/**
|
||||
* 获取所有的key
|
||||
@@ -21,26 +24,89 @@ public interface UnifiedDataAppService {
|
||||
*/
|
||||
UnifiedDataUnit getUnifiedDataUnit(String key);
|
||||
|
||||
/**
|
||||
* 获取数据单元
|
||||
* @param var1
|
||||
* @param var2
|
||||
* @return
|
||||
*/
|
||||
UnifiedData getUnifiedData(String var1, String var2);
|
||||
|
||||
/**
|
||||
* 获取数据值
|
||||
* @param var1
|
||||
* @param var2
|
||||
* @return
|
||||
*/
|
||||
Object getValue(String var1, String var2);
|
||||
|
||||
/**
|
||||
* 设置数据值
|
||||
* @param var1
|
||||
* @param var2
|
||||
* @param var3
|
||||
*/
|
||||
void setValue(String var1, String var2, Object var3);
|
||||
|
||||
/**
|
||||
* 设置数据值,不记录日志
|
||||
* @param var1
|
||||
* @param var2
|
||||
* @param var3
|
||||
*/
|
||||
void setValueNoLog(String var1, String var2, Object var3);
|
||||
|
||||
/**
|
||||
* 获取历史数据
|
||||
* @param var1
|
||||
* @param var2
|
||||
* @return List<UnifiedData
|
||||
*/
|
||||
List<UnifiedData> getHistoryUnifiedData(String var1, String var2);
|
||||
|
||||
/**
|
||||
* 获取所有数据key
|
||||
* @param var1
|
||||
* @return List<String>
|
||||
*/
|
||||
List<String> getAllDataKey(String var1);
|
||||
|
||||
/**
|
||||
* 删除数据
|
||||
* @param var1
|
||||
* @param var2
|
||||
*/
|
||||
void removeValue(String var1, String var2);
|
||||
|
||||
/**'
|
||||
* 设置数据值,不记录日志
|
||||
* @param var1
|
||||
* @param var2
|
||||
* @param var3
|
||||
*/
|
||||
void setValueWithPersistenceNoLog(String var1, String var2, Object var3);
|
||||
|
||||
/**
|
||||
* 设置数据值,记录日志
|
||||
* @param var1
|
||||
* @param var2
|
||||
* @param var3
|
||||
*/
|
||||
void setValueWithPersistence(String var1, String var2, Object var3);
|
||||
|
||||
/**
|
||||
* 删除数据,记录日志
|
||||
* @param var1
|
||||
* @param var2
|
||||
*/
|
||||
void removeValueWithPersistence(String var1, String var2);
|
||||
|
||||
/**
|
||||
* 判断两个对象是否相等
|
||||
* @param a
|
||||
* @param b
|
||||
* @return
|
||||
*/
|
||||
static boolean isEquals(Object a, Object b) {
|
||||
return ObjectUtil.equal(a, b);
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import java.util.Date;
|
||||
|
||||
/**
|
||||
* 统一数据源管理
|
||||
* @author 20220102CG\noblelift
|
||||
*/
|
||||
@Data
|
||||
public class UdwDto {
|
||||
|
||||
@@ -15,6 +15,9 @@ import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author 20220102CG\noblelift
|
||||
*/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@Api(tags = "内存点位管理")
|
||||
|
||||
@@ -7,6 +7,9 @@ import org.springframework.data.domain.Pageable;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author 20220102CG\noblelift
|
||||
*/
|
||||
public interface UdwManageService {
|
||||
/**
|
||||
* 根据条件查询
|
||||
|
||||
@@ -16,6 +16,9 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author 20220102CG\noblelift
|
||||
*/
|
||||
@Service
|
||||
public class UdwManagerServiceImpl implements UdwManageService {
|
||||
|
||||
|
||||
@@ -6,6 +6,9 @@ import org.nl.acs.udw.UnifiedDataAppService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author 20220102CG\noblelift
|
||||
*/
|
||||
public class UnifiedDataAccessorImpl implements UnifiedDataAccessor {
|
||||
private String unified_key;
|
||||
private UnifiedDataAppService unifiedDataAppService;
|
||||
@@ -21,26 +24,32 @@ public class UnifiedDataAccessorImpl implements UnifiedDataAccessor {
|
||||
this.unifiedDataAppService = unifiedDataService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getAllKey() {
|
||||
return this.unifiedDataAppService.getAllDataKey(this.unified_key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValue(String key) {
|
||||
return this.unifiedDataAppService.getValue(this.unified_key, key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(String key, Object value) {
|
||||
this.unifiedDataAppService.setValue(this.unified_key, key, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValueWithPersistence(String key, Object value) {
|
||||
this.unifiedDataAppService.setValueWithPersistence(this.unified_key, key, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UnifiedData getUnifiedData(String key) {
|
||||
return this.unifiedDataAppService.getUnifiedData(this.unified_key, key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UnifiedData> getHistoryUnifiedData(String key) {
|
||||
return this.unifiedDataAppService.getHistoryUnifiedData(this.unified_key, key);
|
||||
}
|
||||
|
||||
@@ -8,6 +8,9 @@ import org.nl.common.exception.BadRequestException;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author 20220102CG\noblelift
|
||||
*/
|
||||
@Slf4j
|
||||
public class UnifiedDataAppServiceImpl implements UnifiedDataAppService {
|
||||
public static UnifiedDataAppService unifiedDataAppService;
|
||||
@@ -28,15 +31,18 @@ public class UnifiedDataAppServiceImpl implements UnifiedDataAppService {
|
||||
return unifiedDataAppService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getAllUnifiedKey() {
|
||||
return new ArrayList(this.factory.keySet());
|
||||
}
|
||||
|
||||
@Override
|
||||
public UnifiedDataUnit getUnifiedDataUnit(String unified_key) {
|
||||
UnifiedDataUnit dataUnit = (UnifiedDataUnit) this.factory.get(unified_key);
|
||||
return dataUnit == null ? null : dataUnit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getAllDataKey(String unified_key) {
|
||||
UnifiedDataUnit dataUnit = (UnifiedDataUnit) this.factory.get(unified_key);
|
||||
if (dataUnit == null) {
|
||||
@@ -47,6 +53,7 @@ public class UnifiedDataAppServiceImpl implements UnifiedDataAppService {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public UnifiedData getUnifiedData(String unified_key, String key) {
|
||||
UnifiedDataUnit dataUnit = this.getUnifiedDataUnit(unified_key);
|
||||
if (dataUnit == null) {
|
||||
@@ -57,11 +64,13 @@ public class UnifiedDataAppServiceImpl implements UnifiedDataAppService {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValue(String unified_key, String key) {
|
||||
UnifiedData unifiedData = this.getUnifiedData(unified_key, key);
|
||||
return unifiedData == null ? null : unifiedData.getValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeValueWithPersistence(String unified_key, String key) {
|
||||
UnifiedDataUnit dataUnit = this.getUnifiedDataUnit(unified_key);
|
||||
if (dataUnit != null) {
|
||||
@@ -80,6 +89,7 @@ public class UnifiedDataAppServiceImpl implements UnifiedDataAppService {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeValue(String unified_key, String key) {
|
||||
UnifiedDataUnit dataUnit = this.getUnifiedDataUnit(unified_key);
|
||||
if (dataUnit != null) {
|
||||
@@ -100,18 +110,22 @@ public class UnifiedDataAppServiceImpl implements UnifiedDataAppService {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValueNoLog(String unified_key, String key, Object value) {
|
||||
this.setValue(unified_key, key, value, false, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(String unified_key, String key, Object value) {
|
||||
this.setValue(unified_key, key, value, false, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValueWithPersistenceNoLog(String unified_key, String key, Object value) {
|
||||
this.setValue(unified_key, key, value, true, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValueWithPersistence(String unified_key, String key, Object value) {
|
||||
this.setValue(unified_key, key, value, true, true);
|
||||
}
|
||||
@@ -172,6 +186,7 @@ public class UnifiedDataAppServiceImpl implements UnifiedDataAppService {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UnifiedData> getHistoryUnifiedData(String unified_key, String key) {
|
||||
UnifiedDataUnit dataUnit = this.getUnifiedDataUnit(unified_key);
|
||||
if (dataUnit == null) {
|
||||
|
||||
@@ -8,6 +8,9 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author 20220102CG\noblelift
|
||||
*/
|
||||
@Data
|
||||
public class UnifiedDataUnit {
|
||||
private String unifiedKey;
|
||||
|
||||
Reference in New Issue
Block a user