Selaa lähdekoodia

取得TMID數量及各產品使用狀況API 取得使用資料邏輯修正

jeff 1 vuosi sitten
vanhempi
commit
832ea143a9
1 muutettua tiedostoa jossa 54 lisäystä ja 45 poistoa
  1. 54 45
      TEAMModelBI/Controllers/BITmid/TmidController.cs

+ 54 - 45
TEAMModelBI/Controllers/BITmid/TmidController.cs

@@ -622,6 +622,13 @@ namespace TEAMModelBI.Controllers.BITmid
                             tmidStics.schoolCodeW = (doc.TryGetProperty("schoolCodeW", out JsonElement schCodeW)) ? schCodeW.GetString() : string.Empty;
                             if (!string.IsNullOrWhiteSpace(tmidStics.schoolCode)) schIds.Add(tmidStics.schoolCode);
                             if (!string.IsNullOrWhiteSpace(tmidStics.schoolCodeW)) schIds.Add(tmidStics.schoolCodeW);
+                            if(!string.IsNullOrWhiteSpace(tmidStics.schoolCode) && string.IsNullOrWhiteSpace(tmidStics.schoolId))
+                            {
+                                tmidStics.schoolId = tmidStics.schoolCode;
+                            } else if(!string.IsNullOrWhiteSpace(tmidStics.schoolCodeW) && string.IsNullOrWhiteSpace(tmidStics.schoolId))
+                            {
+                                tmidStics.schoolId = tmidStics.schoolCodeW;
+                            }
                         }
                     }
                     continuationToken = item.GetContinuationToken();
@@ -699,28 +706,28 @@ namespace TEAMModelBI.Controllers.BITmid
                     switch (login.product)
                     {
                         case "HiTeach":
-                            tmidRow.HiTeach++;
+                            tmidRow.hiteach++;
                             break;
                         case "HiTeachCC":
-                            tmidRow.HiTeachCC++;
+                            tmidRow.hiteachcc++;
                             break;
                         case "HiTA":
-                            tmidRow.HiTA++;
+                            tmidRow.hita++;
                             break;
                         case "IES5":
-                            tmidRow.IES5++;
+                            tmidRow.ies5++;
                             break;
                         case "Account":
-                            tmidRow.Account++;
+                            tmidRow.account++;
                             break;
                         case "Sokrates":
-                            tmidRow.Sokrates++;
+                            tmidRow.sokrates++;
                             break;
                         case "SokAPP":
-                            tmidRow.SokAPP++;
+                            tmidRow.sokapp++;
                             break;
                         case "IRS":
-                            tmidRow.IRS++;
+                            tmidRow.irs++;
                             break;
                     }
                 }
@@ -731,30 +738,32 @@ namespace TEAMModelBI.Controllers.BITmid
                     var schRow = sch.Where(s => s.id.Equals(tmidRow.schid)).FirstOrDefault();
                     if(schRow == null)
                     {
-                        sch.Add(new TmidIotProdCntGeo()
+                        TmidIotProdCntGeo tmpData = new TmidIotProdCntGeo();
+                        tmpData.id = id = tmidRow.schid;
+                        tmpData.schid = tmidRow.schid;
+                        if(school.ContainsKey(tmidRow.schid))
                         {
-                            id = tmidRow.schid,
-                            schid = tmidRow.schid,
-                            name = school[tmidRow.schid]["name"],
-                            countryId = school[tmidRow.schid]["countryId"],
-                            countryName = school[tmidRow.schid]["countryName"],
-                            provinceId = school[tmidRow.schid]["provinceId"],
-                            provinceName = school[tmidRow.schid]["provinceName"],
-                            cityId = school[tmidRow.schid]["cityId"],
-                            cityName = school[tmidRow.schid]["cityName"],
-                            distId = school[tmidRow.schid]["distId"],
-                            distName = school[tmidRow.schid]["distName"],
-                        });
+                            tmpData.name = school[tmidRow.schid]["name"];
+                            tmpData.countryId = school[tmidRow.schid]["countryId"];
+                            tmpData.countryName = school[tmidRow.schid]["countryName"];
+                            tmpData.provinceId = school[tmidRow.schid]["provinceId"];
+                            tmpData.provinceName = school[tmidRow.schid]["provinceName"];
+                            tmpData.cityId = school[tmidRow.schid]["cityId"];
+                            tmpData.cityName = school[tmidRow.schid]["cityName"];
+                            tmpData.distId = school[tmidRow.schid]["distId"];
+                            tmpData.distName = school[tmidRow.schid]["distName"];
+                        }
+                        sch.Add(tmpData);
                         schRow = sch.Where(s => s.id.Equals(tmidRow.schid)).FirstOrDefault();
                     }
