whyclxw
2025-02-17 70f6a8d6b295e8149e209b9ca9add886c57a4e11
src/main/java/com/whyc/service/SubTableService.java
@@ -111,12 +111,34 @@
    //锁的告警历史记录总数
    public int getLockAlmHisCount(LockAlarmHis his) {
        String sql="SELECT  count(*) as number FROM db_lock_alarm."+ his.getRecordYear()+" history " +
                " where history.lock_id="+ his.getLockId() ;
                " where  1=1 ";
        if(his.getLids()!=null&&his.getLids().size()>0){
            List<Integer> lids=his.getLids();
            sql+=" and  history.lock_id in (";
            for (int i=0;i<lids.size();i++) {
                if(i==lids.size()-1){
                    sql=sql+lids.get(i)+") ";
                }else{
                    sql=sql+lids.get(i)+",";
                }
            }
        }
        if(his.getStartTime()!=null){
            sql+=" and alm_start_time  >='"+ ThreadLocalUtil.format(his.getStartTime(),1)+"' ";
        }
        if(his.getEndTime()!=null){
            sql+=" and alm_start_time  <='"+ThreadLocalUtil.format(his.getEndTime(),1)+"' ";
        }
        if(his.getAlmIds()!=null){
            String[] almId=his.getAlmIds().split(",");
            sql+=" and  history.alm_id in (";
            for (int i=0;i<almId.length;i++) {
                if(i==almId.length-1){
                    sql=sql+almId[i]+") ";
                }else{
                    sql=sql+almId[i]+",";
                }
            }
        }
        List list = sqlExecuteService.executeQuery_call(sql, new CallBack() {
            @Override
@@ -140,13 +162,35 @@
    //锁的告警历史记录
    public List<LockAlarmHis> getLockAlmHisList(LockAlarmHis his) {
        String sql="SELECT * FROM db_lock_alarm."+ his.getRecordYear()+" history " +
                " where history.lock_id="+  his.getLockId() ;
                " where 1=1 " ;
        if(his.getLids()!=null&&his.getLids().size()>0){
            List<Integer> lids=his.getLids();
            sql+=" and  history.lock_id in (";
            for (int i=0;i<lids.size();i++) {
                if(i==lids.size()-1){
                    sql=sql+lids.get(i)+") ";
                }else{
                    sql=sql+lids.get(i)+",";
                }
            }
        }
        if(his.getStartTime()!=null){
            sql+=" and alm_start_time  >='"+ ThreadLocalUtil.format(his.getStartTime(),1)+"' ";
        }
        if(his.getEndTime()!=null){
            sql+=" and alm_start_time  <='"+ThreadLocalUtil.format(his.getEndTime(),1)+"' ";
        }
        if(his.getAlmIds()!=null){
            String[] almId=his.getAlmIds().split(",");
            sql+=" and  history.alm_id in (";
            for (int i=0;i<almId.length;i++) {
                if(i==almId.length-1){
                    sql=sql+almId[i]+") ";
                }else{
                    sql=sql+almId[i]+",";
                }
            }
        }
        sql+="  ORDER BY alm_start_time asc  limit "+ his.getLimitStart()+","+ his.getLimitEnd()+" ";
        List<LockAlarmHis> list=sqlExecuteService.executeQuery_call(sql, new CallBack() {
            @Override