CrazyIter_Bin 6 tháng trước cách đây
mục cha
commit
270d3a9da3

+ 16 - 1
TEAMModelOS.Extension/HTEX.Test/Program.cs

@@ -30,7 +30,22 @@ namespace HTEX.Test
     {
         public static async Task Main(string[] args)
         {
-           
+
+            string sws = $"{"123".PadLeft(2, '0')}-{"1".PadLeft(2,'0')}";
+
+            List<string> s= new List<string>();
+            s.Add("fbc284072a40da84890e4860c15c453b8638a4b1839455635ab838bbe1a3339d31d8219466cef60f0f4a2622c5dc36c34f8ba143450025d2");
+            s.Add("fbc284072a40da8463057d2118d2978b37eb91e0534cfd525a76c5eed9c793affb417dcd776a68f119af14627d5ee85213f5e3e35f680538");
+            s.Add("fbc284072a40da8463057d2118d2978bf96625e980e310ef69dd62d4778abb46a3341709da302abe3623e3a37dd6796e8222f7143827eaef");
+            s.Add("fbc284072a40da8463057d2118d2978b2a80c26f4ac5aaa6981873f4e062d104a7d20b81890394af238c0acfb0949712980917fe9caee4aa");
+            s.Add("fbc284072a40da84b345d9b6abcc7f857352943f1a7ca844ce0e55c91821ec5b423d1f02b4768ab42017e0a418b25f7925a43125ffd20df7");
+            s.Add("fbc284072a40da8463057d2118d2978b98faee8d973f5641324682352e4aac2ef58c14a14929098788f0cfae40ca5d6a7af1d9c9c219006d");
+            s.Add("fbc284072a40da84c04385f268e6fefff3a0818487e5ccf023de060587c785a3d46ced5c51055055463ea6995045054723b328f9c3b32d27");
+            s.Add("fbc284072a40da84184ab5ec079fb0faea0716bb55bc45fe021d93318b256fb20126f7011f66d683c1b77f835b7def23d6957fb2b861aef0");
+            foreach (var item in s) 
+            {
+                MurmurHash3.Hash32(item);
+            }
             //await MockDataController.MockData();
             var builder = WebApplication.CreateBuilder(args);
 

+ 452 - 0
TEAMModelOS.SDK/Helper/Security/Hash/MurmurHash3.cs

@@ -0,0 +1,452 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace TEAMModelOS.SDK
+{
+    public static class MurmurHash3
+    {
+        public static uint Hash32(string input)
+        {
+            var buffer = Encoding.UTF8.GetBytes(input);
+            uint seed = 0;
+            using var stream = new MemoryStream(buffer);
+            var result = MurmurHash3.Hash32(stream, seed);
+            return result;
+        }
+        public static string Hash128(string input)
+        {
+            var buffer = Encoding.UTF8.GetBytes(input);
+            uint seed = 0;
+            using var stream = new MemoryStream(buffer);
+            var result = MurmurHash3.Hash128(stream, seed);
+            return Convert.ToHexString(result);
+        }
+
+        /// <summary>
+        /// Calculate 32-bit MurmurHash3 hash value using x86 version of the algorithm.
+        /// </summary>
+        /// <param name="stream">Input stream.</param>
+        /// <param name="seed">Seed value.</param>
+        /// <returns>Hash value.</returns>
+        public static uint Hash32(Stream stream, uint seed)
+        {
+            const int uintSize = sizeof(uint);
+            const uint final1 = 0x85ebca6b;
+            const uint final2 = 0xc2b2ae35;
+            const uint n = 0xe6546b64;
+            const uint m = 5;
+
+            uint hash = seed;
+            var buffer = new byte[uintSize].AsSpan();
+            uint length = 0;
+            int bytesRead;
+            while ((bytesRead = stream.Read(buffer)) == uintSize)
+            {
+                uint k = Bits.ToUInt32(buffer);
+                round32(ref k, ref hash);
+                hash = Bits.RotateLeft(hash, 13);
+                hash *= m;
+                hash += n;
+                length += (uint)bytesRead;
+            }
+
+            // process remaning bytes
+            if (bytesRead > 0)
+            {
+                uint remaining = Bits.PartialBytesToUInt32(buffer[..bytesRead]);
+                round32(ref remaining, ref hash);
+                length += (uint)bytesRead;
+            }
+
+            hash ^= length;
+
+            // finalization mix
+            hash ^= hash >> 16;
+            hash *= final1;
+            hash ^= hash >> 13;
+            hash *= final2;
+            hash ^= hash >> 16;
+            return hash;
+        }
+
+        /// <summary>
+        /// Calculate 32-bit MurmurHash3 hash value using x86 version of the algorithm.
+        /// </summary>
+        /// <param name="stream">Input stream.</param>
+        /// <param name="seed">Seed value.</param>
+        /// <returns>A <see cref="Task"/> representing the asynchronous hash operation.</returns>
+        public static async Task<uint> Hash32Async(Stream stream, uint seed)
+        {
+            const int uintSize = sizeof(uint);
+            const uint final1 = 0x85ebca6b;
+            const uint final2 = 0xc2b2ae35;
+            const uint n = 0xe6546b64;
+            const uint m = 5;
+
+            uint hash = seed;
+            var buffer = new byte[uintSize].AsMemory();
+            uint length = 0;
+            int bytesRead;
+            while ((bytesRead = await stream.ReadAsync(buffer).ConfigureAwait(false)) == uintSize)
+            {
+                uint k = Bits.ToUInt32(buffer.Span);
+                round32(ref k, ref hash);
+                hash = Bits.RotateLeft(hash, 13);
+                hash *= m;
+                hash += n;
+                length += (uint)bytesRead;
+            }
+
+            // process remaning bytes
+            if (bytesRead > 0)
+            {
+                uint remaining = Bits.PartialBytesToUInt32(buffer[..bytesRead].Span);
+                round32(ref remaining, ref hash);
+                length += (uint)bytesRead;
+            }
+
+            hash ^= length;
+
+            // finalization mix
+            hash ^= hash >> 16;
+            hash *= final1;
+            hash ^= hash >> 13;
+            hash *= final2;
+            hash ^= hash >> 16;
+            return hash;
+        }
+
+        /// <summary>
+        /// Calculate 32-bit MurmurHash3 hash value.
+        /// </summary>
+        /// <param name="buffer">Input buffer.</param>
+        /// <param name="seed">Seed value.</param>
+        /// <returns>Hash value.</returns>
+        public static uint Hash32(ReadOnlySpan<byte> buffer, uint seed)
+        {
+            const int uintSize = sizeof(uint);
+            const uint final1 = 0x85ebca6b;
+            const uint final2 = 0xc2b2ae35;
+            const uint n = 0xe6546b64;
+            const uint m = 5;
+
+            uint hash = seed;
+            int length = buffer.Length;
+            var (numUInts, leftBytes) = Math.DivRem(length, uintSize);
+            int i = 0;
+            for (; i < numUInts * sizeof(uint); i += sizeof(uint))
+            {
+                uint k = Bits.ToUInt32(buffer[i..(i + sizeof(uint))]);
+                round32(ref k, ref hash);
+                hash = Bits.RotateLeft(hash, 13);
+                hash *= m;
+                hash += n;
+            }
+
+            if (leftBytes > 0)
+            {
+                uint remaining = Bits.PartialBytesToUInt32(buffer[i..(i + leftBytes)]);
+                round32(ref remaining, ref hash);
+            }
+
+            hash ^= (uint)length;
+
+            // finalization mix
+            hash ^= hash >> 16;
+            hash *= final1;
+            hash ^= hash >> 13;
+            hash *= final2;
+            hash ^= hash >> 16;
+            return hash;
+        }
+
+        /// <summary>
+        /// Calculate 128-bit MurmurHash3 hash value using 64-bit version of the algorithm.
+        /// </summary>
+        /// <param name="stream">Input stream.</param>
+        /// <param name="seed">Seed value.</param>
+        /// <returns>128-bit hash value in a Span.</returns>
+        public static byte[] Hash128(Stream stream, uint seed)
+        {
+            const int ulongSize = sizeof(ulong);
+            const int blockSize = ulongSize * 2;
+
+            const ulong c1 = 0x87c37b91114253d5UL;
+            const ulong c2 = 0x4cf5ad432745937fUL;
+
+            ulong h1 = seed;
+            ulong h2 = seed;
+            var buffer = new byte[blockSize].AsSpan();
+            int outputLength = 0;
+            int readBytes;
+            while ((readBytes = stream.Read(buffer)) == blockSize)
+            {
+                ulong ik1 = Bits.ToUInt64(buffer);
+                ulong ik2 = Bits.ToUInt64(buffer[ulongSize..]);
+
+                round128(ref ik1, ref h1, c1, c2, h2, 31, 27, 0x52dce729U);
+                round128(ref ik2, ref h2, c2, c1, h1, 33, 31, 0x38495ab5U);
+
+                outputLength += blockSize;
+            }
+
+            ulong k1;
+            ulong k2;
+
+            if (readBytes > ulongSize)
+            {
+                k2 = Bits.PartialBytesToUInt64(buffer[ulongSize..]);
+                tailRound128(ref k2, ref h2, c2, c1, 33);
+                outputLength += readBytes - ulongSize;
+                readBytes = ulongSize;
+            }
+
+            if (readBytes > 0)
+            {
+                k1 = Bits.PartialBytesToUInt64(buffer[..readBytes]);
+                tailRound128(ref k1, ref h1, c1, c2, 31);
+                outputLength += readBytes;
+            }
+
+            h1 ^= (ulong)outputLength;
+            h2 ^= (ulong)outputLength;
+
+            h1 += h2;
+            h2 += h1;
+
+            fmix64(ref h1);
+            fmix64(ref h2);
+
+            h1 += h2;
+            h2 += h1;
+
+            return makeBytes(h1, h2);
+        }
+
+        /// <summary>
+        /// Calculate 128-bit MurmurHash3 hash value using x64 version of the algorithm.
+        /// </summary>
+        /// <param name="buffer">Input buffer.</param>
+        /// <param name="seed">Seed value.</param>
+        /// <returns>128-bit hash value as a Span of bytes.</returns>
+        public static byte[] Hash128(ReadOnlySpan<byte> buffer, uint seed)
+        {
+            const int blockSize = 16;
+            const ulong c1 = 0x87c37b91114253d5UL;
+            const ulong c2 = 0x4cf5ad432745937fUL;
+
+            ulong h1 = seed;
+            ulong h2 = seed;
+
+            int length = buffer.Length;
+            var (numBlocks, leftBytes) = Math.DivRem(length, blockSize);
+
+            int offset = 0;
+            int end = numBlocks * sizeof(ulong) * 2;
+            while (offset != end)
+            {
+                ulong ik1 = Bits.ToUInt64(buffer[offset..(offset + sizeof(ulong))]);
+                offset += sizeof(ulong);
+                ulong ik2 = Bits.ToUInt64(buffer[offset..(offset + sizeof(ulong))]);
+                offset += sizeof(ulong);
+
+                round128(ref ik1, ref h1, c1, c2, h2, 31, 27, 0x52dce729U);
+                round128(ref ik2, ref h2, c2, c1, h1, 33, 31, 0x38495ab5U);
+            }
+
+            int tail = offset;
+            ulong k1;
+            ulong k2;
+
+            if (leftBytes > sizeof(ulong))
+            {
+                offset += sizeof(ulong);
+                k2 = Bits.PartialBytesToUInt64(buffer[offset..]);
+                tailRound128(ref k2, ref h2, c2, c1, 33);
+                leftBytes = sizeof(ulong);
+            }
+
+            if (leftBytes > 0)
+            {
+                k1 = Bits.PartialBytesToUInt64(buffer[tail..(tail + leftBytes)]);
+                tailRound128(ref k1, ref h1, c1, c2, 31);
+            }
+
+            h1 ^= (ulong)length;
+            h2 ^= (ulong)length;
+
+            h1 += h2;
+            h2 += h1;
+
+            fmix64(ref h1);
+            fmix64(ref h2);
+
+            h1 += h2;
+            h2 += h1;
+
+            return makeBytes(h1, h2);
+        }
+
+        private static byte[] makeBytes(ulong h1, ulong h2)
+        {
+            var result = new byte[16];
+            BitConverter.TryWriteBytes(result, h1);
+            BitConverter.TryWriteBytes(result.AsSpan()[8..], h2);
+            return result;
+        }
+
+        [MethodImpl(MethodImplOptions.AggressiveInlining)]
+        private static void round32(ref uint value, ref uint hash)
+        {
+            const uint c1 = 0xcc9e2d51;
+            const uint c2 = 0x1b873593;
+
+            value *= c1;
+            value = Bits.RotateLeft(value, 15);
+            value *= c2;
+            hash ^= value;
+        }
+
+        [MethodImpl(MethodImplOptions.AggressiveInlining)]
+        private static void round128(
+            ref ulong k,
+            ref ulong h,
+            ulong c1,
+            ulong c2,
+            ulong hn,
+            int krot,
+            int hrot,
+            uint x)
+        {
+            k *= c1;
+            k = Bits.RotateLeft(k, krot);
+            k *= c2;
+            h ^= k;
+            h = Bits.RotateLeft(h, hrot);
+            h += hn;
+            h = (h * 5) + x;
+        }
+
+        [MethodImpl(MethodImplOptions.AggressiveInlining)]
+        private static void fmix64(ref ulong h)
+        {
+            h ^= h >> 33;
+            h *= 0xff51afd7ed558ccdUL;
+            h ^= h >> 33;
+            h *= 0xc4ceb9fe1a85ec53UL;
+            h ^= h >> 33;
+        }
+
+        [MethodImpl(MethodImplOptions.AggressiveInlining)]
+        private static void tailRound128(ref ulong k, ref ulong h, ulong c1, ulong c2, int rot)
+        {
+            k *= c1;
+            k = Bits.RotateLeft(k, rot);
+            k *= c2;
+            h ^= k;
+        }
+    }
+
+    internal static class Bits
+    {
+        [MethodImpl(MethodImplOptions.AggressiveInlining)]
+        internal static ulong RotateLeft(ulong value, int bits)
+        {
+            return (value << bits) | (value >> (64 - bits));
+        }
+
+        [MethodImpl(MethodImplOptions.AggressiveInlining)]
+        internal static uint RotateLeft(uint value, int bits)
+        {
+            return (value << bits) | (value >> (32 - bits));
+        }
+
+        [MethodImpl(MethodImplOptions.AggressiveInlining)]
+        internal static uint RotateRight(uint value, int bits)
+        {
+            return (value >> bits) | (value << (32 - bits));
+        }
+
+        [MethodImpl(MethodImplOptions.AggressiveInlining)]
+        internal static ulong RotateRight(ulong value, int bits)
+        {
+            return (value >> bits) | (value << (64 - bits));
+        }
+
+        [MethodImpl(MethodImplOptions.AggressiveInlining)]
+        internal static ulong ToUInt64(ReadOnlySpan<byte> bytes)
+        {
+            return Unsafe.ReadUnaligned<ulong>(ref MemoryMarshal.GetReference(bytes));
+        }
+
+        [MethodImpl(MethodImplOptions.AggressiveInlining)]
+        internal static uint ToUInt32(ReadOnlySpan<byte> bytes)
+        {
+            return Unsafe.ReadUnaligned<uint>(ref MemoryMarshal.GetReference(bytes));
+        }
+
+        [MethodImpl(MethodImplOptions.AggressiveInlining)]
+        internal static ulong PartialBytesToUInt64(ReadOnlySpan<byte> remainingBytes)
+        {
+            // a switch/case approach is slightly faster than the loop but .net
+            // refuses to inline it due to larger code size.
+            ulong result = 0;
+
+            // trying to modify leftBytes would invalidate inlining
+            // need to use local variable instead
+            for (int i = 0; i < remainingBytes.Length; i++)
+            {
+                result |= ((ulong)remainingBytes[i]) << (i << 3);
+            }
+
+            return result;
+        }
+
+        [MethodImpl(MethodImplOptions.AggressiveInlining)]
+        internal static uint PartialBytesToUInt32(ReadOnlySpan<byte> remainingBytes)
+        {
+            int len = remainingBytes.Length;
+            if (len > 3)
+            {
+                return Bits.ToUInt32(remainingBytes);
+            }
+
+            // a switch/case approach is slightly faster than the loop but .net
+            // refuses to inline it due to larger code size.
+            uint result = remainingBytes[0];
+            if (len > 1)
+            {
+                result |= (uint)(remainingBytes[1] << 8);
+            }
+
+            if (len > 2)
+            {
+                result |= (uint)(remainingBytes[2] << 16);
+            }
+
+            return result;
+        }
+
+        [MethodImpl(MethodImplOptions.AggressiveInlining)]
+        internal static uint SwapBytes32(uint num)
+        {
+            return (Bits.RotateLeft(num, 8) & 0x00FF00FFu)
+                 | (Bits.RotateRight(num, 8) & 0xFF00FF00u);
+        }
+
+        [MethodImpl(MethodImplOptions.AggressiveInlining)]
+        internal static ulong SwapBytes64(ulong num)
+        {
+            num = (Bits.RotateLeft(num, 48) & 0xFFFF0000FFFF0000ul)
+                | (Bits.RotateLeft(num, 16) & 0x0000FFFF0000FFFFul);
+            return (Bits.RotateLeft(num, 8) & 0xFF00FF00FF00FF00ul)
+                 | (Bits.RotateRight(num, 8) & 0x00FF00FF00FF00FFul);
+        }
+    }
+}

+ 128 - 0
TEAMModelOS/Controllers/Third/XunFeiJYY/XunFeiJYYService.cs

@@ -11,6 +11,9 @@ using System.Text.Json.Nodes;
 using TEAMModelOS.SDK.Extension;
 using Microsoft.Azure.Cosmos.Linq;
 using System.Text.Json;
+using System.ComponentModel.DataAnnotations;
+using TEAMModelOS.SDK.Context.Attributes.Azure;
+using Microsoft.Azure.Cosmos.Table;
 
 namespace TEAMModelOS.Controllers.Third.XunFeiJYY
 {
@@ -168,4 +171,129 @@ namespace TEAMModelOS.Controllers.Third.XunFeiJYY
             return (result, code, list);
         }
     }
+    public class XunFeiJYYBind
+    {
+        [Required(ErrorMessage = "{0} 必须填写")]
+        public string param { get; set; }
+        public string id_token { get; set; }
+        public string mobile { get; set; }
+    }
+    [TableName(Name = "ScYxpt")]
+    public class XunFeiJYYStudent : TableEntity
+    {
+        public string id { get; set; }
+        public string userName { get; set; }
+        public string userPhoto { get; set; }
+        public string schoolId { get; set; }
+        public string classId { get; set; }
+        /// <summary>
+        /// 班级号
+        /// </summary>
+        public string classNO { get; set; }
+        /// <summary>
+        /// 班级内的学号即座号
+        /// </summary>
+        public string classNo { get; set; }
+        public string genderCode { get; set; }
+        public string userClassId { get; set; }
+        public string tmdClassId { get; set; }
+        /// <summary>
+        ///优先匹配学号,再匹配姓名,如果名字不同,则检查id是否一致,如果id不一致则是两个人
+        /// </summary>
+        public string tmdStudentId { get; set; }
+        /// <summary>
+        /// MurmurHash3.Hash32 处理后的短码id
+        /// </summary>
+        public string hashNo { get; set; }
+
+    }
+    [TableName(Name = "ScYxpt")]
+    public class XunFeiJYYUser : TableEntity
+    {
+        public string userId { get; set; }
+        public string userName { get; set; }
+        public string userPhoto { get; set; }
+        public string schoolId { get; set; }
+        public string schoolName { get; set; }
+        public string province { get; set; }
+        public string city { get; set; }
+        public string district { get; set; }
+        public string mobile { get; set; }
+        public string genderCode { get; set; }
+        public string tmdid { get; set; }
+    }
+    [TableName(Name = "ScYxpt")]
+    public class XunFeiJYYClass : TableEntity
+    {
+        /// <summary>
+        /// 小学2024届5班
+        /// </summary>
+        public string className { get; set; }
+        /// <summary>
+        /// 毕业年份
+        /// </summary>
+        public string graduatedYear { get; set; }
+        /// <summary>
+        /// 学校id
+        /// </summary>
+        public string schoolId { get; set; }
+
+        /// <summary>
+        /// 学段
+        /// </summary>
+        public string phaseCode { get; set; }
+        /// <summary>
+        /// 
+        /// </summary>
+        public string id { get; set; }
+        /// <summary>
+        /// 系统学段code
+        /// </summary>
+        public string systemPhaseCode { get; set; }
+        /// <summary>
+        /// 班级类型,0行政班,1分层班,2选修班,3自由班,4培训机构下的班级
+        /// </summary>
+        public string classTypeCode { get; set; }
+        /// <summary>
+        /// 该班级是否已毕业,0否1是
+        /// </summary>
+        public string isGraduated { get; set; }
+        /// <summary>
+        /// 入学年份
+        /// </summary>
+        public string inYear { get; set; }
+        /// <summary>
+        /// 班级序号,用作排序
+        /// </summary>
+        public string classOrder { get; set; }
+        /// <summary>
+        /// 学区id
+        /// </summary>
+        public string campusId { get; set; }
+        /// <summary>
+        /// 班级的初始学段(用于跨学段升年级使用)
+        /// </summary>
+        public string initPhaseCode { get; set; }
+        /// <summary>
+        /// 醍摩豆班级id
+        /// </summary>
+        public string tmdClassId { get; set; }
+        /// <summary>
+        /// 醍摩豆学段id
+        /// </summary>
+        public string tmdPeriodId { get; set; }
+        /// <summary>
+        /// 醍摩豆学校简码
+        /// </summary>
+        public string tmdSchoolCode { get; set; }
+    }
+
+    public class XunFeiJYYBindDto
+    {
+        public string id { get; set; }
+        public string code { get; set; }
+        public string name { get; set; }
+        public string key { get; set; }
+
+    }
 }

