optimize
wet 2 years ago
parent 72dc4d553b
commit a5b84f0764

@ -794,113 +794,113 @@ namespace Myshipping.Application
} }
#region 废弃代码
[HttpPost("/BookingOrder/AddOrUpdate")] //[HttpPost("/BookingOrder/AddOrUpdate")]
public async Task<long> AddOrUpdate(BookingOrderDto Dto) //public async Task<long> AddOrUpdate(BookingOrderDto Dto)
{ //{
if (Dto == null) // if (Dto == null)
{ // {
throw Oops.Bah("请传入正常数据!"); // throw Oops.Bah("请传入正常数据!");
} // }
if (Dto.Id == 0) // if (Dto.Id == 0)
{ // {
return await Add(Dto); // return await Add(Dto);
} // }
else // else
{ // {
await Update(Dto); // await Update(Dto);
return Dto.Id; // return Dto.Id;
} // }
} //}
/// <summary> ///// <summary>
/// 增加订舱 ///// 增加订舱
/// </summary> ///// </summary>
/// <param name="input"></param> ///// <param name="input"></param>
/// <returns></returns> ///// <returns></returns>
[SqlSugarUnitOfWork] //[SqlSugarUnitOfWork]
[HttpPost("/BookingOrder/Add")] //[HttpPost("/BookingOrder/Add")]
public async Task<long> Add(BookingOrderDto input) //public async Task<long> Add(BookingOrderDto input)
{ //{
JsonUtil.PropToUpper(input, "ORDNO", "BSSTATUS", "YARDID", "YardContract", "YardContractTel", "YardContractEmail", "MARKS", "DESCRIPTION", "CONSIGNEENAME", "SHIPPERNAME", "NOTIFYPARTYNAME"); // JsonUtil.PropToUpper(input, "ORDNO", "BSSTATUS", "YARDID", "YardContract", "YardContractTel", "YardContractEmail", "MARKS", "DESCRIPTION", "CONSIGNEENAME", "SHIPPERNAME", "NOTIFYPARTYNAME");
var ms = JsonUtil.TrimFields(input); // var ms = JsonUtil.TrimFields(input);
if (!string.IsNullOrEmpty(ms)) // if (!string.IsNullOrEmpty(ms))
{ // {
throw Oops.Bah(ms); // throw Oops.Bah(ms);
} // }
if (input.ctnInputs != null) // 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)}"); // 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); // input.CNTRTOTAL = string.Join(" / ", groupList);
} // }
if (!string.IsNullOrWhiteSpace(input.MBLNO)) // 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).FirstAsync(); // var et = await _rep.Where(x => x.MBLNO == input.MBLNO && x.TenantId == UserManager.TENANT_ID && x.HBLNO == input.HBLNO && x.ParentId == input.ParentId).FirstAsync();
if (et != null) // if (et != null)
{ // {
throw Oops.Bah("当前提单号已存在,请勿重复录入!"); // throw Oops.Bah("当前提单号已存在,请勿重复录入!");
} // }
} // }
var entity = input.Adapt<BookingOrder>(); // var entity = input.Adapt<BookingOrder>();
entity.BOOKINGNO = Yitter.IdGenerator.YitIdHelper.NextId().ToString(); // entity.BOOKINGNO = Yitter.IdGenerator.YitIdHelper.NextId().ToString();
//entity.TOTALNO = NumberToUpper.ToUpper(entity.PKGS == null ? 0 : entity.PKGS); // //entity.TOTALNO = NumberToUpper.ToUpper(entity.PKGS == null ? 0 : entity.PKGS);
await _rep.InsertAsync(entity); // await _rep.InsertAsync(entity);
if (input.ctnInputs != null) // if (input.ctnInputs != null)
{ // {
foreach (var item in input.ctnInputs) // foreach (var item in input.ctnInputs)
{ // {
var ctnentity = item.Adapt<BookingCtn>(); // var ctnentity = item.Adapt<BookingCtn>();
ctnentity.BILLID = entity.Id; // ctnentity.BILLID = entity.Id;
await _repCtn.InsertAsync(ctnentity); // await _repCtn.InsertAsync(ctnentity);
//这里保存有可能没有添加多品名,所有箱下没有货物信息 // //这里保存有可能没有添加多品名,所有箱下没有货物信息
if (item.ctnDetailInputs != null) // if (item.ctnDetailInputs != null)
{ // {
foreach (var it in item.ctnDetailInputs) // foreach (var it in item.ctnDetailInputs)
{ // {
var ctndetail = it.Adapt<BookingCtnDetail>(); // var ctndetail = it.Adapt<BookingCtnDetail>();
ctndetail.CTNID = ctnentity.Id; // ctndetail.CTNID = ctnentity.Id;
await _ctndetailrep.InsertAsync(ctndetail); // await _ctndetailrep.InsertAsync(ctndetail);
} // }
} // }
} // }
} // }
if (input.BookingEDIExt != null) // if (input.BookingEDIExt != null)
{ // {
//写入EDI扩展 // //写入EDI扩展
var ediExtEntity = input.BookingEDIExt.Adapt<BookingEDIExt>(); // var ediExtEntity = input.BookingEDIExt.Adapt<BookingEDIExt>();
ediExtEntity.BookingId = entity.Id; // ediExtEntity.BookingId = entity.Id;
await _bookingEDIExt.InsertAsync(ediExtEntity); // await _bookingEDIExt.InsertAsync(ediExtEntity);
} // }
////添加booking日志 // ////添加booking日志
await _bookinglog.InsertAsync(new BookingLog // await _bookinglog.InsertAsync(new BookingLog
{ // {
Type = "Add", // Type = "Add",
BookingId = entity.Id, // BookingId = entity.Id,
TenantId = Convert.ToInt64(UserManager.TENANT_ID), // TenantId = Convert.ToInt64(UserManager.TENANT_ID),
CreatedTime = DateTime.Now, // CreatedTime = DateTime.Now,
CreatedUserId = UserManager.UserId, // CreatedUserId = UserManager.UserId,
CreatedUserName = UserManager.Name // CreatedUserName = UserManager.Name
}); // });
//////分单不调用 // //////分单不调用
//if (!string.IsNullOrWhiteSpace(input.YARDID) && !string.IsNullOrWhiteSpace(input.YARD) && !string.IsNullOrWhiteSpace(input.MBLNO)) // //if (!string.IsNullOrWhiteSpace(input.YARDID) && !string.IsNullOrWhiteSpace(input.YARD) && !string.IsNullOrWhiteSpace(input.MBLNO))
//{ // //{
// await SendTrace(entity.Id.ToString(), entity.YARDID, entity.YARD, entity.MBLNO); // // await SendTrace(entity.Id.ToString(), entity.YARDID, entity.YARD, entity.MBLNO);
//} // //}
return entity.Id; // return entity.Id;
} //}
#endregion
/// <summary> /// <summary>
/// 删除订舱 /// 删除订舱
/// </summary> /// </summary>
@ -1051,161 +1051,161 @@ namespace Myshipping.Application
} }
#region 废弃代码
/// <summary> ///// <summary>
/// 更新订舱 ///// 更新订舱
/// </summary> ///// </summary>
/// <param name="input"></param> ///// <param name="input"></param>
/// <returns></returns> ///// <returns></returns>
[SqlSugarUnitOfWork] //[SqlSugarUnitOfWork]
[HttpPost("/BookingOrder/Update")] //[HttpPost("/BookingOrder/Update")]
public async Task Update(BookingOrderDto input) //public async Task Update(BookingOrderDto input)
{ //{
JsonUtil.PropToUpper(input, "ORDNO", "BSSTATUS", "YARDID", "YardContract", "YardContractTel", "YardContractEmail", "MARKS", "DESCRIPTION", "CONSIGNEENAME", "SHIPPERNAME", "NOTIFYPARTYNAME"); // JsonUtil.PropToUpper(input, "ORDNO", "BSSTATUS", "YARDID", "YardContract", "YardContractTel", "YardContractEmail", "MARKS", "DESCRIPTION", "CONSIGNEENAME", "SHIPPERNAME", "NOTIFYPARTYNAME");
JsonUtil.TrimFields(input); // JsonUtil.TrimFields(input);
if (input.ctnInputs != null) // 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)}"); // 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); // input.CNTRTOTAL = string.Join(" / ", groupList);
} // }
var main = await _rep.AsQueryable().Filter(null, true).Where(x => x.Id == input.Id).FirstAsync(); // var main = await _rep.AsQueryable().Filter(null, true).Where(x => x.Id == input.Id).FirstAsync();
if (!string.IsNullOrWhiteSpace(input.MBLNO)) // 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(); // 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) // if (et != null)
{ // {
throw Oops.Bah("当前提单号已存在,请勿重复录入!"); // throw Oops.Bah("当前提单号已存在,请勿重复录入!");
} // }
} // }
var entity = input.Adapt<BookingOrder>(); // var entity = input.Adapt<BookingOrder>();
//entity.TOTALNO = NumberToUpper.ToUpper(entity.PKGS == null ? 0 : entity.PKGS); // //entity.TOTALNO = NumberToUpper.ToUpper(entity.PKGS == null ? 0 : entity.PKGS);
await _rep.AsUpdateable(entity).IgnoreColumns(it => new // await _rep.AsUpdateable(entity).IgnoreColumns(it => new
{ // {
it.ParentId, // it.ParentId,
it.TenantId, // it.TenantId,
it.CreatedTime, // it.CreatedTime,
it.CreatedUserId, // it.CreatedUserId,
it.CreatedUserName, // it.CreatedUserName,
it.TenantName, // it.TenantName,
it.IsDeleted, // it.IsDeleted,
it.BOOKINGNO // it.BOOKINGNO
}).ExecuteCommandAsync(); // }).ExecuteCommandAsync();
var ctnlist = await _repCtn.AsQueryable().Where(x => x.BILLID == input.Id).Select(x => x.Id).ToListAsync(); // 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 _repCtn.DeleteAsync(x => x.BILLID == input.Id);
await _ctndetailrep.DeleteAsync(x => ctnlist.Contains((long)x.CTNID)); // await _ctndetailrep.DeleteAsync(x => ctnlist.Contains((long)x.CTNID));
if (input.ctnInputs != null) // if (input.ctnInputs != null)
{ // {
foreach (var item in input.ctnInputs) // foreach (var item in input.ctnInputs)
{ // {
var ctnentity = item.Adapt<BookingCtn>(); // var ctnentity = item.Adapt<BookingCtn>();
ctnentity.BILLID = entity.Id; // ctnentity.BILLID = entity.Id;
await _repCtn.InsertAsync(ctnentity); // await _repCtn.InsertAsync(ctnentity);
if (item.ctnDetailInputs != null) // if (item.ctnDetailInputs != null)
{ // {
foreach (var it in item.ctnDetailInputs) // foreach (var it in item.ctnDetailInputs)
{ // {
var ctndetail = it.Adapt<BookingCtnDetail>(); // var ctndetail = it.Adapt<BookingCtnDetail>();
ctndetail.CTNID = ctnentity.Id; // ctndetail.CTNID = ctnentity.Id;
await _ctndetailrep.InsertAsync(ctndetail); // await _ctndetailrep.InsertAsync(ctndetail);
} // }
} // }
} // }
} // }
if (input.BookingEDIExt != null) // if (input.BookingEDIExt != null)
{ // {
//检索EDI扩展 // //检索EDI扩展
var ediExtEntity = _bookingEDIExt.FirstOrDefault(u => u.BookingId == input.Id); // var ediExtEntity = _bookingEDIExt.FirstOrDefault(u => u.BookingId == input.Id);
if (ediExtEntity == null) // if (ediExtEntity == null)
{ // {
//写入EDI扩展 // //写入EDI扩展
ediExtEntity = input.BookingEDIExt.Adapt<BookingEDIExt>(); // ediExtEntity = input.BookingEDIExt.Adapt<BookingEDIExt>();
ediExtEntity.BookingId = entity.Id; // ediExtEntity.BookingId = entity.Id;
await _bookingEDIExt.InsertAsync(ediExtEntity); // await _bookingEDIExt.InsertAsync(ediExtEntity);
} // }
else // else
{ // {
//更新EDI扩展 // //更新EDI扩展
var currEdiExtEntity = input.BookingEDIExt.Adapt<BookingEDIExt>(); // var currEdiExtEntity = input.BookingEDIExt.Adapt<BookingEDIExt>();
currEdiExtEntity.Id = ediExtEntity.Id; // currEdiExtEntity.Id = ediExtEntity.Id;
currEdiExtEntity.BookingId = ediExtEntity.BookingId; // currEdiExtEntity.BookingId = ediExtEntity.BookingId;
await _bookingEDIExt.AsUpdateable(currEdiExtEntity).IgnoreColumns(it => new // await _bookingEDIExt.AsUpdateable(currEdiExtEntity).IgnoreColumns(it => new
{ // {
it.BookingId, // it.BookingId,
it.TenantId, // it.TenantId,
it.CreatedTime, // it.CreatedTime,
it.CreatedUserId, // it.CreatedUserId,
it.CreatedUserName // it.CreatedUserName
}).ExecuteCommandAsync(); // }).ExecuteCommandAsync();
} // }
} // }
bool flag = true; // bool flag = true;
long bid = 0; // long bid = 0;
foreach (PropertyDescriptor descriptor in TypeDescriptor.GetProperties(entity)) // foreach (PropertyDescriptor descriptor in TypeDescriptor.GetProperties(entity))
{ // {
string name = descriptor.Name; // string name = descriptor.Name;
if (name == "TenantId" || name == "CreatedTime" || name == "UpdatedTime" || name == "CreatedUserId" || name == "CreatedUserName") // if (name == "TenantId" || name == "CreatedTime" || name == "UpdatedTime" || name == "CreatedUserId" || name == "CreatedUserName")
{ // {
continue; // continue;
} // }
object value = descriptor.GetValue(entity); // object value = descriptor.GetValue(entity);
var oldvalue = main.GetType().GetProperty(name).GetValue(main, null); // var oldvalue = main.GetType().GetProperty(name).GetValue(main, null);
if (name == "KGS" || name == "CBM") // if (name == "KGS" || name == "CBM")
{ // {
if (Convert.ToDecimal(value) == Convert.ToDecimal(oldvalue)) // if (Convert.ToDecimal(value) == Convert.ToDecimal(oldvalue))
{ // {
continue; // continue;
} // }
} // }
string _oldvalue = oldvalue != null ? oldvalue.ToString() : ""; // string _oldvalue = oldvalue != null ? oldvalue.ToString() : "";
string _value = value != null ? value.ToString() : ""; // string _value = value != null ? value.ToString() : "";
if (_oldvalue != _value && !string.IsNullOrWhiteSpace(descriptor.Description)) // if (_oldvalue != _value && !string.IsNullOrWhiteSpace(descriptor.Description))
{ // {
if (flag) // if (flag)
{ // {
////添加booking日志 // ////添加booking日志
bid = await _bookinglog.InsertReturnSnowflakeIdAsync(new BookingLog // bid = await _bookinglog.InsertReturnSnowflakeIdAsync(new BookingLog
{ // {
Type = "Edit", // Type = "Edit",
BookingId = entity.Id, // BookingId = entity.Id,
TenantId = Convert.ToInt64(UserManager.TENANT_ID), // TenantId = Convert.ToInt64(UserManager.TENANT_ID),
CreatedTime = DateTime.Now, // CreatedTime = DateTime.Now,
CreatedUserId = UserManager.UserId, // CreatedUserId = UserManager.UserId,
CreatedUserName = UserManager.Name // CreatedUserName = UserManager.Name
}); // });
flag = false; // flag = false;
} // }
await _bookinglogdetail.InsertReturnSnowflakeIdAsync(new BookingLogDetail // await _bookinglogdetail.InsertReturnSnowflakeIdAsync(new BookingLogDetail
{ // {
PId = bid, // PId = bid,
Field = descriptor.Description, // Field = descriptor.Description,
OldValue = _oldvalue, // OldValue = _oldvalue,
NewValue = _value, // NewValue = _value,
}); // });
//if (descriptor.Name == "YARDID" || descriptor.Name == "YARD" || descriptor.Name == "MBLNO") // //if (descriptor.Name == "YARDID" || descriptor.Name == "YARD" || descriptor.Name == "MBLNO")
//{ // //{
// if (!string.IsNullOrWhiteSpace(input.YARDID) && !string.IsNullOrWhiteSpace(input.YARD) && !string.IsNullOrWhiteSpace(input.MBLNO)) // // if (!string.IsNullOrWhiteSpace(input.YARDID) && !string.IsNullOrWhiteSpace(input.YARD) && !string.IsNullOrWhiteSpace(input.MBLNO))
// { // // {
// await SendTrace(entity.Id.ToString(), entity.YARDID, entity.YARD, entity.MBLNO); // // await SendTrace(entity.Id.ToString(), entity.YARDID, entity.YARD, entity.MBLNO);
// } // // }
//} // //}
} // }
} // }
} //}
#endregion
/// <summary> /// <summary>
/// 获取订舱明细 /// 获取订舱明细
/// </summary> /// </summary>
@ -1571,7 +1571,7 @@ namespace Myshipping.Application
var userid = order.CreatedUserId; var userid = order.CreatedUserId;
if (userid != null) if (userid != null)
{ {
//获取当前用户已经录入的货物状态
var list = await _goodsStatus.AsQueryable().LeftJoin(_goodsStatusConfig.AsQueryable(), var list = await _goodsStatus.AsQueryable().LeftJoin(_goodsStatusConfig.AsQueryable(),
(goods, config) => config.Id == goods.ConfigId).Where((goods, config) => config.CreatedUserId == userid && goods.bookingId == input.BookingId). (goods, config) => config.Id == goods.ConfigId).Where((goods, config) => config.CreatedUserId == userid && goods.bookingId == input.BookingId).
OrderBy((goods, config) => config.Sort). OrderBy((goods, config) => config.Sort).
@ -1589,7 +1589,7 @@ namespace Myshipping.Application
Sort = config.Sort Sort = config.Sort
}).ToListAsync(); }).ToListAsync();
//配置中所有的货物状态
var config = _goodsStatusConfig.AsQueryable().Where(config => config.CreatedUserId == userid).ToList().DistinctBy(x => x.StatusName).Select(config => new GoodsStatusQuery var config = _goodsStatusConfig.AsQueryable().Where(config => config.CreatedUserId == userid).ToList().DistinctBy(x => x.StatusName).Select(config => new GoodsStatusQuery
{ {
@ -1604,11 +1604,12 @@ namespace Myshipping.Application
Remark = null, Remark = null,
Sort = config.Sort Sort = config.Sort
}).ToList(); }).ToList();
//去掉两个list中重复的货物状态
foreach (var item in list) foreach (var item in list)
{ {
config.RemoveAll(x => x.ConfigId == item.ConfigId); config.RemoveAll(x => x.ConfigId == item.ConfigId);
} }
var t = list.Union<GoodsStatusQuery>(config).OrderBy(x => x.Sort).DistinctBy(x => x.StatusName).ToList(); var t = list.Union<GoodsStatusQuery>(config).OrderBy(x => x.Sort).DistinctBy(x => x.StatusName).ToList();
if (t != null) if (t != null)
{ {
@ -1632,12 +1633,7 @@ namespace Myshipping.Application
it.BOOKINGNO it.BOOKINGNO
}).ExecuteCommandAsync(); }).ExecuteCommandAsync();
} }
List<long> tslist = new List<long>(); List<long> tslist = new List<long>();
tslist.Add((long)input.BookingId); tslist.Add((long)input.BookingId);
var itemcode = _cache.GetAllTenantParam().Result.Where(x => x.ParaCode == "BOOKING_DATA_PUSH" && x.TenantId == UserManager.TENANT_ID).Select(x => x.ItemCode).FirstOrDefault(); var itemcode = _cache.GetAllTenantParam().Result.Where(x => x.ParaCode == "BOOKING_DATA_PUSH" && x.TenantId == UserManager.TENANT_ID).Select(x => x.ItemCode).FirstOrDefault();

Loading…
Cancel
Save