-                    if (tmidRow.HiTeach > 0) schRow.HiTeach++;
-                    if (tmidRow.HiTeachCC > 0) schRow.HiTeachCC++;
-                    if (tmidRow.HiTA > 0) schRow.HiTA++;
-                    if (tmidRow.IES5 > 0) schRow.IES5++;
-                    if (tmidRow.Account > 0) schRow.Account++;
-                    if (tmidRow.Sokrates > 0) schRow.Sokrates++;
-                    if (tmidRow.SokAPP > 0) schRow.SokAPP++;
-                    if (tmidRow.IRS > 0) schRow.IRS++;
+                    if (tmidRow.hiteach > 0) schRow.hiteach++;
+                    if (tmidRow.hiteachcc > 0) schRow.hiteachcc++;
+                    if (tmidRow.hita > 0) schRow.hita++;
+                    if (tmidRow.ies5 > 0) schRow.ies5++;
+                    if (tmidRow.account > 0) schRow.account++;
+                    if (tmidRow.sokrates > 0) schRow.sokrates++;
+                    if (tmidRow.sokapp > 0) schRow.sokapp++;
+                    if (tmidRow.irs > 0) schRow.irs++;
                 }
             }
             //geo
@@ -784,14 +793,14 @@ namespace TEAMModelBI.Controllers.BITmid
                     });
                     geoRow = geo.Where(s => s.id.Equals(geoid)).FirstOrDefault();
                 }
-                geoRow.HiTeach += schRow.HiTeach;
-                geoRow.HiTeachCC += schRow.HiTeachCC;
-                geoRow.HiTA += schRow.HiTA;
-                geoRow.IES5 += schRow.IES5;
-                geoRow.Account += schRow.Account;
-                geoRow.Sokrates += schRow.Sokrates;
-                geoRow.SokAPP += schRow.SokAPP;
-                geoRow.IRS += schRow.IRS;
+                geoRow.hiteach += schRow.hiteach;
+                geoRow.hiteachcc += schRow.hiteachcc;
+                geoRow.hita += schRow.hita;
+                geoRow.ies5 += schRow.ies5;
+                geoRow.account += schRow.account;
+                geoRow.sokrates += schRow.sokrates;
+                geoRow.sokapp += schRow.sokapp;
+                geoRow.irs += schRow.irs;
             }
 
 
@@ -1106,14 +1115,14 @@ namespace TEAMModelBI.Controllers.BITmid
             public string id { get; set; }
             public string name { get; set; }
             public string schid { get; set; }
-            public int HiTeach { get; set; }
-            public int HiTeachCC { get; set; }
-            public int HiTA { get; set; }
-            public int IES5 { get; set; }
-            public int Account { get; set; }
-            public int Sokrates { get; set; }
-            public int SokAPP { get; set; }
-            public int IRS { get; set; }
+            public int hiteach { get; set; }
+            public int hiteachcc { get; set; }
+            public int hita { get; set; }
+            public int ies5 { get; set; }
+            public int account { get; set; }
+            public int sokrates { get; set; }
+            public int sokapp { get; set; }
+            public int irs { get; set; }
         }
         private class TmidIotProdCntGeo : TmidIotProdCnt
         {