Kaynağa Gözat

Merge branch 'TPE/develop' of http://52.130.252.100:10000/TEAMMODEL/TEAMModelOS into TPE/develop

upon 11 ay önce
ebeveyn
işleme
a7238a7a3f
100 değiştirilmiş dosya ile 7924 ekleme ve 1386 silme
  1. 3 0
      .gitignore
  2. 2 2
      TEAMModelBI/ClientApp/package.json
  3. 1 1
      TEAMModelBI/ClientApp/public/index.html
  4. 46 1
      TEAMModelBI/ClientApp/src/api/index.js
  5. 47 0
      TEAMModelBI/ClientApp/src/language/lang/zh-cn.js
  6. 47 0
      TEAMModelBI/ClientApp/src/language/lang/zh-tw.js
  7. 2 0
      TEAMModelBI/ClientApp/src/main.js
  8. 43 7
      TEAMModelBI/ClientApp/src/router/index.js
  9. 1 0
      TEAMModelBI/ClientApp/src/static/country.json
  10. 5 1
      TEAMModelBI/ClientApp/src/store/index.js
  11. 80 0
      TEAMModelBI/ClientApp/src/store/module/config.js
  12. 2 1
      TEAMModelBI/ClientApp/src/until/common.js
  13. 7 4
      TEAMModelBI/ClientApp/src/until/http.js
  14. 26 3
      TEAMModelBI/ClientApp/src/view/areaServe/areamanage.vue
  15. 45 3
      TEAMModelBI/ClientApp/src/view/common/aside.vue
  16. 605 0
      TEAMModelBI/ClientApp/src/view/htcommunity/adminpanel.vue
  17. 20 17
      TEAMModelBI/ClientApp/src/view/index/index.vue
  18. 156 0
      TEAMModelBI/ClientApp/src/view/issueCoupons/consolidationCoupon.vue
  19. 1164 0
      TEAMModelBI/ClientApp/src/view/issueCoupons/crteadCoupon.vue
  20. 22 0
      TEAMModelBI/ClientApp/src/view/issueCoupons/index.vue
  21. 368 0
      TEAMModelBI/ClientApp/src/view/issueCoupons/notice.vue
  22. 13 1
      TEAMModelBI/ClientApp/src/view/login.vue
  23. 441 119
      TEAMModelBI/ClientApp/src/view/product/details.vue
  24. 229 143
      TEAMModelBI/ClientApp/src/view/product/index.vue
  25. 23 29
      TEAMModelBI/ClientApp/src/view/schoolServe/school.vue
  26. 86 14
      TEAMModelBI/ClientApp/src/view/schoolmanage/schoolAnalyse.vue
  27. 93 15
      TEAMModelBI/ClientApp/src/view/systemConfig/pushmsg/createdpush.vue
  28. 4 1
      TEAMModelBI/ClientApp/src/view/systemConfig/pushmsg/index.vue
  29. 131 32
      TEAMModelBI/ClientApp/src/view/userInquire/details.vue
  30. 1153 0
      TEAMModelBI/ClientApp/src/view/userInquire/idIncrement.vue
  31. 75 40
      TEAMModelBI/ClientApp/src/view/userInquire/index.vue
  32. 7 4
      TEAMModelBI/ClientApp/src/view/userInquire/iot.vue
  33. 304 0
      TEAMModelBI/ClientApp/src/view/userInquire/updCodeW.vue
  34. 2 2
      TEAMModelBI/Controllers/BIBlob/AnalyseFileController.cs
  35. 205 0
      TEAMModelBI/Controllers/BICommon/BICouponController.cs
  36. 14 10
      TEAMModelBI/Controllers/BICommon/BINoticeController.cs
  37. 3 3
      TEAMModelBI/Controllers/BICommon/BIProductUseRecordController.cs
  38. 6 9
      TEAMModelBI/Controllers/BICommon/JointlyController.cs
  39. 2 3
      TEAMModelBI/Controllers/BICommon/StatsNoticeController.cs
  40. 10 10
      TEAMModelBI/Controllers/BIHome/HomeStatisController.cs
  41. 112 6
      TEAMModelBI/Controllers/BIHome/OnLineController.cs
  42. 7 8
      TEAMModelBI/Controllers/BINormal/AbilityMgmtController.cs
  43. 9 9
      TEAMModelBI/Controllers/BINormal/AbilityTaskMgmtController.cs
  44. 21 21
      TEAMModelBI/Controllers/BINormal/AreaRelevantController.cs
  45. 61 63
      TEAMModelBI/Controllers/BINormal/BatchAreaController.cs
  46. 14 14
      TEAMModelBI/Controllers/BINormal/BusinessConfigController.cs
  47. 11 11
      TEAMModelBI/Controllers/BINormal/BusinessUsersController.cs
  48. 224 19
      TEAMModelBI/Controllers/BIProductAnalysis/ProductAnalysisController.cs
  49. 187 69
      TEAMModelBI/Controllers/BISchool/BatchSchoolController.cs
  50. 3 3
      TEAMModelBI/Controllers/BISchool/RoomController.cs
  51. 190 91
      TEAMModelBI/Controllers/BISchool/SchoolController.cs
  52. 0 1
      TEAMModelBI/Controllers/BIServer/BiServersController.cs
  53. 1 1
      TEAMModelBI/Controllers/BIStudent/StuActivityController.cs
  54. 7 7
      TEAMModelBI/Controllers/BIStudent/StudentController.cs
  55. 4 4
      TEAMModelBI/Controllers/BITable/BIOpenApiController.cs
  56. 9 10
      TEAMModelBI/Controllers/BITable/DDStructController.cs
  57. 2 3
      TEAMModelBI/Controllers/BITable/IES5OAuthController.cs
  58. 2 2
      TEAMModelBI/Controllers/BITable/OperateLogController.cs
  59. 18 20
      TEAMModelBI/Controllers/BITable/TableDingDingInfoController.cs
  60. 5 5
      TEAMModelBI/Controllers/BITeacher/TeacherController.cs
  61. 13 12
      TEAMModelBI/Controllers/BITest/Ies5TestController.cs
  62. 29 33
      TEAMModelBI/Controllers/BITest/TestController.cs
  63. 478 203
      TEAMModelBI/Controllers/BITmid/TmidController.cs
  64. 18 18
      TEAMModelBI/Controllers/Census/ActivitySticsController.cs
  65. 2 2
      TEAMModelBI/Controllers/Census/BlobLogController.cs
  66. 21 22
      TEAMModelBI/Controllers/Census/ItemSticsController.cs
  67. 35 35
      TEAMModelBI/Controllers/Census/LessonSticsController.cs
  68. 18 20
      TEAMModelBI/Controllers/Census/PaperController.cs
  69. 26 26
      TEAMModelBI/Controllers/Census/ProductStatisController.cs
  70. 56 58
      TEAMModelBI/Controllers/Census/SchoolController.cs
  71. 3 4
      TEAMModelBI/Controllers/LoginController.cs
  72. 8 11
      TEAMModelBI/Controllers/RepairApi/InitialAreaController.cs
  73. 2 2
      TEAMModelBI/Controllers/RepairApi/NormalController.cs
  74. 15 17
      TEAMModelBI/Controllers/RepairApi/SchoolRepController.cs
  75. 5 5
      TEAMModelBI/Controllers/RepairApi/TeacherREPController.cs
  76. 32 0
      TEAMModelBI/Filter/AspNetCoreBuilderServiceCollectionExtensions.cs
  77. 218 0
      TEAMModelBI/Filter/RequestAuditFilter.cs
  78. 23 0
      TEAMModelBI/Models/AssistSchool.cs
  79. 1 2
      TEAMModelBI/Models/ItemInfo.cs
  80. 41 0
      TEAMModelBI/Models/Purchase.cs
  81. 12 2
      TEAMModelBI/Models/RearEndMiddle.cs
  82. 2 3
      TEAMModelBI/Startup.cs
  83. 4 4
      TEAMModelBI/TEAMModelBI.csproj
  84. 22 23
      TEAMModelBI/Tool/CommonFind.cs
  85. 8 7
      TEAMModelBI/Tool/CosmosBank/ActivityWay.cs
  86. 5 4
      TEAMModelBI/Tool/CosmosBank/JointlySingleQuery1.cs
  87. 4 3
      TEAMModelBI/Tool/CosmosBank/ProductWay.cs
  88. 4 3
      TEAMModelBI/Tool/CosmosBank/SchoolWay.cs
  89. 11 20
      TEAMModelBI/Tool/CosmosBank/StatsWay.cs
  90. 4 2
      TEAMModelBI/Tool/Extension/JwtAuth.cs
  91. 1 2
      TEAMModelBI/Tool/TimeHelper1.cs
  92. 3 1
      TEAMModelBI/appsettings.Development.json
  93. 24 0
      TEAMModelContest/Contest.Server/Contest.Server.csproj
  94. 15 0
      TEAMModelContest/Contest.Server/Program.cs
  95. 113 0
      TEAMModelContest/Contest.Server/Properties/ServiceDependencies/contest - Web Deploy/profile.arm.json
  96. 113 0
      TEAMModelContest/Contest.Server/Properties/ServiceDependencies/contest-test - Web Deploy/profile.arm.json
  97. 113 0
      TEAMModelContest/Contest.Server/Properties/ServiceDependencies/contest-test - Web Deploy1/profile.arm.json
  98. 34 0
      TEAMModelContest/Contest.Server/Properties/launchSettings.json
  99. 8 0
      TEAMModelContest/Contest.Server/appsettings.Development.json
  100. 0 0
      TEAMModelContest/Contest.Server/appsettings.json

+ 3 - 0
.gitignore

@@ -267,3 +267,6 @@ TEAMModelOS.FunctionV4/Properties/ServiceDependencies/TEAMModel-Test - Zip Deplo
 TEAMModelOS.FunctionV4/Properties/ServiceDependencies/teammodelfunction-rc - Zip Deploy/
 /TEAMModelOS.FunctionV4/Properties/serviceDependencies.teammodelfunction-rc - Zip Deploy.json
 /TEAMModelOS/.local-chromium
+
+TEAMModelBI/Properties/ServiceDependencies/teammodelbi-RC - Web Deploy/profile.arm.json
+/TEAMModelOS.Function/local.settings.json

+ 2 - 2
TEAMModelBI/ClientApp/package.json

@@ -4,7 +4,7 @@
     "private": true,
     "scripts": {
         "serve": "vue-cli-service serve",
-        "build": "vue-cli-service build",
+        "build": "set NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service build",
         "lint": "vue-cli-service lint"
     },
     "dependencies": {
@@ -27,7 +27,7 @@
         "less": "^4.1.2",
         "qs": "^6.10.1",
         "splitpanes": "^3.1.1",
-        "vue": "^3.2.0",
+        "vue": "^3.2.26",
         "vue-clipboard3": "^2.0.0",
         "vue-i18n": "^9.2.2",
         "vue-loader-v16": "npm:vue-loader@^16.0.0-alpha.3",

+ 1 - 1
TEAMModelBI/ClientApp/public/index.html

@@ -12,7 +12,7 @@
     </title>
 </head>
 <script src="https://g.alicdn.com/dingding/dinglogin/0.0.5/ddLogin.js"></script>
-<script src="https://at.alicdn.com/t/c/font_2934132_dz617c1kcup.js"></script>
+<script src="https://at.alicdn.com/t/c/font_2934132_mzapgo0jijg.js"></script>
 <script src="../src/access/iconfont.js"></script>
 
 <body>

+ 46 - 1
TEAMModelBI/ClientApp/src/api/index.js

@@ -219,6 +219,14 @@ export default {
     getallSchool(data) {
         return post('/batchschool/get-allscinfo', data)
     },
+    //透過位置取得學校資料
+    getSchooBasicInfo(data) {
+        return post('/batchschool/get-school-basic-info', data)
+    },
+    //弱歸戶
+    updUserSchoolW(data) {
+        return post('/batchschool/upd-user-schoolw', data)
+    },    
 
     //首页dashboard数据接口
     //获取各城市的学校数量(bar)
@@ -551,6 +559,10 @@ export default {
     getfilterSchool(data) {
         return post('/prodanalysis/get-school', data)
     },
+    //ID歸戶增量統計
+    getTmidUseprod(data) {
+        return post('/tmid/get-tmid-useprod', data)
+    },
     /*产品使用分析end*/
 
     //获取地址location
@@ -578,5 +590,38 @@ export default {
     /*ID查询 相关*/
     getUserdatas(data) {
         return post('/tmid/get-tmidstics',data)
-     }
+    },
+    /*ID查询 IOT相关*/
+    getUserIOT(data) {
+        return post('/tmid/get-tmid-iot',data)
+    },
+
+    /*優惠券相關*/
+    // 建立優惠券
+    crtCoupon(data) {
+        return post('/coupon/create-coupon',data)
+    },
+    // 歸戶
+    consolidationCoupon(data) {
+        return post('/coupon/consolidation-coupon',data)
+    },
+
+    /*簡版通知*/
+    // 發送
+    pushNotify(data) {
+        return post('/coupon/push-notify',data)
+    },
+    //統購平台 - 縣市名額設定 ※目前只開放GL站 
+    setPurchaseSeats(data, testflg=false) {
+        let Domain = (testflg) ? 'bb-rc.teammodel.net' : 'bb.teammodel.net';
+        return post(`https://${Domain}/bbauthapi/set-purchase-seats`, data)
+    },
+    //統購平台 - 取得統購平台列表
+    getBBPurchase(data) {
+        return post('/schoolcheck/get-bbpurchase',data)
+    },
+    //統購平台 - 取得縣市學校
+    getCsSchoolByGeo(data) {
+        return post('/schoolcheck/get-school-geo', data)
+    },
 }

+ 47 - 0
TEAMModelBI/ClientApp/src/language/lang/zh-cn.js

@@ -602,6 +602,53 @@ const zh_cn = {
             changeError: '储存变更失败',
         },
         parameterError: '参数错误',
+    },
+    purchase: {
+        purchasePlatform: '统购平台',
+        productManagement: '县市产品名额',
+        prodSeatsInfo: '产品及名额资讯',
+        addNew: '新增',
+        cityOrDistrict: '县市',
+        selectCityOrDistrict: '请选择县市',
+        prodName: '产品名称',
+        selectProd: '请选择产品',
+        space: '空间',
+        inputSpace: '请输入容量',
+        unit: '单位',
+        expirationDate: '使用期限',
+        startDate: '开始时间',
+        endDate: '结束时间',
+        quota: '名额',
+        inputQuota: '请输入名额',
+        school: '学校',
+        schoolName: '学校名称',
+        inputNumber: '请输入数字',
+        receiveNumber: '领取人数',
+        operate: '操作',
+        remove: '移除',
+        selectSchool: '请选择学校',
+        confirmOk: '确定',
+        cancel: '取消',
+        addSchool: '追加学校',
+        extension: '扩充项',
+    },
+    auth:{
+        YMPCVCIM: '学情分析模组',
+        IPDYZYLC: '智慧学校管理服务',
+        _3CLYJ6NP: 'AClass ONE智慧学伴',
+        IPALJ6NY: '数据储存服务空间',
+        VABAJ6NV: '卷卡合一阅卷系统',
+        VLY6J6N6: '教研中心模组',
+        _0VPBDZPG: 'Haboard醍摩豆智慧大屏',
+        B9GPJ6NY: '苏格拉底频道管理',
+        LY9AJ6NY: '苏格拉底频道空间',
+        YL9CJ6NY: '苏格拉底通用议课教室数',
+        LL9MJ6NY: '苏格拉底通用议课连线数',
+        B6V5J6NP: '艺术评测服务',
+        LSZYJ6NA: '智慧体育服务',
+        CVGPJ6NN: '智慧德育服务',
+        LSZYJ6NA: '劳动教育服务',
+        YPXSJ6NJ: '五育看板',
     }
 }
 export default zh_cn

+ 47 - 0
TEAMModelBI/ClientApp/src/language/lang/zh-tw.js

@@ -598,6 +598,53 @@ const zh_tw = {
             changeError: '儲存變更失敗',
         },
         parameterError: '參數錯誤',
+    },
+    purchase: {
+        purchasePlatform: '統購平台',
+        productManagement: '縣市產品名額',
+        prodSeatsInfo: '產品及名額資訊',
+        addNew: '新增',
+        cityOrDistrict: '縣市',
+        selectCityOrDistrict: '請選擇縣市',
+        prodName: '產品名稱',
+        selectProd: '請選擇產品',
+        space: '空間',
+        inputSpace: '請輸入容量',
+        unit: '單位',
+        expirationDate: '使用期限',
+        startDate: '開始時間',
+        endDate: '結束時間',
+        quota: '名額',
+        inputQuota: '請輸入名額',
+        school: '學校',
+        schoolName: '學校名稱',
+        inputNumber: '請輸入數字',
+        receiveNumber: '領取人數',
+        operate: '操作',
+        remove: '移除',
+        selectSchool: '請選擇學校',
+        confirmOk: '確定',
+        cancel: '取消',
+        addSchool: '追加學校',
+        extension: '擴充項',
+    },
+    auth:{
+        YMPCVCIM: '學情分析模組',
+        IPDYZYLC: '智慧學校管理服務',
+        _3CLYJ6NP: 'AClass ONE智慧學伴',
+        IPALJ6NY: '數據儲存服務空間',
+        VABAJ6NV: '卷卡合一閱卷系統',
+        VLY6J6N6: '教研中心模组',
+        _0VPBDZPG: 'Haboard醍摩豆智慧大屏',
+        B9GPJ6NY: '蘇格拉底頻道管理',
+        LY9AJ6NY: '蘇格拉底頻道空間',
+        YL9CJ6NY: '蘇格拉底通用議課教室數',
+        LL9MJ6NY: '蘇格拉底通用議課連線數',
+        B6V5J6NP: '藝術評測服務',
+        LSZYJ6NA: '智慧體育服務',
+        CVGPJ6NN: '智慧德育服務',
+        LSZYJ6NA: '勞動教育服務',
+        YPXSJ6NJ: '五育看板',
     }
 }
 export default zh_tw

+ 2 - 0
TEAMModelBI/ClientApp/src/main.js

@@ -18,6 +18,8 @@ import PersonalPhoto from './components/public/personalPhoto/index.vue'
 import zhCn from "element-plus/lib/locale/lang/zh-cn";
 import 'dayjs/locale/zh-cn';
 
+store.dispatch('config/checkSrvAdr');// 檢查現在站的位置
+
 const app = createApp(App)
 app.config.globalProperties.$api = axios
 app.config.globalProperties.$access = inspect

+ 43 - 7
TEAMModelBI/ClientApp/src/router/index.js

@@ -1,7 +1,8 @@
-import { createWebHashHistory, createRouter } from "vue-router";
+import { createWebHashHistory, createRouter  } from "vue-router";
 import jwt_decode from 'jwt-decode'
 // import store from '@/store/index.js'
-const routes = [{
+const routes = [
+    {
         path: "/",
         redirect: "/login"
     },
@@ -16,12 +17,26 @@ const routes = [{
         name: "test",
         roles: "all",
         component: () => require.ensure([], (require) => require(`@/view/index/test.vue`))
-    },
+    },   
     // {
     //     path: "/dashboard",
     //     name: "dashboard",
     //     component: () => require.ensure([], (require) => require(`@/view/index/dashboard.vue`))
     // },
+    // {
+    //     path: "/htcommunity",
+    //     name: "htcommunity",
+    //     component: () => require.ensure([], (require) => require(`@/view/htcommunity/adminpanel.vue`)),
+    //     children: [{
+    //             name: "adminpanel",
+    //             path: "adminpanel",
+    //             permission: "teacher-read|teacher-upd",
+    //             roles: ['all'],
+    //             isShow: true,
+    //             component: () => require.ensure([], (require) => require(`@/view/htcommunity/adminpanel.vue`))
+    //         },            
+    //     ]
+    // },
     {
         path: "/home",
         name: "home",
@@ -61,6 +76,14 @@ const routes = [{
                 isShow: true,
                 component: () => require.ensure([], (require) => require(`@/view/product/index.vue`))
             },
+            // 統購平台
+            {
+                path: "adminpanel",
+                name: "adminpanel",
+                permission: "teacher-read|teacher-upd",
+                roles: ['admin'],                
+                component: () => require.ensure([], (require) => require(`@/view/htcommunity/adminpanel.vue`))
+            },
             //区校管理(学区管理)--研发部
             {
                 name: "areaManagement",
@@ -231,7 +254,16 @@ const routes = [{
                 roles: ['admin'],
                 isShow: true,
                 component: () => require.ensure([], (require) => require(`@/view/systemConfig/server/index.vue`))
-            }
+            },
+            //優惠券發行
+            {
+                name: 'issuecoupons',
+                path: 'issuecoupons',
+                permission: "",
+                roles: ['admin'],
+                isShow: true,
+                component: () => require.ensure([], (require) => require(`@/view/issueCoupons/index.vue`))
+            },
         ]
     },
     //消息通知跳转页面
@@ -267,11 +299,15 @@ const routes = [{
     // },
 ];
 const router = createRouter({
-    history: createWebHashHistory(),
+    history: createWebHashHistory(),    
     routes,
 });
-router.beforeEach((to, from, next) => {
-    console.log(to, 'router')
+router.beforeEach((to, from, next) => {    
+    console.log(to, 'router')      
+    if (to.query.htype === 'adminlogin')
+    {        
+        localStorage.setItem("htype",'adminlogin');
+    }
     if (to.path === '/login' || to.path === '/resultPage') return next()
     if (to.path === '/login-thirdparty') return next()
     let thirdUser = localStorage.getItem('thirdUser')

Dosya farkı çok büyük olduğundan ihmal edildi
+ 1 - 0
TEAMModelBI/ClientApp/src/static/country.json


+ 5 - 1
TEAMModelBI/ClientApp/src/store/index.js

@@ -1,4 +1,6 @@
 import { createStore } from 'vuex'
+import config from './module/config'
+
 export default createStore({
     state: {
         organizationData: [], //组织架构数据
@@ -113,5 +115,7 @@ export default createStore({
     },
     actions: {},
     getters: {},
-    modules: {}
+    modules: {
+        config
+    }
 })

+ 80 - 0
TEAMModelBI/ClientApp/src/store/module/config.js

@@ -0,0 +1,80 @@
+export default {
+    namespaced: true,
+    state: {
+        srvAdr: '', // 伺服器位置 China, Global
+        srvAdrType: '', // 正式站 product 測試站 test
+        China: {
+            srvAdr: 'China',
+            domainUrl: [
+                {
+                    station: 'product',
+                    url: 'https://bi.teammodel.cn'
+                },
+                {
+                    station: 'rc',
+                    url: 'https://bi-rc.teammodel.cn'
+                },
+            ]
+        },
+        Global: {
+            srvAdr: 'Global',
+            domainUrl: [
+                {
+                    station: 'product',
+                    url: 'https://bi.teammodel.net'
+                },
+                {
+                    station: 'rc',
+                    url: 'https://bi-rc.teammodel.net'
+                },
+            ]
+        }
+    },
+    getters: {
+        getSrvAdr: state => state.srvAdr,
+    },
+    mutations: {
+        setSrvAdr(state, data) {
+            state.srvAdr = data
+        },
+        setSrvAdrType(state, data) {
+            state.srvAdrType = data
+        }
+    },
+    actions: {
+        checkSrvAdr(context) {
+            let domainUrl = window.location.hostname
+
+            let domainUrlArray = []
+
+            context.state.China.domainUrl.forEach(function (item) {
+                item.srvAdr = 'China'
+                domainUrlArray.push(item)
+            })
+            context.state.Global.domainUrl.forEach(function (item) {
+                item.srvAdr = 'Global'
+                domainUrlArray.push(item)
+            })
+
+            let stationSetting = domainUrlArray.find(function (item) {
+                return item.url.indexOf(domainUrl) >= 0
+            })
+
+            if (!stationSetting) {
+                stationSetting = {}
+                stationSetting.station = 'test'
+                stationSetting.srvAdr = 'Global'
+            }
+            context.commit('setSrvAdr', stationSetting.srvAdr)
+            context.commit('setSrvAdrType', stationSetting.station)
+
+            localStorage.setItem('srvAdr', stationSetting.srvAdr)
+            localStorage.setItem('station', stationSetting.station)
+
+        },
+        setSrvAdr(context, param) {
+            localStorage.setItem('srvAdr', param)
+            context.commit('setSrvAdr', param)
+        }
+    }
+}

+ 2 - 1
TEAMModelBI/ClientApp/src/until/common.js

@@ -74,10 +74,11 @@ export default {
         });
         return totaldays
     },
-    timestampToTime(timestamp, state) {
+    timestampToTime(timestamp, state, isUtc=false) {
         if (timestamp === 0) { return 0 }
         let multiple = timestamp.toString().length === 13 ? 1 : 1000
         var date = new Date(Number(timestamp) * multiple); //时间戳为10位需*1000,时间戳为13位的话不需乘1000
+        if (isUtc) date = new Date(date.toLocaleString('en-US', { timeZone: 'UTC' }));
         var Y = date.getFullYear() + '-';
         var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
         var D = (date.getDate() < 10 ? '0' + date.getDate() : date.getDate()) + '   ';

+ 7 - 4
TEAMModelBI/ClientApp/src/until/http.js

@@ -3,7 +3,7 @@ axios.defaults.timeout = 1000000; //设置超时时长
 axios.defaults.baseURL = '';
 //http request 拦截器
 axios.interceptors.request.use(
-    config => {
+    config => {        
         // const token = getCookie('名称');
         config.data = JSON.stringify(config.data);
         console.log(config, '访问内容')
@@ -21,8 +21,7 @@ axios.interceptors.request.use(
             config.url.indexOf('bizconfig') != -1 ||
             config.url.indexOf('paper') != -1 ||
             config.url.indexOf('notice') != -1 ||
-            config.url.indexOf('bizuser') != -1 ||
-            config.url.indexOf('prodanalysis') != -1 
+            config.url.indexOf('bizuser') != -1
         ) {
             config.headers = {
                 'Content-Type': 'application/json',
@@ -33,7 +32,11 @@ axios.interceptors.request.use(
                 'Content-Type': 'application/json',
                 // 'site': 'china'
             }
-        } else if (config.url.indexOf('ies5') != -1 || config.url.indexOf('tmidstics') != -1 || config.url.indexOf('/service/PushNotify') != -1) {
+        } else if (config.url.indexOf('ies5') != -1 ||
+            config.url.indexOf('tmid') != -1 ||
+            config.url.indexOf('/service/PushNotify') != -1 ||
+            config.url.indexOf('prodanalysis') != -1 ||
+            config.url.indexOf('bbauthapi') != -1) {
             config.headers = {
                 'Content-Type': 'application/json',
                 'authorization': 'Bearer ' + JSON.parse(localStorage.access_token)

+ 26 - 3
TEAMModelBI/ClientApp/src/view/areaServe/areamanage.vue

@@ -185,7 +185,7 @@
             <div class="haveSchool">
               <div class="schoolLeft" v-loading="loadingSchoolList" element-loading-text="数据加载中..." v-if="PowerShow">
                 <div class="haveSchool-title">
-                  <div class="select-text">{{ $t(`areaManages.operational.areaAddSchool.schooltitle`) }}</div>
+                  <div class="select-text">{{ $t(`areaManages.operational.areaAddSchool.schooltitle`) }}</div>                                  
                   <div class="select-click">
                     <el-dropdown trigger="click" @command="handleCommand">
                       <span class="el-dropdown-link">
@@ -218,6 +218,10 @@
                   </div>
                   <div class="synchronization-title" v-show="currentlySelect.cutArea"><span>已同步省平台</span></div>
                 </div>
+                <div  class="search-school-btn">
+                <el-button type="primary"  @click="selectAll" size="small">全選</el-button>
+                  <el-button type="primary"  @click="deselectAll" size="small">全不選</el-button>
+                </div>
                 <ul>
                   <li class="details-list-school" v-for="(item, index) in notjoinSchool" :key="item.id" :class="{ active: position === index }">
                     <div class="details-list-checkboxs" @change="multipleChange">
@@ -1449,7 +1453,10 @@ export default {
     //学校列表 未加入学区
     function notjoinSchoolarea () {
       let values = schoolSeach.value
-      let newdata = notjoinPrimitive.value.filter((item) => { return item.name.includes(values) })
+      let newdata = notjoinPrimitive.value.filter((item) => {        
+        // 撈出名稱跟地址包含關鍵字的學校
+         return item.name.includes(values) || item.city?.includes(values) 
+        })        
       notjoinSchool.value = JSON.parse(JSON.stringify(newdata))
     }
     //学校显示(虚拟、实体)
@@ -1518,6 +1525,20 @@ export default {
       return jsonData.map((v) => filterVal.map((j) => v[j]))
     }
 
+    function selectAll() {                
+      notjoinSchool.value.forEach(item => {
+        item.checkstate = true;
+      });      
+      multiplecheck.value = true;
+    }
+    function deselectAll() {      
+      notjoinSchool.value.forEach(item => {
+        item.checkstate = false;
+      });    
+      multiplecheck.value = false;
+    }
+
+
     watch(abilityModel, (newdata) => {
       console.log(newdata)
       newdata
@@ -1653,7 +1674,9 @@ export default {
       exportAreadata,
       exportData,
       exportExcel,
-      formatJson
+      formatJson,
+      selectAll,
+      deselectAll
     }
   },
 }

+ 45 - 3
TEAMModelBI/ClientApp/src/view/common/aside.vue

@@ -42,7 +42,7 @@
 //基础菜单
 
 import { Location, Document, Menu as IconMenu, Setting } from '@element-plus/icons'
-import { getCurrentInstance, ref, watch, onMounted, reactive, toRefs } from 'vue'
+import { getCurrentInstance, ref, watch, onMounted, reactive, toRefs, computed } from 'vue'
 import { useStore } from 'vuex'
 import { useRouter } from 'vue-router'
 import router from '@/router/index.js'
@@ -55,6 +55,9 @@ export default {
     IconMenu,
   },
   setup () {
+    const store = useStore()
+    const srvType = computed(() => store.getters["config/getSrvAdr"]);
+    
     console.log('调用了一次这个页面')
     let { proxy } = getCurrentInstance()
     let menuWidth = ref('64px')
@@ -134,7 +137,7 @@ export default {
             sort: 7,
           },
           {
-            name: '用户查询',
+            name: '用户相關',
             router: '/home/userinquire',
             icon: '#icon-a-97-yonghuchaxun',
             permission: [],
@@ -149,6 +152,24 @@ export default {
           //   isShow: true,
           //   sort: 19,
           // },
+          {
+            name: '發優惠券',
+            router: '/home/issuecoupons',
+            icon: '#icon-Ticket',
+            permission: [],
+            isShow: true,
+            sort: 6,
+            srvType: 'Global'
+          },
+          {
+            name: '統購設定',
+            router: '/home/adminpanel',
+            icon: '#icon-laoshi1',
+            permission: [],
+            isShow: true,
+            sort: 7,
+            srvType: 'Global'
+          },
         ],
       },
       {
@@ -310,8 +331,8 @@ export default {
       },
     ]
     const isCollapse = ref(true)
-    const store = useStore()
     const shenfen = ref('admin')
+
     //路由
     const routers = useRouter()
     let indexMenu = reactive({ currentRoutePath: routers.currentRoute.value.path })
@@ -358,6 +379,15 @@ export default {
         let name = userRoles[n]
         console.log(name)
         for (let i in schoolMenus) {
+
+          // 統購平台大陸先遮蔽
+          if (schoolMenus[i].name === '区校管理') {
+            let siteValue = window.location.host === 'bi.teammodel.cn' ? 'cn' : window.location.host === 'bitest.teammodel.cn' ? 'cn' : 'international'
+            //debugger
+            if (siteValue === 'cn') {
+              schoolMenus[1].child.splice(7, 1);
+            }
+          }
           // if (schoolMenus[i].name === '区校掌握') { continue }
           schoolMenus[i].role.indexOf('all') != -1 ? menuList.value.push(schoolMenus[i]) : ''
           schoolMenus[i].role.includes(name) ? menuList.value.push(schoolMenus[i]) : ''
@@ -392,6 +422,18 @@ export default {
           }
         }
       }
+
+      // 新增功能限制
+      for (let i in menuList.value) {
+        let menuChild = menuList.value[i]
+        for (let y in menuChild.child) {
+          let menuSrvType = menuChild.child[y].srvType
+          if(menuSrvType && menuSrvType != srvType.value){
+            menuChild.child.splice(y, 1)
+          }
+        }
+      }
+
       console.log(menuList.value, result, '菜单')
       //router内容
       let nowUrl = routers.currentRoute.value.path

Dosya farkı çok büyük olduğundan ihmal edildi
+ 605 - 0
TEAMModelBI/ClientApp/src/view/htcommunity/adminpanel.vue


+ 20 - 17
TEAMModelBI/ClientApp/src/view/index/index.vue

@@ -3045,19 +3045,22 @@ export default {
       //    && item.service.includes('IPDYZYLC') && item.service.includes('YMPCVCIM') && item.service.includes('YPXSJ6NJ') 
       //    ? marjorArr.push(item) : '' }) : ''
       //  11.14日修正  关于学校版本问题   根据edition   current /1基础   /2标准   /3专业
-      // schoolList ? schoolList.forEach((item) => {
-      //    item.edition   && item.edition.current === 3 && item.code ==='BIRel' ? marjorArr.push(item):''
-      //   //  item.service.includes('IPDYZYLC') && item.service.includes('YMPCVCIM') &&  item.service.includes('YPXSJ6NJ') && item.code ==='BIRel'  ?  marjorArr.push(item):''
-      //  }) : ''
+      schoolList ? schoolList.forEach((item) => {
+         item.edition   && item.edition.current === 3 && item.code ==='BIRel' ? marjorArr.push(item):''
+        //  item.service.includes('IPDYZYLC') && item.service.includes('YMPCVCIM') &&  item.service.includes('YPXSJ6NJ') && item.code ==='BIRel'  ?  marjorArr.push(item):''
+       }) : ''
        // 標準版
       //  schoolList ? schoolList.forEach((item) => { 
       //   (item.edition == null || item.edition.scaleVersion == null) && item.code ==='BIRel'
       //   && item.service.includes('IPDYZYLC') && item.service.includes('YMPCVCIM') && (!item.service.includes('YPXSJ6NJ')) ? standardArr.push(item) : '' }) : ''
-      // schoolList ? schoolList.forEach((item) => { 
-      //   item.edition  && item.edition.current === 2 && item.code ==='BIRel' ? standardArr.push(item):''
-      //   // item.service.includes('IPDYZYLC') && item.service.includes('YMPCVCIM') && item.code ==='BIRel' ? standardArr.push(item):''
-      // }) : ''
+      schoolList ? schoolList.forEach((item) => { 
+        item.edition  && item.edition.current === 2 && item.code ==='BIRel' ? standardArr.push(item):''
+        // item.service.includes('IPDYZYLC') && item.service.includes('YMPCVCIM') && item.code ==='BIRel' ? standardArr.push(item):''
+      }) : ''
        // 基礎版
+      schoolList ? schoolList.forEach((item) => { 
+        item.code === 'BIRel' && (item.edition == null || (item.edition && item.edition.current == null) || (item.edition && item.edition.current === 1 && (item.edition.scaleVersion == null || item.edition.scaleVersion == ''))) ? basicsArr.push(item):''
+      }) : ''
       //  schoolList ? schoolList.forEach((item) => { 
       //   (item.edition == null || item.edition.scaleVersion == null) && item.code ==='BIRel'
       //   && !item.service.includes('IPDYZYLC') && !item.service.includes('YMPCVCIM') ? basicsArr.push(item) : '' }) : ''
@@ -3067,16 +3070,16 @@ export default {
       //   // !item.service.includes('IPDYZYLC') && !item.service.includes('YMPCVCIM') && item.code ==='BIRel' ? basicsArr.push(item):''
       // }) : ''
        // 评测版
-      //  schoolList ? schoolList.forEach((item) => { 
-      //   item.edition !== null && item.edition.current === 1 && item.code ==='BIRel' && item.service.includes('B6V5J6NP') ? 
-      //   customArr.push(item) : '' }) : ''    
+      schoolList ? schoolList.forEach((item) => { 
+        item.edition !== null && item.code === 'BIRel' && item.edition.scaleVersion == '评测版' ? customArr.push(item) : ''
+      }) : ''    
 
-        schoolList ? schoolList.forEach((item) => {
-          item.service.includes('YPXSJ6NJ') && item.service.includes('B6V5J6NP') && item.service.includes('YMPCVCIM') && item.code ==='BIRel' ? marjorArr.push(item):
-          item.service.includes('IPDYZYLC') && item.service.includes('YMPCVCIM') && (!item.service.includes('YPXSJ6NJ')) && item.code ==='BIRel' ? standardArr.push(item):
-          !item.service.includes('IPDYZYLC') && !item.service.includes('YMPCVCIM') && item.service.includes('B6V5J6NP') && item.code ==='BIRel'   ? customArr.push(item):
-          !item.service.includes('IPDYZYLC') && !item.service.includes('YMPCVCIM') && item.code ==='BIRel'  ? basicsArr.push(item):''
-        }):''
+        // schoolList ? schoolList.forEach((item) => {
+        //   item.service.includes('YPXSJ6NJ') && item.service.includes('B6V5J6NP') && item.service.includes('YMPCVCIM') && item.code ==='BIRel' ? marjorArr.push(item):
+        //   item.service.includes('IPDYZYLC') && item.service.includes('YMPCVCIM') && (!item.service.includes('YPXSJ6NJ')) && item.code ==='BIRel' ? standardArr.push(item):
+        //   !item.service.includes('IPDYZYLC') && !item.service.includes('YMPCVCIM') && item.service.includes('B6V5J6NP') && item.code ==='BIRel'   ? customArr.push(item):
+        //   !item.service.includes('IPDYZYLC') && !item.service.includes('YMPCVCIM') && item.code ==='BIRel'  ? basicsArr.push(item):''
+        // }):''
         //计算版本占比
         console.log(basicsArr,standardArr,marjorArr,customArr,'数组')
         versionsData.value.basics.num = basicsArr.length >0 ?basicsArr.length :0

+ 156 - 0
TEAMModelBI/ClientApp/src/view/issueCoupons/consolidationCoupon.vue

@@ -0,0 +1,156 @@
+<template>
+    <div>
+        <el-form ref="ruleFormRef" :model="consolidationForm" :rules="rules" label-width="120px">
+            <el-form-item label="站別" prop="srvAdr">
+                <el-radio-group v-model="consolidationForm.srvAdr">
+                    <el-radio label="Global" size="large" border>國際站</el-radio>
+                    <el-radio label="China" size="large" border>大陸站</el-radio>
+                </el-radio-group>
+            </el-form-item>
+            <el-form-item label="券號" prop="coupon">
+                <el-input style="width: 500px;" v-model="consolidationForm.coupon" placeholder="請輸入券號" />
+            </el-form-item>
+            <el-form-item label="醍摩豆ID" prop="targets">
+                <div style="display: flex;align-items: flex-end;">
+                    <el-input style="width: 300px;" v-model="consolidationForm.targets" :rows="6" type="textarea" placeholder="請填入教師ID, 並用換行分隔" />
+                    <div style="margin-left: 5px;">總共 {{ targetsCount }} 位</div>
+                </div>
+            </el-form-item>
+            <el-form-item>
+                <el-button type="primary" @click="submitForm(ruleFormRef)" :loading="loading">歸戶</el-button>
+                <el-button @click="resetForm(ruleFormRef)" :loading="loading">重置</el-button>
+            </el-form-item>
+        </el-form>
+    </div>
+</template>
+<script setup>
+import { reactive, ref, computed, getCurrentInstance, markRaw } from 'vue'
+import { Warning, SuccessFilled } from '@element-plus/icons'
+import { ElMessageBox } from 'element-plus'
+let { proxy } = getCurrentInstance()
+const targetsCount = ref(0)
+const ruleFormRef = ref()
+const loading = ref(false)
+const consolidationForm = reactive({
+    srvAdr: '',
+    coupon: '',
+    targets: ""
+})
+
+const checkTargets = (rule, value, callback) => {
+    let isErr = false
+    function isArrayRep(array){
+        var result = new Set();
+        var repeat = new Set();
+        array.forEach(item => {
+            result.has(item) ? repeat.add(item) : result.add(item);
+        })
+        // console.log(result); // {1, 2, "a", 3, "b"}
+        // console.log(repeat); // {1, "a"}
+        // console.log(repeat.size)
+        if(repeat.size != 0){
+            return true
+        } else {
+            return false
+        }
+    }
+    if(value && !/^[0-9\n]+$/.test(value)){
+        isErr = true
+        callback(new Error("只能輸入醍摩豆ID與換行"))
+    } else if(value && isArrayRep(value.split('\n'))){
+        isErr = true
+        callback(new Error("醍摩豆ID有重複"))
+    } else if(value){
+        let errIds = []
+        let tmp = value.split('\n')
+        tmp.forEach(e=> {
+            if(e.length != 10) {
+                errIds.push(e)
+            } else {
+                let now = Math.floor(new Date().getTime() / 1000)
+                let orgId = parseInt(e)
+                if(parseInt(e.substring(0, 1)) >= 6){
+                    orgId -= 5000000000
+                }
+
+                if(orgId > now){
+                    errIds.push(e)
+                }
+            }
+        })
+
+        if(errIds.length > 0){
+            // console.log(errIds, 'errIds')
+            isErr = true
+            callback(new Error("請檢查醍摩豆ID是否符合格式或有空格"))
+        }
+    }
+
+    if(!isErr && value != ''){
+        let tArray = value.split('\n')
+        targetsCount.value = tArray.length
+    } else {
+        targetsCount.value = 0
+    }
+
+    callback()
+}
+
+const rules = reactive({
+    srvAdr: [{required: true, trigger: "blur", message: '請選擇一個站別' }],
+    coupon: [{required: true, trigger: "blur", message: '請選擇一個發券類型' }],
+    targets: [{required: true, validator: checkTargets, trigger: "blur"}],
+})
+
+const submitForm = formEl => {
+  if (!formEl) return
+  formEl.validate(async (valid, ddd) => {
+    if (valid) {
+
+        ElMessageBox.confirm(
+            '開始歸戶?',
+            '',
+            {
+                type: 'info',
+                confirmButtonText: '歸戶'
+            }
+        ).then(async ()=>{
+            loading.value = true
+            let consolidationData = {
+                srvAdr: consolidationForm.srvAdr,
+                ids: consolidationForm.targets.split('\n'),
+                coupon: consolidationForm.coupon
+            }
+            await proxy.$api.consolidationCoupon(consolidationData).then((res) => {
+                console.log(res, '歸戶成功')
+                ElMessageBox.alert('成功', '歸戶',
+                    {
+                        type: 'info',
+                        icon: markRaw(SuccessFilled),
+                    }
+                )
+                resetForm(formEl) // 欄位清除
+            }).catch(e=>{
+                ElMessageBox.alert('歸戶失敗', '歸戶',
+                    {
+                        type: 'warning',
+                        icon: markRaw(Warning),
+                    }
+                )
+            }).finally(() => {
+                loading.value = false
+            })
+        })
+    } else {
+        console.log("error submit!")
+        return false
+    }
+  })
+}
+
+const resetForm = formEl => {
+    if (!formEl) return
+    formEl.resetFields()
+}
+
+</script>

Dosya farkı çok büyük olduğundan ihmal edildi
+ 1164 - 0
TEAMModelBI/ClientApp/src/view/issueCoupons/crteadCoupon.vue


+ 22 - 0
TEAMModelBI/ClientApp/src/view/issueCoupons/index.vue

@@ -0,0 +1,22 @@
+<template>
+  <el-tabs type="border-card">
+      <el-tab-pane label="建立優惠券"><CrteadCoupon /></el-tab-pane>
+    <el-tab-pane label="優惠券歸戶"><ConsolidationCoupon /></el-tab-pane>
+    <el-tab-pane label="通知"><Notice /></el-tab-pane>
+  </el-tabs>
+</template>
+<script>
+import CrteadCoupon from './crteadCoupon.vue'
+import ConsolidationCoupon from './consolidationCoupon.vue'
+import Notice from './notice.vue'
+export default {
+  components: {
+    CrteadCoupon,
+    ConsolidationCoupon,
+    Notice
+  },
+  setup () {
+
+  }
+}
+</script>

+ 368 - 0
TEAMModelBI/ClientApp/src/view/issueCoupons/notice.vue

@@ -0,0 +1,368 @@
+<template>
+    <div>
+        <el-form ref="ruleFormRef" :model="noticeForm" :rules="rules" label-width="120px">
+            <el-form-item label="站別" prop="srvAdr">
+                <el-radio-group v-model="noticeForm.srvAdr">
+                    <el-radio label="Global" size="large" border>國際站</el-radio>
+                    <el-radio label="China" size="large" border>大陸站</el-radio>
+                </el-radio-group>
+            </el-form-item>
+            <el-form-item label="標題" prop="title">
+                <el-input style="width: 500px;" v-model="noticeForm.title" placeholder="請輸入標題" />
+            </el-form-item>
+            <el-form-item label="內容" prop="body">
+                <el-input style="width: 500px;" :rows="6" type="textarea" v-model="noticeForm.body" placeholder="請輸入通知內容" />
+            </el-form-item>
+            <el-form-item label="功能" prop="data">
+                <div style="display: flex;flex-direction: column;">
+                    <div style="display: flex;flex-direction: column;">
+                        <div style="width: 750px;display: flex;margin-bottom:3px;" v-for="(item, index) in noticeForm.data.img" :key="index">
+                            <div style="display: flex;align-items: center;">
+                                <img style="max-width: 150px;margin-right: 3px;" :src="item" alt="沒有圖片" >
+                            </div>
+                            <el-input style="width: 500px;    height: 161px;"  placeholder="請輸入圖片網址" v-model="noticeForm.data.img[index]" />
+                            <div style="display: flex;flex-direction: column;justify-content: space-between;padding: 7px 0px 7px 5px;">
+                                <el-button size="small" @click="delIMGItem(index)" :icon="Close" circle style="margin: 0;"/>
+                                <el-button size="small" @click="addIMGItem(index)" :icon="Plus" circle style="margin: 0;"/>
+                            </div>
+                        </div>
+                    </div>
+                    <div style="display: flex;flex-wrap: nowrap;overflow-x: scroll;max-width: 750px;">
+                        <div v-for="(item, index) in noticeForm.data.action" :key="index" style="min-width: 350px;margin: 6px;display: flex;">
+                            <div style="    padding: 7px;text-align: left;border: 1px solid rgb(189, 189, 189);border-radius: 3px;">
+                                <div>
+                                    <span style="margin-right: 3px;">類型:</span>
+                                    <el-radio-group v-model="item.type">
+                                        <el-radio label="click"  border>按鈕</el-radio>
+                                        <el-radio label="link"  border>超連結</el-radio>
+                                    </el-radio-group>
+                                </div>
+                                <div>
+                                    <span style="margin-right: 3px;">按鈕名稱:</span><el-input v-model="item.label"/>
+                                </div>
+                                <div>
+                                    <span style="margin-right: 3px;">網址:</span><el-input v-model="item.url"/>
+                                </div>
+                                <div>
+                                    <span style="margin-right: 3px;">是否連到產品:</span><el-switch active-text="是" inactive-text="否" v-model="item.quickLogin" />
+                                </div>
+                                <div>
+                                    <span style="margin-right: 3px;">預覽:</span>
+                                    <el-button @click="testButton(item)" :link="item.type == 'link'" size="small" type="primary">{{ item.label ? item.label : "按鈕名稱" }}</el-button>
+                                </div>
+                            </div>
+                            <div style="display: flex;flex-direction: column;justify-content: space-between;height: 100%;padding: 7px;">
+                                <el-button size="small" @click="delActionItem(index)" :icon="Close" circle style="margin: 0;"/>
+                                <el-button size="small" @click="addActionItem(index)" :icon="Plus" circle style="margin: 0;"/>
+                            </div>
+                        </div>
+                    </div>
+                </div>
+            </el-form-item>
+            <el-form-item label="醍摩豆ID" prop="targets">
+                <div style="display: flex;align-items: flex-end;">
+                    <el-input style="width: 300px;" v-model="noticeForm.targets" :rows="6" type="textarea" placeholder="請填入教師ID, 並用換行分隔" />
+                    <div style="margin-left: 5px;">總共 {{ targetsCount }} 位</div>
+                </div>
+            </el-form-item>
+            <el-form-item label="發送者" prop="sender">
+                <el-radio-group v-model="noticeForm.sender">
+                    <el-radio label="HiTeach" size="large" border>HiTeach</el-radio>
+                    <el-radio label="IES" size="large" border>IES</el-radio>
+                    <el-radio label="Sokrates" size="large" border>Sokrates</el-radio>
+                    <el-radio label="Auth" size="large" border>Auth</el-radio>
+                    <el-radio label="Event" size="large" border>Event</el-radio>
+                    <el-radio label="IES MGR" size="large" border>IES MGR</el-radio>
+                    <!-- <el-radio label="HiTA" size="large" border>HiTA</el-radio> -->
+                </el-radio-group>
+            </el-form-item>
+            <el-form-item>
+                <el-button type="primary" @click="submitForm(ruleFormRef)" :loading="loading">發送</el-button>
+                <el-button @click="resetForm(ruleFormRef)" :loading="loading">重置</el-button>
+            </el-form-item>
+        </el-form>
+    </div>
+</template>
+<script setup>
+import { reactive, ref, computed, getCurrentInstance, markRaw } from 'vue'
+import { Warning, SuccessFilled, Plus, Close } from '@element-plus/icons'
+import { ElMessageBox } from 'element-plus'
+let { proxy } = getCurrentInstance()
+const targetsCount = ref(0)
+const ruleFormRef = ref()
+const loading = ref(false)
+const noticeForm = reactive({
+    srvAdr: '',
+    title: '',
+    body: '',
+    data: {
+        img: [""],
+        action:[
+            {
+                type: "click",
+                label: "",
+                url: "",
+                quickLogin: false
+            }
+        ],
+    },
+    targets: "",
+    sender: '',
+    hubName: 'hita5' // 暫時固定
+})
+
+const testButton = (item) => {
+    let url = item.url
+    if(item.quickLogin) {
+        if(url.indexOf("?") >= 0){
+            url += "&code="
+        } else {
+            url += "?code="
+        }
+    }
+    window.open(url, "_blank")
+}
+
+const addIMGItem = (index) =>{
+    noticeForm.data.img.splice(index+1, 0, "")
+}
+
+const delIMGItem = (index) =>{
+    if(noticeForm.data.img.length == 1){
+        noticeForm.data.img.splice(index, 1, "")
+    } else {
+        noticeForm.data.img.splice(index, 1)
+    }
+}
+
+const addActionItem = (index) => {
+    noticeForm.data.action.splice(index+1, 0,  {
+        type: "click",
+        label: "",
+        url: "",
+        quickLogin: false
+    })   
+}
+
+const delActionItem = (index) =>{
+    if(noticeForm.data.action.length == 1){
+        noticeForm.data.action.splice(index, 1, {
+            type: "click",
+            label: "",
+            url: "",
+            quickLogin: false
+        })
+    } else {
+        noticeForm.data.action.splice(index, 1)
+    }
+}
+
+const checkTargets = (rule, value, callback) => {
+    let isErr = false
+    function isArrayRep(array){
+        var result = new Set();
+        var repeat = new Set();
+        array.forEach(item => {
+            result.has(item) ? repeat.add(item) : result.add(item);
+        })
+        // console.log(result); // {1, 2, "a", 3, "b"}
+        // console.log(repeat); // {1, "a"}
+        // console.log(repeat.size)
+        if(repeat.size != 0){
+            return true
+        } else {
+            return false
+        }
+    }
+    if(value && !/^[0-9\n]+$/.test(value)){
+        isErr = true
+        callback(new Error("只能輸入醍摩豆ID與換行"))
+    } else if(value && isArrayRep(value.split('\n'))){
+        isErr = true
+        callback(new Error("醍摩豆ID有重複"))
+    } else if(value){
+        let errIds = []
+        let tmp = value.split('\n')
+        tmp.forEach(e=> {
+            if(e.length != 10) {
+                errIds.push(e)
+            } else {
+                let now = Math.floor(new Date().getTime() / 1000)
+                let orgId = parseInt(e)
+                if(parseInt(e.substring(0, 1)) >= 6){
+                    orgId -= 5000000000
+                }
+
+                if(orgId > now){
+                    errIds.push(e)
+                }
+            }
+        })
+
+        if(errIds.length > 0){
+            // console.log(errIds, 'errIds')
+            isErr = true
+            callback(new Error("請檢查醍摩豆ID是否符合格式或有空格"))
+        }
+    }
+
+    if(!isErr && value != ''){
+        let tArray = value.split('\n')
+        targetsCount.value = tArray.length
+    } else {
+        targetsCount.value = 0
+    }
+
+    callback()
+}
+
+const checkData = (rule, value, callback) => {
+    let action = value.action
+    let errFlag = false
+    action.forEach(item => {
+        if((item.label != "" &&  item.url == "") || (item.label == "" &&  item.url != "")){
+            errFlag = true
+        }
+    })
+
+    if(errFlag){
+        callback(new Error("請將按鈕設定完成"))
+    } else {
+        callback()
+    }
+}
+
+const rules = reactive({
+    srvAdr: [{required: true, trigger: "blur", message: '請選擇一個站別' }],
+    title: [{required: true, trigger: "blur", message: '請填寫標題' }],
+    body: [{required: true, trigger: "blur", message: '請填寫通知內容' }],
+    targets: [{required: true, validator: checkTargets, trigger: "blur"}],
+    sender: [{required: true, trigger: "blur", message: '請選擇一個產品接收'}],
+    data: [{validator: checkData, trigger: "blur"}],
+})
+
+const submitForm = formEl => {
+  if (!formEl) return
+  formEl.validate(async (valid, ddd) => {
+    if (valid) {
+
+        ElMessageBox.confirm(
+            '發送此通知?',
+            '',
+            {
+                type: 'info',
+                confirmButtonText: '發送'
+            }
+        ).then(async ()=>{
+            loading.value = true
+            let request = {
+                srvAdr: noticeForm.srvAdr,
+                title: noticeForm.title,
+                body: noticeForm.body,
+                data: null,
+                tags: [],
+                sender: noticeForm.sender,
+                hubName: noticeForm.hubName,
+            }
+            
+            // 轉型成ARRAY
+            noticeForm.targets.split('\n').forEach(e =>{
+                request.tags.push(e + '_' +request.sender)
+            })
+            
+            //輸出圖片
+            let imgExist = false
+            noticeForm.data.img.forEach(item => {
+                if(item != "") {
+                    imgExist = true
+                }
+            })
+            if(imgExist){
+                // 宣告
+                if(request.data == null) request.data = {}
+                request.data.img = []
+                noticeForm.data.img.forEach(item => {
+                    if(item != "") {
+                        request.data.img.push(item)
+                    }
+                })
+            }
+
+            // 輸出按鈕
+            let actionExist = false
+            noticeForm.data.action.forEach(item => {
+                if(item.label != "" && item.url != "") {
+                    actionExist = true
+                }
+            })
+            if(actionExist){
+                // 宣告
+                if(request.data == null) request.data = {}
+                request.data.action = []
+                noticeForm.data.action.forEach(item => {
+                    if(item.label != "" && item.url != "") {
+                        if(item.quickLogin) {
+                            if(item.url.indexOf("?") >= 0){
+                                item.url += "&code="
+                            } else {
+                                item.url += "?code="
+                            }
+                        }
+                        // 新增全小寫的key給通知設定
+                        item.quickLogin ? item.quicklogin = 1 : item.quicklogin = 0
+                        request.data.action.push(item)
+                    }
+                })
+            }
+
+            if(request.data != null && Object.keys(request.data).length > 0){
+                request.data = JSON.stringify(request.data)
+            }
+            
+            console.log(request)
+
+            await proxy.$api.pushNotify(request).then((res) => {
+                console.log(res, '發送成功')
+                ElMessageBox.alert('成功', '發送通知',
+                    {
+                        type: 'info',
+                        icon: markRaw(SuccessFilled),
+                    }
+                )
+                resetForm(formEl) // 欄位清除
+            }).catch(e=>{
+                ElMessageBox.alert('失敗', '發送通知',
+                    {
+                        type: 'warning',
+                        icon: markRaw(Warning),
+                    }
+                )
+            }).finally(() => {
+                loading.value = false
+            })
+        })
+    } else {
+        console.log("error submit!")
+        return false
+    }
+  })
+}
+
+const resetForm = formEl => {
+    if (!formEl) return
+    formEl.resetFields()
+
+    noticeForm.data = {
+        img: [""],
+        action:[
+            {
+                type: "click",
+                label: "",
+                url: "",
+                quickLogin: false
+            }
+        ],
+    }
+}
+
+</script>

+ 13 - 1
TEAMModelBI/ClientApp/src/view/login.vue

@@ -117,7 +117,19 @@ export default {
         getOrganization()
         Allpermission()
         if (res.roles.includes('admin') || res.roles.includes('leader')) {
-          router.push('/home/index')
+          // 檢查是否為統構平台串接過來的用戶
+          let htype = localStorage.getItem('htype');
+          localStorage.removeItem("htype");
+          if(htype==="adminlogin"){            
+            //router.push({ name: 'adminpanel'}) 
+            // 因為目前網站的router模式為Hash 所以必須用window.location.href的方式轉跳網頁 不然會多代一些前頁的文字
+            window.location.href = window.location.origin+'/#/adminpanel'; 
+                
+            //router.push({ redirect: window.location.href = window.location.origin+'/#/adminpanel' });
+          }else{            
+            router.push('/home/index')
+          }
+          
         } else if (res.roles.includes('assist') || res.roles.includes('sales')) {
           router.push('/home/campus')
         }

+ 441 - 119
TEAMModelBI/ClientApp/src/view/product/details.vue

@@ -21,9 +21,11 @@
       </div>
       <div class="contentbox">
         <div class="school-name">
-          <div class="statistics-address">位于:{{schoolData.region}} {{schoolData.province}}{{schoolData.city}}{{schoolData.dist}}</div>
+          <div class="statistics-address">位于:{{schoolData.region}}
+            {{schoolData.province}}{{schoolData.city}}{{schoolData.dist}}</div>
           <span>{{schoolData.name ? schoolData.name:'暂无名称'}}</span>
-          <div class="statistics-time">统计时间:<span>{{statisticsTime.year}} 年 {{statisticsTime.month}} 月 {{statisticsTime.day}}日</span></div>
+          <div class="statistics-time">统计时间:<span>{{statisticsTime.year}} 年 {{statisticsTime.month}} 月
+              {{statisticsTime.day}}日</span></div>
         </div>
         <div class="basicsdata-box">
           <div class="basicadata-item" v-for="(item,index) in basicaList" :key="index">
@@ -35,8 +37,10 @@
                 </svg>
               </div>
             </div>
-            <div :class="[item.key === 'classtime' || item.key === 'participationnum' ? 'item-nums-special':'item-nums']">
-              <p v-if="item.key === 'classtime' || item.key === 'participationnum'">{{item.valueText}}<span class="timetag">Min</span><br /><span>{{item.valueHText}}<span class="timetag">H</span></span></p>
+            <div
+              :class="[item.key === 'classtime' || item.key === 'participationnum' ? 'item-nums-special':'item-nums']">
+              <p v-if="item.key === 'classtime' || item.key === 'participationnum'">{{item.valueText}}<span
+                  class="timetag">Min</span><br /><span>{{item.valueHText}}<span class="timetag">H</span></span></p>
               <p v-else>{{item.value}}</p>
             </div>
           </div>
@@ -113,6 +117,43 @@
             </div> -->
           </div>
         </div>
+        <div class="minxinbox" v-show="isShowAuth">
+          <div class="lessons-box-maxh">
+            <p class="inuse-title">服務授權</p>
+            <div v-for="(item,index) in serviceTableData" :key="index">
+              <el-card shadow="hover" class="custom-card">
+                <span class="card-column-icon" >
+                  <svg class="cardicon" aria-hidden="true" style="background-color: #ffffff;">
+                    <!-- <use xlink:href="#icon-laoshi1"></use> -->
+                    <use xlink:href="#icon-icon"></use>
+                    
+                    <!-- <use xlink:href="#icon-xuanzexuexiao-01"></use> -->
+                  </svg>
+                </span>                
+                <span class="card-column" style="width: 80%;">{{item.title}}<br/>{{item.expireDate}}</span>
+                <!-- <span class="card-column" style="width: 60%;">{{item.expireDate}}</span> -->
+              </el-card>
+              <el-divider />
+            </div>
+          </div>
+          <div class="inuse-right">
+            <p class="inuse-title">軟體授權</p>
+            <div v-for="(item,index) in softwareTableData" :key="index">
+              <el-card shadow="hover" class="custom-card">
+                <span class="card-column-icon" >
+                  <svg class="cardicon" aria-hidden="true" style="background-color: #ffffff;">
+                    <use xlink:href="#icon-icon-test2"></use>
+                    <!-- <use xlink:href="#icon-xuanzexuexiao-01"></use> -->
+                  </svg>
+                </span>                
+                <span class="card-column" style="width: 80%;">{{item.title}}<br/>{{item.expireDate}}</span>
+                <!-- <span class="card-column" style="width: 60%;">{{item.expireDate}}</span> -->
+              </el-card>
+              <el-divider />
+            </div>
+          </div>
+        </div>
+
       </div>
       <!--上一个或者下一个-->
       <!-- <div class="lastbtn">
@@ -147,97 +188,101 @@
           <div class="areaData">
             <div class="contentbox area-contentbox">
               <div class="header-select">
-        <div class="header-select-title">学区数据详情页</div>
-        <div class="header-select-box">
-          <div class="backbtn">
-            <el-button type="primary" @click="backbtn()">返回</el-button>
-          </div>
-        </div>
-      </div>
-      <div class="contentbox">
-        <div class="school-name">
-          <!-- <div class="statistics-address">位于:{{schoolData.region}} {{schoolData.province}}{{schoolData.city}}{{schoolData.dist}}</div> -->
-          <span>{{schoolData.name ? schoolData.name:'暂无名称'}}</span>
-          <div class="statistics-time">统计时间:<span>{{statisticsTime.year}} 年 {{statisticsTime.month}} 月 {{statisticsTime.day}}日</span></div>
-        </div>
-        <div class="basicsdata-box">
-          <div class="basicadata-item" v-for="(item,index) in basicaList" :key="index">
-            <div class="item-title-images">
-              <div class="item-title">{{item.title}}</div>
-              <div class="item-images">
-                <svg class="analysisicon" aria-hidden="true">
-                  <use :xlink:href="item.icon"></use>
-                </svg>
-              </div>
-            </div>
-            <div :class="[item.key === 'classtime' || item.key === 'participationnum' ? 'item-nums-special':'item-nums']">
-              <p v-if="item.key === 'classtime' || item.key === 'participationnum'">{{item.value}}<span class="timetag">Min</span><br /><span>{{Math.round(item.value/60)}}<span class="timetag">H</span></span></p>
-              <p v-else>{{item.value}}</p>
-            </div>
-          </div>
-        </div>
-        <div class="apparatusAndpower">
-          <div class="inuse-left">
-            <p class="inuse-title">课中互动</p>
-            <div class="inuse-item" v-for="(item,index) in inuseList" :key="index">
-              <div class="item-img">
-                <svg class="inuseicon" aria-hidden="true">
-                  <use :xlink:href="item.icon"></use>
-                </svg>
-              </div>
-              <div class="item-box">
-                <p>{{item.value}}</p>
-                <span>{{item.title}}</span>
-              </div>
-            </div>
-          </div>
-          <div class="apparatus-box">
-            <p class="apparatus-title">设备与授权</p>
-            <div class="apparatus-item" v-for="(item,index) in powerList.facility" :key="index">
-              <div class="item-num">{{item.value}}</div>
-              <span class="item-title">{{item.name}}</span>
-            </div>
-          </div>
-          <div class="power-box">
-            <p class="apparatus-title">课堂与授权</p>
-            <div class="power-item" v-for="(item,index) in powerList.class" :key="index">
-              <div class="item-num">{{item.value}}</div>
-              <span class="item-title">{{item.name}}</span>
-            </div>
-          </div>
-        </div>
-        <div class="minxinbox">
-          <div class="lessons-box">
-            <div class="lessons-item" v-for="(items,indexs) in lessonsList" :key="indexs">
-              <div class="lessons-img-title">
-                <div class="lessons-img">
-                  <svg class="lessonsicon" aria-hidden="true">
-                    <use :xlink:href="items.icon"></use>
-                  </svg>
+                <div class="header-select-title">学区数据详情页</div>
+                <div class="header-select-box">
+                  <div class="backbtn">
+                    <el-button type="primary" @click="backbtn()">返回</el-button>
+                  </div>
                 </div>
-                <!-- <div class="lesson-title">{{items.title}}</div> -->
-              </div>
-              <div class="inquirybox"><span>{{items.content}}</span></div>
-              <div class="less-value">
-                <span class="lessvalue-num">{{items.value}}</span>
-                <!-- {{indexs+1 === lessonsList.length ? items.value:items.value}} -->
-                <span v-if="indexs+1 !== lessonsList.length">/堂课</span>
-              </div>
-              <div class="result-box">
-                <svg class="lessRicon" aria-hidden="true">
-                  <use :xlink:href="items.value !==0 ? '#icon-zhengque2':'#icon-cuowu'"></use>
-                </svg>
               </div>
-            </div>
-          </div>
-          <div class="inuse-right">
-            <div class="inuse-total">
-              <div class="class-title">多形态课堂</div>
-            </div>
-            <div class="echartsX">
-              <Xlines :lineData="echartData.xlines"></Xlines>
-            </div>
-            <!-- <div class="inuse-below">
+              <div class="contentbox">
+                <div class="school-name">
+                  <!-- <div class="statistics-address">位于:{{schoolData.region}} {{schoolData.province}}{{schoolData.city}}{{schoolData.dist}}</div> -->
+                  <span>{{schoolData.name ? schoolData.name:'暂无名称'}}</span>
+                  <div class="statistics-time">统计时间:<span>{{statisticsTime.year}} 年 {{statisticsTime.month}} 月
+                      {{statisticsTime.day}}日</span></div>
+                </div>
+                <div class="basicsdata-box">
+                  <div class="basicadata-item" v-for="(item,index) in basicaList" :key="index">
+                    <div class="item-title-images">
+                      <div class="item-title">{{item.title}}</div>
+                      <div class="item-images">
+                        <svg class="analysisicon" aria-hidden="true">
+                          <use :xlink:href="item.icon"></use>
+                        </svg>
+                      </div>
+                    </div>
+                    <div
+                      :class="[item.key === 'classtime' || item.key === 'participationnum' ? 'item-nums-special':'item-nums']">
+                      <p v-if="item.key === 'classtime' || item.key === 'participationnum'">{{item.value}}<span
+                          class="timetag">Min</span><br /><span>{{Math.round(item.value/60)}}<span
+                            class="timetag">H</span></span></p>
+                      <p v-else>{{item.value}}</p>
+                    </div>
+                  </div>
+                </div>
+                <div class="apparatusAndpower">
+                  <div class="inuse-left">
+                    <p class="inuse-title">课中互动</p>
+                    <div class="inuse-item" v-for="(item,index) in inuseList" :key="index">
+                      <div class="item-img">
+                        <svg class="inuseicon" aria-hidden="true">
+                          <use :xlink:href="item.icon"></use>
+                        </svg>
+                      </div>
+                      <div class="item-box">
+                        <p>{{item.value}}</p>
+                        <span>{{item.title}}</span>
+                      </div>
+                    </div>
+                  </div>
+                  <div class="apparatus-box">
+                    <p class="apparatus-title">设备与授权</p>
+                    <div class="apparatus-item" v-for="(item,index) in powerList.facility" :key="index">
+                      <div class="item-num">{{item.value}}</div>
+                      <span class="item-title">{{item.name}}</span>
+                    </div>
+                  </div>
+                  <div class="power-box">
+                    <p class="apparatus-title">课堂与授权</p>
+                    <div class="power-item" v-for="(item,index) in powerList.class" :key="index">
+                      <div class="item-num">{{item.value}}</div>
+                      <span class="item-title">{{item.name}}</span>
+                    </div>
+                  </div>
+                </div>
+                <div class="minxinbox">
+                  <div class="lessons-box">
+                    <div class="lessons-item" v-for="(items,indexs) in lessonsList" :key="indexs">
+                      <div class="lessons-img-title">
+                        <div class="lessons-img">
+                          <svg class="lessonsicon" aria-hidden="true">
+                            <use :xlink:href="items.icon"></use>
+                          </svg>
+                        </div>
+                        <!-- <div class="lesson-title">{{items.title}}</div> -->
+                      </div>
+                      <div class="inquirybox"><span>{{items.content}}</span></div>
+                      <div class="less-value">
+                        <span class="lessvalue-num">{{items.value}}</span>
+                        <!-- {{indexs+1 === lessonsList.length ? items.value:items.value}} -->
+                        <span v-if="indexs+1 !== lessonsList.length">/堂课</span>
+                      </div>
+                      <div class="result-box">
+                        <svg class="lessRicon" aria-hidden="true">
+                          <use :xlink:href="items.value !==0 ? '#icon-zhengque2':'#icon-cuowu'"></use>
+                        </svg>
+                      </div>
+                    </div>
+                  </div>
+                  <div class="inuse-right">
+                    <div class="inuse-total">
+                      <div class="class-title">多形态课堂</div>
+                    </div>
+                    <div class="echartsX">
+                      <Xlines :lineData="echartData.xlines"></Xlines>
+                    </div>
+                    <!-- <div class="inuse-below">
               <div class="below-item" v-for="(itemA,index) in classType" :key="index">
                 <p>{{itemA.name}}</p>
                 <div class="valuebox">
@@ -246,9 +291,9 @@
                 <div :class="itemA.class"></div>
               </div>
             </div> -->
-          </div>
-        </div>
-      </div>
+                  </div>
+                </div>
+              </div>
             </div>
           </div>
         </el-tab-pane>
@@ -282,6 +327,7 @@ import * as echarts from 'echarts'
 let props = defineProps({
   detailsData: Object,
   pattern:Object,
+  authDetailsData:Object,
 })
 console.log(props.detailsData, '子组件')
 let value1 = ref('')
@@ -650,14 +696,21 @@ let schoolData = ref({
   city: '',
   dist: '',
 })
-let lessonsList = ref([
+let lessonsList = ref([    
   { icon: '#icon--caozuorizhi', title: 'IES课程', content: '使用IES课程', state: true, value: 0 },
-  { icon: '#icon--caozuorizhi', title: 'webIrs', content: '使用webIrs', state: true, value: 0 },
-  { icon: '#icon--caozuorizhi', title: 'IRS', content: '使用IRS', state: true, value: 0 },
-  { icon: '#icon--caozuorizhi', title: 'HiTA', content: '使用HiTA', state: false, value: 0 },
-  { icon: '#icon--caozuorizhi', title: 'HaBoard', content: '使用HaBoard', state: false, value: 0 },
-  { icon: '#icon--caozuorizhi', title: 'IES5资源', content: '使用IES5资源', state: true, value: 0 },
-  { icon: '#icon--caozuorizhi', title: 'T指数', content: '课程T绿灯数', state: true, value: 0 },
+    { icon: '#icon--caozuorizhi', title: 'webIrs', content: '使用webIrs', state: true, value: 0 },
+    { icon: '#icon--caozuorizhi', title: 'IRS', content: '使用IRS', state: true, value: 0 },
+    { icon: '#icon--caozuorizhi', title: 'HiTA', content: '使用HiTA', state: true, value: 0 },
+    { icon: '#icon--caozuorizhi', title: 'HaBoard', content: '使用HaBoard', state: true, value: 0 },
+    { icon: '#icon--caozuorizhi', title: 'HaBoard', content: '使用IES5资源', state: true, value: 0 },
+    { icon: '#icon--caozuorizhi', title: 'text', content: '使用文字云', state: false, value: 0 },
+    { icon: '#icon--caozuorizhi', title: 'ClouDAS', content: '使用ClouDAS', state: false, value: 0 },
+    { icon: '#icon--caozuorizhi', title: 'GPT', content: '使用GPT', state: false, value: 0 },
+    { icon: '#icon--caozuorizhi', title: 'IES5测验', content: '使用IES5卷测验', state: true, value: 0 },
+    { icon: '#icon--caozuorizhi', title: 'Excel测验', content: '使用Excel卷测验', state: true, value: 0 },
+    { icon: '#icon--caozuorizhi', title: '纸本测验', content: '使用纸本测验', state: true, value: 0 },
+    { icon: '#icon--caozuorizhi', title: 'T课堂', content: '符合T课堂数', state: true, value: 0 },
+    { icon: '#icon--caozuorizhi', title: 'T指数', content: '课程T绿灯数', state: true, value: 0 },
 ])
 let inuseList = ref([
   { title: '任务数', value: 15, icon: '#icon-renwu', percent: '41.2%', class: 'task', textClass: 'task-text' },
@@ -671,8 +724,10 @@ let classType = ref([
   { name: '任务型态课堂', value: 20, percent: '10%', class: 'topic', textClass: 'topic-text' },
   { name: '差异化形态课堂', value: 20, percent: '5%', class: 'interaction', textClass: 'interaction-text' },
   { name: '测验型态课堂', value: 30, percent: '15%', class: 'testclass', textClass: 'testclass-text' },
-  { name: '无型态课堂', value: 0, percent: '0%', class: 'noneclass', textClass: 'noneclassclass-text' },
-  { name: '未上课', value: 0, percent: '0%', class: 'noneclass', textClass: 'noneclassclass-text' },
+  { name: '协作型态课堂', value: 30, percent: '15%', class: 'testclass', textClass: 'testclass-text' },
+  { name: '互评型态课堂', value: 30, percent: '15%', class: 'testclass', textClass: 'testclass-text' },
+  { name: '教材展示', value: 0, percent: '0%', class: 'noneclass', textClass: 'noneclassclass-text' },
+  { name: '白板应用', value: 0, percent: '0%', class: 'noneclass', textClass: 'noneclassclass-text' },
 ])
 let echartData = ref({
   total: 0,
@@ -723,7 +778,7 @@ let echartData = ref({
         }
       },
       boundaryGap: true, // 坐标轴两边是否留白
-      data: ['合作型态', '互动型态', '任务型态', '差异化型态', '测验型态', '无型态', '未上课']
+      data: ['合作型态', '互动型态', '任务型态', '差异化型态', '测验型态', '协作', '互评', '教材展示', '白板应用']
     },
     yAxis: [
       {
@@ -787,6 +842,110 @@ let echartData = ref({
     ]
   }
 })
+let serviceTableData = ref([{}])
+let softwareTableData = ref([{}])
+let productData = ref([
+  {   
+    name: 'ezStation 2',
+    prodcode: '3222NIYD',    
+  },
+  {
+    name: 'HiTeach STD',
+    prodcode: 'J223IZ6M',    
+  },
+  {
+    name: 'HiTeach TBL',
+    prodcode: '3222C6D2',    
+  },
+  {
+    name: 'HiTeach PRO',
+    prodcode: 'J223IZAM',
+  },
+  {
+    name: 'HiTeach Lite',
+    prodcode: 'J2236ZCX',
+  },
+  {
+    name: 'HiTeach Mobile',
+    prodcode: '3222DNG2',
+  },
+  {
+    name: 'HiTeach Premium',
+    prodcode: '3222IAVN',
+  },
+  {
+    name: 'HiTeach5',
+    prodcode: 'BYJ6LZ6Z',
+  },
+  {
+    name: 'HiTeachCC',
+    prodcode: 'LZLL6ZEI',
+  },
+  {
+    name: proxy.$t(`auth.YMPCVCIM`),
+    prodcode: 'YMPCVCIM',
+  },
+  {
+    name: proxy.$t(`auth.IPDYZYLC`),
+    prodcode: 'IPDYZYLC',
+  },
+  {
+    name: proxy.$t(`auth._3CLYJ6NP`),
+    prodcode: '3CLYJ6NP',
+  },
+  {
+    name: proxy.$t(`auth.IPALJ6NY`),
+    prodcode: 'IPALJ6NY',
+  },
+  {
+    name: proxy.$t(`auth.VABAJ6NV`),
+    prodcode: 'VABAJ6NV',
+  },
+  {
+    name: proxy.$t(`auth._0VPBDZPG`),
+    prodcode: '0VPBDZPG',
+  },
+  {
+    name: proxy.$t(`auth.B9GPJ6NY`),
+    prodcode: 'B9GPJ6NY',
+  },
+  {
+    name: proxy.$t(`auth.LY9AJ6NY`),
+    prodcode: 'LY9AJ6NY',
+  },
+  {
+    name: proxy.$t(`auth.YL9CJ6NY`),
+    prodcode: 'YL9CJ6NY',
+  },
+  {
+    name: proxy.$t(`auth.LL9MJ6NY`),
+    prodcode: 'LL9MJ6NY',
+  },
+  {
+    name: proxy.$t(`auth.B6V5J6NP`),
+    prodcode: 'B6V5J6NP',
+  },
+  {
+    name: proxy.$t(`auth.LSZYJ6NA`),
+    prodcode: 'LSZYJ6NA',
+  },
+  {
+    name: proxy.$t(`auth.CVGPJ6NN`),
+    prodcode: 'CVGPJ6NN',
+  },
+  {
+    name: proxy.$t(`auth.VDPGJ6NC`),
+    prodcode: 'VDPGJ6NC',
+  },
+  {
+    name: proxy.$t(`auth.YPXSJ6NJ`),
+    prodcode: 'YPXSJ6NJ',
+  },
+])
+let isShowAuth = true
+
+  
+
 function init (againvalue) {
   console.log(againvalue,'是什么值')
   // let totalsArr = []
@@ -800,6 +959,10 @@ function init (againvalue) {
   console.log(propsbox, '数据')
   //学校基础信息
   let { name, region, province, city, dist } = propsbox.detailsData.school
+  //如果沒有學校名稱 改為用城市區名
+  if(propsbox.detailsData.school.name === "" || propsbox.detailsData.school.name === null || propsbox.detailsData.school.name === undefined){
+    name = propsbox.detailsData.name;
+  }  
   schoolData.value.name = appearState.value ==='default' ? name: appearState.value ==='area' ? propsbox.detailsData.name:''
   schoolData.value.region = region
   schoolData.value.province = province
@@ -826,14 +989,39 @@ function init (againvalue) {
   basicaList.value[7].valueHText=proxy.$common.numberToTextWithUnit(Math.round(lessonLengMin/60))
 
   //处理课中使用数据
-  let { useIES, useWebIrs, useDeviceIrs, useHita, useHaboard, useIES5Resource, tGreen } = propsbox.detailsData
-  lessonsList.value[0].value = useIES
-  lessonsList.value[1].value = useWebIrs
-  lessonsList.value[2].value = useDeviceIrs
-  lessonsList.value[3].value = useHita
-  lessonsList.value[4].value = useHaboard
-  lessonsList.value[5].value = useIES5Resource
-  lessonsList.value[6].value = tGreen
+  // let { useIES, useWebIrs, useDeviceIrs, useHita, useHaboard, useIES5Resource, tGreen } = propsbox.detailsData
+  // lessonsList.value[0].value = useIES
+  // lessonsList.value[1].value = useWebIrs
+  // lessonsList.value[2].value = useDeviceIrs
+  // lessonsList.value[3].value = useHita
+  // lessonsList.value[4].value = useHaboard
+  // lessonsList.value[5].value = useIES5Resource
+  // lessonsList.value[6].value = tGreen
+
+  //处理课中使用数据
+  let { useIES, useWebIrs, useDeviceIrs, useHita, useHaboard, useIES5Resource, tGreen,useWordCloud,useClouDAS,useGPT,useIesTest,useExcelTest,usePaperTest,tLesson} = propsbox.detailsData
+    lessonsList.value[0].value = useIES ?useIES:0
+    lessonsList.value[1].value = useWebIrs ? useWebIrs:0
+    lessonsList.value[2].value = useDeviceIrs ? useDeviceIrs:0
+    lessonsList.value[3].value = useHita ? useHita:0
+    lessonsList.value[4].value = useHaboard ?  useHaboard:0
+    lessonsList.value[5].value =useIES5Resource ? useIES5Resource:0
+    //由hita 调整为 文字云
+    lessonsList.value[6].value = useWordCloud ?useWordCloud:0
+    //由HaBoard 调整为 ClouDAS
+    lessonsList.value[7].value = useClouDAS ? useClouDAS:0
+    //增加使用GPT
+    lessonsList.value[8].value = useGPT ?useGPT:0
+    //由IES5资源调整为 使用IES5卷测验
+    lessonsList.value[9].value = useIesTest ? useIesTest:0
+    //新增Excel
+    lessonsList.value[10].value=useExcelTest ? useExcelTest:0
+    //新增纸本
+    lessonsList.value[11].value=usePaperTest ?usePaperTest:0
+    //符合T课堂数
+    lessonsList.value[12].value=tLesson ? tLesson:0
+    // T綠燈
+    lessonsList.value[13].value=tGreen
 
   //授权占比
   let { deviceCnt, deviceNoAuth, deviceAuth, lessonCnt928, lessonCntId, lessonCntDevice, lessonCntIdDevice } = propsbox.detailsData
@@ -853,7 +1041,7 @@ function init (againvalue) {
   inuseList.value[3].value = proxy.$common.numberToTextWithUnit(interact)
 
   //处理多形态课堂
-  let { lTypeCoop, lTypeIact, lTypeMis, lTypeTst, lTypeDif, lTypeNone,lessonLeng0} = propsbox.detailsData
+  let { lTypeCoop, lTypeIact, lTypeMis, lTypeTst, lTypeDif, lTypeNone,lessonLeng0,learnCoop,learnPeer} = propsbox.detailsData
   let totalNum = [lTypeCoop, lTypeIact, lTypeMis, lTypeTst, lTypeDif].reduce((prev, cur) => { return prev + cur }, 0)
   echartData.value.total = totalNum
   console.log(totalNum)
@@ -871,7 +1059,7 @@ function init (againvalue) {
   classType.value[5].value = lessonLeng0 ? lessonLeng0:0
 
   //echarts占比
-  echartData.value.xlines.series[0].data = [lTypeCoop, lTypeIact, lTypeMis, lTypeTst, lTypeDif, lTypeNone, classType.value[5].value]
+  echartData.value.xlines.series[0].data = [lTypeCoop, lTypeIact, lTypeMis, lTypeTst, lTypeDif, learnCoop, learnPeer, lTypeNone, classType.value[5].value]
   // echartData.value.xlines.series[1].data = [classType.value[1].percent]
   // echartData.value.xlines.series[2].data = [classType.value[2].percent]
   // echartData.value.xlines.series[3].data = [classType.value[3].percent]
@@ -949,6 +1137,65 @@ function init (againvalue) {
      console.log(trimData,'清理过后的')
      tableData.value=trimData
   }
+
+  // 服務授權
+  // 取得指定學校的授權資料
+  let foundItem = propsbox.authDetailsData.find(item => item.schId === propsbox.detailsData.schoolId);
+  if (foundItem !== undefined) {
+    isShowAuth = true;
+    let serviceArr = [];
+    foundItem.authService.forEach((item) => {
+      //debugger;
+      // 依照對應的產品代碼取得產品名稱
+      let productDataItem = productData.value.find(itempd => itempd.prodcode === item.prodCode);
+      if (productDataItem !== undefined) {
+        let expireDate = "";
+        if (item.endDate === 0) {
+          expireDate = '服務到期日 : 無限期';
+        } else {
+          expireDate = '服務到期日 : ' + proxy.$common.timestampToTime(item.endDate, 'all')
+        }
+        let serviceItem = {
+          title: productDataItem.name,
+          //expireDate: '服務到期日 : ' + proxy.$common.timestampToTime(item.startDate, 'all') + ' - ' + proxy.$common.timestampToTime(item.endDate, 'all')
+          expireDate: expireDate
+        }
+        serviceArr.push(serviceItem);
+      }
+    })
+    serviceTableData.value = serviceArr;
+
+    // 軟體授權    
+    let softwareArr = [];
+    foundItem.authSerial.forEach((item) => {      
+      // 依照對應的產品代碼取得產品名稱
+      let productDataItem = productData.value.find(itempd => itempd.prodcode === item.prodCode);
+      if (productDataItem !== undefined) {
+        let expireDate = "";
+        if (item.endDate === 0) {
+          expireDate = '服務到期日 : 無限期';
+        } else {
+          expireDate = '服務到期日 : ' + proxy.$common.timestampToTime(item.endDate, 'all')
+        }
+        let softwareItem = {
+          title: productDataItem.name,
+          expireDate: expireDate
+        }
+        softwareArr.push(softwareItem);
+      }
+    })
+    softwareTableData.value = softwareArr;
+
+
+  }else{
+    isShowAuth = false;
+  }
+ 
+  
+
+
+
+
 }
 function detailsSchool(value){
   console.log(value,'查看要传的数据')
@@ -966,6 +1213,7 @@ init()
   width: 100%;
   position: relative;
 }
+
 .header-select {
   width: 100%;
   height: 60px;
@@ -973,6 +1221,7 @@ init()
   background-color: #fff;
   box-shadow: 0 2px 5px #e9e9e9;
 }
+
 .header-select-title,
 .header-select-box {
   display: inline-block;
@@ -982,14 +1231,17 @@ init()
   padding-left: 1%;
   line-height: 60px;
 }
+
 .header-select-title {
   font-size: 18px;
   font-weight: bold;
 }
+
 .header-select-box {
   text-align: right;
   padding-right: 1%;
 }
+
 .select-box-time,
 .select-box-area,
 .select-box-school {
@@ -997,6 +1249,7 @@ init()
   vertical-align: top;
   padding-top: 1%;
 }
+
 .contentbox {
   width: 98%;
   /* padding: 1% 1%; */
@@ -1005,10 +1258,12 @@ init()
   margin: 0.5% 1%;
   padding-bottom: 0.5%;
 }
+
 .area-contentbox {
   width: 100%;
   margin: 0%;
 }
+
 .analysisicon {
   width: 2.3em;
   height: 2.3em;
@@ -1018,6 +1273,7 @@ init()
   margin-right: 25px;
   margin-left: 0px; */
 }
+
 .basicsdata-box {
   overflow: hidden;
   width: 100%;
@@ -1026,9 +1282,9 @@ init()
   flex-wrap: nowrap;
   justify-content: space-between;
 }
+
 .apparatusAndpower {
-  width: 100%;
-  display: flex;
+  width: 100%;display: flex;
   flex-wrap: nowrap;
   line-height: 60px;
   /* justify-content: space-between; */
@@ -1079,7 +1335,7 @@ init()
   border-bottom: 1px dashed #e9e9e9;
   font-size: 16px;
   font-weight: bold;
-  color: #fff;
+  color:black;
 }
 .item-num {
   font-size: 20px;
@@ -1140,6 +1396,16 @@ init()
   overflow: hidden;
   overflow-y: auto;
 }
+.lessons-box-maxh {
+  width: 50%;
+  
+  border-radius: 5px;
+  background: #fff;
+  box-shadow: 0 2px 5px #e9e9e9;
+  margin: 0.5% 1%;
+  overflow: hidden;
+  overflow-y: auto;
+}
 .lessons-item {
   width: 100%;
   padding: 0% 10%;
@@ -1499,5 +1765,61 @@ init()
 .contentbox .el-divider {
   margin: 10px 0;
 }
+.data-tables .header-class,
+  .data-tables 
+  .el-table-v2__row-cell 
+  {
+    /* width: v-bind(cellWidth + "%") !important; */
+    justify-content: center;
+    text-align: center;
+  }
+  .data-tables .general {
+    /* width: v-bind(cellWidth + "%") !important; */
+    justify-content: center;
+    text-align: center;
+  }
+  .data-tables .generalid {    
+    justify-content: left;
+    text-align: left;
+  }
+  .data-tables .btn-class {
+    /* width: v-bind(cellWidth + "%") !important; */
+    justify-content: center;
+    text-align: center;
+  }
+  .data-tables {
+    width: 93%;
+    padding: 0px 20px;
+    height: 100%;
+  }
+  .el-table__body, .el-scrollbar__view {
+    width: 100%;
+  }
+  .custom-card {
+  line-height: 60px;
+  width: 95%;
+  margin-top: 10px;
+  margin-left: 20px;
+  }
+  .card-column {
+    float:left;
+    text-align: left;   
+    /* margin-right: 80px;   */
+    /* width: 30%; */
+  }
+  .card-column-icon {
+    float:left;
+    text-align: left;   
+    margin-right: 40px;
+    width: 8%;  
+  }
+  .cardicon {
+  width: 3em;
+  height: 3em;
+  vertical-align: -0.5em;
+  fill: currentColor;
+}
+  
+  
 </style>
 

+ 229 - 143
TEAMModelBI/ClientApp/src/view/product/index.vue

@@ -166,10 +166,10 @@
         </div>
       </div>
     </div>
-    <div class="data-tables">
+    <div class="data-tables" v-loading="searchLoading" v-if="showState==='default'"  element-loading-text="正在准备数据中...">
       <el-auto-resizer>
         <template #default="{ height, width }">
-          <el-table-v2 v-model:sort-state="sortState" :columns="columns" :data="filterdata" :width="width" :height="height" @column-sort="onSort" fixed />
+          <el-table-v2 v-model:sort-state="sortState" :columns="columns" :data="filterdata" :width="width" :height="height" @column-sort="onSort" fixed  :row-class="rowClassName" />
         </template>
       </el-auto-resizer>
     </div>
@@ -219,7 +219,7 @@
     </div>
   </div>
   <div v-else-if="showState==='details'">
-    <Details @myback="changStateshow" :detailsData="detailsData" :pattern="pattern"></Details>
+    <Details @myback="changStateshow" :detailsData="detailsData" :pattern="pattern" :authDetailsData="authDetailsData"></Details>
   </div>
   <div class="dialog-filter" v-if="exportstate">
     <el-dialog v-model="exportstate" title="筛选导出" width="35%">
@@ -275,7 +275,7 @@
             <el-button size="small" type="info" disabled :icon="Search" v-else>个人数据查询</el-button>
           </div>
           <div class="header-title-hint" v-show="deleteSchoolArr.length >0">
-            <span>目前支持同时最多10名用户查询</span>
+            <span>目前支持同时最多100名用户查询</span>
           </div>
         </div>
       </div>
@@ -328,8 +328,8 @@
 <script setup>
 import option_cn from '@/static/regions/region_cn.json'
 import option_gl from '@/static/regions/region_gl.json'
-import { ref, getCurrentInstance, watch, h, nextTick } from 'vue'
-import { ElMessage, TableV2SortOrder, ElLoading, ElCheckbox,HeaderCellSlotProps,ElPopover} from 'element-plus'
+import { ref, getCurrentInstance, watch, h, nextTick, reactive } from 'vue'
+import { ElMessage, TableV2SortOrder, ElLoading, ElCheckbox,HeaderCellSlotProps,ElPopover,Column, RowClassNameGetter} from 'element-plus'
 import { Filter } from '@element-plus/icons'
 import { multipleSheetExport } from '@/until/multipleSheetExport'
 import { Search, CirclePlus } from '@element-plus/icons-vue'
@@ -345,6 +345,9 @@ let activeNames = ref(['1'])
 let showState = ref('default')
 let findValue = ref()
 let test = ref([])
+let searchLoading=ref(false)
+let sortValue = reactive({});
+
 let columns = ref([
   {
     key: "name",
@@ -355,6 +358,15 @@ let columns = ref([
     // sortable: true,
     headerClass: 'general',
   },
+  {
+    key: "date",
+    dataKey: "date",//需要渲染当前列的数据字段,如{id:9527,name:'Mike'},则填id
+    title: "時間",//显示在单元格表头的文本
+    width: 100,//当前列的宽度,必须设置
+    fixed: false,//是否固定列
+     sortable: true,
+    headerClass: 'general',
+  },
   {
     key: "schoolId",
     dataKey: "schoolId",//需要渲染当前列的数据字段,如{id:9527,name:'Mike'},则填id
@@ -456,6 +468,7 @@ let columns = ref([
 const popoverRef = ref()
 const siteValue = window.location.host === 'localhost:5001' ? 'cn' : window.location.host === 'bi.teammodel.cn' ? 'cn' : window.location.host === 'bitest.teammodel.cn' ? 'cn' : 'international'
 const optionsData = siteValue === 'cn' ? option_cn : option_gl
+//const optionsData = option_gl
 columns.value[0].headerCellRenderer = (props = HeaderCellSlotProps) => {
       return (
         <div class="items-center justify-center">
@@ -495,6 +508,7 @@ const sortState = ref({
   'date':TableV2SortOrder.ASC,
 })
 const onSort = ({key,order}) => {
+  sortValue = {key:key,order:order};
   console.log(key,order)
   sortState.value[key] = order
   let field=key;let modes=order;let allData=filterdata.value
@@ -720,6 +734,7 @@ let exportStandard = ref([
   { title: '授权类型', value: 0, key: 'powertype', option: [{ name: '全部', value: 'all' }, { name: '试用', value: 'test' }, { name: '已授权', value: 'power' }] },
 ])
 let detailsData = ref()
+let authDetailsData = ref()
 let pattern=ref({
    state:'school',
    data:''
@@ -778,7 +793,12 @@ const monthOptions=function disabledDate(time){
                 const elTimeData = timeyear.toString() + timemonth.toString();
                 return elTimeData >= nowDate; 
 }
-
+function rowClassName({rowIndex}) {  
+      if (filterdata.value[rowIndex].geoInfo) {
+        return 'highlight-row'; // 对第二行应用特定样式
+      }
+      return ''; // 其他行不做特殊处理
+    }
 function changeState (value) {
   console.log(value)
   showState.value = 'details'
@@ -786,6 +806,7 @@ function changeState (value) {
   pattern.value.state=clickNum.value.subject === 0 ? 'school':clickNum.value.subject === 1 ? 'area':''
   clickNum.value.subject === 1 ? pattern.value.data=primevalData.value:''
   detailsData.value = value.rowData
+  //debugger
 }
 function changStateshow (value) {
   console.log(value, '状态改变')
@@ -798,7 +819,7 @@ function dataInit () {
   initLoading.value=true
   let dataList = []
   proxy.$api.getCapacity({}).then((res) => {
-    console.log(res, 'areList')
+    console.log(res, 'areList')    
     dataSource.value.area = res.areas
     res.areas.forEach((item) => {
       dataList.push({ id: item.id, name: item.name, province: item.provName, city: item.cityName, children: [] })
@@ -815,7 +836,7 @@ function dataInit () {
         })
       })
       console.log(dataList, 'result!')
-      options.value = dataList
+      options.value = dataList      
       dataSource.value.composite = dataList
       dataSource.value.originalSchool = res.scInfos
       tableData.value = res.scInfos
@@ -831,156 +852,182 @@ function dataInit () {
     ElMessage.error('API异常,基础数据获取异常')
   })
 }
- function serachToresult (startTime, endTime, product, schools, unit) {
+function serachToresult(startTime, endTime, product, schools, unit) {
   // let data = { "dateFrom": "2023-04-12", "dateTo": "2023-04-19", "prod": "HiTeach", "schoolIds": ["tbslgb", "habook"], "dateUnit": "Day" }
-  if(!startTime || !endTime){
+  if (!startTime || !endTime) {
     ElMessage.info('请选择时间进行数据搜索')
     return
   }
+  searchLoading.value = true;
   let data = { "dateFrom": startTime, "dateTo": endTime, "prod": product, "schoolIds": schools, "dateUnit": unit }
   console.log(data, '内容')
   console.log(clickNum.value.time, '数字')
-  proxy.$api.getUseproduct(data).then(async(res) => {
+  proxy.$api.getUseproduct(data).then(async (res) => {
     console.log(res, 'backPromise')
-    console.log(clickNum.value.subject,'选的数字')
+    console.log(clickNum.value.subject, '选的数字')
     //区别学校or学区呈现数据
-    if(clickNum.value.subject === 0){
-      let adds={
-      key: "schoolId",
-      dataKey: "schoolId",//需要渲染当前列的数据字段,如{id:9527,name:'Mike'},则填id
-      title: "简码",//显示在单元格表头的文本
-      width: 100,//当前列的宽度,必须设置
-      headerClass: 'general',
+    if (clickNum.value.subject === 0) {
+      let adds = {
+        key: "schoolId",
+        dataKey: "schoolId",//需要渲染当前列的数据字段,如{id:9527,name:'Mike'},则填id
+        title: "简码",//显示在单元格表头的文本
+        width: 100,//当前列的宽度,必须设置
+        headerClass: 'general',
       }
-      let resultA=columns.value.findIndex((item)=>{return item.key =='schoolId'})
-      console.log(resultA,'查找')
-      resultA === -1 ? columns.value.splice(1,0,adds):''
-      cellWidth.value=(100 / columns.value.length).toFixed(2)
-      res.state === 200 ? (res.data.forEach((item) => { item.name = item.school.name ? item.school.name : '暂无' }), filterdata.value = res.data,primevalData.value=res.data) : ''
-    }else if(clickNum.value.subject === 1){
+      let resultA = columns.value.findIndex((item) => { return item.key == 'schoolId' })
+      console.log(resultA, '查找')
+      resultA === -1 ? columns.value.splice(1, 0, adds) : ''
+      cellWidth.value = (100 / columns.value.length).toFixed(2)
+      if (res.state === 200) {
+        res.data.forEach((item) => { item.name = item.school.name ? item.school.name : '暂无' });
+        res.geo.forEach((item) => {
+
+          if (item.school.name || (item.school.name === "")) {
+            item.name = item.school.name;
+          } else if (item.geoInfo) {
+            item.name = item.geoInfo;
+          } else { item.name = '暂无'; }
+        });
+
+        
+        filterdata.value = [...res.geo, ...res.data];
+        primevalData.value = [...res.geo, ...res.data];
+      }
+      //res.state === 200 ? (res.data.forEach((item) => { item.name = item.school.name ? item.school.name : '暂无' }), filterdata.value = res.data,primevalData.value=res.data) : ''
+    } else if (clickNum.value.subject === 1) {
       console.log(optionsValue.value)
-      primevalData.value=res.data
-      let allDatas=primevalData.value
-      let catalogueArr=[];let resultArr=[]
-      if(clickNum.value.time === 1){   //做学区 月 的数据累加
-      //时间分类
-       let multiDimensionalArray = allDatas.reduce((acc, curr) => {
-        let { year, month } = curr;
-        let yearIndex = acc.findIndex(item => item[0] === year);
-        if (yearIndex === -1) {
-          acc.push([year, [month]]);
-        } else {
-          acc[yearIndex][1].push(month);
-        }
-        return acc;
-      }, []);
-      console.log(multiDimensionalArray,'结果')
-      multiDimensionalArray.forEach((item)=>{
-        let yearValue=item[0]
-        item[1]=[...new Set(item[1])]
-        let monthDats=item[1]
-        item[1].forEach((itemMonth)=>{
-          for(let i=0;i< optionsValue.value.length;i++){
-            let areaIdTime=[]
-            let areaIdValue=optionsValue.value[i]
-            res.data.forEach((itema)=>{
-              itema.school.areaId === areaIdValue && itema.year ===yearValue && itema.month ===itemMonth ? areaIdTime.push(itema):''
-            })
-            catalogueArr.push(areaIdTime)
+      primevalData.value = [...res.geo, ...res.data]
+      let allDatas = primevalData.value
+      let catalogueArr = []; let resultArr = []
+      if (clickNum.value.time === 1) {   //做学区 月 的数据累加
+        //时间分类
+        let multiDimensionalArray = allDatas.reduce((acc, curr) => {
+          let { year, month } = curr;
+          let yearIndex = acc.findIndex(item => item[0] === year);
+          if (yearIndex === -1) {
+            acc.push([year, [month]]);
+          } else {
+            acc[yearIndex][1].push(month);
           }
+          return acc;
+        }, []);
+        console.log(multiDimensionalArray, '结果')
+        multiDimensionalArray.forEach((item) => {
+          let yearValue = item[0]
+          item[1] = [...new Set(item[1])]
+          let monthDats = item[1]
+          item[1].forEach((itemMonth) => {
+            for (let i = 0; i < optionsValue.value.length; i++) {
+              let areaIdTime = []
+              let areaIdValue = optionsValue.value[i]
+              res.data.forEach((itema) => {
+                itema.school.areaId === areaIdValue && itema.year === yearValue && itema.month === itemMonth ? areaIdTime.push(itema) : ''
+              })
+              catalogueArr.push(areaIdTime)
+            }
+          })
         })
-      })
-      catalogueArr=catalogueArr.filter((items)=>{return items.length>0})
-        console.log(catalogueArr,'进行时间分类区分')
-        for(let i in catalogueArr){
-          let result=await someDataMerge(catalogueArr[i])
+        catalogueArr = catalogueArr.filter((items) => { return items.length > 0 })
+        console.log(catalogueArr, '进行时间分类区分')
+        for (let i in catalogueArr) {
+          let result = await someDataMerge(catalogueArr[i])
           resultArr.push(result)
         }
-      console.log(resultArr,'月 结果')
-      // let newArray=[]
-      // let resultArr=[]
-      //  for(let i=0;i< optionsValue.value.length;i++){
-      //    let arrays=[]
-      //    res.data.forEach((item)=>{
-      //     item.school.areaId === optionsValue.value[i] ? arrays.push(item):''
-      //    })
-      //    newArray.push(arrays)
-      //  }
-      //  newArray=newArray.filter(item => item.length > 0)
-      //  console.log(newArray,'处理前的newArray')
-      //  for(let i in newArray){
-      //    let result=await someDataMerge(newArray[i])
-      //    resultArr.push(result)
-      //  }
-      //  console.log(newArray,'得出的结果')
-      //  resultArr.forEach((item)=>{
-      //   let areIds=item.school.length >0 ? item.school[0].areaId:''
-      //   if(areIds){
-      //     options.value.forEach((items)=>{
-      //     items.id === areIds ? item.name=items.name:''
-      //     })
-      //   }
-      //   //去重schollId
-      //   item.schoolId=[...new Set(item.schoolId)]
-      //  })
-      // console.log(resultArr,'集合')
-      }else if(clickNum.value.time === 0){   //处理 学区  天 的结果 
+        console.log(resultArr, '月 结果')
+        // let newArray=[]
+        // let resultArr=[]
+        //  for(let i=0;i< optionsValue.value.length;i++){
+        //    let arrays=[]
+        //    res.data.forEach((item)=>{
+        //     item.school.areaId === optionsValue.value[i] ? arrays.push(item):''
+        //    })
+        //    newArray.push(arrays)
+        //  }
+        //  newArray=newArray.filter(item => item.length > 0)
+        //  console.log(newArray,'处理前的newArray')
+        //  for(let i in newArray){
+        //    let result=await someDataMerge(newArray[i])
+        //    resultArr.push(result)
+        //  }
+        //  console.log(newArray,'得出的结果')
+        //  resultArr.forEach((item)=>{
+        //   let areIds=item.school.length >0 ? item.school[0].areaId:''
+        //   if(areIds){
+        //     options.value.forEach((items)=>{
+        //     items.id === areIds ? item.name=items.name:''
+        //     })
+        //   }
+        //   //去重schollId
+        //   item.schoolId=[...new Set(item.schoolId)]
+        //  })
+        // console.log(resultArr,'集合')
+      } else if (clickNum.value.time === 0) {   //处理 学区  天 的结果 
         //时间分类
         let uniqueNames = [...new Set(allDatas.map(item => item.date))];
-        uniqueNames.forEach((item)=>{
-          for(let i=0;i< optionsValue.value.length;i++){
-            let areaIdTime=[]
-            let areaIdValue=optionsValue.value[i]
-            res.data.forEach((itema)=>{
-              itema.school.areaId === areaIdValue && itema.date ===item ? areaIdTime.push(itema):''
+        uniqueNames.forEach((item) => {
+          for (let i = 0; i < optionsValue.value.length; i++) {
+            let areaIdTime = []
+            let areaIdValue = optionsValue.value[i]
+            res.data.forEach((itema) => {
+              itema.school.areaId === areaIdValue && itema.date === item ? areaIdTime.push(itema) : ''
             })
             catalogueArr.push(areaIdTime)
           }
         })
-        catalogueArr=catalogueArr.filter((items)=>{return items.length>0})
-        console.log(catalogueArr,'进行时间分类区分')
-        for(let i in catalogueArr){
-          let result=await someDataMerge(catalogueArr[i])
+        catalogueArr = catalogueArr.filter((items) => { return items.length > 0 })
+        console.log(catalogueArr, '进行时间分类区分')
+        for (let i in catalogueArr) {
+          let result = await someDataMerge(catalogueArr[i])
           resultArr.push(result)
         }
-        console.log(resultArr,'天 结果')
-        filterdata.value=resultArr
-      }else if(clickNum.value.time === 2){   //学区  年
+        console.log(resultArr, '天 结果')
+        filterdata.value = [...res.geo, ...resultArr];
+        //filterdata.value=resultArr
+      } else if (clickNum.value.time === 2) {   //学区  年
         //时间分类
         let uniqueYear = [...new Set(allDatas.map(item => item.year))];
-        uniqueYear.forEach((item)=>{
-          for(let i=0;i< optionsValue.value.length;i++){
-            let areaIdTime=[]
-            let areaIdValue=optionsValue.value[i]
-            res.data.forEach((itema)=>{
-              itema.school.areaId === areaIdValue && itema.year ===item ? areaIdTime.push(itema):''
+        uniqueYear.forEach((item) => {
+          for (let i = 0; i < optionsValue.value.length; i++) {
+            let areaIdTime = []
+            let areaIdValue = optionsValue.value[i]
+            res.data.forEach((itema) => {
+              itema.school.areaId === areaIdValue && itema.year === item ? areaIdTime.push(itema) : ''
             })
             catalogueArr.push(areaIdTime)
           }
         })
-        catalogueArr=catalogueArr.filter((items)=>{return items.length>0})
-        console.log(catalogueArr,'进行时间分类区分')
-        for(let i in catalogueArr){
-          let result=await someDataMerge(catalogueArr[i])
+        catalogueArr = catalogueArr.filter((items) => { return items.length > 0 })
+        console.log(catalogueArr, '进行时间分类区分')
+        for (let i in catalogueArr) {
+          let result = await someDataMerge(catalogueArr[i])
           resultArr.push(result)
         }
-       }
-         //数据标准 学区名称
-         resultArr.forEach((item)=>{
-          console.log(item)
-          let areas=item.school[0].areaId
-          options.value.forEach((items)=>{
-            items.id === areas ? item.name=items.name:''
-          })
+      }
+      //数据标准 学区名称
+      resultArr.forEach((item) => {
+        console.log(item)
+        let areas = item.school[0].areaId
+        options.value.forEach((items) => {
+          items.id === areas ? item.name = items.name : ''
         })
-        filterdata.value=resultArr
+      })
+      filterdata.value = [...res.geo, ...resultArr];
+      //filterdata.value=resultArr
       //处理table表header内容
-      let resultColumns=columns.value.findIndex((item)=>{return  item.key==='schoolId'})
-      resultColumns !==-1 ? columns.value.splice(1,1):''
-      cellWidth.value=(100 / columns.value.length).toFixed(2)
-    }else{
-      filterdata.value=res.data
+      let resultColumns = columns.value.findIndex((item) => { return item.key === 'schoolId' })
+      resultColumns !== -1 ? columns.value.splice(1, 1) : ''
+      cellWidth.value = (100 / columns.value.length).toFixed(2)
+    } else {
+      filterdata.value = [...res.geo, ...res.data];
+      //filterdata.value=res.data
     }
+    filterdata.value.forEach((item) => {
+      if ((item.name === null || item.name === "" || item.name === undefined) && item.geoInfo !== null && item.geoInfo !== "" && item.geoInfo !== undefined) {
+        item.name = item.geoInfo;
+      }
+    })
+    authDetailsData.value = res.auth;
+    searchLoading.value = false;    
   }).catch((err) => {
     ElMessage.error('API异常,数据获取失败')
   })
@@ -1000,15 +1047,15 @@ async function searchData () {
   let dateUnits = ''
   let times = { start: productData.value.timevalue[0], end: productData.value.timevalue[1] }
   let yearValues=''
-  clickNum.value.time === 2 ? (yearValues=productData.value.timevalue.slice(0,4),times.start=productData.value.timevalue,times.end=yearValues+'-12-31'):''
-  if (clickNum.value.filter === 0 && searchValue) {
-    if (clickNum.value.subject === 0) {
+  clickNum.value.time === 2 ? (yearValues=productData.value.timevalue.slice(0,4),times.start=productData.value.timevalue,times.end=yearValues+'-12-31'):'' 
+  if (clickNum.value.filter === 0 && searchValue) { // 篩選類型 => 來源類型
+    if (clickNum.value.subject === 0) {// 目标范围 => 學校     
       console.log(searchValue, '进入1')
       searchValue.forEach((item) => {
         schoolArr.push(item[1])
       })
       console.log(schoolArr, '结果0')
-    } else if (clickNum.value.subject === 1) {
+    } else if (clickNum.value.subject === 1) { // 目标范围 => 學區              
       searchValue.forEach((item) => {
         let ids = item
         dataSource.value.composite.forEach((itema) => {
@@ -1016,16 +1063,16 @@ async function searchData () {
         })
       })
       console.log(schoolArr, '结果1')
-    } else if (clickNum.value.subject === 2) {
+    } else if (clickNum.value.subject === 2) { // 目标范围 => 沒用到        
       let state = ''
       typeof optionsValue.value == 'string' ? state = 'province' : state = 'city'
       let resultData = await filterDistrict(state, optionsValue.value)
       console.log(resultData, '结果2')
       schoolArr = resultData
     }
-  } else if (clickNum.value.filter === 1 && searchValue) {
+  } else if (clickNum.value.filter === 1 && searchValue) {// 篩選類型 => 地區城市    
     console.log(clickNum.value.district, '999999')
-    if (clickNum.value.district !== 2) {
+    if (clickNum.value.district !== 2) {// 地区选择 => 不等於學區(省或是城市)
       console.log(optionsValue.value, '城市关键值')
       console.log(typeof optionsValue.value, 'type')
       let state = ''
@@ -1033,7 +1080,7 @@ async function searchData () {
       let resultData = await filterDistrict(state, optionsValue.value)
       schoolArr = resultData
       console.log(resultData, state, '省级查询及状态')
-    } else {
+    } else {// 地区选择 => 學區
       searchValue.forEach((item) => {
         let ids = item
         dataSource.value.composite.forEach((itema) => {
@@ -1246,8 +1293,8 @@ function exportExcel () {
     { label: '任务型态', key: 'lTypeMis' },
     { label: '差异化型态', key: 'lTypeDif' },
     { label: '测验型态', key: 'lTypeTst' },
-    { label: '无型态', key: 'lTypeNone' },
-    { label: '未上课', key: 'lTypeNone' },
+    { label: '教材展示', key: 'lTypeNone' },
+    { label: '白板应用', key: 'lTypeNone' },
   ]
   fieldList.value.forEach((item) => {
     exportList.value.forEach((items) => {
@@ -1430,10 +1477,12 @@ function someDataMerge(arr){
         month:0,
         day:0,
     }
-    const mergedData = arr.reduce((acc, cur) => {
+    
+  const mergedData = arr.reduce((acc, cur) => {
     // 合并对象的基本信息
     acc.deviceAuth += cur.deviceAuth;
-    acc.deviceCnt +=cur.deviceCnt
+    //acc.deviceCnt +=cur.deviceCnt
+    acc.deviceCnt += 0
     acc.deviceNoAuth +=cur.deviceNoAuth
     acc.interact +=cur.interact
     acc.item +=cur.item
@@ -1454,7 +1503,8 @@ function someDataMerge(arr){
     acc.stuLessonLengMin +=cur.stuLessonLengMin
     acc.stuShow +=cur.stuShow
     acc.tGreen +=cur.tGreen
-    acc.tmidCnt +=cur.tmidCnt
+    //acc.tmidCnt +=cur.tmidCnt
+    acc.tmidCnt += 0
     acc.toolType='HiTeach'
     acc.date=cur.date
     acc.year=cur.year
@@ -1479,19 +1529,41 @@ function someDataMerge(arr){
     // 返回累加器对象
     return acc;
   },tatalArr)
+  // 教室數及教師數去重處理
+  let arrdeviceCnt = [];
+  let arrtmidCnt = [];  
+  arr.forEach((arritem) => {
+    arritem.deviceList.forEach((item) => {
+      arrdeviceCnt.push(item);
+    })
+    arritem.tmidList.forEach((item) => {
+      arrtmidCnt.push(item);
+    })
+  })  
+  const uniquedcArray = Array.from(new Set(arrdeviceCnt));
+  const uniquetiArray = Array.from(new Set(arrtmidCnt));
+  mergedData.deviceCnt = uniquedcArray.length;
+  mergedData.tmidCnt = uniquetiArray.length;
+  
   return mergedData
 }
 //数据筛选
 function filterSchooltype(){
   let filterValue=filterType.value
   let dataArr=primevalData.value
-  let result=[]
+  let result=[]  
   console.log(primevalData.value,'原始值')
   console.log(filterValue,'状态值')
+  
   filterValue.totalShow ? result=primevalData.value:result=dataArr.filter((item)=>{return item.schoolId !=="allschool"})
-  filterValue.unregistered ? result=result:result=result.filter((item)=>{return item.school.areaId !== null})
+  filterValue.unregistered ? result=result:result=result.filter((item)=>{return item.schoolId !== "noschoolid"}) 
+  
   console.log(result,'赋值')
-  filterdata.value=result
+  filterdata.value=result;
+  //debugger
+  if(sortValue.key){
+    onSort(sortValue);  
+  }  
 }
 //获取查看所有老师BTN
 function examineAllteach(value){
@@ -1499,6 +1571,15 @@ function examineAllteach(value){
   touchNowteach.value=value.rowData
   store.commit('transmitUsers', [])
   let data={tmids:teachList,mode:'simple'}
+  
+  // 預設搜尋時間範圍(當年1月到當月)
+  let date = new Date()
+  let nowYear = date.getFullYear()
+  let nowMonth = date.getMonth()
+  data.dateUnit = "month"
+  data.dateFrom = nowYear + "-1"
+  data.dateTo = nowYear + "-" + (nowMonth+1)
+  
   proxy.$api.getUserdatas(data).then((res)=>{
     console.log(res,'查询老师')
     res.length >0 ?(res.forEach((item)=>{item.levels=item.points && item.points.level ?item.points.level:0}),teachData.value=res,originalTeachdata.value=res) :(teachData.value=[],ElMessage.info('暂无查询到相应用户数据'))
@@ -1510,8 +1591,8 @@ function selectTeach (value) {
     console.log(deleteSchoolArr.value,'6666')
 }
 function seachAllteach(){
-  if(deleteSchoolArr.value.length >10){
-      ElMessage.info('当前查询人数仅支持小于或等于10名用户')
+  if(deleteSchoolArr.value.length >100){
+      ElMessage.info('当前查询人数仅支持小于或等于100名用户')
       return
   }
   console.log(deleteSchoolArr.value,'传递出去的参数')
@@ -1863,5 +1944,10 @@ watch(clickNum, (newv) => {
 .dialog-teachlist .el-dialog__header{
   padding: 5px;
 
+}
+.highlight-row {
+  /* background-color: #ffcccc; 特定行的背景色 */
+  background-color: #c6e2ff; /* 特定行的背景色 */
+  
 }
 </style>

+ 23 - 29
TEAMModelBI/ClientApp/src/view/schoolServe/school.vue

@@ -808,18 +808,20 @@ export default {
                 item.versions = item.service.includes('YPXSJ6NJ') && item.service.includes('B6V5J6NP') ? '专业版' : item.service.includes('YMPCVCIM') ? '标准版' : '基础版';
           } */
           //11.14日修正  关于学校版本问题   根据edition   current /1基础   /2标准   /3专业
-           /* if(item.edition !== null){
-            item.edition.current === 1 && item.service.includes('B6V5J6NP') ? item.versions='评测版':
-            item.edition.current === 3 ?  item.versions='专业版':
-            item.edition.current === 2 ? item.versions='标准版':
-            item.edition.current === 1 ? item.versions='基础版':''
+          if (item.code === 'BIRel'){
+            item.edition && item.edition.scaleVersion == '评测版' ? item.versions = '评测版' :
+            item.edition && item.edition.current === 3 ? item.versions = '专业版' :
+            item.edition && item.edition.current === 2 ? item.versions = '标准版' :
+            item.edition == null || (item.edition && item.edition.current == null) || (item.edition && item.edition.current === 1 && (item.edition.scaleVersion == null || item.edition.scaleVersion == '')) ? item.versions = '基础版' : ''
           }else{
-            item.versions='基础版'
-          } */
+            item.versions=''
+          }
+          /*
           item.versions =item.service.includes('YPXSJ6NJ') && item.service.includes('B6V5J6NP') && item.service.includes('YMPCVCIM') ? '专业版':
           item.service.includes('IPDYZYLC') && item.service.includes('YMPCVCIM') && (!item.service.includes('YPXSJ6NJ')) ? '标准版':
           !item.service.includes('IPDYZYLC') && !item.service.includes('YMPCVCIM') && item.service.includes('B6V5J6NP')   ?'评测版':
           !item.service.includes('IPDYZYLC') && !item.service.includes('YMPCVCIM')  ? '基础版':'基础版' 
+                    */
         }),
         tableData.value.push(...res.scInfos),originalNum.value = res.scInfos.length,
         originalData.value = res.scInfos,tablesccnt.value = res.allCnt) 
@@ -1525,32 +1527,24 @@ export default {
       // debugger;
        // 專業版
         arrState.major ? originalData.value.forEach((item) => {
-          item.service.includes('IPDYZYLC') && item.service.includes('YMPCVCIM') && item.service.includes('YPXSJ6NJ') ? 
-          marjorArr.push(item) : '' }) : '' 
-
-         {/* arrState.major ? originalData.value.forEach((item) => {
-          item.edition  && !item.edition.scaleVersion && item.edition.current === 3 ? marjorArr.push(item):''
-         }) : '' */}
-
+         // item.service.includes('IPDYZYLC') && item.service.includes('YMPCVCIM') && item.service.includes('YPXSJ6NJ') ? marjorArr.push(item) : '' }) : '' 
+         item.edition && item.edition.current === 3 && item.code === 'BIRel' ? marjorArr.push(item) : ''
+        }) : ''
        // 標準版
         arrState.standard ? originalData.value.forEach((item) => { 
-        item.service.includes('IPDYZYLC') && item.service.includes('YMPCVCIM') && (!item.service.includes('YPXSJ6NJ')) ? 
-        standardArr.push(item) : '' }) : '' 
-        /* arrState.standard ? originalData.value.forEach((item) => { 
-          item.edition  && !item.edition.scaleVersion && item.edition.current === 2  ? standardArr.push(item):''
-        }) : '' */
+         // item.service.includes('IPDYZYLC') && item.service.includes('YMPCVCIM') && (!item.service.includes('YPXSJ6NJ')) ? standardArr.push(item) : ''
+         item.edition && item.edition.current === 2 && item.code === 'BIRel' ? standardArr.push(item) : ''
+        }) : ''
        // 基礎版
-       arrState.basics ? originalData.value.forEach((item) => { 
-        !item.service.includes('IPDYZYLC') && !item.service.includes('YMPCVCIM') && !item.service.includes('B6V5J6NP') ? 
-        basicsArr.push(item) : '' }) : '' 
-
-        /* arrState.basics ? originalData.value.forEach((item) => { 
-          item.edition  && !item.edition.scaleVersion && item.edition.current === 1 ? basicsArr.push(item):
-          item.edition ==null ? basicsArr.push(item):''
-        }) : '' */
+        arrState.basics ? originalData.value.forEach((item) => { 
+         // !item.service.includes('IPDYZYLC') && !item.service.includes('YMPCVCIM') && !item.service.includes('B6V5J6NP') ? basicsArr.push(item) : ''
+         item.code === 'BIRel' && (item.edition == null || (item.edition && item.edition.current == null) || (item.edition && item.edition.current === 1 && (item.edition.scaleVersion == null || item.edition.scaleVersion == ''))) ? basicsArr.push(item) : ''
+        }) : '' 
        // 自訂版
-       arrState.custom ? originalData.value.forEach((item) => { 
-        !item.service.includes('IPDYZYLC') && !item.service.includes('YMPCVCIM') && item.service.includes('B6V5J6NP') ? customArr.push(item) : '' }) : ''   
+        arrState.custom ? originalData.value.forEach((item) => { 
+         // !item.service.includes('IPDYZYLC') && !item.service.includes('YMPCVCIM') && item.service.includes('B6V5J6NP') ? customArr.push(item) : ''
+         item.edition && item.code === 'BIRel' && item.edition.scaleVersion == '评测版' ? customArr.push(item) : ''
+        }) : ''   
         console.log(marjorArr,standardArr,basicsArr,customArr,'重组')        
       let versionArr = [...marjorArr, ...standardArr, ...basicsArr, ...customArr]
       console.log(versionArr, '合并结果')

+ 86 - 14
TEAMModelBI/ClientApp/src/view/schoolmanage/schoolAnalyse.vue

@@ -215,10 +215,30 @@
       </div>
     </div>
     <div class="schoolList-all">
-      <div class="school-list-title">学校列表:</div>
+      <div class="school-list-title">学校列表:</div>    
       <div class="school-search">
+        <el-select  v-model="selectCity" placeholder="篩選城市" style="width: 240px;margin-bottom: 10px;display: flex;" @change="personnelSearch">
+         <el-option
+           v-for="item in schoolCitys"
+           :key="item.city"
+           :label="item.city"
+           :value="item.city"
+         />                 
+       </el-select>                             
         <el-input v-model="searchText.values" placeholder="搜索 学校名称/学校简码" class="input-with-select" size="small" clearable />
       </div>
+      <!-- <div >        
+        <el-select  v-model="selectCity" placeholder="篩選城市" style="width: 240px" @change="personnelSearch">
+         <el-option
+           v-for="item in schoolCitys"
+           :key="item.city"
+           :label="item.city"
+           :value="item.city"
+         />                 
+       </el-select>            
+      </div> -->
+      
+      
       <div class="school-tables" style="width: 100%; height: 60vh" v-loading="searchText.loading" element-loading-background="rgba(0, 0, 0, 0.5)">
         <!-- <el-table :data="schoolDefault" height="55vh" style="width: 100%" v-loading="searchText.loading" element-loading-background="rgba(0, 0, 0, 0.5)" empty-text="暂无数据">
           <el-table-column label="校徽" align="center">
@@ -373,7 +393,7 @@
     </div>
   </div>
 </template>
-<script>
+<script >
 import { ref, reactive, onMounted, getCurrentInstance, watch } from 'vue'
 import Bar from '@/components/echarts/commonBar.vue'
 import CommonLine from '@/components/echarts/commonLine.vue'
@@ -383,9 +403,12 @@ import Gradepie from '@/components/echarts/gradePie.vue'
 import ConventionPie from '@/components/echarts/conventionPie.vue'
 import { useRouter } from 'vue-router'
 import { useStore } from 'vuex'
-import { ElMessage, ElLoading } from 'element-plus'
+import { ElMessage, TableV2SortOrder, ElLoading, ElCheckbox,HeaderCellSlotProps,ElPopover,Column, RowClassNameGetter} from 'element-plus'
+import { Filter } from '@element-plus/icons'
+import { Search, CirclePlus } from '@element-plus/icons-vue'
 import jwt_decode from 'jwt-decode'
 import * as echarts from 'echarts'
+import { unique } from 'element-plus/es/utils'
 export default {
   components: {
     Bar,
@@ -396,6 +419,9 @@ export default {
     CommonBar
   },
   setup () {
+    const selectCity = ref('')
+    let schoolCitys = reactive([{city:'篩選城市'}])    
+    //let schoolDefault = ref([])
     let showState = ref('all')
     let router = useRouter()
     let { proxy } = getCurrentInstance()
@@ -445,7 +471,7 @@ export default {
         // key: "name",
         // dataKey: "name",//需要渲染当前列的数据字段,如{id:9527,name:'Mike'},则填name
         title: "校徽",
-        width: 400,
+        width: 300,
         fixed: false,
         align: 'center',
         cellRenderer: (data) => (
@@ -455,11 +481,19 @@ export default {
           </>
         )
       },
+      {
+        key: "city",
+        dataKey: "city",//需要渲染当前列的数据字段,如{id:9527,name:'Mike'},则填name
+        title: "城市",
+        width: 300,
+        fixed: false,
+        align: 'center',
+      },
       {
         key: "name",
         dataKey: "name",//需要渲染当前列的数据字段,如{id:9527,name:'Mike'},则填name
         title: "名称",
-        width: 400,
+        width: 300,
         fixed: false,
         align: 'center',
       },
@@ -483,12 +517,12 @@ export default {
         key: "schoolId",
         dataKey: "schoolId",//需要渲染当前列的数据字段,如{id:9527,name:'Mike'},则填id
         title: "学校简码",//显示在单元格表头的文本
-        width: 400,//当前列的宽度,必须设置
+        width: 300,//当前列的宽度,必须设置
         align: 'center',
       },
       {
         title: "",
-        width: 400,
+        width: 300,
         align: "center",
         // fixed: 'right',
         cellRenderer: (data) =>
@@ -1788,6 +1822,35 @@ export default {
           })
           allLoding.value.rankData = false
           schoolDefault.value = res.scInfos
+          
+          let cityarr = [];
+          res.scInfos.forEach((item) =>{
+            let citem = {
+              city:item.city
+            }
+            cityarr.push(citem);
+          })
+          
+           //cityarr = [...new Set(cityarr)];
+           cityarr = [...new Set(cityarr.map(item => item.city))];
+           
+          cityarr.forEach((item) => {
+            if (item !== "" && item !== null && item !== undefined) {
+              let citem = {
+                city: item
+              }
+              schoolCitys.push(citem)
+            }
+          })          
+
+          // //schoolCitys.value = cityarr;
+          // schoolCitys = [
+          //   {city:'111'},
+          //   {city:'222'},
+          //   {city:'333'},
+          // ]
+          
+
           searchText.original = res.scInfos
           searchText.loading = false
           serviceVersion(res.productGroup, res.scInfos)
@@ -1807,7 +1870,7 @@ export default {
       }).catch((error) => {
         ElMessage.error('数据获取API异常')
       })
-    }
+    }    
     function allAspects (val, state, behinddata) {
       console.log(val, state, behinddata)
       //let data = state === 'details' ? { schoolId: val } : { tmdId: val }
@@ -1969,8 +2032,7 @@ export default {
       // })
     }
     function detailsSchool (val) {
-      console.log(val);
-      // debugger;
+      console.log(val);      
       let schoolData = val
       schoolDeatilsInfo(schoolData.schoolId)
       showState.value = 'particular'
@@ -2122,7 +2184,7 @@ export default {
           schoolDeatils.value.versions = ''
           anSchool.value.teachNum = res.scStats.tch
           anSchool.value.studentNum = res.scStats.stu
-          anSchool.value.classNum = res.scStats.room
+          anSchool.value.classNum = res.scStats.witRoom
           anSchool.value.classInfoNum = res.scStats.lessStats.all
           detailsLoding.value.header = false
           //处理柱状图
@@ -2359,6 +2421,14 @@ export default {
       let newArr = arr.filter((item) => {
         return item.name.includes(searchText.values) || item.id.includes(searchText.values)
       })
+      debugger
+      if (selectCity.value !== "" && selectCity.value !== "篩選城市") {
+        newArr = newArr.filter((item) => {
+          if (item.city !== null && item.city !== undefined && item.city !== "") {
+            return item.city.includes(selectCity.value)
+          }
+        })
+      }      
       schoolDefault.value = newArr
     }
     showInit()
@@ -2367,13 +2437,15 @@ export default {
       newdata.hasOwnProperty('name') ? (showState.value = 'particular', schoolDeatils.value = newdata, schoolDeatilsInfo(newdata.id), isAreaon.value = true) : ''
     }, { immediate: true, deep: true })
     watch(() => searchText.values, (newvalues) => {
-      if (newvalues.trim().length !== 0) {
+      if (newvalues.trim().length !== 0 || selectCity.value !== "篩選城市") {
         debounce(personnelSearch, 500)
-      } else {
+      } else {        
         schoolDefault.value = searchText.original
       }
     })
-    return {
+    return {            
+      schoolCitys,
+      selectCity,
       headerbasics,
       echartsData,
       imgdata,

+ 93 - 15
TEAMModelBI/ClientApp/src/view/systemConfig/pushmsg/createdpush.vue

@@ -141,7 +141,7 @@
                   <!--学区选择列表(学区)-->
                   <div class="type-list" v-else-if="typeselect ===1">
                     <el-checkbox-group v-model="constructorData.receivedata.area" @change="pitchChange">
-                      <div class="itemtype-area" v-for="item in allList.allArea" :title="item.name">
+                      <div class="itemtype-area" v-for="item in allList.allArea" :key="item" :title="item.name">
                         <el-checkbox :label="item.name" :key="item.id" />
                         <div class="next-icon" @click="subordinate(item.id),typeselect=2,clickname=item.name">
                           下级
@@ -280,7 +280,7 @@
                       </div>
                       <div class="not-inquirebox">
                         <p class="result-titles">查询失败:</p>
-                        <div class="notinquirebox-box" v-for="itemE in batchResult.not">
+                        <div class="notinquirebox-box" v-for="itemE in batchResult.not" :key="itemE">
                           <div class="errorbox" :title="itemE">{{itemE}}</div>
                           <div class="errortitle">未查询到相关信息</div>
                         </div>
@@ -298,7 +298,7 @@
               <el-button size="small" :icon="Delete" @click="clearall">全部清除</el-button>
             </div>
             <div class="receivebox">
-              <el-tag class="crowd-tag" v-for="item in receivedatas" :type="item.dataType==='area' ? 'warning':item.dataType ==='school' ? 'success' :'' " closable @close="removecrowd(item)">
+              <el-tag class="crowd-tag" v-for="item in receivedatas" :key="item" :type="item.dataType==='area' ? 'warning':item.dataType ==='school' ? 'success' :'' " closable @close="removecrowd(item)">
                 {{item.name}}
               </el-tag>
             </div>
@@ -351,7 +351,7 @@
           <div class="crowd">
             <p class="result-title">接收人群</p>
             <div class="crowdbox">
-              <el-tag class="crowd-tag" v-for="item in receivedatas" :type="item.dataType ==='area' ? 'warning':item.dataType ==='school' ? 'success':'' " closable>
+              <el-tag class="crowd-tag" v-for="item in receivedatas" :key="item" :type="item.dataType ==='area' ? 'warning':item.dataType ==='school' ? 'success':'' " closable>
                 {{item.name}}
               </el-tag>
             </div>
@@ -880,21 +880,99 @@ function publish () {
   })
 }
 //system通知  访问TW API内容
-function pushSystem(){
+ function pushSystem(){    
   console.log(constructorData.value)
   console.log(receivedatas.value)
   console.log(constructorData.value.receiveType)
   let tagsData=[]; let receives=constructorData.value.receiveType =='hita5' ? 'HiTA':constructorData.value.receiveType
-  receivedatas.value.forEach((item)=>{tagsData.push(item.id+'_'+receives)})
-  let data=''
-  if(constructorData.value.systemType ==='interior'){
-    data={tags:tagsData,title:constructorData.value.basic.title,body:constructorData.value.basic.content,sender:'HiTeach'}
-  }else{
-    data={hubName:constructorData.value.receiveType,tags:tagsData,title:constructorData.value.basic.title,body:constructorData.value.basic.content,sender:'HiTeach'}
+  receivedatas.value.forEach((item) => { tagsData.push(item.id + '_' + receives) })
+  let action = {};
+  let data = {};
+  // 設定內容
+  if (constructorData.value.basic.callbackstate) {
+    if (constructorData.value.basic.callbackFn === '1') {// 同意拒絕
+      action = {
+        action: [
+          {
+            "type": "click",
+            "label": "同意",
+            "url": constructorData.value.basic.skipUrl,
+            "tokenbindtype": 1
+          },
+          {
+            "type": "click",
+            "label": "拒绝",
+            "url": constructorData.value.basic.skipUrl,
+            "tokenbindtype": 1
+          }
+        ]
+      }
+    } else if (constructorData.value.basic.callbackFn === '2') {// 查看
+      action = {
+        action: [
+          {
+            "type": "click",
+            "label": "查看",
+            "url": constructorData.value.basic.skipUrl,
+            "tokenbindtype": 1
+          }
+        ]
+      }
+    }
   }
-  console.log(data,'通知的参数')
-   proxy.$api.sendPushnotify(data).then((res)=>{
-     ElMessage.success('消息发送成功')
+  if (constructorData.value.systemType === 'interior') {
+    data = { 
+      tags: tagsData, 
+      title: constructorData.value.basic.title, 
+      body: constructorData.value.basic.content, 
+      sender: 'HiTeach',
+      eventId: "BI-send",
+      eventName: "BI_SendNotice",      
+      data: JSON.stringify(action)
+     }
+  } else {    
+    data = { 
+      hubName: constructorData.value.receiveType, 
+      tags: tagsData, 
+      title: constructorData.value.basic.title, 
+      body: constructorData.value.basic.content,       
+      sender: 'HiTeach',
+      eventId: "BI-send",
+      eventName: "BI_SendNotice",
+      data: JSON.stringify(action)     
+    }
+  }
+  //debugger;
+  //处理接受人群分类
+  let areaArr = []; let schoolArr = []; let personageArr = [];
+  receivedatas.value.forEach((item) => { item.hasOwnProperty('dataType') ? item.dataType === 'area' ? areaArr.push({ id: item.id, name: item.name }) : item.dataType === 'school' ? schoolArr.push({ id: item.id, name: item.name }) : '' : personageArr.push({ id: item.id, name: item.name }) })
+  let timePs = new Date().getTime();
+  
+  let submitdata = {
+    type: Number(constructorData.value.basic.type) - 1,
+    jumpUrl: constructorData.value.basic.skipstate ? constructorData.value.basic.skipUrl : '',
+    callbackName: constructorData.value.basic.callbackstate && constructorData.value.basic.callbackFn === '1' ? '同意' : constructorData.value.basic.callbackstate && constructorData.value.basic.callbackFn === '2' ? '查看' : '',
+    refuseName: constructorData.value.basic.callbackstate && constructorData.value.basic.callbackFn === '1' ? '拒绝' : '',
+    theme: constructorData.value.basic.title,
+    content: constructorData.value.basic.content,
+    tmdIds: personageArr,
+    schoolIds: schoolArr,
+    areaIds: areaArr,
+    crowdType: constructorData.value.receiveType,
+    sendTime: timePs,
+    source: constructorData.value.source,
+    isOnlySave: true
+  }
+   proxy.$api.sendPushnotify(data).then(async (res)=>{
+    //debugger;
+    
+      await proxy.$api.sendMsgs(submitdata).then((res_save) => {            
+      }).catch((error) => {
+        ElMessage.error('紀錄API异常,消息发送失败!')
+      })
+    
+
+      await ElMessage.success('消息发送成功'), clearData(), router.push('/home/pushmsg');
    }).catch((error)=>{
     ElMessage.error('API异常,消息发送失败!')
    })
@@ -1023,7 +1101,7 @@ watch(store.state.msgData, (newvalue) => {
   clear: both;
 }
 .clearfix {
-  *zoom: 1;
+  zoom: 1;
 }
 .stepsshow {
   display: flex;

+ 4 - 1
TEAMModelBI/ClientApp/src/view/systemConfig/pushmsg/index.vue

@@ -2,7 +2,7 @@
   <div class="msgbox">
     <div class="header">
       <div class="block">
-        <el-date-picker v-model="value1" type="daterange" range-separator="至" start-placeholder="开始时间" end-placeholder="结束时间" :locale="locale" />
+        <!-- <el-date-picker v-model="value1" type="daterange" range-separator="至" start-placeholder="开始时间" end-placeholder="结束时间" :locale="locale" /> -->
       </div>
       <div>
         <el-button type="primary" @click="skipcreated">
@@ -202,6 +202,7 @@ let tableSelect = ref({
     { value: 'common', label: '普通' },
     { value: 'hint', label: '提示' },
     { value: 'special', label: '特殊' },
+    { value: 'system', label: '系統' },
   ]
 })
 let showState = ref('default')
@@ -243,6 +244,8 @@ function changeTag (val) {
     tableData.value = originalData.value.filter((item) => { return item.type === 3 })
   } else if (values === 'special') {
     tableData.value = originalData.value.filter((item) => { return item.type === 4 })
+  } else if (values === 'system') {
+    tableData.value = originalData.value.filter((item) => { return item.type === 1 })
   }
 }
 function detailsMsg (val) {

+ 131 - 32
TEAMModelBI/ClientApp/src/view/userInquire/details.vue

@@ -61,23 +61,23 @@
         </div>
         <el-divider />
         <div class="product-list">
-                    <div class="product-title">
-                        <el-button type="primary" size="small" @click="loginDialog=true">
-                            查看完整登入情况
-                            <el-icon class="el-icon--right"><Right /></el-icon>
-                        </el-button>
-                    </div>
-                    <div class="listbox">
-                        <div :class="[item.state ? item.key:'notenabled','listbox-item']" v-for="item in productdata.slice(0, 4)" :key="item.id">
-                            <p class="item-title">{{item.title}}</p>
-                            <div class="item-content" v-show="item.state">
-                                <div class="content-left">
-                                    <span>上次登陆时间:{{item.valueText}}</span>
-                                </div>
-                            </div>
-                            <div class="notenabled-title" v-show="!item.state">近期未使用</div>
+            <div class="product-title">
+                <el-button type="primary" size="small" @click="loginDialog=true">
+                    查看完整登入情况
+                    <el-icon class="el-icon--right"><Right /></el-icon>
+                </el-button>
+            </div>
+            <div class="listbox">
+                <div :class="[item.state ? item.key:'notenabled','listbox-item']" v-for="item in productdata.slice(0, 4)" :key="item.id">
+                    <p class="item-title">{{item.title}}</p>
+                    <div class="item-content" v-show="item.state">
+                        <div class="content-left">
+                            <span>上次登陆时间:{{item.valueText}}</span>
                         </div>
                     </div>
+                    <div class="notenabled-title" v-show="!item.state">近期未使用</div>
+                </div>
+            </div>
         </div>
         <el-divider />
         <!--账户进阶数据-->
@@ -92,7 +92,17 @@
                     <div>IOT</div>
                     <!-- <div class="expire">到期日:XXXXX</div> -->
                     <div>
-                        <el-button v-for="item in buttonSelect" :key="item.value" :type="item.click ? 'primary':!item.disabled ? '':'info'" size="small" class="clickbox" :disabled="item.disabled" @click="selectTime(item.value)">{{item.name}}</el-button>
+                        <!-- <el-button v-for="item in buttonSelect" :key="item.value" :type="item.click ? 'primary':!item.disabled ? '':'info'" size="small" class="clickbox" :disabled="item.disabled" @click="selectTime(item.value)">{{item.name}}</el-button> -->
+                        <el-date-picker
+                            v-model="searchRange"
+                            type="monthrange"
+                            range-separator="-"
+                            start-placeholder="Start month"
+                            end-placeholder="End month"
+                            style="margin-right: 5px;"
+                            :disabled-date="disabledDate"
+                        />
+                        <el-button :icon="Search" circle  @click="searchIOT"/>
                     </div>
                 </div>
                 <el-divider />
@@ -259,7 +269,7 @@
                                         <p class="subjoin-title">{{subjoinData.hiteachTitle}}</p>
                                             <div v-if="subjoinData.hiteach.length >0">
                                                 <div class="subjoin-content" v-for="item in subjoinData.hiteach" :key="item.key">
-                                                <div>
+                                                <div v-if="item.exps > 0 && item.gets > 0">
                                                     <span>{{item.title}}</span>
                                                     <span class="ccnums" v-show="item.key==='webirs'">{{item.value}}</span>
                                                     <span class="endtimes" v-if="item.exps >= notTime">(到期日:{{item.end}})</span>
@@ -383,9 +393,23 @@ import Ticket from './ticket.vue'
 import Userdetail from './userdetail.vue'
 import replaceHiTeach from './iot.vue'
 import { useRouter } from 'vue-router'
+import { Search } from '@element-plus/icons-vue'
+import { ElMessage } from 'element-plus'
+
 let props = defineProps({
     searchdata: Object,
+    defDate: Array
 })
+
+const searchRange = ref(props.defDate)
+
+// 日曆元件限制設定
+const disabledDate = time => {
+    if(time.getTime() > (Date.now())){ // 不能超過今天
+        return true
+    }
+}
+
 let router=useRouter()
 const store = useStore()
 let {ctx:that,proxy } = getCurrentInstance()
@@ -674,7 +698,15 @@ let rightsdata=ref([
     {name:'XXXXXX',time:'2024/08/29',code:'ais'},
 ])
 let detailsData = ref()
-detailsData.value = props.searchdata?.length > 0 ? props.searchdata : ''
+if(props.searchdata?.length > 0){
+    detailsData.value = props.searchdata
+    detailsData.value.forEach( e =>{
+        e.searchRange = searchRange.value
+    })
+
+} else {
+    detailsData.value = ''
+}
 let transferNum=ref(0)   //*滚动的数值*
 let ies5datas=ref(detailsData.value[transferNum.value].ies5)
 let sokratesData=ref(detailsData.value[transferNum.value].sokrates)
@@ -697,6 +729,9 @@ let powerExtension=ref([
     {title:'議課人數',key:'soknumber',value:0,state:false},
     {title:'智慧評分系統',key:'scorsys',state:false},
     {title:'IRS硬體遙控器',key:'irs',state:true},
+    {title:'蘇格拉底語音轉寫',key:'sokvtt',state:false},
+    {title:'協作',key:'cowork',state:false},
+    {title:'AI GPT服務',key:'aigpt',state:false},
 ])
 let subjoinData=ref({
     hiteachTitle:'HiTeach 附加功能',
@@ -705,7 +740,10 @@ let subjoinData=ref({
         {title:'AI苏格拉底小数据',key:'soklite',start:0,end:0,value:0,gets:0,exps:0},
         {title:'智慧评分',key:'smartrating',start:0,end:0,value:0,gets:0,exps:0},
         {title:'clouDAS诊断分析',key:'cloudas',start:0,end:0,value:0,gets:0,exps:0},
-        {title:'Web IRS连线数',key:'webirs',start:0,end:0,value:0,gets:0,exps:0}
+        {title:'Web IRS连线数',key:'webirs',start:0,end:0,value:0,gets:0,exps:0},
+        {title:'蘇格拉底語音轉寫',key:'sokvtt',start:0,end:0,value:0,gets:0,exps:0},
+        {title:'協作',key:'cowork',start:0,end:0,value:0,gets:0,exps:0},
+        {title:'AI GPT服務',key:'aigpt',start:0,end:0,value:0,gets:0,exps:0},
     ],
     hiteachCCTitle:'HiTeach CC 权限',
     hiteachCC:[
@@ -756,6 +794,53 @@ const backClick = () => {
         emits('parentClick','default')
     }
 }
+
+const searchIOT = ()=>{
+    try {
+        let searchIot = {
+            tmids: [detailsData.value[transferNum.value].id],
+            dateUnit: 'month'
+        }
+
+        let from = new Date(searchRange.value[0])
+        let to = new Date(searchRange.value[1])
+
+        let fromYear = from.getFullYear()
+        let fromMonth = from.getMonth()+1
+
+        let toYear = to.getFullYear()
+        let toMonth = to.getMonth()+1
+
+        searchIot.dateFrom = `${fromYear}-${fromMonth}`
+        searchIot.dateTo = `${toYear}-${toMonth}`
+
+        console.log(searchIot, 'searchIot')
+        
+        loading.value = true
+        proxy.$api.getUserIOT(searchIot).then((res) => {
+            console.log(res[0].iot)
+            detailsData.value[transferNum.value].iot = res[0].iot
+            if(res[0].iot.hiteach.month !==null) {
+                detailsIot.value = res[0].iot.hiteach.month
+                iotState.value = true
+            } else {
+                detailsIot.value = null
+                iotState.value = false
+            }
+            
+            // 搜尋成功修改預設時間
+            detailsData.value[transferNum.value].searchRange = searchRange.value
+
+        }).catch((err) => {
+            ElMessage.error('API异常,查询失败')
+        }).finally(() => {
+            loading.value = false
+        });
+    } catch(e){
+        ElMessage.error('請先選擇查詢月份!!')
+    }
+}
+
 // initdata()
 function initdata() {
     console.log(detailsData.value,'进入方法查看')
@@ -837,6 +922,9 @@ function initdata() {
             apruleItem.soknumber !==0 ? (powerExtension.value[12].state=true,powerExtension.value[12].value=apruleItem.soknumber):powerExtension.value[12].state=false //議課人數
             apruleItem.scorsys ? (powerExtension.value[13].state=true,powerExtension.value[13].value=apruleItem.soknumber):powerExtension.value[13].state=false //智慧評分系統
             apruleItem.hasOwnProperty('irs') ? powerExtension.value[14].state=false:powerExtension.value[14].state=true  //IRS硬體遙控器
+            apruleItem.sokvtt ? powerExtension.value[15].state = true : powerExtension.value[15].state = false //蘇格拉底語音轉寫
+            apruleItem.cowork ? powerExtension.value[16].state = true : powerExtension.value[16].state = false //協作
+            apruleItem.aigpt ? powerExtension.value[17].state = true : powerExtension.value[17].state = false //AI GPT服務
             item.apruleArr=powerExtension.value
         }
         //处理时间
@@ -853,7 +941,10 @@ function initdata() {
     console.log(powerList.value,'权益内容')
     //处理权益内 附加功能(HITeach附加 CC权限)
     let hiteachData=benefits.hiteach !==null ?benefits.hiteach:[] ; let ccData=benefits.hiteachcc !==null  ?benefits.hiteachcc:[]
-    console.log(hiteachData,ccData)
+    console.log(hiteachData, ccData)
+    subjoinData.value.hiteach.forEach((items) => {
+        items.start = 0, items.end = 0, items.value = 0, items.gets = 0, items.exps = 0
+    })
     if(hiteachData.length >0){
         hiteachData.forEach((item)=>{
             let funcKey=item.func;let startTime=proxy.$common.timestampToTime(item.get);let endTime=proxy.$common.timestampToTime(item.exp)
@@ -900,22 +991,29 @@ function bytesToGB(bytes) {
 function init(){
     loading.value=true
     console.log(detailsData.value,transferNum.value,'查看IOT')
-    //处理关于iot问题
-    detailsData.value[transferNum.value].iot.hiteach.day !==null ? 
-    (buttonSelect.value[0].click=true,detailsIot.value=detailsData.value[transferNum.value].iot.hiteach.day,iotState.value=true):
-    detailsData.value[transferNum.value].iot.hiteach.month !==null ? 
-    (buttonSelect.value[1].click=true,detailsIot.value=detailsData.value[transferNum.value].iot.hiteach.month,iotState.value=true):
-    detailsData.value[transferNum.value].iot.hiteach.year !==null ? 
-    (buttonSelect.value[2].click=true,detailsIot.value=detailsData.value[transferNum.value].iot.hiteach.year,iotState.value=true):iotState.value=false
+    // 处理关于iot问题(目前預設都取[月])
+    if(detailsData.value[transferNum.value].iot.hiteach.month !==null) {
+        detailsIot.value = detailsData.value[transferNum.value].iot.hiteach.month
+        iotState.value = true
+    } else {
+        iotState.value = false
+    }
+
+    // detailsData.value[transferNum.value].iot.hiteach.day !==null ? 
+    // (buttonSelect.value[0].click=true,detailsIot.value=detailsData.value[transferNum.value].iot.hiteach.day,iotState.value=true):
+    // detailsData.value[transferNum.value].iot.hiteach.month !==null ? 
+    // (buttonSelect.value[1].click=true,detailsIot.value=detailsData.value[transferNum.value].iot.hiteach.month,iotState.value=true):
+    // detailsData.value[transferNum.value].iot.hiteach.year !==null ? 
+    // (buttonSelect.value[2].click=true,detailsIot.value=detailsData.value[transferNum.value].iot.hiteach.year,iotState.value=true):iotState.value=false
 
     //BTN显示问题
-    console.log(detailsData.value,'按钮问题')
-    detailsData.value[transferNum.value].iot.hiteach.day ? (buttonSelect.value[0].disabled=false):(buttonSelect.value[0].disabled=true,buttonSelect.value[0].click=false)
-    detailsData.value[transferNum.value].iot.hiteach.month ? (buttonSelect.value[1].disabled=false):(buttonSelect.value[1].disabled=true,buttonSelect.value[1].click=false)
-    detailsData.value[transferNum.value].iot.hiteach.year  ? (buttonSelect.value[2].disabled=false):(buttonSelect.value[2].disabled=true,buttonSelect.value[2].click=false)
+    // console.log(detailsData.value,'按钮问题')
+    // detailsData.value[transferNum.value].iot.hiteach.day ? (buttonSelect.value[0].disabled=false):(buttonSelect.value[0].disabled=true,buttonSelect.value[0].click=false)
+    // detailsData.value[transferNum.value].iot.hiteach.month ? (buttonSelect.value[1].disabled=false):(buttonSelect.value[1].disabled=true,buttonSelect.value[1].click=false)
+    // detailsData.value[transferNum.value].iot.hiteach.year  ? (buttonSelect.value[2].disabled=false):(buttonSelect.value[2].disabled=true,buttonSelect.value[2].click=false)
     
     //获取hiteach 版本号
-     let versionsData=detailsData.value[transferNum.value].iot.hiteach ?.year ?.verList
+     let versionsData=detailsData.value[transferNum.value].iot.hiteach ?.month ?.verList
     console.log(versionsData)
      let hiteachV=versionsData ? versionsData.sort((a,b)=>{return b-a}):'暂无'
      console.log(hiteachV,'版本号')
@@ -940,6 +1038,7 @@ function cutUser(){
     ies5datas.value=detailsData.value[transferNum.value].ies5
     sokratesData.value=detailsData.value[transferNum.value].sokrates
     pointsData.value=detailsData.value[transferNum.value]
+    searchRange.value = detailsData.value[transferNum.value].searchRange
     powerList.value=[]
     initdata()
     init()

Dosya farkı çok büyük olduğundan ihmal edildi
+ 1153 - 0
TEAMModelBI/ClientApp/src/view/userInquire/idIncrement.vue


+ 75 - 40
TEAMModelBI/ClientApp/src/view/userInquire/index.vue

@@ -1,51 +1,63 @@
 <template>
-    <div class="inquirebox" v-if="pageShow ==='default'">
+    <div class="inquirebox" >
         <div class="inquire-title">
             <p>TEAM Model 智慧教育</p>
         </div>
-        <div class="searchbox" v-loading="searchLoading" element-loading-text="数据搜索中...">
-            <div class="searchbox-title">
-                <p>用户查询</p>
-            </div>
-            <el-divider border-style="dashed" />
-            <div class="searchbox-item">
-                <el-input v-model="searchvalue" placeholder="输入手机号码/醍摩豆账号 进行搜索" class="input-with-select">
-                <template #prepend>
-                    <el-select v-model="selecttypes" placeholder="Select" style="width: 120px">
-                    <el-option label="精准查询" value="precise" />
-                    <!-- <el-option label="批量查询/操作" value="batch" /> -->
-                    </el-select>
-                </template>
-                <template #append>
-                    <el-button :icon="Search" @click="seachSole()"/>
-                </template>
-                </el-input>
-            </div>
-            <div class="recordbox" v-if="selecttypes==='precise'">
-                <p>搜索记录:</p>
-                <div class="recordbox-item">
-                    <el-tag v-for="tag in searchRecordsArr"  class="mx-1" closable type="''"  effect="light" @close="deleteLog(tag)" @click="searchvalue=tag">
-                        {{ tag }}
-                    </el-tag>
+        <el-tabs v-if="pageShow ==='default'" style="width: 100%;height:100%;" type="card" class="demo-tabs" v-model="activeTab">
+            <el-tab-pane label="用户查询" style="padding: 1%;display: flex;justify-content: center;" name="tab1">
+                <div class="searchbox" v-loading="searchLoading" element-loading-text="数据搜索中...">
+                    <div class="searchbox-title">
+                        <p>用户查询</p>
+                    </div>
+                    <el-divider border-style="dashed" />
+                    <div class="searchbox-item">
+                        <el-input v-model="searchvalue" placeholder="输入手机号码/醍摩豆账号 进行搜索" class="input-with-select">
+                        <template #prepend>
+                            <el-select v-model="selecttypes" placeholder="Select" style="width: 120px">
+                            <el-option label="精准查询" value="precise" />
+                            <!-- <el-option label="批量查询/操作" value="batch" /> -->
+                            </el-select>
+                        </template>
+                        <template #append>
+                            <el-button :icon="Search" @click="seachSole()"/>
+                        </template>
+                        </el-input>
+                    </div>
+                    <div class="recordbox" v-if="selecttypes==='precise'">
+                        <p>搜索记录:</p>
+                        <div class="recordbox-item">
+                            <el-tag v-for="tag in searchRecordsArr"  class="mx-1" closable type="''"  effect="light" @close="deleteLog(tag)" @click="searchvalue=tag">
+                                {{ tag }}
+                            </el-tag>
+                        </div>
+                        <div class="dele-all" v-show="searchRecordsArr.length >0">
+                            <el-icon size="14" @click="deleAllsearch"><Delete /></el-icon>
+                        </div>
+                    </div>
+                    <div class="recordbox" v-else="selecttypes ==='batch'">
+                        <p>搜索结果:</p>
+                    </div>
                 </div>
-                <div class="dele-all" v-show="searchRecordsArr.length >0">
-                    <el-icon size="14" @click="deleAllsearch"><Delete /></el-icon>
-                </div>
-            </div>
-            <div class="recordbox" v-else="selecttypes ==='batch'">
-                <p>搜索结果:</p>
-            </div>
+            </el-tab-pane>
+            <el-tab-pane label="弱歸戶" style="padding: 1%" name="tab2">
+                <UpdCodeW />
+            </el-tab-pane>
+            <el-tab-pane label="ID歸戶增量統計"  name="tab3">
+                <IdIncrement />
+            </el-tab-pane>
+        </el-tabs>
+        <div class="inquirebox-details" v-else-if="pageShow ==='details'">
+            <Detailsbox :searchdata="searchResult" :defDate="defDate" @parentClick="backClicks"></Detailsbox>
         </div>
     </div>
-    <div class="inquirebox-details" v-else-if="pageShow ==='details'">
-        <Detailsbox :searchdata="searchResult" @parentClick="backClicks"></Detailsbox>
-    </div>
 </template>
 <script setup>
-import { ref, getCurrentInstance, watch, h, nextTick,provide } from 'vue'
+import { ref, reactive, getCurrentInstance, watch, h, nextTick,provide } from 'vue'
 import { ElMessage, ElLoading } from 'element-plus'
 import { Search,Delete } from '@element-plus/icons'
 import Detailsbox from './details.vue'
+import UpdCodeW from './updCodeW.vue'
+import IdIncrement from './idIncrement.vue'
 import {useRoute} from "vue-router"
 import { useStore } from 'vuex'
 let { proxy } = getCurrentInstance()
@@ -65,7 +77,9 @@ let pageShow = ref('default')
 let searchvalue=ref('')
 let selecttypes = ref('precise')
 let searchResult=ref()
+let defDate = ref()
 let searchLoading=ref(false)
+let activeTab = reactive('tab1')
 const searchRecordsArr = ref(localStorage.getItem('searchRecords') ?  JSON.parse(localStorage.getItem('searchRecords')):[]);
 const backClicks=()=>{pageShow.value='default'}
 console.log(searchRecordsArr.value,'搜索记录')
@@ -87,8 +101,8 @@ function seachSole(datavalue) {
         searchvalue.value=searchvalue.value.replace(/,/g, ',');
         userArr = searchvalue.value.split(',');
     }
-    if(userArr.length >10){
-            ElMessage.info('同时查询人员不能大于10,请调整查询范围')
+    if(userArr.length >100){
+            ElMessage.info('同时查询人员不能大于100,请调整查询范围')
             return
     }
     //let testdata=['1524738018','1595321354']
@@ -102,12 +116,20 @@ function seachSole(datavalue) {
         type:searchvalue.value.includes(',') || searchvalue.value.includes(',') ? 'multiple':'only',
         time:Date.now()
     }
+    // 預設搜尋時間範圍(當年1月到當月)
+    let date = new Date()
+    let nowYear = date.getFullYear()
+    let nowMonth = date.getMonth()
+    data.dateUnit = "month"
+    data.dateFrom = nowYear + "-1"
+    data.dateTo = nowYear + "-" + (nowMonth+1)
+
     proxy.$api.getUserdatas(data).then((res) => { 
         //重置vuex内的值,预防下次Menu进入 自动获取vuex值进行查询
         store.commit('transmitUsers', [])
         console.log(res, 'user back')
         res.length >0 ? 
-        (searchResult.value=res,searchLoading.value=false,pageShow.value='details'):
+        (searchResult.value=res,searchLoading.value=false,pageShow.value='details',defDate.value=[new Date(nowYear, 0), new Date(nowYear, nowMonth)]):
         (ElMessage.error('暂无搜索到相关人员,请检查信息搜索'),searchLoading.value=false)
         //搜索记录
         if(res.length >0){saveSearchRecord(searchvalue.value)}
@@ -170,9 +192,10 @@ function deleAllsearch(){
     align-items: center;
     justify-content: center;
     position: relative;
+    /* height: 86vh; */
 }
 .searchbox{
-    width:60%;
+    width: 40vw;
     height:50vh;
     background-color: #fff;
     z-index:999;
@@ -238,4 +261,16 @@ function deleAllsearch(){
     top:1%;
     right:5%;
 }
+</style>
+<style>
+.demo-tabs .el-tabs__item.is-active{
+    color: #333333;
+    font-weight: bold;
+    font-size: 17px;
+}
+.demo-tabs .el-tabs__item.is-active{
+    border-bottom-color: #fff !important;
+    border-bottom-width: 3px;
+    background-color: #ffffffad;
+}
 </style>

+ 7 - 4
TEAMModelBI/ClientApp/src/view/userInquire/iot.vue

@@ -488,7 +488,7 @@
     city: '',
     dist: '',
   })
-  let lessonsList = ref([
+  let lessonsList = ref([  
     { icon: '#icon--caozuorizhi', title: 'IES课程', content: '使用IES课程', state: true, value: 0 },
     { icon: '#icon--caozuorizhi', title: 'webIrs', content: '使用webIrs', state: true, value: 0 },
     { icon: '#icon--caozuorizhi', title: 'IRS', content: '使用IRS', state: true, value: 0 },
@@ -502,6 +502,7 @@
     { icon: '#icon--caozuorizhi', title: 'Excel测验', content: '使用Excel卷测验', state: true, value: 0 },
     { icon: '#icon--caozuorizhi', title: '纸本测验', content: '使用纸本测验', state: true, value: 0 },
     { icon: '#icon--caozuorizhi', title: 'T课堂', content: '符合T课堂数', state: true, value: 0 },
+    { icon: '#icon--caozuorizhi', title: 'T指数', content: '课程T绿灯数', state: true, value: 0 },
   ])
   let inuseList = ref([
     { title: '学习任务数', value: 15, icon: '#icon-renwu', percent: '41.2%', class: 'task', textClass: 'task-text' },
@@ -516,8 +517,8 @@
     { name: '差异化形态课堂', value: 20, percent: '5%', class: 'interaction', textClass: 'interaction-text' },
     { name: '协作型态课堂', value: 30, percent: '15%', class: 'testclass', textClass: 'testclass-text' },
     { name: '互评型态课堂', value: 30, percent: '15%', class: 'testclass', textClass: 'testclass-text' },
-    { name: '无型态课堂', value: 0, percent: '0%', class: 'noneclass', textClass: 'noneclassclass-text' },
-    { name: '未上课', value: 0, percent: '0%', class: 'noneclass', textClass: 'noneclassclass-text' },
+    { name: '教材展示', value: 0, percent: '0%', class: 'noneclass', textClass: 'noneclassclass-text' },
+    { name: '白板应用', value: 0, percent: '0%', class: 'noneclass', textClass: 'noneclassclass-text' },
   ])
   let echartData = ref({
     total: 0,
@@ -568,7 +569,7 @@
           }
         },
         boundaryGap: true, // 坐标轴两边是否留白
-        data: ['合作', '互动', '任务', '差异化', '协作','互评', '无型态', '未上课']
+        data: ['合作', '互动', '任务', '差异化', '协作','互评', '教材展示', '白板应用']
       },
       yAxis: [
         {
@@ -691,6 +692,8 @@
     lessonsList.value[11].value=usePaperTest ?usePaperTest:0
     //符合T课堂数
     lessonsList.value[12].value=tLesson ? tLesson:0
+    // T綠燈
+    lessonsList.value[13].value=tGreen
   
     //授权内容
     let {lessonCnt928,lessonCntId, lessonCntDevice, lessonCntIdDevice,deviceCnt } = propsbox.detailsData

+ 304 - 0
TEAMModelBI/ClientApp/src/view/userInquire/updCodeW.vue

@@ -0,0 +1,304 @@
+<template>
+    <div class="updCodeWBox" v-loading="loading" :element-loading-text="loadingStr">
+        <!-- <div class="updCodeWBox-title">
+            <p>弱歸戶</p>
+        </div>
+        <el-divider border-style="dashed" /> -->
+        <div style="line-height: 1px;height: 100%;overflow: auto;">
+            <div style="margin-bottom: 10px;">
+                <h3>區域</h3>
+                <el-radio-group class="radioSty" v-model="countryId" @change="cIdChange">
+                    <el-radio label="CN" size="large"  border>大陆地区</el-radio>
+                    <el-radio label="TW" size="large" border>臺灣地區</el-radio>
+                </el-radio-group>
+            </div>
+            
+            <div style="margin-bottom: 10px;" v-if="provinceIdData != null">
+                <h3>省/直轄市</h3>
+                <el-radio-group class="radioSty" v-model="provinceId" @change="pIdChange">
+                    <el-radio size="large" :label="p.provinceId"  border v-for="p in provinceIdData">{{ p.provinceName }}</el-radio>
+                </el-radio-group>
+            </div>
+
+            <div style="margin-bottom: 10px;" v-if="cityIdData != null">
+                <h3>市/界</h3>
+                <el-radio-group class="radioSty" v-model="cityId">
+                    <el-radio size="large" :label="c.cityId"  border v-for="c in cityIdData" @click="searchSchool(c.cityId)">{{ c.cityName }}</el-radio>
+                </el-radio-group>
+            </div>
+
+            <div style="margin-bottom: 10px;margin-top: 70px;">
+                <div style="display: flex;justify-content: center;align-items: center;">
+                    <span style="font-weight: bold;font-size: 23px;margin-right: 5px;">搜尋</span>
+                    <el-input v-model="wordFilter" placeholder="請填入簡碼或學校名稱" style="width: 500px;"/>
+                </div>
+                <el-table :data="showData" stripe style="width: 100%" >
+                    <el-table-column prop="code" label="代碼"  />
+                    <el-table-column prop="shortCode" label="簡碼"  />
+                    <el-table-column prop="name" label="學校名稱"  />
+                    <el-table-column label="">
+                        <template #default="scope">
+                            <el-button type="primary" size="small" @click="handleUpdSchoolW(scope.row.id, scope.row.name, scope.row.shortCode)">歸戶</el-button>
+                        </template>
+                    </el-table-column>
+                </el-table>
+            </div>
+        </div>
+    </div>
+</template>
+<script setup>
+import country from '@/static/country.json'
+import { h, reactive, ref, computed, getCurrentInstance, markRaw } from 'vue'
+import { SuccessFilled, Warning } from '@element-plus/icons'
+import { ElMessageBox, ElMessage, ElInput, ElForm, ElFormItem } from 'element-plus'
+let { proxy } = getCurrentInstance()
+
+const loading = ref(false)
+const countryId = ref(null)
+const provinceId = ref(null)
+const provinceIdData = ref(null)
+const cityId = ref(null)
+const cityIdData = ref(null)
+const tableData = ref([])
+const wordFilter = ref('')
+const loadingStr = ref('')
+
+const cIdChange = (cId) => {
+    cityId.value = null
+    provinceId.value = null
+    provinceIdData.value = null
+    cityIdData.value = null
+    switch(cId){
+        case 'TW':
+            cityIdData.value = country.filter(function(c){
+                return c.countryId == cId && c.lang == 'zh-tw' && c.areaType == 'y'
+            })
+        break;
+        case 'CN':
+            provinceIdData.value = country.filter(function(c){
+                return c.countryId == cId && c.lang == 'zh-cn' && c.areaType == 'p'
+            })
+        break;
+    }
+}
+
+const pIdChange = (provinceId) =>{
+    cityId.value = null
+    cityIdData.value = null
+    let lang = ''
+    switch(countryId.value){
+        case 'TW':
+            lang = 'zh-tw'
+        break;
+        case 'CN':
+            lang = 'zh-cn'
+        break;
+    }
+
+    cityIdData.value = country.filter(function(c){
+        return c.provinceId == provinceId && c.lang == lang && c.areaType == 'y'
+    })
+}
+
+const searchSchool = async (cityId) =>{
+    let data = {
+        countryId: countryId.value,
+        cityId: cityId,
+        fullData: true
+    }
+
+    if(provinceId.value != null) {
+        data.provinceId = provinceId.value
+    }
+    wordFilter.value = ''
+    loadingStr.value = '搜索學校中...'
+    loading.value = true
+
+    await proxy.$api.getSchooBasicInfo(data).then((res) => {
+        tableData.value = res
+    }).catch(e=>{
+        ElMessage.error('搜尋失敗')
+    }).finally(() => {
+        loading.value = false
+    })
+}
+
+const showData = computed({
+    get(){
+        if(wordFilter.value != ''){
+            let result = []
+            console.log(wordFilter.value, 'wordFilter.value')
+            tableData.value.forEach((f)=>{
+                if(f.name.indexOf(wordFilter.value) >= 0){
+                    result.push(f)
+                } else if(f.shortCode && f.shortCode.indexOf(wordFilter.value) >= 0){
+                    result.push(f)
+                }
+            })
+            return result
+        } else {
+            return tableData.value
+        }
+    }
+})
+
+const handleUpdSchoolW = async (schDocId, schName, shortCode) =>{
+    const iDsCount = ref(0)
+    // 檢查array 內容是否重複
+    function isArrayRep(array){
+        var result = new Set();
+        var repeat = new Set();
+        array.forEach(item => {
+            result.has(item) ? repeat.add(item) : result.add(item);
+        })
+        // console.log(result); // {1, 2, "a", 3, "b"}
+        // console.log(repeat); // {1, "a"}
+        // console.log(repeat.size)
+        if(repeat.size != 0){
+            return true
+        } else {
+            return false
+        }
+    }
+    // 規則檢查: iDs
+    const checkIds = (value) => {
+        let isErr = false
+        if(!value) {
+            isErr = true
+            return "請填入要歸戶的醍摩豆ID"
+        } else if(value && !/^[0-9\n]+$/.test(value)){
+            isErr = true
+            return "只能輸入醍摩豆ID與換行"
+        } else if(value && isArrayRep(value.split('\n'))){
+            isErr = true
+            return "醍摩豆ID有重複"
+        } else if(value){
+            let errIds = []
+            let tmp = value.split('\n')
+            tmp.forEach(e=> {
+                if(e.length != 10) {
+                    errIds.push(e)
+                } else {
+                    let now = Math.floor(new Date().getTime() / 1000)
+                    let orgId = parseInt(e)
+                    if(parseInt(e.substring(0, 1)) >= 6){
+                        orgId -= 5000000000
+                    }
+
+                    if(orgId > now){
+                        errIds.push(e)
+                    }
+                }
+            })
+
+            if(errIds.length > 0){
+                // console.log(errIds, 'errIds')
+                isErr = true
+                return "請檢查醍摩豆ID是否符合格式或有空格"
+            }
+        }
+
+        if(!isErr && value != ''){
+            let tArray = value.split('\n')
+            iDsCount.value = tArray.length
+        } else {
+            iDsCount.value = 0
+        }
+
+        return true
+    }
+
+    if(!shortCode){
+        ElMessageBox.alert('此學校目前沒有簡碼', `***${schName}***`,
+            {
+                type: 'warning',
+                icon: markRaw(Warning),
+            }
+        )
+        // 中斷
+        return 
+    }
+
+    ElMessageBox.prompt(
+        '請填入要歸戶的醍摩豆ID', `歸戶至 ${schName} - ${shortCode}`, {
+            confirmButtonText: '歸戶',
+            cancelButtonText: '取消',
+            inputType: 'textarea',
+            inputValidator: checkIds,
+            customClass: 'prompClass',
+            roundButton: true,
+            closeOnClickModal: false
+        }
+    ).then(({value})=>{
+        let showStr = value.replaceAll('\n', ', ')
+        ElMessageBox.confirm(
+            `確認要歸戶以下的醍摩豆ID嗎?\n${showStr} \n\n 總共 ${iDsCount.value} 位`,
+            `歸戶至 ${schName}  - ${shortCode}`,
+            {
+                confirmButtonText: '確認',
+                cancelButtonText: '先不要',
+                type: 'info',
+                customClass: 'confirmClass'
+            }
+        ).then(async ()=>{
+            let reqData = {
+                schoolDocId: schDocId,
+                ids: value.split('\n')
+            }
+            
+            loadingStr.value = '弱歸戶...'
+            loading.value = true
+
+            await proxy.$api.updUserSchoolW(reqData).then((res) => {
+                ElMessageBox.alert('成功', '弱歸戶成功',
+                    {
+                        type: 'info',
+                        icon: markRaw(SuccessFilled),
+                    }
+                )
+            }).catch(e=>{
+                ElMessage.error('搜尋失敗')
+            }).finally(() => {
+                loading.value = false
+            })
+        })
+    })
+}
+</script>
+<style>
+.prompClass textarea{
+    min-height: 220px!important;
+}
+.confirmClass p{
+    white-space: pre-line;
+}
+.radioSty .el-radio__input{
+    display: none;
+}
+.radioSty .el-radio__label{
+    font-weight: bold;
+    font-size: 15px!important;
+}
+.radioSty .el-radio{
+    margin-right: 10px;
+}
+</style>
+<style scoped>
+.updCodeWBox{
+    width: 100%;
+    height: 82vh;
+    background-color: #fff;
+    z-index:999;
+    box-shadow: 5px 5px 10px rgba(0, 0, 0, 0.3);
+    border-radius: 10px;
+    padding: 1%;
+    text-align: left;
+}
+.updCodeWBox-title{
+    line-height: 40px;
+    font-size:24px;
+    font-weight: bold;
+    color:#7b84a9;
+    text-align: center;
+}
+</style>

+ 2 - 2
TEAMModelBI/Controllers/BIBlob/AnalyseFileController.cs

@@ -206,7 +206,7 @@ namespace TEAMModelBI.Controllers.BIBlob
             RecCnt saveCnts = new();
             //var ipGroup = aGInfos.GroupBy(g => g.properties.clientIp).ToDictionary(k => k.Key, k => k.Count()).ToList();
 
-            List<RecAppGWInfo> recInfo = aGInfos.Select(s => new RecAppGWInfo { hour = cHour, ip = s.properties.clientIp, api = s.properties.requestUri.Split("?").ToList().Count() > 1 ? s.properties.requestUri.Split("?").ToList()[0] : s.properties.requestUri, hostName = s.properties.hostname }).ToList();
+            List<RecAppGWInfo> recInfo = aGInfos.Select(s => new RecAppGWInfo { hour = cHour, ip = s.properties.CIp, api = s.properties.CsUriStem.Split("?").ToList().Count() > 1 ? s.properties.CsUriStem.Split("?").ToList()[0] : s.properties.CsUriStem, hostName = s.properties.CsHost }).ToList();
 
             List<RecApiCnt> apiCnt = recInfo.GroupBy(a => a.api).Select(g => new RecApiCnt { api = g.Key, count = g.Count(), hour = cHour, hostName = g.Select(h => h.hostName).Distinct().ToList(), ip = g.Select(i => i.ip).Distinct().ToList() }).ToList();
             saveCnts.apiCnt= apiCnt;
@@ -296,7 +296,7 @@ namespace TEAMModelBI.Controllers.BIBlob
 
                 RecCnt saveCnts = new();
 
-                List<RecAppGWInfo> recInfo = aGInfos.Select(s => new RecAppGWInfo { hour = cHour, ip = s.properties.clientIp, api = s.properties.requestUri.Split("?").ToList().Count() > 1 ? s.properties.requestUri.Split("?").ToList()[0] : s.properties.requestUri, hostName = s.properties.hostname }).ToList();
+                List<RecAppGWInfo> recInfo = aGInfos.Select(s => new RecAppGWInfo { hour = cHour, ip = s.properties.CIp, api = s.properties.CsUriStem.Split("?").ToList().Count() > 1 ? s.properties.CsUriStem.Split("?").ToList()[0] : s.properties.CsUriStem, hostName = s.properties.CsHost }).ToList();
 
                 List<RecApiCnt> apiCnt = recInfo.GroupBy(a => a.api).Select(g => new RecApiCnt { api = g.Key, count = g.Count(), hour = cHour, hostName = g.Select(h => h.hostName).Distinct().ToList(), ip = g.Select(i => i.ip).Distinct().ToList() }).ToList();
                 saveCnts.apiCnt = apiCnt;

+ 205 - 0
TEAMModelBI/Controllers/BICommon/BICouponController.cs

@@ -0,0 +1,205 @@
+using Microsoft.AspNetCore.Hosting;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.Extensions.Configuration;
+using Microsoft.Extensions.Options;
+using System.Net.Http;
+using TEAMModelOS.SDK.DI;
+using TEAMModelOS.SDK;
+using TEAMModelOS.Models;
+using System.Text.Json;
+using System.Threading.Tasks;
+using System.Collections.Generic;
+using System.Text;
+using TEAMModelOS.SDK.Extension;
+using System;
+using System.Net.Http.Json;
+using System.ComponentModel.DataAnnotations;
+using System.Net;
+using System.Net.Http.Headers;
+using Newtonsoft.Json;
+using System.Text.Encodings.Web;
+
+namespace TEAMModelBI.Controllers.BICommon
+{
+    [Route("coupon")]
+    [ApiController]
+    public class BICouponController : ControllerBase
+    {
+        private readonly DingDing _dingDing;
+        private readonly Option _option;
+        private readonly IConfiguration _configuration;
+        private readonly AzureServiceBusFactory _serviceBus;
+        private readonly IHttpClientFactory _http;
+        private readonly CoreAPIHttpService _coreAPIHttpService;
+        private readonly IWebHostEnvironment _environment; //读取文件
+        private readonly HttpClient _httpClient;
+
+        public BICouponController(DingDing dingDing, IOptionsSnapshot<Option> option, IConfiguration configuration, AzureServiceBusFactory serviceBus, IHttpClientFactory http, CoreAPIHttpService coreAPIHttpService, IWebHostEnvironment hostingEnvironment, HttpClient httpClient)
+        {
+            _dingDing = dingDing;
+            _option = option?.Value;
+            _configuration = configuration;
+            _serviceBus = serviceBus;
+            _http = http;
+            _coreAPIHttpService = coreAPIHttpService;
+            _environment = hostingEnvironment;
+            _httpClient = httpClient;
+        }
+
+        /// <summary>
+        /// 建立優惠券
+        /// </summary>
+        /// <param name="GenerateCouponRequest"></param>
+        /// <returns></returns>
+        //[AuthToken(Roles = "admin,rdc,assist,sales")]
+        [HttpPost("create-coupon")]
+        public async Task<IActionResult> CreateCoupon(GenerateCouponRequest request)
+        {
+            try
+            {
+                //string url = _configuration.GetValue<string>("HaBookAuth:CoreAPI");
+                string url = "https://api2.teammodel.net";
+                if (request.srvAdr == "China") url = "https://api2.teammodel.cn";
+                
+                string AccessToken = await getCoreAccessToken();
+                var client = _http.CreateClient();
+                client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", AccessToken);
+                HttpResponseMessage response = await client.PostAsJsonAsync($"{url}/Service/GenerateCoupon", request);
+                if (response.StatusCode == HttpStatusCode.OK)
+                {
+                    string jsonStr = await response.Content.ReadAsStringAsync();
+                    var options1 = new JsonSerializerOptions
+                    {
+                        Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping
+                    };
+
+                    await _dingDing.SendBotMsg(System.Text.Json.JsonSerializer.Serialize(request, options1), GroupNames.高飛);
+                    return Ok(jsonStr.ToObject<JsonElement>());
+                }
+                else {
+                    return BadRequest();
+                }
+            }
+            catch (Exception ex) {
+                return BadRequest();
+            }
+        }
+
+        /// <summary>
+        /// 歸戶
+        /// </summary>
+        /// <param name="GenerateCouponRequest"></param>
+        /// <returns></returns>
+        //[AuthToken(Roles = "admin,rdc,assist,sales")]
+        [HttpPost("consolidation-coupon")]
+        public async Task<IActionResult> ConsolidationCoupon(ConsolidationCouponRequest request)
+        {
+            try
+            {
+                //string url = _configuration.GetValue<string>("HaBookAuth:CoreAPI");
+                string url = "https://api2.teammodel.net";
+                if (request.srvAdr == "China") url = "https://api2.teammodel.cn";
+                string AccessToken = await getCoreAccessToken();
+                var client = _http.CreateClient();
+                client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", AccessToken);
+                HttpResponseMessage response = await client.PostAsJsonAsync($"{url}/Service/CouponConsolidation", request);
+                if (response.StatusCode == HttpStatusCode.OK)
+                {
+                    return Ok(new { state = 0, msg = "歸戶成功" });
+                }
+                else
+                {
+                    return BadRequest();
+                }
+            }
+            catch (Exception ex)
+            {
+                return BadRequest();
+            }
+        }
+
+        /// <summary>
+        /// 通知
+        /// </summary>
+        /// <param name="GenerateCouponRequest"></param>
+        /// <returns></returns>
+        //[AuthToken(Roles = "admin,rdc,assist,sales")]
+        [HttpPost("push-notify")]
+        public async Task<IActionResult> PushNotify(PushNotifyRequest request)
+        {
+            try
+            {
+                //string url = _configuration.GetValue<string>("HaBookAuth:CoreAPI");
+                string url = "https://api2.teammodel.net";
+                if (request.srvAdr == "China") url = "https://api2.teammodel.cn";
+                string AccessToken = await getCoreAccessToken();
+                var client = _http.CreateClient();
+                client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", AccessToken);
+                HttpResponseMessage response = await client.PostAsJsonAsync($"{url}/Service/PushNotify", request);
+                if (response.StatusCode == HttpStatusCode.OK)
+                {
+                    return Ok(new { state = 0, msg = "發送成功" });
+                }
+                else
+                {
+                    return BadRequest();
+                }
+            }
+            catch (Exception ex)
+            {
+                return BadRequest();
+            }
+        }
+
+        private async Task<string> getCoreAccessToken()
+        {
+            string AccessToken = "";
+            try
+            {
+                string Url = _configuration.GetValue<string>("HaBookAuth:CoreAPI") + "/oauth2/token";
+                string GrantType = "device";
+                string ClientID = _configuration.GetValue<string>("HaBookAuth:CoreService:clientID");
+                string Secret = _configuration.GetValue<string>("HaBookAuth:CoreService:clientSecret");
+                var content = new { grant_type = GrantType, client_id = ClientID, client_secret = Secret };
+                var response = await _http.CreateClient().PostAsJsonAsync($"{Url}", content);
+                if (response.IsSuccessStatusCode)
+                {
+                    string responseBody = response.Content.ReadAsStringAsync().Result;
+                    using (JsonDocument document = JsonDocument.Parse(responseBody.ToString()))
+                    {
+                        if (document.RootElement.TryGetProperty("access_token", out JsonElement AccessTokenObj))
+                        {
+                            AccessToken = AccessTokenObj.ToString();
+                        }
+                    }
+                }
+                return AccessToken;
+            }
+            catch (Exception ex)
+            {
+                return AccessToken;
+            }
+        }
+
+
+    }
+
+    public class info
+    {
+        public string l { get; set; }
+        public string n { get; set; }
+        public string u { get; set; }
+    }
+    public class CouponRule
+    {
+        public string q { get; set; }
+        //可獲得的權益
+        public string b { get; set; }
+        //若已有權益 則給積分
+        public int p { get; set; } = 0;
+    }
+
+    public record GenerateCouponRequest([Required] string srvAdr, [Required] string CouponType, List<string> targets, string couponName, int quantity, [Required] long expire, [Required] List<CouponRule> rule, string eventName, List<info> info, int maxTaker = -1);
+    public record ConsolidationCouponRequest([Required] string srvAdr, [Required] string coupon, [Required] List<string> ids);
+    public record PushNotifyRequest([Required] string srvAdr, [Required] string title, [Required] string body, [Required] List<string> tags, [Required] string sender, [Required] string hubName, string data = null);
+}

+ 14 - 10
TEAMModelBI/Controllers/BICommon/BINoticeController.cs

@@ -17,14 +17,12 @@ using TEAMModelBI.Models;
 using System.Linq;
 using TEAMModelBI.Filter;
 using TEAMModelOS.SDK.Models.Cosmos.BI;
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using System;
 using TEAMModelOS.SDK.Models.Service.BI;
 using TEAMModelOS.SDK.Models.Cosmos.BI.BISchool;
 using TEAMModelBI.Tool.Extension;
 using TEAMModelOS.SDK.Models;
-using DocumentFormat.OpenXml.Spreadsheet;
-using System.Net.Http.Json;
 
 namespace TEAMModelBI.Controllers.BICommon
 {
@@ -105,7 +103,7 @@ namespace TEAMModelBI.Controllers.BICommon
             List<IdInfo> idInfos = new();
             var cosmosClient = _azureCosmos.GetCosmosClient();
 
-            await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<IdInfo>(queryText: "select c.id,c.name,c.picture from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Teacher-{scId}") }))
+            await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIteratorSql<IdInfo>(queryText: "select c.id,c.name,c.picture from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Teacher-{scId}") }))
             {
                 idInfos.Add(item);
             }
@@ -138,6 +136,7 @@ namespace TEAMModelBI.Controllers.BICommon
                 if (!jsonElement.TryGetProperty("crowdType", out JsonElement _crowdType)) return BadRequest();
                 if (!jsonElement.TryGetProperty("sendTime", out JsonElement sendTime)) return BadRequest();
                 jsonElement.TryGetProperty("source", out JsonElement source);
+                jsonElement.TryGetProperty("isOnlySave", out JsonElement isOnlySave);
 
                 var cosmosClient = _azureCosmos.GetCosmosClient();
                 //DateTimeOffset dateTime = DateTimeOffset.UtcNow;
@@ -175,7 +174,7 @@ namespace TEAMModelBI.Controllers.BICommon
                     if (tmdIds.Count > 0)
                     {
                         tchSql.Append(BICommonWay.ManyScSql(" where c.id ", tmdIds.Select(s => s.id).ToList()));
-                        await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<IdNameCode>(queryText: tchSql.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
+                        await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIteratorSql<IdNameCode>(queryText: tchSql.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
                         {
                             var tempId = idNameCodes.FindAll(fa => fa.id.Equals(item.id)).ToList();
                             if (tempId.Count == 0)
@@ -190,7 +189,7 @@ namespace TEAMModelBI.Controllers.BICommon
                     if (schoolIds.Count > 0)
                     {
                         scAreaSql.Append(BICommonWay.ManyScSql(" where c.areaId", areaIds.Select(s => s.id).ToList()));
-                        await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<string>(queryText: scAreaSql.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
+                        await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIteratorSql<string>(queryText: scAreaSql.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
                         {
                             var tempScId = schoolIds.FindAll(fa => fa.Equals(item)).ToList();
                             if (tempScId.Count == 0)
@@ -205,7 +204,7 @@ namespace TEAMModelBI.Controllers.BICommon
                     if (schoolIds.Count > 0)
                     {
                         scTchSql.Append(BICommonWay.ManyScSql(" and c.code", schoolIds.Select(s => s.id).ToList(), $"Teacher-"));
-                        await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<IdNameCode>(queryText: scTchSql.ToString(), requestOptions: new QueryRequestOptions() { }))
+                        await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIteratorSql<IdNameCode>(queryText: scTchSql.ToString(), requestOptions: new QueryRequestOptions() { }))
                         {
                             var tempId = idNameCodes.FindAll(fa => fa.id.Equals(item.id)).ToList();
                             if (tempId.Count == 0)
@@ -234,8 +233,11 @@ namespace TEAMModelBI.Controllers.BICommon
                 };
 
                 bINotice = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Common").CreateItemAsync<BINotice>(bINotice, new PartitionKey("BINotice"));
-                //BI发送端外通知
-                _coreAPIHttpService.BIPushNotify(bINotice, new Dictionary<string, object> { { "tmdid", _tmdIds }, { "sendId", bINotice.crowdIds} }, _option.Location, _configuration, _dingDing);
+                if (isOnlySave.GetBoolean()) 
+                {
+                    //BI发送端外通知
+                    _coreAPIHttpService.BIPushNotify(bINotice, new Dictionary<string, object> { { "tmdid", _tmdIds }, { "sendId", bINotice.crowdIds } }, _option.Location, _configuration, _dingDing);
+                }
 
                 return Ok(new { state = RespondCode.Ok, bINotice });
             }
@@ -262,7 +264,9 @@ namespace TEAMModelBI.Controllers.BICommon
             StringBuilder sql = new("select value(c) from c");
             if (!string.IsNullOrEmpty($"{id}"))
                 sql.Append($" where c.id='{id}'");
-            await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<BINotice>(queryText: sql.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("BINotice") }))
+
+            sql.Append($" order by c.sendTime desc ");
+            await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIteratorSql<BINotice>(queryText: sql.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("BINotice") }))
             {
                 bINotices.Add(item);
             }

+ 3 - 3
TEAMModelBI/Controllers/BICommon/BIProductUseRecordController.cs

@@ -12,7 +12,7 @@ using TEAMModelOS.SDK.Context.Constant;
 using System.Threading.Tasks;
 using System;
 using TEAMModelOS.SDK.Models.Cosmos.BI.BICommon;
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using TEAMModelOS.SDK.Extension;
 using System.Collections.Generic;
 using TEAMModelOS.SDK.Models.Cosmos.BI;
@@ -70,9 +70,9 @@ namespace TEAMModelBI.Controllers.BICommon
             ProductUseRecord productUseRecord = null;
             UseRecord useRecord = new();
             var resUseRecord = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Common").ReadItemStreamAsync($"{year}", new PartitionKey("ProductUseRecord"));
-            if (resUseRecord.Status == 200)
+            if (resUseRecord.StatusCode == System.Net.HttpStatusCode.OK)
             {
-                using var fileJson = await JsonDocument.ParseAsync(resUseRecord.ContentStream);
+                using var fileJson = await JsonDocument.ParseAsync(resUseRecord.Content);
                 productUseRecord = fileJson.ToObject<ProductUseRecord>();
             }
 

+ 6 - 9
TEAMModelBI/Controllers/BICommon/JointlyController.cs

@@ -1,5 +1,4 @@
-using Azure.Cosmos;
-using Microsoft.AspNetCore.Http;
+using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Mvc;
 using Microsoft.Extensions.Options;
 using System.Collections.Generic;
@@ -8,7 +7,7 @@ using System.Threading.Tasks;
 using TEAMModelOS.Models;
 using TEAMModelOS.SDK.DI;
 using TEAMModelOS.SDK.Extension;
-
+using Microsoft.Azure.Cosmos;
 namespace TEAMModelBI.Controllers.BICommon
 {
     [Route("jointly")]
@@ -49,9 +48,9 @@ namespace TEAMModelBI.Controllers.BICommon
             {
                 foreach (var temp in types)
                 {
-                    await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", _containers[temp]).GetItemQueryStreamIterator(queryText: $"select value(c) from c where c.id='{id}'", requestOptions: string.IsNullOrEmpty($"{code}") ? new QueryRequestOptions() { } : new QueryRequestOptions() { PartitionKey = new PartitionKey($"{code}") }))
+                    await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", _containers[temp]).GetItemQueryStreamIteratorSql(queryText: $"select value(c) from c where c.id='{id}'", requestOptions: string.IsNullOrEmpty($"{code}") ? new QueryRequestOptions() { } : new QueryRequestOptions() { PartitionKey = new PartitionKey($"{code}") }))
                     {
-                        using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                        using var json = await JsonDocument.ParseAsync(item.Content);
                         if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
                         {
                             foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
@@ -66,9 +65,9 @@ namespace TEAMModelBI.Controllers.BICommon
             {
                 foreach (var contaoner in _containers)
                 {
-                    await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", contaoner).GetItemQueryStreamIterator(queryText: $"select value(c) from c where c.id='{id}'", requestOptions: string.IsNullOrEmpty($"{code}") ? new QueryRequestOptions() { } : new QueryRequestOptions() { PartitionKey = new PartitionKey($"{code}") }))
+                    await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", contaoner).GetItemQueryStreamIteratorSql(queryText: $"select value(c) from c where c.id='{id}'", requestOptions: string.IsNullOrEmpty($"{code}") ? new QueryRequestOptions() { } : new QueryRequestOptions() { PartitionKey = new PartitionKey($"{code}") }))
                     {
-                        using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                        using var json = await JsonDocument.ParseAsync(item.Content);
                         if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
                         {
                             foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
@@ -79,9 +78,7 @@ namespace TEAMModelBI.Controllers.BICommon
                     }
                 }
             }
-
             return Ok(new { state = 200, infos = objs });
         }
-
     }
 }

+ 2 - 3
TEAMModelBI/Controllers/BICommon/StatsNoticeController.cs

@@ -11,12 +11,11 @@ using System.Text.Json;
 using System.Threading.Tasks;
 using TEAMModelOS.SDK.Context.Constant;
 using System;
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using TEAMModelOS.SDK.Extension;
 using TEAMModelOS.SDK.Models.Cosmos.BI.BICommon;
 using System.Collections.Generic;
 using System.Text;
-using DocumentFormat.OpenXml.Office2010.Excel;
 
 namespace TEAMModelBI.Controllers.BICommon
 {
@@ -81,7 +80,7 @@ namespace TEAMModelBI.Controllers.BICommon
                 }
                 List<StatsNotice> statsNotices = new();
 
-                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<StatsNotice>(queryText: sqlTxt.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("StatsNotice") }))
+                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIteratorSql<StatsNotice>(queryText: sqlTxt.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("StatsNotice") }))
                 {
                     statsNotices.Add(item);
                 }

+ 10 - 10
TEAMModelBI/Controllers/BIHome/HomeStatisController.cs

@@ -6,7 +6,7 @@ using System.Linq;
 using System.Threading.Tasks;
 using System.Text.Json;
 using TEAMModelOS.SDK.DI;
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using Microsoft.Extensions.Options;
 using TEAMModelOS.SDK.Models;
 using TEAMModelOS.Models;
@@ -88,9 +88,9 @@ namespace TEAMModelBI.Controllers.BIHome
                 //    cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.Global);
 
                 List<ProvinceStandard> standards = new();
-                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryStreamIterator(queryText: $"select c.provCode,c.provName,c.standard from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base-Area") }))
+                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryStreamIteratorSql(queryText: $"select c.provCode,c.provName,c.standard from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base-Area") }))
                 {
-                    using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                    using var json = await JsonDocument.ParseAsync(item.Content);
                     if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
                     {
                         var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
@@ -199,7 +199,7 @@ namespace TEAMModelBI.Controllers.BIHome
 
                 List<CityStandard> standards = new();
                 //查询省份区域
-                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<Area>(queryText: $"select c.id,c.cityCode,c.cityName,c.standard from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-Area") }))
+                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIteratorSql<Area>(queryText: $"select c.id,c.cityCode,c.cityName,c.standard from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-Area") }))
                 {
                     CityStandard Citystics = new CityStandard
                     {
@@ -268,7 +268,7 @@ namespace TEAMModelBI.Controllers.BIHome
 
                 List<DistrictStandard> districtStandards = new();
                 //查询省份区域
-                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<Area>(queryText: $"select c.id,c.name,c.cityName,c.standard from c where c.cityCode='{_cityCode}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-Area") }))
+                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIteratorSql<Area>(queryText: $"select c.id,c.name,c.cityName,c.standard from c where c.cityCode='{_cityCode}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-Area") }))
                 {
                     DistrictStandard districtStandard = new()
                     {
@@ -340,7 +340,7 @@ namespace TEAMModelBI.Controllers.BIHome
 
                 List<AllCityStics> tempAllCityStics = new();
                 //查询省份区域
-                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<Area>(queryText: $"select c.id,c.name,c.cityCode,c.cityName,c.standard from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-Area") }))
+                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIteratorSql<Area>(queryText: $"select c.id,c.name,c.cityCode,c.cityName,c.standard from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-Area") }))
                 {
                     AllCityStics Citystics = new()
                     {
@@ -473,10 +473,10 @@ namespace TEAMModelBI.Controllers.BIHome
                 //查询学校已使用空间大小
                 foreach (var itemId in schoolId)
                 {
-                    await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: $"SELECT sum(c.size) as size FROM c ",
+                    await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIteratorSql(queryText: $"SELECT sum(c.size) as size FROM c ",
                         requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Teacher-{itemId}") }))
                     {
-                        var json = await JsonDocument.ParseAsync(item.ContentStream);
+                        var json = await JsonDocument.ParseAsync(item.Content);
                         foreach (var elmt in json.RootElement.GetProperty("Documents").EnumerateArray())
                         {
                             if (elmt.TryGetProperty("size", out JsonElement _size) && _size.ValueKind.Equals(JsonValueKind.Number))
@@ -591,9 +591,9 @@ namespace TEAMModelBI.Controllers.BIHome
                 ////教师数据
                 //List<string> teacherId = new List<string>(); //教师Id集合
                 ////查询教师的大小和教师集合信息
-                //await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryStreamIterator(queryText: $"select c.id,c.size from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
+                //await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryStreamIteratorSql(queryText: $"select c.id,c.size from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
                 //{
-                //    using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                //    using var json = await JsonDocument.ParseAsync(item.Content);
                 //    foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
                 //    {
                 //        totalSize += obj.GetProperty("size").GetInt64();

+ 112 - 6
TEAMModelBI/Controllers/BIHome/OnLineController.cs

@@ -1,4 +1,4 @@
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using Azure.Storage.Blobs;
 using Azure.Storage.Blobs.Models;
 using Microsoft.AspNetCore.Http;
@@ -96,9 +96,115 @@ namespace TEAMModelBI.Controllers.BIHome
             todayTchCnt = await CommonFind.GetSqlValueCount(cosmosClient, "Teacher", addSql, "Base");
             todayStuCnt = await CommonFind.GetSqlValueCount(cosmosClient, "Student", addSql, "Base");
 
-            string onStuSql = $"select value(count(c.id)) from c join t in c.loginInfos where array_length(c.loginInfos) > 0 and t.expire > {hour1} and c.pk='Base'";
-            onTchCnt = await CommonFind.GetSqlValueCount(cosmosClient, "Teacher", onStuSql);
-            onStuCnt = await CommonFind.GetSqlValueCount(cosmosClient, "Student", onStuSql);
+            //string onStuSql = $"select value(count(c.id)) from c join t in c.loginInfos where array_length(c.loginInfos) > 0 and t.expire > {hour1} and c.pk='Base'";
+            //onTchCnt = await CommonFind.GetSqlValueCount(cosmosClient, "Teacher", onStuSql);
+            //onStuCnt = await CommonFind.GetSqlValueCount(cosmosClient, "Student", onStuSql);
+
+            #region 取得在線人數
+            var dateDay = dateTime.ToString("yyyyMMdd"); //获取当天的日期
+            var redisClinet = _azureRedis.GetRedisClient(8);
+            var (strDaySt, strDayEt) = TimeHelper.GetUnixToDate(daySt, dayEt, "yyyyMMddHH");
+            Dictionary<long, int> allDays = new();  //所有在线人数
+            Dictionary<long, int> tchDays = new();  //教师在线人数
+            Dictionary<long, int> stuDays = new();  //学生在线人数
+            Dictionary<long, int> tmdDays = new();  //醍摩豆账户学生
+            int tchkey = 0;// 最近時間的key
+
+            // 撈redis記錄的教師在線人數
+            SortedSetEntry[] tchDay = redisClinet.SortedSetRangeByScoreWithScores($"Login:IES:teacher:{dateDay}");
+            if (tchDay.Length > 0)// 如果redis有資料就直接使用
+            {
+                foreach (var item in tchDay)
+                {
+                    int val = ((int)item.Score);
+                    int key = ((int)item.Element);
+                    tchDays.Add(key, val);                   
+                }
+                
+                var tchDaysOrderBy = tchDays.OrderBy(o => o.Key).ToList();
+                tchkey = (int)tchDaysOrderBy[tchDaysOrderBy.Count - 1].Key;
+                onTchCnt = (int)tchDaysOrderBy[tchDaysOrderBy.Count - 1].Value;              
+            }
+            else
+            {// 如果redis沒資料去Azure Storage取
+                string tableSqlTch = $"PartitionKey eq 'HourLogin' and RowKey ge '{strDaySt}' and RowKey le '{strDayEt}'";
+                List<HourLogin> hourLoginsTch = await table.QueryWhereString<HourLogin>(tableSqlTch);
+
+                if (hourLoginsTch.Count > 0)
+                {
+                    foreach (var item in hourLoginsTch)
+                    {                       
+                        tchDays.Add(item.Hour, item.Teacher);                       
+                    }
+                    var tchDaysOrderBy = tchDays.OrderBy(o => o.Key).ToList();
+                    tchkey = (int)tchDaysOrderBy[tchDaysOrderBy.Count - 1].Key;
+                    onTchCnt = (int)tchDaysOrderBy[tchDaysOrderBy.Count - 1].Value;
+                }
+            }
+            // 撈redis記錄的學生在線人數
+            SortedSetEntry[] stuDay = redisClinet.SortedSetRangeByScoreWithScores($"Login:IES:student:{dateDay}");
+            if (stuDay.Length > 0)// 如果redis有資料就直接使用
+            {
+                foreach (var item in stuDay)
+                {
+                    int val = ((int)item.Score);
+                    int key = ((int)item.Element);
+                    stuDays.Add(key, val);
+                }
+
+                var stuDaysOrderBy = stuDays.OrderBy(o => o.Key).ToList();
+                onStuCnt = (int)stuDaysOrderBy[stuDaysOrderBy.Count - 1].Value;
+            }
+            else
+            {// 如果redis沒資料去Azure Storage取
+                string tableSqlStu = $"PartitionKey eq 'HourLogin' and RowKey ge '{strDaySt}' and RowKey le '{strDayEt}'";
+                List<HourLogin> hourLoginsStu = await table.QueryWhereString<HourLogin>(tableSqlStu);                
+                if (hourLoginsStu.Count > 0)
+                {
+                    foreach (var item in hourLoginsStu)
+                    {
+                        stuDays.Add(item.Hour, item.Student);
+                    }
+                    var stuDaysOrderBy = stuDays.OrderBy(o => o.Key).ToList();
+                    onStuCnt = (int)stuDaysOrderBy[stuDaysOrderBy.Count - 1].Value;             
+                }
+            }
+
+            SortedSetEntry[] tmdDay = redisClinet.SortedSetRangeByScoreWithScores($"Login:IES:tmduser:{dateDay}");
+            if (tmdDay.Length > 0)
+            {
+                foreach (var item in tmdDay)
+                {
+                    int val = (int)item.Score;
+                    int key = (int)item.Element;
+                    tmdDays.Add(key, val);                   
+                }
+                int iValue = 0;
+                if (tmdDays.TryGetValue(tchkey, out iValue)) 
+                {
+                    onStuCnt = onStuCnt + tmdDays[tchkey]; // 用最近時間的key取在線醍摩豆账户学生數
+                }                
+            }
+            else
+            {
+                string tableSqlTmd = $"PartitionKey eq 'HourLogin' and RowKey ge '{strDaySt}' and RowKey le '{strDayEt}'";
+                List<HourLogin> hourLoginsTmd = await table.QueryWhereString<HourLogin>(tableSqlTmd);
+                if (hourLoginsTmd.Count > 0)
+                {
+                    foreach (var item in hourLoginsTmd)
+                    {                        
+                        var utcTo = new DateTimeOffset(new DateTime(dateTime.Year, dateTime.Month, dateTime.Day, item.Hour, 00, 00)).Hour;
+                        tmdDays.Add(utcTo, item.TmdUser);                       
+                    }
+                    int iValue = 0;
+                    if (tmdDays.TryGetValue(tchkey, out iValue))
+                    {
+                        onStuCnt = onStuCnt + tmdDays[tchkey]; // 用最近時間的key取在線醍摩豆账户学生數
+                    }                    
+                }
+            }
+
+            #endregion
 
             //接口访问量
             List<RecCnt> recCnts = new();
@@ -415,12 +521,12 @@ namespace TEAMModelBI.Controllers.BIHome
          
 
             var ScSql = $"select c.id,c.name,c.size,c.scale, c.edition, c.service from c";
-            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<RecScEd>(queryText: ScSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("BIRel") }))
+            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIteratorSql<RecScEd>(queryText: ScSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("BIRel") }))
             {
                 scEdCnt.Add(item);
             }
             
-            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<RecScEd>(queryText: ScSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("VirtualBase") }))
+            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIteratorSql<RecScEd>(queryText: ScSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("VirtualBase") }))
             {
                 scEdCnt.Add(item);
             }          

+ 7 - 8
TEAMModelBI/Controllers/BINormal/AbilityMgmtController.cs

@@ -10,14 +10,13 @@ using TEAMModelOS.SDK.Models;
 using TEAMModelOS.Models;
 using Microsoft.Extensions.Options;
 using System.Text.Json;
-using Azure.Cosmos;
-using HTEXLib.COMM.Helpers;
+using Microsoft.Azure.Cosmos;
 using System.Text;
 using TEAMModelOS.SDK.Extension;
 using TEAMModelBI.Filter;
 using TEAMModelBI.Tool.Extension;
 using TEAMModelOS.SDK.Context.BI;
-
+using TEAMModelOS.SDK;
 namespace TEAMModelBI.Controllers.BINormal
 {
     [Route("biabilitymgmt")]
@@ -63,7 +62,7 @@ namespace TEAMModelBI.Controllers.BINormal
 
                 List<Ability> abilities = new();
                 string sqltxt = "select value(c) from c";
-                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<Ability>(queryText: sqltxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Ability-{standard}") }))
+                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIteratorSql<Ability>(queryText: sqltxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Ability-{standard}") }))
                 {
                     abilities.Add(item);
                 }
@@ -141,7 +140,7 @@ namespace TEAMModelBI.Controllers.BINormal
                 List<AbilityTask> syllabus = new();
                 string sql = $"select value(c) from c where c.abilityId='{id}'";
                 var response = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").DeleteItemStreamAsync(id.ToString(), new PartitionKey($"Ability-{standard}"));
-                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<AbilityTask>(queryText: sql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"AbilityTask-{standard}") }))
+                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIteratorSql<AbilityTask>(queryText: sql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"AbilityTask-{standard}") }))
                 {
                     syllabus.Add(item);
                 }
@@ -150,14 +149,14 @@ namespace TEAMModelBI.Controllers.BINormal
                     var sresponse = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").DeleteItemsStreamAsync(syllabus.Select(x => x.id).ToList(), $"AbilityTask-{standard}");
                 }
 
-                if (response.Status == 200)
+                if (response.StatusCode == System.Net.HttpStatusCode.OK)
                 {
                     //保存操作记录
                     await AzureStorageBlobExtensions.SaveBILog(blobClient, tableClient, "abilityTask-del", $"{_tmdName}【{_tmdId}】删除册别,删除ID:{id}", _dingDing, httpContext: HttpContext);
 
                     return Ok(new { state = 200 });
                 }
-                else return Ok(new { state = response.Status });
+                else return Ok(new { state = response.StatusCode });
             }
             catch (Exception ex)
             {
@@ -214,7 +213,7 @@ namespace TEAMModelBI.Controllers.BINormal
                     {
                         sqltxt.Append($" and c.dimension = '{ability.dimension}' and c.name = '{ability.name}'  and c.no = '{ability.no}' ");
                         List<Ability> abilities = new List<Ability>();
-                        await foreach (var item in azureClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<Ability>(queryText: sqltxt.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey(ability.code) }))
+                        await foreach (var item in azureClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIteratorSql<Ability>(queryText: sqltxt.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey(ability.code) }))
                         {
                             abilities.Add(item);
                         }

+ 9 - 9
TEAMModelBI/Controllers/BINormal/AbilityTaskMgmtController.cs

@@ -10,8 +10,6 @@ using TEAMModelOS.Models;
 using Microsoft.Extensions.Options;
 using System.Text.Json;
 using TEAMModelOS.SDK.Models;
-using Azure.Cosmos;
-using HTEXLib.COMM.Helpers;
 using TEAMModelOS.SDK.Models.Cosmos.Common;
 using System.Text;
 using TEAMModelBI.Filter;
@@ -19,6 +17,8 @@ using TEAMModelOS.SDK.Services;
 using TEAMModelBI.Tool.Extension;
 using TEAMModelOS.SDK.Extension;
 using TEAMModelOS.SDK.Context.BI;
+using TEAMModelOS.SDK;
+using Microsoft.Azure.Cosmos;
 
 namespace TEAMModelBI.Controllers.BINormal
 {
@@ -76,7 +76,7 @@ namespace TEAMModelBI.Controllers.BINormal
                 {
                     return Ok(new { state = 400,message="该ID未找到章节" });
                 }
-                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<AbilityTask>(queryText: $"select value(c) from c where c.abilityId='{abilityId}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"AbilityTask-{standard}") }))
+                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIteratorSql<AbilityTask>(queryText: $"select value(c) from c where c.abilityId='{abilityId}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"AbilityTask-{standard}") }))
                 {
                     var rns = item.children.Select(x => x.rnodes);
                     if (rns != null)
@@ -174,7 +174,7 @@ namespace TEAMModelBI.Controllers.BINormal
                             abilityTask.scope = abilityTaskTree.scope;
                             abilityTask.codeval = $"{recordAbilityTask.standard}";
                             abilityTask.standard = $"{recordAbilityTask.standard}";
-                            await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Normal").CreateItemAsync<AbilityTask>(abilityTask, new Azure.Cosmos.PartitionKey($"AbilityTask-{recordAbilityTask.standard}"));
+                            await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Normal").CreateItemAsync<AbilityTask>(abilityTask, new PartitionKey($"AbilityTask-{recordAbilityTask.standard}"));
                             msgBuilder.Append($"新增章节功能,章节ID:{abilityTask.id} 分区键:{abilityTask.code}");
                             type = "abilityTask-add";
                         }
@@ -188,7 +188,7 @@ namespace TEAMModelBI.Controllers.BINormal
                             AbilityService.TreeToList(abilityTaskTree.trees, nodes, now);
                             abilityTask.children = nodes;
                             abilityTaskTree.auth = abilityTask.auth;
-                            await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Normal").ReplaceItemAsync<AbilityTask>(abilityTask, abilityTask.id, new Azure.Cosmos.PartitionKey($"AbilityTask-{recordAbilityTask.standard}"));
+                            await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Normal").ReplaceItemAsync<AbilityTask>(abilityTask, abilityTask.id, new PartitionKey($"AbilityTask-{recordAbilityTask.standard}"));
                             msgBuilder.Append($"修改章节功能,章节ID:{abilityTask.id} 分区键:{abilityTask.code}");
                             type = "abilityTask-update";
                         }
@@ -215,7 +215,7 @@ namespace TEAMModelBI.Controllers.BINormal
                             codeval = $"{recordAbilityTask.standard}",
                             standard = $"{recordAbilityTask.standard}"
                         };
-                        await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Normal").CreateItemAsync<AbilityTask>(abilityTask, new Azure.Cosmos.PartitionKey($"AbilityTask-{recordAbilityTask.standard}"));
+                        await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Normal").CreateItemAsync<AbilityTask>(abilityTask, new PartitionKey($"AbilityTask-{recordAbilityTask.standard}"));
 
                         msgBuilder.Append($"新增章节功能,章节ID:{abilityTask.id} 分区键:{abilityTask.code}");
                         type = "abilityTask-add";
@@ -263,14 +263,14 @@ namespace TEAMModelBI.Controllers.BINormal
                 //}
                 var response = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").DeleteItemStreamAsync(id.ToString(), new PartitionKey($"AbilityTask-{standard}"));
 
-                string msg = $"{_tmdName}【{_tmdId}】删除册别,删除状态:{response.Status},删除ID:{id}";
+                string msg = $"{_tmdName}【{_tmdId}】删除册别,删除状态:{response.StatusCode},删除ID:{id}";
 
                 //保存操作记录
                 await AzureStorageBlobExtensions.SaveBILog(blobClient, tableClient, "abilitytask-del", msg, _dingDing, httpContext: HttpContext);
-                if (response.Status == 204)
+                if (response.StatusCode == System.Net.HttpStatusCode.OK)
                     return Ok(new { state = 200 });
                 else
-                    return Ok(new { state = response.Status });
+                    return Ok(new { state = response.StatusCode });
             }
             catch (Exception ex)
             {

+ 21 - 21
TEAMModelBI/Controllers/BINormal/AreaRelevantController.cs

@@ -1,4 +1,4 @@
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Mvc;
 using Microsoft.Extensions.Configuration;
@@ -79,9 +79,9 @@ namespace TEAMModelBI.Controllers.BINormal
                     sqltxt = $"SELECT c.code,c.id,c.name,c.schoolCode,c.province,c.city,c.dist,c.picture,c.period,c.areaId,c.standard,c.manyAreas FROM c join m in c.manyAreas WHERE (c.areaId ='{_areaId}' or m.areaId='{_areaId}')";
                 }
                 //IES5實體學校
-                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: sqltxt, requestOptions:new QueryRequestOptions() { PartitionKey = new PartitionKey("Base")})) 
+                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIteratorSql(queryText: sqltxt, requestOptions:new QueryRequestOptions() { PartitionKey = new PartitionKey("Base")})) 
                 {
-                    using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                    using var json = await JsonDocument.ParseAsync(item.Content);
                     if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0) 
                     {
                         foreach(var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
@@ -118,9 +118,9 @@ namespace TEAMModelBI.Controllers.BINormal
                     }
                 }
                 //虛擬學校
-                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: sqltxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("VirtualBase") }))
+                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIteratorSql(queryText: sqltxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("VirtualBase") }))
                 {
-                    using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                    using var json = await JsonDocument.ParseAsync(item.Content);
                     if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
                     {
                         foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
@@ -185,9 +185,9 @@ namespace TEAMModelBI.Controllers.BINormal
                 //}
 
                 var responseSet = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").ReadItemStreamAsync($"{areaId}", new PartitionKey("AreaSetting"));
-                if (responseSet.Status == 200)
+                if (responseSet.StatusCode == System.Net.HttpStatusCode.OK)
                 {
-                    using var fileJson = await JsonDocument.ParseAsync(responseSet.ContentStream);
+                    using var fileJson = await JsonDocument.ParseAsync(responseSet.Content);
                     AreaSetting delSet = fileJson.ToObject<AreaSetting>();
                     if (!string.IsNullOrEmpty(delSet.accessConfig))
                         return Ok(new { state = 401, msg = "区域已经规定了,不能切换能能力" });
@@ -200,7 +200,7 @@ namespace TEAMModelBI.Controllers.BINormal
                     tempSchool.standard = null;
 
                     List<Teacher> teachers = new();
-                    await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<Teacher>(queryText: $"SELECT value(c) FROM c join s in c.schools where s.schoolId ='{schoolId}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
+                    await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIteratorSql<Teacher>(queryText: $"SELECT value(c) FROM c join s in c.schools where s.schoolId ='{schoolId}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
                     {
                         teachers.Add(item);
                     }
@@ -291,9 +291,9 @@ namespace TEAMModelBI.Controllers.BINormal
 
             Teacher teacher = new();
             var response = await cosmosClient.GetContainer("TEAMModelOS", "Teacher").ReadItemStreamAsync($"{tmdId}", new PartitionKey($"Base"));
-            if (response.Status == 200)
+            if (response.StatusCode == System.Net.HttpStatusCode.OK)
             {
-                using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                using var json = await JsonDocument.ParseAsync(response.Content);
                 teacher = json.ToObject<Teacher>();
                 var existArea = teacher.areas.Find(f => f.areaId.Equals($"{areaId}"));
                 if (existArea == null)
@@ -331,13 +331,13 @@ namespace TEAMModelBI.Controllers.BINormal
                         foreach (var item in schoolMs)
                         {
                             var resSc = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync($"{item.id}", new PartitionKey($"Base"));
-                            if (resSc.Status == 200)
+                            if (resSc.StatusCode == System.Net.HttpStatusCode.OK)
                             {
                                 SchoolTeacher schoolTeacher = null;
                                 var resScTch = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync($"{tmdId}", new PartitionKey($"Teacher-{item.id}"));
-                                if (resScTch.Status == 200)
+                                if (resScTch.StatusCode == System.Net.HttpStatusCode.OK)
                                 {
-                                    using var json = await JsonDocument.ParseAsync(resScTch.ContentStream);
+                                    using var json = await JsonDocument.ParseAsync(resScTch.Content);
                                     schoolTeacher = json.ToObject<SchoolTeacher>();
                                     if (!schoolTeacher.roles.Contains("admin"))
                                     {
@@ -414,7 +414,7 @@ namespace TEAMModelBI.Controllers.BINormal
             //    cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.Global);
             
             List<BaseInfo> areaManages = new();
-            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<BaseInfo>(queryText:$"select c.id,c.name,c.picture from c join a in c.areas where a.areaId ='{areaId}' and c.code='Base'",requestOptions:new QueryRequestOptions() { PartitionKey = new PartitionKey("Base")}))
+            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIteratorSql<BaseInfo>(queryText:$"select c.id,c.name,c.picture from c join a in c.areas where a.areaId ='{areaId}' and c.code='Base'",requestOptions:new QueryRequestOptions() { PartitionKey = new PartitionKey("Base")}))
             {
                 areaManages.Add(item);
             }
@@ -443,9 +443,9 @@ namespace TEAMModelBI.Controllers.BINormal
 
             Teacher teacher = null;
             var response = await cosmosClient.GetContainer("TEAMModelOS", "Teacher").ReadItemStreamAsync($"{tmdId}", new PartitionKey($"Base"));
-            if (response.Status == 200)
+            if (response.StatusCode == System.Net.HttpStatusCode.OK)
             {
-                using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                using var json = await JsonDocument.ParseAsync(response.Content);
                 teacher = json.ToObject<Teacher>();
                 var existArea = teacher.areas.Find(f => f.areaId.Equals($"{areaId}"));
                 if (existArea != null)
@@ -488,7 +488,7 @@ namespace TEAMModelBI.Controllers.BINormal
             else
                 areaScSql.Append(" where c.areaId = null or c.areaId = ''");
 
-            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<AreaSchool>(queryText: areaScSql.ToString(),requestOptions:new QueryRequestOptions() { PartitionKey = new PartitionKey("Base")}))
+            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIteratorSql<AreaSchool>(queryText: areaScSql.ToString(),requestOptions:new QueryRequestOptions() { PartitionKey = new PartitionKey("Base")}))
             {
                 areaSchool.Add(item);
             }
@@ -496,9 +496,9 @@ namespace TEAMModelBI.Controllers.BINormal
             areaSchool.ForEach(async areaSc =>
             {
                 var response = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(areaSc.id, new PartitionKey("ProductSum"));
-                if (response.Status == 200)
+                if (response.StatusCode == System.Net.HttpStatusCode.OK)
                 {
-                    using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                    using var json = await JsonDocument.ParseAsync(response.Content);
                     if (json.RootElement.TryGetProperty("serial", out JsonElement serial) && !serial.ValueKind.Equals(JsonValueKind.Null))
                     {
                         areaSc.serial = serial.ToObject<List<SchoolProductSumData>>().Count;//.Select(x => x.prodCode).ToList();
@@ -551,7 +551,7 @@ namespace TEAMModelBI.Controllers.BINormal
                 scIdsSql = "select value(c.id) from c where c.areaId = null or c.areaId = ''";
             scIds = await CommonFind.GetValueSingle(cosmosClient, "School", scIdsSql, "Base");
 
-            //await foreach (var itemId in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<string>(queryText: scIdsSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") })) 
+            //await foreach (var itemId in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIteratorSql<string>(queryText: scIdsSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") })) 
             //{
             //    scIds.Add(itemId);
             //}
@@ -559,7 +559,7 @@ namespace TEAMModelBI.Controllers.BINormal
             foreach (var scId in scIds)
             {
                 string tchIdSql = $"select value(c.id) from c where array_contains(c.roles,'assist',true) and c.pk='Teacher'";
-                await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<string>(queryText: tchIdSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Teacher-{scId}") }))
+                await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIteratorSql<string>(queryText: tchIdSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Teacher-{scId}") }))
                 {
                     tchIds.Add(item);
                 }

+ 61 - 63
TEAMModelBI/Controllers/BINormal/BatchAreaController.cs

@@ -9,9 +9,8 @@ using System.Threading.Tasks;
 using TEAMModelOS.Models;
 using TEAMModelOS.SDK.DI;
 using TEAMModelOS.SDK.Models;
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using System.Text.Json;
-using HTEXLib.COMM.Helpers;
 using TEAMModelOS.SDK.Models.Cosmos.Common;
 using TEAMModelOS.SDK.Models.Cosmos.BI;
 using Azure.Messaging.ServiceBus;
@@ -28,7 +27,6 @@ using System.Net;
 using TEAMModelOS.SDK;
 using TEAMModelOS.SDK.Context.BI;
 using System.Text;
-using DocumentFormat.OpenXml.Bibliography;
 using Microsoft.Extensions.Hosting;
 using Microsoft.AspNetCore.Hosting;
 using TEAMModelOS.SDK.Context.Constant;
@@ -133,9 +131,9 @@ namespace TEAMModelBI.Controllers.BINormal
                     }
                 }
 
-                await foreach (var itemArea in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryStreamIterator(queryText: areaSql.ToString(), continuationToken: pageToken, requestOptions: new QueryRequestOptions() { MaxItemCount = pageSize, PartitionKey = new PartitionKey("Base-Area") })) 
+                await foreach (var itemArea in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryStreamIteratorSql(queryText: areaSql.ToString(), continuationToken: pageToken, requestOptions: new QueryRequestOptions() { MaxItemCount = pageSize, PartitionKey = new PartitionKey("Base-Area") })) 
                 {
-                    using var json = await JsonDocument.ParseAsync(itemArea.ContentStream);
+                    using var json = await JsonDocument.ParseAsync(itemArea.Content);
                     if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetInt16() > 0) 
                     {
                         foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
@@ -143,9 +141,9 @@ namespace TEAMModelBI.Controllers.BINormal
                             areas.Add(obj.ToObject<RecArea>());
                         }
 
-                        if (iscontinuation) 
+                        if (iscontinuation)
                         {
-                            continuationToken = itemArea.GetContinuationToken();
+                            continuationToken = itemArea.ContinuationToken;
                             break;
                         }
                     } 
@@ -159,7 +157,7 @@ namespace TEAMModelBI.Controllers.BINormal
                 //    //List<AreaQuoteRecord> aqr = await table.QueryWhereString<AreaQuoteRecord>($"PartitionKey eq 'QuoteRecord' and  areaId eq '{area.id}'");
                 //    //aqr.Sort((x, y) => y.RowKey.CompareTo(x.RowKey));
 
-                //    await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<string>(queryText: $"select value(c.accessConfig) from c where c.id='{area.id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("AreaSetting") }))
+                //    await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIteratorSql<string>(queryText: $"select value(c.accessConfig) from c where c.id='{area.id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("AreaSetting") }))
                 //    {
                 //        if (string.IsNullOrEmpty(item))
                 //            area.cutArea = false;
@@ -178,7 +176,7 @@ namespace TEAMModelBI.Controllers.BINormal
                     //List<AreaQuoteRecord> aqr = await table.QueryWhereString<AreaQuoteRecord>($"PartitionKey eq 'QuoteRecord' and  areaId eq '{area.id}'");
                     //aqr.Sort((x, y) => y.RowKey.CompareTo(x.RowKey));
 
-                    await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<string>(queryText: $"select value(c.accessConfig) from c where c.id='{area.id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("AreaSetting") }))
+                    await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIteratorSql<string>(queryText: $"select value(c.accessConfig) from c where c.id='{area.id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("AreaSetting") }))
                     {
                         if (string.IsNullOrEmpty(item))
                             area.cutArea = false;
@@ -249,7 +247,7 @@ namespace TEAMModelBI.Controllers.BINormal
                 queryText += $"WHERE c.standard='{standard}'";
                 queryText += $" OR c.name='{name}'";
                 if(!string.IsNullOrWhiteSpace(shortCode)) queryText += $" OR c.shortCode='{shortCode}'";
-                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<Area>(queryText: $"{queryText}", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-Area") }))
+                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIteratorSql<Area>(queryText: $"{queryText}", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-Area") }))
                 {
                     //查询新的是否存在
                     if (item.standard.Equals($"{standard}"))
@@ -263,14 +261,14 @@ namespace TEAMModelBI.Controllers.BINormal
                 }
 
                 //查询新的是否存在
-                //await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<Area>(queryText: $"select value(c) from c where c.standard='{standard}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-Area") }))
+                //await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIteratorSql<Area>(queryText: $"select value(c) from c where c.standard='{standard}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-Area") }))
                 //{
                 //    if (item.standard.Equals($"{standard}"))
                 //        return Ok(new { state = 1, message = "新创区的standard已存在请检查" });
                 //}
 
                 //查询新的区级名称是否存在
-                //await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<Area>(queryText: $"select value(c) from c where c.name='{name}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-Area") }))
+                //await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIteratorSql<Area>(queryText: $"select value(c) from c where c.name='{name}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-Area") }))
                 //{
                 //    if (item.name.Equals($"{name}"))
                 //        return Ok(new { state = 1, message = "区级名称相同,请检测区级名称!" });
@@ -370,7 +368,7 @@ namespace TEAMModelBI.Controllers.BINormal
                 if (!string.IsNullOrEmpty($"{oldStandard}") && !string.IsNullOrEmpty($"{_oldId}"))
                 {
                     //查询要复制区域的能力标准点 
-                    await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<Ability>(queryText: $"select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Ability-{oldStandard}") }))
+                    await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIteratorSql<Ability>(queryText: $"select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Ability-{oldStandard}") }))
                     {
                         if (!string.IsNullOrEmpty(item.blob))
                         {
@@ -408,7 +406,7 @@ namespace TEAMModelBI.Controllers.BINormal
                     try
                     {
                         //微能力点
-                        await foreach (var atask in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<AbilityTask>(queryText: $"select value(c) from c ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"AbilityTask-{oldStandard}") }))
+                        await foreach (var atask in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIteratorSql<AbilityTask>(queryText: $"select value(c) from c ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"AbilityTask-{oldStandard}") }))
                         {
                             List<Tnode> tnodes = new List<Tnode>();
                             foreach (Tnode tnode in atask.children)
@@ -454,7 +452,7 @@ namespace TEAMModelBI.Controllers.BINormal
                     //}
 
                     //新政策文件
-                    await foreach (StandardFile standardFile in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<StandardFile>(queryText: $"select value(c) from c where  c.id='{_oldId}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StandardFile") }))
+                    await foreach (StandardFile standardFile in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIteratorSql<StandardFile>(queryText: $"select value(c) from c where  c.id='{_oldId}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StandardFile") }))
                     {
                         if (standardFile != null)
                         {
@@ -465,7 +463,7 @@ namespace TEAMModelBI.Controllers.BINormal
                     }
 
                     //新的区域设置
-                    await foreach (AreaSetting areaSetting in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<AreaSetting>(queryText: $"select value(c) from c where c.id='{_oldId}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("AreaSetting") }))
+                    await foreach (AreaSetting areaSetting in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIteratorSql<AreaSetting>(queryText: $"select value(c) from c where c.id='{_oldId}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("AreaSetting") }))
                     {
                         if (areaSetting != null)
                         {
@@ -478,14 +476,14 @@ namespace TEAMModelBI.Controllers.BINormal
                 else
                 {
                     Area area = null;
-                    await foreach (var tempArea in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<Area>(queryText: $"select value(c) from c where c.standard='standard2'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-Area") }))
+                    await foreach (var tempArea in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIteratorSql<Area>(queryText: $"select value(c) from c where c.standard='standard2'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-Area") }))
                     {
                         area = tempArea;
                     }
                     if (area != null)
                     {
                         //查询要复制区域的能力标准点 
-                        await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<Ability>(queryText: $"select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Ability-{area.standard}") }))
+                        await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIteratorSql<Ability>(queryText: $"select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Ability-{area.standard}") }))
                         {
                             if (!string.IsNullOrEmpty(item.blob))
                             {
@@ -524,7 +522,7 @@ namespace TEAMModelBI.Controllers.BINormal
                         try
                         {
                             //微能力点
-                            await foreach (var atask in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<AbilityTask>(queryText: $"select value(c) from c ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"AbilityTask-{area.standard}") }))
+                            await foreach (var atask in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIteratorSql<AbilityTask>(queryText: $"select value(c) from c ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"AbilityTask-{area.standard}") }))
                             {
                                 List<Tnode> tnodes = new List<Tnode>();
                                 foreach (Tnode tnode in atask.children)
@@ -571,7 +569,7 @@ namespace TEAMModelBI.Controllers.BINormal
                         //}
 
                         //新政策文件
-                        await foreach (StandardFile standardFile in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<StandardFile>(queryText: $"select value(c) from c where  c.id='{area.id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StandardFile") }))
+                        await foreach (StandardFile standardFile in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIteratorSql<StandardFile>(queryText: $"select value(c) from c where  c.id='{area.id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StandardFile") }))
                         {
                             if (standardFile != null)
                             {
@@ -582,7 +580,7 @@ namespace TEAMModelBI.Controllers.BINormal
                         }
 
                         //新的区域设置
-                        await foreach (AreaSetting areaSetting in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<AreaSetting>(queryText: $"select value(c) from c where c.id='{area.id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("AreaSetting") }))
+                        await foreach (AreaSetting areaSetting in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIteratorSql<AreaSetting>(queryText: $"select value(c) from c where c.id='{area.id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("AreaSetting") }))
                         {
                             if (areaSetting != null)
                             {
@@ -669,7 +667,7 @@ namespace TEAMModelBI.Controllers.BINormal
                 }
                 queryWhere = $"WHERE ({queryWhere}) AND c.id != '{id}'";
                 queryText = $"{queryText}{queryWhere}";
-                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<Area>(queryText: $"{queryText}", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-Area") }))
+                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIteratorSql<Area>(queryText: $"{queryText}", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-Area") }))
                 {
                     //查询区级名称是否存在
                     if (item.name.Equals($"{name}"))
@@ -689,18 +687,18 @@ namespace TEAMModelBI.Controllers.BINormal
                 var _azureCosmosClientCsv2Read = _azureCosmos.GetCosmosClient(name: "CoreServiceV2CnRead");
                 //學校資料庫驗證 [式樣待確認,先封印]
                 ///學區簡碼重複驗證
-                //await foreach (var item in _azureCosmosClientCsv2Read.GetContainer("Core", "School").GetItemQueryStreamIterator(queryText: sqlCheckRep, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("district") })) 
+                //await foreach (var item in _azureCosmosClientCsv2Read.GetContainer("Core", "School").GetItemQueryStreamIteratorSql(queryText: sqlCheckRep, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("district") })) 
                 //{
-                //    using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                //    using var json = await JsonDocument.ParseAsync(item.Content);
                 //    if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetInt16() > 0)
                 //    {
                 //        return Ok(new { state = 1, message = "此学区简码与其他 [学区] 简码相同请检查!" });
                 //    }                    
                 //}
                 ///學校簡碼重複驗證
-                //await foreach (var item in _azureCosmosClientCsv2Read.GetContainer("Core", "School").GetItemQueryStreamIterator(queryText: sqlCheckRep, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("base") }))
+                //await foreach (var item in _azureCosmosClientCsv2Read.GetContainer("Core", "School").GetItemQueryStreamIteratorSql(queryText: sqlCheckRep, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("base") }))
                 //{
-                //    using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                //    using var json = await JsonDocument.ParseAsync(item.Content);
                 //    if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetInt16() > 0)
                 //    {
                 //        return Ok(new { state = 1, message = "此学区简码与其他 [学校] 简码相同请检查!" });
@@ -768,9 +766,9 @@ namespace TEAMModelBI.Controllers.BINormal
                 var table = tableClient.GetTableReference("IESLogin");
 
                 var responseSet = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").ReadItemStreamAsync($"{_oldId}", new PartitionKey("AreaSetting"));
-                if (responseSet.Status == 200)
+                if (responseSet.StatusCode == HttpStatusCode.OK)
                 {
-                    using var fileJson = await JsonDocument.ParseAsync(responseSet.ContentStream);
+                    using var fileJson = await JsonDocument.ParseAsync(responseSet.Content);
                     AreaSetting delSet = fileJson.ToObject<AreaSetting>();
                     if (!string.IsNullOrEmpty(delSet.accessConfig))
                         return Ok(new { state = 401, msg = "区域已经规定了,不能切换能能力" });
@@ -782,7 +780,7 @@ namespace TEAMModelBI.Controllers.BINormal
                 List<string> abilityIds = new();  //册别的ID集合
 
                 //查询册别信息
-                await foreach (var tempAbility in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<Ability>(queryText: $"select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Ability-{_oldStandard}") }))
+                await foreach (var tempAbility in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIteratorSql<Ability>(queryText: $"select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Ability-{_oldStandard}") }))
                 {
                     abilityIds.Add(tempAbility.id);  //查询出来册别ID添加册别ID集合
                 }
@@ -793,7 +791,7 @@ namespace TEAMModelBI.Controllers.BINormal
                 }
 
                 List<string> abilityTaskIds = new();  //章节ID集合
-                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<AbilityTask>(queryText: $"select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"AbilityTask-{_oldStandard}") }))
+                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIteratorSql<AbilityTask>(queryText: $"select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"AbilityTask-{_oldStandard}") }))
                 {
                     abilityTaskIds.Add(item.id);   //查询出来的章节信息ID添加到战绩集合
                 }
@@ -807,7 +805,7 @@ namespace TEAMModelBI.Controllers.BINormal
                 List<Task<ItemResponse<AbilityTask>>> abilityTasks = new();  //存储章节
 
                 //查询要复制区域的能力标准点 
-                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<Ability>(queryText: $"select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Ability-{_newStandard}") }))
+                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIteratorSql<Ability>(queryText: $"select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Ability-{_newStandard}") }))
                 {
                     if (!string.IsNullOrEmpty(item.blob))
                     {
@@ -846,7 +844,7 @@ namespace TEAMModelBI.Controllers.BINormal
                 try
                 {
                     //微能力点
-                    await foreach (var atask in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<AbilityTask>(queryText: $"select value(c) from c ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"AbilityTask-{_newStandard}") }))
+                    await foreach (var atask in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIteratorSql<AbilityTask>(queryText: $"select value(c) from c ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"AbilityTask-{_newStandard}") }))
                     {
                         List<Tnode> tnodes = new();
                         foreach (Tnode tnode in atask.children)
@@ -885,7 +883,7 @@ namespace TEAMModelBI.Controllers.BINormal
                 StandardFile saveFile = new();
 
                 //新政策文件
-                await foreach (StandardFile standardFile in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<StandardFile>(queryText: $"select value(c) from c where  c.id='{_newId}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StandardFile") }))
+                await foreach (StandardFile standardFile in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIteratorSql<StandardFile>(queryText: $"select value(c) from c where  c.id='{_newId}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StandardFile") }))
                 {
                     if (standardFile != null)
                     {
@@ -899,9 +897,9 @@ namespace TEAMModelBI.Controllers.BINormal
                 if (saveFile.id != null)
                 {
                     var respFile = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").ReadItemStreamAsync(saveFile.id, new PartitionKey("StandardFile"));
-                    if (respFile.Status == 200)
+                    if (respFile.StatusCode == HttpStatusCode.OK)
                     {
-                        using var json = await JsonDocument.ParseAsync(respFile.ContentStream);
+                        using var json = await JsonDocument.ParseAsync(respFile.Content);
                         tempFile = json.ToObject<StandardFile>();
                         await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").DeleteItemAsync<StandardFile>(tempFile.id, new PartitionKey("StandardFile"));
                     }
@@ -911,7 +909,7 @@ namespace TEAMModelBI.Controllers.BINormal
 
                 //新的区域设置
                 AreaSetting saveSetting = new AreaSetting();
-                await foreach (AreaSetting areaSetting in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<AreaSetting>(queryText: $"select value(c) from c where c.id='{_newId}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("AreaSetting") }))
+                await foreach (AreaSetting areaSetting in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIteratorSql<AreaSetting>(queryText: $"select value(c) from c where c.id='{_newId}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("AreaSetting") }))
                 {
                     if (areaSetting != null)
                     {
@@ -926,9 +924,9 @@ namespace TEAMModelBI.Controllers.BINormal
                 if (saveSetting.id != null)
                 {
                     var respSetting = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").ReadItemStreamAsync(saveSetting.id, new PartitionKey("AreaSetting"));
-                    if (respSetting.Status == 200)
+                    if (respSetting.StatusCode == HttpStatusCode.OK)
                     {
-                        using var json = await JsonDocument.ParseAsync(respSetting.ContentStream);
+                        using var json = await JsonDocument.ParseAsync(respSetting.Content);
                         tempSetting = json.ToObject<AreaSetting>();
                         await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").DeleteItemAsync<AreaSetting>(tempFile.id, new PartitionKey("AreaSetting"));
                     }
@@ -1005,16 +1003,16 @@ namespace TEAMModelBI.Controllers.BINormal
             //}
 
             var response = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").ReadItemStreamAsync($"{areaId}", new PartitionKey("Base-Area"));
-            if (response.Status == 200)
+            if (response.StatusCode == HttpStatusCode.OK)
             {
-                using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                using var json = await JsonDocument.ParseAsync(response.Content);
                 Area area = json.ToObject<Area>();
                 if (area.standard == $"{standard}") 
                 {
                     await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").DeleteItemAsync<Area>(area.id, new PartitionKey("Base-Area")); //删除区
 
                     List<Teacher> teachers = new();
-                    await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<Teacher>(queryText: $"SELECT distinct value(c) FROM c join a in c.areas join s in c.schools where a.areaId='{area.id}' or s.areaId='{area.id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") })) 
+                    await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIteratorSql<Teacher>(queryText: $"SELECT distinct value(c) FROM c join a in c.areas join s in c.schools where a.areaId='{area.id}' or s.areaId='{area.id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") })) 
                     {
                         teachers.Add(item);
                     }
@@ -1044,7 +1042,7 @@ namespace TEAMModelBI.Controllers.BINormal
                     List<string> abilityTaskIds = new();  //章节ID集合
 
                     //查询册别信息
-                    await foreach (var tempAbility in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<Ability>(queryText: $"select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Ability-{area.standard}") }))
+                    await foreach (var tempAbility in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIteratorSql<Ability>(queryText: $"select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Ability-{area.standard}") }))
                     {
                         abilityIds.Add(tempAbility.id);  //查询出来册别ID添加册别ID集合
                     }
@@ -1054,7 +1052,7 @@ namespace TEAMModelBI.Controllers.BINormal
                         var sresponse = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").DeleteItemsStreamAsync(abilityIds, $"Ability-{area.standard}");
                     }
 
-                    await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<AbilityTask>(queryText: $"select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"AbilityTask-{area.standard}") }))
+                    await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIteratorSql<AbilityTask>(queryText: $"select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"AbilityTask-{area.standard}") }))
                     {
                         abilityTaskIds.Add(item.id);   //查询出来的章节信息ID添加到战绩集合
                     }
@@ -1066,9 +1064,9 @@ namespace TEAMModelBI.Controllers.BINormal
                     //区域政策文件
                     StandardFile delFile = new();
                     var responseFile = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").ReadItemStreamAsync(area.id, new PartitionKey("StandardFile"));
-                    if(responseFile.Status == 200)
+                    if(responseFile.StatusCode == HttpStatusCode.OK)
                     {
-                        using var fileJson = await JsonDocument.ParseAsync(responseFile.ContentStream);
+                        using var fileJson = await JsonDocument.ParseAsync(responseFile.Content);
                         delFile = fileJson.ToObject<StandardFile>();
                         await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").DeleteItemAsync<StandardFile>(delFile.id, new PartitionKey("StandardFile"));
                     }
@@ -1076,16 +1074,16 @@ namespace TEAMModelBI.Controllers.BINormal
                     //区域设置
                     AreaSetting delSet = new();
                     var responseSet = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").ReadItemStreamAsync(area.id, new PartitionKey("AreaSetting"));
-                    if (responseSet.Status == 200)
+                    if (responseSet.StatusCode == HttpStatusCode.OK)
                     {
-                        using var fileJson = await JsonDocument.ParseAsync(responseSet.ContentStream);
+                        using var fileJson = await JsonDocument.ParseAsync(responseSet.Content);
                         delSet = fileJson.ToObject<AreaSetting>();
                         await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").DeleteItemAsync<AreaSetting>(delSet.id, new PartitionKey("AreaSetting"));
                     }
 
                     List<object> fileobj = new();
                     //先删除原有的文件
-                    List<Task<Response<bool>>> DelList = new();
+                    List<Task<Azure.Response<bool>>> DelList = new();
                     await foreach (BlobItem blobItem in blobClient.GetBlobsAsync(BlobTraits.None, BlobStates.None, $"yxpt/{area.standard}/"))
                     {
                         fileobj.Add(blobItem.Name);
@@ -1101,7 +1099,7 @@ namespace TEAMModelBI.Controllers.BINormal
                         int pages = (DelList.Count + 255) / 256;
                         for (int i = 0; i < pages; i++)
                         {
-                            List<Task<Response<bool>>> delList = DelList.Skip((i) * 256).Take(256).ToList();
+                            List<Task<Azure.Response<bool>>> delList = DelList.Skip((i) * 256).Take(256).ToList();
                             await Task.WhenAll(delList);
                         }
                     }
@@ -1150,9 +1148,9 @@ namespace TEAMModelBI.Controllers.BINormal
                 if (area != null)
                 {
                     var responseSet = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").ReadItemStreamAsync($"{_oldId}", new PartitionKey("AreaSetting"));
-                    if (responseSet.Status == 200)
+                    if (responseSet.StatusCode == HttpStatusCode.OK)
                     {
-                        using var fileJson = await JsonDocument.ParseAsync(responseSet.ContentStream);
+                        using var fileJson = await JsonDocument.ParseAsync(responseSet.Content);
                         AreaSetting delSet = fileJson.ToObject<AreaSetting>();
                         if (!string.IsNullOrEmpty(delSet.accessConfig))
                             return Ok(new { state = 401, msg = "区域已经规定了,不能切换能能力" });
@@ -1161,7 +1159,7 @@ namespace TEAMModelBI.Controllers.BINormal
                     List<string> abilityIds = new();  //册别的ID集合
 
                     //查询册别信息
-                    await foreach (var tempAbility in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<Ability>(queryText: $"select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Ability-{area.standard}") }))
+                    await foreach (var tempAbility in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIteratorSql<Ability>(queryText: $"select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Ability-{area.standard}") }))
                     {
                         abilityIds.Add(tempAbility.id);  //查询出来册别ID添加册别ID集合
                     }
@@ -1172,7 +1170,7 @@ namespace TEAMModelBI.Controllers.BINormal
                     }
 
                     List<string> abilityTaskIds = new List<string>();  //章节ID集合
-                    await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<AbilityTask>(queryText: $"select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"AbilityTask-{area.standard}") }))
+                    await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIteratorSql<AbilityTask>(queryText: $"select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"AbilityTask-{area.standard}") }))
                     {
                         abilityTaskIds.Add(item.id);   //查询出来的章节信息ID添加到战绩集合
                     }
@@ -1192,7 +1190,7 @@ namespace TEAMModelBI.Controllers.BINormal
                         try
                         {
                             //查询要复制区域的能力标准点 
-                            await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<Ability>(queryText: $"select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Ability-{newstand.standard}") }))
+                            await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIteratorSql<Ability>(queryText: $"select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Ability-{newstand.standard}") }))
                             {
                                 if (!string.IsNullOrEmpty(item.blob))
                                     item.blob = item.blob.Replace($"/{newstand.standard}/", $"/{area.standard}/");
@@ -1206,7 +1204,7 @@ namespace TEAMModelBI.Controllers.BINormal
                                 //await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").CreateItemAsync(item, new PartitionKey($"Ability-{_oldStandard}"));
 
                                 var respond = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").ReadItemStreamAsync(item.id, new PartitionKey(item.code));
-                                if (respond.Status != 200)
+                                if (respond.StatusCode != HttpStatusCode.OK)
                                     abilities.Add(cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").CreateItemAsync(item, new PartitionKey($"Ability-{area.standard}")));
                                 else
                                     repeatAbilityId.Add(item.id);
@@ -1241,7 +1239,7 @@ namespace TEAMModelBI.Controllers.BINormal
                         try
                         {
                             //微能力点
-                            await foreach (var atask in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<AbilityTask>(queryText: $"select value(c) from c ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"AbilityTask-{newstand.standard}") }))
+                            await foreach (var atask in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIteratorSql<AbilityTask>(queryText: $"select value(c) from c ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"AbilityTask-{newstand.standard}") }))
                             {
                                 List<Tnode> tnodes = new();
                                 foreach (Tnode tnode in atask.children)
@@ -1268,7 +1266,7 @@ namespace TEAMModelBI.Controllers.BINormal
                                 atask.codeval = $"{area.standard}";
 
                                 var respond = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").ReadItemStreamAsync(atask.id, new PartitionKey(atask.code));
-                                if (respond.Status != 200)
+                                if (respond.StatusCode != HttpStatusCode.OK)
                                     ////添加区能力标准点中的节点 
                                     //abilityTasks.Add(cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").CreateItemAsync(atask, new PartitionKey($"AbilityTask-{_oldStandard}")));
                                     await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").CreateItemAsync(atask, new PartitionKey($"AbilityTask-{area.standard}"));
@@ -1309,7 +1307,7 @@ namespace TEAMModelBI.Controllers.BINormal
 
                     StandardFile saveFile = new();
                     //新政策文件
-                    await foreach (StandardFile standardFile in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<StandardFile>(queryText: $"select value(c) from c where  c.id='{standardFileId}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StandardFile") }))
+                    await foreach (StandardFile standardFile in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIteratorSql<StandardFile>(queryText: $"select value(c) from c where  c.id='{standardFileId}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StandardFile") }))
                     {
                         if (standardFile != null)
                         {
@@ -1324,9 +1322,9 @@ namespace TEAMModelBI.Controllers.BINormal
                     if (saveFile.id != null)
                     {
                         var respFile = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").ReadItemStreamAsync(saveFile.id, new PartitionKey("StandardFile"));
-                        if (respFile.Status == 200)
+                        if (respFile.StatusCode == HttpStatusCode.OK)
                         {
-                            using var json = await JsonDocument.ParseAsync(respFile.ContentStream);
+                            using var json = await JsonDocument.ParseAsync(respFile.Content);
                             tempFile = json.ToObject<StandardFile>();
                             await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").DeleteItemAsync<StandardFile>(tempFile.id, new PartitionKey("StandardFile"));
                         }
@@ -1344,7 +1342,7 @@ namespace TEAMModelBI.Controllers.BINormal
 
                     //新的区域设置
                     AreaSetting saveSetting = new();
-                    await foreach (AreaSetting areaSetting in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<AreaSetting>(queryText: $"select value(c) from c where c.id='{standardFileId}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("AreaSetting") }))
+                    await foreach (AreaSetting areaSetting in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIteratorSql<AreaSetting>(queryText: $"select value(c) from c where c.id='{standardFileId}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("AreaSetting") }))
                     {
                         if (areaSetting != null)
                         {
@@ -1359,9 +1357,9 @@ namespace TEAMModelBI.Controllers.BINormal
                     if (saveSetting.id != null)
                     {
                         var respSetting = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").ReadItemStreamAsync(saveSetting.id, new PartitionKey("AreaSetting"));
-                        if (respSetting.Status == 200)
+                        if (respSetting.StatusCode == HttpStatusCode.OK)
                         {
-                            using var json = await JsonDocument.ParseAsync(respSetting.ContentStream);
+                            using var json = await JsonDocument.ParseAsync(respSetting.Content);
                             tempSetting = json.ToObject<AreaSetting>();
                             await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").DeleteItemAsync<AreaSetting>(saveSetting.id, new PartitionKey("AreaSetting"));
                         }

+ 14 - 14
TEAMModelBI/Controllers/BINormal/BusinessConfigController.cs

@@ -1,4 +1,4 @@
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Mvc;
 using Microsoft.Extensions.Options;
@@ -71,7 +71,7 @@ namespace TEAMModelBI.Controllers.BINormal
 
                 await cosmosClient.GetContainer("TEAMModelOS", "Normal").CreateItemAsync<BizConfig>(bizConfig, new PartitionKey("BizConfig"));
 
-                await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Normal").GetItemQueryIterator<BizUsers>(queryText: $"select value(c) from c where c.mobile ={bizConfig.mobile}", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("BizUsers") })) 
+                await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Normal").GetItemQueryIteratorSql<BizUsers>(queryText: $"select value(c) from c where c.mobile ={bizConfig.mobile}", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("BizUsers") })) 
                 {
                     bizUsers.Add(item);
                 }
@@ -103,9 +103,9 @@ namespace TEAMModelBI.Controllers.BINormal
             else
             {
                 var response = await cosmosClient.GetContainer("TEAMModelOS", "Normal").ReadItemStreamAsync(bizConfig.id, new PartitionKey("BizConfig"));
-                if (response.Status == 200)
+                if (response.StatusCode == System.Net.HttpStatusCode.OK)
                 {
-                    using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                    using var json = await JsonDocument.ParseAsync(response.Content);
                     BizConfig tempBizConfig = json.ToObject<BizConfig>();
 
                     bizConfig.pk = "BizConfig";
@@ -146,7 +146,7 @@ namespace TEAMModelBI.Controllers.BINormal
             }
 
             List<Business> businesses = new();
-            await foreach (var items in cosmosClient.GetContainer("TEAMModelOS", "Normal").GetItemQueryIterator<Business>(queryText: sqlTxt.ToString(), requestOptions:  new QueryRequestOptions() { PartitionKey = new PartitionKey("BizConfig") }))
+            await foreach (var items in cosmosClient.GetContainer("TEAMModelOS", "Normal").GetItemQueryIteratorSql<Business>(queryText: sqlTxt.ToString(), requestOptions:  new QueryRequestOptions() { PartitionKey = new PartitionKey("BizConfig") }))
             {
                 businesses.Add(items);
             }
@@ -172,14 +172,14 @@ namespace TEAMModelBI.Controllers.BINormal
                 //企業聯絡人 刪除該企業聯絡資訊
                 List<string> bizUsersIdList = new List<string>();
                 StringBuilder sql = new($"SELECT VALUE c.id FROM c JOIN r IN c.relation WHERE r.bizId = '{id}'");
-                await foreach (var items in cosmosClient.GetContainer("TEAMModelOS", "Normal").GetItemQueryIterator<string>(queryText: sql.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("BizUsers") })) {
+                await foreach (var items in cosmosClient.GetContainer("TEAMModelOS", "Normal").GetItemQueryIteratorSql<string>(queryText: sql.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("BizUsers") })) {
                     bizUsersIdList.Add(items);
                 }
                 if(bizUsersIdList.Count > 0)
                 {
                     string bizUsersIdListStr = JsonSerializer.Serialize(bizUsersIdList);
                     sql = new($"SELECT * FROM c WHERE ARRAY_CONTAINS({bizUsersIdListStr}, c.id, true)");
-                    await foreach (BizUsers item in cosmosClient.GetContainer("TEAMModelOS", "Normal").GetItemQueryIterator<BizUsers>(queryText: sql.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("BizUsers") }))
+                    await foreach (BizUsers item in cosmosClient.GetContainer("TEAMModelOS", "Normal").GetItemQueryIteratorSql<BizUsers>(queryText: sql.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("BizUsers") }))
                     {
                         item.relation.RemoveAll(r => r.bizId == $"{id}");
                         await cosmosClient.GetContainer("TEAMModelOS", "Normal").ReplaceItemAsync<BizUsers>(item, item.id, new PartitionKey("BizUsers"));
@@ -229,9 +229,9 @@ namespace TEAMModelBI.Controllers.BINormal
             BizConfig bizConfig = new();
 
             var response = await cosmosClient.GetContainer("TEAMModelOS", "Normal").ReadItemStreamAsync($"{id}", new PartitionKey("BizConfig"));
-            if (response.Status == 200)
+            if (response.StatusCode == System.Net.HttpStatusCode.OK)
             {
-                using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                using var json = await JsonDocument.ParseAsync(response.Content);
                 bizConfig = json.ToObject<BizConfig>();
                 var auth_token = JwtAuthExtension.CreateBusinessApiToken(_option.Location, bizConfig.id, _option.JwtSecretKey, bizConfig.isCustomize);
                 bizConfig.jti = auth_token.jti;
@@ -284,9 +284,9 @@ namespace TEAMModelBI.Controllers.BINormal
             List<BizSchool> noBizSc = new();
             BizConfig bizConfig = new();
             var response = await cosmosClient.GetContainer("TEAMModelOS", "Normal").ReadItemStreamAsync($"{id}", new PartitionKey("BizConfig"));
-            if (response.Status == RespondCode.Ok)
+            if (response.StatusCode == System.Net.HttpStatusCode.OK)
             {
-                using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                using var json = await JsonDocument.ParseAsync(response.Content);
                 bizConfig = json.ToObject<BizConfig>();
                 foreach (var item in bizSchool)
                 {
@@ -345,7 +345,7 @@ namespace TEAMModelBI.Controllers.BINormal
 
             List<OpenSchool> openSchools = new();
 
-            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<OpenSchool>(queryText: "select c.id,c.code,c.name,c.picture from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
+            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIteratorSql<OpenSchool>(queryText: "select c.id,c.code,c.name,c.picture from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
             {
                 openSchools.Add(item);
             }
@@ -353,9 +353,9 @@ namespace TEAMModelBI.Controllers.BINormal
             if (!string.IsNullOrEmpty($"id"))
             {
                 var response = await cosmosClient.GetContainer("TEAMModelOS", "Normal").ReadItemStreamAsync($"{id}", new PartitionKey("BizConfig"));
-                if (response.Status == RespondCode.Ok)
+                if (response.StatusCode == System.Net.HttpStatusCode.OK)
                 {
-                    using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                    using var json = await JsonDocument.ParseAsync(response.Content);
                     bizConfig = json.ToObject<BizConfig>();
                     if (bizConfig.schools.Count > 0)
                     {

+ 11 - 11
TEAMModelBI/Controllers/BINormal/BusinessUsersController.cs

@@ -1,4 +1,4 @@
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Mvc;
 using Microsoft.Extensions.Configuration;
@@ -64,7 +64,7 @@ namespace TEAMModelBI.Controllers.BINormal
             }
 
             List<BizUsers> bizUsers = new();
-            await foreach (var items in cosmosClient.GetContainer("TEAMModelOS", "Normal").GetItemQueryIterator<BizUsers>(queryText: sqlTxt.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("BizUsers") }))
+            await foreach (var items in cosmosClient.GetContainer("TEAMModelOS", "Normal").GetItemQueryIteratorSql<BizUsers>(queryText: sqlTxt.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("BizUsers") }))
             {
                 bizUsers.Add(items);
             }
@@ -112,9 +112,9 @@ namespace TEAMModelBI.Controllers.BINormal
             else 
             {
                 var response = await cosmosClient.GetContainer("TEAMModelOS", "Normal").ReadItemStreamAsync(bizUsers.id, new PartitionKey("BizUsers"));
-                if (response.Status == RespondCode.Ok)
+                if (response.StatusCode == System.Net.HttpStatusCode.OK)
                 {
-                    using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                    using var json = await JsonDocument.ParseAsync(response.Content);
                     BizUsers tempbizUsers = json.ToObject<BizUsers>();
 
                     bizUsers.pk = "BizUsers";
@@ -152,7 +152,7 @@ namespace TEAMModelBI.Controllers.BINormal
             string sql = $"select value(c) from c where c.mobile ={mobile}";
 
             List<BizUsers> bizUsers = new();
-            await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS,"Normal").GetItemQueryIterator<BizUsers>(queryText:sql,requestOptions:new QueryRequestOptions() { PartitionKey = new PartitionKey("BizUsers") }))
+            await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS,"Normal").GetItemQueryIteratorSql<BizUsers>(queryText:sql,requestOptions:new QueryRequestOptions() { PartitionKey = new PartitionKey("BizUsers") }))
             {
                 bizUsers.Add(item);
             }
@@ -193,9 +193,9 @@ namespace TEAMModelBI.Controllers.BINormal
             StringBuilder strMsg = new($"{tmdName}[{tmdId}]操作:");
             string salt = Utils.CreatSaltString(8);
             var response = await cosmosClient.GetContainer("TEAMModelOS", "Normal").ReadItemStreamAsync($"{id}", new PartitionKey("BizUsers"));
-            if (response.Status == 200)
+            if (response.StatusCode == System.Net.HttpStatusCode.OK)
             {
-                using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                using var json = await JsonDocument.ParseAsync(response.Content);
                 bizUsers = json.ToObject<BizUsers>();
                 bizUsers.salt = salt;
                 bizUsers.pwd = Utils.HashedPassword(bizUsers.mobile.ToString(), salt);
@@ -279,9 +279,9 @@ namespace TEAMModelBI.Controllers.BINormal
             else { return Ok(new { state = RespondCode.ParamsError, msg = "类型错误" }); }
 
             var response = await cosmosClient.GetContainer("TEAMModelOS", "Normal").ReadItemStreamAsync($"{id}", new PartitionKey("BizUsers"));
-            if (response.Status == RespondCode.Ok)
+            if (response.StatusCode == System.Net.HttpStatusCode.OK)
             {
-                using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                using var json = await JsonDocument.ParseAsync(response.Content);
                 bizUsers = json.ToObject<BizUsers>();
             }
 
@@ -310,7 +310,7 @@ namespace TEAMModelBI.Controllers.BINormal
                 }
             }
 
-            if (response.Status == RespondCode.Ok) 
+            if (response.StatusCode == System.Net.HttpStatusCode.OK) 
             {
                 bizUsers = await cosmosClient.GetContainer("TEAMModelOS", "Normal").ReplaceItemAsync<BizUsers>(bizUsers, bizUsers.id, new PartitionKey("BizUsers"));
             }
@@ -345,7 +345,7 @@ namespace TEAMModelBI.Controllers.BINormal
 
             List<BizUsers> businessUsers = new();
             string sql = $"select value(c) from c join s in c.relation  where c.code='BizUsers' and s.bizId = '{id}'";
-            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Normal").GetItemQueryIterator<BizUsers>(queryText: sql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("BizUsers") }))
+            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Normal").GetItemQueryIteratorSql<BizUsers>(queryText: sql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("BizUsers") }))
             {
                 businessUsers.Add(item);
             }

Dosya farkı çok büyük olduğundan ihmal edildi
+ 224 - 19
TEAMModelBI/Controllers/BIProductAnalysis/ProductAnalysisController.cs


+ 187 - 69
TEAMModelBI/Controllers/BISchool/BatchSchoolController.cs

@@ -1,5 +1,4 @@
-using Azure.Cosmos;
-using HTEXLib.COMM.Helpers;
+using Microsoft.Azure.Cosmos;
 using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Mvc;
 using Microsoft.Extensions.Options;
@@ -32,13 +31,11 @@ using TEAMModelOS.SDK.Context.Constant;
 using Pipelines.Sockets.Unofficial.Arenas;
 using Microsoft.Identity.Client;
 using TEAMModelOS.SDK.Models.Dtos;
-using DocumentFormat.OpenXml.Spreadsheet;
-using DocumentFormat.OpenXml.Wordprocessing;
-using DocumentFormat.OpenXml.Bibliography;
-using HTEXLib;
 using TEAMModelOS.SDK.Models.Service.BI;
 using TEAMModelOS.SDK.Models.Cosmos.BI.BISchool;
-using DocumentFormat.OpenXml.Vml.Office;
+using System.Net.Http.Headers;
+using System.Text.Encodings.Web;
+using System.ComponentModel.DataAnnotations;
 
 namespace TEAMModelBI.Controllers.BISchool
 {
@@ -115,7 +112,7 @@ namespace TEAMModelBI.Controllers.BISchool
                 {
                     createSchoolInfo = await SchoolCode.GenerateSchoolCode(createSchoolInfo, _dingDing, _environment);
                     var schoolStatu = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync($"{createSchoolInfo.id}", new PartitionKey($"Base"));
-                    if (schoolStatu.Status != 200) tempStaus = false;
+                    if (schoolStatu.StatusCode != HttpStatusCode.OK) tempStaus = false;
                     else createSchoolInfo.createCount = createSchoolInfo.createCount >= 3 ? createSchoolInfo.createCount = 3 : createSchoolInfo.createCount += 1;
                 } while (tempStaus);
                 createScInfo.Add(createSchoolInfo);
@@ -164,9 +161,9 @@ namespace TEAMModelBI.Controllers.BISchool
                         Area area = null;
                         //查询区是否存在
                         var respAreaId = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").ReadItemStreamAsync($"{bischool.areaId}", new PartitionKey("Base-Area"));
-                        if (respAreaId.Status == 200)
+                        if (respAreaId.StatusCode == HttpStatusCode.OK)
                         {
-                            using var areaBase = await JsonDocument.ParseAsync(respAreaId.ContentStream);
+                            using var areaBase = await JsonDocument.ParseAsync(respAreaId.Content);
                             area = areaBase.ToObject<Area>();
                         }
 
@@ -186,7 +183,7 @@ namespace TEAMModelBI.Controllers.BISchool
                         {
                             createSchoolInfo = await SchoolCode.GenerateSchoolCode(createSchoolInfo, _dingDing, _environment);
                             var schoolStatu = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync($"{createSchoolInfo.id}", new PartitionKey($"Base"));
-                            if (schoolStatu.Status != 200) tempStaus = false;
+                            if (schoolStatu.StatusCode != HttpStatusCode.OK) tempStaus = false;
                             else createSchoolInfo.createCount = createSchoolInfo.createCount >= 3 ? createSchoolInfo.createCount = 3 : createSchoolInfo.createCount += 1;
                         } while (tempStaus);
 
@@ -247,9 +244,9 @@ namespace TEAMModelBI.Controllers.BISchool
                             {
                                 Teacher teacher = new();
                                 var resTeache = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemStreamAsync($"{tmdIndo.id}", new PartitionKey("Base"));
-                                if (resTeache.Status == 200)
+                                if (resTeache.StatusCode == HttpStatusCode.OK)
                                 {
-                                    using var tchJson = await JsonDocument.ParseAsync(resTeache.ContentStream);
+                                    using var tchJson = await JsonDocument.ParseAsync(resTeache.Content);
                                     teacher = tchJson.ToObject<Teacher>();
                                     Teacher.TeacherSchool tchSc = null;
                                     //var tempTch = teacher.schools.Select(x => x.schoolId.Equals(upSchool.id)).ToString();
@@ -329,7 +326,7 @@ namespace TEAMModelBI.Controllers.BISchool
                     //{
                     //    List<string> scName = new();
                     //    //查询学校名称是否全字段匹配
-                    //    await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<string>(queryText: $"select value(c.name) from c where c.name='{bischool.name}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
+                    //    await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIteratorSql<string>(queryText: $"select value(c.name) from c where c.name='{bischool.name}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
                     //    {
                     //        scName.Add(item);
                     //    }
@@ -339,7 +336,7 @@ namespace TEAMModelBI.Controllers.BISchool
                     //    var respAreaId = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").ReadItemStreamAsync($"{bischool.areaId}", new PartitionKey("Base-Area"));
                     //    if (respAreaId.Status == 200)
                     //    {
-                    //        using var areaBase = await JsonDocument.ParseAsync(respAreaId.ContentStream);
+                    //        using var areaBase = await JsonDocument.ParseAsync(respAreaId.Content);
                     //        area = areaBase.ToObject<Area>();
                     //    }
 
@@ -348,7 +345,7 @@ namespace TEAMModelBI.Controllers.BISchool
                     //    var responseSet = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").ReadItemStreamAsync($"{bischool.areaId}", new PartitionKey("AreaSetting"));
                     //    if (responseSet.Status == 200)
                     //    {
-                    //        using var fileJson = await JsonDocument.ParseAsync(responseSet.ContentStream);
+                    //        using var fileJson = await JsonDocument.ParseAsync(responseSet.Content);
                     //        AreaSetting delSet = fileJson.ToObject<AreaSetting>();
                     //        if (!string.IsNullOrEmpty(delSet.accessConfig))
                     //            isSYNCArea = true;
@@ -420,7 +417,7 @@ namespace TEAMModelBI.Controllers.BISchool
                     //                    var resTeache = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemStreamAsync($"{coreUser.id}", new PartitionKey("Base"));
                     //                    if (resTeache.Status == 200)
                     //                    {
-                    //                        using var tchJson = await JsonDocument.ParseAsync(resTeache.ContentStream);
+                    //                        using var tchJson = await JsonDocument.ParseAsync(resTeache.Content);
                     //                        teacher = tchJson.ToObject<Teacher>();
                     //                        //教师存在,在该教师信息中添加要管理的学校信息
                     //                        teacher.schools.Add(new Teacher.TeacherSchool { areaId = string.IsNullOrEmpty(bischool.areaId) ? "" : bischool.areaId, schoolId = createSchoolInfo.id, name = bischool.name, status = "join", time = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() });
@@ -613,7 +610,7 @@ namespace TEAMModelBI.Controllers.BISchool
                         else
                             sqlTxt.Append(" order by c.createTime asc");
 
-                        await foreach (var itemSchool in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<AssistSchool>(queryText: sqlTxt.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
+                        await foreach (var itemSchool in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIteratorSql<AssistSchool>(queryText: sqlTxt.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
                         {
                             schoolAssists.Add(itemSchool);
                         }
@@ -623,9 +620,9 @@ namespace TEAMModelBI.Controllers.BISchool
                 {
                     scCnt = await CommonFind.GetSqlValueCount(cosmosClient, "School", scCntSql.ToString(), "Base");
 
-                    await foreach (var itemSchool in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: stringBuilder.ToString(), continuationToken: pageToken, requestOptions: new QueryRequestOptions() { MaxItemCount = pageSize, PartitionKey = new PartitionKey("Base") }))
+                    await foreach (var itemSchool in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIteratorSql(queryText: stringBuilder.ToString(), continuationToken: pageToken, requestOptions: new QueryRequestOptions() { MaxItemCount = pageSize, PartitionKey = new PartitionKey("Base") }))
                     {
-                        using var json = await JsonDocument.ParseAsync(itemSchool.ContentStream);
+                        using var json = await JsonDocument.ParseAsync(itemSchool.Content);
                         if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetInt16() > 0)
                         {
                             foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
@@ -634,7 +631,7 @@ namespace TEAMModelBI.Controllers.BISchool
                             }
                             if (iscontinuation)
                             {
-                                continuationToken = itemSchool.GetContinuationToken();
+                                continuationToken = itemSchool.ContinuationToken;
                                 break;
                             }
                         }
@@ -651,7 +648,7 @@ namespace TEAMModelBI.Controllers.BISchool
                 //        if ($"{order}".Equals("desc"))
                 //            sqlTxt.Append(" order by c.createTime desc");
 
-                //        await foreach (var itemSchool in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<AssistSchool>(queryText: sqlTxt.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
+                //        await foreach (var itemSchool in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIteratorSql<AssistSchool>(queryText: sqlTxt.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
                 //        {
                 //            schoolAssists.Add(itemSchool);
                 //        }
@@ -690,9 +687,9 @@ namespace TEAMModelBI.Controllers.BISchool
 
                 //    scCnt = await CommonFind.GetSqlValueCount(cosmosClient, "School", scCntSql.ToString(), "Base");
 
-                //    await foreach (var itemSchool in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: stringBuilder.ToString(), continuationToken: pageToken, requestOptions: new QueryRequestOptions() { MaxItemCount = pageSize, PartitionKey = new PartitionKey("Base") }))
+                //    await foreach (var itemSchool in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIteratorSql(queryText: stringBuilder.ToString(), continuationToken: pageToken, requestOptions: new QueryRequestOptions() { MaxItemCount = pageSize, PartitionKey = new PartitionKey("Base") }))
                 //    {
-                //        using var json = await JsonDocument.ParseAsync(itemSchool.ContentStream);
+                //        using var json = await JsonDocument.ParseAsync(itemSchool.Content);
                 //        if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetInt16() > 0)
                 //        {
                 //            foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
@@ -701,7 +698,7 @@ namespace TEAMModelBI.Controllers.BISchool
                 //            }
                 //            if (iscontinuation)
                 //            {
-                //                continuationToken = itemSchool.GetContinuationToken();
+                //                continuationToken = itemSchool.ContinuationToken;
                 //                break;
                 //            }
                 //        }
@@ -711,9 +708,9 @@ namespace TEAMModelBI.Controllers.BISchool
                 foreach (var item in schoolAssists)
                 {
                     var response = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(item.id, new PartitionKey("ProductSum"));
-                    if (response.Status == 200)
+                    if (response.StatusCode == HttpStatusCode.OK)
                     {
-                        using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                        using var json = await JsonDocument.ParseAsync(response.Content);
                         if (json.RootElement.TryGetProperty("serial", out JsonElement serial) && !serial.ValueKind.Equals(JsonValueKind.Null))
                             item.serial = serial.ToObject<List<SchoolProductSumData>>().Select(x => x.prodCode).ToList();
                         if (json.RootElement.TryGetProperty("service", out JsonElement service) && !service.ValueKind.Equals(JsonValueKind.Null))
@@ -732,7 +729,7 @@ namespace TEAMModelBI.Controllers.BISchool
                 //    var response = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(school.id, new PartitionKey("ProductSum"));
                 //    if (response.Status == 200)
                 //    {
-                //        using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                //        using var json = await JsonDocument.ParseAsync(response.Content);
                 //        if (json.RootElement.TryGetProperty("serial", out JsonElement serial) && !serial.ValueKind.Equals(JsonValueKind.Null))
                 //        {
                 //            school.serial = serial.ToObject<List<SchoolProductSumData>>().Select(x => x.prodCode).ToList();
@@ -833,7 +830,7 @@ namespace TEAMModelBI.Controllers.BISchool
                         if ($"{order}".Equals("desc"))
                             sqlTxt.Append(" order by c.createTime desc");
 
-                        await foreach (var itemSchool in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<AssistSchool>(queryText: sqlTxt.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
+                        await foreach (var itemSchool in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIteratorSql<AssistSchool>(queryText: sqlTxt.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
                         {
                             schoolAssists.Add(itemSchool);
                         }
@@ -846,9 +843,9 @@ namespace TEAMModelBI.Controllers.BISchool
 
                     scCnt = await CommonFind.GetSqlValueCount(cosmosClient, "School", scCntSql.ToString(), "Base");
 
-                    await foreach (var itemSchool in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: stringBuilder.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
+                    await foreach (var itemSchool in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIteratorSql(queryText: stringBuilder.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
                     {
-                        using var json = await JsonDocument.ParseAsync(itemSchool.ContentStream);
+                        using var json = await JsonDocument.ParseAsync(itemSchool.Content);
                         if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetInt16() > 0)
                         {
                             foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
@@ -862,9 +859,9 @@ namespace TEAMModelBI.Controllers.BISchool
                 foreach (var item in schoolAssists)
                 {
                     var response = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(item.id, new PartitionKey("ProductSum"));
-                    if (response.Status == 200)
+                    if (response.StatusCode == HttpStatusCode.OK)
                     {
-                        using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                        using var json = await JsonDocument.ParseAsync(response.Content);
                         if (json.RootElement.TryGetProperty("serial", out JsonElement serial) && !serial.ValueKind.Equals(JsonValueKind.Null))
                             item.serial = serial.ToObject<List<SchoolProductSumData>>().Select(x => x.prodCode).ToList();
                         if (json.RootElement.TryGetProperty("service", out JsonElement service) && !service.ValueKind.Equals(JsonValueKind.Null))
@@ -899,9 +896,9 @@ namespace TEAMModelBI.Controllers.BISchool
             foreach (var temp in schoolAssists)
             {
                 var response = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(temp.id, new PartitionKey("ProductSum"));
-                if (response.Status == 200)
+                if (response.StatusCode == HttpStatusCode.OK)
                 {
-                    using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                    using var json = await JsonDocument.ParseAsync(response.Content);
                     if (json.RootElement.TryGetProperty("serial", out JsonElement serial) && !serial.ValueKind.Equals(JsonValueKind.Null))
                     {
                         temp.serial = serial.ToObject<List<SchoolProductSumData>>().Select(x => x.prodCode).ToList();
@@ -944,9 +941,9 @@ namespace TEAMModelBI.Controllers.BISchool
                 var cosmosClient = _azureCosmos.GetCosmosClient();
                 //if ($"{site}".Equals(BIConst.Global))
                 //    cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.Global);
-                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: managerSql, requestOptions: new QueryRequestOptions() { }))
+                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIteratorSql(queryText: managerSql, requestOptions: new QueryRequestOptions() { }))
                 {
-                    using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                    using var json = await JsonDocument.ParseAsync(item.Content);
                     foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
                     {
                         string id = obj.GetProperty("id").GetString(); //管理员ID
@@ -971,9 +968,9 @@ namespace TEAMModelBI.Controllers.BISchool
                 //管理模组学校
                 List<string> baseModuleSchoos = new List<string>();
                 string baseWhereOption = (!string.IsNullOrEmpty(schoolId)) ? $" and c.id='{schoolId}'" : string.Empty;
-                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: $"select c.id from c join serviceProduct in c.service.product where serviceProduct.prodCode = 'IPDYZYLC' {baseWhereOption}", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Product") }))
+                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIteratorSql(queryText: $"select c.id from c join serviceProduct in c.service.product where serviceProduct.prodCode = 'IPDYZYLC' {baseWhereOption}", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Product") }))
                 {
-                    using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                    using var json = await JsonDocument.ParseAsync(item.Content);
                     foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
                     {
                         string tempSchoolId = obj.GetProperty("id").GetString();  //学校ID
@@ -984,9 +981,9 @@ namespace TEAMModelBI.Controllers.BISchool
                 //学校信息
                 List<object> schools = new List<object>();
                 string schoolWhereOption = (!string.IsNullOrEmpty(schoolId)) ? $" where c.id='{schoolId}'" : string.Empty;
-                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: $"select c.id,c.name,c.period,c.schoolCode,c.region,c.province,c.city,c.picture from c {schoolWhereOption}", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
+                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIteratorSql(queryText: $"select c.id,c.name,c.period,c.schoolCode,c.region,c.province,c.city,c.picture from c {schoolWhereOption}", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
                 {
-                    using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                    using var json = await JsonDocument.ParseAsync(item.Content);
                     foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
                     {
                         dynamic schoolExpando = new ExpandoObject();
@@ -1107,8 +1104,8 @@ namespace TEAMModelBI.Controllers.BISchool
                         
                         //計算學校版本
                         List<SchoolProductSumData> services = new List<SchoolProductSumData>();
-                        Azure.Response productSumResponse = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync($"{_schoolId}", new PartitionKey("ProductSum"));
-                        if (productSumResponse.Status == 200)
+                        ResponseMessage productSumResponse = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync($"{_schoolId}", new PartitionKey("ProductSum"));
+                        if (productSumResponse.StatusCode == HttpStatusCode.OK)
                         {
                             var doc = JsonDocument.Parse(productSumResponse.Content);
                             if (doc.RootElement.TryGetProperty("service", out JsonElement service))
@@ -1129,7 +1126,7 @@ namespace TEAMModelBI.Controllers.BISchool
                         //修改学校教师关联的信息
                         string sql = $"SELECT distinct value(c) FROM c join A1 in c.schools where A1.schoolId='{tempShool.id}'";
                         List<Teacher> teachers = new();
-                        await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<Teacher>(sql, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey("Base") }))
+                        await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIteratorSql<Teacher>(sql, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey("Base") }))
                         {
                             teachers.Add(item);
                         }
@@ -1148,9 +1145,9 @@ namespace TEAMModelBI.Controllers.BISchool
                         //学校信息中间件更新
                         BIRelation biRel = new();
                         var respRel = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync(tempShool.id, new PartitionKey("BIRel"));
-                        if (respRel.Status == 200)
+                        if (respRel.StatusCode == HttpStatusCode.OK)
                         {
-                            using var fileJson = await JsonDocument.ParseAsync(respRel.ContentStream);
+                            using var fileJson = await JsonDocument.ParseAsync(respRel.Content);
                             biRel = fileJson.ToObject<BIRelation>();
                         }
                         else
@@ -1191,7 +1188,7 @@ namespace TEAMModelBI.Controllers.BISchool
                             biRel.assists = idInfos;
                         }
 
-                        if (respRel.Status == 200)
+                        if (respRel.StatusCode == HttpStatusCode.OK)
                         {
                             await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync<BIRelation>(biRel, biRel.id, new PartitionKey("BIRel"));
                         }
@@ -1264,7 +1261,7 @@ namespace TEAMModelBI.Controllers.BISchool
 
                 List<School> schools = new List<School>();
 
-                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<School>(queryText: sqltxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
+                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIteratorSql<School>(queryText: sqltxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
                 {
                     schools.Add(item);
                 }
@@ -1298,7 +1295,7 @@ namespace TEAMModelBI.Controllers.BISchool
             //    cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.Global);
             string sqltxt = $"SELECT * FROM c order by c.id offset {endPosition} limit {pageSize}";
 
-            await foreach (var itemSchool in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<School>(queryText: sqltxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
+            await foreach (var itemSchool in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIteratorSql<School>(queryText: sqltxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
             {
                 AssistSchool schoolAssist = new()
                 {
@@ -1362,7 +1359,7 @@ namespace TEAMModelBI.Controllers.BISchool
                 foreach (var item in scNames)
                 {
                     //查询学校名称是否全字段匹配
-                    await foreach (var sc in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<string>(queryText: $"select value(c.name) from c where c.name='{item}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
+                    await foreach (var sc in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIteratorSql<string>(queryText: $"select value(c.name) from c where c.name='{item}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
                     {
                         existScNames.Add(item);
                     }
@@ -1402,16 +1399,16 @@ namespace TEAMModelBI.Controllers.BISchool
                 {
                     //查询区是否存在
                     var respAreaId = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").ReadItemStreamAsync($"{item}", new PartitionKey("Base-Area"));
-                    if (respAreaId.Status != 200)
+                    if (respAreaId.StatusCode != HttpStatusCode.OK)
                     {
                         noAreaIds.Add(item);
                     }
 
                     //查询去是否同步省平台
                     var responseSet = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").ReadItemStreamAsync($"{item}", new PartitionKey("AreaSetting"));
-                    if (responseSet.Status == 200)
+                    if (responseSet.StatusCode == HttpStatusCode.OK)
                     {
-                        using var fileJson = await JsonDocument.ParseAsync(responseSet.ContentStream);
+                        using var fileJson = await JsonDocument.ParseAsync(responseSet.Content);
                         AreaSetting delSet = fileJson.ToObject<AreaSetting>();
                         if (!string.IsNullOrEmpty(delSet.accessConfig))
                             synPro.Add(item);
@@ -1428,7 +1425,7 @@ namespace TEAMModelBI.Controllers.BISchool
                 {
                     createSchoolInfo = await SchoolCode.GenerateSchoolCode(createSchoolInfo, _dingDing, _environment);
                     var schoolStatu = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync($"{createSchoolInfo.id}", new PartitionKey($"Base"));
-                    if (schoolStatu.Status != 200) tempStaus = false;
+                    if (schoolStatu.StatusCode != HttpStatusCode.OK) tempStaus = false;
                     else createSchoolInfo.createCount = createSchoolInfo.createCount >= 3 ? createSchoolInfo.createCount = 3 : createSchoolInfo.createCount += 1;
                 } while (tempStaus);
                 createScInfo.Add(createSchoolInfo);
@@ -1462,7 +1459,7 @@ namespace TEAMModelBI.Controllers.BISchool
             foreach (BISchool bISchool in bISchools)
             {
                 //查询学校名称是否全字段匹配
-                await foreach (var sc in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<string>(queryText: $"select value(c.name) from c where c.name='{bISchool.name}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
+                await foreach (var sc in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIteratorSql<string>(queryText: $"select value(c.name) from c where c.name='{bISchool.name}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
                 {
                     existScNames.Add(bISchool);
                 }
@@ -1495,16 +1492,16 @@ namespace TEAMModelBI.Controllers.BISchool
                 {
                     //查询区是否存在
                     var respAreaId = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").ReadItemStreamAsync($"{bISchool.areaId}", new PartitionKey("Base-Area"));
-                    if (respAreaId.Status != 200)
+                    if (respAreaId.StatusCode != HttpStatusCode.OK)
                     {
                         noAreaIds.Add(bISchool);
                     }
 
                     //查询去是否同步省平台
                     var responseSet = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").ReadItemStreamAsync($"{bISchool.areaId}", new PartitionKey("AreaSetting"));
-                    if (responseSet.Status == 200)
+                    if (responseSet.StatusCode == HttpStatusCode.OK)
                     {
-                        using var fileJson = await JsonDocument.ParseAsync(responseSet.ContentStream);
+                        using var fileJson = await JsonDocument.ParseAsync(responseSet.Content);
                         AreaSetting delSet = fileJson.ToObject<AreaSetting>();
                         if (!string.IsNullOrEmpty(delSet.accessConfig))
                             synPro.Add(bISchool);
@@ -1527,7 +1524,7 @@ namespace TEAMModelBI.Controllers.BISchool
                 {
                     createSchoolInfo = await SchoolCode.GenerateSchoolCode(createSchoolInfo, _dingDing, _environment);
                     var schoolStatu = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync($"{createSchoolInfo.id}", new PartitionKey($"Base"));
-                    if (schoolStatu.Status != 200) tempStaus = false;
+                    if (schoolStatu.StatusCode != HttpStatusCode.OK) tempStaus = false;
                     else createSchoolInfo.createCount = createSchoolInfo.createCount >= 3 ? createSchoolInfo.createCount = 3 : createSchoolInfo.createCount += 1;
                 } while (tempStaus);
                 bISchool.id = createSchoolInfo.id;
@@ -1569,9 +1566,9 @@ namespace TEAMModelBI.Controllers.BISchool
                         if (tempTeacher != null)
                         {
                             var response = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync($"{msId}", new PartitionKey($"Teacher-{scId}"));
-                            if (response.Status == 200)
+                            if (response.StatusCode == HttpStatusCode.OK)
                             {
-                                using var tchJson = await JsonDocument.ParseAsync(response.ContentStream);
+                                using var tchJson = await JsonDocument.ParseAsync(response.Content);
                                 SchoolTeacher tchSc = tchJson.ToObject<SchoolTeacher>();
                                 if (tchSc.roles.Contains("admin"))
                                 {
@@ -1617,9 +1614,9 @@ namespace TEAMModelBI.Controllers.BISchool
 
                             Teacher teacher = new() { id = coreUser.id, name = coreUser.name, picture = coreUser.picture, pk = "Base", code = "Base", size = 1, createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() };
                             var responseSc = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(scId, new PartitionKey("Base"));
-                            if (responseSc.Status == 200)
+                            if (responseSc.StatusCode == HttpStatusCode.OK)
                             {
-                                using var tchJson = await JsonDocument.ParseAsync(responseSc.ContentStream);
+                                using var tchJson = await JsonDocument.ParseAsync(responseSc.Content);
                                 School scInfo = tchJson.ToObject<School>();
                                 teacher.schools.Add(new() { schoolId = scInfo.id, name = scInfo.name, status = "join", time = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(), picture = scInfo.picture, areaId = scInfo.areaId });
                             }
@@ -1671,9 +1668,9 @@ namespace TEAMModelBI.Controllers.BISchool
             {
                 School school = new();
                 var resSc = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync($"{item.id}", new PartitionKey("Base"));
-                if (resSc.Status == 200)
+                if (resSc.StatusCode == HttpStatusCode.OK)
                 {
-                    using var sJson = await JsonDocument.ParseAsync(resSc.ContentStream);
+                    using var sJson = await JsonDocument.ParseAsync(resSc.Content);
                     school = sJson.ToObject<School>();
                     //CoreUser coreUser = await _coreAPIHttpService.GetUserInfo(new Dictionary<string, string> { { "key", $"19940828843" } }, _option.Location, _configuration);
                     var content = new StringContent(item.mobiles.ToArray().ToJsonString(), Encoding.UTF8, "application/json");
@@ -1683,14 +1680,14 @@ namespace TEAMModelBI.Controllers.BISchool
                     foreach (var tmd in tmdInfos)
                     {
                         var respone = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemStreamAsync($"{tmd.id}", new PartitionKey("Base"));
-                        if (respone.Status == 200)
+                        if (respone.StatusCode == HttpStatusCode.OK)
                         {
-                            using var tchJson = await JsonDocument.ParseAsync(respone.ContentStream);
+                            using var tchJson = await JsonDocument.ParseAsync(respone.Content);
                             teacher = tchJson.ToObject<Teacher>();
                             var response = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync($"{tmd.id}", new PartitionKey($"Teacher-{item.id}"));
-                            if (response.Status == 200)
+                            if (response.StatusCode == HttpStatusCode.OK)
                             {
-                                using var scTchJson = await JsonDocument.ParseAsync(response.ContentStream);
+                                using var scTchJson = await JsonDocument.ParseAsync(response.Content);
                                 SchoolTeacher tchSc = scTchJson.ToObject<SchoolTeacher>();
                                 if (tchSc.roles.Contains("admin"))
                                 {
@@ -1779,6 +1776,112 @@ namespace TEAMModelBI.Controllers.BISchool
             return Ok(new { state = RespondCode.Ok, error });
         }
 
+        /// <summary>
+        /// 根據地理位置搜尋學校基本訊息
+        /// </summary>
+        /// <param name="GenerateCouponRequest"></param>
+        /// <returns></returns>
+        //[AuthToken(Roles = "admin,rdc,assist,sales")]
+        [HttpPost("get-school-basic-info")]
+        public async Task<IActionResult> GetSchoolBasicInfo(SchoolDataRequest request)
+        {
+            try
+            {
+                string url = _configuration.GetValue<string>("HaBookAuth:CoreAPI");
+                string AccessToken = await getCoreAccessToken();
+                var client = _http.CreateClient();
+                client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", AccessToken);
+                HttpResponseMessage response = await client.PostAsJsonAsync($"{url}/Service/SchoolData", request);
+                if (response.StatusCode == HttpStatusCode.OK)
+                {
+                    string jsonStr = await response.Content.ReadAsStringAsync();
+                    var options1 = new JsonSerializerOptions
+                    {
+                        Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping
+                    };
+
+                    
+                    return Ok(jsonStr.ToObject<JsonElement>());
+                }
+                else
+                {
+                    return BadRequest();
+                }
+            }
+            catch (Exception ex)
+            {
+                return BadRequest();
+            }
+        }
+
+        /// <summary>
+        /// 弱歸戶
+        /// </summary>
+        /// <param name="GenerateCouponRequest"></param>
+        /// <returns></returns>
+        //[AuthToken(Roles = "admin,rdc,assist,sales")]
+        [HttpPost("upd-user-schoolw")]
+        public async Task<IActionResult> UpdUserSchoolW(UpdateUserSchoolCodeWRequest request)
+        {
+            try
+            {
+                string url = _configuration.GetValue<string>("HaBookAuth:CoreAPI");
+                string AccessToken = await getCoreAccessToken();
+                var client = _http.CreateClient();
+                client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", AccessToken);
+                HttpResponseMessage response = await client.PostAsJsonAsync($"{url}/Service/UpdateUserSchoolCodeW", request);
+                if (response.StatusCode == HttpStatusCode.OK)
+                {
+                    string jsonStr = await response.Content.ReadAsStringAsync();
+                    var options1 = new JsonSerializerOptions
+                    {
+                        Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping
+                    };
+
+
+                    return Ok(jsonStr.ToObject<JsonElement>());
+                }
+                else
+                {
+                    return BadRequest();
+                }
+            }
+            catch (Exception ex)
+            {
+                return BadRequest();
+            }
+        }
+
+        private async Task<string> getCoreAccessToken()
+        {
+            string AccessToken = "";
+            try
+            {
+                string Url = _configuration.GetValue<string>("HaBookAuth:CoreAPI") + "/oauth2/token";
+                string GrantType = "device";
+                string ClientID = _configuration.GetValue<string>("HaBookAuth:CoreService:clientID");
+                string Secret = _configuration.GetValue<string>("HaBookAuth:CoreService:clientSecret");
+                var content = new { grant_type = GrantType, client_id = ClientID, client_secret = Secret };
+                var response = await _http.CreateClient().PostAsJsonAsync($"{Url}", content);
+                if (response.IsSuccessStatusCode)
+                {
+                    string responseBody = response.Content.ReadAsStringAsync().Result;
+                    using (JsonDocument document = JsonDocument.Parse(responseBody.ToString()))
+                    {
+                        if (document.RootElement.TryGetProperty("access_token", out JsonElement AccessTokenObj))
+                        {
+                            AccessToken = AccessTokenObj.ToString();
+                        }
+                    }
+                }
+                return AccessToken;
+            }
+            catch (Exception ex)
+            {
+                return AccessToken;
+            }
+        }
+
         #region   预设学校基础信息 多语言
 
         /// <summary>
@@ -2017,5 +2120,20 @@ namespace TEAMModelBI.Controllers.BISchool
             public string name { get; set; }
             public List<string> mobiles { get; set; }
         }
+
+        public record SchoolDataRequest
+        (
+            string countryId,
+            string provinceId,
+            string cityId,
+            string shortCode,
+            bool fullData = false
+        );
+
+        public record UpdateUserSchoolCodeWRequest
+        (
+            [Required] List<string> ids,
+            [Required] string schoolDocId
+        );
     }
 }

+ 3 - 3
TEAMModelBI/Controllers/BISchool/RoomController.cs

@@ -1,4 +1,4 @@
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Mvc;
 using Microsoft.Extensions.Configuration;
@@ -70,9 +70,9 @@ namespace TEAMModelBI.Controllers.BISchool
                 //}
 
                 var response = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync($"{roomId}", new PartitionKey($"{roomCode}"));
-                if (response.Status == 200)
+                if (response.StatusCode == System.Net.HttpStatusCode.OK)
                 {
-                    using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                    using var json = await JsonDocument.ParseAsync(response.Content);
                     Room roomInfo = json.ToObject<Room>();
                     roomInfo.serial = string.IsNullOrEmpty($"{serial}") ? null : $"{serial}";
 

+ 190 - 91
TEAMModelBI/Controllers/BISchool/SchoolController.cs

@@ -1,5 +1,4 @@
-using Azure.Cosmos;
-using HTEXLib.COMM.Helpers;
+using Microsoft.Azure.Cosmos;
 using MathNet.Numerics.LinearAlgebra.Double;
 using Microsoft.AspNetCore.Hosting;
 using Microsoft.AspNetCore.Http;
@@ -107,9 +106,9 @@ namespace TEAMModelBI.Controllers.BISchool
                     sqltxt.Append($" WHERE c.pk='School' and (c.areaId = '' or c.areaId = null or IS_DEFINED(c.areaId) = false)");
 
                 List<NotAreaSchool> tempNotAreaSchools = new();
-                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: sqltxt.ToString(), continuationToken: pageToken, requestOptions: new QueryRequestOptions() { MaxItemCount = pageSize, PartitionKey = new PartitionKey("Base") }))
+                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIteratorSql(queryText: sqltxt.ToString(), continuationToken: pageToken, requestOptions: new QueryRequestOptions() { MaxItemCount = pageSize, PartitionKey = new PartitionKey("Base") }))
                 {
-                    using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                    using var json = await JsonDocument.ParseAsync(item.Content);
                     if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
                     {
                         foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
@@ -137,7 +136,7 @@ namespace TEAMModelBI.Controllers.BISchool
 
                         if (iscontinuation)
                         {
-                            continuationToken = item.GetContinuationToken();
+                            continuationToken = item.ContinuationToken;
                             break;
                         }
                     }
@@ -187,9 +186,9 @@ namespace TEAMModelBI.Controllers.BISchool
                 List<NotAreaSchool> notAreaSchools = new();
                 foreach (string pk in partitionKeys)
                 {
-                    await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: sqltxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"{pk}") }))
+                    await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIteratorSql(queryText: sqltxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"{pk}") }))
                     {
-                        using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                        using var json = await JsonDocument.ParseAsync(item.Content);
                         if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
                         {
                             foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
@@ -276,9 +275,9 @@ namespace TEAMModelBI.Controllers.BISchool
                 //}
 
                 var responseSet = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").ReadItemStreamAsync($"{_areaId}", new PartitionKey("AreaSetting"));
-                if (responseSet.Status == 200)
+                if (responseSet.StatusCode == HttpStatusCode.OK)
                 {
-                    using var fileJson = await JsonDocument.ParseAsync(responseSet.ContentStream);
+                    using var fileJson = await JsonDocument.ParseAsync(responseSet.Content);
                     AreaSetting delSet = fileJson.ToObject<AreaSetting>();
                     if (!string.IsNullOrEmpty(delSet.accessConfig))
                         return Ok(new { state = 401, msg = "区域已经规定了,不能切换能能力" });
@@ -309,7 +308,7 @@ namespace TEAMModelBI.Controllers.BISchool
 
                             msg.Append($"{school.name}【{school.id}】学校移除多区域的名单:");
                             List<Teacher> teachers = new();
-                            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<Teacher>(queryText: $"SELECT value(c) FROM c join s in c.schools where s.schoolId ='{school.id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
+                            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIteratorSql<Teacher>(queryText: $"SELECT value(c) FROM c join s in c.schools where s.schoolId ='{school.id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
                             {
                                 teachers.Add(item);
                             }
@@ -369,7 +368,7 @@ namespace TEAMModelBI.Controllers.BISchool
 
                 AssistSchool schoolAssists = new(); //返回学校列表集合
                 string sqlTxt = $"select c.id,c.code,c.schoolCode,c.name,c.region,c.province,c.city,c.dist,c.size,c.address,c.picture,c.type,c.scale,c.areaId,c.standard,c.period,c.campuses from c where c.id='{schoolId}'";
-                await foreach (var itemSchool in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<AssistSchool>(queryText: sqlTxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
+                await foreach (var itemSchool in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIteratorSql<AssistSchool>(queryText: sqlTxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
                 {
                     schoolAssists = itemSchool;
                 }
@@ -377,9 +376,9 @@ namespace TEAMModelBI.Controllers.BISchool
                 if (schoolAssists.id != null)
                 {
                     var response = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(schoolAssists.id, new PartitionKey("ProductSum"));
-                    if (response.Status == 200)
+                    if (response.StatusCode == HttpStatusCode.OK)
                     {
-                        using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                        using var json = await JsonDocument.ParseAsync(response.Content);
                         if (json.RootElement.TryGetProperty("serial", out JsonElement serial) && !serial.ValueKind.Equals(JsonValueKind.Null))
                         {
                             schoolAssists.serial = serial.ToObject<List<SchoolProductSumData>>().Select(x => x.prodCode).ToList();
@@ -402,7 +401,7 @@ namespace TEAMModelBI.Controllers.BISchool
                 //無實體學校 => 取得虛擬學校
                 else
                 {
-                    await foreach (var itemSchool in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<AssistSchool>(queryText: sqlTxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("VirtualBase") }))
+                    await foreach (var itemSchool in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIteratorSql<AssistSchool>(queryText: sqlTxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("VirtualBase") }))
                     {
                         schoolAssists = itemSchool;
                     }
@@ -443,11 +442,11 @@ namespace TEAMModelBI.Controllers.BISchool
                 string _auth = HttpContext.GetXAuth("AuthToken");
                 var (tmdId, tmdName, pic, did, dname, dpic) = HttpJwtAnalysis.JwtXAuthBI(_auth, _option);
                 var response = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(school.id, new PartitionKey($"Base"));
-                if (response.Status == 200)
+                if (response.StatusCode == HttpStatusCode.OK)
                 {
                     string sql = $"SELECT distinct value(c) FROM c join A1 in c.schools where A1.schoolId='{school.id}'";
                     List<Teacher> teachers = new();
-                    await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<Teacher>(sql, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey("Base") }))
+                    await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIteratorSql<Teacher>(sql, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey("Base") }))
                     {
                         teachers.Add(item);
                     }
@@ -500,16 +499,16 @@ namespace TEAMModelBI.Controllers.BISchool
             {
                 School school = new();
                 var response = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(sid, new PartitionKey("Base"));
-                if (response.Status == 200)
+                if (response.StatusCode == HttpStatusCode.OK)
                 {
-                    using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                    using var json = await JsonDocument.ParseAsync(response.Content);
                     school = json.ToObject<School>();
                 }
 
                 long teach = 0;
-                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: $"SELECT sum(c.size) as size FROM c ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Teacher-{sid}") }))
+                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIteratorSql(queryText: $"SELECT sum(c.size) as size FROM c ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Teacher-{sid}") }))
                 {
-                    var json = await JsonDocument.ParseAsync(item.ContentStream);
+                    var json = await JsonDocument.ParseAsync(item.Content);
                     foreach (var elmt in json.RootElement.GetProperty("Documents").EnumerateArray())
                     {
                         if (elmt.TryGetProperty("size", out JsonElement _size) && _size.ValueKind.Equals(JsonValueKind.Number))
@@ -720,7 +719,7 @@ namespace TEAMModelBI.Controllers.BISchool
             //    cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.Global);
 
             List<BaseInfo> scManages = new();
-            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<BaseInfo>(queryText: $"select c.id,c.name,c.picture from c where ARRAY_CONTAINS(c.roles,'admin',true) and c.code='Teacher-{scId}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Teacher-{scId}") }))
+            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIteratorSql<BaseInfo>(queryText: $"select c.id,c.name,c.picture from c where ARRAY_CONTAINS(c.roles,'admin',true) and c.code='Teacher-{scId}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Teacher-{scId}") }))
             {
                 scManages.Add(item);
             }
@@ -768,9 +767,9 @@ namespace TEAMModelBI.Controllers.BISchool
                 {
                     var resScInfo = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync($"{schoolId}", new PartitionKey("Base"));
 
-                    if (resScInfo.Status == 200)
+                    if (resScInfo.StatusCode == HttpStatusCode.OK)
                     {
-                        using var tchJson = await JsonDocument.ParseAsync(resScInfo.ContentStream);
+                        using var tchJson = await JsonDocument.ParseAsync(resScInfo.Content);
                         School scInfo = tchJson.ToObject<School>();
                         areaId = scInfo.areaId;
                     }
@@ -781,9 +780,9 @@ namespace TEAMModelBI.Controllers.BISchool
                 Teacher teacher = new();
                 SchoolTeacher schoolTeacher = new();
                 var resTeacher = await cosmosClient.GetContainer("TEAMModelOS", "Teacher").ReadItemStreamAsync($"{tmdId}", new PartitionKey($"Base"));
-                if (resTeacher.Status == 200)
+                if (resTeacher.StatusCode == HttpStatusCode.OK)
                 {
-                    using var tchJson = await JsonDocument.ParseAsync(resTeacher.ContentStream);
+                    using var tchJson = await JsonDocument.ParseAsync(resTeacher.Content);
                     teacher = tchJson.ToObject<Teacher>();
 
                     var existArea = teacher.schools.Find(f => f.schoolId.Equals($"{schoolId}"));
@@ -812,9 +811,9 @@ namespace TEAMModelBI.Controllers.BISchool
                 if (teacher != null)
                 {
                     var response = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync($"{tmdId}", new PartitionKey($"Teacher-{schoolId}"));
-                    if (response.Status == 200)
+                    if (response.StatusCode == HttpStatusCode.OK)
                     {
-                        using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                        using var json = await JsonDocument.ParseAsync(response.Content);
                         schoolTeacher = json.ToObject<SchoolTeacher>();
                         if (!schoolTeacher.roles.Contains("admin"))
                         {
@@ -822,6 +821,12 @@ namespace TEAMModelBI.Controllers.BISchool
                             schoolTeacher.roles.Add("admin");
                             schoolTeacher.status = "join";
                             schoolTeacher = await cosmosClient.GetContainer("TEAMModelOS", "School").ReplaceItemAsync<SchoolTeacher>(schoolTeacher, schoolTeacher.id, new PartitionKey($"Teacher-{schoolId}"));
+
+                            #region 同時更新teacher的school.status
+                            var school = teacher.schools.Find(f => f.schoolId.Equals($"{schoolId}"));
+                            school.status = "join";
+                            await cosmosClient.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync<Teacher>(teacher, teacher.id, new PartitionKey("Base"));                            
+                            #endregion
                             strMsg.Append($"并设置管理员,学校信息{schoolName}【{schoolId}】");
                         }
                         else
@@ -888,9 +893,9 @@ namespace TEAMModelBI.Controllers.BISchool
             if (rmvFromSc) //從老師的學校列表移除該學校
             {
                 var response = await cosmosClient.GetContainer("TEAMModelOS", "Teacher").ReadItemStreamAsync($"{tmdId}", new PartitionKey("Base"));
-                if (response.Status == 200)
+                if (response.StatusCode == HttpStatusCode.OK)
                 {
-                    using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                    using var json = await JsonDocument.ParseAsync(response.Content);
                     Teacher teacher = json.ToObject<Teacher>();
                     teacher.schools.RemoveAll(s => scIds.Contains(s.schoolId));
                     await cosmosClient.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync<Teacher>(teacher, teacher.id, new PartitionKey("Base"));
@@ -901,7 +906,7 @@ namespace TEAMModelBI.Controllers.BISchool
             foreach (var scId in scIds)
             {
                 var response = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync($"{tmdId}", new PartitionKey($"Teacher-{scId}"));
-                if (response.Status == 200)
+                if (response.StatusCode == HttpStatusCode.OK)
                 {
                     if (rmvFromSc) //將該老師從學校的老師名單中移除
                     {
@@ -911,7 +916,7 @@ namespace TEAMModelBI.Controllers.BISchool
                     }
                     else
                     {
-                        using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                        using var json = await JsonDocument.ParseAsync(response.Content);
                         scTeacher = json.ToObject<SchoolTeacher>();
                         if (scTeacher.roles.Contains("admin"))
                         {
@@ -963,9 +968,9 @@ namespace TEAMModelBI.Controllers.BISchool
                 if (schools.Count > 0)
                 {
                     var resTeacher = await cosmosClient.GetContainer("TEAMModelOS", "Teacher").ReadItemStreamAsync($"{tmdId}", new PartitionKey($"Base"));
-                    if (resTeacher.Status == 200)
+                    if (resTeacher.StatusCode == HttpStatusCode.OK)
                     {
-                        using var tchJson = await JsonDocument.ParseAsync(resTeacher.ContentStream);
+                        using var tchJson = await JsonDocument.ParseAsync(resTeacher.Content);
                         teacher = tchJson.ToObject<Teacher>();
                     }
                     else
@@ -992,9 +997,9 @@ namespace TEAMModelBI.Controllers.BISchool
                             existSchool.name = school.name;
 
                         var response = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync($"{tmdId}", new PartitionKey($"Teacher-{school.id}"));
-                        if (response.Status == 200)
+                        if (response.StatusCode == HttpStatusCode.OK)
                         {
-                            using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                            using var json = await JsonDocument.ParseAsync(response.Content);
                             schoolTeacher = json.ToObject<SchoolTeacher>();
                             if (!schoolTeacher.roles.Contains("admin"))
                             {
@@ -1025,7 +1030,7 @@ namespace TEAMModelBI.Controllers.BISchool
                         msg.Append($"{school.name}[{school.id}]");
                     }
 
-                    if (resTeacher.Status == 200)
+                    if (resTeacher.StatusCode == HttpStatusCode.OK)
                         teacher = await cosmosClient.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync<Teacher>(teacher, teacher.id, new PartitionKey("Base"));
                     else
                         teacher = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").CreateItemAsync<Teacher>(teacher, new PartitionKey("Base"));
@@ -1092,44 +1097,44 @@ namespace TEAMModelBI.Controllers.BISchool
                         List<string> scTchIds = new();
                         List<string> scStuIds = new();
                         string scTecSql = $"select value(c.id) from c where ARRAY_LENGTH(c.roles) > 0 and c.status = 'join'";
-                        await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<string>(queryText: scTecSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Teacher-{tempId}") }))
+                        await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIteratorSql<string>(queryText: scTecSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Teacher-{tempId}") }))
                         {
                             scTchIds.Add(item);
                         }
 
                         string scStuSql = $"select value(c.id) from c";
-                        await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Student").GetItemQueryIterator<string>(queryText: scStuSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-{tempId}") }))
+                        await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Student").GetItemQueryIteratorSql<string>(queryText: scStuSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-{tempId}") }))
                         {
                             scStuIds.Add(item);
                         }
 
                         var response = await cosmosClient.GetContainer("TEAMModelOS", "School").DeleteItemStreamAsync($"{tempId}", new PartitionKey($"Base"));
-                        if (response.Status == 204)
-                            msg.AppendLine($"{tmdName}【{tmdId}】删除学校,删除状态:{response.Status},删除ID:{tempId}");
+                        if (response.StatusCode == HttpStatusCode.NoContent)
+                            msg.AppendLine($"{tmdName}【{tmdId}】删除学校,删除状态:{response.StatusCode},删除ID:{tempId}");
                         else
-                            delSchoolRels.Add(new DelSchoolRel() { id = $"{tempId}", code = "Base", type = 1, status = response.Status });
+                            delSchoolRels.Add(new DelSchoolRel() { id = $"{tempId}", code = "Base", type = 1, status = (int)HttpStatusCode.NoContent });
 
                         //删除学校信息中间
                         var resBiRel = await cosmosClient.GetContainer("TEAMModelOS", "School").DeleteItemStreamAsync($"{tempId}", new PartitionKey($"BIRel"));
-                        if (resBiRel.Status == 204)
-                            msg.AppendLine($"{tmdName}【{tmdId}】删除学校信息中间件,删除状态:{resBiRel.Status},删除ID:{tempId}");
+                        if (resBiRel.StatusCode == HttpStatusCode.NoContent)
+                            msg.AppendLine($"{tmdName}【{tmdId}】删除学校信息中间件,删除状态:{resBiRel.StatusCode},删除ID:{tempId}");
                         else
-                            delSchoolRels.Add(new DelSchoolRel() { id = $"{tempId}", code = "Base", type = 1, status = response.Status });
+                            delSchoolRels.Add(new DelSchoolRel() { id = $"{tempId}", code = "Base", type = 1, status = (int)response.StatusCode });
 
                         foreach (var item in scTchIds)
                         {
                             //学校教师信息
                             var tchRespnse = await cosmosClient.GetContainer("TEAMModelOS", "School").DeleteItemStreamAsync($"{item}", new PartitionKey($"Teacher-{tempId}"));
-                            if (tchRespnse.Status == 204)
-                                msg.AppendLine($"删除教师,删除状态:{tchRespnse.Status},删除ID:{item}");
+                            if (tchRespnse.StatusCode == HttpStatusCode.NoContent)
+                                msg.AppendLine($"删除教师,删除状态:{tchRespnse.StatusCode},删除ID:{item}");
                             else
-                                delSchoolRels.Add(new DelSchoolRel() { id = $"{item}", code = $"Teacher-{tempId}", type = 2, status = response.Status });
+                                delSchoolRels.Add(new DelSchoolRel() { id = $"{item}", code = $"Teacher-{tempId}", type = 2, status = (int)response.StatusCode });
 
                             //教师基础信息
                             var tchBaseResponse = await cosmosClient.GetContainer("TEAMModelOS", "Teacher").ReadItemStreamAsync($"{item}", new PartitionKey("Base"));
-                            if (tchBaseResponse.Status == 200)
+                            if (tchBaseResponse.StatusCode == HttpStatusCode.OK)
                             {
-                                using var json = await JsonDocument.ParseAsync(tchBaseResponse.ContentStream);
+                                using var json = await JsonDocument.ParseAsync(tchBaseResponse.Content);
                                 Teacher teacher = json.ToObject<Teacher>();
                                 var tempSc = teacher.schools.Find(f => f.schoolId.Equals($"{tempId}"));
                                 if (tempSc != null)
@@ -1139,38 +1144,38 @@ namespace TEAMModelBI.Controllers.BISchool
                                 }
                             }
                             else
-                                delSchoolRels.Add(new DelSchoolRel { id = $"{item}", code = "Base", type = 2, status = response.Status });
+                                delSchoolRels.Add(new DelSchoolRel { id = $"{item}", code = "Base", type = 2, status = (int)response.StatusCode });
                         }
                         //删除学校学生
                         foreach (var item in scStuIds)
                         {
                             var stuRespnse = await cosmosClient.GetContainer("TEAMModelOS", "Student").DeleteItemStreamAsync($"{item}", new PartitionKey($"Base-{tempId}"));
-                            if (stuRespnse.Status == 204)
-                                msg.AppendLine($"删除学生,删除状态:{stuRespnse.Status},删除ID:{item}");
+                            if (stuRespnse.StatusCode == HttpStatusCode.NoContent)
+                                msg.AppendLine($"删除学生,删除状态:{stuRespnse.StatusCode},删除ID:{item}");
                             else
-                                delSchoolRels.Add(new DelSchoolRel() { id = $"{item}", code = $"Base-{tempId}", type = 3, status = response.Status });
+                                delSchoolRels.Add(new DelSchoolRel() { id = $"{item}", code = $"Base-{tempId}", type = 3, status = (int)response.StatusCode });
                         }
                     }
                     //虛擬學校刪除
                     else
                     {
                         var response = await cosmosClient.GetContainer("TEAMModelOS", "School").DeleteItemStreamAsync($"{tempId}", new PartitionKey($"VirtualBase"));
-                        if (response.Status == 204)
-                            msg.AppendLine($"{tmdName}【{tmdId}】删除学校,删除状态:{response.Status},删除ID:{tempId}");
+                        if (response.StatusCode == HttpStatusCode.NoContent)
+                            msg.AppendLine($"{tmdName}【{tmdId}】删除学校,删除状态:{response.StatusCode},删除ID:{tempId}");
                         else
-                            delSchoolRels.Add(new DelSchoolRel() { id = $"{tempId}", code = "VirtualBase", type = 1, status = response.Status });
+                            delSchoolRels.Add(new DelSchoolRel() { id = $"{tempId}", code = "VirtualBase", type = 1, status = (int)response.StatusCode });
                     }
                 }
 
 
                 //string scTecSql = $"select value(c.id) from c where ARRAY_LENGTH(c.roles) > 0 and c.status = 'join'";
-                //await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<string>(queryText: scTecSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Teacher-{schoolId}") }))
+                //await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIteratorSql<string>(queryText: scTecSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Teacher-{schoolId}") }))
                 //{
                 //    scTchIds.Add(item);
                 //}
 
                 //string scStuSql = $"select value(c.id) from c";
-                //await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<string>(queryText: scStuSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-{schoolId}") }))
+                //await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIteratorSql<string>(queryText: scStuSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-{schoolId}") }))
                 //{
                 //    scStuIds.Add(item);
                 //}
@@ -1262,9 +1267,9 @@ namespace TEAMModelBI.Controllers.BISchool
             if (schoolInfo != null)
             {
                 var response = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(schoolInfo.id, new PartitionKey("ProductSum"));
-                if (response.Status == 200)
+                if (response.StatusCode == HttpStatusCode.OK)
                 {
-                    using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                    using var json = await JsonDocument.ParseAsync(response.Content);
                     if (json.RootElement.TryGetProperty("serial", out JsonElement serial) && !serial.ValueKind.Equals(JsonValueKind.Null))
                         schoolInfo.serial = serial.ToObject<List<ProductSumInfos>>();
 
@@ -1339,9 +1344,9 @@ namespace TEAMModelBI.Controllers.BISchool
 
             RecSchool recSchool = new();
             var response = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync($"{schoolId}", new PartitionKey("Base"));
-            if (response.Status == 200)
+            if (response.StatusCode == HttpStatusCode.OK)
             {
-                using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                using var json = await JsonDocument.ParseAsync(response.Content);
                 recSchool = json.ToObject<RecSchool>();
             }
             else return Ok(new { state = RespondCode.NotFound, msg = "未找到该学校" });
@@ -1452,7 +1457,7 @@ namespace TEAMModelBI.Controllers.BISchool
 
             //获取当前学期所有的课程记录
             List<LessAnalyse> records = new List<LessAnalyse>();
-            await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<LessAnalyse>(queryText: $"select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"LessonRecord-{schoolId}") }))
+            await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIteratorSql<LessAnalyse>(queryText: $"select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"LessonRecord-{schoolId}") }))
             {
                 records.Add(item);
             }
@@ -1465,7 +1470,7 @@ namespace TEAMModelBI.Controllers.BISchool
 
             List<LessonCount> scount = new();
             List<LessonCount> tcount = new();
-            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<LessonCount>(queryText: "select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"LessonCount-{schoolId}-{year}") }))
+            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIteratorSql<LessonCount>(queryText: "select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"LessonCount-{schoolId}-{year}") }))
             {
                 scount.Add(item);
             }
@@ -1474,7 +1479,7 @@ namespace TEAMModelBI.Controllers.BISchool
             foreach (var tId in teacIds)
             {
                 var sqlTxtt = $"select value(c) from c where c.id='{tId}'";
-                await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<LessonCount>(queryText: sqlTxtt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"LessonCount-{year}") }))
+                await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIteratorSql<LessonCount>(queryText: sqlTxtt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"LessonCount-{year}") }))
                 {
                     tcount.Add(item);
                 }
@@ -1859,15 +1864,15 @@ namespace TEAMModelBI.Controllers.BISchool
             AnSchool school = new();  //学校基础基础信息
 
             var response = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync($"{schoolId}", new PartitionKey("Base"));
-            if (response.Status == 200)
+            if (response.StatusCode == HttpStatusCode.OK)
             {
-                using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                using var json = await JsonDocument.ParseAsync(response.Content);
                 school = json.ToObject<AnSchool>();
             }
             else return Ok(new { state = RespondCode.NotFound, msg = "未找到该学校" });
             List<LessAnalyse> lessAnalyses = new();
 
-            await foreach (var lessItem in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<LessAnalyse>(queryText: "select c.id,c.code,c.periodId,c.subjectId,c.grade from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"LessonRecord-{school.id}") }))
+            await foreach (var lessItem in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIteratorSql<LessAnalyse>(queryText: "select c.id,c.code,c.periodId,c.subjectId,c.grade from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"LessonRecord-{school.id}") }))
             {
                 lessAnalyses.Add(lessItem);
             }
@@ -1878,9 +1883,9 @@ namespace TEAMModelBI.Controllers.BISchool
             var subCnt = subs.Select(x => new { name = x.key, value = x.count });
 
             var responseProduct = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(school.id, new PartitionKey("ProductSum"));
-            if (responseProduct.Status == 200)
+            if (responseProduct.StatusCode == HttpStatusCode.OK)
             {
-                using var json = await JsonDocument.ParseAsync(responseProduct.ContentStream);
+                using var json = await JsonDocument.ParseAsync(responseProduct.Content);
                 if (json.RootElement.TryGetProperty("serial", out JsonElement _serial) && !_serial.ValueKind.Equals(JsonValueKind.Null))
                 {
                     school.serial = _serial.ToObject<List<SchoolProductSumData>>().Select(x => x.prodCode).ToList();
@@ -1915,7 +1920,7 @@ namespace TEAMModelBI.Controllers.BISchool
             if (!string.IsNullOrEmpty($"{areaId}"))
                 sql.Append($" where c.areaId = '{areaId}'");
 
-            await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS,"School").GetItemQueryIterator<ScBriefInfo>(queryText: sql.ToString(), requestOptions:new QueryRequestOptions() { PartitionKey = new PartitionKey("Base")}))
+            await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS,"School").GetItemQueryIteratorSql<ScBriefInfo>(queryText: sql.ToString(), requestOptions:new QueryRequestOptions() { PartitionKey = new PartitionKey("Base")}))
             {
                 scBriefs.Add(item);
             }
@@ -1981,9 +1986,9 @@ namespace TEAMModelBI.Controllers.BISchool
                         allCnt += await CommonFind.GetSqlValueCount(cosmosClient, "School", serialAllSql, $"Product-{scProd.id}");
 
                         var response = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(scProd.id, new PartitionKey("ProductSum"));
-                        if (response.Status == 200)
+                        if (response.StatusCode == HttpStatusCode.OK)
                         {
-                            using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                            using var json = await JsonDocument.ParseAsync(response.Content);
                             if (json.RootElement.TryGetProperty("serial", out JsonElement serial) && !serial.ValueKind.Equals(JsonValueKind.Null))
                             {
                                 List<string> serials = serial.ToObject<List<SchoolProductSumData>>().Select(x => x.prodCode).ToList();
@@ -2010,7 +2015,7 @@ namespace TEAMModelBI.Controllers.BISchool
                     //    var response = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(scProd.id, new PartitionKey("ProductSum"));
                     //    if (response.Status == 200)
                     //    {
-                    //        using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                    //        using var json = await JsonDocument.ParseAsync(response.Content);
                     //        if (json.RootElement.TryGetProperty("serial", out JsonElement serial) && !serial.ValueKind.Equals(JsonValueKind.Null))
                     //        {
                     //            scProd.serial = serial.ToObject<List<SchoolProductSumData>>().Select(x => x.prodCode).ToList(); 
@@ -2056,9 +2061,9 @@ namespace TEAMModelBI.Controllers.BISchool
 
             List<School> schools = new();
 
-            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: sqlTxt.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
+            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIteratorSql(queryText: sqlTxt.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
             {
-                using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                using var json = await JsonDocument.ParseAsync(item.Content);
                 if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
                 {
                     foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
@@ -2102,9 +2107,9 @@ namespace TEAMModelBI.Controllers.BISchool
 
                 foreach (var school in schools)
                 {
-                    await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: $"SELECT sum(c.size) as size FROM c ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Teacher-{school}") }))
+                    await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIteratorSql(queryText: $"SELECT sum(c.size) as size FROM c ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Teacher-{school}") }))
                     {
-                        var json = await JsonDocument.ParseAsync(item.ContentStream);
+                        var json = await JsonDocument.ParseAsync(item.Content);
                         foreach (var elmt in json.RootElement.GetProperty("Documents").EnumerateArray())
                         {
                             if (elmt.TryGetProperty("size", out JsonElement _size) && _size.ValueKind.Equals(JsonValueKind.Number))
@@ -2297,7 +2302,7 @@ namespace TEAMModelBI.Controllers.BISchool
             List<string> scIds = new();
 
             string mScSql = $"SELECT value(REPLACE(c.code, 'Teacher-', '')) FROM c where array_contains(c.roles,'admin',true) and c.pk='Teacher' and c.id='{tmdId}'";
-            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<string>(queryText: mScSql, requestOptions: new QueryRequestOptions() { }))
+            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIteratorSql<string>(queryText: mScSql, requestOptions: new QueryRequestOptions() { }))
             {
                 scIds.Add(item);
             }
@@ -2345,7 +2350,7 @@ namespace TEAMModelBI.Controllers.BISchool
 
             List<ScSimple> scSimple = new();
 
-            await foreach (var itemSchool in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<ScSimple>(queryText: scSql.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
+            await foreach (var itemSchool in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIteratorSql<ScSimple>(queryText: scSql.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
             {
                 scSimple.Add(itemSchool);
             }
@@ -2412,9 +2417,9 @@ namespace TEAMModelBI.Controllers.BISchool
 
                 ////取得各產品目前可得數量
                 var response = await db.ReadItemStreamAsync(school_code.ToString(), new PartitionKey($"ProductSum"));
-                if (response.Status == 200)
+                if (response.StatusCode == HttpStatusCode.OK)
                 {
-                    using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                    using var json = await JsonDocument.ParseAsync(response.Content);
                     productSum = json.ToObject<SchoolProductSum>();
                     prodinfo = productSum.prodinfo;
                     serviceSum = productSum.service;
@@ -2424,9 +2429,9 @@ namespace TEAMModelBI.Controllers.BISchool
                 List<string> serialPermitList = getSerialPermitProdcodeList();
                 string serialPermitJsonStr = JsonConvert.SerializeObject(serialPermitList);
                 string serialQueryText = $"SELECT * FROM c WHERE c.dataType = 'serial' AND ARRAY_CONTAINS({serialPermitJsonStr}, c.prodCode)";
-                await foreach (var itemsr in db.GetItemQueryStreamIterator(queryText: serialQueryText, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Product-{school_code}") }))
+                await foreach (var itemsr in db.GetItemQueryStreamIteratorSql(queryText: serialQueryText, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Product-{school_code}") }))
                 {
-                    using var json = await JsonDocument.ParseAsync(itemsr.ContentStream);
+                    using var json = await JsonDocument.ParseAsync(itemsr.Content);
                     if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
                     {
                         deviceForCoreService uuidForCore;
@@ -2440,9 +2445,9 @@ namespace TEAMModelBI.Controllers.BISchool
                 //服務
                 List<SchoolProductSumDataService> service = new List<SchoolProductSumDataService>();
                 SchoolProductSum schoolProductSum;
-                await foreach (var items in db.GetItemQueryStreamIterator(queryText: $"SELECT * FROM c WHERE c.id = '{school_code}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ProductSum") }))
+                await foreach (var items in db.GetItemQueryStreamIteratorSql(queryText: $"SELECT * FROM c WHERE c.id = '{school_code}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ProductSum") }))
                 {
-                    using var json = await JsonDocument.ParseAsync(items.ContentStream);
+                    using var json = await JsonDocument.ParseAsync(items.Content);
                     if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
                     {
                         foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
@@ -2459,7 +2464,7 @@ namespace TEAMModelBI.Controllers.BISchool
                     {
                         spOrderRow = new SchoolProductOrder();
                         spOrderRow.prodCode = serviceRow.prodCode;
-                        spOrderRow.avaliable = serviceRow.avaliable;
+                        spOrderRow.avaliable = UTCNow>serviceRow.endDate ? 0 : serviceRow.avaliable;
                         spOrderRow.avaliableStartDate = serviceRow.startDate;
                         spOrderRow.avaliableEndDate = serviceRow.endDate;
                         serviceOrder.Add(spOrderRow);
@@ -2467,9 +2472,9 @@ namespace TEAMModelBI.Controllers.BISchool
                 }
 
                 //硬體
-                await foreach (var itemhd in db.GetItemQueryStreamIterator(queryText: $"SELECT * FROM c WHERE c.dataType = 'hard'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Product-{school_code}") }))
+                await foreach (var itemhd in db.GetItemQueryStreamIteratorSql(queryText: $"SELECT * FROM c WHERE c.dataType = 'hard'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Product-{school_code}") }))
                 {
-                    using var json = await JsonDocument.ParseAsync(itemhd.ContentStream);
+                    using var json = await JsonDocument.ParseAsync(itemhd.Content);
                     if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
                     {
                         foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
@@ -2483,9 +2488,9 @@ namespace TEAMModelBI.Controllers.BISchool
                 ////取得教師分配空間
                 long teach = 0;
                 var querysp = $"SELECT SUM(c.size) as size FROM c";
-                await foreach (var item in db.GetItemQueryStreamIterator(queryText: querysp, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Teacher-{school_code}") }))
+                await foreach (var item in db.GetItemQueryStreamIteratorSql(queryText: querysp, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Teacher-{school_code}") }))
                 {
-                    var jsonts = await JsonDocument.ParseAsync(item.ContentStream);
+                    var jsonts = await JsonDocument.ParseAsync(item.Content);
                     foreach (var obj in jsonts.RootElement.GetProperty("Documents").EnumerateArray())
                     {
                         teach = obj.GetProperty("size").GetInt64() * 1073741824; //G換算
@@ -2600,6 +2605,100 @@ namespace TEAMModelBI.Controllers.BISchool
 
         #endregion
 
+        #region 統購平台用
+        /// <summary>
+        /// 取得CoreBB學校訂單履歷資訊  暂时这样处理
+        /// </summary>
+        /// <param name="request"></param>
+        /// <returns></returns>
+        [ProducesDefaultResponseType]
+        [HttpPost("get-bbpurchase")]
+        public async Task<IActionResult> GetBBpurchase(JsonElement jsonElement)
+        {
+            List<object> result = new List<object>();
+            try
+            {
+                var client = _azureCosmos.GetCosmosClient(name:"CoreServiceV2");
+                string sqlPurchase = $"SELECT * FROM c ";
+                List<PurchaseSeats> purchaseSeatsList = new List<PurchaseSeats>();
+                await foreach (PurchaseSeats item in client.GetContainer("Habb", "Auth").GetItemQueryIteratorSql<PurchaseSeats>(queryText: sqlPurchase, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("purchase") }))
+                {
+                    purchaseSeatsList.Add(item);
+                }
+                Dictionary<string, List<PurchaseSchoolSeats>> purchaseSchoolSeatsDic = new Dictionary<string, List<PurchaseSchoolSeats>>();
+                string sqlSchool = $"SELECT * FROM c ";
+                await foreach (PurchaseSchoolSeats item in client.GetContainer("Habb", "Auth").GetItemQueryIteratorSql<PurchaseSchoolSeats>(queryText: sqlSchool, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("purchaseSchool") }))
+                {
+                    if(!purchaseSchoolSeatsDic.ContainsKey(item.purchaseId))
+                    {
+                        purchaseSchoolSeatsDic.Add(item.purchaseId, new List<PurchaseSchoolSeats>() { item });
+                    }
+                    else
+                    {
+                        purchaseSchoolSeatsDic[item.purchaseId].Add(item);
+                    }
+                }
+
+                return Ok(new { geo = purchaseSeatsList, school = purchaseSchoolSeatsDic });
+            }
+            catch (Exception ex)
+            {
+                return BadRequest();
+            }
+        }
+        /// <summary>
+        /// 取得CoreService縣市所屬學校
+        /// </summary>
+        /// <param name="request"></param>
+        /// <returns></returns>
+        [ProducesDefaultResponseType]
+        [HttpPost("get-school-geo")]
+        public async Task<IActionResult> GetCsSchoolByGeo(JsonElement jsonElement)
+        {
+            List<CsSchoolBase> result = new List<CsSchoolBase>();
+            try
+            {
+                string err = string.Empty;
+                string countryId = (jsonElement.TryGetProperty("countryId", out JsonElement _countryId)) ? _countryId.GetString() : string.Empty;
+                string provinceId = (jsonElement.TryGetProperty("provinceId", out JsonElement _provinceId)) ? _provinceId.GetString() : string.Empty;
+                string cityId = (jsonElement.TryGetProperty("cityId", out JsonElement _cityId)) ? _cityId.GetString() : string.Empty;
+                string distId = (jsonElement.TryGetProperty("distId", out JsonElement _distId)) ? _distId.GetString() : string.Empty;
+                //輸入項檢驗
+                if (string.IsNullOrWhiteSpace(countryId)) { err = "Invalid countryId."; }
+                else if(countryId.Equals("CN"))
+                {
+                    if (string.IsNullOrWhiteSpace(provinceId)) { err = "Invalid provinceId."; }
+                    else if (string.IsNullOrWhiteSpace(cityId)) { err = "Invalid cityId."; }
+                }
+                else if (countryId.Equals("TW"))
+                {
+                    if (string.IsNullOrWhiteSpace(cityId)) { err = "Invalid cityId."; }
+                }
+                if(!string.IsNullOrWhiteSpace(err)) ///錯誤訊息輸出
+                {
+                    return Ok(new { err = err, data = result });
+                }
+                //取得CS學校
+                var client = _azureCosmos.GetCosmosClient(name:"CoreServiceV2CnRead");
+                string sql = $"SELECT * FROM c WHERE c.countryId = '{countryId}'";
+                if (!string.IsNullOrWhiteSpace(provinceId)) sql += $" AND c.provinceId = '{provinceId}'";
+                if (!string.IsNullOrWhiteSpace(cityId)) sql += $" AND c.cityId = '{cityId}'";
+                if (!string.IsNullOrWhiteSpace(distId)) sql += $" AND c.distId = '{distId}'";
+                await foreach (CsSchoolBase item in client.GetContainer("Core", "School").GetItemQueryIteratorSql<CsSchoolBase>(queryText: sql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("base") }))
+                {
+                    result.Add(item);
+                }
+
+                return Ok(new { err = err, data = result });
+            }
+            catch (Exception ex)
+            {
+                return BadRequest();
+            }
+        }
+
+        #endregion
+
         /// <summary>
         /// 未加入区域的学校
         /// </summary>

+ 0 - 1
TEAMModelBI/Controllers/BIServer/BiServersController.cs

@@ -13,7 +13,6 @@ using System.Net.Http;
 using TEAMModelOS.SDK.Extension;
 using System.Text;
 using System.Net;
-using HTEXLib.COMM.Helpers;
 using System.Net.Http.Json;
 using TEAMModelOS.SDK;
 using TEAMModelBI.Filter;

+ 1 - 1
TEAMModelBI/Controllers/BIStudent/StuActivityController.cs

@@ -1,4 +1,4 @@
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Mvc;
 using Microsoft.Extensions.Options;

+ 7 - 7
TEAMModelBI/Controllers/BIStudent/StudentController.cs

@@ -1,4 +1,4 @@
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Mvc;
 using Microsoft.Extensions.Options;
@@ -48,9 +48,9 @@ namespace TEAMModelBI.Controllers.BIStudent
             //if ($"{site}".Equals(BIConst.Global))
             //    cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.Global);
             List<object> objs = new();
-            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Student").GetItemQueryStreamIterator(queryText: $"select value(c) from c where c.id='{studentId}'", requestOptions: string.IsNullOrEmpty($"{code}") ? new QueryRequestOptions() { } : new QueryRequestOptions() { PartitionKey = new PartitionKey($"{code}") }))
+            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Student").GetItemQueryStreamIteratorSql(queryText: $"select value(c) from c where c.id='{studentId}'", requestOptions: string.IsNullOrEmpty($"{code}") ? new QueryRequestOptions() { } : new QueryRequestOptions() { PartitionKey = new PartitionKey($"{code}") }))
             {
-                using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                using var json = await JsonDocument.ParseAsync(item.Content);
                 if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetInt16() > 0) 
                 {
                     foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
@@ -83,9 +83,9 @@ namespace TEAMModelBI.Controllers.BIStudent
                 //string sqlTxt = "SELECT select c.id,c.code,c.classIds FROM c  where c.pk='Activity' and c.classIds <> []";
                 string sqlTxt = "select c.id,c.code,c.classIds from c where c.school='cswznb' and c.classIds <> []";
                 List<CorrectStu> correctStus = new();
-                await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Student").GetItemQueryStreamIterator(queryText: sqlTxt, requestOptions: new QueryRequestOptions() { }))
+                await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Student").GetItemQueryStreamIteratorSql(queryText: sqlTxt, requestOptions: new QueryRequestOptions() { }))
                 {
-                    using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                    using var json = await JsonDocument.ParseAsync(item.Content);
                     foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
                     {
                         obj.TryGetProperty("id", out JsonElement tempTd);
@@ -106,7 +106,7 @@ namespace TEAMModelBI.Controllers.BIStudent
 
                 if (correctStus.Count > 0)
                 {
-                    foreach (var correct in correctStus)
+                    /*foreach (var correct in correctStus)
                     {
                         StuActivity stuActivity = await cosmosClient.GetContainer("TEAMModelOS", "Student").ReadItemAsync<StuActivity>(correct.id, new PartitionKey(correct.code));
                         if (stuActivity != null)
@@ -115,7 +115,7 @@ namespace TEAMModelBI.Controllers.BIStudent
 
                             await cosmosClient.GetContainer("TEAMModelOS", "Student").ReplaceItemAsync<StuActivity>(stuActivity, stuActivity.id, new PartitionKey(stuActivity.code));
                         }
-                    }
+                    }*/
 
                     return Ok(new { state = 200, msg = "去重成功" });
                 }

+ 4 - 4
TEAMModelBI/Controllers/BITable/BIOpenApiController.cs

@@ -1,4 +1,4 @@
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Mvc;
 using Microsoft.Extensions.Options;
@@ -57,9 +57,9 @@ namespace TEAMModelBI.Controllers.BITable
             }
 
             List<ReadApi> openApis = new();
-            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Normal").GetItemQueryStreamIterator(queryText:sqlTxt.ToString(),requestOptions:new QueryRequestOptions() { PartitionKey = new PartitionKey("Api")}))
+            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Normal").GetItemQueryStreamIteratorSql(queryText:sqlTxt.ToString(),requestOptions:new QueryRequestOptions() { PartitionKey = new PartitionKey("Api")}))
             {
-                using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                using var json = await JsonDocument.ParseAsync(item.Content);
                 if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt32() > 0) 
                 {
                     foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
@@ -124,7 +124,7 @@ namespace TEAMModelBI.Controllers.BITable
                 else
                 {
                     var response = await cosmosClient.GetContainer("TEAMModelOS", "Normal").ReadItemStreamAsync(openApi.id, new PartitionKey("Api"));
-                    if (response.Status == 200)
+                    if (response.StatusCode == System.Net.HttpStatusCode.OK)
                     {
                         openApi.ttl = -1;
                         openApi.pk = "Api";

+ 9 - 10
TEAMModelBI/Controllers/BITable/DDStructController.cs

@@ -14,11 +14,10 @@ using TEAMModelOS.Models;
 using TEAMModelOS.SDK.DI;
 using TEAMModelOS.SDK.Extension;
 using TEAMModelOS.SDK.Models.Service;
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using TEAMModelOS.SDK.Models;
 using TEAMModelBI.Controllers.BISchool;
 using TEAMModelOS.SDK.Models.Cosmos.BI;
-using Microsoft.Azure.Cosmos.Table;
 using TEAMModelOS.SDK;
 using TEAMModelOS.SDK.Context.BI;
 
@@ -282,7 +281,7 @@ namespace TEAMModelBI.Controllers.BITable
                         //string sqltxt = $"select distinct value(c) from c join A1 in c.ddbinds where A1.userid ='{itemUser.Userid}'";
                         //try
                         //{
-                        //    await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<Teacher>(queryText: sqltxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
+                        //    await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIteratorSql<Teacher>(queryText: sqltxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
                         //    {
                         //        dDAndTmdInfo.tmdId = item.id;
                         //        dDAndTmdInfo.isexist = true;
@@ -292,7 +291,7 @@ namespace TEAMModelBI.Controllers.BITable
                         //            var schoolRoles = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync(item.id, new PartitionKey($"Teacher-{item.defaultSchool}"));
                         //            if (schoolRoles.Status == 200)
                         //            {
-                        //                using var json = await JsonDocument.ParseAsync(schoolRoles.ContentStream);
+                        //                using var json = await JsonDocument.ParseAsync(schoolRoles.Content);
                         //                if (json.RootElement.TryGetProperty("roles", out JsonElement _roles) && _roles.ValueKind != JsonValueKind.Null)
                         //                {
                         //                    foreach (var obj in _roles.EnumerateArray())
@@ -371,7 +370,7 @@ namespace TEAMModelBI.Controllers.BITable
                                         string sqltxt = $"select distinct value(c) from c join A1 in c.ddbinds where A1.userid ='{itemUser2.Userid}'";
                                         try
                                         {
-                                            await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<Teacher>(queryText: sqltxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
+                                            await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIteratorSql<Teacher>(queryText: sqltxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
                                             {
                                                 dDAndTmdInfo2.tmdId = item.id;
                                                 dDAndTmdInfo2.isexist = true;
@@ -379,9 +378,9 @@ namespace TEAMModelBI.Controllers.BITable
                                                 if (!string.IsNullOrEmpty($"{item.defaultSchool}"))
                                                 {
                                                     var schoolRoles = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync(item.id, new PartitionKey($"Teacher-{item.defaultSchool}"));
-                                                    if (schoolRoles.Status == 200)
+                                                    if (schoolRoles.StatusCode == System.Net.HttpStatusCode.OK)
                                                     {
-                                                        using var json = await JsonDocument.ParseAsync(schoolRoles.ContentStream);
+                                                        using var json = await JsonDocument.ParseAsync(schoolRoles.Content);
                                                         if (json.RootElement.TryGetProperty("roles", out JsonElement _roles) && _roles.ValueKind != JsonValueKind.Null)
                                                         {
                                                             foreach (var obj in _roles.EnumerateArray())
@@ -503,7 +502,7 @@ namespace TEAMModelBI.Controllers.BITable
                             string sqltxt = $"select distinct value(c) from c join A1 in c.ddbinds where A1.userid ='{tempid}'";
                             try
                             {
-                                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<Teacher>(queryText: sqltxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
+                                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIteratorSql<Teacher>(queryText: sqltxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
                                 {
                                     dDUserInfoAndTMD.tmdId = item.id;
                                     dDUserInfoAndTMD.isexist = true;
@@ -511,9 +510,9 @@ namespace TEAMModelBI.Controllers.BITable
                                     if (!string.IsNullOrEmpty($"{item.defaultSchool}"))
                                     {
                                         var schoolRoles = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync(item.id, new PartitionKey($"Teacher-{item.defaultSchool}"));
-                                        if (schoolRoles.Status == 200)
+                                        if (schoolRoles.StatusCode == System.Net.HttpStatusCode.OK)
                                         {
-                                            using var json = await JsonDocument.ParseAsync(schoolRoles.ContentStream);
+                                            using var json = await JsonDocument.ParseAsync(schoolRoles.Content);
                                             if (json.RootElement.TryGetProperty("roles", out JsonElement _roles) && _roles.ValueKind != JsonValueKind.Null)
                                             {
                                                 foreach (var obj in _roles.EnumerateArray())

+ 2 - 3
TEAMModelBI/Controllers/BITable/IES5OAuthController.cs

@@ -1,6 +1,5 @@
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using Azure.Storage.Blobs;
-using DocumentFormat.OpenXml.Spreadsheet;
 using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Mvc;
 using Microsoft.Extensions.Options;
@@ -123,7 +122,7 @@ namespace TEAMModelBI.Controllers.BITable
                     if (oAuthShow.Type.Equals("art")) 
                     {
                         var isExist = await cosmosClinet.GetContainer(Constant.TEAMModelOS, "Normal").ReadItemStreamAsync($"{oAuthShow.Code}", new PartitionKey("ArtSetting"));
-                        if (isExist.Status != 200)
+                        if (isExist.StatusCode != System.Net.HttpStatusCode.OK)
                         {
                             artSetting = await cosmosClinet.GetContainer(Constant.TEAMModelOS, "Normal").ReadItemAsync<ArtSetting>("default", new PartitionKey("ArtSetting"));
                             artSetting.id = oAuthShow.Code;

+ 2 - 2
TEAMModelBI/Controllers/BITable/OperateLogController.cs

@@ -1,6 +1,5 @@
 using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Mvc;
-using Microsoft.Azure.Cosmos.Table;
 using Microsoft.Extensions.Options;
 using System;
 using System.Collections.Generic;
@@ -17,6 +16,7 @@ using TEAMModelBI.Tool.Extension;
 using TEAMModelOS.SDK.Extension;
 
 using TEAMModelOS.SDK.Context.BI;
+using Microsoft.Azure.Cosmos.Table;
 
 namespace TEAMModelBI.Controllers.BITable
 {
@@ -138,7 +138,7 @@ namespace TEAMModelBI.Controllers.BITable
                 //保存操作记录
                 await AzureStorageBlobExtensions.SaveBILog(blobClient, tableClient, "operatelog-del", operateStr?.ToString(), _dingDing, httpContext: HttpContext);
 
-                if (temp.Count > 0)
+                if (temp.Count() > 0)
                 {
                     return Ok(new { state = 200 });
                 }

+ 18 - 20
TEAMModelBI/Controllers/BITable/TableDingDingInfoController.cs

@@ -17,10 +17,8 @@ using System.Net.Http.Json;
 using TEAMModelOS.SDK.Models.Cosmos.BI;
 using System.Net;
 using TEAMModelOS.SDK.Extension;
-using OpenXmlPowerTools;
 using System.Text;
-using Azure.Cosmos;
-using Microsoft.Azure.Cosmos.Table;
+using Microsoft.Azure.Cosmos;
 using TEAMModelBI.Filter;
 using TEAMModelBI.Tool.Extension;
 using TEAMModelBI.Models;
@@ -30,8 +28,8 @@ using TEAMModelOS.SDK.Context.BI;
 using TEAMModelOS.SDK.Models;
 using TEAMModelOS.SDK.Context.Constant;
 using TEAMModelOS.SDK.Models.Dtos;
-using DocumentFormat.OpenXml.Bibliography;
 using TEAMModelOS.SDK.Models.Cosmos.BI.BISchool;
+using Microsoft.Azure.Cosmos.Table;
 
 namespace TEAMModelBI.Controllers.BITable
 {
@@ -186,7 +184,7 @@ namespace TEAMModelBI.Controllers.BITable
                 var users = await table.FindListByDict<DingDingUserInfo>(new Dictionary<string, object> { { "PartitionKey", $"{divide}" } });
 
                 List<DingDingUserInfo> noExisits = new();
-                if (users.Count > 0)
+                if (users.Count() > 0)
                 {
                     //var temps = users.Union(tempddUserInfos).Except(users.Intersect(tempddUserInfos));
                     List<DingDingUserInfo> existsUserInfo = users.Where(u => !tempddUserInfos.Exists(e => u.userId.Equals(e.userId) && u.PartitionKey.Equals(e.PartitionKey))).ToList();
@@ -418,7 +416,7 @@ namespace TEAMModelBI.Controllers.BITable
                         {
                             string tempSql = $"select value(c) from c join a in c.sales where a.id='{itemR}'";
 
-                            await foreach (var itemRel in cosmosCliet.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<BIRelation>(queryText: tempSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("BIRel") }))
+                            await foreach (var itemRel in cosmosCliet.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIteratorSql<BIRelation>(queryText: tempSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("BIRel") }))
                             {
                                 var tempRel = itemRel.sales.Find(f => f.id.Equals(itemR));
                                 itemRel.sales.Remove(tempRel);
@@ -428,7 +426,7 @@ namespace TEAMModelBI.Controllers.BITable
                             }
 
                             //string sql = $"select value(c) from c where c.pk='Teacher' and c.id='{item.tmdId}'";
-                            //await foreach (var scTch in cosmosCliet.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<SchoolTeacher>(queryText: sql, requestOptions: new QueryRequestOptions() { })) 
+                            //await foreach (var scTch in cosmosCliet.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIteratorSql<SchoolTeacher>(queryText: sql, requestOptions: new QueryRequestOptions() { })) 
                             //{
                             //    if (scTch.roles.Contains("sales"))
                             //    {
@@ -455,7 +453,7 @@ namespace TEAMModelBI.Controllers.BITable
 
                             string tempSql = $"select value(c) from c join a in c.assists where a.id='{itemR}'";
 
-                            await foreach (var itemRel in cosmosCliet.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<BIRelation>(queryText: tempSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("BIRel") }))
+                            await foreach (var itemRel in cosmosCliet.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIteratorSql<BIRelation>(queryText: tempSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("BIRel") }))
                             {
                                 var tempRel = itemRel.sales.Find(f => f.id.Equals(itemR));
                                 itemRel.assists.Remove(tempRel);
@@ -465,7 +463,7 @@ namespace TEAMModelBI.Controllers.BITable
                             }
 
                             //string sql = $"select value(c) from c where c.pk='Teacher' and c.id='{item.tmdId}'";
-                            //await foreach (var scTch in cosmosCliet.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<SchoolTeacher>(queryText: sql, requestOptions: new QueryRequestOptions() { }))
+                            //await foreach (var scTch in cosmosCliet.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIteratorSql<SchoolTeacher>(queryText: sql, requestOptions: new QueryRequestOptions() { }))
                             //{
                             //    if (scTch.roles.Contains("assist"))
                             //    {
@@ -869,7 +867,7 @@ namespace TEAMModelBI.Controllers.BITable
                     var userInfos = await table.FindListByDict<DingDingUserInfo>(new Dictionary<string, object> { { "PartitionKey", $"{partitionKey}" } });
 
                     var adminInfos = userInfos.FindAll(x => x.roles.Contains("admin"));
-                    if (adminInfos.Count == 1)
+                    if (adminInfos.Count() == 1)
                     {
                         return Ok(new { state = 403, msg = "已经是最后一个管理员了" });
                     }
@@ -1037,11 +1035,11 @@ namespace TEAMModelBI.Controllers.BITable
                 var users = await table.FindListByDict<DingDingUserInfo>(new Dictionary<string, object> { { "PartitionKey", $"{divide}" } });
 
                 List<DingDingUserInfo> noExisits = new();
-                if (users.Count > 0)
+                if (users.Count() > 0)
                 {
                     //var temps = users.Union(tempddUserInfos).Except(users.Intersect(tempddUserInfos));
                     List<DingDingUserInfo> existsUserInfo = users.Where(u => !tempddUserInfos.Exists(e => u.userId.Equals(e.userId) && u.PartitionKey.Equals(e.PartitionKey))).ToList();
-                    if (users.Count >= tempddUserInfos.Count)
+                    if (users.Count() >= tempddUserInfos.Count)
                     {
                         existsUserInfo.AddRange(tempddUserInfos.Where(e => !users.Exists(u => e.userId.Equals(u.userId) && e.PartitionKey.Equals(u.PartitionKey))).ToList());
                     }
@@ -1435,7 +1433,7 @@ namespace TEAMModelBI.Controllers.BITable
                 string reole = null;
 
                 var tempUser = await table.FindListByDict<DingDingUserInfo>(new Dictionary<string, object> { { "PartitionKey", $"{partKey}" }, { "RowKey", $"{rowKey}" } });
-                if (tempUser.Count > 0)
+                if (tempUser.Count() > 0)
                 {
                     foreach (var item in tempUser)
                     {
@@ -1462,9 +1460,9 @@ namespace TEAMModelBI.Controllers.BITable
 
                     Teacher teacher = new();
                     var respone = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemStreamAsync(coreUser.id, new PartitionKey("Base"));
-                    if (respone.Status == 200)
+                    if (respone.StatusCode == HttpStatusCode.OK)
                     {
-                        using var json = await JsonDocument.ParseAsync(respone.ContentStream);
+                        using var json = await JsonDocument.ParseAsync(respone.Content);
                         teacher = json.ToObject<Teacher>();
                     }
                     else
@@ -1480,7 +1478,7 @@ namespace TEAMModelBI.Controllers.BITable
                     }
 
                     List<Task<ItemResponse<BIRelation>>> scRole = new();
-                    await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<BIRelation>(queryText: $"select value(c) from c join a in c.assists join s in c.sales  where c.code='BIRel' and  s.id='{oldTmdId}' or a.id='{oldTmdId}'", requestOptions:new QueryRequestOptions() { PartitionKey = new PartitionKey("BIRel") }))
+                    await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIteratorSql<BIRelation>(queryText: $"select value(c) from c join a in c.assists join s in c.sales  where c.code='BIRel' and  s.id='{oldTmdId}' or a.id='{oldTmdId}'", requestOptions:new QueryRequestOptions() { PartitionKey = new PartitionKey("BIRel") }))
                     {
                         var tempAss = item.assists.Find(f => f.id.Equals($"{oldTmdId}"));
                         if (tempAss != null)
@@ -1515,13 +1513,13 @@ namespace TEAMModelBI.Controllers.BITable
                     }
 
                     //List<Task<ItemResponse<SchoolTeacher>>> schoolTeachers = new();
-                    //await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<SchoolTeacher>($"select value(c) from c where c.pk='Teacher' and c.id='{oldTmdId}'"))
+                    //await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIteratorSql<SchoolTeacher>($"select value(c) from c where c.pk='Teacher' and c.id='{oldTmdId}'"))
                     //{
                     //    item.id = coreUser.id;
                     //    var resp = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync($"{coreUser.id}", new PartitionKey($"{item.code}"));
                     //    if (resp.Status == 200)
                     //    {
-                    //        using var json = await JsonDocument.ParseAsync(resp.ContentStream);
+                    //        using var json = await JsonDocument.ParseAsync(resp.Content);
                     //        SchoolTeacher scTeacher = json.ToObject<SchoolTeacher>();
                     //        if (scTeacher.roles.Contains("sales"))
                     //            scTeacher.roles.Remove("sales");
@@ -1570,7 +1568,7 @@ namespace TEAMModelBI.Controllers.BITable
                     //    }
                     //}
 
-                    if (respone.Status == 200)
+                    if (respone.StatusCode == HttpStatusCode.OK)
                         await cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync<Teacher>(teacher, teacher.id, new PartitionKey("Base"));
                     else
                         await cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").CreateItemAsync<Teacher>(teacher, new PartitionKey("Base"));
@@ -1676,7 +1674,7 @@ namespace TEAMModelBI.Controllers.BITable
                     {
                         var table = _azureStorage.GetCloudTableClient().GetTableReference("BIDDUserInfo");
                         var users = await table.FindListByDict<DingDingUserInfo>(new Dictionary<string, object> { { "PartitionKey", $"{partitionKey}" }, { "userId", $"{itemUser.Userid}" }, { "unionId", $"{itemUser.Unionid}" } });
-                        if (users.Count > 0)
+                        if (users.Count() > 0)
                         {
                             foreach (var user in users)
                             {

+ 5 - 5
TEAMModelBI/Controllers/BITeacher/TeacherController.cs

@@ -1,7 +1,7 @@
 using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Mvc;
 using Microsoft.Extensions.Options;
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using System.Text.Json;
 using System.Threading.Tasks;
 using System.Collections.Generic;
@@ -58,9 +58,9 @@ namespace TEAMModelBI.Controllers.BITeacher
                 sqlTxt = $"select c.id,c.name,c.code,c.picture from c join a1 in c.schools where a1.schoolId='{schoolCode}'";
             }
 
-            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Teacher").GetItemQueryStreamIterator(queryText: sqlTxt, requestOptions:new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
+            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Teacher").GetItemQueryStreamIteratorSql(queryText: sqlTxt, requestOptions:new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
             {
-                using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                using var json = await JsonDocument.ParseAsync(item.Content);
                 if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetInt16() > 0) 
                 {
                     foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
@@ -97,9 +97,9 @@ namespace TEAMModelBI.Controllers.BITeacher
             //    cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.Global);
             List<object> objs = new();
 
-            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Teacher").GetItemQueryStreamIterator(queryText: $"select value(c) from c where c.id='{teacherId}'", requestOptions: string.IsNullOrEmpty($"{code}") ? new QueryRequestOptions() { } : new QueryRequestOptions() { PartitionKey = new PartitionKey($"{code}") }))
+            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Teacher").GetItemQueryStreamIteratorSql(queryText: $"select value(c) from c where c.id='{teacherId}'", requestOptions: string.IsNullOrEmpty($"{code}") ? new QueryRequestOptions() { } : new QueryRequestOptions() { PartitionKey = new PartitionKey($"{code}") }))
             {
-                using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                using var json = await JsonDocument.ParseAsync(item.Content);
                 if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0) 
                 {
                     foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray()) 

+ 13 - 12
TEAMModelBI/Controllers/BITest/Ies5TestController.cs

@@ -2,6 +2,7 @@
 using Microsoft.AspNetCore.Hosting;
 using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Mvc;
+using Microsoft.Azure.Cosmos;
 using Microsoft.Extensions.Configuration;
 using Microsoft.Extensions.Options;
 using StackExchange.Redis;
@@ -103,7 +104,7 @@ namespace TEAMModelBI.Controllers.BITest
 
             if ($"{actType}".Equals("Study"))
             {
-                study = await cosmosClient.GetContainer("TEAMModelOS", "Common").ReadItemAsync<Study>($"{id}", new Azure.Cosmos.PartitionKey($"Study-{code}"));
+                study = await cosmosClient.GetContainer("TEAMModelOS", "Common").ReadItemAsync<Study>($"{id}", new PartitionKey($"Study-{code}"));
                 if (study.groupLists.Count > 0)
                 {
                     var group = study.groupLists;
@@ -122,7 +123,7 @@ namespace TEAMModelBI.Controllers.BITest
             }
             else if ($"{actType}".Equals("Vote"))
             {
-                vote = await cosmosClient.GetContainer("TEAMModelOS", "Common").ReadItemAsync<Vote>($"{id}", new Azure.Cosmos.PartitionKey($"Vote-{code}"));
+                vote = await cosmosClient.GetContainer("TEAMModelOS", "Common").ReadItemAsync<Vote>($"{id}", new PartitionKey($"Vote-{code}"));
                 classes = vote.classes;
                 stuLists = vote.stuLists;
                 tchLists = vote.tchLists;
@@ -130,7 +131,7 @@ namespace TEAMModelBI.Controllers.BITest
             }
             else if ($"{actType}".Equals("Homework"))
             {
-                work = await cosmosClient.GetContainer("TEAMModelOS", "Common").ReadItemAsync<Homework>($"{id}", new Azure.Cosmos.PartitionKey($"Homework-{code}"));
+                work = await cosmosClient.GetContainer("TEAMModelOS", "Common").ReadItemAsync<Homework>($"{id}", new PartitionKey($"Homework-{code}"));
                 classes = work.classes;
                 stuLists = work.stuLists;
                 tchLists = work.tchLists;
@@ -138,7 +139,7 @@ namespace TEAMModelBI.Controllers.BITest
             }
             else if ($"{actType}".Equals("Survey")) 
             {
-                survey = await cosmosClient.GetContainer("TEAMModelOS", "Common").ReadItemAsync<Survey>($"{id}", new Azure.Cosmos.PartitionKey($"Survey-{code}"));
+                survey = await cosmosClient.GetContainer("TEAMModelOS", "Common").ReadItemAsync<Survey>($"{id}", new PartitionKey($"Survey-{code}"));
                 classes = survey.classes;
                 stuLists = survey.stuLists;
                 tchLists = survey.tchLists;
@@ -146,7 +147,7 @@ namespace TEAMModelBI.Controllers.BITest
             }
             else if ($"{actType}".Equals("ExamLite")) 
             {
-                examLite = await cosmosClient.GetContainer("TEAMModelOS", "Common").ReadItemAsync<ExamLite>($"{id}", new Azure.Cosmos.PartitionKey($"ExamLite-{code}"));
+                examLite = await cosmosClient.GetContainer("TEAMModelOS", "Common").ReadItemAsync<ExamLite>($"{id}", new PartitionKey($"ExamLite-{code}"));
                 classes = examLite.classes;
                 stuLists = examLite.stuLists;
                 tchLists = examLite.tchLists;
@@ -154,7 +155,7 @@ namespace TEAMModelBI.Controllers.BITest
             }
             else if ($"{actType}".Equals("Exam"))
             {
-                examInfo = await cosmosClient.GetContainer("TEAMModelOS", "Common").ReadItemAsync<ExamInfo>($"{id}", new Azure.Cosmos.PartitionKey($"Exam-{code}"));
+                examInfo = await cosmosClient.GetContainer("TEAMModelOS", "Common").ReadItemAsync<ExamInfo>($"{id}", new PartitionKey($"Exam-{code}"));
                 classes = examInfo.classes;
                 stuLists = examInfo.stuLists;
                 school = examInfo.school;
@@ -165,37 +166,37 @@ namespace TEAMModelBI.Controllers.BITest
             if ($"{actType}".Equals("Study"))
             {
                 study.staffIds = idsList;
-                study = await cosmosClient.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync<Study>(study, study.id, new Azure.Cosmos.PartitionKey($"Study-{code}"));
+                study = await cosmosClient.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync<Study>(study, study.id, new PartitionKey($"Study-{code}"));
                 showAct = study;
             }
             else if ($"{actType}".Equals("Vote"))
             {
                 vote.staffIds = idsList;
-                vote = await cosmosClient.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync<Vote>(vote, vote.id, new Azure.Cosmos.PartitionKey($"Vote-{code}")); 
+                vote = await cosmosClient.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync<Vote>(vote, vote.id, new PartitionKey($"Vote-{code}")); 
                 showAct = vote;
             }
             else if ($"{actType}".Equals("Homework"))
             {
                 work.staffIds = idsList;
-                work = await cosmosClient.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync<Homework>(work, work.id, new Azure.Cosmos.PartitionKey($"Homework-{code}"));
+                work = await cosmosClient.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync<Homework>(work, work.id, new PartitionKey($"Homework-{code}"));
                 showAct = work;
             }
             else if ($"{actType}".Equals("Survey"))
             {
                 survey.staffIds = idsList;
-                survey = await cosmosClient.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync<Survey>(survey, survey.id, new Azure.Cosmos.PartitionKey($"Survey-{code}"));
+                survey = await cosmosClient.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync<Survey>(survey, survey.id, new PartitionKey($"Survey-{code}"));
                 showAct = work;
             }
             else if ($"{actType}".Equals("ExamLite"))
             {
                 examLite.staffIds = idsList;
-                examLite = await cosmosClient.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync<ExamLite>(examLite, examLite.id, new Azure.Cosmos.PartitionKey($"ExamLite-{code}"));
+                examLite = await cosmosClient.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync<ExamLite>(examLite, examLite.id, new PartitionKey($"ExamLite-{code}"));
                 showAct = work;
             }
             else if ($"{actType}".Equals("Exam"))
             {
                 examInfo.staffIds = idsList;
-                examInfo = await cosmosClient.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync<ExamInfo>(examInfo, examInfo.id, new Azure.Cosmos.PartitionKey($"Exam-{code}"));
+                examInfo = await cosmosClient.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync<ExamInfo>(examInfo, examInfo.id, new PartitionKey($"Exam-{code}"));
                 showAct = work;
             }
 

+ 29 - 33
TEAMModelBI/Controllers/BITest/TestController.cs

@@ -1,12 +1,10 @@
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using DingTalk.Api;
 using DingTalk.Api.Request;
 using DingTalk.Api.Response;
-using HTEXLib.COMM.Helpers;
 using Microsoft.AspNetCore.Hosting;
 using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Mvc;
-using Microsoft.Azure.Cosmos.Table;
 using Microsoft.Extensions.Configuration;
 using Microsoft.Extensions.Options;
 using System;
@@ -53,15 +51,13 @@ using Azure.Storage.Blobs;
 using Azure.Storage.Blobs.Specialized;
 using System.Web;
 using Azure.Storage.Sas;
-using DocumentFormat.OpenXml.Drawing.Diagrams;
-using DocumentFormat.OpenXml.Bibliography;
 using TEAMModelOS.SDK.Models.Service.BIStatsWay;
 using MathNet.Numerics.LinearAlgebra.Double;
 using TEAMModelOS.SDK.Models.Cosmos.BI.BISchool;
-using DocumentFormat.OpenXml.Drawing;
 using Microsoft.OData.Edm;
 using TEAMModelOS.SDK.Models.Cosmos.OpenEntity;
 using TEAMModelOS.SDK.Models.Cosmos.BI.BICommon;
+using Microsoft.Azure.Cosmos.Table;
 
 namespace TEAMModelBI.Controllers.BITest
 {
@@ -108,7 +104,7 @@ namespace TEAMModelBI.Controllers.BITest
             List<string> abilityIds = new();  //册别的ID集合
 
             //查询册别信息
-            await foreach (var tempAbility in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<Ability>(queryText: $"select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Ability-{_oldStandard}") }))
+            await foreach (var tempAbility in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIteratorSql<Ability>(queryText: $"select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Ability-{_oldStandard}") }))
             {
                 abilityIds.Add(tempAbility.id);  //查询出来册别ID添加册别ID集合
             }
@@ -120,7 +116,7 @@ namespace TEAMModelBI.Controllers.BITest
 
             List<string> abilityTaskIds = new();  //章节ID集合
 
-            await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<AbilityTask>(queryText: $"select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"AbilityTask-{_oldStandard}") }))
+            await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIteratorSql<AbilityTask>(queryText: $"select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"AbilityTask-{_oldStandard}") }))
             {
                 abilityTaskIds.Add(item.id);   //查询出来的章节信息ID添加到战绩集合
             }
@@ -464,7 +460,7 @@ namespace TEAMModelBI.Controllers.BITest
                     stringBuilder.Append($" where c.id='{_schoolCode}'");
                 }
 
-                //await foreach (var itemSchool in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<School>(queryText: stringBuilder.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
+                //await foreach (var itemSchool in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIteratorSql<School>(queryText: stringBuilder.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
                 //{
                 //    SchoolAssist schoolAssist = new()
                 //    {
@@ -488,7 +484,7 @@ namespace TEAMModelBI.Controllers.BITest
                 //    var response = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(itemSchool.id, new PartitionKey("ProductSum"));
                 //    if (response.Status == 200)
                 //    {
-                //        using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                //        using var json = await JsonDocument.ParseAsync(response.Content);
 
                 //        if (json.RootElement.TryGetProperty("serial", out JsonElement serial) && !serial.ValueKind.Equals(JsonValueKind.Null))
                 //        {
@@ -510,9 +506,9 @@ namespace TEAMModelBI.Controllers.BITest
                 //}
                 //return Ok(new { state = 200, schoolAssists });
 
-                await foreach (var itemSchool in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: stringBuilder.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
+                await foreach (var itemSchool in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIteratorSql(queryText: stringBuilder.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
                 {
-                    using var jsonSchool = await JsonDocument.ParseAsync(itemSchool.ContentStream);
+                    using var jsonSchool = await JsonDocument.ParseAsync(itemSchool.Content);
                     foreach (var objSchool in jsonSchool.RootElement.GetProperty("Documents").EnumerateArray())
                     {
                         var schoolId = objSchool.GetProperty("id").GetString();
@@ -539,9 +535,9 @@ namespace TEAMModelBI.Controllers.BITest
                         catch { schoolAssist.scale = 0; }
 
                         var response = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(schoolId, new PartitionKey("ProductSum"));
-                        if (response.Status == 200)
+                        if (response.StatusCode == HttpStatusCode.OK)
                         {
-                            using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                            using var json = await JsonDocument.ParseAsync(response.Content);
                             if (json.RootElement.TryGetProperty("serial", out JsonElement serial) && !serial.ValueKind.Equals(JsonValueKind.Null))
                             {
                                 schoolAssist.serial = serial.ToObject<List<SchoolProductSumData>>().Select(x => x.prodCode).ToList();
@@ -589,9 +585,9 @@ namespace TEAMModelBI.Controllers.BITest
             foreach (var temp in schoolAssists)
             {
                 var response = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(temp.id, new PartitionKey("ProductSum"));
-                if (response.Status == 200)
+                if (response.StatusCode == HttpStatusCode.OK)
                 {
-                    using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                    using var json = await JsonDocument.ParseAsync(response.Content);
                     if (json.RootElement.TryGetProperty("serial", out JsonElement serial) && !serial.ValueKind.Equals(JsonValueKind.Null))
                     {
                         temp.serial = serial.ToObject<List<SchoolProductSumData>>().Select(x => x.prodCode).ToList();
@@ -669,10 +665,10 @@ namespace TEAMModelBI.Controllers.BITest
 
                 //string sqlText = $"select value(c.id) from c where c.pk='Item' and c.field={i}";
                 string sqlText = $"select value(COUNT(c.id)) from c where c.pk='Item' and c.field={i}";
-                await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<int>(queryText: sqlText, requestOptions: new QueryRequestOptions() { }))
+                await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIteratorSql<int>(queryText: sqlText, requestOptions: new QueryRequestOptions() { }))
                 {
                     total += item;
-                    //using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                    //using var json = await JsonDocument.ParseAsync(item.Content);
                     //if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetInt32() > 0)
                     //{
                     //    foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
@@ -684,10 +680,10 @@ namespace TEAMModelBI.Controllers.BITest
                     //}
                 }
 
-                await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<int>(queryText: sqlText, requestOptions: new QueryRequestOptions() { }))
+                await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIteratorSql<int>(queryText: sqlText, requestOptions: new QueryRequestOptions() { }))
                 {
                     total += item;
-                    //using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                    //using var json = await JsonDocument.ParseAsync(item.Content);
                     //if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetInt64() > 0)
                     //{
                     //    foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
@@ -784,9 +780,9 @@ namespace TEAMModelBI.Controllers.BITest
             {
                 var start = 00022222330;
                 long tempCount = 0;
-                await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: $"SELECT c._ts,c.name,c.id FROM c WHERE c._ts>={start}L", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
+                await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIteratorSql(queryText: $"SELECT c._ts,c.name,c.id FROM c WHERE c._ts>={start}L", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
                 {
-                    using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                    using var json = await JsonDocument.ParseAsync(item.Content);
                     if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetInt64() > 0)
                     {
                         foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
@@ -1031,9 +1027,9 @@ namespace TEAMModelBI.Controllers.BITest
             List<School> schools = new List<School>();
             //string sqlTxt = $"SELECT * FROM c where c.code='Base' order by c.id offset {endPosition} limit {pageSize}";
             string sqlTxt = $"SELECT * FROM c order by c.id offset {pageSize} limit {endPosition}";
-            await foreach (var tempPage in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: sqlTxt, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey("Base") }))
+            await foreach (var tempPage in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIteratorSql(queryText: sqlTxt, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey("Base") }))
             {
-                using var json = await JsonDocument.ParseAsync(tempPage.ContentStream);
+                using var json = await JsonDocument.ParseAsync(tempPage.Content);
                 if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetInt16() > 0)
                 {
                     foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
@@ -1081,9 +1077,9 @@ namespace TEAMModelBI.Controllers.BITest
 
             List<School> schools = new();
 
-            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: "select value(c) from c", continuationToken: pageToken, requestOptions: new QueryRequestOptions() { MaxItemCount = pageSize, PartitionKey = new PartitionKey("Base") }))
+            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIteratorSql(queryText: "select value(c) from c", continuationToken: pageToken, requestOptions: new QueryRequestOptions() { MaxItemCount = pageSize, PartitionKey = new PartitionKey("Base") }))
             {
-                using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                using var json = await JsonDocument.ParseAsync(item.Content);
                 if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
                 {
                     foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
@@ -1093,7 +1089,7 @@ namespace TEAMModelBI.Controllers.BITest
 
                     if (iscontinuation)
                     {
-                        continuationToken = item.GetContinuationToken();
+                        continuationToken = item.ContinuationToken;
                         break;
                     }
                 }
@@ -1325,13 +1321,13 @@ namespace TEAMModelBI.Controllers.BITest
 
             var cosmosDefaulat = _azureCosmos.GetCosmosClient(); //默认数据库
             List<School> schools = new();
-            await foreach (var item in cosmosDefaulat.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<School>(queryText: "select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
+            await foreach (var item in cosmosDefaulat.GetContainer("TEAMModelOS", "School").GetItemQueryIteratorSql<School>(queryText: "select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
             {
                 schools.Add(item);
             }
             var cosmosGlobal = _azureCosmos.GetCosmosClient(name: "Global"); //默认数据库
             List<School> schoolGlobals = new();
-            await foreach (var item in cosmosGlobal.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<School>(queryText: "select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
+            await foreach (var item in cosmosGlobal.GetContainer("TEAMModelOS", "School").GetItemQueryIteratorSql<School>(queryText: "select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
             {
                 schoolGlobals.Add(item);
             }
@@ -1357,7 +1353,7 @@ namespace TEAMModelBI.Controllers.BITest
             //School school = new();
             //if (response.Status == 200)
             //{
-            //    using var json = await JsonDocument.ParseAsync(response.ContentStream);
+            //    using var json = await JsonDocument.ParseAsync(response.Content);
             //    school = json.ToObject<School>();
             //}
 
@@ -1407,7 +1403,7 @@ namespace TEAMModelBI.Controllers.BITest
             //        }
             //    }
             //}
-            var (an, saveUrl) = await BILogAnalyseService.GetPathAnalyse(_azureStorage, _ipSearcher, _dingDing, $"{path}", BIConst.LogChina, timeType: $"{jTimeType}");
+            var (an, saveUrl) = await BILogAnalyseService.GetPathAnalyse(_azureStorage, _dingDing, $"{path}", BIConst.LogChina, timeType: $"{jTimeType}");
 
             return Ok(new { state = RespondCode.Ok, cnt = filename.Count, filename, an, saveUrl });
         }
@@ -1433,7 +1429,7 @@ namespace TEAMModelBI.Controllers.BITest
 
 
             string path = $"resourceId=/SUBSCRIPTIONS/73B7F9EF-D8B7-4444-9E8D-D80B43BF3CD4/RESOURCEGROUPS/TEAMMODELCHENGDU/PROVIDERS/MICROSOFT.NETWORK/APPLICATIONGATEWAYS/OSFIREWARE/y={y}/m={m}/d={d}/h={h}/m=00/PT1H.json";
-            var retn = await BILogAnalyseService.GetPathAnalyse(_azureStorage, _ipSearcher, _dingDing, path, BIConst.LogChina);
+            var retn = await BILogAnalyseService.GetPathAnalyse(_azureStorage, _dingDing, path, BIConst.LogChina);
             if (retn.recCnts.IsNotEmpty())
             {
                 //https://teammodelos.blob.core.chinacloudapi.cn/0-public/pie-borderRadius.html
@@ -1469,7 +1465,7 @@ namespace TEAMModelBI.Controllers.BITest
                 var ptD = pastTime.Day >= 10 ? $"{pastTime.Day}" : $"0{pastTime.Day}";
 
                 string dayPath = $"resourceId=/SUBSCRIPTIONS/73B7F9EF-D8B7-4444-9E8D-D80B43BF3CD4/RESOURCEGROUPS/TEAMMODELCHENGDU/PROVIDERS/MICROSOFT.NETWORK/APPLICATIONGATEWAYS/OSFIREWARE/y={ptY}/m={ptM}/d={ptD}";
-                var dayRetn = await BILogAnalyseService.GetPathAnalyse(_azureStorage, _ipSearcher, _dingDing, dayPath, BIConst.LogChina, timeType: "Day");
+                var dayRetn = await BILogAnalyseService.GetPathAnalyse(_azureStorage, _dingDing, dayPath, BIConst.LogChina, timeType: "Day");
 
                 if (dayRetn.recCnts.IsNotEmpty())
                 {

Dosya farkı çok büyük olduğundan ihmal edildi
+ 478 - 203
TEAMModelBI/Controllers/BITmid/TmidController.cs


+ 18 - 18
TEAMModelBI/Controllers/Census/ActivitySticsController.cs

@@ -1,4 +1,4 @@
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Mvc;
 using Microsoft.Extensions.Options;
@@ -66,7 +66,7 @@ namespace TEAMModelBI.Controllers.Census
                 if (!string.IsNullOrEmpty($"{areaId}"))
                 {
                     string areaSc = $"select value(c.id) from c where c.pk='School' and c.areaId='{areaId}'";
-                    await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<string>(queryText: areaSc, requestOptions: new QueryRequestOptions() { }))
+                    await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIteratorSql<string>(queryText: areaSc, requestOptions: new QueryRequestOptions() { }))
                     {
                         scIds.Add(item);
                     }
@@ -260,9 +260,9 @@ namespace TEAMModelBI.Controllers.Census
                 //string stSql = $"{oftenSql} join s in c.currency where c.TeacherTrain and {comSql} and s.submitTime = 0 or s.submitTime >= {setting.submitTime}";
                 //submitCount = await CommonFind.GetSqlValueCount(cosmosClient, "Teacher", ctSql);
 
-                await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Teacher").GetItemQueryStreamIterator(queryText: $"select c.id,c.code,c.totalTime,c.onlineTime,c.offlineTime,c.classTime,c.currency from c where c.pk='TeacherTrain' and {comSql}", requestOptions: new QueryRequestOptions() { })) 
+                await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Teacher").GetItemQueryStreamIteratorSql(queryText: $"select c.id,c.code,c.totalTime,c.onlineTime,c.offlineTime,c.classTime,c.currency from c where c.pk='TeacherTrain' and {comSql}", requestOptions: new QueryRequestOptions() { })) 
                 {
-                    using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                    using var json = await JsonDocument.ParseAsync(item.Content);
                     if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
                     {
                         foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
@@ -319,7 +319,7 @@ namespace TEAMModelBI.Controllers.Census
             //    scSqlTxt.Append($" where c.areaId='{areaId}'");
             //}
 
-            //await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<RecSchool>(queryText: scSqlTxt.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
+            //await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIteratorSql<RecSchool>(queryText: scSqlTxt.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
             //{
             //    schools.Add(item);
             //}
@@ -340,7 +340,7 @@ namespace TEAMModelBI.Controllers.Census
             //{
             //    int count = 0;
             //    int appraise = 0;
-            //    await foreach (var info in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<bool>(queryText: $"select value(array_contains(c.permissions,'train-appraise')) from c", requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey($"Teacher-{school.id}") }))
+            //    await foreach (var info in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIteratorSql<bool>(queryText: $"select value(array_contains(c.permissions,'train-appraise')) from c", requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey($"Teacher-{school.id}") }))
             //    {
             //        if (info)
             //        {
@@ -367,7 +367,7 @@ namespace TEAMModelBI.Controllers.Census
             //    else basics += 1;
 
             //    string sqlTxtSchool = $"select value(c) from c where c.code='LessonRecord-{school}'";
-            //    await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<LessonRecord>(queryText: sqlTxtSchool, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"LessonRecord-{school}") }))
+            //    await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIteratorSql<LessonRecord>(queryText: sqlTxtSchool, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"LessonRecord-{school}") }))
             //    {
             //        records.Add(item);
             //    }
@@ -433,7 +433,7 @@ namespace TEAMModelBI.Controllers.Census
             //foreach (var tecId in tecIds)
             //{
             //    string sqlTxt = $"select value(c) from c where c.id='{tecId}'";
-            //    await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<LessonRecord>(queryText: sqlTxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"LessonRecord") }))
+            //    await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIteratorSql<LessonRecord>(queryText: sqlTxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"LessonRecord") }))
             //    {
             //        records.Add(item);
             //    }
@@ -565,7 +565,7 @@ namespace TEAMModelBI.Controllers.Census
             //    cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.Global);
 
             List<AreaInfo> areaInfos = new();
-            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Normal").GetItemQueryIterator<AreaInfo>(queryText: $"select c.id,c.name,c.standard,c.standardName from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base-Area") }))
+            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Normal").GetItemQueryIteratorSql<AreaInfo>(queryText: $"select c.id,c.name,c.standard,c.standardName from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base-Area") }))
             {
                 areaInfos.Add(item);
             }
@@ -686,9 +686,9 @@ namespace TEAMModelBI.Controllers.Census
                 {
                     School school = new();
                     var response = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync(itemId, new PartitionKey("Base"));
-                    if (response.Status == 200)
+                    if (response.StatusCode == System.Net.HttpStatusCode.OK)
                     {
-                        using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                        using var json = await JsonDocument.ParseAsync(response.Content);
                         school = json.ToObject<School>();
                     }
 
@@ -750,9 +750,9 @@ namespace TEAMModelBI.Controllers.Census
             {
                 School school = new();
                 var response = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync(itemId, new PartitionKey("Base"));
-                if (response.Status == 200)
+                if (response.StatusCode == System.Net.HttpStatusCode.OK)
                 {
-                    using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                    using var json = await JsonDocument.ParseAsync(response.Content);
                     school = json.ToObject<School>();
                 }
                 ActivityCount activityCount = new() { id = itemId, name = school.name != null ? school.name : itemId };
@@ -795,9 +795,9 @@ namespace TEAMModelBI.Controllers.Census
                 {
                     School school = new();
                     var response = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync(schoolId, new PartitionKey("Base"));
-                    if (response.Status == 200)
+                    if (response.StatusCode == System.Net.HttpStatusCode.OK)
                     {
-                        using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                        using var json = await JsonDocument.ParseAsync(response.Content);
                         school = json.ToObject<School>();
                     }
                     ActivityCount activityCount = new() { id = schoolId, name = school.name != null ? school.name : schoolId };
@@ -846,7 +846,7 @@ namespace TEAMModelBI.Controllers.Census
             //    cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.Global);
             List<RecSchool> schools = new();
 
-            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<RecSchool>(queryText: $"select c.id,c.name,c.picture,c.scale from c where c.areaId='{areaId}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
+            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIteratorSql<RecSchool>(queryText: $"select c.id,c.name,c.picture,c.scale from c where c.areaId='{areaId}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
             {
                 schools.Add(item);
             }
@@ -928,9 +928,9 @@ namespace TEAMModelBI.Controllers.Census
                 }
             }
 
-            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIterator(queryText: sqlTxt.ToString(), requestOptions: new QueryRequestOptions() { }))
+            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIteratorSql(queryText: sqlTxt.ToString(), requestOptions: new QueryRequestOptions() { }))
             {
-                using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                using var json = await JsonDocument.ParseAsync(item.Content);
                 foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
                 {
                     infos.Add(obj.ToObject<object>());

+ 2 - 2
TEAMModelBI/Controllers/Census/BlobLogController.cs

@@ -1,4 +1,4 @@
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Mvc;
 using Microsoft.Extensions.Options;
@@ -145,7 +145,7 @@ namespace TEAMModelBI.Controllers.Census
             {
                 foreach (var teacherId in teacherIds)
                 {
-                    await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<RecBlobFile>(queryText: $"SELECT c.id,c.code,c.name,c.size,c.type FROM c where c.pk='Bloblog'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Bloblog-{teacherId}") }))
+                    await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIteratorSql<RecBlobFile>(queryText: $"SELECT c.id,c.code,c.name,c.size,c.type FROM c where c.pk='Bloblog'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Bloblog-{teacherId}") }))
                     {
                         blobFiles.Add(item);
                     }

+ 21 - 22
TEAMModelBI/Controllers/Census/ItemSticsController.cs

@@ -5,7 +5,7 @@ using TEAMModelOS.Models;
 using TEAMModelOS.SDK.DI;
 using System.Threading.Tasks;
 using System.Collections.Generic;
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using System.Text.Json;
 using TEAMModelBI.Tool;
 using System;
@@ -16,7 +16,6 @@ using TEAMModelOS.SDK.Context.BI;
 using Azure.Core;
 using TEAMModelOS.SDK.DI;
 using TEAMModelOS.SDK.Context.Constant;
-using DocumentFormat.OpenXml.Wordprocessing;
 using TEAMModelOS.SDK.Models.Service.BI;
 
 namespace TEAMModelBI.Controllers.Census
@@ -88,9 +87,9 @@ namespace TEAMModelBI.Controllers.Census
             List<object> items = new();
             if (scope.ToString().Equals("private"))
             {
-                await foreach (var item in cosmosClinet.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryStreamIterator(queryDefinition: cosmosDbQuery.CosmosQueryDefinition, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Item-{code}") }))
+                await foreach (var item in cosmosClinet.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryStreamIteratorQuery(queryDefinition: cosmosDbQuery.CosmosQueryDefinition, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Item-{code}") }))
                 {
-                    using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                    using var json = await JsonDocument.ParseAsync(item.Content);
 
                     if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
                     {
@@ -103,9 +102,9 @@ namespace TEAMModelBI.Controllers.Census
             }
             else if (scope.ToString().Equals("school"))
             {
-                await foreach (var item in cosmosClinet.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryDefinition: cosmosDbQuery.CosmosQueryDefinition, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Item-{code}") }))
+                await foreach (var item in cosmosClinet.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIteratorQuery(queryDefinition: cosmosDbQuery.CosmosQueryDefinition, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Item-{code}") }))
                 {
-                    using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                    using var json = await JsonDocument.ParseAsync(item.Content);
 
                     if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
                     {
@@ -118,9 +117,9 @@ namespace TEAMModelBI.Controllers.Census
             }
             else
             {
-                await foreach (var item in cosmosClinet.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryStreamIterator(queryDefinition: cosmosDbQuery.CosmosQueryDefinition, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Item-{code}") }))
+                await foreach (var item in cosmosClinet.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryStreamIteratorQuery(queryDefinition: cosmosDbQuery.CosmosQueryDefinition, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Item-{code}") }))
                 {
-                    using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                    using var json = await JsonDocument.ParseAsync(item.Content);
 
                     if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
                     {
@@ -131,9 +130,9 @@ namespace TEAMModelBI.Controllers.Census
                     }
                 }
 
-                await foreach (var item in cosmosClinet.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryDefinition: cosmosDbQuery.CosmosQueryDefinition, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Item-{code}") }))
+                await foreach (var item in cosmosClinet.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIteratorQuery(queryDefinition: cosmosDbQuery.CosmosQueryDefinition, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Item-{code}") }))
                 {
-                    using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                    using var json = await JsonDocument.ParseAsync(item.Content);
 
                     if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
                     {
@@ -173,9 +172,9 @@ namespace TEAMModelBI.Controllers.Census
                 {
                     School school = new();
                     var rsponse = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(scid, new PartitionKey("Base"));
-                    if (rsponse.Status == 200)
+                    if (rsponse.StatusCode == System.Net.HttpStatusCode.OK)
                     {
-                        using var json = await JsonDocument.ParseAsync(rsponse.ContentStream);
+                        using var json = await JsonDocument.ParseAsync(rsponse.Content);
                         school = json.ToObject<School>();
                     }
 
@@ -226,9 +225,9 @@ namespace TEAMModelBI.Controllers.Census
                 {
                     School school = new();
                     var rsponse = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(schoolId, new PartitionKey("Base"));
-                    if (rsponse.Status == 200) 
+                    if (rsponse.StatusCode == System.Net.HttpStatusCode.OK) 
                     {
-                        using var json = await JsonDocument.ParseAsync(rsponse.ContentStream);
+                        using var json = await JsonDocument.ParseAsync(rsponse.Content);
                         school = json.ToObject<School>();
                     }
 
@@ -295,9 +294,9 @@ namespace TEAMModelBI.Controllers.Census
                     School school = new();
 
                     var response = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(schoolId, new PartitionKey("Base"));
-                    if (response.Status == 200) 
+                    if (response.StatusCode == System.Net.HttpStatusCode.OK) 
                     {
-                        using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                        using var json = await JsonDocument.ParseAsync(response.Content);
                         school = json.ToObject<School>();
                     }
 
@@ -362,9 +361,9 @@ namespace TEAMModelBI.Controllers.Census
                 {
                     School school = new();
                     var response = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(schoolId, new PartitionKey("Base"));
-                    if (response.Status == 200) 
+                    if (response.StatusCode == System.Net.HttpStatusCode.OK) 
                     {
-                        using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                        using var json = await JsonDocument.ParseAsync(response.Content);
                         school = json.ToObject<School>();
                     }
 
@@ -431,9 +430,9 @@ namespace TEAMModelBI.Controllers.Census
                     tableName = "Teacher";
                 }
 
-                await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", tableName).GetItemQueryStreamIterator(queryText: sqlTxt, requestOptions: new QueryRequestOptions() { }))
+                await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", tableName).GetItemQueryStreamIteratorSql(queryText: sqlTxt, requestOptions: new QueryRequestOptions() { }))
                 {
-                    using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                    using var json = await JsonDocument.ParseAsync(item.Content);
                     foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
                     {
                         objItems.Add(obj.ToObject<object>());
@@ -445,9 +444,9 @@ namespace TEAMModelBI.Controllers.Census
                 List<string> tableName = new() { "School", "Teacher" };
                 foreach (string key in tableName) 
                 {
-                    await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", key).GetItemQueryStreamIterator(queryText: sqlTxt, requestOptions: new QueryRequestOptions() { }))
+                    await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", key).GetItemQueryStreamIteratorSql(queryText: sqlTxt, requestOptions: new QueryRequestOptions() { }))
                     {
-                        using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                        using var json = await JsonDocument.ParseAsync(item.Content);
                         foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
                         {
                             objItems.Add(obj.ToObject<object>());

+ 35 - 35
TEAMModelBI/Controllers/Census/LessonSticsController.cs

@@ -7,7 +7,7 @@ using System.Threading.Tasks;
 using TEAMModelOS.Models;
 using TEAMModelOS.SDK.DI;
 using Microsoft.Extensions.Options;
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using System.Text.Json;
 using TEAMModelOS.SDK.Models.Cosmos.Common;
 using TEAMModelOS.SDK.Models;
@@ -73,7 +73,7 @@ namespace TEAMModelBI.Controllers.Census
             else
                 scSql.Append($" where c.areaId = null or c.areaId = ''");
 
-            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<AreaSchools>(queryText: scSql.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base")}))
+            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIteratorSql<AreaSchools>(queryText: scSql.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base")}))
             {
                 areaSchools.Add(item);
             }
@@ -132,7 +132,7 @@ namespace TEAMModelBI.Controllers.Census
 
             foreach (var sId in schools)
             {
-                await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<LessonCount>(queryText: sqlTxts, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"LessonCount-{sId}-{year}") }))
+                await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIteratorSql<LessonCount>(queryText: sqlTxts, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"LessonCount-{sId}-{year}") }))
                 {
                     scount.Add(item);
                 }
@@ -142,7 +142,7 @@ namespace TEAMModelBI.Controllers.Census
             foreach (var tId in teacIds)
             {
                 var sqlTxtt = $"select value(c) from c where c.id='{tId}'";
-                await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<LessonCount>(queryText: sqlTxtt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"LessonCount-{year}") }))
+                await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIteratorSql<LessonCount>(queryText: sqlTxtt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"LessonCount-{year}") }))
                 {
                     tcount.Add(item);
                 }
@@ -229,7 +229,7 @@ namespace TEAMModelBI.Controllers.Census
             //    cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.Global);
 
             List<AllAreaInfo> areaInfos = new();
-            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Normal").GetItemQueryIterator<AllAreaInfo>(queryText: $"select c.id,c.name,c.standard,c.standardName from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base-Area") }))
+            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Normal").GetItemQueryIteratorSql<AllAreaInfo>(queryText: $"select c.id,c.name,c.standard,c.standardName from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base-Area") }))
             {
                 areaInfos.Add(item);
             }
@@ -289,9 +289,9 @@ namespace TEAMModelBI.Controllers.Census
                 {
                     School school = new();
                     var response = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync(itemId, new PartitionKey("Base"));
-                    if (response.Status == 200)
+                    if (response.StatusCode == System.Net.HttpStatusCode.OK)
                     {
-                        using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                        using var json = await JsonDocument.ParseAsync(response.Content);
                         school = json.ToObject<School>();
                     }
 
@@ -354,9 +354,9 @@ namespace TEAMModelBI.Controllers.Census
                 {
                     School school = new();
                     var response = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync(itemId, new PartitionKey("Base"));
-                    if (response.Status == 200)
+                    if (response.StatusCode == System.Net.HttpStatusCode.OK)
                     {
-                        using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                        using var json = await JsonDocument.ParseAsync(response.Content);
                         school = json.ToObject<School>();
                     }
 
@@ -405,16 +405,16 @@ namespace TEAMModelBI.Controllers.Census
                 {
                     School school = new();
                     var response = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync(schoolId, new PartitionKey("Base"));
-                    if (response.Status == 200)
+                    if (response.StatusCode == System.Net.HttpStatusCode.OK)
                     {
-                        using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                        using var json = await JsonDocument.ParseAsync(response.Content);
                         school = json.ToObject<School>();
                     }
 
                     SchoolLen schoolLen = new() { id = schoolId, name = school != null ? school.name : schoolId };
 
                     List<List<double>> begin = new();
-                    await foreach (var lcount in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<LessonCount>(queryText: "select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"LessonCount-{schoolId}-{years}") }))
+                    await foreach (var lcount in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIteratorSql<LessonCount>(queryText: "select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"LessonCount-{schoolId}-{years}") }))
                     {
                         begin.Add(lcount.beginCount);
                     }
@@ -427,7 +427,7 @@ namespace TEAMModelBI.Controllers.Census
             else
             {
                 List<List<double>> begin = new();
-                await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<LessonCount>(queryText: "select value(c) from c where c.pk='LessonCount'", requestOptions: new QueryRequestOptions() { }))
+                await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIteratorSql<LessonCount>(queryText: "select value(c) from c where c.pk='LessonCount'", requestOptions: new QueryRequestOptions() { }))
                 {
                     begin.Add(item.beginCount);
                 }
@@ -459,9 +459,9 @@ namespace TEAMModelBI.Controllers.Census
             {
                 School school = new();
                 var response = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync(scid, new PartitionKey("Base"));
-                if (response.Status == 200)
+                if (response.StatusCode == System.Net.HttpStatusCode.OK)
                 {
-                    using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                    using var json = await JsonDocument.ParseAsync(response.Content);
                     school = json.ToObject<School>();
                 }
 
@@ -485,13 +485,13 @@ namespace TEAMModelBI.Controllers.Census
                 List<LessonCount> tcount = new();
                 DenseMatrix dense = null;
                 var queryClass = $"select value(c) from c ";
-                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<LessonCount>(queryText: queryClass, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"LessonCount-{scid}-{syear}") }))
+                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIteratorSql<LessonCount>(queryText: queryClass, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"LessonCount-{scid}-{syear}") }))
                 {
                     scount.Add(item);
                 }
                 if (tyear > syear)
                 {
-                    await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<LessonCount>(queryText: queryClass, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"LessonCount-{scid}-{tyear}") }))
+                    await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIteratorSql<LessonCount>(queryText: queryClass, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"LessonCount-{scid}-{tyear}") }))
                     {
                         tcount.Add(item);
                     }
@@ -573,7 +573,7 @@ namespace TEAMModelBI.Controllers.Census
             foreach (var school in schools)
             {
                 string sqlTxt = $"select value(c) from c where c.code='LessonRecord-{school}'";
-                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<LessonRecord>(queryText: sqlTxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"LessonRecord-{school}") }))
+                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIteratorSql<LessonRecord>(queryText: sqlTxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"LessonRecord-{school}") }))
                 {
                     records.Add(item);
                 }
@@ -583,7 +583,7 @@ namespace TEAMModelBI.Controllers.Census
             foreach (var tecId in tecIds)
             {
                 string sqlTxt = $"select value(c) from c where c.id='{tecId}'";
-                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<LessonRecord>(queryText: sqlTxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"LessonRecord") }))
+                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIteratorSql<LessonRecord>(queryText: sqlTxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"LessonRecord") }))
                 {
                     records.Add(item);
                 }
@@ -630,9 +630,9 @@ namespace TEAMModelBI.Controllers.Census
             //    cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.Global);
             List<object> lessons = new();
             string sqlTxt = $"select * from c where c.id='{lessonId}'";
-            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: sqlTxt, requestOptions: new QueryRequestOptions() { })) 
+            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIteratorSql(queryText: sqlTxt, requestOptions: new QueryRequestOptions() { })) 
             {
-                using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                using var json = await JsonDocument.ParseAsync(item.Content);
                 foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
                 {
                     lessons.Add(obj.ToObject<object>());
@@ -760,9 +760,9 @@ namespace TEAMModelBI.Controllers.Census
             List<double> yHours = new(daHours);
 
             var openRes = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync($"{year}", new PartitionKey("LessonYear"));
-            if (openRes.Status == 200)
+            if (openRes.StatusCode == System.Net.HttpStatusCode.OK)
             {
-                using var json = await JsonDocument.ParseAsync(openRes.ContentStream);
+                using var json = await JsonDocument.ParseAsync(openRes.Content);
                 LessonStats lessonYear = json.ToObject<LessonStats>();
                 if (type == 0)
                 {
@@ -794,9 +794,9 @@ namespace TEAMModelBI.Controllers.Census
             }
 
             var lessRes = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync($"{hourId}", new PartitionKey("LessonHour"));
-            if (lessRes.Status == 200)
+            if (lessRes.StatusCode == System.Net.HttpStatusCode.OK)
             {
-                using var json = await JsonDocument.ParseAsync(lessRes.ContentStream);
+                using var json = await JsonDocument.ParseAsync(lessRes.Content);
                 LessonStats lessonHour = json.ToObject<LessonStats>();
                 if (type == 0)
                 {
@@ -831,9 +831,9 @@ namespace TEAMModelBI.Controllers.Census
             if (!string.IsNullOrEmpty(schoolId))
             {
                 var openResSc = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync($"{year}", new PartitionKey($"LessonYear-{schoolId}"));
-                if (openResSc.Status == 200)
+                if (openResSc.StatusCode == System.Net.HttpStatusCode.OK)
                 {
-                    using var jsonSc = await JsonDocument.ParseAsync(openResSc.ContentStream);
+                    using var jsonSc = await JsonDocument.ParseAsync(openResSc.Content);
                     LessonStats lessonYearSc = jsonSc.ToObject<LessonStats>();
                     if (type == 0)
                         if (lessonYearSc.open.Count == 0)
@@ -863,9 +863,9 @@ namespace TEAMModelBI.Controllers.Census
                 }
 
                 var lessResSc = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync($"{hourId}", new PartitionKey($"LessonHour-{schoolId}"));
-                if (lessResSc.Status == 200)
+                if (lessResSc.StatusCode == System.Net.HttpStatusCode.OK)
                 {
-                    using var jsonSc = await JsonDocument.ParseAsync(lessResSc.ContentStream);
+                    using var jsonSc = await JsonDocument.ParseAsync(lessResSc.Content);
                     LessonStats lessonHourSc = jsonSc.ToObject<LessonStats>();
                     if (type == 0)
                         if (lessonHourSc.open.Count == 0)
@@ -915,12 +915,12 @@ namespace TEAMModelBI.Controllers.Census
 
             List<LessonRecord> allLesson = new();
 
-            await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<LessonRecord>(queryText: $"select value(c) from c where c.pk='LessonRecord'", requestOptions: new QueryRequestOptions() { }))
+            await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIteratorSql<LessonRecord>(queryText: $"select value(c) from c where c.pk='LessonRecord'", requestOptions: new QueryRequestOptions() { }))
             {
                 allLesson.Add(item);
             }
 
-            await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<LessonRecord>(queryText: $"select value(c) from c where c.pk='LessonRecord'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("LessonRecord") }))
+            await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIteratorSql<LessonRecord>(queryText: $"select value(c) from c where c.pk='LessonRecord'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("LessonRecord") }))
             {
                 allLesson.Add(item);
             }
@@ -930,9 +930,9 @@ namespace TEAMModelBI.Controllers.Census
             foreach (var itemY in lessYears)
             {
                 var response = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(itemY.id, new PartitionKey($"{itemY.code}"));
-                if (response.Status == 200)
+                if (response.StatusCode == System.Net.HttpStatusCode.OK)
                 {
-                    using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                    using var json = await JsonDocument.ParseAsync(response.Content);
                     LessonStats lessonYear = json.ToObject<LessonStats>();
                     lessonYear.open = itemY.open;
                     lessonYear.lesson = itemY.lesson;
@@ -946,9 +946,9 @@ namespace TEAMModelBI.Controllers.Census
             foreach (var itemH in lessHours)
             {
                 var response = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(itemH.id, new PartitionKey($"{itemH.code}"));
-                if (response.Status == 200)
+                if (response.StatusCode == System.Net.HttpStatusCode.OK)
                 {
-                    using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                    using var json = await JsonDocument.ParseAsync(response.Content);
                     LessonStats lessonHour = json.ToObject<LessonStats>();
                     lessonHour.open = itemH.open;
                     lessonHour.lesson = itemH.lesson;

+ 18 - 20
TEAMModelBI/Controllers/Census/PaperController.cs

@@ -1,8 +1,7 @@
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using Azure.Storage.Blobs;
 using Azure.Storage.Blobs.Models;
 using Azure.Storage.Sas;
-using DocumentFormat.OpenXml.Drawing.Diagrams;
 using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Mvc;
 using Microsoft.Extensions.Options;
@@ -23,7 +22,6 @@ using TEAMModelOS.Models;
 using TEAMModelOS.SDK.Context.BI;
 using TEAMModelOS.SDK.Context.Constant;
 using TEAMModelOS.SDK.DI;
-using TEAMModelOS.SDK.DI;
 using TEAMModelOS.SDK.Extension;
 using TEAMModelOS.SDK.Models;
 using TEAMModelOS.SDK.Models.Cosmos.BI;
@@ -106,7 +104,7 @@ namespace TEAMModelBI.Controllers.Census
             List<Paper> papers = new();
             if (scope.ToString().Equals("school"))
             {
-                await foreach (var item in cosmosClinet.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<Paper>(queryText: sql.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Paper-{code}") }))
+                await foreach (var item in cosmosClinet.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIteratorSql<Paper>(queryText: sql.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Paper-{code}") }))
                 {
                     papers.Add(item);
                 }
@@ -152,11 +150,11 @@ namespace TEAMModelBI.Controllers.Census
                         paper.code = $"Paper-{itemSc.newSc}";
 
                         var resState = await cosmosClinet.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync(paper.id, new PartitionKey(paper.code));
-                        if (resState.Status == 200)
+                        if (resState.StatusCode == System.Net.HttpStatusCode.OK)
                             paper.id = Guid.NewGuid().ToString();
 
                         msg.Append($"将学校[{cItem.oldSc}]中的[{cItem.oldId}]试卷复制到新学校试卷新id:{paper.id}");
-                        await foreach (var item in cosmosClinet.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<string>(queryText: $"select value(c.name) from c where c.name='{paper.name}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Paper-{itemSc.newSc}") }))
+                        await foreach (var item in cosmosClinet.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIteratorSql<string>(queryText: $"select value(c.name) from c where c.name='{paper.name}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Paper-{itemSc.newSc}") }))
                         {
                             existPaper.Add(item);
                         }
@@ -293,9 +291,9 @@ namespace TEAMModelBI.Controllers.Census
                     };
                     School school = new();
                     var response = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(schoolId, new PartitionKey("Base"));
-                    if (response.Status == 200)
+                    if (response.StatusCode == System.Net.HttpStatusCode.OK)
                     {
-                        using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                        using var json = await JsonDocument.ParseAsync(response.Content);
                         school = json.ToObject<School>();
                     }
 
@@ -365,9 +363,9 @@ namespace TEAMModelBI.Controllers.Census
             {
                 School school = new();
                 var response = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(schoolId, new PartitionKey("Base"));
-                if (response.Status == 200) 
+                if (response.StatusCode == System.Net.HttpStatusCode.OK) 
                 {
-                    using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                    using var json = await JsonDocument.ParseAsync(response.Content);
                     school = json.ToObject<School>();
                 }
 
@@ -420,9 +418,9 @@ namespace TEAMModelBI.Controllers.Census
                 {
                     School school = new();
                     var response = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(schoolId, new PartitionKey("Base"));
-                    if (response.Status == 200) 
+                    if (response.StatusCode == System.Net.HttpStatusCode.OK) 
                     {
-                        using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                        using var json = await JsonDocument.ParseAsync(response.Content);
                         school = json.ToObject<School>();
                     }
 
@@ -471,9 +469,9 @@ namespace TEAMModelBI.Controllers.Census
                     School school = new();
 
                     var response = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(schoolId, new PartitionKey("Base"));
-                    if(response.Status == 200) 
+                    if(response.StatusCode == System.Net.HttpStatusCode.OK) 
                     {
-                        using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                        using var json = await JsonDocument.ParseAsync(response.Content);
                         school = json.ToObject<School>();
                     }
 
@@ -483,9 +481,9 @@ namespace TEAMModelBI.Controllers.Census
 
                     schoolPaper.totals += await CommonFind.GetSqlValueCount(cosmosClient, "School", sqlTxt, $"Paper-{schoolId}");
 
-                    //await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText:sqlTxt.ToString(),requestOptions:new QueryRequestOptions() { PartitionKey = new PartitionKey($"Paper-{schoolId}")}))
+                    //await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIteratorSql(queryText:sqlTxt.ToString(),requestOptions:new QueryRequestOptions() { PartitionKey = new PartitionKey($"Paper-{schoolId}")}))
                     //{
-                    //    using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                    //    using var json = await JsonDocument.ParseAsync(item.Content);
                     //    if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetInt32() > 0)
                     //    {
                     //        foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
@@ -538,9 +536,9 @@ namespace TEAMModelBI.Controllers.Census
                     tableName = "Teacher";
                 }
 
-                await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", tableName).GetItemQueryStreamIterator(queryText: sqlTxt, requestOptions: new QueryRequestOptions() { }))
+                await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", tableName).GetItemQueryStreamIteratorSql(queryText: sqlTxt, requestOptions: new QueryRequestOptions() { }))
                 {
-                    using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                    using var json = await JsonDocument.ParseAsync(item.Content);
                     foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
                     {
                         paperInfos.Add(obj.ToObject<object>());
@@ -552,9 +550,9 @@ namespace TEAMModelBI.Controllers.Census
                 List<string> tableName = new(){ "School", "Teacher" };
                 foreach (var temp in tableName)
                 {
-                    await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", temp).GetItemQueryStreamIterator(queryText: sqlTxt, requestOptions: new QueryRequestOptions() { }))
+                    await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", temp).GetItemQueryStreamIteratorSql(queryText: sqlTxt, requestOptions: new QueryRequestOptions() { }))
                     {
-                        using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                        using var json = await JsonDocument.ParseAsync(item.Content);
                         foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
                         {
                             paperInfos.Add(obj.ToObject<object>());

+ 26 - 26
TEAMModelBI/Controllers/Census/ProductStatisController.cs

@@ -1,4 +1,4 @@
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Mvc;
 using Microsoft.Extensions.Options;
@@ -58,9 +58,9 @@ namespace TEAMModelBI.Controllers.Census
             //if ($"{site}".Equals(BIConst.Global))
             //    cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.Global);
             List<ProductStatis> productStatis = new List<ProductStatis>();
-            await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: $"SELECT c.serial,c.service FROM c",requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("ProductSum") }))
+            await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIteratorSql(queryText: $"SELECT c.serial,c.service FROM c",requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("ProductSum") }))
             {
-                using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                using var json = await JsonDocument.ParseAsync(item.Content);
                 if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
                 {
                     foreach (var itemCount in json.RootElement.GetProperty("Documents").EnumerateArray())
@@ -195,9 +195,9 @@ namespace TEAMModelBI.Controllers.Census
 
             //取产品的数量
             var response = await clientContainer.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(schoolCode.ToString(), new PartitionKey($"ProductSum"));
-            if (response.Status == 200)
+            if (response.StatusCode == System.Net.HttpStatusCode.OK)
             {
-                using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                using var json = await JsonDocument.ParseAsync(response.Content);
                 productSum = json.ToObject<SchoolProductSum>();
                 prodinfo = productSum.prodinfo;
                 serialRecord = productSum.serial;
@@ -206,9 +206,9 @@ namespace TEAMModelBI.Controllers.Census
             }
 
             //软体
-            await foreach (var item in clientContainer.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: "SELECT * FROM c WHERE c.dataType='serial'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Product-{schoolCode}") }))
+            await foreach (var item in clientContainer.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIteratorSql(queryText: "SELECT * FROM c WHERE c.dataType='serial'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Product-{schoolCode}") }))
             {
-                using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                using var json = await JsonDocument.ParseAsync(item.Content);
                 if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
                 {
                     foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
@@ -219,9 +219,9 @@ namespace TEAMModelBI.Controllers.Census
             }
 
             //服务
-            await foreach (var item in clientContainer.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: "SELECT * FROM c WHERE c.dataType='service'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Product-{schoolCode}") }))
+            await foreach (var item in clientContainer.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIteratorSql(queryText: "SELECT * FROM c WHERE c.dataType='service'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Product-{schoolCode}") }))
             {
-                using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                using var json = await JsonDocument.ParseAsync(item.Content);
                 if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
                 {
                     foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
@@ -232,9 +232,9 @@ namespace TEAMModelBI.Controllers.Census
             }
 
             //硬体
-            await foreach (var item in clientContainer.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: "SELECT * FROM c WHERE c.dataType='hard'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Product-{schoolCode}") }))
+            await foreach (var item in clientContainer.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIteratorSql(queryText: "SELECT * FROM c WHERE c.dataType='hard'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Product-{schoolCode}") }))
             {
-                using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                using var json = await JsonDocument.ParseAsync(item.Content);
                 if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
                 {
                     foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
@@ -246,7 +246,7 @@ namespace TEAMModelBI.Controllers.Census
 
             //学校教室
             List<Room> rooms = new();
-            await foreach (var item in clientContainer.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<Room>(queryText: $"select value(c) from c ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Room-{schoolCode}") }))
+            await foreach (var item in clientContainer.GetContainer("TEAMModelOS", "School").GetItemQueryIteratorSql<Room>(queryText: $"select value(c) from c ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Room-{schoolCode}") }))
             {
                 rooms.Add(item);
             }
@@ -277,9 +277,9 @@ namespace TEAMModelBI.Controllers.Census
                 School school = new();
 
                 var response = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync(scid, new PartitionKey("Base"));
-                if (response.Status == 200)
+                if (response.StatusCode == System.Net.HttpStatusCode.OK)
                 {
-                    using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                    using var json = await JsonDocument.ParseAsync(response.Content);
                     school = json.ToObject<School>();
                 }
 
@@ -287,9 +287,9 @@ namespace TEAMModelBI.Controllers.Census
 
                 List<ProductStatis> productStatis = new();
 
-                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: $"SELECT c.serial,c.service FROM c where c.id='{scid}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("ProductSum") }))
+                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIteratorSql(queryText: $"SELECT c.serial,c.service FROM c where c.id='{scid}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("ProductSum") }))
                 {
-                    using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                    using var json = await JsonDocument.ParseAsync(item.Content);
                     foreach (var itemCount in json.RootElement.GetProperty("Documents").EnumerateArray())
                     {
                         ////所有的产品信息
@@ -407,15 +407,15 @@ namespace TEAMModelBI.Controllers.Census
                     List<SchoolProductSumData> Services = new();
                     School school = new();
                     var response = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync(scId, new PartitionKey("Base"));
-                    if (response.Status == 200)
+                    if (response.StatusCode == System.Net.HttpStatusCode.OK)
                     {
-                        using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                        using var json = await JsonDocument.ParseAsync(response.Content);
                         school = json.ToObject<School>();
                     }
 
-                    await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: $"SELECT c.serial,c.service FROM c where c.id='{scId}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("ProductSum") }))
+                    await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIteratorSql(queryText: $"SELECT c.serial,c.service FROM c where c.id='{scId}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("ProductSum") }))
                     {
-                        using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                        using var json = await JsonDocument.ParseAsync(item.Content);
                         foreach (var itemCount in json.RootElement.GetProperty("Documents").EnumerateArray())
                         {
                             //软体产品
@@ -457,9 +457,9 @@ namespace TEAMModelBI.Controllers.Census
                 //软体产品
                 List<SchoolProductSumData> Services = new();
 
-                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: $"SELECT c.serial,c.service FROM c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("ProductSum") }))
+                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIteratorSql(queryText: $"SELECT c.serial,c.service FROM c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("ProductSum") }))
                 {
-                    using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                    using var json = await JsonDocument.ParseAsync(item.Content);
                     foreach (var itemCount in json.RootElement.GetProperty("Documents").EnumerateArray())
                     {
                         //软体产品
@@ -526,15 +526,15 @@ namespace TEAMModelBI.Controllers.Census
                 List<SchoolProductSumData> Services = new();
                 School school = new();
                 var response = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync(scId, new PartitionKey("Base"));
-                if (response.Status == 200)
+                if (response.StatusCode == System.Net.HttpStatusCode.OK)
                 {
-                    using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                    using var json = await JsonDocument.ParseAsync(response.Content);
                     school = json.ToObject<School>();
                 }
 
-                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: $"SELECT c.serial,c.service FROM c where c.id='{scId}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("ProductSum") }))
+                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIteratorSql(queryText: $"SELECT c.serial,c.service FROM c where c.id='{scId}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("ProductSum") }))
                 {
-                    using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                    using var json = await JsonDocument.ParseAsync(item.Content);
                     foreach (var itemCount in json.RootElement.GetProperty("Documents").EnumerateArray())
                     {
                         //软体产品

Dosya farkı çok büyük olduğundan ihmal edildi
+ 56 - 58
TEAMModelBI/Controllers/Census/SchoolController.cs


+ 3 - 4
TEAMModelBI/Controllers/LoginController.cs

@@ -1,4 +1,4 @@
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using DingTalk.Api;
 using DingTalk.Api.Request;
 using DingTalk.Api.Response;
@@ -12,7 +12,6 @@ using System.Text.Json;
 using System.Threading.Tasks;
 using TEAMModelOS.SDK.DI;
 using TEAMModelOS.SDK.Models;
-using HTEXLib.COMM.Helpers;
 using TEAMModelOS.Models;
 using Microsoft.Extensions.Options;
 using TEAMModelOS.SDK.Extension;
@@ -560,7 +559,7 @@ namespace TEAMModelBI.Controllers
             else return Ok(new { state = RespondCode.ParamsError, msg = "手机号/和邮箱为空" });
 
             List<BizUsers> bizUsers = new();
-            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Normal").GetItemQueryIterator<BizUsers>(queryText:loginSql,requestOptions:new QueryRequestOptions() { PartitionKey = new PartitionKey("BizUsers") }))
+            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Normal").GetItemQueryIteratorSql<BizUsers>(queryText:loginSql,requestOptions:new QueryRequestOptions() { PartitionKey = new PartitionKey("BizUsers") }))
             {
                 bizUsers.Add(item);
             }
@@ -631,7 +630,7 @@ namespace TEAMModelBI.Controllers
             else return Ok(new { state = RespondCode.ParamsError, msg = "手机号/和邮箱为空" });
 
             List<BizUsers> tempBizUsers = new();
-            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Normal").GetItemQueryIterator<BizUsers>(queryText: loginSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("BizUsers") }))
+            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Normal").GetItemQueryIteratorSql<BizUsers>(queryText: loginSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("BizUsers") }))
             {
                 tempBizUsers.Add(item);
             }

+ 8 - 11
TEAMModelBI/Controllers/RepairApi/InitialAreaController.cs

@@ -14,15 +14,12 @@ using TEAMModelBI.Tool.Extension;
 using TEAMModelOS.SDK.Extension;
 using Microsoft.AspNetCore.Hosting;
 using TEAMModelOS.SDK.Models;
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using System;
 using System.Collections.Generic;
 using TEAMModelOS.SDK.Models.Cosmos.Common;
 using System.Linq;
 using Pipelines.Sockets.Unofficial.Arenas;
-using TEAMModelOS.SDK.Models.Cosmos.BI;
-using TEAMModelBI.Filter;
-using HTEXLib.COMM.Helpers;
 using TEAMModelBI.Models;
 
 namespace TEAMModelBI.Controllers.RepairApi
@@ -97,7 +94,7 @@ namespace TEAMModelBI.Controllers.RepairApi
             var table = tableClient.GetTableReference("IESLogin");
 
             //查询新的是否存在
-            await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<Area>(queryText: $"select value(c) from c where c.standard='{standard}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-Area") }))
+            await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIteratorSql<Area>(queryText: $"select value(c) from c where c.standard='{standard}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-Area") }))
             {
                 if (item.standard.Equals($"{standard}"))
                     return Ok(new { state = 1, message = "新创区的standard已存在请检查" });
@@ -172,13 +169,13 @@ namespace TEAMModelBI.Controllers.RepairApi
             Area AreaS2 = null;
             List<Area> areas = new();
 
-            await foreach (var itemArea in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<Area>(queryText: $"select value(c) from c where c.standard='standard2'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-Area") }))
+            await foreach (var itemArea in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIteratorSql<Area>(queryText: $"select value(c) from c where c.standard='standard2'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-Area") }))
             {
                 areas.Add(itemArea);
                 AreaS2 = itemArea;
             }
 
-            await foreach (var itemArea in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<Area>(queryText: $"select value(c) from c where c.standard='standard3'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-Area") }))
+            await foreach (var itemArea in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIteratorSql<Area>(queryText: $"select value(c) from c where c.standard='standard3'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-Area") }))
             {
                 areas.Add(itemArea);
             }
@@ -186,7 +183,7 @@ namespace TEAMModelBI.Controllers.RepairApi
             foreach (var area in areas)
             {
                 //查询要复制区域的能力标准点 
-                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<Ability>(queryText: $"select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Ability-{area.standard}") }))
+                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIteratorSql<Ability>(queryText: $"select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Ability-{area.standard}") }))
                 {
                     if (!string.IsNullOrEmpty(item.blob))
                     {
@@ -225,7 +222,7 @@ namespace TEAMModelBI.Controllers.RepairApi
                 try
                 {
                     //微能力点
-                    await foreach (var atask in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<AbilityTask>(queryText: $"select value(c) from c ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"AbilityTask-{area.standard}") }))
+                    await foreach (var atask in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIteratorSql<AbilityTask>(queryText: $"select value(c) from c ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"AbilityTask-{area.standard}") }))
                     {
                         List<Tnode> tnodes = new();
                         foreach (Tnode tnode in atask.children)
@@ -288,7 +285,7 @@ namespace TEAMModelBI.Controllers.RepairApi
             if (AreaS2 != null)
             {
                 //新政策文件
-                await foreach (StandardFile standardFile in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<StandardFile>(queryText: $"select value(c) from c where  c.id='{AreaS2.id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StandardFile") }))
+                await foreach (StandardFile standardFile in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIteratorSql<StandardFile>(queryText: $"select value(c) from c where  c.id='{AreaS2.id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StandardFile") }))
                 {
                     if (standardFile != null)
                     {
@@ -299,7 +296,7 @@ namespace TEAMModelBI.Controllers.RepairApi
                 }
 
                 //新的区域设置
-                await foreach (AreaSetting areaSetting in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<AreaSetting>(queryText: $"select value(c) from c where c.id='{AreaS2.id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("AreaSetting") }))
+                await foreach (AreaSetting areaSetting in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIteratorSql<AreaSetting>(queryText: $"select value(c) from c where c.id='{AreaS2.id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("AreaSetting") }))
                 {
                     if (areaSetting != null)
                     {

+ 2 - 2
TEAMModelBI/Controllers/RepairApi/NormalController.cs

@@ -1,4 +1,4 @@
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using DinkToPdf;
 using Microsoft.AspNetCore.Hosting;
 using Microsoft.AspNetCore.Http;
@@ -61,7 +61,7 @@ namespace TEAMModelBI.Controllers.RepairApi
             string sql = $"select value(c) from c where c.name = '{oldName}'";
 
             Area area = new();
-            await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<Area>(queryText: sql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base-Area") }))
+            await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIteratorSql<Area>(queryText: sql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base-Area") }))
             {
                 area = item;
             };

+ 15 - 17
TEAMModelBI/Controllers/RepairApi/SchoolRepController.cs

@@ -16,16 +16,14 @@ using System.Text;
 using TEAMModelOS.SDK.Extension;
 using System;
 using TEAMModelOS.SDK.Models;
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using System.Linq;
 using TEAMModelOS.SDK.Context.Constant;
 using Pipelines.Sockets.Unofficial.Arenas;
 using TEAMModelBI.Tool;
 using TEAMModelOS.SDK.Models.Cosmos.BI.BISchool;
 using TEAMModelOS.SDK.Models.Cosmos.BI;
-using DocumentFormat.OpenXml.Math;
 using TEAMModelOS.SDK.Models.Service.BI;
-using TEAMModelBI.Tool.CosmosBank;
 using TEAMModelOS.SDK.Models.Service.BIStatsWay;
 using StackExchange.Redis;
 using System.Text.RegularExpressions;
@@ -161,12 +159,12 @@ namespace TEAMModelBI.Controllers.RepairApi
             if (!string.IsNullOrEmpty($"{periodName}"))
                 scName = $"{periodName}";
 
-            await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<School>(queryText: "select value(c) from c where c.code='Base' and c.period=[]", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
+            await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIteratorSql<School>(queryText: "select value(c) from c where c.code='Base' and c.period=[]", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
             {
                 allSc.Add(item);
             }
 
-            await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<School>(queryText: noPeriodScSql.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
+            await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIteratorSql<School>(queryText: noPeriodScSql.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
             {
                 allSc.Add(item);
             }
@@ -420,10 +418,10 @@ namespace TEAMModelBI.Controllers.RepairApi
                 {
                     BIRelation bIRelation = null;
                     var resRel = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync(itemId, new PartitionKey("BIRel"));
-                    if (resRel.Status == 200)
+                    if (resRel.StatusCode == System.Net.HttpStatusCode.OK)
                     {
                         continue;
-                        //using var fileJson = await JsonDocument.ParseAsync(resRel.ContentStream);
+                        //using var fileJson = await JsonDocument.ParseAsync(resRel.Content);
                         //bIRelation = fileJson.ToObject<BIRelation>();
                     }
                     else
@@ -432,7 +430,7 @@ namespace TEAMModelBI.Controllers.RepairApi
                         string areaName = null;
                         if (!string.IsNullOrEmpty(scBaseInfo.areaId))
                         {
-                            await foreach (var itemName in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<string>(queryText: $"select value(c.name) from c where c.pk='Area' and c.id='{scBaseInfo.areaId}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base-Area") }))
+                            await foreach (var itemName in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIteratorSql<string>(queryText: $"select value(c.name) from c where c.pk='Area' and c.id='{scBaseInfo.areaId}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base-Area") }))
                             {
                                 areaName = itemName;
                             }
@@ -457,9 +455,9 @@ namespace TEAMModelBI.Controllers.RepairApi
                         };
 
                         var response = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync(itemId, new PartitionKey("ProductSum"));
-                        if (response.Status == 200)
+                        if (response.StatusCode == System.Net.HttpStatusCode.OK)
                         {
-                            using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                            using var json = await JsonDocument.ParseAsync(response.Content);
                             if (json.RootElement.TryGetProperty("serial", out JsonElement serial) && !serial.ValueKind.Equals(JsonValueKind.Null))
                             {
                                 List<string> serials = serial.ToObject<List<SchoolProductSumData>>().Select(x => x.prodCode).ToList();
@@ -529,9 +527,9 @@ namespace TEAMModelBI.Controllers.RepairApi
                     id = sc;
                     StatsInfo statsInfo = new();
                     var scDataStats = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Common").ReadItemStreamAsync($"{year}-{sc}", new PartitionKey("Statistics"));
-                    if (scDataStats.Status == 200)
+                    if (scDataStats.StatusCode == System.Net.HttpStatusCode.OK)
                     {
-                        using var fileJson = await JsonDocument.ParseAsync(scDataStats.ContentStream);
+                        using var fileJson = await JsonDocument.ParseAsync(scDataStats.Content);
                         statsInfo = fileJson.ToObject<StatsInfo>();
                     }
                     else
@@ -542,7 +540,7 @@ namespace TEAMModelBI.Controllers.RepairApi
                     statsInfo = await SchoolStatsWay.GetSingleSc(cosmosClient, redisClinet, sc, year);
                     statsInfo.witRoom = ((int)await SchoolStatsWay.GetShoolWisdomRoomCount(_azureCosmos, _azureRedis, _configuration, _httpClient, _dingDing, statsInfo.schoolId));
 
-                    if (scDataStats.Status == 200)
+                    if (scDataStats.StatusCode == System.Net.HttpStatusCode.OK)
                         taskStss.Add(cosmosClient.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync<StatsInfo>(statsInfo, $"{year}-{sc}", new PartitionKey("Statistics")));
                     else
                         taskStss.Add(cosmosClient.GetContainer(Constant.TEAMModelOS, "Common").CreateItemAsync<StatsInfo>(statsInfo, new PartitionKey("Statistics")));
@@ -640,9 +638,9 @@ namespace TEAMModelBI.Controllers.RepairApi
                 where += $"ARRAY_CONTAINS({schIdListStr}, c.id, true)";
             }
             qry = $"{qry}{where}";
-            await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: qry, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base") }))
+            await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIteratorSql(queryText: qry, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base") }))
             {
-                using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                using var json = await JsonDocument.ParseAsync(item.Content);
                 if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
                 {
                     foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
@@ -664,9 +662,9 @@ namespace TEAMModelBI.Controllers.RepairApi
                     whereBIRel += $"ARRAY_CONTAINS({schIdListStr}, c.id, true)";
                 }
                 qryBIRel = $"{qryBIRel}{whereBIRel}";
-                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: qryBIRel, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"BIRel") }))
+                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIteratorSql(queryText: qryBIRel, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"BIRel") }))
                 {
-                    using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                    using var json = await JsonDocument.ParseAsync(item.Content);
                     if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
                     {
                         foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())

+ 5 - 5
TEAMModelBI/Controllers/RepairApi/TeacherREPController.cs

@@ -1,4 +1,4 @@
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Mvc;
 using Pipelines.Sockets.Unofficial.Arenas;
@@ -41,7 +41,7 @@ namespace TEAMModelBI.Controllers.RepairApi
                 School school = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemAsync<School>($"{item}", new PartitionKey("Base"));
 
                 List<Teacher> teachers = new();
-                await foreach (var tch in cosmosClient.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<Teacher>(queryText: $"SELECT value(c) FROM c join s in c.schools where s.schoolId='dghznx' and c.code='Base'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
+                await foreach (var tch in cosmosClient.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIteratorSql<Teacher>(queryText: $"SELECT value(c) FROM c join s in c.schools where s.schoolId='dghznx' and c.code='Base'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
                 {
                     teachers.Add(tch);
                 }
@@ -75,7 +75,7 @@ namespace TEAMModelBI.Controllers.RepairApi
                 tchSql.Append($" where c.id='{tmdId}'");
 
             List<Teacher> tchs = new();
-            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<Teacher>(queryText: tchSql.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
+            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIteratorSql<Teacher>(queryText: tchSql.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
             {
                 tchs.Add(item);
             }
@@ -90,9 +90,9 @@ namespace TEAMModelBI.Controllers.RepairApi
                     foreach (var teacher in tch.schools)
                     {
                         var resSc = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync($"{teacher.schoolId}", new PartitionKey("Base"));
-                        if (resSc.Status == 200)
+                        if (resSc.StatusCode == System.Net.HttpStatusCode.OK)
                         {
-                            using var areaBase = await JsonDocument.ParseAsync(resSc.ContentStream);
+                            using var areaBase = await JsonDocument.ParseAsync(resSc.Content);
                             School school = areaBase.ToObject<School>();
                             if (teacher.areaId != school.areaId)
                                 teacher.areaId = school.areaId;

+ 32 - 0
TEAMModelBI/Filter/AspNetCoreBuilderServiceCollectionExtensions.cs

@@ -0,0 +1,32 @@
+using Google.Protobuf.WellKnownTypes;
+using Microsoft.AspNetCore.Mvc.Filters;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.Extensions.DependencyInjection;
+using System;
+
+namespace TEAMModelOS.Filter
+{
+    public static class AspNetCoreBuilderServiceCollectionExtensions
+    {  /// <summary>
+       /// 注册 Mvc 过滤器
+       /// </summary>
+       /// <typeparam name="TFilter"></typeparam>
+       /// <param name="services"></param>
+       /// <param name="configure"></param>
+       /// <returns></returns>
+        public static IServiceCollection AddMvcFilter<TFilter>(this IServiceCollection services, Action<MvcOptions> configure = default)
+            where TFilter : IFilterMetadata
+        {
+            services.Configure<MvcOptions>(options =>
+            {
+                options.Filters.Add<TFilter>();
+
+                // 其他额外配置
+                configure?.Invoke(options);
+            });
+
+            return services;
+        }
+    }
+
+}

+ 218 - 0
TEAMModelBI/Filter/RequestAuditFilter.cs

@@ -0,0 +1,218 @@
+using Microsoft.AspNetCore.Mvc.Controllers;
+using Microsoft.AspNetCore.Mvc.Filters;
+using System.Security.Claims;
+using System;
+using System.Threading.Tasks;
+using TEAMModelOS.SDK.Extension;
+using Microsoft.Extensions.Logging;
+using TEAMModelOS.SDK;
+using System.IdentityModel.Tokens.Jwt;
+using System.Linq;
+using Azure.Core;
+using TEAMModelOS.SDK.DI;
+using Microsoft.Extensions.Primitives;
+using System.Net.Http;
+using System.Net;
+using System.Net.Http.Json;
+using Microsoft.Extensions.Options;
+using TEAMModelOS.Models;
+
+namespace TEAMModelOS.Filter
+{
+    public class RequestAuditFilter : IAsyncActionFilter
+    {
+        //private readonly ILogger _logger;
+        private readonly IHttpClientFactory _httpClient;
+        private readonly DingDing _dingding;
+        private readonly Option _option; private string p = "bi";
+        public RequestAuditFilter(/*ILoggerFactory loggerFactory*/IHttpClientFactory httpClient, DingDing dingding, IOptionsSnapshot<Option> option)
+        {
+            //  _logger = loggerFactory.CreateLogger<RequestAuditFilter>();
+            _httpClient = httpClient;
+            _dingding=dingding;
+            _option = option?.Value;
+        }
+        public async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
+        {
+            try
+            {
+                string id = string.Empty, name = string.Empty, picture = string.Empty, school = string.Empty, scope = string.Empty, roles = string.Empty;
+                //============== 这里是执行方法之前获取数据 ====================
+
+                // 获取控制器、路由信息
+                //var actionDescriptor = context.ActionDescriptor as ControllerActionDescriptor;
+
+                // 获取请求的方法
+                //var method = actionDescriptor.MethodInfo;
+
+                // 获取 HttpContext 和 HttpRequest 对象
+                var httpContext = context.HttpContext;
+                string ua = httpContext.GetUserAgent();
+                var httpRequest = httpContext.Request;
+
+                // 获取客户端 Ipv4 地址
+                var remoteIPv4 = httpContext.GetRemoteIpAddressToIPv4();
+
+                // 获取请求的 Url 地址
+                // var requestUrl = httpRequest.GetRequestUrlAddress();
+
+
+                // 获取来源 Url 地址
+                var refererUrl = httpRequest.GetRefererUrlAddress();
+
+                // 获取请求参数(写入日志,需序列化成字符串后存储)
+                var parameters = context.ActionArguments;
+
+                // 获取操作人(必须授权访问才有值)"userId" 为你存储的 claims type,jwt 授权对应的是 payload 中存储的键名
+                //var userId = httpContext.User?.FindFirstValue("userId");
+                var authtoken = context.HttpContext.GetXAuth("AuthToken");
+                string tokenSha = string.Empty, client = string.Empty;
+                if (context.HttpContext.Request.Headers.TryGetValue("Authorization", out StringValues Authorization) && Authorization.Any())
+                {
+                    try
+                    {
+                        var jwt = new JwtSecurityTokenHandler().ReadJwtToken(Authorization.ToString().Replace("Bearer ", ""));
+                        client= roles = jwt.Claims.FirstOrDefault(claim => claim.Type.Equals("roles"))?.Value;
+                        tokenSha= ShaHashHelper.GetSHA1(Authorization.ToString());
+                    }
+                    catch (Exception ex)
+                    {
+                        // await _dingding.SendBotMsg($"{ex.Message}\n{ex.StackTrace}\n{Authorization}\n{httpRequest.PathBase}{httpRequest.Path}", GroupNames.成都开发測試群組);
+                    }
+                }
+                if (context.HttpContext.Request.Headers.TryGetValue("X-Auth-IdToken", out StringValues XAuthIdToken)  && XAuthIdToken.Any())
+                {
+                    try
+                    {
+                        var jwt = new JwtSecurityTokenHandler().ReadJwtToken(XAuthIdToken.ToString());
+                        id = jwt.Payload.Sub;
+                        name = jwt.Claims.FirstOrDefault(claim => claim.Type.Equals("name"))?.Value;
+                        if (string.IsNullOrEmpty(tokenSha))
+                        {
+                            tokenSha= ShaHashHelper.GetSHA1(XAuthIdToken.ToString());
+                        }
+                        scope="teacher";
+                    }
+                    catch (Exception ex)
+                    {
+                        await _dingding.SendBotMsg($"{ex.Message}\n{ex.StackTrace}\n{XAuthIdToken}\n{httpRequest.PathBase}{httpRequest.Path}", GroupNames.成都开发測試群組);
+                    }
+                }
+
+                if (context.HttpContext.Request.Headers.TryGetValue("X-Auth-School", out StringValues XAuthSchool) && XAuthSchool.Any())
+                {
+                    try
+                    {
+                        school = XAuthSchool.ToString();
+                    }
+                    catch (Exception ex) { }
+                }
+                if (context.HttpContext.Request.Headers.TryGetValue("X-Auth-ApiToken", out StringValues XAutApiToken) && XAutApiToken.Any())
+                {
+                    try
+                    {
+                        var jwt = new JwtSecurityTokenHandler().ReadJwtToken(XAutApiToken);
+                        id = jwt.Payload.Sub;
+
+                        if (string.IsNullOrEmpty(tokenSha))
+                        {
+                            tokenSha= jwt.Payload.Jti;
+                        }
+                        client="Open";
+                    }
+                    catch (Exception ex)
+                    {
+
+                        await _dingding.SendBotMsg($"{ex.Message}\n{ex.StackTrace}\n{XAutApiToken}\n{httpRequest.PathBase}{httpRequest.Path}", GroupNames.成都开发測試群組);
+                    }
+                }
+                if (!string.IsNullOrWhiteSpace(authtoken))
+                {
+                    try
+                    {
+                        var jwt = new JwtSecurityTokenHandler().ReadJwtToken(authtoken);
+                        id = jwt.Payload.Sub;
+                        school = $"{jwt.Payload.Azp}".Equals("true")|| $"{jwt.Payload.Azp}".Equals("false") ? "" : $"{jwt.Payload.Azp}";
+                        name = jwt.Claims.FirstOrDefault(claim => claim.Type.Equals("name"))?.Value;
+                        scope = jwt.Claims.FirstOrDefault(claim => claim.Type.Equals("scope"))?.Value;
+                        if (string.IsNullOrEmpty(tokenSha))
+                        {
+                            tokenSha= ShaHashHelper.GetSHA1(authtoken);
+                        }
+                    }
+                    catch (Exception ex)
+                    {
+                        await _dingding.SendBotMsg($"{ex.Message}\n{ex.StackTrace}\n{authtoken}\n{httpRequest.PathBase}{httpRequest.Path}", GroupNames.成都开发測試群組);
+                    }
+                }
+                string secChUaPlatform = string.Empty;
+                if (httpContext.Request.Headers.TryGetValue("Sec-Ch-Ua-Platform", out var values))
+                {
+                    secChUaPlatform = values.FirstOrDefault();
+                }
+                if (string.IsNullOrEmpty(tokenSha))
+
+                {
+                    tokenSha= ShaHashHelper.GetSHA1($"{ua}{remoteIPv4}{httpRequest.Host}{secChUaPlatform}");
+                }
+                // 请求时间
+                var requestedTime = DateTimeOffset.Now.GetGMTTime(8).ToUnixTimeMilliseconds();
+                //============== 这里是执行方法之后获取数据 ====================
+                var actionContext = await next();
+                // 获取返回的结果
+                // var returnResult = actionContext.Result;
+
+                // 判断是否请求成功,没有异常就是请求成功
+                // var isRequestSucceed = actionContext.Exception == null;
+
+                // 获取调用堆栈信息,提供更加简单明了的调用和异常堆栈
+                // var stackTrace = EnhancedStackTrace.Current();
+                // string region = await _searcher.SearchIpAsync(remoteIPv4);
+                //同一个账号,同一IP,同一接口,UA标识(UA标识随意切换则表示可能会存在DDOS),时间段
+                //_logger.LogInformation(new{ ua=httpContext.GetUserAgent(), ip=remoteIPv4,time=requestedTime,path =$"{httpRequest.PathBase}{httpRequest.Path}",host= $"{httpRequest.Host}", param=parameters,id ,name ,school,succeed =isRequestSucceed }.ToJsonString());
+
+                var data = new
+                {
+                    //ua =ua,
+                    ip = remoteIPv4,
+                    time = requestedTime,
+                    path = $"{httpRequest.PathBase}{httpRequest.Path}",
+                    host = $"{httpRequest.Host}",
+                    param = parameters,
+                    id = id,
+                    name = name,
+                    school = school,
+                    client = client,
+                    tid = tokenSha,
+                    scope = scope,
+                    // referer = refererUrl,
+                    //platform = secChUaPlatform,
+                    p = p,
+                    l = _option.Location.Contains("China", StringComparison.OrdinalIgnoreCase) ? "China" : "Global"
+                    //idToken=XAuthIdToken
+                };
+                var httpclient = _httpClient.CreateClient();
+                httpclient.Timeout=  TimeSpan.FromSeconds(10);
+#if DEBUG
+                var response = await httpclient.PostAsJsonAsync("http://cdhabook.teammodel.cn:8806/api/http-log", data);
+                //if (response.StatusCode==HttpStatusCode.OK) 
+                //{
+                //    string result =   await response.Content.ReadAsStringAsync();
+
+                //}
+#else
+            _=  httpclient.PostAsJsonAsync("http://cdhabook.teammodel.cn:8806/api/http-log",data);
+#endif
+                //   _ = _httpTrigger.RequestHttpTrigger(data, "China", "http-log");
+            }
+            catch (Exception ex)
+            {
+                await _dingding.SendBotMsg($"HTTP日志访问错误:{ex.Message}\n{ex.StackTrace}", GroupNames.成都开发測試群組);
+                var actionContext = await next();
+            }
+
+        }
+
+    }
+
+}

+ 23 - 0
TEAMModelBI/Models/AssistSchool.cs

@@ -131,6 +131,29 @@ namespace TEAMModelBI.Models
     {
         public string areaId { get; set; }
     }
+    //CoreService學校基本資料
+    public class CsSchoolBase
+    {
+        public string id { get; set; }
+        public string code { get; set; } //學校教育部代碼
+        public string name { get; set; }
+        public string countryId { get; set; }
+        public string countryName { get; set; }
+        public string provinceId { get; set; }
+        public string provinceName { get; set; }
+        public string cityId { get; set; }
+        public string cityName { get; set; }
+        public string distId { get; set; }
+        public string distName { get; set; }
+        public string address { get; set; }
+        public string source { get; set; }
+        public string shortCode { get; set; } //學校簡碼
+        public string lang { get; set; }
+        public string unitType { get; set; }
+        public string tel { get; set; }
+        public string type { get; set; }
+    }
+
     #region api解析
     /// <summary>
     /// api解析

+ 1 - 2
TEAMModelBI/Models/ItemInfo.cs

@@ -1,5 +1,4 @@
-using DocumentFormat.OpenXml.Office2010.ExcelAc;
-using System.Collections.Generic;
+using System.Collections.Generic;
 using TEAMModelOS.SDK.Models;
 
 namespace TEAMModelBI.Models

+ 41 - 0
TEAMModelBI/Models/Purchase.cs

@@ -0,0 +1,41 @@
+using System.Collections.Generic;
+
+namespace TEAMModelBI.Models
+{
+    /// <summary>
+    /// 統購授權 縣市名額
+    /// </summary>
+    public class PurchaseSeats
+    {
+        public string id { get; set; } //統購縣市名額ID 格式:{countryId}-{provinceId}-{cityId}-{districtId}-{產品代碼}
+        public string countryId { get; set; } //[String]國家代碼
+        public string provinceId { get; set; } //[String]省代碼
+        public string cityId { get; set; } //[String]市代碼
+        public string districtId { get; set; } //[String]區代碼
+        public string geoName { get; set; } //行政區名稱
+        public string prodCode { get; set; } //產品代碼
+        public long startDate { get; set; } //授權起始日期 unixtimestamp
+        public long endDate { get; set; } //授權終止日期 unixtimestamp
+        public int seats { get; set; } //名額數
+        public int number { get; set; } //產品數量、空間數
+        public int used { get; set; } //已領用名額數 (document並無此欄位,各校名額加總累計用)
+        public object aprule { get; set; } //產品擴充項
+        public string dataType { get; set; } //分區鍵:purchase
+    }
+    /// <summary>
+    /// 統購授權 各校名額
+    /// </summary>
+    public class PurchaseSchoolSeats
+    {
+        public string schoolCode { get; set; }
+        public string shortCode { get; set; }
+        public string schoolName { get; set; }
+        public int seats { get; set; }
+        public string id { get; set; } //統購學校名額ID 格式:{countryId}-{provinceId}-{cityId}-{districtId}-{產品代碼}-{學校簡碼}
+        public string purchaseId { get; set; } //統購縣市名額ID 格式:{countryId}-{provinceId}-{cityId}-{districtId}-{產品代碼}
+        public List<string> tmids { get; set; } = new List<string>(); //已申請的TMID
+        public int used { get; set; } //已領用名額數
+        public int ttl { get; set; } = -1;
+        public string dataType { get; set; } //分區鍵:purchaseSchool
+    }
+}

+ 12 - 2
TEAMModelBI/Models/RearEndMiddle.cs

@@ -27,7 +27,17 @@ namespace TEAMModelBI.Models
         public List<string> serial { get; set; }
         public List<string> service { get; set; }
         public List<string> hard { get; set; }
-
-
+        /// <summary>
+        /// 城市
+        /// </summary>
+        public string city { get; set; }
+        /// <summary>
+        /// 区/县/郡
+        /// </summary>
+        public string dist { get; set; }
+        /// <summary>
+        /// 區碼
+        /// </summary>
+        public string areaId { get; set; }     
     }
 }

+ 2 - 3
TEAMModelBI/Startup.cs

@@ -5,7 +5,6 @@ using Microsoft.AspNetCore.Hosting;
 using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Mvc;
 using Microsoft.AspNetCore.SpaServices;
-using Microsoft.Azure.Cosmos.Table;
 using Microsoft.Extensions.Configuration;
 using Microsoft.Extensions.DependencyInjection;
 using Microsoft.Extensions.Hosting;
@@ -26,6 +25,7 @@ using TEAMModelOS.SDK.Helper.Common.ReflectorExtensions;
 using TEAMModelOS.SDK.Models;
 using VueCliMiddleware;
 using System.Net.Http;
+using TEAMModelOS.Filter;
 
 namespace TEAMModelBI
 {
@@ -185,6 +185,7 @@ namespace TEAMModelBI
             });
             //等保安全性验证。
             services.AddScoped<SecurityHeadersAttribute>();
+            services.AddMvcFilter<RequestAuditFilter>();
             services.AddAntiforgery(options => options.HeaderName = "X-CSRF-TOKEN");
         }
 
@@ -233,8 +234,6 @@ namespace TEAMModelBI
 #endif
 
             });
-
-
         }
     }
 }

+ 4 - 4
TEAMModelBI/TEAMModelBI.csproj

@@ -1,7 +1,7 @@
 <Project Sdk="Microsoft.NET.Sdk.Web">
 
 	<PropertyGroup>
-		<TargetFramework>net6.0</TargetFramework>
+		<TargetFramework>net8.0</TargetFramework>
 		<RootNamespace>TEAMModelBI</RootNamespace>
 	</PropertyGroup>
 
@@ -65,9 +65,9 @@
 		<SpaRoot>ClientApp\</SpaRoot>
 		<DefaultItemExcludes>$(DefaultItemExcludes);$(SpaRoot)node_modules\**</DefaultItemExcludes>
 		<UserSecretsId>078b5d89-7d90-4f6a-88fc-7d96025990a8</UserSecretsId>
-		<Version>5.2312.6</Version>
-		<AssemblyVersion>5.2312.6.1</AssemblyVersion>
-		<FileVersion>5.2312.6.1</FileVersion>
+		<Version>5.2407.10</Version>
+		<AssemblyVersion>5.2407.10.1</AssemblyVersion>
+		<FileVersion>5.2407.10.1</FileVersion>
 		<Description>TEAMModelBI(BI)</Description>
 		<PackageReleaseNotes>BI版本说明版本切换标记2022000908</PackageReleaseNotes>
 		<PackageId>TEAMModelBI</PackageId>

+ 22 - 23
TEAMModelBI/Tool/CommonFind.cs

@@ -1,13 +1,12 @@
-using Azure.Cosmos;
-using DocumentFormat.OpenXml.Spreadsheet;
+using Microsoft.Azure.Cosmos;
 using System;
 using System.Collections.Generic;
 using System.Text;
 using System.Text.Json;
 using System.Threading.Tasks;
 using TEAMModelBI.Models;
+using TEAMModelOS.SDK.DI;
 using TEAMModelOS.SDK.Models;
-using TEAMModelOS.SDK.Models.Cosmos.Common;
 
 namespace TEAMModelBI.Tool
 {
@@ -26,9 +25,9 @@ namespace TEAMModelBI.Tool
             try
             {
                 string managerSql = $"SELECT DISTINCT REPLACE(c.code, 'Teacher-', '') AS schoolId, c.id, c.name FROM c WHERE ARRAY_CONTAINS(c.roles, '{roles}', true) AND c.pk = 'Teacher' AND c.status = 'join' AND c.code = 'Teacher-{schoolId}'";
-                await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: managerSql, requestOptions: new QueryRequestOptions() { }))
+                await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIteratorSql(queryText: managerSql, requestOptions: new QueryRequestOptions() { }))
                 {
-                    using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                    using var json = await JsonDocument.ParseAsync(item.Content);
                     foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
                     {
                         SchoolTeacherRoles str = new()
@@ -59,9 +58,9 @@ namespace TEAMModelBI.Tool
         {
             List<string> schoolIds = new();
             //string schoolSql = $"SELECT DISTINCT REPLACE(c.code,'Teacher-','') AS schoolId,c.code,c.roles,c.id,c.name From c where ARRAY_CONTAINS(c.roles,'assist',true) AND c.status = 'join' AND c.id='{tmdId}'";
-            //await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: schoolSql, requestOptions: new QueryRequestOptions() { }))
+            //await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIteratorSql(queryText: schoolSql, requestOptions: new QueryRequestOptions() { }))
             //{
-            //    using var json = await JsonDocument.ParseAsync(item.ContentStream);
+            //    using var json = await JsonDocument.ParseAsync(item.Content);
             //    foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
             //    {
             //        schoolIds.Add(obj.GetProperty("schoolId").GetString());
@@ -73,7 +72,7 @@ namespace TEAMModelBI.Tool
                 schoolSql.Append($" and (array_contains(c.roles,'assist',true) or array_contains(c.roles,'sales',true))");
             else
                 schoolSql.Append($" and array_contains(c.roles,'{roles}',true)");
-            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<string>(queryText: schoolSql.ToString(), requestOptions: new QueryRequestOptions() { }))
+            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIteratorSql<string>(queryText: schoolSql.ToString(), requestOptions: new QueryRequestOptions() { }))
             {
                 schoolIds.Add(item);
             }
@@ -92,7 +91,7 @@ namespace TEAMModelBI.Tool
         public static async Task<List<string>> GetValueSingle(CosmosClient cosmosClient, string container, string sqlTxt, string code = null)
         {
             List<string> ids = new();
-            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", container).GetItemQueryIterator<string>(queryText: sqlTxt, requestOptions: !string.IsNullOrEmpty(code) ? new QueryRequestOptions() { PartitionKey = new PartitionKey(code) } : new QueryRequestOptions() { })) 
+            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", container).GetItemQueryIteratorSql<string>(queryText: sqlTxt, requestOptions: !string.IsNullOrEmpty(code) ? new QueryRequestOptions() { PartitionKey = new PartitionKey(code) } : new QueryRequestOptions() { })) 
             {
                 ids.Add(item);
             }
@@ -112,9 +111,9 @@ namespace TEAMModelBI.Tool
         public async Task<List<string>> GetStreamSingle(CosmosClient cosmosClient, string container, string sqlTxt, string single = "id", string code = null)
         {
             List<string> ids = new();
-            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", container).GetItemQueryStreamIterator(queryText: sqlTxt, requestOptions: !string.IsNullOrEmpty(code) ? new QueryRequestOptions() { PartitionKey = new PartitionKey(code) } : new QueryRequestOptions() { }))
+            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", container).GetItemQueryStreamIteratorSql(queryText: sqlTxt, requestOptions: !string.IsNullOrEmpty(code) ? new QueryRequestOptions() { PartitionKey = new PartitionKey(code) } : new QueryRequestOptions() { }))
             {
-                using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                using var json = await JsonDocument.ParseAsync(item.Content);
                 foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
                 {
                     ids.Add(obj.GetProperty(single).GetString());
@@ -134,14 +133,14 @@ namespace TEAMModelBI.Tool
         public static async Task<List<string>> FindScIds(CosmosClient cosmosClient, string sqlTxt, string code)
         {
             List<string> schoolIds = new();
-            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<string>(queryText: sqlTxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey(code) }))
+            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIteratorSql<string>(queryText: sqlTxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey(code) }))
             {
                 schoolIds.Add(item);
             }
 
-            //await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: sqlTxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey(code) }))
+            //await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIteratorSql(queryText: sqlTxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey(code) }))
             //{
-            //    using var json = await JsonDocument.ParseAsync(item.ContentStream);
+            //    using var json = await JsonDocument.ParseAsync(item.Content);
             //    foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
             //    {
             //        schoolIds.Add(obj.GetProperty("id").GetString());
@@ -170,14 +169,14 @@ namespace TEAMModelBI.Tool
             foreach (var school in schools) 
             {
                 string sqlTxt = $"select value(c.id) from c where ARRAY_CONTAINS(c.roles,'{rolesName}',true) and c.status = 'join'";
-                await foreach (var itemTeac in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<string>(queryText: sqlTxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Teacher-{school}") }))
+                await foreach (var itemTeac in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIteratorSql<string>(queryText: sqlTxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Teacher-{school}") }))
                 {
                     teachers.Add(itemTeac);
                 }
                 //string sqlTxt = $"select c.id from c where ARRAY_CONTAINS(c.roles,'{rolesName}',true) and c.status = 'join'";
-                //await foreach (var itemTeac in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: sqlTxt, requestOptions: new QueryRequestOptions() {PartitionKey =new PartitionKey($"Teacher-{school}") }))
+                //await foreach (var itemTeac in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIteratorSql(queryText: sqlTxt, requestOptions: new QueryRequestOptions() {PartitionKey =new PartitionKey($"Teacher-{school}") }))
                 //{
-                //    using var json = await JsonDocument.ParseAsync(itemTeac.ContentStream);
+                //    using var json = await JsonDocument.ParseAsync(itemTeac.Content);
                 //    foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
                 //    {
                 //        teachers.Add(obj.GetProperty("id").GetString());
@@ -200,7 +199,7 @@ namespace TEAMModelBI.Tool
             int totals = 0;
             try
             {
-                await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", container).GetItemQueryIterator<int>(queryText: SqlTxt, requestOptions: string.IsNullOrEmpty(code) ? new QueryRequestOptions() { } : new QueryRequestOptions() { PartitionKey = new PartitionKey($"{code}") }))
+                await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", container).GetItemQueryIteratorSql<int>(queryText: SqlTxt, requestOptions: string.IsNullOrEmpty(code) ? new QueryRequestOptions() { } : new QueryRequestOptions() { PartitionKey = new PartitionKey($"{code}") }))
                 {
                     totals = item;
                 }
@@ -223,7 +222,7 @@ namespace TEAMModelBI.Tool
             int totals = 0;
             foreach (var container in containers)
             {
-                await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", container).GetItemQueryIterator<int>(queryText: SqlTxt, requestOptions: string.IsNullOrEmpty(code) ? new QueryRequestOptions() { } : new QueryRequestOptions() { PartitionKey = new PartitionKey(code) }))
+                await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", container).GetItemQueryIteratorSql<int>(queryText: SqlTxt, requestOptions: string.IsNullOrEmpty(code) ? new QueryRequestOptions() { } : new QueryRequestOptions() { PartitionKey = new PartitionKey(code) }))
                 {
                     totals += item;
                 }
@@ -243,7 +242,7 @@ namespace TEAMModelBI.Tool
         public static async Task<double> GetSqlValueDoubleCounnt(CosmosClient cosmosClient, string container, string SqlTxt, string code = null)
         {
             double totals = 0;
-            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", container).GetItemQueryIterator<double>(queryText: SqlTxt, requestOptions: string.IsNullOrEmpty(code) ? new QueryRequestOptions() { } : new QueryRequestOptions() { PartitionKey = new PartitionKey(code) }))
+            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", container).GetItemQueryIteratorSql<double>(queryText: SqlTxt, requestOptions: string.IsNullOrEmpty(code) ? new QueryRequestOptions() { } : new QueryRequestOptions() { PartitionKey = new PartitionKey(code) }))
             {
                 totals = item;
             }
@@ -264,7 +263,7 @@ namespace TEAMModelBI.Tool
             double totals = 0;
             foreach (var container in containers)
             {
-                await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", container).GetItemQueryIterator<double>(queryText: SqlTxt, requestOptions: string.IsNullOrEmpty(code) ? new QueryRequestOptions() { } : new QueryRequestOptions() { PartitionKey = new PartitionKey(code) }))
+                await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", container).GetItemQueryIteratorSql<double>(queryText: SqlTxt, requestOptions: string.IsNullOrEmpty(code) ? new QueryRequestOptions() { } : new QueryRequestOptions() { PartitionKey = new PartitionKey(code) }))
                 {
                     totals += item;
                 }
@@ -287,7 +286,7 @@ namespace TEAMModelBI.Tool
             List<T> temps = new();
             foreach (var container in containers)
             {
-                await foreach (var items in cosmosClient.GetContainer("TEAMModelOS", container).GetItemQueryIterator<T>(queryText: sqlTxt, requestOptions: string.IsNullOrEmpty(code) ? new QueryRequestOptions() { } : new QueryRequestOptions() { PartitionKey = new PartitionKey(code) }))
+                await foreach (var items in cosmosClient.GetContainer("TEAMModelOS", container).GetItemQueryIteratorSql<T>(queryText: sqlTxt, requestOptions: string.IsNullOrEmpty(code) ? new QueryRequestOptions() { } : new QueryRequestOptions() { PartitionKey = new PartitionKey(code) }))
                 {
                     temps.Add(items);
                 }
@@ -307,7 +306,7 @@ namespace TEAMModelBI.Tool
         public static async Task<List<T>> GetObject<T>(CosmosClient cosmosClient, string containers, string sqlTxt, string code = null)
         {
             List<T> temps = new();
-            await foreach (var items in cosmosClient.GetContainer("TEAMModelOS", containers).GetItemQueryIterator<T>(queryText: sqlTxt, requestOptions: string.IsNullOrEmpty(code) ? new QueryRequestOptions() { } : new QueryRequestOptions() { PartitionKey = new PartitionKey(code) }))
+            await foreach (var items in cosmosClient.GetContainer("TEAMModelOS", containers).GetItemQueryIteratorSql<T>(queryText: sqlTxt, requestOptions: string.IsNullOrEmpty(code) ? new QueryRequestOptions() { } : new QueryRequestOptions() { PartitionKey = new PartitionKey(code) }))
             {
                 temps.Add(items);
             }

+ 8 - 7
TEAMModelBI/Tool/CosmosBank/ActivityWay.cs

@@ -1,7 +1,8 @@
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using System.Collections.Generic;
 using System.Text.Json;
 using System.Threading.Tasks;
+using TEAMModelOS.SDK.DI;
 
 namespace TEAMModelBI.Tool.CosmosBank
 {
@@ -28,9 +29,9 @@ namespace TEAMModelBI.Tool.CosmosBank
                     {
                         foreach (string sc in scIds)
                         {
-                            await foreach (var itemTeac in cosmosClient.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIterator(queryText: sqlTxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"{type}-{sc}") }))
+                            await foreach (var itemTeac in cosmosClient.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIteratorSql(queryText: sqlTxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"{type}-{sc}") }))
                             {
-                                using var json = await JsonDocument.ParseAsync(itemTeac.ContentStream);
+                                using var json = await JsonDocument.ParseAsync(itemTeac.Content);
                                 if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetInt32() > 0)
                                 {
                                     foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
@@ -46,9 +47,9 @@ namespace TEAMModelBI.Tool.CosmosBank
                     {
                         foreach (string sc in scIds)
                         {
-                            await foreach (var itemTeac in cosmosClient.GetContainer("TEAMModelOS", "Teacher").GetItemQueryStreamIterator(queryText: sqlTxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"{type}-{sc}") }))
+                            await foreach (var itemTeac in cosmosClient.GetContainer("TEAMModelOS", "Teacher").GetItemQueryStreamIteratorSql(queryText: sqlTxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"{type}-{sc}") }))
                             {
-                                using var json = await JsonDocument.ParseAsync(itemTeac.ContentStream);
+                                using var json = await JsonDocument.ParseAsync(itemTeac.Content);
                                 if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetInt32() > 0)
                                 {
                                     foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
@@ -81,7 +82,7 @@ namespace TEAMModelBI.Tool.CosmosBank
                 foreach (string type in types)
                 {
                     string sqlTxt = $"select value(count(c.id)) from c where c.pk='{type}' {condSql}";
-                    await foreach (var cnt in cosmosClient.GetContainer("TEAMModelOS", container).GetItemQueryIterator<int>(queryText: sqlTxt, requestOptions: string.IsNullOrEmpty($"{code}") ? new QueryRequestOptions() { } : new QueryRequestOptions() { PartitionKey = new PartitionKey($"{code}") }))
+                    await foreach (var cnt in cosmosClient.GetContainer("TEAMModelOS", container).GetItemQueryIteratorSql<int>(queryText: sqlTxt, requestOptions: string.IsNullOrEmpty($"{code}") ? new QueryRequestOptions() { } : new QueryRequestOptions() { PartitionKey = new PartitionKey($"{code}") }))
                     {
                         total += cnt;
                     }
@@ -110,7 +111,7 @@ namespace TEAMModelBI.Tool.CosmosBank
                     foreach (string type in types)
                     {
                         string sqlTxt = $"select value(count(c.id)) from c where c.pk='{type}' {condSql}";
-                        await foreach (var cnt in cosmosClient.GetContainer("TEAMModelOS", container).GetItemQueryIterator<int>(queryText: sqlTxt, requestOptions: string.IsNullOrEmpty($"{code}") ? new QueryRequestOptions() { } : new QueryRequestOptions() { PartitionKey = new PartitionKey($"{code}") }))
+                        await foreach (var cnt in cosmosClient.GetContainer("TEAMModelOS", container).GetItemQueryIteratorSql<int>(queryText: sqlTxt, requestOptions: string.IsNullOrEmpty($"{code}") ? new QueryRequestOptions() { } : new QueryRequestOptions() { PartitionKey = new PartitionKey($"{code}") }))
                         {
                             total += cnt;
                         }

+ 5 - 4
TEAMModelBI/Tool/CosmosBank/JointlySingleQuery1.cs

@@ -1,6 +1,7 @@
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using System.Collections.Generic;
 using System.Threading.Tasks;
+using TEAMModelOS.SDK.DI;
 
 namespace TEAMModelBI.Tool.CosmosBank
 {
@@ -25,7 +26,7 @@ namespace TEAMModelBI.Tool.CosmosBank
 
             foreach (string conId in containerId) 
             {
-                await foreach (var itemInt in cosmosClient.GetContainer("TEAMModelOS", conId).GetItemQueryIterator<int>(queryText: sql, requestOptions: string.IsNullOrEmpty($"{code}") ? new QueryRequestOptions() { } : new QueryRequestOptions() { PartitionKey = new PartitionKey($"{code}") }))
+                await foreach (var itemInt in cosmosClient.GetContainer("TEAMModelOS", conId).GetItemQueryIteratorSql<int>(queryText: sql, requestOptions: string.IsNullOrEmpty($"{code}") ? new QueryRequestOptions() { } : new QueryRequestOptions() { PartitionKey = new PartitionKey($"{code}") }))
                 {
                     totals += itemInt;
                 }
@@ -51,7 +52,7 @@ namespace TEAMModelBI.Tool.CosmosBank
                 sql = sqlTxt;
             }
 
-            await foreach (var itemInt in cosmosClient.GetContainer("TEAMModelOS", container).GetItemQueryIterator<int>(queryText: sql, requestOptions: string.IsNullOrEmpty($"{code}") ? new QueryRequestOptions() { } : new QueryRequestOptions() { PartitionKey = new PartitionKey($"{code}") }))
+            await foreach (var itemInt in cosmosClient.GetContainer("TEAMModelOS", container).GetItemQueryIteratorSql<int>(queryText: sql, requestOptions: string.IsNullOrEmpty($"{code}") ? new QueryRequestOptions() { } : new QueryRequestOptions() { PartitionKey = new PartitionKey($"{code}") }))
             {
                 totals += itemInt;
             }
@@ -71,7 +72,7 @@ namespace TEAMModelBI.Tool.CosmosBank
         {
             List<string> strList = new();
 
-            await foreach (var itemInt in cosmosClient.GetContainer("TEAMModelOS", containerId).GetItemQueryIterator<string>(queryText: sqlTxt, requestOptions: string.IsNullOrEmpty($"{code}") ? new QueryRequestOptions() { } : new QueryRequestOptions() { PartitionKey = new PartitionKey($"{code}") }))
+            await foreach (var itemInt in cosmosClient.GetContainer("TEAMModelOS", containerId).GetItemQueryIteratorSql<string>(queryText: sqlTxt, requestOptions: string.IsNullOrEmpty($"{code}") ? new QueryRequestOptions() { } : new QueryRequestOptions() { PartitionKey = new PartitionKey($"{code}") }))
             {
                 strList.Add(itemInt);
             }

+ 4 - 3
TEAMModelBI/Tool/CosmosBank/ProductWay.cs

@@ -1,8 +1,9 @@
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using System.Collections.Generic;
 using System.Text.Json;
 using System.Threading.Tasks;
 using TEAMModelBI.Models;
+using TEAMModelOS.SDK.DI;
 using TEAMModelOS.SDK.Models;
 
 namespace TEAMModelBI.Tool.CosmosBank
@@ -25,9 +26,9 @@ namespace TEAMModelBI.Tool.CosmosBank
             foreach (var sc in scIds) 
             {
                 string sqlTxt = $"select array_length(c.service) as totals from c where c.id='{sc.id}'";
-                await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: sqlTxt.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("ProductSum") }))
+                await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIteratorSql(queryText: sqlTxt.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("ProductSum") }))
                 {
-                    using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                    using var json = await JsonDocument.ParseAsync(item.Content);
                     if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetInt16() > 0)
                     {
                         foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())

+ 4 - 3
TEAMModelBI/Tool/CosmosBank/SchoolWay.cs

@@ -1,10 +1,11 @@
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
 using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text.Json;
 using System.Threading.Tasks;
 using TEAMModelBI.Models;
+using TEAMModelOS.SDK.DI;
 using TEAMModelOS.SDK.Extension;
 using TEAMModelOS.SDK.Models;
 using TEAMModelOS.SDK.Models.Cosmos.BI;
@@ -25,7 +26,7 @@ namespace TEAMModelBI.Tool.CosmosBank
             List<BaseInfo> advSchools = new();
             foreach (var item in schoolIds)
             {
-                await foreach (var info in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<BaseInfo>(queryText: $"select c.id,c.name,c.picture,c.areaId from c where c.id='{item}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
+                await foreach (var info in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIteratorSql<BaseInfo>(queryText: $"select c.id,c.name,c.picture,c.areaId from c where c.id='{item}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
                 {
                     advSchools.Add(info);
                 }
@@ -51,7 +52,7 @@ namespace TEAMModelBI.Tool.CosmosBank
             {
                 BIRelation bIRelation = new();
                 var resBiRel = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(item, new PartitionKey($"BIRel"));
-                if (resBiRel.Status == 200)
+                if (resBiRel.StatusCode == System.Net.HttpStatusCode.OK)
                 {
                     JsonDocument jsonD = JsonDocument.Parse(resBiRel.Content);
                     bIRelation = jsonD.RootElement.ToObject<BIRelation>();

+ 11 - 20
TEAMModelBI/Tool/CosmosBank/StatsWay.cs

@@ -1,23 +1,14 @@
-using Azure.Cosmos;
-using DocumentFormat.OpenXml.Bibliography;
-using DocumentFormat.OpenXml.Math;
-using DocumentFormat.OpenXml.Office2010.Excel;
-using Microsoft.OData.Edm;
-using NUnit.Framework.Constraints;
-using OpenXmlPowerTools;
+using Microsoft.Azure.Cosmos;
 using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text.Json;
 using System.Threading.Tasks;
-using TEAMModelBI.Models;
+using TEAMModelOS.SDK.DI;
 using TEAMModelOS.SDK.Extension;
 using TEAMModelOS.SDK.Models;
 using TEAMModelOS.SDK.Models.Cosmos.BI;
-using TEAMModelOS.SDK.Models.Cosmos.BI.BITable;
 using TEAMModelOS.SDK.Models.Service.BI;
-using TEAMModelOS.SDK.Models.Service.BIStatsWay;
-using static TEAMModelBI.Tool.CosmosBank.StatsWay;
 
 namespace TEAMModelBI.Tool.CosmosBank
 {
@@ -118,7 +109,7 @@ namespace TEAMModelBI.Tool.CosmosBank
 
             List<LessRelStats> lessRelStats = new();
             string sql = $"select c.id,c.code,c.startTime,c.clientInteractionCount from c where c.pk='LessonRecord' and c.startTime >= {lastYearS} and c.startTime <= {yearE}";
-            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<LessRelStats>(queryText: sql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"LessonRecord-{id}") })) 
+            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIteratorSql<LessRelStats>(queryText: sql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"LessonRecord-{id}") })) 
             {
                 lessRelStats.Add(item);
             }
@@ -257,14 +248,14 @@ namespace TEAMModelBI.Tool.CosmosBank
                 {
                     case "Exam":
                         exam = await JointlySingleQuery.GetValueInt(cosmosClient, "Common", currSql, $"Exam-{scId}");
-                        await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Common").GetItemQueryIterator<ArtRelStats>(queryText: yearSql, requestOptions:new QueryRequestOptions() { PartitionKey = new PartitionKey($"Exam-{scId}")}))
+                        await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Common").GetItemQueryIteratorSql<ArtRelStats>(queryText: yearSql, requestOptions:new QueryRequestOptions() { PartitionKey = new PartitionKey($"Exam-{scId}")}))
                         {
                             examSts.Add(item);
                         }
                         break;
                     case "Survey":
                         survey = await JointlySingleQuery.GetValueInt(cosmosClient, "Common", currSql, $"Survey-{scId}");
-                        await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Common").GetItemQueryIterator<ArtRelStats>(queryText: yearSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Survey-{scId}") }))
+                        await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Common").GetItemQueryIteratorSql<ArtRelStats>(queryText: yearSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Survey-{scId}") }))
                         {
                             surveySts.Add(item);
                         }
@@ -272,14 +263,14 @@ namespace TEAMModelBI.Tool.CosmosBank
                         break;
                     case "Vote":
                         vote = await JointlySingleQuery.GetValueInt(cosmosClient, "Common", currSql, $"Vote-{scId}");
-                        await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Common").GetItemQueryIterator<ArtRelStats>(queryText: yearSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Vote-{scId}") }))
+                        await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Common").GetItemQueryIteratorSql<ArtRelStats>(queryText: yearSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Vote-{scId}") }))
                         {
                             voteSts.Add(item);
                         }
                         break;
                     case "Homework":
                         homework = await JointlySingleQuery.GetValueInt(cosmosClient, "Common", currSql, $"Homework-{scId}");
-                        await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Common").GetItemQueryIterator<ArtRelStats>(queryText: yearSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Homework-{scId}") }))
+                        await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Common").GetItemQueryIteratorSql<ArtRelStats>(queryText: yearSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Homework-{scId}") }))
                         {
                             homeworkSts.Add(item);
                         }
@@ -441,13 +432,13 @@ namespace TEAMModelBI.Tool.CosmosBank
             List<AreaStudy> trains = new();
 
             School school = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemAsync<School>($"{scId}", new PartitionKey("Base"));
-            //cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<string>(queryText:$"select value(c.areaId) from c where c.id='{scId}'", requestOptions:new QueryRequestOptions() { PartitionKey = new PartitionKey("Base")});
+            //cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIteratorSql<string>(queryText:$"select value(c.areaId) from c where c.id='{scId}'", requestOptions:new QueryRequestOptions() { PartitionKey = new PartitionKey("Base")});
 
             AreaSetting setting = null;
             var responSett = await cosmosClient.GetContainer("TEAMModelOS", "Normal").ReadItemStreamAsync($"{school.areaId}", new PartitionKey("AreaSetting"));
-            if (responSett.Status == 200)
+            if (responSett.StatusCode == System.Net.HttpStatusCode.OK)
             {
-                using var fileJson = await JsonDocument.ParseAsync(responSett.ContentStream);
+                using var fileJson = await JsonDocument.ParseAsync(responSett.Content);
                 setting = fileJson.ToObject<AreaSetting>();
             }
             if (setting == null)
@@ -463,7 +454,7 @@ namespace TEAMModelBI.Tool.CosmosBank
                 };
             }
 
-            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<AreaStudy>(queryText: $"select c.id,c.code,c.totalTime,c.onlineTime,c.offlineTime,c.classTime,c.currency from c where c.pk='TeacherTrain' and c.school='{scId}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"TeacherTrain-{scId}") }))
+            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIteratorSql<AreaStudy>(queryText: $"select c.id,c.code,c.totalTime,c.onlineTime,c.offlineTime,c.classTime,c.currency from c where c.pk='TeacherTrain' and c.school='{scId}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"TeacherTrain-{scId}") }))
             {
                 trains.Add(item);
             }

+ 4 - 2
TEAMModelBI/Tool/Extension/JwtAuth.cs

@@ -50,7 +50,8 @@ namespace TEAMModelBI.Models.Extension
             var securityKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(salt));
             // HmacSha256 有要求必须要大于 128 bits,所以 salt 不能太短,至少要 16 字元以上
             // https://stackoverflow.com/questions/47279947/idx10603-the-algorithm-hs256-requires-the-securitykey-keysize-to-be-greater
-            var signingCredentials = new SigningCredentials(securityKey, SecurityAlgorithms.HmacSha256Signature);
+            //var signingCredentials = new SigningCredentials(securityKey, SecurityAlgorithms.HmacSha256Signature);
+            var signingCredentials = new SigningCredentials(securityKey, SecurityAlgorithms.HmacSha256);
             var header = new JwtHeader(signingCredentials);
             var secToken = new JwtSecurityToken(header, payload);
             // 產出所需要的 JWT securityToken 物件,並取得序列化後的 Token 結果(字串格式)
@@ -93,7 +94,8 @@ namespace TEAMModelBI.Models.Extension
             var securityKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(salt));
             // HmacSha256 有要求必须要大于 128 bits,所以 salt 不能太短,至少要 16 字元以上
             // https://stackoverflow.com/questions/47279947/idx10603-the-algorithm-hs256-requires-the-securitykey-keysize-to-be-greater
-            var signingCredentials = new SigningCredentials(securityKey, SecurityAlgorithms.HmacSha256Signature);
+            //var signingCredentials = new SigningCredentials(securityKey, SecurityAlgorithms.HmacSha256Signature);
+            var signingCredentials = new SigningCredentials(securityKey, SecurityAlgorithms.HmacSha256);
             var header = new JwtHeader(signingCredentials);
             var secToken = new JwtSecurityToken(header, payload);
             // 产出所需要的 JWT securityToken 物件,并取得序列化后的 Token 结果(字串格式)

+ 1 - 2
TEAMModelBI/Tool/TimeHelper1.cs

@@ -1,5 +1,4 @@
-using DocumentFormat.OpenXml.Bibliography;
-using System;
+using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Threading.Tasks;

+ 3 - 1
TEAMModelBI/appsettings.Development.json

@@ -16,7 +16,9 @@
     "JwtSecretKey": "fXO6ko/qyXeYrkecPeKdgXnuLXf9vMEtnBC9OB3s+aA=",
     "Exp": 86400,
     "IdTokenSalt": "8263692E2213497BB55E74792B7900B4",
-    "HttpTrigger": "https://teammodelosfunction-test.chinacloudsites.cn/api/"
+    "HttpTrigger": "https://teammodelosfunction-test.chinacloudsites.cn/api/",
+	"Audience": "72643704-b2e7-4b26-b881-bd5865e7a7a5",
+    "Authority": "https://login.chinacloudapi.cn/4807e9cf-87b8-4174-aa5b-e76497d7392b/v2.0"
     //"HttpTrigger": "http://localhost:7071/api/"
   },
   //大陆站连接字符串 现在是测试站

+ 24 - 0
TEAMModelContest/Contest.Server/Contest.Server.csproj

@@ -0,0 +1,24 @@
+<Project Sdk="Microsoft.NET.Sdk.Web">
+
+  <PropertyGroup>
+    <TargetFramework>net8.0</TargetFramework>
+    <Nullable>enable</Nullable>
+    <ImplicitUsings>enable</ImplicitUsings>
+    <SpaRoot>..\contest.client</SpaRoot>
+    <SpaProxyLaunchCommand>npm run dev</SpaProxyLaunchCommand>
+    <SpaProxyServerUrl>https://localhost:5173</SpaProxyServerUrl>
+  </PropertyGroup>
+
+  <ItemGroup>
+    <ProjectReference Include="..\contest.client\contest.client.esproj">
+      <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
+    </ProjectReference>
+  </ItemGroup>
+
+  <ItemGroup>
+    <PackageReference Include="Microsoft.AspNetCore.SpaProxy">
+      <Version>6.*-*</Version>
+    </PackageReference>
+  </ItemGroup>
+
+</Project>

+ 15 - 0
TEAMModelContest/Contest.Server/Program.cs

@@ -0,0 +1,15 @@
+var builder = WebApplication.CreateBuilder(args);
+
+// Add services to the container.
+
+var app = builder.Build();
+
+app.UseDefaultFiles();
+app.UseStaticFiles();
+
+// Configure the HTTP request pipeline.
+app.UseHttpsRedirection();
+app.MapFallbackToFile("/index.html");
+app.Run();
+
+ 

+ 113 - 0
TEAMModelContest/Contest.Server/Properties/ServiceDependencies/contest - Web Deploy/profile.arm.json

@@ -0,0 +1,113 @@
+{
+  "$schema": "https://schema.management.azure.com/schemas/2018-05-01/subscriptionDeploymentTemplate.json#",
+  "contentVersion": "1.0.0.0",
+  "metadata": {
+    "_dependencyType": "compute.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": "contest",
+      "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')]"
+              }
+            }
+          ]
+        }
+      }
+    }
+  ]
+}

+ 113 - 0
TEAMModelContest/Contest.Server/Properties/ServiceDependencies/contest-test - Web Deploy/profile.arm.json

@@ -0,0 +1,113 @@
+{
+  "$schema": "https://schema.management.azure.com/schemas/2018-05-01/subscriptionDeploymentTemplate.json#",
+  "contentVersion": "1.0.0.0",
+  "metadata": {
+    "_dependencyType": "compute.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": "test",
+      "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')]"
+              }
+            }
+          ]
+        }
+      }
+    }
+  ]
+}

+ 113 - 0
TEAMModelContest/Contest.Server/Properties/ServiceDependencies/contest-test - Web Deploy1/profile.arm.json

@@ -0,0 +1,113 @@
+{
+  "$schema": "https://schema.management.azure.com/schemas/2018-05-01/subscriptionDeploymentTemplate.json#",
+  "contentVersion": "1.0.0.0",
+  "metadata": {
+    "_dependencyType": "compute.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": "test",
+      "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')]"
+              }
+            }
+          ]
+        }
+      }
+    }
+  ]
+}

+ 34 - 0
TEAMModelContest/Contest.Server/Properties/launchSettings.json

@@ -0,0 +1,34 @@
+{
+  "$schema": "https://json.schemastore.org/launchsettings.json",
+  "iisSettings": {
+    "windowsAuthentication": false,
+    "anonymousAuthentication": true,
+    "iisExpress": {
+      "applicationUrl": "http://localhost:7509",
+      "sslPort": 44333
+    }
+  },
+  "profiles": {
+    "Contest.Server": {
+      "commandName": "Project",
+      "dotnetRunMessages": true,
+      "launchBrowser": true,
+      "launchUrl": "weatherforecast",
+      "applicationUrl": "https://localhost:7024;http://localhost:5031",
+      "environmentVariables": {
+        "ASPNETCORE_ENVIRONMENT": "Development",
+        "ASPNETCORE_HOSTINGSTARTUPASSEMBLIES": "Microsoft.AspNetCore.SpaProxy"
+      }
+    },
+    "IIS Express": {
+      "commandName": "IISExpress",
+      "launchBrowser": true,
+      "launchUrl": "weatherforecast",
+      "environmentVariables": {
+        "ASPNETCORE_ENVIRONMENT": "Development",
+        "ASPNETCORE_HOSTINGSTARTUPASSEMBLIES": "Microsoft.AspNetCore.SpaProxy"
+      }
+    }
+  }
+}
+

+ 8 - 0
TEAMModelContest/Contest.Server/appsettings.Development.json

@@ -0,0 +1,8 @@
+{
+  "Logging": {
+    "LogLevel": {
+      "Default": "Information",
+      "Microsoft.AspNetCore": "Warning"
+    }
+  }
+}

+ 0 - 0
TEAMModelContest/Contest.Server/appsettings.json


Bu fark içinde çok fazla dosya değişikliği olduğu için bazı dosyalar gösterilmiyor