Commit 53c8b98a authored by ZWT's avatar ZWT

feat(吉林演示): 松原

1.修改系统首页大屏总览接口,增加区分组织机构逻辑,完成接口冒烟测试;
2.修改系统首页获取井场列表接口,增加区分组织机构逻辑,完成接口冒烟测试;
3.修改系统首页井场功能下钻后提示报错问题,修改用电功率数据获取逻辑,修复报错问题;
4.修改输电线路分页列表查询接口,增加查询条件,在查询父线路列表时只查询10千伏线路,修改线上接口文档同时完成接口冒烟测试;
5.修改系统首页井场实时监控接口,增加区分组织机构逻辑,完成接口冒烟测试;
6.修改系统首页用能分析接口,增加区分组织机构逻辑,完成接口冒烟测试;
7.修改系统首页井场用能分析(双坐标轴)接口,增加区分组织机构逻辑,完成接口冒烟测试;
8.修改系统首页累积用电接口,增加区分组织机构逻辑,完成接口冒烟测试;
9.修改系统首页光伏实时监控接口,增加区分组织机构逻辑,完成接口冒烟测试;
10.修改系统首页井场效果评价接口,增加区分组织机构逻辑,完成接口冒烟测试;
11.修改系统首页先导实验井间开制度接口,增加区分组织机构逻辑,完成接口冒烟测试;

BREAKING CHANGE: 无

Closes 无

