Browse Source

合并服务器

yuanrf 1 week ago
parent
commit
da173b3520

+ 80 - 2
OASystem/OASystem.Api/Controllers/GroupsController.cs

@@ -29,6 +29,9 @@ using OASystem.Domain.ViewModels.Groups;
 using OASystem.Infrastructure.Repositories.CRM;
 using OASystem.Infrastructure.Repositories.Financial;
 using OASystem.Infrastructure.Repositories.Groups;
+using OfficeOpenXml;
+using Org.BouncyCastle.Asn1.Ocsp;
+using Org.BouncyCastle.Utilities.Encoders;
 using Quartz.Util;
 using SqlSugar.Extensions;
 using System.Collections;
@@ -5476,7 +5479,7 @@ FROM
             var permissions = new List<Grp_EnterExitCostPermission>();
             foreach (var userId in dto.UserIds)
             {
-                permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.GroupId, UserId = dto.CurrUserId, CreateUserId = userId });
+                permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.GroupId, UserId = userId, CreateUserId = dto.CurrUserId });
             }
             if (permissions.Any())
             {
@@ -7621,7 +7624,7 @@ FROM
             var permissions = new List<Grp_EnterExitCostDraftPermission>();
             foreach (var userId in dto.UserIds)
             {
-                permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = dto.CurrUserId, CreateUserId = userId });
+                permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
             }
             if (permissions.Any())
             {
@@ -17022,6 +17025,81 @@ ORDER by  gctggrc.id DESC
             return Ok(JsonView(true));
         }
 
