jianghaiqing 2 years ago
commit bc5e1e87ab

@ -72,7 +72,7 @@ namespace Myshipping.Application
public async Task<List<BookingOrderSeaeEdiServiceDto>> PageESeaeEdi(long bookingId)
{
var entities = await _seaeedi.AsQueryable().Filter(null, true).Where(x => x.BookingId == bookingId&&x.IsDeleted==false).ToListAsync();
var entities = await _seaeedi.AsQueryable().Filter(null, true).Where(x => x.BookingId == bookingId && x.IsDeleted == false).ToListAsync();
var list = entities.Adapt<List<BookingOrderSeaeEdiServiceDto>>();
foreach (var item in list)
{
@ -194,76 +194,84 @@ namespace Myshipping.Application
/// <summary>
/// 舱单
/// </summary>
/// <param name="bookingId"></param>
/// <param name="Ids"></param>
/// <returns></returns>
[HttpPost("/BookingOrderSeaeEdi/CustEDI")]
public async Task CustEDI(long bookingId)
public async Task CustEDI(string Ids)
{
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
var arr = Ids.Split(",");
if (arr.Count() > 0)
{
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}");
foreach (var ar in arr)
{
long bookingId = Convert.ToInt64(ar);
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 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);
await _seaeedi.UpdateAsync(x => x.Id == bookingId, x => new BookingOrderSeaeEdi { State = "已发送" });
}
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);
await _seaeedi.UpdateAsync(x => x.Id == bookingId, x => new BookingOrderSeaeEdi { State = "已发送" });
}
}
}
#endregion
}
}

@ -177,7 +177,10 @@ namespace Myshipping.Application.Service.BookingOrderSeaeEdi.Dto
/// 场站
/// </summary>
public string YARD { get; set; }
/// <summary>
/// 状态
/// </summary>
public string State { get; set; }
public List<BookingOrderSeaeEdiCtnDto> EdiCtn { get; set; }

Loading…
Cancel
Save