|
@@ -126,12 +126,13 @@ namespace TEAMModelBI.Controllers.BITmid
|
|
//個人服務授權
|
|
//個人服務授權
|
|
tmidStics.prod = await getTMIDAuthService(cosmosClientCsv2, id, "", true);
|
|
tmidStics.prod = await getTMIDAuthService(cosmosClientCsv2, id, "", true);
|
|
|
|
|
|
- //個人權益(benefits)
|
|
|
|
-
|
|
|
|
//IOT
|
|
//IOT
|
|
- TmidAnalysisCal hiteachYear = await getTMIDIotData(cosmosClientIes5, id, "HiTeach", "year", y, 0, 0, 0, 0);
|
|
|
|
- TmidAnalysisCal hiteachMonth = await getTMIDIotData(cosmosClientIes5, id, "HiTeach", "month", y, m, 0, 0, 0);
|
|
|
|
- TmidAnalysisCal hiteachDay = await getTMIDIotData(cosmosClientIes5, id, "HiTeach", "day", y, m, d, 0, 0);
|
|
|
|
|
|
+ tmidStics.iot.hiteach.year = await getTMIDIotData(cosmosClientIes5, id, "HiTeach", "year", y, 0, 0, 0, 0);
|
|
|
|
+ tmidStics.iot.hiteach.month = await getTMIDIotData(cosmosClientIes5, id, "HiTeach", "month", y, m, 0, 0, 0);
|
|
|
|
+ tmidStics.iot.hiteach.day = await getTMIDIotData(cosmosClientIes5, id, "HiTeach", "day", y, m, d, 0, 0);
|
|
|
|
+ tmidStics.iot.hiteachcc.year = await getTMIDIotData(cosmosClientIes5, id, "HiTeachCC", "year", y, 0, 0, 0, 0);
|
|
|
|
+ tmidStics.iot.hiteachcc.month = await getTMIDIotData(cosmosClientIes5, id, "HiTeachCC", "month", y, m, 0, 0, 0);
|
|
|
|
+ tmidStics.iot.hiteachcc.day = await getTMIDIotData(cosmosClientIes5, id, "HiTeachCC", "day", y, m, d, 0, 0);
|
|
|
|
|
|
tmidDic.Add(id, tmidStics);
|
|
tmidDic.Add(id, tmidStics);
|
|
}
|
|
}
|
|
@@ -298,6 +299,31 @@ namespace TEAMModelBI.Controllers.BITmid
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ //個人權益
|
|
|
|
+ query = new QueryDefinition(@"SELECT * FROM c WHERE (ARRAY_CONTAINS(@key, c.id))")
|
|
|
|
+ .WithParameter("@key", tmidDic.Keys.ToList());
|
|
|
|
+ await foreach (var item in cosmosClientCsv2
|
|
|
|
+ .GetContainer("Core", "ID2")
|
|
|
|
+ .GetItemQueryStreamIterator(query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("benefits") }))
|
|
|
|
+ {
|
|
|
|
+ using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
|
+ if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
|
|
+ {
|
|
|
|
+ foreach (var doc in json.RootElement.GetProperty("Documents").EnumerateArray())
|
|
|
|
+ {
|
|
|
|
+ string id = doc.GetProperty("id").GetString();
|
|
|
|
+ if (doc.TryGetProperty("hiteach", out var elementHiteachData))
|
|
|
|
+ {
|
|
|
|
+ tmidDic[id].benefits.hiteach = elementHiteachData.ToObject<List<object>>();
|
|
|
|
+ }
|
|
|
|
+ if (doc.TryGetProperty("hiteachcc", out var elementHiteachCCData))
|
|
|
|
+ {
|
|
|
|
+ tmidDic[id].benefits.hiteachcc = elementHiteachCCData.ToObject<List<object>>();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
//蘇格拉底資料
|
|
//蘇格拉底資料
|
|
query = new QueryDefinition(@"SELECT * FROM c WHERE (ARRAY_CONTAINS(@key, c.id))")
|
|
query = new QueryDefinition(@"SELECT * FROM c WHERE (ARRAY_CONTAINS(@key, c.id))")
|
|
.WithParameter("@key", tmidDic.Keys.ToList());
|
|
.WithParameter("@key", tmidDic.Keys.ToList());
|
|
@@ -313,15 +339,11 @@ namespace TEAMModelBI.Controllers.BITmid
|
|
string id = doc.GetProperty("id").GetString();
|
|
string id = doc.GetProperty("id").GetString();
|
|
if (doc.TryGetProperty("hiteach_data", out var elementHiteachData))
|
|
if (doc.TryGetProperty("hiteach_data", out var elementHiteachData))
|
|
{
|
|
{
|
|
- if (elementHiteachData.TryGetProperty("total", out var elementTotal))
|
|
|
|
- {
|
|
|
|
- if (elementTotal.TryGetProperty("t_data", out var tDataValue)) tmidDic[id].sokrates.t_data = tDataValue.GetString();
|
|
|
|
- if (elementTotal.TryGetProperty("t_green", out var tGreenValue)) tmidDic[id].sokrates.t_green = tGreenValue.GetString();
|
|
|
|
- if (elementTotal.TryGetProperty("duration", out var durationValue)) tmidDic[id].sokrates.duration = durationValue.GetString();
|
|
|
|
- if (elementTotal.TryGetProperty("attendance", out var attendanceValue)) tmidDic[id].sokrates.attendance = attendanceValue.GetString();
|
|
|
|
- if (elementTotal.TryGetProperty("interaction", out var interactionValue)) tmidDic[id].sokrates.interaction = interactionValue.GetString();
|
|
|
|
- if (elementTotal.TryGetProperty("learning_duration", out var learningDurationValue)) tmidDic[id].sokrates.learning_duration = learningDurationValue.GetString();
|
|
|
|
- }
|
|
|
|
|
|
+ tmidDic[id].sokrates.hiteach_data = elementHiteachData.ToObject<object>();
|
|
|
|
+ }
|
|
|
|
+ if (doc.TryGetProperty("user_channels", out var elementUserChannels))
|
|
|
|
+ {
|
|
|
|
+ tmidDic[id].sokrates.user_channels = elementUserChannels.ToObject<object>();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -423,22 +445,6 @@ namespace TEAMModelBI.Controllers.BITmid
|
|
return Result;
|
|
return Result;
|
|
}
|
|
}
|
|
|
|
|
|
- //取得TMID權益(benefits)
|
|
|
|
- public async Task<object> getTMIDBenefits(CosmosClient cosmosClientCsv2, string tmid)
|
|
|
|
- {
|
|
|
|
- var qryOption = new QueryRequestOptions() { PartitionKey = new PartitionKey("benefits") };
|
|
|
|
- string strQuery = $"SELECT * FROM c WHERE c.id = '{tmid}'";
|
|
|
|
- await foreach (object benefit in cosmosClientCsv2.GetContainer("Core", "ID2").GetItemQueryIterator<object>(strQuery, null, qryOption))
|
|
|
|
- {
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- //輸出項
|
|
|
|
- object Result = new object();
|
|
|
|
-
|
|
|
|
- return Result;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
//Tool
|
|
//Tool
|
|
//資料遮罩
|
|
//資料遮罩
|
|
///規則:
|
|
///規則:
|
|
@@ -485,12 +491,19 @@ namespace TEAMModelBI.Controllers.BITmid
|
|
if (year > 0) strQuery += $" AND c.year = {year}";
|
|
if (year > 0) strQuery += $" AND c.year = {year}";
|
|
if (month > 0) strQuery += $" AND c.month = {month}";
|
|
if (month > 0) strQuery += $" AND c.month = {month}";
|
|
if (day > 0) strQuery += $" AND c.day = {day}";
|
|
if (day > 0) strQuery += $" AND c.day = {day}";
|
|
|
|
+ if (from > 0) strQuery += $" AND c.dateTime >= {from}";
|
|
|
|
+ if (to > 0) strQuery += $" AND c.dateTime <= {to}";
|
|
|
|
|
|
await foreach (TmidAnalysisCosmos tmidAnalysis in cosmosClientIes5.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<TmidAnalysisCosmos>(strQuery, null, qryOption))
|
|
await foreach (TmidAnalysisCosmos tmidAnalysis in cosmosClientIes5.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<TmidAnalysisCosmos>(strQuery, null, qryOption))
|
|
{
|
|
{
|
|
//一般項
|
|
//一般項
|
|
result.tmid = tmidAnalysis.tmid;
|
|
result.tmid = tmidAnalysis.tmid;
|
|
result.dateUnit = tmidAnalysis.dateUnit;
|
|
result.dateUnit = tmidAnalysis.dateUnit;
|
|
|
|
+ result.toolType = tmidAnalysis.toolType;
|
|
|
|
+ result.date = tmidAnalysis.date;
|
|
|
|
+ if (tmidAnalysis.year > 0) result.year = tmidAnalysis.year;
|
|
|
|
+ if (tmidAnalysis.month > 0) result.month = tmidAnalysis.month;
|
|
|
|
+ if (tmidAnalysis.day > 0) result.day = tmidAnalysis.day;
|
|
if (result.from.Equals(0) || tmidAnalysis.dateTime <= result.from) result.from = tmidAnalysis.dateTime;
|
|
if (result.from.Equals(0) || tmidAnalysis.dateTime <= result.from) result.from = tmidAnalysis.dateTime;
|
|
if (result.to.Equals(0) || tmidAnalysis.dateTime >= result.to) result.to = tmidAnalysis.dateTime;
|
|
if (result.to.Equals(0) || tmidAnalysis.dateTime >= result.to) result.to = tmidAnalysis.dateTime;
|
|
//統計項
|
|
//統計項
|
|
@@ -514,6 +527,7 @@ namespace TEAMModelBI.Controllers.BITmid
|
|
result.tmidList = result.tmidList.Union(tmidAnalysis.tmidList).ToList();
|
|
result.tmidList = result.tmidList.Union(tmidAnalysis.tmidList).ToList();
|
|
result.tmidCnt = result.tmidList.Count;
|
|
result.tmidCnt = result.tmidList.Count;
|
|
}
|
|
}
|
|
|
|
+ if (string.IsNullOrWhiteSpace(result.tmid)) result = null;
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -534,9 +548,11 @@ namespace TEAMModelBI.Controllers.BITmid
|
|
public TmidSticsIes5 ies5 { get; set; } = new(); //IES統計資料
|
|
public TmidSticsIes5 ies5 { get; set; } = new(); //IES統計資料
|
|
public TmidPoints points { get; set; } = new();
|
|
public TmidPoints points { get; set; } = new();
|
|
public TmidSokrates sokrates { get; set; } = new();
|
|
public TmidSokrates sokrates { get; set; } = new();
|
|
|
|
+ public TmidBenefits benefits { get; set; } = new();
|
|
public List<TmidCoupon> coupons { get; set; } = new();
|
|
public List<TmidCoupon> coupons { get; set; } = new();
|
|
public List<TmidLoginTime> login { get; set; } = new();
|
|
public List<TmidLoginTime> login { get; set; } = new();
|
|
public List<object> prod { get; set; } = new();
|
|
public List<object> prod { get; set; } = new();
|
|
|
|
+ public TmidIot iot { get; set; } = new();
|
|
}
|
|
}
|
|
//TMID統計 IES5資訊
|
|
//TMID統計 IES5資訊
|
|
private class TmidSticsIes5
|
|
private class TmidSticsIes5
|
|
@@ -581,12 +597,24 @@ namespace TEAMModelBI.Controllers.BITmid
|
|
}
|
|
}
|
|
private class TmidSokrates
|
|
private class TmidSokrates
|
|
{
|
|
{
|
|
- public string t_data { get; set; }
|
|
|
|
- public string t_green { get; set; }
|
|
|
|
- public string duration { get; set; }
|
|
|
|
- public string attendance { get; set; }
|
|
|
|
- public string interaction { get; set; }
|
|
|
|
- public string learning_duration { get; set; }
|
|
|
|
|
|
+ public object hiteach_data { get; set; }
|
|
|
|
+ public object user_channels { get; set; }
|
|
|
|
+ }
|
|
|
|
+ private class TmidBenefits
|
|
|
|
+ {
|
|
|
|
+ public List<object> hiteach { get; set; }
|
|
|
|
+ public List<object> hiteachcc { get; set; }
|
|
|
|
+ }
|
|
|
|
+ private class TmidIot
|
|
|
|
+ {
|
|
|
|
+ public TmidIotYMD hiteach { get; set; } = new();
|
|
|
|
+ public TmidIotYMD hiteachcc { get; set; } = new();
|
|
|
|
+ }
|
|
|
|
+ private class TmidIotYMD
|
|
|
|
+ {
|
|
|
|
+ public TmidAnalysisCal year { get; set; }
|
|
|
|
+ public TmidAnalysisCal month { get; set; }
|
|
|
|
+ public TmidAnalysisCal day { get; set; }
|
|
}
|
|
}
|
|
|
|
|
|
//[API輸出] 訂單履歷
|
|
//[API輸出] 訂單履歷
|