+
+        /// <summary>
+        /// 接团客户名单
+        /// json字符串 AddMultiple(添加多个)
+        /// </summary>
+        /// <param name="_dto"></param>
+        /// <returns></returns>
+        [HttpPost]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
+        public async Task<IActionResult> PostTourClientListJsonFormatAddMultiple(PostTourClientListJsonFormatAddMultipleDto _dto)
+        {
+            #region  参数验证
+            string jsonLabel = _dto.JsonLabel;
+            if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
+            if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
+
+            PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
+
+            #region 页面操作权限验证
+            pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
+
+            if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
+
+            #endregion
+
+            #endregion
+
+            var request = new TourClientListAddMultipleDto();
+            request.DiId = _dto.DiId;
+
+            if (!CommonFun.IsValidJson(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数不是合法的json格式!"));
+            if (string.IsNullOrEmpty(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数值不能为空"));
+            List<TourClientListInfoCN> datas = JsonConvert.DeserializeObject<List<TourClientListInfoCN>>(jsonLabel);
+
+            if (!datas.Any()) return Ok(JsonView(false, "JsonLabel参数值不能为空!"));
+
+            var infos = new List<TourClientListInfo>();
+            foreach (var data in datas)
+            {
+
+                (string lastName, string firstName) = CommonFun.GetLastNameAndFirstName(data.Name);
+
+                string lastNameEn = CommonFun.ConvertToPinyin(lastName),
+                       firstNameEn = CommonFun.ConvertToPinyin(lastName);
+
+                if (string.IsNullOrEmpty(lastNameEn) || string.IsNullOrEmpty(firstNameEn))
+                {
+                    continue;
+                }
+
+                infos.Add(new TourClientListInfo() {
+                    IsAccompany =  1,
+                    LastName = lastName,
+                    FirstName = firstName,
+                    Pinyin = lastNameEn + @"/" + firstNameEn,
+                    Sex = data.Sex.Equals("男") ? 0 : data.Sex.Equals("女")? 1:2,
+                    CompanyFullName = data.CompanyFullName,
+                    Job = data.Job
+                });
+            }
+
+            if (infos.Any())
+            {
+                var viewData = await _tourClientListRep._AddMultiple(request);
+                if (viewData.Code != 0)
+                {
+                    return Ok(JsonView(false, viewData.Msg));
+                }
+                return Ok(JsonView(true));
+            }
+
+            return Ok(JsonView(false));
+        }
+
+
         /// <summary>
         /// 接团客户名单
         /// AddMultiple(添加多个)

+ 66 - 1
OASystem/OASystem.Domain/Dtos/Groups/TourClientListDto.cs

@@ -1,4 +1,5 @@
-using OASystem.Domain.Attributes;
+using Newtonsoft.Json;
+using OASystem.Domain.Attributes;
 using System;
 using System.Collections.Generic;
 using System.Linq;
@@ -144,6 +145,25 @@ namespace OASystem.Domain.Dtos.Groups
         public string? Remark { get; set; }
     }
 
+    /// <summary>
+    /// json字符串 AddMultiple(添加多个)
+    /// </summary>
+    public class PostTourClientListJsonFormatAddMultipleDto : UserPageFuncDtoBase
+    {
+        /// <summary>
+        /// 团组Id
+        /// </summary>
+        public int DiId { get; set; }
+
+        /// <summary>
+        /// json字符串
+        /// </summary>
+        public string JsonLabel { get; set; }
+    }
+
+
+
+
     /// <summary>
     /// 接团客户名单
     /// AddMultiple
@@ -163,6 +183,48 @@ namespace OASystem.Domain.Dtos.Groups
 
     }
 
+    /// <summary>
+    /// 接团客户名单
+    /// AddMultiple Info
+    /// </summary>
+    public class TourClientListInfoCN
+    {
+        /// <summary>
+        /// 姓
+        /// </summary>
+        [JsonProperty("姓名")]
+        [Encrypted]
+        public string? Name { get; set; }
+
+        /// <summary>
+        /// 性别
+        /// 0 男1 女 其他值 未设置
+        /// </summary>
+        [JsonProperty("性别")]
+        public string Sex { get; set; } 
+
+        /// <summary>
+        /// 公司名全称
+        /// </summary>
+        [JsonProperty("单位")]
+        [Encrypted]
+        public string? CompanyFullName { get; set; }
+
+        /// <summary>
+        /// 职位
+        /// </summary>
+        [JsonProperty("职务")]
+        [Encrypted]
+        public string? Job { get; set; }
+
+        /// <summary>
+        /// 生日
+        /// </summary>
+        [JsonProperty("出生日期")]
+        public string? BirthDay { get; set; }
+    }
+
+
     /// <summary>
     /// 接团客户名单
     /// AddMultiple Info
@@ -253,6 +315,9 @@ namespace OASystem.Domain.Dtos.Groups
         public string? Remark { get; set; }
     }
 
+
+
+
     public class TourClientListProcessInfo : TourClientListInfo
     {
         public int Id { get; set; } 

+ 1 - 1
OASystem/OASystem.Domain/ViewModels/Groups/EnterExitCostDraftView.cs

@@ -20,7 +20,7 @@ namespace OASystem.Domain.ViewModels.Groups
         public bool IsSave { get; set; }
         public bool IsView { get; set; } = false;
 
-        public int[] ViewUsers { get; set; }
+        public int[] ViewUsers { get; set; } = Array.Empty<int>();
 
         /// <summary>
         /// Id

+ 1 - 1
OASystem/OASystem.Domain/ViewModels/Groups/EnterExitCostView.cs

@@ -262,7 +262,7 @@ namespace OASystem.Domain.ViewModels.Groups
         public bool IsSave { get; set; }
         public bool IsView { get; set; } = false;
 
-        public int[] ViewUsers { get; set; }
+        public int[] ViewUsers { get; set; } = Array.Empty<int>();
 
         /// <summary>
         /// Id

+ 1 - 0
OASystem/OASystem.Infrastructure/OASystem.Infrastructure.csproj

@@ -16,6 +16,7 @@
     <PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="7.0.0" />
     <PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="7.0.0" />
     <PackageReference Include="NPOI" Version="2.6.0" />
+    <PackageReference Include="pinyin4net" Version="1.0.0" />
     <PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
     <PackageReference Include="SqlSugarCore" Version="5.1.3.32" />
     <PackageReference Include="StackExchange.Redis" Version="2.6.96" />

+ 2 - 2
OASystem/OASystem.Infrastructure/Repositories/Groups/EnterExitCostDraftRepository.cs

@@ -35,7 +35,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
         /// <param name="groupId">草稿Id</param>
         /// <param name="permission">操作权限 1:查看;2:新增;3:编辑;4:删除;5:下载; </param>
         /// <returns></returns>
-        public async Task<bool> PermissionValidationAsync(int groupId, int permission)
+        public async Task<bool> PermissionValidationAsync(int groupId, int userId, int permission=1)
         {
             //参数验证
             if (groupId < 1) return false;
@@ -43,7 +43,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
             if (!permissionIds.Contains(permission)) return false;
 
             var info = await _sqlSugar.Queryable<Grp_EnterExitCostDraftPermission>()
-                     .Where(it => it.DraftId == groupId && it.Permission == permission)
+                     .Where(it => it.DraftId == groupId && it.UserId == userId && it.Permission == permission)
                      .FirstAsync();
             if (info != null) return true;
 

+ 3 - 2
OASystem/OASystem.Infrastructure/Repositories/Groups/EnterExitCostRepository.cs

@@ -38,15 +38,16 @@ namespace OASystem.Infrastructure.Repositories.Groups
         /// <param name="groupId">团组Id</param>
         /// <param name="permission">操作权限 1:查看;2:新增;3:编辑;4:删除;5:下载; </param>
         /// <returns></returns>
-        public async Task<bool> PermissionValidationAsync(int groupId, int permission)
+        public async Task<bool> PermissionValidationAsync(int groupId, int userId, int permission = 1)
         {
             //参数验证
             if (groupId < 1) return false;
+            if (userId < 1) return false;
             var permissionIds = new List<int>() { 1, 2, 3, 4, 5 };
             if (!permissionIds.Contains(permission)) return false;
 
             var info = await _sqlSugar.Queryable<Grp_EnterExitCostPermission>()
-                     .Where(it => it.GroupId == groupId && it.Permission == permission)
+                     .Where(it => it.GroupId == groupId && it.UserId == userId && it.Permission == permission)
                      .FirstAsync();
             if (info != null) return true;
 

+ 100 - 4
OASystem/OASystem.Infrastructure/Tools/CommonFun.cs

@@ -1,4 +1,6 @@
-using NPOI.SS.Formula.Functions;
+using Newtonsoft.Json.Linq;
+using Newtonsoft.Json;
+using NPOI.SS.Formula.Functions;
 using OASystem.Domain.ViewModels.Financial;
 using OASystem.Domain.ViewModels.Groups;
 using System.Collections;
@@ -6,6 +8,8 @@ using System.Globalization;
 using System.Reflection;
 using System.Reflection.Metadata;
 using System.Security.Cryptography;
+using Pinyin4net.Format;
+using Pinyin4net;
 
 namespace OASystem.Infrastructure.Tools;
 
@@ -34,11 +38,11 @@ public static class CommonFun
     }
     public static string ToJson(this object obj)
     {
-        return JsonSerializer.Serialize(obj);
+        return System.Text.Json.JsonSerializer.Serialize(obj);
     }
     public static T ToObject<T>(this string json)
     {
-        return JsonSerializer.Deserialize<T>(json);
+        return System.Text.Json.JsonSerializer.Deserialize<T>(json);
     }
     public static object GetDefaultVal(string typename)
     {
@@ -594,5 +598,97 @@ public static class CommonFun
     }
 
 
-   
+    /// <summary>
+    /// 验证json字符串是否合法
+    /// </summary>
+    /// <param name="jsonString"></param>
+    /// <returns></returns>
+    public static bool IsValidJson(string jsonString)
+    {
+        try
+        {
+            JToken.Parse(jsonString);
+            return true;
+        }
+        catch (JsonReaderException)
+        {
+            return false;
+        }
+    }
+
+
+    /// <summary>
+    /// 常见的双字姓氏列表
+    /// </summary>
+    private static readonly HashSet<string> commonDoubleSurnames = new HashSet<string>
+    {
+        "欧阳", "司马", "上官", "夏侯", "诸葛", "东方", "赫连", "皇甫", "尉迟", "公羊", 
+        "澹台", "公冶", "宗政", "濮阳", "淳于", "单于", "太叔", "申屠", "公孙", "仲孙", 
+        "轩辕", "令狐", "钟离", "宇文", "长孙", "慕容", "鲜于", "闾丘", "司徒", "司空", 
+        "亓官", "司寇", "仉督", "子车", "颛孙", "端木", "巫马", "公西", "漆雕", "乐正",
+        "壤驷", "公良", "拓跋", "夹谷", "宰父", "谷梁", "晋楚", "闫法", "汝鄢", "涂钦", 
+        "段干", "百里", "东郭", "南门", "呼延", "归海", "羊舌", "微生", "岳帅", "缑亢", 
+        "况后", "有琴", "梁丘", "左丘", "东门", "西门", "商牟", "佘佴", "伯赏", "南宫"
+    };
+
+    /// <summary>
+    /// 中文名字取姓氏和名字
+    /// </summary>
+    /// <param name="fullName"></param>
+    /// <returns>姓:lastName 名:firstName</returns>
+    public static (string lastName, string firstName) GetLastNameAndFirstName(string fullName)
+    {
+        if (string.IsNullOrEmpty(fullName) || fullName.Length < 2) return ("", "");
+
+        // 尝试匹配双字姓氏
+        if (fullName.Length > 2)
+        {
+            string potentialDoubleSurname = fullName.Substring(0, 2);
+            if (commonDoubleSurnames.Contains(potentialDoubleSurname))
+            {
+                string lastName = potentialDoubleSurname;
+                string firstName = fullName.Substring(2);
+                return (lastName, firstName);
+            }
+        }
+
+        // 默认单字姓氏
+        string singleSurname = fullName.Substring(0, 1);
+        string remainingName = fullName.Substring(1);
+        return (singleSurname, remainingName);
+    }
+
+    /// <summary>
+    /// 中文名字转拼音
+    /// </summary>
+    /// <param name="chineseName"></param>
+    /// <returns></returns>
+    /// <exception cref="ArgumentException"></exception>
+    public static string ConvertToPinyin(string chineseName)
+    {
+        if (string.IsNullOrEmpty(chineseName)) return "";
+
+        HanyuPinyinOutputFormat format = new HanyuPinyinOutputFormat
+        {
+            ToneType = HanyuPinyinToneType.WITHOUT_TONE,
+            VCharType = HanyuPinyinVCharType.WITH_V,
+            CaseType = HanyuPinyinCaseType.UPPERCASE
+        };
+
+        string pinyin = string.Empty;
+        foreach (char ch in chineseName)
+        {
+            if (PinyinHelper.ToHanyuPinyinStringArray(ch) != null)
+            {
+                pinyin += PinyinHelper.ToHanyuPinyinStringArray(ch, format)[0];
+            }
+            else
+            {
+                pinyin += ch;
+            }
+        }
+
+        return pinyin;
+    }
+
 }