From d5563f55547788d9996f1de3b31896127b802e90 Mon Sep 17 00:00:00 2001 From: jianghaiqing Date: Thu, 10 Aug 2023 12:12:17 +0800 Subject: [PATCH] =?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; + } } }