| | |
| | | import com.whyc.factory.ThreadPoolExecutorFactory; |
| | | import com.whyc.mapper.CommonMapper; |
| | | import com.whyc.pojo.db_alarm.BattAlarmHistory; |
| | | import com.whyc.pojo.db_power_alarm.PowerAlarm; |
| | | import com.whyc.pojo.db_power_alarm.PowerAlarmHistory; |
| | | import com.whyc.service.SubTableService; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | Date startTime,Date endTime, |
| | | String dbName,String tablePrefix, |
| | | Object pojo) throws ParseException { |
| | | Map<String, List<Date>> queryTimeForSubTables = DateUtil.getQueryTimeForSubTablesDesc(startTime, endTime); |
| | | Map<String, List<Date>> queryTimeForSubTables = DateUtil.getQueryTimeForSubTablesDescWithOutDefault(startTime, endTime); |
| | | //查询分表是否存在,存在则查询结果 |
| | | Map<String,Integer> queryCountMap = new LinkedHashMap<>(); |
| | | Set<String> tableYearKeySet = queryTimeForSubTables.keySet(); |
| | | for (String tableYear : tableYearKeySet) { |
| | | List<Date> queryTime = queryTimeForSubTables.get(tableYear); |
| | | |
| | | String tableName; |
| | | if(!tableYear.equals("default")){ |
| | | //数值 |
| | | tableName = tablePrefix+"_"+tableYear; |
| | | String existTableName = commonMapper.existTable(dbName, tableName); |
| | | if(existTableName == null){ |
| | | continue; |
| | | } |
| | | }else{ |
| | | //不存在default |
| | | //tableName = tablePrefix; |
| | | //数值 |
| | | String tableName = tablePrefix+"_"+tableYear; |
| | | String existTableName = commonMapper.existTable(dbName, tableName); |
| | | if(existTableName == null){ |
| | | continue; |
| | | } |
| | | //====== 根据不同类型类型对象对应调整 ====== |
| | |
| | | battAlarmHistory.setAlmEndTime(queryTime.get(1)); |
| | | battAlarmHistory.setRecordYear(tableName); |
| | | int currentCount = service.getBattHisCount(battAlarmHistory); |
| | | queryCountMap.put(tableYear, currentCount); |
| | | } |
| | | else if(pojo instanceof PowerAlarmHistory) { |
| | | PowerAlarmHistory powerAlarmHistory = new PowerAlarmHistory(); |
| | | BeanUtils.copyProperties(pojo, powerAlarmHistory); |
| | | powerAlarmHistory.setAlmStartTime(queryTime.get(0)); |
| | | powerAlarmHistory.setAlmEndTime(queryTime.get(1)); |
| | | powerAlarmHistory.setRecordYear(tableName); |
| | | int currentCount = service.getPowerHisCount(powerAlarmHistory); |
| | | queryCountMap.put(tableYear, currentCount); |
| | | } |
| | | |
| | |
| | | for (String key : keySet) { |
| | | List<Date> queryTime = queryTimeForSubTables.get(key); |
| | | //====== 根据不同类型类型对象对应调整 ====== |
| | | String recordYear = key.equals("default") ? tablePrefix : tablePrefix + "_" + key; |
| | | String recordYear = tablePrefix + "_" + key; |
| | | if(pojo instanceof BattAlarmHistory) { |
| | | BattAlarmHistory battAlarmHistory = new BattAlarmHistory(); |
| | | BeanUtils.copyProperties(pojo, battAlarmHistory); |
| | |
| | | List<BattAlarmHistory> list = service.getBattHisList(battAlarmHistory); |
| | | dataList.addAll(list); |
| | | } |
| | | else if(pojo instanceof PowerAlarmHistory) { |
| | | PowerAlarmHistory powerAlarmHistory = new PowerAlarmHistory(); |
| | | BeanUtils.copyProperties(pojo, powerAlarmHistory); |
| | | powerAlarmHistory.setAlmStartTime(queryTime.get(0)); |
| | | powerAlarmHistory.setAlmEndTime(queryTime.get(1)); |
| | | powerAlarmHistory.setRecordYear(recordYear); |
| | | List<Integer> limitList = tableAndLimitMap.get(key); |
| | | powerAlarmHistory.setLimitStart(limitList.get(0)); |
| | | powerAlarmHistory.setLimitEnd(limitList.get(1)); |
| | | List<PowerAlarmHistory> list = service.getPowerHisList(powerAlarmHistory); |
| | | dataList.addAll(list); |
| | | } |
| | | } |
| | | pageInfo.setList(dataList); |
| | | return pageInfo; |