Pārlūkot izejas kodu

修改:1.23号演示修改需求

chenhongyan1989 10 mēneši atpakaļ
vecāks
revīzija
ed1692f8a4
32 mainītis faili ar 955 papildinājumiem un 286 dzēšanām
  1. 22 0
      energy-manage-common/src/main/java/com/energy/manage/common/po/analysis/AnalysisTypePo.java
  2. 95 0
      energy-manage-common/src/main/java/com/energy/manage/common/po/analysisdatarelationrecords/AnalysisDataRelationRecordsPo.java
  3. 57 0
      energy-manage-common/src/main/java/com/energy/manage/common/po/analysispriorityrecords/AnalysisPriorityRecordsPo.java
  4. 4 4
      energy-manage-service/generator/generatorConfig.xml
  5. 5 0
      energy-manage-service/src/main/java/com/energy/manage/service/constant/analysis/AnalysisConstants.java
  6. 3 2
      energy-manage-service/src/main/java/com/energy/manage/service/controller/analysis/AnalysisController.java
  7. 6 3
      energy-manage-service/src/main/java/com/energy/manage/service/controller/analysisresultreport/AnalysisResultReportController.java
  8. 4 2
      energy-manage-service/src/main/java/com/energy/manage/service/controller/homepage/HomePageController.java
  9. 45 39
      energy-manage-service/src/main/java/com/energy/manage/service/domain/dto/analysis/AnalysisDto.java
  10. 17 0
      energy-manage-service/src/main/java/com/energy/manage/service/domain/dto/analysis/AnalysisTypeExtDto.java
  11. 32 1
      energy-manage-service/src/main/java/com/energy/manage/service/domain/vo/analysis/AnalysisRelateInfoVo.java
  12. 5 0
      energy-manage-service/src/main/java/com/energy/manage/service/domain/vo/analysis/AnalysisResultVo.java
  13. 1 1
      energy-manage-service/src/main/java/com/energy/manage/service/domain/vo/analysis/AnalysisTypeShortVo.java
  14. 16 1
      energy-manage-service/src/main/java/com/energy/manage/service/mappers/analysis/AnalysisResultMapper.java
  15. 8 1
      energy-manage-service/src/main/java/com/energy/manage/service/mappers/analysis/AnalysisTypeMapper.java
  16. 21 0
      energy-manage-service/src/main/java/com/energy/manage/service/mappers/analysisdatarelationrecords/AnalysisDataRelationRecordsMapper.java
  17. 39 0
      energy-manage-service/src/main/java/com/energy/manage/service/mappers/analysispriorityrecords/AnalysisPriorityRecordsMapper.java
  18. 3 1
      energy-manage-service/src/main/java/com/energy/manage/service/mappers/windexceptioncount/WindExceptionCountMapper.java
  19. 2 1
      energy-manage-service/src/main/java/com/energy/manage/service/service/analysis/AnalysisResultReportService.java
  20. 10 2
      energy-manage-service/src/main/java/com/energy/manage/service/service/analysis/AnalysisService.java
  21. 4 2
      energy-manage-service/src/main/java/com/energy/manage/service/service/analysis/impl/AnalysisResultReportServiceImpl.java
  22. 246 173
      energy-manage-service/src/main/java/com/energy/manage/service/service/analysis/impl/AnalysisServiceImpl.java
  23. 7 1
      energy-manage-service/src/main/java/com/energy/manage/service/service/homepage/HomePageService.java
  24. 15 7
      energy-manage-service/src/main/java/com/energy/manage/service/service/homepage/impl/HomePageServiceImpl.java
  25. 114 0
      energy-manage-service/src/main/java/com/energy/manage/service/task/AnalysisTask.java
  26. 19 19
      energy-manage-service/src/main/java/com/energy/manage/service/task/AutoAnalysisTask.java
  27. 29 1
      energy-manage-service/src/main/java/com/energy/manage/service/util/NetUtils.java
  28. 18 22
      energy-manage-service/src/main/resources/mybatis/analysis/AnalysisResultMapper.xml
  29. 8 1
      energy-manage-service/src/main/resources/mybatis/analysis/AnalysisTypeMapper.xml
  30. 66 0
      energy-manage-service/src/main/resources/mybatis/analysisdatarelationrecords/AnalysisDataRelationRecordsPoMapper.xml
  31. 29 0
      energy-manage-service/src/main/resources/mybatis/analysispriorityrecords/AnalysisPriorityRecordsMapper.xml
  32. 5 2
      energy-manage-service/src/main/resources/mybatis/windexceptioncount/WindExceptionCountMapper.xml

+ 22 - 0
energy-manage-common/src/main/java/com/energy/manage/common/po/analysis/AnalysisTypePo.java

@@ -1,9 +1,11 @@
 package com.energy.manage.common.po.analysis;
 
 import lombok.Data;
+import lombok.experimental.Accessors;
 
 import javax.persistence.Table;
 import java.util.Date;
+import java.util.Objects;
 
 /**
  * 分析类型表
@@ -13,6 +15,7 @@ import java.util.Date;
  */
 @Table(name = "analysis_type")
 @Data
+@Accessors(chain = true)
 public class AnalysisTypePo {
 
     /**
@@ -36,6 +39,11 @@ public class AnalysisTypePo {
     private String typeName ;
 
     /**
+     * 分析类型标识
+     */
+    private String typeFlag ;
+
+    /**
      * 创建人
      */
     private Integer createBy ;
@@ -45,4 +53,18 @@ public class AnalysisTypePo {
      */
     private Date createTime ;
 
+    @Override
+    public int hashCode() {
+        return Objects.hash(typeCode,typeName);
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) return true;
+        if (obj == null || getClass() != obj.getClass()) return false;
+        AnalysisTypePo vo = (AnalysisTypePo) obj;
+        return Objects.equals(typeCode, vo.typeCode) &&
+                Objects.equals(typeName, vo.typeName);
+    }
+
 }

+ 95 - 0
energy-manage-common/src/main/java/com/energy/manage/common/po/analysisdatarelationrecords/AnalysisDataRelationRecordsPo.java

