| | |
| | | import java.util.ArrayList;
|
| | | import java.util.Arrays;
|
| | |
|
| | | import com.battmonitor.sql.MysqlConnPool;
|
| | | import com.dev.fgcd.comm.FGCD_Task_Thread_SQL;
|
| | | import com.dev.fgcd.data.FGCD_TestFBOFile;
|
| | |
|
| | |
|
| | | public class FboData {
|
| | | public FboDataType m_DataType = new FboDataType();
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | |
| | | @Override
|
| | | public String toString() {
|
| | | return "FboData [m_DataType=" + m_DataType + ", CRC16=" + CRC16 + ", m_TestTime=" + m_TestTime + ", BattGroup="
|
| | | + BattGroup + ", BattSum=" + BattSum + ", OnlineVol=" + OnlineVol + ", SumVoltage=" + SumVoltage
|
| | | + ", SumCurrent=" + SumCurrent + ", SubCurrent=" + Arrays.toString(SubCurrent) + ", AllCap=" + AllCap
|
| | | + ", SubCap=" + Arrays.toString(SubCap) + ", SingleVol=" + Arrays.toString(SingleVol) + ", maxMonVol="
|
| | | + maxMonVol + ", minMonVol=" + minMonVol + "]";
|
| | | }
|
| | |
|
| | |
|
| | | public static void checkFboFile(File file, FboDataInf data_inf, ArrayList<FboData> al_fbo_data)
|
| | | {
|
| | | File f = file;
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | //按照每读取一笔数据插入数据库的方式
|
| | | public static boolean checkFboFileByOneSql(MysqlConnPool m_ConnPool,File file,FGCD_TestFBOFile fbofile)
|
| | | {
|
| | | File f = file;
|
| | | int file_sum=(int) f.length(); //需要导入文件的文件大小字节(导入数据库进度)
|
| | | int file_block=0; //当前文件导入数据的字节
|
| | | FileInputStream fis = null;
|
| | | int record_num=1;//记录每次放电的笔数
|
| | | FboDataInf data_inf = new FboDataInf();
|
| | | boolean sucess=true;
|
| | | try {
|
| | | fis = new FileInputStream(f);
|
| | | byte[] buf = new byte[256];
|
| | | if(fis.read(buf, 0, buf.length) == 256)
|
| | | {
|
| | | data_inf.setDataInf(buf);
|
| | | int max_test_record_count =FGCD_Task_Thread_SQL.quereyBattMaxTestRecordCount(m_ConnPool, fbofile.battgroupid);
|
| | | //添加inf表记录
|
| | | boolean flag=FGCD_Task_Thread_SQL.insertFBOInfIntoTable(m_ConnPool, data_inf, fbofile.battgroupid,max_test_record_count);
|
| | | while(true&&flag)
|
| | | { |
| | | FboDataType mType = new FboDataType();
|
| | | int tag = mType.checkDataHead(fis);
|
| | | if((0xFD == tag) || (0xFC == tag))
|
| | | {
|
| | | byte[] databuf = new byte[data_inf.BattSum*2 + 32];
|
| | | if(fis.read(databuf) == databuf.length)
|
| | | {
|
| | | FboData m_FboData = new FboData();
|
| | | m_FboData.m_DataType = mType;
|
| | | m_FboData.setData(databuf);
|
| | | //al_fbo_data.add(m_FboData);
|
| | | //System.err.println(m_FboData.toString());
|
| | | boolean bl=FGCD_Task_Thread_SQL.insertFBODataIntoTableByOneSql(m_ConnPool,data_inf,m_FboData,fbofile.battgroupid,record_num,max_test_record_count);
|
| | | sucess=sucess&bl;
|
| | | file_block=record_num*(data_inf.BattSum*2 + 32)+256;
|
| | | FGCD_Task_Thread_SQL.updateFBOGressByOneSql(m_ConnPool,file_sum,file_block,fbofile);//插入文件的进度
|
| | | System.err.println("总数:"+file_sum+" 导入数据:"+file_block);
|
| | | record_num++;
|
| | | }
|
| | | }
|
| | | if(tag == 1)
|
| | | break;
|
| | | }
|
| | | |
| | | }
|
| | | |
| | | } catch (IOException e) {
|
| | | e.printStackTrace();
|
| | | } finally {
|
| | | if(null != fis)
|
| | | {
|
| | | try {
|
| | | fis.close();
|
| | | } catch (IOException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | }
|
| | | return sucess;
|
| | | }
|
| | |
|
| | | public void setData(IdcData i_data)
|
| | | {
|