+ 151 - 89
TEAMModelOS/Controllers/Third/XunFeiJYY/XunFeilJYYController.cs

@@ -32,6 +32,11 @@ using DocumentFormat.OpenXml.InkML;
 using System.IdentityModel.Tokens.Jwt;
 using System.Linq;
 using System.Net.Http.Headers;
+using DocumentFormat.OpenXml.VariantTypes;
+using static TEAMModelOS.SDK.SchoolService;
+using System.Security.Claims;
+using static TEAMModelOS.SDK.StudentService;
+using DocumentFormat.OpenXml.Office2010.Excel;
 
 
 namespace TEAMModelOS.Controllers.Third.XunFeiJYY
@@ -71,6 +76,9 @@ namespace TEAMModelOS.Controllers.Third.XunFeiJYY
         private static readonly string getOrgTeacherById = "getOrgTeacherById";
         //根据学生id查询行政学生
         private static readonly string getOrgStudentById = "getOrgStudentById";
+        //根据行政班级分页查询行政学生信息
+        private static readonly string listOrgStudentInOrgClass = "listOrgStudentInOrgClass";
+
         private readonly AzureCosmosFactory _azureCosmos;
         private readonly DingDing _dingDing;
         private readonly Option _option;
@@ -104,7 +112,148 @@ namespace TEAMModelOS.Controllers.Third.XunFeiJYY
                 new Dictionary<string, string>() { { "schoolId", schoolid } ,{ "param", $"{{\"limit\":{pageSize},\"pageIndex\":{pageIndex}}}" } },pageSize);
             if (data.code== 200)
             {
-               
+                List<XunFeiJYYBindDto> dtos = new List<XunFeiJYYBindDto>();
+                dtos.Add(new XunFeiJYYBindDto {
+                    id="fbc284072a40da84352496274afc3bc55db54e6686cf3af22a9f0a295239691707dc038c5d090450c46bdea890254258b8a118406664bdaf",
+                    code="",
+                    key="school",
+                    name="厦大附属翔安实验学校"
+                }); 
+                dtos.Add(new XunFeiJYYBindDto
+                {
+                    id="03",
+                    code="",
+                    key="period",
+                    name="小学"
+                }); dtos.Add(new XunFeiJYYBindDto
+                {
+                    id="04",
+                    code="",
+                    key="period",
+                    name="初中"
+                });
+                dtos.Add(new XunFeiJYYBindDto
+                {
+                    id="05",
+                    code="",
+                    key="period",
+                    name="高中"
+                });
+                var table = _azureStorage.GetCloudTableClient().GetTableReference("ScYxpt");
+                List<Class> classes = new List<Class>();
+                var schoolDto = dtos.FindAll(x => x.key.Equals("school")).First();
+                var dbclassrs = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School).GetList<Class>($"selelct value c from c ", $"Class-{schoolDto.code}");
+                if (dbclassrs.list.IsNotEmpty()) 
+                {
+                    classes.AddRange(dbclassrs.list);
+                }
+                foreach (XunFeiJYYClass clazz in data.list) 
+                {
+                    var tmdClassNO = clazz.classOrder;
+                    var tmdClassYear = clazz.inYear;
+                    var tmdClassId = MurmurHash3.Hash128(clazz.id);
+                    var periodDto = dtos.Find(x=>x.key.Equals("period") && x.id.Equals(clazz.phaseCode));
+                  
+                    XunFeiJYYClass saveClazz=clazz;
+                    List<XunFeiJYYClass> xfclasses = await table.FindListByDict<XunFeiJYYClass>(new Dictionary<string, object>() { { Constant.PartitionKey, $"XunFeiJYYClass" }, { Constant.RowKey, clazz.id} });
+                    bool dbExists = false;
+                    if (xfclasses.IsNotEmpty())
+                    {
+                        saveClazz=xfclasses.First();
+                        var dbclass= classes.Find(x => x.id.Equals(saveClazz.tmdClassId));
+                        if (dbclass!=null)
+                        {
+                            dbExists = true;
+                        }
+                    }
+                    else {
+                        saveClazz.tmdSchoolCode=schoolDto.code;
+                        saveClazz.tmdPeriodId=periodDto.code;
+                        saveClazz.tmdClassId=tmdClassId;
+                        saveClazz.PartitionKey="XunFeiJYYClass";
+                        dbExists = false;
+                    }
+                    if (!dbExists) 
+                    {
+                        Class @class = new Class
+                        {
+                            id =saveClazz.tmdClassId,
+                            code=$"Class-{schoolDto.code}",
+                            name=saveClazz.className,
+                            pk="Class",
+                            no=tmdClassNO,
+                            periodId=saveClazz.tmdPeriodId,
+                            year=int.Parse(tmdClassYear),
+                            school=schoolDto.code,
+                            graduate=saveClazz.isGraduated.Equals("0") ? 0 : 1,
+                           
+                        };
+                        await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School).UpsertItemAsync(@class,new PartitionKey($"Class-{schoolDto.code}"));
+                        await table.SaveOrUpdate<XunFeiJYYClass>(saveClazz);
+                    }
+                    List<Student> students = new List<Student>();
+                    var dbstudentsrs= await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Student).GetList<Student>($"select value s from s where s.classId='{saveClazz.tmdClassId}'",$"Base-{schoolDto.code}");
+                    if (dbstudentsrs.list.IsNotEmpty()) 
+                    {
+                        students.AddRange(dbstudentsrs.list);
+                    }
+                    var studentDatas = await XunFeiJYYService.PostRequestPageAll<XunFeiJYYStudent>(_httpClientFactory.CreateClient(), listOrgStudentInOrgClass, new Dictionary<string, string>() { { "classId", clazz.id }, { "param", $"{{\"limit\":{pageSize},\"pageIndex\":{pageIndex}}}" } }, pageSize);
+                    if (studentDatas.code==200) 
+                    {
+                        // id规则 inYrear+{学段order}classNO+classNo;
+
+                        foreach (XunFeiJYYStudent student in studentDatas.list)
+                        {
+                            
+                            XunFeiJYYStudent saveStudent = student;
+                            List<XunFeiJYYStudent> xfstudents = await table.FindListByDict<XunFeiJYYStudent>(new Dictionary<string, object>() { { Constant.PartitionKey, $"XunFeiJYYStudent" }, { Constant.RowKey, student.id } });
+                            dbExists = false;
+                            if (xfstudents.IsNotEmpty())
+                            {
+                                saveStudent=xfstudents.First();
+                                var dbstudent = students.Find(x => x.id.Equals(saveStudent.tmdStudentId));
+                                if (dbstudent!=null)
+                                {
+                                    if(dbstudent.name.Equals(saveStudent.userName))
+                                    dbExists = true;
+                                }
+                            }
+                            else
+                            {
+                                saveStudent.tmdStudentId=$"{tmdClassYear}{clazz.phaseCode}{tmdClassNO.PadLeft(2, '0')}{student.classNo.PadLeft(2, '0')}";
+                                saveStudent.hashNo=  $"{MurmurHash3.Hash32(student.id)}";
+                                saveStudent.RowKey = student.id;
+                                saveStudent.PartitionKey="XunFeiJYYStudent";
+                                saveStudent.tmdClassId=saveClazz.tmdClassId;
+                                dbExists = false;
+                            }
+                            if (dbExists)
+                            {
+                                var salt = Utils.CreatSaltString(8);
+                                var pw = Utils.HashedPassword(saveStudent.tmdStudentId, salt);
+                                Student studentSave = new Student
+                                {
+                                    id = student.tmdStudentId,
+                                    code=$"Base-{schoolDto.code}",
+                                    pk="Base",
+                                    gender=string.IsNullOrWhiteSpace(saveStudent.genderCode) ? "S" : saveStudent.genderCode.Equals("0") ? "F" : saveStudent.genderCode.Equals("1") ? "M" : "S",
+                                    classId=saveClazz.tmdClassId,
+                                    periodId=saveClazz.tmdPeriodId,
+                                    name=saveStudent.userName,
+                                    picture= saveStudent.userPhoto,
+                                    year=int.Parse(tmdClassYear),
+                                    no=saveStudent.classNo,
+                                    irs=saveStudent.classNo,
+                                    graduate=saveClazz.isGraduated.Equals("0") ? 0 : 1,
+                                    pw= pw,
+                                    salt=salt,
+                                };
+                                await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Student).UpsertItemAsync(studentSave, new PartitionKey($"Base-{schoolDto.code}"));
+                                await table.SaveOrUpdate<XunFeiJYYStudent>(saveStudent);
+                            }
+                        }
+                    }
+                }
                 return Ok(data.list);
             }
             else {
@@ -381,93 +530,6 @@ namespace TEAMModelOS.Controllers.Third.XunFeiJYY
             }
             return Ok(new { code = 400, rurl= rurl.ToString() });
         }
