whyclxw
2025-03-25 a7fef2846505b08e0711345b17902e7381612d23
src/main/java/com/whyc/util/SubTablePageInfoUtil.java
@@ -3,6 +3,9 @@
import com.github.pagehelper.PageInfo;
import com.whyc.factory.ThreadPoolExecutorFactory;
import com.whyc.mapper.CommonMapper;
import com.whyc.mapper.LockInfMapper;
import com.whyc.pojo.db_area.LockInf;
import com.whyc.pojo.db_lock_alarm.LockAlarm;
import com.whyc.pojo.db_lock_alarm.LockAlarmHis;
import com.whyc.pojo.db_lock_his.LockHis;
import com.whyc.service.SubTableService;
@@ -28,6 +31,9 @@
    @Autowired
    private SubTableService service;
    @Autowired(required = false)
    private LockInfMapper linfMapper;
    /**按年份表分页查询*/
@@ -49,7 +55,7 @@
                continue;
            }
            //====== 根据不同类型类型对象对应调整 ======
            if(pojo instanceof LockHis) {
            if(pojo instanceof LockAlarmHis) {
                LockAlarmHis his = new LockAlarmHis();
                BeanUtils.copyProperties(pojo, his);
                his.setStartTime(queryTime.get(0));
@@ -88,7 +94,7 @@
            List<Date> queryTime = queryTimeForSubTables.get(key);
            //====== 根据不同类型类型对象对应调整 ======
            String recordYear = tablePrefix + "_" + key;
            if(pojo instanceof LockHis) {
            if(pojo instanceof LockAlarmHis) {
                LockAlarmHis his = new LockAlarmHis();
                BeanUtils.copyProperties(pojo, his);
                his.setStartTime(queryTime.get(0));
@@ -97,7 +103,11 @@
                List<Integer> limitList = tableAndLimitMap.get(key);
                his.setLimitStart(limitList.get(0));
                his.setLimitEnd(limitList.get(1));
                List<LockHis> list =  service.getLockAlmHisList(his);
                List<LockAlarmHis> list =  service.getLockAlmHisList(his);
                for (LockAlarmHis alm:list) {
                    LockInf linf=linfMapper.getlinfBylockId(alm.getLockId());
                    alm.setLinf(linf);
                }
                dataList.addAll(list);
            }
@@ -300,4 +310,33 @@
        }
        return resultTableList;
    }
    //实时界面点击查看历史信息
    public List getLockHisWithReal(Date startTime,Date endTime,
                                                      String dbName,String tablePrefix,
                                                      Object pojo) throws ParseException {
        Map<String, List<Date>> queryTimeForSubTables = DateUtil.getQueryTimeForSubTablesDescWithOutDefault(startTime, endTime);
        Set<String> tableYearKeySet = queryTimeForSubTables.keySet();
        List<Object> dataList = new LinkedList<>();
        for (String tableYear : tableYearKeySet) {
            List<Date> queryTime = queryTimeForSubTables.get(tableYear);
            //数值
            String tableName = tablePrefix+"_"+tableYear;
            String existTableName = commonMapper.existTable(dbName, tableName);
            if(existTableName == null){
                continue;
            }
            //====== 根据不同类型类型对象对应调整 ======
            if(pojo instanceof LockHis) {
                LockHis his = new LockHis();
                BeanUtils.copyProperties(pojo, his);
                his.setStartTime(queryTime.get(0));
                his.setEndTime(queryTime.get(1));
                his.setRecordYear(tableName);
                List<LockHis> list =  service.getLockHisWithReal(his);
                dataList.addAll(list);
            }
        }
        return dataList;
    }
}