소스 검색

对接后提交相关代码

shiyue 2 주 전
부모
커밋
b02821f637
27개의 변경된 파일815개의 추가작업 그리고 202개의 파일을 삭제
  1. 6 0
      pom.xml
  2. 16 0
      src/main/java/com/energy/manage/analyse/common/DateUtil.java
  3. 31 0
      src/main/java/com/energy/manage/analyse/common/FilePathProperties.java
  4. 79 0
      src/main/java/com/energy/manage/analyse/common/IPUtils.java
  5. 87 0
      src/main/java/com/energy/manage/analyse/common/NetUtils.java
  6. 38 0
      src/main/java/com/energy/manage/analyse/common/SpringTools.java
  7. 27 12
      src/main/java/com/energy/manage/analyse/controller/anomaly/AnomalyController.java
  8. 9 2
      src/main/java/com/energy/manage/analyse/controller/healthscores/HealthscoresController.java
  9. 7 2
      src/main/java/com/energy/manage/analyse/controller/wakediagnosis/WakeWindFarmController.java
  10. 1 0
      src/main/java/com/energy/manage/analyse/domain/vo/anomaly/AnomalyCount.java
  11. 81 18
      src/main/java/com/energy/manage/analyse/domain/vo/anomaly/AnomalyDailyVO.java
  12. 6 1
      src/main/java/com/energy/manage/analyse/domain/vo/anomaly/AnomalyModelVO.java
  13. 4 0
      src/main/java/com/energy/manage/analyse/domain/vo/anomaly/AnomalyOverviewVO.java
  14. 6 1
      src/main/java/com/energy/manage/analyse/domain/vo/healthscores/HealthscoresTendencyVO.java
  15. 1 0
      src/main/java/com/energy/manage/analyse/domain/vo/healthscores/HealthscoresWindVO.java
  16. 6 6
      src/main/java/com/energy/manage/analyse/mappers/anomaly/AnomalyWindfarmMapper.java
  17. 5 1
      src/main/java/com/energy/manage/analyse/po/anomaly/BaseAnomalyDetectorPO.java
  18. 10 7
      src/main/java/com/energy/manage/analyse/po/wakediagnosis/WakeTurbinePO.java
  19. 6 6
      src/main/java/com/energy/manage/analyse/service/anomaly/AnomalyService.java
  20. 234 56
      src/main/java/com/energy/manage/analyse/service/anomaly/impl/AnomalyServiceImpl.java
  21. 1 1
      src/main/java/com/energy/manage/analyse/service/healthscores/HealthscoresService.java
  22. 41 9
      src/main/java/com/energy/manage/analyse/service/healthscores/impl/HealthscoresServiceImpl.java
  23. 1 1
      src/main/java/com/energy/manage/analyse/service/wakediagnosis/WakeWindFarmService.java
  24. 13 1
      src/main/java/com/energy/manage/analyse/service/wakediagnosis/impl/WakeWindFarmServiceImpl.java
  25. 83 63
      src/main/resources/mybatis/anomaly/AnaomalyMapper.xml
  26. 8 8
      src/main/resources/mybatis/healthscores/HealthscoresMapper.xml
  27. 8 7
      src/main/resources/mybatis/wakediagnosis/WakeWindFarmMapper.xml

+ 6 - 0
pom.xml

@@ -285,6 +285,12 @@
             <version>3.10</version>
         </dependency>
 
+        <!-- 必须引入,scope默认compile即可 -->
+        <dependency>
+            <groupId>com.fasterxml.jackson.datatype</groupId>
+            <artifactId>jackson-datatype-jsr310</artifactId>
+        </dependency>
+
     </dependencies>
 
     <build>

+ 16 - 0
src/main/java/com/energy/manage/analyse/common/DateUtil.java

@@ -0,0 +1,16 @@
+package com.energy.manage.analyse.common;
+
+import java.time.LocalDate;
+import java.time.format.DateTimeFormatter;
+
+public class DateUtil {
+
+    private static final DateTimeFormatter FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd");
+
+    public static String formatLocalDate(LocalDate date) {
+        if (date == null) {
+            return null;
+        }
+        return date.format(FORMATTER);
+    }
+}

+ 31 - 0
src/main/java/com/energy/manage/analyse/common/FilePathProperties.java

@@ -0,0 +1,31 @@
+package com.energy.manage.analyse.common;
+
+import lombok.Data;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.cloud.context.config.annotation.RefreshScope;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+
+
+@Data
+@Component
+@RefreshScope
+public class FilePathProperties {
+
+
+
+    /**
+     * 分析文件内网地址
+     */
+    @Value("${file.intranet.addr}")
+    public String fileIntranetAddr;
+
+    /**
+     * 分析文件外网地址
+     */
+    @Value("${file.external.addr}")
+    public String fileExternalAddr;
+
+
+}

+ 79 - 0
src/main/java/com/energy/manage/analyse/common/IPUtils.java

@@ -0,0 +1,79 @@
+package com.energy.manage.analyse.common;
+
+import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.servlet.http.HttpServletRequest;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+
+public class IPUtils {
+
+    private static Logger logger = LoggerFactory.getLogger(IPUtils.class);
+
+    private static final String IP_UTILS_FLAG = ",";
+    private static final String UNKNOWN = "unknown";
+    private static final String LOCALHOST_IP = "0:0:0:0:0:0:0:1";
+    private static final String LOCALHOST_IP1 = "127.0.0.1";
+
+    /**
+     * 获取IP地址
+     * <p>
+     * 使用Nginx等反向代理软件, 则不能通过request.getRemoteAddr()获取IP地址
+     * 如果使用了多级反向代理的话,X-Forwarded-For的值并不止一个,而是一串IP地址,X-Forwarded-For中第一个非unknown的有效IP字符串,则为真实IP地址
+     */
+    public static String getIpAddr(HttpServletRequest request) {
+        String ip = null;
+        try {
+            //以下两个获取在k8s中,将真实的客户端IP,放到了x-Original-Forwarded-For。而将WAF的回源地址放到了 x-Forwarded-For了。
+            ip = request.getHeader("X-Original-Forwarded-For");
+            if (StringUtils.isEmpty(ip) || UNKNOWN.equalsIgnoreCase(ip)) {
+                ip = request.getHeader("X-Forwarded-For");
+            }
+            //获取nginx等代理的ip
+            if (StringUtils.isEmpty(ip) || UNKNOWN.equalsIgnoreCase(ip)) {
+                ip = request.getHeader("x-forwarded-for");
+            }
+            if (StringUtils.isEmpty(ip) || UNKNOWN.equalsIgnoreCase(ip)) {
+                ip = request.getHeader("X-Real-IP");
+            }
+            if (StringUtils.isEmpty(ip) || UNKNOWN.equalsIgnoreCase(ip)) {
+                ip = request.getHeader("Proxy-Client-IP");
+            }
+            if (StringUtils.isEmpty(ip) || ip.length() == 0 || UNKNOWN.equalsIgnoreCase(ip)) {
+                ip = request.getHeader("WL-Proxy-Client-IP");
+            }
+            if (StringUtils.isEmpty(ip) || UNKNOWN.equalsIgnoreCase(ip)) {
+                ip = request.getHeader("HTTP_CLIENT_IP");
+            }
+            if (StringUtils.isEmpty(ip) || UNKNOWN.equalsIgnoreCase(ip)) {
+                ip = request.getHeader("HTTP_X_FORWARDED_FOR");
+            }
+            //兼容k8s集群获取ip
+            if (StringUtils.isEmpty(ip) || UNKNOWN.equalsIgnoreCase(ip)) {
+                ip = request.getRemoteAddr();
+                if (LOCALHOST_IP1.equalsIgnoreCase(ip) || LOCALHOST_IP.equalsIgnoreCase(ip)) {
+                    //根据网卡取本机配置的IP
+                    InetAddress iNet = null;
+                    try {
+                        iNet = InetAddress.getLocalHost();
+                    } catch (UnknownHostException e) {
+                        logger.error("getClientIp error: {}", e);
+                    }
+                    ip = iNet.getHostAddress();
+                }
+            }
+        } catch (Exception e) {
+            logger.error("IPUtils ERROR ", e);
+        }
+        logger.info("getIpAddr method end, ip: {}", ip);
+        //使用代理,则获取第一个IP地址
+        if (!StringUtils.isEmpty(ip) && ip.indexOf(IP_UTILS_FLAG) > 0) {
+            ip = ip.substring(0, ip.indexOf(IP_UTILS_FLAG));
+        }
+        logger.info("getIpAddr is empty, use default ip: {}", ip);
+        return ip;
+    }
+
+}

+ 87 - 0
src/main/java/com/energy/manage/analyse/common/NetUtils.java

@@ -0,0 +1,87 @@
+package com.energy.manage.analyse.common;
+
+import org.apache.commons.lang3.StringUtils;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * @author chy
+ * @date 2024/7/9 14:08
+ * @desc
+ */
+public class NetUtils {
+
+
+    /**
+     * 内网前缀
+     */
+    private final static String INTRANET_PREFIX = "192.168";
+
+    /**
+     * 内网前缀
+     */
+    private final static String LOCAL_PREFIX = "127.0.0";
+
+    /**
+     * ip:port 正则
+     */
+    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;
+
+
+    /**
+     * 判断当前host 是否是内网
+     * @param ip
+     * @return
+     */
+    public static boolean isIntranet(String ip) {
+        if(StringUtils.isBlank(ip)){
+            return false;
+        }
+        ip.replace("http://","").replace("https://","");
+        return StringUtils.startsWithAny(ip,INTRANET_PREFIX,LOCAL_PREFIX);
+    }
+
+    /**
+     * 根据url获取IP地址与端口号
+     * @param url
+     * @return
+     */
+    public static String getIpAndPort(String url){
+        if(StringUtils.isBlank(url)){
+            return null;
+        }
+        Pattern p = Pattern.compile(IP_PORT_REGEX);
+        Matcher matcher = p.matcher(url);
+        return matcher.find() ? matcher.group() : null ;
+    }
+
+    /**
+     * 获取分析结果文件地址前缀并替换或添加
+     * @param isIntranet
+     * @param fileAddr
+     * @return
+     */
+    public static String getFilePath(boolean isIntranet,String fileAddr){
+        if(StringUtils.isEmpty(fileAddr)){
+            return null;
+        }
+        FilePathProperties filePathProperties = SpringTools.getApplicationContext().getBean(FilePathProperties.class);
+        String minIoIpPort = isIntranet ? filePathProperties.getFileIntranetAddr() : filePathProperties.getFileExternalAddr();
+        System.out.println("isIntranet===>"+isIntranet+"===>"+minIoIpPort);
+        //数据兼容
+        if(StringUtils.startsWith(fileAddr,FILE_ADDR_FREFIX)){
+            return fileAddr.replace(NetUtils.getIpAndPort(fileAddr),minIoIpPort);
+        }
+        return minIoIpPort + fileAddr;
+    }
+
+}

+ 38 - 0
src/main/java/com/energy/manage/analyse/common/SpringTools.java

@@ -0,0 +1,38 @@
+package com.energy.manage.analyse.common;
+
+import org.springframework.beans.BeansException;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
+import org.springframework.stereotype.Component;
+
+@Component
+public class SpringTools implements ApplicationContextAware {
+
+    private static ApplicationContext _applicationContext;
+
+    public SpringTools() { }
+
+    @Override
+    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
+        if (_applicationContext == null) {
+            _applicationContext = applicationContext;
+        }
+
+    }
+
+    public static ApplicationContext getApplicationContext() {
+        return _applicationContext;
+    }
+
+    public static Object getBean(String name) {
+        return getApplicationContext().getBean(name);
+    }
+
+    public static <T> T getBean(Class<T> clazz) {
+        return getApplicationContext().getBean(clazz);
+    }
+
+    public static <T> T getBean(String name, Class<T> clazz) {
+        return getApplicationContext().getBean(name, clazz);
+    }
+}

