jianghaiqing 7 months ago
commit c0b1b837cc

@ -1755,6 +1755,10 @@ namespace Myshipping.Application
}; };
var mlist = await _rep.AsQueryable().Filter(null, true).Where(x => x.Id == input.Id).FirstAsync(); var mlist = await _rep.AsQueryable().Filter(null, true).Where(x => x.Id == input.Id).FirstAsync();
if (mlist.IsDeleted)
{
throw Oops.Bah("当前单据为【已删除】状态,无法修改");
}
if (!string.IsNullOrEmpty(reqId)) if (!string.IsNullOrEmpty(reqId))
{ {
@ -2287,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);
@ -2300,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 });
@ -2338,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中移除待删除的订舱单idkey" + deletingCacheKey);
string result = re.GetStringValue("Result");
throw Oops.Bah(result);
}
}
} }
else catch (Exception)
{ {
await _cache.DelAsync(deletingCacheKey); await _cache.DelAsync(deletingCacheKey);
_logger.LogInformation("从Cache中移除待删除的订舱单idkey" + deletingCacheKey); _logger.LogInformation("从Cache中移除待删除的订舱单idkey" + deletingCacheKey);
throw Oops.Bah(mblno + "删除单据失败"); throw;
}
finally
{
await _cache.DelAsync(deletingCacheKey);
_logger.LogInformation("从Cache中移除待删除的订舱单idkey" + deletingCacheKey);
} }
await _cache.DelAsync(deletingCacheKey);
_logger.LogInformation("从Cache中移除待删除的订舱单idkey" + deletingCacheKey);
} }
// 取消订阅运踪 // 取消订阅运踪

@ -206,6 +206,11 @@ public class CommonConst
/// 省份信息 /// 省份信息
/// </summary> /// </summary>
public const string CACHE_KEY_COMMON_DB_PROVINCE = "CommonDbCodeProvince"; public const string CACHE_KEY_COMMON_DB_PROVINCE = "CommonDbCodeProvince";
/// <summary>
/// 起运港与船代的关系
/// </summary>
public const string CACHE_KEY_COMMON_DB_RELA_PORTLOAD_FORWARDER = "CommonDbRelaPortLoadForwarder";
#endregion #endregion
public const string API_USER_HEADER_KEY = "USER_KEY"; public const string API_USER_HEADER_KEY = "USER_KEY";

@ -24,5 +24,10 @@
/// 通过运踪更新船舶动态开关 /// 通过运踪更新船舶动态开关
/// </summary> /// </summary>
public const string ENABLE_STATUS_TO_SAILING_DATE = "EnableStatusToSailingDate"; public const string ENABLE_STATUS_TO_SAILING_DATE = "EnableStatusToSailingDate";
/// <summary>
/// 删除订舱前是否先询问东胜
/// </summary>
public const string ASK_DS_BEFORE_DELETE_BOOKING_ORDER = "AskDsBeforeDeleteBookingOrder";
} }
} }

@ -0,0 +1,35 @@
using SqlSugar;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Myshipping.Core.Entity
{
[SugarTable("RelaPortLoadForwarder")]
[Description("起运港和船代的关系表")]
public class RelaPortLoadForwarder : CommonDbEntity
{
/// <summary>
/// 起运港代码
/// </summary>
public string PortLoadCode { get; set; }
/// <summary>
/// 船代代码
/// </summary>
public string ForwarderCode { get; set; }
/// <summary>
/// 模块(公用时为空字符串)
/// </summary>
public string Module { get; set; }
/// <summary>
/// 备注
/// </summary>
public string Remark { get; set; }
}
}

@ -101,6 +101,9 @@ namespace Myshipping.Core.Job
//航线与港口的的关系 //航线与港口的的关系
await App.GetService<ICommonDBService>().GetAllRelaPortCarrierLane(true); await App.GetService<ICommonDBService>().GetAllRelaPortCarrierLane(true);
//起运港与船代的的关系
await App.GetService<ICommonDBService>().GetAllRelaPortLoadForwarder(true);
//国家 //国家
await App.GetService<ICommonDBService>().GetAllCountry(true); await App.GetService<ICommonDBService>().GetAllCountry(true);

