瀏覽代碼

获取工单、数据质量和环境数据逻辑

wangchenghong 3 年之前
父節點
當前提交
eccaea9f9f
共有 23 個文件被更改,包括 988 次插入1 次删除
  1. 7 0
      pom.xml
  2. 5 0
      src/main/java/com/persagy/apm/energy/report/common/FeignClientNameConstants.java
  3. 29 0
      src/main/java/com/persagy/apm/energy/report/common/dto/QueryAreaPlatformParamDTO.java
  4. 28 0
      src/main/java/com/persagy/apm/energy/report/common/dto/QueryPjPlatformParamDTO.java
  5. 16 0
      src/main/java/com/persagy/apm/energy/report/common/service/CommonService.java
  6. 38 0
      src/main/java/com/persagy/apm/energy/report/common/service/impl/CommonServiceImpl.java
  7. 53 0
      src/main/java/com/persagy/apm/energy/report/common/utils/DataUtils.java
  8. 178 0
      src/main/java/com/persagy/apm/energy/report/common/utils/DateUtils.java
  9. 60 0
      src/main/java/com/persagy/apm/energy/report/common/utils/HttpUtils.java
  10. 30 0
      src/main/java/com/persagy/apm/energy/report/environment/client/EnvironmentWebClient.java
  11. 13 0
      src/main/java/com/persagy/apm/energy/report/environment/client/fallback/EnvironmentWebClientFallbackFactory.java
  12. 30 0
      src/main/java/com/persagy/apm/energy/report/environment/model/dto/QueryEnvListByParamDTO.java
  13. 12 0
      src/main/java/com/persagy/apm/energy/report/environment/model/vo/EnvAvgRateVO.java
  14. 30 0
      src/main/java/com/persagy/apm/energy/report/environment/service/IEnvironmentWebService.java
  15. 93 0
      src/main/java/com/persagy/apm/energy/report/environment/service/impl/IEnvironmentWebServiceImpl.java
  16. 30 0
      src/main/java/com/persagy/apm/energy/report/iotdataanalysis/service/IDataAnalysisWebService.java
  17. 134 0
      src/main/java/com/persagy/apm/energy/report/iotdataanalysis/service/impl/IDataAnalysisWebServiceImpl.java
  18. 1 1
      src/main/java/com/persagy/apm/energy/report/monthly/detail/business/model/Platform.java
  19. 29 0
      src/main/java/com/persagy/apm/energy/report/workorder/client/WorkOrderWebClient.java
  20. 13 0
      src/main/java/com/persagy/apm/energy/report/workorder/client/fallback/WorkOrderWebClientFallbackFactory.java
  21. 29 0
      src/main/java/com/persagy/apm/energy/report/workorder/model/dto/QueryWorkOrderListByParamDTO.java
  22. 30 0
      src/main/java/com/persagy/apm/energy/report/workorder/service/IWorkOrderWebService.java
  23. 100 0
      src/main/java/com/persagy/apm/energy/report/workorder/service/impl/IWorkOrderWebServiceImpl.java

+ 7 - 0
pom.xml

@@ -88,6 +88,13 @@
             <artifactId>integrated-swagger2-spring-boot-starter</artifactId>
         </dependency>
 
+        <!--jep -->
+        <dependency>
+            <groupId>jep</groupId>
+            <artifactId>jep</artifactId>
+            <version>2.24</version>
+        </dependency>
+
         <dependency>
             <groupId>com.persagy</groupId>
             <artifactId>apm-mybatis</artifactId>

+ 5 - 0
src/main/java/com/persagy/apm/energy/report/common/FeignClientNameConstants.java

@@ -8,4 +8,9 @@ package com.persagy.apm.energy.report.common;
  **/
 public class FeignClientNameConstants {
     public static final String SAAS_WEB = "ems-saas-web";
+
+    public static final String WORK_ORDER = "workorder";
+
+    public static final String ENVIRONMENT = "environment-saas-web";
+
 }

+ 29 - 0
src/main/java/com/persagy/apm/energy/report/common/dto/QueryAreaPlatformParamDTO.java

@@ -0,0 +1,29 @@
+package com.persagy.apm.energy.report.common.dto;
+
+import com.persagy.apm.common.model.dto.PoemsFeignBaseDTO;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.util.Date;
+import java.util.List;
+
+@EqualsAndHashCode(callSuper = true)
+@Data
+@ApiModel
+public class QueryAreaPlatformParamDTO extends PoemsFeignBaseDTO {
+
+    @ApiModelProperty("用户id")
+    private String userId;
+
+    @ApiModelProperty("集团编码")
+    private String groupCode;
+
+    @ApiModelProperty("项目id列表")
+    private List<String> projectIdList;
+
+    @ApiModelProperty("生成报告时间")
+    private Date reportDate;
+
+}

+ 28 - 0
src/main/java/com/persagy/apm/energy/report/common/dto/QueryPjPlatformParamDTO.java

@@ -0,0 +1,28 @@
+package com.persagy.apm.energy.report.common.dto;
+
+import com.persagy.apm.common.model.dto.PoemsFeignBaseDTO;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.util.Date;
+
+@EqualsAndHashCode(callSuper = true)
+@Data
+@ApiModel
+public class QueryPjPlatformParamDTO extends PoemsFeignBaseDTO {
+
+    @ApiModelProperty("用户id")
+    private String userId;
+
+    @ApiModelProperty("集团编码")
+    private String groupCode;
+
+    @ApiModelProperty("项目id")
+    private String projectId;
+
+    @ApiModelProperty("生成报告时间")
+    private Date reportDate;
+
+}

+ 16 - 0
src/main/java/com/persagy/apm/energy/report/common/service/CommonService.java

