From e16302f9d475c7cc4dd18c5abf1a23cb5502e362 Mon Sep 17 00:00:00 2001
From: whyclxw <810412026@qq.com>
Date: 星期三, 28 五月 2025 14:57:56 +0800
Subject: [PATCH] 密码验证加-

---
 src/main/java/com/whyc/service/SubTablePageInfoService.java |  764 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 759 insertions(+), 5 deletions(-)

diff --git a/src/main/java/com/whyc/service/SubTablePageInfoService.java b/src/main/java/com/whyc/service/SubTablePageInfoService.java
index ef1d1ef..b7fdf46 100644
--- a/src/main/java/com/whyc/service/SubTablePageInfoService.java
+++ b/src/main/java/com/whyc/service/SubTablePageInfoService.java
@@ -1,10 +1,8 @@
 package com.whyc.service;
 
-import com.whyc.dto.InterfaceParam;
-import com.whyc.dto.ReportBattDTO;
-import com.whyc.dto.StandardFeatureCurve;
-import com.whyc.dto.UpsAlarmDTO;
+import com.whyc.dto.*;
 import com.whyc.dto.paramter.AlarmPar;
+import com.whyc.dto.paramter.AnalysisDto;
 import com.whyc.dto.paramter.DevAlarmPar;
 import com.whyc.dto.result.AlarmRes;
 import com.whyc.dto.result.RealDateDTO;
@@ -1231,7 +1229,7 @@
                 "            db_user.tb_user_battgroup_baojigroup_usr.baoji_group_id=db_user.tb_user_battgroup_baojigroup_battgroup.baoji_group_id  " +
                 "            and db_user.tb_user_inf.uid=db_user.tb_user_battgroup_baojigroup_usr.uid and db_user.tb_user_inf.uid="+param.getUId()+"  " +
                 "            )";
