optimize
wet 2 years ago
parent 4edb266d21
commit a39c11ab23

@ -173,7 +173,7 @@ namespace Myshipping.Application
var etoday = DateTime.Now.AddDays(15); var etoday = DateTime.Now.AddDays(15);
//List<long> userlist = await DataFilterExtensions.GetDataScopeIdList(); //List<long> userlist = await DataFilterExtensions.GetDataScopeIdList();
var entities = await _rep.AsQueryable() var entities = await _rep.AsQueryable()
.WhereIF(input.firstFlag, x=>x.ETD<= etoday&&x.ETD>=ftoday||x.ETD==null) .WhereIF(input.firstFlag, x=>x.ETD<= etoday||x.ETD>=ftoday||x.ETD==null)
.WhereIF(string.IsNullOrWhiteSpace(input.HBLNO), x => x.ParentId == 0 || x.ParentId == null) .WhereIF(string.IsNullOrWhiteSpace(input.HBLNO), x => x.ParentId == 0 || x.ParentId == null)
.WhereIF(pidlist != null && pidlist.Count > 0, x => pidlist.Contains(x.Id)) .WhereIF(pidlist != null && pidlist.Count > 0, x => pidlist.Contains(x.Id))
.WhereIF(!string.IsNullOrWhiteSpace(input.BSNO), u => u.BSNO.Contains(input.BSNO)) .WhereIF(!string.IsNullOrWhiteSpace(input.BSNO), u => u.BSNO.Contains(input.BSNO))

