public async Task <List <t_equipmentListDto> > t_equipmentList(t_equipmentListInputDto input)
 {
     return(await JIT_t_equipment.GetAll().Join(JIT_t_OrganizationUnit.GetAll(), A => A.FWorkCenterID, B => B.Id,
                                                (A, B) => new
     {
         A.FInterID,
         A.FNumber,
         A.FName,
         B.DisplayName,
         A.FType,
         A.FWorkCenterID
     })
            .Where(w => w.FType == PublicEnum.EquipmentType.设备 && w.FName.Contains(input.FName) &&
                   (input.FWorkCenterID.Equals(0) || w.FWorkCenterID.Equals(input.FWorkCenterID))).Select(s =>
                                                                                                          new t_equipmentListDto
     {
         FInterID = s.FInterID,
         FNumber = s.FNumber,
         FName = s.FName,
         DisplayName = s.DisplayName,
         FWorkCenterID = s.FWorkCenterID
     })
            .PageBy(input)
            .ToListAsync());
 }
 /// <summary>
 /// 获取所有车间
 /// </summary>
 public async Task <List <SelectModel> > GetSelectModel()
 {
     return(await JIT_t_OrganizationUnit.GetAll()
            .Select(s => new SelectModel {
         value = s.Id.ToString(), title = s.DisplayName
     }).ToListAsync());
 }
        public async Task <int> Delete(OrganizationDeleteDto input)
        {
            var count = 0;
            var query = JIT_t_OrganizationUnit.GetAll().Where(p => p.Id == input.Id)
                        .Include(p => p.Children);

            var entity = await query.SingleOrDefaultAsync(p => true);



            var ORByID = JIT_t_OrganizationUnit.GetAll().SingleOrDefault(p => p.Id == entity.ParentId);

            var EmployeeByID = EmployeeApp.GetOneselfAndJunior(new int[] { input.Id });

            List <Entities.Employee> EmployeeList = new EditableList <Entities.Employee>();

            if (EmployeeByID != null)
            {
                EmployeeList = EmployeeApp._ERepository.GetAll()
                               .Where(p => p.IsDeleted == false && EmployeeByID.Contains(p.FDepartment)).ToList();
            }


            if (entity != null)
            {
                foreach (var e in EmployeeList)
                {
                    if (ORByID != null)
                    {
                        e.FDepartment = ORByID.Id;
                    }
                    else
                    {
                        e.FDepartment = EmployeeApp._ERepository.GetAll().FirstOrDefault(p => p.Id == entity.ParentId && p.IsDeleted == false).Id;
                    }

                    EmployeeApp._ERepository.Update(e);
                }

                entity.IsDeleted     = true;
                entity.DeletionTime  = DateTime.Now;
                entity.DeleterUserId = this.AbpSession.UserId.HasValue ? this.AbpSession.UserId.Value : 0;
                count++;
                foreach (var c in entity.Children)
                {
                    c.IsDeleted     = true;
                    c.DeletionTime  = DateTime.Now;
                    c.DeleterUserId = this.AbpSession.UserId.HasValue ? this.AbpSession.UserId.Value : 0;
                    count++;
                }

                await JIT_t_OrganizationUnit.UpdateAsync(entity);
            }

            return(count);
        }
        public async Task <List <OrganizationDto> > GetChildMenuList(int ParentID)
        {
            var quers = await JIT_t_OrganizationUnit.GetAll().Where(p => p.IsDeleted == false).ToListAsync();

            var list = quers.MapTo <List <OrganizationDto> >();

            var result = list.Where(x => x.ParentId == ParentID);

            return(result.ToList());
        }
        public async Task <List <OrganizationDtoTest> > GetAll(OrganizationGetAllInput input)
        {
            var query = JIT_t_OrganizationUnit.GetAll().Where(p => p.IsDeleted.HasValue && !p.IsDeleted.Value);

            if (input.OrganizationType.HasValue)
            {
                //过滤组织类型
                OrganizationTypeSpecification wcsf = new OrganizationTypeSpecification(input.OrganizationType.Value);
                query = query.Where(wcsf);
            }

            if (input.isWorkCenter)
            {
                query = query.Where(p => p.FWorkshopType);
            }

            var data = await query.ToListAsync();

            return(data.MapTo <List <OrganizationDtoTest> >());
        }
        public async Task <t_OrganizationUnit> Get(OrganizationDeleteDto input)
        {
            var entity = await JIT_t_OrganizationUnit.GetAll().SingleOrDefaultAsync(p => p.Id == input.Id && p.IsDeleted == false);

            return(entity.MapTo <t_OrganizationUnit>());
        }