修改任务新增方法

optimize
jianghaiqing 2 years ago
parent caa2f25f32
commit e92dc08a79

@ -8,7 +8,7 @@ using System.Threading.Tasks;
namespace Myshipping.Application.Entity
{
[Tenant("taskmanage")]
public class TaskManageDbEntity
public abstract class TaskManageDbEntity
{
/// <summary>
/// 主键
@ -20,33 +20,46 @@ namespace Myshipping.Application.Entity
/// <summary>
/// 创建时间
/// </summary>
public DateTime CreateTime { get; set; }
public virtual DateTime CreatedTime { get; set; }
/// <summary>
/// 修改时间
/// </summary>
public DateTime? ModifyTime { get; set; }
public virtual DateTime? UpdatedTime { get; set; }
/// <summary>
/// 创建人
/// 创建人ID
/// </summary>
public string CreateUser { get; set; }
public virtual string CreatedUserId { get; set; }
/// <summary>
/// 修改人
/// 创建人名称
/// </summary>
public string ModifyUser { get; set; }
public virtual string CreatedUserName { get; set; }
/// <summary>
/// 修改人ID
/// </summary>
public virtual string UpdatedUserId { get; set; }
/// <summary>
/// 修改人名称
/// </summary>
public virtual string UpdatedUserName { get; set; }
/// <summary>
/// 租户id
/// </summary>
//[SugarColumn(ColumnDescription = "租户id")]
public virtual long? TenantId { get; set; }
/// <summary>
/// 租户名称
/// </summary>
public virtual string TenantName { get; set; }
/// <summary>
/// 软删除
/// </summary>
//[SugarColumn(ColumnDescription = "软删除")]
public virtual bool IsDeleted { get; set; } = false;
}
}

