From a03b155d5ef495b5d89c92133da4a2727ec2a92f Mon Sep 17 00:00:00 2001 From: jianghaiqing Date: Thu, 10 Aug 2023 13:40:44 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=AE=A2=E8=88=B1=E4=BF=9D?= =?UTF-8?q?=E5=AD=98=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BookingOrder/BookingOrderService.cs | 234 +++++++++++++++++- .../BookingOrder/IBookingOrderService.cs | 18 +- Myshipping.Web.Core/applicationconfig.json | 6 +- 3 files changed, 244 insertions(+), 14 deletions(-) diff --git a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs index 114cb9e5..8cc2ca1f 100644 --- a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs +++ b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs @@ -130,7 +130,7 @@ namespace Myshipping.Application private readonly SqlSugarRepository _repLineOpMgrConfig; private readonly SqlSugarRepository _repSysEmp; private readonly SqlSugarRepository _repAutoYard; - + private readonly IServiceWorkFlowManageService _serviceWorkFlowManageService; const string CONST_MAPPING_MODULE = "BOOK_OR_CLOSING"; const string CONST_MAPPING_MODULE_ROUTE = "BOOK_OR_CLOSING_RT"; @@ -152,7 +152,8 @@ namespace Myshipping.Application SqlSugarRepository excelrep, SqlSugarRepository repUserMail, SqlSugarRepository goodsStatus, SqlSugarRepository goodsStatusConfig, SqlSugarRepository repTenant, SqlSugarRepository repBookingStatus, SqlSugarRepository bookingEDIExt, SqlSugarRepository serviceItem, SqlSugarRepository paraContractNoInfoRepository, IHttpContextAccessor httpContextAccessor, IBookingGoodsStatusConfigService GoodsConfig, SqlSugarRepository djyWebsiteAccountConfigRepository, - ISysOrgService orgService, SqlSugarRepository repLineOpMgrConfig, SqlSugarRepository repSysEmp, SqlSugarRepository repAutoYard) + ISysOrgService orgService, SqlSugarRepository repLineOpMgrConfig, SqlSugarRepository repSysEmp, SqlSugarRepository repAutoYard, + IServiceWorkFlowManageService serviceWorkFlowManageService) { this._logger = logger; this._rep = rep; @@ -198,6 +199,8 @@ namespace Myshipping.Application this._repLineOpMgrConfig = repLineOpMgrConfig; this._repSysEmp = repSysEmp; this._repAutoYard = repAutoYard; + + _serviceWorkFlowManageService = serviceWorkFlowManageService; } #region 主表和箱信息 @@ -980,23 +983,41 @@ namespace Myshipping.Application if (string.IsNullOrEmpty(entity.CUSTNO)) { - var Config = config.Where(x => x.SystemCode == "YDC").FirstOrDefault(); - if (Config != null) + if (App.Configuration["ServiceStatusOpenAuto"] == "1") { - _goodsStatus.Delete(x => x.bookingId == Id && x.ConfigId == Config.Id); - //更新货物状态 + await SetGoodsStatusCancel("YDC",Id); + await SetBookingOrderGoodsStatus(Id); } + else + { + var Config = config.Where(x => x.SystemCode == "YDC").FirstOrDefault(); + if (Config != null) + { + _goodsStatus.Delete(x => x.bookingId == Id && x.ConfigId == Config.Id); + //更新货物状态 + await SetBookingOrderGoodsStatus(Id); + } + } } if (string.IsNullOrEmpty(entity.MBLNO)) { - var Config = config.Where(x => x.SystemCode == "YSDBC").FirstOrDefault(); - if (Config != null) + if (App.Configuration["ServiceStatusOpenAuto"] == "1") { - _goodsStatus.Delete(x => x.bookingId == Id && x.ConfigId == Config.Id); - //更新货物状态 + await SetGoodsStatusCancel("YSDBC", Id); + await SetBookingOrderGoodsStatus(Id); } + else + { + var Config = config.Where(x => x.SystemCode == "YSDBC").FirstOrDefault(); + if (Config != null) + { + _goodsStatus.Delete(x => x.bookingId == Id && x.ConfigId == Config.Id); + //更新货物状态 + await SetBookingOrderGoodsStatus(Id); + } + } } #endregion } @@ -8422,6 +8443,12 @@ HLCUTA12307DPXJ3 以这票为例 6个柜 public async Task SetGoodsStatus(string code, long bookingId) { + if (App.Configuration["ServiceStatusOpenAuto"] == "1") + { + await SetGoodsStatusPush(code, bookingId); + return; + } + var CreatedUserId = _rep.AsQueryable().Filter(null, true).Where(x => x.Id == bookingId).Select(x => x.CreatedUserId).First(); if (CreatedUserId != null) { @@ -8831,6 +8858,193 @@ HLCUTA12307DPXJ3 以这票为例 6个柜 await SendBookingOrder(orderlist.ToArray()); } + #region 推送服务状态 + /// + /// 推送服务状态 + /// + /// 服务状态代码 + /// 订舱ID + /// 是否默认同步东胜 true-自动同步 false-不自动同步 + /// + public async Task SetGoodsStatusPush(string code, long bookingId, bool isAutoSyncDS = false) + { + string batchNo = IDGen.NextID().ToString(); + + /* + 1、调取推送服务状态。 + 2、获取单票的服务状态排序值最大状态。写入订舱的状态(BSSTATUSNAME) + 3、调取同步订舱同步东胜。 + */ + if (string.IsNullOrWhiteSpace(code)) + { + _logger.LogInformation("批次={no} 调取{name} 服务状态代码不能为空", batchNo, nameof(SetGoodsStatusPush)); + throw Oops.Oh($"服务状态代码不能为空"); + } + + if (bookingId == 0) + { + _logger.LogInformation("批次={no} 调取{name} 订舱ID不能为空", batchNo, nameof(SetGoodsStatusPush)); + throw Oops.Oh($"订舱ID不能为空"); + } + + var saveStatusRlt = await _serviceWorkFlowManageService.SaveServiceStatus(new ModifyServiceProjectStatusDto + { + BookingId = bookingId, + SourceType = TrackingSourceTypeEnum.AUTO, + StatusCodes = new List { + new ModifyServiceProjectStatusDetailDto { + StatusCode = code + } + } + }); + + _logger.LogInformation("批次={no} 异步推送状态完成,结果={rlt}", batchNo, JSON.Serialize(saveStatusRlt)); + + if (saveStatusRlt.succ) + { + //拉取最新的状态数据,并取已完成的排序最大的状态写入订舱的字段 BSSTATUSNAME + var bookingOrder = _rep.AsQueryable().Filter(null, true) + .First(a => a.Id == bookingId); + + QueryServiceProjectWithStatus queryInfo = new QueryServiceProjectWithStatus + { + BookingId = bookingId, + QueryType = TrackingQueryTypeEnum.QUERY_SERVICE_PROJECT, + TenantId = bookingOrder.TenantId.Value + }; + + var queryRlt = await _serviceWorkFlowManageService.GetEnableStatusListByBusiness(queryInfo); + + if (queryRlt.succ) + { + var statusList = JSON.Deserialize>(JSON.Serialize(queryRlt.ext)); + + if (statusList != null) + { + var maxStatus = statusList.Where(a => a.IsYield) + .OrderByDescending(a => a.CalcSortNo).FirstOrDefault(); + + if (maxStatus != null) + { + var model = _rep.AsQueryable().Filter(null, true) + .First(a => a.Id == bookingId); + + model.BSSTATUSNAME = maxStatus.ShowName; + model.VERSION = IDGen.NextID().ToString().Replace("-", ""); + + //更新订舱 + _rep.AsUpdateable(model) + .UpdateColumns(it => new + { + it.BSSTATUSNAME, + it.VERSION + }).ExecuteCommand(); + + //推送东胜 + if (isAutoSyncDS) + await SendBookingOrder(new long[] { bookingId }); + } + } + } + } + } + #endregion + + #region 取消服务状态 + /// + /// 取消服务状态 + /// + /// 服务状态代码 + /// 订舱编号 + /// 是否默认同步东胜 true-自动同步 false-不自动同步 + /// + public async Task SetGoodsStatusCancel(string code, long bookingId, bool isAutoSyncDS = false) + { + string batchNo = IDGen.NextID().ToString(); + + /* + 1、调取推送服务状态。 + 2、获取单票的服务状态排序值最大状态。写入订舱的状态(BSSTATUSNAME) + 3、调取同步订舱同步东胜。 + */ + if (string.IsNullOrWhiteSpace(code)) + { + _logger.LogInformation("批次={no} 调取{name} 服务状态代码不能为空", batchNo, nameof(SetGoodsStatusPush)); + throw Oops.Oh($"服务状态代码不能为空"); + } + + if (bookingId == 0) + { + _logger.LogInformation("批次={no} 调取{name} 订舱ID不能为空", batchNo, nameof(SetGoodsStatusPush)); + throw Oops.Oh($"订舱ID不能为空"); + } + + var saveStatusRlt = await _serviceWorkFlowManageService.CancelServiceStatus(new ModifyServiceProjectStatusDto + { + BookingId = bookingId, + SourceType = TrackingSourceTypeEnum.AUTO, + StatusCodes = new List { + new ModifyServiceProjectStatusDetailDto { + StatusCode = code + } + } + }); + + _logger.LogInformation("批次={no} 异步取消状态完成,结果={rlt}", batchNo, JSON.Serialize(saveStatusRlt)); + + if (saveStatusRlt.succ) + { + //拉取最新的状态数据,并取已完成的排序最大的状态写入订舱的字段 BSSTATUSNAME + var bookingOrder = _rep.AsQueryable().Filter(null, true) + .First(a => a.Id == bookingId); + + QueryServiceProjectWithStatus queryInfo = new QueryServiceProjectWithStatus + { + BookingId = bookingId, + QueryType = TrackingQueryTypeEnum.QUERY_SERVICE_PROJECT, + TenantId = bookingOrder.TenantId.Value + }; + + var queryRlt = await _serviceWorkFlowManageService.GetEnableStatusListByBusiness(queryInfo); + + if (queryRlt.succ) + { + var statusList = JSON.Deserialize>(JSON.Serialize(queryRlt.ext)); + + if (statusList != null) + { + var maxStatus = statusList.Where(a => a.IsYield) + .OrderByDescending(a => a.CalcSortNo).FirstOrDefault(); + + var model = _rep.AsQueryable().Filter(null, true) + .First(a => a.Id == bookingId); + + if (maxStatus != null) + { + model.BSSTATUSNAME = maxStatus.ShowName; + } + else + { + model.BSSTATUSNAME = string.Empty; + } + + model.VERSION = IDGen.NextID().ToString().Replace("-", ""); + + //更新订舱 + _rep.AsUpdateable(model) + .UpdateColumns(it => new + { + it.BSSTATUSNAME, + it.VERSION + }).ExecuteCommand(); + + //推送东胜 + await SendBookingOrder(new long[] { bookingId }); + } + } + } + } + #endregion } } diff --git a/Myshipping.Application/Service/BookingOrder/IBookingOrderService.cs b/Myshipping.Application/Service/BookingOrder/IBookingOrderService.cs index 6deb95b8..0e5252d6 100644 --- a/Myshipping.Application/Service/BookingOrder/IBookingOrderService.cs +++ b/Myshipping.Application/Service/BookingOrder/IBookingOrderService.cs @@ -78,6 +78,22 @@ namespace Myshipping.Application Task AutoYardData(long bookId); - + /// + /// 推送服务状态 + /// + /// 服务状态代码 + /// 订舱ID + /// 是否默认同步东胜 true-自动同步 false-不自动同步 + /// + Task SetGoodsStatusPush(string code, long bookingId, bool isAutoSyncDS = false); + + /// + /// 取消服务状态 + /// + /// 服务状态代码 + /// 订舱编号 + /// 是否默认同步东胜 true-自动同步 false-不自动同步 + /// + Task SetGoodsStatusCancel(string code, long bookingId, bool isAutoSyncDS = false); } } \ No newline at end of file diff --git a/Myshipping.Web.Core/applicationconfig.json b/Myshipping.Web.Core/applicationconfig.json index dd600407..5211d2fa 100644 --- a/Myshipping.Web.Core/applicationconfig.json +++ b/Myshipping.Web.Core/applicationconfig.json @@ -122,9 +122,9 @@ "RemainHours": 2 }, "ITEMCODE": true, - "SendBookingOrderMQUri":"amqp://hechuan_booking:hechuan_booking123@47.104.207.5:12567/hechuan_booking", + "SendBookingOrderMQUri": "amqp://hechuan_booking:hechuan_booking123@47.104.207.5:12567/hechuan_booking", "ShippingOrderCompareUrl": "http://60.209.125.238:35210/api/TaskShippingOrderCompare/ExcuteShippingOrderCompare", "BCOrDraftUserKey": "BookingOrderPlat", - "BCOrDraftUserSecret": "228b2db5952d13291f228d441018c1b6" - + "BCOrDraftUserSecret": "228b2db5952d13291f228d441018c1b6", + "ServiceStatusOpenAuto": "0" } \ No newline at end of file