Bladeren bron

'电力告警分页'

yq 3 jaren geleden
bovenliggende
commit
ed6336773f

+ 13 - 3
fiveep-controller/src/main/java/com/bizmatics/controller/web/HtAnalogDataController.java

@@ -2,11 +2,8 @@ package com.bizmatics.controller.web;
 
 
 import com.bizmatics.common.core.bean.ApiResult;
-import com.bizmatics.model.HtAnalogData;
 import com.bizmatics.model.vo.DataManagementVO;
-import com.bizmatics.model.vo.HtAnalogDataVo;
 import com.bizmatics.service.HtAnalogDataService;
-import com.bizmatics.service.impl.HtAnalogDataServiceImpl;
 import com.bizmatics.service.vo.*;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
@@ -106,6 +103,19 @@ public class HtAnalogDataController {
         return ApiResult.success(htAnalogDataService.getElectricIco(siteId, date));
     }
 
+    /**
+     * 历史电流电压评分
+     * @param deviceName
+     * @param startTime
+     * @param endTime
+     * @return
+     */
+    @GetMapping("rtRealScore")
+    public ApiResult<List<RealScoreVO>> rtRealScore(@RequestParam String deviceName,
+                                                            @RequestParam Date startTime,
+                                                            @RequestParam Date endTime) {
+        return ApiResult.success(htAnalogDataService.rtRealScore(deviceName, startTime,endTime));
+    }
 
     /**
      *数据管理-同比分析报表-统计图数据查询

+ 11 - 1
fiveep-controller/src/main/java/com/bizmatics/controller/web/RtAnalogDataController.java

@@ -4,10 +4,10 @@ package com.bizmatics.controller.web;
 import com.bizmatics.common.core.bean.ApiResult;
 import com.bizmatics.service.RtAnalogDataService;
 import com.bizmatics.service.vo.RadCountVO;
+import com.bizmatics.service.vo.RealScoreVO;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
-
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
@@ -59,6 +59,16 @@ public class RtAnalogDataController {
         return ApiResult.success(rtAnalogDataService.getEpLoad(siteId));
     }
 
+    /**
+     * 电能质量(实时评分)
+     * @param deviceName 设备编号
+     * @return
+     */
+    @GetMapping("realScore")
+    public ApiResult<RealScoreVO> realScore(@RequestParam String deviceName){
+        return ApiResult.success(rtAnalogDataService.realScore(deviceName));
+    }
+
     @RequestMapping("DataReport")
     public ApiResult<List<Map<String,Object>>> getDataReport(@RequestParam Integer siteId,
                                                              @RequestParam(required = false) Date startTime,

+ 16 - 1
fiveep-persistence/src/main/java/com/bizmatics/persistence/mapper/AlarmPowerMapper.java

@@ -2,8 +2,8 @@ package com.bizmatics.persistence.mapper;
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.bizmatics.model.AlarmPower;
 import com.bizmatics.common.mvc.base.CrudMapper;
+import com.bizmatics.model.AlarmPower;
 import org.apache.ibatis.annotations.Param;
 import org.springframework.stereotype.Repository;
 
@@ -63,5 +63,20 @@ public interface AlarmPowerMapper extends CrudMapper<AlarmPower> {
                           @Param("startTime") Date startTime,
                           @Param("endTime") Date endTime);
 
+    Page<Map<String,Object>> gradeSiteList(IPage<Map<String,Object>> page,
+                                           @Param("userId") Integer userId,
+                                           @Param("siteId") Integer siteId,
+                                           @Param("startTime") Date startTime,
+                                           @Param("endTime") Date endTime,
+                                           @Param("oneGrads") List<String> oneGrads,
+                                           @Param("otherGrads") List<String> otherGrads);
+    Page<AlarmPower> gradeList(IPage<AlarmPower> page,
+                               @Param("userId") Integer userId,
+                               @Param("siteId") Integer siteId,
+                               @Param("startTime") Date startTime,
+                               @Param("endTime") Date endTime,
+                               @Param("grades") List<String> grades,
+                               @Param("gradeType") Integer gradeType);
+
     List<AlarmPower> getLoopStatusListMap(@Param("siteId") Integer siteId);
 }

+ 78 - 0
fiveep-persistence/src/main/resources/mapper/mysql/AlarmPowerMapper.xml

