航线同步接口

optimize
wanghaomei 2 years ago
parent 2604ba3866
commit 8423f31ae7

@ -31,6 +31,7 @@ using System.Net.Http;
using Myshipping.Core.Service; using Myshipping.Core.Service;
using System.Reflection.Emit; using System.Reflection.Emit;
using Myshipping.Application.Service.DataSync.Dto; using Myshipping.Application.Service.DataSync.Dto;
using Newtonsoft.Json.Linq;
namespace Myshipping.Application namespace Myshipping.Application
{ {
@ -58,13 +59,16 @@ namespace Myshipping.Application
private readonly SqlSugarRepository<BookingGoodsStatusConfig> _goodsStatusConfig; private readonly SqlSugarRepository<BookingGoodsStatusConfig> _goodsStatusConfig;
private readonly SqlSugarRepository<DjyTenantLine> _repline; private readonly SqlSugarRepository<DjyTenantLine> _repline;
private readonly SqlSugarRepository<MappingCarrier> _mapcarrier; 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, public DataSyncService(ILogger<DataSyncService> logger, ISysCacheService cache, SqlSugarRepository<BookingOrder> rep, SqlSugarRepository<BookingCtn> repCtn,
SqlSugarRepository<SysUser> repUser, SqlSugarRepository<SysTenant> repTenant, SqlSugarRepository<DjyCustomer> djycustomer, SqlSugarRepository<SysUser> repUser, SqlSugarRepository<SysTenant> repTenant, SqlSugarRepository<DjyCustomer> djycustomer,
SqlSugarRepository<DjyCustomerContact> djycustomercontact, SqlSugarRepository<DjyVesselInfo> vesselinfo, SqlSugarRepository<BookingCtnDetail> ctndetailrep SqlSugarRepository<DjyCustomerContact> djycustomercontact, SqlSugarRepository<DjyVesselInfo> vesselinfo, SqlSugarRepository<BookingCtnDetail> ctndetailrep
, SqlSugarRepository<BookingEDIExt> bookingEDIExt, SqlSugarRepository<BookingLog> bookinglog, SqlSugarRepository<BookingLogDetail> bookinglogdetail, , SqlSugarRepository<BookingEDIExt> bookingEDIExt, SqlSugarRepository<BookingLog> bookinglog, SqlSugarRepository<BookingLogDetail> bookinglogdetail,
SqlSugarRepository<BookingGoodsStatus> goodsStatus, SqlSugarRepository<BookingGoodsStatusConfig> goodsStatusConfig, SqlSugarRepository<DjyTenantLine> repline, 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._logger = logger;
this._rep = rep; this._rep = rep;
@ -84,6 +88,8 @@ namespace Myshipping.Application
this._goodsStatusConfig = goodsStatusConfig; this._goodsStatusConfig = goodsStatusConfig;
this._repline = repline; this._repline = repline;
this._mapcarrier = mapcarrier; this._mapcarrier = mapcarrier;
this._codePortRep = codePortRep;
this._codeLaneRep = codeLaneRep;
} }
@ -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 #endregion
#region 下载数据 #region 下载数据

@ -0,0 +1,34 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Myshipping.Application.Service.DataSync.Dto
{
public class LineSyncDto
{
/// <summary>
/// 类型保存save、删除del
/// </summary>
public string Type { get; set; }
/// <summary>
/// 数据列表
/// </summary>
public List<LineSyncModel> DataList { get; set; }
}
public class LineSyncModel
{
/// <summary>
/// 代码
/// </summary>
public string Code { get; set; }
/// <summary>
/// 名称
/// </summary>
public string Name { get; set; }
}
}
Loading…
Cancel
Save