@@ -0,0 +1,95 @@
+package com.energy.manage.common.po.analysisdatarelationrecords;
+
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import javax.persistence.Table;
+import java.util.Date;
+
+
+@Table(name = "analysis_data_relation_records")
+@Data
+@Accessors(chain = true)
+public class AnalysisDataRelationRecordsPo {
+
+    /**
+     * 主键id
+     */
+    private Long id;
+
+    /**
+     * 批次编号
+     */
+    private String dataBatchNum;
+
+    /**
+     * 风场编号
+     */
+    private String powerFarmID;
+
+    /**
+     * 数据开始时间
+     */
+    private String beginTime;
+
+    /**
+     * 数据结束时间
+     */
+    private String endTime;
+
+    /**
+     * 过滤月份
+     */
+    private String excludingMonths;
+
+    /**
+     * 创建时间
+     */
+    private Date cretateTime;
+
+    /**
+     * 更新时间
+     */
+    private Date updateTime;
+
+    /**
+     * 分析类型标识
+     */
+    private String configAnalysis;
+
+    /**
+     * 风机编号
+     */
+    private String turbines;
+
+    /**
+     * 风速
+     */
+    private String valueWindSpeed;
+
+    /**
+     * 桨距角
+     */
+    private String valuePitchAngle;
+
+    /**
+     * 用功功率
+     */
+    private String valueActivePower;
+
+    /**
+     * 风机转速
+     */
+    private String valueGeneratorSpeed;
+
+    /**
+     * 关联任务id
+     */
+    private String taskId;
+
+    /**
+     * 手动/自动分析
+     */
+    private String autoOrManual;
+
+}

+ 57 - 0
energy-manage-common/src/main/java/com/energy/manage/common/po/analysispriorityrecords/AnalysisPriorityRecordsPo.java

@@ -0,0 +1,57 @@
+package com.energy.manage.common.po.analysispriorityrecords;
+
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import javax.persistence.Table;
+import java.io.Serializable;
+import java.util.Date;
+
+
+/**
+ * @author: chy
+ * @date: 2025/2/11
+ * @description: 分析优先级记录表
+ */
+
+@Table(name = "analysis_priority_records")
+@Data
+@Accessors(chain = true)
+public class AnalysisPriorityRecordsPo {
+
+    /**
+     * 主键
+     */
+    private Long id;
+
+    /**
+     * 分析批次号
+     */
+    private String batchCode;
+
+    /**
+     * 优先级 默认0
+     */
+    private int priority = 0;
+
+    /**
+     * 创建时间
+     */
+    private Date createTime;
+
+    /**
+     * 更新时间
+     */
+    private Date updateTime;
+
+    /**
+     * 执行状态 0:未执行  1:已执行
+     */
+    private int executeStatus = 0;
+
+    /**
+     * 执行id
+     */
+    private String taskId;
+
+}

+ 4 - 4
energy-manage-service/generator/generatorConfig.xml

@@ -76,7 +76,7 @@
         </javaTypeResolver>
 
         <!-- java实体类路径 -->
-        <javaModelGenerator targetPackage="com.energy.manage.common.po.detectionpointdic" targetProject="src/main/java">
+        <javaModelGenerator targetPackage="analysisdatarelationrecords" targetProject="src/main/java">
             <!--  for MyBatis3/MyBatis3Simple
                 自动为每一个生成的类创建一个构造方法,构造方法包含了所有的field;而不是使用setter;
               -->
@@ -90,7 +90,7 @@
         </javaModelGenerator>
 
         <!-- 生成映射文件xml的包名和位置-->
-        <sqlMapGenerator targetPackage="mybatis.detectionpointdic" targetProject="src/main/resources">
+        <sqlMapGenerator targetPackage="mybatis.analysisdatarelationrecords" targetProject="src/main/resources">
             <!-- 是否让schema作为包后缀-->
             <property name="enableSubPackages" value="false"/>
         </sqlMapGenerator>
@@ -99,7 +99,7 @@
             type="XMLMAPPER" 会将接口的实现放在 mapper.xml中,也推荐这样配置。
             type="ANNOTATEDMAPPER",接口的实现通过注解写在接口上面
          -->
-        <javaClientGenerator type="XMLMAPPER" targetPackage="com.energy.manage.service.mappers.detectionpointdic"
+        <javaClientGenerator type="XMLMAPPER" targetPackage="com.energy.manage.service.mappers.analysisdatarelationrecords"
                              targetProject="src/main/java">
             <!-- 是否让schema作为包后缀-->
             <property name="enableSubPackages" value="false"/>
@@ -113,7 +113,7 @@
             生成全部表tableName设为 %
         -->
 
-        <table tableName="detection_point_dic" domainObjectName="DetectionPointDic"
+        <table tableName="analysis_data_relation_records" domainObjectName="analysisDataRelationRecordsPo"
                enableDeleteByExample="false"
                enableCountByExample="false"
                enableSelectByExample="false"

+ 5 - 0
energy-manage-service/src/main/java/com/energy/manage/service/constant/analysis/AnalysisConstants.java

@@ -71,6 +71,11 @@ public interface AnalysisConstants {
 
     String IMAGE_SUFFIX = ".png";
 
+    /**
+     * 已执行状态
+     */
+    Integer ON_CALL = 1;
+
 
 
 }

+ 3 - 2
energy-manage-service/src/main/java/com/energy/manage/service/controller/analysis/AnalysisController.java

