From d5563f55547788d9996f1de3b31896127b802e90 Mon Sep 17 00:00:00 2001 From: jianghaiqing Date: Thu, 10 Aug 2023 12:12:17 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E8=BF=81=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Entity/BookingYardDataAuto.cs | 33 ++++ .../Entity/Booking_AutoYardImport.cs | 44 +++++ .../Enum/TrackingSourceTypeEnum.cs | 10 +- .../BookingOrder/BookingValueAddedService.cs | 4 +- .../Dto/ModifyServiceProjectDto.cs | 5 + .../BookingOrder/Dto/OcrUploadOutputDto.cs | 24 +++ .../TaskShippingOrderCompareService.cs | 21 +- .../Interface/IServiceWorkFlowBaseService.cs | 13 +- .../IServiceWorkFlowManageService.cs | 14 ++ .../ServiceWorkFlowBaseService.cs | 85 +++++++- .../ServiceWorkFlowManageService.cs | 187 +++++++++++++++++- 11 files changed, 429 insertions(+), 11 deletions(-) create mode 100644 Myshipping.Application/Entity/BookingYardDataAuto.cs create mode 100644 Myshipping.Application/Entity/Booking_AutoYardImport.cs create mode 100644 Myshipping.Application/Service/BookingOrder/Dto/OcrUploadOutputDto.cs diff --git a/Myshipping.Application/Entity/BookingYardDataAuto.cs b/Myshipping.Application/Entity/BookingYardDataAuto.cs new file mode 100644 index 00000000..31984631 --- /dev/null +++ b/Myshipping.Application/Entity/BookingYardDataAuto.cs @@ -0,0 +1,33 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Myshipping.Application.Entity +{ + [SugarTable("booking_auto_yard_import")] + [Description("场站数据自动引入状态")] + public class BookingYardDataAuto + { + /// + /// 主键 + /// + [SugarColumn(IsIdentity = true, ColumnDescription = "Id主键", IsPrimaryKey = true)] //通过特性设置主键和自增列 + public long Id { get; set; } + /// + /// 状态:引入成功、比对失败 + /// + public string Status { get; set; } + /// + /// 比对结果内容 + /// + public string Content { get; set; } + /// + /// 创建时间 + /// + public DateTime? CreatedTime { get; set; } + } +} diff --git a/Myshipping.Application/Entity/Booking_AutoYardImport.cs b/Myshipping.Application/Entity/Booking_AutoYardImport.cs new file mode 100644 index 00000000..df376573 --- /dev/null +++ b/Myshipping.Application/Entity/Booking_AutoYardImport.cs @@ -0,0 +1,44 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Myshipping.Application.Entity +{ + /// + /// + /// + [SugarTable("booking_auto_yard_import")] + [Description("场站自动引入信息")] + public class Booking_AutoYardImport + { + /// + /// 主键 + /// + [SugarColumn(ColumnDescription = "Id主键", IsPrimaryKey = true)] //通过特性设置主键和自增列 + public long Id { get; set; } + /// + /// 状态:引入成功、比对失败 + /// + public string Status { get; set; } + /// + /// 比对结果内容 + /// + public string Content { get; set; } + /// + /// 创建时间 + /// + public DateTime? CreatedTime { get; set; } + /// + /// 场站数据JSON + /// + public string YardJson { get; set; } + /// + /// 比对数据时填写的箱信息JSON + /// + public string CtnJson { get; set; } + } +} diff --git a/Myshipping.Application/Enum/TrackingSourceTypeEnum.cs b/Myshipping.Application/Enum/TrackingSourceTypeEnum.cs index 689d7bc0..e8f011cd 100644 --- a/Myshipping.Application/Enum/TrackingSourceTypeEnum.cs +++ b/Myshipping.Application/Enum/TrackingSourceTypeEnum.cs @@ -12,15 +12,15 @@ namespace Myshipping.Application /// public enum TrackingSourceTypeEnum { - /// - /// 自动 - /// - [Description("自动")] - AUTO, /// /// 人工 /// [Description("人工")] MANUAL, + /// + /// 自动 + /// + [Description("自动")] + AUTO } } diff --git a/Myshipping.Application/Service/BookingOrder/BookingValueAddedService.cs b/Myshipping.Application/Service/BookingOrder/BookingValueAddedService.cs index fc62ab4b..a3d8d088 100644 --- a/Myshipping.Application/Service/BookingOrder/BookingValueAddedService.cs +++ b/Myshipping.Application/Service/BookingOrder/BookingValueAddedService.cs @@ -2276,7 +2276,7 @@ namespace Myshipping.Application OpertType = TrackingOperTypeEnum.MANUAL, OperUserId = UserManager.UserId.ToString(), OperUserName = UserManager.Name, - SourceType = TrackingSourceTypeEnum.MANUAL, + SourceType = model.SourceType, StatusList = model.StatusCodes.Select(a => new TrackingMessageMainStatusInfo { StatusCode = a.StatusCode, @@ -2368,7 +2368,7 @@ namespace Myshipping.Application OpertType = TrackingOperTypeEnum.MANUAL, OperUserId = UserManager.UserId.ToString(), OperUserName = UserManager.Name, - SourceType = TrackingSourceTypeEnum.MANUAL, + SourceType = model.SourceType, StatusList = model.StatusCodes.Select(a => new TrackingMessageMainStatusInfo { StatusCode = a.StatusCode, diff --git a/Myshipping.Application/Service/BookingOrder/Dto/ModifyServiceProjectDto.cs b/Myshipping.Application/Service/BookingOrder/Dto/ModifyServiceProjectDto.cs index 3cc49b5e..7d8a3d68 100644 --- a/Myshipping.Application/Service/BookingOrder/Dto/ModifyServiceProjectDto.cs +++ b/Myshipping.Application/Service/BookingOrder/Dto/ModifyServiceProjectDto.cs @@ -32,6 +32,11 @@ namespace Myshipping.Application /// public long BookingId { get; set; } + /// + /// 来源类型 + /// + public TrackingSourceTypeEnum SourceType { get; set; } = TrackingSourceTypeEnum.MANUAL; + /// /// 服务项目状态明细 /// diff --git a/Myshipping.Application/Service/BookingOrder/Dto/OcrUploadOutputDto.cs b/Myshipping.Application/Service/BookingOrder/Dto/OcrUploadOutputDto.cs new file mode 100644 index 00000000..5b400837 --- /dev/null +++ b/Myshipping.Application/Service/BookingOrder/Dto/OcrUploadOutputDto.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Myshipping.Application +{ + /// + /// Ocr上传后返回 + /// + public class OcrUploadOutputDto + { + /// + /// OCR返回文件名(后面调用OCR获取内容时使用) + /// + public string OcrFileName { get; set; } + + /// + /// 上传附件的文件名 + /// + public string UploadFileName { get; set; } + } +} diff --git a/Myshipping.Application/Service/TaskManagePlat/TaskShippingOrderCompareService.cs b/Myshipping.Application/Service/TaskManagePlat/TaskShippingOrderCompareService.cs index 9fd3f1c6..5cbd65ce 100644 --- a/Myshipping.Application/Service/TaskManagePlat/TaskShippingOrderCompareService.cs +++ b/Myshipping.Application/Service/TaskManagePlat/TaskShippingOrderCompareService.cs @@ -37,14 +37,18 @@ namespace Myshipping.Application private readonly SqlSugarRepository _bookingOrderContaRepository; //private readonly SqlSugarRepository _userRepository; + private readonly IBookingValueAddedService _bookingValueAddedService; + public TaskShippingOrderCompareService(ISysCacheService cache, ILogger logger, - SqlSugarRepository bookingOrderRepository, SqlSugarRepository bookingOrderContaRepository) + SqlSugarRepository bookingOrderRepository, SqlSugarRepository bookingOrderContaRepository, + IBookingValueAddedService bookingValueAddedService) { _cache = cache; _logger = logger; _bookingOrderRepository = bookingOrderRepository; _bookingOrderContaRepository = bookingOrderContaRepository; + _bookingValueAddedService = bookingValueAddedService; } /// /// 执行下货纸比对 @@ -153,6 +157,21 @@ namespace Myshipping.Application { orderInfo.LstShipOrderCompareRlt = "NO_DIFF"; orderInfo.LstShipOrderCompareRltName = "正常"; + + //推送状态JHQ + if (App.Configuration["ServiceStatusOpenAuto"] == "1") + { + //比对成功后触发下货纸比对状态 + var saveStatusRlt = await _bookingValueAddedService.SaveServiceStatus(new ModifyServiceProjectStatusDto + { + BookingId = long.Parse(bookingId), + SourceType = TrackingSourceTypeEnum.AUTO, + StatusCodes = new List { + new ModifyServiceProjectStatusDetailDto { StatusCode = "XHZBDCHG" } } + }); + + _logger.LogInformation("批次={no} 异步推送下货纸比对状态完成,结果={rlt}", batchNo, JSON.Serialize(saveStatusRlt)); + } } } else diff --git a/Myshipping.Application/Service/TrackingSystem/Interface/IServiceWorkFlowBaseService.cs b/Myshipping.Application/Service/TrackingSystem/Interface/IServiceWorkFlowBaseService.cs index 518ef0e6..ce04a903 100644 --- a/Myshipping.Application/Service/TrackingSystem/Interface/IServiceWorkFlowBaseService.cs +++ b/Myshipping.Application/Service/TrackingSystem/Interface/IServiceWorkFlowBaseService.cs @@ -130,7 +130,18 @@ namespace Myshipping.Application /// 返回回执 Task> GetEnableProjectWithStatusList(string tenantId, bool isAvoidCache = false); + /// + /// 获取可用的服务项目字典列表 + /// + /// 是否重新加载缓存 + /// + Task> GetEnableProjectDictTreeList(bool isAvoidCache = false); - + /// + /// 获取可用的服务状态字典列表 + /// + /// 是否重新加载缓存 + /// + Task> GetEnableStatusDictTreeList(bool isAvoidCache = false); } } diff --git a/Myshipping.Application/Service/TrackingSystem/Interface/IServiceWorkFlowManageService.cs b/Myshipping.Application/Service/TrackingSystem/Interface/IServiceWorkFlowManageService.cs index 967c580a..eeae98b2 100644 --- a/Myshipping.Application/Service/TrackingSystem/Interface/IServiceWorkFlowManageService.cs +++ b/Myshipping.Application/Service/TrackingSystem/Interface/IServiceWorkFlowManageService.cs @@ -77,5 +77,19 @@ namespace Myshipping.Application /// 查询服务项目和状态详情 /// 返回回执 Task GetEnableStatusListByBusiness(QueryServiceProjectWithStatus model); + + /// + /// 保存服务状态 + /// + /// 修改服务状态详情 + /// 返回回执 + Task SaveServiceStatus(ModifyServiceProjectStatusDto model); + + /// + /// 取消服务状态 + /// + /// 修改服务状态详情 + /// 返回回执 + Task CancelServiceStatus(ModifyServiceProjectStatusDto model); } } diff --git a/Myshipping.Application/Service/TrackingSystem/ServiceWorkFlowBaseService.cs b/Myshipping.Application/Service/TrackingSystem/ServiceWorkFlowBaseService.cs index c652b0a9..4d44df00 100644 --- a/Myshipping.Application/Service/TrackingSystem/ServiceWorkFlowBaseService.cs +++ b/Myshipping.Application/Service/TrackingSystem/ServiceWorkFlowBaseService.cs @@ -3,6 +3,7 @@ using Furion.DistributedIDGenerator; using Furion.DynamicApiController; using Furion.FriendlyException; using Furion.JsonSerialization; +using Furion.Localization; using Mapster; using Microsoft.AspNetCore.Mvc; using Microsoft.CodeAnalysis.CSharp.Syntax; @@ -12,7 +13,9 @@ using Myshipping.Application.Entity; using Myshipping.Application.Helper; using Myshipping.Core; using Myshipping.Core.Entity; +using Myshipping.Core.Service; using MySqlX.XDevAPI.Common; +using Npoi.Mapper; using NPOI.SS.Formula.Functions; using NPOI.SS.Formula.PTG; using NPOI.Util; @@ -2015,6 +2018,86 @@ namespace Myshipping.Application } #endregion - + #region 获取可用的服务项目字典列表 + /// + /// 获取可用的服务项目字典列表 + /// + /// 是否重新加载缓存 + /// + [HttpGet("/ServiceWorkFlowBase/GetEnableProjectDictTreeList")] + public async Task> GetEnableProjectDictTreeList([FromQuery] bool isAvoidCache = false) + { + List resultList = new List(); + + var list = await GetEnableProjectList(UserManager.TENANT_ID.ToString(), isAvoidCache); + + if(list.Count > 0) + { + resultList.Add(new Core.Service.DictTreeOutput + { + Code = "booking_service_item", + Name = "订舱服务项目", + Children = list.OrderBy(a => a.SortNo).Select(a => new DictTreeOutput { + Code = a.ServiceProjectCode, + Name = a.ServiceProjectName + }).ToList() + }); + + } + + return resultList; + } + #endregion + + #region 获取可用的服务状态字典列表 + /// + /// 获取可用的服务状态字典列表 + /// + /// 是否重新加载缓存 + /// + [HttpGet("/ServiceWorkFlowBase/GetEnableStatusDictTreeList")] + public async Task> GetEnableStatusDictTreeList([FromQuery] bool isAvoidCache = false) + { + List resultList = new List(); + + var list = await GetEnableProjectWithStatusList(UserManager.TENANT_ID.ToString(), isAvoidCache); + + if (list.Count > 0) + { + resultList.Add(new Core.Service.DictTreeOutput + { + Code = "booking_goods_status", + Name = "订舱货物状态", + Children = list.OrderBy(a => a.SortNo).SelectMany(a => { + var rltList = new List(); + a.StatusList.ForEach(b => + { + rltList.Add(new DictTreeOutput + { + Code = b.StatusSKUCode, + Name = b.StatusSKUName, + Remark = b.BackgroundColor + }); + + if (b.SubStatusList != null && b.SubStatusList.Count > 0) + { + rltList.AddRange(b.SubStatusList.Select(c => new DictTreeOutput + { + Code = c.StatusSKUCode, + Name = c.StatusSKUName, + Remark = c.BackgroundColor + }).ToList()); + } + }); + + return rltList; + }).ToList() + }); + + } + + return resultList; + } + #endregion } } diff --git a/Myshipping.Application/Service/TrackingSystem/ServiceWorkFlowManageService.cs b/Myshipping.Application/Service/TrackingSystem/ServiceWorkFlowManageService.cs index 008f9ecd..e89eb9ba 100644 --- a/Myshipping.Application/Service/TrackingSystem/ServiceWorkFlowManageService.cs +++ b/Myshipping.Application/Service/TrackingSystem/ServiceWorkFlowManageService.cs @@ -50,6 +50,7 @@ namespace Myshipping.Application private readonly SqlSugarRepository _serviceWorkFlowRunLogInfoRepository; private readonly ICache _cache; private readonly CacheOptions _cacheOptions; + private readonly SqlSugarRepository _bookingOrderRepository; private readonly IServiceWorkFlowBaseService _serviceWorkFlowBaseService; @@ -71,7 +72,8 @@ namespace Myshipping.Application IServiceWorkFlowBaseService serviceWorkFlowBaseService, SqlSugarRepository sysUserRepository, SqlSugarRepository serviceProjectBaseInfoRepository, SqlSugarRepository serviceWorkFlowRunLogInfoRepository, - IOptions cacheOptions, Func resolveNamed) + IOptions cacheOptions, Func resolveNamed, + SqlSugarRepository bookingOrderRepository) { _serviceWorkFlowBaseRepository = serviceWorkFlowBaseRepository; _serviceWorkFlowActivitiesInfoRepository = serviceWorkFlowActivitiesInfoRepository; @@ -88,6 +90,7 @@ namespace Myshipping.Application _sysUserRepository = sysUserRepository; _serviceProjectBaseInfoRepository = serviceProjectBaseInfoRepository; _serviceWorkFlowRunLogInfoRepository = serviceWorkFlowRunLogInfoRepository; + _bookingOrderRepository = bookingOrderRepository; _cacheOptions = cacheOptions.Value; _cache = resolveNamed(_cacheOptions.CacheType.ToString(), default) as ICache; @@ -1949,5 +1952,187 @@ namespace Myshipping.Application } #endregion + + /// + /// 保存服务状态 + /// + /// 修改服务状态详情 + /// 返回回执 + public async Task SaveServiceStatus(ModifyServiceProjectStatusDto model) + { + TaskManageOrderResultDto result = new TaskManageOrderResultDto(); + + string batchNo = IDGen.NextID().ToString(); + + try + { + var bookingOrder = _bookingOrderRepository.AsQueryable().Filter(null, true) + .First(a => a.Id == model.BookingId); + + if (bookingOrder == null) + throw Oops.Oh($"订舱信息获取失败,订舱信息不存在或已作废"); + + _logger.LogInformation("批次={no} 请求保存服务项目 modifyjson={msg}", batchNo, JSON.Serialize(model)); + + TrackingMessageInfo msgInfo = new TrackingMessageInfo + { + Head = new TrackingMessageHeadInfo + { + GID = IDGen.NextID().ToString(), + MessageType = "PROJECT", + ReceiverId = "ServiceProjectStatus", + ReceiverName = "服务项目和状态", + SenderId = "BookingOrder", + SenderName = "海运订舱", + RequestDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"), + Version = "2.0", + RequestAction = "AddOrModify", + }, + Main = new TrackingMessageMainInfo + { + BusiId = model.BookingId.ToString(), + BusiSystemCode = "BOOKING_ORDER", + MBlNo = bookingOrder.MBLNO, + VesselVoyno = $"{bookingOrder.VESSEL}/{bookingOrder.VOYNO}", + OrderNo = bookingOrder.BSNO, + PushType = TrackingPushTypeEnum.Status, + OperTenantId = bookingOrder.TenantId.Value, + OperTenantName = bookingOrder.TenantName, + OpertType = TrackingOperTypeEnum.MANUAL, + OperUserId = UserManager.UserId.ToString(), + OperUserName = UserManager.Name, + SourceType = model.SourceType, + StatusList = model.StatusCodes.Select(a => new TrackingMessageMainStatusInfo + { + StatusCode = a.StatusCode, + StatusDate = a.SetActDate, + StatusVal = a.SetActVal, + Remark = a.ActRemark + }).ToList() + } + }; + DateTime bDate = DateTime.Now; + + _logger.LogInformation("批次={no} 推送保存服务项目 msg={msg}", batchNo, JSON.Serialize(msgInfo)); + + var rlt = await PushStatus(msgInfo); + + DateTime eDate = DateTime.Now; + TimeSpan ts = eDate.Subtract(bDate); + var timeDiff = ts.TotalMilliseconds; + + _logger.LogInformation("批次={no} 请求完成,耗时:{timeDiff}ms. 结果{msg} result={rlt}", batchNo, timeDiff, (rlt.succ ? "成功" : "失败") + , JSON.Serialize(rlt)); + + if (!rlt.succ) + { + result = rlt; + } + else + { + result.succ = true; + result.msg = "推送成功"; + } + + } + catch (Exception ex) + { + result.succ = false; + result.msg = $"服务项目状态推送失败,原因:{ex.Message}"; + } + + return result; + } + + /// + /// 取消服务状态 + /// + /// 修改服务状态详情 + /// 返回回执 + public async Task CancelServiceStatus(ModifyServiceProjectStatusDto model) + { + TaskManageOrderResultDto result = new TaskManageOrderResultDto(); + + string batchNo = IDGen.NextID().ToString(); + + try + { + var bookingOrder = _bookingOrderRepository.AsQueryable().Filter(null, true) + .First(a => a.Id == model.BookingId); + + if (bookingOrder == null) + throw Oops.Oh($"订舱信息获取失败,订舱信息不存在或已作废"); + + _logger.LogInformation("批次={no} 请求保存服务项目 modifyjson={msg}", batchNo, JSON.Serialize(model)); + + TrackingMessageInfo msgInfo = new TrackingMessageInfo + { + Head = new TrackingMessageHeadInfo + { + GID = IDGen.NextID().ToString(), + MessageType = "PROJECT", + ReceiverId = "ServiceProjectStatus", + ReceiverName = "服务项目和状态", + SenderId = "BookingOrder", + SenderName = "海运订舱", + RequestDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"), + Version = "2.0", + RequestAction = "AddOrModify", + }, + Main = new TrackingMessageMainInfo + { + BusiId = model.BookingId.ToString(), + BusiSystemCode = "BOOKING_ORDER", + MBlNo = bookingOrder.MBLNO, + VesselVoyno = $"{bookingOrder.VESSEL}/{bookingOrder.VOYNO}", + OrderNo = bookingOrder.BSNO, + PushType = TrackingPushTypeEnum.Status, + OperTenantId = bookingOrder.TenantId.Value, + OperTenantName = bookingOrder.TenantName, + OpertType = TrackingOperTypeEnum.MANUAL, + OperUserId = UserManager.UserId.ToString(), + OperUserName = UserManager.Name, + SourceType = model.SourceType, + StatusList = model.StatusCodes.Select(a => new TrackingMessageMainStatusInfo + { + StatusCode = a.StatusCode, + StatusDate = a.SetActDate, + StatusVal = a.SetActVal, + Remark = a.ActRemark + }).ToList() + } + }; + DateTime bDate = DateTime.Now; + + _logger.LogInformation("批次={no} 推送保存服务项目 msg={msg}", batchNo, JSON.Serialize(msgInfo)); + + var rlt = await CancelStatus(msgInfo); + + DateTime eDate = DateTime.Now; + TimeSpan ts = eDate.Subtract(bDate); + var timeDiff = ts.TotalMilliseconds; + + _logger.LogInformation("批次={no} 请求完成,耗时:{timeDiff}ms. 结果{msg} result={rlt}", batchNo, timeDiff, (rlt.succ ? "成功" : "失败") + , JSON.Serialize(rlt)); + + if (!rlt.succ) + { + result = rlt; + } + else + { + result.succ = true; + result.msg = "推送成功"; + } + + } + catch (Exception ex) + { + result.succ = false; + result.msg = $"服务项目状态推送失败,原因:{ex.Message}"; + } + + return result; + } } } From a03b155d5ef495b5d89c92133da4a2727ec2a92f Mon Sep 17 00:00:00 2001 From: jianghaiqing Date: Thu, 10 Aug 2023 13:40:44 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=AE=A2=E8=88=B1?= =?UTF-8?q?=E4=BF=9D=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 From c892e32658b0ce0fb8f24beaff5577d4aeef7678 Mon Sep 17 00:00:00 2001 From: jianghaiqing Date: Thu, 10 Aug 2023 15:04:12 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=9C=8D=E5=8A=A1?= =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E7=BC=93=E5=AD=98=E6=97=B6=E9=97=B4=20?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=9C=8D=E5=8A=A1=E7=8A=B6=E6=80=81=E4=BF=9D?= =?UTF-8?q?=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Service/TrackingSystem/ServiceWorkFlowBaseService.cs | 8 ++++---- .../TrackingSystem/ServiceWorkFlowManageService.cs | 2 ++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Myshipping.Application/Service/TrackingSystem/ServiceWorkFlowBaseService.cs b/Myshipping.Application/Service/TrackingSystem/ServiceWorkFlowBaseService.cs index 4d44df00..8ac7f45a 100644 --- a/Myshipping.Application/Service/TrackingSystem/ServiceWorkFlowBaseService.cs +++ b/Myshipping.Application/Service/TrackingSystem/ServiceWorkFlowBaseService.cs @@ -1769,7 +1769,7 @@ namespace Myshipping.Application SortNo = a.SortNo }).OrderBy(a => a.SortNo).ToList(); - await _cache.SetAsync($"{CONST_CACHE_ENABLE_PROJECT}_{tenantId}", projectList); + await _cache.SetAsync($"{CONST_CACHE_ENABLE_PROJECT}_{tenantId}", projectList, TimeSpan.FromHours(8)); } return projectList; @@ -1797,7 +1797,7 @@ namespace Myshipping.Application { statusList = ReloadServiceProjectCacheInfo(tenantId); - await _cache.SetAsync($"{CONST_CACHE_ENABLE_PROJECT_STATUS}_{tenantId}", statusList); + await _cache.SetAsync($"{CONST_CACHE_ENABLE_PROJECT_STATUS}_{tenantId}", statusList, TimeSpan.FromHours(8)); } return statusList; @@ -1816,7 +1816,7 @@ namespace Myshipping.Application { var statusList = ReloadServiceProjectCacheInfo(tenantId); - await _cache.SetAsync($"{CONST_CACHE_ENABLE_PROJECT_STATUS}_{tenantId}", statusList); + await _cache.SetAsync($"{CONST_CACHE_ENABLE_PROJECT_STATUS}_{tenantId}", statusList, TimeSpan.FromHours(8)); _logger.LogInformation($"租户下可用的服务流程详情并写入缓存完成"); @@ -1828,7 +1828,7 @@ namespace Myshipping.Application SortNo = a.SortNo }).OrderBy(a => a.SortNo).ToList(); - await _cache.SetAsync($"{CONST_CACHE_ENABLE_PROJECT}_{tenantId}", projectList); + await _cache.SetAsync($"{CONST_CACHE_ENABLE_PROJECT}_{tenantId}", projectList, TimeSpan.FromHours(8)); _logger.LogInformation($"租户下可用的服务写入缓存完成"); } diff --git a/Myshipping.Application/Service/TrackingSystem/ServiceWorkFlowManageService.cs b/Myshipping.Application/Service/TrackingSystem/ServiceWorkFlowManageService.cs index e89eb9ba..f123254f 100644 --- a/Myshipping.Application/Service/TrackingSystem/ServiceWorkFlowManageService.cs +++ b/Myshipping.Application/Service/TrackingSystem/ServiceWorkFlowManageService.cs @@ -870,6 +870,7 @@ namespace Myshipping.Application it.ACT_DATE, it.IS_YIELD, it.ACT_REMARK, + it.ACT_VAL, it.UpdatedTime, it.UpdatedUserId, it.UpdatedUserName @@ -960,6 +961,7 @@ namespace Myshipping.Application it.ACT_DATE, it.IS_YIELD, it.ACT_REMARK, + it.ACT_VAL, it.UpdatedTime, it.UpdatedUserId, it.UpdatedUserName