ProductStatisController.cs 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508
  1. using Azure.Cosmos;
  2. using Microsoft.AspNetCore.Http;
  3. using Microsoft.AspNetCore.Mvc;
  4. using Microsoft.Extensions.Options;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Linq;
  8. using System.Text.Json;
  9. using System.Threading.Tasks;
  10. using TEAMModelBI.Tool;
  11. using TEAMModelOS.Models;
  12. using TEAMModelOS.SDK.DI;
  13. using TEAMModelOS.SDK.Extension;
  14. using TEAMModelOS.SDK.Models;
  15. namespace TEAMModelBI.Controllers.Census
  16. {
  17. [Route("product")]
  18. [ApiController]
  19. public class ProductStatisController : ControllerBase
  20. {
  21. //数据容器
  22. private readonly AzureCosmosFactory _azureCosmos;
  23. //钉钉提示信息
  24. private readonly DingDing _dingDing;
  25. private readonly Option _option;
  26. /// <summary>
  27. /// 软体产品
  28. /// </summary>
  29. private readonly Dictionary<string, string> _serials = new() { { "3222NIYD", "ezStation 2" }, { "J223IZ6M", "HiTeach STD" }, { "3222C6D2", "HiTeach TBL" }, { "J223IZAM", "HiTeach PRO" }, { "J2236ZCX", "HiTeach Lite" }, { "3222DNG2", "HiTeach Mobile" }, { "3222IAVN", "HiTeach Premium" }, { "BYJ6LZ6Z", "HiTeach5" } };
  30. /// <summary>
  31. /// 服务产品
  32. /// </summary>
  33. private readonly Dictionary<string, string> _services = new() { { "YMPCVCIM", "学情分析模组" }, { "IPDYZYLC", "智慧学校管理服务" }, { "3CLYJ6NP", "AClass ONE智慧学伴" }, { "IPALJ6NY", "数据储存服务空间" }, { "VABAJ6NV", "卷卡合一阅卷系统" } };
  34. public ProductStatisController(AzureCosmosFactory azureCosmos, DingDing dingDing, IOptionsSnapshot<Option> option)
  35. {
  36. _azureCosmos = azureCosmos;
  37. _dingDing = dingDing;
  38. _option = option?.Value;
  39. }
  40. /// <summary>
  41. /// 统计模组数量
  42. /// </summary>
  43. /// <returns></returns>
  44. [ProducesDefaultResponseType]
  45. [HttpPost("get-allcount")]
  46. public async Task<IActionResult> GetProductSum()
  47. {
  48. var cosmosClient = _azureCosmos.GetCosmosClient();
  49. List<ProductStatis> productStatis = new List<ProductStatis>();
  50. await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: $"SELECT c.serial,c.service FROM c",requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("ProductSum") }))
  51. {
  52. using var json = await JsonDocument.ParseAsync(item.ContentStream);
  53. if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
  54. {
  55. foreach (var itemCount in json.RootElement.GetProperty("Documents").EnumerateArray())
  56. {
  57. ////所有的产品
  58. //List<SchoolProductSumProdInfo> prodInfo = itemCount.GetProperty("prodinfo").ToObject<List<SchoolProductSumProdInfo>>();
  59. //foreach (var tempProdInfo in prodInfo)
  60. //{
  61. // ProductStatis tempPerod = productStatis.Find(x => x.prodCode.Equals(tempProdInfo.prodCode));
  62. // if (!string.IsNullOrEmpty($"{tempPerod}"))
  63. // {
  64. // tempPerod.Count += 1;
  65. // }
  66. // else
  67. // {
  68. // ProductStatis tempProd = new ProductStatis()
  69. // {
  70. // prodCode = tempProdInfo.prodCode,
  71. // prodName = tempProdInfo.prodName,
  72. // //dataType = tempProdInfo.dataType,
  73. // Count = 1,
  74. // };
  75. // productStatis.Add(tempProd);
  76. // }
  77. //}
  78. //软体产品
  79. List<SchoolProductSumData> tempSerials = itemCount.GetProperty("serial").ToObject<List<SchoolProductSumData>>();
  80. foreach (var serial in tempSerials)
  81. {
  82. ProductStatis tempPerod = productStatis.Find(x => x.prodCode.Equals(serial.prodCode));
  83. if (!string.IsNullOrEmpty($"{tempPerod}"))
  84. {
  85. tempPerod.Count += 1;
  86. }
  87. else
  88. {
  89. ProductStatis tempProd = new ProductStatis()
  90. {
  91. prodCode = serial.prodCode,
  92. prodName = _serials[serial.prodCode],
  93. //dataType = "",
  94. Count = 1,
  95. };
  96. productStatis.Add(tempProd);
  97. }
  98. }
  99. //服务产品
  100. List<SchoolProductSumData> service = itemCount.GetProperty("service").ToObject<List<SchoolProductSumData>>();
  101. foreach (var ser in service)
  102. {
  103. ProductStatis tempPerod = productStatis.Find(x => x.prodCode.Equals(ser.prodCode));
  104. if (!string.IsNullOrEmpty($"{tempPerod}"))
  105. {
  106. tempPerod.Count += 1;
  107. }
  108. else
  109. {
  110. ProductStatis tempProd = new ProductStatis()
  111. {
  112. prodCode = ser.prodCode,
  113. prodName = _services[ser.prodCode],
  114. //dataType = "",
  115. Count = 1,
  116. };
  117. productStatis.Add(tempProd);
  118. }
  119. }
  120. }
  121. }
  122. //if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
  123. //{
  124. // var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
  125. // while (accounts.MoveNext())
  126. // {
  127. // JsonElement account = accounts.Current;
  128. // List<SchoolProductSumProdInfo> prodInfo = account.GetProperty("prodinfo").ToObject<List<SchoolProductSumProdInfo>>();
  129. // foreach (var tempProdInfo in prodInfo)
  130. // {
  131. // ProductStatis tempPerod = productStatis.Find(x => x.prodName.Equals(tempProdInfo.prodName));
  132. // if (!string.IsNullOrEmpty($"{tempPerod}"))
  133. // {
  134. // tempPerod.Count += 1;
  135. // }
  136. // else
  137. // {
  138. // ProductStatis tempProd = new ProductStatis()
  139. // {
  140. // prodCode = tempProdInfo.prodCode,
  141. // prodName = tempProdInfo.prodName,
  142. // dataType = tempProdInfo.dataType,
  143. // Count = 1,
  144. // };
  145. // productStatis.Add(tempProd);
  146. // }
  147. // }
  148. // }
  149. //}
  150. }
  151. return Ok(new { state = 200, productStatis });
  152. }
  153. /// <summary>
  154. /// 单个学校的模组
  155. /// </summary>
  156. /// <param name="jsonElement"></param>
  157. /// <returns></returns>
  158. [HttpPost("get-assistschool")]
  159. public async Task<IActionResult> GetAssistSchoolId(JsonElement jsonElement)
  160. {
  161. if (!jsonElement.TryGetProperty("tmdId", out JsonElement tmdId)) return BadRequest();
  162. var cosmosClient = _azureCosmos.GetCosmosClient();
  163. List<string> schoolIds = await CommonFind.FindSchoolIds(cosmosClient, $"{tmdId}");
  164. List<SchoolProduct> schoolProducts = new List<SchoolProduct>();
  165. foreach (var scid in schoolIds)
  166. {
  167. School school = new();
  168. var response = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync(scid, new PartitionKey("Base"));
  169. if (response.Status == 200)
  170. {
  171. using var json = await JsonDocument.ParseAsync(response.ContentStream);
  172. school = json.ToObject<School>();
  173. }
  174. SchoolProduct sProduct = new SchoolProduct() { id = scid, name = school != null ? school.name : scid };
  175. List<ProductStatis> productStatis = new();
  176. await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: $"SELECT c.serial,c.service FROM c where c.id='{scid}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("ProductSum") }))
  177. {
  178. using var json = await JsonDocument.ParseAsync(item.ContentStream);
  179. foreach (var itemCount in json.RootElement.GetProperty("Documents").EnumerateArray())
  180. {
  181. ////所有的产品信息
  182. //List<SchoolProductSumProdInfo> prodInfo = itemCount.GetProperty("prodinfo").ToObject<List<SchoolProductSumProdInfo>>();
  183. //foreach (var tempProdInfo in prodInfo)
  184. //{
  185. // ProductStatis tempPerod = productStatis.Find(x => x.prodCode.Equals(tempProdInfo.prodCode));
  186. // if (!string.IsNullOrEmpty($"{tempPerod}"))
  187. // {
  188. // tempPerod.Count += 1;
  189. // }
  190. // else
  191. // {
  192. // ProductStatis tempProd = new ProductStatis()
  193. // {
  194. // prodCode = tempProdInfo.prodCode,
  195. // prodName = tempProdInfo.prodName,
  196. // //dataType = tempProdInfo.dataType,
  197. // Count = 1,
  198. // };
  199. // productStatis.Add(tempProd);
  200. // }
  201. //}
  202. //软体产品
  203. List<SchoolProductSumData> tempSerials = itemCount.GetProperty("serial").ToObject<List<SchoolProductSumData>>();
  204. foreach (var serial in tempSerials)
  205. {
  206. ProductStatis tempPerod = productStatis.Find(x => x.prodCode.Equals(serial.prodCode));
  207. if (!string.IsNullOrEmpty($"{tempPerod}"))
  208. {
  209. tempPerod.Count += 1;
  210. }
  211. else
  212. {
  213. ProductStatis tempProd = new ProductStatis()
  214. {
  215. prodCode = serial.prodCode,
  216. prodName = _serials[serial.prodCode],
  217. //dataType = "",
  218. Count = 1,
  219. };
  220. productStatis.Add(tempProd);
  221. }
  222. }
  223. //服务产品
  224. List<SchoolProductSumData> service = itemCount.GetProperty("service").ToObject<List<SchoolProductSumData>>();
  225. foreach (var ser in service)
  226. {
  227. ProductStatis tempPerod = productStatis.Find(x => x.prodCode.Equals(ser.prodCode));
  228. if (!string.IsNullOrEmpty($"{tempPerod}"))
  229. {
  230. tempPerod.Count += 1;
  231. }
  232. else
  233. {
  234. ProductStatis tempProd = new ProductStatis()
  235. {
  236. prodCode = ser.prodCode,
  237. prodName = _services[ser.prodCode],
  238. //dataType = "",
  239. Count = 1,
  240. };
  241. productStatis.Add(tempProd);
  242. }
  243. }
  244. }
  245. }
  246. sProduct.product = productStatis;
  247. schoolProducts.Add(sProduct);
  248. }
  249. return Ok(new { state = 200, schoolProducts }) ;
  250. }
  251. /// <summary>
  252. /// 所有模组统计
  253. /// </summary>
  254. /// <returns></returns>
  255. [HttpPost("get-moduleanalys")]
  256. public async Task<IActionResult> GetModuleAnalys(JsonElement jsonElement)
  257. {
  258. jsonElement.TryGetProperty("tmdId", out JsonElement tmdId);
  259. var cosmosClient = _azureCosmos.GetCosmosClient();
  260. long buyServiceCount = 0; //所有购买服务数量
  261. long buySerialsCount = 0; //所有购买软体数量
  262. long lastYearServiceCount = 0; //去年购买服务数量
  263. long yearServiceCount = 0; //今年购买服务数量
  264. long lastYearSerialsCount = 0; //去年购买软体数量
  265. long yearSerialsCount = 0; //今年购买软体数量
  266. var (lastYearStart, lastYearEnd) = TimeHelper.GetStartOrEnd(DateTimeOffset.Parse($"{DateTimeOffset.UtcNow.Year - 1}-1-1"), "year", false); //计算去年开始/结束时间
  267. var (yearStart, yearEnd) = TimeHelper.GetStartOrEnd(DateTimeOffset.UtcNow, "year", false); //计算今年开始/结束时间
  268. if (!string.IsNullOrEmpty($"{tmdId}"))
  269. {
  270. List<RecSchoolAnalys> schoolAnalys = new();
  271. List<string> schoolIds = await CommonFind.FindSchoolIds(cosmosClient, $"{tmdId}");
  272. foreach (var scId in schoolIds)
  273. {
  274. //软体产品
  275. List<SchoolProductSumData> Serials = new();
  276. //软体产品
  277. List<SchoolProductSumData> Services = new();
  278. School school = new();
  279. var response = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync(scId, new PartitionKey("Base"));
  280. if (response.Status == 200)
  281. {
  282. using var json = await JsonDocument.ParseAsync(response.ContentStream);
  283. school = json.ToObject<School>();
  284. }
  285. await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: $"SELECT c.serial,c.service FROM c where c.id='{scId}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("ProductSum") }))
  286. {
  287. using var json = await JsonDocument.ParseAsync(item.ContentStream);
  288. foreach (var itemCount in json.RootElement.GetProperty("Documents").EnumerateArray())
  289. {
  290. //软体产品
  291. Serials.AddRange(itemCount.GetProperty("serial").ToObject<List<SchoolProductSumData>>().Where(x => x.avaliable > 0).ToList());
  292. //服务产品
  293. Services.AddRange(itemCount.GetProperty("service").ToObject<List<SchoolProductSumData>>().Where(x => x.avaliable > 0).ToList());
  294. }
  295. }
  296. long tempBuySerc = await CommonFind.FindTotals(cosmosClient, "select count(c.id) as totals from c where c.dataType='service' and c.pk='Product'", "School", $"Product-{scId}");
  297. long tempBuySeri = await CommonFind.FindTotals(cosmosClient, "select count(c.id) as totals from c where c.dataType='serial' and c.pk='Product'", "School", $"Product-{scId}");
  298. string sqlTxt = "select count(c.id) as totals from c where c.pk='Product' and c.dataType='{0}' and c.regDate>={1} and c.regDate<={2}";
  299. long tempLastYearSerc = await CommonFind.FindTotals(cosmosClient, string.Format(sqlTxt, "service", lastYearStart, lastYearEnd), "School", $"Product-{scId}"); //计算去年购买的服务数量
  300. long tempyearSerc = await CommonFind.FindTotals(cosmosClient, string.Format(sqlTxt, "service", yearStart, yearEnd), "School", $"Product-{scId}"); //今年购买的服务数量
  301. long tempLastYearSeri = await CommonFind.FindTotals(cosmosClient, string.Format(sqlTxt, "serial", lastYearStart, lastYearEnd), "School", $"Product-{scId}"); //计算去年购买的软体数量
  302. long tempYearSeri = await CommonFind.FindTotals(cosmosClient, string.Format(sqlTxt, "serial", yearStart, yearEnd), "School", $"Product-{scId}"); //今年购买的软体数量
  303. schoolAnalys.Add(new RecSchoolAnalys { id = school.id, name = school.name, picture = school.picture, size = school.size, scale = school.scale, buySerc = tempBuySerc, lastYearSerc = tempLastYearSerc, yearSerc = tempyearSerc, buySeri = tempBuySeri, lastYearSeri = tempLastYearSeri, yearSeri = tempYearSeri });
  304. lastYearServiceCount += tempLastYearSerc;
  305. yearServiceCount += tempyearSerc;
  306. buyServiceCount += tempBuySerc;
  307. lastYearSerialsCount += tempLastYearSeri;
  308. yearSerialsCount += tempYearSeri;
  309. buySerialsCount += tempBuySeri;
  310. }
  311. return Ok(new { state = 200, buyServiceCount, buySerialsCount, lastYearServiceCount, yearServiceCount, lastYearSerialsCount, yearSerialsCount, schoolAnalys });
  312. }
  313. else
  314. {
  315. //软体产品
  316. List<SchoolProductSumData> Serials = new();
  317. //软体产品
  318. List<SchoolProductSumData> Services = new();
  319. await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: $"SELECT c.serial,c.service FROM c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("ProductSum") }))
  320. {
  321. using var json = await JsonDocument.ParseAsync(item.ContentStream);
  322. foreach (var itemCount in json.RootElement.GetProperty("Documents").EnumerateArray())
  323. {
  324. //软体产品
  325. Serials.AddRange(itemCount.GetProperty("serial").ToObject<List<SchoolProductSumData>>().Where(x => x.avaliable > 0).ToList());
  326. //服务产品
  327. Services.AddRange(itemCount.GetProperty("service").ToObject<List<SchoolProductSumData>>().Where(x => x.avaliable > 0).ToList());
  328. }
  329. }
  330. var serialsCout = Serials.GroupBy(kv => new { kv.prodCode }).Select(y => new { key = y.Key.prodCode, value = y.Count() }).ToList();
  331. var servicesCout = Services.GroupBy(kv => new { kv.prodCode }).Select(y => new { key = y.Key.prodCode, value = y.Count() }).ToList();
  332. List<string> containers = new List<string>() { "School" };
  333. buyServiceCount = await CommonFind.FindTotals(cosmosClient, "select count(c.id) as totals from c where c.dataType='service' and c.pk='Product'", containers);
  334. buySerialsCount = await CommonFind.FindTotals(cosmosClient, "select count(c.id) as totals from c where c.dataType='serial' and c.pk='Product'", containers);
  335. string sqlTxt = "select count(c.id) as totals from c where c.pk='Product' and c.dataType='{0}' and c.regDate>={1} and c.regDate<={2}";
  336. lastYearServiceCount = await CommonFind.FindTotals(cosmosClient, string.Format(sqlTxt, "service", lastYearStart, lastYearEnd), containers); //计算去年购买的服务数量
  337. yearServiceCount = await CommonFind.FindTotals(cosmosClient, string.Format(sqlTxt, "service", yearStart, yearEnd), containers); //今年购买的服务数量
  338. lastYearSerialsCount = await CommonFind.FindTotals(cosmosClient, string.Format(sqlTxt, "serial", lastYearStart, lastYearEnd), containers); //计算去年购买的软体数量
  339. yearSerialsCount = await CommonFind.FindTotals(cosmosClient, string.Format(sqlTxt, "serial", yearStart, yearEnd), containers); //今年购买的软体数量
  340. return Ok(new { state = 200, buyServiceCount, buySerialsCount, lastYearServiceCount, yearServiceCount, lastYearSerialsCount, yearSerialsCount, serialsCout, servicesCout });
  341. }
  342. }
  343. /// <summary>
  344. /// 顾问关联的学校模组
  345. /// </summary>
  346. /// <param name="jsonElement"></param>
  347. /// <returns></returns>
  348. [HttpPost("get-adviserschool")]
  349. public async Task<IActionResult> GetAdviserSchool(JsonElement jsonElement)
  350. {
  351. if (!jsonElement.TryGetProperty("tmdId", out JsonElement tmdId)) return BadRequest();
  352. long buyServiceCount = 0; //购买服务数量
  353. long buySerialsCount = 0; //购买软体数量
  354. long lastYearServiceCount = 0; //去年购买服务数量
  355. long yearServiceCount = 0; //今年购买服务数量
  356. long lastYearSerialsCount = 0; //去年购买软体数量
  357. long yearSerialsCount = 0; //今年购买软体数量
  358. List<RecSchoolAnalys> schoolAnalys = new();
  359. var (lastYearStart, lastYearEnd) = TimeHelper.GetStartOrEnd(DateTimeOffset.Parse($"{DateTimeOffset.UtcNow.Year - 1}-1-1"), "year", false); //计算去年开始/结束时间
  360. var (yearStart, yearEnd) = TimeHelper.GetStartOrEnd(DateTimeOffset.UtcNow, "year", false); //计算今年开始/结束时间
  361. var cosmosClient = _azureCosmos.GetCosmosClient();
  362. List<string> schoolIds = await CommonFind.FindSchoolIds(cosmosClient, $"{tmdId}");
  363. foreach (var scId in schoolIds)
  364. {
  365. //软体产品
  366. List<SchoolProductSumData> Serials = new();
  367. //软体产品
  368. List<SchoolProductSumData> Services = new();
  369. School school = new();
  370. var response = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync(scId, new PartitionKey("Base"));
  371. if (response.Status == 200)
  372. {
  373. using var json = await JsonDocument.ParseAsync(response.ContentStream);
  374. school = json.ToObject<School>();
  375. }
  376. await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: $"SELECT c.serial,c.service FROM c where c.id='{scId}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("ProductSum") }))
  377. {
  378. using var json = await JsonDocument.ParseAsync(item.ContentStream);
  379. foreach (var itemCount in json.RootElement.GetProperty("Documents").EnumerateArray())
  380. {
  381. //软体产品
  382. Serials.AddRange(itemCount.GetProperty("serial").ToObject<List<SchoolProductSumData>>().Where(x => x.avaliable > 0).ToList());
  383. //服务产品
  384. Services.AddRange(itemCount.GetProperty("service").ToObject<List<SchoolProductSumData>>().Where(x => x.avaliable > 0).ToList());
  385. }
  386. }
  387. long tempBuySerc = await CommonFind.FindTotals(cosmosClient, "select count(c.id) as totals from c where c.dataType='service' and c.pk='Product'", "School", $"Product-{scId}");
  388. long tempBuySeri = await CommonFind.FindTotals(cosmosClient, "select count(c.id) as totals from c where c.dataType='serial' and c.pk='Product'", "School", $"Product-{scId}");
  389. string sqlTxt = "select count(c.id) as totals from c where c.pk='Product' and c.dataType='{0}' and c.regDate>={1} and c.regDate<={2}";
  390. long tempLastYearSerc = await CommonFind.FindTotals(cosmosClient, string.Format(sqlTxt, "service", lastYearStart, lastYearEnd), "School", $"Product-{scId}"); //计算去年购买的服务数量
  391. long tempyearSerc = await CommonFind.FindTotals(cosmosClient, string.Format(sqlTxt, "service", yearStart, yearEnd), "School", $"Product-{scId}"); //今年购买的服务数量
  392. long tempLastYearSeri = await CommonFind.FindTotals(cosmosClient, string.Format(sqlTxt, "serial", lastYearStart, lastYearEnd), "School", $"Product-{scId}"); //计算去年购买的软体数量
  393. long tempYearSeri = await CommonFind.FindTotals(cosmosClient, string.Format(sqlTxt, "serial", yearStart, yearEnd), "School", $"Product-{scId}"); //今年购买的软体数量
  394. schoolAnalys.Add(new RecSchoolAnalys { id = school.id, name = school.name, picture = school.picture, size = school.size, scale = school.scale, buySerc = tempBuySerc, lastYearSerc = tempLastYearSerc, yearSerc = tempyearSerc, buySeri = tempBuySeri, lastYearSeri = tempLastYearSeri, yearSeri = tempYearSeri });
  395. lastYearServiceCount += tempLastYearSerc;
  396. yearServiceCount += tempyearSerc;
  397. buyServiceCount += tempBuySerc;
  398. lastYearSerialsCount += tempLastYearSeri;
  399. yearSerialsCount += tempYearSeri;
  400. buySerialsCount += tempBuySeri;
  401. }
  402. return Ok(new { state = 200, buyServiceCount, buySerialsCount, lastYearServiceCount, yearServiceCount, lastYearSerialsCount, yearSerialsCount, schoolAnalys });
  403. }
  404. /// <summary>
  405. /// 显示学校的模组分析
  406. /// </summary>
  407. public record RecSchoolAnalys
  408. {
  409. public string id { get; set; }
  410. public string name { get; set; }
  411. public string picture { get; set; }
  412. public int size { get; set; }
  413. public int scale { get; set; }
  414. public long buySerc { get; set; }
  415. public long lastYearSerc { get; set; }
  416. public long yearSerc { get; set; }
  417. public long buySeri { get; set; }
  418. public long lastYearSeri { get; set; }
  419. public long yearSeri { get; set; }
  420. }
  421. public record SchoolProduct
  422. {
  423. public string id { get; set; }
  424. public string name { get; set; }
  425. public List<ProductStatis> product { get; set; }
  426. }
  427. public record ProductStatis
  428. {
  429. public string prodCode { get; set; }
  430. public string prodName { get; set; }
  431. //public string dataType { get; set; }
  432. public long Count { get; set; }
  433. }
  434. }
  435. }