diff --git a/Myshipping.Application/Entity/TaskManagePlat/TaskManageDbEntity.cs b/Myshipping.Application/Entity/TaskManagePlat/TaskManageDbEntity.cs index 5fbf3b57..5c0bb34b 100644 --- a/Myshipping.Application/Entity/TaskManagePlat/TaskManageDbEntity.cs +++ b/Myshipping.Application/Entity/TaskManagePlat/TaskManageDbEntity.cs @@ -8,7 +8,7 @@ using System.Threading.Tasks; namespace Myshipping.Application.Entity { [Tenant("taskmanage")] - public class TaskManageDbEntity + public abstract class TaskManageDbEntity { /// /// 主键 @@ -20,33 +20,46 @@ namespace Myshipping.Application.Entity /// /// 创建时间 /// - public DateTime CreateTime { get; set; } + public virtual DateTime CreatedTime { get; set; } /// /// 修改时间 /// - public DateTime? ModifyTime { get; set; } + public virtual DateTime? UpdatedTime { get; set; } /// - /// 创建人 + /// 创建人ID /// - public string CreateUser { get; set; } + public virtual string CreatedUserId { get; set; } /// - /// 修改人 + /// 创建人名称 /// - public string ModifyUser { get; set; } + public virtual string CreatedUserName { get; set; } + + /// + /// 修改人ID + /// + public virtual string UpdatedUserId { get; set; } + + /// + /// 修改人名称 + /// + public virtual string UpdatedUserName { get; set; } /// /// 租户id /// - //[SugarColumn(ColumnDescription = "租户id")] public virtual long? TenantId { get; set; } + /// + /// 租户名称 + /// + public virtual string TenantName { get; set; } + /// /// 软删除 /// - //[SugarColumn(ColumnDescription = "软删除")] public virtual bool IsDeleted { get; set; } = false; } } diff --git a/Myshipping.Application/Myshipping.Application.xml b/Myshipping.Application/Myshipping.Application.xml index 66043b38..6b1b610a 100644 --- a/Myshipping.Application/Myshipping.Application.xml +++ b/Myshipping.Application/Myshipping.Application.xml @@ -3771,24 +3771,34 @@ 主键 - + 创建时间 - + 修改时间 - + - 创建人 + 创建人ID - + - 修改人 + 创建人名称 + + + + + 修改人ID + + + + + 修改人名称 @@ -3796,6 +3806,11 @@ 租户id + + + 租户名称 + + 软删除 @@ -10497,59 +10512,70 @@ - - 报文惟一主键 - + + 报文惟一主键 + + 08dabd4e-dcc3-471a-8031-cf066ed0a8f4 报文类型 TASK-任务 + TASK 发送方代码 + MAIL_PARSE 发送方名称 + 邮件解析 接收方代码 + TaskManage 接收方名称 + 任务管理平台 请求方登录TOKEN(可以是真实的登录人TOKEN或者是服务模拟登录人TOKEN) + eyJhbGciOiJSUzI1NiIsImtpZCI6IkQ1RTkxMDI5OUU0RURFNUZEM0EwNTJBMEFDRDUzMUQzIiwidHlwIjoiYXQrand0In0 版本号 默认1.0 + 1.0 请求时间 + 2022-12-23 14:29:11 请求授权KEY + testkey 请求操作类型 + Add @@ -10706,6 +10732,53 @@ 提单草单内容 + + + 箱信息 + + + + + 集装箱号 + + RFCU2088064 + + + + 铅封号 + + T090518 + + + + 件数 + + 222 + + + + 重量 + + 1651 + + + + 尺寸 + + 9.67 + + + + 箱型代码 + + 20GP + + + + 箱型 + + 20GP + SI详情 @@ -10821,6 +10894,11 @@ 第三付款地 + + + 箱信息 + + diff --git a/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskManageMapper.cs b/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskManageMapper.cs new file mode 100644 index 00000000..53910eed --- /dev/null +++ b/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskManageMapper.cs @@ -0,0 +1,48 @@ +using Mapster; +using Myshipping.Application.Entity; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Myshipping.Application +{ + public class TaskManageMapper : IRegister + { + public void Register(TypeAdapterConfig config) + { + config.ForType() + .Map(dest => dest.SHIPPER, src => src.Shipper) + .Map(dest => dest.CONSIGNEE, src => src.Consignee) + .Map(dest => dest.NOTIFYPARTY, src => src.NotifyParty) + .Map(dest => dest.MARKS, src => src.Marks) + .Map(dest => dest.DESCRIPTION, src => src.Description) + .Map(dest => dest.REMARK, src => src.Remark) + .Map(dest => dest.BLFRT, src => src.BLFRT) + .Map(dest => dest.SERVICE, src => src.Service) + .Map(dest => dest.ISSUETYPE, src => src.IssueType) + .Map(dest => dest.PORT_LOADID, src => src.PortLoadId) + .Map(dest => dest.PORT_LOAD, src => src.PortLoad) + .Map(dest => dest.PORT_DISCHARGEID, src => src.PortDischargeId) + .Map(dest => dest.PORT_DISCHARGE, src => src.PortDischarge) + .Map(dest => dest.PORT_TRANSID, src => src.PortTransId) + .Map(dest => dest.PORT_TRANS, src => src.PortTrans) + .Map(dest => dest.DESTINATION_ID, src => src.DestinationId) + .Map(dest => dest.DESTINATION, src => src.Destination) + .Map(dest => dest.KIND_PKGS, src => src.KindPKGS) + .Map(dest => dest.PKGS, src => src.PKGS) + .Map(dest => dest.THIRDPAYADDR, src => src.ThirdPayAddr); + + + config.ForType() + .Map(dest => dest.CONTA_NO, src => src.ContaNo) + .Map(dest => dest.SEAL_NO, src => src.SealNo) + .Map(dest => dest.PKGS, src => src.PKGS) + .Map(dest => dest.KGS, src => src.KGS) + .Map(dest => dest.CBM, src => src.CBM) + .Map(dest => dest.CONTA_TYPE, src => src.ContaType) + .Map(dest => dest.CONTA_TYPE_NAME, src => src.ContaTypeName); + } + } +} diff --git a/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskManageOrderMessageHeadInfo.cs b/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskManageOrderMessageHeadInfo.cs index 29bf7496..12362b1a 100644 --- a/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskManageOrderMessageHeadInfo.cs +++ b/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskManageOrderMessageHeadInfo.cs @@ -12,66 +12,77 @@ namespace Myshipping.Application /// /// public class TaskManageOrderMessageHeadInfo - { + { /// /// 报文惟一主键 /// + ///08dabd4e-dcc3-471a-8031-cf066ed0a8f4 public string GID { get; set; } = IDGen.NextID().ToString(); /// /// 报文类型 TASK-任务 /// + /// TASK [Required(ErrorMessage = "必填")] public string MessageType { get; set; } /// /// 发送方代码 /// + /// MAIL_PARSE [Required(ErrorMessage = "必填")] public string SenderId { get; set; } /// /// 发送方名称 /// + /// 邮件解析 [Required(ErrorMessage = "必填")] public string SenderName { get; set; } /// /// 接收方代码 /// + /// TaskManage [Required(ErrorMessage = "必填")] public string ReceiverId { get; set; } /// /// 接收方名称 /// + /// 任务管理平台 [Required(ErrorMessage = "必填")] public string ReceiverName { get; set; } /// /// 请求方登录TOKEN(可以是真实的登录人TOKEN或者是服务模拟登录人TOKEN) /// + /// eyJhbGciOiJSUzI1NiIsImtpZCI6IkQ1RTkxMDI5OUU0RURFNUZEM0EwNTJBMEFDRDUzMUQzIiwidHlwIjoiYXQrand0In0 public string Token { get; set; } /// /// 版本号 默认1.0 /// + /// 1.0 [Required(ErrorMessage = "必填")] public string Version { get; set; } = "1.0"; /// /// 请求时间 /// + /// 2022-12-23 14:29:11 public string RequestDate { get; set; } /// /// 请求授权KEY /// + /// testkey public string SenderKey { get; set; } /// /// 请求操作类型 /// + /// Add [Required(ErrorMessage = "必填")] public string RequestAction { get; set; } = "Add"; } diff --git a/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskManageOrderSIFeedBackContaInfo.cs b/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskManageOrderSIFeedBackContaInfo.cs new file mode 100644 index 00000000..740f6351 --- /dev/null +++ b/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskManageOrderSIFeedBackContaInfo.cs @@ -0,0 +1,56 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Myshipping.Application +{ + /// + /// 箱信息 + /// + public class TaskManageOrderSIFeedBackContaInfo + { + /// + /// 集装箱号 + /// + /// RFCU2088064 + public string ContaNo { get; set; } + + /// + /// 铅封号 + /// + /// T090518 + public string SealNo { get; set; } + + /// + /// 件数 + /// + /// 222 + public int PKGS { get; set; } + + /// + /// 重量 + /// + /// 1651 + public decimal? KGS { get; set; } + + /// + /// 尺寸 + /// + /// 9.67 + public decimal? CBM { get; set; } + + /// + /// 箱型代码 + /// + /// 20GP + public string ContaType { get; set; } + + /// + /// 箱型 + /// + /// 20GP + public string ContaTypeName { get; set; } + } +} diff --git a/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskManageOrderSIFeedBackInfo.cs b/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskManageOrderSIFeedBackInfo.cs index 51306969..c1da60b0 100644 --- a/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskManageOrderSIFeedBackInfo.cs +++ b/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskManageOrderSIFeedBackInfo.cs @@ -99,5 +99,10 @@ namespace Myshipping.Application /// 第三付款地 /// public string ThirdPayAddr { get; set; } + + /// + /// 箱信息 + /// + public List ContaList { get; set; } } } diff --git a/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs b/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs index 0b7917e7..b9319d73 100644 --- a/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs +++ b/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs @@ -2,6 +2,8 @@ using Furion.DistributedIDGenerator; using Furion.DynamicApiController; using Furion.FriendlyException; +using Mapster; +using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Logging; using Myshipping.Application.Entity; @@ -22,12 +24,20 @@ namespace Myshipping.Application public class TaskManageService : ITaskManageService, IDynamicApiController { private readonly SqlSugarRepository _taskBaseInfoRepository; + private readonly SqlSugarRepository _taskSIFeedBackInfoRepository; + private readonly SqlSugarRepository _taskSIFeedBackContaInfoRepository; + private readonly ILogger _logger; public TaskManageService(SqlSugarRepository taskBaseInfoRepository, + SqlSugarRepository taskSIFeedBackInfoRepository, + SqlSugarRepository taskSIFeedBackContaInfoRepository, ILogger logger) { _taskBaseInfoRepository = taskBaseInfoRepository; + _taskSIFeedBackInfoRepository = taskSIFeedBackInfoRepository; + _taskSIFeedBackContaInfoRepository = taskSIFeedBackContaInfoRepository; + _logger = logger; } /// @@ -35,6 +45,7 @@ namespace Myshipping.Application /// /// 任务详情 /// 返回回执 + [AllowAnonymous,HttpPost("/TaskManage/CreateTaskJob")] public async Task CreateTaskJob(TaskManageOrderMessageInfo info) { TaskManageOrderResultDto result = new TaskManageOrderResultDto(); @@ -46,10 +57,7 @@ namespace Myshipping.Application 1、判断当前任务的主键是否已入库,已入库不允许重复,返回错误提示。 2、 */ - if(info.Main.TaskType == TaskBaseTypeEnum.BC) - { - result = await InitTaskJob(info); - } + result = await InitTaskJob(info); } catch (Exception ex) { @@ -71,8 +79,7 @@ namespace Myshipping.Application try { - var taskInfo = _taskBaseInfoRepository.AsQueryable().First(t => t.OUT_BUSI_NO == info.Head.GID - && t.TASK_TYPE == info.Main.TaskType.ToString()); + var taskInfo = _taskBaseInfoRepository.AsQueryable().First(t => t.OUT_BUSI_NO == info.Head.GID); if (taskInfo != null) throw Oops.Oh($"任务已经存在不能重复提交"); @@ -80,6 +87,7 @@ namespace Myshipping.Application taskInfo = new TaskBaseInfo { PK_ID = IDGen.NextID().ToString(), + TASK_NO = info.Head.GID, STATUS = TaskStatusEnum.Create.ToString(), IsDeleted = false, IS_EXCEPT = 0, @@ -96,6 +104,9 @@ namespace Myshipping.Application TASK_TYPE = info.Main.TaskType.ToString(), }; + taskInfo.CreatedTime = DateTime.Now; + taskInfo.UpdatedTime = taskInfo.CreatedTime; + if (!string.IsNullOrWhiteSpace(taskInfo.CARRIER_ID) && taskInfo.CARRIER_ID == "MSC") { @@ -109,11 +120,45 @@ namespace Myshipping.Application //新增 await _taskBaseInfoRepository.InsertAsync(taskInfo); + //SI反馈入库 + if (info.Main.TaskType == TaskBaseTypeEnum.SI_FEEDBACK) + { + if(info.Main.SIFeedBack == null) + throw Oops.Oh($"任务类型={info.Main.TaskType.ToString()} SIFeedBack信息必传"); + + TaskSIFeedBackInfo taskSIFeedBackInfo = info.Main.SIFeedBack.Adapt(); + + taskSIFeedBackInfo.PK_ID = IDGen.NextID().ToString(); + taskSIFeedBackInfo.TASK_PKID = taskInfo.PK_ID; + + taskSIFeedBackInfo.CreatedTime = taskInfo.CreatedTime; + taskSIFeedBackInfo.UpdatedTime = taskInfo.CreatedTime; + + await _taskSIFeedBackInfoRepository.InsertAsync(taskSIFeedBackInfo); + + //SI反馈箱信息入库 + if(info.Main.SIFeedBack.ContaList != null && info.Main.SIFeedBack.ContaList.Count > 0) + { + info.Main.SIFeedBack.ContaList.ForEach( async ctn => { + var contaInfo = ctn.Adapt(); + + contaInfo.PK_ID = IDGen.NextID().ToString(); + contaInfo.P_PKID = taskSIFeedBackInfo.PK_ID; + + contaInfo.CreatedTime = taskInfo.CreatedTime; + contaInfo.UpdatedTime = taskInfo.CreatedTime; + + await _taskSIFeedBackContaInfoRepository.InsertAsync(contaInfo); + }); + } + } + + result.succ = true; + result.msg = "新增任务成功"; } catch (Exception ex) { - result.succ = false; - result.msg = $"创建任务异常,{ex.Message}"; + throw Oops.Oh($"{ex.Message}"); } return result;