|
|
@@ -124,6 +124,8 @@ public class AnalysisServiceImpl implements AnalysisService {
|
|
|
if(analysisDto.getAutoOrManual().equalsIgnoreCase(AnalysisConstants.MANUAL_ANALYSIS)){
|
|
|
transferAnalysisFlagByCode(analysisDto);
|
|
|
}
|
|
|
+ //当有功功率没有设置的话 设置默认值 整个风场最大额定功率*1.2
|
|
|
+ setActivePower(analysisDto);
|
|
|
//将配置文件中的算法json转换为对象
|
|
|
JsonNode rootNode = mapper.readTree(algorithmProperties.getAnalysisAlgorithmJson());
|
|
|
//将入参analysisDto转换为算法标准json
|
|
|
@@ -406,13 +408,15 @@ public class AnalysisServiceImpl implements AnalysisService {
|
|
|
* @param newValue
|
|
|
*/
|
|
|
private void dealGraphSetsAndCustomFilter(JsonNode subNode, Object newValue){
|
|
|
- List<Integer> list = (List) newValue;
|
|
|
+ List<Double> list = (List) newValue;
|
|
|
if(list.size() == 0){
|
|
|
return;
|
|
|
}
|
|
|
AtomicInteger index = new AtomicInteger(0);
|
|
|
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();
|
|
|
});
|
|
|
}
|
|
|
@@ -470,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
|
|
|
* @param analysisDto
|
|
|
* @return
|
|
|
@@ -479,12 +523,15 @@ public class AnalysisServiceImpl implements AnalysisService {
|
|
|
List<String> engineCodes = analysisDto.getTurbines();
|
|
|
//获取风场编号
|
|
|
String fieldCode = analysisDto.getPowerFarmID();
|
|
|
+ if(StringUtils.isBlank(fieldCode)){
|
|
|
+ return null;
|
|
|
+ }
|
|
|
//查询最大功率
|
|
|
BigDecimal ratedCapacity = windEngineGroupMapper.selectMaxRatedCapacity(fieldCode,engineCodes);
|
|
|
//功率因数 1.2
|
|
|
BigDecimal powerFactorRated = new BigDecimal(algorithmProperties.getPowerFactorRated());
|
|
|
//返回功率
|
|
|
- return ratedCapacity == null ? "0" : ratedCapacity.multiply(powerFactorRated).toString();
|
|
|
+ return ratedCapacity == null ? null : ratedCapacity.multiply(powerFactorRated).toString();
|
|
|
}
|
|
|
|
|
|
@Autowired
|
|
|
@@ -518,24 +565,28 @@ public class AnalysisServiceImpl implements AnalysisService {
|
|
|
* @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<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);
|
|
|
}
|
|
|
|
|
|
}
|