@ -190,11 +190,10 @@ namespace Myshipping.Application
{ {
throw Oops.Bah("当前提单号已存在,请勿重复录入!"); throw Oops.Bah("当前提单号已存在,请勿重复录入!");
} }
var entity = model.Adapt<BookingOrder>(); var entity = model.Adapt<BookingOrder>();
entity.CreatedUserId = user.Result.Id; entity.CreatedUserId = user.Result.Id;
entity.CreatedUserName = user.Result.Name; entity.CreatedUserName = user.Result.Name.ToString();
entity.CreatedTime = DateTime.Now; entity.CreatedTime = DateTime.Now;
entity.ParentId =0; entity.ParentId =0;
await _rep.InsertAsync(entity); await _rep.InsertAsync(entity);
@ -204,6 +203,8 @@ namespace Myshipping.Application
{ {
var ctnentity = item.Adapt<BookingCtn>(); var ctnentity = item.Adapt<BookingCtn>();
ctnentity.BILLID = entity.Id; ctnentity.BILLID = entity.Id;
ctnentity.CreatedUserId = user.Result.Id;
ctnentity.CreatedUserName = user.Result.Name;
await _repCtn.InsertAsync(ctnentity); await _repCtn.InsertAsync(ctnentity);
//这里保存有可能没有添加多品名,所有箱下没有货物信息 //这里保存有可能没有添加多品名,所有箱下没有货物信息
@ -213,6 +214,8 @@ namespace Myshipping.Application
{ {
var ctndetail = it.Adapt<BookingCtnDetail>(); var ctndetail = it.Adapt<BookingCtnDetail>();
ctndetail.CTNID = ctnentity.Id; ctndetail.CTNID = ctnentity.Id;
ctndetail.CreatedUserId = user.Result.Id;
ctndetail.CreatedUserName = user.Result.Name;
await _ctndetailrep.InsertAsync(ctndetail); await _ctndetailrep.InsertAsync(ctndetail);
} }
} }
@ -229,6 +232,8 @@ namespace Myshipping.Application
ediExtEntity.CreatedUserId = user.Result.Id; ediExtEntity.CreatedUserId = user.Result.Id;
ediExtEntity.CreatedUserName = user.Result.Name; ediExtEntity.CreatedUserName = user.Result.Name;
ediExtEntity.CreatedTime = DateTime.Now; ediExtEntity.CreatedTime = DateTime.Now;
ediExtEntity.CreatedUserId = user.Result.Id;
ediExtEntity.CreatedUserName = user.Result.Name;
await _bookingEDIExt.InsertAsync(ediExtEntity); await _bookingEDIExt.InsertAsync(ediExtEntity);
} }
////添加booking日志 ////添加booking日志
@ -283,6 +288,8 @@ namespace Myshipping.Application
{ {
var ctnentity = item.Adapt<BookingCtn>(); var ctnentity = item.Adapt<BookingCtn>();
ctnentity.BILLID = fdentity.Id; ctnentity.BILLID = fdentity.Id;
ctnentity.CreatedUserId = user.Result.Id;
ctnentity.CreatedUserName = user.Result.Name;
await _repCtn.InsertAsync(ctnentity); await _repCtn.InsertAsync(ctnentity);
//这里保存有可能没有添加多品名,所有箱下没有货物信息 //这里保存有可能没有添加多品名,所有箱下没有货物信息
@ -292,6 +299,9 @@ namespace Myshipping.Application
{ {
var ctndetail = dit.Adapt<BookingCtnDetail>(); var ctndetail = dit.Adapt<BookingCtnDetail>();
ctndetail.CTNID = ctnentity.Id; ctndetail.CTNID = ctnentity.Id;
ctndetail.CreatedUserId = user.Result.Id;
ctndetail.CreatedUserName = user.Result.Name;
await _ctndetailrep.InsertAsync(ctndetail); await _ctndetailrep.InsertAsync(ctndetail);
} }
} }
@ -376,6 +386,8 @@ namespace Myshipping.Application
{ {
var ctnentity = item.Adapt<BookingCtn>(); var ctnentity = item.Adapt<BookingCtn>();
ctnentity.BILLID = main.Id; ctnentity.BILLID = main.Id;
ctnentity.CreatedUserId = user.Result.Id;
ctnentity.CreatedUserName = user.Result.Name;
await _repCtn.InsertAsync(ctnentity); await _repCtn.InsertAsync(ctnentity);
if (item.ctnDetailInputs != null) if (item.ctnDetailInputs != null)
{ {
@ -383,6 +395,9 @@ namespace Myshipping.Application
{ {
var ctndetail = it.Adapt<BookingCtnDetail>(); var ctndetail = it.Adapt<BookingCtnDetail>();
ctndetail.CTNID = ctnentity.Id; ctndetail.CTNID = ctnentity.Id;
ctndetail.CreatedUserId = user.Result.Id;
ctndetail.CreatedUserName = user.Result.Name;
await _ctndetailrep.InsertAsync(ctndetail); await _ctndetailrep.InsertAsync(ctndetail);
} }
} }
@ -410,7 +425,8 @@ namespace Myshipping.Application
var currEdiExtEntity = model.BookingEDIExt.Adapt<BookingEDIExt>(); var currEdiExtEntity = model.BookingEDIExt.Adapt<BookingEDIExt>();
currEdiExtEntity.Id = ediExtEntity.Id; currEdiExtEntity.Id = ediExtEntity.Id;
currEdiExtEntity.UpdatedUserId = user.Result.Id;
currEdiExtEntity.UpdatedTime = DateTime.Now;
await _bookingEDIExt.AsUpdateable(currEdiExtEntity).IgnoreColumns(it => new await _bookingEDIExt.AsUpdateable(currEdiExtEntity).IgnoreColumns(it => new
{ {
it.BookingId, it.BookingId,
@ -518,6 +534,8 @@ namespace Myshipping.Application
{ {
var ctnentity = item.Adapt<BookingCtn>(); var ctnentity = item.Adapt<BookingCtn>();
ctnentity.BILLID = fdmain.Id; ctnentity.BILLID = fdmain.Id;
ctnentity.CreatedUserId = user.Result.Id;
ctnentity.CreatedUserName = user.Result.Name;
await _repCtn.InsertAsync(ctnentity); await _repCtn.InsertAsync(ctnentity);
if (it.ctnDetailInputs != null) if (it.ctnDetailInputs != null)
{ {
@ -525,6 +543,8 @@ namespace Myshipping.Application
{ {
var ctndetail = it_.Adapt<BookingCtnDetail>(); var ctndetail = it_.Adapt<BookingCtnDetail>();
ctndetail.CTNID = ctnentity.Id; ctndetail.CTNID = ctnentity.Id;
ctndetail.CreatedUserId = user.Result.Id;
ctndetail.CreatedUserName = user.Result.Name;
await _ctndetailrep.InsertAsync(ctndetail); await _ctndetailrep.InsertAsync(ctndetail);
} }
} }
@ -548,6 +568,8 @@ namespace Myshipping.Application
{ {
var ctnentity = item.Adapt<BookingCtn>(); var ctnentity = item.Adapt<BookingCtn>();
ctnentity.BILLID = fdentity.Id; ctnentity.BILLID = fdentity.Id;
ctnentity.CreatedUserId = user.Result.Id;
ctnentity.CreatedUserName = user.Result.Name;
await _repCtn.InsertAsync(ctnentity); await _repCtn.InsertAsync(ctnentity);
//这里保存有可能没有添加多品名,所有箱下没有货物信息 //这里保存有可能没有添加多品名,所有箱下没有货物信息
@ -557,6 +579,8 @@ namespace Myshipping.Application
{ {
var ctndetail = dit.Adapt<BookingCtnDetail>(); var ctndetail = dit.Adapt<BookingCtnDetail>();
ctndetail.CTNID = ctnentity.Id; ctndetail.CTNID = ctnentity.Id;
ctndetail.CreatedUserId = user.Result.Id;
ctndetail.CreatedUserName = user.Result.Name;
await _ctndetailrep.InsertAsync(ctndetail); await _ctndetailrep.InsertAsync(ctndetail);
} }
} }

@ -346,18 +346,33 @@ public static class SqlSugarSetup
} }
if (entityInfo.PropertyName == "CreatedUserName") if (entityInfo.PropertyName == "CreatedUserName")
{
var CreatedUserName = ((dynamic)entityInfo.EntityValue).CreatedUserName;
if (string.IsNullOrEmpty(CreatedUserName))
entityInfo.SetValue(App.User.FindFirst(ClaimConst.CLAINM_NAME)?.Value); entityInfo.SetValue(App.User.FindFirst(ClaimConst.CLAINM_NAME)?.Value);
} }
} }
}
// 更新操作 // 更新操作
if (entityInfo.OperationType == DataFilterType.UpdateByObject) if (entityInfo.OperationType == DataFilterType.UpdateByObject)
{ {
if (entityInfo.PropertyName == "UpdatedTime") if (entityInfo.PropertyName == "UpdatedTime")
entityInfo.SetValue(DateTime.Now); entityInfo.SetValue(DateTime.Now);
if (entityInfo.PropertyName == "UpdatedUserId") if (entityInfo.PropertyName == "UpdatedUserId")
{
var UpdatedUserId = ((dynamic)entityInfo.EntityValue).UpdatedUserId;
if (UpdatedUserId == null || UpdatedUserId == 0)
entityInfo.SetValue(App.User?.FindFirst(ClaimConst.CLAINM_USERID)?.Value); entityInfo.SetValue(App.User?.FindFirst(ClaimConst.CLAINM_USERID)?.Value);
}
if (entityInfo.PropertyName == "UpdatedUserName") if (entityInfo.PropertyName == "UpdatedUserName")
{
var UpdatedUserName = ((dynamic)entityInfo.EntityValue).UpdatedUserName;
if (string.IsNullOrEmpty(UpdatedUserName))
entityInfo.SetValue(App.User?.FindFirst(ClaimConst.CLAINM_NAME)?.Value); entityInfo.SetValue(App.User?.FindFirst(ClaimConst.CLAINM_NAME)?.Value);
}
} }
}; };

Loading…
Cancel
Save