|
|
|
@ -61,6 +61,7 @@ namespace Myshipping.Application
|
|
|
|
|
private readonly SqlSugarRepository<MappingCarrier> _mapcarrier;
|
|
|
|
|
private readonly SqlSugarRepository<CodeLane> _codeLaneRep;
|
|
|
|
|
private readonly SqlSugarRepository<CodePort> _codePortRep;
|
|
|
|
|
private readonly SqlSugarRepository<RelaPortCarrierLane> _relaPortLane;
|
|
|
|
|
private readonly ICommonDBService _commonDBService;
|
|
|
|
|
|
|
|
|
|
public DataSyncService(ILogger<DataSyncService> logger, ISysCacheService cache, SqlSugarRepository<BookingOrder> rep, SqlSugarRepository<BookingCtn> repCtn,
|
|
|
|
@ -69,7 +70,7 @@ namespace Myshipping.Application
|
|
|
|
|
, SqlSugarRepository<BookingEDIExt> bookingEDIExt, SqlSugarRepository<BookingLog> bookinglog, SqlSugarRepository<BookingLogDetail> bookinglogdetail,
|
|
|
|
|
SqlSugarRepository<BookingGoodsStatus> goodsStatus, SqlSugarRepository<BookingGoodsStatusConfig> goodsStatusConfig, SqlSugarRepository<DjyTenantLine> repline,
|
|
|
|
|
SqlSugarRepository<BookingRemark> bookingremark, SqlSugarRepository<MappingCarrier> mapcarrier,
|
|
|
|
|
SqlSugarRepository<CodePort> codePortRep, SqlSugarRepository<CodeLane> codeLaneRep, ICommonDBService commonDBService)
|
|
|
|
|
SqlSugarRepository<CodePort> codePortRep, SqlSugarRepository<CodeLane> codeLaneRep, ICommonDBService commonDBService, SqlSugarRepository<RelaPortCarrierLane> relaPortLane)
|
|
|
|
|
{
|
|
|
|
|
this._logger = logger;
|
|
|
|
|
this._rep = rep;
|
|
|
|
@ -92,6 +93,7 @@ namespace Myshipping.Application
|
|
|
|
|
this._codePortRep = codePortRep;
|
|
|
|
|
this._codeLaneRep = codeLaneRep;
|
|
|
|
|
this._commonDBService = commonDBService;
|
|
|
|
|
this._relaPortLane = relaPortLane;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -1638,6 +1640,96 @@ namespace Myshipping.Application
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 目的港上传同步
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpPost("/DataSync/SyncDisport"), ApiUser(ApiCode = "SyncDisport")]
|
|
|
|
|
[SqlSugarUnitOfWork]
|
|
|
|
|
public async Task SyncDisport(DisportSyncDto dto)
|
|
|
|
|
{
|
|
|
|
|
var idList = dto.DataList.Select(x => x.Code).ToList();
|
|
|
|
|
var portList = _codePortRep.Where(x => idList.Contains(x.Code)).ToList();
|
|
|
|
|
var relaList = _relaPortLane.Where(x => idList.Contains(x.PortCode) && (x.CarrierCode == null || x.CarrierCode == "") && (x.Module == null || x.Module == "")).ToList();
|
|
|
|
|
var laneList = _codeLaneRep.ToList();
|
|
|
|
|
if (dto.Type == "save")
|
|
|
|
|
{
|
|
|
|
|
foreach (var dtoPort in dto.DataList)
|
|
|
|
|
{
|
|
|
|
|
var port = portList.FirstOrDefault(x => x.Code == dtoPort.Code);
|
|
|
|
|
if (port != null)
|
|
|
|
|
{
|
|
|
|
|
dtoPort.Adapt(port);
|
|
|
|
|
port.ModifyTime = DateTime.Now;
|
|
|
|
|
port.ModifyUser = UserManager.Name;
|
|
|
|
|
await _codePortRep.UpdateAsync(port);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
port = new CodePort();
|
|
|
|
|
port.GID = Guid.NewGuid().ToString();
|
|
|
|
|
dtoPort.Adapt(port);
|
|
|
|
|
port.CreateTime = DateTime.Now;
|
|
|
|
|
port.CreateUser = UserManager.Name;
|
|
|
|
|
await _codePortRep.InsertAsync(port);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//处理港口、航线对应关系
|
|
|
|
|
var lane = laneList.FirstOrDefault(x => x.CnName == port.ShippingRoute);
|
|
|
|
|
if (lane != null)
|
|
|
|
|
{
|
|
|
|
|
var rela = relaList.FirstOrDefault(x => x.PortCode == port.Code && x.LaneCode == lane.Code);
|
|
|
|
|
if (rela == null) //没有存在的映射关系,直接添加
|
|
|
|
|
{
|
|
|
|
|
rela = new RelaPortCarrierLane();
|
|
|
|
|
rela.GID = Guid.NewGuid().ToString();
|
|
|
|
|
rela.PortCode = port.Code;
|
|
|
|
|
rela.LaneCode = lane.Code;
|
|
|
|
|
rela.CarrierCode = "";
|
|
|
|
|
rela.Module = "";
|
|
|
|
|
rela.CreateTime = DateTime.Now;
|
|
|
|
|
rela.CreateUser = UserManager.Name;
|
|
|
|
|
await _relaPortLane.InsertAsync(rela);
|
|
|
|
|
}
|
|
|
|
|
else if (rela.LaneCode != lane.Code) //存在映射关系,但不是上传数据中的航线
|
|
|
|
|
{
|
|
|
|
|
rela.LaneCode = lane.Code; //修改航线映射
|
|
|
|
|
rela.ModifyTime = DateTime.Now;
|
|
|
|
|
rela.ModifyUser = UserManager.Name;
|
|
|
|
|
await _relaPortLane.UpdateAsync(rela);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
await _commonDBService.GetAllPort(false); //刷新缓存
|
|
|
|
|
await _commonDBService.GetAllRelaPortCarrierLane(false); //刷新缓存
|
|
|
|
|
}
|
|
|
|
|
else if (dto.Type == "del")
|
|
|
|
|
{
|
|
|
|
|
//删除港口数据
|
|
|
|
|
foreach (var port in portList)
|
|
|
|
|
{
|
|
|
|
|
await _codePortRep.DeleteAsync(port);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//删除映射关系
|
|
|
|
|
foreach (var rela in relaList)
|
|
|
|
|
{
|
|
|
|
|
await _relaPortLane.DeleteAsync(rela);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
await _commonDBService.GetAllPort(false); //刷新缓存
|
|
|
|
|
await _commonDBService.GetAllRelaPortCarrierLane(false); //刷新缓存
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Bah($"同步类型无效:{dto.Type}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 下载数据
|
|
|
|
|