wet 2 years ago
commit 3fa158df78

@ -91,5 +91,10 @@ namespace Myshipping.Application
/// 状态 succ-成功 failure-失败 timeout-超时
/// </summary>
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);
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>()
.Map(dest => dest.Shipper, src => src.SHIPPER)
.Map(dest => dest.Consignee, src => src.CONSIGNEE)

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

@ -59,6 +59,7 @@ using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Xml.Linq;
using static Aliyun.OSS.Model.CreateSelectObjectMetaInputFormatModel;
using static Aliyun.OSS.Model.ListPartsResult;
namespace Myshipping.Application
{
@ -1368,17 +1369,16 @@ namespace Myshipping.Application
/// <summary>
/// 请求提单纸登记
/// </summary>
/// <param name="taskPKId">任务主键</param>
/// <param name="model">提单纸登记请求参数</param>
/// <returns></returns>
/// <param name="laraPaperList">提单纸登记请求参数列表</param>
/// <returns>返回结果</returns>
[HttpPost("/TaskManage/LaraPaperRegistPost")]
public async Task<TaskManageOrderResultDto> LaraPaperRegistPost(string taskPKId, LaraPaperRegistPostDto model)
public async Task<TaskManageOrderResultDto> LaraPaperRegistPost(List<LaraPaperRegistPostDto> laraPaperList)
{
TaskManageOrderResultDto result = new TaskManageOrderResultDto();
string batchNo = IDGen.NextID().ToString();
_logger.LogInformation("批次={no} id={id} LARA提单纸登记开始", batchNo, taskPKId);
_logger.LogInformation("批次={no} num={num} LARA提单纸登记开始", batchNo, laraPaperList.Count);
/*
1LARA
@ -1392,7 +1392,10 @@ namespace Myshipping.Application
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);
@ -1404,130 +1407,84 @@ namespace Myshipping.Application
if (userWebAccountConfig == null)
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()
.First(t => t.Code.Equals(CONST_LARA_DOWN_URL_CODE, StringComparison.OrdinalIgnoreCase))?.Value;
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
{
PK_ID = IDGen.NextID().ToString(),
TASK_ID = taskBaseInfo.PK_ID,
TASK_ID = lara.TaskId,
BOOKING_ORDER_NO = "",
CreatedUserId = UserManager.UserId,
CreatedUserName = UserManager.Name,
STATUS = "temp",
IS_TIMEOUT = 0,
START_DATE = startDate,
START_DATE = DateTime.Now,
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);
//请求远程链接
Dictionary<string, string> formDict = new Dictionary<string, string> {
{"bno", taskBaseInfo.MBL_NO },
{"num_from", model.NumberFrom },
{"num_to", model.NumberTo },
{"numbers", model.PageNumbers },
{"vessel_code", "" },
{"voyage_code", "" },
{"bl_status", "All" },
{"bl_type", "Original Bill" },
{"issue_code", "ALL" },
{"web_user", webAccountConfig.Account },
{"web_pwd", webAccountConfig.Password },
{"customer_user", "myshipping" },
{"customer_pwd", "" },
};
//请求
var postResult = await InnerRemoteDownLaraPaper(batchNo, downloadUrl, formDict);
//重新获取下载历史
var downloadHisInfo = _taskOriginalDownloadHisInfoRepository.AsQueryable()
.First(t => t.PK_ID == taskLARAPaperInfo.PK_ID);
await _taskLARAPaperInfoRepository.InsertAsync(taskLARAPaperInfo);
JObject jobjItem = new JObject();
jobjItem.Add("customer_user", "myshipping");
jobjItem.Add("customer_pwd", "");
jobjItem.Add("web_user", userWebAccountConfig.Account);
jobjItem.Add("web_pwd", userWebAccountConfig.Password);
jobjItem.Add("bno", lara.MBLNO);
jobjItem.Add("num_from", lara.NumberFrom);
jobjItem.Add("num_to", lara.NumberTo);
jobjItem.Add("numbers", lara.PageNumbers);
jobjItem.Add("vessel_code", "");
jobjItem.Add("voyage_code", "");
jobjItem.Add("bl_status", "All");
jobjItem.Add("bl_type", "Original Bill");
jobjItem.Add("issue_code", "ALL");
jarr.Add(jobjItem);
//更新任务状态
var taskModel = _taskBaseInfoRepository.AsQueryable().First(t => t.PK_ID == taskBaseInfo.PK_ID);
downloadHisInfo.END_DATE = (DateTime)postResult.ext;
downloadHisInfo.RESULT_NOTE = postResult.msg;
});
//await InnerDownloadOriginalTask(batchNo, taskInfo, userWebAccountConfig);
bool isDownSucc = false;
var postResult = await InnerRemoteDownLaraPaper(batchNo, downloadUrl, JSON.Serialize(jobjPost));
//下载返回成功后,更新记录并生成扣费记录
if (postResult.succ)
{
downloadHisInfo.STATUS = "succ";
downloadHisInfo.RESULT_URL = postResult.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";
result.succ = true;
result.msg = "成功";
}
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)
{
result.succ = false;
result.msg = ex.Message;
throw Oops.Bah("请求提单纸登记异常,{0}", ex.Message);
}
return result;
}
#endregion
#region 远程请求请求提单纸登记
/// <summary>
@ -1535,9 +1492,9 @@ namespace Myshipping.Application
/// </summary>
/// <param name="batchNo">批次号</param>
/// <param name="url">请求URL</param>
/// <param name="dic">请求参数</param>
/// <param name="jsonMsg">请求参数</param>
/// <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();
@ -1548,7 +1505,7 @@ namespace Myshipping.Application
_logger.LogInformation("批次={no} 请求报文开始", batchNo);
var res = await url.SetHttpMethod(HttpMethod.Post)
.SetBody(dic, "application/x-www-form-urlencoded")
.SetBody(jsonMsg, "application/json")
.SetContentEncoding(Encoding.UTF8)
.PostAsync();
@ -1597,7 +1554,7 @@ namespace Myshipping.Application
/// <param name="PKIds">任务主键数组</param>
/// <returns>返回结果</returns>
[HttpPost("/TaskManage/LaraPaperRegist")]
public async Task<LaraPaperRegistDto> LaraPaperRegist(string[] PKIds)
public async Task<LaraPaperRegistDto> LaraPaperRegist([FromQuery]string[] PKIds)
{
LaraPaperRegistDto result = new LaraPaperRegistDto();

Loading…
Cancel
Save