@@ -43,10 +43,11 @@ public class AnalysisController extends BaseServiceController {
     @UserLoginToken
     @ApiOperation(value = "分析结果列表")
     @GetMapping("/analysisResultList")
-    public ResultResp<Page<AnalysisResultVo>> analysisResultList(AnalysisResultDto analysisResultDto)
+    public ResultResp<Page<AnalysisResultVo>> analysisResultList(HttpServletRequest request,AnalysisResultDto analysisResultDto)
     {
         analysisResultDto.setRoleId(getRoleId());
-        return pageResult(analysisService.analysisResultList(analysisResultDto),analysisResultDto);
+        boolean isIntranet = NetUtils.isIntranet(IPUtils.getIpAddr(request));
+        return pageResult(analysisService.analysisResultList(analysisResultDto,isIntranet),analysisResultDto);
     }
 
     @UserLoginToken

+ 6 - 3
energy-manage-service/src/main/java/com/energy/manage/service/controller/analysisresultreport/AnalysisResultReportController.java

@@ -2,12 +2,14 @@ package com.energy.manage.service.controller.analysisresultreport;
 
 import com.energy.manage.common.reponse.ResultResp;
 import com.energy.manage.service.controller.base.BaseServiceController;
-import com.energy.manage.service.domain.dto.analysis.AnalysisResultReportDto;
 import com.energy.manage.service.domain.vo.analysis.AnalysisResultReportVo;
 import com.energy.manage.service.service.analysis.AnalysisResultReportService;
+import com.energy.manage.service.util.IPUtils;
+import com.energy.manage.service.util.NetUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
+import javax.servlet.http.HttpServletRequest;
 import java.util.List;
 
 /**
@@ -30,9 +32,10 @@ public class AnalysisResultReportController extends BaseServiceController {
     }
 
     @GetMapping("/getRportType")
-    public ResultResp getRportType()
+    public ResultResp getRportType(HttpServletRequest request)
     {
-        return success(analysisResultReportService.getRportType());
+        boolean isIntranet = NetUtils.isIntranet(IPUtils.getIpAddr(request));
+        return success(analysisResultReportService.getRportType(isIntranet));
     }
 
 }

+ 4 - 2
energy-manage-service/src/main/java/com/energy/manage/service/controller/homepage/HomePageController.java

@@ -30,8 +30,10 @@ public class HomePageController extends BaseServiceController {
     @UserLoginToken
     @GetMapping("/queryStatistics")
     public ResultResp queryStatistics(@RequestParam("codeNumber") String codeNumber,
-                            @RequestParam("codeType") String codeType){
-        return success(homePageService.queryStatistics(getRoleId(), codeNumber, codeType));
+                            @RequestParam("codeType") String codeType,
+                            @RequestParam("startTime") String startTime,
+                            @RequestParam("endTime") String endTime){
+        return success(homePageService.queryStatistics(getRoleId(), codeNumber, codeType,startTime,endTime));
     }
 
 

+ 45 - 39
energy-manage-service/src/main/java/com/energy/manage/service/domain/dto/analysis/AnalysisDto.java

@@ -3,7 +3,6 @@ package com.energy.manage.service.domain.dto.analysis;
 import lombok.Data;
 import lombok.experimental.Accessors;
 
-import java.util.Date;
 import java.util.List;
 
 /**
@@ -84,50 +83,57 @@ public class AnalysisDto {
 
     /*分析类型 configAnalysis*/
     /**
-     * 分析类型code
+     * 分析类型code与flag 格式(["typeCode|typeFlag",...])
      */
     private List<String> configAnalysis;
 
-    /*图像设置参数 graphSets*/
+/**
+ * 图像设置参数 graphSets
+ * @deprecated  since 2025-01-23(年前需求会议,由于前端绘图该属性算法无需再传给算法)
+ *=========================================graphSets DEPRECATED START==================================
+ */
     /**
      * 直驱发电机转速轴系
      */
-    private List<Double> dgeneratorSpeed;
-
-    /**
-     * 非直驱发电机转速轴系设置
-     */
-    private List<Double> igeneratorSpeed;
-
-    /**
-     * 直驱发电机转矩轴系
-     */
-    private List<Double> dgeneratorTorque;
-
-    /**
-     * 非直驱发电机转矩轴系
-     */
-    private List<Double> igeneratorTorque;
-
-    /**
-     *风能利用系数轴系
-     */
-    private List<Double> cp;
-
-    /**
-     * 叶尖速比轴系
-     */
-    private List<Double> tsr;
-
-    /**
-     * 桨距角轴系
-     */
-    private List<Double> pitchAngle;
-
-    /**
-     * 有功功率轴系
-     */
-    private List<Double> activePower;
+//    private List<Double> dgeneratorSpeed;
+//
+//    /**
+//     * 非直驱发电机转速轴系设置
+//     */
+//    private List<Double> igeneratorSpeed;
+//
+//    /**
+//     * 直驱发电机转矩轴系
+//     */
+//    private List<Double> dgeneratorTorque;
+//
+//    /**
+//     * 非直驱发电机转矩轴系
+//     */
+//    private List<Double> igeneratorTorque;
+//
+//    /**
+//     *风能利用系数轴系
+//     */
+//    private List<Double> cp;
+//
+//    /**
+//     * 叶尖速比轴系
+//     */
+//    private List<Double> tsr;
+//
+//    /**
+//     * 桨距角轴系
+//     */
+//    private List<Double> pitchAngle;
+//
+//    /**
+//     * 有功功率轴系
+//     */
+//    private List<Double> activePower;
+/**
+ * =========================================graphSets DEPRECATED END ==================================
+ */
 
     /**
      * 分析人

+ 17 - 0
energy-manage-service/src/main/java/com/energy/manage/service/domain/dto/analysis/AnalysisTypeExtDto.java

@@ -0,0 +1,17 @@
+package com.energy.manage.service.domain.dto.analysis;
+
+import com.energy.manage.common.po.analysis.AnalysisTypePo;
+
+/**
+ * @author chy
+ * @date 2025/2/7 14:47
+ * @desc
+ */
+public class AnalysisTypeExtDto extends AnalysisTypePo {
+
+    /**
+     * 数据转换类型code
+     */
+    private String dataTransferTypeCode;
+
+}

+ 32 - 1
energy-manage-service/src/main/java/com/energy/manage/service/domain/vo/analysis/AnalysisRelateInfoVo.java

@@ -6,6 +6,8 @@ import lombok.Data;
 import lombok.experimental.Accessors;
 
 import java.util.Date;
+import java.util.List;
+import java.util.Map;
 import java.util.Set;
 
 /**
@@ -20,7 +22,7 @@ public class AnalysisRelateInfoVo {
     /**
      * 已分析的批次信息
      */
-    private Set<AnalysisTypeShortVo> analysisTypes;
+    private List<Map<String, Object>> analysisTypes;
 
     /**
      * 已分析的风机列表
@@ -41,6 +43,19 @@ public class AnalysisRelateInfoVo {
     /**
      * 数据结束时间
      */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
+    private Date analysisStartTime;
+
+
+    /**
+     * 数据开始时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
+    private Date analysisEndTime;
+
+    /**
+     * 数据结束时间
+     */
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm",timezone = "GMT+8")
     private Date dataEndTime;
 
@@ -49,4 +64,20 @@ public class AnalysisRelateInfoVo {
      */
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm",timezone = "GMT+8")
     private Date analysisFinishTime;
+
+    /**
+     * 分析完成时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm",timezone = "GMT+8")
+    private Date createTime;
+
+    /**
+     * 分析备注
+     */
+    private String sketch;
+
+    /**
+     * 分析主题
+     */
+    private String analysisName;
 }

+ 5 - 0
energy-manage-service/src/main/java/com/energy/manage/service/domain/vo/analysis/AnalysisResultVo.java

@@ -131,4 +131,9 @@ public class AnalysisResultVo {
      */
     private List<AnalysisResultReportVo> reportVos;
 
+    /**
+     * 当前序号
+     */
+    private String orderNum;
+
 }

+ 1 - 1
energy-manage-service/src/main/java/com/energy/manage/service/domain/vo/analysis/AnalysisTypeShortVo.java

@@ -26,7 +26,7 @@ public class AnalysisTypeShortVo {
 
     @Override
     public int hashCode() {
-        return Objects.hash(analysisTypeCode,analysisTypeCode);
+        return Objects.hash(analysisTypeCode,analysisTypeName);
     }
 
     @Override

+ 16 - 1
energy-manage-service/src/main/java/com/energy/manage/service/mappers/analysis/AnalysisResultMapper.java

@@ -47,7 +47,9 @@ public interface AnalysisResultMapper extends MyMapper<AnalysisResultPo> {
      * @param fieldCodes
      * @return
      */
-    List<AnalysisResultVo> selectLastBatchResultByFieldCode(@Param("fieldCodes") List<String> fieldCodes);
+    List<AnalysisResultVo> selectLastBatchResultByFieldCode(@Param("fieldCodes") List<String> fieldCodes,
+                                                            @Param("startTime") String startTime,
+                                                            @Param("endTime") String endTime);
 
 
     /**
@@ -100,4 +102,17 @@ public interface AnalysisResultMapper extends MyMapper<AnalysisResultPo> {
      */
     AnalysisResultPo selectByBatchCode(@Param("batchCode") String batchCode);
 
+
+    /**
+     * 查询排队中或运行中的分析数量
+     * @return
+     */
+    int selectAnalysisingCount();
+
+    /**
+     * 查询运行中的分析数量
+     * @return
+     */
+    int selectAnalysisProcessingCount();
+
 }

+ 8 - 1
energy-manage-service/src/main/java/com/energy/manage/service/mappers/analysis/AnalysisTypeMapper.java

@@ -34,5 +34,12 @@ public interface AnalysisTypeMapper extends MyMapper <AnalysisTypePo>{
      * @param typeCodes
      * @return
      */
-    List<String> selecFlagtByCode(@Param("typeCodes") List<String> typeCodes);
+    List<String> selecFlagtByCodes(@Param("typeCodes") List<String> typeCodes);
+
+    /**
+     * 单个查询
+     * @param typeCode
+     * @return
+     */
+    String selecFlagByCode(@Param("typeCode") String typeCode);
 }

+ 21 - 0
energy-manage-service/src/main/java/com/energy/manage/service/mappers/analysisdatarelationrecords/AnalysisDataRelationRecordsMapper.java

@@ -0,0 +1,21 @@
+package com.energy.manage.service.mappers.analysisdatarelationrecords;
+
+import com.energy.manage.common.mapper.MyMapper;
+import com.energy.manage.common.po.analysisdatarelationrecords.AnalysisDataRelationRecordsPo;
+import org.apache.ibatis.annotations.Param;
+import org.springframework.stereotype.Repository;
+
+/**
+ * @Author: chy
+ * @Date: 2025/2/11 10:02
+ */
+@Repository
+public interface AnalysisDataRelationRecordsMapper extends MyMapper<AnalysisDataRelationRecordsPo> {
+
+
+    AnalysisDataRelationRecordsPo selectByTaskId(@Param("taskId") String taskId);
+
+    @Override
+    int insertSelective(AnalysisDataRelationRecordsPo analysisDataRelationRecordsPo);
+
+}

+ 39 - 0
energy-manage-service/src/main/java/com/energy/manage/service/mappers/analysispriorityrecords/AnalysisPriorityRecordsMapper.java

@@ -0,0 +1,39 @@
+package com.energy.manage.service.mappers.analysispriorityrecords;
+
+
+import com.energy.manage.common.mapper.MyMapper;
+import com.energy.manage.common.po.analysispriorityrecords.AnalysisPriorityRecordsPo;
+import org.apache.ibatis.annotations.Param;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+
+/**
+ * @Author: chy
+ * @Date: 2025/2/11 10:02
+ */
+
+@Repository
+public interface AnalysisPriorityRecordsMapper extends MyMapper<AnalysisPriorityRecordsPo> {
+
+    /**
+     * 查询排在第一位的优先级
+     * @return
+     */
+    AnalysisPriorityRecordsPo queryFirstPriority();
+
+    /**
+     * 更新执行状态
+     * @param taskId
+     * @param executeStatus
+     * @return
+     */
+    int updateExecuteStatus(@Param("taskId") String taskId,
+                            @Param("executeStatus") Integer executeStatus);
+
+    /**
+     * 查询所有的优先级
+     * @return
+     */
+    List<AnalysisPriorityRecordsPo> queryAllPriority();
+}

+ 3 - 1
energy-manage-service/src/main/java/com/energy/manage/service/mappers/windexceptioncount/WindExceptionCountMapper.java

@@ -48,7 +48,9 @@ public interface WindExceptionCountMapper extends MyMapper<WindExceptionCountPo>
      * @param fieldCodes
      * @return
      */
-    List<WindExceptionCountVo> selectByfieldCodes(@Param("fieldCodes") List<String> fieldCodes);
+    List<WindExceptionCountVo> selectByfieldCodes(@Param("fieldCodes") List<String> fieldCodes,
+                                                  @Param("startTime") String startTime,
+                                                  @Param("endTime") String endTime);
 
     /**
      * 通过批次查询有异常的风机信息

+ 2 - 1
energy-manage-service/src/main/java/com/energy/manage/service/service/analysis/AnalysisResultReportService.java

@@ -13,6 +13,7 @@ import java.util.List;
 public interface AnalysisResultReportService {
 
 
+
     /**
      * 批量添加保存报告
      * @param resultReportVos
@@ -25,5 +26,5 @@ public interface AnalysisResultReportService {
      * 查询报告类型
      * @return
      */
-    List<AnalysisResultReportTypeVo> getRportType();
+    List<AnalysisResultReportTypeVo> getRportType(Boolean isIntranet);
 }

+ 10 - 2
energy-manage-service/src/main/java/com/energy/manage/service/service/analysis/AnalysisService.java

@@ -28,7 +28,7 @@ public interface AnalysisService {
      * @param analysisResultDto
      * @return
      */
-    List<AnalysisResultVo> analysisResultList(AnalysisResultDto analysisResultDto);
+    List<AnalysisResultVo> analysisResultList(AnalysisResultDto analysisResultDto,Boolean isIntranet);
 
 
 
@@ -63,6 +63,14 @@ public interface AnalysisService {
 
 
     /**
+     * 调用分析并做调用算法参数处理
+     * @param analysisDto
+     * @throws Exception
+     */
+    void callAnalysis(AnalysisDto analysisDto) throws Exception;
+
+
+    /**
      * 分析编辑查询
      * @param batchCode
      * @return
@@ -74,7 +82,7 @@ public interface AnalysisService {
      * @param batchCode
      * @return
      */
-    Set<AnalysisTypeShortVo> queryAnalysisedType(String batchCode);
+    List<Map<String, Object>> queryAnalysisedType(String batchCode);
 
     /**
      * 查询所有的分析类型

+ 4 - 2
energy-manage-service/src/main/java/com/energy/manage/service/service/analysis/impl/AnalysisResultReportServiceImpl.java

@@ -6,7 +6,7 @@ import com.energy.manage.service.domain.vo.analysis.AnalysisResultReportTypeVo;
 import com.energy.manage.service.domain.vo.analysis.AnalysisResultReportVo;
 import com.energy.manage.service.mappers.analysis.AnalysisResultReportMapper;
 import com.energy.manage.service.service.analysis.AnalysisResultReportService;
-import org.springframework.beans.BeanUtils;
+import com.energy.manage.service.util.NetUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -35,6 +35,7 @@ public class AnalysisResultReportServiceImpl implements AnalysisResultReportServ
     public int saveReportBatch(List<AnalysisResultReportVo> resultReportVos) {
         AtomicInteger integer = new AtomicInteger(0);
         resultReportVos.forEach(item -> {
+            item.setReportAddr(item.getReportAddr().replaceFirst(NetUtils.IP_PORT_REGEX, ""));
             AnalysisResultReportPo resultReportPo = analysisResultReportMapper.selectByBatchCodeAndReportType(item.getBatchCode(),item.getReportType());
             if(resultReportPo != null){
                 analysisResultReportMapper.updateReport(item);
@@ -52,7 +53,7 @@ public class AnalysisResultReportServiceImpl implements AnalysisResultReportServ
      * @return
      */
     @Override
-    public List<AnalysisResultReportTypeVo> getRportType() {
+    public List<AnalysisResultReportTypeVo> getRportType(Boolean isIntranet) {
         List<AnalysisResultReportTypeVo> resultReportTypeVos = new ArrayList<>();
         Arrays.stream(ResultReportEnums.values()).forEach(item -> {
             AnalysisResultReportTypeVo resultReportTypeVo = new AnalysisResultReportTypeVo();
@@ -64,4 +65,5 @@ public class AnalysisResultReportServiceImpl implements AnalysisResultReportServ
     }
 
 
+
 }

+ 246 - 173
energy-manage-service/src/main/java/com/energy/manage/service/service/analysis/impl/AnalysisServiceImpl.java

@@ -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());
     }
 
 }

+ 7 - 1
energy-manage-service/src/main/java/com/energy/manage/service/service/homepage/HomePageService.java

@@ -18,8 +18,14 @@ public interface HomePageService {
      * 驾驶舱首页查询
      * @param codeNumber
      * @param codeType
+     * @param startTime
+     * @param endTime
      */
-    HomePageVo queryStatistics(Integer roleId, String codeNumber, String codeType);
+    HomePageVo queryStatistics(Integer roleId,
+                               String codeNumber,
+                               String codeType,
+                               String startTime,
+                               String endTime);
 
 
     /**

+ 15 - 7
energy-manage-service/src/main/java/com/energy/manage/service/service/homepage/impl/HomePageServiceImpl.java

@@ -58,7 +58,11 @@ public class HomePageServiceImpl implements HomePageService {
      * @param codeType
      */
     @Override
-    public HomePageVo queryStatistics(Integer roleId,String codeNumber, String codeType) {
+    public HomePageVo queryStatistics(Integer roleId,
+                                      String codeNumber,
+                                      String codeType,
+                                      String startTime,
+                                      String endTime) {
         //返回实体对象
         HomePageVo homePageVo = new HomePageVo();
         //风场
@@ -74,9 +78,9 @@ public class HomePageServiceImpl implements HomePageService {
             return homePageVo;
         }
         //设置未分析、分析中、已分析数目
-        setAnalysisCount(homePageVo,fieldCodes);
+        setAnalysisCount(homePageVo,fieldCodes,startTime,endTime);
         //设置异常数、异常信息
-        setErrCountAndInfo(homePageVo,fieldCodes);
+        setErrCountAndInfo(homePageVo,fieldCodes,startTime,endTime);
         return homePageVo;
     }
 
@@ -160,9 +164,11 @@ public class HomePageServiceImpl implements HomePageService {
      * 分析数设置
      * @param homePageVo
      * @param fieldCodes
+     * @param startTime
+     * @param endTime
      */
-    private void setAnalysisCount(HomePageVo homePageVo,List<String> fieldCodes){
-        List<AnalysisResultVo> resultVos = analysisResultMapper.selectLastBatchResultByFieldCode(fieldCodes);
+    private void setAnalysisCount(HomePageVo homePageVo,List<String> fieldCodes,String startTime,String endTime){
+        List<AnalysisResultVo> resultVos = analysisResultMapper.selectLastBatchResultByFieldCode(fieldCodes,startTime,endTime);
         Integer total = fieldCodes.size();
         if(CollectionUtils.isEmpty(resultVos)){
             //分析结果为空的时候证明没有风场没有进行分析
@@ -188,9 +194,11 @@ public class HomePageServiceImpl implements HomePageService {
      * 设置异常数
      * @param homePageVo
      * @param fieldCodes
+     * @param startTime
+     * @param endTime
      */
-    public void setErrCountAndInfo(HomePageVo homePageVo, List<String> fieldCodes){
-        List<WindExceptionCountVo> exceptionCounts = exceptionCountMapper.selectByfieldCodes(fieldCodes);
+    public void setErrCountAndInfo(HomePageVo homePageVo, List<String> fieldCodes, String startTime, String endTime){
+        List<WindExceptionCountVo> exceptionCounts = exceptionCountMapper.selectByfieldCodes(fieldCodes, startTime, endTime);
         //风机异常数
         Set<String> engineCodes = new HashSet<>();
         //处理异常数

+ 114 - 0
energy-manage-service/src/main/java/com/energy/manage/service/task/AnalysisTask.java

@@ -0,0 +1,114 @@
+package com.energy.manage.service.task;
+
+import com.energy.manage.common.po.analysisdatarelationrecords.AnalysisDataRelationRecordsPo;
+import com.energy.manage.common.po.analysispriorityrecords.AnalysisPriorityRecordsPo;
+import com.energy.manage.service.constant.analysis.AnalysisConstants;
+import com.energy.manage.service.domain.dto.analysis.AnalysisDto;
+import com.energy.manage.service.mappers.analysis.AnalysisResultMapper;
+import com.energy.manage.service.mappers.analysisdatarelationrecords.AnalysisDataRelationRecordsMapper;
+import com.energy.manage.service.mappers.analysispriorityrecords.AnalysisPriorityRecordsMapper;
+import com.energy.manage.service.service.analysis.AnalysisService;
+import com.xxl.job.core.handler.annotation.XxlJob;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * @author chy
+ * @date 2025/2/11 16:18
+ * @desc 分析任务执行
+ */
+
+@Slf4j
+@Component
+public class AnalysisTask {
+
+    @Autowired
+    private AnalysisService analysisService;
+
+    @Autowired
+    private AnalysisPriorityRecordsMapper priorityRecordsMapper;
+
+    @Autowired
+    private AnalysisResultMapper resultMapper;
+
+    @Autowired
+    private AnalysisDataRelationRecordsMapper dataRelationRecordsMapper;
+
+    @XxlJob(value = "analysisTaskExecute")
+    public void analysisTaskExecute() {
+        log.info("触发自动分析定时任务开始");
+        try{
+            int analysisingCount = resultMapper.selectAnalysisProcessingCount();
+            if (analysisingCount > 0){
+                log.info("当前有正在分析的数据,排队分析返回");
+                return;
+            }
+            //获取要执行的分析任务
+            AnalysisPriorityRecordsPo priorityRecordsPo = priorityRecordsMapper.queryFirstPriority();
+            if (priorityRecordsPo == null){
+                log.info("当前没有要分析的任务在排队中,分析返回");
+                return;
+            }
+            //调用分析
+            analysisService.callAnalysis(getAnalysisDto(priorityRecordsPo));
+            //更新任务优先级状态表
+            priorityRecordsMapper.updateExecuteStatus(priorityRecordsPo.getTaskId(), AnalysisConstants.ON_CALL);
+        }catch (Exception e){
+            log.error("触发自动分析定时任务异常",e);
+        }
+
+        log.info("触发自动分析定时任务结束");
+    }
+
+
+    /**
+     * 获取要执行的分析任务参数
+     * @return
+     */
+    private AnalysisDto getAnalysisDto(AnalysisPriorityRecordsPo priorityRecordsPo){
+        AnalysisDataRelationRecordsPo dataRelationRecordsPo = dataRelationRecordsMapper.selectByTaskId(priorityRecordsPo.getTaskId());
+        AnalysisDto returnDto = new AnalysisDto();
+        BeanUtils.copyProperties(dataRelationRecordsPo,returnDto);
+        //设置分析类型
+        returnDto.setConfigAnalysis(Arrays.asList(dataRelationRecordsPo.getConfigAnalysis().split(",")));
+        //设置风机
+        if(StringUtils.isNotEmpty(dataRelationRecordsPo.getTurbines())){
+            returnDto.setTurbines(Arrays.asList(dataRelationRecordsPo.getTurbines().split(",")));
+        }
+        //设置排除月份
+        if(StringUtils.isNotEmpty(dataRelationRecordsPo.getExcludingMonths())) {
+            returnDto.setExcludingMonths(Arrays.asList(dataRelationRecordsPo.getExcludingMonths().split(",")));
+        }
+        //设置有功功率
+        if(StringUtils.isNotEmpty(dataRelationRecordsPo.getValueActivePower())) {
+            returnDto.setValueActivePower(getDoubleList(dataRelationRecordsPo.getValueActivePower()));
+        }
+        //设置风机转速
+        if(StringUtils.isNotEmpty(dataRelationRecordsPo.getValueGeneratorSpeed())) {
+            returnDto.setValueGeneratorSpeed(getDoubleList(dataRelationRecordsPo.getValueGeneratorSpeed()));
+        }
+        //设置桨距角
+        if(StringUtils.isNotEmpty(dataRelationRecordsPo.getValuePitchAngle())) {
+            returnDto.setValuePitchAngle(getDoubleList(dataRelationRecordsPo.getValuePitchAngle()));
+        }
+        //设置风速
+        if(StringUtils.isNotEmpty(dataRelationRecordsPo.getValueWindSpeed())) {
+            returnDto.setValueWindSpeed(getDoubleList(dataRelationRecordsPo.getValueWindSpeed()));
+        }
+        return returnDto;
+     }
+
+     private List<Double> getDoubleList(String value){
+         if(StringUtils.isNotEmpty(value)){
+             return Arrays.asList(value.split(",")).stream().map(Double::parseDouble).collect(Collectors.toList());
+         }
+         return null;
+     }
+}

+ 19 - 19
energy-manage-service/src/main/java/com/energy/manage/service/task/AutoAnalysisTask.java

@@ -42,25 +42,25 @@ public class AutoAnalysisTask {
     /**
      * 自动分析
      */
-    @XxlJob(value = "autoAnalysis")
-    void autoAnalysis() {
-        log.info("触发自动分析定时任务开始");
-        if(analysisService.checkAnalysising()){
-            log.info("当前有正在分析的数据,自动分析返回");
-            return;
-        }
-        //获取转换完成且未自动分析的的批次号
-        DataTransferVo dataTransferVo = dataTransferMapper.selectBatchCodeForAutoAnaly();
-        if(dataTransferVo == null || StringUtils.isBlank(dataTransferVo.getBatchCode())){
-            log.info("当前没有秒级、分钟级全部转换完成的数据,自动分析返回");
-            return;
-        }
-        //分析调用
-        analysisService.analysis(assignmentAnalysisDto(dataTransferVo));
-        //自动分析调用完成之后更新状态
-        analysisResultMapper.updateCallStatus(dataTransferVo.getBatchCode());
-        log.info("触发自动分析定时任务结束");
-    }
+//    @XxlJob(value = "autoAnalysis")
+//    void autoAnalysis() {
+//        log.info("触发自动分析定时任务开始");
+//        if(analysisService.checkAnalysising()){
+//            log.info("当前有正在分析的数据,自动分析返回");
+//            return;
+//        }
+//        //获取转换完成且未自动分析的的批次号
+//        DataTransferVo dataTransferVo = dataTransferMapper.selectBatchCodeForAutoAnaly();
+//        if(dataTransferVo == null || StringUtils.isBlank(dataTransferVo.getBatchCode())){
+//            log.info("当前没有秒级、分钟级全部转换完成的数据,自动分析返回");
+//            return;
+//        }
+//        //分析调用
+//        analysisService.analysis(assignmentAnalysisDto(dataTransferVo));
+//        //自动分析调用完成之后更新状态
+//        analysisResultMapper.updateCallStatus(dataTransferVo.getBatchCode());
+//        log.info("触发自动分析定时任务结束");
+//    }
 
 
     /**

+ 29 - 1
energy-manage-service/src/main/java/com/energy/manage/service/util/NetUtils.java

@@ -1,6 +1,9 @@
 package com.energy.manage.service.util;
 
+import com.energy.manage.service.property.analysis.AlgorithmProperties;
 import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
 
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
@@ -26,7 +29,15 @@ public class NetUtils {
     /**
      * ip:port 正则
      */
-    private final static String IP_PORT_REGEX = "^(http[s]?://)?([^:/\\s]+)(:)+[0-9]{1,}/";
+    public final static String IP_PORT_REGEX = "^(http[s]?://)?([^:/\\s]+)(:)+[0-9]{1,}/";
+
+    /**
+     * 协议
+     */
+    private static final String FILE_ADDR_FREFIX = "http://";
+
+
+//    private static AlgorithmProperties algorithmProperties;
 
 
     /**
@@ -55,4 +66,21 @@ public class NetUtils {
         Matcher matcher = p.matcher(url);
         return matcher.find() ? matcher.group() : null ;
     }
+
+    /**
+     * 获取分析结果文件地址前缀并替换或添加
+     * @param isIntranet
+     * @param fileAddr
+     * @return
+     */
+    public static String getFilePath(boolean isIntranet,String fileAddr){
+        AlgorithmProperties algorithmProperties = SpringTools.getApplicationContext().getBean(AlgorithmProperties.class);
+        String minIoIpPort = isIntranet ? algorithmProperties.getAnalysisFileIntranetAddr() : algorithmProperties.getAnalysisFileExternalAddr();
+        //数据兼容
+        if(StringUtils.startsWith(fileAddr,FILE_ADDR_FREFIX)){
+            return fileAddr.replace(NetUtils.getIpAndPort(fileAddr),minIoIpPort);
+        }
+        return minIoIpPort + fileAddr;
+    }
+
 }

+ 18 - 22
energy-manage-service/src/main/resources/mybatis/analysis/AnalysisResultMapper.xml

@@ -30,34 +30,20 @@
 
     <select id="selectByCondition" parameterType="com.energy.manage.service.domain.dto.analysis.AnalysisResultDto" resultType="com.energy.manage.service.domain.vo.analysis.AnalysisResultVo">
         select
-            field.field_name,
-            result.field_code,
-            result.batch_code,
-            result.analysis_state,
-            result.err_state,
-            result.err_info,
-            result.create_time,
-            result.analysis_progress,
-            result.on_off_call,
-            result.analysis_name,
-            result.data_start_time,
-            result.data_end_time,
-            result.sketch,
-            result.data_type_code,
-            result.analysis_start_time,
-            result.analysis_finish_time,
-            type.transfer_type_name as data_type_name
+            result.*,
+            field.field_name
         from analysis_result result
         left join sys_organization_auth auth
         on result.field_code = auth.code_number
         left join wind_field field
         on result.field_code = field.field_code
-        left join data_transfer_type type
-        on result.data_type_code = type.transfer_type
         where auth.role_id = #{roleId,jdbcType=INTEGER}
         <if test="fieldName != null and fieldName != ''">
             and field.field_name like concat('%', #{fieldName,jdbcType=VARCHAR}, '%')
         </if>
+        <if test="analysisName != null and analysisName != ''">
+            and result.analysis_name like concat('%', #{analysisName,jdbcType=VARCHAR}, '%')
+        </if>
         <if test="analysisState != null">
             and result.analysis_state = #{analysisState}
         </if>
@@ -111,7 +97,7 @@
         where batch_code = #{batchCode,jdbcType=VARCHAR}
     </select>
 
-    <select id="selectLastBatchResultByFieldCode" parameterType="java.lang.String" resultType="com.energy.manage.service.domain.vo.analysis.AnalysisResultVo">
+    <select id="selectLastBatchResultByFieldCode"  resultType="com.energy.manage.service.domain.vo.analysis.AnalysisResultVo">
         select *
         from  analysis_result
         where id in (
@@ -123,6 +109,17 @@
                 #{item,jdbcType=VARCHAR}
             </foreach>
         )
+        <if test="startTime != null and endTime != null">
+            and analysis_start_time between #{startTime,jdbcType=VARCHAR} and #{endTime,jdbcType=VARCHAR}
+        </if>
+    </select>
+
+    <select id="selectAnalysisingCount" resultType="int">
+        select count(*) from analysis_result where analysis_state = 10 or analysis_state = 20
+    </select>
+
+    <select id="selectAnalysisProcessingCount" resultType="int">
+        select count(*) from analysis_result where analysis_state = 20
     </select>
 
 
@@ -169,8 +166,7 @@
 
     <update id="updateByBatchCode" parameterType="com.energy.manage.service.domain.dto.analysis.AnalysisDto">
         update analysis_result
-        set analysis_state = 10,
-            data_start_time = #{beginTime,jdbcType=INTEGER},
+        set  data_start_time = #{beginTime,jdbcType=INTEGER},
             data_end_time = #{endTime,jdbcType=VARCHAR},
             data_type_code = #{scada,jdbcType=VARCHAR},
             analysis_start_time = now(),

+ 8 - 1
energy-manage-service/src/main/resources/mybatis/analysis/AnalysisTypeMapper.xml

@@ -31,7 +31,7 @@
             and type_code = #{typeCode,jdbcType=VARCHAR}
         </if>
     </select>
-    <select id="selecFlagtByCode" parameterType="java.lang.String" resultType="java.lang.String">
+    <select id="selecFlagtByCodes" parameterType="java.lang.String" resultType="java.lang.String">
         select
         type_flag
         from analysis_type
@@ -43,4 +43,11 @@
                 </foreach>
         </if>
     </select>
+
+    <select id="selecFlagByCode" parameterType="java.lang.String" resultType="java.lang.String">
+        select
+        type_flag
+        from analysis_type
+        where  type_code = #{typeCode,jdbcType=VARCHAR}
+    </select>
 </mapper>

+ 66 - 0
energy-manage-service/src/main/resources/mybatis/analysisdatarelationrecords/AnalysisDataRelationRecordsPoMapper.xml

@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.energy.manage.service.mappers.analysisdatarelationrecords.AnalysisDataRelationRecordsMapper">
+  <resultMap id="BaseResultMap" type="com.energy.manage.common.po.analysisdatarelationrecords.AnalysisDataRelationRecordsPo">
+    <id column="id" jdbcType="BIGINT" property="id" />
+    <result column="data_batch_num" jdbcType="VARCHAR" property="dataBatchNum" />
+    <result column="power_farm_id" jdbcType="VARCHAR" property="powerFarmID" />
+    <result column="begin_time" jdbcType="TIMESTAMP" property="beginTime" />
+    <result column="end_time" jdbcType="TIMESTAMP" property="endTime" />
+    <result column="excluding_months" jdbcType="VARCHAR" property="excludingMonths" />
+    <result column="cretate_time" jdbcType="TIMESTAMP" property="cretateTime" />
+    <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
+    <result column="config_analysis" jdbcType="VARCHAR" property="configAnalysis" />
+    <result column="turbines" jdbcType="VARCHAR" property="turbines" />
+    <result column="value_wind_speed" jdbcType="VARCHAR" property="valueWindSpeed" />
+    <result column="value_pitch_angle" jdbcType="VARCHAR" property="valuePitchAngle" />
+    <result column="value_active_power" jdbcType="VARCHAR" property="valueActivePower" />
+    <result column="value_generator_speed" jdbcType="VARCHAR" property="valueGeneratorSpeed" />
+    <result column="task_id" jdbcType="VARCHAR" property="taskId" />
+    <result column="auto_or_manual" jdbcType="VARCHAR" property="autoOrManual" />
+  </resultMap>
+  <sql id="Base_Column_List">
+    id, data_batch_num, power_farm_id, begin_time, end_time, excluding_months, is_delete,
+    cretate_time, update_time, config_analysis, turbines, value_wind_speed, value_pitch_angle,
+    value_active_power, value_generator_speed, task_id, auto_or_manual
+  </sql>
+
+  <select id="selectByTaskId" parameterType="java.lang.String" resultMap="BaseResultMap">
+        select * from analysis_data_relation_records where task_id = #{taskId,jdbcType=VARCHAR}
+  </select>
+
+  <insert id="insertSelective" parameterType="com.energy.manage.common.po.analysisdatarelationrecords.AnalysisDataRelationRecordsPo">
+      INSERT INTO analysis_data_relation_records
+      <trim prefix="(" suffix=")" suffixOverrides=",">
+        <if test="dataBatchNum != null">data_batch_num,</if>
+        <if test="powerFarmID != null">power_farm_id,</if>
+        <if test="beginTime != null">begin_time,</if>
+        <if test="endTime != null">end_time,</if>
+        <if test="excludingMonths != null">excluding_months,</if>
+        <if test="configAnalysis != null">config_analysis,</if>
+        <if test="turbines != null">turbines,</if>
+        <if test="valueWindSpeed != null">value_wind_speed,</if>
+        <if test="valuePitchAngle != null">value_pitch_angle,</if>
+        <if test="valueActivePower != null">value_active_power,</if>
+        <if test="valueGeneratorSpeed != null">value_generator_speed,</if>
+        <if test="taskId != null">task_id,</if>
+        <if test="autoOrManual != null">auto_or_manual,</if>
+      </trim>
+      <trim prefix="VALUES (" suffix=")" suffixOverrides=",">
+        <if test="dataBatchNum != null">#{dataBatchNum,jdbcType=VARCHAR},</if>
+        <if test="powerFarmID != null">#{powerFarmID,jdbcType=VARCHAR},</if>
+        <if test="beginTime != null">#{beginTime,jdbcType=TIMESTAMP},</if>
+        <if test="endTime != null">#{endTime,jdbcType=TIMESTAMP},</if>
+        <if test="excludingMonths != null">#{excludingMonths,jdbcType=VARCHAR},</if>
+        <if test="configAnalysis != null">#{configAnalysis,jdbcType=VARCHAR},</if>
+        <if test="turbines != null">#{turbines,jdbcType=VARCHAR},</if>
+        <if test="valueWindSpeed != null">#{valueWindSpeed,jdbcType=VARCHAR},</if>
+        <if test="valuePitchAngle != null">#{valuePitchAngle,jdbcType=VARCHAR},</if>
+        <if test="valueActivePower != null">#{valueActivePower,jdbcType=VARCHAR},</if>
+        <if test="valueGeneratorSpeed != null">#{valueGeneratorSpeed,jdbcType=VARCHAR},</if>
+        <if test="taskId != null">#{taskId,jdbcType=VARCHAR},</if>
+        <if test="autoOrManual != null">#{autoOrManual,jdbcType=VARCHAR},</if>
+      </trim>
+  </insert>
+
+</mapper>

+ 29 - 0
energy-manage-service/src/main/resources/mybatis/analysispriorityrecords/AnalysisPriorityRecordsMapper.xml

@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.energy.manage.service.mappers.analysispriorityrecords.AnalysisPriorityRecordsMapper">
+  <resultMap id="BaseResultMap" type="com.energy.manage.common.po.analysispriorityrecords.AnalysisPriorityRecordsPo">
+    <id column="id" jdbcType="BIGINT" property="id" />
+    <result column="batch_code" jdbcType="VARCHAR" property="batchCode" />
+    <result column="priority" jdbcType="TINYINT" property="priority" />
+    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
+    <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
+    <result column="execute_status" jdbcType="TINYINT" property="executeStatus" />
+    <result column="task_id" jdbcType="VARCHAR" property="taskId" />
+  </resultMap>
+  <sql id="Base_Column_List">
+    id, batch_code, priority, create_time, update_time, execute_status, task_id
+  </sql>
+
+  <select id="queryFirstPriority" resultMap="BaseResultMap">
+    select * from analysis_priority_records where execute_status = 0 order by priority desc , update_time asc limit 1
+  </select>
+
+  <select id="queryAllPriority" resultMap="BaseResultMap">
+    select * from analysis_priority_records where execute_status = 0 order by priority desc , update_time asc
+  </select>
+  <update id="updateExecuteStatus">
+    update analysis_priority_records
+    set execute_status = #{executeStatus,jdbcType=TINYINT}
+    where task_id = #{taskId,jdbcType=VARCHAR}
+  </update>
+</mapper>

+ 5 - 2
energy-manage-service/src/main/resources/mybatis/windexceptioncount/WindExceptionCountMapper.xml

@@ -49,7 +49,7 @@
         order by count.update_time desc
     </select>
 
-    <select id="selectByfieldCodes" parameterType="java.lang.String" resultType="com.energy.manage.service.domain.vo.windexceptioncount.WindExceptionCountVo">
+    <select id="selectByfieldCodes" resultType="com.energy.manage.service.domain.vo.windexceptioncount.WindExceptionCountVo">
         select
             count.*,
             engine.engine_name,
@@ -74,7 +74,10 @@
                     <foreach collection="fieldCodes" open="(" separator="," close=")" item="fieldCode">
                         #{fieldCode,jdbcType=VARCHAR}
                     </foreach>
-                );
+                )
+        <if test="startTime != null and endTime != null">
+            and analysis_start_time between #{startTime,jdbcType=VARCHAR} and #{endTime,jdbcType=VARCHAR}
+        </if>
     </select>
 
     <insert id="insertPoSelective" parameterType="com.energy.manage.service.domain.dto.windexceptioncount.WindExceptionCountDto">