From 375e8a4b63e47b247f993a63ebbbb3dcaee8269b Mon Sep 17 00:00:00 2001 From: wanghaomei Date: Thu, 8 Jun 2023 17:39:17 +0800 Subject: [PATCH] =?UTF-8?q?=E8=88=B9=E6=9C=9F@=E6=94=B9=E4=B8=BA=E8=88=B9?= =?UTF-8?q?=E6=9C=9F=E7=BB=B4=E6=8A=A4=E4=BA=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Service/DataSync/DataSyncService.cs | 41 ++++++++++--------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/Myshipping.Application/Service/DataSync/DataSyncService.cs b/Myshipping.Application/Service/DataSync/DataSyncService.cs index ad27b372..bac88109 100644 --- a/Myshipping.Application/Service/DataSync/DataSyncService.cs +++ b/Myshipping.Application/Service/DataSync/DataSyncService.cs @@ -266,7 +266,7 @@ namespace Myshipping.Application public async Task SyncCustomer(List model) { var userlist = await _repUser.AsQueryable().Filter(null, true).Where(x => x.IsDeleted == false && x.TenantId == UserManager.TENANT_ID).ToListAsync(); - var mlist = await _djycustomer.AsQueryable().Filter(null, true).Where(x => x.IsDeleted == false && x.TenantId == UserManager.TENANT_ID).ToListAsync(); + var mlist = await _djycustomer.AsQueryable().Filter(null, true).Where(x => x.IsDeleted == false && x.TenantId == UserManager.TENANT_ID).ToListAsync(); var shiplist = await _codeForwarder.AsQueryable().ToListAsync(); foreach (var item in model) { @@ -421,10 +421,10 @@ namespace Myshipping.Application public async Task SyncVesselDateList(List model) { - var mapcarrier = _mapcarrier.Where(x => x.Module == "HeChuan").ToList(); + var mapcarrier = _mapcarrier.Where(x => x.Module == "HeChuan").ToList(); var userlist = _repUser.AsQueryable().Filter(null, true).Where(x => x.IsDeleted == false && x.TenantId == UserManager.TENANT_ID).ToList(); - var mlist = _vesselinfo.AsQueryable().Filter(null, true).Where(x => x.TenantId == UserManager.TENANT_ID).ToList(); - var orderlist= _rep.AsQueryable().Filter(null, true).Where(x => x.TenantId == UserManager.TENANT_ID && x.IsDeleted == false).ToList(); + var mlist = _vesselinfo.AsQueryable().Filter(null, true).Where(x => x.TenantId == UserManager.TENANT_ID).ToList(); + var orderlist = _rep.AsQueryable().Filter(null, true).Where(x => x.TenantId == UserManager.TENANT_ID && x.IsDeleted == false).ToList(); foreach (var item in model) { @@ -432,7 +432,7 @@ namespace Myshipping.Application { throw Oops.Bah("BSNO未录入"); } - + var m = mlist.Where(x => x.BSNO == item.BSNO).FirstOrDefault(); var entity = item.Adapt(); entity.Vessel = item.Vessel.ToUpper().Trim(); @@ -476,7 +476,7 @@ namespace Myshipping.Application if (!string.IsNullOrEmpty(item.CARRIER) && !string.IsNullOrEmpty(item.Vessel) && (!string.IsNullOrEmpty(item.Voyno) || !string.IsNullOrWhiteSpace(item.VoynoInside))) { - var order = orderlist.Where(x => x.CARRIERID == item.CARRIERID && x.VESSEL == item.Vessel) + var order = orderlist.Where(x => x.CARRIERID == item.CARRIERID && x.VESSEL == item.Vessel) .WhereIF(!string.IsNullOrEmpty(item.Voyno), x => x.VOYNO == item.Voyno) .WhereIF(!string.IsNullOrEmpty(item.VoynoInside), x => x.VOYNOINNER == item.VoynoInside).ToList(); @@ -584,7 +584,7 @@ namespace Myshipping.Application var userlist = await _repUser.AsQueryable().Filter(null, true).Where(x => x.IsDeleted == false && x.TenantId == UserManager.TENANT_ID).ToListAsync(); var djycustomer = await _djycustomer.AsQueryable().Filter(null, true).Where(x => x.IsDeleted == false && x.TenantId == UserManager.TENANT_ID).ToListAsync(); var goodsconfig = await _goodsStatusConfig.AsQueryable().Filter(null, true).Where(x => x.IsDeleted == false && x.TenantId == UserManager.TENANT_ID).ToListAsync(); - var orderlist = await _rep.AsQueryable().Filter(null, true).Where(x => x.IsDeleted == false&& x.TenantId == UserManager.TENANT_ID).ToListAsync(); + var orderlist = await _rep.AsQueryable().Filter(null, true).Where(x => x.IsDeleted == false && x.TenantId == UserManager.TENANT_ID).ToListAsync(); var linelist = await _repline.AsQueryable().Filter(null, true).Where(m => m.TenantId == UserManager.TENANT_ID).ToListAsync(); foreach (var model in list) @@ -598,12 +598,12 @@ namespace Myshipping.Application throw Oops.Bah("未录入创建人"); } - var user = userlist.Where(x => x.Name == model.CreatedUserName.Trim() && x.IsDeleted == false).FirstOrDefault(); + var user = userlist.Where(x => x.Name == model.CreatedUserName.Trim() && x.IsDeleted == false).FirstOrDefault(); if (user == null) { throw Oops.Bah($"未匹配到创建人{model.CreatedUserName.Trim()}请联系管理员添加相关用户"); } - var order = orderlist.Where(x => x.BSNO == model.BSNO ).FirstOrDefault(); + var order = orderlist.Where(x => x.BSNO == model.BSNO).FirstOrDefault(); if (order == null) @@ -687,7 +687,7 @@ namespace Myshipping.Application } if (!string.IsNullOrEmpty(entity.LineName)) { - var line = linelist.Where(m => m.LineName.Contains(entity.LineName)).FirstOrDefault(); + var line = linelist.Where(m => m.LineName.Contains(entity.LineName)).FirstOrDefault(); if (line == null) { await _repline.InsertAsync(new DjyTenantLine @@ -1674,12 +1674,12 @@ namespace Myshipping.Application public async Task SaveSyncVesselDate(List dto) { var infolist = _vesselinfo.AsQueryable().Filter(null, true).Where(x => x.TenantId == UserManager.TENANT_ID).ToList(); - var orderlist = await _rep.AsQueryable().Filter(null, true).Where(x => x.TenantId == UserManager.TENANT_ID && x.IsDeleted == false).ToListAsync(); - + var orderlist = await _rep.AsQueryable().Filter(null, true).Where(x => x.TenantId == UserManager.TENANT_ID && x.IsDeleted == false).ToListAsync(); + foreach (var item in dto) { var model = infolist.Where(x => x.Vessel == item.Vessel && x.Voyno == item.Voyno).FirstOrDefault(); - if (model != null) + if (model != null) { model.ETA = item.ETA; model.YgtETD = item.ETD; @@ -1825,7 +1825,7 @@ namespace Myshipping.Application [SqlSugarUnitOfWork] public async Task SaveSyncGHVesselDate(List dto) { - var orderlist = await _rep.AsQueryable().Filter(null, true).Where(x => x.TenantId == UserManager.TENANT_ID && x.IsDeleted == false).ToListAsync(); + var orderlist = await _rep.AsQueryable().Filter(null, true).Where(x => x.TenantId == UserManager.TENANT_ID && x.IsDeleted == false).ToListAsync(); foreach (var item in dto) { @@ -2187,14 +2187,17 @@ namespace Myshipping.Application var usrList = _repUser.AsQueryable().Filter(null, true).Where(u => u.TenantId == tenantId && !u.IsDeleted).ToList(); Dictionary> dic = new Dictionary>(); - //遍历船名航次,查询订舱数据 + //遍历船名航次,查询船期维护人 foreach (var item in dto) { - var boUserList = _rep.AsQueryable().Filter(null, true).Where(x => x.VESSEL == item.Vessel && x.VOYNO == item.Voyno && (x.ParentId == 0 || x.ParentId == null) && !x.IsDeleted && x.TenantId == tenantId) - .Select(x => x.CreatedUserId).ToList(); - if (boUserList.Count > 0) + var veUserList = _vesselinfo.AsQueryable().Filter(null, true) + .Where(v => v.TenantId == tenantId && v.Vessel == item.Vessel && v.Voyno == item.Voyno && !v.IsDeleted) + .Select(x => x.CreatedUserId) + .ToList(); + + if (veUserList.Count > 0) { - var phoneList = usrList.Where(u => boUserList.Contains(u.Id) && u.Phone != "" && u.Phone != null).Select(x => x.Phone).ToList(); + var phoneList = usrList.Where(u => veUserList.Contains(u.Id) && u.Phone != "" && u.Phone != null).Select(x => x.Phone).ToList(); foreach (var phone in phoneList) {