@@ -115,6 +115,84 @@
             </if>
         </where>
     </select>
+    <select id="gradeSiteList" resultType="java.util.Map">
+        SELECT us.site_id as siteId,s.site_name as siteName
+        (select count(*)
+        FROM alarm_power as ap
+        WHERE d.device_code = ap.device_code
+        <if test="oneGrads != null and oneGrads.size() > 0">
+            and ap.meas_name in
+            <foreach collection="oneGrads" item="name" index="index" open="(" close=")" separator=",">
+                #{name}
+            </foreach>
+        </if>
+        <if test="startTime != null and endTime != null">
+            and ap.sending_time between #{startTime} and #{endTime}
+        </if>) as oneGrade,
+        (select count(*)
+        FROM alarm_power as ap
+        WHERE d.device_code = ap.device_code
+        <if test="otherGrads != null and otherGrads.size() > 0">
+            and ap.meas_name in
+            <foreach collection="otherGrads" item="name" index="index" open="(" close=")" separator=",">
+                #{name}
+            </foreach>
+        </if>
+        <if test="startTime != null and endTime != null">
+            and ap.sending_time between #{startTime} and #{endTime}
+        </if>) as twoGrade,
+        (select count(*)
+        FROM alarm_power as ap
+        WHERE d.device_code = ap.device_code
+        <if test="startTime != null and endTime != null">
+            and ap.sending_time between #{startTime} and #{endTime}
+        </if>) as countGrade
+        from user_site as us
+        inner join device as d
+        on us.site_id = d.site_id
+        inner join site as s
+        on s.id = us.site_id
+        <where>
+            <if test="userId != null and userId != 0">
+                and us.user_id = #{userId}
+            </if>
+            <if test="siteId != null and siteId != 0">
+                and us.site_id = #{siteId}
+            </if>
+        </where>
+        group by us.site_id
+    </select>
+    <select id="gradeList" resultType="com.bizmatics.model.AlarmPower">
+        select ap.*
+        from user_site as us
+        inner join device as d
+        on us.site_id = d.site_id
+        inner join alarm_power as ap
+        on d.device_code = ap.device_code
+        <where>
+            <if test="userId != null and userId != 0">
+                and us.user_id = #{userId}
+            </if>
+            <if test="siteId != null and siteId != 0">
+                and us.site_id = #{siteId}
+            </if>
+            <if test="startTime != null and endTime != null">
+                and ap.sending_time between #{startTime} and #{endTime}
+            </if>
+            <if test="gradeType == 1 or gradeType == 3">
+                and ap.meas_name in
+                <foreach collection="otherGrads" item="name" index="index" open="(" close=")" separator=",">
+                    #{name}
+                </foreach>
+            </if>
+            <if test="gradeType == 2">
+                and ap.meas_name not in
+                <foreach collection="otherGrads" item="name" index="index" open="(" close=")" separator=",">
+                    #{name}
+                </foreach>
+            </if>
+        </where>
+    </select>
 
 
 </mapper>

+ 25 - 1
fiveep-service/src/main/java/com/bizmatics/service/AlarmPowerService.java

@@ -1,8 +1,9 @@
 package com.bizmatics.service;
 
 import com.bizmatics.common.core.bean.CommonPage;
-import com.bizmatics.model.AlarmPower;
 import com.bizmatics.common.mvc.base.CrudService;
+import com.bizmatics.model.AlarmPower;
+import com.bizmatics.service.vo.AlarmGradeVO;
 import com.bizmatics.service.vo.ApCountVO;
 import com.bizmatics.service.vo.CommonIcoVO;
 