@ -782,6 +782,11 @@
省份信息 省份信息
</summary> </summary>
</member> </member>
<member name="F:Myshipping.Core.CommonConst.CACHE_KEY_COMMON_DB_RELA_PORTLOAD_FORWARDER">
<summary>
起运港与船代的关系
</summary>
</member>
<member name="F:Myshipping.Core.CommonConst.ENTITY_ASSEMBLY_NAME"> <member name="F:Myshipping.Core.CommonConst.ENTITY_ASSEMBLY_NAME">
<summary> <summary>
程序集 程序集
@ -872,6 +877,11 @@
通过运踪更新船舶动态开关 通过运踪更新船舶动态开关
</summary> </summary>
</member> </member>
<member name="F:Myshipping.Core.Const.TenantParamCode.ASK_DS_BEFORE_DELETE_BOOKING_ORDER">
<summary>
删除订舱前是否先询问东胜
</summary>
</member>
<member name="P:Myshipping.Core.Entity.CodeCarrier.Code"> <member name="P:Myshipping.Core.Entity.CodeCarrier.Code">
<summary> <summary>
代码 代码
@ -1727,6 +1737,26 @@
备注 备注
</summary> </summary>
</member> </member>
<member name="P:Myshipping.Core.Entity.RelaPortLoadForwarder.PortLoadCode">
<summary>
起运港代码
</summary>
</member>
<member name="P:Myshipping.Core.Entity.RelaPortLoadForwarder.ForwarderCode">
<summary>
船代代码
</summary>
</member>
<member name="P:Myshipping.Core.Entity.RelaPortLoadForwarder.Module">
<summary>
模块(公用时为空字符串)
</summary>
</member>
<member name="P:Myshipping.Core.Entity.RelaPortLoadForwarder.Remark">
<summary>
备注
</summary>
</member>
<member name="T:Myshipping.Core.Entity.DBEntityTenant"> <member name="T:Myshipping.Core.Entity.DBEntityTenant">
<summary> <summary>
自定义租户基类实体 自定义租户基类实体
@ -7347,6 +7377,12 @@
</summary> </summary>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:Myshipping.Core.Service.ISysCacheService.GetAllRelaPortLoadForwarder">
<summary>
获取公共库 起运港与船代的关系表
</summary>
<returns></returns>
</member>
<member name="M:Myshipping.Core.Service.ISysCacheService.GetAllCodeCountry"> <member name="M:Myshipping.Core.Service.ISysCacheService.GetAllCodeCountry">
<summary> <summary>
获取公共库 国家 获取公共库 国家
@ -7569,6 +7605,12 @@
</summary> </summary>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:Myshipping.Core.Service.ISysCacheService.SetAllRelaPortLoadForwarder(System.Collections.Generic.List{Myshipping.Core.Entity.RelaPortLoadForwarder})">
<summary>
设置公共库 起运港与船代的关系表
</summary>
<returns></returns>
</member>
<member name="M:Myshipping.Core.Service.ISysCacheService.SetAllCodeCountry(System.Collections.Generic.List{Myshipping.Core.Entity.CodeCountry})"> <member name="M:Myshipping.Core.Service.ISysCacheService.SetAllCodeCountry(System.Collections.Generic.List{Myshipping.Core.Entity.CodeCountry})">
<summary> <summary>
设置公共库 国家 设置公共库 国家
@ -7893,7 +7935,13 @@
</member> </member>
<member name="M:Myshipping.Core.Service.SysCacheService.GetAllRelaPortCarrierLane"> <member name="M:Myshipping.Core.Service.SysCacheService.GetAllRelaPortCarrierLane">
<summary> <summary>
设置公共库 航线与港口的的关系表 获取公共库 航线与港口的的关系表
</summary>
<returns></returns>
</member>
<member name="M:Myshipping.Core.Service.SysCacheService.GetAllRelaPortLoadForwarder">
<summary>
获取公共库 起运港与船代的关系表
</summary> </summary>
<returns></returns> <returns></returns>
</member> </member>
@ -8011,6 +8059,12 @@
</summary> </summary>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:Myshipping.Core.Service.SysCacheService.SetAllRelaPortLoadForwarder(System.Collections.Generic.List{Myshipping.Core.Entity.RelaPortLoadForwarder})">
<summary>
设置公共库 起运港与船代的关系表
</summary>
<returns></returns>
</member>
<member name="M:Myshipping.Core.Service.SysCacheService.SetAllCodeCountry(System.Collections.Generic.List{Myshipping.Core.Entity.CodeCountry})"> <member name="M:Myshipping.Core.Service.SysCacheService.SetAllCodeCountry(System.Collections.Generic.List{Myshipping.Core.Entity.CodeCountry})">
<summary> <summary>
设置公共库 国家 设置公共库 国家
@ -10173,6 +10227,12 @@
</summary> </summary>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:Myshipping.Core.Service.ICommonDBService.GetAllRelaPortLoadForwarder(System.Boolean)">
<summary>
起运港与船代的关系
</summary>
<returns></returns>
</member>
<member name="M:Myshipping.Core.Service.ICommonDBService.GetAllCountry(System.Boolean)"> <member name="M:Myshipping.Core.Service.ICommonDBService.GetAllCountry(System.Boolean)">
<summary> <summary>
国家 国家

