|
|
|
@ -11,8 +11,10 @@ using Microsoft.Extensions.Options;
|
|
|
|
|
using Myshipping.Application.ConfigOption;
|
|
|
|
|
using Myshipping.Application.Entity;
|
|
|
|
|
using Myshipping.Core;
|
|
|
|
|
using Myshipping.Core.Entity;
|
|
|
|
|
using Myshipping.Core.Service;
|
|
|
|
|
using Org.BouncyCastle.Crypto;
|
|
|
|
|
using SqlSugar;
|
|
|
|
|
using StackExchange.Profiling.Internal;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
@ -25,6 +27,7 @@ using System.Runtime.InteropServices;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Text.Json;
|
|
|
|
|
using System.Text.RegularExpressions;
|
|
|
|
|
using System.Threading;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Yitter.IdGenerator;
|
|
|
|
|
|
|
|
|
@ -37,10 +40,12 @@ namespace Myshipping.Application
|
|
|
|
|
public class BookingValueAddedService : IBookingValueAddedService, IDynamicApiController, ITransient
|
|
|
|
|
{
|
|
|
|
|
private readonly ISysCacheService _cache;
|
|
|
|
|
private readonly IDjyWebsiteAccountConfigService _webAccountConfig;
|
|
|
|
|
//private readonly IDjyWebsiteAccountConfigService _webAccountConfig;
|
|
|
|
|
private readonly ILogger<BookingTruckService> _logger;
|
|
|
|
|
private readonly SqlSugarRepository<BookingOrder> _bookingOrderRepository;
|
|
|
|
|
private readonly SqlSugarRepository<BookingFile> _bookingfile;
|
|
|
|
|
private readonly SqlSugarRepository<DjyWebsiteAccountConfig> _djyWebsiteAccountConfigRepository;
|
|
|
|
|
private readonly SqlSugarRepository<SysUser> _sysUserRepository;
|
|
|
|
|
|
|
|
|
|
const string CONST_MAPPING_BC_MODULE_ROUTE = "BC_DOWN_RT";
|
|
|
|
|
const string CONST_MAPPING_DRAFT_MODULE_ROUTE = "DRAFT_DOWN_RT";
|
|
|
|
@ -54,7 +59,7 @@ namespace Myshipping.Application
|
|
|
|
|
|
|
|
|
|
public BookingValueAddedService(ISysCacheService cache, ILogger<BookingTruckService> logger,
|
|
|
|
|
SqlSugarRepository<BookingOrder> bookingOrderRepository, SqlSugarRepository<BookingFile> bookingfile,
|
|
|
|
|
IDjyWebsiteAccountConfigService webAccountConfig)
|
|
|
|
|
SqlSugarRepository<DjyWebsiteAccountConfig> djyWebsiteAccountConfigRepository, SqlSugarRepository<SysUser> sysUserRepository)
|
|
|
|
|
{
|
|
|
|
|
_cache = cache;
|
|
|
|
|
_logger = logger;
|
|
|
|
@ -62,7 +67,8 @@ namespace Myshipping.Application
|
|
|
|
|
_bookingOrderRepository = bookingOrderRepository;
|
|
|
|
|
_bookingfile = bookingfile;
|
|
|
|
|
|
|
|
|
|
_webAccountConfig = webAccountConfig;
|
|
|
|
|
_djyWebsiteAccountConfigRepository = djyWebsiteAccountConfigRepository;
|
|
|
|
|
_sysUserRepository = sysUserRepository;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -128,14 +134,21 @@ namespace Myshipping.Application
|
|
|
|
|
var fail = downResultList.Count(x => !x.succ);
|
|
|
|
|
|
|
|
|
|
if (succ > 0)
|
|
|
|
|
{
|
|
|
|
|
result.batchTotal = succ.ToString();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
result.batchTotal = "- ";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(fail > 0)
|
|
|
|
|
{
|
|
|
|
|
if (succ > 0)
|
|
|
|
|
result.batchTotal = result.batchTotal+"/"+ fail.ToString();
|
|
|
|
|
|
|
|
|
|
result.batchTotal = "/" + fail.ToString();
|
|
|
|
|
result.batchTotal += "/" + fail.ToString();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
result.batchTotal += " -";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
@ -218,7 +231,7 @@ namespace Myshipping.Application
|
|
|
|
|
string webKey = string.Format(CONST_FORMAT_WEB, bcOrDraftRouteCfg.MapCode);
|
|
|
|
|
|
|
|
|
|
//获取个人对应的账户,这里GetAccountConfig逻辑优先取个人,个人没有配置取公司对应配置
|
|
|
|
|
var userWebAccountConfig = _webAccountConfig.GetAccountConfig(webKey, UserManager.UserId).GetAwaiter()
|
|
|
|
|
var userWebAccountConfig = GetAccountConfig(webKey, UserManager.UserId,UserManager.TENANT_ID).GetAwaiter()
|
|
|
|
|
.GetResult();
|
|
|
|
|
|
|
|
|
|
_logger.LogInformation("批次={no} 获取获取网站的账户完成,result={Num}", batchNo, JSON.Serialize(userWebAccountConfig));
|
|
|
|
@ -302,7 +315,7 @@ namespace Myshipping.Application
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//这里先写入附件表
|
|
|
|
|
await SaveEDIFile(bookingOrder.Id, bookFilePath, new System.IO.FileInfo(currFilePath).Name,
|
|
|
|
|
await SaveEDIFile(bookingOrder.Id, bookFilePath, new System.IO.FileInfo(currFilePath).Name,
|
|
|
|
|
fileTypeCode, fileTypeName);
|
|
|
|
|
|
|
|
|
|
result.succ = true;
|
|
|
|
@ -416,14 +429,21 @@ namespace Myshipping.Application
|
|
|
|
|
var fail = downResultList.Count(x => !x.succ);
|
|
|
|
|
|
|
|
|
|
if (succ > 0)
|
|
|
|
|
{
|
|
|
|
|
result.batchTotal = succ.ToString();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
result.batchTotal = "- ";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (fail > 0)
|
|
|
|
|
{
|
|
|
|
|
if (succ > 0)
|
|
|
|
|
result.batchTotal = result.batchTotal + "/" + fail.ToString();
|
|
|
|
|
|
|
|
|
|
result.batchTotal = "/" + fail.ToString();
|
|
|
|
|
result.batchTotal += "/" + fail.ToString();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
result.batchTotal += " -";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
@ -525,7 +545,7 @@ namespace Myshipping.Application
|
|
|
|
|
string webKey = string.Format(CONST_FORMAT_WEB, bcOrDraftRouteCfg.MapCode);
|
|
|
|
|
|
|
|
|
|
//获取个人对应的账户,这里GetAccountConfig逻辑优先取个人,个人没有配置取公司对应配置
|
|
|
|
|
var userWebAccountConfig = _webAccountConfig.GetAccountConfig(webKey, UserManager.UserId).GetAwaiter()
|
|
|
|
|
var userWebAccountConfig = GetAccountConfig(webKey, UserManager.UserId, UserManager.TENANT_ID).GetAwaiter()
|
|
|
|
|
.GetResult();
|
|
|
|
|
|
|
|
|
|
_logger.LogInformation("批次={no} 获取获取网站的账户完成,result={Num}", batchNo, JSON.Serialize(userWebAccountConfig));
|
|
|
|
@ -698,7 +718,10 @@ namespace Myshipping.Application
|
|
|
|
|
{
|
|
|
|
|
_logger.LogInformation("批次={no} 对应请求报文 request={res}", batchNo, JSON.Serialize(info));
|
|
|
|
|
|
|
|
|
|
var res = await url.SetHttpMethod(HttpMethod.Post)
|
|
|
|
|
var res = await url.OnClientCreating(client => {
|
|
|
|
|
// client 为 HttpClient 对象
|
|
|
|
|
client.Timeout = TimeSpan.FromMinutes(15); // 设置超时时间 15分钟
|
|
|
|
|
}).SetHttpMethod(HttpMethod.Post)
|
|
|
|
|
.SetBody(JSON.Serialize(info), "application/json")
|
|
|
|
|
.SetContentEncoding(Encoding.UTF8)
|
|
|
|
|
.PostAsync();
|
|
|
|
@ -747,7 +770,10 @@ namespace Myshipping.Application
|
|
|
|
|
{
|
|
|
|
|
_logger.LogInformation("批次={no} 对应请求报文 request={res}", batchNo, JSON.Serialize(info));
|
|
|
|
|
|
|
|
|
|
var res = await url.SetHttpMethod(HttpMethod.Post)
|
|
|
|
|
var res = await url.OnClientCreating(client => {
|
|
|
|
|
// client 为 HttpClient 对象
|
|
|
|
|
client.Timeout = TimeSpan.FromMinutes(15); // 设置超时时间 15分钟
|
|
|
|
|
}).SetHttpMethod(HttpMethod.Post)
|
|
|
|
|
.SetBody(JSON.Serialize(info), "application/json")
|
|
|
|
|
.SetContentEncoding(Encoding.UTF8)
|
|
|
|
|
.PostAsync();
|
|
|
|
@ -936,14 +962,21 @@ namespace Myshipping.Application
|
|
|
|
|
var fail = downResultList.Count(x => !x.succ);
|
|
|
|
|
|
|
|
|
|
if (succ > 0)
|
|
|
|
|
{
|
|
|
|
|
result.batchTotal = succ.ToString();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
result.batchTotal = "- ";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (fail > 0)
|
|
|
|
|
{
|
|
|
|
|
if (succ > 0)
|
|
|
|
|
result.batchTotal = result.batchTotal + "/" + fail.ToString();
|
|
|
|
|
|
|
|
|
|
result.batchTotal = "/" + fail.ToString();
|
|
|
|
|
result.batchTotal += "/" + fail.ToString();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
result.batchTotal += " -";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
@ -1035,7 +1068,7 @@ namespace Myshipping.Application
|
|
|
|
|
string webKey = string.Format(CONST_FORMAT_WEB, bcOrDraftRouteCfg.MapCode);
|
|
|
|
|
|
|
|
|
|
//获取个人对应的账户,这里GetAccountConfig逻辑优先取个人,个人没有配置取公司对应配置
|
|
|
|
|
var userWebAccountConfig = _webAccountConfig.GetAccountConfig(webKey, UserManager.UserId).GetAwaiter()
|
|
|
|
|
var userWebAccountConfig = GetAccountConfig(webKey, UserManager.UserId, UserManager.TENANT_ID).GetAwaiter()
|
|
|
|
|
.GetResult();
|
|
|
|
|
|
|
|
|
|
_logger.LogInformation("批次={no} 获取获取网站的账户完成,result={Num}", batchNo, JSON.Serialize(userWebAccountConfig));
|
|
|
|
@ -1128,6 +1161,29 @@ namespace Myshipping.Application
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取个人或公司网站账户配置
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="typeCode">账户类型代码</param>
|
|
|
|
|
/// <param name="userId">用户ID</param>
|
|
|
|
|
/// <param name="tendId">租户ID</param>
|
|
|
|
|
/// <returns>返回账户配置</returns>
|
|
|
|
|
private async Task<DjyWebsiteAccountConfig> GetAccountConfig(string typeCode,long userId,long tendId)
|
|
|
|
|
{
|
|
|
|
|
DjyWebsiteAccountConfig accountConfig = new DjyWebsiteAccountConfig();
|
|
|
|
|
accountConfig = await _djyWebsiteAccountConfigRepository.EntityContext.CopyNew().Queryable<DjyWebsiteAccountConfig>()
|
|
|
|
|
.FirstAsync(x => x.TypeCode == typeCode && x.CreatedUserId == userId);
|
|
|
|
|
|
|
|
|
|
if (accountConfig == null)
|
|
|
|
|
{
|
|
|
|
|
accountConfig = await _djyWebsiteAccountConfigRepository.EntityContext.CopyNew().Queryable<DjyWebsiteAccountConfig>()
|
|
|
|
|
.FirstAsync(x => x.TypeCode == typeCode && x.TenantId == tendId && x.IsTenant == true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return accountConfig;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class DateTimeJsonConverter : System.Text.Json.Serialization.JsonConverter<DateTime>
|
|
|
|
|