whycxzp
2025-04-30 4fce1788cfb5bc37484060b068daf6303a584058
src/main/java/com/whyc/service/BattRealTimeDataHistoryService.java
@@ -269,4 +269,45 @@
        });
        return list;
    }
    /**
     * select * from tb_batt_realdata_100001_2025_04 where record_time in
     * (SELECT MIN(record_time) AS min_time FROM tb_batt_realdata_100001_2025_04
     * GROUP BY DATE(record_time))
     *
     * @param tableName
     * @param timeAgo
     * @return
     */
    public List<BattRealTimeDataHistory> getFirstRecordListOfDay(String tableName, Date timeAgo) {
        String sqlExtra;
        if(timeAgo!=null){
            sqlExtra = " where record_time > '" + timeAgo + "'";
        }else{
            sqlExtra = "";
        }
        String sql = "select * from db_power_history." + tableName + " where record_time in (SELECT MIN(record_time) FROM db_power_history." + tableName + sqlExtra +" GROUP BY DATE(record_time))";
        List<BattRealTimeDataHistory> list = sqlExecuteService.executeQuery_call(sql, new CallBack() {
            @Override
            public List getResults(ResultSet rs) throws SQLException {
                List<BattRealTimeDataHistory> list = new LinkedList<>();
                //如果存在记录
                while (rs.next()) {
                    BattRealTimeDataHistory his = new BattRealTimeDataHistory();
                    his.setTestStartTime(rs.getTimestamp("test_start_time"));
                    his.setRecordTime(rs.getTimestamp("record_time"));
                    his.setMonNum(rs.getInt("mon_num"));
                    his.setMonVol(rs.getFloat("mon_vol"));
                    his.setMonRes(rs.getFloat("mon_res"));
                    his.setMonTmp(rs.getFloat("mon_tmp"));
                    list.add(his);
                }
                return list;
            }
        });
        return list;
    }
}