|
@@ -53,7 +53,7 @@ namespace TEAMModelOS.Controllers
|
|
|
private readonly Option _option;
|
|
|
private readonly IPSearcher _searcher;
|
|
|
public IConfiguration _configuration { get; set; }
|
|
|
- public TestController(IPSearcher searcher,IOptionsSnapshot<Option> option, CoreAPIHttpService coreAPIHttpService, HttpClient httpClient,IWebHostEnvironment environment, AzureCosmosFactory azureCosmos, AzureRedisFactory azureRedis, AzureStorageFactory azureStorage, IConfiguration configuration, AzureServiceBusFactory serviceBus, DingDing dingDing)
|
|
|
+ public TestController(IPSearcher searcher, IOptionsSnapshot<Option> option, CoreAPIHttpService coreAPIHttpService, HttpClient httpClient, IWebHostEnvironment environment, AzureCosmosFactory azureCosmos, AzureRedisFactory azureRedis, AzureStorageFactory azureStorage, IConfiguration configuration, AzureServiceBusFactory serviceBus, DingDing dingDing)
|
|
|
{
|
|
|
_azureCosmos = azureCosmos;
|
|
|
_azureRedis = azureRedis;
|
|
@@ -61,13 +61,13 @@ namespace TEAMModelOS.Controllers
|
|
|
_dingDing = dingDing;
|
|
|
_serviceBus = serviceBus; _configuration = configuration;
|
|
|
_environment = environment;
|
|
|
- _httpClient= httpClient;
|
|
|
- _option= option.Value;
|
|
|
- _coreAPIHttpService= coreAPIHttpService;
|
|
|
- _searcher= searcher;
|
|
|
+ _httpClient = httpClient;
|
|
|
+ _option = option.Value;
|
|
|
+ _coreAPIHttpService = coreAPIHttpService;
|
|
|
+ _searcher = searcher;
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
/*
|
|
|
[
|
|
|
{"method":"台北市","params":{"CountryId":"TW","CityId":"30"}},1
|
|
@@ -101,13 +101,14 @@ namespace TEAMModelOS.Controllers
|
|
|
/// <returns></returns>
|
|
|
[ProducesDefaultResponseType]
|
|
|
[HttpPost("get-schools")]
|
|
|
- public async Task<IActionResult> GetSchools(JsonElement json) {
|
|
|
+ public async Task<IActionResult> GetSchools(JsonElement json)
|
|
|
+ {
|
|
|
|
|
|
string msg = "{\"standard\":\"standard3\",\"tmdids\":[\"1635136038\"],\"school\":\"pbjyey\",\"update\":[\"TeacherAbility\"],\"statistics\":0}";
|
|
|
try
|
|
|
{
|
|
|
TeacherTrainChange change = msg.ToObject<TeacherTrainChange>();
|
|
|
-
|
|
|
+
|
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
|
string insql = $"where c.id in ({string.Join(",", change.tmdids.Select(x => $"'{x}'"))})";
|
|
|
string selsql = $"select value(c) from c {insql} ";
|
|
@@ -285,10 +286,12 @@ namespace TEAMModelOS.Controllers
|
|
|
return Ok();
|
|
|
}
|
|
|
|
|
|
- public async Task<(List<SchoolInfo> schoolInfos,List<string> nodata)> GetSchoolAsync(List<string> regions) {
|
|
|
- List < SchoolInfo > schools= new List<SchoolInfo>();
|
|
|
+ public async Task<(List<SchoolInfo> schoolInfos, List<string> nodata)> GetSchoolAsync(List<string> regions)
|
|
|
+ {
|
|
|
+ List<SchoolInfo> schools = new List<SchoolInfo>();
|
|
|
List<string> nodata = new List<string>();
|
|
|
- foreach (var region in regions) {
|
|
|
+ foreach (var region in regions)
|
|
|
+ {
|
|
|
Dictionary<string, object> data = new Dictionary<string, object>();
|
|
|
data.Add("method", "api/School/getSchool");
|
|
|
data.Add("params", new { CountryId = "CN", CityId = region });
|
|
@@ -296,9 +299,10 @@ namespace TEAMModelOS.Controllers
|
|
|
if (responseMessage.StatusCode == HttpStatusCode.OK)
|
|
|
{
|
|
|
string Content = await responseMessage.Content.ReadAsStringAsync();
|
|
|
- try {
|
|
|
+ try
|
|
|
+ {
|
|
|
Content.ToObject<JsonElement>().TryGetProperty("result", out JsonElement content);
|
|
|
- if (content.ValueKind.Equals(JsonValueKind.Object) && content.TryGetProperty("data", out JsonElement _data))
|
|
|
+ if (content.ValueKind.Equals(JsonValueKind.Object) && content.TryGetProperty("data", out JsonElement _data))
|
|
|
{
|
|
|
if (_data.ValueKind.Equals(JsonValueKind.Array))
|
|
|
{
|
|
@@ -308,21 +312,27 @@ namespace TEAMModelOS.Controllers
|
|
|
schools.AddRange(infos.Where(x => x.name != null && x.cityName != null).ToList());
|
|
|
}
|
|
|
}
|
|
|
- else {
|
|
|
+ else
|
|
|
+ {
|
|
|
nodata.Add(data.ToJsonString());
|
|
|
continue;
|
|
|
}
|
|
|
}
|
|
|
- else { nodata.Add(data.ToJsonString());
|
|
|
- continue; }
|
|
|
- } catch (Exception ex) {
|
|
|
+ else
|
|
|
+ {
|
|
|
+ nodata.Add(data.ToJsonString());
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
nodata.Add(data.ToJsonString());
|
|
|
- throw new Exception(ex.Message,ex.InnerException);
|
|
|
+ throw new Exception(ex.Message, ex.InnerException);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- return (schools, nodata);
|
|
|
-
|
|
|
+ return (schools, nodata);
|
|
|
+
|
|
|
}
|
|
|
public class SchoolInfo
|
|
|
{
|
|
@@ -349,7 +359,7 @@ namespace TEAMModelOS.Controllers
|
|
|
public async Task<IActionResult> GenerateSchoolCodes(JsonElement json)
|
|
|
{
|
|
|
List<SchoolData> schoolss = json.GetProperty("schools").ToObject<List<SchoolData>>();
|
|
|
- dynamic data = await SchoolService.GenerateSchoolCode(schoolss, _dingDing, _environment);
|
|
|
+ dynamic data = await SchoolService.GenerateSchoolCode(schoolss, _dingDing, _environment);
|
|
|
return Ok(data);
|
|
|
}
|
|
|
|
|
@@ -383,7 +393,7 @@ namespace TEAMModelOS.Controllers
|
|
|
}
|
|
|
await _azureRedis.GetRedisClient(8).HashSetAsync($"Blob:Record", new RedisValue($"{name}"), new RedisValue($"{blobsize}"));
|
|
|
|
|
|
- await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-ServiceBus,Blob() 容器:{name}使用:{root},文件分类:{list.ToJsonString()}",GroupNames.成都开发測試群組);
|
|
|
+ await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-ServiceBus,Blob() 容器:{name}使用:{root},文件分类:{list.ToJsonString()}", GroupNames.成都开发測試群組);
|
|
|
return Ok(list);
|
|
|
}
|
|
|
else
|
|
@@ -590,15 +600,18 @@ namespace TEAMModelOS.Controllers
|
|
|
public async Task<IActionResult> DownloadContentItem(JsonElement request)
|
|
|
{
|
|
|
ItemBlob itemBlob = null;
|
|
|
- try {
|
|
|
+ try
|
|
|
+ {
|
|
|
BlobDownloadInfo blobDownloadResult = await _azureStorage.GetBlobContainerClient($"hbcn").GetBlobClient($"/item/12b865c9-a223-278a-2be1-e336b9ead99e/12b865c9-a223-278a-2be1-e336b9ead99e.json")
|
|
|
.DownloadAsync();
|
|
|
if (blobDownloadResult != null)
|
|
|
{
|
|
|
var json = JsonDocument.Parse(blobDownloadResult.Content);
|
|
|
- itemBlob = json.RootElement.ToObject<ItemBlob>();
|
|
|
+ itemBlob = json.RootElement.ToObject<ItemBlob>();
|
|
|
}
|
|
|
- } catch (Exception ex) {
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
itemBlob = null;
|
|
|
}
|
|
|
return Ok(new { itemBlob });
|
|
@@ -615,11 +628,11 @@ namespace TEAMModelOS.Controllers
|
|
|
[HttpPost("get-bind-data")]
|
|
|
public async Task<IActionResult> GetData(JsonElement request)
|
|
|
{
|
|
|
-
|
|
|
- var areaId =request.GetProperty("areaId");
|
|
|
+
|
|
|
+ var areaId = request.GetProperty("areaId");
|
|
|
var table = _azureStorage.GetCloudTableClient().GetTableReference("ScYxpt");
|
|
|
List<ScTeacher> teachers = await table.FindListByDict<ScTeacher>(new Dictionary<string, object> { { "PartitionKey", "ScTeacher" }, { "areaId", $"{areaId}" } });
|
|
|
- return Ok(teachers.Select(x =>new {x.areaId,x.PXID,x.TID,x.TeacherName,x.tmdid,x.SchoolName,x.DisName }));
|
|
|
+ return Ok(teachers.Select(x => new { x.areaId, x.PXID, x.TID, x.TeacherName, x.tmdid, x.SchoolName, x.DisName }));
|
|
|
}
|
|
|
|
|
|
/// 删除
|
|
@@ -633,13 +646,13 @@ namespace TEAMModelOS.Controllers
|
|
|
{
|
|
|
|
|
|
BlobDownloadResult Recording = await _azureStorage.GetBlobContainerClient("1595321354").GetBlobClient($"records/271528531841781760/Record/.Recording.json").DownloadContentAsync();
|
|
|
- var json = Recording.Content.ToString();
|
|
|
+ var json = Recording.Content.ToString();
|
|
|
var jsonByte = Encoding.UTF8.GetBytes(json);
|
|
|
Stream stream = new MemoryStream(jsonByte);
|
|
|
- var doc= JsonDocument.Parse(stream);
|
|
|
+ var doc = JsonDocument.Parse(stream);
|
|
|
School school = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<School>("hbcn", new PartitionKey("Base"));
|
|
|
- _= _azureStorage.SaveLog("find-school", school.ToJsonString(),httpContext:HttpContext,dingDing:_dingDing,scope:"school");
|
|
|
- return Ok(new { doc, school, });
|
|
|
+ _ = _azureStorage.SaveLog("find-school", school.ToJsonString(), httpContext: HttpContext, dingDing: _dingDing, scope: "school");
|
|
|
+ return Ok(new { doc, school, });
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -654,12 +667,15 @@ namespace TEAMModelOS.Controllers
|
|
|
{
|
|
|
|
|
|
|
|
|
- try {
|
|
|
+ try
|
|
|
+ {
|
|
|
BlobDownloadResult baseblobDownload = await _azureStorage.GetBlobContainerClient("habook").GetBlobClient($"/records/299813002894381056/IES/Base.json").DownloadContentAsync();
|
|
|
LessonBase lessonBase = baseblobDownload.Content.ToObjectFromJson<LessonBase>();
|
|
|
return Ok(lessonBase);
|
|
|
|
|
|
- } catch (RequestFailedException ex)when(ex.Status==404) {
|
|
|
+ }
|
|
|
+ catch (RequestFailedException ex) when (ex.Status == 404)
|
|
|
+ {
|
|
|
return BadRequest("文件不存在!");
|
|
|
}
|
|
|
LessonBase lessonBases = request.ToObject<LessonBase>();
|
|
@@ -687,23 +703,29 @@ namespace TEAMModelOS.Controllers
|
|
|
{
|
|
|
string sql = $"select c.id,c.name ,b.schoolId as code from c join b in c.schools where b.areaId='9ae614ba-0771-4502-a56e-0537bc5207c3'";
|
|
|
List<IdNameCode> codes = new List<IdNameCode>();
|
|
|
- await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher).GetItemQueryIterator<IdNameCode>(sql, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey("Base") })) {
|
|
|
+ await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher).GetItemQueryIterator<IdNameCode>(sql, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey("Base") }))
|
|
|
+ {
|
|
|
codes.Add(item);
|
|
|
}
|
|
|
List<dynamic> data = new List<dynamic>(); ;
|
|
|
- foreach (IdNameCode code in codes) {
|
|
|
- try {
|
|
|
+ foreach (IdNameCode code in codes)
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
TeacherTrain train = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher).ReadItemAsync<TeacherTrain>(code.id, new PartitionKey($"TeacherTrain-{code.code}"));
|
|
|
- data.Add(new { code.id,code.name,code.code, train.totalTime, train.onlineTime, train.classTime, train.offlineTime });
|
|
|
- } catch (Exception ex) {
|
|
|
- data.Add(new { code.id, code.name, code.code, totalTime=0, onlineTime=0,classTime=0, offlineTime=0 });
|
|
|
+ data.Add(new { code.id, code.name, code.code, train.totalTime, train.onlineTime, train.classTime, train.offlineTime });
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ data.Add(new { code.id, code.name, code.code, totalTime = 0, onlineTime = 0, classTime = 0, offlineTime = 0 });
|
|
|
}
|
|
|
}
|
|
|
return Ok(new { data });
|
|
|
}
|
|
|
|
|
|
[HttpPost("test-scteacher-dn")]
|
|
|
- public async Task<IActionResult> TestScteacherDn(JsonElement json) {
|
|
|
+ public async Task<IActionResult> TestScteacherDn(JsonElement json)
|
|
|
+ {
|
|
|
var table = _azureStorage.GetCloudTableClient().GetTableReference("ScYxpt");
|
|
|
string sqls = "select distinct value(c.id )from c where c.code='Base' and IS_DEFINED(c.finalScore)=true ";
|
|
|
//https://teammodelos.blob.core.chinacloudapi.cn/teammodelos
|
|
@@ -711,48 +733,52 @@ namespace TEAMModelOS.Controllers
|
|
|
List<ScTeacher> teachers = await table.FindListByDict<ScTeacher>(new Dictionary<string, object>() { { "PartitionKey", "ScTeacher" }, { "areaId", "870a5a6b-1ab3-461a-bdeb-baec19780ddb" } });
|
|
|
List<string> ids = new List<string>();
|
|
|
await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher)
|
|
|
- .GetItemQueryIterator<string>(sqls, requestOptions: new QueryRequestOptions {PartitionKey= new PartitionKey("Base") }))
|
|
|
+ .GetItemQueryIterator<string>(sqls, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey("Base") }))
|
|
|
{
|
|
|
ids.Add(item);
|
|
|
}
|
|
|
long now = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
|
|
|
List<string> erorr = new List<string>();
|
|
|
List<ScTeacher> teachersUp = new List<ScTeacher>();
|
|
|
- foreach (var id in ids) {
|
|
|
- try {
|
|
|
+ foreach (var id in ids)
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
BlobDownloadResult baseblobDownload = await _azureStorage.GetBlobContainerClient("teammodelos").GetBlobClient($"/yxpt/jinniu/scbind/{id}.json").DownloadContentAsync();
|
|
|
ScBindData scBindData = baseblobDownload.Content.ToObjectFromJson<ScBindData>();
|
|
|
- var tcd= teachers.Find(x => x.RowKey.Equals(scBindData.pxid));
|
|
|
+ var tcd = teachers.Find(x => x.RowKey.Equals(scBindData.pxid));
|
|
|
if (tcd != null)
|
|
|
{
|
|
|
Teacher teacher = new Teacher
|
|
|
{
|
|
|
createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),
|
|
|
- pk ="Base",
|
|
|
+ pk = "Base",
|
|
|
code = "Base",
|
|
|
id = id,
|
|
|
name = scBindData.username,
|
|
|
size = 2,
|
|
|
defaultSchool = tcd.schoolCode,
|
|
|
schools = new List<TeacherSchool> {
|
|
|
- new TeacherSchool
|
|
|
+ new TeacherSchool
|
|
|
{
|
|
|
schoolId = tcd.schoolCode, status = "join", time = now, name = scBindData.sn, areaId = tcd.areaId
|
|
|
}
|
|
|
},
|
|
|
- binds = new List<ThirdBind> {
|
|
|
- new ThirdBind
|
|
|
- {
|
|
|
+ binds = new List<ThirdBind> {
|
|
|
+ new ThirdBind
|
|
|
+ {
|
|
|
type= "scsyxpt",userid=scBindData.userid,username= scBindData.username,account=scBindData.account,data=new List<string>{ scBindData.ToJsonString()}
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
- await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS,Constant.Teacher).UpsertItemAsync(teacher,new PartitionKey("Base"));
|
|
|
+ await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher).UpsertItemAsync(teacher, new PartitionKey("Base"));
|
|
|
tcd.tmdid = id;
|
|
|
teachersUp.Add(tcd);
|
|
|
}
|
|
|
-
|
|
|
- } catch (Exception ) {
|
|
|
+
|
|
|
+ }
|
|
|
+ catch (Exception)
|
|
|
+ {
|
|
|
erorr.Add(id);
|
|
|
}
|
|
|
}
|
|
@@ -760,10 +786,11 @@ namespace TEAMModelOS.Controllers
|
|
|
return Ok();
|
|
|
}
|
|
|
[HttpPost("fix-jinniupujiang-teacher-videotime")]
|
|
|
- public async Task<IActionResult> GetScteacher(JsonElement json) {
|
|
|
+ public async Task<IActionResult> GetScteacher(JsonElement json)
|
|
|
+ {
|
|
|
if (!json.TryGetProperty("areaId", out JsonElement _areaId)) { return BadRequest(); }
|
|
|
- Area area= await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Normal).ReadItemAsync<Area>($"{_areaId}", new PartitionKey("Base-Area"));
|
|
|
- AreaSetting setting = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Normal).ReadItemAsync<AreaSetting>($"{_areaId}", new PartitionKey("AreaSetting"));
|
|
|
+ Area area = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Normal).ReadItemAsync<Area>($"{_areaId}", new PartitionKey("Base-Area"));
|
|
|
+ AreaSetting setting = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Normal).ReadItemAsync<AreaSetting>($"{_areaId}", new PartitionKey("AreaSetting"));
|
|
|
List<string> teachers = new List<string>();
|
|
|
//获取这个区的教师
|
|
|
string schoolSql = $"SELECT value c.id FROM c join a in c.schools where a.areaId='{_areaId}' and c.code='Base' ";
|
|
@@ -773,12 +800,13 @@ namespace TEAMModelOS.Controllers
|
|
|
teachers.Add(item);
|
|
|
}
|
|
|
//获取这些老师的研修记录
|
|
|
- string tr =$"SELECT distinct value(c) FROM c join a in c.currency.teacherAilities where c.id in ({string.Join(",", teachers.Select(x=>$"'{x}'"))}) and c.pk='TeacherTrain' and a.videoTime<300 ";
|
|
|
+ string tr = $"SELECT distinct value(c) FROM c join a in c.currency.teacherAilities where c.id in ({string.Join(",", teachers.Select(x => $"'{x}'"))}) and c.pk='TeacherTrain' and a.videoTime<300 ";
|
|
|
List<TeacherTrain> teacherTrains = new List<TeacherTrain>();
|
|
|
await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher)
|
|
|
- .GetItemQueryIterator<TeacherTrain>(tr, requestOptions: new QueryRequestOptions { }))
|
|
|
+ .GetItemQueryIterator<TeacherTrain>(tr, requestOptions: new QueryRequestOptions { }))
|
|
|
{
|
|
|
- if (!item.tmdid.Equals("1528783259") || !item.tmdid.Equals("1530606136") ) {
|
|
|
+ if (!item.tmdid.Equals("1528783259") || !item.tmdid.Equals("1530606136"))
|
|
|
+ {
|
|
|
teacherTrains.Add(item);
|
|
|
}
|
|
|
}
|
|
@@ -791,7 +819,7 @@ namespace TEAMModelOS.Controllers
|
|
|
nodeIdsDB.Add(y);
|
|
|
}
|
|
|
List<AbilitySub> abilitySubs = new List<AbilitySub>();
|
|
|
- List< TeacherVideoTime > teacherVideoTimes= new List<TeacherVideoTime>();
|
|
|
+ List<TeacherVideoTime> teacherVideoTimes = new List<TeacherVideoTime>();
|
|
|
string ids = teacherTrains.Select(x => x.id).ToJsonString();
|
|
|
string sqls = $" select value(c) from c where c.code='AbilityTask-{area.standard}'";
|
|
|
List<AbilityTask> abilityTasks = new List<AbilityTask>();
|
|
@@ -807,25 +835,28 @@ namespace TEAMModelOS.Controllers
|
|
|
if (item.currency.teacherAilities.Count() > 3)
|
|
|
{
|
|
|
//如果选择了大于三个能力点的教师,则优先获取上传了认证材料的的能力点,
|
|
|
- var uploadHas= item.currency.teacherAilities.FindAll(x => x.uploadHas == 1 && x.videoTime<300);
|
|
|
- if (uploadHas.Any()) {
|
|
|
+ var uploadHas = item.currency.teacherAilities.FindAll(x => x.uploadHas == 1 && x.videoTime < 300);
|
|
|
+ if (uploadHas.Any())
|
|
|
+ {
|
|
|
teacherAbility.AddRange(uploadHas);
|
|
|
}
|
|
|
|
|
|
- if (teacherAbility.Count < 3) {
|
|
|
+ if (teacherAbility.Count < 3)
|
|
|
+ {
|
|
|
// 如果仍然未满足数量。则再去获取 没有上传认证材料,但是又有学习时间长的能力点。
|
|
|
- var hasVideoTime = item.currency.teacherAilities.FindAll(x => x.uploadHas != 1 && x.videoTime < 300).OrderByDescending(o=>o.videoTime);
|
|
|
+ var hasVideoTime = item.currency.teacherAilities.FindAll(x => x.uploadHas != 1 && x.videoTime < 300).OrderByDescending(o => o.videoTime);
|
|
|
var disCount = 3 - teacherAbility.Count;
|
|
|
teacherAbility.AddRange(hasVideoTime.Take(disCount));
|
|
|
}
|
|
|
}
|
|
|
- else {
|
|
|
- teacherAbility.AddRange(item.currency.teacherAilities.Where(ab=>ab.videoTime<300));
|
|
|
+ else
|
|
|
+ {
|
|
|
+ teacherAbility.AddRange(item.currency.teacherAilities.Where(ab => ab.videoTime < 300));
|
|
|
}
|
|
|
TeacherFile teacherFile = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher).ReadItemAsync<TeacherFile>(item.id, new PartitionKey($"TeacherFile-{item.code.Replace("TeacherTrain-", "")}"));
|
|
|
foreach (var ability in teacherAbility)
|
|
|
{
|
|
|
- TeacherVideoTime teacherVideoTime = new TeacherVideoTime { code= item.code.Replace("TeacherTrain-", ""), id = item.id, abilityId = ability.id, no = ability.no, train_time = ability.videoTime };
|
|
|
+ TeacherVideoTime teacherVideoTime = new TeacherVideoTime { code = item.code.Replace("TeacherTrain-", ""), id = item.id, abilityId = ability.id, no = ability.no, train_time = ability.videoTime };
|
|
|
double fileview = 0;
|
|
|
var filerecord = teacherFile.fileRecords.FindAll(x => x.files.Where(y => y.abilityId.Equals(ability.id)).Count() > 0);
|
|
|
filerecord.ForEach(x => {
|
|
@@ -871,9 +902,10 @@ namespace TEAMModelOS.Controllers
|
|
|
HashSet<string> childIds = new HashSet<string>();
|
|
|
foreach (var ps in valuePairs)
|
|
|
{
|
|
|
- HashSet<string> abilityIds = teacherFile.fileRecords.SelectMany(x => x.files).Select(x => x.abilityId).Where(abid=>abid.Equals(ability.id)).ToHashSet();
|
|
|
+ HashSet<string> abilityIds = teacherFile.fileRecords.SelectMany(x => x.files).Select(x => x.abilityId).Where(abid => abid.Equals(ability.id)).ToHashSet();
|
|
|
double view = 0;
|
|
|
- foreach (var abid in abilityIds) {
|
|
|
+ foreach (var abid in abilityIds)
|
|
|
+ {
|
|
|
var record = teacherFile.fileRecords.FindAll(x => x.files.Where(y => y.abilityId.Equals(abid)).Count() > 0);
|
|
|
record.ForEach(x => {
|
|
|
var file = x.files.FindAll(y => y.abilityId.Equals($"{abid}"));
|
|
@@ -884,7 +916,7 @@ namespace TEAMModelOS.Controllers
|
|
|
});
|
|
|
}
|
|
|
double minut = view / 60;
|
|
|
- teacherVideoTime.after_time= minut;
|
|
|
+ teacherVideoTime.after_time = minut;
|
|
|
if (minut < 300)
|
|
|
{
|
|
|
var fils = teacherFile.fileRecords.Find(x => x.hash.Equals(ps.Key));
|
|
@@ -918,37 +950,45 @@ namespace TEAMModelOS.Controllers
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
- else {
|
|
|
+ else
|
|
|
+ {
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
- if (childIds.Any()) {
|
|
|
- string code = teacherFile.code.Replace("TeacherFile-", "");
|
|
|
- if (!string.IsNullOrWhiteSpace(code)) {
|
|
|
- try {
|
|
|
+ if (childIds.Any())
|
|
|
+ {
|
|
|
+ string code = teacherFile.code.Replace("TeacherFile-", "");
|
|
|
+ if (!string.IsNullOrWhiteSpace(code))
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
AbilitySub abilitySub = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher).ReadItemAsync<AbilitySub>(ability.id, new PartitionKey($"AbilitySub-{code}-{teacherFile.id}"));
|
|
|
- var taskIds= abilitySub.taskRcds.Select(x => x.id);
|
|
|
- var notin= childIds.Except(taskIds);
|
|
|
- if (notin.Any()) {
|
|
|
- abilitySub.taskRcds.AddRange(notin.Select(x => new AbilityTaskRcd { id=x,done=true}));
|
|
|
+ var taskIds = abilitySub.taskRcds.Select(x => x.id);
|
|
|
+ var notin = childIds.Except(taskIds);
|
|
|
+ if (notin.Any())
|
|
|
+ {
|
|
|
+ abilitySub.taskRcds.AddRange(notin.Select(x => new AbilityTaskRcd { id = x, done = true }));
|
|
|
abilitySubs.Add(abilitySub);
|
|
|
}
|
|
|
- } catch (Exception ex) {
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
teacherVideoTimes.Add(teacherVideoTime);
|
|
|
}
|
|
|
- // teacherFile = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher).ReplaceItemAsync<TeacherFile>(teacherFile, teacherFile.id, new PartitionKey(teacherFile.code));
|
|
|
- // item.update.Add(StatisticsService.TeacherAbility);
|
|
|
- // await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher).ReplaceItemAsync<TeacherTrain>(item, item.id, new PartitionKey(item.code));
|
|
|
+ // teacherFile = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher).ReplaceItemAsync<TeacherFile>(teacherFile, teacherFile.id, new PartitionKey(teacherFile.code));
|
|
|
+ // item.update.Add(StatisticsService.TeacherAbility);
|
|
|
+ // await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher).ReplaceItemAsync<TeacherTrain>(item, item.id, new PartitionKey(item.code));
|
|
|
}
|
|
|
|
|
|
- var data = teacherVideoTimes.GroupBy(x => x.code).Select(x=>new { x.Key,count= x.ToList().Count,list =x.ToList()}).OrderByDescending(x=>x.count);
|
|
|
+ var data = teacherVideoTimes.GroupBy(x => x.code).Select(x => new { x.Key, count = x.ToList().Count, list = x.ToList() }).OrderByDescending(x => x.count);
|
|
|
return Ok(new { data, abilitySubs });
|
|
|
}
|
|
|
|
|
|
- public class TeacherVideoTime{
|
|
|
+ public class TeacherVideoTime
|
|
|
+ {
|
|
|
public string code { get; set; }
|
|
|
public string id { get; set; }
|
|
|
public string abilityId { get; set; }
|
|
@@ -967,7 +1007,8 @@ namespace TEAMModelOS.Controllers
|
|
|
{
|
|
|
idNameCodes.Add(item);
|
|
|
}
|
|
|
- foreach (var item in idNameCodes) {
|
|
|
+ foreach (var item in idNameCodes)
|
|
|
+ {
|
|
|
try
|
|
|
{
|
|
|
TeacherTrain teacherTrain = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher).ReadItemAsync<TeacherTrain>(item.id, new PartitionKey($"TeacherTrain-{item.code}"));
|
|
@@ -976,162 +1017,60 @@ namespace TEAMModelOS.Controllers
|
|
|
teacherTrain.update.Add("TeacherClass");
|
|
|
await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher).ReplaceItemAsync<TeacherTrain>(teacherTrain, teacherTrain.id, new PartitionKey($"TeacherTrain-{item.code}"));
|
|
|
}
|
|
|
- } catch (Exception ex) {
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
continue;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
return Ok();
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- [HttpPost("fix-teacher-ability-files")]
|
|
|
- public async Task<IActionResult> TestScteacher(JsonElement json) {
|
|
|
- if (!json.TryGetProperty("ids", out JsonElement _ids)) return BadRequest();
|
|
|
- List<string> idss = _ids.Deserialize<List<string>>();
|
|
|
- if (!idss.Any()) {
|
|
|
- return BadRequest();
|
|
|
- }
|
|
|
- var table = _azureStorage.GetCloudTableClient().GetTableReference("ScYxpt");
|
|
|
+ [HttpPost("delete-error-data")]
|
|
|
+ public async Task<IActionResult> TestScteacher(JsonElement json)
|
|
|
+ {
|
|
|
|
|
|
- List<string> schools = new List<string>();
|
|
|
- string schoolSql = " select value(c.id) from c where c.areaId='870a5a6b-1ab3-461a-bdeb-baec19780ddb' ";
|
|
|
- await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School).GetItemQueryIterator<string>(schoolSql, requestOptions: new QueryRequestOptions { PartitionKey=new PartitionKey("Base")}))
|
|
|
- {
|
|
|
- schools.Add(item);
|
|
|
- }
|
|
|
- List<TeacherFile> teacherFiles = new List<TeacherFile>();
|
|
|
- string sqls = $"select distinct c.id,c.code from c where c.pk='TeacherFile' and c.id in ({string.Join(",", idss.Select(x => $"'{x}'"))}) ";
|
|
|
- List<IdNameCode> ids = new List<IdNameCode>();
|
|
|
- await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher).GetItemQueryIterator<IdNameCode>(sqls, requestOptions: new QueryRequestOptions { }))
|
|
|
- {
|
|
|
- item.code= item.code.Replace("TeacherFile-", "");
|
|
|
- if (schools.Contains(item.code)) {
|
|
|
- ids.Add(item);
|
|
|
- }
|
|
|
- }
|
|
|
- var grp = ids.GroupBy(g => g.code).Select(x => new { key = x.Key, list = x.ToList() });
|
|
|
-
|
|
|
- //foreach (var gp in grp) {
|
|
|
- // foreach (var tch in gp.list) {
|
|
|
- // if (!string.IsNullOrWhiteSpace(tch.id)) {
|
|
|
- // var id = ids.Find(x => x.id.Equals(tch.id))?.id;
|
|
|
- // if (id != null) {
|
|
|
- // TeacherFile teacherFile = new TeacherFile { id = id,pk= "TeacherFile",code= $"TeacherFile-{gp.key}",ttl=-1 };
|
|
|
- // try {
|
|
|
- // TeacherTrain teacherTrain = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher).ReadItemAsync<TeacherTrain>(id, new PartitionKey($"TeacherTrain-{gp.key}"));
|
|
|
- // teacherTrain.update.Add("TeacherAbility");
|
|
|
- // await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher).ReplaceItemAsync<TeacherTrain>(teacherTrain,id, new PartitionKey($"TeacherTrain-{gp.key}"));
|
|
|
- // } catch (Exception) {
|
|
|
- // }
|
|
|
- // List<AbilitySub> abilitySubs = new List<AbilitySub>();
|
|
|
- // string sql = "select value(c) from c ";
|
|
|
- // try
|
|
|
- // {
|
|
|
- // await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher).GetItemQueryIterator<AbilitySub>
|
|
|
- // (sql, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey($"AbilitySub-{gp.key}-{id}") }))
|
|
|
- // {
|
|
|
- // abilitySubs.Add(item);
|
|
|
- // }
|
|
|
-
|
|
|
- // Dictionary<string, RecordFileAbility> valuePairs = new Dictionary<string, RecordFileAbility>();
|
|
|
- // var taskids= abilitySubs.SelectMany(x => x.taskRcds).Select(x => x.id).ToHashSet();
|
|
|
- // if (taskids.Any())
|
|
|
- // {
|
|
|
-
|
|
|
- // List<AbilityTask> abilityTasks = new List<AbilityTask>();
|
|
|
- // string taskSql = $"select distinct value(c) from c join b in c.children where c.code='AbilityTask-standard10' and b.id in ({string.Join(",", taskids.Select(m=>$"'{m}'"))})";
|
|
|
- // await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Normal).GetItemQueryIterator<AbilityTask>
|
|
|
- // (taskSql, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey($"AbilityTask-standard10") }))
|
|
|
- // {
|
|
|
- // abilityTasks.Add(item);
|
|
|
- // }
|
|
|
- // abilityTasks.ForEach(x => {
|
|
|
- // x.children.ForEach(y => {
|
|
|
- // var di= taskids.ToList().Find(z => z.Equals(y.id));
|
|
|
- // if (!string.IsNullOrWhiteSpace(di)) {
|
|
|
- // y.rnodes.ForEach(r => {
|
|
|
- // if (valuePairs.ContainsKey(r.hash))
|
|
|
- // {
|
|
|
- // valuePairs.TryGetValue(r.hash, out var value);
|
|
|
- // value.fileAbilities.Add(new FileAbility { url = r.link, abilityId = x.abilityId, taskId = x.id, nodeId = di });
|
|
|
- // }
|
|
|
- // else {
|
|
|
- // valuePairs.Add(r.hash, new RecordFileAbility
|
|
|
- // {
|
|
|
- // fileRecord =
|
|
|
- // new FileRecord { hash = r.hash, size = r.size.Value, duration = r.duration, view = (int)r.duration, type = r.type, done = true },
|
|
|
- // fileAbilities = new List<FileAbility> { new FileAbility { url=r.link,abilityId=x.abilityId,taskId=x.id,nodeId=di } }
|
|
|
- // });
|
|
|
- // }
|
|
|
- // });
|
|
|
- // }
|
|
|
- // });
|
|
|
- // });
|
|
|
- // }
|
|
|
- // foreach (var item in valuePairs)
|
|
|
- // {
|
|
|
- // teacherFile.fileRecords.Add(new FileRecord
|
|
|
- // {
|
|
|
- // hash = item.Value.fileRecord.hash,
|
|
|
- // size = item.Value.fileRecord.size,
|
|
|
- // duration = item.Value.fileRecord.duration,
|
|
|
- // view = (int)item.Value.fileRecord.view,
|
|
|
- // type = item.Value.fileRecord.type,
|
|
|
- // done = true,
|
|
|
- // files = item.Value.fileAbilities
|
|
|
- // });
|
|
|
- // }
|
|
|
- // }
|
|
|
- // catch (Exception ex)
|
|
|
- // {
|
|
|
- // return BadRequest(new { ex = ex.Message, ms = ex.StackTrace });
|
|
|
-
|
|
|
- // }
|
|
|
- // teacherFiles.Add(teacherFile);
|
|
|
- // await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher).UpsertItemAsync(teacherFile, new PartitionKey(teacherFile.code));
|
|
|
- // }
|
|
|
- // }
|
|
|
- // }
|
|
|
- //}
|
|
|
-
|
|
|
- return Ok(teacherFiles);
|
|
|
+ return Ok();
|
|
|
}
|
|
|
|
|
|
|
|
|
public class RecordFileAbility
|
|
|
{
|
|
|
|
|
|
- public FileRecord fileRecord { get; set; }
|
|
|
+ public FileRecord fileRecord { get; set; }
|
|
|
public List<FileAbility> fileAbilities { get; set; }
|
|
|
}
|
|
|
[HttpPost("test-blob-folder")]
|
|
|
public async Task<IActionResult> TestBlobFolder(JsonElement json)
|
|
|
{
|
|
|
- var client = _azureStorage.GetBlobContainerClient("1595321354") ;
|
|
|
+ var client = _azureStorage.GetBlobContainerClient("1595321354");
|
|
|
List<BlobItem> blobItems = new List<BlobItem>();
|
|
|
HashSet<string> ids = new HashSet<string>();
|
|
|
string path = $"records";
|
|
|
- await foreach (BlobItem item in client.GetBlobsAsync(BlobTraits.None, BlobStates.None, path)) {
|
|
|
- var p= item.Name.Split("/");
|
|
|
- if (p.Length > 2) {
|
|
|
+ await foreach (BlobItem item in client.GetBlobsAsync(BlobTraits.None, BlobStates.None, path))
|
|
|
+ {
|
|
|
+ var p = item.Name.Split("/");
|
|
|
+ if (p.Length > 2)
|
|
|
+ {
|
|
|
ids.Add(p[1]);
|
|
|
}
|
|
|
}
|
|
|
List<string> lessonIds = new List<string>();
|
|
|
string sql = "select value(c.id) from c ";
|
|
|
- await foreach(var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher)
|
|
|
- .GetItemQueryIterator<string>(queryText:sql ,requestOptions:new QueryRequestOptions { PartitionKey= new PartitionKey("LessonRecord-1595321354") }))
|
|
|
+ await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher)
|
|
|
+ .GetItemQueryIterator<string>(queryText: sql, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey("LessonRecord-1595321354") }))
|
|
|
{
|
|
|
lessonIds.Add(item);
|
|
|
}
|
|
|
- var notdata = ids.Except(lessonIds);
|
|
|
- var notblob = lessonIds.Except(ids).ToList() ;
|
|
|
- List<string> paths = notdata.Select(x => $"records/{x}").ToList() ;
|
|
|
+ var notdata = ids.Except(lessonIds);
|
|
|
+ var notblob = lessonIds.Except(ids).ToList();
|
|
|
+ List<string> paths = notdata.Select(x => $"records/{x}").ToList();
|
|
|
await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher).DeleteItemsStreamAsync(notblob, "LessonRecord-1595321354");
|
|
|
await _azureStorage.GetBlobServiceClient().DeleteBlobs(_dingDing, "1595321354", paths);
|
|
|
- return Ok(new { lessonIds , ids , notdata, notblob });
|
|
|
+ return Ok(new { lessonIds, ids, notdata, notblob });
|
|
|
}
|
|
|
}
|
|
|
}
|