|
@@ -29,6 +29,7 @@ import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import javax.annotation.Resource;
|
|
|
import java.lang.reflect.Field;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.*;
|
|
@@ -70,6 +71,9 @@ public class AnalysisServiceImpl implements AnalysisService {
|
|
|
@Autowired
|
|
|
private WindEngineGroupMapper windEngineGroupMapper;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private AlgorithmProperties algorithmProperties;
|
|
|
+
|
|
|
|
|
|
private static AnalysisOptionRecordsMapper optionRecordsMapper;
|
|
|
|
|
@@ -110,13 +114,13 @@ public class AnalysisServiceImpl implements AnalysisService {
|
|
|
transferAnalysisFlagByCode(analysisDto);
|
|
|
}
|
|
|
//将配置文件中的算法json转换为对象
|
|
|
- JsonNode rootNode = mapper.readTree(AlgorithmProperties.analysisJson);
|
|
|
+ JsonNode rootNode = mapper.readTree(algorithmProperties.getAnalysisAlgorithmJson());
|
|
|
//将入参analysisDto转换为算法标准json
|
|
|
dataProccess(analysisDto,rootNode);
|
|
|
log.info("调用分析算法之前,将入参analysisDto转换为算法标准json = {}" , mapper.writeValueAsString(rootNode));
|
|
|
System.out.println("json入参:" + rootNode.toString());
|
|
|
//调用算法
|
|
|
- String result = HttpUtils.doPost(AlgorithmProperties.analysisUrl,mapper.writeValueAsString(rootNode));
|
|
|
+ String result = HttpUtils.doPost(algorithmProperties.getAnalysisUrl(),mapper.writeValueAsString(rootNode));
|
|
|
log.info("调用算法分析返回结果:{}",result);
|
|
|
//手动操作进行操作记录添加
|
|
|
if(analysisDto.getAutoOrManual().equals(AnalysisConstants.MANUAL_ANALYSIS)){
|
|
@@ -364,9 +368,9 @@ public class AnalysisServiceImpl implements AnalysisService {
|
|
|
// 匹配到属性名称,进行值的修改
|
|
|
if (entry.getKey().equalsIgnoreCase(propertyName)) {
|
|
|
//判断当前节点有没有子节点 排除分析节点
|
|
|
- if(!entry.getValue().fields().hasNext() && !propertyName.equalsIgnoreCase(AlgorithmProperties.configAnalysisProperties)){
|
|
|
+ if(!entry.getValue().fields().hasNext() && !propertyName.equalsIgnoreCase(algorithmProperties.getConfigAnalysisProperties())){
|
|
|
//数组属性得特殊处理
|
|
|
- if(AlgorithmProperties.arrayProperties.contains(propertyName)){
|
|
|
+ if(algorithmProperties.getAnalysisArrayProperties().contains(propertyName)){
|
|
|
ArrayNode arrayNode = mapper.createArrayNode();
|
|
|
((List<String>)newValue).stream().forEach(item-> arrayNode.add(item));
|
|
|
((ObjectNode) parentNode).set(propertyName,arrayNode);
|
|
@@ -392,13 +396,13 @@ public class AnalysisServiceImpl implements AnalysisService {
|
|
|
*/
|
|
|
private void assignmentByPropertyName(JsonNode subNode, String propertyName, Object newValue,String scada){
|
|
|
//scada数据筛选过滤 、图像设置特殊处理
|
|
|
- if(AlgorithmProperties.graphSetsProperties.contains(propertyName)
|
|
|
- || AlgorithmProperties.customFilterProperties.contains(propertyName)){
|
|
|
+ if(algorithmProperties.getGraphSetsProperties().contains(propertyName)
|
|
|
+ || algorithmProperties.getCustomFilterProperties().contains(propertyName)){
|
|
|
dealGraphSetsAndCustomFilter(subNode, newValue);
|
|
|
return ;
|
|
|
}
|
|
|
//分析类型特殊处理
|
|
|
- if(AlgorithmProperties.configAnalysisProperties.equals(propertyName)){
|
|
|
+ if(algorithmProperties.getConfigAnalysisProperties().equals(propertyName)){
|
|
|
dealConfigAnalysis(subNode, newValue,scada);
|
|
|
return;
|
|
|
}
|
|
@@ -431,7 +435,7 @@ public class AnalysisServiceImpl implements AnalysisService {
|
|
|
ArrayNode arrayNode = (ArrayNode) subNode;
|
|
|
List<String> analysisTypes = (List) newValue;
|
|
|
for(int i = 0 ; i < analysisTypes.size() ; i++){
|
|
|
- JsonNode childNode = mapper.readTree(AlgorithmProperties.configAnalysisJson);
|
|
|
+ JsonNode childNode = mapper.readTree(algorithmProperties.getAnalysisTypeJson());
|
|
|
//分析类型解析
|
|
|
String[] types = analysisTypes.get(i).split("\\|");
|
|
|
AtomicInteger index = new AtomicInteger(0);
|
|
@@ -486,7 +490,7 @@ public class AnalysisServiceImpl implements AnalysisService {
|
|
|
//查询最大功率
|
|
|
BigDecimal ratedCapacity = windEngineGroupMapper.selectMaxRatedCapacity(fieldCode,engineCodes);
|
|
|
//功率因数 1.2
|
|
|
- BigDecimal powerFactorRated = new BigDecimal(AlgorithmProperties.powerFactorRated);
|
|
|
+ BigDecimal powerFactorRated = new BigDecimal(algorithmProperties.getPowerFactorRated());
|
|
|
//返回功率
|
|
|
return ratedCapacity == null ? "0" : ratedCapacity.multiply(powerFactorRated).toString();
|
|
|
}
|