-        sql+="   order by history.BattGroupId asc,history.alm_start_time desc,history.monnum asc limit "+param.getLimitStart()+","+param.getLimitEnd()+" ";
+        sql+="   order by history.alm_start_time desc,history.BattGroupId asc,history.monnum asc limit "+param.getLimitStart()+","+param.getLimitEnd()+" ";
 
         List<AlarmRes> list = sqlExecuteService.executeQuery_call(sql, new CallBack() {
             @Override
@@ -3477,4 +3475,760 @@
         String sql="delete from db_upspwrdev_alarm.tb_upspwrdev_alarm_history_"+year+" where num = "+num+"";
         sqlExecuteService.execute(sql);
     }
+
+    //鑾峰彇鎬荤殑鏀剧數鐢垫祦鐨勬�诲��
+    public Float getSumCurr(int battGroupId, int testRecordCount) {
+        String sql="  SELECT  sum(ABS(test_curr)) as sumCurr " +
+                "        FROM db_batt_testdata.tb_batttestdata_"+battGroupId+
+                "        WHERE test_record_count = " +testRecordCount+
+                "          and mon_num =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.getFloat("sumCurr"));
+                } catch (SQLException e) {
+                    e.printStackTrace();
+                }
+                return temp;
+            }
+        });
+        Float sumCurr =0f;
+        if(list!=null){
+            sumCurr= (Float) list.get(0);
+        }
+        return sumCurr;
+    }
+    //鑾峰彇鎬荤殑鏀剧數璁板綍
+    public List<BatttestdataId> getAllTdata(int battGroupId, int testRecordCount) {
+        String sql="  SELECT  *   FROM db_batt_testdata.tb_batttestdata_"+battGroupId+
+                "        WHERE test_record_count = " +testRecordCount+
+                "        order by record_num desc";
+        List<BatttestdataId> list = sqlExecuteService.executeQuery_call(sql, new CallBack() {
+            @Override
+            public List getResults(ResultSet rs) throws SQLException {
+                List list=new ArrayList<>();
+                try {
+                    while (rs.next()){
+                        BatttestdataId tdata=new BatttestdataId();
+                        tdata.setBattGroupId(rs.getInt("BattGroupId"));
+                        tdata.setTestRecordCount(rs.getInt("test_record_count"));
+                        tdata.setTestType(rs.getInt("test_type"));
+                        tdata.setDataNew(rs.getInt("data_new"));
+                        tdata.setDataAvailable(rs.getInt("data_available"));
+                        tdata.setRecordNum(rs.getInt("record_num"));
+                        tdata.setTestStarttime(rs.getTimestamp("test_starttime"));
+                        tdata.setRecordTime(rs.getTimestamp("record_time"));
+                        tdata.setTestTimelong(rs.getInt("test_timelong"));
+                        tdata.setOnlineVol(rs.getFloat("online_vol"));
+                        tdata.setGroupVol(rs.getFloat("group_vol"));
+                        tdata.setTestCurr(rs.getFloat("test_curr"));
+                        tdata.setTestCap(rs.getFloat("test_cap"));
+                        tdata.setMonNum(rs.getInt("mon_num"));
+                        tdata.setMonVol(rs.getFloat("mon_vol"));
+                        tdata.setMonTmp(rs.getFloat("mon_tmp"));
+                        list.add(tdata);
+                    }
+                } catch (SQLException e) {
+                    e.printStackTrace();
+                }
+                return list;
+            }
+        });
+        return list;
+    }
+   //鍒犻櫎璁板綍
+    public void deleteData(int battGroupId, int testRecordCount, int num) {
+        String sql="  delete   FROM db_batt_testdata.tb_batttestdata_"+battGroupId+
+                "        WHERE test_record_count = " +testRecordCount+
+                "        and record_num>"+num;
+        sqlExecuteService.executeUpdate(sql,null);
+    }
+    //鍒涘缓clear
+    public void creatClear(int battGroupId) {
+        String sql=" CREATE TABLE IF NOT EXISTS db_batt_testdata.tb_batttestdata_clear_"+battGroupId+" (" +
+                "  `num` bigint(20) NOT NULL AUTO_INCREMENT," +
+                "  `BattGroupId` int(11) NOT NULL DEFAULT '0'," +
+                "  `test_record_count` int(11) NOT NULL DEFAULT '0'," +
+                "  `test_type` int(11) NOT NULL DEFAULT '0'," +
+                "  `data_new` tinyint(1) NOT NULL DEFAULT '0'," +
+                "  `data_available` tinyint(1) NOT NULL DEFAULT '0'," +
+                "  `record_num` int(11) NOT NULL DEFAULT '0'," +
+                "  `test_starttime` datetime NOT NULL DEFAULT '1982-01-01 00:00:00'," +
+                "  `record_time` datetime NOT NULL DEFAULT '1982-01-01 00:00:00'," +
+                "  `test_timelong` int(11) NOT NULL DEFAULT '0'," +
+                "  `online_vol` float NOT NULL DEFAULT '0'," +
+                "  `group_vol` float NOT NULL DEFAULT '0'," +
+                "  `test_curr` float NOT NULL DEFAULT '0'," +
+                "  `test_cap` float NOT NULL DEFAULT '0'," +
+                "  `mon_num` int(11) NOT NULL DEFAULT '0'," +
+                "  `mon_vol` float NOT NULL DEFAULT '0'," +
+                "  `mon_tmp` float NOT NULL DEFAULT '0'," +
+                "  PRIMARY KEY (`num`)," +
+                "  KEY `index_test_record_count` (`test_record_count`)" +
+                ")";
+        sqlExecuteService.execute(sql);
+    }
+    //鍏堝瓨鍏lear琛�
+    public void insertClear(int battGroupId, int testRecordCount,int recordNum) {
+        //鍒ゆ柇琛ㄦ槸鍚﹀瓨鍦�
+
+        String sql = "INSERT INTO db_batt_testdata.tb_batttestdata_clear_" + battGroupId
+                + "(BattGroupId,test_record_count,test_type,data_new,data_available,record_num,test_starttime,record_time,test_timelong,online_vol,group_vol,test_curr,test_cap,mon_num,mon_vol,mon_tmp) "
+        + "(SELECT BattGroupId,test_record_count,test_type,data_new,data_available,record_num,test_starttime,record_time,test_timelong,online_vol,group_vol,test_curr,test_cap,mon_num,mon_vol,mon_tmp from db_batt_testdata.tb_batttestdata_" + battGroupId
+                + " WHERE test_record_count = " +testRecordCount
+                + " and record_num > " + recordNum
+                + ")";
+        sqlExecuteService.executeUpdate(sql,null);
+    }
+    //鑾峰彇闇�瑕佹仮澶嶇殑鏀剧數璁板綍
+    public List<BatttestdataClear> getClearTdata(int battGroupId, int testRecordCount) {
+        String sql="  SELECT  *  " +
+                "        FROM db_batt_testdata.tb_batttestdata_"+battGroupId+
+                "        WHERE test_record_count = " +testRecordCount+
+                "        ";
+        List<BatttestdataClear> list = sqlExecuteService.executeQuery_call(sql, new CallBack() {
+            @Override
+            public List getResults(ResultSet rs) throws SQLException {
+                List list=new ArrayList<>();
+                try {
+                    while (rs.next()){
+                        BatttestdataClear clear=new BatttestdataClear();
+                        clear.setBattGroupId(rs.getInt("BattGroupId"));
+                        clear.setTestRecordCount(rs.getInt("test_record_count"));
+                        clear.setTestType(rs.getInt("test_type"));
+                        clear.setDataNew(rs.getInt("data_new"));
+                        clear.setDataAvailable(rs.getInt(""));
+                        clear.setRecordNum(rs.getInt("record_num"));
+                        clear.setTestStarttime(rs.getTimestamp("test_starttime"));
+                        clear.setRecordTime(rs.getTimestamp("record_time"));
+                        clear.setTestTimelong(rs.getInt("test_timelong"));
+                        clear.setOnlineVol(rs.getFloat("online_vol"));
+                        clear.setGroupVol(rs.getFloat("group_vol"));
+                        clear.setTestCurr(rs.getFloat("test_curr"));
+                        clear.setTestCap(rs.getFloat("test_cap"));
+                        clear.setMonNum(rs.getInt("mon_num"));
+                        clear.setMonVol(rs.getFloat("mon_vol"));
+                        clear.setMonTmp(rs.getFloat("mon_tmp"));
+                        list.add(clear);
+                    }
+                } catch (SQLException e) {
+                    e.printStackTrace();
+                }
+                return list;
+            }
+        });
+        return list;
+    }
+
+    public void insertRecover(int battGroupId, int testRecordCount) {
+        String sql = "INSERT INTO db_batt_testdata.tb_batttestdata_" + battGroupId
+                + "(BattGroupId,test_record_count,test_type,data_new,data_available,record_num,test_starttime,record_time,test_timelong,online_vol,group_vol,test_curr,test_cap,mon_num,mon_vol,mon_tmp) "
+                + "(SELECT BattGroupId,test_record_count,test_type,data_new,data_available,record_num,test_starttime,record_time,test_timelong,online_vol,group_vol,test_curr,test_cap,mon_num,mon_vol,mon_tmp from db_batt_testdata.tb_batttestdata_clear_" + battGroupId
+                + " WHERE test_record_count = " +testRecordCount
+                + ")";
+        sqlExecuteService.executeUpdate(sql,null);
+    }
+
+    public void deleteRecover(int battGroupId, int testRecordCount) {
+        String sql="  delete   FROM db_batt_testdata.tb_batttestdata_clear_"+battGroupId+
+                "        WHERE test_record_count = " +testRecordCount;
+        sqlExecuteService.executeUpdate(sql,null);
+    }
+    //鍏堟煡璇㈠嚭鎵�鏈夌殑璁板綍
+    public List<BatttestdataClear> getRecoveInf(int battGroupId, int testRecordCount) {
+        String sql="  SELECT  distinct  battGroupId,test_record_count,record_num  FROM db_batt_testdata.tb_batttestdata_clear_"+battGroupId+
+                "        WHERE test_record_count = " +testRecordCount+
+                "        order by record_num asc";
+        List<BatttestdataClear> list = sqlExecuteService.executeQuery_call(sql, new CallBack() {
+            @Override
+            public List getResults(ResultSet rs) throws SQLException {
+                List list=new ArrayList<>();
+                try {
+                    while (rs.next()){
+                        BatttestdataClear tclear=new BatttestdataClear();
+                        tclear.setBattGroupId(rs.getInt("BattGroupId"));
+                        tclear.setTestRecordCount(rs.getInt("test_record_count"));
+                        tclear.setRecordNum(rs.getInt("record_num"));
+                        list.add(tclear);
+                    }
+                } catch (SQLException e) {
+                    e.printStackTrace();
+                }
+                return list;
+            }
+        });
+        return list;
+    }
+    //鏌ュ嚭闇�瑕侀浼扮殑鏁版嵁
+    public List<AnaysisData> getAnaysisData(int battGroupId, int testRecordCount) {
+        String sql="  SELECT  distinct  record_num,test_timelong,group_vol,test_cap,mon_num,mon_vol,test_curr FROM db_batt_testdata.tb_batttestdata_"+battGroupId+
+                "        WHERE test_record_count = " +testRecordCount+
+                "        order by record_num asc,mon_num asc ";
+        List<AnaysisData> list = sqlExecuteService.executeQuery_call(sql, new CallBack() {
+            @Override
+            public List getResults(ResultSet rs) throws SQLException {
+                List list=new ArrayList<>();
+                List<Float> monVols=null;
+                List<Integer> monNums=null;
+                AnaysisData data=null;
+                int num=0;
+                try {
+                    while (rs.next()){
+                        int monNum=rs.getInt("mon_num");
+                        float monvol=rs.getFloat("mon_vol");
+                        int recordNum=rs.getInt("record_num");
+                        if(num!=recordNum){
+                            if(num!=0){
+                                data.setMonVols(monVols);
+                                data.setMonNums(monNums);
+                                list.add(data);
+                            }
+                            data=new AnaysisData();
+                            monVols=new ArrayList<>();
+                            monNums=new ArrayList<>();
+                            data.setTestTimelong(rs.getInt("test_timelong"));
+                            data.setRecordTime(ActionUtil.secToTime(data.getTestTimelong()));
+                            data.setGroupVol(rs.getFloat("group_vol"));
+                            data.setTestCap(rs.getFloat("test_cap"));
+                            data.setGroupCurr(rs.getFloat("test_curr"));
+                            data.setRecordNum(recordNum);
+                            num=recordNum;
+                        }
+                        monVols.add(monvol);
+                        monNums.add(monNum);
+                    }
+                    data.setMonVols(monVols);
+                    data.setMonNums(monNums);
+                    list.add(data);
+                } catch (SQLException e) {
+                    e.printStackTrace();
+                }
+                return list;
+            }
+        });
+        return list;
+    }
+    //灏嗚В鏋愬嚭鐨勬暟鎹瓨鍏ユ暟鎹簱琛�
+    public void storeAnaysisToSqlWithNum(int battGroupId,int testRecordCount, List<AnaylsisId> idList) {
+        ArrayList  sql_str=new ArrayList();
+        String tableName="db_analysis."+"tb_analysis_"+battGroupId;
+        //妫�娴嬭〃鏄惁瀛樺湪
+        if(idList!=null){
+            String insertSql="insert into "+tableName+" "
+                    + "("
+                    + "test_record_count,"
+                    + "record_num,"
+                    + "record_time,"
+                    + "mon_num,"
+                    + "mon_vol,"
+                    + "flag"
+                    + ") "
+                    + " values ";
+            for (int i=0;i<idList.size();i++) {
+                AnaylsisId ays=idList.get(i);
+                if(i>0){
+                    insertSql+=" ,  ";
+                }
+                insertSql=insertSql
+                        + "("
+                        + ays.getTestRecordCount()+","
+                        + ays.getRecordNum()+","
+                        + "'"+ays.getRecordTime()+"',"
+                        + ays.getMonNum()+","
+                        + ays.getMonVol()+","
+                        + 1+""
+                        + ")";//濡傛灉瀵瑰簲鏄瓧绗﹀嚑涓甫涓婂崟寮曞彿
+            }
+            sql_str.add(insertSql);
+        }
+        sqlExecuteService.makeManualCommit(sql_str);
+    }
+    //灏嗚В鏋愮殑缁勭鐢靛帇淇敼鍒版暟鎹簱
+    public void updateAnaysisToSqlWithNum(int battGroupId, int testRecordCount, List<AnaylsisId> groupVolList) {
+        ArrayList  sql_str=new ArrayList();
+        String tableName="db_analysis."+"tb_analysis_"+battGroupId;
+        if(groupVolList!=null){
+            for ( AnaylsisId ays:groupVolList) {
+                String updateSql="update "+tableName+" set group_vol="+ays.getGroupVol()+" where test_record_count="+testRecordCount+" and record_num="+ays.getRecordNum();
+                sql_str.add(updateSql);
+            }
+        }
+        sqlExecuteService.makeManualCommit(sql_str);
+    }
+
+    //楠岃瘉鍒嗘瀽琛ㄦ槸鍚﹀瓨鍦�
+    public int judgeTable_anaysis(int battGroupId, int testRecordCount) {
+        String sql="select count(*) as tableNum " +
+                "        from INFORMATION_SCHEMA.TABLES " +
+                "        where TABLE_SCHEMA = 'db_analysis' " +
+                "          and TABLE_NAME = 'tb_analysis_"+battGroupId+"'";
+        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("tableNum"));
+                } catch (SQLException e) {
+                    e.printStackTrace();
+                }
+                return temp;
+            }
+        });
+        int tableNum =0;
+        if(list!=null){
+            tableNum= (int) list.get(0);
+        }
+        return tableNum;
+    }
+    //妫�娴嬭〃鏄瓨鍦ㄥ悗testRecordCount鏁版嵁鏄惁瀛樺湪
+    public int getAnaysisIdByTestRecordCount(int battGroupId, int testRecordCount) {
+        String sql="  SELECT  count(*) as sum FROM db_analysis.tb_analysis_"+battGroupId+
+                "        WHERE test_record_count = " +testRecordCount;
+        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("sum"));
+                } catch (SQLException e) {
+                    e.printStackTrace();
+                }
+                return temp;
+            }
+        });
+        int sum =0;
+        if(list!=null){
+            sum= (int) list.get(0);
+        }
+        return sum;
+    }
+    //妫�娴嬩功鍚﹀瓨鍦ㄨˉ鍏呯殑鏁版嵁
+    public int getAnaysisSupplement(int battGroupId, int testRecordCount) {
+        String sql="  SELECT  count(*) as supple FROM db_analysis.tb_analysis_"+battGroupId+
+                "        WHERE flag=0 and test_record_count = " +testRecordCount;
+        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("supple"));
+                } catch (SQLException e) {
+                    e.printStackTrace();
+                }
+                return temp;
+            }
+        });
+        int supple =0;
+        if(list!=null){
+            supple= (int) list.get(0);
+        }
+        return supple;
+    }
+
+    //妫�娴嬩功鍚﹀瓨鍦ㄨˉ鍏呯殑鏁版嵁
+    public int getAnaysisNum(int battGroupId, int testRecordCount) {
+        String sql="  SELECT  count(DISTINCT mon_num) as anaNum FROM db_analysis.tb_analysis_"+battGroupId+
+                "        WHERE flag=1 and test_record_count = " +testRecordCount;
+        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("anaNum"));
+                } catch (SQLException e) {
+                    e.printStackTrace();
+                }
+                return temp;
+            }
+        });
+        int anaNum =0;
+        if(list!=null){
+            anaNum= (int) list.get(0);
+        }
+        return anaNum;
+    }
+
+
+    //鍒涘缓clear
+    public void creatAnasys(int battGroupId) {
+        String sql=" CREATE TABLE IF NOT EXISTS db_analysis.tb_analysis_"+battGroupId+" (" +
+                "   `num` int(11) NOT NULL AUTO_INCREMENT," +
+                "   `test_record_count` int(11) NOT NULL DEFAULT '0'," +
+                "  `record_num` int not NULL DEFAULT 0," +
+                "  `record_time` varchar(64) not NULL DEFAULT '00:00:00'," +
+                "  `group_vol` float not NULL DEFAULT 0," +
+                "  `mon_num` int  not NULL DEFAULT 0," +
+                "  `mon_vol` float  not NULL DEFAULT 0," +
+                "  `flag` int  not NULL DEFAULT 0," +
+                "  PRIMARY KEY (`num`)" +
+                ") ENGINE=InnoDB AUTO_INCREMENT=1 ";
+        sqlExecuteService.execute(sql);
+    }
+    //鏌ヨ棰勪及鏁版嵁
+    public List<AnaylsisId> getAnaysisXls(int battGroupId, int testRecordCount) {
+        String sql="  SELECT  distinct  num,test_record_count,record_num,record_time,group_vol,mon_vol,mon_num,flag FROM db_analysis.tb_analysis_"+battGroupId+
+                "        WHERE test_record_count = " +testRecordCount+
+                "        order by test_record_count asc ,record_num asc ,mon_num ASC ";
+        List<AnaylsisId> list = sqlExecuteService.executeQuery_call(sql, new CallBack() {
+            @Override
+            public List getResults(ResultSet rs) throws SQLException {
+                List list=new ArrayList<>();
+                try {
+                    while (rs.next()){
+                        AnaylsisId idData=new AnaylsisId();
+                        idData.setNum(rs.getInt("num"));
+                        idData.setTestRecordCount(rs.getInt("test_record_count"));
+                        idData.setRecordNum(rs.getInt("record_num"));
+                        idData.setRecordTime(rs.getString("record_time"));
+                        idData.setGroupVol(rs.getFloat("group_vol"));
+                        idData.setMonNum(rs.getInt("mon_num"));
+                        idData.setMonVol(rs.getFloat("mon_vol"));
+                        idData.setFlag(rs.getInt("flag"));
+                        list.add(idData);
+                    }
+                } catch (SQLException e) {
+                    e.printStackTrace();
+                }
+                return list;
+            }
+        });
+        return list;
+    }
+    //琛ュ墠闈㈢殑鏁版嵁
+    public void insertBeforeData(int battGroupId, int testRecordCount, List<AnaysisData> list) {
+        ArrayList  sql_str=new ArrayList();
+        String tableName="db_analysis."+"tb_analysis_"+battGroupId;
+        //妫�娴嬭〃鏄惁瀛樺湪
+        if(list!=null){
+            String insertSql="insert into "+tableName+" "
+                    + "("
+                    + "test_record_count,"
+                    + "record_num,"
+                    + "record_time,"
+                    + "group_vol,"
+                    + "mon_num,"
+                    + "mon_vol,"
+                    + "flag"
+                    + ") "
+                    + " values ";
+            for (int i=0;i<list.size();i++) {
+                AnaysisData ays=list.get(i);
+                List monVols=ays.getMonVols();
+                for (int j=0;j<monVols.size();j++) {
+                    if(!(i==0&&j==0)){
+                        insertSql+=" ,  ";
+                    }
+                    String volSql="("
+                            + testRecordCount+","
+                            + ays.getRecordNum()+","
+                            + "'"+ays.getRecordTime()+"',"
+                            + ays.getGroupVol()+","
+                            + (j+1)+","
+                            + monVols.get(j)+","
+                            + 0+""
+                            + ")";//濡傛灉瀵瑰簲鏄瓧绗﹀嚑涓甫涓婂崟寮曞彿
+                    insertSql+=volSql;
+                }
+            }
+            sql_str.add(insertSql);
+        }
+        sqlExecuteService.makeManualCommit(sql_str);
+    }
+    //2.灏嗘暟鎹彃鍏ョ數姹犵粍鏁版嵁
+    public void insertAnaysisXlsToTdata(int battGroupId, int testRecordCount, List<XlsToTdata> list) {
+        ArrayList  sql_str=new ArrayList();
+        String tableName="db_batt_testdata."+"tb_batttestdata_"+battGroupId;
+        //妫�娴嬭〃鏄惁瀛樺湪
+        if(list!=null){
+            String insertSql="insert into "+tableName+" "
+                    + "("
+                    + "BattGroupId,"
+                    + "test_record_count,"
+                    + "record_num,"
+                    + "record_time,"
+                    + "test_starttime,"
+                    + "test_timelong,"
+                    + "group_vol,"
+                    + "test_curr,"
+                    + "test_cap,"
+                    + "mon_num,"
+                    + "mon_vol,"
+                    + "test_type,"
+                    + "data_new,"
+                    + "data_available"
+                    + ") "
+                    + " values ";
+            for (int i=0;i<list.size();i++) {
+                XlsToTdata tdata=list.get(i);
+                List monVols=tdata.getMonVols();
+                for (int j=0;j<monVols.size();j++) {
+                    if(!(i==0&&j==0)){
+                        insertSql+=" ,  ";
+                    }
+                    String volSql="("
+                            + battGroupId+","
+                            + testRecordCount+","
+                            + (i+1)+","
+                            + "'"+tdata.getRecordTime()+"',"
+                            + "'"+ActionUtil.sdf.format(new Date())+"',"
+                            + tdata.getTestTimelong()+","
+                            + tdata.getGroupVol()+","
+                            + tdata.getGroupCurr()+","
+                            + tdata.getTestCap()+","
+                            + (j+1)+","
+                            + monVols.get(j)+","
+                            + 3+","
+                            + 1+","
+                            + 1+""
+                            + ")";//濡傛灉瀵瑰簲鏄瓧绗﹀嚑涓甫涓婂崟寮曞彿
+                    insertSql+=volSql;
+                }
+            }
+            sql_str.add(insertSql);
+        }
+        sqlExecuteService.makeManualCommit(sql_str);
+    }
+
+    //棰勪及
+    public List<PredictDataId> getPredictDataId(int battGroupId, int testRecordCount) {
+        String sql="  SELECT  distinct  * FROM db_batt_testdata.tb_batttestdata_"+battGroupId+
+                "        WHERE test_record_count = " +testRecordCount+
+                "        order by record_num asc,mon_num asc ";
+        List<PredictDataId> list = sqlExecuteService.executeQuery_call(sql, new CallBack() {
+            @Override
+            public List getResults(ResultSet rs) throws SQLException {
+                List list=new ArrayList<>();
+                try {
+                    while (rs.next()){
+                        PredictDataId data=new PredictDataId();
+                        data.setBattGroupId(rs.getInt("BattGroupId"));
+                        data.setTestRecordCount(rs.getInt("test_record_count"));
+                        data.setTestCap(rs.getFloat("test_type"));
+                        data.setDataNew(rs.getInt("data_new"));
+                        data.setDataAvailable(rs.getInt("data_available"));
+                        data.setRecordNum(rs.getInt("record_num"));
+                        data.setTestStarttime(rs.getTimestamp("test_starttime"));
+                        data.setRecordTime(rs.getTimestamp("record_time"));
+                        data.setTestTimelong(rs.getInt("test_timelong"));
+                        data.setOnlineVol(rs.getFloat("online_vol"));
+                        data.setGroupVol(rs.getFloat("group_vol"));
+                        data.setTestCurr(rs.getFloat("test_curr"));
+                        data.setTestCap(rs.getFloat("test_cap"));
+                        data.setMonNum(rs.getInt("mon_num"));
+                        data.setMonVol(rs.getFloat("mon_vol"));
+                        data.setMonTmp(rs.getFloat("mon_tmp"));
+                        list.add(data);
+                    }
+                } catch (SQLException e) {
+                    e.printStackTrace();
+                }
+                return list;
+            }
+        });
+        return list;
+    }
+    //2.鍙栧嚭鏈�鍚庝竴绗旀暟鎹�
+    public List<PredictDataId> getPredictDataIdLast(int battGroupId, int testRecordCount, int maxRecordNum) {
+        String sql="  SELECT  distinct  * FROM db_batt_testdata.tb_batttestdata_"+battGroupId+
+            "        WHERE test_record_count = " +testRecordCount+" and record_num="+maxRecordNum+
+            "        order by record_num asc,mon_num asc ";
+        List<PredictDataId> list = sqlExecuteService.executeQuery_call(sql, new CallBack() {
+            @Override
+            public List getResults(ResultSet rs) throws SQLException {
+                List list=new ArrayList<>();
+                try {
+                    while (rs.next()){
+                        PredictDataId data=new PredictDataId();
+                        data.setBattGroupId(rs.getInt("BattGroupId"));
+                        data.setTestRecordCount(rs.getInt("test_record_count"));
+                        data.setTestType(rs.getInt("test_type"));
+                        data.setDataNew(rs.getInt("data_new"));
+                        data.setDataAvailable(rs.getInt("data_available"));
+                        data.setRecordNum(rs.getInt("record_num"));
+                        data.setTestStarttime(rs.getTimestamp("test_starttime"));
+                        data.setRecordTime(rs.getTimestamp("record_time"));
+                        data.setTestTimelong(rs.getInt("test_timelong"));
+                        data.setOnlineVol(rs.getFloat("online_vol"));
+                        data.setGroupVol(rs.getFloat("group_vol"));
+                        data.setTestCurr(rs.getFloat("test_curr"));
+                        data.setTestCap(rs.getFloat("test_cap"));
+                        data.setMonNum(rs.getInt("mon_num"));
+                        data.setMonVol(rs.getFloat("mon_vol"));
+                        data.setMonTmp(rs.getFloat("mon_tmp"));
+                        list.add(data);
+                    }
+                } catch (SQLException e) {
+                    e.printStackTrace();
+                }
+                return list;
+            }
+        });
+        return list;
+    }
+    //3.鍙栧嚭棰勪及瀵硅薄鐨刴axRecordNum涔嬪悗鐨勬暟鎹�
+    public List<PredictDataId> getPredictDataIdAgain(int battGroupId, int testRecordCount, int maxRecordNum) {
+        String sql="  SELECT  distinct  * FROM db_batt_testdata.tb_batttestdata_"+battGroupId+
+                "        WHERE test_record_count = " +testRecordCount+" and record_num>="+maxRecordNum+
+                "        order by record_num asc,mon_num asc ";
+        List<PredictDataId> list = sqlExecuteService.executeQuery_call(sql, new CallBack() {
+            @Override
+            public List getResults(ResultSet rs) throws SQLException {
+                List list=new ArrayList<>();
+                try {
+                    while (rs.next()){
+                        PredictDataId data=new PredictDataId();
+                        data.setBattGroupId(rs.getInt("BattGroupId"));
+                        data.setTestRecordCount(rs.getInt("test_record_count"));
+                        data.setTestType(rs.getInt("test_type"));
+                        data.setDataNew(rs.getInt("data_new"));
+                        data.setDataAvailable(rs.getInt("data_available"));
+                        data.setRecordNum(rs.getInt("record_num"));
+                        data.setTestStarttime(rs.getTimestamp("test_starttime"));
+                        data.setRecordTime(rs.getTimestamp("record_time"));
+                        data.setTestTimelong(rs.getInt("test_timelong"));
+                        data.setOnlineVol(rs.getFloat("online_vol"));
+                        data.setGroupVol(rs.getFloat("group_vol"));
+                        data.setTestCurr(rs.getFloat("test_curr"));
+                        data.setTestCap(rs.getFloat("test_cap"));
+                        data.setMonNum(rs.getInt("mon_num"));
+                        data.setMonVol(rs.getFloat("mon_vol"));
+                        data.setMonTmp(rs.getFloat("mon_tmp"));
+                        list.add(data);
+                    }
+                } catch (SQLException e) {
+                    e.printStackTrace();
+                }
+                return list;
+            }
+        });
+        return list;
+    }
+    //灏嗘暟鎹彃鍏d琛�
+    public void addPredictDataId(int battGroupId, int testRecordCount2, List<PredictDataId> list2, List<PredictDataId> list1, Map<Integer,PredictDataId> mapDifference) {
+        ArrayList  sql_str=new ArrayList();
+        String tableName="db_batt_testdata."+"tb_batttestdata_"+battGroupId;
+        //鍏堟彃鍏�2
+        if(list2!=null){
+            String insertSql2="insert into "+tableName+" "
+                    + "("
+                    + "BattGroupId,"
+                    + "test_record_count,"
+                    + "test_type,"
+                    + "data_new,"
+                    + "data_available,"
+                    + "record_num,"
+                    + "test_starttime,"
+                    + "record_time,"
+                    + "test_timelong,"
+                    + "online_vol,"
+                    + "group_vol,"
+                    + "test_curr,"
+                    + "test_cap,"
+                    + "mon_num,"
+                    + "mon_vol,"
+                    + "mon_tmp"
+                    + ") "
+                    + " values ";
+            for (int i=0;i<list2.size();i++) {
+                PredictDataId data2=list2.get(i);
+                    String sql2="("
+                            +battGroupId+","
+                            + data2.getTestRecordCount()+","
+                            + data2.getTestType()+","
+                            + data2.getDataNew()+","
+                            + data2.getDataAvailable()+","
+                            + data2.getRecordNum()+1+","
+                            + "'"+ActionUtil.sdf.format(data2.getTestStarttime())+"',"
+                            + "'"+ActionUtil.sdf.format(data2.getRecordTime())+"',"
+                            + data2.getTestTimelong()+","
+                            + data2.getOnlineVol()+","
+                            + data2.getGroupVol()+","
+                            + data2.getTestCurr()+","
+                            + data2.getTestCap()+","
+                            + data2.getMonNum()+","
+                            + data2.getMonVol()+","
+                            + data2.getMonTmp()+""
+                            + ")";//濡傛灉瀵瑰簲鏄瓧绗﹀嚑涓甫涓婂崟寮曞彿
+                    insertSql2+=sql2;
+            }
+            sql_str.add(insertSql2);
+        }
+        //鍐嶆彃鍏�1
+        if(list1!=null){
+            String insertSql1="insert into "+tableName+" "
+                    + "("
+                    + "BattGroupId,"
+                    + "test_record_count,"
+                    + "test_type,"
+                    + "data_new,"
+                    + "data_available,"
+                    + "record_num,"
+                    + "test_starttime,"
+                    + "record_time,"
+                    + "test_timelong,"
+                    + "online_vol,"
+                    + "group_vol,"
+                    + "test_curr,"
+                    + "test_cap,"
+                    + "mon_num,"
+                    + "mon_vol,"
+                    + "mon_tmp"
+                    + ") "
+                    + " values ";
+            for (int i=0;i<list1.size();i++) {
+                PredictDataId data1=list1.get(i);
+                String sql1="("
+                        +battGroupId+","
+                        + data1.getTestRecordCount()+","
+                        + data1.getTestType()+","
+                        + data1.getDataNew()+","
+                        + data1.getDataAvailable()+","
+                        + data1.getRecordNum()+","
+                        + "'"+ActionUtil.sdf.format(data1.getTestStarttime())+"',"
+                        + "'"+ActionUtil.sdf.format(data1.getRecordTime())+"',"
+                        + data1.getTestTimelong()+mapDifference.get(data1.getMonNum()).getTestTimelong()+","
+                        + data1.getOnlineVol()+","
+                        + data1.getGroupVol()+","
+                        + data1.getTestCurr()+mapDifference.get(data1.getMonNum()).getTestCurr()+","
+                        + data1.getTestCap()+mapDifference.get(data1.getMonNum()).getTestCap()+","
+                        + data1.getMonNum()+","
+                        + data1.getMonVol()+mapDifference.get(data1.getMonNum()).getMonVol()+","
+                        + data1.getMonTmp()+mapDifference.get(data1.getMonNum()).getMonTmp()+""
+                        + ")";//濡傛灉瀵瑰簲鏄瓧绗﹀嚑涓甫涓婂崟寮曞彿
+                insertSql1+=sql1;
+            }
+            sql_str.add(insertSql1);
+        }
+        sqlExecuteService.makeManualCommit(sql_str);
+    }
+    //鑾峰彇褰撳墠澶╁钩鍧囪礋杞界數娴�
+    public Float getAvgLoadCurr(Integer powerId, String tableName) {
+        String sql="  select avg(load_curr) as avgCurr from "+tableName +" where DATE(record_time) = CURDATE() ";
+        List<Float> list = sqlExecuteService.executeQuery_call(sql, new CallBack() {
+            @Override
+            public List getResults(ResultSet rs) throws SQLException {
+                List list=new ArrayList<>();
+                try {
+                    while (rs.next()){
+                        list.add(rs.getFloat("avgCurr"));
+                    }
+                } catch (SQLException e) {
+                    e.printStackTrace();
+                }
+                return list;
+            }
+        });
+        float avgCurr=0f;
+        if (list!=null){
+            avgCurr=list.get(0);
+        }
+        return avgCurr;
+    }
 }

--
Gitblit v1.9.1