[skip ci]
parent 48a1d22d
...@@ -32,75 +32,10 @@ public class CounterBuilder { ...@@ -32,75 +32,10 @@ public class CounterBuilder {
this.setFieldValue("__CREATETIME__", DateUtil.date().toString()); this.setFieldValue("__CREATETIME__", DateUtil.date().toString());
} }
public CounterBuilder(String groupName) {
this.groupName = groupName;
}
public static String getInstanceId() {
if (globalCounterBuilder.fieldValueMap.containsKey(COUNTER_NAME_INSTANCE)) {
return globalCounterBuilder.fieldValueMap.get(COUNTER_NAME_INSTANCE);
} else {
return "";
}
}
public static CounterBuilder getCounterBuilder(String counterName) {
if (counterBuilders.containsKey(counterName)) {
return counterBuilders.get(counterName);
} else {
CounterBuilder counterBuilder = new CounterBuilder();
counterBuilders.put(counterName, counterBuilder);
return counterBuilder;
}
}
public ConcurrentHashMap<String, String> getFieldValueMap() {
return fieldValueMap;
}
public ConcurrentHashMap<String, AtomicLong> getCounterMap() {
return counterMap;
}
public String getGroupName() {
return groupName;
}
public void setGroupName(String groupName) {
this.groupName = groupName;
}
public CounterBuilder addCounter(Throwable throwable) {
return this.addCounter("Exception-Total")
.addCounter("Exception-" + throwable.getClass().getSimpleName(), 1, CounterBuildItemInfoType.ERROR);
}
public CounterBuilder addCounter(Throwable throwable, Class<?> reporter) {
return this.addCounter("Exception-Total")
.addCounter("Exception-" + throwable.getClass().getSimpleName())
.addCounter(reporter.getSimpleName() + "-" + throwable.getClass().getSimpleName(), 1, CounterBuildItemInfoType.ERROR);
}
public CounterBuilder addCounter(String counterName) { public CounterBuilder addCounter(String counterName) {
return this.addCounter(counterName, 1, detectInfoTypeByCounterName(counterName)); return this.addCounter(counterName, 1, detectInfoTypeByCounterName(counterName));
} }
public CounterBuilder addCounter(String counterName, Class<?> reporter) {
return this.addCounter(reporter.getSimpleName() + "-" + counterName, 1, detectInfoTypeByCounterName(counterName));
}
public CounterBuilder addCounter(String counterName, Class<?> reporter, CounterBuildItemInfoType infoType) {
return addCounter(reporter.getSimpleName() + "-" + counterName, 1L, infoType);
}
public CounterBuilder addCounter(String counterName, CounterBuildItemInfoType infoType) {
return addCounter(counterName, 1L, infoType);
}
public CounterBuilder addCounter(String counterName, long v) {
return this.addCounter(counterName, v, detectInfoTypeByCounterName(counterName));
}
public CounterBuilder addCounter(String counterName, long v, CounterBuildItemInfoType infoType) { public CounterBuilder addCounter(String counterName, long v, CounterBuildItemInfoType infoType) {
if (counterName == null || counterName.isEmpty()) { if (counterName == null || counterName.isEmpty()) {
return this; return this;
...@@ -124,34 +59,6 @@ public class CounterBuilder { ...@@ -124,34 +59,6 @@ public class CounterBuilder {
return this; return this;
} }
public CounterBuilder setCounter(String counterName, long v) {
return this.setCounter(counterName, v, detectInfoTypeByCounterName(counterName));
}
public CounterBuilder setCounter(String counterName, long newCounterValue, CounterBuildItemInfoType infoType) {
if (counterName == null || counterName.isEmpty()) {
return this;
}
if (CharSequenceUtil.isNotBlank(this.groupName)) {
counterName = String.format("%s-%s", this.groupName, counterName);
}
if (this.fieldValueMap.containsKey(counterName)) {
this.counterMap.get(counterName).set(newCounterValue);
return this;
}
if (this.fieldValueMap.containsKey(counterName)) {
this.counterMap.get(counterName).set(newCounterValue);
return this;
}
this.counterMap.put(counterName, new AtomicLong(newCounterValue));
this.fileInfoTypeMap.put(counterName, infoType);
return this;
}
public CounterBuilder setFieldValue(String fieldName, String fieldValue) { public CounterBuilder setFieldValue(String fieldName, String fieldValue) {
return setFieldValue(fieldName, fieldValue, detectInfoTypeByCounterName(fieldName)); return setFieldValue(fieldName, fieldValue, detectInfoTypeByCounterName(fieldName));
} }
...@@ -180,34 +87,6 @@ public class CounterBuilder { ...@@ -180,34 +87,6 @@ public class CounterBuilder {
return CounterBuildItemInfoType.NORNAL; return CounterBuildItemInfoType.NORNAL;
} }
public long getCounter(String counterName) {
if (counterName == null || counterName.isEmpty()) {
return 0;
}
if (CharSequenceUtil.isNotBlank(this.groupName)) {
counterName = String.format("%s-%s", this.groupName, counterName);
}
if (!this.counterMap.containsKey(counterName)) {
return 0;
} else {
return this.counterMap.get(counterName).get();
}
}
public String getFieldValue(String fieldName) {
if (fieldName == null || fieldName.isEmpty()) {
return "";
}
if (CharSequenceUtil.isNotBlank(this.groupName)) {
fieldName = String.format("%s-%s", this.groupName, fieldName);
}
return this.fieldValueMap.getOrDefault(fieldName, "");//[fieldName];
}
@Override @Override
public String toString() { public String toString() {
ArrayList<String> lines = new ArrayList<>(this.fieldValueMap.size() + this.counterMap.size()); ArrayList<String> lines = new ArrayList<>(this.fieldValueMap.size() + this.counterMap.size());
...@@ -232,19 +111,6 @@ public class CounterBuilder { ...@@ -232,19 +111,6 @@ public class CounterBuilder {
return stringBuilder.toString(); return stringBuilder.toString();
} }
public DynObj toDynObj() {
DynObj obj = new DynObj();
ImmutableList<Map.Entry<String, String>> fieldsList = ImmutableList.copyOf(this.fieldValueMap.entrySet());
fieldsList.forEach(item -> {
obj.put(item.getKey(), item.getValue());
});
ImmutableList<Map.Entry<String, AtomicLong>> fieldsList2 = ImmutableList.copyOf(this.counterMap.entrySet());
fieldsList2.forEach(item -> {
obj.put(item.getKey(), item.getValue().get());
});
return obj;
}
public enum CounterBuildItemInfoType { public enum CounterBuildItemInfoType {
NORNAL, NORNAL,
ERROR; ERROR;
......
package pps.core.common.utils;
import cn.hutool.core.text.CharSequenceUtil;
import xstartup.annotation.XText;
import java.io.Serializable;
import java.lang.reflect.Field;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
@XText("动态对象容器")
public class DynObj extends TreeMap<String, Object> implements Serializable {
private static final long serialVersionUID = 1L;
public DynObj() {
super(String.CASE_INSENSITIVE_ORDER);
}
public DynObj(Map obj) {
super(String.CASE_INSENSITIVE_ORDER);
this.merge(obj);
}
public static List<DynObj> sort(List<DynObj> list, String... fields) {
list.sort((o1, o2) -> {
for (String field : fields) {
Object fieldValue1 = o1.get(field);
Object fieldValue2 = o2.get(field);
if (fieldValue1 == null && fieldValue2 == null)
continue;
if (fieldValue1 != null && fieldValue2 == null)
return 1;
if (fieldValue1 == null)
return -1;
if (fieldValue1 instanceof Comparable) {
int v = ((Comparable) fieldValue1).compareTo(fieldValue2);
if (v != 0)
return v;
}
}
return 0;
});
return list;
}
public DynObj put(String key, Object value) {
super.put(key, value);
return this;
}
public DynObj mergeObjectField(Object obj) throws IllegalAccessException {
if (obj instanceof Map) {
return merge((Map) obj);
} else {
Field[] fields = obj.getClass().getDeclaredFields();
for (Field f : fields) {
String propertyName = f.getName();
f.setAccessible(true);
Object propertyValue = f.get(obj);// ReflectionUtils.getField(f, obj);
if (propertyValue == null)
continue;
this.put(propertyName, propertyValue);
}
return this;
}
}
public DynObj merge(Map obj) {
if (obj == null)
return this;
if (this.equals(obj))
return this;
obj.forEach((k, v) -> {
if (k == null) {
// this.put("", v);
return;
} else {
this.put(k.toString(), v);
}
});
return this;
}
public String getString(String key) {
Object v = get(key);
if (v == null) {
return null;
}
if (v instanceof String) {
return (String) v;
} else {
return v.toString();
}
}
public String getString(String key, String defaultValue) {
Object v = get(key);
if (v == null) {
return defaultValue;
}
if (v instanceof String) {
String strV = (String) v;
if (CharSequenceUtil.isBlank(strV)) {
return defaultValue;
} else {
return strV;
}
} else {
return v.toString();
}
}
public int getInt(String key) {
return getInt(key, 0);
}
public int getInt(String key, int defaultValue) {
Object v = get(key);
if (v == null) {
return defaultValue;
}
String strValue = v.toString().toLowerCase();
if (CharSequenceUtil.isBlank(strValue)) {
return defaultValue;
}
if (WellKnownRegexValidator.completelyMatches(strValue, WellKnownRegex.INTEGER)) {
return Integer.parseInt(strValue);
} else {
return defaultValue;
}
}
public Boolean boolValue(String fieldName) {
return boolValue(fieldName, Boolean.FALSE);
}
public Boolean boolValue(String fieldName, Boolean defaultValue) {
if (!this.containsKey(fieldName)) {
return defaultValue;
}
Object v = this.get(fieldName);
if (v == null) {
return Boolean.FALSE;
}
String strV = v.toString();
if (strV.equals("0") || strV.equals("false") || strV.equals("False")) {
return Boolean.FALSE;
}
return Boolean.TRUE;
}
public String strValue(String fieldName) {
return strValue(fieldName, "");
}
public String strValue(String fieldName, String defaultValue) {
if (!this.containsKey(fieldName)) {
return defaultValue;
}
Object v = this.get(fieldName);
if (v == null) {
return null;
}
return v.toString();
}
public Integer intValue(String fieldName) {
return intValue(fieldName, null);
}
public Integer intValue(String fieldName, Integer defaultValue) {
String strValue = strValue(fieldName, null);
if (CharSequenceUtil.isBlank(strValue)) {
return defaultValue;
} else {
return Integer.parseInt(strValue);
}
}
public Double doubleValue(String fieldName) {
return doubleValue(fieldName, null);
}
public Double doubleValue(String fieldName, Double defaultValue) {
String strValue = strValue(fieldName, null);
if (CharSequenceUtil.isBlank(strValue)) {
return defaultValue;
} else {
return Double.parseDouble(strValue);
}
}
public String description(String... keys) {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < keys.length; i++) {
String k = keys[i];
String v = getString(k, "");
if (i > 0) {
sb.append(", ");
}
sb.append(String.format("[%s]:%s", k, v));
}
return sb.toString();
}
public void mergeTo(Map m) {
this.forEach(m::put);
}
public String stringByLeves(String keys, String defaultValue) {
if (CharSequenceUtil.isBlank(keys)) {
return defaultValue;
}
int idx = keys.indexOf(".");
if (idx == 0) {
return stringByLeves(keys.substring(1), defaultValue);
} else if (idx == -1) {
return getString(keys, defaultValue);
} else {
String k = keys.substring(0, idx);
if (!this.containsKey(k)) {
return defaultValue;
}
DynObj obj = new DynObj((Map) this.get(k));
return obj.stringByLeves(keys.substring(idx + 1), defaultValue);
}
}
}
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