From 216c337fcbfe7e44495d29b732ea4d42f8aafaf4 Mon Sep 17 00:00:00 2001 From: zhangxiaofeng Date: Wed, 6 Mar 2024 17:28:01 +0800 Subject: [PATCH 1/4] =?UTF-8?q?1.=E8=B0=83=E6=95=B4=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E6=96=87=E4=BB=B6RunType=E5=B1=9E=E6=80=A7=EF=BC=9B2.=E5=92=8C?= =?UTF-8?q?=E5=B7=9D=E6=96=B0=E5=BB=BA=E7=94=A8=E6=88=B7=E6=97=B6=EF=BC=8C?= =?UTF-8?q?=E8=BF=9B=E8=A1=8C=E4=B8=80=E4=BA=9B=E5=88=9D=E5=A7=8B=E5=8C=96?= =?UTF-8?q?=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Service/Fee/FeeRecordService.cs | 2 +- Myshipping.Core/Const/CommonConst.cs | 22 ++++++++---- Myshipping.Core/Myshipping.Core.xml | 27 +++++++++++--- .../Service/Role/ISysRoleService.cs | 1 + .../Service/Role/SysRoleService.cs | 16 +++++++-- .../Service/User/Dto/SysDataUserMenuDto.cs | 16 ++++++--- .../Service/User/SysUserService.cs | 35 ++++++++++++++++++- Myshipping.Web.Entry/appsettings.json | 9 ++++- 8 files changed, 107 insertions(+), 21 deletions(-) diff --git a/Myshipping.Application/Service/Fee/FeeRecordService.cs b/Myshipping.Application/Service/Fee/FeeRecordService.cs index ead73d53..40cb988f 100644 --- a/Myshipping.Application/Service/Fee/FeeRecordService.cs +++ b/Myshipping.Application/Service/Fee/FeeRecordService.cs @@ -65,7 +65,7 @@ namespace Myshipping.Application // 如果费用中含有机密费用,再判断是否有查询的权限 if (feeRecords.Any(r => !r.IsOpen)) { - bool canReviewSecretFee = await _sysUserRoleService.IsUserInRole(UserManager.UserId, CommonConst.SECRET_FEE_REVIEW); + bool canReviewSecretFee = await _sysUserRoleService.IsUserInRole(UserManager.UserId, CommonConst.ROLE_SECRET_FEE_REVIEW); if (!canReviewSecretFee) { feeRecords.RemoveAll(r => !r.IsOpen && r.CreatedUserId != UserManager.UserId); diff --git a/Myshipping.Core/Const/CommonConst.cs b/Myshipping.Core/Const/CommonConst.cs index b0bff400..3aa0d089 100644 --- a/Myshipping.Core/Const/CommonConst.cs +++ b/Myshipping.Core/Const/CommonConst.cs @@ -227,9 +227,14 @@ public class CommonConst #region 角色Code /// - /// 机密费用检阅角色 + /// 机密费用检阅角色Code /// - public const string SECRET_FEE_REVIEW = "SecretFeeReview"; + public const string ROLE_SECRET_FEE_REVIEW = "SecretFeeReview"; + + /// + /// 普通员工角色Code + /// + public const string ROLE_COMMON_EMPLOYEE = "CommonEmployee"; #endregion #region 费用 @@ -245,17 +250,22 @@ public class CommonConst #region 系统运行方式 /// - /// 标准模式 + /// 和川(会执行一些和川特有的逻辑) + /// + public const string RUN_TYPE_HECHUAN = "HeChuan"; + + /// + /// 标准模式(自用) /// - public const string RUN_TYPE_NORMAL = "NORMAL"; + public const string RUN_TYPE_NORMAL = "Normal"; /// - /// 客户订舱-客户端 + /// 客户订舱系统-客户端 /// public const string RUN_TYPE_CUST = "CUST"; /// - /// 客户订舱-大简云运营端 + /// 客户订舱系统-大简云运营端 /// public const string RUN_TYPE_DJY = "DJY"; #endregion diff --git a/Myshipping.Core/Myshipping.Core.xml b/Myshipping.Core/Myshipping.Core.xml index d602d403..7a4c81b6 100644 --- a/Myshipping.Core/Myshipping.Core.xml +++ b/Myshipping.Core/Myshipping.Core.xml @@ -792,9 +792,14 @@ 删除字段 - + - 机密费用检阅角色 + 机密费用检阅角色Code + + + + + 普通员工角色Code @@ -807,19 +812,24 @@ 币别缓存键 + + + 和川(会执行一些和川特有的逻辑) + + - 标准模式 + 标准模式(自用) - 客户订舱-客户端 + 客户订舱系统-客户端 - 客户订舱-大简云运营端 + 客户订舱系统-大简云运营端 @@ -15772,6 +15782,13 @@ + + + 根据角色Code查询角色主键 + + 角色Code + 角色主键 + 租户参数 diff --git a/Myshipping.Core/Service/Role/ISysRoleService.cs b/Myshipping.Core/Service/Role/ISysRoleService.cs index e02acf00..8bb14ea7 100644 --- a/Myshipping.Core/Service/Role/ISysRoleService.cs +++ b/Myshipping.Core/Service/Role/ISysRoleService.cs @@ -11,6 +11,7 @@ public interface ISysRoleService Task DeleteRole(DeleteRoleInput input); Task GetNameByRoleId(long roleId); Task GetRoleDropDown(); + Task GetRoleIdByRoleCode(string roleCode); Task GetRoleInfo([FromQuery] QueryRoleInput input); Task GetRoleList([FromQuery] RoleInput input); Task> GetUserDataScopeIdList(List roleIdList, long orgId); diff --git a/Myshipping.Core/Service/Role/SysRoleService.cs b/Myshipping.Core/Service/Role/SysRoleService.cs index c5e845cd..8d30da86 100644 --- a/Myshipping.Core/Service/Role/SysRoleService.cs +++ b/Myshipping.Core/Service/Role/SysRoleService.cs @@ -148,7 +148,7 @@ public class SysRoleService : ISysRoleService, IDynamicApiController, ITransient var sysRole = await _sysRoleRep.FirstOrDefaultAsync(u => u.Id == input.Id); if (sysRole.IsNullOrZero()) throw Oops.Oh(ErrorCode.D1006); - if (sysRole.RoleType==RoleType.AdminRole) + if (sysRole.RoleType == RoleType.AdminRole) throw Oops.Oh("请勿删除管理员角色"); try { @@ -168,7 +168,7 @@ public class SysRoleService : ISysRoleService, IDynamicApiController, ITransient throw; } - + } /// @@ -188,7 +188,7 @@ public class SysRoleService : ISysRoleService, IDynamicApiController, ITransient throw Oops.Oh(ErrorCode.D1006); var sysRole = input.Adapt(); await _sysRoleRep.AsUpdateable(sysRole).IgnoreColumns(ignoreAllNullColumns: true).IgnoreColumns(u => new { u.DataScopeType }).ExecuteCommandAsync(); - + } /// @@ -333,4 +333,14 @@ public class SysRoleService : ISysRoleService, IDynamicApiController, ITransient { return await _sysRoleDataScopeService.GetRoleDataScopeIdList(new List { input.Id }); } + + /// + /// 根据角色Code查询角色主键 + /// + /// 角色Code + /// 角色主键 + public async Task GetRoleIdByRoleCode(string roleCode) + { + return await _sysRoleRep.AsQueryable(x => x.Code == roleCode).Select(x => x.Id).FirstAsync(); + } } diff --git a/Myshipping.Core/Service/User/Dto/SysDataUserMenuDto.cs b/Myshipping.Core/Service/User/Dto/SysDataUserMenuDto.cs index db53a01b..16964432 100644 --- a/Myshipping.Core/Service/User/Dto/SysDataUserMenuDto.cs +++ b/Myshipping.Core/Service/User/Dto/SysDataUserMenuDto.cs @@ -9,22 +9,30 @@ namespace Myshipping.Core.Service.User.Dto public class SysDataUserMenuDto { public long UserId { get; set; } - public List childrens { get; set; } + public List childrens { get; set; } } public class children { + public children() { } + public children(long menuId, DataScopeType dataScopeType, bool isEdit) + { + MenuId = menuId; + DataScopeType = dataScopeType; + IsEdit = isEdit; + } public long MenuId { get; set; } public DataScopeType DataScopeType { get; set; } - + public bool IsEdit { get; set; } } - public class RightList { + public class RightList + { public long UserId { get; set; } @@ -39,7 +47,7 @@ namespace Myshipping.Core.Service.User.Dto public long OrgId { get; set; } - + public bool IsEdit { get; set; } } diff --git a/Myshipping.Core/Service/User/SysUserService.cs b/Myshipping.Core/Service/User/SysUserService.cs index 2836a1b1..74c850ce 100644 --- a/Myshipping.Core/Service/User/SysUserService.cs +++ b/Myshipping.Core/Service/User/SysUserService.cs @@ -22,6 +22,7 @@ using System.Web; using System.Text; using Furion.EventBus; using Microsoft.AspNetCore.Authorization; +using Myshipping.Core.Const; namespace Myshipping.Core.Service; @@ -39,6 +40,8 @@ public class SysUserService : ISysUserService, IDynamicApiController, ITransient private readonly ISysUserRoleService _sysUserRoleService; private readonly ISysEmpPosService _sysEmpPosService; private readonly IEventPublisher _publisher; + private readonly ISysDataUserMenu _sysDataUserMenu; + private readonly ISysRoleService _sysRoleService; public SysUserService(SqlSugarRepository sysUserRep, ISysCacheService sysCacheService, @@ -47,7 +50,9 @@ public class SysUserService : ISysUserService, IDynamicApiController, ITransient ISysUserRoleService sysUserRoleService, ISysConfigService sysConfigService, ISysEmpPosService sysEmpPosService, - IEventPublisher publisher) + IEventPublisher publisher, + ISysDataUserMenu sysDataUserMenu, + ISysRoleService sysRoleService) { _sysUserRep = sysUserRep; _sysCacheService = sysCacheService; @@ -57,6 +62,8 @@ public class SysUserService : ISysUserService, IDynamicApiController, ITransient _sysConfigService = sysConfigService; _sysEmpPosService = sysEmpPosService; _publisher = publisher; + _sysDataUserMenu = sysDataUserMenu; + _sysRoleService = sysRoleService; } /// @@ -122,6 +129,32 @@ public class SysUserService : ISysUserService, IDynamicApiController, ITransient input.SysEmpParam.Id = newUser.Id.ToString(); // 增加员工信息 await _sysEmpService.AddOrUpdate(input.SysEmpParam); + + // 如果当前运行模式为和川,则进行一些初始化操作 + if (App.Configuration["RunType"] == CommonConst.RUN_TYPE_HECHUAN) + { + // 绑定角色:普通员工 + long? roleId = await _sysRoleService.GetRoleIdByRoleCode(CommonConst.ROLE_COMMON_EMPLOYEE); + if (roleId != null) + { + await _sysUserRoleService.GrantRole(new UpdateUserInput() + { + Id = newUser.Id, + GrantRoleIdList = new List() { (long)roleId } + }); + } + + // 授权"订舱台账"菜单的数据范围 + var userMenuDto = new User.Dto.SysDataUserMenuDto() + { + UserId = newUser.Id, + childrens = new List() { + new(MenuConst.MenuBookingOrder, DataScopeType.DEPT_WITH_CHILD, true) + } + }; + await _sysDataUserMenu.GrantData(userMenuDto); + } + _sysUserRep.CurrentCommitTran(); await _sysCacheService.DelByPatternAsync(CommonConst.CACHE_KEY_USERSDATASCOPE); } diff --git a/Myshipping.Web.Entry/appsettings.json b/Myshipping.Web.Entry/appsettings.json index 1c3e5ce1..8ceafb13 100644 --- a/Myshipping.Web.Entry/appsettings.json +++ b/Myshipping.Web.Entry/appsettings.json @@ -38,5 +38,12 @@ }, "AllowedHosts": "*", "Urls": "http://localhost:5120", - "RunType": "NORMAL" //运行方式:CUST客户端、DJY大简云运营端、NORMAL普通订舱模式 + + /* **********RunType运行方式说明********** + HeChuan 和川(会执行一些和川特有的逻辑) + Normal 标准模式(自用) + CUST 客户订舱系统-客户端 + DJY 客户订舱系统-大简云运营端 + */ + "RunType": "HeChuan" } \ No newline at end of file From 986bf3b61986403fee41972e31a21ae45262991b Mon Sep 17 00:00:00 2001 From: wanghaomei <86whm@163.com> Date: Thu, 7 Mar 2024 10:09:19 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E6=89=A3=E8=B4=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Event/BookingFeeSubscriber.cs | 32 ++++++++++++++----- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/Myshipping.Application/Event/BookingFeeSubscriber.cs b/Myshipping.Application/Event/BookingFeeSubscriber.cs index 0f732623..c5d70b10 100644 --- a/Myshipping.Application/Event/BookingFeeSubscriber.cs +++ b/Myshipping.Application/Event/BookingFeeSubscriber.cs @@ -66,6 +66,7 @@ namespace Myshipping.Application.Event var repoUser = scope.ServiceProvider.GetRequiredService>(); var repoBooking = scope.ServiceProvider.GetRequiredService>(); var repoFeeRecord = scope.ServiceProvider.GetRequiredService>(); + var repoTenantParamValue = scope.ServiceProvider.GetRequiredService>(); var cache = scope.ServiceProvider.GetRequiredService(); var typeStr = $"{bsType}_{sendType}"; @@ -73,13 +74,13 @@ namespace Myshipping.Application.Event var idToDo = idList.Except(dbFeeRecord).ToList(); var sysCfg = await cache.GetAllSysConfig(); var feeUrl = sysCfg.FirstOrDefault(x => x.Code == "djyFeeApiUrl"); - var feeUserId = sysCfg.FirstOrDefault(x => x.Code == "djyFeeApiUserId"); - var feeKey = sysCfg.FirstOrDefault(x => x.Code == "djyFeeApiKey"); - if (feeKey == null || string.IsNullOrEmpty(feeUrl.Value) - || feeUserId == null || string.IsNullOrEmpty(feeUserId.Value) - || feeKey == null || string.IsNullOrEmpty(feeKey.Value)) + //var feeUserId = sysCfg.FirstOrDefault(x => x.Code == "djyFeeApiUserId"); + //var feeKey = sysCfg.FirstOrDefault(x => x.Code == "djyFeeApiKey"); + if (feeUrl == null || string.IsNullOrEmpty(feeUrl.Value)) + //|| feeUserId == null || string.IsNullOrEmpty(feeUserId.Value) + //|| feeKey == null || string.IsNullOrEmpty(feeKey.Value)) { - var errMsg = "大简云扣费URL和KEY未配置"; + var errMsg = "大简云扣费URL未配置"; _logger.LogError(errMsg); DingTalkGroupHelper.SendDingTalkGroupMessage("bookingFeeNotify", "扣费失败提醒", errMsg); return; @@ -90,6 +91,21 @@ namespace Myshipping.Application.Event var order = await repoBooking.AsQueryable().Filter(null, true).FirstAsync(x => x.Id == id); var iptId = string.IsNullOrEmpty(order.OPID) ? order.CreatedUserId.Value : Convert.ToInt64(order.OPID); var user = await repoUser.AsQueryable().Filter(null, true).FirstAsync(x => x.Id == iptId); + var keyList = await repoTenantParamValue.AsQueryable() + .Filter(null, true) + .Where(x => x.TenantId == order.TenantId && (x.ParaCode == "BOOKING_FEE_USERID" || x.ParaCode == "BOOKING_FEE_USERKEY")) + .ToListAsync(); + if (keyList.Count < 2) + { + var errMsg = $"未找到{order.MBLNO}({id})所在租户的授权userid和key,无法调用扣费"; + _logger.LogError(errMsg); + DingTalkGroupHelper.SendDingTalkGroupMessage("bookingFeeNotify", "扣费失败提醒", errMsg); + continue; + } + var feeUserId = keyList.First(x => x.ParaCode == "BOOKING_FEE_USERID").ItemCode; + var feeUserKey = keyList.First(x => x.ParaCode == "BOOKING_FEE_USERKEY").ItemCode; + + if (user == null || string.IsNullOrEmpty(user.DjyUserId)) { var errMsg = $"未找到{order.MBLNO}({id})的用户信息,无法调用扣费"; @@ -100,11 +116,11 @@ namespace Myshipping.Application.Event var seconds = DateTime.Now.ToTimeStamp(); var runId = Guid.NewGuid().ToString(); - var srcBeforMD5 = $"{runId}{feeUserId.Value}expend{bsType}{sendType}{id}{order.MBLNO}{seconds}{feeKey.Value}"; + var srcBeforMD5 = $"{runId}{feeUserId}expend{bsType}{sendType}{id}{order.MBLNO}{seconds}{feeUserKey}"; var postObj = new { runId, - userId = feeUserId.Value, + userId = feeUserId, module = "expend",//固定 bsType = $"{bsType}", sendType = $"{sendType}", From ec507dda14710ef60413e4d4f3dfbcf3451d20d8 Mon Sep 17 00:00:00 2001 From: wanghaomei <86whm@163.com> Date: Thu, 7 Mar 2024 10:49:21 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E8=A1=A5=E6=89=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BookingOrder/BookingOrderService.cs | 37 ++++++++++++++----- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs index cc3e3797..59431519 100644 --- a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs +++ b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs @@ -10286,6 +10286,16 @@ namespace Myshipping.Application } } + /// + /// 临时补扣费用 + /// + /// + [HttpGet("/BookingOrder/FeeById"), AllowAnonymous] + public async Task FeeById(List idList, int bsType = 28, int sendtype = 0) + { + await _publisher.PublishAsync(new ChannelEventSource($"Booking:DoFeeRecord", new { bsType = bsType, sendtype = sendtype, idList = idList })); + } + #endregion #region 打印船公司ONE的订舱附件 @@ -12154,22 +12164,28 @@ namespace Myshipping.Application UNLocationCode = model.placeOfDeliveryUnLocCode, cityName = model.placeOfDeliveryCityName, }, - selectedRoute = new MSKAPIBookingRoute { - bookingSchedules = new MSKAPIBookingSchedules { + selectedRoute = new MSKAPIBookingRoute + { + bookingSchedules = new MSKAPIBookingSchedules + { originDepartureDateTimeLocal = model.originDepartureDateTimeLocal.Value.ToString("yyyy-MM-dd"), destinationArrivalDateTimeLocal = model.destinationArrivalDateTimeLocal.Value.ToString("yyyy-MM-dd"), - transportMode = new MSKAPIBookingTransportMode { - vessel = new MSKAPIBookingTransportModeVessel { + transportMode = new MSKAPIBookingTransportMode + { + vessel = new MSKAPIBookingTransportModeVessel + { name = model.vesselName, maerskVesselCode = model.carrierVesselCode, }, exportVoyageNumber = model.exportVoyageNumber, }, - startLocation = new MSKAPIBookingRouteDetailsBase { + startLocation = new MSKAPIBookingRouteDetailsBase + { cityName = model.placeOfReceiptCityName, UNLocationCode = model.placeOfReceiptUnLocCode }, - endLocation= new MSKAPIBookingRouteDetailsBase { + endLocation = new MSKAPIBookingRouteDetailsBase + { cityName = model.placeOfDeliveryCityName, UNLocationCode = model.placeOfDeliveryUnLocCode }, @@ -12209,7 +12225,8 @@ namespace Myshipping.Application { model.ctns.ForEach(ctn => { - MSKAPIBookingEquipmentAndHaulage haulage = new MSKAPIBookingEquipmentAndHaulage { + MSKAPIBookingEquipmentAndHaulage haulage = new MSKAPIBookingEquipmentAndHaulage + { equipmentDetails = new MSKAPIBookingEquipmentAndHaulageItem(), stuffingDetails = new List() }; @@ -12217,7 +12234,8 @@ namespace Myshipping.Application haulage.equipmentDetails.ISOEquipmentCode = ctn.ctnCode; haulage.equipmentDetails.equipmentQuantity = ctn.ctnNum; - haulage.stuffingDetails.Add(new MSKAPIBookingStuffingdetails { + haulage.stuffingDetails.Add(new MSKAPIBookingStuffingdetails + { stuffingValue = (int)ctn.ctnSufferWeight.Value, stuffingMeasurementType = "WEIGHT", stuffingMeasurementUnit = "KGS" @@ -12234,7 +12252,7 @@ namespace Myshipping.Application _bookingDeliveryRecordRep.Insert(recordInfo); - if(recordCtnList.Count > 0) + if (recordCtnList.Count > 0) { recordCtnList.ForEach(async x => { @@ -12493,5 +12511,6 @@ namespace Myshipping.Application return list; } #endregion + } } From 7a624cc4cb80f56d8b3c40b36c15de4074628e80 Mon Sep 17 00:00:00 2001 From: wanghaomei <86whm@163.com> Date: Thu, 7 Mar 2024 10:53:02 +0800 Subject: [PATCH 4/4] config --- Myshipping.Web.Core/applicationconfig.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Myshipping.Web.Core/applicationconfig.json b/Myshipping.Web.Core/applicationconfig.json index 9fa46e60..09a42970 100644 --- a/Myshipping.Web.Core/applicationconfig.json +++ b/Myshipping.Web.Core/applicationconfig.json @@ -56,7 +56,7 @@ }, "Cache": { "CacheType": "RedisCache", // RedisCache - "RedisConnectionString": "192.168.0.247:6379,password=,defaultDatabase=11" + "RedisConnectionString": "127.0.0.1:6379,password=,defaultDatabase=11" }, "SnowId": { "WorkerId": "1" // 取值范围0~63,默认1