wanghaomei 1 year ago
commit afdef107b1

@ -1202,7 +1202,6 @@ namespace Myshipping.Application
await _rep.UpdateAsync(x => x.Id == Id, x => new BookingOrder { IsDeleted = true }); await _rep.UpdateAsync(x => x.Id == Id, x => new BookingOrder { IsDeleted = true });
await _bookingEDIExt.UpdateAsync(x => x.BookingId == Id && x.IsDeleted == false, x => new BookingEDIExt { IsDeleted = true }); await _bookingEDIExt.UpdateAsync(x => x.BookingId == Id && x.IsDeleted == false, x => new BookingEDIExt { IsDeleted = true });
_logger.LogInformation(mblno + "删除成功!"); _logger.LogInformation(mblno + "删除成功!");
} }
else else
{ {
@ -8248,18 +8247,20 @@ namespace Myshipping.Application
{ {
StatusName = ""; StatusName = "";
} }
order.BSSTATUSNAME = StatusName; //order.BSSTATUSNAME = StatusName;
await _rep.AsUpdateable(order).IgnoreColumns(it => new //await _rep.AsUpdateable(order).IgnoreColumns(it => new
{ //{
it.ParentId, // it.ParentId,
it.TenantId, // it.TenantId,
it.CreatedTime, // it.CreatedTime,
it.CreatedUserId, // it.CreatedUserId,
it.CreatedUserName, // it.CreatedUserName,
it.TenantName, // it.TenantName,
it.IsDeleted, // it.IsDeleted,
it.BOOKINGNO // it.BOOKINGNO
}).ExecuteCommandAsync(); //}).ExecuteCommandAsync();
await _rep.UpdateAsync(x => x.Id == bookingId, x => new BookingOrder { BSSTATUSNAME = StatusName });
} }
} }

