optimize
wet 2 years ago
parent 5e011eeed6
commit 6b3e788241

@ -2088,10 +2088,114 @@ namespace Myshipping.Application
} }
/// <summary>
/// 爬虫上传船期
/// </summary>
/// <returns></returns>
[HttpGet("/DataSync/SaveSyncVesselDate"), ApiUser(ApiCode = "SaveSyncVesselDate")]
[SqlSugarUnitOfWork]
public async Task SaveSyncVesselDate(List<DjyVesselDto> dto)
{
foreach (var item in dto)
{
var model = _vesselinfo.Where(x => x.Vessel == item.Vessel && x.Voyno == item.Voyno && x.CARRIERID == item.CARRIERID && x.TenantId == UserManager.TENANT_ID).First();
model.ETA = item.ETA;
model.ETD = item.ETD;
await _vesselinfo.AsUpdateable(model).IgnoreColumns().ExecuteCommandAsync();
var order = await _rep.AsQueryable().Where(x => x.VESSEL == item.Vessel && x.VOYNO == item.Voyno && x.CARRIERID == item.CARRIERID && x.TenantId == UserManager.TENANT_ID).ToListAsync();
if (order != null)
{
foreach (var it in order)
{
if (it.ETA != item.ETA)
{
////添加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
});
await _bookinglogdetail.InsertReturnSnowflakeIdAsync(new BookingLogDetail
{
PId = bid,
Field = "ETA",
OldValue = it.ETA == null ? "" : it.ETA.ToString(),
NewValue = item.ETA == null ? "" : item.ETA.ToString(),
});
it.ETA = item.ETA;
}
if (it.ETD != item.ETD)
{
////添加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
});
await _bookinglogdetail.InsertReturnSnowflakeIdAsync(new BookingLogDetail
{
PId = bid,
Field = "ETD",
OldValue = it.ETD == null ? "" : it.ETD.ToString(),
NewValue = item.ETD == null ? "" : item.ETD.ToString(),
});
it.ETD = item.ETD;
}
await _rep.AsUpdateable(it).IgnoreColumns().ExecuteCommandAsync();
}
}
}
}
#endregion #endregion
#region 下载数据 #region 下载数据
/// <summary>
/// 爬虫获取船名航次
/// </summary>
/// <returns></returns>
[HttpGet("/DataSync/GetSyncVesselDate"), ApiUser(ApiCode = "GetSyncVesselDate")]
public async Task<dynamic> GetSyncVesselDate()
{
var list = await _vesselinfo.AsQueryable().Where(x => x.ETD != null && x.ATD != null && x.TenantId == UserManager.TENANT_ID).Select(x => new DjyVesselDto
{
Vessel = x.Vessel,
Voyno = x.Voyno,
VoynoInside = x.VoynoInside,
CARRIER = x.CARRIER,
CARRIERID = x.CARRIERID,
ETD = null,
ETA = null
}).ToListAsync();
return list;
}

@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Myshipping.Application.Service.DataSync.Dto
{
public class DjyVesselDto
{
public string Vessel { get; set; }
public string Voyno { get; set; }
public string VoynoInside { get; set; }
public string CARRIER { get; set; }
public string CARRIERID { get; set; }
public DateTime? ETD { get; set; }
public DateTime? ETA { get; set; }
}
}
Loading…
Cancel
Save