ATD同步更新

optimize
wet 2 years ago
parent 683ee5f98c
commit 41926d6c0e

@ -847,7 +847,7 @@ namespace Myshipping.Application
public async Task<List<BookingStatusLogDto>> GetBookingStatusLog(long Id)
{
var statuslog = await _repStatuslog.AsQueryable().Filter(null, true).Where(x => x.BookingId == Id).OrderByDescending(x=>x.OpTime).ToListAsync();
var statuslog = await _repStatuslog.AsQueryable().Filter(null, true).Where(x => x.BookingId == Id).OrderByDescending(x => x.OpTime).ToListAsync();
var dto = statuslog.Adapt<List<BookingStatusLogDto>>();
foreach (var item in dto)
{
@ -1035,7 +1035,7 @@ namespace Myshipping.Application
var dicdatalist = _cache.GetAllDictData().Result;
foreach (var item in all)
{
#region 日志
//新增数据
var bookingStatusLog = new BookingStatusLog();
bookingStatusLog.BookingId = item.BookingId;
@ -1055,6 +1055,20 @@ namespace Myshipping.Application
Value = t.Value
}).ToListAsync();
if (item.detail != null && item.detail.Count > 0)
{
foreach (var dt in item.detail)
{
var BookingStatusLogDetail = new BookingStatusLogDetail();
BookingStatusLogDetail.PId = bookingStatusLog.Id;
BookingStatusLogDetail.Status = dt.Status;
BookingStatusLogDetail.CNTRNO = dt.CNTRNO;
BookingStatusLogDetail.OPTime = dt.OPTime;
await _statuslogdetail.InsertAsync(BookingStatusLogDetail);
}
}
#endregion
#region 订舱状态
if (item.Status == "舱单")
{
@ -1136,18 +1150,68 @@ namespace Myshipping.Application
}
#endregion
if (item.detail != null && item.detail.Count > 0)
#region ATD
if (item.Status == "ATD")
{
foreach (var dt in item.detail)
{
var BookingStatusLogDetail = new BookingStatusLogDetail();
BookingStatusLogDetail.PId = bookingStatusLog.Id;
BookingStatusLogDetail.Status = dt.Status;
BookingStatusLogDetail.CNTRNO = dt.CNTRNO;
BookingStatusLogDetail.OPTime = dt.OPTime;
await _statuslogdetail.InsertAsync(BookingStatusLogDetail);
var o = _rep.AsQueryable().Where(x => x.Id == item.BookingId).FirstAsync().Result;
var oldatd = o.ATD;
if (oldatd!= item.OpTime) {
o.ATD = item.OpTime;
await _rep.UpdateAsync(o);
////添加booking日志
var bid = await _bookinglog.InsertReturnSnowflakeIdAsync(new BookingLog
{
Type = "Edit",
BookingId = item.BookingId,
TenantId = o.TenantId,
CreatedTime = DateTime.Now,
CreatedUserId = UserManager.UserId,
CreatedUserName = UserManager.Name
});
await _bookinglogdetail.InsertReturnSnowflakeIdAsync(new BookingLogDetail
{
PId = bid,
Field = "实际开船",
OldValue = oldatd==null?"": oldatd.ToString(),
NewValue = item.OpTime == null ? "" : item.OpTime.ToString(),
});
}
if (!string.IsNullOrWhiteSpace(o.VESSEL)&&!string.IsNullOrWhiteSpace(o.VOYNO)) {
var order = await _rep.AsQueryable().Where(x => x.VOYNO == o.VOYNO && x.VESSEL == o.VESSEL&&x.TenantId==o.TenantId).ToListAsync();
foreach (var it in order)
{
var _oldatd = it.ATD;
if (_oldatd != item.OpTime)
{
it.ATD = item.OpTime;
await _rep.UpdateAsync(it);
////添加booking日志
var _bid = await _bookinglog.InsertReturnSnowflakeIdAsync(new BookingLog
{
Type = "Edit",
BookingId = it.Id,
TenantId = it.TenantId,
CreatedTime = DateTime.Now,
CreatedUserId = UserManager.UserId,
CreatedUserName = UserManager.Name
});
await _bookinglogdetail.InsertReturnSnowflakeIdAsync(new BookingLogDetail
{
PId = _bid,
Field = "实际开船",
OldValue = _oldatd == null ? "" : _oldatd.ToString(),
NewValue = item.OpTime == null ? "" : item.OpTime.ToString(),
});
}
}
}
}
#endregion
}
}
#endregion

Loading…
Cancel
Save