package com.whyc.service; import com.whyc.dto.Real.QuarterData; 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; import javax.annotation.Resource; import java.util.HashMap; import java.util.List; @Service public class BattRealdataIdService { @Autowired private SubTablePageInfoService subTablePageInfoService; @Resource private CommonMapper commonMapper; //获取电池组最近一季度的单体数据 public Response getBattQuarter(Integer battgroupId) { HashMap map = new HashMap<>(); List datelist = ActionUtil.getLastQuarterYearMonths(); for (String date:datelist) { 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 list=subTablePageInfoService.getBattRealHis(tableName,"mon_vol"); map.put(date,list); } return new Response().setII(1,map.size()>0,map,"获取电池组最近一季度的数据"); } }