wet 2 years ago
commit 3fa158df78

@ -91,5 +91,10 @@ namespace Myshipping.Application
/// 状态 succ-成功 failure-失败 timeout-超时 /// 状态 succ-成功 failure-失败 timeout-超时
/// </summary> /// </summary>
public string STATUS { get; set; } public string STATUS { get; set; }
/// <summary>
/// 提单纸页数
/// </summary>
public int DRAFT_NUM { get; set; }
} }
} }

@ -357,6 +357,26 @@ namespace Myshipping.Application
.Map(dest => dest.UpdatedUserName, src => src.UpdatedUserName); .Map(dest => dest.UpdatedUserName, src => src.UpdatedUserName);
config.ForType<LaraPaperRecordDto, TaskLARAPaperInfo>()
.Map(dest => dest.PK_ID, src => src.PKId)
.Map(dest => dest.TASK_ID, src => src.TaskId)
.Map(dest => dest.NUMBER_FROM, src => src.NumberFrom)
.Map(dest => dest.NUMBER_TO, src => src.NumberTo)
.Map(dest => dest.PAGE_NUMBERS, src => src.PageNumbers)
.Map(dest => dest.PAGE_SUM, src => src.PageSum)
.Map(dest => dest.MBL_NO, src => src.MBLNo)
.Map(dest => dest.ORIGINAL_DOWN_TIME, src => src.OriginalDownTime)
.Map(dest => dest.ISSUE_TYPE, src => src.IssueType)
.Map(dest => dest.ISSUE_TYPE_NAME, src => src.IssueTypeName)
.Map(dest => dest.CreatedTime, src => src.CreatedTime)
.Map(dest => dest.UpdatedTime, src => src.UpdatedTime)
.Map(dest => dest.RESULT_NOTE, src => src.ResultNote)
.Map(dest => dest.CreatedUserId, src => src.CreatedUserId)
.Map(dest => dest.CreatedUserName, src => src.CreatedUserName)
.Map(dest => dest.UpdatedUserId, src => src.UpdatedUserId)
.Map(dest => dest.UpdatedUserName, src => src.UpdatedUserName);
config.ForType<TaskSIFeedBackInfo, TaskSIFeedBackResultBusiDto>() config.ForType<TaskSIFeedBackInfo, TaskSIFeedBackResultBusiDto>()
.Map(dest => dest.Shipper, src => src.SHIPPER) .Map(dest => dest.Shipper, src => src.SHIPPER)
.Map(dest => dest.Consignee, src => src.CONSIGNEE) .Map(dest => dest.Consignee, src => src.CONSIGNEE)

@ -93,10 +93,9 @@ namespace Myshipping.Application
/// <summary> /// <summary>
/// 请求提单纸登记 /// 请求提单纸登记
/// </summary> /// </summary>
/// <param name="taskPKId">任务主键</param> /// <param name="laraPaperList">提单纸登记请求参数列表</param>
/// <param name="model">提单纸登记请求参数</param>
/// <returns>返回结果</returns> /// <returns>返回结果</returns>
Task<TaskManageOrderResultDto> LaraPaperRegistPost(string taskPKId, LaraPaperRegistPostDto model); Task<TaskManageOrderResultDto> LaraPaperRegistPost(List<LaraPaperRegistPostDto> laraPaperList);
/// <summary> /// <summary>
/// 下载任务附件 /// 下载任务附件

