/// <summary> /// 查询车载历史数据 /// </summary> /// <returns></returns> private List <TbccCarAiData> GetCarHistData() { try { if (BaseServer.AddUploadStateColumn(_CarTableName, _LastUploadTime)) { FrmMain._MainForm.AppendLogText(string.Format("添加上报状态并更新成功[ProjectId={0}] [NetId={1}]", _ProjectNo, _NetId)); } List <TbccCarAiData> carHistDataList = new List <TbccCarAiData>(); //string sql = string.Format("select * from {0} where BeginTime<='{1}' order by BeginTime desc limit 1", _CarStartUpTableName, _LastUploadTime); //List<TbccCarStartUp> carStartUp = BaseServer._DBHelper.ReadEntityList<TbccCarStartUp>(sql); //if (carStartUp != null && carStartUp.Count > 0) //{ // string currentTimeWhere = string.Format(" and updateTime < '{0}' ", DateTime.Now.AddHours(2).ToString("yyyy-MM-dd HH:mm:ss")); // currentTimeWhere = string.Format(" and parentId = '{0}'", carStartUp[0].Id);//更改策略为根据启停上报,无需根据当前时间判断 // sql = string.Format("select * from {0} where updateTime > '{1}' {3} order by updateTime limit {2}", _CarTableName, _LastUploadTime, FrmMain._uploadLimit, currentTimeWhere); // carHistDataList = BaseServer._DBHelper.ReadEntityList<TbccCarAiData>(sql); // //在上位机中启停数据已处理完,并且当前进度之后无数据,表示该启停数据已经完成 // if ((carHistDataList.Count == 0 && carStartUp[0].Finished == 1)) // { // //获取下一个启停,去下一个启停中查询历史数据 // sql = string.Format("select * from {0} where id>{1} order by id limit 1", _CarStartUpTableName, carStartUp[0].Id); // carStartUp = BaseServer._DBHelper.ReadEntityList<TbccCarStartUp>(sql); // if (carStartUp != null && carStartUp.Count > 0) // { // currentTimeWhere = string.Format(" and parentId = '{0}'", carStartUp[0].Id);//更改策略为根据启停上报,无需根据当前时间判断 // sql = string.Format("select * from {0} where updateTime > '{1}' {3} order by updateTime limit {2}", _CarTableName, _LastUploadTime, FrmMain._uploadLimit, currentTimeWhere); // carHistDataList = BaseServer._DBHelper.ReadEntityList<TbccCarAiData>(sql); // } // } //} string sql = string.Format("select * from {0} where fdap4jcUploadState=0 and updateTime>'2015-12-01 00:00' and updateTime<'{2}' order by updateTime limit {1};", _CarTableName, FrmMain._uploadLimit, DateTime.Now.AddHours(2)); carHistDataList = BaseServer._DBHelper.ReadEntityList <TbccCarAiData>(sql); return(carHistDataList); } catch (Exception ex) { FrmMain._MainForm.AppendLogText(string.Format("查询车载历史数据出错[ProjectId={0}] [NetId={1}]:{2}", _ProjectNo, _NetId, ex.Message)); } return(new List <TbccCarAiData>()); }