@ -40,7 +40,7 @@ namespace Myshipping.Application
_account = account; _account = account;
this._logger = logger; this._logger = logger;
_rep = rep; _rep = rep;
repStatuslog = _repStatuslog; _repStatuslog = repStatuslog;
_statuslogdetail = statuslogdetail; _statuslogdetail = statuslogdetail;
_repBookingStatus = repBookingStatus; _repBookingStatus = repBookingStatus;
_bookingorderservice = bookingorderservice; _bookingorderservice = bookingorderservice;
@ -51,6 +51,7 @@ namespace Myshipping.Application
/// </summary> /// </summary>
/// <param name="Ids"></param> /// <param name="Ids"></param>
/// <returns></returns> /// <returns></returns>
[HttpPost("/BookingYunZong/RefreshYunZong")]
public async Task RefreshYunZong(long[] Ids) public async Task RefreshYunZong(long[] Ids)
{ {
var order = await _rep.AsQueryable().Filter(null, true).Where(x => Ids.Contains(x.Id)).ToListAsync(); var order = await _rep.AsQueryable().Filter(null, true).Where(x => Ids.Contains(x.Id)).ToListAsync();
@ -128,7 +129,7 @@ namespace Myshipping.Application
} }
[NonAction]
[SqlSugarUnitOfWork] [SqlSugarUnitOfWork]
public async Task ExecuteYard(string rtn) public async Task ExecuteYard(string rtn)
{ {
@ -176,11 +177,9 @@ namespace Myshipping.Application
var tinum = yarddto.Where(x => x.TiXiangShiJian != null).Count(); var tinum = yarddto.Where(x => x.TiXiangShiJian != null).Count();
var fcnum = yarddto.Where(x => x.FanChangShiJian != 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(); var old = await _repStatuslog.AsQueryable().Filter(null, true).Where(x => x.BookingId == bookingId && x.Category == "yunzong" && x.IsDeleted == false && (x.Status == "提箱" || x.Status == "返场")).ToListAsync();
await _repStatuslog.DeleteAsync(x => x.BookingId == bookingId && x.Category == "yunzong" && (x.Status == "提箱" || x.Status == "返场")); var oldid = old.Select(x => x.Id).ToList();
foreach (var ot in old) await _repStatuslog.DeleteAsync(x => oldid.Contains(x.Id));
{ await _statuslogdetail.DeleteAsync(x => oldid.Contains(x.PId));
await _statuslogdetail.DeleteAsync(x => x.PId == ot.Id);
}
if (xl > 0 && tinum > 0) if (xl > 0 && tinum > 0)
{ {
@ -232,7 +231,7 @@ namespace Myshipping.Application
} }
[NonAction]
[SqlSugarUnitOfWork] [SqlSugarUnitOfWork]
public async Task ExecuteHLW(string rtn) public async Task ExecuteHLW(string rtn)
{ {
@ -266,7 +265,7 @@ namespace Myshipping.Application
Value = t.Value Value = t.Value
}).ToListAsync(); }).ToListAsync();
var jarrInnerData = item.GetValue("data") as JArray; var jarrInnerData = item.GetValue("data") as JArray;
List<YardDataDto> yarddto = new List<YardDataDto>();
DateTime? TimeCangDan = null; DateTime? TimeCangDan = null;
DateTime? FangXingShiJian = null; DateTime? FangXingShiJian = null;
@ -330,7 +329,7 @@ namespace Myshipping.Application
} }
} }
[NonAction]
[SqlSugarUnitOfWork] [SqlSugarUnitOfWork]
public async Task ExecuteYGT(string rtn) public async Task ExecuteYGT(string rtn)
{ {
@ -348,11 +347,10 @@ namespace Myshipping.Application
foreach (JObject item in jarrData) foreach (JObject item in jarrData)
{ {
//每票 货物 //每票 货物
var mblno = item.GetValue("bno").ToString(); 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 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 == bookingId).Select((d, t) => new 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, BookingId = d.BookingId,
StaCode = d.StaCode, StaCode = d.StaCode,
@ -362,67 +360,297 @@ namespace Myshipping.Application
Value = t.Value Value = t.Value
}).ToListAsync(); }).ToListAsync();
var jarrInnerData = item.GetValue("data") as JArray; var jarrInnerData = item.GetValue("data") as JArray;
List<YardDataDto> yarddto = new List<YardDataDto>(); List<YGTDataDto> ygtdto = new List<YGTDataDto>();
DateTime? TimeCangDan = null; DateTime? SJLGShiJian = null;//ATD
DateTime? FangXingShiJian = null; DateTime? YJDGShiJian = null;//ETA
DateTime? SJDGShiJian = null;//ATA
DateTime? YJLGShiJian = null;//ETD
int xl = 0;
foreach (JObject dataItem in jarrInnerData) foreach (JObject dataItem in jarrInnerData)
{ {
TimeCangDan = dataItem.GetDateTimeValue("YuPeiShiJian"); //舱单时间 SJLGShiJian = dataItem.GetDateTimeValue("sjlg_time"); //实际离港时间
FangXingShiJian = dataItem.GetDateTimeValue("FangXingShiJian"); //放行时间 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
});
} }
await _repStatuslog.DeleteAsync(x => x.BookingId == bookingId && x.Category == "yunzong" && (x.Status == "舱单" || x.Status == "报关")); }
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);
if (TimeCangDan != null) 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(); var bookingStatusLog = new BookingStatusLog();
bookingStatusLog.BookingId = bookingId; bookingStatusLog.BookingId = bookingOrder.Id;
bookingStatusLog.Category = "yunzong"; bookingStatusLog.Category = "yunzong";
bookingStatusLog.CreatedTime = DateTime.Now; bookingStatusLog.CreatedTime = DateTime.Now;
bookingStatusLog.Status = "舱单"; bookingStatusLog.Status = "运抵";
bookingStatusLog.OpTime = TimeCangDan; bookingStatusLog.OpTime = xl == ydnum ? ygtdto.Select(x => x.YunDiShiJian).Max() : null;
bookingStatusLog.MBLNO = mblno; bookingStatusLog.MBLNO = mblno;
await _repStatuslog.InsertAsync(bookingStatusLog); await _repStatuslog.InsertAsync(bookingStatusLog);
if (list.Where(x => x.StaCode == "sta_cangdan").FirstOrDefault() == null)
foreach (var dt in ygtdto)
{ {
BookingStatus bookingStatus = new BookingStatus(); var BookingStatusLogDetail = new BookingStatusLogDetail();
bookingStatus.BookingId = bookingId; BookingStatusLogDetail.PId = bookingStatusLog.Id;
bookingStatus.StaCode = "sta_cangdan"; BookingStatusLogDetail.Status = "运抵";
bookingStatus.StaName = dicdatalist.Where(x => x.Code == "sta_cangdan").Select(x => x.Value).FirstOrDefault(); BookingStatusLogDetail.CNTRNO = dt.CNTRNO;
bookingStatus.StaTime = TimeCangDan; BookingStatusLogDetail.OPTime = dt.YunDiShiJian;
bookingStatus.StaCate = "book_sta_cate_billtrace"; await _statuslogdetail.InsertAsync(BookingStatusLogDetail);
await _repBookingStatus.InsertAsync(bookingStatus); }
} }
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);
} }
if (FangXingShiJian != null) if (xl > 0 && mfnum > 0 && mfnum == xl)
{ {
//新增数据 //新增数据
var bookingStatusLog = new BookingStatusLog(); var bookingStatusLog = new BookingStatusLog();
bookingStatusLog.BookingId = bookingId; bookingStatusLog.BookingId = bookingOrder.Id;
bookingStatusLog.Category = "yunzong"; bookingStatusLog.Category = "yunzong";
bookingStatusLog.CreatedTime = DateTime.Now; bookingStatusLog.CreatedTime = DateTime.Now;
bookingStatusLog.Status = "报关"; bookingStatusLog.Status = "码放";
bookingStatusLog.OpTime = FangXingShiJian; bookingStatusLog.OpTime = null;
bookingStatusLog.MBLNO = mblno; bookingStatusLog.MBLNO = mblno;
await _repStatuslog.InsertAsync(bookingStatusLog); await _repStatuslog.InsertAsync(bookingStatusLog);
if (list.Where(x => x.Code == "sta_haifang").FirstOrDefault() == null) }
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(); BookingStatus bookingStatus = new BookingStatus();
bookingStatus.BookingId = bookingId; bookingStatus.BookingId = bookingOrder.Id;
bookingStatus.StaCode = "sta_haifang"; bookingStatus.StaCode = "sta_haifang";
bookingStatus.StaName = dicdatalist.Where(x => x.Code == "sta_haifang").Select(x => x.Value).FirstOrDefault(); bookingStatus.StaName = dicdatalist.Where(x => x.Code == "sta_atd").Select(x => x.Value).FirstOrDefault();
bookingStatus.StaTime = FangXingShiJian; bookingStatus.StaTime = SJLGShiJian;
bookingStatus.StaCate = "book_sta_cate_billtrace"; bookingStatus.StaCate = "book_sta_cate_billtrace";
await _repBookingStatus.InsertAsync(bookingStatus); await _repBookingStatus.InsertAsync(bookingStatus);
await _bookingorderservice.SetGoodsStatus("BG", bookingId);
await _bookingorderservice.SendBookingOrder(new long[] { bookingId });
} }
} }
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 });
}
} }
} }
} }

@ -24,4 +24,16 @@ namespace Myshipping.Application.Service.BookingYunZong.Dto
} }
public class YGTDataDto
{
public string CNTRNO { get; set; }
public DateTime? YunDiShiJian { get; set; }
public DateTime? WaiLiShiJian { get; set; }
public string MTFX { get; set; }
public DateTime? ZhuangzhaiShiJian { get; set; }
public DateTime? ZhuangChuanShiJian { get; set; }
public DateTime? RuGangShiJian { get; set; }
}
} }

Loading…
Cancel
Save