optimize
wet 1 year ago
parent ce4ffe9a29
commit 71bfc3930c

@ -889,28 +889,8 @@ namespace Myshipping.Application
if (Config != null) if (Config != null)
{ {
_goodsStatus.Delete(x => x.bookingId == Id && x.ConfigId == Config.Id); _goodsStatus.Delete(x => x.bookingId == Id && x.ConfigId == Config.Id);
var ConfigId = _goodsStatus.Where(x => x.FinishTime.HasValue && x.bookingId == Id).OrderByDescending(x => x.FinishTime).Select(x => x.ConfigId).First(); //更新货物状态
string BSSTATUSNAME = String.Empty; await SetBookingOrderGoodsStatus(Id);
if (ConfigId == null)
{
main.BSSTATUSNAME = "";
}
else
{
BSSTATUSNAME = config.Where(x => x.Id == ConfigId).Select(x => x.StatusName).FirstOrDefault();
main.BSSTATUSNAME = BSSTATUSNAME == null ? "" : BSSTATUSNAME;
}
await _rep.AsUpdateable(main).IgnoreColumns(it => new
{
it.ParentId,
it.TenantId,
it.CreatedTime,
it.CreatedUserId,
it.CreatedUserName,
it.TenantName,
it.IsDeleted,
it.BOOKINGNO
}).ExecuteCommandAsync();
} }
} }
if (string.IsNullOrEmpty(entity.MBLNO)) if (string.IsNullOrEmpty(entity.MBLNO))
@ -919,28 +899,8 @@ namespace Myshipping.Application
if (Config != null) if (Config != null)
{ {
_goodsStatus.Delete(x => x.bookingId == Id && x.ConfigId == Config.Id); _goodsStatus.Delete(x => x.bookingId == Id && x.ConfigId == Config.Id);
var ConfigId = _goodsStatus.Where(x => x.FinishTime.HasValue && x.bookingId == Id).OrderByDescending(x => x.FinishTime).Select(x => x.ConfigId).First(); //更新货物状态
string BSSTATUSNAME = String.Empty; await SetBookingOrderGoodsStatus(Id);
if (ConfigId == null)
{
main.BSSTATUSNAME = "";
}
else
{
BSSTATUSNAME = config.Where(x => x.Id == ConfigId).Select(x => x.StatusName).FirstOrDefault();
main.BSSTATUSNAME = BSSTATUSNAME == null ? "" : BSSTATUSNAME;
}
await _rep.AsUpdateable(main).IgnoreColumns(it => new
{
it.ParentId,
it.TenantId,
it.CreatedTime,
it.CreatedUserId,
it.CreatedUserName,
it.TenantName,
it.IsDeleted,
it.BOOKINGNO
}).ExecuteCommandAsync();
} }
} }
#endregion #endregion
@ -1565,14 +1525,12 @@ namespace Myshipping.Application
entity.FinishTime = item.FinishTime; entity.FinishTime = item.FinishTime;
entity.FinishUserId = UserManager.UserId; entity.FinishUserId = UserManager.UserId;
} }
await _goodsStatus.InsertAsync(entity); await _goodsStatus.InsertAsync(entity);
} }
//更新货物状态
await SetBookingOrderGoodsStatus((long)input.BookingId);
var order = _rep.Where(x => x.Id == input.BookingId).First(); var order = _rep.Where(x => x.Id == input.BookingId).First();
var userid = order.CreatedUserId; var userid = order.CreatedUserId;
if (userid != null) if (userid != null)
@ -1593,8 +1551,8 @@ namespace Myshipping.Application
ExtData = goods.ExtData, ExtData = goods.ExtData,
Remark = goods.Remark, Remark = goods.Remark,
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
{ {
@ -1615,38 +1573,13 @@ namespace Myshipping.Application
{ {
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)
{
var StatusName = t.Where(x => x.FinishTime.HasValue).OrderByDescending(x => x.FinishTime).Select(x => x.StatusName).FirstOrDefault();
if (StatusName == null)
{
StatusName = "";
}
order.BSSTATUSNAME = StatusName;
await _rep.AsUpdateable(order).IgnoreColumns(it => new
{
it.ParentId,
it.TenantId,
it.CreatedTime,
it.CreatedUserId,
it.CreatedUserName,
it.TenantName,
it.IsDeleted,
it.BOOKINGNO
}).ExecuteCommandAsync();
}
await SendBookingOrder(new long[] { order.Id });
return t; return t;
} }
//推送东胜
await SendBookingOrder(new long[] { (long)input.BookingId });
return null; return null;
} }
@ -8039,11 +7972,12 @@ namespace Myshipping.Application
} }
/// <summary> /// <summary>
/// 设置货物状态完成,并推送东胜 /// 设置货物状态完成
/// </summary> /// </summary>
/// <param name="code"></param> /// <param name="code"></param>
/// <param name="bookingId"></param> /// <param name="bookingId"></param>
/// <returns></returns> /// <returns></returns>
public async Task SetGoodsStatus(string code, long bookingId) public async Task SetGoodsStatus(string code, long bookingId)
{ {
@ -8062,23 +7996,60 @@ namespace Myshipping.Application
gs.FinishUserId = UserManager.UserId; gs.FinishUserId = UserManager.UserId;
await _goodsStatus.InsertAsync(gs); await _goodsStatus.InsertAsync(gs);
var order = _rep.AsQueryable().Filter(null, true).First(x => x.Id == bookingId);
order.BSSTATUSNAME = gsCfg.StatusName;
await _rep.AsUpdateable(order).IgnoreColumns(it => new
{
it.ParentId,
it.TenantId,
it.CreatedTime,
it.CreatedUserId,
it.CreatedUserName,
it.TenantName,
it.IsDeleted,
it.BOOKINGNO
}).ExecuteCommandAsync();
_logger.LogInformation($"发送{code}后自动完成货物状态,Id{bookingId},操作人:{UserManager.Name}"); _logger.LogInformation($"发送{code}后自动完成货物状态,Id{bookingId},操作人:{UserManager.Name}");
//更新货物状态
await SetBookingOrderGoodsStatus(bookingId);
}
}
}
/// <summary>
/// 更新主单货物状态
/// </summary>
/// <param name="bookingId"></param>
/// <returns></returns>
public async Task SetBookingOrderGoodsStatus(long bookingId)
{
var order = _rep.AsQueryable().Filter(null, true).First(x => x.Id == bookingId);
var createUserid = order.CreatedUserId;
//获取当前用户已经录入的货物状态
var list = await _goodsStatus.AsQueryable().LeftJoin(_goodsStatusConfig.AsQueryable(),
(goods, config) => config.Id == goods.ConfigId).Where((goods, config) => config.CreatedUserId == createUserid && goods.bookingId == bookingId).
OrderBy((goods, config) => config.Sort).
Select((goods, config) => new GoodsStatusQuery
{
ConfigId = config.Id,
SystemCode = config.SystemCode,
StatusName = config.StatusName,
FinishTime = goods.FinishTime,
FinishUser = goods.FinishUser,
FinishUserId = goods.FinishUserId,
IsPublic = goods.IsPublic,
ExtData = goods.ExtData,
Remark = goods.Remark,
Sort = config.Sort
}).ToListAsync();
if (list != null)
{
var StatusName = list.Where(x => x.FinishTime.HasValue).OrderByDescending(x => x.Sort).Select(x => x.StatusName).FirstOrDefault();
if (StatusName == null)
{
StatusName = "";
} }
order.BSSTATUSNAME = StatusName;
await _rep.AsUpdateable(order).IgnoreColumns(it => new
{
it.ParentId,
it.TenantId,
it.CreatedTime,
it.CreatedUserId,
it.CreatedUserName,
it.TenantName,
it.IsDeleted,
it.BOOKINGNO
}).ExecuteCommandAsync();
} }
} }
#endregion #endregion

