string sql = @" SELECT CAST(USER_ID AS NVARCHAR2(50)) USER_ID, LNG, LAT, TO_CHAR(REPORTTIME,'yyyy-mm-dd hh24:mi:ss') REPORTTIME FROM LPB_TRACEPOINT_TEMP
WHERE TRUNC(REPORTTIME) >= TO_DATE('2021-06-01','YYYY-MM-DD') AND TRUNC(REPORTTIME) <= TO_DATE('2021-06-10','YYYY-MM-DD')
AND TYPE = 'GPS'AND LNG!= 0 AND LAT!= 0 ORDER BY REPORTTIME";
List<OracleParameter> ListOp = new List<OracleParameter>();
DataTable dt = OracleHelper.Query(sql);
//List<TRACEPOINT> datas = DataTableUtil.ToList<TRACEPOINT>(dt);
var ent = dt.Rows.Cast<DataRow>();
var datas = ent.Select(t => new TRACEPOINT
{
USER_ID = t["USER_ID"] + "",
LNG = t["LNG"] + "" == "" ? 0 : Convert.ToDouble(t["LNG"] + ""),
LAT = t["LNG"] + "" == "" ? 0 : Convert.ToDouble(t["LAT"] + ""),
REPORTTIME = t["REPORTTIME"] + ""
});
Task.Run(() =>
{
for (DateTime cbt = DateTime.Parse("2021-06-01"); cbt <= DateTime.Parse("2021-06-10"); cbt = cbt.AddDays(1))
{
RedisClient redis = new RedisClient("127.0.0.1", 6379, "123456");//redis服务IP和端口
string DATE_STR = cbt.ToString("yyyyMMdd");
var itemData = datas.Where(e => Convert.ToDateTime(e.REPORTTIME).Date == cbt.Date).ToList();
redis.Set<List<TRACEPOINT>>("tracePoint" + DATE_STR, itemData);
redis.Dispose();
//Log.WriteLogAtTxt("任务1 " + DATE_STR, DateTime.Now.ToString("yyyyMMdd"));
}
});
datatable转list
最新推荐文章于 2023-09-19 14:58:22 发布