diff --git a/Myshipping.Application/Service/TaskManagePlat/TaskManageBCService.cs b/Myshipping.Application/Service/TaskManagePlat/TaskManageBCService.cs index b23f7889..38593539 100644 --- a/Myshipping.Application/Service/TaskManagePlat/TaskManageBCService.cs +++ b/Myshipping.Application/Service/TaskManagePlat/TaskManageBCService.cs @@ -1,4 +1,5 @@ -using Furion; +using DocumentFormat.OpenXml.Office2010.Excel; +using Furion; using Furion.DependencyInjection; using Furion.DistributedIDGenerator; using Furion.DynamicApiController; @@ -82,6 +83,8 @@ namespace Myshipping.Application private readonly IDjyCustomerService _djyCustomerService; private readonly INamedServiceProvider _namedBookingMSKAPIServiceProvider; private readonly IDjyTenantParamService _djyTenantParamService; + private readonly ICommonDBService _commonDBService; + private readonly INamedServiceProvider _namedBookingSlotServiceProvider; @@ -126,7 +129,7 @@ namespace Myshipping.Application SqlSugarRepository bookingSlotAllocationRepository, SqlSugarRepository bookingSlotAllocationCtnRepository, SqlSugarRepository bookingOrderContactRepository, - SqlSugarRepository bookingSlotCompareRepository) + SqlSugarRepository bookingSlotCompareRepository, ICommonDBService commonDBService) { _taskBaseRepository = taskBaseRepository; _taskBCInfoRepository = taskBCInfoRepository; @@ -153,6 +156,7 @@ namespace Myshipping.Application _namedBookingMSKAPIServiceProvider = namedBookingMSKAPIServiceProvider; _namedBookingSlotServiceProvider = namedBookingSlotServiceProvider; _djyTenantParamService = djyTenantParamService; + _commonDBService = commonDBService; _logger = logger; } @@ -4041,27 +4045,60 @@ namespace Myshipping.Application } #endregion + #region 同步更新船名基础表 /// /// 同步更新船名基础表 /// /// BC任务主键 - /// + /// 返回回执 public async Task SyncDjyVesselInfo(string taskPKId) { - var taskBase = _taskBaseRepository.AsQueryable().First(a => a.PK_ID == taskPKId); + TaskManageOrderResultDto result = new TaskManageOrderResultDto(); - if (taskBase == null) - throw Oops.Oh($"任务主键{taskPKId}无法获取业务信息"); + try + { + var taskBase = _taskBaseRepository.AsQueryable().Filter(null,true).First(a => a.PK_ID == taskPKId); - var taskBCInfo = _taskBCInfoRepository.AsQueryable().First(a => a.TASK_ID == taskBase.PK_ID); + if (taskBase == null) + throw Oops.Oh($"任务主键{taskPKId}无法获取业务信息"); - if (taskBCInfo == null) - throw Oops.Oh($"BC任务主键{taskPKId}无法获取业务信息"); + var taskBCInfo = _taskBCInfoRepository.AsQueryable().Filter(null, true).First(a => a.TASK_ID == taskBase.PK_ID); + + if (taskBCInfo == null) + throw Oops.Oh($"BC任务主键{taskPKId}无法获取业务信息"); + if(!string.IsNullOrWhiteSpace(taskBCInfo.VESSEL)) + { + var syncRlt = await _commonDBService.SyncVessel(new Core.Service.CommonDB.Dto.CodeVesselDto { Name = taskBCInfo.VESSEL }); + if (string.IsNullOrWhiteSpace(syncRlt)) + { + result.succ = true; - return null; + _logger.LogInformation($"任务BC MBLNO:{taskBCInfo.MBL_NO} 同步船名成功 新增船名{taskBCInfo.VESSEL}"); + } + else + { + result.succ = false; + result.msg = syncRlt; + } + } + else + { + result.succ = false; + result.msg = "BC的船名为空"; + } + + } + catch(Exception ex) + { + result.succ = false; + result.msg = $"同步船名到船名基础表异常,原因:{ex.Message}"; + } + + return result; } + #endregion } /// diff --git a/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs b/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs index 02fb7de1..f13e9c1e 100644 --- a/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs +++ b/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs @@ -1061,33 +1061,34 @@ namespace Myshipping.Application _logger.LogInformation($"入库完BC,自动推送状态到API订舱列表 mblno={info.Main.BCInfo.MBLNo} synRlt={JSON.Serialize(synRlt)}"); } - if (info.Main.TaskType == TaskBaseTypeEnum.BC_MODIFY) - { - var name = _namedTaskManageBCServiceProvider + var name = _namedTaskManageBCServiceProvider .GetService(nameof(TaskManageBCService)); + if (info.Main.TaskType == TaskBaseTypeEnum.BC_MODIFY) + { await name.SyncBookingSlotChange(bcInfo.TASK_ID, bcInfo.TenantId.Value); } + await name.SyncDjyVesselInfo(bcInfo.TASK_ID); #region 自动化处理 - if (taskInfo.CARRIER_ID =="CMA") - { - var flow = _taskFlowTenant.AsQueryable().Filter(null, true).Where(t => t.FlowCode == "CMABC" && t.IsMain == true &&t.TenantId== taskInfo.TenantId.Value).First(); - if (flow!=null) - { - //方法请求参数 - RecursiveMethodModel mt = new RecursiveMethodModel(); - //TODO待完善请求参数 - mt.parse_attachment = info.Main.parse_attachment; + //if (taskInfo.CARRIER_ID =="CMA") + //{ + // var flow = _taskFlowTenant.AsQueryable().Filter(null, true).Where(t => t.FlowCode == "CMABC" && t.IsMain == true &&t.TenantId== taskInfo.TenantId.Value).First(); + // if (flow!=null) + // { + // //方法请求参数 + // RecursiveMethodModel mt = new RecursiveMethodModel(); + // //TODO待完善请求参数 + // mt.parse_attachment = info.Main.parse_attachment; - RecursiveMethod(flow, 0, mt); - } + // RecursiveMethod(flow, 0, mt); + // } - } + //} diff --git a/Myshipping.Core/Myshipping.Core.xml b/Myshipping.Core/Myshipping.Core.xml index d3d21a98..e81aeb31 100644 --- a/Myshipping.Core/Myshipping.Core.xml +++ b/Myshipping.Core/Myshipping.Core.xml @@ -9229,6 +9229,11 @@ 新增船名信息 + + + 同步船名信息 + + 获取船名映射 @@ -9540,13 +9545,6 @@ 公开数据:获取箱型映射代码 - - - 同步船名 - - 请求参数 - 返回主键 - 代码 @@ -10873,7 +10871,7 @@ 查询条件 - + 同步船名 diff --git a/Myshipping.Core/Service/CommonDB/CommonDBService.cs b/Myshipping.Core/Service/CommonDB/CommonDBService.cs index b5290cef..89cd1a66 100644 --- a/Myshipping.Core/Service/CommonDB/CommonDBService.cs +++ b/Myshipping.Core/Service/CommonDB/CommonDBService.cs @@ -13,6 +13,7 @@ using Myshipping.Core.Service.CommonDB.Dto; using Microsoft.Extensions.Logging; using Myshipping.Core.Entity.CommonDB; using Microsoft.AspNetCore.Authorization; +using System.Reflection.Metadata.Ecma335; namespace Myshipping.Core.Service; /// @@ -276,6 +277,29 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie await GetAllVessel(); } + /// + /// 同步船名信息 + /// + [HttpPost("/commondb/syncvessel")] + public async Task SyncVessel([FromBody] CodeVesselDto dto) + { + var list = await _sysCacheService.GetAllCodeVessel(); + var count = list.Where(x => x.Name.Trim() == dto.Name.Trim()).Count(); + if (count > 0) + { + return "已存在记录"; + } + var entity = dto.Adapt(); + entity.GID = Guid.NewGuid().ToString(); + entity.CreateTime = DateTime.Now; + entity.CreateUser = UserManager.DjyUserId; + await _codeVesselRep.InsertAsync(entity); + + await GetAllVessel(); + + return string.Empty; + } + /// /// 获取船名映射 /// @@ -2401,13 +2425,4 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie } #endregion - /// - /// 同步船名 - /// - /// 请求参数 - /// 返回主键 - public async Task SyncVesselInfo(CodeVesselDto model) - { - return null; - } } diff --git a/Myshipping.Core/Service/CommonDB/ICommonDBService.cs b/Myshipping.Core/Service/CommonDB/ICommonDBService.cs index 2b587ef5..577bf2cf 100644 --- a/Myshipping.Core/Service/CommonDB/ICommonDBService.cs +++ b/Myshipping.Core/Service/CommonDB/ICommonDBService.cs @@ -199,5 +199,5 @@ public interface ICommonDBService /// /// 请求参数 /// 返回主键 - Task SyncVesselInfo(CodeVesselDto model); + Task SyncVessel([FromBody] CodeVesselDto dto); }