jianghaiqing 2 years ago
commit 2a86291312

@ -335,6 +335,266 @@ namespace Myshipping.Application
return list;
}
/// <summary>
/// 立即返回保存信息
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("/BookingOrder/Save")]
public async Task<BookingOrderOutput> Save(BookingOrderDto input){
if (input == null)
{
throw Oops.Bah("请传入正常数据!");
}
JsonUtil.PropToUpper(input, "ORDNO", "BSSTATUS", "YardContract", "YardContractTel", "YardContractEmail", "MARKS", "DESCRIPTION", "CONSIGNEENAME", "SHIPPERNAME", "NOTIFYPARTYNAME");
JsonUtil.TrimFields(input);
if (input.ctnInputs != null)
{
var groupList = input.ctnInputs.Where(x => x.CTNNUM > 0).GroupBy(c => c.CTNALL).Select(g => $"{g.Key}*{g.Sum(gg => gg.CTNNUM)}");
input.CNTRTOTAL = string.Join(" / ", groupList);
}
if (!string.IsNullOrWhiteSpace(input.MBLNO))
{
var et = await _rep.Where(x => x.MBLNO == input.MBLNO && x.TenantId == UserManager.TENANT_ID && x.HBLNO == input.HBLNO && x.ParentId == input.ParentId && x.Id != input.Id).FirstAsync();
if (et != null)
{
throw Oops.Bah("当前提单号已存在,请勿重复录入!");
}
}
var entity = input.Adapt<BookingOrder>();
if (input.Id == 0)
{
entity.BOOKINGNO = Yitter.IdGenerator.YitIdHelper.NextId().ToString();
await _rep.InsertAsync(entity);
if (input.ctnInputs != null)
{
foreach (var item in input.ctnInputs)
{
var ctnentity = item.Adapt<BookingCtn>();
ctnentity.BILLID = entity.Id;
await _repCtn.InsertAsync(ctnentity);
//这里保存有可能没有添加多品名,所有箱下没有货物信息
if (item.ctnDetailInputs != null)
{
foreach (var it in item.ctnDetailInputs)
{
var ctndetail = it.Adapt<BookingCtnDetail>();
ctndetail.CTNID = ctnentity.Id;
await _ctndetailrep.InsertAsync(ctndetail);
}
}
}
}
if (input.BookingEDIExt != null)
{
//写入EDI扩展
var ediExt = input.BookingEDIExt.Adapt<BookingEDIExt>();
ediExt.BookingId = entity.Id;
await _bookingEDIExt.InsertAsync(ediExt);
}
////添加booking日志
await _bookinglog.InsertAsync(new BookingLog
{
Type = "Add",
BookingId = entity.Id,
TenantId = Convert.ToInt64(UserManager.TENANT_ID),
CreatedTime = DateTime.Now,
CreatedUserId = UserManager.UserId,
CreatedUserName = UserManager.Name
});
}
else
{
var mlist = await _rep.AsQueryable().Filter(null, true).Where(x => x.Id == input.Id).FirstAsync();
await _rep.AsUpdateable(entity).IgnoreColumns(it => new
{
it.ParentId,
it.TenantId,
it.CreatedTime,
it.CreatedUserId,
it.CreatedUserName,
it.TenantName,
it.IsDeleted,
it.BOOKINGNO
}).ExecuteCommandAsync();
var ctnlist = await _repCtn.AsQueryable().Where(x => x.BILLID == input.Id).Select(x => x.Id).ToListAsync();
await _repCtn.DeleteAsync(x => x.BILLID == input.Id);
await _ctndetailrep.DeleteAsync(x => ctnlist.Contains((long)x.CTNID));
if (input.ctnInputs != null)
{
foreach (var item in input.ctnInputs)
{
var ctnentity = item.Adapt<BookingCtn>();
ctnentity.BILLID = entity.Id;
await _repCtn.InsertAsync(ctnentity);
if (item.ctnDetailInputs != null)
{
foreach (var it in item.ctnDetailInputs)
{
var ctndetail = it.Adapt<BookingCtnDetail>();
ctndetail.CTNID = ctnentity.Id;
await _ctndetailrep.InsertAsync(ctndetail);
}
}
}
}
if (input.BookingEDIExt != null)
{
//检索EDI扩展
var ediExt = _bookingEDIExt.FirstOrDefault(u => u.BookingId == input.Id);
if (ediExt == null)
{
//写入EDI扩展
ediExt = input.BookingEDIExt.Adapt<BookingEDIExt>();
ediExt.BookingId = entity.Id;
await _bookingEDIExt.InsertAsync(ediExt);
}
else
{
//更新EDI扩展
var currEdiExtEntity = input.BookingEDIExt.Adapt<BookingEDIExt>();
currEdiExtEntity.Id = ediExt.Id;
currEdiExtEntity.BookingId = ediExt.BookingId;
await _bookingEDIExt.AsUpdateable(currEdiExtEntity).IgnoreColumns(it => new
{
it.BookingId,
it.TenantId,
it.CreatedTime,
it.CreatedUserId,
it.CreatedUserName
}).ExecuteCommandAsync();
}
}
bool flag = true;
long bid = 0;
foreach (PropertyDescriptor descriptor in TypeDescriptor.GetProperties(entity))
{
string name = descriptor.Name;
if (name == "TenantId" || name == "CreatedTime" || name == "UpdatedTime" || name == "CreatedUserId" || name == "CreatedUserName")
{
continue;
}
object value = descriptor.GetValue(entity);
var oldvalue = mlist.GetType().GetProperty(name).GetValue(mlist, null);
if (name == "KGS" || name == "CBM")
{
if (Convert.ToDecimal(value) == Convert.ToDecimal(oldvalue))
{
continue;
}
}
string _oldvalue = oldvalue != null ? oldvalue.ToString() : "";
string _value = value != null ? value.ToString() : "";
if (_oldvalue != _value && !string.IsNullOrWhiteSpace(descriptor.Description))
{
if (flag)
{
////添加booking日志
bid = await _bookinglog.InsertReturnSnowflakeIdAsync(new BookingLog
{
Type = "Edit",
BookingId = entity.Id,
TenantId = Convert.ToInt64(UserManager.TENANT_ID),
CreatedTime = DateTime.Now,
CreatedUserId = UserManager.UserId,
CreatedUserName = UserManager.Name
});
flag = false;
}
await _bookinglogdetail.InsertReturnSnowflakeIdAsync(new BookingLogDetail
{
PId = bid,
Field = descriptor.Description,
OldValue = _oldvalue,
NewValue = _value,
});
}
}
}
var Id = entity.Id;
BookingOrderOutput ordOut = new BookingOrderOutput();
var main = await _rep.FirstOrDefaultAsync(u => u.Id == Id);
if (main != null)
{
ordOut = main.Adapt<BookingOrderOutput>();
var ctnlist = await _repCtn.AsQueryable().Where(x => x.BILLID == Id).ToListAsync();
var ctninput = ctnlist.Adapt<List<BookingCtnDto>>();
foreach (var item in ctninput)
{
var ctndetaillist = await _ctndetailrep.AsQueryable().Where(x => x.CTNID == item.Id).ToListAsync();
item.ctnDetailInputs = ctndetaillist.Adapt<List<BookingCtnDetailDto>>();
}
ordOut.ctnInputs = ctninput;
var ordUrl = _repOrderUrl.FirstOrDefault(x => x.BookingId == Id);
if (ordUrl != null)
{
ordOut.Link = new BookingOrderUrlOutput()
{
LinkUrlTxxp = ordUrl.UrlTxxp,
LinkUrlVgm = ordUrl.UrlVgm,
LinkUrlVmgSi = ordUrl.UrlVgmSi,
};
}
}
List<BookingOrderDto> HbList = new List<BookingOrderDto>();
var _hblist = await _rep.AsQueryable().Where(x => x.ParentId == Id).ToListAsync();
if (_hblist != null)
{
HbList = _hblist.Adapt<List<BookingOrderDto>>();
foreach (var item in HbList)
{
var ctnlist = await _repCtn.AsQueryable().Where(x => x.BILLID == item.Id).ToListAsync();
var ctninput = ctnlist.Adapt<List<BookingCtnDto>>();
foreach (var it in ctninput)
{
var ctndetaillist = await _ctndetailrep.AsQueryable().Where(x => x.CTNID == it.Id).ToListAsync();
it.ctnDetailInputs = ctndetaillist.Adapt<List<BookingCtnDetailDto>>();
}
item.ctnInputs = ctninput;
//检索EDI扩展
var ediExt = _bookingEDIExt.FirstOrDefault(u => u.BookingId == item.Id);
if (ediExt != null)
{
item.BookingEDIExt = ediExt.Adapt<BookingEDIExtDto>();
}
}
ordOut.HbList = HbList;
}
//检索EDI扩展
var ediExtEntity = _bookingEDIExt.FirstOrDefault(u => u.BookingId == Id);
if (ediExtEntity != null)
{
ordOut.BookingEDIExt = ediExtEntity.Adapt<BookingEDIExtDto>();
}
return ordOut;
}
[HttpPost("/BookingOrder/AddOrUpdate")]
public async Task<long> AddOrUpdate(BookingOrderDto Dto)
@ -343,6 +603,7 @@ namespace Myshipping.Application
{
throw Oops.Bah("请传入正常数据!");
}
if (Dto.Id == 0)
{
return await Add(Dto);
@ -363,31 +624,6 @@ namespace Myshipping.Application
[HttpPost("/BookingOrder/Add")]
public async Task<long> Add(BookingOrderDto input)
{
//if (input.ParentId == 0)
//{
// //if (!string.IsNullOrWhiteSpace(input.HBLNO))
// //{
// // throw Oops.Bah("主单不需要填写分单号");
// //}
// if (string.IsNullOrWhiteSpace(input.MBLNO))
// {
// throw Oops.Bah("请填写提单号!");
// }
//}
//else
//{
// if (string.IsNullOrWhiteSpace(input.MBLNO))
// {
// throw Oops.Bah("请填写主提单号");
// }
// if (string.IsNullOrWhiteSpace(input.HBLNO))
// {
// throw Oops.Bah("请填写分提单号");
// }
//}
JsonUtil.PropToUpper(input, "ORDNO", "BSSTATUS", "YardContract", "YardContractTel", "YardContractEmail", "MARKS", "DESCRIPTION", "CONSIGNEENAME", "SHIPPERNAME", "NOTIFYPARTYNAME");
JsonUtil.TrimFields(input);
if (input.ctnInputs != null)
@ -484,28 +720,7 @@ namespace Myshipping.Application
[HttpPost("/BookingOrder/Update")]
public async Task Update(BookingOrderDto input)
{
//if (input.ParentId == 0)
//{
// //if (!string.IsNullOrWhiteSpace(input.HBLNO))
// //{
// // throw Oops.Bah("主单不需要填写分单号");
// //}
// if (string.IsNullOrWhiteSpace(input.MBLNO))
// {
// throw Oops.Bah("请填写提单号!");
// }
//}
//else
//{
// if (string.IsNullOrWhiteSpace(input.MBLNO))
// {
// throw Oops.Bah("请填写主提单号");
// }
// if (string.IsNullOrWhiteSpace(input.HBLNO))
// {
// throw Oops.Bah("请填写分提单号");
// }
//}
JsonUtil.PropToUpper(input, "ORDNO", "BSSTATUS", "YardContract", "YardContractTel", "YardContractEmail", "MARKS", "DESCRIPTION", "CONSIGNEENAME", "SHIPPERNAME", "NOTIFYPARTYNAME");
JsonUtil.TrimFields(input);
if (input.ctnInputs != null)

@ -111,5 +111,13 @@ namespace Myshipping.Core.Entity
/// 租户名称
/// </summary>
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>
</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">
<summary>
@ -10766,18 +10776,32 @@
</member>
<member name="M:Myshipping.Core.Service.DjyEdiSettingService.Add(Myshipping.Core.AddDjyEdiSettingInput)">
<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>
<param name="input"></param>
<returns></returns>
</member>
<member name="M:Myshipping.Core.Service.DjyEdiSettingService.Update(Myshipping.Core.UpdateDjyEdiSettingInput)">
<summary>
更新EDI参数设置
更新EDI参数设置准备作废使用save接口代替
</summary>
<param name="input"></param>
<returns></returns>
</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)">
<summary>
删除EDI参数设置
@ -15474,6 +15498,11 @@
租户名称
</summary>
</member>
<member name="P:Myshipping.Core.DjyEdiSettingInput.SendType">
<summary>
发送类型
</summary>
</member>
<member name="T:Myshipping.Core.AddDjyEdiSettingInput">
<summary>
EDI参数设置新增输入参数

@ -49,7 +49,7 @@ namespace Myshipping.Core.Service
}
/// <summary>
/// 增加EDI参数设置
/// 增加EDI参数设置准备作废使用save接口代替
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
@ -58,20 +58,80 @@ namespace Myshipping.Core.Service
{
var cc = _rep.AsQueryable()
.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)
{
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>();
await _rep.InsertAsync(entity);
await CacheData();
return entity.Id;
}
/// <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>
/// <param name="input"></param>
/// <returns></returns>
@ -87,10 +147,10 @@ namespace Myshipping.Core.Service
}
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)
{
throw Oops.Bah($"该租户({input.TenantName})已存在相同类型({input.EDICODE}相同船司({input.CARRIERID})的参数设置");
throw Oops.Bah($"该租户({input.TenantName})已存在相同类型({input.EDICODE}相同船司({input.CARRIERID})、相同发送类型({input.SendType})的参数设置");
}
entity = input.Adapt(entity);
@ -100,6 +160,35 @@ namespace Myshipping.Core.Service
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>
/// 删除EDI参数设置
/// </summary>
@ -141,7 +230,7 @@ namespace Myshipping.Core.Service
{
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);
}
}

