|
@@ -14,7 +14,7 @@ using TEAMModelOS.SDK.DI;
|
|
using TEAMModelOS.SDK.Extension;
|
|
using TEAMModelOS.SDK.Extension;
|
|
using TEAMModelOS.SDK.Models;
|
|
using TEAMModelOS.SDK.Models;
|
|
|
|
|
|
-namespace TEAMModelBI.Controllers.BISchool
|
|
|
|
|
|
+namespace TEAMModelBI.Controllers.Census
|
|
{
|
|
{
|
|
/// <summary>
|
|
/// <summary>
|
|
/// 试卷
|
|
/// 试卷
|
|
@@ -46,11 +46,11 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
{
|
|
{
|
|
jsonElement.TryGetProperty("tmdId", out JsonElement tmdId);
|
|
jsonElement.TryGetProperty("tmdId", out JsonElement tmdId);
|
|
if(!jsonElement.TryGetProperty("term", out JsonElement term)) return BadRequest();
|
|
if(!jsonElement.TryGetProperty("term", out JsonElement term)) return BadRequest();
|
|
- var (start, end) = DateTimeHeloer.GetTermStartOrEnd(DateTime.Now);
|
|
|
|
|
|
+ var (start, end) = TimeHelper.GetTermStartOrEnd(DateTime.Now);
|
|
var cosmosClient = _azureCosmos.GetCosmosClient();
|
|
var cosmosClient = _azureCosmos.GetCosmosClient();
|
|
object paperCount = new object();
|
|
object paperCount = new object();
|
|
|
|
|
|
- StringBuilder sqlTxt = new StringBuilder("select count(c.id) AS totals from c");
|
|
|
|
|
|
+
|
|
|
|
|
|
if (!string.IsNullOrEmpty($"{tmdId}"))
|
|
if (!string.IsNullOrEmpty($"{tmdId}"))
|
|
{
|
|
{
|
|
@@ -58,14 +58,23 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
schoolIds = await CommonFind.FindSchoolIds(cosmosClient, $"{tmdId}");
|
|
schoolIds = await CommonFind.FindSchoolIds(cosmosClient, $"{tmdId}");
|
|
|
|
|
|
List<SchoolPaper> schoolPapers = new List<SchoolPaper>();
|
|
List<SchoolPaper> schoolPapers = new List<SchoolPaper>();
|
|
-
|
|
|
|
- if (bool.Parse($"{term}") == true)
|
|
|
|
|
|
+ string time = "";
|
|
|
|
+ bool bos = bool.Parse($"{term}");
|
|
|
|
+ if (bos == true)
|
|
{
|
|
{
|
|
- sqlTxt.Append($" where c.createTime >={start} and c.createTime <={end}");
|
|
|
|
|
|
+ time = $" where c.createTime >={start} and c.createTime <={end}";
|
|
}
|
|
}
|
|
|
|
|
|
foreach (var schoolId in schoolIds)
|
|
foreach (var schoolId in schoolIds)
|
|
{
|
|
{
|
|
|
|
+ StringBuilder sqlTxt = new StringBuilder("select count(c.id) AS totals from c");
|
|
|
|
+ if (bos != true)
|
|
|
|
+ sqlTxt.Append($" where c.code='Paper-{schoolId}'");
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ sqlTxt.Append(time);
|
|
|
|
+ sqlTxt.Append($" and c.code='Paper-{schoolId}'");
|
|
|
|
+ };
|
|
School school = new();
|
|
School school = new();
|
|
var response = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(schoolId, new PartitionKey("Base"));
|
|
var response = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(schoolId, new PartitionKey("Base"));
|
|
if (response.Status == 200)
|
|
if (response.Status == 200)
|
|
@@ -85,7 +94,7 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- sqlTxt.Append(" where c.pk='Paper' ");
|
|
|
|
|
|
+ StringBuilder sqlTxt = new StringBuilder("select count(c.id) AS totals from c where c.pk='Paper'");
|
|
if (bool.Parse($"{term}") == true)
|
|
if (bool.Parse($"{term}") == true)
|
|
{
|
|
{
|
|
sqlTxt.Append($" and c.createTime >= {start} and c.createTime <={end}");
|
|
sqlTxt.Append($" and c.createTime >= {start} and c.createTime <={end}");
|
|
@@ -140,7 +149,7 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
|
|
|
|
SchoolPaper schoolPaper = new SchoolPaper() { id = schoolId , name = school != null ? school.name : schoolId };
|
|
SchoolPaper schoolPaper = new SchoolPaper() { id = schoolId , name = school != null ? school.name : schoolId };
|
|
|
|
|
|
- schoolPaper.totals = await CommonFind.FindTotals(cosmosClient, "select COUNT(c.id) AS totals from c", new List<string>() { "School" });
|
|
|
|
|
|
+ schoolPaper.totals = await CommonFind.FindTotals(cosmosClient, $"select COUNT(c.id) AS totals from c where c.code='Paper-{schoolId}'", new List<string>() { "School" });
|
|
|
|
|
|
schoolPapers.Add(schoolPaper);
|
|
schoolPapers.Add(schoolPaper);
|
|
}
|
|
}
|
|
@@ -158,7 +167,7 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
{
|
|
{
|
|
jsonElement.TryGetProperty("tmdId", out JsonElement tmdId);
|
|
jsonElement.TryGetProperty("tmdId", out JsonElement tmdId);
|
|
var cosmosClient = _azureCosmos.GetCosmosClient();
|
|
var cosmosClient = _azureCosmos.GetCosmosClient();
|
|
- List<MonthStartEnd> endList1 = DateTimeHeloer.GetYearMonthlyStartEnd13(DateTimeOffset.UtcNow.Year);
|
|
|
|
|
|
+ List<MonthStartEnd> endList1 = TimeHelper.GetYearMonthlyStartEnd13(DateTimeOffset.UtcNow.Year);
|
|
if (string.IsNullOrEmpty($"{tmdId}"))
|
|
if (string.IsNullOrEmpty($"{tmdId}"))
|
|
{
|
|
{
|
|
Dictionary<string, long> schoolYears = new Dictionary<string, long>();
|
|
Dictionary<string, long> schoolYears = new Dictionary<string, long>();
|
|
@@ -194,7 +203,7 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
Dictionary<string, long> yearCount = new Dictionary<string, long>();
|
|
Dictionary<string, long> yearCount = new Dictionary<string, long>();
|
|
foreach (var temp in endList1)
|
|
foreach (var temp in endList1)
|
|
{
|
|
{
|
|
- string sqlTxt = $"SELECT COUNT(c.id) AS totals FROM c WHERE c.createTime >= {temp.start} and c.createTime <= {temp.end} and c.pk='Paper'";
|
|
|
|
|
|
+ string sqlTxt = $"SELECT COUNT(c.id) AS totals FROM c WHERE c.code='Paper-{schoolId}' and c.createTime >= {temp.start} and c.createTime <= {temp.end} and c.pk='Paper'";
|
|
long totals = await CommonFind.FindTotals(cosmosClient, sqlTxt, new List<string>() { "School", "Teacher" });
|
|
long totals = await CommonFind.FindTotals(cosmosClient, sqlTxt, new List<string>() { "School", "Teacher" });
|
|
|
|
|
|
yearCount.Add(temp.yearMonth, totals);
|
|
yearCount.Add(temp.yearMonth, totals);
|
|
@@ -216,7 +225,7 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
{
|
|
{
|
|
jsonElement.TryGetProperty("tmdId", out JsonElement tmdId);
|
|
jsonElement.TryGetProperty("tmdId", out JsonElement tmdId);
|
|
var cosmosClient = _azureCosmos.GetCosmosClient();
|
|
var cosmosClient = _azureCosmos.GetCosmosClient();
|
|
- var (start, end) = DateTimeHeloer.GetTermStartOrEnd(DateTime.Now);
|
|
|
|
|
|
+ var (start, end) = TimeHelper.GetTermStartOrEnd(DateTime.Now);
|
|
|
|
|
|
var totals = new object();
|
|
var totals = new object();
|
|
if (!string.IsNullOrEmpty($"{tmdId}"))
|
|
if (!string.IsNullOrEmpty($"{tmdId}"))
|
|
@@ -270,6 +279,59 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
return Ok(new { state = 200, totals });
|
|
return Ok(new { state = 200, totals });
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 依据试卷Id查询试卷信息 数据管理工具——查询工具
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <param name="jsonElement"></param>
|
|
|
|
+ /// <returns></returns>
|
|
|
|
+ [HttpPost("get-info")]
|
|
|
|
+ public async Task<IActionResult> GetInfo(JsonElement jsonElement)
|
|
|
|
+ {
|
|
|
|
+ if (!jsonElement.TryGetProperty("paperId", out JsonElement paperId)) return BadRequest();
|
|
|
|
+ jsonElement.TryGetProperty("isPersonal", out JsonElement isPersonal);
|
|
|
|
+
|
|
|
|
+ var cosmosClient = _azureCosmos.GetCosmosClient();
|
|
|
|
+
|
|
|
|
+ List<object> paperInfos = new List<object>();
|
|
|
|
+ string sqlTxt = $"select * from c where c.id='{paperId}' and c.pk='Paper'";
|
|
|
|
+
|
|
|
|
+ if (!string.IsNullOrEmpty($"{isPersonal}"))
|
|
|
|
+ {
|
|
|
|
+ string tableName = "School";
|
|
|
|
+ if (bool.Parse($"{isPersonal}") == true)
|
|
|
|
+ {
|
|
|
|
+ tableName = "Teacher";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", tableName).GetItemQueryStreamIterator(queryText: sqlTxt, requestOptions: new QueryRequestOptions() { }))
|
|
|
|
+ {
|
|
|
|
+ using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
|
+ foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
|
|
|
|
+ {
|
|
|
|
+ paperInfos.Add(obj.ToObject<object>());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ List<string> tableName = new List<string> { "School", "Teacher" };
|
|
|
|
+ foreach (var temp in tableName)
|
|
|
|
+ {
|
|
|
|
+ await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", temp).GetItemQueryStreamIterator(queryText: sqlTxt, requestOptions: new QueryRequestOptions() { }))
|
|
|
|
+ {
|
|
|
|
+ using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
|
+ foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
|
|
|
|
+ {
|
|
|
|
+ paperInfos.Add(obj.ToObject<object>());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return Ok(new { state = 200, paperInfos });
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
public record SchoolPaper
|
|
public record SchoolPaper
|
|
{
|
|
{
|
|
public string id { get; set; }
|
|
public string id { get; set; }
|