فهرست منبع

Merge branch 'develop5.0-tmd' into develop6.0-tmd

CrazyIter_Bin 3 سال پیش
والد
کامیت
41c8da4b15
29فایلهای تغییر یافته به همراه432 افزوده شده و 934 حذف شده
  1. 31 6
      TEAMModeBI/ClientApp/src/components/AbilityTree.vue
  2. 1 1
      TEAMModeBI/ClientApp/src/components/echarts/baseBar.vue
  3. 2 2
      TEAMModeBI/ClientApp/src/components/echarts/baseBarAcross.vue
  4. 1 1
      TEAMModeBI/ClientApp/src/components/echarts/basicPie.vue
  5. 25 13
      TEAMModeBI/ClientApp/src/view/created/created.vue
  6. 1 1
      TEAMModeBI/ClientApp/src/view/home.vue
  7. 4 2
      TEAMModeBI/ClientApp/src/view/index/dashboard.vue
  8. 19 14
      TEAMModeBI/ClientApp/src/view/teachermanage/school.vue
  9. 4 3
      TEAMModeBI/ClientApp/src/view/teachermanage/traitmanage.vue
  10. 36 0
      TEAMModeBI/Controllers/BISchool/SchoolController.cs
  11. 0 370
      TEAMModeBI/Controllers/DingDingStruc/DDDeptController.cs
  12. 66 358
      TEAMModeBI/Controllers/DingDingStruc/DDStructController.cs
  13. 7 4
      TEAMModeBI/Controllers/DingDingStruc/TableDingDingInfoController.cs
  14. 6 3
      TEAMModeBI/appsettings.Development.json
  15. 4 1
      TEAMModelOS.SDK/Models/Cosmos/Research/TeacherTrain.cs
  16. 139 99
      TEAMModelOS.SDK/Models/Service/StatisticsService.cs
  17. 17 13
      TEAMModelOS/ClientApp/src/view/abilityMgmt/Index.vue
  18. 6 6
      TEAMModelOS/ClientApp/src/view/areaSetting/AreaSetting.vue
  19. 32 12
      TEAMModelOS/ClientApp/src/view/jyzx/HomePage.vue
  20. 2 3
      TEAMModelOS/ClientApp/src/view/jyzx/HourDetail.vue
  21. 3 3
      TEAMModelOS/ClientApp/src/view/jyzx/index.vue
  22. 1 1
      TEAMModelOS/ClientApp/src/view/jyzx/newHomePage.vue
  23. 2 1
      TEAMModelOS/ClientApp/src/view/syllabus/Syllabus.vue
  24. 7 7
      TEAMModelOS/ClientApp/src/view/user/UserCenter.vue
  25. 1 0
      TEAMModelOS/Controllers/Analysis/ClassAnalysisController.cs
  26. 1 1
      TEAMModelOS/Controllers/Common/ExamController.cs
  27. 3 0
      TEAMModelOS/Controllers/Research/AbilityStatisticsController.cs
  28. 8 6
      TEAMModelOS/Controllers/School/ClassController.cs
  29. 3 3
      TEAMModelOS/TEAMModelOS.csproj

+ 31 - 6
TEAMModeBI/ClientApp/src/components/AbilityTree.vue

@@ -27,7 +27,7 @@
                         </span>
                         <template #dropdown>
                             <el-dropdown-menu>
-                                <el-dropdown-item @click="uploadFiles=true"><i class="el-icon-plus" @click="editAbility"></i>本地文件</el-dropdown-item>
+                                <el-dropdown-item @click="openUpload"><i class="el-icon-plus" @click="editAbility"></i>本地文件</el-dropdown-item>
                             </el-dropdown-menu>
                         </template>
                     </el-dropdown>
@@ -89,7 +89,7 @@
     <!--上传资源-->
     <div class="uploadFile">
         <el-dialog v-model="uploadFiles" title="新增资源" width="30%">
-            <el-upload class="upload-demo" drag action="" :auto-upload="false" :on-change="uploadResource">
+            <el-upload ref="uploadRef" class="upload-demo" drag action="" :auto-upload="false" :on-change="uploadResource" :file-list="nomarl">
                 <svg class="resource-upload" aria-hidden="true">
                     <use xlink:href="#icon-yunduanshangchuan"></use>
                 </svg>
