EDI设置修改

optimize
wanghaomei 2 years ago
parent 8a03945837
commit 9a5681151c

@ -111,5 +111,13 @@ namespace Myshipping.Core.Entity
/// 租户名称 /// 租户名称
/// </summary> /// </summary>
public string TenantName { get; set; } public string TenantName { get; set; }
/// <summary>
/// 发送类型
/// </summary>
public string SendType { get; set; }
/// <summary>
/// 启用标志
/// </summary>
public bool EnableFlag { get; set; } = true;
} }
} }

@ -2034,6 +2034,16 @@
租户名称 租户名称
</summary> </summary>
</member> </member>
<member name="P:Myshipping.Core.Entity.DjyEdiSetting.SendType">
<summary>
发送类型
</summary>
</member>
<member name="P:Myshipping.Core.Entity.DjyEdiSetting.EnableFlag">
<summary>
启用标志
</summary>
</member>
<member name="T:Myshipping.Core.Entity.DjyTenantConfig"> <member name="T:Myshipping.Core.Entity.DjyTenantConfig">
<summary> <summary>
@ -10766,18 +10776,32 @@
</member> </member>
<member name="M:Myshipping.Core.Service.DjyEdiSettingService.Add(Myshipping.Core.AddDjyEdiSettingInput)"> <member name="M:Myshipping.Core.Service.DjyEdiSettingService.Add(Myshipping.Core.AddDjyEdiSettingInput)">
<summary> <summary>
增加EDI参数设置 增加EDI参数设置准备作废使用save接口代替
</summary>
<param name="input"></param>
<returns></returns>
</member>
<member name="M:Myshipping.Core.Service.DjyEdiSettingService.Save(Myshipping.Core.UpdateDjyEdiSettingInput)">
<summary>
保存EDI参数设置
</summary> </summary>
<param name="input"></param> <param name="input"></param>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:Myshipping.Core.Service.DjyEdiSettingService.Update(Myshipping.Core.UpdateDjyEdiSettingInput)"> <member name="M:Myshipping.Core.Service.DjyEdiSettingService.Update(Myshipping.Core.UpdateDjyEdiSettingInput)">
<summary> <summary>
更新EDI参数设置 更新EDI参数设置准备作废使用save接口代替
</summary> </summary>
<param name="input"></param> <param name="input"></param>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:Myshipping.Core.Service.DjyEdiSettingService.SetEnable(System.Int64)">
<summary>
设置启用启用后同船司、同发送类型的其他EDI通道会被取消启用
</summary>
<param name="id"></param>
<returns></returns>
</member>
<member name="M:Myshipping.Core.Service.DjyEdiSettingService.Delete(Myshipping.Core.GetDjyEdiSettingInput)"> <member name="M:Myshipping.Core.Service.DjyEdiSettingService.Delete(Myshipping.Core.GetDjyEdiSettingInput)">
<summary> <summary>
删除EDI参数设置 删除EDI参数设置
@ -15474,6 +15498,11 @@
租户名称 租户名称
</summary> </summary>
</member> </member>
<member name="P:Myshipping.Core.DjyEdiSettingInput.SendType">
<summary>
发送类型
</summary>
</member>
<member name="T:Myshipping.Core.AddDjyEdiSettingInput"> <member name="T:Myshipping.Core.AddDjyEdiSettingInput">
<summary> <summary>
EDI参数设置新增输入参数 EDI参数设置新增输入参数

