DESKTOP-G961P6V\Zhh 2 years ago
parent
commit
67e2aac2ec
  1. 2
      src/Shentun.Peis.Application.Contracts/OrganizationUnits/TreeChildViewDto.cs
  2. 2
      src/Shentun.Peis.Application/DiagnosisFunctions/DiagnosisFunctionAppService.cs
  3. 5
      src/Shentun.Peis.Application/ItemTypes/ItemTypeAppService.cs
  4. 2
      src/Shentun.Peis.Application/RegisterChecks/RegisterCheckAppService.cs
  5. 48
      src/Shentun.Peis.Domain/ItemTypes/ItemTypeManager.cs

2
src/Shentun.Peis.Application.Contracts/OrganizationUnits/TreeChildViewDto.cs

@ -22,6 +22,8 @@ namespace Shentun.Peis.OrganizationUnits
/// </summary>
public string SimpleCode { get; set; }
public int DisplayOrder { get; set; }
public List<TreeChildViewDto> TreeChildren { get; set; }
}
}

2
src/Shentun.Peis.Application/DiagnosisFunctions/DiagnosisFunctionAppService.cs

@ -378,7 +378,7 @@ namespace Shentun.Peis.DiagnosisFunctions
join registerAsbitem in await _registerAsbitemRepository.GetQueryableAsync() on registerCheck.Id equals registerAsbitem.RegisterCheckId
join registerCheckItem in await _registerCheckItemRepository.GetQueryableAsync() on registerCheck.Id equals registerCheckItem.RegisterCheckId
join asbitem in await _asbitemRepository.GetQueryableAsync() on registerAsbitem.AsbitemId equals asbitem.Id
join item in (await _itemRepository.GetQueryableAsync()).Include(x => x.ReferenceRanges).Include(x => x.ItemResultMatches).Include(x => x.ItemResultTemplates)
join item in (await _itemRepository.GetQueryableAsync()).Include(x => x.ReferenceRanges).Include(x => x.ItemResultMatches).Include(x => x.ItemResultTemplates).AsNoTracking()
on registerCheckItem.ItemId equals item.Id
join unit in await _unitRepository.GetQueryableAsync()
on item.UnitId equals unit.Id into unitExist

5
src/Shentun.Peis.Application/ItemTypes/ItemTypeAppService.cs

@ -75,6 +75,7 @@ namespace Shentun.Peis.ItemTypes
var entity = await _manager.CreateAsync(createEntity);
entity = await Repository.InsertAsync(entity);
await _itemTypeCache.SetAsync(entity.Id, entity);
await _manager.UpdateDisplayOrder(); //全局更新
var dto = ObjectMapper.Map<ItemType, ItemTypeDto>(entity);
return dto;
}
@ -118,7 +119,8 @@ namespace Shentun.Peis.ItemTypes
ParentId = p.ParentId,
Code = p.PathCode,
DisplayName = p.DisplayName,
SimpleCode = p.SimpleCode
SimpleCode = p.SimpleCode,
DisplayOrder = p.DisplayOrder
};
return GetTree(items.ToList(), 0, "");
}
@ -184,6 +186,7 @@ namespace Shentun.Peis.ItemTypes
{
return (from p in items
where p.Code.StartsWith(prefix) && p.Code.Count(a => a == '.') == deep
orderby p.DisplayOrder ascending
let subs = GetTree(items, deep + 1, p.Code)
select new TreeChildViewDto()
{

2
src/Shentun.Peis.Application/RegisterChecks/RegisterCheckAppService.cs

@ -205,7 +205,7 @@ namespace Shentun.Peis.RegisterChecks
if (asbitemIds.Any())
{
entlist = entlist.Where(m => asbitemIds.Contains(m.RegisterCheckAsbitems.FirstOrDefault().Id));
entlist = entlist.Where(m => asbitemIds.Contains(m.RegisterCheckAsbitems.FirstOrDefault().AsbitemId));
}
else
{

48
src/Shentun.Peis.Domain/ItemTypes/ItemTypeManager.cs

@ -43,7 +43,7 @@ namespace Shentun.Peis.ItemTypes
Verify(entity);
await EntityHelper.CheckSameName<ItemType, Guid>(_repository, entity.DisplayName);
var pathCode = await CreatePathCode(entity.ParentId);
if(pathCode.Length > 11 )
if (pathCode.Length > 11)
{
throw new UserFriendlyException("项目类别只允许最多两级");
}
@ -102,7 +102,7 @@ namespace Shentun.Peis.ItemTypes
DataHelper.CheckEntityIsNull(entity);
DataHelper.CheckStringIsNull(entity.DisplayName, "名称");
if( (entity.GuidTypeId - '0') < 0 || (entity.GuidTypeId - '0') > 10)
if ((entity.GuidTypeId - '0') < 0 || (entity.GuidTypeId - '0') > 10)
{
throw new UserFriendlyException("指引单类别无效");
}
@ -128,7 +128,8 @@ namespace Shentun.Peis.ItemTypes
{
//最大pathcode
var LastPathCode = (await _repository.GetListAsync(o => o.ParentId == Guid.Empty || o.ParentId == null))
.OrderByDescending(o => {
.OrderByDescending(o =>
{
var sortCode = o.PathCode.Replace(".", "");
return Convert.ToInt32(sortCode);
}).FirstOrDefault();
@ -151,7 +152,8 @@ namespace Shentun.Peis.ItemTypes
//最大pathcode
var LastPathCode = (await _repository.GetListAsync(o => o.ParentId == parentId))
.OrderByDescending(o => {
.OrderByDescending(o =>
{
var sortCode = o.PathCode.Replace(".", "");
return Convert.ToInt32(sortCode);
}).Select(s => s.PathCode).FirstOrDefault();
@ -234,6 +236,42 @@ namespace Shentun.Peis.ItemTypes
return itmeTypeIds;
}
/// <summary>
/// 更新排序
/// </summary>
/// <returns></returns>
public async Task UpdateDisplayOrder()
{
List<ItemType> newItemTypeList = new List<ItemType>();
var itemTypeList = (await _repository.GetQueryableAsync()).OrderBy(o => o.DisplayOrder).ToList();
foreach (var itemType in itemTypeList.Where(m => m.ParentId == null).OrderBy(o => o.DisplayOrder))
{
newItemTypeList.Add(itemType);
GetChildItemType(itemTypeList, itemType.Id, newItemTypeList);
}
foreach (var itemType in newItemTypeList)
{
itemType.DisplayOrder = newItemTypeList.IndexOf(itemType) + 1;
}
await _repository.UpdateManyAsync(newItemTypeList);
}
private void GetChildItemType(List<ItemType> itemTypeList, Guid itemTypeId, List<ItemType> newItemTypeList)
{
if (itemTypeList.Where(m => m.ParentId == itemTypeId).Count() > 0)
{
foreach (var itemType in itemTypeList.Where(m => m.ParentId == itemTypeId).OrderBy(o => o.DisplayOrder))
{
newItemTypeList.Add(itemType);
GetChildItemType(itemTypeList, itemType.Id, newItemTypeList);
}
}
}
}
}
Loading…
Cancel
Save