whyclxw
6 天以前 ab1ce4e7d9feb6e1da8db8abf0deb552afddc7d6
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,"预警分析管理-查询所有的属性对应关系");
    }
}