src/main/java/com/whyc/controller/AlmParamController.java
@@ -35,14 +35,6 @@ @Autowired private PwrdevAlarmParamService pwrAlmparamService; @Autowired private BattalarmDataService battalarmDataService; @Autowired private PwrdevAlarmService pwrdevAlarmService; @Autowired private BattRealdataIdService battRealdataIdService; /*@PostMapping("getBattAlmParam") @@ -129,31 +121,4 @@ return new Response<List<AlarmParam>>().set(1,list); } @PostMapping("getBattAlmAnalyse") @ApiOperation("预警分析管理-电池告警") public Response getBattAlmAnalyse(@RequestBody AlmAnalyseDto dto){ Integer uid=ActionUtil.getUser().getId(); dto.setUid(uid); return battalarmDataService.getBattAlmAnalyse(dto); } @GetMapping("getBattHisRealInAlm") @ApiOperation("预警分析管理-电池组主属性和分析属性") public Response getBattHisRealInAlm(@RequestParam Integer battgroupId,@RequestParam String startTime,@RequestParam(required = false) Integer almId,@RequestParam(required = false) Integer intervalTime) throws ParseException, InterruptedException { return battRealdataIdService.getBattHisRealInAlm(battgroupId,startTime,almId,intervalTime); } @PostMapping("getPwrtAlmAnalyse") @ApiOperation("预警分析管理-电源告警") public Response getPwrtAlmAnalyse(@RequestBody AlmAnalyseDto dto){ Integer uid=ActionUtil.getUser().getId(); dto.setUid(uid); return pwrdevAlarmService.getPwrtAlmAnalyse(dto); } @GetMapping("getPwrHisRealInAlm") @ApiOperation("预警分析管理-电源主属性和分析属性") public Response getPwrHisRealInAlm(@RequestParam Integer powerId,@RequestParam String startTime,@RequestParam(required = false) Integer almId,@RequestParam(required = false) Integer intervalTime) throws ParseException, InterruptedException { return pwrdevAlarmService.getPwrHisRealInAlm(powerId,startTime,almId,intervalTime); } } src/main/java/com/whyc/controller/AnalysisAlmController.java
New file @@ -0,0 +1,50 @@ package com.whyc.controller; import com.whyc.dto.Param.AlmAnalyseDto; import com.whyc.dto.Response; import com.whyc.service.AlmAnalysisParamService; import com.whyc.service.BattRealdataIdService; import com.whyc.service.BattalarmDataService; import com.whyc.service.PwrdevAlarmService; import com.whyc.util.ActionUtil; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import java.text.ParseException; @RequestMapping("analysis") @RestController @Api(tags = "预警分析管理") public class AnalysisAlmController { @Autowired private BattalarmDataService battalarmDataService; @Autowired private PwrdevAlarmService pwrdevAlarmService; @Autowired private AlmAnalysisParamService almAnalysisParamService; @PostMapping("getBattAlmAnalyse") @ApiOperation("预警分析管理-电池告警") public Response getBattAlmAnalyse(@RequestBody AlmAnalyseDto dto){ Integer uid= ActionUtil.getUser().getId(); dto.setUid(uid); return battalarmDataService.getBattAlmAnalyse(dto); } @PostMapping("getPwrtAlmAnalyse") @ApiOperation("预警分析管理-电源告警") public Response getPwrtAlmAnalyse(@RequestBody AlmAnalyseDto dto){ Integer uid=ActionUtil.getUser().getId(); dto.setUid(uid); return pwrdevAlarmService.getPwrtAlmAnalyse(dto); } @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); } } src/main/java/com/whyc/dto/AnalysisAlm/ResAnalysis.java
New file @@ -0,0 +1,20 @@ package com.whyc.dto.AnalysisAlm; import lombok.Data; import java.util.Date; @Data public class ResAnalysis { private Date recordTime; private String dataName1; private Float dataValue1; private String dataName2; private Float dataValue2; private String dataName3; private Float dataValue3; private String dataName4; private Float dataValue4; private String dataName5; private Float dataValue5; } src/main/java/com/whyc/mapper/BattInfMapper.java
@@ -62,5 +62,7 @@ //获取站点下的电池组(下拉) List<BattInf> getBattByUid(@Param("uid") Integer uid, @Param("provice") String provice, @Param("city") String city, @Param("country") String country, @Param("stationName") String stationName); //根据查询条件获取电池组集合 BattInf getBattgroupIdList(@Param("battgroupId") Integer battgroupId); BattInf getBattgroupIdInf(@Param("battgroupId") Integer battgroupId); //查询电源下所有的电池组id List<Integer> getBattgroupIdList(@Param("powerId") Integer powerId); } src/main/java/com/whyc/pojo/db_alarm/BattalarmData.java
@@ -95,4 +95,9 @@ @TableField(exist = false) private String fullName; @TableField(exist = false) private Integer stationId; @TableField(exist = false) private Integer powerId; } src/main/java/com/whyc/pojo/db_pwrdev_alarm/PwrdevAlarm.java
@@ -12,6 +12,7 @@ import java.io.Serializable; import java.util.Date; import java.util.List; /** * <p> @@ -34,7 +35,7 @@ private Long num; @ApiModelProperty(value = "电源ID") private Long powerId; private Integer powerId; @ApiModelProperty(value = "告警ID") private Integer almId; @@ -85,4 +86,7 @@ private String country; @TableField(exist = false) private String fullName; @TableField(exist = false) private List<Integer> battgroupIdList; } src/main/java/com/whyc/service/AlmAnalysisParamService.java
@@ -1,15 +1,41 @@ package com.whyc.service; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.whyc.dto.AnalysisAlm.ResAnalysis; import com.whyc.dto.Real.RealDateDTO; import com.whyc.dto.Response; import com.whyc.factory.ThreadPoolExecutorFactory; import com.whyc.mapper.AlmAnalysisParamMapper; import com.whyc.pojo.db_data_history.BattRealdataId; import com.whyc.pojo.db_data_history.PwrdevHistorydataId; import com.whyc.pojo.db_param.AlmAnalysisParam; import com.whyc.pojo.db_param.AppParam; import com.whyc.util.ActionUtil; import com.whyc.util.DateUtil; import com.whyc.util.ThreadLocalUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.text.ParseException; import java.util.*; import java.util.concurrent.CountDownLatch; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; import static java.lang.Thread.sleep; @Service public class AlmAnalysisParamService { @Autowired(required = false) private AlmAnalysisParamMapper mapper; @Autowired private AppParamService appParamService; @Autowired private SubTablePageInfoService subTablePageInfoService; //获取告警almId对应的分析配置属性值 public AlmAnalysisParam getAnalysisParam(Integer almId) { QueryWrapper wrapper=new QueryWrapper(); @@ -18,4 +44,159 @@ AlmAnalysisParam param= mapper.selectOne(wrapper); return param; } //预警分析管理-电源主属性和分析属性 public Response getHisRealInAlm(Integer battgroupId,Integer powerId, String startTime, Integer almId,Integer intervalTime) 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; } Date cyscleDate=ActionUtil.getDateAdd(ThreadLocalUtil.parse(startTime,1),cycleTime*(-1)); //获取cyscleDate到现在所有的历史实时数据 List<List<Date>> monthTimeList = DateUtil.getMonthTime(cyscleDate,new Date()); //获取告警almId对应的分析配置属性值 AlmAnalysisParam almAnalysisParam=getAnalysisParam(almId); if(almAnalysisParam==null||almAnalysisParam.getMainFieldType()==null){ return new Response().set(1,false,"无对应分析属性"); }else{ //分组查看需要查询电源/电池实时表的哪些数据 Map<String,List<String>> groupmap=groupPwrAndBatt(almAnalysisParam); List<String> battList=groupmap.get("batt"); List<String> pwrList=groupmap.get("pwr"); if(battgroupId!=null){ if(battList!=null&&battList.size()>0){ List battHislist=getBattRealData(battgroupId,monthTimeList,battList); map.put("batt",battHislist); } } if(powerId!=null){ if(pwrList!=null&&pwrList.size()>0){ List pwrHislist=getPwrRealData(powerId,monthTimeList,pwrList); map.put("pwr",pwrHislist); } } return new Response().setIII(1,true, map,almAnalysisParam,"预警分析管理-电源主属性和分析属性"); } } //分组查看需要查询电源/电池实时表的哪些数据 private Map<String, List<String>> groupPwrAndBatt(AlmAnalysisParam almAnalysisParam) { Map<String, List<String>> map = new HashMap<>(); List<String> battList=new ArrayList<>(); List<String> pwrList=new ArrayList<>(); if(almAnalysisParam.getMainFieldType()==1||almAnalysisParam.getMainFieldType()==2||almAnalysisParam.getMainFieldType()==3){ if(almAnalysisParam.getMainField()!=null||almAnalysisParam.getMainField().length()>0){ pwrList.add(almAnalysisParam.getMainField()); } }else{ if(almAnalysisParam.getMainField()!=null||almAnalysisParam.getMainField().length()>0){ battList.add(almAnalysisParam.getMainField()); } } if(almAnalysisParam.getMinorField1Type()==1||almAnalysisParam.getMinorField1Type()==2||almAnalysisParam.getMinorField1Type()==3){ if(almAnalysisParam.getMinorField1()!=null&&almAnalysisParam.getMinorField1().length()>0){ pwrList.add(almAnalysisParam.getMinorField1()); } }else{ if(almAnalysisParam.getMinorField1()!=null&&almAnalysisParam.getMinorField1().length()>0){ battList.add(almAnalysisParam.getMinorField1()); } } if(almAnalysisParam.getMinorField2Type()==1||almAnalysisParam.getMinorField2Type()==2||almAnalysisParam.getMinorField2Type()==3){ if(almAnalysisParam.getMinorField2()!=null&&almAnalysisParam.getMinorField2().length()>0){ pwrList.add(almAnalysisParam.getMinorField2()); } }else{ if(almAnalysisParam.getMinorField2()!=null&&almAnalysisParam.getMinorField2().length()>0){ battList.add(almAnalysisParam.getMinorField2()); } } if(almAnalysisParam.getMinorField3Type()==1||almAnalysisParam.getMinorField3Type()==2||almAnalysisParam.getMinorField3Type()==3){ if(almAnalysisParam.getMinorField3()!=null&&almAnalysisParam.getMinorField3().length()>0){ pwrList.add(almAnalysisParam.getMinorField3()); } }else{ if(almAnalysisParam.getMinorField3()!=null&&almAnalysisParam.getMinorField3().length()>0){ battList.add(almAnalysisParam.getMinorField3()); } } if(almAnalysisParam.getMinorField4Type()==1||almAnalysisParam.getMinorField4Type()==2||almAnalysisParam.getMinorField4Type()==3){ if(almAnalysisParam.getMinorField4()!=null&&almAnalysisParam.getMinorField4().length()>0){ pwrList.add(almAnalysisParam.getMinorField4()); } }else{ if(almAnalysisParam.getMinorField4()!=null&&almAnalysisParam.getMinorField4().length()>0){ battList.add(almAnalysisParam.getMinorField4()); } } map.put("pwr",pwrList); map.put("batt",battList); return map; } //连接池获取电源历史实时数据 public List getPwrRealData(Integer powerId,List<List<Date>> monthTimeList,List<String> pwrList) throws InterruptedException { List<ResAnalysis> dataList = new LinkedList<>(); ThreadPoolExecutor pool = ThreadPoolExecutorFactory.getPoolExecutor(); CountDownLatch latch = new CountDownLatch(monthTimeList.size()); for (int i = 0; i < monthTimeList.size(); i++) { int finalI = i; pool.execute(() -> { int finalII = finalI; PwrdevHistorydataId pwrHis = new PwrdevHistorydataId(); pwrHis.setRecordDatetime(monthTimeList.get(finalII).get(0)); pwrHis.setRecordDatetime1(monthTimeList.get(finalII).get(1)); String table = powerId + "_" + ThreadLocalUtil.format(pwrHis.getRecordDatetime(),2); pwrHis.setTableName(table);//表名时间格式部分 //判断表是否存在 int tableNum = subTablePageInfoService.judgeTable_pwrhis(table); List<ResAnalysis> list = new ArrayList(); if (tableNum > 0) { list = subTablePageInfoService.getPwrHisRealInAlm(pwrHis,pwrList); } dataList.addAll(list); latch.countDown(); }); sleep(200); } latch.await(10, TimeUnit.MINUTES); List dataListSorted = dataList.stream().sorted(Comparator.comparing(ResAnalysis::getRecordTime)).collect(Collectors.toList()); return dataListSorted; } //电池告警点击具体告警信息查看从告警开始时间到现在的历史实时数据 public List getBattRealData(Integer battgroupId, List<List<Date>> monthTimeList,List<String> battList) throws ParseException, InterruptedException { List<ResAnalysis> dataList = new LinkedList<>(); ThreadPoolExecutor pool = ThreadPoolExecutorFactory.getPoolExecutor(); CountDownLatch latch = new CountDownLatch(monthTimeList.size()); for (int i = 0; i < monthTimeList.size(); i++) { int finalI = i; pool.execute(() -> { int finalII = finalI; BattRealdataId realdata = new BattRealdataId(); realdata.setRecordTime(monthTimeList.get(finalII).get(0)); realdata.setRecordTime1(monthTimeList.get(finalII).get(1)); String table = battgroupId + "_" + ThreadLocalUtil.format(realdata.getRecordTime(),2); realdata.setTableName(table);//表名时间格式部分 //判断表是否存在 int tableNum = subTablePageInfoService.judgeTable_realdata(table); List<ResAnalysis> list = new ArrayList(); if (tableNum > 0) { list = subTablePageInfoService.getBattHisRealInAlm(realdata,battList); } dataList.addAll(list); latch.countDown(); }); sleep(200); } latch.await(10, TimeUnit.MINUTES); List dataListSorted = dataList.stream().sorted(Comparator.comparing(ResAnalysis::getRecordTime)).collect(Collectors.toList()); return dataListSorted; } } src/main/java/com/whyc/service/BattAlmparamService.java
@@ -27,8 +27,8 @@ private BattInfService binfService; //获取电池告警参数 public Response getBattAlmParam(ParamAlmDto dto) { //根据查询条件获取电池组集合 BattInf binf=binfService.getBattgroupIdList(dto.getBattgroupId()); //根据查询条件获取电池组 BattInf binf=binfService.getBattgroupIdInf(dto.getBattgroupId()); QueryWrapper wrapper=new QueryWrapper(); wrapper.eq("battgroup_id",dto.getBattgroupId()); if(dto.getAlmIdList()!=null){ src/main/java/com/whyc/service/BattInfService.java
@@ -490,8 +490,12 @@ List<BattInf> list=mapper.getBattByUid(uid,provice,city,country,stationName); return new Response().setII(1,list.size()>0,list,"获取站点下的电池组(下拉)"); } //根据查询条件获取电池组集合 public BattInf getBattgroupIdList(Integer battgroupId) { return mapper.getBattgroupIdList(battgroupId); //根据查询条件获取电池组 public BattInf getBattgroupIdInf(Integer battgroupId) { return mapper.getBattgroupIdInf(battgroupId); } //查询电源下所有的电池组id public List<Integer> getBattgroupIdList(Integer powerId) { return mapper.getBattgroupIdList(powerId); } } src/main/java/com/whyc/service/BattRealdataIdService.java
@@ -43,11 +43,6 @@ @Autowired private BattInfService binfService; @Autowired private AlmAnalysisParamService almAnalysisParamService; @Autowired private AppParamService appParamService; //获取电池组最近一季度的单体数据 @@ -225,47 +220,5 @@ latch.await(10, TimeUnit.MINUTES); List dataListSorted = dataList.stream().sorted(Comparator.comparing(RealDateDTO::getRecordTime)).collect(Collectors.toList()); return new Response().set(1, dataListSorted); } //电池告警点击具体告警信息查看从告警开始时间到现在的历史实时数据 public Response getBattHisRealInAlm(Integer battgroupId, String startTime, Integer almId,Integer intervalTime) throws ParseException, InterruptedException { //获取告警almId对应的分析配置属性值 AlmAnalysisParam almAnalysisParam= almAnalysisParamService.getAnalysisParam(almId); List<RealDateDTO> dataList = new LinkedList<>(); Integer cycleTime=0; //获取预警分析周期阈值 if(intervalTime==null){ AppParam appParam = appParamService.getAlarmAnalysisCycle(); cycleTime=appParam.getParamValue().intValue(); }else{ cycleTime=intervalTime; } Date cyscleDate=ActionUtil.getDateAdd(ThreadLocalUtil.parse(startTime,1),cycleTime*(-1)); //获取cyscleDate到现在所有的历史实时数据 List<List<Date>> monthTimeList = DateUtil.getMonthTime(cyscleDate,new Date()); ThreadPoolExecutor pool = ThreadPoolExecutorFactory.getPoolExecutor(); CountDownLatch latch = new CountDownLatch(monthTimeList.size()); for (int i = 0; i < monthTimeList.size(); i++) { int finalI = i; pool.execute(() -> { int finalII = finalI; BattRealdataId realdata = new BattRealdataId(); realdata.setRecordTime(monthTimeList.get(finalII).get(0)); realdata.setRecordTime1(monthTimeList.get(finalII).get(1)); String table = battgroupId + "_" + ThreadLocalUtil.format(realdata.getRecordTime(),2); realdata.setTableName(table);//表名时间格式部分 //判断表是否存在 int tableNum = subTablePageInfoService.judgeTable_realdata(table); List<RealDateDTO> list = new ArrayList(); if (tableNum > 0) { list = subTablePageInfoService.getBattHisRealInAlm(realdata); } dataList.addAll(list); latch.countDown(); }); sleep(200); } latch.await(10, TimeUnit.MINUTES); List dataListSorted = dataList.stream().sorted(Comparator.comparing(RealDateDTO::getRecordTime)).collect(Collectors.toList()); return new Response().setIII(1,true, dataListSorted,almAnalysisParam,"电池告警点击具体告警信息查看从告警开始时间到现在的历史实时数据"); } } src/main/java/com/whyc/service/PwrdevAlarmService.java
@@ -48,6 +48,8 @@ private AlmAnalysisParamService almAnalysisParamService; @Autowired private SubTablePageInfoService subTablePageInfoService; @Autowired private BattInfService battInfService; //获取电源实时告警信息 public Response getPwrAlmReal(AlmDto almDto) { PageHelper.startPage(almDto.getPageNum(),almDto.getPageSize()); @@ -109,49 +111,14 @@ public Response getPwrtAlmAnalyse(AlmAnalyseDto dto) { PageHelper .startPage(dto.getPageNum(),dto.getPageSize()); List<PwrdevAlarm> list=mapper.getPwrtAlmAnalyse(dto); for (PwrdevAlarm pwrAlm:list) { pwrAlm.setAlmName(PowerAlarmEnum.getValue(pwrAlm.getAlmId())); //查询电源下所有的电池组id List<Integer> battgroupIdList = battInfService.getBattgroupIdList(pwrAlm.getPowerId()); pwrAlm.setBattgroupIdList(battgroupIdList); } PageInfo pageInfo=new PageInfo(list); return new Response().setII(1,list!=null,pageInfo,"电源告警分析"); } //预警分析管理-电源主属性和分析属性 public Response getPwrHisRealInAlm(Integer powerId, String startTime, Integer almId,Integer intervalTime) throws ParseException, InterruptedException { //获取告警almId对应的分析配置属性值 AlmAnalysisParam almAnalysisParam= almAnalysisParamService.getAnalysisParam(almId); List<PwrdevHistorydataId> dataList = new LinkedList<>(); Integer cycleTime=0; //获取预警分析周期阈值 if(intervalTime==null){ AppParam appParam = appParamService.getAlarmAnalysisCycle(); cycleTime=appParam.getParamValue().intValue(); }else{ cycleTime=intervalTime; } Date cyscleDate=ActionUtil.getDateAdd(ThreadLocalUtil.parse(startTime,1),cycleTime*(-1)); //获取cyscleDate到现在所有的历史实时数据 List<List<Date>> monthTimeList = DateUtil.getMonthTime(cyscleDate,new Date()); ThreadPoolExecutor pool = ThreadPoolExecutorFactory.getPoolExecutor(); CountDownLatch latch = new CountDownLatch(monthTimeList.size()); for (int i = 0; i < monthTimeList.size(); i++) { int finalI = i; pool.execute(() -> { int finalII = finalI; PwrdevHistorydataId pwrHis = new PwrdevHistorydataId(); pwrHis.setRecordDatetime(monthTimeList.get(finalII).get(0)); pwrHis.setRecordDatetime1(monthTimeList.get(finalII).get(1)); String table = powerId + "_" + ThreadLocalUtil.format(pwrHis.getRecordDatetime(),2); pwrHis.setTableName(table);//表名时间格式部分 //判断表是否存在 int tableNum = subTablePageInfoService.judgeTable_pwrhis(table); List<PwrdevHistorydataId> list = new ArrayList(); if (tableNum > 0) { list = subTablePageInfoService.getPwrHisRealInAlm(pwrHis); } dataList.addAll(list); latch.countDown(); }); sleep(200); } latch.await(10, TimeUnit.MINUTES); List dataListSorted = dataList.stream().sorted(Comparator.comparing(PwrdevHistorydataId::getRecordDatetime)).collect(Collectors.toList()); return new Response().setIII(1,true, dataListSorted,almAnalysisParam,"预警分析管理-电源主属性和分析属性"); } } src/main/java/com/whyc/service/SubTablePageInfoService.java
@@ -3,6 +3,7 @@ import com.whyc.dto.AlmHis.BattAlmPar; import com.whyc.dto.AlmHis.DevAlmPar; import com.whyc.dto.AlmHis.PwrAlmPar; import com.whyc.dto.AnalysisAlm.ResAnalysis; import com.whyc.dto.Real.*; import com.whyc.dto.Statistic.QuarterPwr7Res; import com.whyc.mapper.CallBack; @@ -16,9 +17,11 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.lang.reflect.Field; import java.sql.ResultSet; import java.sql.SQLException; import java.util.*; import java.util.stream.Collectors; @Service public class SubTablePageInfoService { @@ -797,27 +800,38 @@ return list; } //电池数据历史实时处理(预警分析) public List<RealDateDTO> getBattHisRealInAlm(BattRealdataId realdata) { String sql=" select record_time, group_vol, online_vol,group_curr, mon_vol, mon_tmp, mon_res, mon_num,record_num " + public List<ResAnalysis> getBattHisRealInAlm(BattRealdataId realdata, List<String> battList) { String result = battList.stream().collect(Collectors.joining(",")); String sql=" select record_time,"+result+" " + " from db_data_history.tb_batt_realdata_"+realdata.getTableName()+" " + " where record_time >= '"+ThreadLocalUtil.format(realdata.getRecordTime(),1)+"' " + " and record_time <= '"+ThreadLocalUtil.format(realdata.getRecordTime1(),1)+"' " + " order by record_time asc,mon_num asc"; List<RealDateDTO> list = sqlExecuteService.executeQuery_call(sql, new CallBack() { List<ResAnalysis> list = sqlExecuteService.executeQuery_call(sql, new CallBack() { @Override public List getResults(ResultSet rs) throws SQLException { List<RealDateDTO> list=new ArrayList<>(); List<ResAnalysis> list=new ArrayList<>(); while (rs.next()){ RealDateDTO ph=new RealDateDTO(); ResAnalysis ph=new ResAnalysis(); ph.setRecordTime(rs.getTimestamp("record_time")); ph.setGroupVol(rs.getFloat("group_vol")); ph.setOnlineVol(rs.getFloat("online_vol")); ph.setGroupCurr(rs.getFloat("group_curr")); ph.setMonVol(rs.getFloat("mon_vol")); ph.setMonTmp(rs.getFloat("mon_tmp")); ph.setMonRes(rs.getFloat("mon_res")); ph.setMonNum(rs.getInt("mon_num")); ph.setRecordNum(rs.getInt("record_num")); for (int i=0;i<battList.size();i++){ try { Float value = rs.getFloat(battList.get(i)); String propertyName = "dataName"+(i+1); Field fieldName = ResAnalysis.class.getDeclaredField(propertyName); fieldName.setAccessible(true); // 如果字段是私有的,需要设置为可访问 fieldName.set(ph,battList.get(i)); String propertyValue = "dataValue"+(i+1); Field fieldValue = ResAnalysis.class.getDeclaredField(propertyValue); fieldValue.setAccessible(true); fieldValue.set(ph,value); } catch (NoSuchFieldException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } } list.add(ph); } return list; @@ -827,105 +841,39 @@ } //电源数据历史实时处理(预警分析) public List<PwrdevHistorydataId> getPwrHisRealInAlm(PwrdevHistorydataId pwrHis) { String sql=" select * " + public List<ResAnalysis> getPwrHisRealInAlm(PwrdevHistorydataId pwrHis, List<String> pwrList) { String result = pwrList.stream().collect(Collectors.joining(",")); String sql=" select record_datetime,"+result+" " + " from db_data_history.tb_pwrdev_historydata_"+pwrHis.getTableName()+" " + " where record_datetime >= '"+ThreadLocalUtil.format(pwrHis.getRecordDatetime(),1)+"' " + " and record_datetime <= '"+ThreadLocalUtil.format(pwrHis.getRecordDatetime1(),1)+"' " + " order by record_datetime asc "; List<PwrdevHistorydataId> list = sqlExecuteService.executeQuery_call(sql, new CallBack() { List<ResAnalysis> list = sqlExecuteService.executeQuery_call(sql, new CallBack() { @Override public List getResults(ResultSet rs) throws SQLException { List<PwrdevHistorydataId> list=new ArrayList<>(); List<ResAnalysis> list=new ArrayList<>(); while (rs.next()){ PwrdevHistorydataId data=new PwrdevHistorydataId(); data.setRecordDatetime(rs.getTimestamp("record_datetime")); data.setAcin1Vola(rs.getFloat("acin1_vola")); data.setAcin1Volb(rs.getFloat("acin1_volb")); data.setAcin1Volc(rs.getFloat("acin1_volc")); data.setAcin2Vola(rs.getFloat("acin2_vola")); data.setAcin2Volb(rs.getFloat("acin2_volb")); data.setAcin2Volc(rs.getFloat("acin2_volc")); data.setAcoutVola(rs.getFloat("acout_vola")); data.setAcoutVolb(rs.getFloat("acout_volb")); data.setAcoutVolc(rs.getFloat("acout_volc")); data.setAcoutCurra(rs.getFloat("acout_curra")); data.setAcoutCurrb(rs.getFloat("acout_currb")); data.setAcoutCurrc(rs.getFloat("acout_currc")); data.setDcoutVol(rs.getFloat("dcout_vol")); data.setDcoutCurr(rs.getFloat("dcout_curr")); ResAnalysis ph=new ResAnalysis(); ph.setRecordTime(rs.getTimestamp("record_datetime")); for (int i=0;i<pwrList.size();i++){ try { Float value = rs.getFloat(pwrList.get(i)); String propertyName = "dataName"+(i+1); Field fieldName = ResAnalysis.class.getDeclaredField(propertyName); fieldName.setAccessible(true); // 如果字段是私有的,需要设置为可访问 fieldName.set(ph,pwrList.get(i)); data.setBattgroup1Vol(rs.getFloat("battgroup1_vol")); data.setBattgroup1Curr(rs.getFloat("battgroup1_curr")); data.setBattgroup2Vol(rs.getFloat("battgroup2_vol")); data.setBattgroup2Curr(rs.getFloat("battgroup2_curr")); data.setTemprature(rs.getFloat("temprature")); data.setMOutputvol(rs.getFloat("m_outputvol")); data.setM1Outcurr(rs.getFloat("m1_outcurr")); data.setM2Outcurr(rs.getFloat("m2_outcurr")); data.setM3Outcurr(rs.getFloat("m3_outcurr")); data.setM4Outcurr(rs.getFloat("m4_outcurr")); data.setM5Outcurr(rs.getFloat("m5_outcurr")); data.setM6Outcurr(rs.getFloat("m6_outcurr")); data.setM7Outcurr(rs.getFloat("m7_outcurr")); data.setM8Outcurr(rs.getFloat("m8_outcurr")); data.setM9Outcurr(rs.getFloat("m9_outcurr")); data.setM10Outcurr(rs.getFloat("m10_outcurr")); data.setM11Outcurr(rs.getFloat("m11_outcurr")); data.setM12Outcurr(rs.getFloat("m12_outcurr")); data.setM13Outcurr(rs.getFloat("m13_outcurr")); data.setM14Outcurr(rs.getFloat("m14_outcurr")); data.setM15Outcurr(rs.getFloat("m15_outcurr")); data.setM16Outcurr(rs.getFloat("m16_outcurr")); data.setAcin1Curra(rs.getFloat("acin1_curra")); data.setAcin1Currb(rs.getFloat("acin1_currb")); data.setAcin1Currc(rs.getFloat("acin1_currc")); data.setLoaderCurr(rs.getFloat("loader_curr")); data.setBattgroup1Ah(rs.getFloat("battgroup1_ah")); data.setBattgroup1Temp(rs.getFloat("battgroup1_temp")); data.setBattgroup2Ah(rs.getFloat("battgroup2_ah")); data.setBattgroup2Temp(rs.getFloat("battgroup2_temp")); data.setAcdcmTemp(rs.getFloat("acdcm_temp")); data.setM1OutVol(rs.getFloat("m1_out_vol")); data.setM2OutVol(rs.getFloat("m2_out_vol")); data.setM3OutVol(rs.getFloat("m3_out_vol")); data.setM4OutVol(rs.getFloat("m4_out_vol")); data.setM5OutVol(rs.getFloat("m5_out_vol")); data.setM6OutVol(rs.getFloat("m6_out_vol")); data.setM7OutVol(rs.getFloat("m7_out_vol")); data.setM8OutVol(rs.getFloat("m8_out_vol")); data.setM9OutVol(rs.getFloat("m9_out_vol")); data.setM10OutVol(rs.getFloat("m10_out_vol")); data.setM11OutVol(rs.getFloat("m11_out_vol")); data.setM12OutVol(rs.getFloat("m12_out_vol")); data.setM13OutVol(rs.getFloat("m13_out_vol")); data.setM14OutVol(rs.getFloat("m14_out_vol")); data.setM15OutVol(rs.getFloat("m15_out_vol")); data.setM16OutVol(rs.getFloat("m16_out_vol")); data.setUseracin1Vola(rs.getFloat("useracin1_vola")); data.setUseracin1Volb(rs.getFloat("useracin1_volb")); data.setUseracin1Volc(rs.getFloat("useracin1_volc")); data.setUseracin1Curra(rs.getFloat("useracin1_curra")); data.setUseracin1Currb(rs.getFloat("useracin1_currb")); data.setUseracin1Currc(rs.getFloat("useracin1_currc")); data.setUseracin1Freq(rs.getFloat("useracin1_freq")); data.setUseracin2Vola(rs.getFloat("useracin2_vola")); data.setUseracin2Volb(rs.getFloat("useracin2_volb")); data.setUseracin2Volc(rs.getFloat("useracin2_volc")); data.setUseracin2Curra(rs.getFloat("useracin2_curra")); data.setUseracin2Currb(rs.getFloat("useracin2_currb")); data.setUseracin2Currc(rs.getFloat("useracin2_currc")); data.setUseracin2Freq(rs.getFloat("useracin2_freq")); data.setMTemper1(rs.getFloat("m_temper1")); data.setMTemper2(rs.getFloat("m_temper2")); data.setMTemper3(rs.getFloat("m_temper3")); data.setMHumidity1(rs.getFloat("m_humidity1")); data.setMHumidity2(rs.getFloat("m_humidity2")); data.setMHumidity3(rs.getFloat("m_humidity3")); list.add(data); String propertyValue = "dataValue"+(i+1); Field fieldValue = ResAnalysis.class.getDeclaredField(propertyValue); fieldValue.setAccessible(true); fieldValue.set(ph,value); } catch (NoSuchFieldException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } } list.add(ph); } return list; } src/main/resources/mapper/BattInfMapper.xml
@@ -466,7 +466,7 @@ </if> </where> </select> <select id="getBattgroupIdList" resultType="com.whyc.pojo.db_station.BattInf"> <select id="getBattgroupIdInf" resultType="com.whyc.pojo.db_station.BattInf"> select distinct tb_batt_inf.* ,tb_station_inf.station_type,tb_station_inf.station_name,tb_station_inf.provice,tb_station_inf.city,tb_station_inf.country,tb_station_inf.full_name from db_station.tb_batt_inf,db_station.tb_station_inf @@ -476,4 +476,12 @@ </where> limit 1 </select> <select id="getBattgroupIdList" resultType="java.lang.Integer"> select distinct tb_batt_inf.battgroup_id from db_station.tb_batt_inf <where> tb_batt_inf.power_id=#{powerId} </where> order by battgroup_num asc </select> </mapper> src/main/resources/mapper/BattalarmDataMapper.xml
@@ -78,7 +78,8 @@ ) </select> <select id="getBattAlmAnalyse" resultType="com.whyc.pojo.db_alarm.BattalarmData"> select tb_battalarm_data.*,tb_batt_inf.battgroup_name,tb_station_inf.station_name,tb_station_inf.provice,tb_station_inf.city,tb_station_inf.country,tb_station_inf.full_name select tb_battalarm_data.*,tb_batt_inf.battgroup_name,tb_batt_inf.power_id,tb_batt_inf.station_id ,tb_station_inf.station_name,tb_station_inf.provice,tb_station_inf.city,tb_station_inf.country,tb_station_inf.full_name from db_alarm.tb_battalarm_data,db_station.tb_batt_inf,db_station.tb_station_inf <where> tb_battalarm_data.battgroup_id=tb_batt_inf.battgroup_id