| 
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -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); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					} |