+ 27 - 12
src/main/java/com/energy/manage/analyse/controller/anomaly/AnomalyController.java

@@ -1,5 +1,7 @@
 package com.energy.manage.analyse.controller.anomaly;
 
+import com.energy.manage.analyse.common.IPUtils;
+import com.energy.manage.analyse.common.NetUtils;
 import com.energy.manage.analyse.common.reponse.ResultResp;
 import com.energy.manage.analyse.controller.base.BaseServiceController;
 import com.energy.manage.analyse.domain.dto.AnomalyDTO;
@@ -12,6 +14,7 @@ import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
+import javax.servlet.http.HttpServletRequest;
 import java.util.List;
 
 
@@ -30,8 +33,8 @@ public class AnomalyController extends BaseServiceController {
 
     @ApiOperation("查询异常风机概览")
     @PostMapping("/getAnomalyOverview")
-    public ResultResp<AnomalyOverviewVO> getAnomalyOverview(@RequestBody AnomalyDTO anomalyDTO){
-        AnomalyOverviewVO anomalyOverview= anomalyService.getAnomalyOverview(anomalyDTO);
+    public ResultResp<List<AnomalyOverviewVO>> getAnomalyOverview(@RequestBody AnomalyDTO anomalyDTO){
+        List<AnomalyOverviewVO> anomalyOverview= anomalyService.getAnomalyOverview(anomalyDTO);
         return success(anomalyOverview);
     }
 
@@ -59,37 +62,49 @@ public class AnomalyController extends BaseServiceController {
 
     @ApiOperation("风速功率模块模块")
     @PostMapping("/getAnomalyWindpwr")
-    public ResultResp<AnomalyWindpwrVO> getAnomalyWindpwr(@RequestBody AnomalyModelDTO anomalyModelDTO){
-        AnomalyWindpwrVO anomalyWindpwrVO = anomalyService.getAnomalyWindpwr(anomalyModelDTO);
+    public ResultResp<AnomalyWindpwrVO> getAnomalyWindpwr(@RequestBody AnomalyModelDTO anomalyModelDTO, HttpServletRequest request){
+
+        //判断是否是内网
+        boolean isIntranet = NetUtils.isIntranet(IPUtils.getIpAddr(request));
+        AnomalyWindpwrVO anomalyWindpwrVO = anomalyService.getAnomalyWindpwr(anomalyModelDTO,isIntranet);
         return success(anomalyWindpwrVO);
     }
 
 
     @ApiOperation("偏航模块模块")
     @PostMapping("/geAnomalyYaw")
-    public ResultResp<AnomalyYawVO> geAnomalyYaw(@RequestBody AnomalyModelDTO anomalyModelDTO){
-        AnomalyYawVO anomalyYawVO = anomalyService.geAnomalyYaw(anomalyModelDTO);
+    public ResultResp<AnomalyYawVO> geAnomalyYaw(@RequestBody AnomalyModelDTO anomalyModelDTO, HttpServletRequest request){
+        log.warn("ip" + "=====>"+IPUtils.getIpAddr(request));
+        //判断是否是内网
+        boolean isIntranet = NetUtils.isIntranet(IPUtils.getIpAddr(request));
+        AnomalyYawVO anomalyYawVO = anomalyService.geAnomalyYaw(anomalyModelDTO,isIntranet);
         return success(anomalyYawVO);
     }
 
     @ApiOperation("变桨模块模块")
     @PostMapping("/getAnomalyPitch")
-    public ResultResp<AnomalyPitchVO> getAnomalyPitch(@RequestBody AnomalyModelDTO anomalyModelDTO){
-        AnomalyPitchVO anomalyPitchVO = anomalyService.getAnomalyPitch(anomalyModelDTO);
+    public ResultResp<AnomalyPitchVO> getAnomalyPitch(@RequestBody AnomalyModelDTO anomalyModelDTO, HttpServletRequest request){
+        //判断是否是内网
+        boolean isIntranet = NetUtils.isIntranet(IPUtils.getIpAddr(request));
+        AnomalyPitchVO anomalyPitchVO = anomalyService.getAnomalyPitch(anomalyModelDTO,isIntranet);
         return success(anomalyPitchVO);
     }
 
     @ApiOperation("气动性能")
     @PostMapping("/getAerodynamics")
-    public ResultResp<AnomalyAerodynamicsVO> getAerodynamics(@RequestBody AnomalyModelDTO anomalyModelDTO){
-        AnomalyAerodynamicsVO anomalyAerodynamicsVO = anomalyService.getAerodynamics(anomalyModelDTO);
+    public ResultResp<AnomalyAerodynamicsVO> getAerodynamics(@RequestBody AnomalyModelDTO anomalyModelDTO, HttpServletRequest request){
+        //判断是否是内网
+        boolean isIntranet = NetUtils.isIntranet(IPUtils.getIpAddr(request));
+        AnomalyAerodynamicsVO anomalyAerodynamicsVO = anomalyService.getAerodynamics(anomalyModelDTO,isIntranet);
         return success(anomalyAerodynamicsVO);
     }
 
     @ApiOperation("运行状态模块模块")
     @PostMapping("/getAnomalyCtrlParam")
-    public ResultResp<AnomalyCtrlParamVO> getAnomalyCtrlParam(@RequestBody AnomalyModelDTO anomalyModelDTO){
-        AnomalyCtrlParamVO anomalyCtrlParamVO = anomalyService.getAnomalyCtrlParam(anomalyModelDTO);
+    public ResultResp<AnomalyCtrlParamVO> getAnomalyCtrlParam(@RequestBody AnomalyModelDTO anomalyModelDTO,HttpServletRequest request){
+        //判断是否是内网
+        boolean isIntranet = NetUtils.isIntranet(IPUtils.getIpAddr(request));
+        AnomalyCtrlParamVO anomalyCtrlParamVO = anomalyService.getAnomalyCtrlParam(anomalyModelDTO,isIntranet);
         return success(anomalyCtrlParamVO);
     }
 

+ 9 - 2
src/main/java/com/energy/manage/analyse/controller/healthscores/HealthscoresController.java

@@ -1,5 +1,6 @@
 package com.energy.manage.analyse.controller.healthscores;
 
+import com.energy.manage.analyse.common.DateUtil;
 import com.energy.manage.analyse.common.reponse.ResultResp;
 import com.energy.manage.analyse.controller.base.BaseServiceController;
 import com.energy.manage.analyse.domain.vo.healthscores.HealthOverviewVO;
@@ -62,8 +63,14 @@ public class HealthscoresController extends BaseServiceController {
                                                                @ApiParam(value = "engineId参数为客户内部风机ID,可通过风机概览页面获取", required = true)
                                                                @RequestParam(value = "engineId") String engineId,
                                                                @ApiParam(value = "day参数为查询多少天的趋势图数据,如7天,30天,365天", required = true)
-                                                               @RequestParam(value = "day") int day){
-        List<HealthscoresTendencyVO> list = healthscoresService.getLastDaysTrend(day,fieldId,engineId);
+                                                               @RequestParam(value = "day") int day,
+                                                               @ApiParam(value = "time", required = true)
+                                                               @RequestParam(value = "dateTime") String dateTime){
+
+        List<HealthscoresTendencyVO> list = healthscoresService.getLastDaysTrend(day,fieldId,engineId,dateTime);
+        for (HealthscoresTendencyVO item : list) {
+            item.setBirthday(DateUtil.formatLocalDate(item.getSourceDatetime()));
+        }
         return success(list);
     }
 

+ 7 - 2
src/main/java/com/energy/manage/analyse/controller/wakediagnosis/WakeWindFarmController.java

@@ -1,5 +1,7 @@
 package com.energy.manage.analyse.controller.wakediagnosis;
 
+import com.energy.manage.analyse.common.IPUtils;
+import com.energy.manage.analyse.common.NetUtils;
 import com.energy.manage.analyse.common.reponse.ResultResp;
 import com.energy.manage.analyse.controller.base.BaseServiceController;
 import com.energy.manage.analyse.domain.vo.wakewindfarm.WakeWindFarmVO;
@@ -13,6 +15,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
+import javax.servlet.http.HttpServletRequest;
 import java.util.List;
 
 /**
@@ -35,9 +38,11 @@ public class WakeWindFarmController extends BaseServiceController {
             @ApiParam(value = "fieldCode参数为平台内部风场编号", required = true)
             @RequestParam(value = "fieldCode") String fieldCode,
             @ApiParam(value = "datatime参数为查询日期,当参数为空时,默认查昨天日期的数据", required = false)
-            @RequestParam(value = "datatime",required = false) String datatime){
+            @RequestParam(value = "datatime",required = false) String datatime, HttpServletRequest request){
 
-        WakeWindFarmVO wakeWindFarmVO = wakeWindFarmService.getWakeWindFarm(fieldCode,datatime);
+        //判断是否是内网
+        boolean isIntranet = NetUtils.isIntranet(IPUtils.getIpAddr(request));
+        WakeWindFarmVO wakeWindFarmVO = wakeWindFarmService.getWakeWindFarm(fieldCode,datatime,isIntranet);
         return success(wakeWindFarmVO);
 
     }

+ 1 - 0
src/main/java/com/energy/manage/analyse/domain/vo/anomaly/AnomalyCount.java

@@ -10,6 +10,7 @@ import lombok.Setter;
 @ApiModel("模块统计雷达图")
 public class AnomalyCount {
 
+
     @ApiModelProperty("风速功率 任意检测器异常")
     private  Integer model1Count;
     @ApiModelProperty("偏航 任意检测器异常 ")

+ 81 - 18
src/main/java/com/energy/manage/analyse/domain/vo/anomaly/AnomalyDailyVO.java

@@ -1,5 +1,6 @@
 package com.energy.manage.analyse.domain.vo.anomaly;
 
+import com.fasterxml.jackson.annotation.JsonFormat;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Getter;
@@ -16,35 +17,97 @@ public class AnomalyDailyVO {
 
 
     @ApiModelProperty("时间")
+    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "Asia/Shanghai")
     private Date createTime;
 
-    @ApiModelProperty("模块1(风速功率)异常占比")
-    private BigDecimal  model1WindpwrAnomalyRate;
+    @ApiModelProperty("模块1(风速功率)功率曲线检测器--新增")
+    private BigDecimal model1WindpwrPowercurveRatio;
 
-    @ApiModelProperty("模块2(偏航)异常占比")
-    private BigDecimal model2YawAnomalyRate;
+    @ApiModelProperty("模块1(风速功率)功率散点检测器比例 -- 新增")
+    private BigDecimal model1WindpwrScatterRatio;
 
-    @ApiModelProperty("模块3(变桨)异常占比")
-    private BigDecimal model3PitchAnomalyRate;
 
-    @ApiModelProperty("模块4(运行状态)异常占比")
-    private BigDecimal model4CtrlparamAnomalyRate;
+    @ApiModelProperty("模块2(偏航)偏航角度检测器比例--新增")
+    private BigDecimal model2YawStaticyawRatio;
 
-    @ApiModelProperty("模块5(气动性能)异常占比")
-    private BigDecimal model5AerodynamicsAnomalyRatio;
 
+    @ApiModelProperty("模块2(偏航)扭缆角度检测器--新增")
+    private BigDecimal model2YawCabletwistRatio;
 
-    public AnomalyDailyVO(Date createTime, BigDecimal model1WindpwrAnomalyRate, BigDecimal model2YawAnomalyRate,
-                          BigDecimal model3PitchAnomalyRate, BigDecimal model4CtrlparamAnomalyRate,
-                            BigDecimal model5AerodynamicsAnomalyRatio ){
 
+
+    @ApiModelProperty("模块3(变桨)变桨检测器比例--新增")
+    private BigDecimal model3PitchPitchregulationRatio;
+
+
+
+    @ApiModelProperty("模块3(变桨)变桨-转速-功率检测器--新增")
+    private BigDecimal model3PitchPitchcoordRatio;
+
+
+
+    @ApiModelProperty("模块4(运行状态)电气功率质量检测器比例新增")
+    private BigDecimal model4CtrlparamPowerqualityRatio;
+
+
+    @ApiModelProperty("模块4(运行状态)机械运行状态检测器比例 -- 新增")
+    private BigDecimal model4CtrlparamOperationstateRatio;
+
+    @ApiModelProperty("模块4(运行状态)降载检测器比例--新增")
+    private BigDecimal model4CtrlparamDeloadRatio;
+
+
+    @ApiModelProperty("模块5(气动性能)Cp检测器异常比例--新增")
+    private BigDecimal model5AerodynamicsCpRatio;
+
+
+    @ApiModelProperty("模块5(气动性能)TSR风速分箱检测器异常比例--新增")
+    private BigDecimal model5AerodynamicsTsrRatio;
+
+
+    @ApiModelProperty("模块5(气动性能)Cp-TSR联合分布检测器异常比例--新增")
+    private BigDecimal model5AerodynamicsCpTsrRatio;
+
+    public AnomalyDailyVO(){}
+
+    public AnomalyDailyVO(Date createTime,
+
+            BigDecimal model1WindpwrPowercurveRatio,
+            BigDecimal model1WindpwrScatterRatio,
+
+            BigDecimal model2YawStaticyawRatio,
+            BigDecimal model2YawCabletwistRatio,
+
+            BigDecimal model3PitchPitchregulationRatio,
+            BigDecimal model3PitchPitchcoordRatio,
+
+            BigDecimal model4CtrlparamPowerqualityRatio,
+            BigDecimal model4CtrlparamOperationstateRatio,
+            BigDecimal model4CtrlparamDeloadRatio,
+
+            BigDecimal model5AerodynamicsCpRatio,
+            BigDecimal model5AerodynamicsTsrRatio,
+            BigDecimal model5AerodynamicsCpTsrRatio
+    ) {
         this.createTime = createTime;
-        this.model1WindpwrAnomalyRate = model1WindpwrAnomalyRate;
-        this.model2YawAnomalyRate = model2YawAnomalyRate;
-        this.model3PitchAnomalyRate = model3PitchAnomalyRate;
-        this.model4CtrlparamAnomalyRate = model4CtrlparamAnomalyRate;
-        this.model5AerodynamicsAnomalyRatio = model5AerodynamicsAnomalyRatio;
 
+        this.model1WindpwrPowercurveRatio = model1WindpwrPowercurveRatio;
+        this.model1WindpwrScatterRatio = model1WindpwrScatterRatio;
+
+        this.model2YawStaticyawRatio = model2YawStaticyawRatio;
+        this.model2YawCabletwistRatio = model2YawCabletwistRatio;
+
+        this.model3PitchPitchregulationRatio = model3PitchPitchregulationRatio;
+        this.model3PitchPitchcoordRatio = model3PitchPitchcoordRatio;
+
+        this.model4CtrlparamPowerqualityRatio = model4CtrlparamPowerqualityRatio;
+        this.model4CtrlparamDeloadRatio = model4CtrlparamDeloadRatio;
+        this.model4CtrlparamOperationstateRatio = model4CtrlparamOperationstateRatio;
+
+
+        this.model5AerodynamicsCpRatio = model5AerodynamicsCpRatio;
+        this.model5AerodynamicsTsrRatio = model5AerodynamicsTsrRatio;
+        this.model5AerodynamicsCpTsrRatio = model5AerodynamicsCpTsrRatio;
     }
 
 

+ 6 - 1
src/main/java/com/energy/manage/analyse/domain/vo/anomaly/AnomalyModelVO.java

@@ -2,6 +2,7 @@ package com.energy.manage.analyse.domain.vo.anomaly;
 
 import com.energy.manage.analyse.po.anomaly.AnomalyModelPO;
 import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
 import lombok.Getter;
 import lombok.Setter;
 
@@ -12,7 +13,11 @@ public class AnomalyModelVO extends AnomalyModelPO {
 
 
 
-
+    /**
+     * 风机名称
+     */
+    @ApiModelProperty("风机名称")
+    private String engineName;
 
 
 

+ 4 - 0
src/main/java/com/energy/manage/analyse/domain/vo/anomaly/AnomalyOverviewVO.java

@@ -13,6 +13,10 @@ import lombok.Setter;
 @ApiModel("风机异常概览")
 public class AnomalyOverviewVO {
 
+    private String fieldId;
+
+    private String fieldName;
+
     /**
      * 风场总异常
      */

+ 6 - 1
src/main/java/com/energy/manage/analyse/domain/vo/healthscores/HealthscoresTendencyVO.java

@@ -1,6 +1,7 @@
 package com.energy.manage.analyse.domain.vo.healthscores;
 
 import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fasterxml.jackson.annotation.JsonValue;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Getter;
@@ -8,6 +9,7 @@ import lombok.Setter;
 
 import java.math.BigDecimal;
 import java.time.LocalDate;
+import java.time.format.DateTimeFormatter;
 
 @Getter
 @Setter
@@ -38,9 +40,12 @@ public class HealthscoresTendencyVO {
      * 坐标x
      */
     @ApiModelProperty("坐标x")
-    @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
+    @JsonFormat(pattern = "yyyy-MM-dd")
     private LocalDate sourceDatetime;
 
+    @ApiModelProperty("坐标x时间")
+    private String birthday;
+
     /**
      * 叶轮健康评分 (0-100)
      * 对应数据库字段:rotor_score (DECIMAL(5,2), 可为空)

+ 1 - 0
src/main/java/com/energy/manage/analyse/domain/vo/healthscores/HealthscoresWindVO.java

@@ -10,5 +10,6 @@ import lombok.Setter;
 @ApiModel
 public class HealthscoresWindVO extends HealthscoresWindPO {
 
+    private String fieldName;
 
 }

+ 6 - 6
src/main/java/com/energy/manage/analyse/mappers/anomaly/AnomalyWindfarmMapper.java

@@ -25,7 +25,7 @@ public interface AnomalyWindfarmMapper extends MyMapper<AnomalyWindfarmPO> {
      * @param endTime
      * @return
      */
-    AnomalyOverviewVO selectAnomalyWindfarmAndFieldId(@Param("fieldId") String fieldId,
+    List<AnomalyOverviewVO> selectAnomalyWindfarmAndFieldId(@Param("fieldId") String fieldId,
                                                       @Param("beginTime") String beginTime,
                                                       @Param("endTime") String endTime);
 
@@ -68,8 +68,8 @@ public interface AnomalyWindfarmMapper extends MyMapper<AnomalyWindfarmPO> {
      * @return
      */
     BaseAnomalyDetectorPO selectAnomalyDetectorAll(@Param("fieldId") String fieldId,
-                                                   @Param("engineId") String engineId,
                                                    @Param("tableName") String tableName,
+                                                   @Param("engineId") String engineId,
                                                    @Param("beginTime") String beginTime,
                                                    @Param("endTime") String endTime);
 
@@ -119,8 +119,8 @@ public interface AnomalyWindfarmMapper extends MyMapper<AnomalyWindfarmPO> {
      */
     AnomalySensorCountVO selectAnomalySensorCountVO(@Param("fieldId") String fieldId,
                                                     @Param("year") String year,
-                                                    @Param("startDate") String beginTime,
-                                                    @Param("endDate") String endTime);
+                                                    @Param("beginTime") String beginTime,
+                                                    @Param("endTime") String endTime);
 
 
     /**
@@ -133,7 +133,7 @@ public interface AnomalyWindfarmMapper extends MyMapper<AnomalyWindfarmPO> {
      */
     AnomalyCount selectModeCount(@Param("fieldId") String fieldId,
                                  @Param("year") String year,
-                                 @Param("startDate") String beginTime,
-                                 @Param("endDate") String endTime);
+                                 @Param("beginTime") String beginTime,
+                                 @Param("endTime") String endTime);
 
 }

+ 5 - 1
src/main/java/com/energy/manage/analyse/po/anomaly/BaseAnomalyDetectorPO.java

@@ -3,6 +3,8 @@ package com.energy.manage.analyse.po.anomaly;
 import lombok.AllArgsConstructor;
 import lombok.Data;
 import lombok.NoArgsConstructor;
+
+import java.math.BigDecimal;
 import java.time.LocalDate;
 import java.time.LocalDateTime;
 
@@ -45,7 +47,7 @@ public class BaseAnomalyDetectorPO {
     /**
      * 传感器异常类型
      */
-    private Integer sensorAnomalyType;
+    private String sensorAnomalyType;
 
     /**
      * 传感器异常计数
@@ -87,6 +89,8 @@ public class BaseAnomalyDetectorPO {
      */
     private LocalDateTime createTime;
 
+    private BigDecimal detectorAnomalyRate;
+
 
 
 }

+ 10 - 7
src/main/java/com/energy/manage/analyse/po/wakediagnosis/WakeTurbinePO.java

@@ -25,29 +25,32 @@ public class WakeTurbinePO  implements Serializable {
     @ApiModelProperty(value = "主键ID", hidden = true)
     private Long id;
 
-    @ApiModelProperty(value = "风场ID", required = true, example = "WF001")
+    @ApiModelProperty(value = "风场ID", required = true)
     private String fieldId;
 
-    @ApiModelProperty(value = "风机ID", required = true, example = "TUR001")
+    @ApiModelProperty(value = "风机ID", required = true)
     private String engineId;
 
     @ApiModelProperty(value = "是否受尾流影响(0或1)")
-    private BigDecimal isWake;
+    private Integer isWake;
 
     @ApiModelProperty(value = "湍流强度")
     private BigDecimal turbulenceIntensity;
 
-    @ApiModelProperty(value = "尾流速度损失", example = "0.25")
+    @ApiModelProperty(value = "尾流速度损失")
     private BigDecimal velocityDeficit;
 
-    @ApiModelProperty(value = "检测置信度", example = "0.95")
+    @ApiModelProperty(value = "检测置信度")
     private BigDecimal confidentLevel;
 
-    @ApiModelProperty(value = "每个风机的尾流影响图", example = "0.00")
-    private BigDecimal wakeTurbinePath;
+    @ApiModelProperty(value = "每个风机的尾流影响图")
+    private String wakeTurbinePath;
 
     @ApiModelProperty(value = "数据采集时间", required = true, example = "2023-12-13")
     @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
     private Date dateResource;
 
+    @ApiModelProperty("玫瑰图 - 新增")
+    private String wakeRoseDiagramPath;
+
 }

+ 6 - 6
src/main/java/com/energy/manage/analyse/service/anomaly/AnomalyService.java

@@ -16,7 +16,7 @@ public interface AnomalyService {
      * @param anomalyDTO
      * @return
      */
-    AnomalyOverviewVO getAnomalyOverview(AnomalyDTO anomalyDTO);
+    List<AnomalyOverviewVO> getAnomalyOverview(AnomalyDTO anomalyDTO);
 
     /**
      * 柱状图
@@ -45,28 +45,28 @@ public interface AnomalyService {
      * @param anomalyModelDTO
      * @return
      */
-    AnomalyWindpwrVO getAnomalyWindpwr(AnomalyModelDTO anomalyModelDTO);
+    AnomalyWindpwrVO getAnomalyWindpwr(AnomalyModelDTO anomalyModelDTO, boolean isIntranet);
 
     /**
      * 偏航模块模块
      * @param anomalyModelDTO
      * @return
      */
-    AnomalyYawVO geAnomalyYaw(AnomalyModelDTO anomalyModelDTO);
+    AnomalyYawVO geAnomalyYaw(AnomalyModelDTO anomalyModelDTO, boolean isIntranet);
 
     /**
      * 变桨模块模块
      * @param anomalyModelDTO
      * @return
      */
-    AnomalyPitchVO getAnomalyPitch(AnomalyModelDTO anomalyModelDTO);
+    AnomalyPitchVO getAnomalyPitch(AnomalyModelDTO anomalyModelDTO, boolean isIntranet);
 
     /**
      * 运行状态模块模块
      * @param anomalyModelDTO
      * @return
      */
-    AnomalyCtrlParamVO getAnomalyCtrlParam(AnomalyModelDTO anomalyModelDTO);
+    AnomalyCtrlParamVO getAnomalyCtrlParam(AnomalyModelDTO anomalyModelDTO, boolean isIntranet);
 
 
     /**
@@ -74,7 +74,7 @@ public interface AnomalyService {
      * @param anomalyModelDTO
      * @return
      */
-    AnomalyAerodynamicsVO getAerodynamics(AnomalyModelDTO anomalyModelDTO);
+    AnomalyAerodynamicsVO getAerodynamics(AnomalyModelDTO anomalyModelDTO, boolean isIntranet);
 
 
     /**

+ 234 - 56
src/main/java/com/energy/manage/analyse/service/anomaly/impl/AnomalyServiceImpl.java

@@ -4,12 +4,15 @@ package com.energy.manage.analyse.service.anomaly.impl;
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.collection.CollectionUtil;
 import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
+import com.energy.manage.analyse.common.NetUtils;
 import com.energy.manage.analyse.constant.AnomalySensorType;
 import com.energy.manage.analyse.constant.DetectorTableEnum;
 import com.energy.manage.analyse.constant.DetectorType;
 import com.energy.manage.analyse.domain.dto.AnomalyDTO;
 import com.energy.manage.analyse.domain.dto.AnomalyModelDTO;
 import com.energy.manage.analyse.domain.vo.anomaly.*;
+import com.energy.manage.analyse.domain.vo.healthscores.HealthOverviewListVO;
+import com.energy.manage.analyse.domain.vo.healthscores.HealthscoresWindVO;
 import com.energy.manage.analyse.mappers.anomaly.AnomalyWindfarmMapper;
 import com.energy.manage.analyse.mappers.windenginegroup.WindEngineGroupMapper;
 import com.energy.manage.analyse.mappers.windfield.WindFieldMapper;
@@ -54,7 +57,7 @@ public class AnomalyServiceImpl implements AnomalyService {
 
 
     @Override
-    public AnomalyOverviewVO getAnomalyOverview(AnomalyDTO anomalyDTO) {
+    public List<AnomalyOverviewVO> getAnomalyOverview(AnomalyDTO anomalyDTO) {
 
         String fieldId = null;
         WindFieldPO windFieldPO = getWindField(anomalyDTO.getFieldCode());
@@ -81,7 +84,35 @@ public class AnomalyServiceImpl implements AnomalyService {
         DynamicDataSourceContextHolder.poll();
         // 切换数据源
         DynamicDataSourceContextHolder.push("slave");
-        return anomalyWindfarmMapper.selectAnomalyWindfarmAndFieldId(fieldId, beginTime, endTime);
+
+        List<AnomalyOverviewVO> anomalyOverviewVOList = anomalyWindfarmMapper.selectAnomalyWindfarmAndFieldId(fieldId, beginTime, endTime);
+
+        Set<String> fids = anomalyOverviewVOList.parallelStream().map(AnomalyOverviewVO::getFieldId).collect(Collectors.toSet());
+        List<WindFieldPO> fList = getWindFGroupList(fids);
+        for(AnomalyOverviewVO vo : anomalyOverviewVOList){
+            for(WindFieldPO po : fList){
+                if(vo.getFieldId().equals(po.getFieldId())){
+                    vo.setFieldName(po.getFieldName());
+                }
+            }
+        }
+        return anomalyOverviewVOList;
+    }
+
+    /**
+     * @param fids
+     * @return
+     */
+    private List<WindFieldPO> getWindFGroupList(Set<String> fids) {
+        // 清除当前
+        DynamicDataSourceContextHolder.poll();
+        // 切换数据源
+        DynamicDataSourceContextHolder.push("master");
+        // 查询平台风机模块
+        Example example = new Example(WindFieldPO.class);
+        Example.Criteria criteria = example.createCriteria();
+        criteria.andIn("fieldId", fids);
+        return  windFieldMapper.selectByExample(example);
     }
 
     /**
@@ -205,9 +236,37 @@ public class AnomalyServiceImpl implements AnomalyService {
                 .map(source -> BeanUtil.copyProperties(source, AnomalyModelVO.class))
                 .collect(Collectors.toList());
 
+
+
+        Set<String> eids = anomalyModelVOS.parallelStream().map(AnomalyModelVO::getEngineId).collect(Collectors.toSet());
+        List<WindEngineGroupPO> list = getWindEngineGroupList(eids);
+        for(AnomalyModelVO vo : anomalyModelVOS){
+            for(WindEngineGroupPO po : list){
+                if(vo.getEngineId().equals(po.getEngineId())){
+                    vo.setEngineName(po.getEngineName());
+                }
+            }
+        }
+
         return anomalyModelVOS;
     }
 
+    /**
+     * 查询风机对象集合
+     * @param eids
+     * @return
+     */
+    private List<WindEngineGroupPO> getWindEngineGroupList(Set<String> eids) {
+        // 清除当前
+        DynamicDataSourceContextHolder.poll();
+        // 切换数据源
+        DynamicDataSourceContextHolder.push("master");
+        // 查询平台风机模块
+        Example example = new Example(WindEngineGroupPO.class);
+        Example.Criteria criteria = example.createCriteria();
+        criteria.andIn("engineId", eids);
+        return  windEngineGroupMapper.selectByExample(example);
+    }
 
     @Override
     public AnomalyChartVO getAnomalyModelMap(AnomalyDTO anomalyDTO){
@@ -270,7 +329,7 @@ public class AnomalyServiceImpl implements AnomalyService {
         // 模块1:风速功率检测器
         List<AnomalyThermodynamicDiagramVO> model1PowercurveList = new ArrayList<>();
         List<AnomalyThermodynamicDiagramVO> model1ScatterList = new ArrayList<>();
-        List<AnomalyThermodynamicDiagramVO> model1SimulinkList = new ArrayList<>();
+//        List<AnomalyThermodynamicDiagramVO> model1SimulinkList = new ArrayList<>();
 
         // 模块2:偏航检测器
         List<AnomalyThermodynamicDiagramVO> model2StaticyawList = new ArrayList<>();
@@ -279,7 +338,7 @@ public class AnomalyServiceImpl implements AnomalyService {
         // 模块3:变桨检测器
         List<AnomalyThermodynamicDiagramVO> model3PitchregulationList = new ArrayList<>();
         List<AnomalyThermodynamicDiagramVO> model3PitchcoordList = new ArrayList<>();
-        List<AnomalyThermodynamicDiagramVO> model3MinpitchList = new ArrayList<>();
+//        List<AnomalyThermodynamicDiagramVO> model3MinpitchList = new ArrayList<>();
 
         // 模块4:运行状态检测器
         List<AnomalyThermodynamicDiagramVO> model4PowerqualityList = new ArrayList<>();
@@ -295,14 +354,14 @@ public class AnomalyServiceImpl implements AnomalyService {
         // 模块1:风速功率检测器
         AnomalyThermodynamicDiagramVO model1Powercurve = null;
         AnomalyThermodynamicDiagramVO model1Scatter = null;
-        AnomalyThermodynamicDiagramVO model1Simulink = null;
+//        AnomalyThermodynamicDiagramVO model1Simulink = null;
         // 模块2:偏航检测器
         AnomalyThermodynamicDiagramVO model2Staticyaw = null;
         AnomalyThermodynamicDiagramVO  model2Cabletwist = null;
         // 模块3:变桨检测器
         AnomalyThermodynamicDiagramVO model3Pitchregulation = null;
         AnomalyThermodynamicDiagramVO model3Pitchcoord = null;
-        AnomalyThermodynamicDiagramVO model3Minpitch = null;
+//        AnomalyThermodynamicDiagramVO model3Minpitch = null;
         // 模块4:运行状态检测器
         AnomalyThermodynamicDiagramVO model4Powerquality = null;
         AnomalyThermodynamicDiagramVO model4Operationstate = null;
@@ -327,10 +386,10 @@ public class AnomalyServiceImpl implements AnomalyService {
             model1Scatter.setRatio(anomalyModelPO.getModel1WindpwrScatterRatio());
             model1ScatterList.add(model1Scatter);
 
-            model1Simulink = new AnomalyThermodynamicDiagramVO();
-            model1Simulink.setEngineName(engineMap.get(anomalyModelPO.getEngineId()));
-            model1Simulink.setIfAbnorma(anomalyModelPO.getModel1WindpwrSimulink());
-            model1SimulinkList.add(model1Simulink);
+//            model1Simulink = new AnomalyThermodynamicDiagramVO();
+//            model1Simulink.setEngineName(engineMap.get(anomalyModelPO.getEngineId()));
+//            model1Simulink.setIfAbnorma(anomalyModelPO.getModel1WindpwrSimulink());
+//            model1SimulinkList.add(model1Simulink);
 
             // 模块2:偏航检测器
             model2Staticyaw = new AnomalyThermodynamicDiagramVO();
@@ -358,10 +417,10 @@ public class AnomalyServiceImpl implements AnomalyService {
             model3Pitchcoord.setRatio(anomalyModelPO.getModel3PitchPitchcoordRatio());
             model3PitchcoordList.add(model3Pitchcoord);
 
-            model3Minpitch = new AnomalyThermodynamicDiagramVO();
-            model3Minpitch.setEngineName(engineMap.get(anomalyModelPO.getEngineId()));
-            model3Minpitch.setIfAbnorma(anomalyModelPO.getModel3PitchMinpitch());
-            model3MinpitchList.add(model3Minpitch);
+//            model3Minpitch = new AnomalyThermodynamicDiagramVO();
+//            model3Minpitch.setEngineName(engineMap.get(anomalyModelPO.getEngineId()));
+//            model3Minpitch.setIfAbnorma(anomalyModelPO.getModel3PitchMinpitch());
+//            model3MinpitchList.add(model3Minpitch);
 
             // 模块4:运行状态检测器
             model4Powerquality = new AnomalyThermodynamicDiagramVO();
@@ -401,14 +460,14 @@ public class AnomalyServiceImpl implements AnomalyService {
         // 模块1:风速功率检测器
         map.put(DetectorType.MODEL1_POWERCURVE.getCode(),model1PowercurveList);
         map.put(DetectorType.MODEL1_SCATTER.getCode(),model1ScatterList);
-        map.put(DetectorType.MODEL1_SIMULINK.getCode(),model1SimulinkList);
+//        map.put(DetectorType.MODEL1_SIMULINK.getCode(),model1SimulinkList);
         // 模块2:偏航检测器
         map.put(DetectorType.MODEL2_STATICYAW.getCode(),model2StaticyawList);
         map.put(DetectorType.MODEL2_CABLETWIST.getCode(),model2CabletwistList);
         // 模块3:变桨检测器
         map.put(DetectorType.MODEL3_PITCHREGULATION.getCode(),model3PitchregulationList);
         map.put(DetectorType.MODEL3_PITCHCOORD.getCode(),model3PitchcoordList);
-        map.put(DetectorType.MODEL3_MINPITCH.getCode(),model3MinpitchList);
+//        map.put(DetectorType.MODEL3_MINPITCH.getCode(),model3MinpitchList);
         // 模块4:运行状态检测器
         map.put(DetectorType.MODEL4_POWERQUALITY.getCode(),model4PowerqualityList);
         map.put(DetectorType.MODEL4_OPERATIONSTATE.getCode(),model4OperationstateList);
@@ -553,6 +612,10 @@ public class AnomalyServiceImpl implements AnomalyService {
         }
         String year = String.valueOf(LocalDate.now().getYear());
 
+        // 清除当前
+        DynamicDataSourceContextHolder.poll();
+        // 切换数据源
+        DynamicDataSourceContextHolder.push("slave");
         AnomalySensorCountVO anomalySensorCountVO = anomalyWindfarmMapper.selectAnomalySensorCountVO(fieldId,year,beginTime,endTime);
 
         return anomalySensorCountVO;
@@ -584,6 +647,10 @@ public class AnomalyServiceImpl implements AnomalyService {
         }
         String year = String.valueOf(LocalDate.now().getYear());
 
+        // 清除当前
+        DynamicDataSourceContextHolder.poll();
+        // 切换数据源
+        DynamicDataSourceContextHolder.push("slave");
         AnomalyCount anomalyCount = anomalyWindfarmMapper.selectModeCount(fieldId,year,beginTime,endTime);
 
         return anomalyCount;
@@ -605,6 +672,11 @@ public class AnomalyServiceImpl implements AnomalyService {
         // 场景1:同一年 → 查询单张分表
         if (startYear == endYear) {
             String tableName = TABLE_PREFIX + startYear;
+
+            // 清除当前
+            DynamicDataSourceContextHolder.poll();
+            // 切换数据源
+            DynamicDataSourceContextHolder.push("slave");
             return anomalyWindfarmMapper.selectBySingleTable(anomalyModelDTO.getFieldId(),anomalyModelDTO.getEngineId(),
                     tableName, start.toString(), end.toString());
         }
@@ -612,6 +684,11 @@ public class AnomalyServiceImpl implements AnomalyService {
         else {
             String table1 = TABLE_PREFIX + startYear;
             String table2 = TABLE_PREFIX + endYear;
+
+            // 清除当前
+            DynamicDataSourceContextHolder.poll();
+            // 切换数据源
+            DynamicDataSourceContextHolder.push("slave");
             return anomalyWindfarmMapper.selectByUnionTables(anomalyModelDTO.getFieldId(),anomalyModelDTO.getEngineId(),
                     table1,table2, start.toString(), end.toString());
         }
@@ -622,15 +699,34 @@ public class AnomalyServiceImpl implements AnomalyService {
      * 补全无数据日期(赋值0)
      */
     private List<AnomalyDailyVO> fillMissingDate(LocalDate start, LocalDate end, List<AnomalyDailyVO> data) {
-        Map<Date, AnomalyDailyVO> dataMap = data.stream().collect(Collectors.toMap(AnomalyDailyVO::getCreateTime, dto -> dto));
+
+        // 统一使用东八区,和数据库时间对齐,杜绝时区错位
+        ZoneId zoneId = ZoneId.of("Asia/Shanghai");
+
+
+        // Map key:VO的Date统一转东八区LocalDate
+        Map<LocalDate, AnomalyDailyVO> dataMap = data.stream()
+                .collect(Collectors.toMap(
+                        vo -> vo.getCreateTime()
+                                .toInstant()
+                                .atZone(zoneId)
+                                .toLocalDate(),
+                        vo -> vo
+                ));
 
         List<AnomalyDailyVO> result = new ArrayList<>();
 
         for (LocalDate date = start; !date.isAfter(end); date = date.plusDays(1)) {
-
-            result.add(dataMap.getOrDefault(Date.from(date.atStartOfDay(ZoneId.systemDefault()).toInstant()),
-                    new AnomalyDailyVO(Date.from(date.atStartOfDay(ZoneId.systemDefault()).toInstant()),
-                            new BigDecimal(0), new BigDecimal(0), new BigDecimal(0),new BigDecimal(0),new BigDecimal(0))));
+            AnomalyDailyVO vo = dataMap.get(date);
+            if (vo == null) {
+                // 生成当天0点Date,同样用东八区
+                Date dayDate = Date.from(date.atStartOfDay(zoneId).toInstant());
+                vo = new AnomalyDailyVO(dayDate,
+                        BigDecimal.ZERO, BigDecimal.ZERO, BigDecimal.ZERO, BigDecimal.ZERO, BigDecimal.ZERO,
+                        BigDecimal.ZERO, BigDecimal.ZERO, BigDecimal.ZERO,
+                        BigDecimal.ZERO, BigDecimal.ZERO, BigDecimal.ZERO, BigDecimal.ZERO);
+            }
+            result.add(vo);
         }
         return result;
     }
@@ -642,8 +738,9 @@ public class AnomalyServiceImpl implements AnomalyService {
      * @return
      */
     @Override
-    public AnomalyWindpwrVO getAnomalyWindpwr(AnomalyModelDTO anomalyModelDTO){
+    public AnomalyWindpwrVO getAnomalyWindpwr(AnomalyModelDTO anomalyModelDTO,boolean isIntranet){
 
+        AnomalyWindpwrVO anomalyWindpwrVO = new AnomalyWindpwrVO();
         String beginTime = null;
         String endTime = null;
         if (!StringUtils.isEmpty(anomalyModelDTO.getDatatime())) {
@@ -665,24 +762,41 @@ public class AnomalyServiceImpl implements AnomalyService {
                 anomalyModelDTO.getEngineId(),beginTime,endTime);
         AnomalyPowercurvePO anomalyPowercurvePO = new AnomalyPowercurvePO();
         BeanUtil.copyProperties(powerPO,anomalyPowercurvePO);
+        if(powerPO != null){
+            anomalyPowercurvePO.setFilePath(NetUtils.getFilePath(isIntranet,powerPO.getFilePath()));
+            anomalyPowercurvePO.setGraphPath(NetUtils.getFilePath(isIntranet,powerPO.getGraphPath()));
+            anomalyWindpwrVO.setAnomalyPowercurvePO(anomalyPowercurvePO);
+        }
 
+        // 清除当前
+        DynamicDataSourceContextHolder.poll();
+        // 切换数据源
+        DynamicDataSourceContextHolder.push("slave");
         BaseAnomalyDetectorPO scatterPO =  anomalyWindfarmMapper.selectAnomalyDetectorAll(anomalyModelDTO.getFieldId(),
                 DetectorTableEnum.SCATTER.getFullTableName(year),
                 anomalyModelDTO.getEngineId(),beginTime,endTime);
         AnomalyScatterPO anomalyScatterPO = new AnomalyScatterPO();
         BeanUtil.copyProperties(scatterPO,anomalyScatterPO);
+        if(scatterPO != null){
+            anomalyScatterPO.setFilePath(NetUtils.getFilePath(isIntranet,scatterPO.getFilePath()));
+            anomalyScatterPO.setGraphPath(NetUtils.getFilePath(isIntranet,scatterPO.getGraphPath()));
+            anomalyWindpwrVO.setAnomalyScatterPO(anomalyScatterPO);
+        }
 
+        // 清除当前
+        DynamicDataSourceContextHolder.poll();
+        // 切换数据源
+        DynamicDataSourceContextHolder.push("slave");
         BaseAnomalyDetectorPO simulinkPO =  anomalyWindfarmMapper.selectAnomalyDetectorAll(anomalyModelDTO.getFieldId(),
                 DetectorTableEnum.SIMULINK.getFullTableName(year),
                 anomalyModelDTO.getEngineId(),beginTime,endTime);
         AnomalySimulinkPO  anomalySimulinkPO = new AnomalySimulinkPO();
         BeanUtil.copyProperties(simulinkPO,anomalySimulinkPO);
-
-        AnomalyWindpwrVO anomalyWindpwrVO = new AnomalyWindpwrVO();
-        anomalyWindpwrVO.setAnomalyPowercurvePO(anomalyPowercurvePO);
-        anomalyWindpwrVO.setAnomalyScatterPO(anomalyScatterPO);
-        anomalyWindpwrVO.setAnomalySimulinkPO(anomalySimulinkPO);
-
+        if(simulinkPO != null){
+            anomalySimulinkPO.setFilePath(NetUtils.getFilePath(isIntranet,simulinkPO.getFilePath()));
+            anomalySimulinkPO.setGraphPath(NetUtils.getFilePath(isIntranet,simulinkPO.getGraphPath()));
+            anomalyWindpwrVO.setAnomalySimulinkPO(anomalySimulinkPO);
+        }
         return anomalyWindpwrVO;
     }
 
@@ -692,8 +806,9 @@ public class AnomalyServiceImpl implements AnomalyService {
      * @return
      */
     @Override
-    public AnomalyYawVO geAnomalyYaw(AnomalyModelDTO anomalyModelDTO){
+    public AnomalyYawVO geAnomalyYaw(AnomalyModelDTO anomalyModelDTO,boolean isIntranet){
 
+        AnomalyYawVO anomalyYawVO = new AnomalyYawVO();
         String beginTime = null;
         String endTime = null;
         if (!StringUtils.isEmpty(anomalyModelDTO.getDatatime())) {
@@ -715,17 +830,28 @@ public class AnomalyServiceImpl implements AnomalyService {
                 anomalyModelDTO.getEngineId(),beginTime,endTime);
         AnomalyStaticyawPO anomalyStaticyawPO = new AnomalyStaticyawPO();
         BeanUtil.copyProperties(staticyaw,anomalyStaticyawPO);
+        if(staticyaw != null){
+            anomalyStaticyawPO.setFilePath(NetUtils.getFilePath(isIntranet,staticyaw.getFilePath()));
+            anomalyStaticyawPO.setGraphPath(NetUtils.getFilePath(isIntranet,staticyaw.getGraphPath()));
+            anomalyYawVO.setAnomalyStaticyawPO(anomalyStaticyawPO);
+        }
+
+
+        // 清除当前
+        DynamicDataSourceContextHolder.poll();
+        // 切换数据源
+        DynamicDataSourceContextHolder.push("slave");
 
         BaseAnomalyDetectorPO cabletwistPO =  anomalyWindfarmMapper.selectAnomalyDetectorAll(anomalyModelDTO.getFieldId(),
                 DetectorTableEnum.STATIC_YAW.getFullTableName(year),
                 anomalyModelDTO.getEngineId(),beginTime,endTime);
         AnomalyCabletwistPO anomalyCabletwistPO = new AnomalyCabletwistPO();
         BeanUtil.copyProperties(cabletwistPO,anomalyCabletwistPO);
-
-        AnomalyYawVO anomalyYawVO = new AnomalyYawVO();
-        anomalyYawVO.setAnomalyStaticyawPO(anomalyStaticyawPO);
-        anomalyYawVO.setAnomalyCabletwistPO(anomalyCabletwistPO);
-
+        if(cabletwistPO != null){
+            anomalyCabletwistPO.setFilePath(NetUtils.getFilePath(isIntranet,cabletwistPO.getFilePath()));
+            anomalyCabletwistPO.setGraphPath(NetUtils.getFilePath(isIntranet,cabletwistPO.getGraphPath()));
+            anomalyYawVO.setAnomalyCabletwistPO(anomalyCabletwistPO);
+        }
         return anomalyYawVO;
     }
 
@@ -736,8 +862,9 @@ public class AnomalyServiceImpl implements AnomalyService {
      * @return
      */
     @Override
-    public AnomalyPitchVO getAnomalyPitch(AnomalyModelDTO anomalyModelDTO){
+    public AnomalyPitchVO getAnomalyPitch(AnomalyModelDTO anomalyModelDTO,boolean isIntranet){
 
+        AnomalyPitchVO anomalyPitchVO = new AnomalyPitchVO();
         String beginTime = null;
         String endTime = null;
         if (!StringUtils.isEmpty(anomalyModelDTO.getDatatime())) {
@@ -758,25 +885,47 @@ public class AnomalyServiceImpl implements AnomalyService {
                 DetectorTableEnum.PITCH_REGULATION.getFullTableName(year),
                 anomalyModelDTO.getEngineId(),beginTime,endTime);
         AnomalyPitchregulationPO anomalyPitchregulationPO = new AnomalyPitchregulationPO();
-        BeanUtil.copyProperties(pitchregulationPO,anomalyPitchregulationPO);
+
+        if(pitchregulationPO != null){
+            BeanUtil.copyProperties(pitchregulationPO,anomalyPitchregulationPO);
+            anomalyPitchregulationPO.setFilePath(NetUtils.getFilePath(isIntranet,pitchregulationPO.getFilePath()));
+            anomalyPitchregulationPO.setGraphPath(NetUtils.getFilePath(isIntranet,pitchregulationPO.getGraphPath()));
+            anomalyPitchVO.setAnomalyPitchregulationPO (anomalyPitchregulationPO);
+        }
+
+        // 清除当前
+        DynamicDataSourceContextHolder.poll();
+        // 切换数据源
+        DynamicDataSourceContextHolder.push("slave");
 
         BaseAnomalyDetectorPO pitchcoordPO =  anomalyWindfarmMapper.selectAnomalyDetectorAll(anomalyModelDTO.getFieldId(),
                 DetectorTableEnum.PITCH_COORD.getFullTableName(year),
                 anomalyModelDTO.getEngineId(),beginTime,endTime);
         AnomalyPitchcoordPO anomalyPitchcoordPO = new AnomalyPitchcoordPO();
-        BeanUtil.copyProperties(pitchcoordPO,anomalyPitchcoordPO);
+
+        if(pitchcoordPO != null){
+            BeanUtil.copyProperties(pitchcoordPO,anomalyPitchcoordPO);
+            anomalyPitchcoordPO.setFilePath(NetUtils.getFilePath(isIntranet,pitchcoordPO.getFilePath()));
+            anomalyPitchcoordPO.setGraphPath(NetUtils.getFilePath(isIntranet,pitchcoordPO.getGraphPath()));
+            anomalyPitchVO.setAnomalyPitchcoordPO(anomalyPitchcoordPO);
+        }
+
+        // 清除当前
+        DynamicDataSourceContextHolder.poll();
+        // 切换数据源
+        DynamicDataSourceContextHolder.push("slave");
 
         BaseAnomalyDetectorPO minpitchPO =  anomalyWindfarmMapper.selectAnomalyDetectorAll(anomalyModelDTO.getFieldId(),
                 DetectorTableEnum.MIN_PITCH.getFullTableName(year),
                 anomalyModelDTO.getEngineId(),beginTime,endTime);
         AnomalyMinpitchPO  anomalyMinpitchPO = new AnomalyMinpitchPO();
-        BeanUtil.copyProperties(minpitchPO,anomalyMinpitchPO);
-
-        AnomalyPitchVO anomalyPitchVO = new AnomalyPitchVO();
-        anomalyPitchVO.setAnomalyPitchregulationPO (anomalyPitchregulationPO);
-        anomalyPitchVO.setAnomalyPitchcoordPO(anomalyPitchcoordPO);
-        anomalyPitchVO.setAnomalyMinpitchPO(anomalyMinpitchPO);
 
+        if(minpitchPO != null){
+            BeanUtil.copyProperties(minpitchPO,anomalyMinpitchPO);
+            anomalyMinpitchPO.setFilePath(NetUtils.getFilePath(isIntranet,minpitchPO.getFilePath()));
+            anomalyMinpitchPO.setGraphPath(NetUtils.getFilePath(isIntranet,minpitchPO.getGraphPath()));
+            anomalyPitchVO.setAnomalyMinpitchPO(anomalyMinpitchPO);
+        }
         return anomalyPitchVO;
     }
 
@@ -786,8 +935,9 @@ public class AnomalyServiceImpl implements AnomalyService {
      * @return
      */
     @Override
-    public AnomalyCtrlParamVO getAnomalyCtrlParam(AnomalyModelDTO anomalyModelDTO){
+    public AnomalyCtrlParamVO getAnomalyCtrlParam(AnomalyModelDTO anomalyModelDTO,boolean isIntranet){
 
+        AnomalyCtrlParamVO anomalyCtrlParamVO = new AnomalyCtrlParamVO();
         String beginTime = null;
         String endTime = null;
         if (!StringUtils.isEmpty(anomalyModelDTO.getDatatime())) {
@@ -809,16 +959,26 @@ public class AnomalyServiceImpl implements AnomalyService {
                 anomalyModelDTO.getEngineId(),beginTime,endTime);
         AnomalyPowerqualityPO anomalyPowerqualityPO = new AnomalyPowerqualityPO();
         BeanUtil.copyProperties(powerqualityPO,anomalyPowerqualityPO);
+        if(powerqualityPO != null){
+            anomalyPowerqualityPO.setFilePath(NetUtils.getFilePath(isIntranet,powerqualityPO.getFilePath()));
+            anomalyPowerqualityPO.setGraphPath(NetUtils.getFilePath(isIntranet,powerqualityPO.getGraphPath()));
+            anomalyCtrlParamVO.setAnomalyPowerqualityPO (anomalyPowerqualityPO);
+        }
 
+        // 清除当前
+        DynamicDataSourceContextHolder.poll();
+        // 切换数据源
+        DynamicDataSourceContextHolder.push("slave");
         BaseAnomalyDetectorPO operationPO =  anomalyWindfarmMapper.selectAnomalyDetectorAll(anomalyModelDTO.getFieldId(),
                 DetectorTableEnum.OPERATION.getFullTableName(year),
                 anomalyModelDTO.getEngineId(),beginTime,endTime);
         AnomalyOperationPO anomalyOperationPO = new AnomalyOperationPO();
         BeanUtil.copyProperties(operationPO,anomalyOperationPO);
-
-        AnomalyCtrlParamVO anomalyCtrlParamVO = new AnomalyCtrlParamVO();
-        anomalyCtrlParamVO.setAnomalyPowerqualityPO (anomalyPowerqualityPO);
-        anomalyCtrlParamVO.setAnomalyOperationPO(anomalyOperationPO);
+        if(operationPO != null){
+            anomalyOperationPO.setFilePath(NetUtils.getFilePath(isIntranet,operationPO.getFilePath()));
+            anomalyOperationPO.setGraphPath(NetUtils.getFilePath(isIntranet,operationPO.getGraphPath()));
+            anomalyCtrlParamVO.setAnomalyOperationPO(anomalyOperationPO);
+        }
 
         return anomalyCtrlParamVO;
     }
@@ -830,7 +990,7 @@ public class AnomalyServiceImpl implements AnomalyService {
      * @return
      */
     @Override
-    public AnomalyAerodynamicsVO getAerodynamics(AnomalyModelDTO anomalyModelDTO){
+    public AnomalyAerodynamicsVO getAerodynamics(AnomalyModelDTO anomalyModelDTO,boolean isIntranet){
 
         String beginTime = null;
         String endTime = null;
@@ -848,31 +1008,49 @@ public class AnomalyServiceImpl implements AnomalyService {
         // 切换数据源
         DynamicDataSourceContextHolder.push("slave");
 
+        AnomalyAerodynamicsVO anomalyAerodynamicsVO = new AnomalyAerodynamicsVO();
 
         BaseAnomalyDetectorPO anomalyCpBasePO =  anomalyWindfarmMapper.selectAnomalyDetectorAll(anomalyModelDTO.getFieldId(),
                 DetectorTableEnum.CP_DETECTOR.getFullTableName(year),
                 anomalyModelDTO.getEngineId(),beginTime,endTime);
         AnomalyCpPO anomalyCpPO = new AnomalyCpPO();
         BeanUtil.copyProperties(anomalyCpBasePO,anomalyCpPO);
+        if(anomalyCpBasePO != null){
+            anomalyCpPO.setFilePath(NetUtils.getFilePath(isIntranet,anomalyCpBasePO.getFilePath()));
+            anomalyCpPO.setGraphPath(NetUtils.getFilePath(isIntranet,anomalyCpBasePO.getGraphPath()));
+            anomalyAerodynamicsVO.setAnomalyCpPO(anomalyCpPO);
+        }
+
 
+        // 清除当前
+        DynamicDataSourceContextHolder.poll();
+        // 切换数据源
+        DynamicDataSourceContextHolder.push("slave");
         BaseAnomalyDetectorPO anomalyTsrBasePO =  anomalyWindfarmMapper.selectAnomalyDetectorAll(anomalyModelDTO.getFieldId(),
                 DetectorTableEnum.TSR_DETECTOR.getFullTableName(year),
                 anomalyModelDTO.getEngineId(),beginTime,endTime);
         AnomalyTsrPO anomalyTsrPO = new AnomalyTsrPO();
         BeanUtil.copyProperties(anomalyTsrBasePO,anomalyTsrPO);
+        if(anomalyTsrBasePO != null){
+            anomalyTsrPO.setFilePath(NetUtils.getFilePath(isIntranet,anomalyTsrBasePO.getFilePath()));
+            anomalyTsrPO.setGraphPath(NetUtils.getFilePath(isIntranet,anomalyTsrBasePO.getGraphPath()));
+            anomalyAerodynamicsVO.setAnomalyTsrPO(anomalyTsrPO);
+        }
 
+        // 清除当前
+        DynamicDataSourceContextHolder.poll();
+        // 切换数据源
+        DynamicDataSourceContextHolder.push("slave");
         BaseAnomalyDetectorPO anomalyCpTsrBasePO =  anomalyWindfarmMapper.selectAnomalyDetectorAll(anomalyModelDTO.getFieldId(),
                 DetectorTableEnum.CP_TSR_DETECTOR.getFullTableName(year),
                 anomalyModelDTO.getEngineId(),beginTime,endTime);
         AnomalyCpTsrPO anomalyCpTsrPO = new AnomalyCpTsrPO();
         BeanUtil.copyProperties(anomalyCpTsrBasePO,anomalyCpTsrPO);
-
-
-        AnomalyAerodynamicsVO anomalyAerodynamicsVO = new AnomalyAerodynamicsVO();
-        anomalyAerodynamicsVO.setAnomalyCpPO(anomalyCpPO);
-        anomalyAerodynamicsVO.setAnomalyCpTsrPO(anomalyCpTsrPO);
-        anomalyAerodynamicsVO.setAnomalyTsrPO(anomalyTsrPO);
-
+        if(anomalyCpTsrBasePO != null){
+            anomalyCpTsrPO.setFilePath(NetUtils.getFilePath(isIntranet,anomalyCpTsrBasePO.getFilePath()));
+            anomalyCpTsrPO.setGraphPath(NetUtils.getFilePath(isIntranet,anomalyCpTsrBasePO.getGraphPath()));
+            anomalyAerodynamicsVO.setAnomalyCpPO(anomalyCpPO);
+        }
         return anomalyAerodynamicsVO;
     }
 

+ 1 - 1
src/main/java/com/energy/manage/analyse/service/healthscores/HealthscoresService.java

@@ -37,6 +37,6 @@ public interface HealthscoresService {
      * @param engineId
      * @return
      */
-    List<HealthscoresTendencyVO> getLastDaysTrend(int day, String fieldId, String engineId);
+    List<HealthscoresTendencyVO> getLastDaysTrend(int day, String fieldId, String engineId,String dateTime);
 
 }

+ 41 - 9
src/main/java/com/energy/manage/analyse/service/healthscores/impl/HealthscoresServiceImpl.java

@@ -53,11 +53,6 @@ public class HealthscoresServiceImpl implements HealthscoresService {
             fieldId = windFieldPO.getFieldId();
         }
 
-        if (fieldId == null) {
-            log.warn(" 健康检测大唐内部风场编号没有对应台账fieldId  ");
-            return null;
-        }
-
         String beginTime = null;
         String endTime = null;
         if (!StringUtils.isEmpty(datatime)) {
@@ -69,6 +64,17 @@ public class HealthscoresServiceImpl implements HealthscoresService {
         }
 
         List<HealthscoresWindVO> list = getHealthscoresWind(fieldId, beginTime, endTime);
+
+        Set<String> fids = list.parallelStream().map(HealthscoresWindVO::getFieldId).collect(Collectors.toSet());
+        List<WindFieldPO> fList = getWindFGroupList(fids);
+        for(HealthscoresWindVO vo : list){
+            for(WindFieldPO po : fList){
+                if(vo.getFieldId().equals(po.getFieldId())){
+                    vo.setFieldName(po.getFieldName());
+                }
+            }
+        }
+
         return list;
     }
 
@@ -152,6 +158,22 @@ public class HealthscoresServiceImpl implements HealthscoresService {
         return healthOverviewVO;
     }
 
+    /**
+     * @param fids
+     * @return
+     */
+    private List<WindFieldPO> getWindFGroupList(Set<String> fids) {
+        // 清除当前
+        DynamicDataSourceContextHolder.poll();
+        // 切换数据源
+        DynamicDataSourceContextHolder.push("master");
+        // 查询平台风机模块
+        Example example = new Example(WindFieldPO.class);
+        Example.Criteria criteria = example.createCriteria();
+        criteria.andIn("fieldId", fids);
+        return  windFieldMapper.selectByExample(example);
+    }
+
 
     /**
      * 查询风机对象集合
@@ -171,15 +193,25 @@ public class HealthscoresServiceImpl implements HealthscoresService {
     }
 
 
+    public static LocalDate[] getDateRange(String dateStr, int minusDay) {
+        // 定义格式化器
+        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
+        // 解析传入日期为LocalDate
+        LocalDate endDate = LocalDate.parse(dateStr, formatter);
+        // 计算开始日期:结束日期往前减minusDay天
+        LocalDate startDate = endDate.minusDays(minusDay-1);
+        return new LocalDate[]{startDate, endDate};
+    }
+
     @Override
-    public List<HealthscoresTendencyVO> getLastDaysTrend(int day, String fieldId, String engineId) {
+    public List<HealthscoresTendencyVO> getLastDaysTrend(int day, String fieldId, String engineId,String dateTime) {
         // 1. 校验入参(非空)
         if (Objects.isNull(fieldId) || fieldId.isEmpty() || Objects.isNull(engineId) || engineId.isEmpty()) {
             throw new IllegalArgumentException("风场ID和风机ID不能为空");
         }
 
         // 1. 计算起止日期
-        LocalDate[] range = getLastNDaysRange(day);
+        LocalDate[] range = getDateRange(dateTime,day);
         LocalDate startDate = range[0];
         LocalDate endDate = range[1];
 
@@ -282,8 +314,8 @@ public class HealthscoresServiceImpl implements HealthscoresService {
      * 参数days 为需要查几天的数据
      */
     private LocalDate[] getLastNDaysRange(int days) {
-        LocalDate endDate = LocalDate.now().minusDays(1);
-        LocalDate startDate = endDate.minusDays(days - 1);
+        LocalDate endDate = LocalDate.now();
+        LocalDate startDate = endDate.minusDays(days-1);
         return new LocalDate[]{startDate, endDate};
     }
 

+ 1 - 1
src/main/java/com/energy/manage/analyse/service/wakediagnosis/WakeWindFarmService.java

@@ -14,7 +14,7 @@ public interface WakeWindFarmService {
      * @param datatime
      * @return
      */
-    WakeWindFarmVO getWakeWindFarm(String fieldCode, String datatime);
+    WakeWindFarmVO getWakeWindFarm(String fieldCode, String datatime, boolean isIntranet );
 
 
 

+ 13 - 1
src/main/java/com/energy/manage/analyse/service/wakediagnosis/impl/WakeWindFarmServiceImpl.java

@@ -1,6 +1,7 @@
 package com.energy.manage.analyse.service.wakediagnosis.impl;
 
 import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
+import com.energy.manage.analyse.common.NetUtils;
 import com.energy.manage.analyse.domain.vo.healthscores.HealthOverviewListVO;
 import com.energy.manage.analyse.domain.vo.wakewindfarm.WakeTurbineVO;
 import com.energy.manage.analyse.domain.vo.wakewindfarm.WakeWindFarmVO;
@@ -42,7 +43,7 @@ public class WakeWindFarmServiceImpl implements WakeWindFarmService {
     private static final DateTimeFormatter DATETIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
 
     @Override
-    public WakeWindFarmVO getWakeWindFarm(String fieldCode, String datatime) {
+    public WakeWindFarmVO getWakeWindFarm(String fieldCode, String datatime, boolean isIntranet) {
 
         String fieldId = null;
         WindFieldPO windFieldPO = getWindField(fieldCode);
@@ -72,6 +73,15 @@ public class WakeWindFarmServiceImpl implements WakeWindFarmService {
 
         WakeWindFarmVO wakeWindFarmVO = wakeWindFarmMapper.selectWakeWindfarmAndFieldId(fieldId,beginTime,endTime);
 
+        if(null!=wakeWindFarmVO){
+            wakeWindFarmVO.setVelocityDeficitPath(NetUtils.getFilePath(isIntranet,wakeWindFarmVO.getVelocityDeficitPath()));
+            wakeWindFarmVO.setWakeDiscriptionPath(NetUtils.getFilePath(isIntranet,wakeWindFarmVO.getWakeDiscriptionPath()));
+            wakeWindFarmVO.setWakeDistributePath(NetUtils.getFilePath(isIntranet,wakeWindFarmVO.getWakeDistributePath()));
+            wakeWindFarmVO.setWakeLossConfidentPath(NetUtils.getFilePath(isIntranet,wakeWindFarmVO.getWakeLossConfidentPath()));
+            wakeWindFarmVO.setWakeRoseDiagramPath(NetUtils.getFilePath(isIntranet,wakeWindFarmVO.getWakeRoseDiagramPath()));
+            wakeWindFarmVO.setWindSpeedDistributionChart(NetUtils.getFilePath(isIntranet,wakeWindFarmVO.getWindSpeedDistributionChart()));
+        }
+
         String year = String.valueOf(LocalDate.now().getYear());
         List<WakeTurbineVO> wakeTurbinePOList =  wakeWindFarmMapper.selectWakeTurbineAndFieldId(year, fieldId, beginTime, endTime);
 
@@ -83,6 +93,8 @@ public class WakeWindFarmServiceImpl implements WakeWindFarmService {
                     vo.setEngineName(po.getEngineName());
                 }
             }
+            vo.setWakeTurbinePath(NetUtils.getFilePath(isIntranet,vo.getWakeTurbinePath()));
+            vo.setWakeRoseDiagramPath(NetUtils.getFilePath(isIntranet,vo.getWakeRoseDiagramPath()));
         }
 
         wakeWindFarmVO.setGetWakeTurbineList(wakeTurbinePOList);

+ 83 - 63
src/main/resources/mybatis/anomaly/AnaomalyMapper.xml

@@ -5,6 +5,7 @@
     <!-- 查询风机异常统计数 -->
     <select id="selectAnomalyWindfarmAndFieldId" resultType="com.energy.manage.analyse.domain.vo.anomaly.AnomalyOverviewVO">
         select
+            field_id as fieldId,
             result_anomaly_count as totalAnomalyCount,
             sensor_anomaly_count as sensorAnomalyCount,
             anomaly_detection_count as detectorAnomalyCount
@@ -15,10 +16,10 @@
             field_id = #{fieldId}
         </if>
         <if test="beginTime != null and beginTime != ''">
-            and create_time  <![CDATA[>= ]]> #{beginTime}
+            and source_datetime  <![CDATA[>= ]]> #{beginTime}
         </if>
         <if test="endTime != null and endTime != ''">
-            and create_time <![CDATA[<= ]]> #{endTime}
+            and source_datetime <![CDATA[<= ]]> #{endTime}
         </if>
     </select>
 
@@ -36,10 +37,10 @@
             field_id = #{fieldId}
         </if>
         <if test="beginTime != null and beginTime != ''">
-            and create_time  <![CDATA[>= ]]> #{beginTime}
+            and source_datetime  <![CDATA[>= ]]> #{beginTime}
         </if>
         <if test="endTime != null and endTime != ''">
-            and create_time <![CDATA[<= ]]> #{endTime}
+            and source_datetime <![CDATA[<= ]]> #{endTime}
         </if>
     </select>
 
@@ -193,10 +194,10 @@
             field_id = #{fieldId}
         </if>
         <if test="beginTime != null and beginTime != ''">
-            and create_time  <![CDATA[>= ]]> #{beginTime}
+            and source_datetime  <![CDATA[>= ]]> #{beginTime}
         </if>
         <if test="endTime != null and endTime != ''">
-            and create_time <![CDATA[<= ]]> #{endTime}
+            and source_datetime <![CDATA[<= ]]> #{endTime}
         </if>
     </select>
 
@@ -218,6 +219,7 @@
         <result column="graph_path" property="graphPath" />
         <result column="source_datetime" property="sourceDatetime" />
         <result column="create_time" property="createTime" />
+        <result column="detector_anomaly_rate" property="detectorAnomalyRate" />
     </resultMap>
 
     <!-- 动态查询模块检测器 -->
@@ -232,10 +234,10 @@
             and  engine_id = #{engineId}
         </if>
         <if test="beginTime != null and beginTime != ''">
-            and create_time  <![CDATA[>= ]]> #{beginTime}
+            and source_datetime  <![CDATA[>= ]]> #{beginTime}
         </if>
         <if test="endTime != null and endTime != ''">
-            and create_time <![CDATA[<= ]]> #{endTime}
+            and source_datetime <![CDATA[<= ]]> #{endTime}
         </if>
     </select>
 
@@ -244,17 +246,28 @@
     <!-- 1. 单表统计:指定年度表 -->
     <select id="selectBySingleTable" resultType="com.energy.manage.analyse.domain.vo.anomaly.AnomalyDailyVO">
         SELECT
-            create_time AS createTime,
-            model1_windpwr_anomaly_rate as model1WindpwrAnomalyRate,
-            model2_yaw_anomaly_rate as  model2YawAnomalyRate,
-            model3_pitch_anomaly_rate as model3PitchAnomalyRate,
-            model4_ctrlparam_anomaly_rate as model4CtrlparamAnomalyRate,
-            model5_aerodynamics_anomaly_ratio as model5AerodynamicsAnomalyRatio
+            source_datetime AS createTime,
+            model1_windpwr_powercurve_ratio AS model1WindpwrPowercurveRatio,
+            model1_windpwr_scatter_ratio AS model1WindpwrScatterRatio,
+
+            model2_yaw_staticyaw_ratio AS model2YawStaticyawRatio,
+            model2_yaw_cabletwist_ratio AS model2YawCabletwistRatio,
+
+            model3_pitch_pitchregulation_ratio AS model3PitchPitchregulationRatio,
+            model3_pitch_pitchcoord_ratio AS model3PitchPitchcoordRatio,
+
+            model4_ctrlparam_powerquality_ratio AS model4CtrlparamPowerqualityRatio,
+            model4_ctrlparam_deload_ratio AS model4CtrlparamDeloadRatio,
+            model4_ctrlparam_operationstate_ratio AS model4CtrlparamOperationstateRatio,
+
+            model5_aerodynamics_cp_ratio AS model5AerodynamicsCpRatio,
+            model5_aerodynamics_tsr_ratio AS model5AerodynamicsTsrRatio,
+            model5_aerodynamics_cp_tsr_ratio AS model5AerodynamicsCpTsrRatio
         FROM ${tableName}
         WHERE
         field_id = #{fieldId}
         and engine_id = #{engineId}
-        and create_time BETWEEN #{startDate} AND #{endDate}
+        and source_datetime BETWEEN #{startDate} AND #{endDate}
         ORDER BY create_time ASC
     </select>
 
@@ -278,7 +291,7 @@
         WHERE
         field_id = #{fieldId}
         and engine_id = #{engineId}
-        and  create_time BETWEEN #{startDate} AND #{endDate}
+        and  source_datetime BETWEEN #{startDate} AND #{endDate}
 
         UNION ALL
 
@@ -293,87 +306,94 @@
         WHERE
         field_id = #{fieldId}
         and engine_id = #{engineId}
-        and  create_time BETWEEN #{startDate} AND #{endDate}
+        and  source_datetime BETWEEN #{startDate} AND #{endDate}
         ) AS union_data
         ORDER BY date ASC
     </select>
 
     <select id="selectAnomalySensorCountVO" resultType="com.energy.manage.analyse.domain.vo.anomaly.AnomalySensorCountVO">
 
-        SEL
-        field_id AS fieldId,
-        <!-- 1. 功率传感器异常风机数 -->
-        COUNT(DISTINCT CASE WHEN sensor_anomaly_power = 1 THEN 0 END) AS 'sensorAnomalyPowerCount',
+       SELECT
+    field_id,
+
+
+        COUNT(DISTINCT CASE WHEN sensor_anomaly_power = 1 THEN engine_id END) AS 'sensorAnomalyPowerCount',
+
+
+        COUNT(DISTINCT CASE WHEN sensor_anomaly_wind = 1 THEN engine_id END) AS 'sensorAnomalyWindCount',
 
-        <!-- 2. 风速传感器异常风机数-->
-        COUNT(DISTINCT CASE WHEN sensor_anomaly_wind = 1 THEN 0 END) AS 'sensorAnomalyWindCount',
 
-        <!-- 3. 变桨传感器异常风机数 -->
-        COUNT(DISTINCT CASE WHEN sensor_anomaly_pitch = 1 THEN 0 END) AS 'sensorAnomalyPitchCount',
+        COUNT(DISTINCT CASE WHEN sensor_anomaly_pitch = 1 THEN engine_id END) AS 'sensorAnomalyPitchCount',
 
-        <!-- 4. 转速传感器异常风机数 -->
-        COUNT(DISTINCT CASE WHEN sensor_anomaly_speed = 1 THEN 0 END) AS 'sensorAnomalyApeedCount',
 
-        <!-- 5. 转矩传感器异常风机数 -->
-        COUNT(DISTINCT CASE WHEN sensor_anomaly_torque = 1 THEN 0 END) AS 'sensorAnomalyTorqueCount',
+        COUNT(DISTINCT CASE WHEN sensor_anomaly_speed = 1 THEN engine_id END) AS 'sensorAnomalyApeedCount',
 
-        <!-- 6. 风速-功率逻辑异常风机数 -->
-        COUNT(DISTINCT CASE WHEN sensor_anomaly_wind_pwr = 1 THEN 0 END) AS 'sensorAnomalyWindPwrCount',
 
-        <!-- 7. 转速-扭矩逻辑异常风机数 -->
-        COUNT(DISTINCT CASE WHEN sensor_anomaly_spd_trq = 1 THEN 0 END) AS 'sensorAnomalySpdTrqCount'
+        COUNT(DISTINCT CASE WHEN sensor_anomaly_torque = 1 THEN engine_id END) AS 'sensorAnomalyTorqueCount',
+
+
+        COUNT(DISTINCT CASE WHEN sensor_anomaly_wind_pwr = 1 THEN engine_id END) AS 'sensorAnomalyWindPwrCount',
+
+
+        COUNT(DISTINCT CASE WHEN sensor_anomaly_spd_trq = 1 THEN engine_id END) AS 'sensorAnomalySpdTrqCount'
 
         FROM anomaly_model_${year}
-        where
-            <if test="fieldId!=null">
-                and field_id = #{fieldId}
-            </if>
-            <if test="beginTime != null and beginTime != ''">
-                and create_time  <![CDATA[>= ]]> #{beginTime}
-            </if>
-            <if test="endTime != null and endTime != ''">
-                and create_time <![CDATA[<= ]]> #{endTime}
-            </if>
+        where 1=1
+        <if test="fieldId!=null">
+            and field_id = #{fieldId}
+        </if>
+        <if test="beginTime != null and beginTime != ''">
+            and source_datetime  <![CDATA[>= ]]> #{beginTime}
+        </if>
+        <if test="endTime != null and endTime != ''">
+            and source_datetime <![CDATA[<= ]]> #{endTime}
+        </if>
         GROUP BY field_id
         </select>
 
 
         <!-- yichangjianc异常检测统计  -->
         <select id="selectModeCount" resultType="com.energy.manage.analyse.domain.vo.anomaly.AnomalyCount">
-          SELECT
-    field_id AS fieldId,
+
+SELECT
+    field_id,
+
     COUNT(DISTINCT CASE WHEN
-        model1_windpwr_powercurve = 1 OR model1_windpwr_scatter = 1
-    THEN 0 END) AS 'model1Count',
+        model1_windpwr_powercurve = 1
+        OR model1_windpwr_scatter = 1
+    THEN engine_id END) AS model1Count,
 
     COUNT(DISTINCT CASE WHEN
-        model2_yaw_staticyaw = 1 OR model2_yaw_cabletwist = 1
-    THEN 0 END) AS 'model2Count',
+        model2_yaw_staticyaw = 1
+        OR model2_yaw_cabletwist = 1
+    THEN engine_id END) AS model2Count,
 
     COUNT(DISTINCT CASE WHEN
-        model3_pitch_pitchregulation = 1 OR model3_pitch_pitchcoord = 1
-    THEN 0 END) AS 'model3Count',
+        model3_pitch_pitchregulation = 1
+        OR model3_pitch_pitchcoord = 1
+    THEN engine_id END) AS model3Count,
 
     COUNT(DISTINCT CASE WHEN
-        model4_ctrlparam_powerquality = 1 OR model4_ctrlparam_deload = 1  OR model4_ctrlparam_operationstate = 1
-    THEN 0 END) AS 'model4Count',
+        model4_ctrlparam_powerquality = 1
+        OR model4_ctrlparam_deload = 1
+        OR model4_ctrlparam_operationstate = 1
+    THEN engine_id END) AS model4Count,
 
     COUNT(DISTINCT CASE WHEN
-        model5_aerodynamics_cp = 1 OR model5_aerodynamics_tsr = 1  OR model5_aerodynamics_cp_tsr = 1
-    THEN 0 END) AS 'model5Count'
+        model5_aerodynamics_cp = 1
+        OR model5_aerodynamics_tsr = 1
+        OR model5_aerodynamics_cp_tsr = 1
+    THEN engine_id END) AS model5Count
 
-            FROM anomaly_model_${year}
-            where
-            <if test="fieldId!=null">
-                and field_id = #{fieldId}
-            </if>
+FROM anomaly_model_${year}
+WHERE field_id =#{fieldId}
             <if test="beginTime != null and beginTime != ''">
-                and create_time  <![CDATA[>= ]]> #{beginTime}
+                and source_datetime  <![CDATA[>= ]]> #{beginTime}
             </if>
             <if test="endTime != null and endTime != ''">
-                and create_time <![CDATA[<= ]]> #{endTime}
+                and source_datetime <![CDATA[<= ]]> #{endTime}
             </if>
-            GROUP BY field_id
+GROUP BY field_id;
         </select>
 
 

+ 8 - 8
src/main/resources/mybatis/healthscores/HealthscoresMapper.xml

@@ -38,10 +38,10 @@
             and field_id = #{fieldId}
         </if>
         <if test="beginTime != null and beginTime != ''">
-            and create_time  <![CDATA[>= ]]> #{beginTime}
+            and source_datetime  <![CDATA[>= ]]> #{beginTime}
         </if>
         <if test="endTime != null and endTime != ''">
-            and create_time <![CDATA[<= ]]> #{endTime}
+            and source_datetime <![CDATA[<= ]]> #{endTime}
         </if>
         ORDER BY create_time DESC
     </select>
@@ -67,12 +67,12 @@
             and field_id = #{fieldId}
         </if>
         <if test="beginTime != null and beginTime != ''">
-            and create_time  <![CDATA[>= ]]>  #{beginTime}
+            and source_datetime  <![CDATA[>= ]]>  #{beginTime}
         </if>
         <if test="endTime != null and endTime != ''">
-            and create_time <![CDATA[<= ]]> #{endTime}
+            and source_datetime <![CDATA[<= ]]> #{endTime}
         </if>
-        ORDER BY create_time DESC
+        ORDER BY source_datetime DESC
     </select>
 
     <!-- 查询每个风场风机健康状态 -->
@@ -106,10 +106,10 @@
             and hs.field_id = #{fieldId}
         </if>
         <if test="beginTime != null and beginTime != ''">
-            and hs.create_time  <![CDATA[>= ]]>  #{beginTime}
+            and hs.source_datetime  <![CDATA[>= ]]>  #{beginTime}
         </if>
         <if test="endTime != null and endTime != ''">
-            and hs.create_time <![CDATA[<= ]]> #{endTime}
+            and hs.source_datetime <![CDATA[<= ]]> #{endTime}
         </if>
     </select>
 
@@ -186,7 +186,7 @@
             <if test="engineId!=null">
                 and engine_id = #{engineId}
             </if>
-            and create_time BETWEEN #{startDate} AND #{endDate}
+            and source_datetime BETWEEN #{startDate} AND #{endDate}
         </foreach>
     </select>
 

+ 8 - 7
src/main/resources/mybatis/wakediagnosis/WakeWindFarmMapper.xml

@@ -15,10 +15,10 @@
                 and ww.field_id = #{fieldId}
             </if>
             <if test="beginTime != null and beginTime != ''">
-                and ww.create_time  <![CDATA[>= ]]> #{beginTime}
+                and ww.date_resource  <![CDATA[>= ]]> #{beginTime}
             </if>
             <if test="endTime != null and endTime != ''">
-                and ww.create_time <![CDATA[<= ]]> #{endTime}
+                and ww.date_resource <![CDATA[<= ]]> #{endTime}
             </if>
             order by ww.date_resource desc
     </select>
@@ -33,19 +33,20 @@
             velocity_deficit as velocity_deficit,
             confident_level as confident_level,
             wake_turbine_path as wake_turbine_path,
+            wake_rose_diagram_path as wakeRoseDiagramPath,
             date_resource as date_resource,
             create_time as create_time
-        FROM wake_turbine_#{YEAR}
+        FROM wake_turbine_${year}
+        where 1=1
             <if test="fieldId!=null">
-                and ww.field_id = #{fieldId}
+                and field_id = #{fieldId}
             </if>
             <if test="beginTime != null and beginTime != ''">
-                and ww.create_time  <![CDATA[>= ]]> #{beginTime}
+                and date_resource  <![CDATA[>= ]]> #{beginTime}
             </if>
             <if test="endTime != null and endTime != ''">
-                and ww.create_time <![CDATA[<= ]]> #{endTime}
+                and date_resource <![CDATA[<= ]]> #{endTime}
             </if>
-            ORDER BY create_time DESC
     </select>