|
@@ -107,7 +107,10 @@ namespace TEAMModelOS.Controllers.Third
|
|
|
[HttpPost("sc/get-project-school-teacher")]
|
|
|
[AllowAnonymous]
|
|
|
public async Task<IActionResult> GetProjectSchoolTeacher(JsonElement request) {
|
|
|
- // await _azureStorage.DeleteAll<ScTeacher>(new Dictionary<string, object>() { { "PartitionKey", $"ScTeacher" }, { "areaId", $"{areaId}" } });
|
|
|
+ List<ScSchool > delScSchool = await _azureStorage.FindListByDict<ScSchool>(new Dictionary<string, object>() { { "PartitionKey", "ScSchool" },{ "areaId", "99a4a33b-e21b-44ac-80a1-b31dc40496e0" } });
|
|
|
+ await _azureStorage.DeleteAll(delScSchool);
|
|
|
+ List <ScTeacher> delScTeacher = await _azureStorage.FindListByDict<ScTeacher>(new Dictionary<string, object>() { { "PartitionKey", "ScTeacher" }, { "areaId", "99a4a33b-e21b-44ac-80a1-b31dc40496e0" } });
|
|
|
+ await _azureStorage.DeleteAll(delScTeacher);
|
|
|
if (!request.TryGetProperty("accessConfig", out JsonElement accessConfig)) return BadRequest();
|
|
|
if (!request.TryGetProperty("ignoreSchools", out JsonElement ignoreSchools)) return BadRequest();
|
|
|
if (!request.TryGetProperty("city", out JsonElement city)) return BadRequest();
|
|
@@ -142,7 +145,10 @@ namespace TEAMModelOS.Controllers.Third
|
|
|
{
|
|
|
var matched = matchSchools.Select(x => x.schoolname);
|
|
|
var unmatch = ignore.Select(y => y.name).Except(matched);
|
|
|
- return Ok(new { matched, unmatch });
|
|
|
+ List<string> scschoolUnmatch = schools.Select(y => y.schoolname).Except(matched).ToList();
|
|
|
+ if (scschoolUnmatch.IsNotEmpty()) {
|
|
|
+ return Ok(new { matched, unmatch, scschoolUnmatch });
|
|
|
+ }
|
|
|
}
|
|
|
else {
|
|
|
matchSchools.ForEach(x => {
|
|
@@ -161,7 +167,7 @@ namespace TEAMModelOS.Controllers.Third
|
|
|
}
|
|
|
}
|
|
|
//数据校验
|
|
|
- tbschools = await _azureStorage.FindListByDict<ScSchool>(new Dictionary<string, object>() { { "PartitionKey", $"ScSchool" } });
|
|
|
+ tbschools = await _azureStorage.FindListByDict<ScSchool>(new Dictionary<string, object>() { { "PartitionKey", "ScSchool" } });
|
|
|
if (tbschools.IsNotEmpty())
|
|
|
{
|
|
|
|
|
@@ -181,6 +187,7 @@ namespace TEAMModelOS.Controllers.Third
|
|
|
}
|
|
|
});
|
|
|
|
|
|
+
|
|
|
schoolDatas = await SchoolService.GenerateSchoolCode(schoolDatas, _dingDing, _environment);
|
|
|
saveschools.ForEach(x => {
|
|
|
|
|
@@ -206,15 +213,22 @@ namespace TEAMModelOS.Controllers.Third
|
|
|
x.areaId = $"{areaId}";
|
|
|
x.city = $"{city}";
|
|
|
x.dist = $"{dist}";
|
|
|
- if (string.IsNullOrEmpty(x.schoolCode))
|
|
|
- {
|
|
|
- schoolDatas.Add(new SchoolData { uid = $"{x.schoolid}", province = "四川省", city = $"{city}", name = x.schoolname });
|
|
|
+ var a = ignore.Find(z => z.name.Equals(x.schoolname));
|
|
|
+ if (a != null) {
|
|
|
+ x.schoolCode = a.id;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ if (string.IsNullOrEmpty(x.schoolCode))
|
|
|
+ {
|
|
|
+ schoolDatas.Add(new SchoolData { uid = $"{x.schoolid}", province = "四川省", city = $"{city}", name = x.schoolname });
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
});
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
schoolDatas = await SchoolService.GenerateSchoolCode(schoolDatas, _dingDing, _environment);
|
|
|
schools.ForEach(x => {
|
|
|
-
|
|
|
var schoolData = schoolDatas.Find(y => y.uid.Equals($"{x.schoolid}"));
|
|
|
if (schoolData != null && !string.IsNullOrEmpty(schoolData.id)) {
|
|
|
x.schoolCode = schoolData.id;
|
|
@@ -225,7 +239,7 @@ namespace TEAMModelOS.Controllers.Third
|
|
|
});
|
|
|
|
|
|
schools.RemoveAll(x => string.IsNullOrEmpty(x.schoolCode));
|
|
|
- saveschools = await _azureStorage.SaveAll(schools);
|
|
|
+ saveschools = await _azureStorage.SaveOrUpdateAll(schools);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -300,7 +314,7 @@ namespace TEAMModelOS.Controllers.Third
|
|
|
};
|
|
|
try
|
|
|
{
|
|
|
- await client.GetContainer(Constant.TEAMModelOS, "School").CreateItemAsync<School>(school, new PartitionKey(school.code));
|
|
|
+ //await client.GetContainer(Constant.TEAMModelOS, "School").CreateItemAsync<School>(school, new PartitionKey(school.code));
|
|
|
schoolsScucess.Add(school);
|
|
|
}
|
|
|
catch (CosmosException ex)
|
|
@@ -321,13 +335,20 @@ namespace TEAMModelOS.Controllers.Third
|
|
|
(status, json) = await _httpTrigger.RequestHttpTrigger(dict, _option.Location, "GetTeachersListByProject");
|
|
|
if (status == 200)
|
|
|
{
|
|
|
+ var all = await _azureStorage.FindListByDict<ScSchool>(new Dictionary<string, object>() { { "PartitionKey", $"ScSchool" }, { "areaId", $"{areaId}" } });
|
|
|
teachers = json.ToObject<List<ScTeacher>>(new JsonSerializerOptions { PropertyNameCaseInsensitive = false });
|
|
|
if (teachers.IsNotEmpty()) {
|
|
|
teachers.ForEach(x => {
|
|
|
+
|
|
|
+ ScSchool scSchool= all.Find(y => y.schoolid == x.SchoolID);
|
|
|
+ if (scSchool != null) {
|
|
|
+ x.schoolCode = scSchool.schoolCode;
|
|
|
+ }
|
|
|
x.RowKey = $"{x.PXID}";
|
|
|
x.PartitionKey = "ScTeacher";
|
|
|
x.areaId = $"{areaId}";
|
|
|
});
|
|
|
+
|
|
|
areaTeacher = await _azureStorage.FindListByDict<ScTeacher>(new Dictionary<string, object>() { { "PartitionKey", $"ScTeacher" }, { "areaId", $"{areaId}" } });
|
|
|
if (areaTeacher.IsNotEmpty())
|
|
|
{
|