|
|
|
@ -40,7 +40,7 @@ namespace Myshipping.Application
|
|
|
|
|
[ApiDescriptionSettings("Application", Name = "DataSync", Order = 1), AllowAnonymous]
|
|
|
|
|
public class DataSyncService : IDynamicApiController, ITransient
|
|
|
|
|
{
|
|
|
|
|
private readonly ILogger<BookingOrderService> _logger;
|
|
|
|
|
private readonly ILogger<DataSyncService> _logger;
|
|
|
|
|
private readonly ISysCacheService _cache;
|
|
|
|
|
private readonly SqlSugarRepository<BookingOrder> _rep;
|
|
|
|
|
private readonly SqlSugarRepository<BookingCtn> _repCtn;
|
|
|
|
@ -57,7 +57,7 @@ namespace Myshipping.Application
|
|
|
|
|
private readonly SqlSugarRepository<BookingGoodsStatus> _goodsStatus;
|
|
|
|
|
private readonly SqlSugarRepository<BookingGoodsStatusConfig> _goodsStatusConfig;
|
|
|
|
|
|
|
|
|
|
public DataSyncService(ILogger<BookingOrderService> logger, ISysCacheService cache, SqlSugarRepository<BookingOrder> rep, SqlSugarRepository<BookingCtn> repCtn,
|
|
|
|
|
public DataSyncService(ILogger<DataSyncService> logger, ISysCacheService cache, SqlSugarRepository<BookingOrder> rep, SqlSugarRepository<BookingCtn> repCtn,
|
|
|
|
|
SqlSugarRepository<SysUser> repUser, SqlSugarRepository<SysTenant> repTenant, SqlSugarRepository<DjyCustomer> djycustomer,
|
|
|
|
|
SqlSugarRepository<DjyCustomerContact> djycustomercontact, SqlSugarRepository<DjyVesselInfo> vesselinfo, SqlSugarRepository<BookingCtnDetail> ctndetailrep
|
|
|
|
|
, SqlSugarRepository<BookingEDIExt> bookingEDIExt, SqlSugarRepository<BookingLog> bookinglog, SqlSugarRepository<BookingLogDetail> bookinglogdetail,
|
|
|
|
@ -131,6 +131,7 @@ namespace Myshipping.Application
|
|
|
|
|
/// <param name="model"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpPost("/DataSync/SyncVesselDate"), ApiUser(ApiCode = "SyncVesselDate")]
|
|
|
|
|
[SqlSugarUnitOfWork]
|
|
|
|
|
public async Task<long> SyncVesselDate(DjyVesselInfoDto model)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
@ -161,6 +162,78 @@ namespace Myshipping.Application
|
|
|
|
|
entity.Id = m.Id;
|
|
|
|
|
await _vesselinfo.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync();
|
|
|
|
|
}
|
|
|
|
|
////根据船公司船名航次更新船期信息
|
|
|
|
|
if (!string.IsNullOrEmpty(model.CARRIER) && !string.IsNullOrEmpty(model.Vessel) && (!string.IsNullOrEmpty(model.Voyno) || !string.IsNullOrWhiteSpace(model.VoynoInside)))
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
var order = await _rep.AsQueryable().Filter(null, true).Where(x => x.TenantId == UserManager.TENANT_ID && x.CARRIERID == model.CARRIERID && x.VESSEL == model.Vessel)
|
|
|
|
|
.WhereIF(!string.IsNullOrEmpty(model.Voyno), x => x.VOYNO == model.Voyno)
|
|
|
|
|
.WhereIF(!string.IsNullOrEmpty(model.VoynoInside), x => x.VOYNOINNER == model.VoynoInside).ToListAsync();
|
|
|
|
|
|
|
|
|
|
_logger.LogInformation($"同步船期_查询到{UserManager.TENANT_NAME}需要更新{order.Count()}条订舱数据");
|
|
|
|
|
foreach (var item in order)
|
|
|
|
|
{
|
|
|
|
|
//更新订舱船期
|
|
|
|
|
if (item.ETD != model.ETD)
|
|
|
|
|
{
|
|
|
|
|
item.ETD = model.ETD;
|
|
|
|
|
}
|
|
|
|
|
if (item.ATD != model.ATD)
|
|
|
|
|
{
|
|
|
|
|
item.ATD = model.ATD;
|
|
|
|
|
}
|
|
|
|
|
await _rep.AsUpdateable(item).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 = item.Id,
|
|
|
|
|
TenantId = Convert.ToInt64(UserManager.TENANT_ID),
|
|
|
|
|
CreatedTime = DateTime.Now,
|
|
|
|
|
CreatedUserId = UserManager.UserId,
|
|
|
|
|
CreatedUserName = UserManager.Name
|
|
|
|
|
});
|
|
|
|
|
if (item.ETD != model.ETD)
|
|
|
|
|
{
|
|
|
|
|
await _bookinglogdetail.InsertReturnSnowflakeIdAsync(new BookingLogDetail
|
|
|
|
|
{
|
|
|
|
|
PId = bid,
|
|
|
|
|
Field = "ETD",
|
|
|
|
|
OldValue = item.ETD != null ? item.ETD.ToSqlValue() : null,
|
|
|
|
|
NewValue = model.ETD != null ? model.ETD.ToSqlValue() : null,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
if (item.ATD != model.ATD)
|
|
|
|
|
{
|
|
|
|
|
await _bookinglogdetail.InsertReturnSnowflakeIdAsync(new BookingLogDetail
|
|
|
|
|
{
|
|
|
|
|
PId = bid,
|
|
|
|
|
Field = "ATD",
|
|
|
|
|
OldValue = item.ATD != null ? item.ATD.ToSqlValue() : null,
|
|
|
|
|
NewValue = model.ATD != null ? model.ATD.ToSqlValue() : null,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
return entity.Id;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1805,6 +1878,7 @@ namespace Myshipping.Application
|
|
|
|
|
public async Task<string> Test()
|
|
|
|
|
{
|
|
|
|
|
return $"当前用户:{UserManager.UserId} {UserManager.Name} ,当前租户:{UserManager.TENANT_ID} {UserManager.TENANT_NAME},管理员类型:{(UserManager.IsSuperAdmin ? "超级管理员" : (UserManager.IsTenantAdmin ? "租户管理员" : "普通用户"))}";
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|