From eee388369e22419d3e5930801931de4b99cc2d61 Mon Sep 17 00:00:00 2001 From: wet <1034391973@qq.com> Date: Fri, 13 Jan 2023 16:18:51 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E7=94=A8=E6=88=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Myshipping.Core/Myshipping.Core.xml | 5 +++-- Myshipping.Core/Service/User/ISysUserService.cs | 2 +- Myshipping.Core/Service/User/SysUserService.cs | 7 ++++--- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Myshipping.Core/Myshipping.Core.xml b/Myshipping.Core/Myshipping.Core.xml index dc19a8a2..253d635a 100644 --- a/Myshipping.Core/Myshipping.Core.xml +++ b/Myshipping.Core/Myshipping.Core.xml @@ -15042,11 +15042,12 @@ - + - 获取租户下的用户 + 获取租户下的用户 + 默认0 获取当前用户,可不传 传租户id获取当前租户 diff --git a/Myshipping.Core/Service/User/ISysUserService.cs b/Myshipping.Core/Service/User/ISysUserService.cs index 7764bccb..c19561c5 100644 --- a/Myshipping.Core/Service/User/ISysUserService.cs +++ b/Myshipping.Core/Service/User/ISysUserService.cs @@ -31,5 +31,5 @@ public interface ISysUserService Task> GetDataScopeIdUserList(long userId = 0); void CheckDataScopeByUserId(long userId); void CheckDataScope(long orgId); - Task> GetTenantUser(string name,int type); + Task> GetTenantUser(string name,long? tenantId); } diff --git a/Myshipping.Core/Service/User/SysUserService.cs b/Myshipping.Core/Service/User/SysUserService.cs index 8c105ecb..760067df 100644 --- a/Myshipping.Core/Service/User/SysUserService.cs +++ b/Myshipping.Core/Service/User/SysUserService.cs @@ -544,12 +544,13 @@ public class SysUserService : ISysUserService, IDynamicApiController, ITransient /// 获取租户下的用户 /// /// - /// 默认0 获取当前用户,可不传 1 获取所有用户 + /// 默认0 获取当前用户,可不传 传租户id获取当前租户 /// [HttpGet("/sysUser/GetTenantUser")] - public Task> GetTenantUser(string name, int type = 0) + public Task> GetTenantUser(string name, long? tenantId = 0) { - return _sysUserRep.AsQueryable().Filter(null, true).WhereIF(type == 0, x => x.TenantId == Convert.ToInt64(UserManager.TENANT_ID)) + return _sysUserRep.AsQueryable().Filter(null, true).WhereIF(tenantId == 0, x => x.TenantId == Convert.ToInt64(UserManager.TENANT_ID)) + .WhereIF(tenantId != 0, x => x.TenantId == tenantId) .WhereIF(!string.IsNullOrWhiteSpace(name), x => x.Name.Contains(name)).ToListAsync(); } From 9341fc7a0116b45585099aba182179b998833c54 Mon Sep 17 00:00:00 2001 From: wet <1034391973@qq.com> Date: Tue, 17 Jan 2023 15:44:23 +0800 Subject: [PATCH 2/2] =?UTF-8?q?excel=E5=AF=BC=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BookingOrder/BookingOrderService.cs | 187 +++++++++++++++--- Myshipping.Core/Const/ClaimConst.cs | 13 ++ Myshipping.Core/Manager/UserManager.cs | 16 ++ Myshipping.Core/Service/Auth/AuthService.cs | 6 + 4 files changed, 195 insertions(+), 27 deletions(-) diff --git a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs index 9aeb7efd..c65530cb 100644 --- a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs +++ b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs @@ -1765,6 +1765,7 @@ namespace Myshipping.Application } var order = await _rep.FirstOrDefaultAsync(x => x.Id == bookingId); + var edi = await _bookingEDIExt.FirstOrDefaultAsync(x => x.BookingId == bookingId); if (order == null) { throw Oops.Bah(BookingErrorCode.BOOK001); @@ -1847,27 +1848,96 @@ namespace Myshipping.Application { if (entity.Where(x => x.Row == _row && x.Column == _cellNum).Count() > 0) { - foreach (PropertyDescriptor descriptor in TypeDescriptor.GetProperties(order)) + var name = entity.Where(x => x.Row == _row && x.Column == _cellNum).Select(x => x.Field).FirstOrDefault(); + + if (name.Split('.')[0].ToLower() == "order") { - var name = entity.Where(x => x.Row == _row && x.Column == _cellNum).Select(x => x.Field).FirstOrDefault(); - var _name = descriptor.Name.ToLower(); - if (name == _name) + + foreach (PropertyDescriptor descriptor in TypeDescriptor.GetProperties(order)) { - var value = descriptor.GetValue(order).ToString(); - ICell cell = row.GetCell(_cellNum - 1); - if (descriptor.PropertyType.FullName.Contains("DateTime")) - { - value = value != null ? Convert.ToDateTime(value).ToString("yyyy-MM-dd") : ""; - } - if (cell != null) + var _name = descriptor.Name.ToLower(); + if (name.Split('.')[0].ToLower() == "order" && name.Split('.')[1].ToLower() == _name) { - row.Cells[_cellNum - 1].SetCellValue(value); + var value = descriptor.GetValue(order).ToString(); + ICell cell = row.GetCell(_cellNum - 1); + if (descriptor.PropertyType.FullName.Contains("DateTime")) + { + value = value != null ? Convert.ToDateTime(value).ToString("yyyy-MM-dd") : ""; + } + if (cell != null) + { + row.Cells[_cellNum - 1].SetCellValue(value); + } + else + { + row.CreateCell(_cellNum - 1).SetCellValue(value); + } } - else + } + + + } + + if (name.Split('.')[0].ToLower() == "edi") + { + + foreach (PropertyDescriptor descriptor in TypeDescriptor.GetProperties(edi)) + { + var _name = descriptor.Name.ToLower(); + if (name.Split('.')[0].ToLower() == "edi" && name.Split('.')[1].ToLower() == _name) { - row.CreateCell(_cellNum - 1).SetCellValue(value); + var value = descriptor.GetValue(edi).ToString(); + ICell cell = row.GetCell(_cellNum - 1); + if (descriptor.PropertyType.FullName.Contains("DateTime")) + { + value = value != null ? Convert.ToDateTime(value).ToString("yyyy-MM-dd") : ""; + } + if (cell != null) + { + row.Cells[_cellNum - 1].SetCellValue(value); + } + else + { + row.CreateCell(_cellNum - 1).SetCellValue(value); + } } } + + + } + + if (name.Split('.')[0].ToLower() != "order" && name.Split('.')[0].ToLower() != "edi" && name.Split('.')[0].ToLower() != "ctn") + { + ICell cell = row.GetCell(_cellNum - 1); + var value = string.Empty; + if (name.Split('.')[0].ToLower() == "username") + { + value = UserManager.Name; + } + if (name.Split('.')[0].ToLower() == "usertel") + { + value = UserManager.TEl; + } + if (name.Split('.')[0].ToLower() == "usermobile") + { + value = UserManager.Phone; + } + if (name.Split('.')[0].ToLower() == "useremail") + { + value = UserManager.Email; + } + if (name.Split('.')[0].ToLower() == "usertenant") + { + value = UserManager.TENANT_NAME; + } + if (cell != null) + { + row.Cells[_cellNum - 1].SetCellValue(value); + } + else + { + row.CreateCell(_cellNum - 1).SetCellValue(value); + } } } } @@ -1881,16 +1951,69 @@ namespace Myshipping.Application { if (entity.Where(x => x.Row == _row && x.Column == _cellNum).Count() > 0) { - foreach (PropertyDescriptor descriptor in TypeDescriptor.GetProperties(order)) + var name = entity.Where(x => x.Row == _row && x.Column == _cellNum).Select(x => x.Field).FirstOrDefault(); + + if (name.Split('.')[0].ToLower() == "order") { - var name = entity.Where(x => x.Row == _row && x.Column == _cellNum).Select(x => x.Field).FirstOrDefault(); - var _name = descriptor.Name.ToLower(); - if (name == _name) + foreach (PropertyDescriptor descriptor in TypeDescriptor.GetProperties(order)) { - var value = descriptor.GetValue(order).ToString(); - srow.CreateCell(_cellNum - 1).SetCellValue(value); + var _name = descriptor.Name.ToLower(); + if (name.Split('.')[1].ToLower() == _name && name.Split('.')[0].ToLower() == "order") + { + var value = descriptor.GetValue(order).ToString(); + if (descriptor.PropertyType.FullName.Contains("DateTime")) + { + value = value != null ? Convert.ToDateTime(value).ToString("yyyy-MM-dd") : ""; + } + srow.CreateCell(_cellNum - 1).SetCellValue(value); + } + } + } + if (name.Split('.')[0].ToLower() == "edi") + { + foreach (PropertyDescriptor descriptor in TypeDescriptor.GetProperties(edi)) + { + var _name = descriptor.Name.ToLower(); + if (name.Split('.')[1].ToLower() == _name && name.Split('.')[0].ToLower() == "edi") + { + var value = descriptor.GetValue(edi).ToString(); + if (descriptor.PropertyType.FullName.Contains("DateTime")) + { + value = value != null ? Convert.ToDateTime(value).ToString("yyyy-MM-dd") : ""; + } + srow.CreateCell(_cellNum - 1).SetCellValue(value); + } } } + + if (name.Split('.')[0].ToLower() != "order" && name.Split('.')[0].ToLower() != "edi" && name.Split('.')[0].ToLower() != "ctn") + { + + var value = string.Empty; + if (name.Split('.')[0].ToLower() == "username") + { + value = UserManager.Name; + } + if (name.Split('.')[0].ToLower() == "usertel") + { + value = UserManager.TEl; + } + if (name.Split('.')[0].ToLower() == "usermobile") + { + value = UserManager.Phone; + } + if (name.Split('.')[0].ToLower() == "useremail") + { + value = UserManager.Email; + } + if (name.Split('.')[0].ToLower() == "usertenant") + { + value = UserManager.TENANT_NAME; + } + + srow.CreateCell(_cellNum - 1).SetCellValue(value); + + } } } } @@ -3709,9 +3832,6 @@ namespace Myshipping.Application BookingOrder order = new BookingOrder(); BookingCtn ctn = new BookingCtn(); BookingEDIExt ext = new BookingEDIExt(); - List> list = new List>(); - - ////bookingorder Dictionary dic = new Dictionary(); foreach (PropertyDescriptor descriptor in TypeDescriptor.GetProperties(order)) { @@ -3725,7 +3845,7 @@ namespace Myshipping.Application dic.Add(descriptor.Name, descriptor.Description); } } - list.Add(dic); + Dictionary dic1 = new Dictionary(); @@ -3741,7 +3861,7 @@ namespace Myshipping.Application dic1.Add(descriptor.Name, descriptor.Description); } } - list.Add(dic1); + Dictionary dic2 = new Dictionary(); @@ -3757,9 +3877,22 @@ namespace Myshipping.Application dic2.Add(descriptor.Name, descriptor.Description); } } - list.Add(dic2); - return list; + Dictionary dic3 = new Dictionary(); + dic3.Add("username", "当前登录人"); + dic3.Add("usertel", "当前登录人电话"); + dic3.Add("usermobile", "当前登录人手机"); + dic3.Add("useremail", "当前登录人邮箱"); + dic3.Add("usertenant", "当前登录人所在公司"); + + var dynamic = new + { + order = dic, + ctn = dic1, + edi = dic2, + userinfo = dic3 + }; + return dynamic; } #endregion } diff --git a/Myshipping.Core/Const/ClaimConst.cs b/Myshipping.Core/Const/ClaimConst.cs index d70b347a..fd027310 100644 --- a/Myshipping.Core/Const/ClaimConst.cs +++ b/Myshipping.Core/Const/ClaimConst.cs @@ -40,4 +40,17 @@ public class ClaimConst /// 大简云userid /// public const string DjyUserId = "DjyUserId"; + /// + /// 电话 + /// + public const string Tel = "Tel"; + /// + /// 手机 + /// + public const string Phone = "Phone"; + /// + /// 邮箱 + /// + public const string Email = "Email"; + } diff --git a/Myshipping.Core/Manager/UserManager.cs b/Myshipping.Core/Manager/UserManager.cs index a69c18ad..ece8eb6c 100644 --- a/Myshipping.Core/Manager/UserManager.cs +++ b/Myshipping.Core/Manager/UserManager.cs @@ -46,4 +46,20 @@ public static class UserManager /// 大简云userid /// public static string DjyUserId => App.User.FindFirst(ClaimConst.DjyUserId)?.Value; + + /// + /// 电话 + /// + public static string TEl => App.User.FindFirst(ClaimConst.Tel)?.Value; + + /// + /// 手机 + /// + public static string Phone => App.User.FindFirst(ClaimConst.Phone)?.Value; + + + /// + /// 邮箱 + /// + public static string Email => App.User.FindFirst(ClaimConst.Email)?.Value; } diff --git a/Myshipping.Core/Service/Auth/AuthService.cs b/Myshipping.Core/Service/Auth/AuthService.cs index 7911075b..9bb7dc89 100644 --- a/Myshipping.Core/Service/Auth/AuthService.cs +++ b/Myshipping.Core/Service/Auth/AuthService.cs @@ -95,6 +95,9 @@ public class AuthService : IAuthService, IDynamicApiController, ITransient { ClaimConst.CLAINM_TENANT_TYPE, tenant.TenantType }, { ClaimConst.TENANT_NAME, tenant.Name }, { ClaimConst.DjyUserId, user.DjyUserId }, + { ClaimConst.Tel, user.Tel }, + { ClaimConst.Phone, user.Phone }, + { ClaimConst.Email, user.Email }, }); // 设置Swagger自动登录 @@ -150,6 +153,9 @@ public class AuthService : IAuthService, IDynamicApiController, ITransient { ClaimConst.CLAINM_TENANT_TYPE, tenant.TenantType }, { ClaimConst.TENANT_NAME, tenant.Name }, { ClaimConst.DjyUserId, user.DjyUserId }, + { ClaimConst.Tel, user.Tel }, + { ClaimConst.Phone, user.Phone }, + { ClaimConst.Email, user.Email }, }); // 设置Swagger自动登录