|
|
|
@ -468,20 +468,25 @@ namespace Myshipping.Application
|
|
|
|
|
[SqlSugarUnitOfWork]
|
|
|
|
|
public async Task<dynamic> SyncVesselDateList(List<DjyVesselInfoDto> model)
|
|
|
|
|
{
|
|
|
|
|
Lazy<List<MappingCarrier>> mapcarrier = new(() => _mapcarrier.Where(x => x.Module == "HeChuan").ToList());
|
|
|
|
|
|
|
|
|
|
var mapcarrier = _mapcarrier.Where(x => x.Module == "HeChuan").ToList();
|
|
|
|
|
var userlist = _repUser.AsQueryable().Filter(null, true).Where(x => x.IsDeleted == false && x.TenantId == UserManager.TENANT_ID).ToList();
|
|
|
|
|
var mlist = _vesselinfo.AsQueryable().Filter(null, true).Where(x => x.TenantId == UserManager.TENANT_ID && x.IsDeleted == false).ToList();
|
|
|
|
|
var orderlist = _rep.AsQueryable().Filter(null, true).Where(x => x.TenantId == UserManager.TENANT_ID && x.IsDeleted == false).ToList();
|
|
|
|
|
foreach (var item in model)
|
|
|
|
|
{
|
|
|
|
|
var CreatedUserId = userlist.Where(x => x.Name == item.CreatedUserName).Select(x => x.Id).FirstOrDefault();
|
|
|
|
|
var CreatedUserId = await _repUser.AsQueryable()
|
|
|
|
|
.Filter(null, true)
|
|
|
|
|
.Where(x => x.IsDeleted == false && x.TenantId == UserManager.TENANT_ID && x.Name == item.CreatedUserName)
|
|
|
|
|
.Select(x => x.Id)
|
|
|
|
|
.FirstAsync();
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrWhiteSpace(item.BSNO))
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Bah("BSNO未录入");
|
|
|
|
|
}
|
|
|
|
|
//根据东胜bsno获取当前数据查询不到则为新增
|
|
|
|
|
var m = mlist.Where(x => x.BSNO == item.BSNO).FirstOrDefault();
|
|
|
|
|
var m = await _vesselinfo.AsQueryable()
|
|
|
|
|
.Filter(null, true)
|
|
|
|
|
.Where(x => x.TenantId == UserManager.TENANT_ID && x.IsDeleted == false && x.BSNO == item.BSNO)
|
|
|
|
|
.FirstAsync();
|
|
|
|
|
var entity = item.Adapt<DjyVesselInfo>();
|
|
|
|
|
entity.Vessel = item.Vessel.ToUpper().Trim();
|
|
|
|
|
if (!string.IsNullOrEmpty(item.CARRIER))
|
|
|
|
@ -490,7 +495,7 @@ namespace Myshipping.Application
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(entity.CARRIERID))
|
|
|
|
|
{
|
|
|
|
|
entity.CARRIERID = mapcarrier.Where(x => x.MapName == item.CARRIER).Select(x => x.Code).FirstOrDefault();
|
|
|
|
|
entity.CARRIERID = mapcarrier.Value.Where(x => x.MapName == item.CARRIER).Select(x => x.Code).FirstOrDefault();
|
|
|
|
|
}
|
|
|
|
|
if (string.IsNullOrEmpty(entity.CARRIERID))
|
|
|
|
|
{
|
|
|
|
@ -509,7 +514,11 @@ namespace Myshipping.Application
|
|
|
|
|
if (m == null)
|
|
|
|
|
{
|
|
|
|
|
//查询是否存在相同船名航次数据
|
|
|
|
|
var e = mlist.Where(x => x.CARRIERID == entity.CARRIERID && x.Vessel == entity.Vessel && x.Voyno == entity.Voyno && x.VoynoInside == entity.VoynoInside).FirstOrDefault();
|
|
|
|
|
var e = await _vesselinfo.AsQueryable()
|
|
|
|
|
.Filter(null, true)
|
|
|
|
|
.Where(x => x.TenantId == UserManager.TENANT_ID && x.IsDeleted == false && x.CARRIERID == entity.CARRIERID && x.Vessel == entity.Vessel && x.Voyno == entity.Voyno && x.VoynoInside == entity.VoynoInside)
|
|
|
|
|
.FirstAsync();
|
|
|
|
|
|
|
|
|
|
//2023年7月27日,王书岚:航次为V.开头的不查询船期
|
|
|
|
|
if (!string.IsNullOrEmpty(entity.VoynoInside) && entity.VoynoInside.StartsWith("V."))
|
|
|
|
|
{
|
|
|
|
@ -526,7 +535,7 @@ namespace Myshipping.Application
|
|
|
|
|
{
|
|
|
|
|
entity.ETA = e.ETA;
|
|
|
|
|
}
|
|
|
|
|
await _vesselinfo.AsUpdateable(entity).IgnoreColumns(x => x.TenantId).ExecuteCommandAsync();
|
|
|
|
|
await _vesselinfo.AsUpdateable(entity).IgnoreColumns(x => x.TenantId).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
@ -541,15 +550,18 @@ namespace Myshipping.Application
|
|
|
|
|
{
|
|
|
|
|
entity.ETA = m.ETA;
|
|
|
|
|
}
|
|
|
|
|
await _vesselinfo.AsUpdateable(entity).IgnoreColumns(x => x.TenantId).ExecuteCommandAsync();
|
|
|
|
|
await _vesselinfo.AsUpdateable(entity).IgnoreColumns(x => x.TenantId).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync();
|
|
|
|
|
}
|
|
|
|
|
////根据船公司船名航次更新船期信息
|
|
|
|
|
if (!string.IsNullOrEmpty(item.CARRIER) && !string.IsNullOrEmpty(item.Vessel) && (!string.IsNullOrEmpty(item.Voyno) || !string.IsNullOrWhiteSpace(item.VoynoInside)))
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
var order = orderlist.Where(x => x.CARRIERID == item.CARRIERID && x.VESSEL == item.Vessel)
|
|
|
|
|
.WhereIF(!string.IsNullOrEmpty(item.Voyno), x => x.VOYNO == item.Voyno)
|
|
|
|
|
.WhereIF(!string.IsNullOrEmpty(item.VoynoInside), x => x.VOYNOINNER == item.VoynoInside).Distinct().ToList();
|
|
|
|
|
var order = await _rep.AsQueryable()
|
|
|
|
|
.Filter(null, true)
|
|
|
|
|
.Where(x => x.TenantId == UserManager.TENANT_ID && x.IsDeleted == false && x.CARRIERID == item.CARRIERID && x.VESSEL == item.Vessel)
|
|
|
|
|
.WhereIF(!string.IsNullOrEmpty(item.Voyno), x => x.VOYNO == item.Voyno)
|
|
|
|
|
.WhereIF(!string.IsNullOrEmpty(item.VoynoInside), x => x.VOYNOINNER == item.VoynoInside)
|
|
|
|
|
.Distinct()
|
|
|
|
|
.ToListAsync();
|
|
|
|
|
|
|
|
|
|
_logger.LogInformation($"同步船期_查询到{UserManager.TENANT_NAME}需要更新{order.Count()}条订舱数据");
|
|
|
|
|
foreach (var it in order)
|
|
|
|
|