From 2019a6c444d42d17f09ad0d11b915a3c276de8d7 Mon Sep 17 00:00:00 2001 From: cjy Date: Tue, 5 Nov 2024 17:42:44 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=B7=E8=BF=90=E5=87=BA=E5=8F=A3=E5=86=8D?= =?UTF-8?q?=E6=AC=A1=E6=8F=90=E4=BA=A4=E5=AE=A1=E6=A0=B8=EF=BC=8C=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E8=B4=A7=E7=89=A9=E7=8A=B6=E6=80=81=E5=8F=8A=E4=B8=BB?= =?UTF-8?q?=E5=8D=95=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Constants/MultiLanguageConst.cs | 4 +- .../DS.WMS.Core/Op/Method/SeaExportService.cs | 52 ++++++++- .../Method/SeaExportTaskService.cs | 101 +++++++++++++++++- 3 files changed, 151 insertions(+), 6 deletions(-) diff --git a/ds-wms-service/DS.Module.Core/Constants/MultiLanguageConst.cs b/ds-wms-service/DS.Module.Core/Constants/MultiLanguageConst.cs index 58c5b0c8..1b281a40 100644 --- a/ds-wms-service/DS.Module.Core/Constants/MultiLanguageConst.cs +++ b/ds-wms-service/DS.Module.Core/Constants/MultiLanguageConst.cs @@ -506,7 +506,9 @@ public static class MultiLanguageConst [Description("订舱货物状态已存在")] public const string BookingGoodsStatusConfigExist = "Booking_Goods_Status_Config_Exist"; - + + [Description("海运出口服务项目不能为空")] + public const string SeaExportServiceItemNotExist = "Sea_Export_ServiceItem_Not_Exist"; [Description("舱单分票件数合计超出限制")] public const string SeaExportPartCtnPKGSLimit = "Sea_Export_PartCtn_PKGS_Limit"; diff --git a/ds-wms-service/DS.WMS.Core/Op/Method/SeaExportService.cs b/ds-wms-service/DS.WMS.Core/Op/Method/SeaExportService.cs index e9fecb08..f7518fb8 100644 --- a/ds-wms-service/DS.WMS.Core/Op/Method/SeaExportService.cs +++ b/ds-wms-service/DS.WMS.Core/Op/Method/SeaExportService.cs @@ -20,9 +20,15 @@ using DS.WMS.Core.Op.Entity; using DS.WMS.Core.Op.Interface; using DS.WMS.Core.Sys.Entity; using DS.WMS.Core.Sys.Interface; +using DS.WMS.Core.TaskInteraction.Dtos; +using DS.WMS.Core.TaskInteraction.Entity; +using DS.WMS.Core.TaskInteraction.Interface; +using DS.WMS.Core.TaskInteraction.Method; +using DS.WMS.Core.TaskPlat.Entity; using DS.WMS.Core.TaskPlat.Interface; using LanguageExt; using Mapster; +using Masuit.Tools.Systems; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.DependencyInjection; using Newtonsoft.Json; @@ -52,6 +58,8 @@ public partial class SeaExportService : ISeaExportService private readonly IRedisService _redisBaseService; private readonly IDJYChargeFeeService _dJYChargeFeeService; + private readonly ISeaExportTaskService _seaTaskService; + //private readonly IBookingSlotService _bookingSlotService; private readonly Lazy _taskManageBaseService; @@ -92,7 +100,7 @@ public partial class SeaExportService : ISeaExportService _redisBaseService = _serviceProvider.GetRequiredService(); _dJYChargeFeeService = _serviceProvider.GetRequiredService(); //_bookingSlotService = _serviceProvider.GetRequiredService(); - + _seaTaskService = _serviceProvider.GetRequiredService(); _taskManageBaseService = _serviceProvider.GetRequiredService>(); } @@ -1597,4 +1605,46 @@ public partial class SeaExportService : ISeaExportService return DataResult.Success(model); } #endregion + + + + ///// + ///// + ///// + ///// + ///// + //public async Task CreateOrderAuditTaskAsync(IdModel req) + //{ + + // var tenantDb = saasService.GetBizDbScopeById(user.TenantId); + // var id = long.Parse(req.Id); + // var info = await tenantDb.Queryable().Where(x => x.Id == id).FirstAsync(); + // if (info.IsNull()) + // return await Task.FromResult(DataResult.Failed("不存在的海运出口信息!", MultiLanguageConst.SeaExportExist)); + + // if (string.IsNullOrEmpty(info.ServiceItem)) + // return await Task.FromResult(DataResult.Failed("海运出口服务项目不能为空!", MultiLanguageConst.SeaExportServiceItemNotExist)); + + + // var items = info.ServiceItem.Split(','); + + // if (items.Contains("dingcang")) + // { + // var taskReq = new TaskCreationRequest() + // { + // BusinessId = id, + // BusinessType = BusinessType.OceanShippingExport, + // TaskTypeName = TaskBaseTypeEnum.WAIT_ORDER_AUDIT.ToString(), + // }; + // var result = await _seaTaskService.CreateTaskAsync(taskReq, false); + // if (!result.Succeeded) + // return await Task.FromResult(DataResult.Failed(result.Message)); + + // return + // } + // else + // { + // return await Task.FromResult(DataResult.Failed("不存在的海运出口信息!")); + // } + //} } \ No newline at end of file diff --git a/ds-wms-service/DS.WMS.Core/TaskInteraction/Method/SeaExportTaskService.cs b/ds-wms-service/DS.WMS.Core/TaskInteraction/Method/SeaExportTaskService.cs index d2179a96..063e0104 100644 --- a/ds-wms-service/DS.WMS.Core/TaskInteraction/Method/SeaExportTaskService.cs +++ b/ds-wms-service/DS.WMS.Core/TaskInteraction/Method/SeaExportTaskService.cs @@ -3,15 +3,23 @@ using DS.Module.Core; using DS.Module.Core.Data; using DS.Module.Core.Extensions; using DS.Module.DjyServiceStatus; +using DS.WMS.Core.Invoice.Dtos; +using DS.WMS.Core.Op.Dtos; using DS.WMS.Core.Op.Entity; +using DS.WMS.Core.Op.Interface; +using DS.WMS.Core.Op.Method; using DS.WMS.Core.Sys.Entity; using DS.WMS.Core.TaskInteraction.Dtos; using DS.WMS.Core.TaskInteraction.Entity; using DS.WMS.Core.TaskInteraction.Interface; using DS.WMS.Core.TaskPlat.Dtos; +using DS.WMS.Core.TaskPlat.Entity; +using LanguageExt; +using Mapster; using Masuit.Tools.Systems; using Microsoft.Extensions.DependencyInjection; using Newtonsoft.Json.Linq; +using NPOI.SS.Formula.Functions; using SqlSugar; namespace DS.WMS.Core.TaskInteraction.Method @@ -23,7 +31,7 @@ namespace DS.WMS.Core.TaskInteraction.Method { const TaskBaseTypeEnum BL_CONFIRM_TASK = TaskBaseTypeEnum.WAIT_BILL_CONFIRM; readonly Lazy djyService; - + readonly Lazy seaComService; /// /// 初始化 /// @@ -31,24 +39,109 @@ namespace DS.WMS.Core.TaskInteraction.Method public SeaExportTaskService(IServiceProvider provider) : base(provider) { djyService = new Lazy(provider.GetRequiredService()); + seaComService = new Lazy(provider.GetRequiredService()); } - public override Task CreateTaskAsync(TaskCreationRequest request, bool useTransaction = true) + public override async Task CreateTaskAsync(TaskCreationRequest request, bool useTransaction = true) { if (request.TaskType == TaskBaseTypeEnum.WAIT_BILL_CONFIRM) { request.Steps ??= []; if (!request.Steps.Exists(x => x.Type == StepType.OPConfirm)) { - request.Steps.Add(new TaskStepDto + request.Steps.Add(new TaskStepDto { Type = StepType.OPConfirm, Name = StepType.OPConfirm.ToString() }); } } + try + { + #region + //第二次提交判断 + var check = await GetTasks(request.BusinessId, request.BusinessType, false, request.TaskType); + + await TenantDb.Ado.BeginTranAsync(); + if (check.Count>0) + { + //货物状态 + var goodsStatus = TenantDb.Queryable().First(x => x.StatusCode == "TIJIAO" && x.BusinessId == request.BusinessId); + if (goodsStatus == null) + { + var gsCfg = TenantDb.Queryable().First(x => x.SystemCode == "TIJIAO"); + if (gsCfg != null) + { + var gs = new BookingGoodsStatus() + { + BusinessId = request.BusinessId, + ConfigId = gsCfg.Id, + FinishTime = DateTime.Now, + FinishUserName = User.UserId.IsNull() ? "超级管理员" : User.UserName, + FinishBy = User.UserId.IsNull() ? 0 : long.Parse(User.UserId), + StatusCode = gsCfg.SystemCode, + StatusName = gsCfg.StatusName, + }; + await TenantDb.Insertable(gs).ExecuteCommandAsync(); + } + } + //主单状态变更 + var order = TenantDb.Queryable().Filter(null, true).First(x => x.Id == request.BusinessId); + var oldOrder = order.Adapt(); + order.BusinessStatusName = "已提交"; + order.BusinessStatus = "TIJIAO"; + await TenantDb.Updateable(order).UpdateColumns(x => new + { + x.BusinessStatusName, + x.BusinessStatus + }).EnableDiffLogEvent().ExecuteCommandAsync(); + + // 记录日志 + await seaComService.Value.SaveSeaExportLogAsync(new SeaExportSaveLog() + { + OperateType = "Update", + OldOrder = oldOrder, + NewOrder = order, + SourceCode = "CreateTaskAsync", + SourceName = "审单再次提交更新", + }, TenantDb); - return base.CreateTaskAsync(request, useTransaction); + } + #endregion + var res1 = await base.CreateTaskAsync(request, true); + if (res1.Succeeded) + { + await TenantDb.Ado.CommitTranAsync(); + + if (check.Count > 0) { + //更新大简云货物状态 + var pushModel = new EmbedServiceProjectStatusDto + { + businessId = request.BusinessId.ToString(), + SourceType = 1, + StatusCodes = new List { + new EmbedServiceProjectStatusDetailDto{ + StatusCode = "TIJIAO" + } + } + }; + + await djyStatusService.Value.SaveServiceStatus(pushModel); + } + + return res1; + } + else + { + await TenantDb.Ado.RollbackTranAsync(); + return res1; + } + } + catch (Exception) + { + await TenantDb.Ado.RollbackTranAsync(); + throw; + } } ///