|
|
@@ -20,21 +20,32 @@ namespace BPA.MES.Base.Application.Services.KepServerDataService.Services |
|
|
|
} |
|
|
|
[HttpPost] |
|
|
|
[AllowAnonymous] |
|
|
|
public async Task<Dictionary<string, object>> GetList() |
|
|
|
public async Task<List<object>> GetList() |
|
|
|
{ |
|
|
|
var data =await KepDb.Queryable<ch1_device1>().Where(x=> SqlFunc.DateIsSame(x._TIMESTAMP, DateTime.Now)).Take(1000).ToListAsync(); |
|
|
|
var dicdatass = KepDb.Queryable<ch1_device1>().GroupBy(x => x._NAME).Where(x => SqlFunc.DateIsSame(x._TIMESTAMP, DateTime.Now)).Select(x => x._NAME).ToArray(); |
|
|
|
//to_days(now()) - to_days(o._TIMESTAMP) = 1 |
|
|
|
// to_days(o._TIMESTAMP) = to_days(now()) |
|
|
|
var list = KepDb.Queryable<object>().AS("ch01_device1", "o").Where(" to_days(o._TIMESTAMP) = to_days(now())").ToList(); |
|
|
|
//var data =await KepDb.Queryable<ch1_device1>().Where(x=> SqlFunc.DateIsSame(x._TIMESTAMP, DateTime.Now)).Take(1000).ToListAsync(); |
|
|
|
//var dicdatass = KepDb.Queryable<ch1_device1>().GroupBy(x => x._NAME).Where(x => SqlFunc.DateIsSame(x._TIMESTAMP, DateTime.Now)).Select(x => x._NAME).ToArray(); |
|
|
|
//var dicdata = KepDb.Queryable<ch1_device1>().GroupBy(x => x._NAME).Where(x => SqlFunc.DateIsSame(x._TIMESTAMP, DateTime.Now)).Select(x=>x._NAME).ToDictionary(); |
|
|
|
Dictionary<string, object> dic = new Dictionary<string, object>(); |
|
|
|
DataTable table = new DataTable(); |
|
|
|
foreach (var item in dicdatass) |
|
|
|
{ |
|
|
|
var key = item.ToString(); |
|
|
|
var values = data.Where(x => x._NAME == key).Select(x=>x._VALUE).ToList(); |
|
|
|
dic.Add(key, values); |
|
|
|
} |
|
|
|
var JsonString = JsonConvert.SerializeObject(dic); |
|
|
|
return dic; |
|
|
|
//DataTable table = new DataTable(); |
|
|
|
//foreach (var item in dicdatass) |
|
|
|
//{ |
|
|
|
// var key = item.ToString(); |
|
|
|
// var values = data.Where(x => x._NAME == key).Select(x=>x._VALUE).ToList(); |
|
|
|
// dic.Add(key, values); |
|
|
|
//} |
|
|
|
//var JsonString = JsonConvert.SerializeObject(dic); |
|
|
|
return list; |
|
|
|
} |
|
|
|
[HttpGet] |
|
|
|
[AllowAnonymous] |
|
|
|
public async Task<bool> DeleteKep() |
|
|
|
{ |
|
|
|
var sql = "delete from ch01_device1 where 1=1 order by id limit 1000;"; |
|
|
|
var list = KepDb.Ado.ExecuteCommand(sql); |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
} |