From 6b3e78824146ba684495366792bdcbef1da2f96b Mon Sep 17 00:00:00 2001 From: wet <1034391973@qq.com> Date: Tue, 4 Apr 2023 17:21:10 +0800 Subject: [PATCH] 1 --- .../Service/DataSync/DataSyncService.cs | 112 +++++++++++++++++- .../Service/DataSync/Dto/DjyVesselInfoDto.cs | 25 ++++ 2 files changed, 133 insertions(+), 4 deletions(-) create mode 100644 Myshipping.Application/Service/DataSync/Dto/DjyVesselInfoDto.cs diff --git a/Myshipping.Application/Service/DataSync/DataSyncService.cs b/Myshipping.Application/Service/DataSync/DataSyncService.cs index a7ab2d0d..57a9fae4 100644 --- a/Myshipping.Application/Service/DataSync/DataSyncService.cs +++ b/Myshipping.Application/Service/DataSync/DataSyncService.cs @@ -1737,10 +1737,10 @@ namespace Myshipping.Application StatusName = item.StatusName, Sort = goodsconfig.Where(x => x.CreatedUserId == user.Id).Max(x => x.Sort) + 1, - CreatedTime=DateTime.Now, - CreatedUserId=user.Id, - CreatedUserName=user.Name, - IsDeleted=false + CreatedTime = DateTime.Now, + CreatedUserId = user.Id, + CreatedUserName = user.Name, + IsDeleted = false }); await _goodsStatus.InsertAsync(new BookingGoodsStatus { @@ -2088,10 +2088,114 @@ namespace Myshipping.Application } + + + + /// + /// 爬虫上传船期 + /// + /// + [HttpGet("/DataSync/SaveSyncVesselDate"), ApiUser(ApiCode = "SaveSyncVesselDate")] + [SqlSugarUnitOfWork] + public async Task SaveSyncVesselDate(List 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 #region 下载数据 + /// + /// 爬虫获取船名航次 + /// + /// + [HttpGet("/DataSync/GetSyncVesselDate"), ApiUser(ApiCode = "GetSyncVesselDate")] + public async Task 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; + } diff --git a/Myshipping.Application/Service/DataSync/Dto/DjyVesselInfoDto.cs b/Myshipping.Application/Service/DataSync/Dto/DjyVesselInfoDto.cs new file mode 100644 index 00000000..1e4a6dcc --- /dev/null +++ b/Myshipping.Application/Service/DataSync/Dto/DjyVesselInfoDto.cs @@ -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; } + } +}