Browse Source

Merge branch 'develop' of http://132.232.92.186:3000/XinXiBu/OA2023 into develop

LEIYI 3 months ago
parent
commit
2298e7e95f

+ 70 - 0
OASystem/OASystem.Api/Controllers/GroupsController.cs

@@ -23,6 +23,7 @@ using OASystem.API.OAMethodLib.Hub.HubClients;
 using OASystem.API.OAMethodLib.Hub.Hubs;
 using OASystem.API.OAMethodLib.JuHeAPI;
 using OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice;
+using OASystem.Domain.AesEncryption;
 using OASystem.Domain.Dtos.CRM;
 using OASystem.Domain.Dtos.FileDto;
 using OASystem.Domain.Dtos.Financial;
@@ -2861,6 +2862,10 @@ FROM
         {
             string sql = string.Format("select b.Id,b.Pinyin,b.lastName,b.firstName,b.phone from  Grp_TourClientList a, Crm_DeleClient b where a.clientid = b.id and a.isdel = 0 and a.diid = {0}", diId);
             List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
+            foreach (var item in arr)
+            {
+                EncryptionProcessor.DecryptProperties(item);
+            }
             return arr;
         }
 
@@ -15304,6 +15309,8 @@ ORDER by  gctggrc.id DESC
                 //循环赋值
                 for (int i = 0; i < DcList.Count; i++)
                 {
+                    EncryptionProcessor.DecryptProperties(DcList[i]);
+
                     builder.MoveToCell(0, i + 1, 0, 0);
                     builder.Write(DcList[i].LastName + DcList[i].FirstName);
 
@@ -15347,6 +15354,7 @@ ORDER by  gctggrc.id DESC
                 for (int i = 0; i < DcList.Count; i++)
                 {
                     var dc = DcList[i];
+                    EncryptionProcessor.DecryptProperties(dc);
 
                     if (dc.CompanyFullName.Equals("暂无")) dc.CompanyFullName = "-";
                     if (dc.Job.Equals("暂无")) dc.Job = "-";
@@ -17929,6 +17937,68 @@ ORDER BY
             return Ok(JsonView(true, "操作成功!"));
         }
 
+        [HttpPost]
+        public async Task<IActionResult> encryptionClientInfo()
+        {
+            var jw = JsonView(false, "error");
+            _sqlSugar.BeginTran();
+            try
+            {
+                var deleList = _sqlSugar.Queryable<Crm_DeleClient>().ToList();
+                foreach (var item in deleList)
+                {
+                    EncryptionProcessor.EncryptProperties(item);
+                }
+                var deleCount =  await _sqlSugar.Updateable<Crm_DeleClient>(deleList).
+                         UpdateColumns(x => new 
+                         {
+                              x.FirstName,
+                              x.LastName,
+                              x.Phone,
+                              x.Job,
+                              x.Pinyin
+                         }).ExecuteCommandAsync();
+
+                var CertList = _sqlSugar.Queryable<Crm_CustomerCert>().ToList();
+                foreach (var item in CertList)
+                {
+                    EncryptionProcessor.EncryptProperties(item);
+                }
+                var CertCount = await _sqlSugar.Updateable(CertList).
+                         UpdateColumns(x => new
+                         {
+                            x.CertNo
+                         }).ExecuteCommandAsync();
+
+                var CompanyList = _sqlSugar.Queryable<Crm_CustomerCompany>().ToList();
+                foreach (var item in CompanyList)
+                {
+                    EncryptionProcessor.EncryptProperties(item);
+                }
+                var CompanyCount = await _sqlSugar.Updateable(CompanyList).
+                         UpdateColumns(x => new
+                         {
+                             x.CompanyFullName
+                         }).ExecuteCommandAsync();
+
+                _sqlSugar.CommitTran();
+                jw.Code = 200;
+                jw.Data = new
+                {
+                    deleCount,
+                    CertCount,
+                    CompanyCount
+                };
+            }
+            catch (Exception ex)
+            {
+                jw.Code = 400;
+                jw.Msg = ex.Message;
+                _sqlSugar.RollbackTran();
+            }
+
+            return Ok(jw);
+        }
 
     }
 }