@ -13,132 +13,136 @@ namespace Myshipping.Core
/// EDI类型代码
/// </summary>
public virtual string EDICODE { get; set; }
/// <summary>
/// EDI类型名称
/// </summary>
public virtual string EDINAME { get; set; }
/// <summary>
/// 服务器IP
/// </summary>
public virtual string SERVERIP { get; set; }
/// <summary>
/// 文件夹
/// </summary>
public virtual string FOLDERNAME { get; set; }
/// <summary>
/// 用户名
/// </summary>
public virtual string USERNAME { get; set; }
/// <summary>
/// 密码
/// </summary>
public virtual string PASSWORD { get; set; }
/// <summary>
/// 发送方代码
/// </summary>
public virtual string SENDCODE { get; set; }
/// <summary>
/// 接收方代码
/// </summary>
public virtual string RECEIVECODE { get; set; }
/// <summary>
/// 发送方名称
/// </summary>
public virtual string SENDNAME { get; set; }
/// <summary>
/// 发送方联系人
/// </summary>
public virtual string SENDATTN { get; set; }
/// <summary>
/// 发送方邮箱
/// </summary>
public virtual string SENDTEL { get; set; }
/// <summary>
/// 发送方电话
/// </summary>
public virtual string SENDEMAIL { get; set; }
/// <summary>
/// 发送方公司代码
/// </summary>
public virtual string SENDCOMPANYCODE { get; set; }
/// <summary>
/// 发送方部门代码
/// </summary>
public virtual string SENDSUBCOMPANYCODE { get; set; }
/// <summary>
/// 船公司代码
/// </summary>
public virtual string CARRIERID { get; set; }
/// <summary>
/// 接收方邮箱
/// </summary>
public virtual string RECEIVEEMAIL { get; set; }
/// <summary>
/// 接收方SI邮箱
/// </summary>
public virtual string RECEIVESIEMAIL { get; set; }
/// <summary>
/// 接收方操作
/// </summary>
public virtual string RECEIVEOP { get; set; }
/// <summary>
/// 接收方销售
/// </summary>
public virtual string RECEIVESALE { get; set; }
/// <summary>
/// 接收方部门
/// </summary>
public virtual string RECEIVEDEPT { get; set; }
/// <summary>
/// 发送人电话
/// </summary>
public virtual string SHIPPERTEL { get; set; }
/// <summary>
/// 收货人电话
/// </summary>
public virtual string CONSIGNEETEL { get; set; }
/// <summary>
/// 通知人电话
/// </summary>
public virtual string NOTIFYPARTYTEL { get; set; }
/// <summary>
/// 是否设置TEL
/// </summary>
public virtual string ISUSETEL { get; set; }
/// <summary>
/// 租户ID
/// </summary>
public virtual long TenantId { get; set; }
/// <summary>
/// 租户名称
/// </summary>
public virtual string TenantName { get; set; }
/// <summary>
/// 发送类型
/// </summary>
public string SendType { get; set; } = string.Empty;
}
/// <summary>
@ -158,7 +162,7 @@ namespace Myshipping.Core
/// </summary>
[Required(ErrorMessage = "主键不能为空")]
public long Id { get; set; }
}
/// <summary>
@ -171,7 +175,7 @@ namespace Myshipping.Core
/// </summary>
[Required(ErrorMessage = "主键不能为空")]
public long Id { get; set; }
}
/// <summary>
@ -183,31 +187,31 @@ namespace Myshipping.Core
/// 主键
/// </summary>
public virtual long Id { get; set; }
/// <summary>
/// EDI类型代码
/// </summary>
public virtual string EDICODE { get; set; }
/// <summary>
/// EDI类型名称
/// </summary>
public virtual string EDINAME { get; set; }
/// <summary>
/// 船公司代码
/// </summary>
public virtual string CARRIERID { get; set; }
/// <summary>
/// 租户ID
/// </summary>
public virtual long TenantId { get; set; }
/// <summary>
/// 租户名称
/// </summary>
public virtual string TenantName { get; set; }
}
}

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