optimize
wet 1 year ago
parent 6082bfaead
commit 80d406f729

@ -1243,7 +1243,7 @@ namespace Myshipping.Application
#region 插入货运动态 #region 插入货运动态
//配置中所有的货物状态 //配置中所有的货物状态
var config = _goodsStatusConfig.AsQueryable().Filter(null, true).Where(config => config.CreatedUserId == UserManager.UserId).ToList().DistinctBy(x => x.StatusName).Select(config => new GoodsStatusQuery var config = _goodsStatusConfig.AsQueryable().Filter(null, true).Where(config => config.CreatedUserId == entity.CreatedUserId).ToList().DistinctBy(x => x.StatusName).Select(config => new GoodsStatusQuery
{ {
ConfigId = config.Id, ConfigId = config.Id,
@ -1257,9 +1257,10 @@ namespace Myshipping.Application
Remark = null, Remark = null,
Sort = config.Sort Sort = config.Sort
}).ToList(); }).ToList();
if (config==null) { if (config == null)
_GoodsConfig.InitGoodsStatusConfig(UserManager.UserId, UserManager.Name); {
config = _goodsStatusConfig.AsQueryable().Filter(null, true).Where(config => config.CreatedUserId == UserManager.UserId).ToList().DistinctBy(x => x.StatusName).Select(config => new GoodsStatusQuery _GoodsConfig.InitGoodsStatusConfig((long)entity.CreatedUserId, entity.CreatedUserName);
config = _goodsStatusConfig.AsQueryable().Filter(null, true).Where(config => config.CreatedUserId == entity.CreatedUserId).ToList().DistinctBy(x => x.StatusName).Select(config => new GoodsStatusQuery
{ {
ConfigId = config.Id, ConfigId = config.Id,
@ -1273,47 +1274,89 @@ namespace Myshipping.Application
Remark = null, Remark = null,
Sort = config.Sort Sort = config.Sort
}).ToList(); }).ToList();
} if (!string.IsNullOrEmpty(entity.MBLNO))
if (!string.IsNullOrEmpty(entity.MBLNO))
{
var ConfigId = config.Where(x => x.SystemCode == "YSDBC").Select(x => x.ConfigId).First();
var Status = _goodsStatus.FirstOrDefault(x => x.bookingId == Id && x.ConfigId == ConfigId);
if (Status == null)
{ {
var ConfigId = config.Where(x => x.SystemCode == "YSDBC").Select(x => x.ConfigId).First();
await _goodsStatus.InsertAsync(new BookingGoodsStatus var Status = _goodsStatus.FirstOrDefault(x => x.bookingId == Id && x.ConfigId == ConfigId);
if (Status == null)
{ {
bookingId = Id,
ConfigId = ConfigId, await _goodsStatus.InsertAsync(new BookingGoodsStatus
FinishTime = DateTime.Now, {
FinishUser = UserManager.Name, bookingId = Id,
FinishUserId = UserManager.UserId, ConfigId = ConfigId,
IsPublic = false FinishTime = DateTime.Now,
}); FinishUser = UserManager.Name,
FinishUserId = UserManager.UserId,
IsPublic = false
});
}
} }
if (!string.IsNullOrEmpty(entity.CUSTNO))
{
var ConfigId = config.Where(x => x.SystemCode == "YDC").Select(x => x.ConfigId).First();
var Status = _goodsStatus.FirstOrDefault(x => x.bookingId == Id && x.ConfigId == ConfigId);
if (Status == null)
{
await _goodsStatus.InsertAsync(new BookingGoodsStatus
{
bookingId = Id,
ConfigId = ConfigId,
FinishTime = DateTime.Now,
FinishUser = UserManager.Name,
FinishUserId = UserManager.UserId,
IsPublic = false
});
}
}
} }
if (!string.IsNullOrEmpty(entity.CUSTNO)) else
{ {
var ConfigId = config.Where(x => x.SystemCode == "YDC").Select(x => x.ConfigId).First(); if (!string.IsNullOrEmpty(entity.MBLNO))
var Status = _goodsStatus.FirstOrDefault(x => x.bookingId == Id && x.ConfigId == ConfigId);
if (Status == null)
{ {
var ConfigId = config.Where(x => x.SystemCode == "YSDBC").Select(x => x.ConfigId).First();
await _goodsStatus.InsertAsync(new BookingGoodsStatus var Status = _goodsStatus.FirstOrDefault(x => x.bookingId == Id && x.ConfigId == ConfigId);
if (Status == null)
{ {
bookingId = Id,
ConfigId = ConfigId, await _goodsStatus.InsertAsync(new BookingGoodsStatus
FinishTime = DateTime.Now, {
FinishUser = UserManager.Name, bookingId = Id,
FinishUserId = UserManager.UserId, ConfigId = ConfigId,
IsPublic = false FinishTime = DateTime.Now,
}); FinishUser = UserManager.Name,
FinishUserId = UserManager.UserId,
IsPublic = false
});
}
} }
if (!string.IsNullOrEmpty(entity.CUSTNO))
{
var ConfigId = config.Where(x => x.SystemCode == "YDC").Select(x => x.ConfigId).First();
var Status = _goodsStatus.FirstOrDefault(x => x.bookingId == Id && x.ConfigId == ConfigId);
if (Status == null)
{
await _goodsStatus.InsertAsync(new BookingGoodsStatus
{
bookingId = Id,
ConfigId = ConfigId,
FinishTime = DateTime.Now,
FinishUser = UserManager.Name,
FinishUserId = UserManager.UserId,
IsPublic = false
});
}
}
} }
#endregion #endregion

@ -139,22 +139,11 @@ namespace Myshipping.Application
throw Oops.Oh("请上传正确数据"); throw Oops.Oh("请上传正确数据");
} }
var Template= await _repPrintTemplateShare.AsQueryable().Filter(null, true).Where(x => x.IsDeleted == false && x.TenantId == UserManager.TENANT_ID).ToListAsync(); _repPrintTemplateShare.Delete(x => x.TemplateId == dto[0].TemplateId);
foreach (var item in dto) foreach (var item in dto)
{ {
var entity = item.Adapt<BookingTemplateShare>(); var entity = item.Adapt<BookingTemplateShare>();
var t = Template.Where(x => x.TemplateId == item.TemplateId && x.ShareToId == item.ShareToId).FirstOrDefault(); await _repPrintTemplateShare.InsertAsync(entity);
if (t==null)
{
await _repPrintTemplateShare.InsertAsync(entity);
}
else {
entity.Id = t.Id;
await _repPrintTemplateShare.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync();
}
} }
} }

Loading…
Cancel
Save