|
@@ -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.service.analysis.AnalysisService;
|
|
|
import com.energy.manage.service.util.BeanMapUtils;
|
|
|
+import com.energy.manage.service.util.NetUtils;
|
|
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
|
import com.fasterxml.jackson.databind.JsonNode;
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
@@ -32,8 +33,12 @@ import org.springframework.stereotype.Service;
|
|
|
import javax.annotation.Resource;
|
|
|
import java.lang.reflect.Field;
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.net.URI;
|
|
|
+import java.net.URISyntaxException;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
|
+import java.util.regex.Matcher;
|
|
|
+import java.util.regex.Pattern;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
@@ -85,6 +90,12 @@ public class AnalysisServiceImpl implements AnalysisService {
|
|
|
*/
|
|
|
private static final String OPTION_CONTENT = "手动分析";
|
|
|
|
|
|
+ /**
|
|
|
+ * 分析文件前缀
|
|
|
+ */
|
|
|
+ private static final String FILE_ADDR_FREFIX = "http://";
|
|
|
+
|
|
|
+
|
|
|
private static ObjectMapper mapper = new ObjectMapper();
|
|
|
|
|
|
/**
|
|
@@ -154,7 +165,7 @@ public class AnalysisServiceImpl implements AnalysisService {
|
|
|
* @return
|
|
|
*/
|
|
|
@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<AnalysisTypeVo> analysisTypeVos = analysisTypeMapper.selectByTypeCode(analysisTypeCode);
|
|
@@ -162,9 +173,9 @@ public class AnalysisServiceImpl implements AnalysisService {
|
|
|
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);
|
|
|
//根据分析类型设置分析结果
|
|
@@ -228,8 +239,12 @@ public class AnalysisServiceImpl implements AnalysisService {
|
|
|
* @param analysisTypeCode
|
|
|
* @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);
|
|
|
+ //为每个文件赋值前缀
|
|
|
+ generalFileVos.forEach(item -> item.setFileAddr(getFilePath(isIntranet,item.getFileAddr())));
|
|
|
+ //根据创建时间排序
|
|
|
generalFileVos.sort(Comparator.comparing(AnalysisGeneralFileVo::getCreateTime,Comparator.reverseOrder()));
|
|
|
//删除地址相同的文件
|
|
|
return generalFileVos.stream().collect(Collectors.collectingAndThen(
|
|
@@ -245,11 +260,13 @@ public class AnalysisServiceImpl implements AnalysisService {
|
|
|
* @param fieldEngineCode
|
|
|
* @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);
|
|
|
if(CollectionUtils.isEmpty(diagramRelationVos)){
|
|
|
return diagramRelationVos;
|
|
|
}
|
|
|
+ diagramRelationVos.forEach(item -> item.setFileAddr(getFilePath(intranet,item.getFileAddr())));
|
|
|
//如果风机编号不为空的话则不对风机编号进行排序
|
|
|
if (StringUtils.isNotBlank(fieldEngineCode)) {
|
|
|
diagramRelationVos.sort(Comparator.comparing(AnalysisDiagramRelationVo::getCreateTime, Comparator.reverseOrder()));
|
|
@@ -329,31 +346,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值
|
|
@@ -505,4 +497,45 @@ public class AnalysisServiceImpl implements AnalysisService {
|
|
|
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);
|
|
|
+ }
|
|
|
+
|
|
|
}
|