+ 0 - 1
OASystem/OASystem.Domain/AesEncryption/AesEncryptionHelper.cs

@@ -42,7 +42,6 @@ namespace OASystem.Domain.AesEncryption
         {
             if (string.IsNullOrEmpty(cipherText)) return cipherText;
             if (!EncryptionProcessor.IsEncrypted(cipherText)) return cipherText;
-
             using var aes = Aes.Create();
             aes.Key = Encoding.UTF8.GetBytes(Key);
             aes.IV = Encoding.UTF8.GetBytes(IV);

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

@@ -1,4 +1,5 @@
-using System;
+using OASystem.Domain.Attributes;
+using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;
@@ -66,17 +67,20 @@ namespace OASystem.Domain.Dtos.Groups
         /// <summary>
         /// 姓
         /// </summary>
+        [Encrypted]
         public string? LastName { get; set; }
 
         /// <summary>
         /// 名
         /// </summary>
+        [Encrypted]
         public string? FirstName { get; set; }
 
         /// <summary>
         /// 姓名拼音
         /// 姓/名 eg: LEI/YI
         /// </summary>
+        [Encrypted]
         public string? Pinyin { get; set; }
 
         /// <summary>
@@ -88,21 +92,25 @@ namespace OASystem.Domain.Dtos.Groups
         /// <summary>
         /// 手机号
         /// </summary>
+        [Encrypted]
         public string? Phone { get; set; }
 
         /// <summary>
         /// 公司名全称
         /// </summary>
+        [Encrypted]
         public string? CompanyFullName { get; set; }
 
         /// <summary>
         /// 职位
         /// </summary>
+        [Encrypted]
         public string? Job { get; set; }
 
         /// <summary>
         /// 身份证No
         /// </summary>
+        [Encrypted]
         public string? IDCardNo { get; set; }
 
         /// <summary>
@@ -169,16 +177,19 @@ namespace OASystem.Domain.Dtos.Groups
         /// <summary>
         /// 姓
         /// </summary>
+        [Encrypted]
         public string? LastName { get; set; }
 
         /// <summary>
         /// 名
         /// </summary>
+        [Encrypted]
         public string? FirstName { get; set; }
 
         /// <summary>
         /// 拼音
         /// </summary>
+        [Encrypted]
         public string Pinyin { get; set; }
 
         /// <summary>
@@ -190,21 +201,25 @@ namespace OASystem.Domain.Dtos.Groups
         /// <summary>
         /// 公司名全称
         /// </summary>
+        [Encrypted]
         public string? CompanyFullName { get; set; }
 
         /// <summary>
         /// 职位
         /// </summary>
+        [Encrypted]
         public string? Job { get; set; }
 
         /// <summary>
         /// 身份证No
         /// </summary>
+        [Encrypted]
         public string? IDCardNo { get; set; }
 
         /// <summary>
         /// 手机号
         /// </summary>
+        [Encrypted]
         public string? Phone { get; set; }
 
         /// <summary>

+ 3 - 1
OASystem/OASystem.Domain/Entities/Customer/Crm_CustomerCert.cs

@@ -1,4 +1,5 @@
-using System;
+using OASystem.Domain.Attributes;
+using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;
@@ -35,6 +36,7 @@ namespace OASystem.Domain.Entities.Customer
         /// 证件号
         /// </summary>
         [SugarColumn(IsNullable = true, ColumnDataType = "varchar(30)")]
+        [Encrypted]
         public string CertNo { get; set; }
         /// <summary>
         /// 签发国

+ 2 - 0
OASystem/OASystem.Domain/Entities/Customer/Crm_CustomerCompany.cs

@@ -1,4 +1,5 @@
 
+using OASystem.Domain.Attributes;
 namespace OASystem.Domain.Entities.Customer
 {
     /// <summary>
@@ -19,6 +20,7 @@ namespace OASystem.Domain.Entities.Customer
         /// 全称
         /// </summary>
         [SugarColumn(IsNullable =true,ColumnDataType = "varchar(80)")]
+        [Encrypted]
         public string? CompanyFullName { get; set; }
         /// <summary>
         /// 公司地址

+ 7 - 1
OASystem/OASystem.Domain/Entities/Customer/Crm_DeleClient.cs

@@ -1,4 +1,5 @@
-using System;
+using OASystem.Domain.Attributes;
+using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;
@@ -22,10 +23,12 @@ namespace OASystem.Domain.Entities.Customer
         /// 中文姓
         /// </summary>
         [SugarColumn(IsNullable = true, ColumnDataType = "varchar(50)")]
+        [Encrypted]
         public string LastName { get; set; }
         /// <summary>
         /// 中文名
         /// </summary>
+        [Encrypted]
         [SugarColumn(IsNullable = true, ColumnDataType = "varchar(50)")]
         public string FirstName { get; set; }
         /// <summary>
@@ -37,6 +40,7 @@ namespace OASystem.Domain.Entities.Customer
         /// 名字拼音
         /// </summary>
         [SugarColumn(IsNullable = true, ColumnDataType = "varchar(50)")]
+        [Encrypted]
         public string Pinyin { get; set; }
         /// <summary>
         /// 性别 
@@ -53,6 +57,7 @@ namespace OASystem.Domain.Entities.Customer
         /// 客户手机号
         /// </summary>
         [SugarColumn(IsNullable = true, ColumnDataType = "varchar(20)")]
+        [Encrypted]
         public string Phone { get; set; } = "";
         /// <summary>
         /// 出生省份
@@ -132,6 +137,7 @@ namespace OASystem.Domain.Entities.Customer
         /// 职位
         /// </summary>
         [SugarColumn(IsNullable = true, ColumnDataType = "varchar(200)")]
+        [Encrypted]
         public string Job { get; set; }
         /// <summary>
         /// 本人工作内容

+ 18 - 0
OASystem/OASystem.Domain/ViewModels/Groups/TourClientListView.cs

@@ -1,5 +1,6 @@
 using Google.Protobuf;
 using Newtonsoft.Json;
+using OASystem.Domain.Attributes;
 using OASystem.Domain.Entities.Groups;
 using System;
 using System.Collections.Generic;
@@ -35,26 +36,31 @@ namespace OASystem.Domain.ViewModels.Groups
         /// <summary>
         /// 姓
         /// </summary>
+        [Encrypted]
         public string? LastName { get; set; }
 
         /// <summary>
         /// 名
         /// </summary>
+        [Encrypted]
         public string? FirstName { get; set; }
 
         /// <summary>
         /// 公司名全称
         /// </summary>
+        [Encrypted]
         public string? CompanyFullName { get; set; }
 
         /// <summary>
         /// 职位
         /// </summary>
+        [Encrypted]
         public string? Job { get; set; }
 
         /// <summary>
         /// 身份证No
         /// </summary>
+        [Encrypted]
         public string? IDCardNo { get; set; }
 
         /// <summary>
@@ -95,17 +101,20 @@ namespace OASystem.Domain.ViewModels.Groups
         /// <summary>
         /// 姓
         /// </summary>
+        [Encrypted]
         public string? LastName { get; set; }
 
         /// <summary>
         /// 名
         /// </summary>
+        [Encrypted]
         public string? FirstName { get; set; }
 
         /// <summary>
         /// 姓名拼音
         /// 姓/名 eg: LEI/YI
         /// </summary>
+        [Encrypted]
         public string? Pinyin { get; set; }
 
         /// <summary>
@@ -117,21 +126,25 @@ namespace OASystem.Domain.ViewModels.Groups
         /// <summary>
         /// 手机号
         /// </summary>
+        [Encrypted]
         public string? Phone { get; set; }
 
         /// <summary>
         /// 公司名全称
         /// </summary>
+        [Encrypted]
         public string? CompanyFullName { get; set; }
 
         /// <summary>
         /// 职位
         /// </summary>
+        [Encrypted]
         public string? Job { get; set; }
 
         /// <summary>
         /// 身份证No
         /// </summary>
+        [Encrypted]
         public string? IDCardNo { get; set; }
 
         /// <summary>
@@ -208,15 +221,20 @@ namespace OASystem.Domain.ViewModels.Groups
         /// <summary>
         /// 公司全称
         /// </summary>
+        [Encrypted]
         public string? CompanyFullName { get; set; }
     }
 
     public class SimplClientInfo
     {
         public int Id { get; set; }
+        [Encrypted]
         public string Pinyin { get; set; }
+        [Encrypted]
         public string LastName { get; set; }
+        [Encrypted]
         public string FirstName { get; set; }
+        [Encrypted]
         public string Phone { get;set; }
     }
 }