@ -123,7 +123,8 @@ public class SysDataUserMenuService : ISysDataUserMenu, IDynamicApiController, I
throw Oops.Bah("请上传正确数据!"); throw Oops.Bah("请上传正确数据!");
} }
if (input.childrens!=null&& input.childrens.Count()>0) { if (input.childrens!=null&& input.childrens.Count()>0)
{
await _sysUserDataScopeRep.DeleteAsync(x => x.SysUserId == input.UserId); await _sysUserDataScopeRep.DeleteAsync(x => x.SysUserId == input.UserId);
var list = new List<SysUserDataScope>(); var list = new List<SysUserDataScope>();
@ -141,11 +142,8 @@ public class SysDataUserMenuService : ISysDataUserMenu, IDynamicApiController, I
var userdatalist = _rep.AsQueryable().ToListAsync(); var userdatalist = _rep.AsQueryable().ToListAsync();
_sysCache.Set(CommonConst.CACHE_KEY_USERDATASCOPE, userdatalist); _sysCache.Set(CommonConst.CACHE_KEY_USERDATASCOPE, userdatalist);
} }
} }
catch (System.Exception) catch (System.Exception)
{ {
@ -162,18 +160,18 @@ public class SysDataUserMenuService : ISysDataUserMenu, IDynamicApiController, I
List<SysDataUserMenu> list = new List<SysDataUserMenu>(); List<SysDataUserMenu> list = new List<SysDataUserMenu>();
List<long> datascope = new List<long>(); List<long> datascope = new List<long>();
//if (_sysCache.Exists(CommonConst.CACHE_KEY_USERDATASCOPE)) if (_sysCache.Exists(CommonConst.CACHE_KEY_USERDATASCOPE))
//{ {
// list = await _sysCache.GetAsync<List<SysDataUserMenu>>(CommonConst.CACHE_KEY_USERDATASCOPE); list = await _sysCache.GetAsync<List<SysDataUserMenu>>(CommonConst.CACHE_KEY_USERDATASCOPE);
//} }
//else else
//{ {
// list = await _rep.AsQueryable().ToListAsync(); list = await _rep.AsQueryable().ToListAsync();
// _sysCache.Set(CommonConst.CACHE_KEY_USERDATASCOPE, list); _sysCache.Set(CommonConst.CACHE_KEY_USERDATASCOPE, list);
//} }
list = await _rep.AsQueryable().ToListAsync(); //list = await _rep.AsQueryable().ToListAsync();
_sysCache.Set(CommonConst.CACHE_KEY_USERDATASCOPE, list); //_sysCache.Set(CommonConst.CACHE_KEY_USERDATASCOPE, list);
DataScopeType _dataScopeType = list.Where(x => x.SysMenuId == menuid && x.SysUserId == UserManager.UserId).Select(x => x.DataScopeType).FirstOrDefault(); DataScopeType _dataScopeType = list.Where(x => x.SysMenuId == menuid && x.SysUserId == UserManager.UserId).Select(x => x.DataScopeType).FirstOrDefault();
if (_dataScopeType == DataScopeType.ALL) if (_dataScopeType == DataScopeType.ALL)
{ {

Loading…
Cancel
Save