jianghaiqing 2 years ago
commit c80c93cc54

@ -133,7 +133,11 @@ namespace Myshipping.Application.Enum
[ErrorCodeItemMetadata("vgm发送失败{0}")]
BOOK128,
/// <summary>
/// 舱单发送失败
/// </summary>
[ErrorCodeItemMetadata("舱单发送失败:{0}")]
BOOK129,
/// <summary>
/// 附件不存在

@ -3300,9 +3300,11 @@ namespace Myshipping.Application
var sysconfig = await _cache.GetAllSysConfig();
var urlConfig = sysconfig.FirstOrDefault(x => x.GroupCode == "DJY_CONST" && x.Code == "DjyVgmApiMyshpping");
var useridConfig = sysconfig.FirstOrDefault(x => x.GroupCode == "DJY_CONST" && x.Code == "DjyVgmApiMyshppingUserId");
var userSecretConfig = sysconfig.FirstOrDefault(x => x.GroupCode == "DJY_CONST" && x.Code == "DjyVgmApiMyshppingUserSecret");
var accConfig = await _webAccountConfig.GetAccountConfig("DjyVgm", UserManager.UserId);
if (accConfig == null)
{
throw Oops.Bah("请在网站账号中维护VGM接口的用户id和秘钥");
}
var objMdata = new
{
@ -3341,8 +3343,8 @@ namespace Myshipping.Application
var dictParam = new Dictionary<string, string> {
{ "ac", "vgm" },
{ "uid", useridConfig.Value},
{ "skey", userSecretConfig.Value},
{ "uid", accConfig.Account},
{ "skey", accConfig.Password},
{ "optype", "9"},
{ "mdata", JsonConvert.SerializeObject(objMdata)},
{ "ctndata", JsonConvert.SerializeObject(listCtn)}
@ -5466,9 +5468,7 @@ namespace Myshipping.Application
}
else
{
item.CARRIER = _cache.GetAllCodeCarrier().Result.Where(x => x.Code == item.CARRIERID).Select(x => x.CnName).FirstOrDefault();
}
}
if (!string.IsNullOrEmpty(item.ISSUETYPE))
@ -5477,10 +5477,6 @@ namespace Myshipping.Application
item.ISSUETYPE = ISSUETYPE;
}
var ctn = await _repCtn.AsQueryable().Filter(null, true).Where(x => x.BILLID == item.Id && x.IsDeleted == false).ToListAsync();
item.ctnInputs = ctn.Adapt<List<BookingCtnDto>>();
foreach (var it in item.ctnInputs)
@ -5529,7 +5525,8 @@ namespace Myshipping.Application
const string MqActionExchangeName = "djy.output.dingcang.ds6";
const string MqActionQueueName = "djy.output.dingcang.ds6";
ConnectionFactory factory = new ConnectionFactory();
factory.Uri = new Uri(App.Configuration["BookingOrderMQUri"]);
factory.Uri = new Uri(_cache.GetAllDictData().Result.Where(x => x.Code == "BookingOrderMQUri").Select(x => x.Value).FirstOrDefault());
using (IConnection conn = factory.CreateConnection())
{
IModel mqModel = conn.CreateModel();

@ -31,6 +31,11 @@ using System.Net.Http;
using Myshipping.Core.Service;
using System.Reflection.Emit;
using Myshipping.Application.Service.BookingOrderSeaeEdi.Dto;
using Myshipping.Application.Enum;
using Myshipping.Application.Service.BookingOrder.Dto;
using Newtonsoft.Json.Linq;
using System.Text;
using System.Web;
namespace Myshipping.Application
{
@ -43,13 +48,19 @@ namespace Myshipping.Application
private readonly ILogger<BookingOrderSeaeEdiService> _logger;
private readonly SqlSugarRepository<BookingOrderSeaeEdi> _seaeedi;
private readonly SqlSugarRepository<BookingOrderSeaeEdiCtn> _seaeedictn;
public BookingOrderSeaeEdiService(ILogger<BookingOrderSeaeEdiService> logger, SqlSugarRepository<BookingOrderSeaeEdi> seaeedi, SqlSugarRepository<BookingOrderSeaeEdiCtn> seaeedictn)
private readonly ISysCacheService _cache;
private readonly SqlSugarRepository<BookingStatusLog> _repStatuslog;
private readonly IDjyWebsiteAccountConfigService _webAccountConfig;
public BookingOrderSeaeEdiService(ILogger<BookingOrderSeaeEdiService> logger, SqlSugarRepository<BookingOrderSeaeEdi> seaeedi,
SqlSugarRepository<BookingOrderSeaeEdiCtn> seaeedictn, ISysCacheService cache, SqlSugarRepository<BookingStatusLog> repStatuslog,
IDjyWebsiteAccountConfigService webAccountConfig)
{
this._logger = logger;
this._seaeedi = seaeedi;
this._seaeedictn = seaeedictn;
this._cache = cache;
this._repStatuslog = repStatuslog;
this._webAccountConfig = webAccountConfig;
}
/// <summary>
@ -172,128 +183,76 @@ namespace Myshipping.Application
#region 舱单
///// <summary>
///// 舱单
///// </summary>
///// <param name="bookingId"></param>
///// <returns></returns>
//[HttpPost("/BookingOrderSeaeEdi/CustEDI")]
//public async Task CustEDI(long bookingId)
//{
// var order = _seaeedi.FirstOrDefault(x => x.BookingId == bookingId);
// var ctns = _seaeedictn.Where(x => x.BILLID == bookingId).ToList();
// //船公司
// if (string.IsNullOrEmpty(order.CARRIERID))
// {
// throw Oops.Bah(BookingErrorCode.BOOK118);
// }
// //提单号不能为空
// if (string.IsNullOrEmpty(order.MBLNO))
// {
// throw Oops.Bah(BookingErrorCode.BOOK127);
// }
// if (string.IsNullOrEmpty(order.YARDID))
// {
// throw Oops.Bah("场站未正确选择");
// }
// List<CustEDIDto> custEDIDtos = new List<CustEDIDto>();
// MDATA mDATA = new MDATA();
// mDATA.MBLNO = order.MBLNO;
// mDATA.HBLNO = order.HBLNO;
// mDATA.ETD = order.ETD == null ? "" : Convert.ToDateTime(order.ETD).ToString("yyyy-MM-dd");
// mDATA.FORWARDER = order.SHIPAGENCY;
// mDATA.VESSEL = order.VESSEL;
// mDATA.VOYNO = order.VOYNO;
// mDATA.CARRIER = order.CARRIERID;
// mDATA.SHIPPERNAME = order.SHIPPER;
// mDATA.SHIPPERADDR1 = order.SHIPPERADDR1;
// mDATA.SHIPPERCOUNTRY = order.SHIPPERCOUNTRY;
// mDATA.SHIPPERTEL = order.SHIPPERTEL;
// mDATA.CONSIGNEENAME = order.CONSIGNEE;
// mDATA.CONSIGNEEADDR1 = order.CONSIGNEEADDR1;
// mDATA.CONSIGNEECOUNTRY = order.CONSIGNEERCOUNTRY;
// mDATA.CONSIGNEETEL = order.CONSIGNEETEL;
// mDATA.NOTIFYPARTYNAME = order.NOTIFYPARTY;
// mDATA.NOTIFYPARTYADDR1 = order.NOTIFYPARTYADDR1;
// mDATA.NOTIFYPARTYCOUNTRY = order.NOTIFYPARTYCOUNTRY;
// mDATA.NOTIFYPARTYTEL = order.NOTIFYPARTYTEL;
// //var user = await _repUser.FirstOrDefaultAsync(x => x.Id == UserManager.UserId);
// // int idx = 1;
// // //调用接口
// // var dicUrl = _cache.GetAllDictData().Result.First(x => x.TypeCode == "url_set" && x.Code == "request_emf");
// // var sendObj = new
// // {
// // SystemCode = "djy_hechuan",
// // billOrderId = order.Id.ToString(),
// // sendOrderCode = order.MBLNO,
// // customerName = $"{UserManager.TENANT_NAME}+{UserManager.Name}", //公司名称+用户姓名
// // customerId = order.CUSTOMERID.ToString(),
// // agentName = string.IsNullOrEmpty(order.FORWARDER) ? UserManager.TENANT_NAME : order.FORWARDER,
// // carrierCode = order.CARRIERID,
// // userName = webacc.Account,
// // userPassword = webacc.Password,
// // depotCode = order.YARDID,
// // depotName = order.YARD,
// // linkName = UserManager.Name,
// // linkMobile = user.Phone,
// // linkEmail = user.Email,
// // userId = user.DjyUserId,
// // returnUrl = "",
// // shipName = order.VESSEL,
// // voyNo = order.VOYNO,
// // etdstr = order.ETD.HasValue ? order.ETD.Value.ToString("yyyy-MM-dd") : string.Empty,
// // potrSend = order.PORTLOAD,
// // potrGoal = order.PORTDISCHARGE,
// // boxinfoStr = order.CNTRTOTAL,
// // vgmEndTimeStr = order.CLOSEVGMDATE.HasValue ? order.CLOSEVGMDATE.Value.ToString("yyyy-MM-dd") : string.Empty,
// // BoxInfo = ctns.Select(c => new
// // {
// // index = idx++,
// // boxType = c.CTNALL,
// // boxcount = c.CTNNUM.HasValue ? c.CTNNUM.Value : 0,
// // code = c.CNTRNO,
// // sealCode = c.SEALNO,
// // weigth = c.KGS,
// // weigthTare = c.TAREWEIGHT,
// // weigthTotal = c.WEIGHKGS,
// // weigthType = c.WEIGHTYPE == "累加" ? "SM2" : "SM1"
// // }).ToList(),
// // returnOkUrl = ""
// // };
// // string strPostObj = sendObj.ToJsonString();
// // _logger.LogInformation($"调用VGM直发接口 {dicUrl.Value} 传递数据:{strPostObj}");
// // var strResp = await dicUrl.Value.SetBody(sendObj).PostAsStringAsync();
// // _logger.LogInformation($"调用VGM直发接口返回{strResp}");
// // var jobjResp = JObject.Parse(strResp);
// // int respCode = jobjResp.GetIntValue("code");
// // if (respCode != 200)
// // {
// // 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);
//}
/// <summary>
/// 舱单
/// </summary>
/// <param name="bookingId"></param>
/// <returns></returns>
[HttpPost("/BookingOrderSeaeEdi/CustEDI")]
public async Task CustEDI(long bookingId)
{
var order = await _seaeedi.AsQueryable().Filter(null, true).Where(x => x.BookingId == bookingId).FirstAsync();
var ctns = await _seaeedictn.AsQueryable().Filter(null, true).Where(x => x.PId == order.Id).ToListAsync();
//船公司
if (string.IsNullOrEmpty(order.CARRIERID))
{
throw Oops.Bah(BookingErrorCode.BOOK118);
}
//提单号不能为空
if (string.IsNullOrEmpty(order.MBLNO))
{
throw Oops.Bah(BookingErrorCode.BOOK127);
}
if (string.IsNullOrEmpty(order.YARDID))
{
throw Oops.Bah("场站未正确选择");
}
var dicUrl = _cache.GetAllDictData().Result.First(x => x.TypeCode == "url_set" && x.Code == "request_emf");
var key = _webAccountConfig.GetAccountConfig("DjyCangDan", UserManager.UserId).Result;
List<CustEDIDto> custEDIDtos = new List<CustEDIDto>();
MDATA mDATA = new MDATA();
List<CTNDATAItem> CTNDATA = new List<CTNDATAItem>();
mDATA = order.Adapt<MDATA>();
CTNDATA = ctns.Adapt<List<CTNDATAItem>>();
custEDIDtos.Add(
new CustEDIDto
{
MDATA = mDATA,
CTNDATA = CTNDATA
}
);
string strPostObj = custEDIDtos.ToJsonString();
var sendObj = new
{
ac = "emf",
uid = UserManager.DjyUserId,
skey = key.Password,
optype = "3",
data = strPostObj
};
_logger.LogInformation($"调用舱单接口 {dicUrl.Value} 传递数据:{strPostObj}");
var strResp = await dicUrl.Value.SetContentType("multipart/form-data").SetBody(sendObj).PostAsStringAsync();
_logger.LogInformation($"调用舱单接口返回:{strResp}");
var jobjResp = JObject.Parse(strResp);
int respCode = jobjResp.GetIntValue("code");
if (respCode != 200)
{
throw Oops.Bah(BookingErrorCode.BOOK129, jobjResp.GetStringValue("message"));
}
//货运动态
var bsl = new BookingStatusLog();
bsl.BookingId = bookingId;
bsl.Status = $"保存舱单";
bsl.OpTime = DateTime.Now;
bsl.Category = "ship";
bsl.MBLNO = order.MBLNO;
await _repStatuslog.InsertAsync(bsl);
}

@ -171,7 +171,12 @@ namespace Myshipping.Core.Service
var entity = await _rep.FirstOrDefaultAsync(u => u.Id == input.Id);
await _rep.DeleteAsync(entity);
}
/// <summary>
/// 获取接口Key 个人或公司
/// </summary>
/// <param name="TypeCode"></param>
/// <param name="UserId"></param>
/// <returns></returns>
public async Task<DjyWebsiteAccountConfig> GetAccountConfig(string TypeCode, long UserId)
{
if (string.IsNullOrWhiteSpace(TypeCode)||UserId==0) {

Loading…
Cancel
Save