@ -109,6 +109,12 @@ public interface ISysCacheService
/// <returns></returns> /// <returns></returns>
Task<List<RelaPortCarrierLane>> GetAllRelaPortCarrierLane(); Task<List<RelaPortCarrierLane>> GetAllRelaPortCarrierLane();
/// <summary>
/// 获取公共库 起运港与船代的关系表
/// </summary>
/// <returns></returns>
Task<List<RelaPortLoadForwarder>> GetAllRelaPortLoadForwarder();
/// <summary> /// <summary>
/// 获取公共库 国家 /// 获取公共库 国家
/// </summary> /// </summary>
@ -332,6 +338,12 @@ public interface ISysCacheService
/// <returns></returns> /// <returns></returns>
Task SetAllRelaPortCarrierLane(List<RelaPortCarrierLane> list); Task SetAllRelaPortCarrierLane(List<RelaPortCarrierLane> list);
/// <summary>
/// 设置公共库 起运港与船代的关系表
/// </summary>
/// <returns></returns>
Task SetAllRelaPortLoadForwarder(List<RelaPortLoadForwarder> list);
/// <summary> /// <summary>
/// 设置公共库 国家 /// 设置公共库 国家
/// </summary> /// </summary>

@ -398,7 +398,7 @@ public class SysCacheService : ISysCacheService, IDynamicApiController, ISinglet
} }
/// <summary> /// <summary>
/// 设置公共库 航线与港口的的关系表 /// 获取公共库 航线与港口的的关系表
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public Task<List<RelaPortCarrierLane>> GetAllRelaPortCarrierLane() public Task<List<RelaPortCarrierLane>> GetAllRelaPortCarrierLane()
@ -406,6 +406,15 @@ public class SysCacheService : ISysCacheService, IDynamicApiController, ISinglet
return _cache.GetAsync<List<RelaPortCarrierLane>>(CommonConst.CACHE_KEY_COMMON_DB_LANE_PORT); return _cache.GetAsync<List<RelaPortCarrierLane>>(CommonConst.CACHE_KEY_COMMON_DB_LANE_PORT);
} }
/// <summary>
/// 获取公共库 起运港与船代的关系表
/// </summary>
/// <returns></returns>
public Task<List<RelaPortLoadForwarder>> GetAllRelaPortLoadForwarder()
{
return _cache.GetAsync<List<RelaPortLoadForwarder>>(CommonConst.CACHE_KEY_COMMON_DB_RELA_PORTLOAD_FORWARDER);
}
/// <summary> /// <summary>
/// 获取公共库 国家 /// 获取公共库 国家
/// </summary> /// </summary>
@ -580,6 +589,15 @@ public class SysCacheService : ISysCacheService, IDynamicApiController, ISinglet
return _cache.SetAsync(CommonConst.CACHE_KEY_COMMON_DB_LANE_PORT, list); return _cache.SetAsync(CommonConst.CACHE_KEY_COMMON_DB_LANE_PORT, list);
} }
/// <summary>
/// 设置公共库 起运港与船代的关系表
/// </summary>
/// <returns></returns>
public Task SetAllRelaPortLoadForwarder(List<RelaPortLoadForwarder> list)
{
return _cache.SetAsync(CommonConst.CACHE_KEY_COMMON_DB_RELA_PORTLOAD_FORWARDER, list);
}
/// <summary> /// <summary>
/// 设置公共库 国家 /// 设置公共库 国家
/// </summary> /// </summary>

