|
|
|
@ -35,6 +35,8 @@ using Newtonsoft.Json.Linq;
|
|
|
|
|
using Myshipping.Application.Service.BookingOrder.Dto;
|
|
|
|
|
using Myshipping.Application.Enum;
|
|
|
|
|
using Myshipping.Core.Helper;
|
|
|
|
|
using Furion.TaskScheduler;
|
|
|
|
|
using System.Linq.Expressions;
|
|
|
|
|
|
|
|
|
|
namespace Myshipping.Application
|
|
|
|
|
{
|
|
|
|
@ -264,6 +266,8 @@ namespace Myshipping.Application
|
|
|
|
|
public async Task SyncCustomer(List<DjyCustomerSyncDto> 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 shiplist = await _codeForwarder.AsQueryable().ToListAsync();
|
|
|
|
|
foreach (var item in model)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
@ -272,7 +276,7 @@ namespace Myshipping.Application
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Bah("简称未录入");
|
|
|
|
|
}
|
|
|
|
|
var m = await _djycustomer.AsQueryable().Filter(null, true).Where(x => x.ShortName == item.ShortName && x.IsDeleted == false && x.TenantId == UserManager.TENANT_ID).FirstAsync();
|
|
|
|
|
var m = mlist.Where(x => x.ShortName == item.ShortName).FirstOrDefault();
|
|
|
|
|
var entity = item.Adapt<DjyCustomer>();
|
|
|
|
|
if (m == null)
|
|
|
|
|
{
|
|
|
|
@ -306,7 +310,7 @@ namespace Myshipping.Application
|
|
|
|
|
if (entity.PropString.Contains("shipagency"))
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
var ship = await _codeForwarder.AsQueryable().Where(x => x.Code == entity.CodeName).FirstAsync();
|
|
|
|
|
var ship = shiplist.Where(x => x.Code == entity.CodeName).FirstOrDefault();
|
|
|
|
|
if (ship == null)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
@ -371,7 +375,7 @@ namespace Myshipping.Application
|
|
|
|
|
if (entity.PropString.Contains("shipagency"))
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
var ship = await _codeForwarder.AsQueryable().Where(x => x.Code == entity.CodeName).FirstAsync();
|
|
|
|
|
var ship = shiplist.Where(x => x.Code == entity.CodeName).FirstOrDefault();
|
|
|
|
|
if (ship == null)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
@ -417,7 +421,10 @@ namespace Myshipping.Application
|
|
|
|
|
public async Task<dynamic> SyncVesselDateList(List<DjyVesselInfoDto> model)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
var mapcarrier = await _mapcarrier.Where(x => x.Module == "HeChuan").ToListAsync();
|
|
|
|
|
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();
|
|
|
|
|
foreach (var item in model)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
@ -425,8 +432,8 @@ namespace Myshipping.Application
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Bah("BSNO未录入");
|
|
|
|
|
}
|
|
|
|
|
var userlist = _repUser.AsQueryable().Filter(null, true).Where(x => x.IsDeleted == false && x.TenantId == UserManager.TENANT_ID).ToListAsync();
|
|
|
|
|
var m = await _vesselinfo.AsQueryable().Filter(null, true).Where(x => x.BSNO == item.BSNO && x.TenantId == UserManager.TENANT_ID).FirstAsync();
|
|
|
|
|
|
|
|
|
|
var m = mlist.Where(x => x.BSNO == item.BSNO).FirstOrDefault();
|
|
|
|
|
var entity = item.Adapt<DjyVesselInfo>();
|
|
|
|
|
entity.Vessel = item.Vessel.ToUpper().Trim();
|
|
|
|
|
if (!string.IsNullOrEmpty(item.CARRIER))
|
|
|
|
@ -449,7 +456,7 @@ namespace Myshipping.Application
|
|
|
|
|
if (!string.IsNullOrEmpty(item.CreatedUserName))
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
entity.CreatedUserId = userlist.Result.Where(x => x.Name == item.CreatedUserName).Select(x => x.Id).FirstOrDefault();
|
|
|
|
|
entity.CreatedUserId = userlist.Where(x => x.Name == item.CreatedUserName).Select(x => x.Id).FirstOrDefault();
|
|
|
|
|
}
|
|
|
|
|
if (string.IsNullOrEmpty(item.Voyno))
|
|
|
|
|
{
|
|
|
|
@ -469,9 +476,9 @@ namespace Myshipping.Application
|
|
|
|
|
if (!string.IsNullOrEmpty(item.CARRIER) && !string.IsNullOrEmpty(item.Vessel) && (!string.IsNullOrEmpty(item.Voyno) || !string.IsNullOrWhiteSpace(item.VoynoInside)))
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
var order = await _rep.AsQueryable().Filter(null, true).Where(x => x.TenantId == UserManager.TENANT_ID && x.CARRIERID == item.CARRIERID && x.VESSEL == item.Vessel && x.IsDeleted == false)
|
|
|
|
|
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).ToListAsync();
|
|
|
|
|
.WhereIF(!string.IsNullOrEmpty(item.VoynoInside), x => x.VOYNOINNER == item.VoynoInside).ToList();
|
|
|
|
|
|
|
|
|
|
_logger.LogInformation($"同步船期_查询到{UserManager.TENANT_NAME}需要更新{order.Count()}条订舱数据");
|
|
|
|
|
foreach (var it in order)
|
|
|
|
@ -577,6 +584,9 @@ 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 linelist = await _repline.AsQueryable().Filter(null, true).Where(m => m.TenantId == UserManager.TENANT_ID).ToListAsync();
|
|
|
|
|
|
|
|
|
|
foreach (var model in list)
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrWhiteSpace(model.BSNO))
|
|
|
|
@ -588,12 +598,12 @@ namespace Myshipping.Application
|
|
|
|
|
throw Oops.Bah("未录入创建人");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var user = await _repUser.AsQueryable().Filter(null, true).Where(x => x.Name == model.CreatedUserName.Trim() && x.IsDeleted == false).FirstAsync();
|
|
|
|
|
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 = await _rep.AsQueryable().Filter(null, true).Where(x => x.BSNO == model.BSNO && x.IsDeleted == false).FirstAsync();
|
|
|
|
|
var order = orderlist.Where(x => x.BSNO == model.BSNO ).FirstOrDefault();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (order == null)
|
|
|
|
@ -677,7 +687,7 @@ namespace Myshipping.Application
|
|
|
|
|
}
|
|
|
|
|
if (!string.IsNullOrEmpty(entity.LineName))
|
|
|
|
|
{
|
|
|
|
|
var line = _repline.AsQueryable().Filter(null, true).Where(m => m.TenantId == UserManager.TENANT_ID && m.LineName.Contains(entity.LineName)).FirstAsync();
|
|
|
|
|
var line = linelist.Where(m => m.LineName.Contains(entity.LineName)).FirstOrDefault();
|
|
|
|
|
if (line == null)
|
|
|
|
|
{
|
|
|
|
|
await _repline.InsertAsync(new DjyTenantLine
|
|
|
|
@ -1663,10 +1673,12 @@ namespace Myshipping.Application
|
|
|
|
|
[SqlSugarUnitOfWork]
|
|
|
|
|
public async Task SaveSyncVesselDate(List<DjyVesselDto> 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();
|
|
|
|
|
|
|
|
|
|
foreach (var item in dto)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
var model = _vesselinfo.AsQueryable().Filter(null, true).Where(x => x.Vessel == item.Vessel && x.Voyno == item.Voyno && x.TenantId == UserManager.TENANT_ID).First();
|
|
|
|
|
var model = infolist.Where(x => x.Vessel == item.Vessel && x.Voyno == item.Voyno).FirstOrDefault();
|
|
|
|
|
if (model != null)
|
|
|
|
|
{
|
|
|
|
|
model.ETA = item.ETA;
|
|
|
|
@ -1675,7 +1687,7 @@ namespace Myshipping.Application
|
|
|
|
|
await _vesselinfo.AsUpdateable(model).IgnoreColumns().ExecuteCommandAsync();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var order = await _rep.AsQueryable().Filter(null, true).Where(x => x.VESSEL == item.Vessel && x.VOYNO == item.Voyno && x.TenantId == UserManager.TENANT_ID && x.IsDeleted == false).ToListAsync();
|
|
|
|
|
var order = orderlist.Where(x => x.VESSEL == item.Vessel && x.VOYNO == item.Voyno).ToList();
|
|
|
|
|
bool issend = false;
|
|
|
|
|
if (order != null)
|
|
|
|
|
{
|
|
|
|
@ -1800,6 +1812,7 @@ namespace Myshipping.Application
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -1812,16 +1825,16 @@ namespace Myshipping.Application
|
|
|
|
|
[SqlSugarUnitOfWork]
|
|
|
|
|
public async Task SaveSyncGHVesselDate(List<DjyVesselGHDto> dto)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
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 = _vesselinfo.AsQueryable().Filter(null, true).Where(x => x.Vessel == item.Vessel && x.Voyno == item.Voyno && x.TenantId == UserManager.TENANT_ID).First();
|
|
|
|
|
//var model = _vesselinfo.AsQueryable().Filter(null, true).Where(x => x.Vessel == item.Vessel && x.Voyno == item.Voyno && x.TenantId == UserManager.TENANT_ID).FirstOrDefault();
|
|
|
|
|
//model.ETA = item.ETA;
|
|
|
|
|
//model.ETD = item.ETD;
|
|
|
|
|
//model.ATD = item.ATD;
|
|
|
|
|
//await _vesselinfo.AsUpdateable(model).IgnoreColumns().ExecuteCommandAsync();
|
|
|
|
|
var order = await _rep.AsQueryable().Filter(null, true).Where(x => x.VESSEL == item.Vessel && x.VOYNO == item.Voyno && x.TenantId == UserManager.TENANT_ID && x.IsDeleted == false).ToListAsync();
|
|
|
|
|
var order = orderlist.Where(x => x.VESSEL == item.Vessel && x.VOYNO == item.Voyno).ToList();
|
|
|
|
|
|
|
|
|
|
bool issend = false;
|
|
|
|
|
if (order != null)
|
|
|
|
@ -2153,9 +2166,97 @@ namespace Myshipping.Application
|
|
|
|
|
}
|
|
|
|
|
//推送钉钉消息
|
|
|
|
|
DingTalkGroupHelper.SendDingTalkGroupMessage("hechuanVesselExcepNotify", "船期获取异常提醒", msg);
|
|
|
|
|
|
|
|
|
|
//推送和川钉钉群,@具体操作
|
|
|
|
|
SyncVesselExcepAtOp(dto);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//[HttpPost("/DataSync/SyncVesselDateTest"), ApiUser(ApiCode = "SaveSyncVesselDate")]
|
|
|
|
|
//public async Task SyncVesselDateTest(List<DjyVesselExceptDto> dto)
|
|
|
|
|
private async Task SyncVesselExcepAtOp(List<DjyVesselExceptDto> dto)
|
|
|
|
|
{
|
|
|
|
|
var tenantId = UserManager.TENANT_ID;
|
|
|
|
|
SpareTime.DoOnce(1000, (tmr, l) =>
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
_logger.LogInformation($"SaveSyncVesselDate @通知执行");
|
|
|
|
|
int maxSendLimit = 20; //钉钉每分钟发送限制
|
|
|
|
|
|
|
|
|
|
var usrList = _repUser.AsQueryable().Filter(null, true).Where(u => u.TenantId == tenantId && !u.IsDeleted).ToList();
|
|
|
|
|
Dictionary<string, List<string>> dic = new Dictionary<string, List<string>>();
|
|
|
|
|
|
|
|
|
|
//遍历船名航次,查询订舱数据
|
|
|
|
|
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 phoneList = usrList.Where(u => boUserList.Contains(u.Id) && u.Phone != "" && u.Phone != null).Select(x => x.Phone).ToList();
|
|
|
|
|
|
|
|
|
|
foreach (var phone in phoneList)
|
|
|
|
|
{
|
|
|
|
|
var msg = $"船名:{item.Vessel},航次:{item.Voyno},{item.Message}";
|
|
|
|
|
if (dic.ContainsKey(phone))
|
|
|
|
|
{
|
|
|
|
|
dic[phone].Add(msg);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
dic.Add(phone, new List<string>(new string[] { msg }));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_logger.LogInformation($"处理发送后,准备给{dic.Count}个用户发送通知");
|
|
|
|
|
|
|
|
|
|
if (dic.Count > maxSendLimit) //大于限制,分多次发送
|
|
|
|
|
{
|
|
|
|
|
int times = (int)Math.Ceiling(dic.Count * 1.0 / maxSendLimit);
|
|
|
|
|
_logger.LogInformation($"发送通知超限,准备分为{times}次发送");
|
|
|
|
|
for (var t = 0; t < times; t++)
|
|
|
|
|
{
|
|
|
|
|
var keyList = dic.Keys.Skip(t * maxSendLimit).Take(maxSendLimit);
|
|
|
|
|
var currTimes = t + 1;
|
|
|
|
|
SpareTime.DoOnce(t == 0 ? 1000 : 70 * 1000 * t, doWhat: (st, val) =>
|
|
|
|
|
{
|
|
|
|
|
_logger.LogInformation($"超限第{currTimes}次发送,共{keyList.Count()}个");
|
|
|
|
|
foreach (var k in keyList)
|
|
|
|
|
{
|
|
|
|
|
var content = string.Join("\r\n", dic[k]);
|
|
|
|
|
_logger.LogInformation($"准备发送船期通知给 {k},内容:\r\n{content}");
|
|
|
|
|
//DingTalkGroupHelper.SendDingTalkGroupMessage("", "船期提醒", content, false, new string[] { k }, null);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
foreach (var item in dic)
|
|
|
|
|
{
|
|
|
|
|
var content = string.Join("\r\n", item.Value);
|
|
|
|
|
_logger.LogInformation($"准备发送船期通知给 {item.Key},内容:\r\n{content}");
|
|
|
|
|
//DingTalkGroupHelper.SendDingTalkGroupMessage("", "船期提醒", content, false, new string[] { item.Key }, null);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
var excep = ex;
|
|
|
|
|
while (excep != null)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError(excep.Message);
|
|
|
|
|
_logger.LogError(excep.StackTrace);
|
|
|
|
|
|
|
|
|
|
excep = excep.InnerException;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 下载数据
|
|
|
|
|