whycxzp
2025-03-31 a127882c8f15593783fcf0a1489835c16db70682
src/main/java/com/whyc/service/SubTableService.java
@@ -6,6 +6,7 @@
import com.whyc.pojo.db_alarm.DevLithiumAlarmDataYear;
import com.whyc.pojo.db_dis_batt.BattTestInfData;
import com.whyc.pojo.db_power_alarm.PowerAlarmHistory;
import com.whyc.pojo.db_power_history.BattStationTempHistory;
import com.whyc.util.ActionUtil;
import com.whyc.util.ThreadLocalUtil;
import org.springframework.beans.factory.annotation.Autowired;
@@ -124,6 +125,67 @@
        return list;
    }
    public int getBattStationTempHisCount(BattStationTempHistory tempHistory) {
        String sql="select count(id) as number from db_power_history."+tempHistory.getRecordYearMonth()+" where 1=1 ";
        if(tempHistory.getStartTime()!=null){
            sql+=" and record_time  >='"+ ThreadLocalUtil.format(tempHistory.getStartTime(),1)+"' ";
        }
        if(tempHistory.getEndTime()!=null){
            sql+=" and record_time  <='"+ThreadLocalUtil.format(tempHistory.getEndTime(),1)+"' ";
        }
        List list = sqlExecuteService.executeQuery_call(sql, new CallBack() {
            @Override
            public List getResults(ResultSet rs) throws SQLException {
                LinkedList<Object> temp = new LinkedList<>();
                try {
                    while (rs.next())
                        temp.add(rs.getInt("number"));
                } catch (SQLException e) {
                    e.printStackTrace();
                }
                return temp;
            }
        });
        int num =0;
        if(list!=null){
            num= (int) list.get(0);
        }
        return num;
    }
    public List<BattStationTempHistory> getBattStationTempHisList(BattStationTempHistory tempHistory) {
        String sql="select * from db_power_history."+tempHistory.getRecordYearMonth()+" where 1=1 ";
        if(tempHistory.getStartTime()!=null){
            sql+=" and record_time  >='"+ ThreadLocalUtil.format(tempHistory.getStartTime(),1)+"' ";
        }
        if(tempHistory.getEndTime()!=null){
            sql+=" and record_time  <='"+ThreadLocalUtil.format(tempHistory.getEndTime(),1)+"' ";
        }
        sql+="  ORDER BY record_time desc  limit "+ tempHistory.getLimitStart()+","+ tempHistory.getLimitEnd()+" ";
        List<BattStationTempHistory> list=sqlExecuteService.executeQuery_call(sql, new CallBack() {
            @Override
            public List getResults(ResultSet rs) throws SQLException {
                List<BattStationTempHistory> list=new ArrayList();
                while (rs.next()){
                    BattStationTempHistory data=new BattStationTempHistory();
                    data.setId(rs.getInt("id"));
                    data.setBattGroupId(rs.getInt("batt_group_id"));
                    data.setStationId(rs.getInt("station_id"));
                    data.setCameraId(rs.getString("camera_id"));
                    data.setPixelX(rs.getInt("pixel_x"));
                    data.setPixelY(rs.getInt("pixel_y"));
                    data.setMinTemp(rs.getFloat("min_temp"));
                    data.setMaxTemp(rs.getFloat("max_temp"));
                    data.setMinTempPoint(rs.getString("min_temp_point"));
                    data.setMaxTempPoint(rs.getString("max_temp_point"));
                    data.setRecordTime(rs.getTimestamp("record_time"));
                    list.add(data);
                }
                return list;
            }
        });
        return list;
    }
    //电源告警历史实时计算每张表查询总数
    public int getPowerHisCount(PowerAlarmHistory powerAlarmHistory) {
        String sql="SELECT  count(*) as number FROM db_power_alarm."+ powerAlarmHistory.getRecordYear()+" history " +