|
|
@ -83,6 +83,7 @@ using Myshipping.Application.EDI.VOLTA;
|
|
|
|
using TinyPinyin;
|
|
|
|
using TinyPinyin;
|
|
|
|
using Furion.EventBus;
|
|
|
|
using Furion.EventBus;
|
|
|
|
using Myshipping.Application.Service.BookingSlot.Dto;
|
|
|
|
using Myshipping.Application.Service.BookingSlot.Dto;
|
|
|
|
|
|
|
|
using Myshipping.Application.Service.BookingOrder.Dto.MSKAPI;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Myshipping.Application
|
|
|
|
namespace Myshipping.Application
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -5084,8 +5085,10 @@ namespace Myshipping.Application
|
|
|
|
/// <param name="bookingId"></param>
|
|
|
|
/// <param name="bookingId"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpPost("/BookingOrder/VgmSend")]
|
|
|
|
[HttpPost("/BookingOrder/VgmSend")]
|
|
|
|
public async Task VgmSend(long bookingId)
|
|
|
|
public async Task<object> VgmSend(long bookingId)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
object result = null;
|
|
|
|
|
|
|
|
|
|
|
|
var order = _rep.FirstOrDefault(x => x.Id == bookingId);
|
|
|
|
var order = _rep.FirstOrDefault(x => x.Id == bookingId);
|
|
|
|
var ctns = _repCtn.Where(x => x.BILLID == bookingId).ToList();
|
|
|
|
var ctns = _repCtn.Where(x => x.BILLID == bookingId).ToList();
|
|
|
|
|
|
|
|
|
|
|
@ -5101,268 +5104,408 @@ namespace Myshipping.Application
|
|
|
|
throw Oops.Bah(BookingErrorCode.BOOK127);
|
|
|
|
throw Oops.Bah(BookingErrorCode.BOOK127);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var config = _cache.GetAllTenantParam().Result.FirstOrDefault(x => x.TenantId == UserManager.TENANT_ID && x.ParaCode == "VgmDirectSendCarrierId");
|
|
|
|
/* 1. 先通过 租户参数里的 支持API发送的船司列表 判断是否走API发送
|
|
|
|
if (config == null)
|
|
|
|
* 2. 如果不走API,再通过 租户参数里的 直发船司列表 判断走爬虫直发或大简云发送
|
|
|
|
{
|
|
|
|
*/
|
|
|
|
throw Oops.Bah("请配置租户的VGM直发船司参数");
|
|
|
|
|
|
|
|
}
|
|
|
|
var tenantParamList = _cache.GetAllTenantParam().Result;
|
|
|
|
|
|
|
|
|
|
|
|
var arrCarr = config.ItemCode.Split(",", StringSplitOptions.RemoveEmptyEntries);
|
|
|
|
var vgmApiSendCarrierIdStr = tenantParamList.FirstOrDefault(x => x.TenantId == UserManager.TENANT_ID && x.ParaCode == "VgmApiSendCarrierId");
|
|
|
|
if (!arrCarr.Contains(order.CARRIERID)) //使用大简云发送vgm
|
|
|
|
|
|
|
|
|
|
|
|
string[] vgmApiSendCarrierIdArr = vgmApiSendCarrierIdStr == null
|
|
|
|
|
|
|
|
? new string[0]
|
|
|
|
|
|
|
|
: vgmApiSendCarrierIdStr.ItemCode.Split(",");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// VGM发送方式1:通过API发送
|
|
|
|
|
|
|
|
if (vgmApiSendCarrierIdArr.Contains(order.CARRIERID))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
//ETD不能为空
|
|
|
|
try
|
|
|
|
if (!order.ETD.HasValue)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
throw Oops.Bah("ETD不能为空");
|
|
|
|
if (!order.CARRIERID.Equals("MSK", StringComparison.OrdinalIgnoreCase))
|
|
|
|
}
|
|
|
|
{
|
|
|
|
|
|
|
|
throw Oops.Bah($"[{order.CARRIERID}]船公司暂不支持通过API发送VGM");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//config1
|
|
|
|
|
|
|
|
string userKey = App.Configuration["MSKAPIDjyUserKey"];
|
|
|
|
|
|
|
|
string userSecret = App.Configuration["MSKAPIDjyUserSecret"];
|
|
|
|
|
|
|
|
string env = App.Configuration["MSKAPIOPEnvironment"];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrWhiteSpace(userKey) || string.IsNullOrWhiteSpace(userSecret) || string.IsNullOrWhiteSpace(env))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
throw Oops.Bah("通过MSKAPI发送VGM所需的Key或Secret或Environment未配置,请联系管理员");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//重量不能为空
|
|
|
|
// config2
|
|
|
|
if (!order.KGS.HasValue)
|
|
|
|
var webAccount = await _webAccountConfig.GetAccountConfig("MSKApi", UserManager.UserId) ?? throw Oops.Bah("未配置网站账户,类型:MSKApi");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// config3
|
|
|
|
|
|
|
|
var allSysConfig = await _cache.GetAllSysConfig();
|
|
|
|
|
|
|
|
var url = allSysConfig.FirstOrDefault(x => x.Code == "VgmSendMskApiUrl")?.Value;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrWhiteSpace(url))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
throw Oops.Bah("通过MSKAPI发送VGM所需的Url未配置,请联系管理员,配置名称:[VgmSendMskApiUrl]");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// config4
|
|
|
|
|
|
|
|
var vgmSendMskCustomerCode = tenantParamList.FirstOrDefault(x => x.TenantId == UserManager.TENANT_ID && x.ParaCode == "VgmSendMskCustomerCode")?.ItemCode;
|
|
|
|
|
|
|
|
if (string.IsNullOrWhiteSpace(vgmSendMskCustomerCode))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
throw Oops.Bah("通过MSKAPI发送VGM所需的[客户编号],请联系管理员,配置名称:[VgmSendMskCustomerCode]");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var param = new
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
userKey,
|
|
|
|
|
|
|
|
userSecret,
|
|
|
|
|
|
|
|
operatingEnvironment = env,
|
|
|
|
|
|
|
|
mskAppKey = webAccount.Account,
|
|
|
|
|
|
|
|
mskAppSecret = webAccount.Password,
|
|
|
|
|
|
|
|
shipmentNumber = order.MBLNO,
|
|
|
|
|
|
|
|
brandCode = "MAEU",
|
|
|
|
|
|
|
|
customerCode = vgmSendMskCustomerCode,
|
|
|
|
|
|
|
|
terminalCode = "",
|
|
|
|
|
|
|
|
containerList = new List<object>()
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
foreach (var ctn in ctns)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(ctn.CNTRNO)
|
|
|
|
|
|
|
|
|| !ctn.WEIGHKGS.HasValue
|
|
|
|
|
|
|
|
|| ctn.WEIGHKGS == 0
|
|
|
|
|
|
|
|
|| string.IsNullOrWhiteSpace(ctn.WEIGHTYPE))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
throw Oops.Bah("所有箱子的箱号、称重重量、称重方式都不能为空");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
var vgmMethod = ctn.WEIGHTYPE switch
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
"累加" => "CALCULATED",
|
|
|
|
|
|
|
|
"总重" => "SCALED",
|
|
|
|
|
|
|
|
_ => throw Oops.Bah($"箱号为[{ctn.CNTRNO}]的箱子称重方式非[累加]或[总重],请检查")
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
param.containerList.Add(new
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
containerNumber = ctn.CNTRNO,
|
|
|
|
|
|
|
|
vgmSource = "Shipper",
|
|
|
|
|
|
|
|
vgm = ctn.WEIGHKGS,
|
|
|
|
|
|
|
|
vgmUnit = "KGS",
|
|
|
|
|
|
|
|
vgmMethod,
|
|
|
|
|
|
|
|
authorizedPersonName = UserManager.Name,
|
|
|
|
|
|
|
|
authorizedPersonEmail = UserManager.Email
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_logger.LogInformation("通过MSKAPI发送VGM,单号:{mblno},入参:{param}", order.MBLNO, param.ToJson());
|
|
|
|
|
|
|
|
var resp = await url.SetBody(param).PostAsAsync<MSKAPISendVgmResultDto>();
|
|
|
|
|
|
|
|
_logger.LogInformation("通过MSKAPI发送VGM,单号:{mblno},响应:{resp}", order.MBLNO, resp.ToJson());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (resp.code == 200)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (resp.data.Any(x => !x.status))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
result = resp.data.Select(x => new
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
CNTRNO = x.containerNumber,
|
|
|
|
|
|
|
|
IsSuccess = x.status,
|
|
|
|
|
|
|
|
FailReason = x.error_msg
|
|
|
|
|
|
|
|
}).ToList();
|
|
|
|
|
|
|
|
_logger.LogInformation("通过MSKAPI发送VGM,部分成功,单号:{mblno},详细结果:{data}", order.MBLNO, result.ToJson());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
_logger.LogInformation("通过MSKAPI发送VGM,全部成功,单号:{mblno},详细结果:{data}", order.MBLNO, result.ToJson());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//货运动态
|
|
|
|
|
|
|
|
var bsl = new BookingStatusLog();
|
|
|
|
|
|
|
|
bsl.BookingId = order.Id;
|
|
|
|
|
|
|
|
bsl.Status = $"直发VGM(API)";
|
|
|
|
|
|
|
|
bsl.OpTime = DateTime.Now;
|
|
|
|
|
|
|
|
bsl.Category = "ship";
|
|
|
|
|
|
|
|
bsl.MBLNO = order.MBLNO;
|
|
|
|
|
|
|
|
await _repStatuslog.InsertAsync(bsl);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
_logger.LogInformation("通过MSKAPI发送VGM,VGM服务接口返回失败结果,单号:{mblno}", order.MBLNO);
|
|
|
|
|
|
|
|
throw Oops.Bah($"VGM服务接口返回失败结果:{resp.msg}");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
throw Oops.Bah("重量不能为空");
|
|
|
|
_logger.LogError(ex, "通过MSKAPI发送VGM时发生未知异常,单号:{mblno}", order.MBLNO);
|
|
|
|
|
|
|
|
throw Oops.Bah($"发送失败:{ex.Message}");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
var sysconfig = await _cache.GetAllSysConfig();
|
|
|
|
else
|
|
|
|
var urlConfig = sysconfig.FirstOrDefault(x => x.GroupCode == "DJY_CONST" && x.Code == "DjyVgmApiMyshpping");
|
|
|
|
{
|
|
|
|
var accConfig = await _webAccountConfig.GetAccountConfig("DjyVgm", UserManager.UserId);
|
|
|
|
var config = tenantParamList.FirstOrDefault(x => x.TenantId == UserManager.TENANT_ID && x.ParaCode == "VgmDirectSendCarrierId");
|
|
|
|
if (accConfig == null)
|
|
|
|
if (config == null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
throw Oops.Bah("请在网站账号中维护VGM接口的用户id和秘钥");
|
|
|
|
throw Oops.Bah("请配置租户的VGM直发船司参数");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var objMdata = new
|
|
|
|
var arrCarr = config.ItemCode.Split(",", StringSplitOptions.RemoveEmptyEntries);
|
|
|
|
|
|
|
|
// VGM发送方式2:使用大简云发送vgm
|
|
|
|
|
|
|
|
if (!arrCarr.Contains(order.CARRIERID))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
MBLNO = order.MBLNO,
|
|
|
|
//ETD不能为空
|
|
|
|
CARRIER = order.CARRIERID,
|
|
|
|
if (!order.ETD.HasValue)
|
|
|
|
ChuanMing = order.VESSEL,
|
|
|
|
{
|
|
|
|
HangCi = order.VOYNOINNER,
|
|
|
|
throw Oops.Bah("ETD不能为空");
|
|
|
|
ETD = order.ETD.Value.ToString("yyyy-MM-dd HH:mm:ss"),
|
|
|
|
}
|
|
|
|
ZongZhongLiang = order.KGS.ToString(),
|
|
|
|
|
|
|
|
BeiZhu = "",
|
|
|
|
|
|
|
|
ORDERNO = order.CUSTNO,
|
|
|
|
|
|
|
|
VGMCLOSETIME = order.CLOSEVGMDATE.HasValue ? order.CLOSEVGMDATE.Value.ToString("yyyy-MM-dd HH:mm:ss") : ""
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var listCtn = new List<dynamic>();
|
|
|
|
//重量不能为空
|
|
|
|
foreach (var ctn in ctns)
|
|
|
|
if (!order.KGS.HasValue)
|
|
|
|
{
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(ctn.CTNALL)
|
|
|
|
|
|
|
|
|| string.IsNullOrEmpty(ctn.CNTRNO)
|
|
|
|
|
|
|
|
|| string.IsNullOrEmpty(ctn.SEALNO)
|
|
|
|
|
|
|
|
|| !ctn.WEIGHKGS.HasValue
|
|
|
|
|
|
|
|
|| string.IsNullOrEmpty(ctn.WEIGHDATE))
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
throw Oops.Bah("所有箱子的箱型、箱号、封号、称重重量和称重时间都不能为空");
|
|
|
|
throw Oops.Bah("重量不能为空");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
listCtn.Add(new
|
|
|
|
var sysconfig = await _cache.GetAllSysConfig();
|
|
|
|
|
|
|
|
var urlConfig = sysconfig.FirstOrDefault(x => x.GroupCode == "DJY_CONST" && x.Code == "DjyVgmApiMyshpping");
|
|
|
|
|
|
|
|
var accConfig = await _webAccountConfig.GetAccountConfig("DjyVgm", UserManager.UserId);
|
|
|
|
|
|
|
|
if (accConfig == null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ChengZhongZhongLiang = ctn.WEIGHKGS.Value.ToString(),
|
|
|
|
throw Oops.Bah("请在网站账号中维护VGM接口的用户id和秘钥");
|
|
|
|
ChengZhongShiJian = ctn.WEIGHDATE,
|
|
|
|
}
|
|
|
|
CTNALL = ctn.CTNALL.Replace("'", ""),
|
|
|
|
|
|
|
|
CNTRNO = ctn.CNTRNO,
|
|
|
|
var objMdata = new
|
|
|
|
SEALNO = ctn.SEALNO
|
|
|
|
{
|
|
|
|
});
|
|
|
|
MBLNO = order.MBLNO,
|
|
|
|
}
|
|
|
|
CARRIER = order.CARRIERID,
|
|
|
|
|
|
|
|
ChuanMing = order.VESSEL,
|
|
|
|
|
|
|
|
HangCi = order.VOYNOINNER,
|
|
|
|
|
|
|
|
ETD = order.ETD.Value.ToString("yyyy-MM-dd HH:mm:ss"),
|
|
|
|
|
|
|
|
ZongZhongLiang = order.KGS.ToString(),
|
|
|
|
|
|
|
|
BeiZhu = "",
|
|
|
|
|
|
|
|
ORDERNO = order.CUSTNO,
|
|
|
|
|
|
|
|
VGMCLOSETIME = order.CLOSEVGMDATE.HasValue ? order.CLOSEVGMDATE.Value.ToString("yyyy-MM-dd HH:mm:ss") : ""
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var listCtn = new List<dynamic>();
|
|
|
|
|
|
|
|
foreach (var ctn in ctns)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(ctn.CTNALL)
|
|
|
|
|
|
|
|
|| string.IsNullOrEmpty(ctn.CNTRNO)
|
|
|
|
|
|
|
|
|| string.IsNullOrEmpty(ctn.SEALNO)
|
|
|
|
|
|
|
|
|| !ctn.WEIGHKGS.HasValue
|
|
|
|
|
|
|
|
|| string.IsNullOrEmpty(ctn.WEIGHDATE))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
throw Oops.Bah("所有箱子的箱型、箱号、封号、称重重量和称重时间都不能为空");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var dictParam = new Dictionary<string, string> {
|
|
|
|
listCtn.Add(new
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
ChengZhongZhongLiang = ctn.WEIGHKGS.Value.ToString(),
|
|
|
|
|
|
|
|
ChengZhongShiJian = ctn.WEIGHDATE,
|
|
|
|
|
|
|
|
CTNALL = ctn.CTNALL.Replace("'", ""),
|
|
|
|
|
|
|
|
CNTRNO = ctn.CNTRNO,
|
|
|
|
|
|
|
|
SEALNO = ctn.SEALNO
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var dictParam = new Dictionary<string, string> {
|
|
|
|
{ "ac", "vgm" },
|
|
|
|
{ "ac", "vgm" },
|
|
|
|
{ "uid", accConfig.Account},
|
|
|
|
{ "uid", accConfig.Account},
|
|
|
|
{ "skey", accConfig.Password},
|
|
|
|
{ "skey", accConfig.Password},
|
|
|
|
{ "optype", "9"},
|
|
|
|
{ "optype", "9"},
|
|
|
|
{ "mdata", JsonConvert.SerializeObject(objMdata)},
|
|
|
|
{ "mdata", JsonConvert.SerializeObject(objMdata)},
|
|
|
|
{ "ctndata", JsonConvert.SerializeObject(listCtn)}
|
|
|
|
{ "ctndata", JsonConvert.SerializeObject(listCtn)}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
_logger.LogInformation($"调用vgm发送接口:{urlConfig.Value},参数:{JsonConvert.SerializeObject(dictParam)}");
|
|
|
|
_logger.LogInformation($"调用vgm发送接口:{urlConfig.Value},参数:{JsonConvert.SerializeObject(dictParam)}");
|
|
|
|
|
|
|
|
|
|
|
|
var rtn = await urlConfig.Value
|
|
|
|
var rtn = await urlConfig.Value
|
|
|
|
.SetBody(dictParam, "application/x-www-form-urlencoded")
|
|
|
|
.SetBody(dictParam, "application/x-www-form-urlencoded")
|
|
|
|
.PostAsStringAsync();
|
|
|
|
.PostAsStringAsync();
|
|
|
|
|
|
|
|
|
|
|
|
_logger.LogInformation($"调用vgm发送接口:{urlConfig.Value},返回:{rtn}");
|
|
|
|
_logger.LogInformation($"调用vgm发送接口:{urlConfig.Value},返回:{rtn}");
|
|
|
|
|
|
|
|
|
|
|
|
var jobjRtn = JObject.Parse(rtn);
|
|
|
|
var jobjRtn = JObject.Parse(rtn);
|
|
|
|
if (jobjRtn.GetBooleanValue("Success"))
|
|
|
|
if (jobjRtn.GetBooleanValue("Success"))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
//货运动态
|
|
|
|
//货运动态
|
|
|
|
var bsl = new BookingStatusLog();
|
|
|
|
var bsl = new BookingStatusLog();
|
|
|
|
bsl.BookingId = bookingId;
|
|
|
|
bsl.BookingId = bookingId;
|
|
|
|
bsl.Status = $"发送VGM";
|
|
|
|
bsl.Status = $"发送VGM";
|
|
|
|
bsl.OpTime = DateTime.Now;
|
|
|
|
bsl.OpTime = DateTime.Now;
|
|
|
|
bsl.Category = "ship";
|
|
|
|
bsl.Category = "ship";
|
|
|
|
bsl.MBLNO = order.MBLNO;
|
|
|
|
bsl.MBLNO = order.MBLNO;
|
|
|
|
await _repStatuslog.InsertAsync(bsl);
|
|
|
|
await _repStatuslog.InsertAsync(bsl);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
throw Oops.Bah(jobjRtn.GetStringValue("Message"));
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// VGM发送方式3:直接调用vgm接口直发
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
throw Oops.Bah(jobjRtn.GetStringValue("Message"));
|
|
|
|
//判断船公司是否支持
|
|
|
|
}
|
|
|
|
var allowCarrier = _cache.GetAllDictData().Result.Where(x => x.TypeCode == "vgm_carrier_list").Select(x => x.Code).ToList();
|
|
|
|
}
|
|
|
|
if (!allowCarrier.Contains(order.CARRIERID))
|
|
|
|
else //直接调用vgm接口直发
|
|
|
|
{
|
|
|
|
{
|
|
|
|
throw Oops.Bah(BookingErrorCode.BOOK117);
|
|
|
|
//判断船公司是否支持
|
|
|
|
}
|
|
|
|
var allowCarrier = _cache.GetAllDictData().Result.Where(x => x.TypeCode == "vgm_carrier_list").Select(x => x.Code).ToList();
|
|
|
|
|
|
|
|
if (!allowCarrier.Contains(order.CARRIERID))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
throw Oops.Bah(BookingErrorCode.BOOK117);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//船公司网站账号
|
|
|
|
//船公司网站账号
|
|
|
|
var carrWebAccMap = _cache.GetAllDictData().Result.FirstOrDefault(x => x.TypeCode == "carrier_web_account_mapping" && x.Code == order.CARRIERID);
|
|
|
|
var carrWebAccMap = _cache.GetAllDictData().Result.FirstOrDefault(x => x.TypeCode == "carrier_web_account_mapping" && x.Code == order.CARRIERID);
|
|
|
|
if (carrWebAccMap == null)
|
|
|
|
if (carrWebAccMap == null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
throw Oops.Bah("不支持的船公司或账号映射未配置");
|
|
|
|
throw Oops.Bah("不支持的船公司或账号映射未配置");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var webacc = _webAccountConfig.GetAccountConfig(carrWebAccMap.Value, UserManager.UserId).Result;
|
|
|
|
var webacc = _webAccountConfig.GetAccountConfig(carrWebAccMap.Value, UserManager.UserId).Result;
|
|
|
|
if (webacc == null)
|
|
|
|
if (webacc == null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
throw Oops.Bah(BookingErrorCode.BOOK125);
|
|
|
|
throw Oops.Bah(BookingErrorCode.BOOK125);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
////箱型映射
|
|
|
|
////箱型映射
|
|
|
|
//var ctnMapping = await _cache.GetAllMappingCtn();
|
|
|
|
//var ctnMapping = await _cache.GetAllMappingCtn();
|
|
|
|
//ctnMapping = ctnMapping.Where(x => x.Module == "BookingVgm").ToList();
|
|
|
|
//ctnMapping = ctnMapping.Where(x => x.Module == "BookingVgm").ToList();
|
|
|
|
//if (ctnMapping.Count == 0)
|
|
|
|
//if (ctnMapping.Count == 0)
|
|
|
|
//{
|
|
|
|
//{
|
|
|
|
// throw Oops.Bah(BookingErrorCode.BOOK122);
|
|
|
|
// throw Oops.Bah(BookingErrorCode.BOOK122);
|
|
|
|
//}
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
//var expCode = ctns.Select(x => x.CTNCODE).Distinct().Except(ctnMapping.Select(y => y.Code)).ToList();
|
|
|
|
//var expCode = ctns.Select(x => x.CTNCODE).Distinct().Except(ctnMapping.Select(y => y.Code)).ToList();
|
|
|
|
//if (expCode.Count > 0)
|
|
|
|
//if (expCode.Count > 0)
|
|
|
|
//{
|
|
|
|
//{
|
|
|
|
// throw Oops.Bah(BookingErrorCode.BOOK123, string.Join(',', expCode));
|
|
|
|
// throw Oops.Bah(BookingErrorCode.BOOK123, string.Join(',', expCode));
|
|
|
|
//}
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
#region 箱信息校验,2022-7-1修改:【累加】的必须有重量、皮重和称重重量;【总重】的只需要称重重量不为空
|
|
|
|
#region 箱信息校验,2022-7-1修改:【累加】的必须有重量、皮重和称重重量;【总重】的只需要称重重量不为空
|
|
|
|
if (ctns.Where(c => c.WEIGHTYPE == "累加" &&
|
|
|
|
if (ctns.Where(c => c.WEIGHTYPE == "累加" &&
|
|
|
|
(
|
|
|
|
(
|
|
|
|
string.IsNullOrEmpty(c.CNTRNO)
|
|
|
|
string.IsNullOrEmpty(c.CNTRNO)
|
|
|
|
|| !c.WEIGHKGS.HasValue
|
|
|
|
|| !c.WEIGHKGS.HasValue
|
|
|
|
|| c.WEIGHKGS == 0
|
|
|
|
|| c.WEIGHKGS == 0
|
|
|
|
|| !c.TAREWEIGHT.HasValue
|
|
|
|
|| !c.TAREWEIGHT.HasValue
|
|
|
|
|| c.TAREWEIGHT == 0
|
|
|
|
|| c.TAREWEIGHT == 0
|
|
|
|
|| !c.KGS.HasValue
|
|
|
|
|| !c.KGS.HasValue
|
|
|
|
|| c.KGS == 0)
|
|
|
|
|| c.KGS == 0)
|
|
|
|
).Count() > 0)
|
|
|
|
).Count() > 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
throw Oops.Bah("称重方式为累加时,箱号、重量、箱皮重以及称重重量都不能为空");
|
|
|
|
throw Oops.Bah("称重方式为累加时,箱号、重量、箱皮重以及称重重量都不能为空");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (ctns.Where(c => c.WEIGHTYPE == "总重" &&
|
|
|
|
if (ctns.Where(c => c.WEIGHTYPE == "总重" &&
|
|
|
|
(
|
|
|
|
(
|
|
|
|
string.IsNullOrEmpty(c.CNTRNO)
|
|
|
|
string.IsNullOrEmpty(c.CNTRNO)
|
|
|
|
|| !c.WEIGHKGS.HasValue
|
|
|
|
|| !c.WEIGHKGS.HasValue
|
|
|
|
|| c.WEIGHKGS == 0)
|
|
|
|
|| c.WEIGHKGS == 0)
|
|
|
|
).Count() > 0)
|
|
|
|
).Count() > 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
throw Oops.Bah("称重方式为总重时,箱号和称重重量都不能为空");
|
|
|
|
throw Oops.Bah("称重方式为总重时,箱号和称重重量都不能为空");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
////场站转换
|
|
|
|
////场站转换
|
|
|
|
//var yardset = _cache.GetAllMappingYard().Result.FirstOrDefault(y => y.Code == order.YARDID && y.Module == "BookingVgm");
|
|
|
|
//var yardset = _cache.GetAllMappingYard().Result.FirstOrDefault(y => y.Code == order.YARDID && y.Module == "BookingVgm");
|
|
|
|
//if (yardset == null)
|
|
|
|
//if (yardset == null)
|
|
|
|
//{
|
|
|
|
//{
|
|
|
|
// throw Oops.Bah(BookingErrorCode.BOOK120, order.YARDID);
|
|
|
|
// throw Oops.Bah(BookingErrorCode.BOOK120, order.YARDID);
|
|
|
|
//}
|
|
|
|
//}
|
|
|
|
if (string.IsNullOrEmpty(order.YARD) || string.IsNullOrEmpty(order.YARDID))
|
|
|
|
if (string.IsNullOrEmpty(order.YARD) || string.IsNullOrEmpty(order.YARDID))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
throw Oops.Bah("场站未正确选择");
|
|
|
|
throw Oops.Bah("场站未正确选择");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// 场站映射
|
|
|
|
// 场站映射
|
|
|
|
string mappingYard, mappingYardId;
|
|
|
|
string mappingYard, mappingYardId;
|
|
|
|
var yardMapList = _cache.GetAllMappingYard().Result?.Where(y => y.Code == order.YARDID && y.Module == "BookingVgm" && (y.CarrierCode == null || y.CarrierCode == "" || y.CarrierCode == order.CARRIERID))?.ToList();
|
|
|
|
var yardMapList = _cache.GetAllMappingYard().Result?.Where(y => y.Code == order.YARDID && y.Module == "BookingVgm" && (y.CarrierCode == null || y.CarrierCode == "" || y.CarrierCode == order.CARRIERID))?.ToList();
|
|
|
|
if (yardMapList?.Any() == true)
|
|
|
|
if (yardMapList?.Any() == true)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var yardset = yardMapList.FirstOrDefault(x => x.CarrierCode == order.CARRIERID)
|
|
|
|
var yardset = yardMapList.FirstOrDefault(x => x.CarrierCode == order.CARRIERID)
|
|
|
|
?? yardMapList.FirstOrDefault(x => x.CarrierCode == null || x.CarrierCode == "");
|
|
|
|
?? yardMapList.FirstOrDefault(x => x.CarrierCode == null || x.CarrierCode == "");
|
|
|
|
|
|
|
|
|
|
|
|
mappingYard = yardset.MapName;
|
|
|
|
mappingYard = yardset.MapName;
|
|
|
|
mappingYardId = yardset.MapCode;
|
|
|
|
mappingYardId = yardset.MapCode;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
mappingYard = order.YARD;
|
|
|
|
mappingYard = order.YARD;
|
|
|
|
mappingYardId = order.YARDID;
|
|
|
|
mappingYardId = order.YARDID;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 船司映射
|
|
|
|
// 船司映射
|
|
|
|
var carrMap = _cache.GetAllMappingCarrier().Result?.Where(y => y.Code == order.CARRIERID && y.Module == "BookingVgm")?.FirstOrDefault();
|
|
|
|
var carrMap = _cache.GetAllMappingCarrier().Result?.Where(y => y.Code == order.CARRIERID && y.Module == "BookingVgm")?.FirstOrDefault();
|
|
|
|
string mappingCarrierId = carrMap != null ? carrMap.MapCode : order.CARRIERID;
|
|
|
|
string mappingCarrierId = carrMap != null ? carrMap.MapCode : order.CARRIERID;
|
|
|
|
|
|
|
|
|
|
|
|
var user = await _repUser.FirstOrDefaultAsync(x => x.Id == UserManager.UserId);
|
|
|
|
var user = await _repUser.FirstOrDefaultAsync(x => x.Id == UserManager.UserId);
|
|
|
|
|
|
|
|
|
|
|
|
int idx = 1;
|
|
|
|
int idx = 1;
|
|
|
|
//调用接口
|
|
|
|
//调用接口
|
|
|
|
var dicUrl = _cache.GetAllDictData().Result.First(x => x.TypeCode == "url_set" && x.Code == "vgm_service_single");
|
|
|
|
var dicUrl = _cache.GetAllDictData().Result.First(x => x.TypeCode == "url_set" && x.Code == "vgm_service_single");
|
|
|
|
var sendObj = new
|
|
|
|
var sendObj = new
|
|
|
|
{
|
|
|
|
{
|
|
|
|
SystemCode = "djy_hechuan",
|
|
|
|
SystemCode = "djy_hechuan",
|
|
|
|
billOrderId = order.Id.ToString(),
|
|
|
|
billOrderId = order.Id.ToString(),
|
|
|
|
sendOrderCode = order.MBLNO,
|
|
|
|
sendOrderCode = order.MBLNO,
|
|
|
|
customerName = $"{UserManager.TENANT_NAME}+{UserManager.Name}", //公司名称+用户姓名
|
|
|
|
customerName = $"{UserManager.TENANT_NAME}+{UserManager.Name}", //公司名称+用户姓名
|
|
|
|
customerId = order.CUSTOMERID.ToString(),
|
|
|
|
customerId = order.CUSTOMERID.ToString(),
|
|
|
|
agentName = string.IsNullOrEmpty(order.FORWARDER) ? UserManager.TENANT_NAME : order.FORWARDER,
|
|
|
|
agentName = string.IsNullOrEmpty(order.FORWARDER) ? UserManager.TENANT_NAME : order.FORWARDER,
|
|
|
|
carrierCode = mappingCarrierId,
|
|
|
|
carrierCode = mappingCarrierId,
|
|
|
|
userName = webacc.Account,
|
|
|
|
userName = webacc.Account,
|
|
|
|
userPassword = webacc.Password,
|
|
|
|
userPassword = webacc.Password,
|
|
|
|
depotCode = mappingYardId,
|
|
|
|
depotCode = mappingYardId,
|
|
|
|
depotName = mappingYard,
|
|
|
|
depotName = mappingYard,
|
|
|
|
linkName = UserManager.Name,
|
|
|
|
linkName = UserManager.Name,
|
|
|
|
linkMobile = user.Phone,
|
|
|
|
linkMobile = user.Phone,
|
|
|
|
linkEmail = user.Email,
|
|
|
|
linkEmail = user.Email,
|
|
|
|
userId = user.DjyUserId,
|
|
|
|
userId = user.DjyUserId,
|
|
|
|
signatory = user.NickName, //2023年8月28日,董怡含:把用户昵称当做vgm上传人
|
|
|
|
signatory = user.NickName, //2023年8月28日,董怡含:把用户昵称当做vgm上传人
|
|
|
|
returnUrl = "",
|
|
|
|
returnUrl = "",
|
|
|
|
shipName = order.VESSEL,
|
|
|
|
shipName = order.VESSEL,
|
|
|
|
voyNo = order.VOYNO,
|
|
|
|
voyNo = order.VOYNO,
|
|
|
|
etdstr = order.ETD.HasValue ? order.ETD.Value.ToString("yyyy-MM-dd") : string.Empty,
|
|
|
|
etdstr = order.ETD.HasValue ? order.ETD.Value.ToString("yyyy-MM-dd") : string.Empty,
|
|
|
|
potrSend = order.PORTLOAD,
|
|
|
|
potrSend = order.PORTLOAD,
|
|
|
|
potrGoal = order.PORTDISCHARGE,
|
|
|
|
potrGoal = order.PORTDISCHARGE,
|
|
|
|
boxinfoStr = order.CNTRTOTAL.Replace("'", ""),
|
|
|
|
boxinfoStr = order.CNTRTOTAL.Replace("'", ""),
|
|
|
|
vgmEndTimeStr = order.CLOSEVGMDATE.HasValue ? order.CLOSEVGMDATE.Value.ToString("yyyy-MM-dd") : string.Empty,
|
|
|
|
vgmEndTimeStr = order.CLOSEVGMDATE.HasValue ? order.CLOSEVGMDATE.Value.ToString("yyyy-MM-dd") : string.Empty,
|
|
|
|
BoxInfo = ctns.Select(c => new
|
|
|
|
BoxInfo = ctns.Select(c => new
|
|
|
|
{
|
|
|
|
{
|
|
|
|
index = idx++,
|
|
|
|
index = idx++,
|
|
|
|
boxType = c.CTNALL.Replace("'", ""),
|
|
|
|
boxType = c.CTNALL.Replace("'", ""),
|
|
|
|
boxcount = c.CTNNUM.HasValue ? c.CTNNUM.Value : 0,
|
|
|
|
boxcount = c.CTNNUM.HasValue ? c.CTNNUM.Value : 0,
|
|
|
|
code = c.CNTRNO,
|
|
|
|
code = c.CNTRNO,
|
|
|
|
sealCode = c.SEALNO,
|
|
|
|
sealCode = c.SEALNO,
|
|
|
|
weigth = c.KGS,
|
|
|
|
weigth = c.KGS,
|
|
|
|
weigthTare = c.TAREWEIGHT,
|
|
|
|
weigthTare = c.TAREWEIGHT,
|
|
|
|
weigthTotal = c.WEIGHKGS,
|
|
|
|
weigthTotal = c.WEIGHKGS,
|
|
|
|
weigthType = c.WEIGHTYPE == "累加" ? "SM2" : "SM1"
|
|
|
|
weigthType = c.WEIGHTYPE == "累加" ? "SM2" : "SM1"
|
|
|
|
}).ToList(),
|
|
|
|
}).ToList(),
|
|
|
|
returnOkUrl = ""
|
|
|
|
returnOkUrl = ""
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
string strPostObj = sendObj.ToJsonString();
|
|
|
|
string strPostObj = sendObj.ToJsonString();
|
|
|
|
_logger.LogInformation($"调用VGM直发接口 {dicUrl.Value} 传递数据:{strPostObj}");
|
|
|
|
_logger.LogInformation($"调用VGM直发接口 {dicUrl.Value} 传递数据:{strPostObj}");
|
|
|
|
var strResp = await dicUrl.Value.SetBody(sendObj).PostAsStringAsync();
|
|
|
|
var strResp = await dicUrl.Value.SetBody(sendObj).PostAsStringAsync();
|
|
|
|
_logger.LogInformation($"调用VGM直发接口返回:{strResp}");
|
|
|
|
_logger.LogInformation($"调用VGM直发接口返回:{strResp}");
|
|
|
|
|
|
|
|
|
|
|
|
var jobjResp = JObject.Parse(strResp);
|
|
|
|
var jobjResp = JObject.Parse(strResp);
|
|
|
|
int respCode = jobjResp.GetIntValue("code");
|
|
|
|
int respCode = jobjResp.GetIntValue("code");
|
|
|
|
if (respCode != 200)
|
|
|
|
if (respCode != 200)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
throw Oops.Bah(BookingErrorCode.BOOK128, jobjResp.GetStringValue("message"));
|
|
|
|
throw Oops.Bah(BookingErrorCode.BOOK128, jobjResp.GetStringValue("message"));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//货运动态
|
|
|
|
|
|
|
|
var bsl = new BookingStatusLog();
|
|
|
|
|
|
|
|
bsl.BookingId = bookingId;
|
|
|
|
|
|
|
|
bsl.Status = $"直发VGM";
|
|
|
|
|
|
|
|
bsl.OpTime = DateTime.Now;
|
|
|
|
|
|
|
|
bsl.Category = "ship";
|
|
|
|
|
|
|
|
bsl.MBLNO = order.MBLNO;
|
|
|
|
|
|
|
|
await _repStatuslog.InsertAsync(bsl);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//货运动态
|
|
|
|
|
|
|
|
var bsl = new BookingStatusLog();
|
|
|
|
|
|
|
|
bsl.BookingId = bookingId;
|
|
|
|
|
|
|
|
bsl.Status = $"直发VGM";
|
|
|
|
|
|
|
|
bsl.OpTime = DateTime.Now;
|
|
|
|
|
|
|
|
bsl.Category = "ship";
|
|
|
|
|
|
|
|
bsl.MBLNO = order.MBLNO;
|
|
|
|
|
|
|
|
await _repStatuslog.InsertAsync(bsl);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//设置货物状态:已发VGM,并回传东胜
|
|
|
|
//设置货物状态:已发VGM,并回传东胜
|
|
|
|
await SetGoodsStatus("YFVGM", bookingId);
|
|
|
|
await SetGoodsStatus("YFVGM", bookingId);
|
|
|
|
await SendBookingOrder(new long[] { bookingId });
|
|
|
|
await SendBookingOrder(new long[] { bookingId });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|