@@ -0,0 +1,16 @@
+package com.persagy.apm.energy.report.common.service;
+
+import io.swagger.annotations.Api;
+
+import java.util.List;
+
+@Api(value = "公共service接口")
+public interface CommonService {
+
+    /**
+     *
+     * @param pjIdList 项目id列表
+     * @return
+     */
+    List<String> getPjNameByPjId(List<String> pjIdList);
+}

+ 38 - 0
src/main/java/com/persagy/apm/energy/report/common/service/impl/CommonServiceImpl.java

@@ -0,0 +1,38 @@
+package com.persagy.apm.energy.report.common.service.impl;
+
+import com.persagy.apm.common.response.PoemsFeignResponse;
+import com.persagy.apm.energy.report.common.service.CommonService;
+import com.persagy.apm.energy.report.saasweb.client.SaasWebClient;
+import com.persagy.apm.energy.report.saasweb.model.dto.QueryProjectDTO;
+import com.persagy.apm.energy.report.saasweb.model.vo.PoemsProjectVO;
+import io.swagger.annotations.Api;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.util.CollectionUtils;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@Api(value = "公共service实现类")
+public class CommonServiceImpl implements CommonService {
+
+    @Autowired
+    SaasWebClient saasWebClient;
+
+    @Override
+    public List<String> getPjNameByPjId(List<String> pjIdList) {
+        QueryProjectDTO queryProjectDTO = new QueryProjectDTO();
+        PoemsFeignResponse<PoemsProjectVO> projectsResponse = saasWebClient.queryProjects(queryProjectDTO);
+        List<PoemsProjectVO> projectVOList = projectsResponse.getContent();
+        if (!CollectionUtils.isEmpty(projectVOList)) {
+            List<String> pjNameList = new ArrayList<>();
+            for (PoemsProjectVO poemsProjectVO : projectVOList) {
+                if (!pjIdList.contains(poemsProjectVO.getProjectId())) {
+                    continue;
+                }
+                pjNameList.add(poemsProjectVO.getProjectName());
+            }
+            return pjNameList;
+        }
+        return null;
+    }
+}

+ 53 - 0
src/main/java/com/persagy/apm/energy/report/common/utils/DataUtils.java

@@ -0,0 +1,53 @@
+package com.persagy.apm.energy.report.common.utils;
+
+import org.nfunk.jep.JEP;
+
+import java.math.BigDecimal;
+
+public class DataUtils {
+    /**
+     * 对象转Double类型
+     *
+     * @param object
+     * @return
+     */
+    public static Double parseDouble(Object object) {
+        if (object == null) {
+            return null;
+        }
+        if (object instanceof String) {
+            return Double.valueOf(object.toString());
+        }
+        if (object instanceof Integer) {
+            return ((Integer) object).doubleValue();
+        }
+        if (object instanceof Long) {
+            return ((Long) object).doubleValue();
+        }
+        if (object instanceof Double) {
+            return (Double) object;
+        }
+        if (object instanceof BigDecimal) {
+            return ((BigDecimal) object).doubleValue();
+        }
+        return (Double) object;
+    }
+
+    /**
+     * 按规则进行计算
+     *
+     * @param standardValue 规则值
+     * @param qualifyFormula 规则
+     * @param data 要进行规则校验的数据
+     * @return
+     */
+    public static Double getQualifyResult(Double standardValue, String qualifyFormula, Double data) {
+        JEP jep = new JEP();
+        String formula = "param1" + qualifyFormula + "param2";
+        jep.addVariable("param1", standardValue);
+        jep.addVariable("param2", data);
+        jep.parseExpression(formula);
+        return jep.getValue();
+    }
+
+}

+ 178 - 0
src/main/java/com/persagy/apm/energy/report/common/utils/DateUtils.java

