diff --git a/Myshipping.Application/Service/BookingTruck/BookingTruckService.cs b/Myshipping.Application/Service/BookingTruck/BookingTruckService.cs index be19c04d..7f0c4d12 100644 --- a/Myshipping.Application/Service/BookingTruck/BookingTruckService.cs +++ b/Myshipping.Application/Service/BookingTruck/BookingTruckService.cs @@ -31,6 +31,7 @@ using System.ComponentModel; using System.IO; using System.Linq; using System.Net.Http; +using System.Security.Cryptography; using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; @@ -56,6 +57,8 @@ namespace Myshipping.Application private readonly SqlSugarRepository _bookingExcelTemplateRepository; private readonly SqlSugarRepository _sysUserRepository; private readonly ITaskManageExternalService _taskManageExternalService; + private readonly ISysUserService _sysUserService; + private readonly IDjyCustomerService _djyCustomerService; const string PRINT_LIST_TYPE_KEY = "booking_truck_print_list"; const string PRINT_DATASOURCE_KEY = "booking_order"; @@ -69,6 +72,7 @@ namespace Myshipping.Application SqlSugarRepository djyUserConfigConfig, SqlSugarRepository bookingExcelTemplateRepository, SqlSugarRepository sysUserRepository, + ISysUserService sysUserService, IDjyCustomerService djyCustomerService, ITaskManageExternalService taskManageExternalService) { _cache = cache; @@ -84,6 +88,8 @@ namespace Myshipping.Application _djyUserConfigConfig = djyUserConfigConfig; _bookingExcelTemplateRepository = bookingExcelTemplateRepository; _sysUserRepository = sysUserRepository; + _sysUserService = sysUserService; + _djyCustomerService = djyCustomerService; } /// @@ -259,7 +265,7 @@ namespace Myshipping.Application try { - var model = InnerCreateTruckFromBookingOrder(bookingId); + var model = await InnerCreateTruckFromBookingOrder(bookingId); result.succ = true; result.ext = model; @@ -445,7 +451,7 @@ namespace Myshipping.Application } - private BookingTruckShowDto InnerCreateTruckFromBookingOrder(long bookingId) + private async Task InnerCreateTruckFromBookingOrder(long bookingId) { BookingTruckShowDto model = null; @@ -466,11 +472,54 @@ namespace Myshipping.Application model.MBLNo = orderInfo.MBLNO; model.Vessel = orderInfo.VESSEL; model.VoyNo = orderInfo.VOYNO; + model.YARDCONTRACT = orderInfo.YARDCONTRACT; + model.YARDCONTRACTTEL = orderInfo.YARDCONTRACTTEL; + model.TruckTime = DateTime.Now; model.FromName = UserManager.Name; model.FromTel = UserManager.TEl; model.FromMail = UserManager.Email; + //这里岗位是调度的信息,如果默认只有一条记录,取第一条,其他情况不返回默认值 + var userPosInfo = await _sysUserService.QueryUserByPos("", "PCDD"); + + if(userPosInfo.Count == 1) + { + model.DispatcherId = userPosInfo.FirstOrDefault().SysEmpId; + model.DispatcherName = userPosInfo.FirstOrDefault().SysEmpName; + } + + var yardList = await _djyCustomerService.QuerytDjyCustomerInfo("", new string[] { "yard" }, 999); + + if(yardList.Count > 0) + { + if((string.IsNullOrWhiteSpace(model.YARDCONTRACT) || string.IsNullOrWhiteSpace(model.YARDCONTRACTTEL)) + && !string.IsNullOrWhiteSpace(model.YARD)) + { + var yardInfo = yardList.Select(a => + { + return new { KNum = a.ShortName.IndexOf(model.YARD), + Equls = a.ShortName.Equals(model.YARD, StringComparison.OrdinalIgnoreCase) ? 1 : 0, + Obj = a }; + }).Where(a=>a.KNum >= 0) + .OrderByDescending(a => a.Equls) + .ThenBy(a=>a.KNum) + .FirstOrDefault().Obj; + + if(yardInfo != null) + { + if (string.IsNullOrWhiteSpace(model.YARDCONTRACT)) + model.YARDCONTRACT = yardInfo.Chief?.Trim(); + + if (string.IsNullOrWhiteSpace(model.YARDCONTRACTTEL)) + model.YARDCONTRACTTEL = yardInfo.Tel?.Trim(); + } + } + } + + model.InYardContact = orderInfo.YARDCONTRACT; + model.InYardContractTel = orderInfo.YARDCONTRACTTEL; + if (orderInfo.KGS.HasValue) { //计算总吨数 @@ -542,7 +591,7 @@ namespace Myshipping.Application try { - var model = InnerCreateTruckFromBookingOrder(bookingId); + var model = await InnerCreateTruckFromBookingOrder(bookingId); result.succ = true; result.ext = model; @@ -568,7 +617,7 @@ namespace Myshipping.Application try { - var model = InnerCreateTruckFromBookingOrder(bookingId); + var model = await InnerCreateTruckFromBookingOrder(bookingId); result.succ = true; diff --git a/Myshipping.Core/Myshipping.Core.xml b/Myshipping.Core/Myshipping.Core.xml index 668f7421..59a82fb9 100644 --- a/Myshipping.Core/Myshipping.Core.xml +++ b/Myshipping.Core/Myshipping.Core.xml @@ -15294,6 +15294,14 @@ 所属租户 + + + 通过职位获取用户信息 + + + 职位代码 PCDD-调度 + 返回用户详情 + 用户数据范围 diff --git a/Myshipping.Core/Service/User/ISysUserService.cs b/Myshipping.Core/Service/User/ISysUserService.cs index c7f7d9f4..4584aea4 100644 --- a/Myshipping.Core/Service/User/ISysUserService.cs +++ b/Myshipping.Core/Service/User/ISysUserService.cs @@ -32,4 +32,11 @@ public interface ISysUserService void CheckDataScopeByUserId(long userId); void CheckDataScope(long orgId); Task> GetTenantUser(string name,long? tenantId); + /// + /// 通过职位获取用户信息 + /// + /// + /// 职位代码 PCDD-调度 + /// 返回用户详情 + Task> QueryUserByPos(string name, string pos); }