瀏覽代碼

Merge branch 'develop5.0-tmd' of http://52.130.252.100:10000/TEAMMODEL/TEAMModelOS into develop5.0-tmd

CrazyIter_Bin 3 年之前
父節點
當前提交
e55982121a

+ 1 - 1
TEAMModeBI/ClientApp/src/api/index.js

@@ -6,7 +6,7 @@ export default {
     },
     //发送短信验证码
     Phonepin(data) {
-        return post('/common/login/send-sms', data)
+        return post('/common/biservers/send-sms', data)
     },
     //验证手机号和验证
     verifyCode(data) {

+ 59 - 62
TEAMModeBI/ClientApp/src/view/bindPhone.vue

@@ -27,68 +27,68 @@
     </el-dialog>
 </template>
 <script>
-import { reactive, ref, getCurrentInstance, watch } from "vue";
+import { reactive, ref, getCurrentInstance, watch } from 'vue'
 // import { Phonepin, verifyCode, bindUserid } from "@/api/index.js";
-import { ElMessage } from "element-plus";
-import { useRouter } from "vue-router";
-import { useStore } from "vuex";
+import { ElMessage } from 'element-plus'
+import { useRouter } from 'vue-router'
+import { useStore } from 'vuex'
 export default {
     setup(props, content) {
-        let { proxy } = getCurrentInstance();
-        let store = useStore();
-        console.log(store.state.binDingstatus);
-        let centerDialogVisible = ref(true);
+        let { proxy } = getCurrentInstance()
+        let store = useStore()
+        console.log(store.state.binDingstatus)
+        let centerDialogVisible = ref(true)
         let phonenum = reactive({
-            phone: "",
-            code: "",
-        });
+            phone: '',
+            code: '',
+        })
         //验证冷却
         let showCode = reactive({
             status: true,
-            count: "",
+            count: '',
             timer: null,
-        });
+        })
         var phoneData = {
             to: phonenum.phone,
-            lang: "zh-cn",
+            lang: 'zh-cn',
             HasUser: true,
-            country: "86",
-        };
-        var { phoneCode } = pin(proxy);
+            country: '86',
+        }
+        var { phoneCode } = pin(proxy)
         //路由
-        const router = useRouter();
+        const router = useRouter()
         //关闭弹窗
         function close() {
-            centerDialogVisible.value = false;
-            store.commit("BindStatus", false);
+            centerDialogVisible.value = false
+            store.commit('BindStatus', false)
         }
         //监听状态值
         watch(
             () => store.state.binDingstatus,
             (a) => {
-                store.state.binDingstatus = a;
-                centerDialogVisible.value = a;
+                store.state.binDingstatus = a
+                centerDialogVisible.value = a
             }
-        );
+        )
         //验证码冷却及发送验证码
         function getCode() {
             //验证码冷却部分
-            const TIME_COUNT = 60;
+            const TIME_COUNT = 60
             if (!showCode.timer) {
-                showCode.count = TIME_COUNT;
-                showCode.status = false;
+                showCode.count = TIME_COUNT
+                showCode.status = false
                 showCode.timer = setInterval(() => {
                     if (showCode.count > 0 && showCode.count <= TIME_COUNT) {
-                        showCode.count--;
+                        showCode.count--
                     } else {
-                        showCode.status = true;
-                        clearInterval(showCode.timer);
-                        showCode.timer = null;
+                        showCode.status = true
+                        clearInterval(showCode.timer)
+                        showCode.timer = null
                     }
-                }, 1000);
+                }, 1000)
             }
             //请求接口
-            phoneCode(phoneData);
+            phoneCode(phoneData)
         }
         //手机号码绑定流程
         function bindUser(proxy) {
@@ -96,40 +96,39 @@ export default {
             let codeNum = {
                 mobile: phonenum.phone,
                 Authorization_Pin: phonenum.code,
-            };
-            console.log(codeNum, "手机号和验证码");
+            }
+            console.log(codeNum, '手机号和验证码')
             //验证手机号和验证码
             proxy.$api.verifyCode(codeNum).then((res) => {
-                console.log(res, "验证手机号和验证码");
+                console.log(res, '验证手机号和验证码')
                 if (res.error) {
                     res.error === 3 || res.error === 4
-                        ? ElMessage.error("验证码错误")
+                        ? ElMessage.error('验证码错误')
                         : res.error === 1
-                        ? ElMessage.error("无手机绑定的醍摩豆账号")
+                        ? ElMessage.error('无手机绑定的醍摩豆账号')
                         : res.error === 5
-                        ? ElMessage.error("无效的手机号码")
-                        : ElMessage.error("接口异常请重新尝试绑定");
+                        ? ElMessage.error('无效的手机号码')
+                        : ElMessage.error('接口异常请重新尝试绑定')
                 } else if (res.status && res.status === 200) {
-                    let userInfo = JSON.parse(localStorage.getItem("DingUser"));
-                    console.log(userInfo, "用户信息");
-                    let paramData = { mobile: phonenum.phone, param: userInfo };
-                    bindId(paramData, proxy);
+                    let userInfo = JSON.parse(localStorage.getItem('DingUser'))
+                    console.log(userInfo, '用户信息')
+                    let paramData = { mobile: phonenum.phone, param: userInfo }
+                    bindId(paramData, proxy)
                 }
-            });
+            })
         }
         //绑定操作
         function bindId(paramData, proxy) {
             proxy.$api.bindUserid(paramData).then((res) => {
-                console.log(res, "返回的结果");
+                console.log(res, '返回的结果')
                 res.status === 1 || res.status === 3
-                    ? ElMessage.error("绑定失败,请稍后重试")
+                    ? ElMessage.error('绑定失败,请稍后重试')
                     : res.status === 2
-                    ? ElMessage.error("账户已被绑定,请选择其他账号绑定")
+                    ? ElMessage.error('账户已被绑定,请选择其他账号绑定')
                     : res.status === 200
-                    ? (ElMessage.success("绑定成功,即将跳转..."),
-                      router.push("/home"))
-                    : ElMessage.error("出现未知错误");
-            });
+                    ? (ElMessage.success('绑定成功,即将跳转...'), router.push('/home'))
+                    : ElMessage.error('出现未知错误')
+            })
         }
         return {
             store,
@@ -143,9 +142,9 @@ export default {
             bindUser,
             bindId,
             close,
-        };
+        }
     },
-};
+}
 //发送验证码API
 function pin(proxy) {
     let phoneCode = (datas) => {
@@ -154,18 +153,16 @@ function pin(proxy) {
             lang: datas.lang,
             HasUser: datas.HasUser,
             country: datas.country,
-        };
+        }
         let { codesInfo } = proxy.$api.Phonepin(parameter).then((res) => {
-            console.log(res, "接口返回");
-            res.status === 200
-                ? ElMessage.success("验证码发送成功")
-                : ElMessage.error("验证码发送失败");
-        });
-        console.log("codesInfo", codesInfo);
-    };
+            console.log(res, '接口返回')
+            res.status === 200 ? ElMessage.success('验证码发送成功') : ElMessage.error('验证码发送失败')
+        })
+        console.log('codesInfo', codesInfo)
+    }
     return {
         phoneCode,
-    };
+    }
 }
 </script>
 <style scoped>

+ 1 - 1
TEAMModeBI/ClientApp/src/view/common/aside.vue

@@ -60,7 +60,7 @@ const schoolMenus = [
                 isShow: true,
             },
             {
-                name: '区管理',
+                name: '区管理',
                 router: '/home/areamanage',
                 role: 'admin',
                 icon: '#icon-quyuguanli',

+ 16 - 13
TEAMModeBI/ClientApp/src/view/login.vue

@@ -1,7 +1,7 @@
 <template>
     <div class="backgorundbox">
         <div class="loginbox">
-            <div class="logintitle">醍摩豆账号登录</div>
+            <div class="logintitle">{{msgText}}</div>
             <div class="usrpwd" v-if="loginModel">
                 <div class='userbox' style="margin-bottom:10%">
                     <el-input v-model="user" placeholder="醍摩豆ID/手机号码" prefix-icon="el-icon-user" />
@@ -70,6 +70,7 @@ export default {
             text: '',
             background: '',
         })