@@ -169,6 +169,10 @@ export default {
         let uploadList = ref([])
         let changeShow = ref(false)
         let BlobContent = ref({})
+        //watch判断用,上传后不重新赋值
+        let watchModel = ref(true)
+        let uploadRef = ref()
+        let nomarl = ref([])
         onMounted(() => {
             resourceData = resourceData.push(...props.tree)
             console.log(props.tree, '树状')
@@ -379,6 +383,11 @@ export default {
                 detailsInfo.value.url ? (previewStates.value = true) : ''
             }
         }
+        //打开上传组件 顺便处理uploadLIst
+        function openUpload() {
+            nomarl.value = []
+            uploadFiles.value = true
+        }
         //上传资源
         function uploadResource(val) {
             console.log(val, '触发了')
@@ -389,6 +398,7 @@ export default {
         }
         //确认上传
         function confirmUpload() {
+            watchModel.value = false
             let urlHost = JSON.parse(localStorage.getItem('blobInfo'))
             let urlheader = urlHost.osblob_uri.substring(0, urlHost.osblob_uri.indexOf('cn') + 2)
             let space = urlHost.osblob_uri.slice(urlHost.osblob_uri.indexOf('cn') + 3)
@@ -454,14 +464,18 @@ export default {
             proxy.$api.addChild(datas).then((res) => {
                 console.log(res, '存储变更的返回')
                 res.state === 200 ? (ElMessage.success('储存变更成功'), (uploadList.value = [])) : ElMessage.error('储存变更失败')
+                uploadFileData.value = []
             })
+            setTimeout((watchModel.value = true), '2000')
         }
         //删除资源
         function deleteResource(val, index) {
+            watchModel.value = false
+            console.log(val)
             let urlHost = JSON.parse(localStorage.getItem('blobInfo'))
             let urlheader = urlHost.osblob_uri.substring(0, urlHost.osblob_uri.indexOf('cn') + 2)
             let space = urlHost.osblob_uri.slice(urlHost.osblob_uri.indexOf('cn') + 3)
-            console.log(val, index, '删除的信息')
+            console.log(val, index, uploadList, '删除的信息')
             ElMessageBox.confirm('确定要移除该资源吗?', '温馨提示', {
                 confirmButtonText: '确定',
                 cancelButtonText: '取消',
@@ -514,10 +528,17 @@ export default {
                             let datas = { tmdId: user.tmdId, tmdName: user.tmdName, standard: props.stand, abilityTask: [dataInfo] }
                             proxy.$api.addChild(datas).then((res) => {
                                 console.log(res, '删除的API返回')
-                                res.state === 200 ? ElMessage.success('删除成功') : ElMessage.error('删除失败')
+                                res.state === 200
+                                    ? (ElMessage.success('删除成功'),
+                                      uploadList.value.forEach((item, index) => {
+                                          item.blob === val.link ? uploadList.value.splice(index, 1) : ''
+                                      }))
+                                    : ElMessage.error('删除失败')
+                                setTimeout((watchModel.value = true), '2000')
                             })
                         } else {
                             ElMessage.warning('删除失败')
+                            setTimeout((watchModel.value = true), '2000')
                         }
                     })
                 })
@@ -581,8 +602,8 @@ export default {
             props,
             (nweProps) => {
                 nextTick(() => {
-                    console.log(fileList.value.id, '触发了监听')
-                    if (!fileList.value.id) {
+                    console.log(watchModel.value, '值')
+                    if (watchModel.value) {
                         treeRef.value.setCurrentKey(nweProps.defaultinfo)
                         fileList.value.id = nweProps.defaultinfo
                         curNode.value = nweProps.tree[0].rnodes
@@ -624,6 +645,10 @@ export default {
             changes,
             deleteResource,
             deleteChapter,
+            watchModel,
+            openUpload,
+            nomarl,
+            uploadRef,
         }
     },
 }

+ 1 - 1
TEAMModeBI/ClientApp/src/components/echarts/baseBar.vue

@@ -70,7 +70,7 @@ class InitChart {
             },
             grid: {
                 left: '0%',
-                top: '5%',
+                top: '10%',
                 right: '0%',
                 bottom: '0%',
                 containLabel: true,

+ 2 - 2
TEAMModeBI/ClientApp/src/components/echarts/baseBarAcross.vue

@@ -68,9 +68,9 @@ class InitChart {
             },
             grid: {
                 left: '0%',
-                top: '5%',
+                top: '10%',
                 right: '2%',
-                bottom: '1%',
+                bottom: '0%',
                 containLabel: true,
             },
             xAxis: [datas.xAxis],

+ 1 - 1
TEAMModeBI/ClientApp/src/components/echarts/basicPie.vue

@@ -68,7 +68,7 @@ class InitChart {
                 },
             },
             legend: {
-                top: '75%',
+                top: '85%',
                 itemWidth: 10,
                 itemHeight: 10,
                 data: datas.legendData,

+ 25 - 13
TEAMModeBI/ClientApp/src/view/created/created.vue

@@ -118,7 +118,7 @@
             </el-form>
         </div>
         <div class="submitbtn">
-            <el-button type="success" @click="createdArea">创建</el-button>
+            <el-button type="success" @click="createdArea();createdLoading=true" :loading="createdLoading">创建</el-button>
             <el-button type="info" @click="closeandreturn('close','area')">取消</el-button>
         </div>
     </div>
@@ -190,7 +190,7 @@
                 <el-button @click="addschool">添加学校</el-button>
             </div>
             <div>
-                <el-button type="primary" @click="createdSchool">提交创建</el-button>
+                <el-button type="primary" @click="createdSchool();createdSchoolLoading=true" :loading="createdSchoolLoading">提交创建</el-button>
                 <el-button @click="closeandreturn('close','school')">取消</el-button>
             </div>
         </ul>
@@ -231,17 +231,17 @@
                 <el-table :data="batchData" style="width: 100%">
                     <el-table-column prop="index" label="编号" width="100" type=index align="center" />
                     <el-table-column prop="name" label="名称" width="200" align="center" />
-                    <el-table-column prop="admin" label="管理关联账号" width="120" align="center" />
-                    <el-table-column prop="period" label="学段" width="100" align="center" />
+                    <el-table-column prop="admin" label="管理关联账号" width="150" align="center" />
+                    <el-table-column prop="period" label="学段" width="150" align="center" />
                     <el-table-column prop="size" label="空间大小" width="100" align="center" />
-                    <el-table-column prop="region" label="国家" width="80" align="center" />
-                    <el-table-column prop="province" label="省" width="80" align="center" />
-                    <el-table-column prop="city" label="市" width="80" align="center" />
-                    <el-table-column prop="dist" label="区" width="80" align="center" />
-                    <el-table-column prop="address" label="详细地址" width="200" align="center" />
+                    <el-table-column prop="region" label="国家" width="100" align="center" />
+                    <el-table-column prop="province" label="省" width="100" align="center" />
+                    <el-table-column prop="city" label="市" width="100" align="center" />
+                    <el-table-column prop="dist" label="区" width="100" align="center" />
+                    <el-table-column prop="address" label="详细地址" width="250" align="center" />
                 </el-table>
                 <div class="batchs-btn">
-                    <el-button type="primary" size="medium" @click="quantity">批量建立学校</el-button>
+                    <el-button type="primary" size="medium" @click="quantity();createdSchoolLoading=true" :loading="createdSchoolLoading">批量建立学校</el-button>
                 </div>
             </div>
         </div>
@@ -350,6 +350,9 @@ export default {
             distInfo: [],
             distValue: '',
         })
+        //创建区域btn loading
+        let createdLoading = ref(false)
+        let createdSchoolLoading = ref(false)
         provinceOptions.value.optionInfo = optionsData
         //地区选择器
         function onChange(e, val) {
@@ -422,7 +425,8 @@ export default {
                 tmdName: users.tmdName,
             }
             console.log(createdParame, '创区数据')
-            proxy.$api.createAreas(createdParame).then((res) => (res.state === 200 ? ElMessage.success('学区创建成功') : ElMessage.error('学区创建失败')))
+            proxy.$api.createAreas(createdParame).then((res) => (res.state === 200 ? (ElMessage.success('学区创建成功'), router.push({ path: '/home/areamanage' })) : ElMessage.error('学区创建失败')))
+            createdArea.value = false
         }
         onMounted(() => {
             formArea.value = JSON.parse(JSON.stringify(areaData))
@@ -474,7 +478,12 @@ export default {
             let parameter = { tmdId: users.tmdId, tmdName: users.tmdName, biSchools: datas, lang: JSON.parse(localStorage.getItem('language')) }
             console.log(parameter, '创建学校最后的数据格式')
             proxy.$api.createdSchools(parameter).then((res) => {
-                res.state === 200 ? ElMessage.success('创建成功') : res.state === 201 ? ElMessage.info('学校已存在,请勿重复创建') : ElMessage.error('创建失败,请检查数据内容')
+                res.state === 200
+                    ? (ElMessage.success('创建成功'), router.push({ path: '/home/schoolmanage' }))
+                    : res.state === 201
+                    ? ElMessage.info('学校已存在,请勿重复创建')
+                    : ElMessage.error('创建失败,请检查数据内容')
+                createdSchoolLoading.value = false
                 console.log(model, 'model值')
             })
         }
@@ -535,8 +544,9 @@ export default {
             proxy.$api.createdSchools(datas).then((res) => {
                 console.log(res, '批量创校的返回')
                 res.state === 200
-                    ? (ElMessage.success('批量创校成功'), (batchList.value = false), (batchData.value = []))
+                    ? (ElMessage.success('批量创校成功'), (batchList.value = false), (batchData.value = []), router.push({ path: '/home/schoolmanage' }))
                     : (ElMessage.error('批量创校失败'), (batchList.value = false), (batchData.value = []))
+                createdSchoolLoading.value = false
             })
         }
         function closeDialog(done) {
@@ -630,6 +640,8 @@ export default {
             distOptions,
             areaSelctChange,
             downloadModel,
+            createdLoading,
+            createdSchoolLoading,
         }
     },
 }

+ 1 - 1
TEAMModeBI/ClientApp/src/view/home.vue

@@ -1,6 +1,6 @@
 <template>
     <div class="common-layout viewbox">
-        <el-container style="height: 977px; border: 1px solid #eee">
+        <el-container style="height: 100vh; border: 1px solid #eee">
             <Aside></Aside>
             <el-container>
                 <el-header>

+ 4 - 2
TEAMModeBI/ClientApp/src/view/index/dashboard.vue

@@ -45,7 +45,7 @@
                     </div>
                 </div>
                 <div class="map">
-                    <div class="chart" v-loading="loading.map" element-loading-background="rgba(62,182,250, 0.5)">
+                    <div class="chart" v-loading="loading.map" element-loading-background="rgba(62,182,250, 0.3)">
                         <ChinaMap :mapData="mapData"></ChinaMap>
                     </div>
                     <div class="map1"></div>
@@ -393,6 +393,7 @@ ul > li {
     background: url('../../assets/img/dashboard-bg.jpg') no-repeat;
     background-size: cover;
     line-height: 1.15;
+    height: 100vh;
 }
 /*头部样式*/
 .headers {
@@ -419,6 +420,7 @@ ul > li {
     width: 100%;
     padding: 0.25rem 1.225rem 0;
     display: flex;
+    height: 85vh;
 }
 /*left one*/
 .column {
@@ -431,7 +433,7 @@ ul > li {
 }
 .mainBox .column .panel {
     position: relative;
-    height: 17rem;
+    height: 33%;
     border: 1px solid rgba(25, 186, 139, 0.17);
     background: url('../../assets/img/placeholder.png');
     padding: 0 1.1875rem 2.5rem;

+ 19 - 14
TEAMModeBI/ClientApp/src/view/teachermanage/school.vue

@@ -87,7 +87,7 @@
                 </el-form-item>
                 <el-form-item label="校徽:" class="school-form-badge">
                     <el-upload class="upload-demo" :headers="uploadHeader" action="/blob/upload-public" :before-upload="changeBadge" :on-exceed="handleExceed" :on-success="success" :on-error="handleUpdErr">
-                        <el-image style="width: 150px; height: 105px" :src="nowPitchdata.picture" fit="fill"></el-image>
+                        <el-image style="width: 125px; height:125px" :src="nowPitchdata.picture" fit="contain"></el-image>
                         <div class="changebadge">
                             <el-button>更 换</el-button>
                         </div>
@@ -102,7 +102,7 @@
                 </el-form-item>
                 <el-form-item label="当前管家:" class="school-form-admin">
                     <el-select v-model="adminvalue" placeholder="管家名单" multiple @change="assistChange">
-                        <el-option v-for="item in adminoptions" :key="item.name" :label="item.mobile+'——'+item.name" :value="item.tmdId ===null ? '':item.tmdId" :disabled="!item.isexist">
+                        <el-option v-for="item in adminoptions" :key="item.name" :label="item.mobile+'——'+item.name" :value="item.tmdId ===null ? '':item.tmdId" :disabled="!item.tmdId">
                             <!-- <span style="float: left">{{ item.mobile }}-{{item.name}}</span>
                             <i style="float: right;color: var(--el-text-color-secondary);font-size: 13px;" v-show="item.isexist === false">
                                 <svg class="school-admin-check" aria-hidden="true">
@@ -360,14 +360,18 @@ export default {
         }
         //获取所有的顾问API访问
         function getAllassists() {
-            let data = { deptId: '' }
-            proxy.$api.getAllassist(data).then((res) => {
-                res.state === 200 ? adminoptions.value.push(...res.dDAndTmdInfos) : ''
-            })
-            let dataA = { deptId: '67690917' }
-            proxy.$api.getAllassist(dataA).then((res) => {
-                console.log(res, '研发A')
-                res.state === 200 ? adminoptions.value.push(...res.dDAndTmdInfos) : ''
+            // let data = { deptId: '' }
+            // proxy.$api.getAllassist(data).then((res) => {
+            //     res.state === 200 ? adminoptions.value.push(...res.dDAndTmdInfos) : ''
+            // })
+            // let dataA = { deptId: '67690917' }
+            // proxy.$api.getAllassist(dataA).then((res) => {
+            //     console.log(res, '研发A')
+            //     res.state === 200 ? adminoptions.value.push(...res.dDAndTmdInfos) : ''
+            // })
+            proxy.$api.getEveryinfo({}).then((res) => {
+                console.log(res, '顾问返回')
+                res.state === 200 ? adminoptions.value.push(...res.ddUserInfos) : ''
             })
             console.log(adminoptions.value, '目前所有顾问')
         }
@@ -519,6 +523,10 @@ export default {
     padding: 4% 2%;
     border: 1px dashed #ccc;
 }
+.upload-demo {
+    width: 125px;
+    height: 125px;
+}
 .school-form-name {
     width: 50%;
 }
@@ -527,7 +535,7 @@ export default {
 }
 .school-form-badge,
 .school-form-code {
-    width: 20%;
+    width: 18%;
 }
 .school-form-grading {
     width: 45%;
@@ -569,7 +577,6 @@ export default {
 .dist-box {
     margin-left: 1%;
 }
-
 /*btn*/
 .boxselect {
     width: 60px;
@@ -721,13 +728,11 @@ export default {
 }
 .school-form-badge .el-form-item__content {
     border: 1px solid #ccc;
-    border-radius: 10px;
     position: relative;
 }
 .changebadge .el-button {
     width: 100%;
     height: 100%;
-    border-radius: 10px;
     font-size: 18px;
     color: #fff;
 }

+ 4 - 3
TEAMModeBI/ClientApp/src/view/teachermanage/traitmanage.vue

@@ -504,6 +504,7 @@ export default {
                 })
                 abilityData.value = []
                 abilityData.value.push(...res.abilities)
+                originalAbilityData.value = []
                 originalAbilityData.value.push(...res.abilities)
                 abilitylenth.value = res.abilities.length
                 for (let x in res.abilities) {
@@ -541,10 +542,10 @@ export default {
         async function getsectiontrre(standardName, ids) {
             let resultData = ''
             let datas = { standard: standardName, abilityId: ids }
-            await proxy.$api.getAbilityDeatils(datas).then((res) => {
-                console.log(res, '查询章节返回')
+            await proxy.$api.getAbilityDeatils(datas).then(async (res) => {
                 resultData = res.abilityTaskTreeNodes.length
-                ;(res.state === 200) !== 0 ? conductTree(res.abilityTaskTreeNodes) : ElMessage.error('章节数据API异常')
+                console.log(res, '查询章节返回')
+                ;(res.state === 200) !== 0 ? await conductTree(res.abilityTaskTreeNodes) : ElMessage.error('章节数据API异常')
             })
             return resultData
         }

+ 36 - 0
TEAMModeBI/Controllers/BISchool/SchoolController.cs

@@ -109,6 +109,8 @@ namespace TEAMModeBI.Controllers.BISchool
                     tmdId = $"{_tmdId}",
                     tmdName = $"{_tmdName}",
                     visitApi = "/schoolcheck/set-schooljoinarea",
+                    operateType = "修改",
+                    funModule = "学校",
                     operateTime = DateTime.Now,
                     operateDescribe = $"{_tmdName}【{_tmdId}】已操作学校加入区域功能,加入的区域:{standard},学校ID:{string.Join("|", schoolCodes.ToArray())}"
                 };
@@ -138,8 +140,42 @@ namespace TEAMModeBI.Controllers.BISchool
             }
         }
 
+        /// <summary>
+        /// 依据醍摩豆账户查询顾问管理学校的基础信息
+        /// </summary>
+        /// <param name="jsonElement"></param>
+        /// <returns></returns>
+        [HttpPost("get-assustschool")]
+        public async Task<IActionResult> GetAssistSchool(JsonElement jsonElement)
+        {
+            if (!jsonElement.TryGetProperty("tmdId", out JsonElement tmdId)) return BadRequest();
+            List<string> schoolIds = new List<string>();
+            List<object> schools = new List<object>();
+            var cosmosClient = _azureCosmos.GetCosmosClient();
+            string sqlTxt = $"SELECT DISTINCT REPLACE(c.code, 'Teacher-', '') AS schoolId FROM c WHERE c.pk = 'Teacher' AND c.status = 'join' AND ARRAY_CONTAINS(c.roles, 'assist', true) AND c.id='{tmdId}' ";
+            await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: sqlTxt, requestOptions: new QueryRequestOptions() { }))
+            {
+                using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
+                {
+                    schoolIds.Add(obj.GetProperty("schoolId").GetString());
+                }
+            }
 
+            foreach (var item in schoolIds)
+            {
+                await foreach (var itemBase in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: $"select c.id,c.code,c.name,c.picture,c.region,c.province,c.city,c.dist from c where c.id='{item}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
+                {
+                    var json = await JsonDocument.ParseAsync(itemBase.ContentStream);
+                    foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
+                    {
+                        schools.Add(obj.ToObject<object>());
+                    }
+                }
+            }
 
+            return Ok(new { state = 200, schools });
+        }
 
         /// <summary>
         /// 未加入区域的学校

+ 0 - 370
TEAMModeBI/Controllers/DingDingStruc/DDDeptController.cs

@@ -1,370 +0,0 @@
-using Microsoft.AspNetCore.Http;
-using Microsoft.AspNetCore.Mvc;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
-using Microsoft.Extensions.Configuration;
-using TEAMModelOS.SDK.DI;
-using TEAMModelOS.Models;
-using DingTalk.Api;
-using DingTalk.Api.Request;
-using DingTalk.Api.Response;
-using TEAMModelOS.SDK.Models.Cosmos.BI;
-using System.Text.Json;
-using Azure.Cosmos;
-
-namespace TEAMModeBI.Controllers.DingDingStruc
-{
-    [Route("branch")]
-    [ApiController]
-    public class DDDeptController : ControllerBase
-    {
-        private readonly IConfiguration _configuration;
-        //数据容器
-        private readonly AzureCosmosFactory _azureCosmos;
-        //钉钉提示信息
-        private readonly DingDing _dingDing;
-        private readonly Option _option;
-
-        public DDDeptController(IConfiguration configuration,AzureCosmosFactory azureCosmos)
-        {
-            _configuration = configuration;
-            _azureCosmos = azureCosmos;
-        }
-
-        #region   从钉钉拿数据存CosmosDB中
-
-        /// <summary>
-        /// 获取部门机构
-        /// </summary>
-        /// <returns></returns>
-        [ProducesDefaultResponseType]
-        [HttpPost("get-depts")]
-        public async Task<IActionResult> GetDDDepts() 
-        {
-            try
-            {
-                string appKey = _configuration["DingDingAuth:appKey"];
-                string appSecret = _configuration["DingDingAuth:appSecret"];
-                string agentld = _configuration["DingDingAuth:Agentld"];
-
-                //获取access_token
-                DefaultDingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/gettoken");
-                OapiGettokenRequest request = new OapiGettokenRequest() { Appkey = appKey, Appsecret = appSecret };
-                request.SetHttpMethod("Get");
-                OapiGettokenResponse response = client.Execute(request);
-                if (response.IsError)
-                {
-                    return BadRequest();
-                }
-
-                //access_token的有效期为7200秒(2小时),有效期内重复获取会返回相同结果并自动续期,过期后获取会返回新的access_token
-                string access_token = response.AccessToken;
-
-                //获取一级部门列表
-                IDingTalkClient V2departClient = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/v2/department/listsub");
-                OapiV2DepartmentListsubRequest reqPartment1 = new OapiV2DepartmentListsubRequest() { DeptId = 1L, Language = "zh_CN" };
-                OapiV2DepartmentListsubResponse rspPartment1 = V2departClient.Execute(reqPartment1, access_token);
-                if (rspPartment1.IsError)
-                {
-                    return BadRequest();
-                }
-
-                DeptNode deptNodes = new DeptNode();
-                deptNodes.id = agentld;
-                deptNodes.code = "DDPartment";
-                deptNodes.pk = "DDPartment";
-                deptNodes.ttl = -1;
-
-                List<DeptInfo> deptlist = new List<DeptInfo>();
-                if (rspPartment1.Result != null) 
-                {
-                    foreach (var depts in rspPartment1.Result) 
-                    {
-                        DeptInfo deptInfo = new DeptInfo();
-                        deptInfo.id = depts.DeptId;
-                        deptInfo.pid = depts.ParentId;
-                        deptInfo.name = depts.Name;
-
-                        //获取一级部门用户列表
-                        IDingTalkClient userListClient1 = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/user/listid");
-                        OapiUserListidRequest reqUsers1 = new OapiUserListidRequest() { DeptId = depts.DeptId };
-                        OapiUserListidResponse rspUsers1 = userListClient1.Execute(reqUsers1, access_token);
-                        if (rspUsers1.Result != null)
-                        {
-                            deptInfo.users = rspUsers1.Result.UseridList;
-                        }
-
-                        //获取二级部门列表
-                        OapiV2DepartmentListsubRequest reqPartment2 = new OapiV2DepartmentListsubRequest() { DeptId = depts.DeptId, Language = "zh_CN" };
-                        OapiV2DepartmentListsubResponse rspPartment2 = V2departClient.Execute(reqPartment2, access_token);
-                        if (rspPartment2.Result != null)
-                        {
-                            foreach (var depts2 in rspPartment2.Result)
-                            {
-                                DeptInfo deptInfo2 = new DeptInfo();
-                                deptInfo2.id = depts2.DeptId;
-                                deptInfo2.pid = depts2.ParentId;
-                                deptInfo2.name = depts2.Name;
-
-                                //获取三级部门用户列表
-                                OapiUserListidRequest reqUsers2 = new OapiUserListidRequest() { DeptId = depts2.DeptId };
-                                OapiUserListidResponse rspUsers2 = userListClient1.Execute(reqUsers2, access_token);
-                                if (rspUsers2.Result != null)
-                                {
-                                    //添加三级部门用户
-                                    deptInfo2.users = rspUsers2.Result.UseridList;
-                                }
-
-                                //获取三级部门列表
-                                OapiV2DepartmentListsubRequest reqPartment3 = new OapiV2DepartmentListsubRequest() { DeptId = depts2.DeptId, Language = "zh_CN" };
-                                OapiV2DepartmentListsubResponse rspPartment3 = V2departClient.Execute(reqPartment3, access_token);
-                                if (rspPartment3.Result != null) 
-                                {
-                                    foreach (var depts3 in rspPartment3.Result) 
-                                    {
-                                        DeptInfo deptInfo3 = new DeptInfo();
-                                        deptInfo3.id = depts3.DeptId;
-                                        deptInfo3.pid = depts3.ParentId;
-                                        deptInfo3.name = depts3.Name;
-
-                                        //获取三级部门用户列表
-                                        OapiUserListidRequest reqUsers3 = new OapiUserListidRequest() { DeptId = depts3.DeptId };
-                                        OapiUserListidResponse rspUsers3 = userListClient1.Execute(reqUsers3, access_token);
-                                        if (rspUsers3.Result != null)
-                                        {
-                                            //添加三级部门用户
-                                            deptInfo3.users = rspUsers3.Result.UseridList;
-                                        }
-
-                                        //获取四级部门列表
-                                        OapiV2DepartmentListsubRequest reqPartment4 = new OapiV2DepartmentListsubRequest() { DeptId = depts3.DeptId, Language = "zh_CN" };
-                                        OapiV2DepartmentListsubResponse rspPartment4 = V2departClient.Execute(reqPartment4, access_token);
-                                        if (rspPartment4.Result != null)
-                                        {
-                                            foreach (var depts4 in rspPartment4.Result)
-                                            {
-                                                DeptInfo deptInfo4 = new DeptInfo();
-                                                deptInfo4.id = depts4.DeptId;
-                                                deptInfo4.pid = depts4.ParentId;
-                                                deptInfo4.name = depts4.Name;
-
-                                                //获取四级部门用户列表
-                                                OapiUserListidRequest reqUsers4 = new OapiUserListidRequest() { DeptId = depts4.DeptId };
-                                                OapiUserListidResponse rspUsers4 = userListClient1.Execute(reqUsers4, access_token);
-                                                if (rspUsers4.Result != null)
-                                                {
-                                                    //添加四级部门用户
-                                                    deptInfo4.users = rspUsers4.Result.UseridList;
-                                                }
-
-                                                //获取五级部门列表
-                                                OapiV2DepartmentListsubRequest reqPartment5 = new OapiV2DepartmentListsubRequest() { DeptId = depts4.DeptId, Language = "zh_CN" };
-                                                OapiV2DepartmentListsubResponse rspPartment5 = V2departClient.Execute(reqPartment5, access_token);
-                                                if (rspPartment5.Result != null) 
-                                                {
-                                                    foreach (var depts5 in rspPartment5.Result)
-                                                    {
-                                                        DeptInfo deptInfo5 = new DeptInfo();
-                                                        deptInfo5.id = depts5.DeptId;
-                                                        deptInfo5.pid = depts5.ParentId;
-                                                        deptInfo5.name = depts5.Name;
-
-                                                        //获取五级部门用户列表
-                                                        OapiUserListidRequest reqUsers5 = new OapiUserListidRequest() { DeptId = depts4.DeptId };
-                                                        OapiUserListidResponse rspUsers5 = userListClient1.Execute(reqUsers4, access_token);
-                                                        if (rspUsers5.Result != null)
-                                                        {
-                                                            //添加四级部门用户
-                                                            deptInfo5.users = rspUsers5.Result.UseridList;
-                                                        }
-
-                                                        deptlist.Add(deptInfo5);
-                                                    }                                                    
-                                                }
-                                                deptlist.Add(deptInfo4);
-                                            }                                        
-                                        }
-                                        deptlist.Add(deptInfo3);
-                                    }
-                                }
-                                deptlist.Add(deptInfo2);
-                            }
-                        }
-                        deptlist.Add(deptInfo);
-                    }
-                }
-                deptNodes.depts = deptlist;
-                await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Normal").CreateItemAsync<DeptNode>(deptNodes, new Azure.Cosmos.PartitionKey($"DDPartment"));
-
-                return Ok(new { state = 200, message = "钉钉的组织架构添加到数据库成功", deptNodes = deptNodes });
-            }
-            catch (Exception ex)
-            {
-                return Ok(new { state = 1, message = $"访问失败!状态:{ex.StackTrace} 错误:{ex.Message}" });
-            }
-        }
-
-        /// <summary>
-        /// 获取钉钉离职员工列表
-        /// </summary>
-        /// <returns></returns>
-        [ProducesDefaultResponseType]
-        [HttpPost("get-quitstaff")]
-        public async Task<IActionResult> GetQuitStaff() 
-        {
-            try
-            {
-                string appKey = _configuration["DingDingAuth:appKey"];
-                string appSecret = _configuration["DingDingAuth:appSecret"];
-                string agentld = _configuration["DingDingAuth:Agentld"];
-
-                //获取access_token
-                DefaultDingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/gettoken");
-                OapiGettokenRequest request = new OapiGettokenRequest() { Appkey = appKey, Appsecret = appSecret };
-                request.SetHttpMethod("Get");
-                OapiGettokenResponse response = client.Execute(request);
-                if (response.IsError)
-                {
-                    return BadRequest();
-                }
-
-                //access_token的有效期为7200秒(2小时),有效期内重复获取会返回相同结果并自动续期,过期后获取会返回新的access_token
-                string access_token = response.AccessToken;
-                List<string> datalist =  new List<string>();
-                IDingTalkClient quitStaffClient = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/smartwork/hrm/employee/querydimission");
-                OapiSmartworkHrmEmployeeQuerydimissionRequest reqDimission = new OapiSmartworkHrmEmployeeQuerydimissionRequest() { Offset = 0L, Size = 50L };
-                OapiSmartworkHrmEmployeeQuerydimissionResponse rspDimission = quitStaffClient.Execute(reqDimission, access_token);
-                if (rspDimission.SubErrCode == "60011")
-                {
-                    return Ok(new { state = 60011,message= "没有调用该接口的权限!" });
-                }
-                else if (rspDimission.Result != null)
-                {
-                    datalist = rspDimission.Result.DataList;
-                    return Ok(new { state = 200, datalist = datalist });
-                }
-                else 
-                {
-                    return Ok(new { state = rspDimission.SubErrCode, message = rspDimission.Errmsg });
-                }
-            }
-            catch (Exception ex)
-            {
-                await _dingDing.SendBotMsg($"BI,{_option.Location},branch/get-quitstaff \n{ex.Message}{ex.StackTrace}", GroupNames.成都开发測試群組);
-                return BadRequest();
-            }
-        }
-
-
-
-
-
-
-        #endregion  
-
-        #region 从数据库获取(设置、修改、)钉钉组织架构信息
-
-        /// <summary>
-        /// 依据当前部门编号获取下级部门信息
-        /// </summary>
-        /// <param name="jsonElement"></param>
-        /// <returns></returns>
-        [ProducesDefaultResponseType]
-        [HttpPost("get-partment")]
-        public async Task<IActionResult> GetPartment(JsonElement jsonElement)
-        {
-            try
-            {
-                if (!jsonElement.TryGetProperty("pid", out JsonElement pid)) return BadRequest();
-
-                var client = _azureCosmos.GetCosmosClient();              
-                List<DeptInfo> deptInfos = new List<DeptInfo>();
-                string sqltxt = $"select a1.id,a1.pid,a1.name,a1.users from c join a1 IN c.depts where a1.pid={pid}";
-                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<DeptInfo>(queryText: sqltxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("DDPartment") }))
-                {
-                    deptInfos.Add(item);
-                }
-
-                return Ok(new { state = 200, deptInfos });
-            }
-            catch (Exception ex)
-            {
-                return Ok(new { state = 1, message = $"访问失败! 状态:{ex.StackTrace} 错误:{ex.Message}" });
-            }
-        }
-
-        /// <summary>
-        /// 依据当前部门编号和钉钉信息中的UserId查询所有父级部门编号  层次五层
-        /// </summary>
-        /// <param name="jsonElement"></param>
-        /// <returns></returns>
-        [ProducesDefaultResponseType]
-        [HttpPost("get-parentdept")]
-        public async Task<IActionResult> GetParentDept(JsonElement jsonElement)
-        {
-            try
-            {
-                if (!jsonElement.TryGetProperty("id", out JsonElement id)) return BadRequest();
-                if (!jsonElement.TryGetProperty("userid", out JsonElement userid)) return BadRequest();
-
-                var client = _azureCosmos.GetCosmosClient();
-                List<string> parentDept = new List<string>();
-                parentDept.Add(id.ToString());
-                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<DeptNode>(queryText: $"select * from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("DDPartment") }))
-                {
-                    DeptInfo deptInfo = item.depts.Find(x => x.id.Equals(long.Parse(id.ToString())));
-                    var name = deptInfo.users.Find(x => x.Equals(userid.ToString()));
-                    //if (name.Equals(userid.ToString()))
-                    if ($"{userid}".Equals(deptInfo.users.Find(x => x.Equals($"{userid}"))))
-                    {
-                        if (!deptInfo.pid.Equals(1))
-                        {
-                            parentDept.Add(deptInfo.pid.ToString());
-                            DeptInfo deptInfo1 = item.depts.Find(x => x.id.Equals(long.Parse($"{deptInfo.pid}")));
-                            if (!deptInfo1.pid.Equals(1))
-                            {
-                                parentDept.Add(deptInfo1.pid.ToString());
-                                DeptInfo deptInfo2 = item.depts.Find(x => x.id.Equals(long.Parse($"{deptInfo1.pid}")));
-                                if (!deptInfo2.pid.Equals(1))
-                                {
-                                    parentDept.Add(deptInfo2.pid.ToString());
-                                    DeptInfo deptInfo3 = item.depts.Find(x => x.id.Equals(long.Parse($"{deptInfo2.pid}")));
-                                    if (!deptInfo3.pid.Equals(1))
-                                    {
-                                        parentDept.Add(deptInfo3.pid.ToString());
-                                        DeptInfo deptInfo4 = item.depts.Find(x => x.id.Equals(long.Parse($"{deptInfo3.pid}")));
-                                        if (!deptInfo4.pid.Equals(1))
-                                        {
-                                            parentDept.Add(deptInfo4.pid.ToString());
-                                        }
-                                        else parentDept.Add(deptInfo4.pid.ToString());
-                                    }
-                                    else parentDept.Add(deptInfo3.pid.ToString());
-                                }
-                                else parentDept.Add(deptInfo2.pid.ToString());
-                            }
-                            else parentDept.Add(deptInfo1.pid.ToString());
-                        }
-                        else parentDept.Add(deptInfo.pid.ToString());
-                    }
-                    else
-                    {
-                        return Ok(new { state = 2, message = "该用户不在该组!" });
-                    }
-                }
-                return Ok(new { state = 200, parentDept = parentDept });
-            }
-            catch (Exception ex)
-            {
-                return Ok(new { state = 1, message = $"访问失败! 状态:{ex.StackTrace} 错误:{ex.Message}" });
-            }
-        }
-
-
-
-
-        #endregion
-    }
-}

+ 66 - 358
TEAMModeBI/Controllers/DingDingStruc/DDStructController.cs

@@ -51,37 +51,6 @@ namespace TEAMModeBI.Controllers.DingDingStruc
             _snowflakeId = snowflakeId;
         }
 
-        /// <summary>
-        /// 获取组织架构列表
-        /// </summary>
-        /// <returns></returns>
-        [ProducesDefaultResponseType]
-        [HttpPost("ddminstruc")]
-        public async Task<IActionResult> DDMainStruc()
-        {
-            string str_appKey = _configuration["DingDingAuth:appKey"];
-            string str_appSecret = _configuration["DingDingAuth:appSecret"];
-
-            //获取企业内部应用的accessToken
-            IDingTalkClient Iclient = new DefaultDingTalkClient("https://oapi.dingtalk.com/gettoken");
-            OapiGettokenRequest request = new OapiGettokenRequest();
-            request.Appkey = str_appKey;
-            request.Appsecret = str_appSecret;
-            request.SetHttpMethod("GET");
-            OapiGettokenResponse tokenResponse = Iclient.Execute(request);
-            if (tokenResponse.IsError)
-            {
-                return Ok(new { state = 0, message = "请检查配置" });
-            }
-            string access_token1 = tokenResponse.AccessToken;
-            IDingTalkClient dingTalkClient = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/org/union/trunk/get");
-            OapiOrgUnionTrunkGetRequest oapiOrgUnionTrunkGetRequest = new OapiOrgUnionTrunkGetRequest();
-            OapiOrgUnionTrunkGetResponse oapiOrgUnionTrunkGetResponse = dingTalkClient.Execute(oapiOrgUnionTrunkGetRequest, tokenResponse.AccessToken);
-
-            return Ok(new { oapiOrgUnionTrunkGetResponse.RequestId , oapiOrgUnionTrunkGetResponse.Body, oapiOrgUnionTrunkGetResponse.Result });
-
-        }
-
         /// <summary>
         /// 获取分支组织列表信息
         /// </summary>
@@ -312,70 +281,77 @@ namespace TEAMModeBI.Controllers.DingDingStruc
                 OapiV2UserListResponse rspV2UserList1 = userListClient.Execute(reqUserList1, access_token);
                 List<DDUserInfoAndTMD> dDAndTmdInfos = new List<DDUserInfoAndTMD>();
 
+                List<DingDingUserInfo> ddUserInfos = new List<DingDingUserInfo>();
+
                 if (rspV2UserList1.Result.List != null)
                 {
                     foreach (var itemUser in rspV2UserList1.Result.List)
                     {
-                        DDUserInfoAndTMD dDAndTmdInfo = new DDUserInfoAndTMD();
-                        dDAndTmdInfo.unionid = itemUser.Unionid;
-                        dDAndTmdInfo.userid = itemUser.Userid;
-                        dDAndTmdInfo.title = itemUser.Title;
-                        dDAndTmdInfo.name = itemUser.Name;
-                        dDAndTmdInfo.mobile = itemUser.Mobile;
-                        dDAndTmdInfo.jobNumber = itemUser.JobNumber;
-                        dDAndTmdInfo.avatar = itemUser.Avatar;
-                        dDAndTmdInfo.depts = itemUser.DeptIdList;
-
-                        List<string> roles = new List<string>();//角色列表
-                        List<string> power = new List<string>();//权限列表
-                        string sqltxt = $"select distinct value(c) from c join A1 in c.ddbinds where A1.userid ='{itemUser.Userid}'";
-                        try
+                        List<DingDingUserInfo> temp = await _azureStorage.FindListByDict<DingDingUserInfo>(new Dictionary<string, object> { { "RowKey", $"{itemUser.Userid}" } });
+                        foreach (var item in temp)
                         {
-                            await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<Teacher>(queryText: sqltxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
-                            {
-                                dDAndTmdInfo.tmdId = item.id;
-                                dDAndTmdInfo.isexist = true;
-
-                                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)
-                                    {
-                                        using var json = await JsonDocument.ParseAsync(schoolRoles.ContentStream);
-                                        if (json.RootElement.TryGetProperty("roles", out JsonElement _roles) && _roles.ValueKind != JsonValueKind.Null)
-                                        {
-                                            foreach (var obj in _roles.EnumerateArray())
-                                            {
-                                                //初始定义顾问的assistant 更改为assist
-                                                if (obj.GetString().Equals($"assist"))
-                                                {
-                                                    roles.Add(obj.GetString());
-                                                }
-                                            }
-                                        }
-                                        if (json.RootElement.TryGetProperty("permissions", out JsonElement _permissions) && _permissions.ValueKind != JsonValueKind.Null)
-                                        {
-                                            foreach (var obj in _permissions.EnumerateArray())
-                                            {
-                                                //显示BI权限
-                                                foreach (var aut in authorityBIList)
-                                                {
-                                                    if (aut.RowKey.Equals(obj.GetString()))
-                                                    {
-                                                        power.Add(obj.GetString());
-                                                    }
-                                                }
-                                            }
-                                        }
-                                    }
-
-                                    dDAndTmdInfo.tmdroles = roles;
-                                    dDAndTmdInfo.tmdpower = power;
-                                }
-                            }
+                            ddUserInfos.Add(item);
                         }
-                        catch { }
-                        dDAndTmdInfos.Add(dDAndTmdInfo);
+
+                        //DDUserInfoAndTMD dDAndTmdInfo = new DDUserInfoAndTMD();
+                        //dDAndTmdInfo.unionid = itemUser.Unionid;
+                        //dDAndTmdInfo.userid = itemUser.Userid;
+                        //dDAndTmdInfo.title = itemUser.Title;
+                        //dDAndTmdInfo.name = itemUser.Name;
+                        //dDAndTmdInfo.mobile = itemUser.Mobile;
+                        //dDAndTmdInfo.jobNumber = itemUser.JobNumber;
+                        //dDAndTmdInfo.avatar = itemUser.Avatar;
+                        //dDAndTmdInfo.depts = itemUser.DeptIdList;
+
+                        //List<string> roles = new List<string>();//角色列表
+                        //List<string> power = new List<string>();//权限列表
+                        //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") }))
+                        //    {
+                        //        dDAndTmdInfo.tmdId = item.id;
+                        //        dDAndTmdInfo.isexist = true;
+
+                        //        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)
+                        //            {
+                        //                using var json = await JsonDocument.ParseAsync(schoolRoles.ContentStream);
+                        //                if (json.RootElement.TryGetProperty("roles", out JsonElement _roles) && _roles.ValueKind != JsonValueKind.Null)
+                        //                {
+                        //                    foreach (var obj in _roles.EnumerateArray())
+                        //                    {
+                        //                        //初始定义顾问的assistant 更改为assist
+                        //                        if (obj.GetString().Equals($"assist"))
+                        //                        {
+                        //                            roles.Add(obj.GetString());
+                        //                        }
+                        //                    }
+                        //                }
+                        //                if (json.RootElement.TryGetProperty("permissions", out JsonElement _permissions) && _permissions.ValueKind != JsonValueKind.Null)
+                        //                {
+                        //                    foreach (var obj in _permissions.EnumerateArray())
+                        //                    {
+                        //                        //显示BI权限
+                        //                        foreach (var aut in authorityBIList)
+                        //                        {
+                        //                            if (aut.RowKey.Equals(obj.GetString()))
+                        //                            {
+                        //                                power.Add(obj.GetString());
+                        //                            }
+                        //                        }
+                        //                    }
+                        //                }
+                        //            }
+
+                        //            dDAndTmdInfo.tmdroles = roles;
+                        //            dDAndTmdInfo.tmdpower = power;
+                        //        }
+                        //    }
+                        //}
+                        //catch { }
                     }
                 }
 
@@ -473,7 +449,7 @@ namespace TEAMModeBI.Controllers.DingDingStruc
                         }
                     }
                 }
-                return Ok(new { state = 200, dDAndTmdInfos });
+                return Ok(new { state = 200, count = ddUserInfos.Count, ddUserInfos }) ;
             }
             catch (Exception ex)
             {
@@ -482,64 +458,6 @@ namespace TEAMModeBI.Controllers.DingDingStruc
             }
         }
 
-        /// <summary>
-        /// 获取当前用户的父级集合
-        /// </summary>
-        /// <param name="jsonElement"></param>
-        /// <returns></returns>
-        [ProducesDefaultResponseType]
-        [HttpPost("get-parentdept")]
-        public async Task<IActionResult> GetParentDept(JsonElement jsonElement) 
-        {
-            try
-            {
-                if (!jsonElement.TryGetProperty("userId", out JsonElement userId)) return Ok(new { state = 1, message = "参数错误!" });
-
-                string appKey = _configuration["DingDingAuth:appKey"];
-                string appSecret = _configuration["DingDingAuth:appSecret"];
-
-                //获取access_token
-                DefaultDingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/gettoken");
-                OapiGettokenRequest request = new OapiGettokenRequest();
-                request.Appkey = appKey;
-                request.Appsecret = appSecret;
-                request.SetHttpMethod("Get");
-                OapiGettokenResponse response = client.Execute(request);
-                if (response.IsError)
-                {
-                    return BadRequest();
-                }
-
-                //access_token的有效期为7200秒(2小时),有效期内重复获取会返回相同结果并自动续期,过期后获取会返回新的access_token
-                string access_token = response.AccessToken; 
-
-                IDingTalkClient v2DeartDeptClient = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/v2/department/listparentbyuser");
-                OapiV2DepartmentListparentbyuserRequest reqDeartDept = new OapiV2DepartmentListparentbyuserRequest() { Userid = userId.ToString() };
-                OapiV2DepartmentListparentbyuserResponse rspDeartDept = v2DeartDeptClient.Execute(reqDeartDept, access_token);
-
-                if (rspDeartDept.Result != null)
-                {
-                    List<long> userParentDept = new List<long>();
-                    //var parentDept = rspDeartDept.Result.ParentList;
-                    foreach (var temp in rspDeartDept.Result.ParentList)
-                    {
-                        foreach (var deptTemp in temp.ParentDeptIdList)
-                        {
-                            userParentDept.Add(deptTemp);
-                        }
-                    }
-
-                    return Ok(new { state = 200, parentList = userParentDept });
-                }
-
-                return Ok(new { state = 2, message = "访问失败!" });
-            }
-            catch (Exception ex)
-            {
-                return Ok(new { state = 2, message = $"访问失败!状态:{ex.StackTrace} 错误:{ex.Message}" });
-            }
-        }
-
         /// <summary>
         /// 依据钉钉UserID查询钉钉用户信息
         /// </summary>
@@ -1554,216 +1472,6 @@ namespace TEAMModeBI.Controllers.DingDingStruc
             public List<DDUserInfoAndTMD> tmddd { get; set; }
         }
 
-        /// <summary>
-        /// 查询钉钉的组织结构信息  测试保存日志文件  //测试新的查询用户
-        /// </summary>
-        /// <param name="jsonElement"></param>
-        /// <returns></returns>
-        [ProducesDefaultResponseType]
-        [HttpPost("get-ddstruct")]
-        public async Task<IActionResult> GetDingDingStruct(JsonElement jsonElement) 
-        {
-            try
-            {
-                jsonElement.TryGetProperty("ddDept", out JsonElement _ddDept);
-                jsonElement.TryGetProperty("ddUserId", out JsonElement _ddUserId);
-                if (!jsonElement.TryGetProperty("tmdId", out JsonElement _tmdId)) return BadRequest();
-                if (!jsonElement.TryGetProperty("tmdName", out JsonElement _tmdName)) return BadRequest();
-
-                string appKey = _configuration["DingDingAuth:appKey"];
-                string appSecret = _configuration["DingDingAuth:appSecret"];
-                string agentld = _configuration["DingDingAuth:Agentld"];
-
-                //获取access_token
-                DefaultDingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/gettoken");
-                OapiGettokenRequest request = new OapiGettokenRequest() { Appkey = appKey, Appsecret = appSecret};
-                request.SetHttpMethod("Get");
-                OapiGettokenResponse response = client.Execute(request);
-                if (response.IsError)
-                {
-                    return BadRequest();
-                }
-
-                //access_token的有效期为7200秒(2小时),有效期内重复获取会返回相同结果并自动续期,过期后获取会返回新的access_token
-                string access_token = response.AccessToken;
-
-
-
-                ////获取一级部门列表
-                //IDingTalkClient v2ListsubClient1 = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/v2/department/listsub");
-                //OapiV2DepartmentListsubRequest reqlistsub1 = new OapiV2DepartmentListsubRequest() { DeptId = 1L, Language = "zh_CN" };
-                //OapiV2DepartmentListsubResponse rsplistsub1 = v2ListsubClient1.Execute(reqlistsub1, access_token);
-                //var deptlis = rsplistsub1.Result;
-
-
-
-                //foreach (var deptList in rsplistsub1.Result)
-                //{
-                //    DeptInfo deptInfo = new DeptInfo();
-                //    deptInfo.deptId = deptList.DeptId;
-                //    deptInfo.deptName = deptList.Name;
-                //    deptInfo.parentId = deptList.ParentId;
-
-                //    //获取一级部门用户列表
-                //    IDingTalkClient userListClient1 = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/user/listid");
-                //    OapiUserListidRequest reqUserList1 = new OapiUserListidRequest() { DeptId = deptList.DeptId };
-                //    OapiUserListidResponse rspUserList1 = userListClient1.Execute(reqUserList1, access_token);
-                //    if (rspUserList1.Result != null)
-                //    {
-                //        deptInfo.ddUserList = rspUserList1.Result.UseridList;
-                //    }
-                //}
-
-                IDingTalkClient userInfoClient = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/v2/user/get");
-
-                OapiV2UserGetRequest reqUserInfo = new OapiV2UserGetRequest() { Userid = $"{_ddUserId}", Language = "zh_CN" };
-                OapiV2UserGetResponse rspUserInfo = userInfoClient.Execute(reqUserInfo, access_token);
-                var userInfo = rspUserInfo.Result;
-
-
-                if (!string.IsNullOrEmpty($"{_ddDept}"))
-                {
-
-                    IDingTalkClient listsimpleClient = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/user/listsimple");
-                    OapiUserListsimpleRequest reqListsimple = new OapiUserListsimpleRequest();
-                    reqListsimple.DeptId = 67690917L;
-                    reqListsimple.Cursor = 0L;
-                    reqListsimple.Size = 50L;
-                    reqListsimple.SetHttpMethod("GET");
-                    OapiUserListsimpleResponse rsListsimple = listsimpleClient.Execute(reqListsimple, access_token);
-                    var tempResult1 = rsListsimple.Result;
-
-                    IDingTalkClient UserListclient = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/industry/user/list");
-                    OapiIndustryUserListRequest reqIndustry = new OapiIndustryUserListRequest();
-                    reqIndustry.DeptId = long.Parse($"{_ddDept}");
-                    reqIndustry.Size = 100;
-                    OapiIndustryUserListResponse rspUserList = UserListclient.Execute(reqIndustry, access_token);
-                    Console.WriteLine(rspUserList.Body);
-
-
-                    IDingTalkClient userListClient = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/v2/user/list");
-                    OapiV2UserListRequest reqUserList = new OapiV2UserListRequest();
-                    reqUserList.DeptId = long.Parse($"{_ddDept}");
-                    reqUserList.Cursor = 0L;
-                    reqUserList.Size = 50L;
-                    reqUserList.ContainAccessLimit = false;
-                    reqUserList.OrderField = "custom";
-                    reqUserList.Language = "zh_CN";
-                    reqUserList.SetHttpMethod("GET");
-                    OapiV2UserListResponse rsp = userListClient.Execute(reqUserList, access_token);
-
-                    var tempResult = rsp.Result;
-
-                    //保存操作记录
-                    string blobOrTable = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds().ToString();
-                    //string blobOrTable = _snowflakeId.NextId().ToString();
-                    string dept = string.IsNullOrEmpty($"{_ddDept}") ? "【顶层】" : $"{_ddDept}";
-                    OperateLog bIOperateLog = new OperateLog
-                    {
-                        PartitionKey = "OperateLog-BI",
-                        RowKey = blobOrTable,
-                        recordID = blobOrTable,
-                        platformSource = "BI",
-                        tmdId = $"{_tmdId}",
-                        tmdName = $"{_tmdName}",
-                        operateDescribe = $"查询钉钉组织结构{dept}",
-                        visitApi = "dd/get-ddstruct",
-                        operateTime = DateTime.Now
-                    };
-
-                    //await _azureStorage.Save<OperateLog>(bIOperateLog);//保存操作记录
-
-                    //await _azureStorage.UploadFileByContainer("0-public", new { options = rsplistsub1.Result }.ToJsonString(), "OperateLog", $"BI/{blobOrTable}/{blobOrTable}_old.json");  //保存没操作前原记录
-
-                    //await _azureStorage.UploadFileByContainer("0-public", new { options = rsplistsub1.Result }.ToJsonString(), "OperateLog", $"BI/{blobOrTable}/{blobOrTable}_new.json");  //保存操作后新记录
-
-                    Dictionary<string, object> dic = new Dictionary<string, object> { { "PartitionKey", "OperateLog-BI" } };
-                    List<OperateLog> authorityBIList = await _azureStorage.FindListByDict<OperateLog>(dic);
-
-                    return Ok(new { state = 200, tempResult, authorityBIList });
-                }
-                else
-                {
-
-                    //获取一级部门列表
-                    IDingTalkClient v2ListsubClient1 = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/v2/department/listsub");
-                    OapiV2DepartmentListsubRequest reqlistsub1 = new OapiV2DepartmentListsubRequest() { DeptId = 1L, Language = "zh_CN" };
-                    OapiV2DepartmentListsubResponse rsplistsub1 = v2ListsubClient1.Execute(reqlistsub1, access_token);
-
-                    IDingTalkClient userListClient = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/v2/user/list");
-                    OapiV2UserListRequest reqUserList = new OapiV2UserListRequest();
-                    reqUserList.DeptId = 1L;
-                    reqUserList.Cursor = 0L;
-                    reqUserList.Size = 50L;
-                    reqUserList.ContainAccessLimit = false;
-                    reqUserList.OrderField = "custom";
-                    reqUserList.Language = "zh_CN";
-                    reqUserList.SetHttpMethod("GET");
-                    OapiV2UserListResponse rsp = client.Execute(reqUserList, access_token);
-
-                    var tempResult = rsp.Result;
-
-                    string blobOrTable = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds().ToString();
-                    //保存操作记录
-                    string dept = string.IsNullOrEmpty($"{_ddDept}") ? "【顶层】" : $"{_ddDept}";
-                    OperateLog bIOperateLog = new OperateLog
-                    {
-                        PartitionKey = "OperateLog-BI",
-                        RowKey = blobOrTable,
-                        recordID = blobOrTable,
-                        platformSource = "BI",
-                        tmdId = $"{_tmdId}",
-                        tmdName = $"{_tmdName}",
-                        operateDescribe = $"查询钉钉组织结构{dept}",
-                        visitApi = "dd/get-ddstruct",
-                        operateTime = DateTime.Now
-                    };
-
-                    await _azureStorage.Save<OperateLog>(bIOperateLog);
-
-                    //await _azureStorage.UploadFileByContainer("0-public", new { options = rsplistsub1.Result }.ToJsonString(), "OperateLog", $"BI/{blobOrTable}/{blobOrTable}_old.json");  //保存没操作前原记录
-
-                    //await _azureStorage.UploadFileByContainer("0-public", new { options = rsplistsub1.Result }.ToJsonString(), "OperateLog", $"BI/{blobOrTable}/{blobOrTable}_new.json");  //保存操作后新记录
-
-                    Dictionary<string, object> dic = new Dictionary<string, object> { { "PartitionKey", "OperateLog-BI" } };
-                    List<OperateLog> authorityBIList = await _azureStorage.FindListByDict<OperateLog>(dic);
-                    return Ok(new { state = 200, tempResult, authorityBIList });
-                }
-            }
-            catch (Exception ex)
-            {
-                await _dingDing.SendBotMsg($"BI,{_option.Location}  dd/get-ddstruct \n   {ex.Message}{ex.StackTrace}", GroupNames.成都开发測試群組);
-                return BadRequest();
-            }
-        }
-
-        /// <summary>
-        /// 钉钉部门和人员信息
-        /// </summary>
-        public record DeptUserInfo 
-        {
-            /// <summary>
-            /// 部门ID
-            /// </summary>
-            public long deptId { get; set; }
-
-            /// <summary>
-            /// 部门父级ID
-            /// </summary>
-            public long parentId { get; set; }
-
-            /// <summary>
-            /// 部门名称
-            /// </summary>
-            public string name { get; set; }
-
-            /// <summary>
-            /// 部门里面的人员
-            /// </summary>
-            public List<DDUserInfoAndTMD> deptUsers { get; set; }
-        }
-
-
 
         /// <summary>
         /// 返回钉钉和能查询到醍摩豆信息

+ 7 - 4
TEAMModeBI/Controllers/DingDingStruc/TableDingDingInfoController.cs

@@ -81,7 +81,7 @@ namespace TEAMModeBI.Controllers.DingDingStruc
                 string appKey = _configuration["DingDingAuth:appKey"];
                 string appSecret = _configuration["DingDingAuth:appSecret"];
 
-                string divide = appKey.Equals("dingrucgsnt8p13rfbgd") ? "continent" : "international";
+                string divide = _configuration["CustomParam:SiteScope"];
 
                 HttpClient httpClient = _http.CreateClient();
                 string url = _configuration.GetValue<string>("HaBookAuth:CoreId:userinfo");
@@ -198,7 +198,8 @@ namespace TEAMModeBI.Controllers.DingDingStruc
         {
             try
             {
-                Dictionary<string, object> dic = new Dictionary<string, object> { { "PartitionKey", "continent" } };
+                string divide = _configuration["CustomParam:SiteScope"];
+                Dictionary<string, object> dic = new Dictionary<string, object> { { "PartitionKey", $"{divide}" } };
                 List<DingDingUserInfo> ddUserInfoList = await _azureStorage.FindListByDict<DingDingUserInfo>(dic);
 
                 List<ddUserInfo> ddUserInfos = new();
@@ -256,7 +257,7 @@ namespace TEAMModeBI.Controllers.DingDingStruc
                 string appKey = _configuration["DingDingAuth:appKey"];
                 string appSecret = _configuration["DingDingAuth:appSecret"];
 
-                string divide = appKey.Equals("dingrucgsnt8p13rfbgd") ? "continent" : "international";
+                string divide = _configuration["CustomParam:SiteScope"];
 
                 //操作记录
                 OperateLog operateLog = new OperateLog();
@@ -338,7 +339,7 @@ namespace TEAMModeBI.Controllers.DingDingStruc
 
                 string appKey = _configuration["DingDingAuth:appKey"];
                 string appSecret = _configuration["DingDingAuth:appSecret"];
-                string divide = appKey.Equals("dingrucgsnt8p13rfbgd") ? "continent" : "international";
+                string divide = _configuration["CustomParam:SiteScope"];
 
                 //操作记录
                 OperateLog operateLog = new OperateLog();
@@ -419,6 +420,8 @@ namespace TEAMModeBI.Controllers.DingDingStruc
                 operateLog.platformSource = "BI";
                 operateLog.tmdId = $"{_tmdId}";
                 operateLog.tmdName = $"{_tmdName}";
+                operateLog.operateType = "修改";
+                operateLog.funModule = "权限";
                 operateLog.visitApi = "/tabledd/set-permissions";
                 operateLog.operateTime = DateTime.Now;
                 StringBuilder stringBuilder = new StringBuilder($"{_tmdName}【{_tmdId}】醍摩豆账号");

+ 6 - 3
TEAMModeBI/appsettings.Development.json

@@ -44,7 +44,7 @@
       "ConnectionString": "Endpoint=sb://teammodelos.servicebus.chinacloudapi.cn/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=Sy4h4EQ8zP+7w/lOLi1X3tGord/7ShFHimHs1vC50Dc=",
       "ActiveTask": "dep-active-task", //消息
       "NoticeTask": "dep-notice-task", //消息
-      "ItemCondQueue": "dep-itemcond"  //队列消息
+      "ItemCondQueue": "dep-itemcond" //队列消息
     }
   },
   "HaBookAuth": {
@@ -52,8 +52,8 @@
       "userinfo": "https://api2.teammodel.cn/Oauth2/GetUserInfos"
     },
     "sendSMS": {
-      "smstion": "https://api2.teammodel.net/service/sandsms/pin",      //验证醍摩豆账户是否存在,存在并发送验证码, 失败就不发送验证码
-      "verifiysms": "https://api2.teammodel.net/service/verifiy/pin"    //验证短信验证码信息
+      "smstion": "https://api2.teammodel.net/service/sandsms/pin", //验证醍摩豆账户是否存在,存在并发送验证码, 失败就不发送验证码
+      "verifiysms": "https://api2.teammodel.net/service/verifiy/pin" //验证短信验证码信息
     },
     "Account": "https://account.teammodel.cn",
     "CoreAPI": "https://api2.teammodel.cn",
@@ -65,5 +65,8 @@
       "getnotification": "https://api2.teammodel.net/service/getnotification",
       "delnotification": "https://api2.teammodel.net/service/delnotification"
     }
+  },
+  "CustomParam": {
+    "SiteScope": "continent" // 站点范围  continent 大路站  international 国际站
   }
 }

+ 4 - 1
TEAMModelOS.SDK/Models/Cosmos/Research/TeacherTrain.cs

@@ -250,7 +250,10 @@ namespace TEAMModelOS.SDK.Models
         /// <summary>
         /// -1 未评论任何人。
         /// </summary>
-        public int debateOrther { get; set; } = -1;
+        public int debateOrther  {
+            get;
+            set;
+              } 
         /// <summary>
         /// 评论别人的id集合
         /// </summary>

+ 139 - 99
TEAMModelOS.SDK/Models/Service/StatisticsService.cs

@@ -49,7 +49,8 @@ namespace TEAMModelOS.SDK
 
         public static async Task DoChange(TeacherTrainChange change, AzureCosmosFactory _azureCosmos)
         {
-            if (change.tmdids.IsNotEmpty() && change.update.Count() > 0  && !string.IsNullOrEmpty(change.school)) {
+            if (change.tmdids.IsNotEmpty() && change.update.Count() > 0 && !string.IsNullOrEmpty(change.school))
+            {
 
                 var client = _azureCosmos.GetCosmosClient();
                 string insql = $"where c.id in ({string.Join(",", change.tmdids.Select(x => $"'{x}'"))})";
@@ -89,10 +90,11 @@ namespace TEAMModelOS.SDK
             }
 
         }
-        public static async Task SendServiceBus((string standard, List<string> tmdids, string school, List<string> update, int statistics)list, IConfiguration _configuration, AzureServiceBusFactory _serviceBus, CosmosClient client) {
+        public static async Task SendServiceBus((string standard, List<string> tmdids, string school, List<string> update, int statistics) list, IConfiguration _configuration, AzureServiceBusFactory _serviceBus, CosmosClient client)
+        {
             if (list.tmdids.IsNotEmpty() && list.update.IsNotEmpty())
             {
-                string insql = $"where c.id in ({string.Join(",", list. tmdids.Select(x => $"'{x}'"))})";
+                string insql = $"where c.id in ({string.Join(",", list.tmdids.Select(x => $"'{x}'"))})";
                 string selsql = $"select value(c) from c {insql} ";
                 List<TeacherTrain> teacherTrains = new List<TeacherTrain>();
                 await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<TeacherTrain>(queryText: selsql,
@@ -145,7 +147,7 @@ namespace TEAMModelOS.SDK
             //}
         }
 
-        public static async Task GetAreaAndAreaSetting(  string schoolId, string _standard, CosmosClient client, HttpContext httpContext)
+        public static async Task GetAreaAndAreaSetting(string schoolId, string _standard, CosmosClient client, HttpContext httpContext)
         {
             School school = null;
             AreaSetting setting = null;
@@ -154,36 +156,38 @@ namespace TEAMModelOS.SDK
             {
                 standard = _standard;
             }
-            else if(!string.IsNullOrEmpty(schoolId)) {
+            else if (!string.IsNullOrEmpty(schoolId))
+            {
                 //优先找校级
                 setting = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<AreaSetting>(schoolId, new PartitionKey("AreaSetting"));
                 //优先找校级
                 school = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<School>(schoolId, new PartitionKey("Base"));
             }
         }
-        public static async Task<List<(List<TeacherTrain> trains, List<RGroupList> yxtrain)>> StatisticsArea(AreaSetting setting, Area area, CosmosClient client, DingDing _dingDing,  HashSet<string> updates)
+        public static async Task<List<(List<TeacherTrain> trains, List<RGroupList> yxtrain)>> StatisticsArea(AreaSetting setting, Area area, CosmosClient client, DingDing _dingDing, HashSet<string> updates)
         {
-           List<(List<TeacherTrain> trains, List<RGroupList> yxtrain)> teacherTrains = new List<(List<TeacherTrain> trains, List<RGroupList> yxtrain)>() ;
+            List<(List<TeacherTrain> trains, List<RGroupList> yxtrain)> teacherTrains = new List<(List<TeacherTrain> trains, List<RGroupList> yxtrain)>();
             List<School> schools = new List<School>();
             await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School")
             .GetItemQueryIterator<School>(queryText: $"select value(c) from c where c.areaId='{area.id}'  ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base") }))
             {
                 schools.Add(item);
             }
-            await foreach ((List<TeacherTrain> trains, List<RGroupList> yxtrain) tarain in GetStatisticsSchool(schools, setting, area, client,_dingDing,updates))
+            await foreach ((List<TeacherTrain> trains, List<RGroupList> yxtrain) tarain in GetStatisticsSchool(schools, setting, area, client, _dingDing, updates))
             {
                 teacherTrains.Add(tarain);
             }
             return teacherTrains;
         }
-        private static async IAsyncEnumerable<(List<TeacherTrain> trains, List<RGroupList> yxtrain)> GetStatisticsSchool(List<School> schools, AreaSetting setting, Area area, CosmosClient client, DingDing _dingDing,  HashSet<string> updates)
+        private static async IAsyncEnumerable<(List<TeacherTrain> trains, List<RGroupList> yxtrain)> GetStatisticsSchool(List<School> schools, AreaSetting setting, Area area, CosmosClient client, DingDing _dingDing, HashSet<string> updates)
         {
             foreach (var school in schools)
             {
-                yield return await StatisticsSchool(school.id, setting, area, client,_dingDing,updates);
+                yield return await StatisticsSchool(school.id, setting, area, client, _dingDing, updates);
             }
         }
-        public static async Task<(List<TeacherTrain> trains, List<RGroupList> yxtrain)> StatisticsSchool(string school, AreaSetting setting, Area area, CosmosClient client,DingDing _dingDing,HashSet<string> updates) {
+        public static async Task<(List<TeacherTrain> trains, List<RGroupList> yxtrain)> StatisticsSchool(string school, AreaSetting setting, Area area, CosmosClient client, DingDing _dingDing, HashSet<string> updates)
+        {
             List<RGroupList> yxtrain = await GroupListService.GetGroupListMemberByType(client, "yxtrain", new List<string> { "school" }, $"{school}", _dingDing);
             List<TeacherTrain> trains = new List<TeacherTrain>();
             var members = yxtrain.SelectMany(x => x.members).ToList();
@@ -191,29 +195,34 @@ namespace TEAMModelOS.SDK
             {
                 return (trains, yxtrain);
             }
-            
+
             await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher")
-             .GetItemQueryIterator<TeacherTrain>(queryText: $"select value(c) from c  ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"TeacherTrain-{school}") })) {
-               
+             .GetItemQueryIterator<TeacherTrain>(queryText: $"select value(c) from c  ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"TeacherTrain-{school}") }))
+            {
+
                 trains.Add(item);
             }
-            if (updates != null) {
+            if (updates != null)
+            {
                 foreach (var up in updates)
                 {
                     trains.ForEach(x => x.update.Add(up));
                 }
             }
             var update = trains.FindAll(x => x.update.Count() > 0);
-            var noupdate = trains.FindAll(x => x.update.Count() <=0);
-            
+            var noupdate = trains.FindAll(x => x.update.Count() <= 0);
+
             var unStatistics = members.Select(x => x.id).Except(trains.Select(x => x.id));
             List<TeacherTrain> teacherTrains = new List<TeacherTrain>();
             List<TeacherTrain> returnTrains = new List<TeacherTrain>();
-            if (update.IsNotEmpty()) {
+            if (update.IsNotEmpty())
+            {
                 teacherTrains.AddRange(update);
             }
-            if (unStatistics != null) {
-                foreach (string x in unStatistics) {
+            if (unStatistics != null)
+            {
+                foreach (string x in unStatistics)
+                {
                     var member = members.Find(y => y.id.Equals(x));
                     teacherTrains.Add(new TeacherTrain
                     {
@@ -222,9 +231,9 @@ namespace TEAMModelOS.SDK
                         code = $"TeacherTrain-{school}",
                         tmdid = x,
                         name = member.name,
-                        picture=member.picture,
+                        picture = member.picture,
                         school = school,
-                        update = new HashSet<string> { TeacherAbility,TeacherClass,OfflineRecord }
+                        update = new HashSet<string> { TeacherAbility, TeacherClass, OfflineRecord }
                     });
                 }
             }
@@ -234,7 +243,7 @@ namespace TEAMModelOS.SDK
             {
                 studies.Add(item);
             }
-            returnTrains = await GetStatisticsTeacher(teacherTrains, setting, area, client,studies);
+            returnTrains = await GetStatisticsTeacher(teacherTrains, setting, area, client, studies);
             //await foreach (var tarain in GetStatisticsTeacher(teacherTrains, setting, area, client))
             //{
             //    returnTrains.Add(tarain);
@@ -246,7 +255,7 @@ namespace TEAMModelOS.SDK
             //移除不在研修名单的人员
             returnTrains.RemoveAll(x => !members.Select(y => y.id).Contains(x.id));
             returnTrains.ForEach(x => {
-                var mbm= members.Find(y => y.id.Equals(x.id));
+                var mbm = members.Find(y => y.id.Equals(x.id));
                 if (mbm != null)
                 {
                     x.groupName = mbm?.groupName;
@@ -255,14 +264,14 @@ namespace TEAMModelOS.SDK
                 }
             });
 
-            return (returnTrains, yxtrain); 
+            return (returnTrains, yxtrain);
         }
         private static async Task<List<TeacherTrain>> GetStatisticsTeacher(List<TeacherTrain> trains, AreaSetting setting, Area area, CosmosClient client, List<Study> studies)
         {
             List<Task<TeacherTrain>> teachers = new List<Task<TeacherTrain>>();
             foreach (var train in trains)
             {
-                teachers.Add(StatisticsTeacher(train, setting, area, client,studies));  //yield return await  StatisticsTeacher(  train,   setting,   area,   client);
+                teachers.Add(StatisticsTeacher(train, setting, area, client, studies));  //yield return await  StatisticsTeacher(  train,   setting,   area,   client);
             }
             int pagesize = 50;
             if (teachers.Count <= pagesize)
@@ -278,17 +287,20 @@ namespace TEAMModelOS.SDK
                     await Task.WhenAll(lists);
                 }
             }
-           
+
             return trains;
         }
-        public static async Task<TeacherTrain> StatisticsTeacher(TeacherTrain train,  AreaSetting setting, Area area, CosmosClient client,List<Study> studies) {
+        public static async Task<TeacherTrain> StatisticsTeacher(TeacherTrain train, AreaSetting setting, Area area, CosmosClient client, List<Study> studies)
+        {
             string _school = train.school;
             string _tmdid = train.tmdid;
-           // TeacherTrain teacher_train = null;
+            // TeacherTrain teacher_train = null;
             List<Task<TeacherTrain>> teachers = new List<Task<TeacherTrain>>();
-            if (train.update.Count > 0) {
-                foreach (string property in train.update) {
-                    teachers.Add(DoProperty(train.update, property, setting, area, client, train,studies));
+            if (train.update.Count > 0)
+            {
+                foreach (string property in train.update)
+                {
+                    teachers.Add(DoProperty(train.update, property, setting, area, client, train, studies));
                 }
                 int pagesize = 50;
                 if (teachers.Count <= pagesize)
@@ -322,19 +334,21 @@ namespace TEAMModelOS.SDK
                 train.finalScore = 0;
 
             }
-            else {
+            else
+            {
                 //学时<=0 则是为
                 train.finalScore = -1;
             }
-            
+
             await client.GetContainer(Constant.TEAMModelOS, "Teacher").UpsertItemAsync<TeacherTrain>(train, new PartitionKey($"TeacherTrain-{_school}"));
             return train;
         }
-        private static async Task<TeacherTrain> DoProperty(HashSet<string> updateProperty,string property, AreaSetting setting, Area area, CosmosClient client, TeacherTrain train ,List<Study> studies )
+        private static async Task<TeacherTrain> DoProperty(HashSet<string> updateProperty, string property, AreaSetting setting, Area area, CosmosClient client, TeacherTrain train, List<Study> studies)
         {
             string _school = train.school;
             string _tmdid = train.tmdid;
-            switch (property) {
+            switch (property)
+            {
                 case TeacherAbility:
                     train = await DoTeacherAbility(train, setting, area, client, _school, _tmdid);
                     train.update.Remove(TeacherAbility);
@@ -346,7 +360,7 @@ namespace TEAMModelOS.SDK
                     break;
                 //线下研修
                 case OfflineRecord:
-                    train = await DoOfflineRecord(train, setting, area, client, _school, _tmdid,studies);
+                    train = await DoOfflineRecord(train, setting, area, client, _school, _tmdid, studies);
                     train.update.Remove(OfflineRecord);
                     break;
                 //投票
@@ -374,9 +388,10 @@ namespace TEAMModelOS.SDK
                     break;
             }
             return train;
-            
+
         }
-        public static async Task<TeacherTrain> DoTeacherVote(TeacherTrain train, AreaSetting setting, Area area, CosmosClient client, string _school, string _tmdid) {
+        public static async Task<TeacherTrain> DoTeacherVote(TeacherTrain train, AreaSetting setting, Area area, CosmosClient client, string _school, string _tmdid)
+        {
             int voteJoin = 0;
             int voteDone = 0;
             int voteAreaJoin = 0;
@@ -495,7 +510,8 @@ namespace TEAMModelOS.SDK
         /// <param name="_school"></param>
         /// <param name="_tmdid"></param>
         /// <returns></returns>
-        public static async Task<TeacherTrain> DoOfflineRecord(TeacherTrain train, AreaSetting setting, Area area, CosmosClient client, string _school, string _tmdid, List<Study> studies) {
+        public static async Task<TeacherTrain> DoOfflineRecord(TeacherTrain train, AreaSetting setting, Area area, CosmosClient client, string _school, string _tmdid, List<Study> studies)
+        {
             //owner:  school  area
             //线下 学校研修活动
             List<StuActivity> activities = new List<StuActivity>();
@@ -505,7 +521,8 @@ namespace TEAMModelOS.SDK
                 activities.Add(item);
             }
             string insql = "";
-            if (studies.IsEmpty()) {
+            if (studies.IsEmpty())
+            {
                 studies = new List<Study>();
                 if (activities.IsNotEmpty())
                 {
@@ -517,9 +534,9 @@ namespace TEAMModelOS.SDK
                     }
 
                 }
-                
+
             }
-           
+
             List<StudyRecord> studyRecords = new List<StudyRecord>();
             await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher")
             .GetItemQueryIterator<StudyRecord>(queryText: $"select value(c) from c {insql} ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StudyRecord-{_tmdid}") }))
@@ -527,17 +544,19 @@ namespace TEAMModelOS.SDK
                 studyRecords.Add(item);
             }
             List<HomeworkRecord> homeworkRecords = new List<HomeworkRecord>();
-            List<Study> workids= studies.FindAll(x => !string.IsNullOrEmpty(x.workId));
-           
-            bool haswork=false;
-            List<string > workidSubmits = new List<string >();
-            if (workids.IsNotEmpty()) {
+            List<Study> workids = studies.FindAll(x => !string.IsNullOrEmpty(x.workId));
+
+            bool haswork = false;
+            List<string> workidSubmits = new List<string>();
+            if (workids.IsNotEmpty())
+            {
                 string rcdsql = $" where c.id in ({string.Join(",", workids.Select(o => $"'{o.workId}'"))})";
                 await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher")
                 .GetItemQueryIterator<HomeworkRecord>(queryText: $"select value(c) from c {rcdsql} ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"HomeworkRecord-{_tmdid}") }))
                 {
-                    var content= item.content.FindAll(x => x.prime);
-                    if (content.IsNotEmpty()) {
+                    var content = item.content.FindAll(x => x.prime);
+                    if (content.IsNotEmpty())
+                    {
                         workidSubmits.Add(item.id);
                     }
                     homeworkRecords.Add(item);
@@ -547,33 +566,37 @@ namespace TEAMModelOS.SDK
             }
             //如果交了至少一份作业
             //一份作业都没有交
-            
+
             //标记是否计算所有学时。
-            bool getAll= false;
+            bool getAll = false;
             if (haswork)
             {
                 //如果有作业就需要检查是否至少交了一份作业。 如果交了一份,并且通过了,则可以计算全部。具体查看mark qweorrty
                 getAll = false;
             }
-            else { 
+            else
+            {
                 //如果没有作业,则计算全部学时。
-                getAll= true;
+                getAll = true;
             }
             activities.ForEach(item => {
                 Study study = studies.Find(y => y.id.Equals(item.id) && !string.IsNullOrEmpty(y.workId));
-                if (study != null) {
+                if (study != null)
+                {
                     StudyRecord studyRecord = studyRecords.Find(y => y.id.Equals(item.id));
-                    if (studyRecord!=null && studyRecord.status > 0) {
+                    if (studyRecord != null && studyRecord.status > 0)
+                    {
                         //mark qweorrty
                         var submit = workidSubmits.Find(y => y.Equals(study.workId));
-                        if (submit != null) { 
+                        if (submit != null)
+                        {
                             getAll = true;
                         }
                     }
                 }
             });
             List<OfflineRecord> offlines = new List<OfflineRecord>();
-          
+
             activities.ForEach(item =>
             {
                 Study study = studies.Find(y => y.id.Equals(item.id));
@@ -586,10 +609,11 @@ namespace TEAMModelOS.SDK
                         name = item.name,
                         done = item.taskStatus,
                         owner = item.owner,
-                        sethour=study.hour
+                        sethour = study.hour
                     };
                     bool workOk = false;
-                    if (!string.IsNullOrEmpty(study.workId)) {
+                    if (!string.IsNullOrEmpty(study.workId))
+                    {
                         HomeworkRecord homeworkRecord = homeworkRecords.Find(y => y.id.Equals(study.workId));
                         Attachment attachment = homeworkRecord != null ? homeworkRecord.content.Find(x => x.prime) : null;
                         record.haswork = 1;
@@ -602,7 +626,8 @@ namespace TEAMModelOS.SDK
                             workOk = true;
                         }
                     }
-                    if (studyRecord != null) {
+                    if (studyRecord != null)
+                    {
                         if (getAll)
                         {
                             record.hour = studyRecord.status == 1 ? study.hour : 0;
@@ -616,7 +641,8 @@ namespace TEAMModelOS.SDK
                                 record.score = -1;
                             }
                         }
-                        else {
+                        else
+                        {
                             if (workOk && !string.IsNullOrEmpty(study.workId))
                             {
                                 record.hour = studyRecord.status == 1 ? study.hour : 0;
@@ -636,7 +662,8 @@ namespace TEAMModelOS.SDK
                                 record.hour = 0;
                                 record.score = studyRecord.status;
                             }
-                            else {
+                            else
+                            {
                                 record.hour = studyRecord.status == 1 ? study.hour : 0;
                                 record.score = studyRecord.status;
                                 if (record.score >= 0)
@@ -653,9 +680,9 @@ namespace TEAMModelOS.SDK
                     offlines.Add(record);
                 }
             });
-            
+
             //标记已经有需要提交作业的线下研修活动。则需要检查至少有一次的作业提交记录。否则不能获得学时。
-            int sum   = offlines.Select(x => x.hour).Sum();
+            int sum = offlines.Select(x => x.hour).Sum();
             //if (haswork) 
             //{
             //    var workd= homeworkRecords.Where(z=>z.content.IsNotEmpty()).SelectMany(x => x.content).Where(y => y.prime);
@@ -672,9 +699,10 @@ namespace TEAMModelOS.SDK
             {
                 train.offlineTime = 0;
             }
-            else {
+            else
+            {
                 train.offlineTime = sum > setting.offlineTime ? setting.offlineTime : sum;
-               
+
             }
             train.offlineRecords = offlines;
             return train;
@@ -693,8 +721,12 @@ namespace TEAMModelOS.SDK
         {
             string code = $"ClassVideo-{_school}";
             ClassVideo classVideo = null;
-            try {  classVideo = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemAsync<ClassVideo>($"{_tmdid}", new PartitionKey(code)); 
-            } catch (Exception ex) {
+            try
+            {
+                classVideo = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemAsync<ClassVideo>($"{_tmdid}", new PartitionKey(code));
+            }
+            catch (Exception ex)
+            {
                 classVideo = null;
             }
             if (classVideo != null && classVideo.files.IsNotEmpty())
@@ -711,21 +743,23 @@ namespace TEAMModelOS.SDK
                 }
                 train.teacherClasses = new List<TeacherClass> { new Models.TeacherClass { url = files.url, score = files.score, hash = files.hash, name = files.name, size = files.size } };
             }
-            else {
+            else
+            {
                 train.classTime = 0;
             }
             return train;
         }
-        
-        public static async Task<TeacherTrain> DoTeacherAbility(TeacherTrain train, AreaSetting setting,Area area ,  CosmosClient client,string _school,string _tmdid) {
+
+        public static async Task<TeacherTrain> DoTeacherAbility(TeacherTrain train, AreaSetting setting, Area area, CosmosClient client, string _school, string _tmdid)
+        {
             //视频播放
-            List<string> abilityIds = new List<string> ();
+            List<string> abilityIds = new List<string>();
             TeacherFile file = null;
             try
             {
                 file = await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemAsync<TeacherFile>(_tmdid, new PartitionKey($"TeacherFile-{_school}"));
             }
-            catch (CosmosException )
+            catch (CosmosException)
             {
                 file = new TeacherFile
                 {
@@ -738,19 +772,20 @@ namespace TEAMModelOS.SDK
                 await client.GetContainer(Constant.TEAMModelOS, "Teacher").CreateItemAsync<TeacherFile>(file, new PartitionKey($"TeacherFile-{_school}"));
             }
 
-            List<AbilitySub> abilitySubs= new List<AbilitySub> ();
+            List<AbilitySub> abilitySubs = new List<AbilitySub>();
             //认证材料
             await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher")
                      .GetItemQueryIterator<AbilitySub>(queryText: $"select value(c) from c ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"AbilitySub-{_school}-{_tmdid}") }))
             {
                 abilitySubs.Add(item);
-               
+
             }
             List<Ability> abilities = new List<Ability>();
             string insql = "";
-            if (abilitySubs.IsNotEmpty()) {
-                 insql =$" where c.id in ({string.Join(",", abilitySubs.Select(o => $"'{o.id}'"))})";
-           
+            if (abilitySubs.IsNotEmpty())
+            {
+                insql = $" where c.id in ({string.Join(",", abilitySubs.Select(o => $"'{o.id}'"))})";
+
             }
             await foreach (var item in client.GetContainer("TEAMModelOS", "Normal")
                 .GetItemQueryIterator<Ability>(queryText: $"select c.comid, c.id,c.name,c.currency,c.no,c.dimension,c.hour,c.stds,c.abilityCount from c {insql} ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Ability-{area.standard}") }))
@@ -758,8 +793,9 @@ namespace TEAMModelOS.SDK
                 abilities.Add(item);
 
             }
-            List<Debate> debates= new List<Debate>();
-            if (abilities.IsNotEmpty()) {
+            List<Debate> debates = new List<Debate>();
+            if (abilities.IsNotEmpty())
+            {
                 await foreach (var item in client.GetContainer("TEAMModelOS", "School")
                 .GetItemQueryIterator<Debate>(queryText: $"select distinct value(c) from c join b in  c.replies  where b.tmdid='{_tmdid}'and  c.source='uploadscore' and c.comid in ({string.Join(",", abilities.Select(o => $"'{o.comid}'"))})",
                 requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Debate-{_school}") }))
@@ -767,16 +803,17 @@ namespace TEAMModelOS.SDK
                     debates.Add(item);
                 }
             }
-            Currency currency= new Currency();
+            Currency currency = new Currency();
             Currency currencyAll = new Currency();
 
 
             abilitySubs.ForEach(item => {
                 int currencyInt = item.from == 1 ? 1 : 0;
-                Ability ability = abilities.Find(x=>x.id.Equals(item.id));
-                if (ability != null) {
+                Ability ability = abilities.Find(x => x.id.Equals(item.id));
+                if (ability != null)
+                {
+
 
-                  
 
                     if (ability != null)
                     {
@@ -818,25 +855,28 @@ namespace TEAMModelOS.SDK
                     }
 
                     List<TeacherHprecord> hprecords = new List<TeacherHprecord>();
-                    List<Debate> debateOrthers = debates.FindAll(x => x.comid.Equals(ability.comid) && x.replies.IsNotEmpty() );
+                    List<Debate> debateOrthers = debates.FindAll(x => x.comid.Equals(ability.comid) && x.replies.IsNotEmpty());
                     int debateOrther = -1;
                     List<string> replyIds = new List<string>();
-                    if (debateOrthers.IsNotEmpty()) {
+                    if (debateOrthers.IsNotEmpty())
+                    {
                         debateOrther = debateOrthers.Count;
-                        var replies= debateOrthers.SelectMany(x => x.replies).Where(z => z.tmdid.Equals(_tmdid));
-                        if (replies != null && replies.Count() > 0) {
+                        var replies = debateOrthers.SelectMany(x => x.replies).Where(z => z.tmdid.Equals(_tmdid));
+                        if (replies != null && replies.Count() > 0)
+                        {
                             replyIds = replies.Select(x => x.id).ToList();
                         }
                     }
                     TeacherAbility teacherAbility = new Models.TeacherAbility
-                    { replyIds = replyIds,
+                    {
+                        replyIds = replyIds,
                         debateOrther = debateOrther,
                         id = ability.id,
                         currency = currencyInt,
                         no = ability.no,
                         name = ability.name,
                         dimension = ability.dimension,
-                        zpscore = item.self==0?1:item.self,
+                        zpscore = item.self == 0 ? 1 : item.self,
                         hprecord = hprecords,
                         uploadHas = item.uploads.Count
                     };
@@ -858,8 +898,8 @@ namespace TEAMModelOS.SDK
                         view = view > limit ? limit : view;
                         teacherAbility.videoTime = (int)view;
                         teacherAbility.limitTime = ability.hour;
-                        teacherAbility.onlineTime = (int)(view / setting.lessonMinutes);
-                        
+                        teacherAbility.onlineTime = setting.lessonMinutes != 0 ? (int)(view / setting.lessonMinutes) : 0;
+
                     }
                     if (item.otherScore.IsNotEmpty())
                     {
@@ -911,7 +951,7 @@ namespace TEAMModelOS.SDK
                         }
                     }
                     if (currencyInt == 1)
-                    {    
+                    {
                         currency.subCount += 1;
                         currency.uploadTotal += ability.stds.FindAll(x => x.task.IsNotEmpty()).Select(y => y.task).Count();
                         currency.teacherAilities.Add(teacherAbility);
@@ -924,12 +964,12 @@ namespace TEAMModelOS.SDK
             train.currency = currency;
             train.currencyAll = currencyAll;
             train.currency.videoTime = train.currency.teacherAilities.Select(x => x.videoTime).Sum();
-            train.currencyAll.videoTime= train.currencyAll.teacherAilities.Select(x => x.videoTime).Sum();
+            train.currencyAll.videoTime = train.currencyAll.teacherAilities.Select(x => x.videoTime).Sum();
             //如果总分钟数超过20学时,则直接复制20学时。
-            var videoTime = (int)(train.currency.videoTime / setting.lessonMinutes);
-            train.onlineTime = videoTime > setting.onlineTime ? setting.onlineTime:videoTime;
+            var videoTime = setting.lessonMinutes != 0 ? (int)(train.currency.videoTime / setting.lessonMinutes) : 0;
+            train.onlineTime = videoTime > setting.onlineTime ? setting.onlineTime : videoTime;
             var bhg = train.currency.teacherAilities.FindAll(x => x.xzscore > 0);
-            if (bhg.IsNotEmpty()&& bhg.Count == train.currency.subCount)
+            if (bhg.IsNotEmpty() && bhg.Count == train.currency.subCount)
             {
                 ///要全部合格才能获得学时。
                 train.currency.submitTime = setting.submitTime;
@@ -937,6 +977,6 @@ namespace TEAMModelOS.SDK
             }
             return train;
         }
-        
+
     }
 }

+ 17 - 13
TEAMModelOS/ClientApp/src/view/abilityMgmt/Index.vue

@@ -537,6 +537,19 @@
 			} else {
 				this.getVolumeList()
 			}
+			
+			if(sessionStorage.getItem('areaId')){
+				this.$api.ability.getAreaSetting({
+					areaId:sessionStorage.getItem('areaId')
+				}).then(res => {
+					if(res.setting){
+						this.areaSetting = res.setting
+						this.dimensionList = res.setting.dimensions
+						// this.addVolumeForm.dimension = res.setting.dimensions[0].code
+					}
+				})
+			}
+			
 		},
 		methods: {
 			/* 自定义创建维度 */
@@ -585,7 +598,8 @@
 			},
 			/* 获取维度名称 */
 			getName(code) {
-				return this.$GLOBAL.DIMENSIONS().find(i => i.code === code).val
+				let dimension = this.dimensionList.find(i => i.code === code)
+				return dimension ? dimension.name : '无'
 			},
 			/* 添加题目 */
 			onAddQues(val){
@@ -914,19 +928,9 @@
 			doEditVolume() {
 				this.curVolume.compulsory = this.curVolume.currency === 1
 				this.addVolumeForm = JSON.parse(JSON.stringify(this.curVolume))
+				
 				this.isEditVolume = true
 				this.isAddVolumeModal = true
-				if(this.isAreaAbility){
-					this.$api.ability.getAreaSetting({
-						areaId:sessionStorage.getItem('areaId')
-					}).then(res => {
-						if(res.setting){
-							this.areaSetting = res.setting
-							this.dimensionList = res.setting.dimensions
-							// this.addVolumeForm.dimension = res.setting.dimensions[0].code
-						}
-					})
-				}
 			},
 			/* 删除当前册别 */
 			doDeleteVolume() {
@@ -1323,7 +1327,7 @@
 						size: file.size,
 						cntr: 'teammodelos',
 						duration:file.duration || 0,
-						hash:file.md5 || ''
+						hash:file.hash || ''
 					})
 				})
 				this.modifyIdArr.push(this.curChapter.data.id)

+ 6 - 6
TEAMModelOS/ClientApp/src/view/areaSetting/AreaSetting.vue

@@ -16,32 +16,32 @@
 				<div class="content">
 					<div class="setting-item">
 						<p>单个学时</p>
-						<InputNumber :max="100" :min="1" v-model="areaSetting.lessonMinutes"></InputNumber>
+						<InputNumber :max="2000" :min="0" v-model="areaSetting.lessonMinutes"></InputNumber>
 						<span> 分钟</span>
 					</div>
 					<div class="setting-item">
 						<p>总体合格需要</p>
-						<InputNumber :max="100" :min="1" v-model="areaSetting.allTime"></InputNumber>
+						<InputNumber :max="2000" :min="0" v-model="areaSetting.allTime"></InputNumber>
 						<span> 学时</span>
 					</div>
 					<div class="setting-item">
 						<p>线上研修合格需要</p>
-						<InputNumber :max="100" :min="1" v-model="areaSetting.onlineTime"></InputNumber>
+						<InputNumber :max="2000" :min="0" v-model="areaSetting.onlineTime"></InputNumber>
 						<span> 学时</span>
 					</div>
 					<div class="setting-item">
 						<p>线下研修合格需要</p>
-						<InputNumber :max="100" :min="1" v-model="areaSetting.offlineTime"></InputNumber>
+						<InputNumber :max="2000" :min="0" v-model="areaSetting.offlineTime"></InputNumber>
 						<span> 学时</span>
 					</div>
 					<div class="setting-item">
 						<p>认证材料合格需要</p>
-						<InputNumber :max="100" :min="1" v-model="areaSetting.submitTime"></InputNumber>
+						<InputNumber :max="2000" :min="0" v-model="areaSetting.submitTime"></InputNumber>
 						<span> 学时</span>
 					</div>
 					<div class="setting-item">
 						<p>课堂实录合格需要</p>
-						<InputNumber :max="100" :min="1" v-model="areaSetting.classTime"></InputNumber>
+						<InputNumber :max="2000" :min="0" v-model="areaSetting.classTime"></InputNumber>
 						<span> 学时</span>
 					</div>
 				</div>

+ 32 - 12
TEAMModelOS/ClientApp/src/view/jyzx/HomePage.vue

@@ -282,6 +282,7 @@ export default {
             }
             this.$api.jyzx.getStudyTime(req).then((res) => {
                 if (res) {
+                    console.log(res.setting);
                     this.setting = res.setting
                     this.totalTime = res.teacherTrain.totalTime
                     this.videoTime = res.teacherTrain.currency.videoTime
@@ -292,28 +293,47 @@ export default {
                     this.applicaTime = res.teacherTrain.currency.submitTime
                     this.discussTime = res.teacherTrain.classTime
                     // 线上研修
-                    if (this.onlineTime >= 20) {
-                        this.onlinePer = 100
+                    if(res.setting.onlineTime) {
+                        if (this.onlineTime >= res.setting.onlineTime) {
+                            this.onlinePer = 100
+                        } else {
+                            this.onlinePer = ((res.teacherTrain.onlineTime / res.setting.onlineTime) * 100).toFixed(1)
+                        }
                     } else {
-                        this.onlinePer = ((res.teacherTrain.onlineTime / res.setting.onlineTime) * 100).toFixed(1)
+                        this.onlinePer = 0
                     }
+                    
                     // 校本研修
-                    if (this.offlineTime >= 10) {
-                        this.offlinePer = 100
+                    if(res.setting.offlineTime) {
+                        if (this.offlineTime >= res.setting.offlineTime) {
+                            this.offlinePer = 100
+                        } else {
+                            this.offlinePer = ((res.teacherTrain.offlineTime / res.setting.offlineTime) * 100).toFixed(1)
+                        }
                     } else {
-                        this.offlinePer = ((res.teacherTrain.offlineTime / res.setting.offlineTime) * 100).toFixed(1)
+                        this.offlinePer = 0
                     }
+
                     // 应用考核
-                    if (this.applicaTime >= 15) {
-                        this.applicaPer = 100
+                    if(res.setting.submitTime) {
+                        if (this.applicaTime >= res.setting.submitTime) {
+                            this.applicaPer = 100
+                        } else {
+                            this.applicaPer = ((res.teacherTrain.currency.submitTime / res.setting.submitTime) * 100).toFixed(1)
+                        }
                     } else {
-                        this.applicaPer = ((res.teacherTrain.currency.submitTime / res.setting.submitTime) * 100).toFixed(1)
+                        this.applicaPer = 0
                     }
+
                     // 课堂实录
-                    if (this.discussTime >= 5) {
-                        this.discussPer = 100
+                    if(res.setting.classTime) {
+                        if (this.discussTime >= res.setting.classTime) {
+                            this.discussPer = 100
+                        } else {
+                            this.discussPer = ((res.teacherTrain.classTime / res.setting.classTime) * 100).toFixed(1)
+                        }
                     } else {
-                        this.discussPer = ((res.teacherTrain.classTime / res.setting.classTime) * 100).toFixed(1)
+                        this.discussPer = 0
                     }
                     this.percent = ((this.totalTime / res.setting.allTime) * 100).toFixed(1)
                     // 检测

+ 2 - 3
TEAMModelOS/ClientApp/src/view/jyzx/HourDetail.vue

@@ -43,9 +43,8 @@ export default {
     computed: {
         // 整体完成进度
         somePercent() {
-            if (this.hourInfo) {
-                console.log((this.hourInfo.value || 0) / this.hourInfo.total * 100);
-                return (this.hourInfo.value || 0) / this.hourInfo.total * 100
+            if (this.hourInfo && this.hourInfo.total) {
+                return (((this.hourInfo.value || 0) / this.hourInfo.total) * 100).toFixed(1)
             }
             return 0
         },

+ 3 - 3
TEAMModelOS/ClientApp/src/view/jyzx/index.vue

@@ -409,7 +409,7 @@ export default {
                             let arr = res.abilityFiles.find(abl => {return abl.abilityId === item.id})
                             // item.total = 0
                             if(arr) {
-                                item.total = parseInt(arr.view/60)
+                                item.total = parseInt(arr.view / 60)
                                 this.abliyTotal += item.total >= times ? (times * 60) : arr.view
                                 item.done = item.total >= times ? true : false
                             }
@@ -1478,8 +1478,8 @@ export default {
     },
     computed: {
         totalShow() {
-            if(this.setting) {
-                let total = parseInt(this.abliyTotal/60/this.setting.lessonMinutes)
+            if(this.setting && this.setting.lessonMinutes) {
+                let total = parseInt(this.abliyTotal / 60 / this.setting.lessonMinutes)
                 return total > this.setting.onlineTime ? this.setting.onlineTime : total
             } else {
                 return 0

+ 1 - 1
TEAMModelOS/ClientApp/src/view/jyzx/newHomePage.vue

@@ -374,7 +374,7 @@ export default {
         // 整体完成进度
         allPercent() {
             if (this.settings && this.settings.allTime) {
-                return (this.teacherInfo.totalTime || 0) * 100 / this.settings.allTime
+                return ((this.teacherInfo.totalTime || 0) * 100 / this.settings.allTime).toFixed(1)
             }
             return 0
         },

+ 2 - 1
TEAMModelOS/ClientApp/src/view/syllabus/Syllabus.vue

@@ -1491,7 +1491,8 @@
 						link: `/syllabus/${this.curNode.id}/${file.name}`,
 						title: file.name,
 						type: file.type,
-						cntr: this.curCode
+						cntr: this.curCode,
+						hash:file.hash
 					})
 				})
 				this.modifyIdArr.push(this.curChapter.data.id)

+ 7 - 7
TEAMModelOS/ClientApp/src/view/user/UserCenter.vue

@@ -551,22 +551,22 @@ export default {
     width: 100%;
     height: 100%;
     display: flex;
+    align-items: center;
     justify-content: center;
-    // align-items: center;
+    background: #fafafa;
 }
 .user-info-box {
-    margin-top: 120px;
-    padding: 50px 50px;
-    height: -moz-fit-content;
+    margin-top: -2%;
+    padding: 60px 80px;
     height: fit-content;
-    border-radius: 30px;
+    border-radius: 0px;
     box-shadow: 0 0 10px 5px #e9e9e9;
     position: relative;
-    // color: white;
+    background: #ffffff;
     width: 700px;
 }
 .base-info-item {
-    width: 600px;
+    width: 540px;
     margin: 0px auto;
     padding: 15px 25px 15px 5px;
     display: flex;

+ 1 - 0
TEAMModelOS/Controllers/Analysis/ClassAnalysisController.cs

@@ -467,6 +467,7 @@ namespace TEAMModelOS.Controllers.Analysis
             }
             catch (Exception e)
             {
+                await _dingDing.SendBotMsg($"OS,{_option.Location},analysis/getTPCount()\n{e.Message}{e.StackTrace}", GroupNames.成都开发測試群組);
                 return null;
             }
         }

+ 1 - 1
TEAMModelOS/Controllers/Common/ExamController.cs

@@ -996,7 +996,7 @@ namespace TEAMModelOS.Controllers
             }
             catch (Exception e)
             {
-                await _dingDing.SendBotMsg($"OS,{_option.Location},exam/upsertRecord()\n{e.Message}", GroupNames.醍摩豆服務運維群組);
+                await _dingDing.SendBotMsg($"OS,{_option.Location},exam/upsertRecord()\n{e.Message}\n{e.StackTrace}", GroupNames.醍摩豆服務運維群組);
                 return BadRequest();
             }
 

+ 3 - 0
TEAMModelOS/Controllers/Research/AbilityStatisticsController.cs

@@ -251,6 +251,7 @@ namespace TEAMModelOS.Controllers
                     x.currency.teacherAilities.ForEach(y => {
                         y.videoTime = (int)y.videoTime;
                         y.onlineTime = (int)y.onlineTime;
+                        y.debateOrther = y.debateOrther > 0 ? y.debateOrther : 0;
                     });
                 });
                 return Ok(new { teacherTrains, setting, schools = schoolInfos, totalTime, hgcount, teacherAilities, teacherCount = countArea, appraiseCount = appraiseArea });
@@ -359,6 +360,7 @@ namespace TEAMModelOS.Controllers
                     x.currency.teacherAilities.ForEach(y => {
                         y.videoTime = (int)y.videoTime;
                         y.onlineTime = (int)y.onlineTime;
+                        y.debateOrther= y.debateOrther>0? y.debateOrther: 0;
                     });
                 });
                 //try
@@ -492,6 +494,7 @@ namespace TEAMModelOS.Controllers
                 teacherTrain.currency.teacherAilities.ForEach(y => {
                     y.videoTime = (int)y.videoTime;
                     y.onlineTime = (int)y.onlineTime;
+                    y.debateOrther = y.debateOrther > 0 ? y.debateOrther : 0;
                 });
                 return Ok(new { teacherTrain, setting });
             }

+ 8 - 6
TEAMModelOS/Controllers/School/ClassController.cs

@@ -282,13 +282,15 @@ namespace TEAMModelOS.Controllers
                 {
                     courses.Add(item);
                 }
+                //courses.ForEach(c => c.schedule.Where(s => !string.IsNullOrEmpty(s.classId)&& s.classId.Equals(id))
                 foreach (Course course in courses)
                 {
-                    foreach (var sc in course.schedule)
-                    {
-                        if (sc.classId.Equals(id))
-                        {
-                            sc.classId = "";
+                    for (int i =0;i< course.schedule.Count;i++) {
+                        if (!string.IsNullOrEmpty(course.schedule[i].classId)) {
+                            string classId = course.schedule[i].classId;
+                            if (classId.Equals(id.GetString())) { 
+                                course.schedule.RemoveAt(i);
+                            }
                         }
                     }
                     taskCourses.Add(client.GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync(course, course.id, new PartitionKey((course.code))));
@@ -301,7 +303,7 @@ namespace TEAMModelOS.Controllers
             }
             catch (Exception ex)
             {
-                await _dingDing.SendBotMsg($"OS,{_option.Location},class/Delete()\n{ex.Message}", GroupNames.醍摩豆服務運維群組);
+                await _dingDing.SendBotMsg($"OS,{_option.Location},class/Delete()\n{ex.Message}\n{ex.StackTrace}", GroupNames.醍摩豆服務運維群組);
                 return BadRequest();
             }
         }

+ 3 - 3
TEAMModelOS/TEAMModelOS.csproj

@@ -38,9 +38,9 @@
     <SpaRoot>ClientApp\</SpaRoot>
     <DefaultItemExcludes>$(DefaultItemExcludes);$(SpaRoot)node_modules\**</DefaultItemExcludes>
     <UserSecretsId>078b5d89-7d90-4f6a-88fc-7d96025990a8</UserSecretsId>
-    <Version>5.2201.6</Version>
-    <AssemblyVersion>5.2201.6.1</AssemblyVersion>
-    <FileVersion>5.2201.6.1</FileVersion>
+    <Version>5.2201.7</Version>
+    <AssemblyVersion>5.2201.7.1</AssemblyVersion>
+    <FileVersion>5.2201.7.1</FileVersion>
     <Description>TEAMModelOS(IES5)版本更新。</Description>
     <PackageReleaseNotes>版本说明</PackageReleaseNotes>
   </PropertyGroup>