You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

656 lines
33 KiB
C#

using Furion.DependencyInjection;
using Furion.DynamicApiController;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Myshipping.Core;
using Myshipping.Core.Service;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Myshipping.Application.Entity;
using Furion.FriendlyException;
using Newtonsoft.Json.Linq;
using Furion.RemoteRequest.Extensions;
using System.Net.Http;
using Myshipping.Application.Service.BookingYunZong.Dto;
using Myshipping.Core.Entity;
namespace Myshipping.Application
{
/// <summary>
/// 运踪模块
/// </summary>
[ApiDescriptionSettings("Application", Name = "BookingYunZong", Order = 1)]
public class BookingYunZongService : IBookingYunZong, IDynamicApiController, ITransient
{
private readonly ILogger<BookingYunZongService> _logger;
private readonly ISysCacheService _cache;
private readonly IDjyWebsiteAccountConfigService _account;
private readonly SqlSugarRepository<BookingOrder> _rep;
private readonly SqlSugarRepository<BookingStatusLog> _repStatuslog;
private readonly SqlSugarRepository<BookingStatusLogDetail> _statuslogdetail;
private readonly SqlSugarRepository<BookingStatus> _repBookingStatus;
private readonly IBookingOrderService _bookingorderservice;
public BookingYunZongService(ILogger<BookingYunZongService> logger, ISysCacheService cache, IDjyWebsiteAccountConfigService account, SqlSugarRepository<BookingStatus> repBookingStatus,
SqlSugarRepository<BookingOrder> rep, SqlSugarRepository<BookingStatusLog> repStatuslog, SqlSugarRepository<BookingStatusLogDetail> statuslogdetail, IBookingOrderService bookingorderservice)
{
_cache = cache;
_account = account;
this._logger = logger;
_rep = rep;
1 year ago
_repStatuslog = repStatuslog;
_statuslogdetail = statuslogdetail;
_repBookingStatus = repBookingStatus;
_bookingorderservice = bookingorderservice;
}
/// <summary>
/// 刷新运踪
/// </summary>
/// <param name="Ids"></param>
/// <returns></returns>
public async Task RefreshYunZong(long[] Ids)
{
var order = await _rep.AsQueryable().Filter(null, true).Where(x => Ids.Contains(x.Id)).ToListAsync();
var key = _cache.GetAllSysConfig().Result.Where(x => x.Code == "billTraceNewUserKey").Select(x => x.Value).FirstOrDefault();
if (string.IsNullOrEmpty(key))
{
throw Oops.Bah("未获取到相关KEY请联系管理员");
}
var url = _cache.GetAllDictData().Result.Where(x => x.Code == "billTraceYgtUrl").Select(x => x.Value).FirstOrDefault();
var secret = _cache.GetAllSysConfig().Result.Where(x => x.Code == "billTraceNewUserSecret").Select(x => x.Value).FirstOrDefault();
if (string.IsNullOrEmpty(secret))
{
throw Oops.Bah("未获取到相关SECRET请联系管理员");
}
JObject jobjSend = new JObject();
jobjSend.Add("user_key", new JValue(key));
jobjSend.Add("user_secret", new JValue(secret));
jobjSend.Add("customer_id", new JValue(UserManager.TENANT_ID));
jobjSend.Add("customer_name", new JValue(UserManager.TENANT_NAME));
JArray jarrCZTemos = new JArray();
JArray jarrHLWTemos = new JArray();
JArray jarrYGTTemos = new JArray();
foreach (var item in order)
{
if (!string.IsNullOrEmpty(item.YARDID) && !string.IsNullOrEmpty(item.MBLNO))
{
JObject jobjczTemp = new JObject();
jobjczTemp.Add("web_code", new JValue(item.YARDID));
jobjczTemp.Add("bno", new JValue(item.MBLNO.Trim()));
jarrCZTemos.Add(jobjczTemp);
}
JObject jobjhlwTemp = new JObject();
jobjhlwTemp.Add("web_code", "HLW_CD");
jobjhlwTemp.Add("bno", new JValue(item.MBLNO.Trim()));
jarrHLWTemos.Add(jobjhlwTemp);
JObject jobjygtTemp = new JObject();
jobjygtTemp.Add("web_code", "YGT_YZ");
jobjygtTemp.Add("bno", new JValue(item.MBLNO.Trim()));
jarrYGTTemos.Add(jobjygtTemp);
}
if (jarrCZTemos.Count > 0)
{
jobjSend.Add("data_list", "");
jobjSend.Add("data_list", jarrCZTemos);
var json = jobjSend.ToJsonString();
_logger.LogInformation("运踪查询场站参数:" + json);
var rtn = await url.SetHttpMethod(HttpMethod.Post).SetBody(jobjSend.ToJsonString()).PostAsStringAsync();
_logger.LogInformation("运踪查询场站查询结果:" + rtn);
await ExecuteYard(rtn);
}
if (jarrHLWTemos.Count > 0)
{
jobjSend.Add("data_list", "");
jobjSend.Add("data_list", jarrHLWTemos);
var json = jobjSend.ToJsonString();
_logger.LogInformation("运踪查询HLW+参数:" + json);
var rtn = await url.SetHttpMethod(HttpMethod.Post).SetBody(jobjSend.ToJsonString()).PostAsStringAsync();
_logger.LogInformation("运踪查询HLW+查询结果:" + rtn);
await ExecuteHLW(rtn);
}
if (jarrYGTTemos.Count > 0)
{
jobjSend.Add("data_list", "");
jobjSend.Add("data_list", jarrYGTTemos);
var json = jobjSend.ToJsonString();
_logger.LogInformation("运踪查询YGT参数" + json);
var rtn = await url.SetHttpMethod(HttpMethod.Post).SetBody(jobjSend.ToJsonString()).PostAsStringAsync();
_logger.LogInformation("运踪查询YGT查询结果" + rtn);
await ExecuteYGT(rtn);
}
}
[SqlSugarUnitOfWork]
public async Task ExecuteYard(string rtn)
{
JObject jobjRtn = JObject.Parse(rtn);
var code = jobjRtn.GetValue("code").ToString();
var msg = jobjRtn.GetValue("msg").ToString();
if (code != "200")
{
_logger.LogError($"请求爬虫获取【场站数据】出错:{msg}");
return;
}
JArray jarrData = jobjRtn.GetValue("data") as JArray;
foreach (JObject item in jarrData)
{
//每票 货物
var mblno = item.GetValue("bno").ToString();
var bookingId = await _rep.AsQueryable().Filter(null, true).Where(x => x.MBLNO == mblno).Select(x => x.Id).FirstAsync();
var jarrInnerData = item.GetValue("data") as JArray;
List<YardDataDto> yarddto = new List<YardDataDto>();
foreach (JObject dataItem in jarrInnerData)
{
var CNTRNO = dataItem.GetStringValue("CNTRNO"); //箱号
var TiXiangShiJian = dataItem.GetDateTimeValue("TiXiangShiJian"); //提箱时间
var FanChangShiJian = dataItem.GetDateTimeValue("FanChangShiJian"); //返厂时间
var XiangLiang = dataItem.GetIntValue("XiangLiang"); //箱量
yarddto.Add(new YardDataDto
{
CNTRNO = CNTRNO,
TiXiangShiJian = TiXiangShiJian,
FanChangShiJian = FanChangShiJian,
XiangLiang = XiangLiang,
});
}
var xl = yarddto.Select(x => x.XiangLiang).FirstOrDefault();
var tinum = yarddto.Where(x => x.TiXiangShiJian != null).Count();
var fcnum = yarddto.Where(x => x.FanChangShiJian != null).Count();
var old = await _repStatuslog.AsQueryable().Filter(null, true).Where(x => x.BookingId == bookingId && x.Category == "yunzong" && x.IsDeleted == false && (x.Status == "提箱" || x.Status == "返场")).ToListAsync();
1 year ago
var oldid = old.Select(x => x.Id).ToList();
await _repStatuslog.DeleteAsync(x => oldid.Contains(x.Id));
await _statuslogdetail.DeleteAsync(x => oldid.Contains(x.PId));
if (xl > 0 && tinum > 0)
{
//新增数据
var bookingStatusLog = new BookingStatusLog();
bookingStatusLog.BookingId = bookingId;
bookingStatusLog.Category = "yunzong";
bookingStatusLog.CreatedTime = DateTime.Now;
bookingStatusLog.Status = "提箱";
bookingStatusLog.OpTime = xl == tinum ? yarddto.Select(x => x.TiXiangShiJian).Max() : null;
bookingStatusLog.MBLNO = mblno;
await _repStatuslog.InsertAsync(bookingStatusLog);
foreach (var dt in yarddto)
{
var BookingStatusLogDetail = new BookingStatusLogDetail();
BookingStatusLogDetail.PId = bookingStatusLog.Id;
BookingStatusLogDetail.Status = "提箱";
BookingStatusLogDetail.CNTRNO = dt.CNTRNO;
BookingStatusLogDetail.OPTime = dt.TiXiangShiJian;
await _statuslogdetail.InsertAsync(BookingStatusLogDetail);
}
}
if (xl > 0 && fcnum > 0)
{
//新增数据
var bookingStatusLog = new BookingStatusLog();
bookingStatusLog.BookingId = bookingId;
bookingStatusLog.Category = "yunzong";
bookingStatusLog.CreatedTime = DateTime.Now;
bookingStatusLog.Status = "返场";
bookingStatusLog.OpTime = xl == tinum ? yarddto.Select(x => x.FanChangShiJian).Max() : null;
bookingStatusLog.MBLNO = mblno;
await _repStatuslog.InsertAsync(bookingStatusLog);
foreach (var dt in yarddto)
{
var BookingStatusLogDetail = new BookingStatusLogDetail();
BookingStatusLogDetail.PId = bookingStatusLog.Id;
BookingStatusLogDetail.Status = "返场";
BookingStatusLogDetail.CNTRNO = dt.CNTRNO;
BookingStatusLogDetail.OPTime = dt.FanChangShiJian;
await _statuslogdetail.InsertAsync(BookingStatusLogDetail);
}
}
}
}
[SqlSugarUnitOfWork]
public async Task ExecuteHLW(string rtn)
{
JObject jobjRtn = JObject.Parse(rtn);
var code = jobjRtn.GetValue("code").ToString();
var msg = jobjRtn.GetValue("msg").ToString();
if (code != "200")
{
_logger.LogError($"请求爬虫获取【HLW+数据】出错:{msg}");
return;
}
var dicdatalist = _cache.GetAllDictData().Result;
JArray jarrData = jobjRtn.GetValue("data") as JArray;
foreach (JObject item in jarrData)
{
//每票 货物
var mblno = item.GetValue("bno").ToString();
var bookingId = await _rep.AsQueryable().Filter(null, true).Where(x => x.MBLNO == mblno).Select(x => x.Id).FirstAsync();
var list = await _repBookingStatus.AsQueryable().Filter(null, true).InnerJoin<SysDictData>((d, t) => d.StaCode == t.Code && d.StaCate == "book_sta_cate_billtrace" && d.BookingId == bookingId).Select((d, t) => new
{
BookingId = d.BookingId,
StaCode = d.StaCode,
StaName = d.StaName,
StaTime = d.StaTime,
Code = t.Code,
Value = t.Value
}).ToListAsync();
var jarrInnerData = item.GetValue("data") as JArray;
1 year ago
DateTime? TimeCangDan = null;
DateTime? FangXingShiJian = null;
foreach (JObject dataItem in jarrInnerData)
{
TimeCangDan = dataItem.GetDateTimeValue("YuPeiShiJian"); //舱单时间
FangXingShiJian = dataItem.GetDateTimeValue("FangXingShiJian"); //放行时间
}
await _repStatuslog.DeleteAsync(x => x.BookingId == bookingId && x.Category == "yunzong" && (x.Status == "舱单" || x.Status == "报关"));
if (TimeCangDan != null)
{
//新增数据
var bookingStatusLog = new BookingStatusLog();
bookingStatusLog.BookingId = bookingId;
bookingStatusLog.Category = "yunzong";
bookingStatusLog.CreatedTime = DateTime.Now;
bookingStatusLog.Status = "舱单";
bookingStatusLog.OpTime = TimeCangDan;
bookingStatusLog.MBLNO = mblno;
await _repStatuslog.InsertAsync(bookingStatusLog);
if (list.Where(x => x.StaCode == "sta_cangdan").FirstOrDefault() == null)
{
BookingStatus bookingStatus = new BookingStatus();
bookingStatus.BookingId = bookingId;
bookingStatus.StaCode = "sta_cangdan";
bookingStatus.StaName = dicdatalist.Where(x => x.Code == "sta_cangdan").Select(x => x.Value).FirstOrDefault();
bookingStatus.StaTime = TimeCangDan;
bookingStatus.StaCate = "book_sta_cate_billtrace";
await _repBookingStatus.InsertAsync(bookingStatus);
}
}
if (FangXingShiJian != null)
{
//新增数据
var bookingStatusLog = new BookingStatusLog();
bookingStatusLog.BookingId = bookingId;
bookingStatusLog.Category = "yunzong";
bookingStatusLog.CreatedTime = DateTime.Now;
bookingStatusLog.Status = "报关";
bookingStatusLog.OpTime = FangXingShiJian;
bookingStatusLog.MBLNO = mblno;
await _repStatuslog.InsertAsync(bookingStatusLog);
if (list.Where(x => x.Code == "sta_haifang").FirstOrDefault() == null)
{
BookingStatus bookingStatus = new BookingStatus();
bookingStatus.BookingId = bookingId;
bookingStatus.StaCode = "sta_haifang";
bookingStatus.StaName = dicdatalist.Where(x => x.Code == "sta_haifang").Select(x => x.Value).FirstOrDefault();
bookingStatus.StaTime = FangXingShiJian;
bookingStatus.StaCate = "book_sta_cate_billtrace";
await _repBookingStatus.InsertAsync(bookingStatus);
await _bookingorderservice.SetGoodsStatus("BG", bookingId);
await _bookingorderservice.SendBookingOrder(new long[] { bookingId });
}
}
}
}
[SqlSugarUnitOfWork]
public async Task ExecuteYGT(string rtn)
{
JObject jobjRtn = JObject.Parse(rtn);
var code = jobjRtn.GetValue("code").ToString();
var msg = jobjRtn.GetValue("msg").ToString();
if (code != "200")
{
_logger.LogError($"请求爬虫获取【YGT数据】出错{msg}");
return;
}
var dicdatalist = _cache.GetAllDictData().Result;
JArray jarrData = jobjRtn.GetValue("data") as JArray;
foreach (JObject item in jarrData)
{
//每票 货物
var mblno = item.GetValue("bno").ToString();
1 year ago
var bookingOrder = await _rep.AsQueryable().Filter(null, true).Where(x => x.MBLNO == mblno && x.IsDeleted == false).FirstAsync();
var list = await _repBookingStatus.AsQueryable().Filter(null, true).InnerJoin<SysDictData>((d, t) => d.StaCode == t.Code && d.StaCate == "book_sta_cate_billtrace" && d.BookingId == bookingOrder.Id).Select((d, t) => new
{
BookingId = d.BookingId,
StaCode = d.StaCode,
StaName = d.StaName,
StaTime = d.StaTime,
Code = t.Code,
Value = t.Value
}).ToListAsync();
var jarrInnerData = item.GetValue("data") as JArray;
1 year ago
List<YGTDataDto> ygtdto = new List<YGTDataDto>();
DateTime? SJLGShiJian = null;//ATD
DateTime? YJDGShiJian = null;//ETA
DateTime? SJDGShiJian = null;//ATA
DateTime? YJLGShiJian = null;//ETD
int xl = 0;
foreach (JObject dataItem in jarrInnerData)
{
1 year ago
SJLGShiJian = dataItem.GetDateTimeValue("sjlg_time"); //实际离港时间
YJDGShiJian = dataItem.GetDateTimeValue("yjdk_time"); //预计到港时间
SJDGShiJian = dataItem.GetDateTimeValue("sjdk_time"); //实际到港时间
YJLGShiJian = dataItem.GetDateTimeValue("yjlk_time"); //预计离港时间
var xh_info = dataItem.GetValue("xh_info") as JArray;
xl = xh_info.Count();
foreach (JObject it in xh_info)
{
var CNTRNO = it.GetStringValue("ctn_no"); //箱号
var yd_time = it.GetDateTimeValue("yd_time"); //运抵时间
var wl_time = it.GetDateTimeValue("wl_time"); //外理时间
var mtfx = it.GetStringValue("mtfx"); //码头放行
var zz_time = it.GetDateTimeValue("zz_time"); //装载时间
var ck_time = it.GetDateTimeValue("ck_time"); //装船时间
var rg_time = it.GetDateTimeValue("rg_time"); //入港时间
ygtdto.Add(new YGTDataDto
{
CNTRNO = CNTRNO,
YunDiShiJian = yd_time,
WaiLiShiJian = wl_time,
MTFX = mtfx,
ZhuangzhaiShiJian = zz_time,
ZhuangChuanShiJian = ck_time,
RuGangShiJian = rg_time
});
}
}
1 year ago
var rgnum = ygtdto.Where(x => x.RuGangShiJian != null).Count();
var ydnum = ygtdto.Where(x => x.YunDiShiJian != null).Count();
var zznum = ygtdto.Where(x => x.ZhuangzhaiShiJian != null).Count();
var wlnum = ygtdto.Where(x => x.WaiLiShiJian != null).Count();
var mfnum = ygtdto.Where(x => x.MTFX == "Y").Count();
var zcnum = ygtdto.Where(x => x.ZhuangChuanShiJian != null).Count();
var old = await _repStatuslog.AsQueryable().Filter(null, true).Where(x => x.BookingId == bookingOrder.Id && x.Category == "yunzong" && x.IsDeleted == false && (x.Status == "运抵" || x.Status == "装载" || x.Status == "外理" || x.Status == "码放" || x.Status == "装船" || x.Status == "入港" || x.Status == "ATD")).ToListAsync();
var oldid = old.Select(x => x.Id).ToList();
await _repStatuslog.DeleteAsync(x => oldid.Contains(x.Id));
await _statuslogdetail.DeleteAsync(x => oldid.Contains(x.PId));
if (xl > 0 && rgnum > 0)
{
//新增数据
var bookingStatusLog = new BookingStatusLog();
bookingStatusLog.BookingId = bookingOrder.Id;
bookingStatusLog.Category = "yunzong";
bookingStatusLog.CreatedTime = DateTime.Now;
bookingStatusLog.Status = "入港";
bookingStatusLog.OpTime = xl == ydnum ? ygtdto.Select(x => x.RuGangShiJian).Max() : null;
bookingStatusLog.MBLNO = mblno;
await _repStatuslog.InsertAsync(bookingStatusLog);
1 year ago
foreach (var dt in ygtdto)
{
var BookingStatusLogDetail = new BookingStatusLogDetail();
BookingStatusLogDetail.PId = bookingStatusLog.Id;
BookingStatusLogDetail.Status = "入港";
BookingStatusLogDetail.CNTRNO = dt.CNTRNO;
BookingStatusLogDetail.OPTime = dt.RuGangShiJian;
await _statuslogdetail.InsertAsync(BookingStatusLogDetail);
}
}
if (xl > 0 && ydnum > 0)
{
//新增数据
var bookingStatusLog = new BookingStatusLog();
1 year ago
bookingStatusLog.BookingId = bookingOrder.Id;
bookingStatusLog.Category = "yunzong";
bookingStatusLog.CreatedTime = DateTime.Now;
1 year ago
bookingStatusLog.Status = "运抵";
bookingStatusLog.OpTime = xl == ydnum ? ygtdto.Select(x => x.YunDiShiJian).Max() : null;
bookingStatusLog.MBLNO = mblno;
await _repStatuslog.InsertAsync(bookingStatusLog);
1 year ago
foreach (var dt in ygtdto)
{
1 year ago
var BookingStatusLogDetail = new BookingStatusLogDetail();
BookingStatusLogDetail.PId = bookingStatusLog.Id;
BookingStatusLogDetail.Status = "运抵";
BookingStatusLogDetail.CNTRNO = dt.CNTRNO;
BookingStatusLogDetail.OPTime = dt.YunDiShiJian;
await _statuslogdetail.InsertAsync(BookingStatusLogDetail);
}
1 year ago
}
1 year ago
if (xl > 0 && zznum > 0 && zznum == xl)
{
//新增数据
var bookingStatusLog = new BookingStatusLog();
bookingStatusLog.BookingId = bookingOrder.Id;
bookingStatusLog.Category = "yunzong";
bookingStatusLog.CreatedTime = DateTime.Now;
bookingStatusLog.Status = "装载";
bookingStatusLog.OpTime = xl == zznum ? ygtdto.Select(x => x.ZhuangzhaiShiJian).Max() : null;
bookingStatusLog.MBLNO = mblno;
await _repStatuslog.InsertAsync(bookingStatusLog);
}
if (xl > 0 && wlnum > 0 && wlnum == xl)
{
//新增数据
var bookingStatusLog = new BookingStatusLog();
bookingStatusLog.BookingId = bookingOrder.Id;
bookingStatusLog.Category = "yunzong";
bookingStatusLog.CreatedTime = DateTime.Now;
bookingStatusLog.Status = "外理";
bookingStatusLog.OpTime = null;
bookingStatusLog.MBLNO = mblno;
await _repStatuslog.InsertAsync(bookingStatusLog);
}
1 year ago
if (xl > 0 && mfnum > 0 && mfnum == xl)
{
//新增数据
var bookingStatusLog = new BookingStatusLog();
1 year ago
bookingStatusLog.BookingId = bookingOrder.Id;
bookingStatusLog.Category = "yunzong";
bookingStatusLog.CreatedTime = DateTime.Now;
1 year ago
bookingStatusLog.Status = "码放";
bookingStatusLog.OpTime = null;
bookingStatusLog.MBLNO = mblno;
await _repStatuslog.InsertAsync(bookingStatusLog);
1 year ago
}
if (xl > 0 && zcnum > 0)
{
//新增数据
var bookingStatusLog = new BookingStatusLog();
bookingStatusLog.BookingId = bookingOrder.Id;
bookingStatusLog.Category = "yunzong";
bookingStatusLog.CreatedTime = DateTime.Now;
bookingStatusLog.Status = "装船";
bookingStatusLog.OpTime = xl == ydnum ? ygtdto.Select(x => x.ZhuangChuanShiJian).Max() : null;
bookingStatusLog.MBLNO = mblno;
await _repStatuslog.InsertAsync(bookingStatusLog);
foreach (var dt in ygtdto)
{
var BookingStatusLogDetail = new BookingStatusLogDetail();
BookingStatusLogDetail.PId = bookingStatusLog.Id;
BookingStatusLogDetail.Status = "装船";
BookingStatusLogDetail.CNTRNO = dt.CNTRNO;
BookingStatusLogDetail.OPTime = dt.ZhuangChuanShiJian;
await _statuslogdetail.InsertAsync(BookingStatusLogDetail);
}
}
if (SJLGShiJian != null)
{
//新增数据
var bookingStatusLog = new BookingStatusLog();
bookingStatusLog.BookingId = bookingOrder.Id;
bookingStatusLog.Category = "yunzong";
bookingStatusLog.CreatedTime = DateTime.Now;
bookingStatusLog.Status = "ATD";
bookingStatusLog.OpTime = SJLGShiJian;
bookingStatusLog.MBLNO = mblno;
await _repStatuslog.InsertAsync(bookingStatusLog);
if (list.Where(x => x.Code == "sta_atd").FirstOrDefault() == null)
{
BookingStatus bookingStatus = new BookingStatus();
1 year ago
bookingStatus.BookingId = bookingOrder.Id;
bookingStatus.StaCode = "sta_haifang";
1 year ago
bookingStatus.StaName = dicdatalist.Where(x => x.Code == "sta_atd").Select(x => x.Value).FirstOrDefault();
bookingStatus.StaTime = SJLGShiJian;
bookingStatus.StaCate = "book_sta_cate_billtrace";
await _repBookingStatus.InsertAsync(bookingStatus);
}
}
1 year ago
bool open = false;
//ATD
if (SJLGShiJian != null && bookingOrder.ATD != SJLGShiJian)
{
var oldorder = bookingOrder;
bookingOrder.ATD = SJLGShiJian;
await _rep.UpdateAsync(x => x.Id == bookingOrder.Id, x => new BookingOrder { ATD = SJLGShiJian });
await _bookingorderservice.SaveLog(bookingOrder, oldorder);
open = true;
if (!string.IsNullOrEmpty(bookingOrder.VESSEL) && !string.IsNullOrEmpty(bookingOrder.VOYNO) && !string.IsNullOrEmpty(bookingOrder.CARRIERID))
{
var neworder = await _rep.AsQueryable().Filter(null, true).Where(x => x.VOYNO == bookingOrder.VOYNO && x.VESSEL == bookingOrder.VESSEL && x.CARRIERID == bookingOrder.CARRIERID && x.TenantId == bookingOrder.TenantId && x.IsDeleted == false && x.Id != bookingOrder.Id).ToListAsync();
foreach (var it in neworder)
{
var _oldorder = it;
if (it.ATD != SJLGShiJian)
{
it.ATD = SJLGShiJian;
await _rep.UpdateAsync(x => x.Id == it.Id, x => new BookingOrder { ATD = SJLGShiJian });
await _bookingorderservice.SaveLog(it, _oldorder);
await _bookingorderservice.SendBookingOrder(new long[] { it.Id });
}
}
}
}
//ETA
if (YJDGShiJian != null && bookingOrder.StartETA != YJDGShiJian)
{
var oldorder = bookingOrder;
bookingOrder.StartETA = YJDGShiJian;
await _rep.UpdateAsync(x => x.Id == bookingOrder.Id, x => new BookingOrder { StartETA = YJDGShiJian });
await _bookingorderservice.SaveLog(bookingOrder, oldorder);
open = true;
if (!string.IsNullOrEmpty(bookingOrder.VESSEL) && !string.IsNullOrEmpty(bookingOrder.VOYNO) && !string.IsNullOrEmpty(bookingOrder.CARRIERID))
{
var neworder = await _rep.AsQueryable().Filter(null, true).Where(x => x.VOYNO == bookingOrder.VOYNO && x.VESSEL == bookingOrder.VESSEL && x.CARRIERID == bookingOrder.CARRIERID && x.TenantId == bookingOrder.TenantId && x.IsDeleted == false && x.Id != bookingOrder.Id).ToListAsync();
foreach (var it in neworder)
{
var _oldorder = it;
if (it.StartETA != YJDGShiJian)
{
it.StartETA = YJDGShiJian;
await _rep.UpdateAsync(x => x.Id == it.Id, x => new BookingOrder { StartETA = YJDGShiJian });
await _bookingorderservice.SaveLog(it, _oldorder);
await _bookingorderservice.SendBookingOrder(new long[] { it.Id });
}
}
}
}
//ATA
if (SJDGShiJian != null && bookingOrder.StartATA != SJDGShiJian)
{
var oldorder = bookingOrder;
bookingOrder.StartATA = SJDGShiJian;
await _rep.UpdateAsync(x => x.Id == bookingOrder.Id, x => new BookingOrder { StartATA = SJDGShiJian });
await _bookingorderservice.SaveLog(bookingOrder, oldorder);
open = true;
if (!string.IsNullOrEmpty(bookingOrder.VESSEL) && !string.IsNullOrEmpty(bookingOrder.VOYNO) && !string.IsNullOrEmpty(bookingOrder.CARRIERID))
{
var neworder = await _rep.AsQueryable().Filter(null, true).Where(x => x.VOYNO == bookingOrder.VOYNO && x.VESSEL == bookingOrder.VESSEL && x.CARRIERID == bookingOrder.CARRIERID && x.TenantId == bookingOrder.TenantId && x.IsDeleted == false && x.Id != bookingOrder.Id).ToListAsync();
foreach (var it in neworder)
{
var _oldorder = it;
if (it.StartATA != SJDGShiJian)
{
it.StartATA = SJDGShiJian;
await _rep.UpdateAsync(x => x.Id == it.Id, x => new BookingOrder { StartATA = SJDGShiJian });
await _bookingorderservice.SaveLog(it, _oldorder);
await _bookingorderservice.SendBookingOrder(new long[] { it.Id });
}
}
}
}
//ETD
if (YJLGShiJian != null && bookingOrder.YgtETD != YJLGShiJian)
{
var oldorder = bookingOrder;
bookingOrder.YgtETD = YJLGShiJian;
await _rep.UpdateAsync(x => x.Id == bookingOrder.Id, x => new BookingOrder { YgtETD = YJLGShiJian });
await _bookingorderservice.SaveLog(bookingOrder, oldorder);
open = true;
if (!string.IsNullOrEmpty(bookingOrder.VESSEL) && !string.IsNullOrEmpty(bookingOrder.VOYNO) && !string.IsNullOrEmpty(bookingOrder.CARRIERID))
{
var neworder = await _rep.AsQueryable().Filter(null, true).Where(x => x.VOYNO == bookingOrder.VOYNO && x.VESSEL == bookingOrder.VESSEL && x.CARRIERID == bookingOrder.CARRIERID && x.TenantId == bookingOrder.TenantId && x.IsDeleted == false && x.Id != bookingOrder.Id).ToListAsync();
foreach (var it in neworder)
{
var _oldorder = it;
if (it.YgtETD != YJLGShiJian)
{
it.YgtETD = YJLGShiJian;
await _rep.UpdateAsync(x => x.Id == it.Id, x => new BookingOrder { YgtETD = YJLGShiJian });
await _bookingorderservice.SaveLog(it, _oldorder);
await _bookingorderservice.SendBookingOrder(new long[] { it.Id });
}
}
}
}
if (open)
{
await _bookingorderservice.SendBookingOrder(new long[] { bookingOrder.Id });
}
}
}
}
}