+ 3 - 0
OASystem/OASystem.Infrastructure/Repositories/Groups/AirTicketResRepository.cs

@@ -2,6 +2,7 @@
 using Newtonsoft.Json;
 using Newtonsoft.Json.Linq;
 using OASystem.Domain;
+using OASystem.Domain.AesEncryption;
 using OASystem.Domain.Dtos.Groups;
 using OASystem.Domain.Entities.Customer;
 using OASystem.Domain.Entities.Financial;
@@ -240,6 +241,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
                             else
                             {
                                 Crm_DeleClient DeleClient = _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.IsDel == 0 && a.Id == int.Parse(item)).First();
+                                EncryptionProcessor.DecryptProperties(DeleClient);
                                 _AirTicketReservations[i].ClientNameStr += DeleClient.Pinyin + ',';
                             }
                         }
@@ -375,6 +377,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
                 }
                 string sqlClient = string.Format("select b.Id,b.Pinyin,b.lastName,b.firstName,b.phone from  Grp_TourClientList a, Crm_DeleClient b where a.clientid = b.id and a.isdel = 0 and a.diid = {0}", dto.DiId);
                 var clientArr = _sqlSugar.SqlQueryable<SimplClientInfo>(sqlClient).ToList();
+                foreach (var item in clientArr) { EncryptionProcessor.DecryptProperties(item); }
                 #endregion
 
                 var data = new

