|
|
@ -2291,6 +2291,9 @@ namespace Myshipping.Application
|
|
|
|
// 要取消订阅运踪的列表
|
|
|
|
// 要取消订阅运踪的列表
|
|
|
|
List<BillTraceUnsubscribeList> waitUnsubscribeBilltrace = new(arr.Count());
|
|
|
|
List<BillTraceUnsubscribeList> waitUnsubscribeBilltrace = new(arr.Count());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var tenantParamList = await _cache.GetAllTenantParam();
|
|
|
|
|
|
|
|
var isAskDs = tenantParamList.FirstOrDefault(x => x.TenantId == UserManager.TENANT_ID && x.ParaCode == TenantParamCode.ASK_DS_BEFORE_DELETE_BOOKING_ORDER);
|
|
|
|
|
|
|
|
|
|
|
|
foreach (var ar in arr)
|
|
|
|
foreach (var ar in arr)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
long Id = Convert.ToInt64(ar);
|
|
|
|
long Id = Convert.ToInt64(ar);
|
|
|
@ -2304,27 +2307,64 @@ namespace Myshipping.Application
|
|
|
|
|
|
|
|
|
|
|
|
// 将待删除的订舱单id存放到Cache中。目的:使用SendBookingOrder()推送订舱单数据前通过Cache判断是否正在走删除逻辑,来决定是否推送(如果是正在处理删除逻辑的数据,则不推送)
|
|
|
|
// 将待删除的订舱单id存放到Cache中。目的:使用SendBookingOrder()推送订舱单数据前通过Cache判断是否正在走删除逻辑,来决定是否推送(如果是正在处理删除逻辑的数据,则不推送)
|
|
|
|
string deletingCacheKey = $"DeletingBookingOrderId_{ar}";
|
|
|
|
string deletingCacheKey = $"DeletingBookingOrderId_{ar}";
|
|
|
|
await _cache.SetTimeoutAsync(deletingCacheKey, null, TimeSpan.FromMinutes(1));
|
|
|
|
|
|
|
|
_logger.LogInformation("设置待删除的订舱单id到Cache中,key:" + deletingCacheKey);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BookingOrderDelete bookingOrderDelete = new BookingOrderDelete();
|
|
|
|
try
|
|
|
|
List<BookingOrderDeleteDetail> deletelist = new List<BookingOrderDeleteDetail>();
|
|
|
|
|
|
|
|
deletelist.Add(new BookingOrderDeleteDetail
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Id = Id,
|
|
|
|
await _cache.SetTimeoutAsync(deletingCacheKey, null, TimeSpan.FromMinutes(1));
|
|
|
|
MBLNO = mblno
|
|
|
|
_logger.LogInformation("设置待删除的订舱单id到Cache中,key:" + deletingCacheKey);
|
|
|
|
});
|
|
|
|
|
|
|
|
bookingOrderDelete.Delete = deletelist;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var stn = await url.SetBody(bookingOrderDelete).PostAsStringAsync();
|
|
|
|
|
|
|
|
var jobj = stn.ToJObject();
|
|
|
|
|
|
|
|
_logger.LogInformation(mblno + "删除单据:" + jobj);
|
|
|
|
|
|
|
|
if (jobj.GetIntValue("Code") == 200)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
JObject data = jobj.GetValue("Data") as JObject;
|
|
|
|
|
|
|
|
JArray NoDeleted = data.GetValue("NoDeleted") as JArray;
|
|
|
|
|
|
|
|
var deleteTime = DateTime.Now;
|
|
|
|
var deleteTime = DateTime.Now;
|
|
|
|
if (NoDeleted == null || NoDeleted.Count() == 0)
|
|
|
|
if (isAskDs?.ItemCode == "YES")
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
BookingOrderDelete bookingOrderDelete = new BookingOrderDelete();
|
|
|
|
|
|
|
|
List<BookingOrderDeleteDetail> deletelist = new List<BookingOrderDeleteDetail>
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
new BookingOrderDeleteDetail
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Id = Id,
|
|
|
|
|
|
|
|
MBLNO = mblno
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
bookingOrderDelete.Delete = deletelist;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var stn = await url.SetBody(bookingOrderDelete).PostAsStringAsync();
|
|
|
|
|
|
|
|
var jobj = stn.ToJObject();
|
|
|
|
|
|
|
|
_logger.LogInformation(mblno + "删除单据:" + jobj);
|
|
|
|
|
|
|
|
if (jobj.GetIntValue("Code") == 200)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
JObject data = jobj.GetValue("Data") as JObject;
|
|
|
|
|
|
|
|
JArray NoDeleted = data.GetValue("NoDeleted") as JArray;
|
|
|
|
|
|
|
|
if (NoDeleted == null || NoDeleted.Count() == 0 || (NoDeleted[0] is JObject re2 && re2.GetIntValue("Code") == 201))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var ctnlist = await _repCtn.AsQueryable().Where(x => x.BILLID == Id).Select(x => x.Id).ToListAsync();
|
|
|
|
|
|
|
|
await _repCtn.UpdateAsync(x => x.BILLID == Id, x => new BookingCtn { IsDeleted = true });
|
|
|
|
|
|
|
|
await _ctndetailrep.UpdateAsync(x => ctnlist.Contains((long)x.CTNID), x => new BookingCtnDetail { IsDeleted = true });
|
|
|
|
|
|
|
|
await _rep.UpdateAsync(x => x.Id == Id, x => new BookingOrder { IsDeleted = true, DeleteTime = deleteTime });
|
|
|
|
|
|
|
|
await _bookingEDIExt.UpdateAsync(x => x.BookingId == Id && x.IsDeleted == false, x => new BookingEDIExt { IsDeleted = true });
|
|
|
|
|
|
|
|
_logger.LogInformation(mblno + "删除成功!");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 取消订阅运踪
|
|
|
|
|
|
|
|
waitUnsubscribeBilltrace.Add(new BillTraceUnsubscribeList(Id.ToString(), mblno));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 记录日志
|
|
|
|
|
|
|
|
var newOrder = order.Adapt<BookingOrder>();
|
|
|
|
|
|
|
|
newOrder.IsDeleted = true;
|
|
|
|
|
|
|
|
newOrder.DeleteTime = deleteTime;
|
|
|
|
|
|
|
|
await SaveLog(newOrder, order, "删除");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var re = NoDeleted[0] as JObject;
|
|
|
|
|
|
|
|
string result = re.GetStringValue("Result");
|
|
|
|
|
|
|
|
throw Oops.Bah(result);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
throw Oops.Bah(mblno + "删除单据失败");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var ctnlist = await _repCtn.AsQueryable().Where(x => x.BILLID == Id).Select(x => x.Id).ToListAsync();
|
|
|
|
var ctnlist = await _repCtn.AsQueryable().Where(x => x.BILLID == Id).Select(x => x.Id).ToListAsync();
|
|
|
|
await _repCtn.UpdateAsync(x => x.BILLID == Id, x => new BookingCtn { IsDeleted = true });
|
|
|
|
await _repCtn.UpdateAsync(x => x.BILLID == Id, x => new BookingCtn { IsDeleted = true });
|
|
|
@ -2342,48 +2382,19 @@ namespace Myshipping.Application
|
|
|
|
newOrder.DeleteTime = deleteTime;
|
|
|
|
newOrder.DeleteTime = deleteTime;
|
|
|
|
await SaveLog(newOrder, order, "删除");
|
|
|
|
await SaveLog(newOrder, order, "删除");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var re = NoDeleted[0] as JObject;
|
|
|
|
|
|
|
|
if (re.GetIntValue("Code") == 201)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var ctnlist = await _repCtn.AsQueryable().Where(x => x.BILLID == Id).Select(x => x.Id).ToListAsync();
|
|
|
|
|
|
|
|
await _repCtn.UpdateAsync(x => x.BILLID == Id, x => new BookingCtn { IsDeleted = true });
|
|
|
|
|
|
|
|
await _ctndetailrep.UpdateAsync(x => ctnlist.Contains((long)x.CTNID), x => new BookingCtnDetail { IsDeleted = true });
|
|
|
|
|
|
|
|
await _rep.UpdateAsync(x => x.Id == Id, x => new BookingOrder { IsDeleted = true, DeleteTime = deleteTime });
|
|
|
|
|
|
|
|
await _bookingEDIExt.UpdateAsync(x => x.BookingId == Id && x.IsDeleted == false, x => new BookingEDIExt { IsDeleted = true });
|
|
|
|
|
|
|
|
_logger.LogInformation(mblno + "删除成功!");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 取消订阅运踪
|
|
|
|
|
|
|
|
waitUnsubscribeBilltrace.Add(new BillTraceUnsubscribeList(Id.ToString(), mblno));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 记录日志
|
|
|
|
|
|
|
|
var newOrder = order.Adapt<BookingOrder>();
|
|
|
|
|
|
|
|
newOrder.IsDeleted = true;
|
|
|
|
|
|
|
|
newOrder.DeleteTime = deleteTime;
|
|
|
|
|
|
|
|
await SaveLog(newOrder, order, "删除");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
await _cache.DelAsync(deletingCacheKey);
|
|
|
|
|
|
|
|
_logger.LogInformation("从Cache中移除待删除的订舱单id,key:" + deletingCacheKey);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
string result = re.GetStringValue("Result");
|
|
|
|
|
|
|
|
throw Oops.Bah(result);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
catch (Exception)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
await _cache.DelAsync(deletingCacheKey);
|
|
|
|
await _cache.DelAsync(deletingCacheKey);
|
|
|
|
_logger.LogInformation("从Cache中移除待删除的订舱单id,key:" + deletingCacheKey);
|
|
|
|
_logger.LogInformation("从Cache中移除待删除的订舱单id,key:" + deletingCacheKey);
|
|
|
|
|
|
|
|
|
|
|
|
throw Oops.Bah(mblno + "删除单据失败");
|
|
|
|
throw;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
finally
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
await _cache.DelAsync(deletingCacheKey);
|
|
|
|
|
|
|
|
_logger.LogInformation("从Cache中移除待删除的订舱单id,key:" + deletingCacheKey);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
await _cache.DelAsync(deletingCacheKey);
|
|
|
|
|
|
|
|
_logger.LogInformation("从Cache中移除待删除的订舱单id,key:" + deletingCacheKey);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 取消订阅运踪
|
|
|
|
// 取消订阅运踪
|
|
|
|