| | |
| | | package com.whyc.service; |
| | | |
| | | import com.whyc.dto.Real.QuarterData; |
| | | import com.whyc.dto.Real.CompareDto; |
| | | import com.whyc.dto.Real.QuarterDto; |
| | | import com.whyc.dto.Response; |
| | | import com.whyc.mapper.CommonMapper; |
| | | import com.whyc.pojo.db_data_history.BattRealdataId; |
| | | import com.whyc.util.ActionUtil; |
| | | import com.whyc.util.SubTablePageInfoUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | |
| | | //获取电池组最近一季度的单体数据 |
| | | public Response getBattQuarter(Integer battgroupId) { |
| | | HashMap<String,Object> map = new HashMap<>(); |
| | | Float maxVol=0f; |
| | | Float minVol=0f; |
| | | Float avgVol=0f; |
| | | int num=0; |
| | | List<String> datelist = ActionUtil.getLastQuarterYearMonths(); |
| | | for (String date:datelist) { |
| | | for (int i=0;i<datelist.size();i++) { |
| | | String date=datelist.get(i); |
| | | String tableName ="db_data_history.tb_batt_realdata_"+battgroupId+"_"+date; |
| | | String existTableName = commonMapper.existTable("db_data_history", "tb_batt_realdata_"+battgroupId+"_"+date); |
| | | if(existTableName == null){ |
| | | continue; |
| | | } |
| | | //判断表是否存在 |
| | | List<QuarterData> list=subTablePageInfoService.getBattRealHis(tableName,"mon_vol"); |
| | | map.put(date,list); |
| | | List<QuarterDto> datalist=subTablePageInfoService.getBattRealHis(tableName,"mon_vol"); |
| | | map.put(date,datalist); |
| | | //获取表中最大,最小,平均数据值 |
| | | CompareDto compareData=subTablePageInfoService.getBattCompareHis(tableName,"mon_vol"); |
| | | if(num==0){ |
| | | maxVol=compareData.getMaxValue(); |
| | | minVol=compareData.getMinValue(); |
| | | } |
| | | if (compareData.getMaxValue() >= maxVol) { |
| | | maxVol =compareData.getMaxValue(); |
| | | } |
| | | if (compareData.getMinValue() <= minVol) { |
| | | minVol = compareData.getMinValue(); |
| | | } |
| | | avgVol += compareData.getAvgValue(); |
| | | map.put("maxVol",maxVol); |
| | | map.put("minVol",minVol); |
| | | map.put("avgVol",avgVol/datelist.size()); |
| | | num++; |
| | | } |
| | | return new Response().setII(1,map.size()>0,map,"获取电池组最近一季度的数据"); |
| | | } |