whyclxw
6 天以前 ab1ce4e7d9feb6e1da8db8abf0deb552afddc7d6
预警分析管理-切换时间间隔和副属性/查询所有的属性对应关系
3个文件已修改
1个文件已添加
119 ■■■■ 已修改文件
src/main/java/com/whyc/controller/AnalysisAlmController.java 18 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/dto/AnalysisAlm/AnalysisChangeRes.java 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/service/AlmAnalysisParamService.java 73 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/service/AppParamService.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/controller/AnalysisAlmController.java
@@ -1,5 +1,6 @@
package com.whyc.controller;
import com.whyc.dto.AnalysisAlm.AnalysisChangeRes;
import com.whyc.dto.Param.AlmAnalyseDto;
import com.whyc.dto.Response;
import com.whyc.service.AlmAnalysisParamService;
@@ -44,7 +45,20 @@
    @GetMapping("getHisRealInAlm")
    @ApiOperation("预警分析管理-电源主属性和分析属性")
    public Response getHisRealInAlm(@RequestParam Integer battgroupId,@RequestParam Integer powerId,@RequestParam String startTime,@RequestParam(required = false) Integer almId,@RequestParam(required = false) Integer intervalTime) throws ParseException, InterruptedException {
        return almAnalysisParamService.getHisRealInAlm(battgroupId,powerId,startTime,almId,intervalTime);
    public Response getHisRealInAlm(@RequestParam Integer battgroupId,@RequestParam Integer powerId,@RequestParam String startTime,@RequestParam(required = false) Integer almId) throws ParseException, InterruptedException {
        return almAnalysisParamService.getHisRealInAlm(battgroupId,powerId,startTime,almId);
    }
    @PostMapping("getHisRealWithChage")
    @ApiOperation("预警分析管理-切换时间间隔和副属性")
    public Response getHisRealWithChage(@RequestBody AnalysisChangeRes res) throws ParseException, InterruptedException {
        return almAnalysisParamService.getHisRealWithChage(res);
    }
    @PostMapping("getAlmSummaryParam")
    @ApiOperation("预警分析管理-查询所有的属性对应关系")
    public Response getAlmSummaryParam(){
        return almAnalysisParamService.getAlmSummaryParam();
    }
}
src/main/java/com/whyc/dto/AnalysisAlm/AnalysisChangeRes.java
New file
@@ -0,0 +1,21 @@
package com.whyc.dto.AnalysisAlm;
import lombok.Data;
@Data
public class AnalysisChangeRes {
    private Integer battgroupId;
    private Integer powerId;
    private String startTime;
    private Integer intervalTime;
    private String dataName1;
    private Integer dataType1;
    private String dataName2;
    private Integer dataType2;
    private String dataName3;
    private Integer dataType3;
    private String dataName4;
    private Integer dataType4;
    private String dataName5;
    private Integer dataType5;
}
src/main/java/com/whyc/service/AlmAnalysisParamService.java
@@ -1,6 +1,7 @@
package com.whyc.service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.whyc.dto.AnalysisAlm.AnalysisChangeRes;
import com.whyc.dto.AnalysisAlm.ResAnalysis;
import com.whyc.dto.Real.RealDateDTO;
import com.whyc.dto.Response;
@@ -50,23 +51,16 @@
    }
    //预警分析管理-电源主属性和分析属性
    public Response getHisRealInAlm(Integer battgroupId,Integer powerId, String startTime, Integer almId,Integer intervalTime) throws ParseException, InterruptedException {
    public Response getHisRealInAlm(Integer battgroupId,Integer powerId, String startTime, Integer almId) throws ParseException, InterruptedException {
        Map<String,Object> map=new HashMap<>();
        map.put("batt",null);
        map.put("pwr",null);
        Integer cycleTime=0;
        //获取预警分析周期阈值
        if(intervalTime==null){
            AppParam appParam = appParamService.getAlarmAnalysisCycle();
            cycleTime=appParam.getParamValue().intValue();
        }else{
            cycleTime=intervalTime;
        }
        Integer cycleTime=appParam.getParamValue().intValue();
        Date cyscleDate=ActionUtil.getDateAdd(ThreadLocalUtil.parse(startTime,1),cycleTime*(-1));
        //获取cyscleDate到现在所有的历史实时数据
        List<List<Date>> monthTimeList = DateUtil.getMonthTime(cyscleDate,new Date());
        //总的属性配置
        List<AlmSummaryParam> summaryList=summaryParamService.getInfo();
        //获取告警almId对应的分析配置属性值
        AlmAnalysisParam almAnalysisParam=getAnalysisParam(almId);
        if(almAnalysisParam==null||almAnalysisParam.getMainFieldType()==null){
@@ -88,7 +82,7 @@
                    map.put("pwr",pwrHislist);
                }
            }
            return new Response().setIII(1,true, map,summaryList,"预警分析管理-电源主属性和分析属性");
            return new Response().setII(1,true, map,"预警分析管理-电源主属性和分析属性");
        }
    }
    //分组查看需要查询电源/电池实时表的哪些数据
