Commit 965985d0 authored by ZWT's avatar ZWT

feat(吉林演示): 松原

1.开发间开优化结果统计功能,创建间开优化效果统计表,生成对应代码;
2.修改15天,10天,3天,1天间开优化功能,修改代码结构;

BREAKING CHANGE: 无

Closes 无

[skip ci]
parent d495a98d
package pps.core.common.utils;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.text.CharSequenceUtil;
import com.google.common.collect.ImmutableList;
import java.util.ArrayList;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicLong;
/*
* 计数构建器
* */
public class CounterBuilder {
public static final CounterBuilder globalCounterBuilder = new CounterBuilder();
public final String counterId = UUID.randomUUID().toString();
private final ConcurrentHashMap<String, String> fieldValueMap = new ConcurrentHashMap<>();
private final ConcurrentHashMap<String, AtomicLong> counterMap = new ConcurrentHashMap<>();
private final ConcurrentHashMap<String, CounterBuildItemInfoType> fileInfoTypeMap = new ConcurrentHashMap<>();
private String groupName;
public CounterBuilder() {
this.setFieldValue("__COUNTERID__", counterId);
this.setFieldValue("__CREATETIME__", DateUtil.date().toString());
}
public CounterBuilder addCounter(String counterName) {
return this.addCounter(counterName, 1, detectInfoTypeByCounterName(counterName));
}
public CounterBuilder addCounter(String counterName, long v, CounterBuildItemInfoType infoType) {
if (CharSequenceUtil.isBlank(counterName)) {
return this;
}
if (CharSequenceUtil.isNotBlank(this.groupName)) {
counterName = String.format("%s-%s", this.groupName, counterName);
}
if (this.counterMap.containsKey(counterName)) {
this.counterMap.get(counterName).getAndAdd(v);
return this;
}
this.counterMap.put(counterName, new AtomicLong(v));
this.fileInfoTypeMap.put(counterName, infoType);
return this;
}
public void setFieldValue(String fieldName, String fieldValue) {
setFieldValue(fieldName, fieldValue, detectInfoTypeByCounterName(fieldName));
}
public void setFieldValue(String fieldName, String fieldValue, CounterBuildItemInfoType infoType) {
if (CharSequenceUtil.isBlank(fieldName)) {
return;
}
if (CharSequenceUtil.isNotBlank(this.groupName)) {
fieldName = String.format("%s-%s", this.groupName, fieldName);
}
this.fieldValueMap.put(fieldName, fieldValue);
this.fileInfoTypeMap.put(fieldName, infoType);
}
private CounterBuildItemInfoType detectInfoTypeByCounterName(String counterName) {
if (CharSequenceUtil.containsAny(counterName, "Error", "error", "ERROR", "Exception")) {
return CounterBuildItemInfoType.ERROR;
}
return CounterBuildItemInfoType.NORNAL;
}
@Override
public String toString() {
ArrayList<String> lines = new ArrayList<>(this.fieldValueMap.size() + this.counterMap.size());
StringBuilder stringBuilder = new StringBuilder();
ImmutableList<Map.Entry<String, String>> fieldsList = ImmutableList.copyOf(this.fieldValueMap.entrySet());
fieldsList.forEach(item -> {
lines.add(String.format("%s : %s", item.getKey(), item.getValue()));
});
ImmutableList<Map.Entry<String, AtomicLong>> fieldsList2 = ImmutableList.copyOf(this.counterMap.entrySet());
fieldsList2.forEach(item -> {
lines.add(String.format("%s : %d", item.getKey(), item.getValue().get()));
});
for (String line : lines) {
stringBuilder.append(line).append(System.getProperty("line.separator"));
}
return stringBuilder.toString();
}
public enum CounterBuildItemInfoType {
NORNAL,
ERROR;
}
}
\ No newline at end of file
...@@ -2,7 +2,6 @@ package pps.core.system.cache; ...@@ -2,7 +2,6 @@ package pps.core.system.cache;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.text.CharSequenceUtil; import cn.hutool.core.text.CharSequenceUtil;
import pps.core.common.utils.CounterBuilder;
import xstartup.annotation.XText; import xstartup.annotation.XText;
import xstartup.base.XContext; import xstartup.base.XContext;
import xstartup.cache.XCacheLife; import xstartup.cache.XCacheLife;
...@@ -112,7 +111,6 @@ public class SysDictionaryCache implements XCacheObject, XCacheLife { ...@@ -112,7 +111,6 @@ public class SysDictionaryCache implements XCacheObject, XCacheLife {
* @param caches * @param caches
*/ */
public static void set(XContext context, String alias, List<SysDictionaryCache> caches) { public static void set(XContext context, String alias, List<SysDictionaryCache> caches) {
CounterBuilder.globalCounterBuilder.addCounter("setCache");
Tool.get(Tool.class).set(context, alias, caches); Tool.get(Tool.class).set(context, alias, caches);
} }
...@@ -128,9 +126,7 @@ public class SysDictionaryCache implements XCacheObject, XCacheLife { ...@@ -128,9 +126,7 @@ public class SysDictionaryCache implements XCacheObject, XCacheLife {
list = list.stream().filter((SysDictionaryCache b) -> !CharSequenceUtil.equals(b.getId(), dicId)) list = list.stream().filter((SysDictionaryCache b) -> !CharSequenceUtil.equals(b.getId(), dicId))
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
CounterBuilder.globalCounterBuilder.addCounter("deleteCache");
Tool.get(Tool.class).delete(context, alias, SysDictionaryCache.class); Tool.get(Tool.class).delete(context, alias, SysDictionaryCache.class);
CounterBuilder.globalCounterBuilder.addCounter("setCache");
Tool.get(Tool.class).set(context, alias, list); Tool.get(Tool.class).set(context, alias, list);
} }
...@@ -141,7 +137,6 @@ public class SysDictionaryCache implements XCacheObject, XCacheLife { ...@@ -141,7 +137,6 @@ public class SysDictionaryCache implements XCacheObject, XCacheLife {
* @param alias * @param alias
*/ */
public static void deleteCache(XContext context, String alias) { public static void deleteCache(XContext context, String alias) {
CounterBuilder.globalCounterBuilder.addCounter("deleteCache");
Tool.get(Tool.class).delete(context, alias, SysDictionaryCache.class); Tool.get(Tool.class).delete(context, alias, SysDictionaryCache.class);
} }
......
...@@ -734,11 +734,7 @@ public class WindPredictionFutureService { ...@@ -734,11 +734,7 @@ public class WindPredictionFutureService {
for (DateTime dateTime : rangeToList) { for (DateTime dateTime : rangeToList) {
output = new GetWindPredictionFutureOutput(); output = new GetWindPredictionFutureOutput();
//时间偏移 //时间偏移
if (betweenDay != 0) { dataDate = dateTime;
dataDate = DateUtil.offsetDay(dateTime, betweenDay);
} else {
dataDate = dateTime;
}
output.setDataTime(dataDate); output.setDataTime(dataDate);
//匹配预测发电量 //匹配预测发电量
if (predictedMap.containsKey(dataDate)) { if (predictedMap.containsKey(dataDate)) {
......
...@@ -927,14 +927,14 @@ public class SpaceOptimizeBaseService { ...@@ -927,14 +927,14 @@ public class SpaceOptimizeBaseService {
case "1": case "1":
this.gridConnectedOptimization(context, wellheadDTOList, durationDTOList, unOptimizeDurationList, this.gridConnectedOptimization(context, wellheadDTOList, durationDTOList, unOptimizeDurationList,
relation.getWellheadsByInstitutionIdIdMap().get(detail.getId()), detail, monthNum, periodId, relation.getWellheadsByInstitutionIdIdMap().get(detail.getId()), detail, monthNum, periodId,
powerInput, offset > 1 ? startDate : optimizeDate powerInput, startDate
); );
break; break;
//离网型优化 //离网型优化
case "0": case "0":
this.offGridOptimization(context, wellheadDTOList, durationDTOList, unOptimizeDurationList, this.offGridOptimization(context, wellheadDTOList, durationDTOList, unOptimizeDurationList,
relation.getWellheadsByInstitutionIdIdMap().get(detail.getId()), relation.getStorageAvgMap(), detail, periodId, relation.getWellheadsByInstitutionIdIdMap().get(detail.getId()), relation.getStorageAvgMap(), detail, periodId,
powerInput, offset > 1 ? startDate : optimizeDate powerInput, startDate
); );
break; break;
default: default:
......
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>gf_back</artifactId>
<groupId>gf</groupId>
<version>1.0.0-pps</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>D01-dependency</artifactId>
<version>1.0.0-pps</version>
<packaging>pom</packaging>
<modules>
<module>pps-dependency-all</module>
</modules>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<groupId>gf</groupId>
<modelVersion>4.0.0</modelVersion>
<artifactId>pps-dependency-all</artifactId>
<version>1.0.0-pps</version>
<packaging>jar</packaging>
<properties>
<pps.version>1.0.0-pps</pps.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>gf</groupId>
<artifactId>pps-common</artifactId>
<version>${pps.version}</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>central</id>
<name>aliyun maven</name>
<url>https://maven.aliyun.com/repository/public/</url>
<layout>default</layout>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>xstartup-hz</id>
<url>http://dev.sunboxauto.com/HZ/_packaging/xstartup-hz/maven/v1</url>
<releases>
<enabled>true</enabled>
</releases>
</repository>
</repositories>
</project>
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
<module>C00-common</module> <module>C00-common</module>
<module>C02-system</module> <module>C02-system</module>
<module>C10-task</module> <module>C10-task</module>
<module>D01-dependency</module>
<module>C09-base</module> <module>C09-base</module>
<module>C11-space</module> <module>C11-space</module>
<module>C12-prediction</module> <module>C12-prediction</module>
......
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