@ -49,7 +49,7 @@ namespace Myshipping.Core.Service
} }
/// <summary> /// <summary>
/// 增加EDI参数设置 /// 增加EDI参数设置准备作废使用save接口代替
/// </summary> /// </summary>
/// <param name="input"></param> /// <param name="input"></param>
/// <returns></returns> /// <returns></returns>
@ -58,20 +58,80 @@ namespace Myshipping.Core.Service
{ {
var cc = _rep.AsQueryable() var cc = _rep.AsQueryable()
.Filter(null, true) .Filter(null, true)
.Count(x => x.EDICODE == input.EDICODE && x.TenantId == input.TenantId && x.CARRIERID == input.CARRIERID); .Count(x => x.EDICODE == input.EDICODE && x.TenantId == input.TenantId && x.CARRIERID == input.CARRIERID && x.SendType == input.SendType);
if (cc > 0) if (cc > 0)
{ {
throw Oops.Bah($"该租户({input.TenantName})已存在相同类型({input.EDICODE}相同船司({input.CARRIERID})的参数设置"); throw Oops.Bah($"该租户({input.TenantName})已存在相同类型({input.EDICODE}相同船司({input.CARRIERID})、相同发送类型({input.SendType})的参数设置");
} }
var entity = input.Adapt<DjyEdiSetting>(); var entity = input.Adapt<DjyEdiSetting>();
await _rep.InsertAsync(entity); await _rep.InsertAsync(entity);
await CacheData(); await CacheData();
return entity.Id; return entity.Id;
} }
/// <summary> /// <summary>
/// 更新EDI参数设置 /// 保存EDI参数设置
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("/DjyEdiSetting/save")]
public async Task<long> Save(UpdateDjyEdiSettingInput input)
{
DjyEdiSetting entity = null;
if (input.Id == 0) //新增
{
var cc = _rep.AsQueryable()
.Filter(null, true)
.Count(x => x.EDICODE == input.EDICODE && x.TenantId == input.TenantId && x.CARRIERID == input.CARRIERID && x.SendType == input.SendType);
if (cc > 0)
{
throw Oops.Bah($"该租户({input.TenantName})已存在相同类型({input.EDICODE})、相同船司({input.CARRIERID})、相同发送类型({input.SendType})的参数设置");
}
entity = input.Adapt<DjyEdiSetting>();
await _rep.InsertAsync(entity);
//其他同船司、同发送类型的都禁用
var otherList = _rep.Where(x => x.TenantId == input.TenantId && x.CARRIERID == input.CARRIERID && x.Id != entity.Id).ToList();
foreach (var item in otherList)
{
item.EnableFlag = false;
await _rep.UpdateAsync(item);
}
}
else
{
entity = _rep.AsQueryable()
.Filter(null, true)
.First(x => x.Id == input.Id);
if (entity == null)
{
throw Oops.Bah($"未找到数据");
}
var cc = _rep.AsQueryable().Filter(null, true)
.Count(x => x.EDICODE == input.EDICODE && x.TenantId == input.TenantId && x.CARRIERID == input.CARRIERID && x.SendType == input.SendType && x.Id != input.Id);
if (cc > 0)
{
throw Oops.Bah($"该租户({input.TenantName})已存在相同类型({input.EDICODE})、相同船司({input.CARRIERID})、相同发送类型({input.SendType})的参数设置");
}
entity = input.Adapt(entity);
await _rep.UpdateAsync(entity);
}
await CacheData();
return entity.Id;
}
/// <summary>
/// 更新EDI参数设置准备作废使用save接口代替
/// </summary> /// </summary>
/// <param name="input"></param> /// <param name="input"></param>
/// <returns></returns> /// <returns></returns>
@ -87,10 +147,10 @@ namespace Myshipping.Core.Service
} }
var cc = _rep.AsQueryable().Filter(null, true) var cc = _rep.AsQueryable().Filter(null, true)
.Count(x => x.EDICODE == input.EDICODE && x.TenantId == input.TenantId && x.CARRIERID == input.CARRIERID && x.Id != input.Id); .Count(x => x.EDICODE == input.EDICODE && x.TenantId == input.TenantId && x.CARRIERID == input.CARRIERID && x.SendType == input.SendType && x.Id != input.Id);
if (cc > 0) if (cc > 0)
{ {
throw Oops.Bah($"该租户({input.TenantName})已存在相同类型({input.EDICODE}相同船司({input.CARRIERID})的参数设置"); throw Oops.Bah($"该租户({input.TenantName})已存在相同类型({input.EDICODE}相同船司({input.CARRIERID})、相同发送类型({input.SendType})的参数设置");
} }
entity = input.Adapt(entity); entity = input.Adapt(entity);
@ -100,6 +160,35 @@ namespace Myshipping.Core.Service
return entity.Id; return entity.Id;
} }
/// <summary>
/// 设置启用启用后同船司、同发送类型的其他EDI通道会被取消启用
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[HttpPost("/DjyEdiSetting/SetEnable")]
public async Task SetEnable(long id)
{
var entity = _rep.AsQueryable()
.Filter(null, true)
.First(x => x.Id == id);
if (entity == null)
{
throw Oops.Bah($"未找到数据");
}
entity.EnableFlag = true;
await _rep.UpdateAsync(entity);
//其他同船司、同发送类型的都禁用
var otherList = _rep.Where(x => x.TenantId == entity.TenantId && x.CARRIERID == entity.CARRIERID && x.Id != entity.Id).ToList();
foreach (var item in otherList)
{
item.EnableFlag = false;
await _rep.UpdateAsync(item);
}
}
/// <summary> /// <summary>
/// 删除EDI参数设置 /// 删除EDI参数设置
/// </summary> /// </summary>
@ -141,7 +230,7 @@ namespace Myshipping.Core.Service
{ {
if (!_cacheService.Exists(CommonConst.CACHE_KEY_DJY_EDI_SETTING)) if (!_cacheService.Exists(CommonConst.CACHE_KEY_DJY_EDI_SETTING))
{ {
var list = _rep.AsQueryable().Filter(null, true).OrderBy(x=>x.EDINAME).ToList(); var list = _rep.AsQueryable().Filter(null, true).OrderBy(x => x.EDINAME).ToList();
await _cacheService.SetAllEdiSetting(list); await _cacheService.SetAllEdiSetting(list);
} }
} }

@ -138,6 +138,10 @@ namespace Myshipping.Core
/// 租户名称 /// 租户名称
/// </summary> /// </summary>
public virtual string TenantName { get; set; } public virtual string TenantName { get; set; }
/// <summary>
/// 发送类型
/// </summary>
public string SendType { get; set; } = string.Empty;
} }

@ -10,10 +10,13 @@ namespace Myshipping.Core.Service
Task<dynamic> Page([FromQuery] QueryDjyEdiSettingInput input); Task<dynamic> Page([FromQuery] QueryDjyEdiSettingInput input);
Task<long> Add(AddDjyEdiSettingInput input); Task<long> Add(AddDjyEdiSettingInput input);
Task<long> Update(UpdateDjyEdiSettingInput input); Task<long> Update(UpdateDjyEdiSettingInput input);
Task<long> Save(UpdateDjyEdiSettingInput input);
Task Delete(GetDjyEdiSettingInput input); Task Delete(GetDjyEdiSettingInput input);
Task<DjyEdiSetting> Get([FromQuery] GetDjyEdiSettingInput input); Task<DjyEdiSetting> Get([FromQuery] GetDjyEdiSettingInput input);
//Task<dynamic> List([FromQuery] QueryDjyEdiSettingInput input); //Task<dynamic> List([FromQuery] QueryDjyEdiSettingInput input);
Task SetEnable(long id);
Task CacheData(bool flag); Task CacheData(bool flag);
} }

Loading…
Cancel
Save