@@ -204,5 +198,64 @@
        List dataListSorted = dataList.stream().sorted(Comparator.comparing(ResAnalysis::getRecordTime)).collect(Collectors.toList());
        return dataListSorted;
    }
    //预警分析管理-切换时间间隔和副属性
    public Response getHisRealWithChage(AnalysisChangeRes res) throws ParseException, InterruptedException {
        Map<String,Object> map=new HashMap<>();
        map.put("batt",null);
        map.put("pwr",null);
        Integer cycleTime=0;
        //获取预警分析周期阈值
        AppParam appParam = appParamService.getAlarmAnalysisCycle();
        if(res.getIntervalTime()==null){
            cycleTime=appParam.getParamValue().intValue();
        }else{
            //将数据库中时间间隔修改
            appParamService.updateAlarmAnalysisCycle(res.getIntervalTime());
            cycleTime=res.getIntervalTime();
        }
        Date cyscleDate=ActionUtil.getDateAdd(ThreadLocalUtil.parse(res.getStartTime(),1),cycleTime*(-1));
        //获取cyscleDate到现在所有的历史实时数据
        List<List<Date>> monthTimeList = DateUtil.getMonthTime(cyscleDate,new Date());
        //获取告警almId对应的分析配置属性值
        AlmAnalysisParam almAnalysisParam=new AlmAnalysisParam();
        //将属性拷贝至almAnalysisParam中
        copyProperties(almAnalysisParam,res);
        //分组查看需要查询电源/电池实时表的哪些数据
        Map<String,  Map<String,Integer>> groupmap=groupPwrAndBatt(almAnalysisParam);
        Map<String,Integer> battMap=groupmap.get("batt");
        Map<String,Integer> pwrMap=groupmap.get("pwr");
        if(res.getBattgroupId()!=null){
            if(battMap!=null&&battMap.size()>0){
                List battHislist=getBattRealData(res.getBattgroupId(),monthTimeList,battMap);
                map.put("batt",battHislist);
            }
        }
        if(res.getPowerId()!=null){
            if(pwrMap!=null&&pwrMap.size()>0){
                List pwrHislist=getPwrRealData(res.getPowerId(),monthTimeList,pwrMap);
                map.put("pwr",pwrHislist);
            }
        }
        return new Response().setII(1,true, map,"预警分析管理-切换时间间隔和副属性");
    }
    //将属性拷贝至almAnalysisParam中
    private void copyProperties(AlmAnalysisParam almAnalysisParam, AnalysisChangeRes res) {
        almAnalysisParam.setMainField(res.getDataName1());
        almAnalysisParam.setMainFieldType(res.getDataType1());
        almAnalysisParam.setMinorField1(res.getDataName2());
        almAnalysisParam.setMinorField1Type(res.getDataType2());
        almAnalysisParam.setMinorField2(res.getDataName3());
        almAnalysisParam.setMinorField2Type(res.getDataType3());
        almAnalysisParam.setMinorField3(res.getDataName4());
        almAnalysisParam.setMinorField3Type(res.getDataType4());
        almAnalysisParam.setMinorField4(res.getDataName5());
        almAnalysisParam.setMinorField4Type(res.getDataType5());
    }
    //预警分析管理-查询所有的属性对应关系
    public Response getAlmSummaryParam() {
        //总的属性配置
        List<AlmSummaryParam> summaryList=summaryParamService.getInfo();
        return new Response().setII(1,true,summaryList,"预警分析管理-查询所有的属性对应关系");
    }
}
src/main/java/com/whyc/service/AppParamService.java
@@ -62,4 +62,11 @@
        AppParam param=mapper.selectOne(wrapper);
        return param;
    }
    //将数据库中时间间隔修改
    public void updateAlarmAnalysisCycle(Integer intervalTime) {
        UpdateWrapper wrapper=new UpdateWrapper();
        wrapper.eq("param_name_psx","alm_analysis_already_time");
        wrapper.set("param_value",intervalTime);
        mapper.update(null,wrapper);
    }
}