+        let msgText = ref('钉钉账号登录')
         onMounted(() => {
             console.log(window.location.href, 'mounted!')
             if (window.location.href.indexOf('?code') != -1) {
@@ -81,7 +82,9 @@ export default {
         })
         //处理登录icon变化
         watch(loginModel, () => {
-            loginImg.value = loginModel.value == true ? (loginImg.value = require('../assets/img/erweima.png')) : (loginImg.value = require('../assets/img/mima.png'))
+            loginModel.value == true
+                ? ((loginImg.value = require('../assets/img/erweima.png')), (msgText.value = '钉钉账号登录'))
+                : ((loginImg.value = require('../assets/img/mima.png')), (msgText.value = '钉钉扫码登录'))
         })
         let { editState } = test(proxy)
         function test(proxy) {
@@ -117,9 +120,8 @@ export default {
                 res.state === 200 ? (store.commit('ChangOrganization', res.deptlist), localStorage.setItem('organization', JSON.stringify(res.deptlist))) : ''
             })
         }
-        //醍摩豆或手机登录
+        //钉钉账号或扫码登录
         function userlogin(proxy) {
-            console.log(comRef.value, '子页面的!!!!')
             loading = ElLoading.service({
                 lock: true,
                 text: 'Loading',
@@ -134,15 +136,15 @@ export default {
                 account: user.value,
                 password: pwd.value,
             }
-            proxy.$api.loginUser(params).then(async (res) => {
-                console.log(res, '登录接口返回成功!')
-                res.error
-                    ? (ElMessage.error('密码错误'), loading.close())
-                    : res.id_token
-                    ? (getTeachinfo(proxy, res.id_token), Allpermission(proxy), getOrganization(proxy))
-                    : (loading.close(), ElMessage.error('登录失败'))
-                // router.push("/home");
-            })
+            // proxy.$api.loginUser(params).then(async (res) => {
+            //     console.log(res, '登录接口返回成功!')
+            //     res.error
+            //         ? (ElMessage.error('密码错误'), loading.close())
+            //         : res.id_token
+            //         ? (getTeachinfo(proxy, res.id_token), Allpermission(proxy), getOrganization(proxy))
+            //         : (loading.close(), ElMessage.error('登录失败'))
+            //     // router.push("/home");
+            // })
         }
         //获取教师个人信息
         function getTeachinfo(proxy, param) {
@@ -188,6 +190,7 @@ export default {
             router,
             getTeachinfo,
             loading,
+            msgText,
         }
     },
 }

+ 1 - 1
TEAMModeBI/ClientApp/src/view/teachermanage/areamanage.vue

@@ -1,6 +1,6 @@
 <template>
     <div>
-        <p class="nowtitle">区域管理</p>
+        <div class="nowtitle">区域管理</div>
         <div class="traitfrom">
             <el-table :data="optionData" style="width: 100%" :highlight-current-row="true" max-height="750">
                 <el-table-column prop="index" label="编号" width="200" type=index align="center" />

+ 40 - 16
TEAMModeBI/Controllers/BISchool/BatchSchoolController.cs

@@ -17,6 +17,7 @@ using TEAMModelOS.SDK.Models;
 using TEAMModelOS.SDK.Models.Cosmos.BI;
 using static TEAMModelOS.SDK.Models.Teacher;
 using Microsoft.AspNetCore.Hosting;  //引用读取文件
+using TEAMModelOS.SDK.Models.Service;
 
 namespace TEAMModeBI.Controllers.BISchool
 {
@@ -231,12 +232,39 @@ namespace TEAMModeBI.Controllers.BISchool
                     var cosmosClient = _azureCosmos.GetCosmosClient();
                     foreach (BISchool bischool in foundSchools.biSchools)
                     {
-                        var schoolStatus = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync($"{bischool.id}", new PartitionKey($"Base"));
+                        CreateSchoolInfo createSchoolInfo = new CreateSchoolInfo()
+                        {
+                            province = bischool.province,
+                            id = "",
+                            name = bischool.name,
+                            city = bischool.city,
+                            aname = "",
+                            createCount = 0,
+                        };
+
+                        //生成学校ID
+                        createSchoolInfo = await SchoolCode.GenerateSchoolCode(createSchoolInfo, _dingDing, _environment);  
+
+                        var schoolStatus = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync($"{createSchoolInfo.id}", new PartitionKey($"Base"));
                         if (schoolStatus.Status == 200)
                         {
-                            schools.Add(bischool);
+                            createSchoolInfo.createCount = 1;
+                            createSchoolInfo = await SchoolCode.GenerateSchoolCode(createSchoolInfo, _dingDing, _environment);
+                            var schoolStatu1 = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync($"{createSchoolInfo.id}", new PartitionKey($"Base"));
+                            if (schoolStatu1.Status == 200)
+                            {
+                                createSchoolInfo.createCount = 2;                                
+                                createSchoolInfo = await SchoolCode.GenerateSchoolCode(createSchoolInfo, _dingDing, _environment);
+                                var schoolStatu2 = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync($"{createSchoolInfo.id}", new PartitionKey($"Base"));
+                                if (schoolStatu2.Status == 200)
+                                {
+                                    createSchoolInfo.createCount = 3;
+                                    createSchoolInfo = await SchoolCode.GenerateSchoolCode(createSchoolInfo, _dingDing, _environment);
+                                }
+                            }
                         }
-                        else
+
+                        if (createSchoolInfo.id != null)
                         {
                             List<Period> periods = new List<Period>();
                             string campusId = Guid.NewGuid().ToString();
@@ -255,7 +283,7 @@ namespace TEAMModeBI.Controllers.BISchool
                             });
                             School upSchool = new School
                             {
-                                id = bischool.id,
+                                id = createSchoolInfo.id,
                                 name = bischool.name,
                                 size = bischool.size,
                                 code = "Base",
@@ -267,13 +295,13 @@ namespace TEAMModeBI.Controllers.BISchool
                                 address = bischool.address,
                                 picture = "https://teammodelstorage.blob.core.chinacloudapi.cn/0-public/school/bbf54fb3-3fc8-43ae-a358-107281c174cc.png",
                                 timeZone = new TEAMModelOS.SDK.Models.TimeZone { label = "(UTC+08:00) 北京,重庆,香港特别行政区,乌鲁木齐", value = "+08:00" },
-                                type = 2,
+                                type = 1,
                                 pk = "School",
                                 ttl = -1,
-                                schoolCode = bischool.id,
+                                schoolCode = createSchoolInfo.id,
                                 period = periods
                             };
-                            stringBuilder.Append($"创建学校:{upSchool.id}【{upSchool.name}】");
+                            stringBuilder.Append($"创建学校:{upSchool.name}【{upSchool.id}】");
                             //创建学校
                             await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").CreateItemAsync<School>(upSchool, new PartitionKey(upSchool.code));
                             Teacher teacher = null;
@@ -288,12 +316,12 @@ namespace TEAMModeBI.Controllers.BISchool
                             if (teacher != null)
                             {
                                 //教师存在,在该教师信息中添加要管理的学校信息
-                                teacher.schools.Add(new Teacher.TeacherSchool { schoolId = bischool.id, name = bischool.name, status = "join", time = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() });
+                                teacher.schools.Add(new Teacher.TeacherSchool { schoolId = createSchoolInfo.id, name = bischool.name, status = "join", time = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() });
                                 await cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync<Teacher>(teacher, bischool.admin, new PartitionKey("Base"));
                                 SchoolTeacher schoolTeacher = new SchoolTeacher
                                 {
                                     id = bischool.admin,
-                                    code = $"Teacher-{bischool.id}",
+                                    code = $"Teacher-{createSchoolInfo.id}",
                                     roles = new List<string> { "admin", "teacher" },
                                     job = "管理员",
                                     name = teacher.name,
@@ -319,8 +347,8 @@ namespace TEAMModeBI.Controllers.BISchool
                                     picture = "",
                                     //创建账号并第一次登录IES5则默认赠送1G
                                     size = 1,
-                                    defaultSchool = bischool.id,
-                                    schools = new List<Teacher.TeacherSchool>() { new TeacherSchool { schoolId = bischool.id, name = bischool.name, status = "join", time = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() } }
+                                    defaultSchool = createSchoolInfo.id,
+                                    schools = new List<Teacher.TeacherSchool>() { new TeacherSchool { schoolId = createSchoolInfo.id, name = bischool.name, status = "join", time = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() } }
                                 };
 
                                 stringBuilder.Append($"没有该教师信息创建的教师信息:{addteacher.name}【{addteacher.id}】");
@@ -328,7 +356,7 @@ namespace TEAMModeBI.Controllers.BISchool
                                 SchoolTeacher schoolTeacher = new SchoolTeacher
                                 {
                                     id = bischool.admin,
-                                    code = $"Teacher-{bischool.id}",
+                                    code = $"Teacher-{createSchoolInfo.id}",
                                     roles = new List<string> { "admin", "teacher" },
                                     job = "管理员",
                                     name = bischool.admin,
@@ -1200,10 +1228,6 @@ namespace TEAMModeBI.Controllers.BISchool
         /// </summary>
         public record BISchool()
         {
-            /// <summary>
-            /// 学校ID
-            /// </summary>
-            public string id { get; set; }
             /// <summary>
             /// 学校名称
             /// </summary>

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

@@ -0,0 +1,160 @@
+using Azure.Cosmos;
+using Microsoft.AspNetCore.Http;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.Extensions.Options;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text.Json;
+using System.Threading.Tasks;
+using TEAMModelOS.Models;
+using TEAMModelOS.SDK.DI;
+using TEAMModelOS.SDK.Extension;
+using TEAMModelOS.SDK.Models;
+using TEAMModelOS.SDK.Models.Cosmos.BI;
+
+namespace TEAMModeBI.Controllers.BISchool
+{
+    [Route("schoolcheck")]
+    [ApiController]
+    public class SchoolController : ControllerBase
+    {
+        private readonly AzureCosmosFactory _azureCosmos;
+        private readonly DingDing _dingDing;
+        private readonly Option _option;
+        private readonly AzureStorageFactory _azureStorage;
+
+        public SchoolController(AzureCosmosFactory azureCosmos, DingDing dingDing, AzureStorageFactory azureStorage, IOptionsSnapshot<Option> option) 
+        {
+            _azureCosmos = azureCosmos;
+            _dingDing = dingDing;
+            _azureStorage = azureStorage;
+            _option = option?.Value;
+        }
+
+        /// <summary>
+        /// 查询未加入区域的学校
+        /// </summary>
+        /// <returns></returns>
+        [ProducesDefaultResponseType]
+        [HttpPost("get-notarea")]
+        public async Task<IActionResult> GetNotAreaSchool() 
+        {
+            try
+            {
+                var cosmosClient = _azureCosmos.GetCosmosClient();
+                string sqltxt = $"SELECT c.id,c.name,c.schoolCode,c.province,c.city,c.dist FROM c WHERE c.standard=null";
+                List<NotAreaSchool> notAreaSchools = new List<NotAreaSchool>();
+                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: sqltxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") })) 
+                {
+                    using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                    if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
+                    {
+                        foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
+                        {
+                            NotAreaSchool notAreaSchool = new NotAreaSchool()
+                            {
+                                id = obj.GetProperty("id").GetString(),
+                                name = obj.GetProperty("name").GetString(),
+                                schoolCode = obj.GetProperty("schoolCode").GetString(),
+                                province = obj.GetProperty("province").GetString(),
+                                city = obj.GetProperty("city").GetString(),
+                                dist = obj.GetProperty("dist").GetString(),
+                            };
+                            notAreaSchools.Add(notAreaSchool);
+                        }
+                    }
+                }
+
+                return Ok(new { state = 200, notAreaSchools });
+            }
+            catch (Exception ex)
+            {
+                await _dingDing.SendBotMsg($"BI,{_option.Location}  /schoolcheck/get-notarea   \n    {ex.Message}{ex.StackTrace}", GroupNames.醍摩豆服務運維群組);
+                return BadRequest();
+            }
+        }
+
+        /// <summary>
+        /// 学校加入区
+        /// </summary>
+        /// <param name="jsonElement"></param>
+        /// <returns></returns>
+        [ProducesDefaultResponseType]
+        [HttpPost("set-schooljoinarea")]
+        public async Task<IActionResult> SetSchoolJoinArea(JsonElement jsonElement) 
+        {
+            try
+            {
+                if (!jsonElement.TryGetProperty("tmdId", out JsonElement _tmdId)) return BadRequest();   //醍摩豆账户
+                if (!jsonElement.TryGetProperty("tmdName", out JsonElement _tmdName)) return BadRequest(); //醍摩豆账号名称
+                if (!jsonElement.TryGetProperty("standard", out JsonElement standard)) return BadRequest();
+                if (!jsonElement.TryGetProperty("schoolCode", out JsonElement _schoolCode)) return BadRequest();
+
+                List<string> schoolCodes = _schoolCode.ToObject<List<string>>();
+
+                var cosmosCliet = _azureCosmos.GetCosmosClient();
+                //操作记录
+                string blobOrTable = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds().ToString();
+                OperateLog operateLog = new OperateLog
+                {
+                    PartitionKey = "OperateLog-BI",
+                    RowKey = blobOrTable,
+                    recordID = blobOrTable,
+                    platformSource = "BI",
+                    tmdId = $"{_tmdId}",
+                    tmdName = $"{_tmdName}",
+                    visitApi = "/schoolcheck/set-schooljoinarea",
+                    operateTime = DateTime.Now,
+                    operateDescribe = $"{_tmdName}【{_tmdId}】已操作学校加入区域功能,加入的区域:{standard}"
+                };
+
+                if (schoolCodes.Count > 0) 
+                {
+                    foreach (var tempCode in schoolCodes) 
+                    {
+                        School school = await cosmosCliet.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<School>(tempCode,new PartitionKey("Base"));
+                        if (school != null) 
+                        {
+                            school.standard = $"{standard}";
+                            await cosmosCliet.GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync<School>(school, school.id, new PartitionKey(school.code));
+                        }
+                    }
+                }
+
+                await _azureStorage.Save<OperateLog>(operateLog);   //保存操作记录
+
+                return Ok(new { state = 200 });
+            }
+            catch (Exception ex)
+            {
+                await _dingDing.SendBotMsg($"BI,{_option.Location}  /schoolcheck/set-schooljoinarea   \n    {ex.Message}{ex.StackTrace}", GroupNames.醍摩豆服務運維群組);
+                return BadRequest();
+            }
+        }
+
+
+
+
+        /// <summary>
+        /// 未加入区域的学校
+        /// </summary>
+        public record NotAreaSchool 
+        {
+            public string id { get; set; }
+
+            public string name { get; set; }
+
+            public string schoolCode { get; set; }
+
+            public string province { get; set; }
+
+            public string city { get; set; }
+
+            public string dist { get; set; }
+
+
+        }
+
+    }
+}

+ 103 - 1
TEAMModeBI/Controllers/BIServer/BiServersController.cs

@@ -14,6 +14,7 @@ using TEAMModelOS.SDK.Extension;
 using System.Text;
 using System.Net;
 using HTEXLib.COMM.Helpers;
+using System.Net.Http.Json;
 
 namespace TEAMModeBI.Controllers.BIServer
 {
@@ -29,12 +30,15 @@ namespace TEAMModeBI.Controllers.BIServer
         //读取配置信息
         private readonly IConfiguration _configuration;
 
-        public BiServersController(AzureCosmosFactory azureCosmos, DingDing dingDing, IOptionsSnapshot<Option> option, IConfiguration configuration)
+        private readonly IHttpClientFactory _http;
+
+        public BiServersController(AzureCosmosFactory azureCosmos, DingDing dingDing, IOptionsSnapshot<Option> option, IConfiguration configuration, IHttpClientFactory http)
         {
             _azureCosmos = azureCosmos;
             _dingDing = dingDing;
             _option = option?.Value;
             _configuration = configuration;
+            _http = http;
         }
 
         /// <summary>
@@ -78,6 +82,104 @@ namespace TEAMModeBI.Controllers.BIServer
             }
         }
 
+        /// <summary>
+        /// 发送验证码
+        /// </summary>
+        /// <param name="jsonElement"></param>
+        /// <returns></returns>
+        [ProducesDefaultResponseType]
+        [HttpPost("send-sms")]
+        public async Task<IActionResult> send_sms(JsonElement jsonElement)
+        {
+            try
+            {
+                if (!jsonElement.TryGetProperty("country", out JsonElement country)) return BadRequest();
+                if (!jsonElement.TryGetProperty("to", out JsonElement to)) return BadRequest();
+                if (!jsonElement.TryGetProperty("lang", out JsonElement lang)) return BadRequest();
+                if (!jsonElement.TryGetProperty("HasUser", out JsonElement HasUser)) return BadRequest();
+
+                string smsurl = _configuration.GetValue<string>("HaBookAuth:CoreAPI");
+                HttpClient httpClient = _http.CreateClient();
+                HttpResponseMessage responseMessage = await httpClient.PostAsJsonAsync($"{smsurl}/service/sandsms/pin", jsonElement);
+                if (responseMessage.StatusCode == HttpStatusCode.OK)
+                {
+                    string str_json = await responseMessage.Content.ReadAsStringAsync();
+                    if (string.IsNullOrEmpty($"{str_json}"))
+                    {
+                        return Ok(new { status = 200, message = "发送成功" });
+                    }
+                    else
+                    {
+                        return Ok(str_json);
+                    }
+                }
+                else
+                {
+                    return Ok(new { status = 0, message = "发送失败!" });
+                }
+            }
+            catch (Exception ex)
+            {
+                return Ok(new { status = 0, message = $"发送失败!{ex.Message}" });
+            }
+        }
+
+        /// <summary>
+        /// 验证码和手机的验证
+        /// </summary>
+        /// <param name="jsonElement"></param>
+        /// <returns></returns>
+        [ProducesDefaultResponseType]
+        [HttpPost("verfiypin")]
+        public async Task<IActionResult> VerifiyPIN(JsonElement jsonElement)
+        {
+            try
+            {
+                if (!jsonElement.TryGetProperty("mobile", out JsonElement mobile)) return BadRequest();
+                if (!jsonElement.TryGetProperty("Authorization_Pin", out JsonElement sms)) return BadRequest();
+
+                string smsurl = _configuration.GetValue<string>("HaBookAuth:CoreAPI");
+                HttpClient httpClient = new HttpClient();
+                var temp_job = new { Authorization_Pin = sms };
+                //var content = new StringContent(temp_job.ToJsonString(), Encoding.UTF8, "application/json");
+                HttpResponseMessage responseMessage = await httpClient.PostAsJsonAsync($"{smsurl}/service/verifiy/pin", temp_job);
+
+                if (responseMessage.StatusCode == HttpStatusCode.OK)
+                {
+                    string responseBody = await responseMessage.Content.ReadAsStringAsync();
+                    var json = responseBody.ToObject<JsonElement>();
+                    json.TryGetProperty("resule", out JsonElement jsone);
+                    if (!string.IsNullOrEmpty($"{jsone}"))
+                    {
+                        string[] mobules = $"{jsone}".Split("-");
+                        string temp_mobile = mobules.Length >= 2 ? mobules[1] : mobules[0];
+                        if (mobile.ToString().Equals(temp_mobile))
+                        {
+                            return Ok(new { status = 200, message = "手机号和验证码验证都过了" });
+                        }
+                        else
+                        {
+                            return Ok(new { status = 5, message = "手机号码不正确" });
+                        }
+                    }
+                    else
+                    {
+                        return Ok(json);
+                    }
+                }
+                else
+                {
+                    return Ok(new { status = 0, message = "发送状态错误" });
+                }
+            }
+            catch (Exception ex)
+            {
+                return Ok(new { status = 0, message = $"发送状态错误{ex.Message}" });
+            }
+        }
+
+
+
         public record userInfo
         {
             public string mobile { get; set; }

+ 136 - 0
TEAMModeBI/Controllers/OperateRecord/OperateLogController.cs

@@ -0,0 +1,136 @@
+using Microsoft.AspNetCore.Http;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.Azure.Cosmos.Table;
+using Microsoft.Extensions.Options;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text.Json;
+using System.Threading.Tasks;
+using TEAMModelOS.Models;
+using TEAMModelOS.SDK.DI;
+using TEAMModelOS.SDK.Models.Cosmos.BI;
+using System.Text;
+
+namespace TEAMModeBI.Controllers.OperateRecord
+{
+    [Route("operatelog")]
+    [ApiController]
+    public class OperateLogController : ControllerBase
+    {
+        private readonly AzureStorageFactory _azureStorage;
+        private readonly DingDing _dingDing;
+        private readonly Option _option;
+
+        public OperateLogController(AzureStorageFactory azureStorage, DingDing dingDing, IOptionsSnapshot<Option> option)
+        {
+            _azureStorage = azureStorage;
+            _dingDing = dingDing;
+            _option = option?.Value;
+        }
+
+        /// <summary>
+        /// 查询BI操作记录
+        /// </summary>
+        /// <param name="jsonElement"></param>
+        /// <returns></returns>
+        [HttpPost("get-operatelogbydate")]
+        public async Task<IActionResult> GetOperateLogByDate(JsonElement jsonElement) 
+        {
+            try
+            {
+                jsonElement.TryGetProperty("startDate", out JsonElement startDate);
+                jsonElement.TryGetProperty("endDate", out JsonElement endDate);
+
+                List<OperateLog> operateLogs = null;
+
+                StringBuilder tableSql = new StringBuilder();
+
+                if (!string.IsNullOrEmpty($"{startDate}"))
+                {
+                    operateLogs = await _azureStorage.QueryWhereString<OperateLog>($"RowKey {QueryComparisons.GreaterThanOrEqual} '{startDate}'");
+                }
+                else if (!string.IsNullOrEmpty($"{startDate}") && !string.IsNullOrEmpty($"{endDate}"))
+                {
+                    operateLogs = await _azureStorage.QueryWhereString<OperateLog>($"RowKey {QueryComparisons.GreaterThanOrEqual} '{startDate}' {TableOperators.And} RowKey {QueryComparisons.LessThanOrEqual} '{endDate}'");
+                }
+                else
+                {
+                    operateLogs = await _azureStorage.QueryWhereString<OperateLog>();
+                    //operateLogs = await _azureStorage.FindListByDict<OperateLog>(dic);
+                }
+
+                return Ok(new { state = 200, operateLogs });
+            }
+            catch (Exception ex)
+            {
+                await _dingDing.SendBotMsg($"BI,{_option.Location}   /operatelog/get-operatelogbydate    {ex.Message}{ex.StackTrace}", GroupNames.醍摩豆服務運維群組);
+                return BadRequest();
+            }
+        }
+
+        /// <summary>
+        /// 删除操作记录
+        /// </summary>
+        /// <param name="jsonElement"></param>
+        /// <returns></returns>
+        [HttpPost("del-operatelogbydate")]
+        public async Task<IActionResult> DelOperateLogByDate(JsonElement jsonElement) 
+        {
+            try
+            {
+                if (!jsonElement.TryGetProperty("tmdId", out JsonElement _tmdId)) return BadRequest();   //醍摩豆账户
+                if (!jsonElement.TryGetProperty("tmdName", out JsonElement _tmdName)) return BadRequest(); //醍摩豆账号名称                
+                jsonElement.TryGetProperty("startDate", out JsonElement startDate);
+                jsonElement.TryGetProperty("endDate", out JsonElement endDate);
+                jsonElement.TryGetProperty("rowKey", out JsonElement rowKey);
+
+                //操作记录
+                OperateLog operateLog = new OperateLog();
+                string blobOrTable = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds().ToString();
+                operateLog.PartitionKey = "OperateLog-BI";
+                operateLog.RowKey = blobOrTable;
+                operateLog.recordID = blobOrTable;
+                operateLog.platformSource = "BI";
+                operateLog.tmdId = $"{_tmdId}";
+                operateLog.tmdName = $"{_tmdName}";
+                operateLog.visitApi = "/operatelog/del-operatelogbydate";
+                operateLog.operateTime = DateTime.Now;
+                operateLog.operateDescribe = $"{_tmdName}【{_tmdId}】账户删除操作记录,开始-结束时间戳:{startDate}-{endDate}";
+
+                //var temp = await _azureStorage.Delete<OperateLog>(partitionKey: "OperateLog-BI", rowKey: $"{startDate}");  //删除单个
+                StringBuilder operateStr = new StringBuilder($"{_tmdName}【{_tmdId}】账户删除操作记录,");
+                StringBuilder tableStrWhere = new StringBuilder();
+                if (!string.IsNullOrEmpty($"{rowKey}"))
+                {
+                    tableStrWhere.Append($"RowKey {QueryComparisons.Equal} '{rowKey}'");
+                    operateStr.Append($"删除的时间戳:{rowKey}");
+                }
+                else
+                {
+                    tableStrWhere.Append($"RowKey {QueryComparisons.GreaterThanOrEqual} '{startDate}'{TableOperators.And} RowKey {QueryComparisons.LessThanOrEqual} '{endDate}'");
+                    operateStr.Append($"删除的时间戳,开始——结束时间戳:{startDate}-{endDate}");
+                }
+                var temp = await _azureStorage.DeleteStringWhere<OperateLog>(rowKey: tableStrWhere.ToString());
+
+                await _azureStorage.Save<OperateLog>(operateLog); //保存操作记录
+                if (temp.Count > 0)
+                {
+                    return Ok(new { state = 200 });
+                }
+                else return Ok(new { state = 400 });
+            }
+            catch (Exception ex)
+            {
+                await _dingDing.SendBotMsg($"BI, {_option.Location} /operatelog/del-operatelogbydate  {ex.Message}{ex.StackTrace}", GroupNames.醍摩豆服務運維群組);
+                return BadRequest();
+            }
+
+        }
+
+
+
+
+
+    }
+}

文件差異過大導致無法顯示
+ 15172 - 0
TEAMModeBI/JsonFile/Region/region.json


+ 82 - 0
TEAMModelOS.SDK/DI/AzureStorage/AzureStorageTableExtensions.cs

@@ -513,5 +513,87 @@ namespace TEAMModelOS.SDK.DI
                 default: return null;
             }
         }
+
+
+        /// <summary>
+        /// 查询条件传string类型
+        /// </summary>
+        /// <typeparam name="T"></typeparam>
+        /// <param name="azureStorage"></param>
+        /// <param name="strWhere">查询条件| 例:$"RowKey {QueryComparisons.GreaterThanOrEqual} '{123456}' {TableOperators.And} RowKey {QueryComparisons.LessThanOrEqual} '{123456}'" </param>
+        /// <returns></returns>
+        public static async Task<List<T>> QueryWhereString<T>(this AzureStorageFactory azureStorage, string strWhere = null) where T : TableEntity, new()
+        {
+            CloudTable TableName = await azureStorage.InitializeTable<T>();
+            var exQuery = new TableQuery<T>();
+            exQuery.Where(strWhere);
+            return await QueryList<T>(exQuery, TableName);
+        }
+
+        /// <summary>
+        /// 删除单个记录
+        /// </summary>
+        /// <typeparam name="T"></typeparam>
+        /// <param name="azureStorage"></param>
+        /// <param name="partitionKey"></param>
+        /// <param name="rowKey"></param>
+        /// <returns></returns>
+        public static async Task<TableResult> DeleteSingle<T>(this AzureStorageFactory azureStorage, string partitionKey, string rowKey) where T : ITableEntity, new()
+        {
+            // query all rows
+            CloudTable TableName = await azureStorage.InitializeTable<T>();
+            var queryOperation = TableOperation.Retrieve<T>(partitionKey, rowKey);
+
+            var tableResult = await TableName.ExecuteAsync(queryOperation);
+            if (tableResult.Result is T item)
+            {
+                var deleteOperation = TableOperation.Delete(item);
+                var dels = await TableName.ExecuteAsync(deleteOperation);
+                return dels;
+            }
+            else return null;
+        }
+
+        /// <summary>
+        /// 删除多个  带有后期优化该方法
+        /// </summary>
+        /// <typeparam name="T"></typeparam>
+        /// <param name="azureStorage"></param>
+        /// <param name="rowKey"></param>
+        /// <returns></returns>
+        public static async Task<List<string>> DeleteStringWhere<T>(this AzureStorageFactory azureStorage, string rowKey) where T : ITableEntity, new()
+        {
+            // query all rows
+            CloudTable TableName = await azureStorage.InitializeTable<T>();
+
+            var exQuery = new TableQuery<T>();
+            exQuery.Where(rowKey);
+            TableContinuationToken continuationToken = null;
+            List<T> entitys = new List<T>();
+            do
+            {
+                var result = await TableName.ExecuteQuerySegmentedAsync(exQuery, continuationToken);                
+                if (result.Results.Count > 0)
+                {
+                    entitys.AddRange(result.ToList());
+                }
+                continuationToken = result.ContinuationToken;
+            } while (continuationToken != null);
+
+            List<string> ster = new List<string>();
+            foreach (var item in entitys)
+            {
+                var queryOperation = TableOperation.Retrieve<T>(item.PartitionKey, item.RowKey);
+                var tableResult = await TableName.ExecuteAsync(queryOperation);
+                if (tableResult.Result is T items)
+                {
+                    var deleteOperation = TableOperation.Delete(items);
+                    await TableName.ExecuteAsync(deleteOperation);
+                    ster.Add(items.RowKey);
+                }
+            }
+
+            return ster;
+        }
     }
 }

+ 19 - 0
TEAMModelOS.SDK/Models/Cosmos/BI/CreateSchoolInfo.cs

@@ -0,0 +1,19 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace TEAMModelOS.SDK.Models.Cosmos.BI
+{
+    /// <summary>
+    /// 创校使用
+    /// </summary>
+    public class CreateSchoolInfo
+    {
+        public string province { get; set; }
+        public string id { get; set; }
+        public int createCount { get; set; }
+        public string name { get; set; }
+        public string city { get; set; }
+        public string aname { get; set; }
+    }
+}

+ 653 - 0
TEAMModelOS.SDK/Models/Service/SchoolCode.cs

@@ -0,0 +1,653 @@
+using Microsoft.AspNetCore.Hosting;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.International.Converters.PinYinConverter;
+using Microsoft.International.Converters.TraditionalChineseToSimplifiedConverter;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Text.Json;
+using System.Text.RegularExpressions;
+using System.Threading.Tasks;
+using TEAMModelOS.SDK.DI;
+using TEAMModelOS.SDK.Extension;
+using TEAMModelOS.SDK.Models.Cosmos.BI;
+
+namespace TEAMModelOS.SDK.Models.Service
+{
+    public class SchoolCode
+    {
+        /// <summary>
+        /// 依据彬哥写的生成的学校Code所改的方法
+        /// </summary>
+        /// <param name="json"></param>
+        /// <param name="_dingDing"></param>
+        /// <param name="_environment"></param>
+        /// <returns></returns>
+        public static async Task<CreateSchoolInfo> GenerateSchoolCode(CreateSchoolInfo schoolInfo, DingDing _dingDing, IWebHostEnvironment _environment)
+        {
+            string path = $"{_environment.ContentRootPath}/JsonFile/Region/region.json";
+
+            StreamReader streamReader = new StreamReader(new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite), Encoding.UTF8);
+            StringBuilder stringBuilder = new StringBuilder();
+            string text;
+            while ((text = streamReader.ReadLine()) != null)
+            {
+                stringBuilder.Append(text.ToString());
+            }
+            streamReader.Close();
+            string input = stringBuilder.ToString();
+            List<Region> region = input.ToObject<List<Region>>();
+            schoolInfo.province = ChineseConverter.Convert(schoolInfo.province, ChineseConversionDirection.TraditionalToSimplified);
+            if (String.IsNullOrEmpty(schoolInfo.city))
+            {
+                schoolInfo.city = schoolInfo.province;
+            }
+            else
+            {
+                schoolInfo.city = ChineseConverter.Convert(schoolInfo.city, ChineseConversionDirection.TraditionalToSimplified);
+            }
+
+            schoolInfo.name = ChineseConverter.Convert(schoolInfo.name, ChineseConversionDirection.TraditionalToSimplified);
+            comeRemoveStr.ForEach(c => { schoolInfo.province = schoolInfo.province.Replace(c, ""); });
+            prvcRemoveStr.ForEach(c => { schoolInfo.province = schoolInfo.province.Replace(c, ""); });
+            var province = region.Find(r => r.name.Contains(schoolInfo.province));
+            string tmpprovince = schoolInfo.province;
+            string tmpcity = schoolInfo.city;
+            if (province != null)
+            {
+                schoolInfo.province = province.name;
+                comeRemoveStr.ForEach(c => { schoolInfo.city = schoolInfo.city.Replace(c, ""); });
+                cityRemoveStr.ForEach(c => { schoolInfo.city = schoolInfo.city.Replace(c, ""); });
+                nationRemoveStr.ForEach(c => { schoolInfo.city = schoolInfo.city.Replace(c, ""); });
+
+                tmpcity = schoolInfo.city;
+                var city = province.children.Find(r => r.name.Contains(schoolInfo.city));
+
+                if (city == null)
+                {
+                    city = province.children.Find(r => r.name.Contains(schoolInfo.city));
+                    if (city == null)
+                    {
+                        city = province.children.SelectMany(x => x.children).ToList().Find(r => r.name.Contains(schoolInfo.city));
+                    }
+                }
+                if (city != null)
+                {
+                    schoolInfo.city = city.name;
+                }
+            }
+
+            string name = schoolInfo.name;
+            //去除冗余的学校信息,只保留地名和校名关键信息
+            schemoveStr.ForEach(str =>
+            {
+                name = name.Replace(str, "");
+            });
+            string[] names = name.Split("(");
+
+            if (names.Length > 1)
+            {
+                name = $"{names[0]}";
+                for (int index = 1; index < names.Length; index++)
+                {
+                    name = $"{name}{names[index].Substring(0, 1)}";
+                    var afnames = names[index].Split(")");
+                    if (afnames.Length > 1)
+                    {
+                        for (int i = 1; i < afnames.Length; i++)
+                        {
+                            name = $"{name}{afnames[i]}";
+                        }
+                    }
+                }
+            }
+
+            names = name.Split("(");
+            if (names.Length > 1)
+            {
+                name = $"{names[0]}";
+                for (int index = 1; index < names.Length; index++)
+                {
+                    name = $"{name}{names[index].Substring(0, 1)}";
+                    var afnames = names[index].Split(")");
+                    if (afnames.Length > 1)
+                    {
+                        for (int i = 1; i < afnames.Length; i++)
+                        {
+                            name = $"{name}{afnames[i]}";
+                        }
+                    }
+                }
+            }
+
+            name = Regex.Replace(name, "[ \\[ \\] \\^ \\-|()【】/' {}_*×――(^)$%~!@#$…&%¥—+=<>《》!!???::•`·、。,;,.;\"‘’“”-]", " ");
+            //检查是否有英文
+            if (Regex.Matches(name, "[a-zA-Z]").Count > 0)
+            {
+                var array = Regex.Split(name, "\\s+", RegexOptions.IgnoreCase);
+                StringBuilder tmpname = new StringBuilder();
+                if (array.Length > 1)
+                {
+                    foreach (var item in array)
+                    {
+                        var arr = item.Select(x => $"{x}");
+                        int index = 0;
+                        foreach (var stra in arr)
+                        {
+                            if (Regex.Matches(stra, "[a-zA-Z]").Count > 0)
+                            {
+                                if (index == 1 || index == 0)
+                                {
+                                    tmpname.Append(stra);
+                                }
+                                else
+                                {
+
+                                }
+                            }
+                            else
+                            {
+                                tmpname.Append(stra);
+                            }
+                            index++;
+                        }
+                    }
+                }
+                else
+                {
+                    var arr = name.Select(x => $"{x}");
+                    int index = 0;
+                    foreach (var stra in arr)
+                    {
+                        if (Regex.Matches(stra, "[A-Z]").Count > 0)
+                        {
+                            tmpname.Append(stra);
+                        }
+                        else if (Regex.Matches(stra, "[a-z]").Count > 0)
+                        {
+                        }
+                        else
+                        {
+                            tmpname.Append(stra);
+                        }
+                        index++;
+                    }
+
+                }
+                name = tmpname.ToString();
+            }
+
+            name = Regex.Replace(name, @"\s", "");
+            name = name.Replace("\\", "");
+            if (name.Length > 6)
+            {
+                //新区,高新,产业等非新政单位
+                areaRemoveStr.ForEach(str =>
+                {
+                    name = name.Replace(str.Key, str.Value);
+                });
+                //去除冗余的学校信息,只保留地名和校名关键信息
+                schooRemoveStr.ForEach(str =>
+                {
+                    name = name.Replace(str, "");
+                });
+
+                //替换民族信息词
+                if (name.Length > 6)
+                {
+                    nationRemoveStr.ForEach(str =>
+                    {
+                        name = name.Replace(str, "");
+                    });
+                }
+                //替换学校信息的副词
+                if (name.Length > 6)
+                {
+                    foreach (var str in schooReplaceStr)
+                    {
+                        if (name.Length <= 6)
+                        {
+                            break;
+                        }
+                        name = name.Replace(str.Key, str.Value);
+
+                    }
+                }
+                //替换省简称信息词
+                string tmpname = name;
+                if (name.Length > 6)
+                {
+                    proReplaceStr.ForEach(str =>
+                    {
+                        name = name.Replace(str.Key, str.Value);
+                    });
+                    //如果替换后仍然大于6位,则取消,直接替换省份完整的词
+                    if (name.Length > 6)
+                    {
+                        name = tmpname.Replace(tmpprovince, "");
+                    }
+                }
+                //替换城市信息词
+                if (name.Length > 6)
+                {
+                    name = name.Replace(tmpcity, "");
+                }
+
+            }
+            int len = name.Length;
+            if (len > 6)
+            {
+                foreach (var str in afterSchoolRm)
+                {
+                    if (name.Length <= 6)
+                    {
+                        break;
+                    }
+                    name = name.Replace(str, "");
+                }
+            }
+            len = name.Length;
+            if (len >= 6)
+            {
+                name = $"{name.Substring(0, 1)}{name.Substring(len - 5, 3)}{name.Substring(len - 2, 2)}";
+            }
+            //if (len <= 7 && len > 6)
+            //{
+            //    name = name.Substring(len - 6);
+            //}
+            if (len <= 4)
+            {
+                name = $"{schoolInfo.city.Substring(0, 2)}{name}";
+            }
+            if (len == 5)
+            {
+                name = $"{schoolInfo.city.Substring(0, 1)}{name}";
+            }
+            string code = ToFirstPinYin(name);
+            schoolInfo.aname = name;
+            schoolInfo.id = code;
+
+            switch (schoolInfo.createCount)
+            {
+                case 1:
+                    if (schoolInfo.id.Equals(code))
+                    {
+                        string a_z = "abcdefghijklmnopqrstuvwxyz";
+                        var fs = schoolInfo.aname.Select(x => x).ToArray();
+                        var sp = schoolInfo.name.Select(x => x).ToArray();
+                        int Len = sp.Length;
+                        if (sp.Length >= fs.Length)
+                        {
+                            len = fs.Count();
+                        }
+
+                        for (int index = 0; index < len; index++)
+                        {
+                            if ($"{sp[index]}".Equals($"{fs[index]}"))
+                            {
+                                short st = ChineseChar.GetStrokeNumber(sp[index]);
+                                if (st > 0)
+                                {
+                                    var ins = st % 27;
+                                    var insch = a_z[ins];
+                                    if (schoolInfo.aname.EndsWith($"{insch}"))
+                                    {
+                                        ins = (st + 1) % 27;
+                                        insch = a_z[ins];
+                                    }
+                                    schoolInfo.id = schoolInfo.id.Insert(index, $"{insch}").Remove(index + 1, 1);
+                                    break;
+                                }
+                            }
+                        }
+                    }
+                    break;
+                case 2:
+                    if (schoolInfo.id.Equals(code))
+                    {
+                        var fs = schoolInfo.aname.Select(x => x).ToArray();
+                        var sp = schoolInfo.name.Select(x => x).ToArray();
+                        int Len = sp.Length;
+                        if (sp.Length >= fs.Length)
+                        {
+                            len = fs.Count();
+                        }
+
+                        for (int index = 0; index < len; index++)
+                        {
+                            if (!$"{sp[index]}".Equals($"{fs[index]}"))
+                            {
+                                var spstr = ToPinYin($"{sp[index]}");
+                                var fsstr = ToPinYin($"{fs[index]}");
+                                var insch = spstr.Select(x => $"{x}").Except(fsstr.Select(z => $"{z}"));
+                                if (insch != null && insch.Count() > 0)
+                                {
+                                    if (index > 1)
+                                    {
+                                        schoolInfo.id = schoolInfo.id.Insert(index - 1, insch.First()).Remove(index, 1);
+                                    }
+                                    else if (index == 1)
+                                    {
+                                        schoolInfo.id = schoolInfo.id.Insert(index, insch.First()).Remove(index - 1, 1);
+                                    }
+                                }
+                            }
+                        }
+                    }
+                    break;
+                case 3:
+                    if (schoolInfo.id.Equals(code))
+                    {
+                        string letter = RandomSmallLetter(1, false);
+                        string small = code.Substring(0, code.Length - 1);
+                        bool end = code.EndsWith(letter);
+                        if (end)
+                        {
+                            string tempLetter = RandomSmallLetter(1, false);
+                            schoolInfo.id = $"{small}{tempLetter}";
+                        }
+                        else 
+                        {
+                            schoolInfo.id = $"{small}{letter}";
+                        }
+                    }
+                    break;
+                default:
+                    break;
+            }
+
+            return schoolInfo;
+        }
+
+        /// <summary>
+        /// 生成随机字母
+        /// </summary>
+        /// <param name="Length">长度</param>
+        /// <param name="Sleep">是否要在生成前将当前线程阻止以避免重复</param>
+        /// <returns></returns>
+        public static string RandomSmallLetter(int Length, bool Sleep)
+        {
+            if (Sleep) System.Threading.Thread.Sleep(3);
+            char[] Pattern = new char[] { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' };
+            string result = "";
+            int n = Pattern.Length;
+            System.Random random = new Random(~unchecked((int)DateTime.Now.Ticks));
+            for (int i = 0; i < Length; i++)
+            {
+                int rnd = random.Next(0, n);
+                result += Pattern[rnd];
+            }
+            return result;
+        }
+
+        public static string ToPinYin(string val)
+        {
+            StringBuilder sb = new StringBuilder();
+            val.ToCharArray().ToList().ForEach(x =>
+            {
+                if (('a' <= x && x <= 'z') || ('A' <= x && x <= 'Z') || ('0' <= x && x <= '9'))
+                {
+                    sb.Append(x);
+                }
+                else
+                {
+                    try
+                    {
+                        ChineseChar cc = new ChineseChar(x);
+                        if (cc.Pinyins.Count > 0 && cc.Pinyins[0].Length > 0)
+                        {
+                            sb.Append(cc.Pinyins[0]);
+                        }
+                    }
+                    catch (Exception ex)
+                    {
+                    }
+                }
+            });
+            return sb.ToString().ToLower();
+        }
+        public static string ToFirstPinYin(string val)
+        {
+            StringBuilder sb = new StringBuilder();
+            val.ToCharArray().ToList().ForEach(x =>
+            {
+                if (('a' <= x && x <= 'z') || ('A' <= x && x <= 'Z') || ('0' <= x && x <= '9'))
+                {
+                    sb.Append(x);
+                }
+                else
+                {
+                    try
+                    {
+                        ChineseChar cc = new ChineseChar(x);
+                        if (cc.Pinyins.Count > 0 && cc.Pinyins[0].Length > 0)
+                        {
+                            sb.Append(cc.Pinyins[0][0]);
+                        }
+                    }
+                    catch (Exception ex)
+                    {
+                    }
+                }
+            });
+            return sb.ToString().ToLower();
+        }
+
+        public static List<string> comeRemoveStr = new List<string>() { "省", "市", "区", "州", "县", "旗", "盟", "自治" };
+        public static List<string> prvcRemoveStr = new List<string>() { "回族", "维吾尔", "壮族", };
+        public static List<string> cityRemoveStr = new List<string>() { "蒙古族", "地区", "壮族", "朝鲜族", "直辖" };
+        public static List<string> nationRemoveStr = new List<string> {
+            "维吾尔","回族", "自治", "满族", "蒙古", "壮族", "苗族" , "侗族", "瑶族",
+            "达斡尔","鄂温克","朝鲜","畲族","土家","各族","仫佬","毛南","羌族","彝族","仡佬","布依","水族",
+            "傣族","纳西","哈尼","拉祜","佤族","傈僳","独龙","怒族","白族","普米","固族","哈萨克","土族","撒拉","景颇","族"
+        };
+        public static List<string> schemoveStr = new List<string> { "第", "校区", "部", "楼", "与", "学校", "校园", };
+        public static List<string> schooRemoveStr = new List<string>() {"省", "市",  "区", "州", "县", "旗", "盟","办事处","街道", "自治",
+           "镇","村","乡","街","路","站","馆"
+        };
+        public static List<string> afterSchoolRm = new List<string>() {"校","园","院", "湾","峡","沟","山","庄",
+            "堡","江","屯","岭","溪","河","桥","营","铺","坡","寨","场","湖","巷","集","关","庙","寺","矿","塘"};
+        public static List<KeyValuePair<string, string>> areaRemoveStr = new List<KeyValuePair<string, string>>{
+            new KeyValuePair<string, string>("高新技术产业开发区", "高") ,
+             new KeyValuePair<string, string>("经济技术开发区", "经") ,
+            new KeyValuePair<string, string>("国际", "际") ,
+            new KeyValuePair<string, string>("中国", ""),
+            new KeyValuePair<string, string>("国家", ""),
+            new KeyValuePair<string, string>("新区", ""),
+            new KeyValuePair<string, string>("高新", "高"),
+            new KeyValuePair<string, string>("园区", ""),
+            new KeyValuePair<string, string>("产业", "产"),
+            new KeyValuePair<string, string>("经济", "经"),
+            new KeyValuePair<string, string>("开发", "开"),
+            new KeyValuePair<string, string>("中心", "") ,
+            new KeyValuePair<string, string>("集团", "") ,
+            new KeyValuePair<string, string>("公司", "") ,
+            new KeyValuePair<string, string>("有限", "") ,
+            new KeyValuePair<string, string>("股份", "") ,
+            new KeyValuePair<string, string>("服务", "") ,
+            new KeyValuePair<string, string>("基地", "") ,
+            new KeyValuePair<string, string>("社区", "社") ,
+            new KeyValuePair<string, string>("职工", "") ,
+            new KeyValuePair<string, string>("专修", ""),
+            new KeyValuePair<string, string>("实验", "验"),
+            new KeyValuePair<string, string>("完全", ""),
+            new KeyValuePair<string, string>("一贯制", "") ,
+            new KeyValuePair<string, string>("联办", ""),
+            new KeyValuePair<string, string>("联合", ""),
+            new KeyValuePair<string, string>("完小", "小"),
+            new KeyValuePair<string, string>("义务", ""),
+            new KeyValuePair<string, string>("基础", ""),
+            new KeyValuePair<string, string>("制造", "")
+        };
+        public static List<KeyValuePair<string, string>> schooReplaceStr = new List<KeyValuePair<string, string>> {
+            new KeyValuePair<string, string>("分校", "分") ,
+            new KeyValuePair<string, string>("分园", "分") ,
+            new KeyValuePair<string, string>("分院", "分") ,
+            new KeyValuePair<string, string>("藏文", "藏"),
+            new KeyValuePair<string, string>("职业技术学院", "职") ,
+            new KeyValuePair<string, string>("创新创业", "创") ,
+            new KeyValuePair<string, string>("就业创业", "就") ,
+            new KeyValuePair<string, string>("应用核技术", "核") ,
+            new KeyValuePair<string, string>("职业学院", "职") ,
+            new KeyValuePair<string, string>("幼儿园", "幼") ,
+            new KeyValuePair<string, string>("幼儿", "幼") ,
+            new KeyValuePair<string, string>("小学", "小") ,
+            new KeyValuePair<string, string>("中学", "中") ,
+            new KeyValuePair<string, string>("中等", "中") ,
+            new KeyValuePair<string, string>("双语", "双") ,
+            new KeyValuePair<string, string>("初中", "初") ,
+            new KeyValuePair<string, string>("初级", "初") ,
+            new KeyValuePair<string, string>("广播", "广"),
+            new KeyValuePair<string, string>("高中", "高") ,
+            new KeyValuePair<string, string>("高级", "高") ,
+            new KeyValuePair<string, string>("大学", "大") ,
+            new KeyValuePair<string, string>("学院", "院") ,
+            new KeyValuePair<string, string>("综合", "综") ,
+            new KeyValuePair<string, string>("职业", "职") ,
+            new KeyValuePair<string, string>("技术", "技") ,
+            new KeyValuePair<string, string>("专科", "专") ,
+            new KeyValuePair<string, string>("外国语", "外"),
+            new KeyValuePair<string, string>("九年", "九") ,
+            new KeyValuePair<string, string>("五年", "五") ,
+            new KeyValuePair<string, string>("年制", "制") ,
+            new KeyValuePair<string, string>("高等", "高") ,
+            new KeyValuePair<string, string>("院校", "院") ,
+            new KeyValuePair<string, string>("初等", "小") ,
+            new KeyValuePair<string, string>("附属", "附"),
+            new KeyValuePair<string, string>("寄宿制", "寄") ,
+            new KeyValuePair<string, string>("寄宿", "寄") ,
+            new KeyValuePair<string, string>("卫生", "卫") ,
+            new KeyValuePair<string, string>("创业", "创") ,
+            new KeyValuePair<string, string>("继续", "继") ,
+            new KeyValuePair<string, string>("开放", "开") ,
+            new KeyValuePair<string, string>("技师", "技") ,
+            new KeyValuePair<string, string>("成人", "成") ,
+            new KeyValuePair<string, string>("教育", "教") ,
+            new KeyValuePair<string, string>("科技", "科") ,
+            new KeyValuePair<string, string>("行政", "政") ,
+            new KeyValuePair<string, string>("生物", "生") ,
+            new KeyValuePair<string, string>("美术", "美") ,
+            new KeyValuePair<string, string>("设计", "设") ,
+            new KeyValuePair<string, string>("传播", "传") ,
+            new KeyValuePair<string, string>("计算机", "算") ,
+            new KeyValuePair<string, string>("土木", "土") ,
+            new KeyValuePair<string, string>("石油", "油") ,
+            new KeyValuePair<string, string>("科普", "普") ,
+            new KeyValuePair<string, string>("电信", "信") ,
+            new KeyValuePair<string, string>("联合", "联") ,
+            new KeyValuePair<string, string>("电商", "商") ,
+            new KeyValuePair<string, string>("纺织", "织") ,
+            new KeyValuePair<string, string>("服装", "服") ,
+            new KeyValuePair<string, string>("新闻", "新") ,
+            new KeyValuePair<string, string>("网络", "网") ,
+            new KeyValuePair<string, string>("应用", "应") ,
+            new KeyValuePair<string, string>("畜牧", "畜") ,
+            new KeyValuePair<string, string>("兽医", "兽") ,
+            new KeyValuePair<string, string>("师范", "师") ,
+            new KeyValuePair<string, string>("人文", "文") ,
+            new KeyValuePair<string, string>("创新", "创") ,
+            new KeyValuePair<string, string>("法官", "法") ,
+            new KeyValuePair<string, string>("邮电", "邮") ,
+            new KeyValuePair<string, string>("文化", "文") ,
+            new KeyValuePair<string, string>("函授", "函") ,
+            new KeyValuePair<string, string>("科学", "科") ,
+            new KeyValuePair<string, string>("信息", "息") ,
+            new KeyValuePair<string, string>("水利", "利") ,
+            new KeyValuePair<string, string>("水电", "电") ,
+            new KeyValuePair<string, string>("电力", "力") ,
+            new KeyValuePair<string, string>("环境", "环") ,
+            new KeyValuePair<string, string>("建材", "材") ,
+            new KeyValuePair<string, string>("机电", "机") ,
+            new KeyValuePair<string, string>("航空", "空") ,
+            new KeyValuePair<string, string>("航天", "天") ,
+            new KeyValuePair<string, string>("警察", "警") ,
+            new KeyValuePair<string, string>("警官", "警") ,
+            new KeyValuePair<string, string>("财贸", "财") ,
+            new KeyValuePair<string, string>("电子", "电") ,
+            new KeyValuePair<string, string>("建筑", "筑") ,
+            new KeyValuePair<string, string>("艺术", "艺") ,
+            new KeyValuePair<string, string>("体育", "体") ,
+            new KeyValuePair<string, string>("城市", "城") ,
+            new KeyValuePair<string, string>("地质", "地") ,
+            new KeyValuePair<string, string>("医药", "药") ,
+            new KeyValuePair<string, string>("政法", "法") ,
+            new KeyValuePair<string, string>("铁路", "铁") ,
+            new KeyValuePair<string, string>("铁道", "道") ,
+            new KeyValuePair<string, string>("轨道", "轨") ,
+            new KeyValuePair<string, string>("交通", "通") ,
+            new KeyValuePair<string, string>("医学院", "医") ,
+            new KeyValuePair<string, string>("医学", "医") ,
+            new KeyValuePair<string, string>("传媒", "媒") ,
+            new KeyValuePair<string, string>("工程", "程") ,
+            new KeyValuePair<string, string>("临床", "临") ,
+            new KeyValuePair<string, string>("化工", "化") ,
+            new KeyValuePair<string, string>("林业", "林") ,
+            new KeyValuePair<string, string>("老年", "老") ,
+            new KeyValuePair<string, string>("旅游", "游") ,
+            new KeyValuePair<string, string>("护理", "护") ,
+            new KeyValuePair<string, string>("贸易", "贸") ,
+            new KeyValuePair<string, string>("中医药", "中医") ,
+            new KeyValuePair<string, string>("资源", "源") ,
+            new KeyValuePair<string, string>("冶金", "冶") ,
+            new KeyValuePair<string, string>("能源", "能") ,
+            new KeyValuePair<string, string>("汽车", "车") ,
+            new KeyValuePair<string, string>("医科", "医") ,
+            new KeyValuePair<string, string>("机械", "械") ,
+            new KeyValuePair<string, string>("应用", "应") ,
+            new KeyValuePair<string, string>("电气", "电") ,
+            new KeyValuePair<string, string>("材料", "材") ,
+            new KeyValuePair<string, string>("劳动", "劳") ,
+            new KeyValuePair<string, string>("轻工", "轻") ,
+            new KeyValuePair<string, string>("农业", "农") ,
+            new KeyValuePair<string, string>("委员会", "委") ,
+             new KeyValuePair<string, string>("专业", "专") ,
+            new KeyValuePair<string, string>("广播", "广"),
+            new KeyValuePair<string, string>("电视", "电") ,
+            new KeyValuePair<string, string>("工商", "商") ,
+            new KeyValuePair<string, string>("工业", "工") ,
+            new KeyValuePair<string, string>("管理", "管") ,
+            new KeyValuePair<string, string>("社会主义", "社") ,
+            new KeyValuePair<string, string>("社会", "社") ,
+            new KeyValuePair<string, string>("自动化", "自") ,
+        };
+        public static List<KeyValuePair<string, string>> proReplaceStr = new List<KeyValuePair<string, string>> {
+            new KeyValuePair<string, string>("北京","京") ,
+            new KeyValuePair<string, string>("天津","津") ,
+            new KeyValuePair<string, string>("河北","冀") ,
+            new KeyValuePair<string, string>("山西","晋") ,
+            new KeyValuePair<string, string>("内蒙古","蒙") ,
+            new KeyValuePair<string, string>("辽宁","辽") ,
+            new KeyValuePair<string, string>("吉林","吉") ,
+            new KeyValuePair<string, string>("黑龙江","黑") ,
+            new KeyValuePair<string, string>("上海","沪") ,
+            new KeyValuePair<string, string>("江苏","苏") ,
+            new KeyValuePair<string, string>("浙江","浙") ,
+            new KeyValuePair<string, string>("安徽","皖") ,
+            new KeyValuePair<string, string>("福建","闽") ,
+            new KeyValuePair<string, string>("江西","赣") ,
+            new KeyValuePair<string, string>("山东","鲁") ,
+            new KeyValuePair<string, string>("河南","豫") ,
+            new KeyValuePair<string, string>("湖北","鄂") ,
+            new KeyValuePair<string, string>("湖南","湘") ,
+            new KeyValuePair<string, string>("广东","粤") ,
+            new KeyValuePair<string, string>("广西","桂") ,
+            new KeyValuePair<string, string>("海南","琼") ,
+            new KeyValuePair<string, string>("四川","川") ,
+            new KeyValuePair<string, string>("贵州","贵") ,
+            new KeyValuePair<string, string>("云南","云") ,
+            new KeyValuePair<string, string>("重庆","渝") ,
+            new KeyValuePair<string, string>("西藏","藏") ,
+            new KeyValuePair<string, string>("陕西","陕") ,
+            new KeyValuePair<string, string>("甘肃","甘") ,
+            new KeyValuePair<string, string>("青海","青") ,
+            new KeyValuePair<string, string>("宁夏","宁") ,
+            new KeyValuePair<string, string>("新疆","新") ,
+            new KeyValuePair<string, string>("香港","港") ,
+            new KeyValuePair<string, string>("澳门","澳") ,
+            new KeyValuePair<string, string>("台湾","台")
+        };
+
+    }
+}

+ 7 - 2
TEAMModelOS/ClientApp/src/view/student-account/stulist/MgtStuList.vue

@@ -237,6 +237,7 @@ export default {
             this.saveStuList(this.stuListShow[this.curIndex])
         },
         confirmSetNo() {
+            if (!this.editIrs) return
             //检查IRS号码重复
             let isRepeat = false
             this.students.forEach((item, index) => {
@@ -260,7 +261,7 @@ export default {
         },
         editStu(row, index) {
             this.editIndex = index
-            this.editIrs = parseInt(row.irs)
+            this.editIrs = row.irs ? parseInt(row.irs) : null
         },
         // 批量移除学生
         batchRemove() {
@@ -370,7 +371,8 @@ export default {
                             name: this.listInfo.listName,
                             periodId: this.listInfo.periodId,
                             school: this.$store.state.userInfo.schoolCode,
-                            members: []
+                            members: [],
+                            scount: 0
                             // creatorId: this.$store.state.userInfo.TEAMModelId,
                             // students: [],
                             // tmids: [],
@@ -469,6 +471,7 @@ export default {
                                     this.stuList.splice(index, 1)
                                 }
                             })
+                            this.selectList(0)
                             this.$Message.success(this.$t('teachermgmt.rmvOk'))
                         },
                         err => {
@@ -494,11 +497,13 @@ export default {
                     this.$Message.success(this.$t('cusMgt.updOk'))
                     this.addStuStatus = false
                     if (isPush) {
+                        params.id = res.list.id
                         this.stuList.unshift(params)
                         this.listInfo = {
                             listName: '',
                             periodId: ''
                         }
+                        this.selectList(0)
                     } else {
                         this.stuList.splice(this.curIndex, 1, params)
                     }