我的任务-LARA纸

optimize
jianghaiqing 2 years ago
parent b28f238f1c
commit 65e3fbff00

@ -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; }
} }
} }

@ -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}");
TaskLARAPaperInfo taskLARAPaperInfo = new TaskLARAPaperInfo
{
PK_ID = IDGen.NextID().ToString(),
TASK_ID = taskBaseInfo.PK_ID,
BOOKING_ORDER_NO = "",
CreatedUserId = UserManager.UserId,
CreatedUserName = UserManager.Name,
STATUS = "temp",
IS_TIMEOUT = 0,
START_DATE = startDate,
TenantId = UserManager.TENANT_ID,
TenantName = UserManager.TENANT_NAME
};
//写入记录
_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", "" },
};
//请求 JObject jobjPost = new JObject();
var postResult = await InnerRemoteDownLaraPaper(batchNo, downloadUrl, formDict); jobjPost.Add("customer_user", "myshipping");
jobjPost.Add("customer_pwd", "");
JArray jarr = new JArray();
jobjPost.Add("lara_list", jarr);
//重新获取下载历史 laraPaperList.ForEach(async lara =>
var downloadHisInfo = _taskOriginalDownloadHisInfoRepository.AsQueryable() {
.First(t => t.PK_ID == taskLARAPaperInfo.PK_ID); TaskLARAPaperInfo taskLARAPaperInfo = new TaskLARAPaperInfo
{
PK_ID = IDGen.NextID().ToString(),
TASK_ID = lara.TaskId,
BOOKING_ORDER_NO = "",
CreatedUserId = UserManager.UserId,
CreatedUserName = UserManager.Name,
STATUS = "temp",
IS_TIMEOUT = 0,
START_DATE = DateTime.Now,
TenantId = UserManager.TENANT_ID,
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,
};
//更新任务状态 //写入记录
var taskModel = _taskBaseInfoRepository.AsQueryable().First(t => t.PK_ID == taskBaseInfo.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);
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) 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 else
{ {
if (postResult.isTimeout) result.succ = false;
{ result.msg = postResult.msg;
downloadHisInfo.STATUS = "timeout";
}
else
{
downloadHisInfo.STATUS = "failure";
}
} }
//更新下载历史
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