@ -3771,24 +3771,34 @@
主键
</summary>
</member>
<member name="P:Myshipping.Application.Entity.TaskManageDbEntity.CreateTime">
<member name="P:Myshipping.Application.Entity.TaskManageDbEntity.CreatedTime">
<summary>
创建时间
</summary>
</member>
<member name="P:Myshipping.Application.Entity.TaskManageDbEntity.ModifyTime">
<member name="P:Myshipping.Application.Entity.TaskManageDbEntity.UpdatedTime">
<summary>
修改时间
</summary>
</member>
<member name="P:Myshipping.Application.Entity.TaskManageDbEntity.CreateUser">
<member name="P:Myshipping.Application.Entity.TaskManageDbEntity.CreatedUserId">
<summary>
创建人
创建人ID
</summary>
</member>
<member name="P:Myshipping.Application.Entity.TaskManageDbEntity.ModifyUser">
<member name="P:Myshipping.Application.Entity.TaskManageDbEntity.CreatedUserName">
<summary>
修改人
创建人名称
</summary>
</member>
<member name="P:Myshipping.Application.Entity.TaskManageDbEntity.UpdatedUserId">
<summary>
修改人ID
</summary>
</member>
<member name="P:Myshipping.Application.Entity.TaskManageDbEntity.UpdatedUserName">
<summary>
修改人名称
</summary>
</member>
<member name="P:Myshipping.Application.Entity.TaskManageDbEntity.TenantId">
@ -3796,6 +3806,11 @@
租户id
</summary>
</member>
<member name="P:Myshipping.Application.Entity.TaskManageDbEntity.TenantName">
<summary>
租户名称
</summary>
</member>
<member name="P:Myshipping.Application.Entity.TaskManageDbEntity.IsDeleted">
<summary>
软删除
@ -10497,59 +10512,70 @@
</summary>
</member>
<member name="P:Myshipping.Application.TaskManageOrderMessageHeadInfo.GID">
<summary>
报文惟一主键
</summary>
<summary>
报文惟一主键
</summary>
<example>08dabd4e-dcc3-471a-8031-cf066ed0a8f4</example>
</member>
<member name="P:Myshipping.Application.TaskManageOrderMessageHeadInfo.MessageType">
<summary>
报文类型 TASK-任务
</summary>
<example>TASK</example>
</member>
<member name="P:Myshipping.Application.TaskManageOrderMessageHeadInfo.SenderId">
<summary>
发送方代码
</summary>
<example>MAIL_PARSE</example>
</member>
<member name="P:Myshipping.Application.TaskManageOrderMessageHeadInfo.SenderName">
<summary>
发送方名称
</summary>
<example>邮件解析</example>
</member>
<member name="P:Myshipping.Application.TaskManageOrderMessageHeadInfo.ReceiverId">
<summary>
接收方代码
</summary>
<example>TaskManage</example>
</member>
<member name="P:Myshipping.Application.TaskManageOrderMessageHeadInfo.ReceiverName">
<summary>
接收方名称
</summary>
<example>任务管理平台</example>
</member>
<member name="P:Myshipping.Application.TaskManageOrderMessageHeadInfo.Token">
<summary>
请求方登录TOKEN可以是真实的登录人TOKEN或者是服务模拟登录人TOKEN
</summary>
<example>eyJhbGciOiJSUzI1NiIsImtpZCI6IkQ1RTkxMDI5OUU0RURFNUZEM0EwNTJBMEFDRDUzMUQzIiwidHlwIjoiYXQrand0In0</example>
</member>
<member name="P:Myshipping.Application.TaskManageOrderMessageHeadInfo.Version">
<summary>
版本号 默认1.0
</summary>
<example>1.0</example>
</member>
<member name="P:Myshipping.Application.TaskManageOrderMessageHeadInfo.RequestDate">
<summary>
请求时间
</summary>
<example>2022-12-23 14:29:11</example>
</member>
<member name="P:Myshipping.Application.TaskManageOrderMessageHeadInfo.SenderKey">
<summary>
请求授权KEY
</summary>
<example>testkey</example>
</member>
<member name="P:Myshipping.Application.TaskManageOrderMessageHeadInfo.RequestAction">
<summary>
请求操作类型
</summary>
<example>Add</example>
</member>
<member name="T:Myshipping.Application.TaskManageOrderMessageInfo">
<summary>
@ -10706,6 +10732,53 @@
提单草单内容
</summary>
</member>
<member name="T:Myshipping.Application.TaskManageOrderSIFeedBackContaInfo">
<summary>
箱信息
</summary>
</member>
<member name="P:Myshipping.Application.TaskManageOrderSIFeedBackContaInfo.ContaNo">
<summary>
集装箱号
</summary>
<example>RFCU2088064</example>
</member>
<member name="P:Myshipping.Application.TaskManageOrderSIFeedBackContaInfo.SealNo">
<summary>
铅封号
</summary>
<example>T090518</example>
</member>
<member name="P:Myshipping.Application.TaskManageOrderSIFeedBackContaInfo.PKGS">
<summary>
件数
</summary>
<example>222</example>
</member>
<member name="P:Myshipping.Application.TaskManageOrderSIFeedBackContaInfo.KGS">
<summary>
重量
</summary>
<example>1651</example>
</member>
<member name="P:Myshipping.Application.TaskManageOrderSIFeedBackContaInfo.CBM">
<summary>
尺寸
</summary>
<example>9.67</example>
</member>
<member name="P:Myshipping.Application.TaskManageOrderSIFeedBackContaInfo.ContaType">
<summary>
箱型代码
</summary>
<example>20GP</example>
</member>
<member name="P:Myshipping.Application.TaskManageOrderSIFeedBackContaInfo.ContaTypeName">
<summary>
箱型
</summary>
<example>20GP</example>
</member>
<member name="T:Myshipping.Application.TaskManageOrderSIFeedBackInfo">
<summary>
SI详情
@ -10821,6 +10894,11 @@
第三付款地
</summary>
</member>
<member name="P:Myshipping.Application.TaskManageOrderSIFeedBackInfo.ContaList">
<summary>
箱信息
</summary>
</member>
<member name="T:Myshipping.Application.TaskManageOrderVGMFeedBackInfo">
<summary>

@ -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<TaskManageOrderSIFeedBackInfo, TaskSIFeedBackInfo>()
.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<TaskManageOrderSIFeedBackContaInfo, TaskSIFeedBackContaInfo>()
.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);
}
}
}

