Quellcode durchsuchen

Merge branch 'master' into feature-management-2021-9-16

jichaobo vor 3 Jahren
Ursprung
Commit
499f7282ed

+ 1 - 1
fiveep-common/fiveep-common-core/src/main/java/com/bizmatics/common/core/util/DateUtils.java

@@ -66,7 +66,7 @@ public final class DateUtils extends org.apache.commons.lang3.time.DateUtils {
      * 默认时间格式
      */
     private static final String DEFAULT_LOCAL_DATE_TIME_FMT = "yyyy-MM-dd'T'HH:mm:ss";
-    private static final String DEFAULT_DATE_TIME_FMT = "yyyy-MM-dd'T'HH:mm:ssZ";
+    private static final String DEFAULT_DATE_TIME_FMT = "yyyy-MM-dd HH:mm:ss";
 
     private DateUtils() {
     }

+ 1 - 1
fiveep-common/fiveep-common-mvc/src/main/java/com/bizmatics/common/mvc/config/convert/StringDateConverter.java

@@ -1,6 +1,6 @@
 package com.bizmatics.common.mvc.config.convert;
 
-import com.bizmatics.common.core.util.DateUtils;
+import  com.bizmatics.common.core.util.DateUtils;
 import org.springframework.core.convert.converter.Converter;
 
 import java.util.Date;

+ 0 - 25
fiveep-controller/src/main/java/com/bizmatics/controller/MyConfiguration.java

@@ -1,25 +0,0 @@
-package com.bizmatics.controller;
-
-import org.springframework.context.annotation.Configuration;
-import org.springframework.http.converter.HttpMessageConverter;
-import org.springframework.http.converter.StringHttpMessageConverter;
-import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
-
-import java.nio.charset.StandardCharsets;
-import java.util.List;
-
-
-@Configuration
-public class MyConfiguration extends WebMvcConfigurationSupport {
-
-    @Override
-    protected void extendMessageConverters(List<HttpMessageConverter<?>> converters) {
-        // 解决controller返回字符串中文乱码问题
-        for (HttpMessageConverter<?> converter : converters) {
-            if (converter instanceof StringHttpMessageConverter) {
-                ((StringHttpMessageConverter)converter).setDefaultCharset(StandardCharsets.UTF_8);
-            }
-        }
-    }
-
-}

+ 50 - 5
fiveep-controller/src/main/java/com/bizmatics/controller/web/AlarmPowerController.java

@@ -5,14 +5,11 @@ import com.bizmatics.common.core.bean.ApiResult;
 import com.bizmatics.common.core.bean.CommonPage;
 import com.bizmatics.model.AlarmPower;
 import com.bizmatics.service.AlarmPowerService;
+import com.bizmatics.service.vo.AlarmGradeVO;
 import com.bizmatics.service.vo.ApCountVO;
 import com.bizmatics.service.vo.CommonIcoVO;
 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;
+import org.springframework.web.bind.annotation.*;
 
 import java.util.Date;
 import java.util.List;
@@ -81,6 +78,54 @@ public class AlarmPowerController {
         return ApiResult.success(alarmPowerService.page(startTime, endTime, status, siteId, current, size));
     }
 
+    /**
+     * 告警等级统计
+     * @param siteId 站点id
+     * @param startTime 开始时间
+     * @param endTime 结束时间
+     * @param current 页数
+     * @param size 条数
+     * @return
+     */
+    @GetMapping("/alarmGradeCount")
+    public ApiResult<CommonPage<AlarmGradeVO>> alarmGradeCount(@RequestParam(required = false) Integer siteId,
+                                                               @RequestParam(required = false) Date startTime,
+                                                               @RequestParam(required = false) Date endTime,
+                                                               @RequestParam Integer current,
+                                                               @RequestParam Integer size){
+        return ApiResult.success(alarmPowerService.alarmGradeCount(siteId, startTime, endTime, current, size));
+    }
+
+    /**
+     * 告警等级集合
+     * @param siteId 站点id
+     * @param startTime 开始时间
+     * @param endTime 结束时间
+     * @param current 页数
+     * @param size 条数
+     * @return
+     */
+    @GetMapping("/alarmGradeList")
+    public ApiResult<CommonPage<AlarmPower>> alarmGradeList(@RequestParam(required = false) Integer siteId,
+                                                            @RequestParam(required = false) Date startTime,
+                                                            @RequestParam(required = false) Date endTime,
+                                                            @RequestParam Integer current,
+                                                            @RequestParam Integer size,
+                                                            @RequestParam(required = false) Integer type){
+
+        return ApiResult.success(alarmPowerService.alarmGradeList(siteId,startTime,endTime,current,size,type));
+    }
+
+    /**
+     * 修改数据
+     * @param alarmPower
+     * @return
+     */
+    @PutMapping
+    public ApiResult<Boolean> update(@RequestBody AlarmPower alarmPower){
+        return ApiResult.success(alarmPowerService.updateById(alarmPower));
+    }
+
     @RequestMapping("LoopStatusList")
     public ApiResult<List<Map<String,Object>>> getLoopStatus(@RequestParam Integer siteId){
         return ApiResult.success(alarmPowerService.getLoopStatusList(siteId));

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

@@ -106,16 +106,16 @@ public class HtAnalogDataController {
 
     /**
      * 历史电流电压评分
-     * @param deviceName
+     * @param deviceCode
      * @param startTime
      * @param endTime
      * @return
      */
     @GetMapping("rtRealScore")
-    public ApiResult<List<RealScoreVO>> rtRealScore(@RequestParam String deviceName,
+    public ApiResult<List<RealScoreVO>> rtRealScore(@RequestParam String deviceCode,
                                                             @RequestParam Date startTime,
                                                             @RequestParam Date endTime) {
-        return ApiResult.success(htAnalogDataService.rtRealScore(deviceName, startTime,endTime));
+        return ApiResult.success(htAnalogDataService.rtRealScore(deviceCode, startTime,endTime));
     }
 
     /**

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

@@ -61,12 +61,12 @@ public class RtAnalogDataController {
 
     /**
      * 电能质量(实时评分)
-     * @param deviceName 设备编号
+     * @param deviceCode 设备编号
      * @return
      */
     @GetMapping("realScore")
-    public ApiResult<RealScoreVO> realScore(@RequestParam String deviceName){
-        return ApiResult.success(rtAnalogDataService.realScore(deviceName));
+    public ApiResult<RealScoreVO> realScore(@RequestParam String deviceCode){
+        return ApiResult.success(rtAnalogDataService.realScore(deviceCode));
     }
 
     @RequestMapping("DataReport")

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

@@ -116,7 +116,7 @@
         </where>
     </select>
     <select id="gradeSiteList" resultType="java.util.Map">
-        SELECT us.site_id as siteId,s.site_name as siteName
+        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
@@ -140,7 +140,7 @@
         </if>
         <if test="startTime != null and endTime != null">
             and ap.sending_time between #{startTime} and #{endTime}
-        </if>) as twoGrade,
+        </if>) as otherGrade,
         (select count(*)
         FROM alarm_power as ap
         WHERE d.device_code = ap.device_code
@@ -181,13 +181,13 @@
             </if>
             <if test="gradeType == 1 or gradeType == 3">
                 and ap.meas_name in
-                <foreach collection="otherGrads" item="name" index="index" open="(" close=")" separator=",">
+                <foreach collection="grades" 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=",">
+                <foreach collection="grades" item="name" index="index" open="(" close=")" separator=",">
                     #{name}
                 </foreach>
             </if>

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

@@ -74,12 +74,12 @@ public interface HtAnalogDataService extends CrudService<HtAnalogData> {
 
     /**
      * 根据设备和时间查看电流电压
-     * @param deviceName
+     * @param deviceCode
      * @param startTime
      * @param endTime
      * @return
      */
-    List<RealScoreVO> rtRealScore(String deviceName, Date startTime, Date endTime);
+    List<RealScoreVO> rtRealScore(String deviceCode, Date startTime, Date endTime);
 
     List<CommonIcoVO> yearOnYearList(DataManagementOneVO dataManagementOneVO);
 

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

@@ -44,10 +44,10 @@ public interface RtAnalogDataService extends CrudService<RtAnalogData> {
 
     /**
      * 电能质量(实时评分)
-     * @param deviceName
+     * @param deviceCode
      * @return
      */
-    RealScoreVO realScore(String deviceName);
+    RealScoreVO realScore(String deviceCode);
 
     /**
      * 填充数据

+ 1 - 3
fiveep-service/src/main/java/com/bizmatics/service/config/ResourcesConfig.java

@@ -11,10 +11,9 @@ import org.springframework.web.filter.CorsFilter;
 import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
 import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
 import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
-
 /**
  * 通用配置
- * 
+ *
  * @author yq
  */
 @Configuration
@@ -41,7 +40,6 @@ public class ResourcesConfig implements WebMvcConfigurer
     {
         registry.addInterceptor(repeatSubmitInterceptor).addPathPatterns("/**");
     }
-
     /**
      * 跨域配置
      */

+ 9 - 5
fiveep-service/src/main/java/com/bizmatics/service/impl/HtAnalogDataServiceImpl.java

@@ -1,6 +1,7 @@
 package com.bizmatics.service.impl;
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.bizmatics.common.core.exception.BusinessException;
 import com.bizmatics.common.core.util.Arith;
@@ -283,15 +284,15 @@ public class HtAnalogDataServiceImpl extends AbstractCrudService<HtAnalogDataMap
     }
 
     @Override
-    public List<RealScoreVO> rtRealScore(String deviceName, Date startTime, Date endTime) {
+    public List<RealScoreVO> rtRealScore(String deviceCode, 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)
+                .eq(HtAnalogData::getDeviceName,deviceCode)
                 .between(HtAnalogData::getDataTime,startTime,endTime);
         List<HtAnalogData> list = this.list(queryWrapper);
         //查询设备
         LambdaQueryWrapper<Device> deviceQuery = Wrappers.lambdaQuery();
-        deviceQuery.eq(Device::getDeviceName,deviceName);
+        deviceQuery.eq(Device::getDeviceCode,deviceCode);
         Device device = deviceService.getOne(deviceQuery);
         Optional.ofNullable(device).orElseThrow(() -> new BusinessException("设备不存在"));
         //查询sd
@@ -301,8 +302,11 @@ public class HtAnalogDataServiceImpl extends AbstractCrudService<HtAnalogDataMap
         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<DeviceAttribute> deviceAttributes = deviceAttributeService.list(adQuery);
+        if (CollectionUtils.isEmpty(deviceAttributes)){
+            throw new BusinessException("da不存在");
+        }
+        DeviceAttribute deviceAttribute = deviceAttributes.stream().min(Comparator.comparing(DeviceAttribute::getId)).get();
         List<RealScoreVO> realScoreVOS = new ArrayList<>();
         for (HtAnalogData htAnalogData:list) {
             RtAnalogData rtAnalogData = BeanMapperUtils.map(htAnalogData, RtAnalogData.class);

+ 14 - 6
fiveep-service/src/main/java/com/bizmatics/service/impl/RtAnalogDataServiceImpl.java

@@ -4,6 +4,7 @@ import cn.afterturn.easypoi.excel.ExcelExportUtil;
 import cn.afterturn.easypoi.excel.entity.ExportParams;
 import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.bizmatics.common.core.exception.BusinessException;
 import com.bizmatics.common.core.util.*;
@@ -115,13 +116,13 @@ public class RtAnalogDataServiceImpl extends AbstractCrudService<RtAnalogDataMap
     }
 
     @Override
-    public RealScoreVO realScore(String deviceName) {
+    public RealScoreVO realScore(String deviceCode) {
         LambdaQueryWrapper<RtAnalogData> queryWrapper = Wrappers.lambdaQuery();
-        queryWrapper.eq(RtAnalogData::getDeviceName,deviceName);
+        queryWrapper.eq(RtAnalogData::getDeviceName,deviceCode);
         RtAnalogData rtAnalogData = getOne(queryWrapper);
         //查询设备
         LambdaQueryWrapper<Device> deviceQuery = Wrappers.lambdaQuery();
-        deviceQuery.eq(Device::getDeviceName,deviceName);
+        deviceQuery.eq(Device::getDeviceCode,deviceCode);
         Device device = deviceService.getOne(deviceQuery);
         Optional.ofNullable(device).orElseThrow(() -> new BusinessException("设备不存在"));
         //查询sd
@@ -131,8 +132,11 @@ public class RtAnalogDataServiceImpl extends AbstractCrudService<RtAnalogDataMap
         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<DeviceAttribute> deviceAttributes = deviceAttributeService.list(adQuery);
+        if (CollectionUtils.isEmpty(deviceAttributes)){
+            throw new BusinessException("da不存在");
+        }
+        DeviceAttribute deviceAttribute = deviceAttributes.stream().min(Comparator.comparing(DeviceAttribute::getId)).get();
         return  fillRealScoreData(rtAnalogData,siteDynamicProperties,deviceAttribute);
     }
 
@@ -184,7 +188,7 @@ public class RtAnalogDataServiceImpl extends AbstractCrudService<RtAnalogDataMap
             score+=20;
         }
         //功率
-        if (realScoreVo.getCOS() <= 0.15){
+        if (realScoreVo.getCos() <= 0.15){
             score+=20;
         }
         realScoreVo.setScore(score);
@@ -210,6 +214,10 @@ public class RtAnalogDataServiceImpl extends AbstractCrudService<RtAnalogDataMap
      * @return
      */
     public Double checkBalun(List<Double> list){
+        long count = list.stream().filter(code -> 0.00 == code).count();
+        if (3 == count){
+            return 0.00;
+        }
         Double max = list.stream().max(Double::compareTo).get();
         Double min = list.stream().min(Double::compareTo).get();
         return Arith.div(Arith.sub(max,min),max);

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

@@ -43,7 +43,7 @@ public class RealScoreVO {
     /**
      * 功率因素
       */
-    private Double COS;
+    private Double cos;
     /**
      * 电流不平衡
      */