| | |
| | | import com.mchange.v2.resourcepool.ResourcePoolListener;
|
| | |
|
| | | public class FGCD_Task_Thread_SQL {
|
| | | |
| | | |
| | | /**
|
| | | * 插入FBO历史数据
|
| | | * @param pool
|
| | |
| | | }
|
| | | return success;
|
| | | }
|
| | | |
| | | //插入FBO——inf信息
|
| | | public static boolean insertFBOInfIntoTable(MysqlConnPool pool,FboDataInf fbo,int BattGoupId,int max_test_record_count) {
|
| | | boolean flag=true;
|
| | | if(fbo.getTestTimeLong() > 0) {
|
| | | String sql_str="INSERT INTO " + Sql_Mysql.Tb_FboTestData_Inf_Table + |
| | | "(BattGroupId,test_record_count,test_starttime,test_timelong,device,test_type,hourrate,save_interval,monomervol,moncapstd,test_curr,test_cap,monvol_limit,gourpvol_limit,mon_count,monvol_limitcount,stop_type,download_time) " + |
| | | " VALUES(" + BattGoupId
|
| | | + "," +max_test_record_count
|
| | | + ",'" + Com.getDateTimeFormat(fbo.TestStartTime.getFBODateTime(), Com.DTF_YMDhms)
|
| | | + "'," + fbo.getTestTimeLong()
|
| | | + "," + fbo.Device
|
| | | + "," + fbo.DataType |
| | | + "," + fbo.HourRate
|
| | | + "," + fbo.SaveInterval
|
| | | + "," + fbo.MonomerVol
|
| | | + "," + fbo.STDCap
|
| | | + "," + fbo.TestCur |
| | | + "," + fbo.TestCap
|
| | | + "," + fbo.MVLLimit
|
| | | + "," + fbo.SumVLLimit
|
| | | + "," + fbo.BattSum
|
| | | + "," + fbo.MVLLimitCount
|
| | | + "," + fbo.StopType
|
| | | + ",'" + Com.getDateTimeFormat(new Date(), Com.DTF_YMDhms)
|
| | | + "')";
|
| | | Sql_Mysql sql = new Sql_Mysql(pool);
|
| | | ResultSet res = null;
|
| | | try {
|
| | | res = sql.sqlMysqlQuery(" SELECT * " + |
| | | " FROM " + Sql_Mysql.Tb_FboTestData_Inf_Table +
|
| | | " WHERE BattGroupId = "+BattGoupId+" AND test_starttime = '"+Com.getDateTimeFormat(fbo.TestStartTime.getFBODateTime(), Com.DTF_YMDhms)+"'");
|
| | | if(!res.next()) {
|
| | | //如果不存在则添加inf表记录
|
| | | sql.sqlMysqlExecute(sql_str);
|
| | | }else {
|
| | | //System.out.println("已存在当前测试数据");
|
| | | flag=false;
|
| | | }
|
| | | } catch (SQLException e) {
|
| | | e.printStackTrace();
|
| | | } finally {
|
| | | if(null != res) {
|
| | | try {
|
| | | res.close();
|
| | | } catch (SQLException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | sql.close_con();
|
| | | }
|
| | | }
|
| | | return flag; |
| | | } |
| | | |
| | | //插入FBO历史数据
|
| | | public static boolean insertFBODataIntoTableByOneSql(MysqlConnPool pool,FboDataInf fbo,FboData data,int BattGoupId,int record_num,int max_test_record_count) {
|
| | | boolean success = false;
|
| | | if(fbo.getTestTimeLong() > 0) {
|
| | | createTb_FboTestData_Table(pool, BattGoupId);
|
| | | ArrayList<String> sql_strs = new ArrayList<>();
|
| | | String sql_str = "INSERT INTO "+Sql_Mysql.Tb_FboTestData_Table+BattGoupId+"(BattGroupId,test_record_count,test_starttime,test_timelong,record_time,record_num,online_vol,sum_vol,test_curr,test_cap,mon_num,mon_vol) " + |
| | | " VALUES";
|
| | | Date record_time = new Date(fbo.TestStartTime.getFBODateTime().getTime()+data.m_TestTime.getTestTimeLong()*1000);
|
| | | if(data.BattSum > 0) {
|
| | | //有单体时
|
| | | for(int k=0;k<data.BattSum && k<data.SingleVol.length;k++) {
|
| | | sql_strs.add(sql_str + "("
|
| | | + "" + BattGoupId
|
| | | + "," + max_test_record_count
|
| | | + ",'" + Com.getDateTimeFormat(fbo.TestStartTime.getFBODateTime(), Com.DTF_YMDhms)
|
| | | + "'," + data.m_TestTime.getTestTimeLong()
|
| | | + ",'" + Com.getDateTimeFormat(record_time, Com.DTF_YMDhms)
|
| | | + "'," + record_num
|
| | | + "," + data.OnlineVol
|
| | | + "," + data.SumVoltage
|
| | | + "," + data.SumCurrent
|
| | | + "," + data.AllCap
|
| | | + "," + (k+1)
|
| | | + "," + data.SingleVol[k]
|
| | | + ")");
|
| | | } |
| | | }else { |
| | | //没有单体数据时
|
| | | sql_strs.add(sql_str + "("
|
| | | + "" + BattGoupId
|
| | | + "," + max_test_record_count
|
| | | + ",'" + Com.getDateTimeFormat(fbo.TestStartTime.getFBODateTime(), Com.DTF_YMDhms)
|
| | | + "'," + data.m_TestTime.getTestTimeLong()
|
| | | + ",'" + Com.getDateTimeFormat(record_time, Com.DTF_YMDhms)
|
| | | + "'," +record_num
|
| | | + "," + data.OnlineVol
|
| | | + "," + data.SumVoltage
|
| | | + "," + data.SumCurrent
|
| | | + "," + data.AllCap
|
| | | + "," + 0
|
| | | + "," + 0
|
| | | + ")");
|
| | | }
|
| | | Sql_Mysql sql = new Sql_Mysql(pool);
|
| | | success = sql.makeManualCommit(sql_strs);
|
| | | sql.close_con();
|
| | | } |
| | | return success;
|
| | | } |
| | |
|
| | | /**
|
| | | * 创建FBO历史数据_ID表
|
| | |
| | | return (test_record_count+1);
|
| | | }
|
| | |
|
| | |
|
| | | //文件导入进度修改
|
| | | public static void updateFBOGressByOneSql(MysqlConnPool pool,int file_sum,int file_block,FGCD_TestFBOFile fbofile) {
|
| | | String sql_str = " update " + Sql_Mysql.Tb_Fgcd_Filedownload_Table +
|
| | | " set now_data_block1="+file_block+",total_data_block1="+file_sum+" WHERE BattGroupId = " + fbofile.battgroupid+" and dev_id="+fbofile.dev_id;
|
| | | Sql_Mysql sql = new Sql_Mysql(pool);
|
| | | try {
|
| | | sql.sqlMysqlExecute(sql_str);
|
| | | } catch (SQLException e) {
|
| | | e.printStackTrace();
|
| | | } finally {
|
| | | sql.close_con();
|
| | | }
|
| | | }
|
| | |
|
| | | public static void updateFBOFIleExportFlag(MysqlConnPool pool, FGCD_TestFBOFile fbofile) {
|
| | | String sql_str = " Update " + Sql_Mysql.Tb_Fgcd_Filedownload_Table +
|