+ 10 - 0
OASystem/OASystem.Infrastructure/Repositories/Groups/CustomersRepository.cs

@@ -1,6 +1,7 @@
 using AutoMapper;
 using NPOI.POIFS.Crypt.Dsig;
 using OASystem.Domain;
+using OASystem.Domain.AesEncryption;
 using OASystem.Domain.Dtos.Financial;
 using OASystem.Domain.Dtos.Groups;
 using OASystem.Domain.Entities.Customer;
@@ -78,6 +79,10 @@ namespace OASystem.Infrastructure.Repositories.Groups
                 {
                     sql = string.Format("SELECT * FROM Crm_DeleClient cdc where id in ({0}) and IsDel  = 0", strCrmIds);
                     clietArr = _sqlSugar.SqlQueryable<Crm_DeleClient>(sql).ToList();
+                    foreach (var item in clietArr)
+                    {
+                        EncryptionProcessor.DecryptProperties(item);
+                    }
                 }
 
                 foreach (var item in Customers)
@@ -113,6 +118,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
                     {
                         var name = string.Empty;
                         var clientObject = clietArr.Find(x => x.Id == parseIntValue);
+                        EncryptionProcessor.DecryptProperties(clientObject);
                         name += (clientObject?.LastName + clientObject?.FirstName);
 
                         if (!string.IsNullOrWhiteSpace(name))
@@ -154,6 +160,10 @@ namespace OASystem.Infrastructure.Repositories.Groups
                 {
                     sql = string.Format("SELECT * FROM Crm_DeleClient cdc where id in ({0}) and IsDel  = 0", strCrmIds);
                     clietArr = _sqlSugar.SqlQueryable<Crm_DeleClient>(sql).ToList();
+                    foreach (var item in clietArr)
+                    {
+                        EncryptionProcessor.DecryptProperties(item);
+                    }
                 }
 
                 foreach (var item in Customers)

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

@@ -2,6 +2,7 @@
 using Newtonsoft.Json;
 using NPOI.OpenXmlFormats.Wordprocessing;
 using OASystem.Domain;
+using OASystem.Domain.AesEncryption;
 using OASystem.Domain.Dtos;
 using OASystem.Domain.Dtos.Financial;
 using OASystem.Domain.Dtos.Groups;
@@ -416,7 +417,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
                             param.ShippingSpaceSpecialNeeds = item.ShippingSpaceSpecialNeeds;
                             param.ShippingSpaceTypeId = item.ShippingSpaceTypeId;
                             param.Id = clientInfo.Id;
-
+                            EncryptionProcessor.DecryptProperties(param);
                             TourClientListInfoArr.Add(param);
                         }
 
