|
|
@@ -2,7 +2,6 @@ package com.energy.manage.service.service.analysis.impl;
|
|
|
|
|
|
import cn.hutool.core.io.FileUtil;
|
|
|
import cn.hutool.core.util.ZipUtil;
|
|
|
-import cn.hutool.db.PageResult;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.energy.manage.common.base.Page;
|
|
|
import com.energy.manage.common.constant.redis.ManagerRedisKeyConstant;
|
|
|
@@ -10,6 +9,8 @@ import com.energy.manage.common.enums.IdPrefixEnum;
|
|
|
import com.energy.manage.common.po.analysis.AnalysisOptionRecordsPo;
|
|
|
import com.energy.manage.common.po.analysis.AnalysisResultPo;
|
|
|
import com.energy.manage.common.po.analysis.AnalysisTypePo;
|
|
|
+import com.energy.manage.common.po.analysisdatarelationrecords.AnalysisDataRelationRecordsPo;
|
|
|
+import com.energy.manage.common.po.analysispriorityrecords.AnalysisPriorityRecordsPo;
|
|
|
import com.energy.manage.common.po.windfield.WindFieldPO;
|
|
|
import com.energy.manage.common.reponse.ConstVar;
|
|
|
import com.energy.manage.common.reponse.ResultResp;
|
|
|
@@ -21,16 +22,19 @@ import com.energy.manage.service.domain.dto.analysis.AnalysisDto;
|
|
|
import com.energy.manage.service.domain.dto.analysis.AnalysisResultDto;
|
|
|
import com.energy.manage.service.domain.vo.analysis.*;
|
|
|
import com.energy.manage.service.domain.vo.cockpit.CompanyFieldAndBatchTreeVo;
|
|
|
+import com.energy.manage.service.domain.vo.datatransfer.DataTransferTypeVo;
|
|
|
import com.energy.manage.service.domain.vo.system.SysOrganizationAuthVo;
|
|
|
import com.energy.manage.service.domain.vo.windenginegroup.WindEngineGroupPageVo;
|
|
|
import com.energy.manage.service.domain.vo.windenginegroup.WindEngineGroupShortVo;
|
|
|
import com.energy.manage.service.domain.vo.windenginegroup.WindEngineGroupVo;
|
|
|
import com.energy.manage.service.domain.vo.windfield.WindFieldDescriptVo;
|
|
|
import com.energy.manage.service.domain.vo.windfield.WindFieldVo;
|
|
|
-import com.energy.manage.service.domain.vo.windfieldbatch.WindFieldBatchVo;
|
|
|
import com.energy.manage.service.filter.LoginUser;
|
|
|
import com.energy.manage.service.filter.LoginUserContextHolder;
|
|
|
import com.energy.manage.service.mappers.analysis.*;
|
|
|
+import com.energy.manage.service.mappers.analysisdatarelationrecords.AnalysisDataRelationRecordsMapper;
|
|
|
+import com.energy.manage.service.mappers.analysispriorityrecords.AnalysisPriorityRecordsMapper;
|
|
|
+import com.energy.manage.service.mappers.datatransfertype.DataTransferTypeMapper;
|
|
|
import com.energy.manage.service.mappers.system.SysOrganizationAuthMapper;
|
|
|
import com.energy.manage.service.mappers.system.SysUserInfoMapper;
|
|
|
import com.energy.manage.service.mappers.windenginegroup.WindEngineGroupMapper;
|
|
|
@@ -121,6 +125,15 @@ public class AnalysisServiceImpl implements AnalysisService {
|
|
|
private WindFieldMapper windFieldMapper;
|
|
|
|
|
|
@Autowired
|
|
|
+ private AnalysisPriorityRecordsMapper priorityRecordsMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private AnalysisDataRelationRecordsMapper dataRelationRecordsMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private DataTransferTypeMapper dataTransferTypeMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
private AlgorithmProperties algorithmProperties;
|
|
|
|
|
|
@Autowired
|
|
|
@@ -147,11 +160,6 @@ public class AnalysisServiceImpl implements AnalysisService {
|
|
|
private static final String OPTION_CONTENT = "手动分析";
|
|
|
|
|
|
/**
|
|
|
- * 分析文件前缀
|
|
|
- */
|
|
|
- private static final String FILE_ADDR_FREFIX = "http://";
|
|
|
-
|
|
|
- /**
|
|
|
* 分析编号分隔符
|
|
|
*/
|
|
|
private final static String SEPARATOR = "-";
|
|
|
@@ -181,15 +189,68 @@ public class AnalysisServiceImpl implements AnalysisService {
|
|
|
/**
|
|
|
* 分析结果列表
|
|
|
* @param analysisResultDto
|
|
|
+ * @param isIntranet
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
- public List<AnalysisResultVo> analysisResultList(AnalysisResultDto analysisResultDto) {
|
|
|
+ public List<AnalysisResultVo> analysisResultList(AnalysisResultDto analysisResultDto, Boolean isIntranet) {
|
|
|
+ List<DataTransferTypeVo> transferTypeVos = dataTransferTypeMapper.selectAllInfo();
|
|
|
List<AnalysisResultVo> resultVos = analysisResultMapper.selectByCondition(analysisResultDto);
|
|
|
- resultVos.stream().forEach(item -> item.setReportVos(resultReportMapper.selectByBatchCode(item.getBatchCode())));
|
|
|
+ List<AnalysisPriorityRecordsPo> priorityRecords = priorityRecordsMapper.queryAllPriority();
|
|
|
+ resultVos.stream().forEach(item -> {
|
|
|
+ //设置数据类型名称
|
|
|
+ setDataTypeName(item,transferTypeVos);
|
|
|
+ if(CollectionUtils.isNotEmpty(priorityRecords)){
|
|
|
+ setOrderNum(item,priorityRecords);
|
|
|
+ }
|
|
|
+ //设置报告
|
|
|
+ item.setReportVos(setReportAddress(resultReportMapper.selectByBatchCode(item.getBatchCode()),isIntranet));
|
|
|
+ });
|
|
|
return resultVos;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 设置数据类型名称
|
|
|
+ * @param analysisResultVo
|
|
|
+ * @param transferTypeVos
|
|
|
+ */
|
|
|
+ private void setDataTypeName(AnalysisResultVo analysisResultVo, List<DataTransferTypeVo> transferTypeVos) {
|
|
|
+ if(StringUtils.isBlank(analysisResultVo.getDataTypeCode())){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ Map<String,String> typeMap = transferTypeVos.stream().collect(Collectors.toMap(DataTransferTypeVo::getTransferType, DataTransferTypeVo::getTransferTypeName));
|
|
|
+ List<String> dataTypeCodes = Arrays.asList(analysisResultVo.getDataTypeCode().split(","));
|
|
|
+ List<String> dataTypeNames = dataTypeCodes.stream().map(typeCode -> typeMap.get(typeCode)).collect(Collectors.toList());
|
|
|
+ analysisResultVo.setDataTypeName(dataTypeNames.stream().collect(Collectors.joining(",")));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 设置排队中的任务排队序号
|
|
|
+ * @param analysisResultVo
|
|
|
+ */
|
|
|
+ private void setOrderNum(AnalysisResultVo analysisResultVo, List<AnalysisPriorityRecordsPo> priorityRecords) {
|
|
|
+ priorityRecords.stream().forEach(item -> {
|
|
|
+ if(item.getBatchCode().equals(analysisResultVo.getBatchCode())){
|
|
|
+ String currentOrderNum = analysisResultVo.getOrderNum();
|
|
|
+ String newOrderNum = String.valueOf(priorityRecords.indexOf(item) + 1);
|
|
|
+ String orderNum = StringUtils.isBlank(currentOrderNum) ? newOrderNum : currentOrderNum + "," + newOrderNum;
|
|
|
+ analysisResultVo.setOrderNum(orderNum);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 设置报告地址
|
|
|
+ * @param reportVos
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private List<AnalysisResultReportVo> setReportAddress(List<AnalysisResultReportVo> reportVos, Boolean isIntranet) {
|
|
|
+ if(CollectionUtils.isNotEmpty(reportVos)){
|
|
|
+ reportVos.stream().forEach(item -> item.setReportAddr(NetUtils.getFilePath(isIntranet,item.getReportAddr())));
|
|
|
+ }
|
|
|
+ return reportVos;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public Page<WindFieldPO> analysisResulFieldList(AnalysisResultDto analysisResultDto){
|
|
|
int pageNum = analysisResultDto.getPageNum();
|
|
|
@@ -241,38 +302,119 @@ 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
|
|
|
- dataProccess(analysisDto,rootNode);
|
|
|
- log.info("调用分析算法之前,将入参analysisDto转换为算法标准json = {}" , mapper.writeValueAsString(rootNode));
|
|
|
- System.out.println("json入参:" + rootNode.toString());
|
|
|
- //调用算法
|
|
|
- String result = HttpUtils.doPost(algorithmProperties.getAnalysisUrl(),mapper.writeValueAsString(rootNode));
|
|
|
- log.info("调用算法分析返回结果:{}",result);
|
|
|
- //调用分析算法接口后更新数据筛选记录
|
|
|
- updateAnalysisByBatchCode(analysisDto);
|
|
|
- //手动操作进行操作记录添加
|
|
|
- if(analysisDto.getAutoOrManual().equals(AnalysisConstants.MANUAL_ANALYSIS)){
|
|
|
- addOptionRecords(analysisDto.getPowerFarmID(),null,OPTION_CONTENT);
|
|
|
+ //当有功功率没有设置的话 设置默认值 整个风场最大额定功率*1.2 (图像设计移动到前端了,废弃)
|
|
|
+// setActivePower(analysisDto);
|
|
|
+ //查询分析中或者排队中的数量
|
|
|
+ int analysingCount = analysisResultMapper.selectAnalysisingCount();
|
|
|
+ if(analysingCount > 0){
|
|
|
+ String taskId = UUIDUtil.getShortUUIDLowCase();
|
|
|
+ //排队
|
|
|
+ addPriorityRecord(analysisDto.getDataBatchNum(), taskId);
|
|
|
+ //保存请求参数
|
|
|
+ addDataRelationRecord(analysisDto,taskId);
|
|
|
+ //更新任务状态为排队中
|
|
|
+ analysisResultMapper.updateAnalysisState(analysisDto.getDataBatchNum());
|
|
|
+ }else{
|
|
|
+ //调用算法逻辑(排队逻辑)
|
|
|
+ callAnalysis(analysisDto);
|
|
|
}
|
|
|
return ResultResp.SUCCESS();
|
|
|
- } catch (JsonProcessingException e) {
|
|
|
+ } catch (Exception e) {
|
|
|
log.error("批次号 = {} 手动分析异常",analysisDto.getDataBatchNum(),e);
|
|
|
return ResultResp.FAIL();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 将任务添加到优先级记录表
|
|
|
+ * @param batchCode
|
|
|
+ */
|
|
|
+ private void addPriorityRecord(String batchCode,String taskId) {
|
|
|
+ AnalysisPriorityRecordsPo priorityRecordsPo = new AnalysisPriorityRecordsPo()
|
|
|
+ .setBatchCode(batchCode)
|
|
|
+ .setTaskId(taskId);
|
|
|
+ priorityRecordsMapper.insertSelective(priorityRecordsPo);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 将任务参数传入参数数据表
|
|
|
+ * @param analysisDto
|
|
|
+ */
|
|
|
+ private void addDataRelationRecord(AnalysisDto analysisDto,String taskId) {
|
|
|
+ AnalysisDataRelationRecordsPo relationRecordsPo = new AnalysisDataRelationRecordsPo();
|
|
|
+ BeanUtils.copyProperties(analysisDto,relationRecordsPo);
|
|
|
+ //设置分析类型
|
|
|
+ relationRecordsPo.setConfigAnalysis(analysisDto.getConfigAnalysis().stream().collect(Collectors.joining(",")));
|
|
|
+ //设置风机
|
|
|
+ if(CollectionUtils.isNotEmpty(analysisDto.getTurbines())){
|
|
|
+ relationRecordsPo.setTurbines(analysisDto.getTurbines().stream().collect(Collectors.joining(",")));
|
|
|
+ }
|
|
|
+ //设置排除月份
|
|
|
+ if(CollectionUtils.isNotEmpty(analysisDto.getExcludingMonths())) {
|
|
|
+ relationRecordsPo.setExcludingMonths(analysisDto.getExcludingMonths().stream().collect(Collectors.joining(",")));
|
|
|
+ }
|
|
|
+ //设置有功功率
|
|
|
+ if(CollectionUtils.isNotEmpty(analysisDto.getValueActivePower())) {
|
|
|
+ relationRecordsPo.setValueActivePower(analysisDto.getValueActivePower().stream().map(Object::toString).collect(Collectors.joining(",")));
|
|
|
+ }
|
|
|
+ //设置风机转速
|
|
|
+ if(CollectionUtils.isNotEmpty(analysisDto.getValueGeneratorSpeed())) {
|
|
|
+ relationRecordsPo.setValueGeneratorSpeed(analysisDto.getValueGeneratorSpeed().stream().map(Object::toString).collect(Collectors.joining(",")));
|
|
|
+ }
|
|
|
+ //设置桨距角
|
|
|
+ if(CollectionUtils.isNotEmpty(analysisDto.getValuePitchAngle())) {
|
|
|
+ relationRecordsPo.setValuePitchAngle(analysisDto.getValuePitchAngle().stream().map(Object::toString).collect(Collectors.joining(",")));
|
|
|
+ }
|
|
|
+ //设置风速
|
|
|
+ if(CollectionUtils.isNotEmpty(analysisDto.getValueWindSpeed())) {
|
|
|
+ relationRecordsPo.setValueWindSpeed(analysisDto.getValueWindSpeed().stream().map(Object::toString).collect(Collectors.joining(",")));
|
|
|
+ }
|
|
|
+ relationRecordsPo.setTaskId(taskId);
|
|
|
+ dataRelationRecordsMapper.insertSelective(relationRecordsPo);
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 调用算法
|
|
|
+ * @param analysisDto
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public void callAnalysis(AnalysisDto analysisDto) throws Exception{
|
|
|
+ //将配置文件中的算法json转换为对象
|
|
|
+ JsonNode rootNode = mapper.readTree(algorithmProperties.getAnalysisAlgorithmJson());
|
|
|
+ //将入参analysisDto转换为算法标准json
|
|
|
+ dataProccess(analysisDto,rootNode);
|
|
|
+ log.info("调用分析算法之前,将入参analysisDto转换为算法标准json = {}" , mapper.writeValueAsString(rootNode));
|
|
|
+ //调用算法
|
|
|
+ String result = HttpUtils.doPost(algorithmProperties.getAnalysisUrl(),mapper.writeValueAsString(rootNode));
|
|
|
+ log.info("调用算法分析返回结果:{}",result);
|
|
|
+ //调用分析算法接口后更新数据筛选记录
|
|
|
+ updateAnalysisByBatchCode(analysisDto);
|
|
|
+ //手动操作进行操作记录添加
|
|
|
+ if(analysisDto.getAutoOrManual().equals(AnalysisConstants.MANUAL_ANALYSIS)){
|
|
|
+ addOptionRecords(analysisDto.getPowerFarmID(),null,OPTION_CONTENT);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
* 更新数据筛选记录
|
|
|
* @param analysisDto
|
|
|
*/
|
|
|
- public void updateAnalysisByBatchCode(AnalysisDto analysisDto){
|
|
|
+ private void updateAnalysisByBatchCode(AnalysisDto analysisDto){
|
|
|
+ //多数据源拼接
|
|
|
+ Set<String> dataTypeCode = analysisDto.getConfigAnalysis().stream().map(item -> getLastStr(item)).collect(Collectors.toSet());
|
|
|
+ analysisDto.setScada(dataTypeCode.stream().collect(Collectors.joining(",")));
|
|
|
analysisResultMapper.updateByBatchCode(analysisDto);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 获取最后一个字符串
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private String getLastStr(String str){
|
|
|
+ String[] strings = str.split("\\|");
|
|
|
+ return strings[strings.length-1];
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 分析编辑查询(查询分析类型、风机组)
|
|
|
@@ -292,17 +434,15 @@ public class AnalysisServiceImpl implements AnalysisService {
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
- public Set<AnalysisTypeShortVo> queryAnalysisedType(String batchCode){
|
|
|
- Set<AnalysisTypeShortVo> analysisTypeSet = new HashSet<>();
|
|
|
+ public List<Map<String, Object>> queryAnalysisedType(String batchCode){
|
|
|
+ Set<String> analysisCodes = new HashSet<>();
|
|
|
//总图分析类型
|
|
|
List<AnalysisGeneralFileVo> generalFileVos = generalFileMapper.selectByBatchCode(batchCode);
|
|
|
- generalFileVos.stream().forEach(item -> analysisTypeSet.add(new AnalysisTypeShortVo().setAnalysisTypeCode(item.getAnalysisTypeCode())
|
|
|
- .setAnalysisTypeName(item.getAnalysisTypeName())));
|
|
|
+ generalFileVos.stream().forEach(item -> analysisCodes.add(item.getAnalysisTypeCode()));
|
|
|
//分图分析类型
|
|
|
List<AnalysisDiagramRelationVo> relationVos = diagramRelationMapper.selectByBatchCode(batchCode);
|
|
|
- relationVos.stream().forEach(item -> analysisTypeSet.add(new AnalysisTypeShortVo().setAnalysisTypeCode(item.getAnalysisTypeCode())
|
|
|
- .setAnalysisTypeName(item.getAnalysisTypeName())));
|
|
|
- return analysisTypeSet;
|
|
|
+ relationVos.stream().forEach(item -> analysisCodes.add(item.getAnalysisTypeCode()));
|
|
|
+ return getAnalysisType(analysisCodes);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -310,7 +450,19 @@ public class AnalysisServiceImpl implements AnalysisService {
|
|
|
*/
|
|
|
@Override
|
|
|
public List<Map<String, Object>> queryAllAnalysisType() {
|
|
|
+ return getAnalysisType(null);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ *过滤分析类型并生成树形结构
|
|
|
+ * @param analysisCodes
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private List<Map<String, Object>> getAnalysisType(Set<String> analysisCodes){
|
|
|
List<AnalysisTypePo> analysisTypePos = analysisTypeMapper.selectAll();
|
|
|
+ if(CollectionUtils.isNotEmpty(analysisCodes)){
|
|
|
+ analysisTypePos = analysisTypePos.stream().filter(item -> analysisCodes.contains(item.getTypeCode())).collect(Collectors.toList());
|
|
|
+ }
|
|
|
return TreeUtil.getJava8ResultTree(BeanMapUtils.listBeanToListMap(analysisTypePos), "parentId", "id");
|
|
|
}
|
|
|
|
|
|
@@ -442,6 +594,9 @@ public class AnalysisServiceImpl implements AnalysisService {
|
|
|
*/
|
|
|
@Override
|
|
|
public FieldAndAnalysisInfoVo getFieldInfo(String batchCode) {
|
|
|
+ if(StringUtils.isBlank(batchCode)){
|
|
|
+ return new FieldAndAnalysisInfoVo();
|
|
|
+ }
|
|
|
AnalysisResultPo analysisResultPo = analysisResultMapper.selectByBatchCode(batchCode);
|
|
|
return new FieldAndAnalysisInfoVo().setFieldInfo(getWindFieldDescriptVo(analysisResultPo.getFieldCode()))
|
|
|
.setAnalysisInfo(getAnalysisCodeInfo(batchCode));
|
|
|
@@ -476,10 +631,8 @@ public class AnalysisServiceImpl implements AnalysisService {
|
|
|
private AnalysisRelateInfoVo getAnalysisCodeInfo(String batchCode){
|
|
|
AnalysisRelateInfoVo returnVo = new AnalysisRelateInfoVo();
|
|
|
AnalysisResultPo analysisResultPo = analysisResultMapper.selectByBatchCode(batchCode);
|
|
|
- returnVo.setDataStartTime(analysisResultPo.getDataStartTime())
|
|
|
- .setDataEndTime(analysisResultPo.getDataEndTime())
|
|
|
- .setAnalysisFinishTime(analysisResultPo.getAnalysisFinishTime())
|
|
|
- .setUpdateByName(sysUserInfoMapper.getUserInfoByUserId(analysisResultPo.getCreateBy()).getUserName())
|
|
|
+ BeanUtils.copyProperties(analysisResultPo,returnVo);
|
|
|
+ returnVo.setUpdateByName(sysUserInfoMapper.getUserInfoByUserId(analysisResultPo.getCreateBy()).getUserName())
|
|
|
.setAnalysisTypes(queryAnalysisedType(batchCode))
|
|
|
.setWindEngineGroups(queryAnalysisedEngine(batchCode,null));
|
|
|
return returnVo;
|
|
|
@@ -678,7 +831,11 @@ public class AnalysisServiceImpl implements AnalysisService {
|
|
|
return resultList;
|
|
|
}
|
|
|
analysisTypeVos = analysisTypeVos.stream().filter(item->StringUtils.isNotBlank(item.getTypeCode())).sorted(Comparator.comparing(AnalysisTypeVo::getParentId)).collect(Collectors.toList());
|
|
|
- analysisTypeVos.forEach(analysisTypeVo -> resultList.add(BeanMapUtils.beanToMap(analysisTypeVo)));
|
|
|
+ analysisTypeVos.forEach(analysisTypeVo -> {
|
|
|
+ String[] typeFlagStrs = analysisTypeVo.getTypeFlag().split("\\|");
|
|
|
+ analysisTypeVo.setTypeFlag(typeFlagStrs[typeFlagStrs.length-1]);
|
|
|
+ resultList.add(BeanMapUtils.beanToMap(analysisTypeVo));
|
|
|
+ });
|
|
|
return resultList;
|
|
|
// return TreeUtil.getJava8ResultTree(resultList, AnalysisConstants.ANALYSIS_TYPE_PARRENT_KEY,AnalysisConstants.ANALYSIS_TYPE_KEY);
|
|
|
}
|
|
|
@@ -713,7 +870,7 @@ public class AnalysisServiceImpl implements AnalysisService {
|
|
|
Collectors.maxBy(Comparator.comparing(AnalysisGeneralFileVo::getCreateTime)))
|
|
|
).values().stream().map(Optional::get).collect(Collectors.toList());
|
|
|
//添加内外网前缀
|
|
|
- generalFileVos.forEach(item -> item.setFileAddr(getFilePath(isIntranet,item.getFileAddr())));
|
|
|
+ generalFileVos.forEach(item -> item.setFileAddr(NetUtils.getFilePath(isIntranet,item.getFileAddr())));
|
|
|
//当同一个批次、同一个分析类型下,存在多个总文件时,说明一定是按照机型分析,需过滤掉total机型的文件
|
|
|
if(generalFileVos.size() > 1){
|
|
|
generalFileVos = generalFileVos.stream().filter(item -> !item.getEngineTypeCode().equals(GENERAL_FILE_TYPE_CODE)).collect(Collectors.toList());
|
|
|
@@ -744,7 +901,7 @@ public class AnalysisServiceImpl implements AnalysisService {
|
|
|
//对风机编号进行排序
|
|
|
.sorted(Comparator.comparing(AnalysisDiagramRelationVo::getFieldEngineCode)).collect(Collectors.toList());
|
|
|
//添加内外网前缀
|
|
|
- diagramRelationVos.forEach(item -> item.setFileAddr(getFilePath(intranet,item.getFileAddr())));
|
|
|
+ diagramRelationVos.forEach(item -> item.setFileAddr(NetUtils.getFilePath(intranet,item.getFileAddr())));
|
|
|
return diagramRelationVos;
|
|
|
}
|
|
|
|
|
|
@@ -834,7 +991,15 @@ public class AnalysisServiceImpl implements AnalysisService {
|
|
|
if(CollectionUtils.isEmpty(configAnalysisCodes)){
|
|
|
return;
|
|
|
}
|
|
|
- analysisDto.setConfigAnalysis(analysisTypeMapper.selecFlagtByCode(configAnalysisCodes));
|
|
|
+ //去重处理
|
|
|
+ Set<String> flags = new HashSet<>();
|
|
|
+ configAnalysisCodes.stream().forEach(item -> {
|
|
|
+ String[] typeStrs = item.split("\\|");
|
|
|
+ String flag = analysisTypeMapper.selecFlagByCode(typeStrs[0]);
|
|
|
+ flag = flag.substring(0,flag.lastIndexOf("|") + 1) + typeStrs[1];
|
|
|
+ flags.add(flag);
|
|
|
+ });
|
|
|
+ analysisDto.setConfigAnalysis(flags.stream().collect(Collectors.toList()));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -845,13 +1010,13 @@ public class AnalysisServiceImpl implements AnalysisService {
|
|
|
private void dataProccess(AnalysisDto analysisDto,JsonNode rootNode){
|
|
|
//前端入参类
|
|
|
Field[] analysisFields = analysisDto.getClass().getDeclaredFields();
|
|
|
- String scada = analysisDto.getScada();
|
|
|
+// String scada = analysisDto.getScada();
|
|
|
Arrays.asList(analysisFields).stream().forEach(field -> {
|
|
|
field.setAccessible(true);
|
|
|
try {
|
|
|
//值不能为空且值为list的时候list长度不能为0
|
|
|
if(field.get(analysisDto) != null){
|
|
|
- updateNodesByPropertyName(rootNode, field.getName(), field.get(analysisDto),scada);
|
|
|
+ updateNodesByPropertyName(rootNode, field.getName(), field.get(analysisDto));
|
|
|
}
|
|
|
} catch (IllegalAccessException e) {
|
|
|
e.printStackTrace();
|
|
|
@@ -866,7 +1031,7 @@ public class AnalysisServiceImpl implements AnalysisService {
|
|
|
* @param propertyName 属性名称
|
|
|
* @param newValue 新值
|
|
|
*/
|
|
|
- private void updateNodesByPropertyName(JsonNode parentNode, String propertyName, Object newValue,String scada) {
|
|
|
+ private void updateNodesByPropertyName(JsonNode parentNode, String propertyName, Object newValue) {
|
|
|
//遍历当前节点
|
|
|
for (Iterator<Map.Entry<String, JsonNode>> it = parentNode.fields(); it.hasNext(); ) {
|
|
|
Map.Entry<String, JsonNode> entry = it.next();
|
|
|
@@ -874,7 +1039,7 @@ public class AnalysisServiceImpl implements AnalysisService {
|
|
|
if (entry.getKey().equalsIgnoreCase(propertyName)) {
|
|
|
//分析类型及有子节点的处理
|
|
|
if(propertyName.equalsIgnoreCase(algorithmProperties.getConfigAnalysisProperties()) || entry.getValue().fields().hasNext()){
|
|
|
- assignmentByPropertyName(entry.getValue(), propertyName, newValue,scada);
|
|
|
+ assignmentByPropertyName(entry.getValue(), propertyName, newValue);
|
|
|
return;
|
|
|
}
|
|
|
//数组属性得特殊处理
|
|
|
@@ -886,23 +1051,10 @@ public class AnalysisServiceImpl implements AnalysisService {
|
|
|
}
|
|
|
//普通单节点
|
|
|
((ObjectNode) parentNode).put(propertyName, newValue.toString());
|
|
|
- //判断当前节点有没有子节点 排除分析节点
|
|
|
-// if(!entry.getValue().fields().hasNext() && !propertyName.equalsIgnoreCase(algorithmProperties.getConfigAnalysisProperties())){
|
|
|
-// //数组属性得特殊处理
|
|
|
-// if(algorithmProperties.getAnalysisArrayProperties().contains(propertyName)){
|
|
|
-// ArrayNode arrayNode = mapper.createArrayNode();
|
|
|
-// ((List<String>)newValue).stream().forEach(item-> arrayNode.add(item));
|
|
|
-// ((ObjectNode) parentNode).set(propertyName,arrayNode);
|
|
|
-// }else{
|
|
|
-// ((ObjectNode) parentNode).put(propertyName, newValue.toString());
|
|
|
-// }
|
|
|
-// }else{
|
|
|
-// assignmentByPropertyName(entry.getValue(), propertyName, newValue,scada);
|
|
|
-// }
|
|
|
return;
|
|
|
}
|
|
|
// 递归搜索子节点
|
|
|
- updateNodesByPropertyName(entry.getValue(), propertyName, newValue,scada);
|
|
|
+ updateNodesByPropertyName(entry.getValue(), propertyName, newValue);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
@@ -913,22 +1065,22 @@ public class AnalysisServiceImpl implements AnalysisService {
|
|
|
* @param propertyName
|
|
|
* @param newValue
|
|
|
*/
|
|
|
- private void assignmentByPropertyName(JsonNode subNode, String propertyName, Object newValue,String scada){
|
|
|
+ private void assignmentByPropertyName(JsonNode subNode, String propertyName, Object newValue){
|
|
|
//scada数据筛选过滤 、图像设置特殊处理
|
|
|
- if(algorithmProperties.getGraphSetsProperties().contains(propertyName)
|
|
|
- || algorithmProperties.getCustomFilterProperties().contains(propertyName)){
|
|
|
+// if(algorithmProperties.getGraphSetsProperties().contains(propertyName)||
|
|
|
+ if(algorithmProperties.getCustomFilterProperties().contains(propertyName)){
|
|
|
dealGraphSetsAndCustomFilter(subNode, newValue);
|
|
|
return ;
|
|
|
}
|
|
|
//分析类型特殊处理
|
|
|
if(algorithmProperties.getConfigAnalysisProperties().equals(propertyName)){
|
|
|
- dealConfigAnalysis(subNode, newValue,scada);
|
|
|
+ dealConfigAnalysis(subNode, newValue);
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * scada数据筛选过滤 、图像设置特殊处理
|
|
|
+ * scada数据筛选过滤 、图像设置特殊处理(图像设置特殊处理废弃)
|
|
|
* @param subNode
|
|
|
* @param newValue
|
|
|
*/
|
|
|
@@ -951,7 +1103,7 @@ public class AnalysisServiceImpl implements AnalysisService {
|
|
|
* @param subNode
|
|
|
* @param newValue
|
|
|
*/
|
|
|
- private void dealConfigAnalysis(JsonNode subNode, Object newValue,String scada){
|
|
|
+ private void dealConfigAnalysis(JsonNode subNode, Object newValue){
|
|
|
try{
|
|
|
ArrayNode arrayNode = (ArrayNode) subNode;
|
|
|
List<String> analysisTypes = (List) newValue;
|
|
|
@@ -961,11 +1113,7 @@ public class AnalysisServiceImpl implements AnalysisService {
|
|
|
String[] types = analysisTypes.get(i).split("\\|");
|
|
|
AtomicInteger index = new AtomicInteger(0);
|
|
|
childNode.fields().forEachRemaining(entry-> {
|
|
|
- if(StringUtils.isNotBlank(scada) && entry.getKey().equals(AnalysisConstants.SCADA)){
|
|
|
- ((ObjectNode)childNode).put(entry.getKey(), scada);
|
|
|
- }else{
|
|
|
- ((ObjectNode)childNode).put(entry.getKey(), types[index.get()]);
|
|
|
- }
|
|
|
+ ((ObjectNode)childNode).put(entry.getKey(), types[index.get()]);
|
|
|
index.incrementAndGet();
|
|
|
});
|
|
|
arrayNode.add(childNode);
|
|
|
@@ -1004,23 +1152,23 @@ 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);
|
|
|
- }
|
|
|
+// 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);
|
|
|
+// }
|
|
|
|
|
|
/**
|
|
|
* 将源列表中非空元素替换到目标列表中且下标不变
|
|
|
@@ -1072,20 +1220,6 @@ public class AnalysisServiceImpl implements AnalysisService {
|
|
|
|
|
|
|
|
|
/**
|
|
|
- * 获取分析结果文件地址前缀并替换或添加
|
|
|
- * @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 fieldCode
|
|
|
* @return
|
|
|
@@ -1112,77 +1246,16 @@ public class AnalysisServiceImpl implements AnalysisService {
|
|
|
* @throws InterruptedException
|
|
|
*/
|
|
|
public static void main(String[] args) throws InterruptedException, URISyntaxException {
|
|
|
- List<AnalysisDiagramRelationVo> diagramRelationVos = new ArrayList<>();
|
|
|
- AnalysisDiagramRelationVo a1 = new AnalysisDiagramRelationVo();
|
|
|
- AnalysisDiagramRelationVo a2 = new AnalysisDiagramRelationVo();
|
|
|
- AnalysisDiagramRelationVo a3 = new AnalysisDiagramRelationVo();
|
|
|
- AnalysisDiagramRelationVo a4 = new AnalysisDiagramRelationVo();
|
|
|
- a1.setCreateTime(new Date());
|
|
|
- a1.setFieldEngineCode("123");
|
|
|
- a1.setBatchCode("123");
|
|
|
- a1.setAnalysisTypeCode("aaa");
|
|
|
- a1.setFileAddr("a1");
|
|
|
- Thread.sleep(10000);
|
|
|
- a2.setCreateTime(new Date());
|
|
|
- a2.setFieldEngineCode("123");
|
|
|
- a2.setAnalysisTypeCode("aaa");
|
|
|
- a2.setBatchCode("123");
|
|
|
- a2.setFileAddr("a2");
|
|
|
- Thread.sleep(10000);
|
|
|
- a3.setCreateTime(new Date());
|
|
|
- a3.setFieldEngineCode("123");
|
|
|
- a3.setAnalysisTypeCode("aaa");
|
|
|
- a3.setBatchCode("123");
|
|
|
- a3.setFileAddr("a3");
|
|
|
- Thread.sleep(10000);
|
|
|
- a4.setCreateTime(new Date());
|
|
|
- a4.setFieldEngineCode("124");
|
|
|
- a4.setAnalysisTypeCode("aaa");
|
|
|
- a4.setBatchCode("123");
|
|
|
- a4.setFileAddr("a4");
|
|
|
- diagramRelationVos.add(a1);
|
|
|
- diagramRelationVos.add(a2);
|
|
|
- diagramRelationVos.add(a3);
|
|
|
- diagramRelationVos.add(a4);
|
|
|
- diagramRelationVos = diagramRelationVos.stream().collect(Collectors.groupingBy(
|
|
|
- AnalysisDiagramRelationVo::getFieldEngineCode,
|
|
|
- Collectors.maxBy(Comparator.comparing(AnalysisDiagramRelationVo::getCreateTime)))
|
|
|
- ).values().stream()
|
|
|
- .map(Optional::get)
|
|
|
- .collect(Collectors.toList());
|
|
|
- System.out.println(diagramRelationVos);
|
|
|
-
|
|
|
-// 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());
|
|
|
-// a2.setBatchCode("456");
|
|
|
-// generalFileVos.add(a2);
|
|
|
-// Thread.sleep(1000);
|
|
|
-// AnalysisGeneralFileVo a3 = new AnalysisGeneralFileVo();
|
|
|
-// a3.setFileAddr("http://123/412/89.json");
|
|
|
-// a3.setCreateTime(new Date());
|
|
|
-// a3.setBatchCode("789");
|
|
|
-// generalFileVos.add(a3);
|
|
|
-// generalFileVos.sort(Comparator.comparing(AnalysisGeneralFileVo::getCreateTime,Comparator.reverseOrder()));
|
|
|
-// //删除地址相同的文件
|
|
|
-// List<AnalysisGeneralFileVo> returnList = generalFileVos.stream().filter(distinctByKey(item -> replacePath(item.getFileAddr()))).collect(Collectors.toList());
|
|
|
-//
|
|
|
-// returnList.forEach(System.out::println);
|
|
|
-// List<String> list = new ArrayList<>();
|
|
|
-// list.add("123.png");
|
|
|
-// list.add("123.html");
|
|
|
-// list = list.stream().filter(item -> !item.endsWith(".png")).collect(Collectors.toList());
|
|
|
-// System.out.println(list);
|
|
|
-// Matcher matcher = Pattern.compile(ENGINE_CODE_PATTEN).matcher("1231231231/12312/WEM00001");
|
|
|
-// String result = matcher.find() ? matcher.group() : "";
|
|
|
-// System.out.println(result);
|
|
|
+ AnalysisDto analysisDto = new AnalysisDto();
|
|
|
+ List<String> turbines = new ArrayList<>();
|
|
|
+ turbines.add("1");
|
|
|
+ turbines.add("2");
|
|
|
+ turbines.add("3");
|
|
|
+ analysisDto.setTurbines(turbines);
|
|
|
+ AnalysisDataRelationRecordsPo relationRecordsPo = new AnalysisDataRelationRecordsPo();
|
|
|
+ BeanUtils.copyProperties(analysisDto,relationRecordsPo);
|
|
|
+ relationRecordsPo.setTurbines(turbines.stream().collect(Collectors.joining(",")));
|
|
|
+ System.out.println(relationRecordsPo.getTurbines());
|
|
|
}
|
|
|
|
|
|
}
|