|
|
|
@ -128,6 +128,52 @@ namespace Myshipping.Application
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 批量同步客户无返回值
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="model">参数</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpPost("/DataSync/SyncCustomerList"), ApiUser(ApiCode = "SyncCustomerList")]
|
|
|
|
|
public async Task SyncCustomer(List<DjyCustomerSyncDto> model)
|
|
|
|
|
{
|
|
|
|
|
foreach (var item in model)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrWhiteSpace(item.ShortName))
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Bah("简称未录入");
|
|
|
|
|
}
|
|
|
|
|
var m = await _djycustomer.AsQueryable().Filter(null, true).Where(x => x.ShortName == item.ShortName && x.IsDeleted == false).FirstAsync();
|
|
|
|
|
var entity = model.Adapt<DjyCustomer>();
|
|
|
|
|
if (m == null)
|
|
|
|
|
{
|
|
|
|
|
await _djycustomer.InsertAsync(entity);
|
|
|
|
|
foreach (var it in item.ContactList)
|
|
|
|
|
{
|
|
|
|
|
var contact = it.Adapt<DjyCustomerContact>();
|
|
|
|
|
contact.CustomerId = entity.Id;
|
|
|
|
|
await _djycustomercontact.InsertAsync(contact);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
entity.Id = m.Id;
|
|
|
|
|
await _djycustomer.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync();
|
|
|
|
|
await _djycustomercontact.DeleteAsync(x => x.CustomerId == entity.Id);
|
|
|
|
|
foreach (var it in item.ContactList)
|
|
|
|
|
{
|
|
|
|
|
var contact = it.Adapt<DjyCustomerContact>();
|
|
|
|
|
contact.CustomerId = entity.Id;
|
|
|
|
|
await _djycustomercontact.InsertAsync(contact);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 同步船期
|
|
|
|
|
/// </summary>
|
|
|
|
@ -148,7 +194,6 @@ namespace Myshipping.Application
|
|
|
|
|
entity.Vessel = model.Vessel.ToUpper().Trim();
|
|
|
|
|
if (!string.IsNullOrEmpty(model.CARRIERID))
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
entity.CARRIER = _cache.GetAllCodeCarrier().Result.Where(x => x.Code == entity.CARRIERID).Select(x => x.CnName).FirstOrDefault();
|
|
|
|
|
}
|
|
|
|
|
if (!string.IsNullOrEmpty(model.CreatedUserName))
|
|
|
|
@ -240,6 +285,120 @@ namespace Myshipping.Application
|
|
|
|
|
return entity.Id;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 批量同步船期无返回值
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="model"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpPost("/DataSync/SyncVesselDateList"), ApiUser(ApiCode = "SyncVesselDateList")]
|
|
|
|
|
[SqlSugarUnitOfWork]
|
|
|
|
|
public async Task SyncVesselDateList(List<DjyVesselInfoDto> model)
|
|
|
|
|
{
|
|
|
|
|
foreach (var item in model)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrWhiteSpace(item.BSNO))
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Bah("BSNO未录入");
|
|
|
|
|
}
|
|
|
|
|
var userlist = _repUser.AsQueryable().Filter(null, true).Where(x => x.IsDeleted == false).ToListAsync();
|
|
|
|
|
var m = await _vesselinfo.AsQueryable().Filter(null, true).Where(x => x.BSNO == item.BSNO).FirstAsync();
|
|
|
|
|
var entity = model.Adapt<DjyVesselInfo>();
|
|
|
|
|
entity.Vessel = item.Vessel.ToUpper().Trim();
|
|
|
|
|
if (!string.IsNullOrEmpty(item.CARRIERID))
|
|
|
|
|
{
|
|
|
|
|
entity.CARRIER = _cache.GetAllCodeCarrier().Result.Where(x => x.Code == entity.CARRIERID).Select(x => x.CnName).FirstOrDefault();
|
|
|
|
|
}
|
|
|
|
|
if (!string.IsNullOrEmpty(item.CreatedUserName))
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
entity.CreatedUserId = userlist.Result.Where(x => x.Name == item.CreatedUserName).Select(x => x.Id).FirstOrDefault();
|
|
|
|
|
}
|
|
|
|
|
if (m == null)
|
|
|
|
|
{
|
|
|
|
|
await _vesselinfo.InsertAsync(entity);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
entity.Id = m.Id;
|
|
|
|
|
await _vesselinfo.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync();
|
|
|
|
|
}
|
|
|
|
|
////根据船公司船名航次更新船期信息
|
|
|
|
|
if (!string.IsNullOrEmpty(item.CARRIER) && !string.IsNullOrEmpty(item.Vessel) && (!string.IsNullOrEmpty(item.Voyno) || !string.IsNullOrWhiteSpace(item.VoynoInside)))
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
var order = await _rep.AsQueryable().Filter(null, true).Where(x => x.TenantId == UserManager.TENANT_ID && x.CARRIERID == item.CARRIERID && x.VESSEL == item.Vessel && x.IsDeleted == false)
|
|
|
|
|
.WhereIF(!string.IsNullOrEmpty(item.Voyno), x => x.VOYNO == item.Voyno)
|
|
|
|
|
.WhereIF(!string.IsNullOrEmpty(item.VoynoInside), x => x.VOYNOINNER == item.VoynoInside).ToListAsync();
|
|
|
|
|
|
|
|
|
|
_logger.LogInformation($"同步船期_查询到{UserManager.TENANT_NAME}需要更新{order.Count()}条订舱数据");
|
|
|
|
|
foreach (var it in order)
|
|
|
|
|
{
|
|
|
|
|
//更新订舱船期
|
|
|
|
|
if (it.ETD != item.ETD)
|
|
|
|
|
{
|
|
|
|
|
it.ETD = item.ETD;
|
|
|
|
|
}
|
|
|
|
|
if (it.ATD != item.ATD)
|
|
|
|
|
{
|
|
|
|
|
it.ATD = item.ATD;
|
|
|
|
|
}
|
|
|
|
|
await _rep.AsUpdateable(it).IgnoreColumns(it => new
|
|
|
|
|
{
|
|
|
|
|
it.ParentId,
|
|
|
|
|
it.TenantId,
|
|
|
|
|
it.CreatedTime,
|
|
|
|
|
it.CreatedUserId,
|
|
|
|
|
it.CreatedUserName,
|
|
|
|
|
it.UpdatedTime,
|
|
|
|
|
it.UpdatedUserId,
|
|
|
|
|
it.UpdatedUserName,
|
|
|
|
|
it.TenantName,
|
|
|
|
|
it.IsDeleted,
|
|
|
|
|
it.BOOKINGNO
|
|
|
|
|
}).ExecuteCommandAsync();
|
|
|
|
|
//记录日志
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
////添加booking日志
|
|
|
|
|
var bid = await _bookinglog.InsertReturnSnowflakeIdAsync(new BookingLog
|
|
|
|
|
{
|
|
|
|
|
Type = "Edit",
|
|
|
|
|
BookingId = it.Id,
|
|
|
|
|
TenantId = Convert.ToInt64(UserManager.TENANT_ID),
|
|
|
|
|
CreatedTime = DateTime.Now,
|
|
|
|
|
CreatedUserId = UserManager.UserId,
|
|
|
|
|
CreatedUserName = UserManager.Name
|
|
|
|
|
});
|
|
|
|
|
if (it.ETD != item.ETD)
|
|
|
|
|
{
|
|
|
|
|
await _bookinglogdetail.InsertReturnSnowflakeIdAsync(new BookingLogDetail
|
|
|
|
|
{
|
|
|
|
|
PId = bid,
|
|
|
|
|
Field = "ETD",
|
|
|
|
|
OldValue = it.ETD != null ? it.ETD.ToSqlValue() : null,
|
|
|
|
|
NewValue = item.ETD != null ? item.ETD.ToSqlValue() : null,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
if (it.ATD != item.ATD)
|
|
|
|
|
{
|
|
|
|
|
await _bookinglogdetail.InsertReturnSnowflakeIdAsync(new BookingLogDetail
|
|
|
|
|
{
|
|
|
|
|
PId = bid,
|
|
|
|
|
Field = "ATD",
|
|
|
|
|
OldValue = it.ATD != null ? it.ATD.ToSqlValue() : null,
|
|
|
|
|
NewValue = item.ATD != null ? item.ATD.ToSqlValue() : null,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region
|
|
|
|
|
///// <summary>
|
|
|
|
|
///// 同步订舱
|
|
|
|
|