@@ -463,7 +464,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
                             param.ShippingSpaceSpecialNeeds = item.ShippingSpaceSpecialNeeds;
                             param.ShippingSpaceTypeId = item.ShippingSpaceTypeId;
                             param.Id = item.Id;
-
+                            EncryptionProcessor.DecryptProperties(param);
                             TourClientListInfoArr.Add(param);
                         }
 

+ 47 - 15
OASystem/OASystem.Infrastructure/Repositories/Groups/TourClientListRepository.cs

@@ -3,10 +3,12 @@ using MathNet.Numerics.Distributions;
 using NPOI.SS.Formula.PTG;
 using NPOI.Util;
 using OASystem.Domain;
+using OASystem.Domain.AesEncryption;
 using OASystem.Domain.Dtos.CRM;
 using OASystem.Domain.Dtos.Groups;
 using OASystem.Domain.Entities.Customer;
 using OASystem.Domain.Entities.Groups;
+using OASystem.Domain.ViewModels.Financial;
 using OASystem.Domain.ViewModels.Groups;
 using OASystem.Infrastructure.Tools;
 using Org.BouncyCastle.Utilities.Encoders;
@@ -14,6 +16,7 @@ using StackExchange.Redis;
 using System;
 using System.Collections;
 using System.Collections.Generic;
+using System.Diagnostics;
 using System.Globalization;
 using System.Linq;
 using System.Text;
@@ -105,6 +108,13 @@ WHERE
   tcl.IsDel = 0
   AND tcl.DiId = {0}", diId);
                 var data = await _sqlSugar.SqlQueryable<TourClientListByDiIdView>(sql).ToListAsync();
+
+                foreach (var item in data)
+                {
+                    EncryptionProcessor.DecryptProperties(item);
+                }
+
+
                 _result.Code = 0;
                 _result.Data = data;
             }
@@ -148,6 +158,23 @@ WHERE
                 var clientCompanyData =  _sqlSugar.SqlQueryable<CustomerCompanyCiew>(clientCompanySql).ToList();
                 clientCompanyData = clientCompanyData.DistinctBy(it => it.CompanyFullName).ToList();
 
+                foreach ( var item in clientData)
+                {
+                    if (item.FirstName.Length > 5 && item.LastName.Length > 5)
+                    {
+                        EncryptionProcessor.DecryptProperties(item);
+                    }
+                }
+
+                foreach (var item in clientCompanyData)
+                {
+                    if (item.CompanyFullName.Length > 5)
+                    {
+                        EncryptionProcessor.DecryptProperties(item);
+                    }
+                }
+
+
                 var _view = new {
                     ShippingSpaceTypeData = shippingSpaceTypeData1,
                     ClientData = clientData,
@@ -224,7 +251,7 @@ WHERE
                 var data = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).FirstAsync();
                 if (data != null) 
                 {
-
+                    EncryptionProcessor.DecryptProperties(data);
                     data.BirthDay = data.BirthDay?.DateFormat("yyyy-MM-dd") ?? "";
                     _result.Code = 0;
                     _result.Data = data;
@@ -270,18 +297,6 @@ WHERE
                 _sqlSugar.BeginTran();
                 int clientId = -1;
                 int crmCompanyId = -1;
-                var clientInfo = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 
-                                                                                         && it.LastName.Equals(dto.LastName) 
-                                                                                         && it.FirstName.Equals(dto.FirstName) 
-                                                                                         //&& it.Phone.Equals(dto.Phone)
-                                                                                   ).FirstAsync();
-
-                Crm_CustomerCompany _CustomerCompany = new Crm_CustomerCompany()
-                {
-                    CompanyFullName = dto.CompanyFullName,
-                    LastedOpUserId = dto.UserId,
-                    CreateUserId = dto.UserId
-                };
 
                 string idNo = "", birthDay = "";
                 int sex = -1;