@ -59,6 +59,7 @@ using System.Text.RegularExpressions;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Xml.Linq; using System.Xml.Linq;
using static Aliyun.OSS.Model.CreateSelectObjectMetaInputFormatModel; using static Aliyun.OSS.Model.CreateSelectObjectMetaInputFormatModel;
using static Aliyun.OSS.Model.ListPartsResult;
namespace Myshipping.Application namespace Myshipping.Application
{ {
@ -1368,17 +1369,16 @@ namespace Myshipping.Application
/// <summary> /// <summary>
/// 请求提单纸登记 /// 请求提单纸登记
/// </summary> /// </summary>
/// <param name="taskPKId">任务主键</param> /// <param name="laraPaperList">提单纸登记请求参数列表</param>
/// <param name="model">提单纸登记请求参数</param> /// <returns>返回结果</returns>
/// <returns></returns>
[HttpPost("/TaskManage/LaraPaperRegistPost")] [HttpPost("/TaskManage/LaraPaperRegistPost")]
public async Task<TaskManageOrderResultDto> LaraPaperRegistPost(string taskPKId, LaraPaperRegistPostDto model) public async Task<TaskManageOrderResultDto> LaraPaperRegistPost(List<LaraPaperRegistPostDto> laraPaperList)
{ {
TaskManageOrderResultDto result = new TaskManageOrderResultDto(); TaskManageOrderResultDto result = new TaskManageOrderResultDto();
string batchNo = IDGen.NextID().ToString(); string batchNo = IDGen.NextID().ToString();
_logger.LogInformation("批次={no} id={id} LARA提单纸登记开始", batchNo, taskPKId); _logger.LogInformation("批次={no} num={num} LARA提单纸登记开始", batchNo, laraPaperList.Count);
/* /*
1LARA 1LARA
@ -1392,7 +1392,10 @@ namespace Myshipping.Application
try try
{ {
var taskInfo = _taskBaseInfoRepository.AsQueryable().First(t => t.PK_ID == taskPKId); var taskArg = laraPaperList.Select(t => t.TaskId).Distinct().ToArray();
var taskList = _taskBaseInfoRepository.AsQueryable().Where(t => taskArg.Contains(t.PK_ID)).ToList();
_logger.LogInformation("批次={no} 获取任务完成", batchNo); _logger.LogInformation("批次={no} 获取任务完成", batchNo);
@ -1404,130 +1407,84 @@ namespace Myshipping.Application
if (userWebAccountConfig == null) if (userWebAccountConfig == null)
throw Oops.Bah($"个人/公司网站【{CONST_WEB_LARA_ACCOUNT_TYPE}】获取失败,请维护个人/公司网站账户信息"); throw Oops.Bah($"个人/公司网站【{CONST_WEB_LARA_ACCOUNT_TYPE}】获取失败,请维护个人/公司网站账户信息");
await InnerDownloadOriginalTask(batchNo, taskInfo, userWebAccountConfig);
}
catch (Exception ex)
{
throw Oops.Bah("请求提单纸登记异常,{0}", ex.Message);
}
return result;
}
#endregion
//LaraPaperPostUrl
private async Task<TaskManageOrderResultDto> InnerLaraPaperRegistPost(string batchNo, TaskBaseInfo taskBaseInfo, LaraPaperRegistPostDto model,
DjyWebsiteAccountConfig webAccountConfig)
{
TaskManageOrderResultDto result = new TaskManageOrderResultDto();
//正本下载URL
string originalUrl = string.Empty;
try
{
DateTime startDate = DateTime.Now;
var downloadUrl = _cache.GetAllDictData().GetAwaiter().GetResult() var downloadUrl = _cache.GetAllDictData().GetAwaiter().GetResult()
.First(t => t.Code.Equals(CONST_LARA_DOWN_URL_CODE, StringComparison.OrdinalIgnoreCase))?.Value; .First(t => t.Code.Equals(CONST_LARA_DOWN_URL_CODE, StringComparison.OrdinalIgnoreCase))?.Value;
if (string.IsNullOrWhiteSpace(downloadUrl)) if (string.IsNullOrWhiteSpace(downloadUrl))
throw Oops.Bah($"正本下载URL不存在请确认字典是否配置 code={CONST_BOOK_ORIGINAL_DOWN_URL_CODE}"); throw Oops.Bah($"LARA纸下载URL不存在请确认字典是否配置 code={CONST_LARA_DOWN_URL_CODE}");
JObject jobjPost = new JObject();
jobjPost.Add("customer_user", "myshipping");
jobjPost.Add("customer_pwd", "");
JArray jarr = new JArray();
jobjPost.Add("lara_list", jarr);
laraPaperList.ForEach(async lara =>
{
TaskLARAPaperInfo taskLARAPaperInfo = new TaskLARAPaperInfo TaskLARAPaperInfo taskLARAPaperInfo = new TaskLARAPaperInfo
{ {
PK_ID = IDGen.NextID().ToString(), PK_ID = IDGen.NextID().ToString(),
TASK_ID = taskBaseInfo.PK_ID, TASK_ID = lara.TaskId,
BOOKING_ORDER_NO = "", BOOKING_ORDER_NO = "",
CreatedUserId = UserManager.UserId, CreatedUserId = UserManager.UserId,
CreatedUserName = UserManager.Name, CreatedUserName = UserManager.Name,
STATUS = "temp", STATUS = "temp",
IS_TIMEOUT = 0, IS_TIMEOUT = 0,
START_DATE = startDate, START_DATE = DateTime.Now,
TenantId = UserManager.TENANT_ID, TenantId = UserManager.TENANT_ID,
TenantName = UserManager.TENANT_NAME TenantName = UserManager.TENANT_NAME,
PAGE_NUMBERS = lara.PageNumbers,
PAGE_SUM = lara.PageSum,
ISSUE_TYPE = lara.ISSUETYPE,
MBL_NO = lara.MBLNO,
NUMBER_FROM = lara.NumberFrom,
NUMBER_TO = lara.NumberTo,
DRAFT_NUM = lara.DraftNum,
}; };
//写入记录 //写入记录
_taskLARAPaperInfoRepository.Insert(taskLARAPaperInfo); await _taskLARAPaperInfoRepository.InsertAsync(taskLARAPaperInfo);
//请求远程链接 JObject jobjItem = new JObject();
Dictionary<string, string> formDict = new Dictionary<string, string> { jobjItem.Add("customer_user", "myshipping");
{"bno", taskBaseInfo.MBL_NO }, jobjItem.Add("customer_pwd", "");
{"num_from", model.NumberFrom }, jobjItem.Add("web_user", userWebAccountConfig.Account);
{"num_to", model.NumberTo }, jobjItem.Add("web_pwd", userWebAccountConfig.Password);
{"numbers", model.PageNumbers }, jobjItem.Add("bno", lara.MBLNO);
{"vessel_code", "" }, jobjItem.Add("num_from", lara.NumberFrom);
{"voyage_code", "" }, jobjItem.Add("num_to", lara.NumberTo);
{"bl_status", "All" }, jobjItem.Add("numbers", lara.PageNumbers);
{"bl_type", "Original Bill" }, jobjItem.Add("vessel_code", "");
{"issue_code", "ALL" }, jobjItem.Add("voyage_code", "");
{"web_user", webAccountConfig.Account }, jobjItem.Add("bl_status", "All");
{"web_pwd", webAccountConfig.Password }, jobjItem.Add("bl_type", "Original Bill");
{"customer_user", "myshipping" }, jobjItem.Add("issue_code", "ALL");
{"customer_pwd", "" }, jarr.Add(jobjItem);
};
//请求
var postResult = await InnerRemoteDownLaraPaper(batchNo, downloadUrl, formDict);
//重新获取下载历史
var downloadHisInfo = _taskOriginalDownloadHisInfoRepository.AsQueryable()
.First(t => t.PK_ID == taskLARAPaperInfo.PK_ID);
//更新任务状态 });
var taskModel = _taskBaseInfoRepository.AsQueryable().First(t => t.PK_ID == taskBaseInfo.PK_ID); //await InnerDownloadOriginalTask(batchNo, taskInfo, userWebAccountConfig);
downloadHisInfo.END_DATE = (DateTime)postResult.ext;
downloadHisInfo.RESULT_NOTE = postResult.msg;
bool isDownSucc = false; var postResult = await InnerRemoteDownLaraPaper(batchNo, downloadUrl, JSON.Serialize(jobjPost));
//下载返回成功后,更新记录并生成扣费记录
if (postResult.succ) if (postResult.succ)
{ {
downloadHisInfo.STATUS = "succ"; result.succ = true;
downloadHisInfo.RESULT_URL = postResult.msg; result.msg = "成功";
taskModel.COMPLETE_DEAL = TaskCompleteDealEnum.MANUAL.ToString();
taskModel.COMPLETE_DEAL_NAME = TaskCompleteDealEnum.MANUAL.GetDescription();
taskModel.COMPLETE_DATE = DateTime.Now;
taskModel.STATUS = TaskStatusEnum.Complete.ToString();
taskModel.IS_COMPLETE = 1;
isDownSucc = true;
}
else
{
if (postResult.isTimeout)
{
downloadHisInfo.STATUS = "timeout";
} }
else else
{ {
downloadHisInfo.STATUS = "failure"; result.succ = false;
} result.msg = postResult.msg;
} }
//更新下载历史
await _taskOriginalDownloadHisInfoRepository.AsUpdateable(downloadHisInfo).IgnoreColumns(it => new
{
it.TenantId,
it.CreatedUserId,
it.CreatedUserName
}).ExecuteCommandAsync();
} }
catch (Exception ex) catch (Exception ex)
{ {
result.succ = false; throw Oops.Bah("请求提单纸登记异常,{0}", ex.Message);
result.msg = ex.Message;
} }
return result; return result;
} }
#endregion
#region 远程请求请求提单纸登记 #region 远程请求请求提单纸登记
/// <summary> /// <summary>
@ -1535,9 +1492,9 @@ namespace Myshipping.Application
/// </summary> /// </summary>
/// <param name="batchNo">批次号</param> /// <param name="batchNo">批次号</param>
/// <param name="url">请求URL</param> /// <param name="url">请求URL</param>
/// <param name="dic">请求参数</param> /// <param name="jsonMsg">请求参数</param>
/// <returns></returns> /// <returns></returns>
private async Task<TaskManageOrderResultDto> InnerRemoteDownLaraPaper(string batchNo, string url, Dictionary<string, string> dic) private async Task<TaskManageOrderResultDto> InnerRemoteDownLaraPaper(string batchNo, string url, string jsonMsg)
{ {
var result = new TaskManageOrderResultDto(); var result = new TaskManageOrderResultDto();
@ -1548,7 +1505,7 @@ namespace Myshipping.Application
_logger.LogInformation("批次={no} 请求报文开始", batchNo); _logger.LogInformation("批次={no} 请求报文开始", batchNo);
var res = await url.SetHttpMethod(HttpMethod.Post) var res = await url.SetHttpMethod(HttpMethod.Post)
.SetBody(dic, "application/x-www-form-urlencoded") .SetBody(jsonMsg, "application/json")
.SetContentEncoding(Encoding.UTF8) .SetContentEncoding(Encoding.UTF8)
.PostAsync(); .PostAsync();
@ -1597,7 +1554,7 @@ namespace Myshipping.Application
/// <param name="PKIds">任务主键数组</param> /// <param name="PKIds">任务主键数组</param>
/// <returns>返回结果</returns> /// <returns>返回结果</returns>
[HttpPost("/TaskManage/LaraPaperRegist")] [HttpPost("/TaskManage/LaraPaperRegist")]
public async Task<LaraPaperRegistDto> LaraPaperRegist(string[] PKIds) public async Task<LaraPaperRegistDto> LaraPaperRegist([FromQuery]string[] PKIds)
{ {
LaraPaperRegistDto result = new LaraPaperRegistDto(); LaraPaperRegistDto result = new LaraPaperRegistDto();

Loading…
Cancel
Save