|
@@ -1183,22 +1183,53 @@ namespace TEAMModelBI.Controllers.BITest
|
|
|
[HttpPost("get-linqcount")]
|
|
|
public async Task<IActionResult> GetLinqCount()
|
|
|
{
|
|
|
- List<Test> list1 = new();
|
|
|
- list1.Add(new Test { score = 10, name = "001" });
|
|
|
- list1.Add(new Test { score = 20, name = "002" });
|
|
|
- list1.Add(new Test { score = 30, name = "003" });
|
|
|
- list1.Add(new Test { score = 40, name = "004" });
|
|
|
- list1.Add(new Test { score = 50, name = "005" });
|
|
|
- list1.Add(new Test { score = 60, name = "006" });
|
|
|
-
|
|
|
- List<Test> list2 = new();
|
|
|
- list2.Add(new Test { score = 40, name = "004" });
|
|
|
- list2.Add(new Test { score = 50, name = "005" });
|
|
|
- list2.Add(new Test { score = 60, name = "006" });
|
|
|
- list2.Add(new Test { score = 70, name = "007" });
|
|
|
- list2.Add(new Test { score = 80, name = "008" });
|
|
|
- list2.Add(new Test { score = 90, name = "009" });
|
|
|
- list2.Add(new Test { score = 100, name = "010" });
|
|
|
+
|
|
|
+ List<linqTest> linqTests = new()
|
|
|
+ {
|
|
|
+ new linqTest { id = "10110",aresid = "0",name ="明",linq1 = new linq1 { id ="abc0", times = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),cnt=10 } } ,
|
|
|
+ new linqTest { id = "10111",aresid = "1",name ="明1",linq1 = new linq1 { id ="abc1", times = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),cnt=10 } } ,
|
|
|
+ new linqTest { id = "10112",aresid = "2",name ="明2",linq1 = new linq1 { id ="abc2", times = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),cnt=10 } } ,
|
|
|
+ new linqTest { id = "10113",aresid = "3",name ="明3",linq1 = new linq1 { id ="abc3", times = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),cnt=10 } } ,
|
|
|
+ new linqTest { id = "10114",aresid = "4",name ="明4",linq1 = new linq1 { id ="abc4", times = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),cnt=10 } },
|
|
|
+ new linqTest { id = "10115",aresid = "5",name ="明5",linq1 = new linq1 { id ="abc5", times = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),cnt=10 } } ,
|
|
|
+ new linqTest { id = "10116",aresid = "6",name ="明6",linq1 = new linq1 { id ="abc6", times = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),cnt=10 } },
|
|
|
+ new linqTest { id = "10117",aresid = "7",name ="明7",linq1 = new linq1 { id ="abc7", times = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),cnt=10 } },
|
|
|
+ new linqTest { id = "10118",aresid = "8",name ="明8",linq1 = new linq1 { id ="abc8", times = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),cnt=10 } },
|
|
|
+ new linqTest { id = "10119",aresid = "9",name ="明9",linq1 = new linq1 { id ="abc9", times = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),cnt=10 } },
|
|
|
+ new linqTest { id = "10120",aresid = "10",name ="明10",linq1 = new linq1 { id ="abc10", times = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),cnt=10 } }
|
|
|
+ };
|
|
|
+ for (int i = 0; i < 11; i++)
|
|
|
+ {
|
|
|
+ linqTest linqt = new() { id = $"qwe{i}", aresid = $"{i}", name = $"名字{i}", linq1 = new linq1 { id = $"abc{i}", times = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(), cnt = (11 + i) } };
|
|
|
+ linqTests.Add(linqt);
|
|
|
+ }
|
|
|
+
|
|
|
+ var grup = linqTests.GroupBy(g => g.aresid).ToList();
|
|
|
+
|
|
|
+ var grup1 = linqTests.GroupBy(g => g.aresid).Select(s=>new { areid= s.Key,linq1Id = s.Select(sn => sn.linq1.id).ToList(), id = s.Select(sn => sn.id).ToList(), name = s.Select(sn => sn.name).ToList(), linq1Cnt = s.Select(sn => sn.linq1.cnt).ToList(), lescnt = s.Select(sf=>sf.linq1.cnt).Sum()}).ToList();
|
|
|
+
|
|
|
+ return Ok(new { state = RespondCode.Ok, grup1, grup });
|
|
|
+
|
|
|
+ List<Test> list1 = new()
|
|
|
+ {
|
|
|
+ new Test { score = 10, name = "001" },
|
|
|
+ new Test { score = 20, name = "002" },
|
|
|
+ new Test { score = 30, name = "003" },
|
|
|
+ new Test { score = 40, name = "004" },
|
|
|
+ new Test { score = 50, name = "005" },
|
|
|
+ new Test { score = 60, name = "006" }
|
|
|
+ };
|
|
|
+
|
|
|
+ List<Test> list2 = new()
|
|
|
+ {
|
|
|
+ new Test { score = 40, name = "004" },
|
|
|
+ new Test { score = 50, name = "005" },
|
|
|
+ new Test { score = 60, name = "006" },
|
|
|
+ new Test { score = 70, name = "007" },
|
|
|
+ new Test { score = 80, name = "008" },
|
|
|
+ new Test { score = 90, name = "009" },
|
|
|
+ new Test { score = 100, name = "010" }
|
|
|
+ };
|
|
|
|
|
|
//list3 return 2
|
|
|
List<Test> list3 = list1.Where(x => !list2.Any(x2 => x.score == x2.score && x.name == x2.name)).ToList();
|
|
@@ -1239,20 +1270,14 @@ namespace TEAMModelBI.Controllers.BITest
|
|
|
var (lastWeekStart, lastWeekEnd) = TimeHelper.GetStartOrEnd(DateTimeOffset.UtcNow, "lastweek");
|
|
|
|
|
|
|
|
|
- List<linqTest> linqTests = new();
|
|
|
- for (int i = 0; i < 10; i++)
|
|
|
- {
|
|
|
- linqTest linqt = new() { id = $"qwe{i}", name = $"名字{i}", linq1s = new List<linq1> { new linq1 { id = $"abc{i}", times = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() }, new linq1 { id = $"def{i}", times = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() } } };
|
|
|
- linqTests.Add(linqt);
|
|
|
- }
|
|
|
|
|
|
//var set = linqTests.Select((x, y) => x.linq1s.Find(l => l.id.Equals($"abc0"))).ToList();
|
|
|
- var set = linqTests.Where(x => !string.IsNullOrEmpty(x.linq1s.Find(l => l.id.Equals($"abc0")).ToString()));
|
|
|
+ //var set = linqTests.Where(x => !string.IsNullOrEmpty(x.linq1s.Find(l => l.id.Equals($"abc0")).ToString()));
|
|
|
//var tem220p = linqTests.ForEach(x => {
|
|
|
// var coreUser = linqTests.Find(c => c.id.Equals("abc0"));
|
|
|
// }); //.Except(linqTests.Select(y => y.linq1s.Find(n => n.times.Equals("abc0"))));
|
|
|
|
|
|
- return Ok(new { state = 200, Mon, Sun, ss, sss, ssss, sssss, lastWeekStart, lastWeekEnd, have, en2, bingji, cha, jiaoji, chaji, list3, list4, temp, list1, linqTests, set });
|
|
|
+ return Ok(new { state = 200, Mon, Sun, ss, sss, ssss, sssss, lastWeekStart, lastWeekEnd, have, en2, bingji, cha, jiaoji, chaji, list3, list4, temp, list1, linqTests });
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -2141,17 +2166,20 @@ namespace TEAMModelBI.Controllers.BITest
|
|
|
return Ok(new { state = 200, statsInfo });
|
|
|
}
|
|
|
|
|
|
+
|
|
|
public class linqTest
|
|
|
{
|
|
|
public string id { get; set; }
|
|
|
+ public string aresid { get; set; }
|
|
|
public string name { get; set; }
|
|
|
- public List<linq1> linq1s { get; set; }
|
|
|
+ public linq1 linq1 { get; set; }
|
|
|
}
|
|
|
|
|
|
public class linq1
|
|
|
{
|
|
|
public string id { get; set; }
|
|
|
public long times { get; set; }
|
|
|
+ public int cnt { get; set; }
|
|
|
}
|
|
|
|
|
|
public class Test
|