|
|
|
@ -1,93 +1,64 @@
|
|
|
|
|
using Myshipping.Core;
|
|
|
|
|
using Furion;
|
|
|
|
|
using Furion.DependencyInjection;
|
|
|
|
|
using Furion.DistributedIDGenerator;
|
|
|
|
|
using Furion.DynamicApiController;
|
|
|
|
|
using Furion.EventBus;
|
|
|
|
|
using Furion.FriendlyException;
|
|
|
|
|
using Furion.JsonSerialization;
|
|
|
|
|
using Furion.RemoteRequest.Extensions;
|
|
|
|
|
using Mapster;
|
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
using SqlSugar;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Myshipping.Application.Entity;
|
|
|
|
|
using Microsoft.AspNetCore.Authorization;
|
|
|
|
|
using Furion;
|
|
|
|
|
using Microsoft.AspNetCore.Http;
|
|
|
|
|
using Furion.DataEncryption;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Security.Claims;
|
|
|
|
|
using Microsoft.AspNetCore.Authentication.Cookies;
|
|
|
|
|
using Microsoft.AspNetCore.Authentication;
|
|
|
|
|
using Microsoft.AspNetCore.Identity;
|
|
|
|
|
using Furion.FriendlyException;
|
|
|
|
|
using Furion.Logging;
|
|
|
|
|
using System;
|
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
|
using System.Reflection;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using Myshipping.Application.Service.BookingOrder.Dto;
|
|
|
|
|
using Myshipping.Application.ConfigOption;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using Yitter.IdGenerator;
|
|
|
|
|
using Myshipping.Core.Entity;
|
|
|
|
|
using Furion.RemoteRequest.Extensions;
|
|
|
|
|
using System.Net.Http;
|
|
|
|
|
using Myshipping.Core.Service;
|
|
|
|
|
using Myshipping.Application.EDI;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Web;
|
|
|
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
|
using Myshipping.Core.Helper;
|
|
|
|
|
using Myshipping.Application.Enum;
|
|
|
|
|
using Org.BouncyCastle.Asn1.X500;
|
|
|
|
|
using System.Drawing.Drawing2D;
|
|
|
|
|
using StackExchange.Profiling.Internal;
|
|
|
|
|
using Myshipping.Application;
|
|
|
|
|
using Myshipping.Application.EDI.ESL;
|
|
|
|
|
using Myshipping.Application.EDI.PIL;
|
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
using Myshipping.Application.EDI.SeaLead;
|
|
|
|
|
using Myshipping.Application.EDI.SITC;
|
|
|
|
|
using Myshipping.Application.EDI.TSL;
|
|
|
|
|
using Myshipping.Application.EDI.VOLTA;
|
|
|
|
|
using Myshipping.Application.EDI.WY;
|
|
|
|
|
using Myshipping.Application.EDI.YML;
|
|
|
|
|
using Myshipping.Application.EDI.YT;
|
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
using System.Threading;
|
|
|
|
|
using Furion.JsonSerialization;
|
|
|
|
|
using System.Xml.Linq;
|
|
|
|
|
using Myshipping.Application.Entity;
|
|
|
|
|
using Myshipping.Application.Enum;
|
|
|
|
|
using Myshipping.Application.Helper;
|
|
|
|
|
using System.Net;
|
|
|
|
|
using Furion.DistributedIDGenerator;
|
|
|
|
|
using System.Linq.Expressions;
|
|
|
|
|
using Myshipping.Application.Service.BookingOrder.Dto;
|
|
|
|
|
using Myshipping.Application.Service.BookingOrder.Dto.MSKAPI;
|
|
|
|
|
using Myshipping.Application.Service.BookingSlot.Dto;
|
|
|
|
|
using Myshipping.Application.Service.DataSync.Dto;
|
|
|
|
|
using Myshipping.Core;
|
|
|
|
|
using Myshipping.Core.Const;
|
|
|
|
|
using Myshipping.Core.Entity;
|
|
|
|
|
using Myshipping.Core.Entity.PingTai;
|
|
|
|
|
using Myshipping.Core.Extension;
|
|
|
|
|
using System.Text.RegularExpressions;
|
|
|
|
|
using MathNet.Numerics.Distributions;
|
|
|
|
|
using Microsoft.IdentityModel.Tokens;
|
|
|
|
|
using Myshipping.Application.EDI.ESL;
|
|
|
|
|
using Myshipping.Core.Helper;
|
|
|
|
|
using Myshipping.Core.Service;
|
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
|
using NPOI.HSSF.UserModel;
|
|
|
|
|
using NPOI.SS.UserModel;
|
|
|
|
|
using NPOI.SS.Formula.Functions;
|
|
|
|
|
using NPOI.HPSF;
|
|
|
|
|
using MimeKit;
|
|
|
|
|
using NPOI.SS.Formula;
|
|
|
|
|
using NPOI.Util;
|
|
|
|
|
using RabbitMQ.Client;
|
|
|
|
|
using SqlSugar;
|
|
|
|
|
using StackExchange.Profiling.Internal;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Collections.Specialized;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Net.Http;
|
|
|
|
|
using System.Net.Http.Headers;
|
|
|
|
|
using MySqlX.XDevAPI.Common;
|
|
|
|
|
using Ubiety.Dns.Core;
|
|
|
|
|
using static ICSharpCode.SharpZipLib.Zip.ExtendedUnixData;
|
|
|
|
|
using System.Security.Cryptography;
|
|
|
|
|
using Myshipping.Application.Service.DataSync.Dto;
|
|
|
|
|
using RabbitMQ.Client;
|
|
|
|
|
using System.Configuration;
|
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Security.Principal;
|
|
|
|
|
using Myshipping.Core.Const;
|
|
|
|
|
using ICSharpCode.SharpZipLib.BZip2;
|
|
|
|
|
using Myshipping.Application.EDI.VOLTA;
|
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Text.RegularExpressions;
|
|
|
|
|
using System.Threading;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Web;
|
|
|
|
|
using TinyPinyin;
|
|
|
|
|
using Furion.EventBus;
|
|
|
|
|
using Myshipping.Application.Service.BookingSlot.Dto;
|
|
|
|
|
using Myshipping.Application.Service.BookingOrder.Dto.MSKAPI;
|
|
|
|
|
using Microsoft.AspNetCore.Routing.Template;
|
|
|
|
|
using Myshipping.Application.EDI.SeaLead;
|
|
|
|
|
using Myshipping.Application.EDI.SITC;
|
|
|
|
|
using Myshipping.Core.Entity.PingTai;
|
|
|
|
|
using Yitter.IdGenerator;
|
|
|
|
|
|
|
|
|
|
namespace Myshipping.Application
|
|
|
|
|
{
|
|
|
|
@ -5240,10 +5211,418 @@ namespace Myshipping.Application
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 直发VGM(单票)
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="bookingId"></param>
|
|
|
|
|
/// <param name="bookingId">订单Id</param>
|
|
|
|
|
/// <param name="isSendCarr">是否发送船司</param>
|
|
|
|
|
/// <param name="isSendYGT">是否发送云港通</param>
|
|
|
|
|
/// <param name="isCheckRepeat">是否检查重复发送</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpPost("/BookingOrder/VgmSend")]
|
|
|
|
|
public async Task<object> VgmSend(long bookingId)
|
|
|
|
|
public async Task<object> VgmSend(long bookingId, bool isSendCarr, bool isSendYGT, bool? isCheckRepeat)
|
|
|
|
|
{
|
|
|
|
|
//throw Oops.Bah(201, $"是否重新发送?");
|
|
|
|
|
//throw Oops.Bah($"是否重新发送?");
|
|
|
|
|
if (App.Configuration["RunType"] == CommonConst.RUN_TYPE_HECHUAN && App.Configuration["RunTest"] == "true")
|
|
|
|
|
{
|
|
|
|
|
return await VgmSendNewSchema(bookingId, isSendCarr, isSendYGT, isCheckRepeat);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return await VgmSendOldSchema(bookingId);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// VGM发送(新)
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="bookingId">订单Id</param>
|
|
|
|
|
/// <param name="isSendCarr">是否发送船司</param>
|
|
|
|
|
/// <param name="isSendYGT">是否发送云港通</param>
|
|
|
|
|
/// <param name="isCheckRepeat">是否检查重复发送</param>
|
|
|
|
|
/// <remarks>发船司判断走船司直发或者通过大简云新API发送;发云港通通过大简云新API发送</remarks>
|
|
|
|
|
public async Task<object> VgmSendNewSchema(long bookingId, bool isSendCarr, bool isSendYGT, bool? isCheckRepeat)
|
|
|
|
|
{
|
|
|
|
|
if (!isSendCarr && !isSendYGT)
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Bah("VGM发送船司或云港通至少选择一项");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var order = await _rep.FirstOrDefaultAsync(x => x.Id == bookingId);
|
|
|
|
|
var ctns = await _repCtn.Where(x => x.BILLID == bookingId).ToListAsync();
|
|
|
|
|
|
|
|
|
|
if (order == null)
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Bah("未获取到订单信息,可能已被删除,请关闭页面重新打开");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ctns.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Bah("箱信息为空");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 查询vgm发送状态
|
|
|
|
|
var vgmStatus = await _rep.Context.Queryable<BookingVGMStatus>().Where(x => x.BookingId == bookingId).FirstAsync();
|
|
|
|
|
if (vgmStatus == null)
|
|
|
|
|
{
|
|
|
|
|
vgmStatus = new BookingVGMStatus()
|
|
|
|
|
{
|
|
|
|
|
BookingId = bookingId
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 船司VGM是否通过直发的方式
|
|
|
|
|
bool isSendCarrDirect = false;
|
|
|
|
|
|
|
|
|
|
//船公司
|
|
|
|
|
if (string.IsNullOrEmpty(order.CARRIERID))
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Bah(BookingErrorCode.BOOK118);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//提单号不能为空
|
|
|
|
|
if (string.IsNullOrEmpty(order.MBLNO))
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Bah(BookingErrorCode.BOOK127);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(order.YARD) || string.IsNullOrEmpty(order.YARDID))
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Bah("场站未正确选择");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 验证是否重复发送
|
|
|
|
|
if (isCheckRepeat == true)
|
|
|
|
|
{
|
|
|
|
|
var repeatType = new List<string>(2);
|
|
|
|
|
if (isSendCarr && vgmStatus.IsSendCarrierSuccess)
|
|
|
|
|
{
|
|
|
|
|
repeatType.Add("【船司】");
|
|
|
|
|
}
|
|
|
|
|
if (isSendYGT && vgmStatus.IsSendYgtSuccess)
|
|
|
|
|
{
|
|
|
|
|
repeatType.Add("【云港通】");
|
|
|
|
|
}
|
|
|
|
|
if (repeatType.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Bah($"已发送过{string.Join("、", repeatType)}VGM,是否重新发送?");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ctns.Where(c => c.WEIGHTYPE == "累加" &&
|
|
|
|
|
(
|
|
|
|
|
string.IsNullOrEmpty(c.CNTRNO)
|
|
|
|
|
|| !c.WEIGHKGS.HasValue
|
|
|
|
|
|| c.WEIGHKGS == 0
|
|
|
|
|
|| !c.TAREWEIGHT.HasValue
|
|
|
|
|
|| c.TAREWEIGHT == 0
|
|
|
|
|
|| !c.KGS.HasValue
|
|
|
|
|
|| c.KGS == 0)
|
|
|
|
|
).Count() > 0)
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Bah("称重方式为累加时,箱号、重量、箱皮重以及称重重量都不能为空");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ctns.Where(c => c.WEIGHTYPE == "总重" &&
|
|
|
|
|
(
|
|
|
|
|
string.IsNullOrEmpty(c.CNTRNO)
|
|
|
|
|
|| !c.WEIGHKGS.HasValue
|
|
|
|
|
|| c.WEIGHKGS == 0)
|
|
|
|
|
).Count() > 0)
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Bah("称重方式为总重时,箱号和称重重量都不能为空");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var tenantParamList = _cache.GetAllTenantParam().Result;
|
|
|
|
|
|
|
|
|
|
if (isSendCarr)
|
|
|
|
|
{
|
|
|
|
|
var config = tenantParamList.FirstOrDefault(x => x.TenantId == UserManager.TENANT_ID && x.ParaCode == "VgmDirectSendCarrierId");
|
|
|
|
|
if (config != null
|
|
|
|
|
&& config.ItemCode?.Split(",", StringSplitOptions.RemoveEmptyEntries)?.Contains(order.CARRIERID) == true)
|
|
|
|
|
{
|
|
|
|
|
isSendCarrDirect = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (isSendCarrDirect)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
await VGMDirectSendCarrier(bookingId, order, ctns);
|
|
|
|
|
|
|
|
|
|
vgmStatus.IsSendCarrier = true;
|
|
|
|
|
vgmStatus.IsSendCarrierDirect = true;
|
|
|
|
|
vgmStatus.IsSendCarrierSuccess = true;
|
|
|
|
|
vgmStatus.SendCarrierMessage = "发送船司成功";
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
vgmStatus.IsSendCarrier = true;
|
|
|
|
|
vgmStatus.IsSendCarrierDirect = true;
|
|
|
|
|
vgmStatus.IsSendCarrierSuccess = false;
|
|
|
|
|
vgmStatus.SendCarrierMessage = $"发送船司失败:{ex.Message}";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((isSendCarr && !isSendCarrDirect) || isSendYGT)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var sysconfig = await _cache.GetAllSysConfig();
|
|
|
|
|
var urlConfig = sysconfig.FirstOrDefault(x => x.GroupCode == "DJY_CONST" && x.Code == "DjyCarrierAndYgtVgmApi");
|
|
|
|
|
|
|
|
|
|
// 获取用户Key及Secret
|
|
|
|
|
var keySecretParam = tenantParamList.FirstOrDefault(x => x.TenantId == UserManager.TENANT_ID && x.ParaCode == "DjyCarrierAndYgtVgmApiKeySecret");
|
|
|
|
|
if (keySecretParam == null || !keySecretParam.ItemCode.Contains(','))
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Bah("请在租户参数配置【船司及云港通VGM发送API】所需的Key及Secret");
|
|
|
|
|
}
|
|
|
|
|
var keySecretArr = keySecretParam.ItemCode.Split(',');
|
|
|
|
|
var dicHead = new Dictionary<string, string>
|
|
|
|
|
{
|
|
|
|
|
{ "USER_KEY", keySecretArr[0] },
|
|
|
|
|
{ "USER_SECRET", keySecretArr[1] }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
//ETD不能为空
|
|
|
|
|
if (!order.ETD.HasValue)
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Bah("ETD不能为空");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//重量不能为空
|
|
|
|
|
if (!order.KGS.HasValue)
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Bah("重量不能为空");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 场站映射
|
|
|
|
|
string mappingYard;
|
|
|
|
|
var yardMapList = _cache.GetAllMappingYard().Result?.Where(y => y.Code == order.YARDID && y.Module == "VgmPlat" && (y.CarrierCode == null || y.CarrierCode == "" || y.CarrierCode == order.CARRIERID))?.ToList();
|
|
|
|
|
if (yardMapList?.Any() == true)
|
|
|
|
|
{
|
|
|
|
|
var yardset = yardMapList.FirstOrDefault(x => x.CarrierCode == order.CARRIERID)
|
|
|
|
|
?? yardMapList.FirstOrDefault(x => x.CarrierCode == null || x.CarrierCode == "");
|
|
|
|
|
|
|
|
|
|
mappingYard = yardset.MapName;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
mappingYard = order.YARD;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region 判断并验证发送类型
|
|
|
|
|
string carrSendType = null, ygtSendType = null;
|
|
|
|
|
if (isSendCarr && !isSendCarrDirect)
|
|
|
|
|
{
|
|
|
|
|
if (vgmStatus.IsSendCarrierSuccess)
|
|
|
|
|
{
|
|
|
|
|
carrSendType = "update";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
carrSendType = "add";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (isSendYGT)
|
|
|
|
|
{
|
|
|
|
|
if (vgmStatus.IsSendYgtSuccess)
|
|
|
|
|
{
|
|
|
|
|
ygtSendType = "update";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ygtSendType = "add";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (carrSendType != null && ygtSendType != null && carrSendType != ygtSendType)
|
|
|
|
|
{
|
|
|
|
|
if (carrSendType == "add" && ygtSendType == "update")
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Bah("检测到已发送过船司VGM非直发,请分别进行船司VGM的非直发新增以及云港通VGM的修改操作");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Bah("检测到已发送过云港通VGM,请分别进行船司VGM的非直发修改以及云港通VGM的新增操作");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
var sendObj = new VgmPlatDto
|
|
|
|
|
{
|
|
|
|
|
// 到这一步,carrSendType和ygtSendType在都不为null的情况下,应该是一致的
|
|
|
|
|
SendType = (carrSendType ?? ygtSendType) switch
|
|
|
|
|
{
|
|
|
|
|
"add" => "9",
|
|
|
|
|
"update" => "5",
|
|
|
|
|
_ => throw Oops.Bah("无法判断发送类型")
|
|
|
|
|
},
|
|
|
|
|
SendCarr = (isSendCarr && !isSendCarrDirect),
|
|
|
|
|
SendYGT = isSendYGT,
|
|
|
|
|
IsLinkSave = false,
|
|
|
|
|
IsApiSave = false,
|
|
|
|
|
MFNO = vgmStatus.MFNO,
|
|
|
|
|
MBLNO = order.MBLNO,
|
|
|
|
|
CARRIER = order.CARRIERID,
|
|
|
|
|
ETD = order.ETD,
|
|
|
|
|
WeiTuoFaSongFang = "",
|
|
|
|
|
ChuanMing = order.VESSEL,
|
|
|
|
|
HangCi = order.VOYNO,
|
|
|
|
|
BeiZhu = order.CZRemark,
|
|
|
|
|
ZhuangHuoGang = order.PORTLOAD,
|
|
|
|
|
ZhuangHuoGangDaiMa = order.PORTLOADID,
|
|
|
|
|
YARD = mappingYard,
|
|
|
|
|
ORDERNO = order.CUSTNO,
|
|
|
|
|
VGMCLOSETIME = order.CLOSEVGMDATE,
|
|
|
|
|
|
|
|
|
|
CtnList = ctns.Select(c => new VgmPlatCtnDto()
|
|
|
|
|
{
|
|
|
|
|
CTNALL = c.CTNALL,
|
|
|
|
|
CNTRNO = c.CNTRNO,
|
|
|
|
|
SEALNO = c.SEALNO,
|
|
|
|
|
KGS = c.KGS,
|
|
|
|
|
PKGS = c.PKGS,
|
|
|
|
|
PIZHONG = c.TAREWEIGHT.Value,
|
|
|
|
|
ChengZhongFangShi = c.WEIGHTYPE,
|
|
|
|
|
ChengZhongShiJian = string.IsNullOrEmpty(c.WEIGHDATE) ? DateTime.Today.ToString("yyyy-MM-dd") : c.WEIGHDATE,
|
|
|
|
|
ChengZhongZhongLiang = c.WEIGHKGS,
|
|
|
|
|
SendFlag = true
|
|
|
|
|
}).ToList()
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
_logger.LogInformation($"调用VGM平台的发送接口:{urlConfig.Value},参数:{JsonConvert.SerializeObject(sendObj)}");
|
|
|
|
|
|
|
|
|
|
var rtn = await urlConfig.Value
|
|
|
|
|
.SetBody(sendObj, "application/json")
|
|
|
|
|
.SetHeaders(dicHead)
|
|
|
|
|
.PostAsStringAsync();
|
|
|
|
|
|
|
|
|
|
_logger.LogInformation($"调用VGM平台的发送接口:{urlConfig.Value},返回:{rtn}");
|
|
|
|
|
|
|
|
|
|
var jobjRtn = JObject.Parse(rtn);
|
|
|
|
|
var isSuccess = jobjRtn.GetBooleanValue("succeeded");
|
|
|
|
|
var errors = jobjRtn.GetStringValue("errors");
|
|
|
|
|
|
|
|
|
|
var jobjData = jobjRtn.GetJObjectValue("data");
|
|
|
|
|
var carrSendFlag = jobjData?.GetIntValue("carrierSendFlag");
|
|
|
|
|
var ygtSendFlag = jobjData?.GetIntValue("ygtSendFlag");
|
|
|
|
|
var sendRltMsg = jobjData?.GetStringValue("sendRltMsg");
|
|
|
|
|
var vgmMFNO = jobjData?.GetValue("mfno")?.ToString();
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(vgmMFNO))
|
|
|
|
|
{
|
|
|
|
|
vgmStatus.MFNO = vgmMFNO;
|
|
|
|
|
}
|
|
|
|
|
if (isSuccess)
|
|
|
|
|
{
|
|
|
|
|
//货运动态(两种)
|
|
|
|
|
var statusLogList = new List<BookingStatusLog>();
|
|
|
|
|
|
|
|
|
|
if (isSendCarr && !isSendCarrDirect)
|
|
|
|
|
{
|
|
|
|
|
vgmStatus.IsSendCarrier = true;
|
|
|
|
|
if (carrSendFlag == 1)
|
|
|
|
|
{
|
|
|
|
|
vgmStatus.IsSendCarrierSuccess = true;
|
|
|
|
|
vgmStatus.SendCarrierMessage = "发送船司成功";
|
|
|
|
|
|
|
|
|
|
statusLogList.Add(new BookingStatusLog()
|
|
|
|
|
{
|
|
|
|
|
BookingId = bookingId,
|
|
|
|
|
Status = $"发送船司VGM",
|
|
|
|
|
OpTime = DateTime.Now,
|
|
|
|
|
Category = "ship",
|
|
|
|
|
MBLNO = order.MBLNO
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
vgmStatus.IsSendCarrierSuccess = false;
|
|
|
|
|
vgmStatus.SendCarrierMessage = $"发送船司失败:{sendRltMsg}";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (isSendYGT)
|
|
|
|
|
{
|
|
|
|
|
vgmStatus.IsSendYgt = true;
|
|
|
|
|
if (ygtSendFlag == 1)
|
|
|
|
|
{
|
|
|
|
|
vgmStatus.IsSendYgtSuccess = true;
|
|
|
|
|
vgmStatus.SendYgtMessage = "发送云港通成功";
|
|
|
|
|
|
|
|
|
|
statusLogList.Add(new BookingStatusLog()
|
|
|
|
|
{
|
|
|
|
|
BookingId = bookingId,
|
|
|
|
|
Status = $"发送云港通VGM",
|
|
|
|
|
OpTime = DateTime.Now,
|
|
|
|
|
Category = "ship",
|
|
|
|
|
MBLNO = order.MBLNO
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
vgmStatus.IsSendYgtSuccess = false;
|
|
|
|
|
vgmStatus.SendYgtMessage = $"发送云港通失败:{sendRltMsg}";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
await _repStatuslog.InsertAsync(statusLogList);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Bah($"VGM平台返回错误({errors})");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
if (isSendCarr && !isSendCarrDirect)
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrEmpty(vgmStatus.MFNO))
|
|
|
|
|
{
|
|
|
|
|
vgmStatus.IsSendCarrier = true;
|
|
|
|
|
}
|
|
|
|
|
vgmStatus.IsSendCarrierSuccess = false;
|
|
|
|
|
vgmStatus.SendCarrierMessage = $"发送船司失败:{ex.Message}";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (isSendYGT)
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrEmpty(vgmStatus.MFNO))
|
|
|
|
|
{
|
|
|
|
|
vgmStatus.IsSendYgt = true;
|
|
|
|
|
}
|
|
|
|
|
vgmStatus.IsSendYgtSuccess = false;
|
|
|
|
|
vgmStatus.SendYgtMessage = $"发送云港通失败:{ex.Message}";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (vgmStatus.Id == 0)
|
|
|
|
|
{
|
|
|
|
|
await _rep.Context.Insertable(vgmStatus).ExecuteCommandAsync();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
await _rep.Context.Updateable(vgmStatus).ExecuteCommandAsync();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (
|
|
|
|
|
(!isSendCarr || (isSendCarr && vgmStatus.IsSendCarrierSuccess))
|
|
|
|
|
&&
|
|
|
|
|
(!isSendYGT || (isSendYGT && vgmStatus.IsSendYgtSuccess))
|
|
|
|
|
)
|
|
|
|
|
{
|
|
|
|
|
//设置货物状态:已发VGM,并回传东胜
|
|
|
|
|
await SetGoodsStatus("YFVGM", bookingId);
|
|
|
|
|
await SendBookingOrder(new long[] { bookingId });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return vgmStatus;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// VGM发送(通过船司直发或者大简云发送)
|
|
|
|
|
/// </summary>
|
|
|
|
|
public async Task<object> VgmSendOldSchema(long bookingId)
|
|
|
|
|
{
|
|
|
|
|
object result = null;
|
|
|
|
|
|
|
|
|
@ -5498,6 +5877,22 @@ namespace Myshipping.Application
|
|
|
|
|
}
|
|
|
|
|
// VGM发送方式3:直接调用vgm接口直发
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
await VGMDirectSendCarrier(bookingId, order, ctns);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//设置货物状态:已发VGM,并回传东胜
|
|
|
|
|
await SetGoodsStatus("YFVGM", bookingId);
|
|
|
|
|
await SendBookingOrder(new long[] { bookingId });
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// VGM直发船司
|
|
|
|
|
/// </summary>
|
|
|
|
|
private async Task VGMDirectSendCarrier(long bookingId, BookingOrder order, List<BookingCtn> ctns)
|
|
|
|
|
{
|
|
|
|
|
//判断船公司是否支持
|
|
|
|
|
var allowCarrier = _cache.GetAllDictData().Result.Where(x => x.TypeCode == "vgm_carrier_list").Select(x => x.Code).ToList();
|
|
|
|
@ -5651,21 +6046,12 @@ namespace Myshipping.Application
|
|
|
|
|
//货运动态
|
|
|
|
|
var bsl = new BookingStatusLog();
|
|
|
|
|
bsl.BookingId = bookingId;
|
|
|
|
|
bsl.Status = $"直发VGM";
|
|
|
|
|
bsl.Status = $"发送船司VGM(直发)";
|
|
|
|
|
bsl.OpTime = DateTime.Now;
|
|
|
|
|
bsl.Category = "ship";
|
|
|
|
|
bsl.MBLNO = order.MBLNO;
|
|
|
|
|
await _repStatuslog.InsertAsync(bsl);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//设置货物状态:已发VGM,并回传东胜
|
|
|
|
|
await SetGoodsStatus("YFVGM", bookingId);
|
|
|
|
|
await SendBookingOrder(new long[] { bookingId });
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 批量编辑vgm
|
|
|
|
|