@ -12,66 +12,77 @@ namespace Myshipping.Application
///
/// </summary>
public class TaskManageOrderMessageHeadInfo
{
{
/// <summary>
/// 报文惟一主键
/// </summary>
///<example>08dabd4e-dcc3-471a-8031-cf066ed0a8f4</example>
public string GID { get; set; } = IDGen.NextID().ToString();
/// <summary>
/// 报文类型 TASK-任务
/// </summary>
/// <example>TASK</example>
[Required(ErrorMessage = "必填")]
public string MessageType { get; set; }
/// <summary>
/// 发送方代码
/// </summary>
/// <example>MAIL_PARSE</example>
[Required(ErrorMessage = "必填")]
public string SenderId { get; set; }
/// <summary>
/// 发送方名称
/// </summary>
/// <example>邮件解析</example>
[Required(ErrorMessage = "必填")]
public string SenderName { get; set; }
/// <summary>
/// 接收方代码
/// </summary>
/// <example>TaskManage</example>
[Required(ErrorMessage = "必填")]
public string ReceiverId { get; set; }
/// <summary>
/// 接收方名称
/// </summary>
/// <example>任务管理平台</example>
[Required(ErrorMessage = "必填")]
public string ReceiverName { get; set; }
/// <summary>
/// 请求方登录TOKEN可以是真实的登录人TOKEN或者是服务模拟登录人TOKEN
/// </summary>
/// <example>eyJhbGciOiJSUzI1NiIsImtpZCI6IkQ1RTkxMDI5OUU0RURFNUZEM0EwNTJBMEFDRDUzMUQzIiwidHlwIjoiYXQrand0In0</example>
public string Token { get; set; }
/// <summary>
/// 版本号 默认1.0
/// </summary>
/// <example>1.0</example>
[Required(ErrorMessage = "必填")]
public string Version { get; set; } = "1.0";
/// <summary>
/// 请求时间
/// </summary>
/// <example>2022-12-23 14:29:11</example>
public string RequestDate { get; set; }
/// <summary>
/// 请求授权KEY
/// </summary>
/// <example>testkey</example>
public string SenderKey { get; set; }
/// <summary>
/// 请求操作类型
/// </summary>
/// <example>Add</example>
[Required(ErrorMessage = "必填")]
public string RequestAction { get; set; } = "Add";
}

@ -0,0 +1,56 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Myshipping.Application
{
/// <summary>
/// 箱信息
/// </summary>
public class TaskManageOrderSIFeedBackContaInfo
{
/// <summary>
/// 集装箱号
/// </summary>
/// <example>RFCU2088064</example>
public string ContaNo { get; set; }
/// <summary>
/// 铅封号
/// </summary>
/// <example>T090518</example>
public string SealNo { get; set; }
/// <summary>
/// 件数
/// </summary>
/// <example>222</example>
public int PKGS { get; set; }
/// <summary>
/// 重量
/// </summary>
/// <example>1651</example>
public decimal? KGS { get; set; }
/// <summary>
/// 尺寸
/// </summary>
/// <example>9.67</example>
public decimal? CBM { get; set; }
/// <summary>
/// 箱型代码
/// </summary>
/// <example>20GP</example>
public string ContaType { get; set; }
/// <summary>
/// 箱型
/// </summary>
/// <example>20GP</example>
public string ContaTypeName { get; set; }
}
}

@ -99,5 +99,10 @@ namespace Myshipping.Application
/// 第三付款地
/// </summary>
public string ThirdPayAddr { get; set; }
/// <summary>
/// 箱信息
/// </summary>
public List<TaskManageOrderSIFeedBackContaInfo> ContaList { get; set; }
}
}

@ -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<TaskBaseInfo> _taskBaseInfoRepository;
private readonly SqlSugarRepository<TaskSIFeedBackInfo> _taskSIFeedBackInfoRepository;
private readonly SqlSugarRepository<TaskSIFeedBackContaInfo> _taskSIFeedBackContaInfoRepository;
private readonly ILogger<BookingOrderService> _logger;
public TaskManageService(SqlSugarRepository<TaskBaseInfo> taskBaseInfoRepository,
SqlSugarRepository<TaskSIFeedBackInfo> taskSIFeedBackInfoRepository,
SqlSugarRepository<TaskSIFeedBackContaInfo> taskSIFeedBackContaInfoRepository,
ILogger<BookingOrderService> logger)
{
_taskBaseInfoRepository = taskBaseInfoRepository;
_taskSIFeedBackInfoRepository = taskSIFeedBackInfoRepository;
_taskSIFeedBackContaInfoRepository = taskSIFeedBackContaInfoRepository;
_logger = logger;
}
/// <summary>
@ -35,6 +45,7 @@ namespace Myshipping.Application
/// </summary>
/// <param name="info">任务详情</param>
/// <returns>返回回执</returns>
[AllowAnonymous,HttpPost("/TaskManage/CreateTaskJob")]
public async Task<TaskManageOrderResultDto> 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>();
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<TaskSIFeedBackContaInfo>();
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;

Loading…
Cancel
Save