|
|
|
@ -2,6 +2,7 @@
|
|
|
|
|
using Furion.DependencyInjection;
|
|
|
|
|
using Furion.DistributedIDGenerator;
|
|
|
|
|
using Furion.DynamicApiController;
|
|
|
|
|
using Furion.Extensions;
|
|
|
|
|
using Furion.FriendlyException;
|
|
|
|
|
using Furion.JsonSerialization;
|
|
|
|
|
using Furion.Localization;
|
|
|
|
@ -9,6 +10,7 @@ using Furion.RemoteRequest;
|
|
|
|
|
using Furion.RemoteRequest.Extensions;
|
|
|
|
|
using Mapster;
|
|
|
|
|
using Microsoft.AspNetCore.Authorization;
|
|
|
|
|
using Microsoft.AspNetCore.Http;
|
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
using Microsoft.AspNetCore.Mvc.RazorPages;
|
|
|
|
|
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
|
|
|
@ -85,7 +87,8 @@ namespace Myshipping.Application
|
|
|
|
|
private readonly SqlSugarRepository<TaskStoreMsgInfo> _taskStoreMsgInfoRepository;
|
|
|
|
|
private readonly SqlSugarRepository<TaskChangeShipHisInfo> _taskChangeShipHisInfoRepository;
|
|
|
|
|
private readonly SqlSugarRepository<TaskBCInfo> _taskBCInfoRepository;
|
|
|
|
|
|
|
|
|
|
private readonly SqlSugarRepository<TaskBCCTNInfo> _taskBCCTNInfoRepository;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private readonly SqlSugarRepository<BookingOrder> _bookingOrderRepository;
|
|
|
|
|
private readonly SqlSugarRepository<BookingCtn> _bookingOrderContaRepository;
|
|
|
|
@ -139,6 +142,7 @@ namespace Myshipping.Application
|
|
|
|
|
SqlSugarRepository<TaskTruckInfo> taskTruckInfoRepository,
|
|
|
|
|
SqlSugarRepository<TaskTruckCtn> taskTruckCtnRepository,
|
|
|
|
|
SqlSugarRepository<TaskBCInfo> taskBCInfoRepository,
|
|
|
|
|
SqlSugarRepository<TaskBCCTNInfo> taskBCCTNInfoRepository,
|
|
|
|
|
INamedServiceProvider<IBookingOrderService> namedBookingOrderServiceProvider,
|
|
|
|
|
IDjyWebsiteAccountConfigService webAccountConfig,
|
|
|
|
|
ISysCacheService cache,
|
|
|
|
@ -169,6 +173,7 @@ namespace Myshipping.Application
|
|
|
|
|
_taskTruckInfoRepository = taskTruckInfoRepository;
|
|
|
|
|
_taskTruckCtnRepository = taskTruckCtnRepository;
|
|
|
|
|
_taskBCInfoRepository = taskBCInfoRepository;
|
|
|
|
|
_taskBCCTNInfoRepository = taskBCCTNInfoRepository;
|
|
|
|
|
|
|
|
|
|
_namedBookingOrderServiceProvider = namedBookingOrderServiceProvider;
|
|
|
|
|
|
|
|
|
@ -215,9 +220,10 @@ namespace Myshipping.Application
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="info">任务详情</param>
|
|
|
|
|
/// <param name="batchNo">批次号</param>
|
|
|
|
|
/// <param name="file">文件</param>
|
|
|
|
|
/// <returns>返回回执</returns>
|
|
|
|
|
[SqlSugarUnitOfWork]
|
|
|
|
|
private async Task<TaskManageOrderResultDto> InitTaskJob(TaskManageOrderMessageInfo info,string batchNo)
|
|
|
|
|
private async Task<TaskManageOrderResultDto> InitTaskJob(TaskManageOrderMessageInfo info,string batchNo, IFormFile file = null)
|
|
|
|
|
{
|
|
|
|
|
TaskManageOrderResultDto result = new TaskManageOrderResultDto();
|
|
|
|
|
|
|
|
|
@ -238,7 +244,6 @@ namespace Myshipping.Application
|
|
|
|
|
|
|
|
|
|
throw Oops.Oh($"状态已存在,不能重复创建任务");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
taskInfo = new TaskBaseInfo
|
|
|
|
|
{
|
|
|
|
@ -276,7 +281,23 @@ namespace Myshipping.Application
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UserTendDto userTendInfo = GetUserTendInfo(info.Main.RecvUserId);
|
|
|
|
|
UserTendDto userTendInfo = null;
|
|
|
|
|
|
|
|
|
|
//如果大简云用户ID不为空,接收人为空时,通过大简云用户ID关联订舱人ID
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(info.Main.DJYRecvUserId) && string.IsNullOrWhiteSpace(info.Main.TaskUserId))
|
|
|
|
|
{
|
|
|
|
|
userTendInfo = GetUserTendInfoByDJYUserId(info.Main.DJYRecvUserId, info.Main.DJYRecvUserEmail);
|
|
|
|
|
|
|
|
|
|
if(userTendInfo != null)
|
|
|
|
|
{
|
|
|
|
|
taskInfo.IS_PUBLIC = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
userTendInfo = GetUserTendInfo(info.Main.RecvUserId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
taskInfo.CreatedUserId = userTendInfo.userId;
|
|
|
|
|
taskInfo.CreatedUserName = userTendInfo.userName;
|
|
|
|
@ -303,6 +324,30 @@ namespace Myshipping.Application
|
|
|
|
|
//新增
|
|
|
|
|
_taskBaseInfoRepository.Insert(taskInfo);
|
|
|
|
|
|
|
|
|
|
if (file != null)
|
|
|
|
|
{
|
|
|
|
|
var bytes = file.ToByteArray();
|
|
|
|
|
|
|
|
|
|
var fileFullName = await FileAttachHelper.SaveFile(taskInfo.PK_ID, bytes, batchNo, file.FileName,
|
|
|
|
|
GetFileType(file.FileName), "bcfiles");
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(fileFullName))
|
|
|
|
|
{
|
|
|
|
|
if (info.Main.FileList == null)
|
|
|
|
|
{
|
|
|
|
|
info.Main.FileList = new List<TaskManageOrderFileInfo>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
info.Main.FileList.Add(new TaskManageOrderFileInfo
|
|
|
|
|
{
|
|
|
|
|
PKId = IDGen.NextID().ToString(),
|
|
|
|
|
FileName = file.FileName,
|
|
|
|
|
FileType = Path.GetExtension(file.FileName).ToLower(),
|
|
|
|
|
FilePath = fileFullName
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region 附件
|
|
|
|
|
//附件
|
|
|
|
|
if (info.Main.FileList != null && info.Main.FileList.Count > 0)
|
|
|
|
@ -548,6 +593,46 @@ namespace Myshipping.Application
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region BC 任务
|
|
|
|
|
if (info.Main.TaskType == TaskBaseTypeEnum.BC)
|
|
|
|
|
{
|
|
|
|
|
//异步写入
|
|
|
|
|
var bcInfo = info.Main.BCInfo.Adapt<TaskBCInfo>();
|
|
|
|
|
|
|
|
|
|
bcInfo.PK_ID = IDGen.NextID().ToString();
|
|
|
|
|
bcInfo.TASK_ID = taskInfo.PK_ID;
|
|
|
|
|
|
|
|
|
|
bcInfo.CreatedTime = taskInfo.CreatedTime;
|
|
|
|
|
bcInfo.UpdatedTime = taskInfo.CreatedTime;
|
|
|
|
|
|
|
|
|
|
bcInfo.CreatedUserId = taskInfo.CreatedUserId;
|
|
|
|
|
bcInfo.CreatedUserName = taskInfo.CreatedUserName;
|
|
|
|
|
bcInfo.TenantId = taskInfo.TenantId;
|
|
|
|
|
bcInfo.TenantName = taskInfo.TenantName;
|
|
|
|
|
|
|
|
|
|
await _taskBCInfoRepository.InsertAsync(bcInfo);
|
|
|
|
|
|
|
|
|
|
//异步写入集装箱
|
|
|
|
|
info.Main.BCInfo.CtnList.ForEach(async ctn =>
|
|
|
|
|
{
|
|
|
|
|
var bcCtnInfo = ctn.Adapt<TaskBCCTNInfo>();
|
|
|
|
|
|
|
|
|
|
bcCtnInfo.PK_ID = IDGen.NextID().ToString();
|
|
|
|
|
bcCtnInfo.P_ID = bcInfo.PK_ID;
|
|
|
|
|
|
|
|
|
|
bcInfo.CreatedTime = taskInfo.CreatedTime;
|
|
|
|
|
bcInfo.UpdatedTime = taskInfo.CreatedTime;
|
|
|
|
|
|
|
|
|
|
bcInfo.CreatedUserId = taskInfo.CreatedUserId;
|
|
|
|
|
bcInfo.CreatedUserName = taskInfo.CreatedUserName;
|
|
|
|
|
bcInfo.TenantId = taskInfo.TenantId;
|
|
|
|
|
bcInfo.TenantName = taskInfo.TenantName;
|
|
|
|
|
|
|
|
|
|
await _taskBCCTNInfoRepository.InsertAsync(bcCtnInfo);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
if (info.Main.SerialMsgInfo != null)
|
|
|
|
|
{
|
|
|
|
|
var storeInfo = new TaskStoreMsgInfo
|
|
|
|
@ -584,11 +669,12 @@ namespace Myshipping.Application
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 查询订舱表查询用户和租户信息
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 查询订舱表查询用户和租户信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="userId"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
/// <param name="userId">用户ID</param>
|
|
|
|
|
/// <returns>返回用户和租户信息</returns>
|
|
|
|
|
private UserTendDto GetUserTendInfo(string userId)
|
|
|
|
|
{
|
|
|
|
|
UserTendDto userTendDto = null;
|
|
|
|
@ -612,6 +698,40 @@ namespace Myshipping.Application
|
|
|
|
|
|
|
|
|
|
return userTendDto;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 查询订舱表查询用户和租户信息
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 查询订舱表查询用户和租户信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="djyUserId">大简云用户ID</param>
|
|
|
|
|
/// <param name="djyUserEmail">大简云用户邮箱</param>
|
|
|
|
|
/// <returns>返回用户和租户信息</returns>
|
|
|
|
|
private UserTendDto GetUserTendInfoByDJYUserId(string djyUserId,string djyUserEmail)
|
|
|
|
|
{
|
|
|
|
|
UserTendDto userTendDto = null;
|
|
|
|
|
|
|
|
|
|
//这里因为接口是不做授权验证的,所以这里直接写的动态sql提取了用户和租户信息
|
|
|
|
|
var userTendInfo = _sysUserRepository.EntityContext.Queryable<dynamic>("user").AS("sys_user")
|
|
|
|
|
.AddJoinInfo("sys_tenant", "ten", "user.TenantId=ten.Id")
|
|
|
|
|
.Where("user.DjyUserId=@id and user.Email like '%"+ djyUserEmail + "%'", new { id = djyUserId})
|
|
|
|
|
.Select("user.Id as UserId,user.Name as UserName,ten.Id as TendId,ten.Name as TendName").First();
|
|
|
|
|
|
|
|
|
|
if (userTendInfo == null || userTendInfo.TendId == null)
|
|
|
|
|
throw Oops.Oh("当前用户详情获取失败,请确认{0}赋值是否准确", nameof(TaskManageOrderMessageInfo.Main.TaskUserId));
|
|
|
|
|
|
|
|
|
|
userTendDto = new UserTendDto
|
|
|
|
|
{
|
|
|
|
|
userId = long.Parse(userTendInfo.UserId.ToString()),
|
|
|
|
|
userName = userTendInfo.UserName.ToString(),
|
|
|
|
|
tendId = long.Parse(userTendInfo.TendId.ToString()),
|
|
|
|
|
tenantName = userTendInfo.TendName.ToString()
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return userTendDto;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 获取查询参数
|
|
|
|
|
/// <summary>
|
|
|
|
@ -751,7 +871,7 @@ namespace Myshipping.Application
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (nextList.Count > 0)
|
|
|
|
|
resultInfo.LevelNext = nextList.OrderBy(t => t.SortNo).ToList();
|
|
|
|
|
resultInfo.LevelNext.AddRange(nextList.OrderBy(t => t.SortNo).ToList());
|
|
|
|
|
|
|
|
|
|
exceptList.GroupBy(t => new { t.Status, t.TaskType })
|
|
|
|
|
.Select(t => new { Key = t.Key, Total = t.ToList().Sum(p => p.Total) })
|
|
|
|
@ -806,7 +926,7 @@ namespace Myshipping.Application
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (nextList.Count > 0)
|
|
|
|
|
resultInfo.LevelNext = nextList.OrderBy(t => t.SortNo).ToList();
|
|
|
|
|
resultInfo.LevelNext.AddRange(nextList.OrderBy(t => t.SortNo).ToList());
|
|
|
|
|
|
|
|
|
|
personList.GroupBy(t => new { t.Status, t.TaskType })
|
|
|
|
|
.Select(t => new { Key = t.Key, Total = t.ToList().Sum(p => p.Total) })
|
|
|
|
@ -862,7 +982,7 @@ namespace Myshipping.Application
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (nextList.Count > 0)
|
|
|
|
|
resultInfo.LevelNext = nextList.OrderBy(t => t.SortNo).ToList();
|
|
|
|
|
resultInfo.LevelNext.AddRange(nextList.OrderBy(t => t.SortNo).ToList());
|
|
|
|
|
|
|
|
|
|
publicList.GroupBy(t => new { t.Status, t.TaskType })
|
|
|
|
|
.Select(t => new { Key = t.Key, Total = t.ToList().Sum(p => p.Total) })
|
|
|
|
@ -4806,6 +4926,75 @@ namespace Myshipping.Application
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region 创建BC任务
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 创建BC任务
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="file">文件</param>
|
|
|
|
|
/// <param name="jsonData">BC任务详情JSON</param>
|
|
|
|
|
/// <returns>返回回执</returns>
|
|
|
|
|
[AllowAnonymous, HttpPost("/TaskManage/CreateBCTaskJob")]
|
|
|
|
|
public async Task<TaskManageOrderResultDto> CreateBCTaskJob(IFormFile file, [FromForm] string jsonData)
|
|
|
|
|
{
|
|
|
|
|
TaskManageOrderResultDto result = new TaskManageOrderResultDto();
|
|
|
|
|
|
|
|
|
|
string batchNo = IDGen.NextID().ToString();
|
|
|
|
|
|
|
|
|
|
_logger.LogInformation("批次={no} 接收到创建任务报文 报文={msg}", batchNo, jsonData);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
TaskManageOrderMessageInfo info = JSON.Deserialize<TaskManageOrderMessageInfo>(jsonData);
|
|
|
|
|
|
|
|
|
|
if(info == null)
|
|
|
|
|
throw Oops.Bah("jsonData请求内容错误,无法反序列化报文");
|
|
|
|
|
|
|
|
|
|
result = await InitTaskJob(info, batchNo, file);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
result.succ = false;
|
|
|
|
|
result.msg = $"请求任务异常,{ex.Message}";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 获取文件类型
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取文件类型
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="fileName">文件完成路径</param>
|
|
|
|
|
/// <returns>返回文件类型枚举</returns>
|
|
|
|
|
private PrintFileTypeEnum GetFileType(string fileName)
|
|
|
|
|
{
|
|
|
|
|
PrintFileTypeEnum fileType = PrintFileTypeEnum.PDF;
|
|
|
|
|
|
|
|
|
|
switch (Path.GetExtension(fileName).ToLower())
|
|
|
|
|
{
|
|
|
|
|
case ".pdf":
|
|
|
|
|
fileType = PrintFileTypeEnum.PDF;
|
|
|
|
|
break;
|
|
|
|
|
case ".xlsx":
|
|
|
|
|
fileType = PrintFileTypeEnum.XLSX;
|
|
|
|
|
break;
|
|
|
|
|
case ".docx":
|
|
|
|
|
fileType = PrintFileTypeEnum.DOCX;
|
|
|
|
|
break;
|
|
|
|
|
case ".xls":
|
|
|
|
|
fileType = PrintFileTypeEnum.XLS;
|
|
|
|
|
break;
|
|
|
|
|
case ".doc":
|
|
|
|
|
fileType = PrintFileTypeEnum.DOC;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return fileType;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region 样本业务提取帮助类
|
|
|
|
|