@ -51,6 +51,7 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie
private readonly SqlSugarRepository<MappingForwarder> _mappingForwarder; private readonly SqlSugarRepository<MappingForwarder> _mappingForwarder;
private readonly SqlSugarRepository<CodeCity> _codeCityRep; private readonly SqlSugarRepository<CodeCity> _codeCityRep;
private readonly SqlSugarRepository<CodeProvince> _codeProvinceRep; private readonly SqlSugarRepository<CodeProvince> _codeProvinceRep;
private readonly SqlSugarRepository<RelaPortLoadForwarder> _relaPortLoadForwarderRep;
public CommonDBService(SqlSugarRepository<CodeCarrier> codeCarrierRep, public CommonDBService(SqlSugarRepository<CodeCarrier> codeCarrierRep,
SqlSugarRepository<CodeVessel> codeVesselRep, SqlSugarRepository<CodeVessel> codeVesselRep,
SqlSugarRepository<CodeForwarder> codeForwarderRep, SqlSugarRepository<CodeForwarder> codeForwarderRep,
@ -80,7 +81,8 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie
SqlSugarRepository<CodeCountry> codeCountryRep, SqlSugarRepository<CodeCountry> codeCountryRep,
SqlSugarRepository<MappingForwarder> mappingForwarder, SqlSugarRepository<MappingForwarder> mappingForwarder,
SqlSugarRepository<CodeCity> codeCityRep, SqlSugarRepository<CodeCity> codeCityRep,
SqlSugarRepository<CodeProvince> codeProvinceRep SqlSugarRepository<CodeProvince> codeProvinceRep,
SqlSugarRepository<RelaPortLoadForwarder> relaPortLoadForwarderRep
) )
{ {
_codeCarrierRep = codeCarrierRep; _codeCarrierRep = codeCarrierRep;
@ -113,7 +115,7 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie
_mappingForwarder = mappingForwarder; _mappingForwarder = mappingForwarder;
_codeCityRep = codeCityRep; _codeCityRep = codeCityRep;
_codeProvinceRep = codeProvinceRep; _codeProvinceRep = codeProvinceRep;
_relaPortLoadForwarderRep = relaPortLoadForwarderRep;
} }
#endregion #endregion
@ -1918,6 +1920,26 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie
} }
}
[NonAction]
public async Task GetAllRelaPortLoadForwarder(bool flag = false)
{
if (flag)
{
if (!_sysCacheService.Exists(CommonConst.CACHE_KEY_COMMON_DB_RELA_PORTLOAD_FORWARDER))
{
var list = await _relaPortLoadForwarderRep.ToListAsync();
await _sysCacheService.SetAllRelaPortLoadForwarder(list);
}
}
else
{
var list = await _relaPortLoadForwarderRep.ToListAsync();
await _sysCacheService.SetAllRelaPortLoadForwarder(list);
}
} }
/// <summary> /// <summary>

@ -105,6 +105,12 @@ public interface ICommonDBService
/// <returns></returns> /// <returns></returns>
Task GetAllRelaPortCarrierLane(bool flag); Task GetAllRelaPortCarrierLane(bool flag);
/// <summary>
/// 起运港与船代的关系
/// </summary>
/// <returns></returns>
Task GetAllRelaPortLoadForwarder(bool flag);
/// <summary> /// <summary>
/// 国家 /// 国家
/// </summary> /// </summary>

Loading…
Cancel
Save