浏览代码

update 校验金牛区数据。

CrazyIter_Bin 3 年之前
父节点
当前提交
5a61b86d7b

+ 1 - 1
TEAMModelOS.FunctionV4/ServiceBus/ActiveTaskTopic.cs

@@ -1018,7 +1018,7 @@ namespace TEAMModelOS.FunctionV4.ServiceBus
             }
             }
             catch (CosmosException e)
             catch (CosmosException e)
             {
             {
-                await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-更新课堂记录出错-CosmosDB异常{e.Message}\n{e.Status}", GroupNames.成都开发測試群組);
+                await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-更新课堂记录出错-CosmosDB异常{e.Message}\n{e.StackTrace}", GroupNames.成都开发測試群組);
             }
             }
             catch (Exception ex)
             catch (Exception ex)
             {
             {

+ 4 - 0
TEAMModelOS.SDK/Models/Service/Third/ScYxptModel.cs

@@ -94,6 +94,10 @@ namespace TEAMModelOS.SDK.Models
         public string tmdid { get; set; }
         public string tmdid { get; set; }
         public string areaId { get; set; }
         public string areaId { get; set; }
         public string schoolCode { get; set; }
         public string schoolCode { get; set; }
+        /// <summary>
+        /// status =1  表示有效, 0 表示无效。
+        /// </summary>
+        public int status { get; set; }
     }
     }
     public class ScAccessConfig : AccessConfig
     public class ScAccessConfig : AccessConfig
     {
     {

+ 91 - 3
TEAMModelOS/Controllers/Third/ScController.cs

@@ -142,7 +142,95 @@ namespace TEAMModelOS.Controllers.Third
         [HttpPost("sc/get-scs-teacher")]
         [HttpPost("sc/get-scs-teacher")]
         [AllowAnonymous]
         [AllowAnonymous]
         public async Task<IActionResult> getScsTeacher(JsonElement request) {
         public async Task<IActionResult> getScsTeacher(JsonElement request) {
-            return Ok();
+            if (!request.TryGetProperty("accessConfig", out JsonElement accessConfig)) return BadRequest();
+            if (!request.TryGetProperty("city", out JsonElement city)) return BadRequest();
+            if (!request.TryGetProperty("dist", out JsonElement dist)) return BadRequest();
+            if (!request.TryGetProperty("areaId", out JsonElement areaId)) return BadRequest();
+            if (!request.TryGetProperty("standard", out JsonElement standard)) return BadRequest();
+            //数据校验
+            var ScTeachers = await _azureStorage.FindListByDict<ScTeacher>(new Dictionary<string, object>() { { "PartitionKey", "ScTeacher" }, { "areaId", $"{areaId}" } });
+            var ScSchools = await _azureStorage.FindListByDict<ScSchool>(new Dictionary<string, object>() { { "PartitionKey", "ScSchool" }, { "areaId", $"{areaId}" } });
+
+            Dictionary<string, object> dict = new Dictionary<string, object> { { "accessConfig", $"{accessConfig}" } };
+            (int status, string json) = await _httpTrigger.RequestHttpTrigger(dict, _option.Location, "GetTeachersListByProject");
+            var teachers = json.ToObject<List<ScTeacher>>(new JsonSerializerOptions { PropertyNameCaseInsensitive = false });
+            //未保存在数据库的。
+            var a = teachers.Select(x => $"{x.TID}").ToList();
+            var s = ScTeachers.Select(y => $"{ y.TID}").ToList();
+            var asin = a.Except(s).ToList();
+            var updates= teachers.FindAll(x => asin.Contains($"{x.TID}"));
+            var updateTeachers = ScTeachers.FindAll(x => updates.Select(y => $"{ y.PXID}").Contains($"{x.RowKey}"));
+            if (updateTeachers.IsNotEmpty()) {
+                //省平台更新的
+                updateTeachers.ForEach(x => {
+                    var tt = teachers.Find(z => x.RowKey.Equals($"{z.PXID}"));
+                    if (tt != null) {
+                        x.status = 1;
+                        x.TID =tt.TID;
+                        x.TeacherName=tt.TeacherName;
+                        x.SchoolID= tt.SchoolID;
+                        x.SchoolName=tt.SchoolName;
+                        x.ProjectID= tt.ProjectID;
+                        x.ProjectItemID= tt.ProjectItemID;
+                        x.ProjectItemTitle= tt.ProjectItemTitle;
+                        x.ProjectTitle= tt.ProjectTitle;
+                        x.CityID= tt.CityID;
+                        x.DistrictID = tt.DistrictID;
+                        x.CityName= tt.CityName;
+                        x.DisName = tt.DisName;
+                        x.Account= tt.Account;
+                        x.TeacherXK = tt.TeacherXK;
+                        x.TeacherXD= tt.TeacherXD;
+                        x.Mobile = x.Mobile;
+                        x.Email= tt.Email;
+                        x.tmdid = null;
+                        var school = ScSchools.Find(x => x.schoolid == x.schoolid);
+                        x.schoolCode = school?.schoolCode;
+                    }
+                });
+                updateTeachers = await _azureStorage.UpdateAll(updateTeachers);
+            }
+            var unbindtmdid = ScTeachers.FindAll(x => string.IsNullOrEmpty(x.tmdid));
+            var tids = unbindtmdid.Select(x => $"{x.TID}").ToHashSet();
+            if (tids.Count() > 0)
+            {
+                List<DbBind> binds = new List<DbBind>();
+                string sql = $"SELECT c.id,b.userid,b.data FROM c join b in c.binds  where b.userid in ({string.Join(",", tids.Select(x => $"'{x}'"))})";
+                await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<DbBind>
+                    (queryText: sql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base") }))
+                {
+                    binds.Add(item);
+                }
+                if (binds.IsNotEmpty())
+                {
+                    List<ScTeacher> update = new List<ScTeacher>();
+                    binds.ForEach(x => {
+                        var exs = unbindtmdid.FindAll(z => $"{z.TID}".Equals(x.userid));
+                        if (exs.IsNotEmpty())
+                        {
+                            exs.ForEach(y => {
+                                y.tmdid = x.id;
+                            });
+                            update.AddRange(exs);
+                        }
+                    });
+                    var group = update.GroupBy(x => x.RowKey).Select(z => new { z.Key, list = z.ToList() });
+                    List<ScTeacher> scTeachers = new();
+                    group.ToList().ForEach(x => {
+                        if (x.list.Count() == 1)
+                        {
+                            scTeachers.Add(x.list[0]);
+                        }
+                        else if (x.list.Count > 1)
+                        {
+                            scTeachers.Add(x.list[0]);
+                        }
+                    });
+                    scTeachers = await _azureStorage.SaveOrUpdateAll(scTeachers);
+                }
+            }
+            unbindtmdid = await _azureStorage.FindListByDict<ScTeacher>(new Dictionary<string, object> { { "PartitionKey", "ScTeacher" }, { "areaId", $"{areaId}" } });
+            return Ok(unbindtmdid.Select(x => new { x.areaId, x.PXID, x.TID, x.TeacherName, x.tmdid, x.SchoolName, x.DisName }));
         }
         }
 
 
         /// <summary>
         /// <summary>
@@ -406,7 +494,7 @@ namespace TEAMModelOS.Controllers.Third
                     {
                     {
                         List<ScTeacher> unbindtmdid = new List<ScTeacher>();
                         List<ScTeacher> unbindtmdid = new List<ScTeacher>();
                         //未保存在数据库的。
                         //未保存在数据库的。
-                        var saveTeachers= teachers.FindAll(x => !areaTeacher.Select(x => x.RowKey).Contains($"{x.PXID}"));
+                        var saveTeachers= teachers.FindAll(x => !areaTeacher.Select(y => y.RowKey).Contains($"{x.PXID}"));
                         if (saveTeachers.IsNotEmpty()) {
                         if (saveTeachers.IsNotEmpty()) {
                             saveTeachers = await _azureStorage.SaveAll(saveTeachers);
                             saveTeachers = await _azureStorage.SaveAll(saveTeachers);
                             unbindtmdid.AddRange(saveTeachers);
                             unbindtmdid.AddRange(saveTeachers);
@@ -418,7 +506,7 @@ namespace TEAMModelOS.Controllers.Third
                         }
                         }
 
 
                         //处理没有醍摩豆id
                         //处理没有醍摩豆id
-                       var tids= unbindtmdid.Select(x => $"{x.TID}").ToHashSet();
+                        var tids= unbindtmdid.Select(x => $"{x.TID}").ToHashSet();
                         if (tids.Count() > 0) {
                         if (tids.Count() > 0) {
                             List<DbBind> binds = new List<DbBind>();
                             List<DbBind> binds = new List<DbBind>();
                             string sql = $"SELECT c.id,b.userid,b.data FROM c join b in c.binds  where b.userid in ({string.Join(",", tids.Select(x => $"'{x}'"))})";
                             string sql = $"SELECT c.id,b.userid,b.data FROM c join b in c.binds  where b.userid in ({string.Join(",", tids.Select(x => $"'{x}'"))})";

+ 0 - 113
TEAMModelOS/Properties/ServiceDependencies/TeammodelOS - Web Deploy/profile.arm.json

@@ -1,113 +0,0 @@
-{
-  "$schema": "https://schema.management.azure.com/schemas/2018-05-01/subscriptionDeploymentTemplate.json#",
-  "contentVersion": "1.0.0.0",
-  "metadata": {
-    "_dependencyType": "appService.windows"
-  },
-  "parameters": {
-    "resourceGroupName": {
-      "type": "string",
-      "defaultValue": "TEAMModelChengdu",
-      "metadata": {
-        "description": "Name of the resource group for the resource. It is recommended to put resources under same resource group for better tracking."
-      }
-    },
-    "resourceGroupLocation": {
-      "type": "string",
-      "defaultValue": "",
-      "metadata": {
-        "description": "Location of the resource group. Resource groups could have different location than resources, however by default we use API versions from latest hybrid profile which support all locations for resource types we support."
-      }
-    },
-    "resourceName": {
-      "type": "string",
-      "defaultValue": "TeammodelOS",
-      "metadata": {
-        "description": "Name of the main resource to be created by this template."
-      }
-    },
-    "resourceLocation": {
-      "type": "string",
-      "defaultValue": "[parameters('resourceGroupLocation')]",
-      "metadata": {
-        "description": "Location of the resource. By default use resource group's location, unless the resource provider is not supported there."
-      }
-    }
-  },
-  "variables": {
-    "appServicePlan_name": "[concat('Plan', uniqueString(concat(parameters('resourceName'), subscription().subscriptionId)))]",
-    "appServicePlan_ResourceId": "[concat('/subscriptions/', subscription().subscriptionId, '/resourceGroups/', parameters('resourceGroupName'), '/providers/Microsoft.Web/serverFarms/', variables('appServicePlan_name'))]"
-  },
-  "resources": [
-    {
-      "type": "Microsoft.Resources/resourceGroups",
-      "name": "[parameters('resourceGroupName')]",
-      "location": "[parameters('resourceGroupLocation')]",
-      "apiVersion": "2019-10-01"
-    },
-    {
-      "type": "Microsoft.Resources/deployments",
-      "name": "[concat(parameters('resourceGroupName'), 'Deployment', uniqueString(concat(parameters('resourceName'), subscription().subscriptionId)))]",
-      "resourceGroup": "[parameters('resourceGroupName')]",
-      "apiVersion": "2019-10-01",
-      "dependsOn": [
-        "[parameters('resourceGroupName')]"
-      ],
-      "properties": {
-        "mode": "Incremental",
-        "template": {
-          "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
-          "contentVersion": "1.0.0.0",
-          "resources": [
-            {
-              "location": "[parameters('resourceLocation')]",
-              "name": "[parameters('resourceName')]",
-              "type": "Microsoft.Web/sites",
-              "apiVersion": "2015-08-01",
-              "tags": {
-                "[concat('hidden-related:', variables('appServicePlan_ResourceId'))]": "empty"
-              },
-              "dependsOn": [
-                "[variables('appServicePlan_ResourceId')]"
-              ],
-              "kind": "app",
-              "properties": {
-                "name": "[parameters('resourceName')]",
-                "kind": "app",
-                "httpsOnly": true,
-                "reserved": false,
-                "serverFarmId": "[variables('appServicePlan_ResourceId')]",
-                "siteConfig": {
-                  "metadata": [
-                    {
-                      "name": "CURRENT_STACK",
-                      "value": "dotnetcore"
-                    }
-                  ]
-                }
-              },
-              "identity": {
-                "type": "SystemAssigned"
-              }
-            },
-            {
-              "location": "[parameters('resourceLocation')]",
-              "name": "[variables('appServicePlan_name')]",
-              "type": "Microsoft.Web/serverFarms",
-              "apiVersion": "2015-08-01",
-              "sku": {
-                "name": "S1",
-                "tier": "Standard",
-                "family": "S",
-                "size": "S1"
-              },
-              "properties": {
-                "name": "[variables('appServicePlan_name')]"
-              }
-            }
-          ]
-        }
-      }
-    }
-  ]
-}