|
@@ -18,6 +18,7 @@ import com.energy.manage.service.mappers.windfieldbatch.WindFieldBatchMapper;
|
|
|
import com.energy.manage.service.property.analysis.AlgorithmProperties;
|
|
import com.energy.manage.service.property.analysis.AlgorithmProperties;
|
|
|
import com.energy.manage.service.service.analysis.AnalysisService;
|
|
import com.energy.manage.service.service.analysis.AnalysisService;
|
|
|
import com.energy.manage.service.util.BeanMapUtils;
|
|
import com.energy.manage.service.util.BeanMapUtils;
|
|
|
|
|
+import com.energy.manage.service.util.NetUtils;
|
|
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
|
import com.fasterxml.jackson.databind.JsonNode;
|
|
import com.fasterxml.jackson.databind.JsonNode;
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
@@ -32,8 +33,12 @@ import org.springframework.stereotype.Service;
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
|
import java.lang.reflect.Field;
|
|
import java.lang.reflect.Field;
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
|
|
|
+import java.net.URI;
|
|
|
|
|
+import java.net.URISyntaxException;
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
|
|
|
+import java.util.regex.Matcher;
|
|
|
|
|
+import java.util.regex.Pattern;
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -85,6 +90,12 @@ public class AnalysisServiceImpl implements AnalysisService {
|
|
|
*/
|
|
*/
|
|
|
private static final String OPTION_CONTENT = "手动分析";
|
|
private static final String OPTION_CONTENT = "手动分析";
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 分析文件前缀
|
|
|
|
|
+ */
|
|
|
|
|
+ private static final String FILE_ADDR_FREFIX = "http://";
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
private static ObjectMapper mapper = new ObjectMapper();
|
|
private static ObjectMapper mapper = new ObjectMapper();
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -113,6 +124,8 @@ public class AnalysisServiceImpl implements AnalysisService {
|
|
|
if(analysisDto.getAutoOrManual().equalsIgnoreCase(AnalysisConstants.MANUAL_ANALYSIS)){
|
|
if(analysisDto.getAutoOrManual().equalsIgnoreCase(AnalysisConstants.MANUAL_ANALYSIS)){
|
|
|
transferAnalysisFlagByCode(analysisDto);
|
|
transferAnalysisFlagByCode(analysisDto);
|
|
|
}
|
|
}
|
|
|
|
|
+ //当有功功率没有设置的话 设置默认值 整个风场最大额定功率*1.2
|
|
|
|
|
+ setActivePower(analysisDto);
|
|
|
//将配置文件中的算法json转换为对象
|
|
//将配置文件中的算法json转换为对象
|
|
|
JsonNode rootNode = mapper.readTree(algorithmProperties.getAnalysisAlgorithmJson());
|
|
JsonNode rootNode = mapper.readTree(algorithmProperties.getAnalysisAlgorithmJson());
|
|
|
//将入参analysisDto转换为算法标准json
|
|
//将入参analysisDto转换为算法标准json
|
|
@@ -154,7 +167,7 @@ public class AnalysisServiceImpl implements AnalysisService {
|
|
|
* @return
|
|
* @return
|
|
|
*/
|
|
*/
|
|
|
@Override
|
|
@Override
|
|
|
- public List<AnalysisDetailVo> analysisDetail(String batchCode, String analysisTypeCode, String fieldEngineCode) {
|
|
|
|
|
|
|
+ public List<AnalysisDetailVo> analysisDetail(String batchCode, String analysisTypeCode, String fieldEngineCode, boolean isIntranet) {
|
|
|
List<AnalysisDetailVo> analysisDetailVos = new ArrayList<>();
|
|
List<AnalysisDetailVo> analysisDetailVos = new ArrayList<>();
|
|
|
//获取所有的分析类型
|
|
//获取所有的分析类型
|
|
|
List<AnalysisTypeVo> analysisTypeVos = analysisTypeMapper.selectByTypeCode(analysisTypeCode);
|
|
List<AnalysisTypeVo> analysisTypeVos = analysisTypeMapper.selectByTypeCode(analysisTypeCode);
|
|
@@ -162,9 +175,9 @@ public class AnalysisServiceImpl implements AnalysisService {
|
|
|
return analysisDetailVos;
|
|
return analysisDetailVos;
|
|
|
}
|
|
}
|
|
|
//最新总文件
|
|
//最新总文件
|
|
|
- List<AnalysisGeneralFileVo> newGeneralFileVos = getNewGeneralFiles(batchCode,analysisTypeCode);
|
|
|
|
|
|
|
+ List<AnalysisGeneralFileVo> newGeneralFileVos = getNewGeneralFiles(batchCode,analysisTypeCode,isIntranet);
|
|
|
//获取最新分文件
|
|
//获取最新分文件
|
|
|
- List<AnalysisDiagramRelationVo> newDiagramRelationVos = getNewDiagramRelations(batchCode, analysisTypeCode, fieldEngineCode);
|
|
|
|
|
|
|
+ List<AnalysisDiagramRelationVo> newDiagramRelationVos = getNewDiagramRelations(batchCode, analysisTypeCode, fieldEngineCode,isIntranet);
|
|
|
//查询评论
|
|
//查询评论
|
|
|
List<AnalysisCommentDescriptionVo> commentDescriptionVos = commentDescriptionMapper.selecByBatchCodeAndAnalysisTypeCode(batchCode,analysisTypeCode);
|
|
List<AnalysisCommentDescriptionVo> commentDescriptionVos = commentDescriptionMapper.selecByBatchCodeAndAnalysisTypeCode(batchCode,analysisTypeCode);
|
|
|
//根据分析类型设置分析结果
|
|
//根据分析类型设置分析结果
|
|
@@ -228,8 +241,12 @@ public class AnalysisServiceImpl implements AnalysisService {
|
|
|
* @param analysisTypeCode
|
|
* @param analysisTypeCode
|
|
|
* @return
|
|
* @return
|
|
|
*/
|
|
*/
|
|
|
- private List<AnalysisGeneralFileVo> getNewGeneralFiles(String batchCode,String analysisTypeCode){
|
|
|
|
|
|
|
+ private List<AnalysisGeneralFileVo> getNewGeneralFiles(String batchCode,String analysisTypeCode, boolean isIntranet){
|
|
|
|
|
+ //从数据库获取当前批次、当前分析类型的所有的分析总文件
|
|
|
List<AnalysisGeneralFileVo> generalFileVos = generalFileMapper.selectByCondition(batchCode,analysisTypeCode);
|
|
List<AnalysisGeneralFileVo> generalFileVos = generalFileMapper.selectByCondition(batchCode,analysisTypeCode);
|
|
|
|
|
+ //为每个文件赋值前缀
|
|
|
|
|
+ generalFileVos.forEach(item -> item.setFileAddr(getFilePath(isIntranet,item.getFileAddr())));
|
|
|
|
|
+ //根据创建时间排序
|
|
|
generalFileVos.sort(Comparator.comparing(AnalysisGeneralFileVo::getCreateTime,Comparator.reverseOrder()));
|
|
generalFileVos.sort(Comparator.comparing(AnalysisGeneralFileVo::getCreateTime,Comparator.reverseOrder()));
|
|
|
//删除地址相同的文件
|
|
//删除地址相同的文件
|
|
|
return generalFileVos.stream().collect(Collectors.collectingAndThen(
|
|
return generalFileVos.stream().collect(Collectors.collectingAndThen(
|
|
@@ -245,11 +262,13 @@ public class AnalysisServiceImpl implements AnalysisService {
|
|
|
* @param fieldEngineCode
|
|
* @param fieldEngineCode
|
|
|
* @return
|
|
* @return
|
|
|
*/
|
|
*/
|
|
|
- private List<AnalysisDiagramRelationVo> getNewDiagramRelations(String batchCode,String analysisTypeCode,String fieldEngineCode){
|
|
|
|
|
|
|
+ private List<AnalysisDiagramRelationVo> getNewDiagramRelations(String batchCode,String analysisTypeCode,String fieldEngineCode, boolean intranet){
|
|
|
|
|
+ //获取当前批次、当前分析类型的所有分析结果文件
|
|
|
List<AnalysisDiagramRelationVo> diagramRelationVos = diagramRelationMapper.selectByCondition(batchCode,analysisTypeCode,fieldEngineCode);
|
|
List<AnalysisDiagramRelationVo> diagramRelationVos = diagramRelationMapper.selectByCondition(batchCode,analysisTypeCode,fieldEngineCode);
|
|
|
if(CollectionUtils.isEmpty(diagramRelationVos)){
|
|
if(CollectionUtils.isEmpty(diagramRelationVos)){
|
|
|
return diagramRelationVos;
|
|
return diagramRelationVos;
|
|
|
}
|
|
}
|
|
|
|
|
+ diagramRelationVos.forEach(item -> item.setFileAddr(getFilePath(intranet,item.getFileAddr())));
|
|
|
//如果风机编号不为空的话则不对风机编号进行排序
|
|
//如果风机编号不为空的话则不对风机编号进行排序
|
|
|
if (StringUtils.isNotBlank(fieldEngineCode)) {
|
|
if (StringUtils.isNotBlank(fieldEngineCode)) {
|
|
|
diagramRelationVos.sort(Comparator.comparing(AnalysisDiagramRelationVo::getCreateTime, Comparator.reverseOrder()));
|
|
diagramRelationVos.sort(Comparator.comparing(AnalysisDiagramRelationVo::getCreateTime, Comparator.reverseOrder()));
|
|
@@ -329,31 +348,6 @@ public class AnalysisServiceImpl implements AnalysisService {
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * 测试排序去重
|
|
|
|
|
- * @param args
|
|
|
|
|
- * @throws InterruptedException
|
|
|
|
|
- */
|
|
|
|
|
- public static void main(String[] args) throws InterruptedException {
|
|
|
|
|
- List<AnalysisGeneralFileVo> generalFileVos = new ArrayList<>();
|
|
|
|
|
- AnalysisGeneralFileVo a1 = new AnalysisGeneralFileVo();
|
|
|
|
|
- a1.setFileAddr("http://123/412/89.html");
|
|
|
|
|
- a1.setCreateTime(new Date());
|
|
|
|
|
- a1.setBatchCode("123");
|
|
|
|
|
- generalFileVos.add(a1);
|
|
|
|
|
- Thread.sleep(1000);
|
|
|
|
|
- AnalysisGeneralFileVo a2 = new AnalysisGeneralFileVo();
|
|
|
|
|
- a2.setFileAddr("http://123/412/89.html");
|
|
|
|
|
- a2.setCreateTime(new Date());
|
|
|
|
|
- generalFileVos.add(a2);
|
|
|
|
|
- a2.setBatchCode("453");
|
|
|
|
|
- generalFileVos.sort(Comparator.comparing(AnalysisGeneralFileVo::getCreateTime,Comparator.reverseOrder()));
|
|
|
|
|
- //删除地址相同的文件
|
|
|
|
|
- List<AnalysisGeneralFileVo> returnList = generalFileVos.stream().collect(Collectors.collectingAndThen(
|
|
|
|
|
- Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(AnalysisGeneralFileVo::getFileAddr))),
|
|
|
|
|
- ArrayList :: new));
|
|
|
|
|
- returnList.forEach(System.out::println);
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 根据属性修改json值
|
|
* 根据属性修改json值
|
|
@@ -414,13 +408,15 @@ public class AnalysisServiceImpl implements AnalysisService {
|
|
|
* @param newValue
|
|
* @param newValue
|
|
|
*/
|
|
*/
|
|
|
private void dealGraphSetsAndCustomFilter(JsonNode subNode, Object newValue){
|
|
private void dealGraphSetsAndCustomFilter(JsonNode subNode, Object newValue){
|
|
|
- List<Integer> list = (List) newValue;
|
|
|
|
|
|
|
+ List<Double> list = (List) newValue;
|
|
|
if(list.size() == 0){
|
|
if(list.size() == 0){
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
AtomicInteger index = new AtomicInteger(0);
|
|
AtomicInteger index = new AtomicInteger(0);
|
|
|
subNode.fields().forEachRemaining(entry -> {
|
|
subNode.fields().forEachRemaining(entry -> {
|
|
|
- ((ObjectNode) subNode).put(entry.getKey(), list.get(index.get()));
|
|
|
|
|
|
|
+ if(index.get() <= list.size() -1 && list.get(index.get()) != null){
|
|
|
|
|
+ ((ObjectNode) subNode).put(entry.getKey(), list.get(index.get()));
|
|
|
|
|
+ }
|
|
|
index.incrementAndGet();
|
|
index.incrementAndGet();
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
@@ -478,6 +474,46 @@ public class AnalysisServiceImpl implements AnalysisService {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
|
|
+ * 设置额定功率
|
|
|
|
|
+ * @param analysisDto
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ public void setActivePower(AnalysisDto analysisDto){
|
|
|
|
|
+ List<Double> targetList = AnalysisConstants.ACTIVITY_POWER;
|
|
|
|
|
+ List<Double> sourceList = analysisDto.getActivePower();
|
|
|
|
|
+ //替换值为空的元素
|
|
|
|
|
+ replaceNullForList(sourceList,targetList);
|
|
|
|
|
+ //当源列表长度与指定列表长度一样的话 源列表最后一个元素一定不是空,不需要替换值为最大功率*1.2
|
|
|
|
|
+ if(sourceList != null && sourceList.size() == targetList.size()){
|
|
|
|
|
+ analysisDto.setActivePower(targetList);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ String rateCapacity = getRatedCapacity(analysisDto);
|
|
|
|
|
+ if(StringUtils.isNotBlank(rateCapacity)){
|
|
|
|
|
+ //设置额定功率(风场所有风机中最大功率*1.2)
|
|
|
|
|
+ targetList.set(targetList.size() -1 ,new Double(rateCapacity));
|
|
|
|
|
+ }
|
|
|
|
|
+ analysisDto.setActivePower(targetList);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 将源列表中非空元素替换到目标列表中且下标不变
|
|
|
|
|
+ * @param sourcelist
|
|
|
|
|
+ * @param targetList
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ private <T> void replaceNullForList(List<T> sourcelist ,List<T> targetList){
|
|
|
|
|
+ if(CollectionUtils.isEmpty(sourcelist)){
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ sourcelist.stream().forEachOrdered(element -> {
|
|
|
|
|
+ if(element != null){
|
|
|
|
|
+ targetList.set(sourcelist.indexOf(element),element);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
* 获取 ratedCapacity 风机额定功率*1.2
|
|
* 获取 ratedCapacity 风机额定功率*1.2
|
|
|
* @param analysisDto
|
|
* @param analysisDto
|
|
|
* @return
|
|
* @return
|
|
@@ -487,12 +523,15 @@ public class AnalysisServiceImpl implements AnalysisService {
|
|
|
List<String> engineCodes = analysisDto.getTurbines();
|
|
List<String> engineCodes = analysisDto.getTurbines();
|
|
|
//获取风场编号
|
|
//获取风场编号
|
|
|
String fieldCode = analysisDto.getPowerFarmID();
|
|
String fieldCode = analysisDto.getPowerFarmID();
|
|
|
|
|
+ if(StringUtils.isBlank(fieldCode)){
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
//查询最大功率
|
|
//查询最大功率
|
|
|
BigDecimal ratedCapacity = windEngineGroupMapper.selectMaxRatedCapacity(fieldCode,engineCodes);
|
|
BigDecimal ratedCapacity = windEngineGroupMapper.selectMaxRatedCapacity(fieldCode,engineCodes);
|
|
|
//功率因数 1.2
|
|
//功率因数 1.2
|
|
|
BigDecimal powerFactorRated = new BigDecimal(algorithmProperties.getPowerFactorRated());
|
|
BigDecimal powerFactorRated = new BigDecimal(algorithmProperties.getPowerFactorRated());
|
|
|
//返回功率
|
|
//返回功率
|
|
|
- return ratedCapacity == null ? "0" : ratedCapacity.multiply(powerFactorRated).toString();
|
|
|
|
|
|
|
+ return ratedCapacity == null ? null : ratedCapacity.multiply(powerFactorRated).toString();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
@@ -505,4 +544,49 @@ public class AnalysisServiceImpl implements AnalysisService {
|
|
|
AnalysisServiceImpl.windFieldBatchMapper = windFieldBatchMapper;
|
|
AnalysisServiceImpl.windFieldBatchMapper = windFieldBatchMapper;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 获取分析结果文件地址前缀并替换或添加
|
|
|
|
|
+ * @param isIntranet
|
|
|
|
|
+ * @param fileAddr
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ private String getFilePath(boolean isIntranet,String fileAddr){
|
|
|
|
|
+ String minIoIpPort = isIntranet ? algorithmProperties.getAnalysisFileIntranetAddr() : algorithmProperties.getAnalysisFileExternalAddr();
|
|
|
|
|
+ if(StringUtils.startsWith(fileAddr,FILE_ADDR_FREFIX)){
|
|
|
|
|
+ return fileAddr.replace(NetUtils.getIpAndPort(fileAddr),minIoIpPort);
|
|
|
|
|
+ }
|
|
|
|
|
+ return minIoIpPort + fileAddr;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 测试排序去重
|
|
|
|
|
+ * @param args
|
|
|
|
|
+ * @throws InterruptedException
|
|
|
|
|
+ */
|
|
|
|
|
+ public static void main(String[] args) throws InterruptedException, URISyntaxException {
|
|
|
|
|
+// List<AnalysisGeneralFileVo> generalFileVos = new ArrayList<>();
|
|
|
|
|
+// AnalysisGeneralFileVo a1 = new AnalysisGeneralFileVo();
|
|
|
|
|
+// a1.setFileAddr("http://123/412/89.html");
|
|
|
|
|
+// a1.setCreateTime(new Date());
|
|
|
|
|
+// a1.setBatchCode("123");
|
|
|
|
|
+// generalFileVos.add(a1);
|
|
|
|
|
+// Thread.sleep(1000);
|
|
|
|
|
+// AnalysisGeneralFileVo a2 = new AnalysisGeneralFileVo();
|
|
|
|
|
+// a2.setFileAddr("http://123/412/89.html");
|
|
|
|
|
+// a2.setCreateTime(new Date());
|
|
|
|
|
+// generalFileVos.add(a2);
|
|
|
|
|
+// a2.setBatchCode("453");
|
|
|
|
|
+// generalFileVos.sort(Comparator.comparing(AnalysisGeneralFileVo::getCreateTime,Comparator.reverseOrder()));
|
|
|
|
|
+// //删除地址相同的文件
|
|
|
|
|
+// List<AnalysisGeneralFileVo> returnList = generalFileVos.stream().collect(Collectors.collectingAndThen(
|
|
|
|
|
+// Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(AnalysisGeneralFileVo::getFileAddr))),
|
|
|
|
|
+// ArrayList :: new));
|
|
|
|
|
+// returnList.forEach(System.out::println);
|
|
|
|
|
+ List<String> list = new ArrayList<>();
|
|
|
|
|
+ list.add("1");
|
|
|
|
|
+ list.add(0,"2");
|
|
|
|
|
+ System.out.println(list);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|