|
|
|
@ -31,6 +31,7 @@ using System.Net.Http;
|
|
|
|
|
using Myshipping.Core.Service;
|
|
|
|
|
using System.Reflection.Emit;
|
|
|
|
|
using Myshipping.Application.Service.DataSync.Dto;
|
|
|
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
|
|
|
|
|
|
namespace Myshipping.Application
|
|
|
|
|
{
|
|
|
|
@ -58,13 +59,16 @@ namespace Myshipping.Application
|
|
|
|
|
private readonly SqlSugarRepository<BookingGoodsStatusConfig> _goodsStatusConfig;
|
|
|
|
|
private readonly SqlSugarRepository<DjyTenantLine> _repline;
|
|
|
|
|
private readonly SqlSugarRepository<MappingCarrier> _mapcarrier;
|
|
|
|
|
private readonly SqlSugarRepository<CodeLane> _codeLaneRep;
|
|
|
|
|
private readonly SqlSugarRepository<CodePort> _codePortRep;
|
|
|
|
|
|
|
|
|
|
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,
|
|
|
|
|
SqlSugarRepository<BookingGoodsStatus> goodsStatus, SqlSugarRepository<BookingGoodsStatusConfig> goodsStatusConfig, SqlSugarRepository<DjyTenantLine> repline,
|
|
|
|
|
SqlSugarRepository<BookingRemark> bookingremark, SqlSugarRepository<MappingCarrier> mapcarrier)
|
|
|
|
|
SqlSugarRepository<BookingRemark> bookingremark, SqlSugarRepository<MappingCarrier> mapcarrier,
|
|
|
|
|
SqlSugarRepository<CodePort> codePortRep, SqlSugarRepository<CodeLane> codeLaneRep)
|
|
|
|
|
{
|
|
|
|
|
this._logger = logger;
|
|
|
|
|
this._rep = rep;
|
|
|
|
@ -84,6 +88,8 @@ namespace Myshipping.Application
|
|
|
|
|
this._goodsStatusConfig = goodsStatusConfig;
|
|
|
|
|
this._repline = repline;
|
|
|
|
|
this._mapcarrier = mapcarrier;
|
|
|
|
|
this._codePortRep = codePortRep;
|
|
|
|
|
this._codeLaneRep = codeLaneRep;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -431,7 +437,7 @@ namespace Myshipping.Application
|
|
|
|
|
}
|
|
|
|
|
var order = await _rep.AsQueryable().Filter(null, true).Where(x => x.BSNO == model.BSNO && x.IsDeleted == false).FirstAsync();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (order == null)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
@ -497,7 +503,7 @@ namespace Myshipping.Application
|
|
|
|
|
}
|
|
|
|
|
if (!string.IsNullOrEmpty(entity.YARD))
|
|
|
|
|
{
|
|
|
|
|
entity.YARDID = _cache.GetAllCodeCarrier().Result.Where(x => x.CnName == entity.YARD).Select(x => x.Code).FirstOrDefault();
|
|
|
|
|
entity.YARDID = _cache.GetAllCodeCarrier().Result.Where(x => x.CnName == entity.YARD).Select(x => x.Code).FirstOrDefault();
|
|
|
|
|
}
|
|
|
|
|
if (!string.IsNullOrEmpty(entity.CARRIER))
|
|
|
|
|
{
|
|
|
|
@ -509,7 +515,7 @@ namespace Myshipping.Application
|
|
|
|
|
entity.CARRIERID = mapcarrier.Where(x => x.MapName == entity.CARRIER).Select(x => x.Code).FirstOrDefault();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if (!string.IsNullOrEmpty(entity.LineName))
|
|
|
|
|
{
|
|
|
|
@ -526,9 +532,9 @@ namespace Myshipping.Application
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
entity.BOOKINGNO = Yitter.IdGenerator.YitIdHelper.NextId().ToString();
|
|
|
|
|
entity.CreatedUserId = user.Id;
|
|
|
|
|
entity.CreatedUserName = user.Name.ToString();
|
|
|
|
@ -593,7 +599,7 @@ namespace Myshipping.Application
|
|
|
|
|
foreach (var item in model.childrens)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrWhiteSpace(item.HBLNO))
|
|
|
|
|
{
|
|
|
|
@ -674,7 +680,7 @@ namespace Myshipping.Application
|
|
|
|
|
fdentity.CARRIERID = mapcarrier.Where(x => x.MapName == fdentity.CARRIER).Select(x => x.Code).FirstOrDefault();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if (!string.IsNullOrEmpty(item.LineName))
|
|
|
|
|
{
|
|
|
|
@ -691,7 +697,7 @@ namespace Myshipping.Application
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fdentity.BOOKINGNO = Yitter.IdGenerator.YitIdHelper.NextId().ToString();
|
|
|
|
|
fdentity.MBLNO = entity.MBLNO;
|
|
|
|
|
fdentity.CreatedUserId = user.Id;
|
|
|
|
@ -956,7 +962,7 @@ namespace Myshipping.Application
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await _rep.AsUpdateable(entity).IgnoreColumns(it => new
|
|
|
|
|
{
|
|
|
|
|
it.BOOKINGNO,
|
|
|
|
@ -1275,7 +1281,7 @@ namespace Myshipping.Application
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await _rep.AsUpdateable(fdentity).IgnoreColumns(it => new
|
|
|
|
|
{
|
|
|
|
|
it.BOOKINGNO,
|
|
|
|
@ -1314,7 +1320,7 @@ namespace Myshipping.Application
|
|
|
|
|
if (item.BookingEDIExt != null)
|
|
|
|
|
{
|
|
|
|
|
//检索EDI扩展
|
|
|
|
|
var ediExtEntity = await _bookingEDIExt.AsQueryable().Filter(null, true).Where(x => x.BookingId == fdmain.Id).FirstAsync();
|
|
|
|
|
var ediExtEntity = await _bookingEDIExt.AsQueryable().Filter(null, true).Where(x => x.BookingId == fdmain.Id).FirstAsync();
|
|
|
|
|
|
|
|
|
|
if (ediExtEntity == null)
|
|
|
|
|
{
|
|
|
|
@ -1429,7 +1435,7 @@ namespace Myshipping.Application
|
|
|
|
|
if (item.BookingEDIExt != null)
|
|
|
|
|
{
|
|
|
|
|
//检索EDI扩展
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var ediExtEntity = await _bookingEDIExt.AsQueryable().Filter(null, true).Where(x => x.BookingId == fdentity.Id).FirstAsync();
|
|
|
|
|
if (ediExtEntity == null)
|
|
|
|
|
{
|
|
|
|
@ -1572,6 +1578,59 @@ namespace Myshipping.Application
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 航线上传同步
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpPost("/DataSync/SyncLine"), ApiUser(ApiCode = "SyncLine")]
|
|
|
|
|
[SqlSugarUnitOfWork]
|
|
|
|
|
public async Task SyncLine(LineSyncDto dto)
|
|
|
|
|
{
|
|
|
|
|
var idList = dto.DataList.Select(x => x.Code).ToList();
|
|
|
|
|
var laneList = _codeLaneRep.Where(x => idList.Contains(x.Code)).ToList();
|
|
|
|
|
if (dto.Type == "save")
|
|
|
|
|
{
|
|
|
|
|
foreach (var dtoLine in dto.DataList)
|
|
|
|
|
{
|
|
|
|
|
var lane = laneList.FirstOrDefault(x => x.Code == dtoLine.Code);
|
|
|
|
|
if (lane != null)
|
|
|
|
|
{
|
|
|
|
|
lane.EnName = dtoLine.Name;
|
|
|
|
|
lane.CnName = dtoLine.Name;
|
|
|
|
|
lane.ModifyTime = DateTime.Now;
|
|
|
|
|
lane.ModifyUser = UserManager.Name;
|
|
|
|
|
await _codeLaneRep.UpdateAsync(lane);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
lane = new CodeLane();
|
|
|
|
|
lane.GID = Guid.NewGuid().ToString();
|
|
|
|
|
lane.Code = dtoLine.Code;
|
|
|
|
|
lane.EnName = dtoLine.Name;
|
|
|
|
|
lane.CnName = dtoLine.Name;
|
|
|
|
|
lane.LaneType = "SEA";
|
|
|
|
|
lane.CreateTime = DateTime.Now;
|
|
|
|
|
lane.CreateUser = UserManager.Name;
|
|
|
|
|
await _codeLaneRep.InsertAsync(lane);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else if (dto.Type == "del")
|
|
|
|
|
{
|
|
|
|
|
foreach (var lane in laneList)
|
|
|
|
|
{
|
|
|
|
|
await _codeLaneRep.DeleteAsync(lane);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Bah($"同步类型无效:{dto.Type}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 下载数据
|
|
|
|
|