@@ -0,0 +1,178 @@
+package com.persagy.apm.energy.report.common.utils;
+
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Date;
+
+public class DateUtils {
+    public static final String SDFSECOND = "yyyyMMddHHmmss";
+    public static final String SDF_SECOND = "yyyy-MM-dd HH:mm:ss";
+
+    /**
+     * 将pattern格式的字符串日期转换为Date类型日期
+     *
+     * @param source  pattern格式的字符串日期
+     * @param pattern 日期格式如yyyy-MM-dd HH:mm:ss
+     * @return
+     * @throws Exception
+     */
+    public static Date str2Date(String source, String pattern) throws Exception {
+        SimpleDateFormat sdf = new SimpleDateFormat(pattern);
+        return sdf.parse(source);
+    }
+
+    /**
+     * 将Date类型的日期转换成pattern格式的字符串日期
+     *
+     * @param date
+     * @param pattern
+     * @return
+     * @throws Exception
+     */
+    public static String date2Str(Date date, String pattern) throws Exception {
+        SimpleDateFormat sdf = new SimpleDateFormat(pattern);
+        return sdf.format(date);
+    }
+
+    /**
+     * 获取时间按年偏移offset个单位后的时间
+     *
+     * @param date
+     * @param offset
+     * @return
+     */
+    public static Date getYearOff(Date date, int offset) {
+        return getOffset(date, offset, 5);
+    }
+
+    /**
+     * 获取时间按月偏移offset个单位后的时间
+     *
+     * @param date
+     * @param offset
+     * @return
+     */
+    public static Date getMonthOff(Date date, int offset) {
+        return getOffset(date, offset, 4);
+    }
+
+    /**
+     * 获取时间按周偏移offset个单位后的时间
+     *
+     * @param date
+     * @param offset
+     * @return
+     */
+    public static Date getWeekOff(Date date, int offset) {
+        return getOffset(date, offset, 3);
+    }
+
+    /**
+     * 获取时间按日偏移offset个单位后的时间
+     *
+     * @param date
+     * @param offset
+     * @return
+     */
+    public static Date getDayOff(Date date, int offset) {
+        return getOffset(date, offset, 2);
+    }
+
+    /**
+     * 获取时间按小时偏移offset个单位后的时间
+     *
+     * @param date
+     * @param offset
+     * @return
+     */
+    public static Date getHourOff(Date date, int offset) {
+        return getOffset(date, offset, 1);
+    }
+
+    /**
+     * description 获取时间按分钟偏移offset个单位后的时间
+     *
+     * @param date
+     * @param offset
+     * @return java.util.Date
+     * @author feng
+     * @since 18:51 2018/12/10
+     */
+    public static Date getMinuteOff(Date date, int offset) {
+        return getOffset(date, offset, 0);
+    }
+
+    /**
+     * 获取指定时间粒度偏移量偏移后的时间
+     *
+     * @param date
+     * @param offset int 偏移量
+     * @param type   int 时间粒度0-分,1-时,2-天,3-周,4-月,5-年
+     * @return
+     */
+    private static Date getOffset(Date date, int offset, int type) {
+        Calendar cal = Calendar.getInstance();
+        cal.setTime(date);
+        switch (type) {
+            case 0:
+                cal.add(Calendar.MINUTE, offset);
+                break;
+            case 1:
+                cal.add(Calendar.HOUR_OF_DAY, offset);
+                break;
+            case 2:
+                cal.add(Calendar.DAY_OF_MONTH, offset);
+                break;
+            case 3:
+                cal.add(Calendar.DAY_OF_MONTH, offset * 7);
+                break;
+            case 4:
+                cal.add(Calendar.MONTH, offset);
+                break;
+            case 5:
+                cal.add(Calendar.YEAR, offset);
+                break;
+            default:
+                break;
+        }
+        return cal.getTime();
+    }
+
+    /**
+     * 获取某一天的开始时间 即2017-01-01 00:00:00
+     * @param date 时间参数
+     * @return
+     * @throws ParseException
+     */
+    public static Date getStartTimeOfDay(Date date) throws ParseException {
+        Calendar c = Calendar.getInstance();
+        c.setTime(date);
+        int year = c.get(Calendar.YEAR);
+        int month = c.get(Calendar.MONTH);
+        int day = c.get(Calendar.DAY_OF_MONTH);
+        c.set(Calendar.HOUR_OF_DAY, 0);
+        c.set(Calendar.MINUTE, 0);
+        c.set(Calendar.SECOND, 0);
+        c.set(Calendar.MILLISECOND, 0);
+        c.set(Calendar.DAY_OF_MONTH, day);
+        c.set(Calendar.YEAR, year);
+        c.set(Calendar.MONTH, month);
+        return c.getTime();
+    }
+
+    public static Date getFirstDayOfYear(Date date) {
+        Calendar c = Calendar.getInstance();
+        c.setTime(date);
+        int year = c.get(Calendar.YEAR);
+        c.set(Calendar.HOUR_OF_DAY, 0);
+        c.set(Calendar.DAY_OF_MONTH, 1);
+        c.set(Calendar.MINUTE, 0);
+        c.set(Calendar.SECOND, 0);
+        c.set(Calendar.MILLISECOND, 0);
+        c.set(Calendar.YEAR, year);
+        c.set(Calendar.MONTH, 0);
+        return c.getTime();
+    }
+
+}

+ 60 - 0
src/main/java/com/persagy/apm/energy/report/common/utils/HttpUtils.java

@@ -0,0 +1,60 @@
+package com.persagy.apm.energy.report.common.utils;
+
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpVersion;
+import org.apache.http.client.config.RequestConfig;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
+import org.apache.http.util.EntityUtils;
+
+import java.nio.charset.Charset;
+
+public class HttpUtils {
+    private final static PoolingHttpClientConnectionManager CONNECTION_MANAGER = new PoolingHttpClientConnectionManager();
+    private final static CloseableHttpClient HTTP_CLIENT;
+    private static final String UTF8 = "utf-8";
+
+    static {
+        // 设置整个连接池最大连接数 根据自己的场景决定
+        CONNECTION_MANAGER.setMaxTotal(200);
+        // 每个路由(网站)的最大连接数
+        CONNECTION_MANAGER.setDefaultMaxPerRoute(100);
+        RequestConfig requestConfig = RequestConfig.custom()
+                // 连接建立时间,三次握手完成时间
+                .setConnectTimeout(5000)
+                // 数据传输过程中数据包之间间隔的最大时间
+                .setSocketTimeout(5000)
+                // httpClient使用连接池来管理连接,这个时间就是从连接池获取连接的超时时间
+                .setConnectionRequestTimeout(6000).build();
+        HTTP_CLIENT = HttpClients.custom().setConnectionManager(CONNECTION_MANAGER)
+                .setDefaultRequestConfig(requestConfig).build();
+    }
+
+    public static String postJson(String url, String json) throws Exception {
+        HttpPost httpPost = new HttpPost(url);
+        //使用http1.0协议
+        httpPost.setProtocolVersion(HttpVersion.HTTP_1_0);
+        httpPost.addHeader("Content-type", "application/json");
+        httpPost.setEntity(new StringEntity(json, Charset.forName("UTF-8")));
+        CloseableHttpResponse response = HTTP_CLIENT.execute(httpPost);
+        int statusCode = response.getStatusLine().getStatusCode();
+        if (statusCode != 200 && statusCode != 201) {
+            httpPost.abort();
+            response.close();
+            throw new RuntimeException("HttpClient,error status code :" + statusCode);
+        }
+        HttpEntity entity = response.getEntity();
+        String result = null;
+        if (entity != null) {
+            result = EntityUtils.toString(entity, "utf-8");
+        }
+        EntityUtils.consume(entity);
+        response.close();
+        return result;
+    }
+
+}

+ 30 - 0
src/main/java/com/persagy/apm/energy/report/environment/client/EnvironmentWebClient.java