@@ -42,6 +43,29 @@ public interface AlarmPowerService extends CrudService<AlarmPower> {
      */
     CommonPage<AlarmPower> page(Date startTime, Date endTime, Integer status, Integer siteId, Integer current, Integer size);
 
+    /**
+     * 告警等级统计
+     * @param siteId
+     * @param startTime
+     * @param endTime
+     * @return
+     */
+    CommonPage<AlarmGradeVO> alarmGradeCount(Integer siteId,Date startTime,Date endTime,Integer current,Integer size);
+
+    /**
+     * 告警等级集合
+     * @param siteId
+     * @param startTime
+     * @param endTime
+     * @param current
+     * @param size
+     * @param type
+     * @return
+     */
+    CommonPage<AlarmPower> alarmGradeList(Integer siteId,Date startTime,Date endTime,Integer current,Integer size,Integer type);
+
+
+
     List<Map<String,Object>> getLoopStatusList(Integer siteId);
 
 

+ 2 - 14
fiveep-service/src/main/java/com/bizmatics/service/HtAnalogDataService.java

@@ -3,10 +3,7 @@ package com.bizmatics.service;
 import com.bizmatics.common.mvc.base.CrudService;
 import com.bizmatics.model.HtAnalogData;
 import com.bizmatics.model.vo.DataManagementVO;
-import com.bizmatics.service.vo.CommonIcoOneVO;
-import com.bizmatics.service.vo.CommonIcoVO;
-import com.bizmatics.service.vo.HadCountVO;
-import com.bizmatics.service.vo.TimeShareVO;
+import com.bizmatics.service.vo.*;
 
 import java.util.Date;
 import java.util.List;
@@ -81,16 +78,7 @@ public interface HtAnalogDataService extends CrudService<HtAnalogData> {
      * @param endTime
      * @return
      */
-    List<HtAnalogData> listByDeviceAndDate(String deviceName,Date startTime,Date endTime);
-
-    /**
-     * 三相不平衡
-     * @param deviceName
-     * @param startTime
-     * @param endTime
-     * @return
-     */
-    List<CommonIcoVO> balun(String deviceName,Date startTime,Date endTime);
+    List<RealScoreVO> rtRealScore(String deviceName, Date startTime, Date endTime);
 
     List<CommonIcoVO> yearOnYearList(DataManagementVO dataManagementVO);
 

+ 13 - 2
fiveep-service/src/main/java/com/bizmatics/service/RtAnalogDataService.java

@@ -1,8 +1,11 @@
 package com.bizmatics.service;
 
-import com.bizmatics.model.RtAnalogData;
 import com.bizmatics.common.mvc.base.CrudService;
+import com.bizmatics.model.DeviceAttribute;
+import com.bizmatics.model.RtAnalogData;
+import com.bizmatics.model.SiteDynamicProperties;
 import com.bizmatics.service.vo.RadCountVO;
+import com.bizmatics.service.vo.RealScoreVO;
 
 import java.util.Date;
 import java.util.List;
@@ -44,8 +47,16 @@ public interface RtAnalogDataService extends CrudService<RtAnalogData> {
      * @param deviceName
      * @return
      */
-    List<String> realScore(String deviceName);
+    RealScoreVO realScore(String deviceName);
 
+    /**
+     * 填充数据
+     * @param rtAnalogData
+     * @param siteDynamicProperties
+     * @param deviceAttribute
+     * @return
+     */
+    RealScoreVO fillRealScoreData(RtAnalogData rtAnalogData, SiteDynamicProperties siteDynamicProperties, DeviceAttribute deviceAttribute);
 
     /**
      *

+ 16 - 0
fiveep-service/src/main/java/com/bizmatics/service/enums/AlarmGradeCode.java

@@ -0,0 +1,16 @@
+package com.bizmatics.service.enums;
+
+/**
+ * @author yq
+ * @date 2021/10/26 10:16
+ */
+public enum AlarmGradeCode {
+    BusOutage,
+    PhaseLoss,
+    OverV,
+    UnderV,
+    OverEvT,
+    DevAbnormal,
+    DevOffline;
+
+}

+ 52 - 0
fiveep-service/src/main/java/com/bizmatics/service/impl/AlarmPowerServiceImpl.java

@@ -13,7 +13,9 @@ import com.bizmatics.common.spring.util.GlobalUtils;
 import com.bizmatics.model.AlarmPower;
 import com.bizmatics.persistence.mapper.AlarmPowerMapper;
 import com.bizmatics.service.AlarmPowerService;
+import com.bizmatics.service.enums.AlarmGradeCode;
 import com.bizmatics.service.util.SecurityUtils;
+import com.bizmatics.service.vo.AlarmGradeVO;
 import com.bizmatics.service.vo.AlarmPowerExportVO;
 import com.bizmatics.service.vo.ApCountVO;
 import com.bizmatics.service.vo.CommonIcoVO;
@@ -27,6 +29,7 @@ import java.io.IOException;
 import java.text.SimpleDateFormat;
 import java.util.*;
 import java.util.concurrent.TimeUnit;
+import java.util.stream.Collectors;
 
 
 /**
@@ -82,6 +85,55 @@ public class AlarmPowerServiceImpl extends AbstractCrudService<AlarmPowerMapper,
         return this.ToCommonPage(page);
     }
 
+    @Override
+    public CommonPage<AlarmGradeVO> alarmGradeCount(Integer siteId, Date startTime, Date endTime,Integer current,Integer size) {
+        Page<Map<String,Object>> page = new Page<>(current,size);
+        Integer userId = SecurityUtils.getLoginUser().getUser().getUserId().intValue();
+        List<String> otherGrads = Arrays.stream(AlarmGradeCode.values())
+                .filter(alarmGradeCode -> alarmGradeCode.name().equals(AlarmGradeCode.DevOffline.name()))
+                .map(Enum::name).collect(Collectors.toList());
+        List<String> oneGrads = Arrays.stream(AlarmGradeCode.values())
+                .filter(alarmGradeCode -> !alarmGradeCode.name().equals(AlarmGradeCode.DevOffline.name()))
+                .map(Enum::name).collect(Collectors.toList());
+        page  = baseMapper.gradeSiteList(page, userId, siteId, startTime, endTime, oneGrads, otherGrads);
+        List<AlarmGradeVO> list = new ArrayList<>();
+        page.getRecords().forEach(map -> list.add(enhanceAlarmGradeVo(map)));
+        return new CommonPage<>(list,page.getTotal(),page.getSize(),page.getCurrent());
+    }
+
+    @Override
+    public CommonPage<AlarmPower> alarmGradeList(Integer siteId, Date startTime, Date endTime, Integer current, Integer size, Integer type) {
+        List<String> gradeList = null;
+        //1级告警
+        if (1 == type){
+            gradeList = Arrays.stream(AlarmGradeCode.values())
+                    .filter(alarmGradeCode -> alarmGradeCode.name().equals(AlarmGradeCode.DevOffline.name()))
+                    .map(Enum::name).collect(Collectors.toList());
+        }else if (2 == type){
+            gradeList = Arrays.stream(AlarmGradeCode.values())
+                    .map(Enum::name).collect(Collectors.toList());
+        }else if (3 == type){
+            gradeList = Arrays.stream(AlarmGradeCode.values())
+                    .filter(alarmGradeCode -> alarmGradeCode.name().equals(AlarmGradeCode.DevOffline.name()))
+                    .map(Enum::name).collect(Collectors.toList());
+        }
+        Integer userId = SecurityUtils.getLoginUser().getUser().getUserId().intValue();
+        Page<AlarmPower> page = new Page<>(current,size);
+        page = baseMapper.gradeList(page,userId,siteId,startTime,endTime,gradeList,type);
+        return ToCommonPage(page);
+    }
+
+    public AlarmGradeVO enhanceAlarmGradeVo(Map<String,Object> map){
+        AlarmGradeVO alarmGradeVO = new AlarmGradeVO();
+        alarmGradeVO.setSiteId(Integer.parseInt(map.get("siteId").toString()));
+        alarmGradeVO.setSiteName(map.get("siteName").toString());
+        alarmGradeVO.setTotalGrade(Integer.parseInt(map.get("countGrade").toString()));
+        alarmGradeVO.setOneGrade(Integer.parseInt(map.get("oneGrade").toString()));
+        alarmGradeVO.setOtherGrade(Integer.parseInt(map.get("otherGrade").toString()));
+        alarmGradeVO.setTwoGrade(alarmGradeVO.getTotalGrade()-alarmGradeVO.getOneGrade()-alarmGradeVO.getOtherGrade());
+        return alarmGradeVO;
+    }
+
     @Override
     public List<Map<String, Object>> getLoopStatusList(Integer siteId) {
         SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

+ 35 - 39
fiveep-service/src/main/java/com/bizmatics/service/impl/HtAnalogDataServiceImpl.java

@@ -2,22 +2,19 @@ package com.bizmatics.service.impl;
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.bizmatics.common.core.exception.BusinessException;
 import com.bizmatics.common.core.util.Arith;
+import com.bizmatics.common.core.util.BeanMapperUtils;
 import com.bizmatics.common.core.util.DateUtils;
 import com.bizmatics.common.mvc.base.AbstractCrudService;
 import com.bizmatics.common.spring.util.JsonUtils;
-import com.bizmatics.model.HadSiteStatic;
-import com.bizmatics.model.HtAnalogData;
+import com.bizmatics.model.*;
 import com.bizmatics.model.vo.DataManagementVO;
 import com.bizmatics.model.vo.HtAnalogDataVo;
 import com.bizmatics.persistence.mapper.HtAnalogDataMapper;
-import com.bizmatics.service.HadSiteStaticService;
-import com.bizmatics.service.HtAnalogDataService;
+import com.bizmatics.service.*;
 import com.bizmatics.service.util.SecurityUtils;
-import com.bizmatics.service.vo.CommonIcoOneVO;
-import com.bizmatics.service.vo.CommonIcoVO;
-import com.bizmatics.service.vo.HadCountVO;
-import com.bizmatics.service.vo.TimeShareVO;
+import com.bizmatics.service.vo.*;
 import com.fasterxml.jackson.core.type.TypeReference;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -37,6 +34,15 @@ public class HtAnalogDataServiceImpl extends AbstractCrudService<HtAnalogDataMap
 
     @Autowired
     private HadSiteStaticService hadSiteStaticService;
+    @Autowired
+    private RtAnalogDataService rtAnalogDataService;
+
+    @Autowired
+    private DeviceService deviceService;
+    @Autowired
+    private SiteDynamicPropertiesService siteDynamicPropertiesService;
+    @Autowired
+    private DeviceAttributeService deviceAttributeService;
 
     @Override
     public HadCountVO selectCount() {
@@ -274,42 +280,32 @@ public class HtAnalogDataServiceImpl extends AbstractCrudService<HtAnalogDataMap
     }
 
     @Override
-    public List<HtAnalogData> listByDeviceAndDate(String deviceName, Date startTime, Date endTime) {
+    public List<RealScoreVO> rtRealScore(String deviceName, Date startTime, Date endTime) {
         LambdaQueryWrapper<HtAnalogData> queryWrapper = Wrappers.lambdaQuery();
         queryWrapper.select(HtAnalogData::getIa,HtAnalogData::getIb,HtAnalogData::getIc,HtAnalogData::getUa,HtAnalogData::getUb,HtAnalogData::getUc)
                 .eq(HtAnalogData::getDeviceName,deviceName)
                 .between(HtAnalogData::getDataTime,startTime,endTime);
-        return list(queryWrapper);
-    }
-
-    @Override
-    public List<CommonIcoVO> balun(String deviceName, Date startTime, Date endTime) {
-        List<HtAnalogData> list = listByDeviceAndDate(deviceName, startTime, endTime);
-        List<Double> aList = new ArrayList<>();
-        List<Double> uList = new ArrayList<>();
-        List<Double> checkList = new ArrayList<>();
+        List<HtAnalogData> list = this.list(queryWrapper);
+        //查询设备
+        LambdaQueryWrapper<Device> deviceQuery = Wrappers.lambdaQuery();
+        deviceQuery.eq(Device::getDeviceName,deviceName);
+        Device device = deviceService.getOne(deviceQuery);
+        Optional.ofNullable(device).orElseThrow(() -> new BusinessException("设备不存在"));
+        //查询sd
+        LambdaQueryWrapper<SiteDynamicProperties> sdQuery = Wrappers.lambdaQuery();
+        sdQuery.eq(SiteDynamicProperties::getSiteId,device.getSiteId());
+        SiteDynamicProperties siteDynamicProperties = siteDynamicPropertiesService.getOne(sdQuery);
+        Optional.ofNullable(siteDynamicProperties).orElseThrow(() -> new BusinessException("sd不存在"));
+        LambdaQueryWrapper<DeviceAttribute> adQuery = Wrappers.lambdaQuery();
+        adQuery.eq(DeviceAttribute::getSiteId,device.getSiteId());
+        DeviceAttribute deviceAttribute= deviceAttributeService.getOne(adQuery);
+        Optional.ofNullable(deviceAttribute).orElseThrow(() -> new BusinessException("da不存在"));
+        List<RealScoreVO> realScoreVOS = new ArrayList<>();
         for (HtAnalogData htAnalogData:list) {
-            checkList.add(htAnalogData.getIa());
-            checkList.add(htAnalogData.getIb());
-            checkList.add(htAnalogData.getIc());
-            aList.add(checkBalun(checkList));
-            list.clear();
-            checkList.add(htAnalogData.getUa());
-            checkList.add(htAnalogData.getUb());
-            checkList.add(htAnalogData.getUc());
-            uList.add(checkBalun(checkList));
-            list.clear();
-        }
-        List<CommonIcoVO> commonIcoVOS = new ArrayList<>();
-        commonIcoVOS.add(CommonIcoVO.builder().name("电流不平衡度").listDate(aList).build());
-        commonIcoVOS.add(CommonIcoVO.builder().name("电压不平衡度").listDate(uList).build());
-        return commonIcoVOS;
-    }
-
-    public Double checkBalun(List<Double> list){
-        Double max = list.stream().max(Double::compareTo).get();
-        Double min = list.stream().min(Double::compareTo).get();
-        return Arith.div(Arith.sub(max,min),max);
+            RtAnalogData rtAnalogData = BeanMapperUtils.map(htAnalogData, RtAnalogData.class);
+            realScoreVOS.add(rtAnalogDataService.fillRealScoreData(rtAnalogData,siteDynamicProperties,deviceAttribute));
+        }
+        return realScoreVOS;
     }
 
 

+ 62 - 11
fiveep-service/src/main/java/com/bizmatics/service/impl/RtAnalogDataServiceImpl.java

@@ -115,19 +115,34 @@ public class RtAnalogDataServiceImpl extends AbstractCrudService<RtAnalogDataMap
     }
 
     @Override
-    public List<String> realScore(String deviceName) {
+    public RealScoreVO realScore(String deviceName) {
         LambdaQueryWrapper<RtAnalogData> queryWrapper = Wrappers.lambdaQuery();
         queryWrapper.eq(RtAnalogData::getDeviceName,deviceName);
         RtAnalogData rtAnalogData = getOne(queryWrapper);
-
-        return null;
+        //查询设备
+        LambdaQueryWrapper<Device> deviceQuery = Wrappers.lambdaQuery();
+        deviceQuery.eq(Device::getDeviceName,deviceName);
+        Device device = deviceService.getOne(deviceQuery);
+        Optional.ofNullable(device).orElseThrow(() -> new BusinessException("设备不存在"));
+        //查询sd
+        LambdaQueryWrapper<SiteDynamicProperties> sdQuery = Wrappers.lambdaQuery();
+        sdQuery.eq(SiteDynamicProperties::getSiteId,device.getSiteId());
+        SiteDynamicProperties siteDynamicProperties = siteDynamicPropertiesService.getOne(sdQuery);
+        Optional.ofNullable(siteDynamicProperties).orElseThrow(() -> new BusinessException("sd不存在"));
+        LambdaQueryWrapper<DeviceAttribute> adQuery = Wrappers.lambdaQuery();
+        adQuery.eq(DeviceAttribute::getSiteId,device.getSiteId());
+        DeviceAttribute deviceAttribute= deviceAttributeService.getOne(adQuery);
+        Optional.ofNullable(deviceAttribute).orElseThrow(() -> new BusinessException("da不存在"));
+        return  fillRealScoreData(rtAnalogData,siteDynamicProperties,deviceAttribute);
     }
 
     /**
      * 填充实时数据
      */
-    public void fillRealScoreData(RtAnalogData rtAnalogData, SiteDynamicProperties siteDynamicProperties,DeviceAttribute deviceAttribute){
+    @Override
+    public RealScoreVO fillRealScoreData(RtAnalogData rtAnalogData, SiteDynamicProperties siteDynamicProperties,DeviceAttribute deviceAttribute){
         List<Double> checkList = new ArrayList<>();
+        Integer score = 0;
         RealScoreVO realScoreVo = BeanMapperUtils.map(rtAnalogData, RealScoreVO.class);
         checkList.add(realScoreVo.getIa());
         checkList.add(realScoreVo.getIb());
@@ -141,15 +156,51 @@ public class RtAnalogDataServiceImpl extends AbstractCrudService<RtAnalogDataMap
         //电压不平衡
         realScoreVo.setVtBalun(checkBalun(checkList));
         //电压合格率
-        realScoreVo.setUaQualified(Arith.sub(rtAnalogData.getUa(), Double.parseDouble(siteDynamicProperties.getVoltageLevel())));
-        realScoreVo.setUbQualified(Arith.sub(rtAnalogData.getUb(), Double.parseDouble(siteDynamicProperties.getVoltageLevel())));
-        realScoreVo.setUcQualified(Arith.sub(rtAnalogData.getUc(), Double.parseDouble(siteDynamicProperties.getVoltageLevel())));
+        double voltageLevel = Double.parseDouble(siteDynamicProperties.getVoltageLevel());
+        realScoreVo.setUaQualified(Arith.sub(rtAnalogData.getUa(), voltageLevel));
+        realScoreVo.setUbQualified(Arith.sub(rtAnalogData.getUb(),voltageLevel));
+        realScoreVo.setUcQualified(Arith.sub(rtAnalogData.getUc(), voltageLevel));
         //电流负载率
-        realScoreVo.setIaLoad(Arith.div(realScoreVo.getIa(),deviceAttribute.getRatedCurrent()));
-        realScoreVo.setIbLoad(Arith.div(realScoreVo.getIb(),deviceAttribute.getRatedCurrent()));
-        realScoreVo.setIcLoad(Arith.div(realScoreVo.getIc(),deviceAttribute.getRatedCurrent()));
-        //金
+        Double ratedCurrent = deviceAttribute.getRatedCurrent();
+        realScoreVo.setIaLoad(Arith.div(realScoreVo.getIa(),ratedCurrent));
+        realScoreVo.setIbLoad(Arith.div(realScoreVo.getIb(),ratedCurrent));
+        realScoreVo.setIcLoad(Arith.div(realScoreVo.getIc(),ratedCurrent));
+        //计算分数
+        //电压分数
+        if (computeUScore(realScoreVo.getUaQualified(),voltageLevel) && computeUScore(realScoreVo.getUbQualified(),voltageLevel)
+        && computeUScore(realScoreVo.getUcQualified(),voltageLevel)) {
+            score+=20;
+        }
+        //电流分数
+        if (realScoreVo.getIaLoad() <= 0.8 && realScoreVo.getIbLoad() <= 0.8 && realScoreVo.getIcLoad() <= 0.8){
+            score+=20;
+        }
+        //电压平衡分数
+        if (realScoreVo.getElBalun() <= 0.15){
+            score+=20;
+        }
+        //电流平衡分数
+        if (realScoreVo.getVtBalun() <= 0.15){
+            score+=20;
+        }
+        //功率
+        if (realScoreVo.getCOS() <= 0.15){
+            score+=20;
+        }
+        realScoreVo.setScore(score);
+        return realScoreVo;
+    }
 
+    /**
+     * 计算电压分数
+     * @return
+     */
+    public Boolean computeUScore(Double qualified,Double voltageLevel){
+        double mul = Arith.mul(qualified, voltageLevel);
+        if (mul <= 0.07 && mul >= -0.07){
+            return true;
+        }
+        return false;
     }
 
 

+ 35 - 0
fiveep-service/src/main/java/com/bizmatics/service/vo/AlarmGradeVO.java

@@ -0,0 +1,35 @@
+package com.bizmatics.service.vo;
+
+import lombok.Data;
+
+/**
+ * @author yq
+ * @date 2021/10/25 16:46
+ */
+@Data
+public class AlarmGradeVO {
+    /**
+     * 一级告警
+     */
+    private Integer oneGrade;
+    /**
+     * 二级告警
+     */
+    private Integer twoGrade;
+    /**
+     * 其他告警
+     */
+    private Integer otherGrade;
+    /**
+     * 站点名称
+     */
+    private String siteName;
+    /**
+     * 站点名称
+      */
+    private Integer siteId;
+    /**
+     * 总告警数
+     */
+    private Integer totalGrade;
+}

+ 1 - 1
fiveep-service/src/main/java/com/bizmatics/service/vo/RealScoreVO.java

@@ -79,7 +79,7 @@ public class RealScoreVO {
     /**
      * 分数
      */
-    private Double score;
+    private Integer score;
     /**
      * 回路
      */