-        public class XunFeiJYYBind
-        {
-            [Required(ErrorMessage = "{0} 必须填写")]
-            public string param { get; set; }
-            public string id_token { get; set; }
-            public string mobile { get; set; }
-        }
-
-        [TableName(Name = "ScYxpt")]
-        public class XunFeiJYYUser : TableEntity
-        {
-            public string userId { get; set; }
-            public string userName { get; set; }
-            public string userPhoto { get; set; }
-            public string schoolId { get; set; }
-            public string schoolName { get; set; }
-            public string province { get; set; }
-            public string city { get; set; }
-            public string district { get; set; }
-            public string mobile { get; set; }
-            public string genderCode { get; set; }
-            public string  tmdid { get; set; }
-        }
-        [TableName(Name = "ScYxpt")]
-        public class XunFeiJYYClass : TableEntity
-        {
-            /// <summary>
-            /// 小学2024届5班
-            /// </summary>
-            public string className { get; set; }
-            /// <summary>
-            /// 毕业年份
-            /// </summary>
-            public string graduatedYear { get; set; }
-            /// <summary>
-            /// 学校id
-            /// </summary>
-            public string schoolId { get; set; }
-
-            /// <summary>
-            /// 学段
-            /// </summary>
-            public string phaseCode { get; set; }
-            /// <summary>
-            /// 
-            /// </summary>
-            public string id { get; set; }
-            /// <summary>
-            /// 系统学段code
-            /// </summary>
-            public string systemPhaseCode { get; set; }
-            /// <summary>
-            /// 班级类型,0行政班,1分层班,2选修班,3自由班,4培训机构下的班级
-            /// </summary>
-            public string classTypeCode { get; set; }
-            /// <summary>
-            /// 该班级是否已毕业,0否1是
-            /// </summary>
-            public string isGraduated { get; set; }
-            /// <summary>
-            /// 入学年份
-            /// </summary>
-            public string inYear { get; set; }
-            /// <summary>
-            /// 班级序号,用作排序
-            /// </summary>
-            public string classOrder { get; set; }
-            /// <summary>
-            /// 学区id
-            /// </summary>
-            public string campusId { get; set; }
-            /// <summary>
-            /// 班级的初始学段(用于跨学段升年级使用)
-            /// </summary>
-            public string initPhaseCode { get; set; }
-            /// <summary>
-            /// 醍摩豆班级id
-            /// </summary>
-            public string classId { get; set;}
-            /// <summary>
-            /// 醍摩豆学段id
-            /// </summary>
-            public string periodId { get; set; }
-            /// <summary>
-            /// 醍摩豆学校简码
-            /// </summary>
-            public string schoolCode { get; set; }
-        }
+        
     }
 }