@@ -0,0 +1,30 @@
+package com.persagy.apm.energy.report.environment.client;
+
+import com.persagy.apm.common.response.PoemsFeignResponse;
+import com.persagy.apm.energy.report.common.FeignClientNameConstants;
+import com.persagy.apm.energy.report.common.FeignConfig;
+import com.persagy.apm.energy.report.environment.client.fallback.EnvironmentWebClientFallbackFactory;
+import com.persagy.apm.energy.report.environment.model.dto.QueryEnvListByParamDTO;
+import com.persagy.apm.energy.report.environment.model.vo.EnvAvgRateVO;
+import org.apache.poi.ss.formula.functions.T;
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.PostMapping;
+
+/**
+ * 环境健康feign客户端
+ **/
+@FeignClient(name = FeignClientNameConstants.ENVIRONMENT, fallbackFactory = EnvironmentWebClientFallbackFactory.class,
+        configuration = FeignConfig.class)
+public interface EnvironmentWebClient {
+    /**
+     * 根据条件查询环境温度达标率
+     *
+     * @param queryEnvListByParamDTO 查询条件
+     * @return 平均达标率
+     * @author wch
+     * @version V1.0 2021/5/19 2:27 下午
+     */
+    @PostMapping("/Spring/MVC/entrance/unifier/GetEnvTypeRate")
+    PoemsFeignResponse<EnvAvgRateVO> listWorkOrderByParam(QueryEnvListByParamDTO queryEnvListByParamDTO);
+
+}

+ 13 - 0
src/main/java/com/persagy/apm/energy/report/environment/client/fallback/EnvironmentWebClientFallbackFactory.java

@@ -0,0 +1,13 @@
+package com.persagy.apm.energy.report.environment.client.fallback;
+
+import com.persagy.apm.energy.report.environment.client.EnvironmentWebClient;
+import feign.hystrix.FallbackFactory;
+import org.springframework.stereotype.Component;
+
+@Component
+public class EnvironmentWebClientFallbackFactory implements FallbackFactory<EnvironmentWebClient> {
+    @Override
+    public EnvironmentWebClient create(Throwable throwable) {
+        return null;
+    }
+}

+ 30 - 0
src/main/java/com/persagy/apm/energy/report/environment/model/dto/QueryEnvListByParamDTO.java

@@ -0,0 +1,30 @@
+package com.persagy.apm.energy.report.environment.model.dto;
+
+import com.persagy.apm.common.model.dto.PoemsFeignBaseDTO;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.util.List;
+
+@EqualsAndHashCode(callSuper = true)
+@Data
+@ApiModel
+public class QueryEnvListByParamDTO extends PoemsFeignBaseDTO {
+
+    @ApiModelProperty("项目id")
+    private String projectId;
+
+    @ApiModelProperty("环境类型id")
+    private String envTypeId;
+
+    @ApiModelProperty("环境父类型id")
+    private String envParentTypeId;
+
+    @ApiModelProperty("开始时间")
+    private String startTime;
+
+    @ApiModelProperty("结束时间")
+    private String endTime;
+}

+ 12 - 0
src/main/java/com/persagy/apm/energy/report/environment/model/vo/EnvAvgRateVO.java

@@ -0,0 +1,12 @@
+package com.persagy.apm.energy.report.environment.model.vo;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+@ApiModel
+@Data
+public class EnvAvgRateVO {
+    @ApiModelProperty(value = "平均达标率")
+    private Double avgNum;
+}

+ 30 - 0
src/main/java/com/persagy/apm/energy/report/environment/service/IEnvironmentWebService.java

@@ -0,0 +1,30 @@
+package com.persagy.apm.energy.report.environment.service;
+
+import com.persagy.apm.energy.report.common.dto.QueryAreaPlatformParamDTO;
+import com.persagy.apm.energy.report.common.dto.QueryPjPlatformParamDTO;
+import com.persagy.apm.energy.report.monthly.detail.business.model.Platform;
+import io.swagger.annotations.Api;
+
+import java.util.Date;
+import java.util.List;
+
+@Api(value = "环境健康管理service接口")
+public interface IEnvironmentWebService {
+    /**
+     * 获取项目能源管理平台运维温度达标率信息
+     *
+     * @param queryPjPlatformParamDTO 查询条件对象
+     * @author wch
+     * @version V1.0 2021/5/19 4:04 下午
+     */
+    void getPjTempRate(QueryPjPlatformParamDTO queryPjPlatformParamDTO, Platform platform);
+
+    /**
+     * 获取大区能源管理平台运维温度达标率信息
+     *
+     * @param queryAreaPlatformParamDTO 查询条件对象
+     * @author wch
+     * @version V1.0 2021/5/19 4:04 下午
+     */
+    void getAreaTempRate(QueryAreaPlatformParamDTO queryAreaPlatformParamDTO, Platform platform);
+}

+ 93 - 0
src/main/java/com/persagy/apm/energy/report/environment/service/impl/IEnvironmentWebServiceImpl.java