@@ -289,7 +304,7 @@ WHERE
 
                 if (!string.IsNullOrEmpty(dto.IDCardNo))
                 {
-                    
+
                     var idBool = dto.IDCardNo.IsValidChineseId();
                     if (idBool)
                     {
@@ -316,6 +331,20 @@ WHERE
 
                 #endregion
 
+                EncryptionProcessor.EncryptProperties(dto);
+
+                var clientInfo = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 
+                                                                                         && it.LastName.Equals(dto.LastName) 
+                                                                                         && it.FirstName.Equals(dto.FirstName) 
+                                                                                         //&& it.Phone.Equals(dto.Phone)
+                                                                                   ).FirstAsync();
+                
+                Crm_CustomerCompany _CustomerCompany = new Crm_CustomerCompany()
+                {
+                    CompanyFullName = dto.CompanyFullName,
+                    LastedOpUserId = dto.UserId,
+                    CreateUserId = dto.UserId
+                };
 
                 Crm_CustomerCert _CustomerCert = new Crm_CustomerCert()
                 {
@@ -366,7 +395,7 @@ WHERE
                         crmCompanyId = companyInfo.Id;
                         if (companyInfo.CompanyFullName.Equals(dto.CompanyFullName))
                         {
-                            companyInfo.CompanyFullName = dto.CompanyFullName;
+                            companyInfo.CompanyFullName = _CustomerCompany.CompanyFullName;
                             var companyEdit = await _sqlSugar.Updateable(companyInfo).UpdateColumns(it =>
                                                                                  new
                                                                                  {
@@ -591,6 +620,8 @@ WHERE
 
             foreach (var item in _TourClientListInfos)
             {
+                EncryptionProcessor.EncryptProperties(item);
+
                 _sqlSugar.BeginTran();
                 int companyId = -1;
                 int clientId = -1;
@@ -790,6 +821,7 @@ WHERE
 
                 foreach (var item in _TourClientListInfos)
                 {
+                    EncryptionProcessor.EncryptProperties(item);
                     //客户信息
                     var clientInfo = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 &&
                                                                              it.LastName.Equals(item.LastName) &&

+ 5 - 0
OASystem/OASystem.Infrastructure/Repositories/Groups/VisaPriceRepository.cs

@@ -2,6 +2,7 @@
 using AutoMapper;
 using NPOI.SS.Formula.Functions;
 using OASystem.Domain;
+using OASystem.Domain.AesEncryption;
 using OASystem.Domain.Dtos.Financial;
 using OASystem.Domain.Dtos.Groups;
 using OASystem.Domain.Entities.Customer;
@@ -109,6 +110,10 @@ Left Join Sys_SetData as sd With(Nolock) On c.PayDId = sd.Id
                     {
                         sql = string.Format("SELECT * FROM Crm_DeleClient cdc where id in ({0}) and IsDel  = 0", strCrmIds);
                         clietArr = _sqlSugar.SqlQueryable<Crm_DeleClient>(sql).ToList();
+                        foreach (var item in clietArr)
+                        {
+                            EncryptionProcessor.DecryptProperties(item);
+                        }
                     }
 
                     Dictionary<int, string> dic_Currency = new Dictionary<int, string>();