@@ -0,0 +1,93 @@
+package com.persagy.apm.energy.report.environment.service.impl;
+
+import com.persagy.apm.common.response.PoemsFeignResponse;
+import com.persagy.apm.energy.report.common.dto.QueryAreaPlatformParamDTO;
+import com.persagy.apm.energy.report.common.dto.QueryPjPlatformParamDTO;
+import com.persagy.apm.energy.report.common.service.CommonService;
+import com.persagy.apm.energy.report.common.utils.DataUtils;
+import com.persagy.apm.energy.report.common.utils.DateUtils;
+import com.persagy.apm.energy.report.environment.client.EnvironmentWebClient;
+import com.persagy.apm.energy.report.environment.model.dto.QueryEnvListByParamDTO;
+import com.persagy.apm.energy.report.environment.model.vo.EnvAvgRateVO;
+import com.persagy.apm.energy.report.environment.service.IEnvironmentWebService;
+import com.persagy.apm.energy.report.monthly.detail.business.model.Platform;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.TreeMap;
+import java.util.stream.Collectors;
+
+@Service
+public class IEnvironmentWebServiceImpl implements IEnvironmentWebService {
+
+    @Resource
+    private EnvironmentWebClient environmentWebClient;
+    @Resource
+    private CommonService commonService;
+
+    @Override
+    public void getPjTempRate(QueryPjPlatformParamDTO queryPjPlatformParamDTO, Platform platform) {
+        TreeMap<Date, Double> date_rateMap = new TreeMap<>();
+        Date reportDate = queryPjPlatformParamDTO.getReportDate();
+        Date startDate = DateUtils.getFirstDayOfYear(reportDate);
+        while (startDate.before(DateUtils.getMonthOff(reportDate, 1))) {
+            date_rateMap.put(startDate, getEnvAvgRate(queryPjPlatformParamDTO.getProjectId(), reportDate));
+            startDate = DateUtils.getMonthOff(startDate, 1);
+        }
+        List<Double> monthlySummaries = date_rateMap.values().stream().collect(Collectors.toList());
+        platform.setMonthlySummaries(monthlySummaries);
+    }
+
+    private Double getEnvAvgRate(String pjId, Date reportDate) {
+        Double avgRate = null;
+        try {
+            QueryEnvListByParamDTO paramDTO = new QueryEnvListByParamDTO();
+            paramDTO.setProjectId(pjId);
+            paramDTO.setEnvTypeId("Temp");
+            paramDTO.setEnvParentTypeId("Humiture");
+            paramDTO.setStartTime(DateUtils.date2Str(reportDate, DateUtils.SDF_SECOND));
+            paramDTO.setEndTime(DateUtils.date2Str(DateUtils.getMonthOff(reportDate, 1), DateUtils.SDF_SECOND));
+            PoemsFeignResponse<EnvAvgRateVO> response = environmentWebClient.listWorkOrderByParam(paramDTO);
+            EnvAvgRateVO envAvgRateVO = (EnvAvgRateVO) response.getContent();
+            if (null != envAvgRateVO) {
+                return envAvgRateVO.getAvgNum();
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return avgRate;
+    }
+
+    @Override
+    public void getAreaTempRate(QueryAreaPlatformParamDTO queryAreaPlatformParamDTO, Platform platform) {
+        // 合格标准
+        Double standardValue = platform.getStandardValue();
+        // 校验规则
+        String qualifyFormula = platform.getQualifyFormula();
+        // 达标数量
+        Integer satisfiedCount = 0;
+        // 未达标数量
+        Integer unsatisfiedCount = 0;
+        // 未达标项目id列表
+        List<String> unsatisfiedPjIdList = new ArrayList<>();
+        for (String pjId : queryAreaPlatformParamDTO.getProjectIdList()) {
+            Double completeRate = getEnvAvgRate(pjId, queryAreaPlatformParamDTO.getReportDate());
+            if (null != completeRate && null != standardValue) {
+                if (DataUtils.getQualifyResult(standardValue, qualifyFormula, completeRate) == 0.0) {
+                    unsatisfiedCount++;
+                    unsatisfiedPjIdList.add(pjId);
+                } else {
+                    satisfiedCount++;
+                }
+            }
+        }
+        // 根据未达标项目id列表获取不达标项目名称
+        List<String> pjNameList = commonService.getPjNameByPjId(unsatisfiedPjIdList);
+        platform.setSatisfiedCount(satisfiedCount);
+        platform.setUnsatisfiedCount(unsatisfiedCount);
+        platform.setUnsatisfiedProjects(pjNameList);
+    }
+}

+ 30 - 0
src/main/java/com/persagy/apm/energy/report/iotdataanalysis/service/IDataAnalysisWebService.java

@@ -0,0 +1,30 @@
+package com.persagy.apm.energy.report.iotdataanalysis.service;
+
+import com.persagy.apm.energy.report.common.dto.QueryAreaPlatformParamDTO;
+import com.persagy.apm.energy.report.common.dto.QueryPjPlatformParamDTO;
+import com.persagy.apm.energy.report.monthly.detail.business.model.Platform;
+import io.swagger.annotations.Api;
+
+import java.util.Date;
+import java.util.List;
+
+@Api(value = "数据质量服务service接口")
+public interface IDataAnalysisWebService {
+    /**
+     * 获取项目能源管理平台运维变损和总支不平衡率信息
+     *
+     * @param queryPjPlatformParamDTO 查询条件对象
+     * @author wch
+     * @version V1.0 2021/5/19 4:04 下午
+     */
+    void getPjbianSunAndzongZhiRate(QueryPjPlatformParamDTO queryPjPlatformParamDTO, Platform bianSunPlatform, Platform zongZhiPlatform);
+
+    /**
+     * 获取大区能源管理平台运维变损和总支不平衡率信息
+     *
+     * @param queryAreaPlatformParamDTO 查询条件对象
+     * @author wch
+     * @version V1.0 2021/5/19 4:04 下午
+     */
+    void getAreabianSunAndzongZhiRate(QueryAreaPlatformParamDTO queryAreaPlatformParamDTO, Platform bianSunPlatform, Platform zongZhiPlatform);
+}

+ 134 - 0
src/main/java/com/persagy/apm/energy/report/iotdataanalysis/service/impl/IDataAnalysisWebServiceImpl.java

@@ -0,0 +1,134 @@
+package com.persagy.apm.energy.report.iotdataanalysis.service.impl;
+
+import com.alibaba.fastjson.JSONObject;
+import com.persagy.apm.energy.report.common.dto.QueryAreaPlatformParamDTO;
+import com.persagy.apm.energy.report.common.dto.QueryPjPlatformParamDTO;
+import com.persagy.apm.energy.report.common.service.CommonService;
+import com.persagy.apm.energy.report.common.utils.DataUtils;
+import com.persagy.apm.energy.report.common.utils.DateUtils;
+import com.persagy.apm.energy.report.common.utils.HttpUtils;
+import com.persagy.apm.energy.report.iotdataanalysis.service.IDataAnalysisWebService;
+import com.persagy.apm.energy.report.monthly.detail.business.model.Platform;
+import org.apache.commons.collections.CollectionUtils;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.math.BigDecimal;
+import java.util.*;
+import java.util.stream.Collectors;
+@Service
+public class IDataAnalysisWebServiceImpl implements IDataAnalysisWebService {
+
+    @Value("${iot.data.analysis.url}")
+    private String iotDataAnalysisUrl;
+
+    @Resource
+    private CommonService commonService;
+
+    public final static String SUCCESS = "success";
+
+    @Override
+    public void getPjbianSunAndzongZhiRate(QueryPjPlatformParamDTO queryPjPlatformParamDTO, Platform bianSunPlatform, Platform zongZhiPlatform) {
+        TreeMap<Date, Double> biansun_date_rateMap = new TreeMap<>();
+        TreeMap<Date, Double> zongzhi_date_rateMap = new TreeMap<>();
+        Date reportDate = queryPjPlatformParamDTO.getReportDate();
+        Date startDate = DateUtils.getFirstDayOfYear(reportDate);
+        while (startDate.before(DateUtils.getMonthOff(reportDate, 1))) {
+            Double bianSunRate = null;
+            Double zongZhiRate = null;
+            getBianSunAndZongZhiRate(queryPjPlatformParamDTO.getUserId(), queryPjPlatformParamDTO.getGroupCode(), queryPjPlatformParamDTO.getProjectId(), bianSunRate, zongZhiRate, reportDate);
+            biansun_date_rateMap.put(startDate, bianSunRate);
+            zongzhi_date_rateMap.put(startDate, zongZhiRate);
+            startDate = DateUtils.getMonthOff(startDate, 1);
+        }
+        List<Double> bianSunMonthlySummaries = biansun_date_rateMap.values().stream().collect(Collectors.toList());
+        List<Double> zongZhiMonthlySummaries = zongzhi_date_rateMap.values().stream().collect(Collectors.toList());
+        bianSunPlatform.setMonthlySummaries(bianSunMonthlySummaries);
+        zongZhiPlatform.setMonthlySummaries(zongZhiMonthlySummaries);
+    }
+
+    private void getBianSunAndZongZhiRate(String userId, String groupCode, String projectId, Double bianSunRate, Double zongZhiRate, Date reportDate) {
+        try {
+            JSONObject paramObject = new JSONObject();
+            paramObject.put("userId", userId);
+            paramObject.put("groupCode", groupCode);
+            List<String> pjIdList = new ArrayList<>();
+            pjIdList.add(projectId);
+            paramObject.put("projectIdList", pjIdList.toString());
+            Date startTime = DateUtils.getStartTimeOfDay(reportDate);
+            Date endTime = DateUtils.getMonthOff(startTime, 1);
+            paramObject.put("alarmStartTime", startTime);
+            paramObject.put("alarmEndTime", endTime);
+            String url = iotDataAnalysisUrl + "/alarm/show/view/queryList";
+            String response = HttpUtils.postJson(url, paramObject.toString());
+            JSONObject responseObject = JSONObject.parseObject(response);
+            if (SUCCESS.equals(responseObject.getString("respMsg"))) {
+                List<Map> content = (List<Map>) responseObject.get("content");
+                if (CollectionUtils.isNotEmpty(content)) {
+                    Map data = content.get(0);
+                    bianSunRate = DataUtils.parseDouble(data.get("bianSunRate"));
+                    zongZhiRate = DataUtils.parseDouble(data.get("zongZhiRate"));
+                }
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    @Override
+    public void getAreabianSunAndzongZhiRate(QueryAreaPlatformParamDTO queryAreaPlatformParamDTO, Platform bianSunPlatform, Platform zongZhiPlatform) {
+        // 变损合格标准
+        Double bianSunStandardValue = bianSunPlatform.getStandardValue();
+        // 变损校验规则
+        String bianSunQualifyFormula = bianSunPlatform.getQualifyFormula();
+        // 变损达标数量
+        Integer bianSunSatisfiedCount = 0;
+        // 变损未达标数量
+        Integer bianSunUnsatisfiedCount = 0;
+        // 变损未达标项目id列表
+        List<String> bianSunUnsatisfiedPjIdList = new ArrayList<>();
+        // 总支不平衡合格标准
+        Double zongZhiStandardValue = bianSunPlatform.getStandardValue();
+        // 总支不平衡校验规则
+        String zongZhiQualifyFormula = bianSunPlatform.getQualifyFormula();
+        // 总支不平衡达标数量
+        Integer zongZhiSatisfiedCount = 0;
+        // 总支不平衡未达标数量
+        Integer zongZhiUnsatisfiedCount = 0;
+        // 总支不平衡未达标项目id列表
+        List<String> zongZhiUnsatisfiedPjIdList = new ArrayList<>();
+        for (String pjId : queryAreaPlatformParamDTO.getProjectIdList()) {
+            Double bianSunRate = null;
+            Double zongZhiRate = null;
+            getBianSunAndZongZhiRate(queryAreaPlatformParamDTO.getUserId(), queryAreaPlatformParamDTO.getGroupCode(), pjId, bianSunRate, zongZhiRate, queryAreaPlatformParamDTO.getReportDate());
+            if (null != bianSunRate && null != bianSunStandardValue) {
+                if (DataUtils.getQualifyResult(bianSunStandardValue, bianSunQualifyFormula, bianSunRate) == 0.0) {
+                    bianSunUnsatisfiedCount++;
+                    bianSunUnsatisfiedPjIdList.add(pjId);
+                } else {
+                    bianSunSatisfiedCount++;
+                }
+            }
+            if (null != zongZhiRate && null != zongZhiStandardValue) {
+                if (DataUtils.getQualifyResult(zongZhiStandardValue, zongZhiQualifyFormula, zongZhiRate) == 0.0) {
+                    zongZhiUnsatisfiedCount++;
+                    zongZhiUnsatisfiedPjIdList.add(pjId);
+                } else {
+                    zongZhiSatisfiedCount++;
+                }
+            }
+        }
+        // 根据未达标项目id列表获取不达标项目名称
+        List<String> bianSunPjNameList = commonService.getPjNameByPjId(bianSunUnsatisfiedPjIdList);
+        bianSunPlatform.setSatisfiedCount(bianSunSatisfiedCount);
+        bianSunPlatform.setUnsatisfiedCount(bianSunUnsatisfiedCount);
+        bianSunPlatform.setUnsatisfiedProjects(bianSunPjNameList);
+        // 根据未达标项目id列表获取不达标项目名称
+        List<String> zongZhiPjNameList = commonService.getPjNameByPjId(zongZhiUnsatisfiedPjIdList);
+        zongZhiPlatform.setSatisfiedCount(zongZhiSatisfiedCount);
+        zongZhiPlatform.setUnsatisfiedCount(zongZhiUnsatisfiedCount);
+        zongZhiPlatform.setUnsatisfiedProjects(zongZhiPjNameList);
+    }
+
+}

+ 1 - 1
src/main/java/com/persagy/apm/energy/report/monthly/detail/business/model/Platform.java

@@ -24,7 +24,7 @@ public class Platform {
     private List<Double> monthlySummaries;
 
     @ApiModelProperty("合格标准")
-    private String standardValue;
+    private Double standardValue;
 
     @ApiModelProperty("校验规则")
     private String qualifyFormula;

+ 29 - 0
src/main/java/com/persagy/apm/energy/report/workorder/client/WorkOrderWebClient.java

@@ -0,0 +1,29 @@
+package com.persagy.apm.energy.report.workorder.client;
+
+import com.persagy.apm.common.response.PoemsFeignResponse;
+import com.persagy.apm.energy.report.common.FeignClientNameConstants;
+import com.persagy.apm.energy.report.common.FeignConfig;
+import com.persagy.apm.energy.report.workorder.client.fallback.WorkOrderWebClientFallbackFactory;
+import com.persagy.apm.energy.report.workorder.model.dto.QueryWorkOrderListByParamDTO;
+import org.apache.poi.ss.formula.functions.T;
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.PostMapping;
+
+/**
+ * 工单管理feign客户端
+ **/
+@FeignClient(name = FeignClientNameConstants.WORK_ORDER, fallbackFactory = WorkOrderWebClientFallbackFactory.class,
+        configuration = FeignConfig.class)
+public interface WorkOrderWebClient {
+    /**
+     * 根据条件查询工单列表
+     *
+     * @param queryWorkOrderListByParamDTO 查询条件
+     * @return 工单列表信息
+     * @author wch
+     * @version V1.0 2021/5/19 2:27 下午
+     */
+    @PostMapping("/restWorkOrderService/queryWorkOrderList")
+    PoemsFeignResponse<T> listWorkOrderByParam(QueryWorkOrderListByParamDTO queryWorkOrderListByParamDTO);
+
+}

+ 13 - 0
src/main/java/com/persagy/apm/energy/report/workorder/client/fallback/WorkOrderWebClientFallbackFactory.java

@@ -0,0 +1,13 @@
+package com.persagy.apm.energy.report.workorder.client.fallback;
+
+import com.persagy.apm.energy.report.workorder.client.WorkOrderWebClient;
+import feign.hystrix.FallbackFactory;
+import org.springframework.stereotype.Component;
+
+@Component
+public class WorkOrderWebClientFallbackFactory implements FallbackFactory<WorkOrderWebClient> {
+    @Override
+    public WorkOrderWebClient create(Throwable throwable) {
+        return null;
+    }
+}

+ 29 - 0
src/main/java/com/persagy/apm/energy/report/workorder/model/dto/QueryWorkOrderListByParamDTO.java

@@ -0,0 +1,29 @@
+package com.persagy.apm.energy.report.workorder.model.dto;
+
+import com.persagy.apm.common.model.dto.PoemsFeignBaseDTO;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+@EqualsAndHashCode(callSuper = true)
+@Data
+@ApiModel
+public class QueryWorkOrderListByParamDTO extends PoemsFeignBaseDTO {
+
+    @ApiModelProperty("用户id")
+    private String user_id;
+
+    @ApiModelProperty("项目id")
+    private String project_id;
+
+    @ApiModelProperty("时间类型")
+    private String timeType;
+
+    @ApiModelProperty("开始时间")
+    private String start_time;
+
+    @ApiModelProperty("结束时间")
+    private String end_time;
+
+}

+ 30 - 0
src/main/java/com/persagy/apm/energy/report/workorder/service/IWorkOrderWebService.java

@@ -0,0 +1,30 @@
+package com.persagy.apm.energy.report.workorder.service;
+
+import com.persagy.apm.energy.report.common.dto.QueryAreaPlatformParamDTO;
+import com.persagy.apm.energy.report.common.dto.QueryPjPlatformParamDTO;
+import com.persagy.apm.energy.report.monthly.detail.business.model.Platform;
+import io.swagger.annotations.Api;
+
+import java.util.Date;
+import java.util.List;
+
+@Api(value = "工单管理service接口")
+public interface IWorkOrderWebService {
+    /**
+     * 获取项目能源管理平台运维工单完成率信息
+     *
+     * @param queryPjPlatformParamDTO 查询条件对象
+     * @author wch
+     * @version V1.0 2021/5/19 4:04 下午
+     */
+    void getPjWorkOrderRate(QueryPjPlatformParamDTO queryPjPlatformParamDTO, Platform platform);
+
+    /**
+     * 获取大区能源管理平台运维工单完成率信息
+     *
+     * @param queryAreaPlatformParamDTO 查询条件对象
+     * @author wch
+     * @version V1.0 2021/5/19 4:04 下午
+     */
+    void getAreaWorkOrderRate(QueryAreaPlatformParamDTO queryAreaPlatformParamDTO, Platform platform);
+}

+ 100 - 0
src/main/java/com/persagy/apm/energy/report/workorder/service/impl/IWorkOrderWebServiceImpl.java

@@ -0,0 +1,100 @@
+package com.persagy.apm.energy.report.workorder.service.impl;
+
+import com.persagy.apm.common.response.PoemsFeignResponse;
+import com.persagy.apm.energy.report.common.dto.QueryAreaPlatformParamDTO;
+import com.persagy.apm.energy.report.common.dto.QueryPjPlatformParamDTO;
+import com.persagy.apm.energy.report.common.service.CommonService;
+import com.persagy.apm.energy.report.common.utils.DataUtils;
+import com.persagy.apm.energy.report.common.utils.DateUtils;
+import com.persagy.apm.energy.report.monthly.detail.business.model.Platform;
+import com.persagy.apm.energy.report.workorder.client.WorkOrderWebClient;
+import com.persagy.apm.energy.report.workorder.model.dto.QueryWorkOrderListByParamDTO;
+import com.persagy.apm.energy.report.workorder.service.IWorkOrderWebService;
+import org.apache.poi.ss.formula.functions.T;
+import org.nfunk.jep.JEP;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.TreeMap;
+import java.util.stream.Collectors;
+
+
+@Service
+public class IWorkOrderWebServiceImpl implements IWorkOrderWebService {
+
+    @Resource
+    private WorkOrderWebClient workOrderWebClient;
+    @Resource
+    private CommonService commonService;
+
+    @Override
+    public void getPjWorkOrderRate(QueryPjPlatformParamDTO queryPjPlatformParamDTO, Platform platform) {
+        TreeMap<Date, Double> date_rateMap = new TreeMap<>();
+        Date reportDate = queryPjPlatformParamDTO.getReportDate();
+        Date startDate = DateUtils.getFirstDayOfYear(reportDate);
+        while (startDate.before(DateUtils.getMonthOff(reportDate, 1))) {
+            date_rateMap.put(startDate, getWorkOrderCompleteRate(queryPjPlatformParamDTO.getProjectId(), reportDate, queryPjPlatformParamDTO.getUserId()));
+            startDate = DateUtils.getMonthOff(startDate, 1);
+        }
+        List<Double> monthlySummaries = date_rateMap.values().stream().collect(Collectors.toList());
+        platform.setMonthlySummaries(monthlySummaries);
+    }
+
+    private Double getWorkOrderCompleteRate(String projectId, Date reportDate, String userId) {
+        Double completeRate = null;
+        try {
+            QueryWorkOrderListByParamDTO paramDTO = new QueryWorkOrderListByParamDTO();
+            paramDTO.setUser_id(userId);
+            paramDTO.setProject_id(projectId);
+            paramDTO.setTimeType("ask_end_time");
+            paramDTO.setStart_time(DateUtils.date2Str(reportDate, DateUtils.SDFSECOND));
+            paramDTO.setEnd_time(DateUtils.date2Str(DateUtils.getMonthOff(reportDate, 1), DateUtils.SDFSECOND));
+            PoemsFeignResponse<T> response = workOrderWebClient.listWorkOrderByParam(paramDTO);
+            Integer dealCount = response.getCount();
+            paramDTO.setTimeType("create_time");
+            response = workOrderWebClient.listWorkOrderByParam(paramDTO);
+            Integer workCount = response.getCount();
+            if (null != workCount && workCount != 0) {
+                completeRate = Double.valueOf(dealCount) / workCount * 100;
+            }
+            return completeRate;
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return completeRate;
+    }
+
+    @Override
+    public void getAreaWorkOrderRate(QueryAreaPlatformParamDTO queryAreaPlatformParamDTO, Platform platform) {
+        // 合格标准
+        Double standardValue = platform.getStandardValue();
+        // 校验规则
+        String qualifyFormula = platform.getQualifyFormula();
+        // 达标数量
+        Integer satisfiedCount = 0;
+        // 未达标数量
+        Integer unsatisfiedCount = 0;
+        // 未达标项目id列表
+        List<String> unsatisfiedPjIdList = new ArrayList<>();
+        for (String pjId : queryAreaPlatformParamDTO.getProjectIdList()) {
+            Double completeRate = getWorkOrderCompleteRate(pjId, queryAreaPlatformParamDTO.getReportDate(), queryAreaPlatformParamDTO.getUserId());
+            if (null != completeRate && null != standardValue) {
+                if (DataUtils.getQualifyResult(standardValue, qualifyFormula, completeRate) == 0.0) {
+                    unsatisfiedCount++;
+                    unsatisfiedPjIdList.add(pjId);
+                } else {
+                    satisfiedCount++;
+                }
+            }
+        }
+        // 根据未达标项目id列表获取不达标项目名称
+        List<String> pjNameList = commonService.getPjNameByPjId(unsatisfiedPjIdList);
+        platform.setSatisfiedCount(satisfiedCount);
+        platform.setUnsatisfiedCount(unsatisfiedCount);
+        platform.setUnsatisfiedProjects(pjNameList);
+    }
+
+}