Beispiel #1
0
        /// <summary>
        /// 报废管理
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task <PagedResultDto <SupplyScrapSubDto> > GetList(SupplyScrapListInput input)
        {
            var query = from a in _supplyScrapSubRepository.GetAll()
                        join b in _supplyBaseRepository.GetAll() on a.SupplyId equals b.Id
                        join u in _userRepository.GetAll() on a.CreatorUserId equals u.Id
                        let openModel = (from c in _workFlowTaskRepository.GetAll().Where(x => x.FlowID == input.FlowId && x.InstanceID == a.Id.ToString() &&
                                                                                          x.ReceiveID == AbpSession.UserId.Value)
                                         select c)
                                        select new SupplyScrapSubDto()
            {
                Code         = b.Code,
                CreationTime = a.CreationTime,
                ExpiryDate   = b.ExpiryDate,
                ProductDate  = b.CreationTime,
                Id           = a.Id,
                MainId       = a.MainId,
                Money        = b.Money,
                Name         = b.Name,
                Status       = a.Status,
                SupplyId     = a.SupplyId,
                Type         = b.Type,
                TypeName     = ((SupplyType)b.Type).ToString(),
                UserId       = a.CreatorUserId.Value,
                UserId_Name  = u.Name,
                Version      = b.Version,
                OpenModel    = openModel.Count(y => y.Type != 6 && (y.Status == 1 || y.Status == 0)) > 0
                                            ? 1
                                            : 2,
                Reason = a.Reason,
            };

            if (!string.IsNullOrWhiteSpace(input.Status))
            {
                var statusArrty = input.Status.Split(",");
                query = query.Where(r => statusArrty.Contains(r.Status.ToString()));
            }

            var count = await query.CountAsync();

            var model = await query.OrderByDescending(ite => ite.CreationTime).PageBy(input).ToListAsync();

            var list = new List <SupplyScrapSubDto>();

            using (_unitOfWorkManager.Current.DisableFilter(AbpDataFilters.SoftDelete))
            {
                if (model.Count > 0)
                {
                    foreach (var tmp in model)
                    {
                        var firstTask = new FirstTaskModelScrap();
                        tmp.InstanceId = tmp.Id.ToString();
                        _workFlowBusinessTaskManager.SupplementWorkFlowBusinessListForSupplyScrap(input.FlowId, tmp as BusinessWorkFlowListOutput, out firstTask);
                        tmp.FirstTaskId  = firstTask.TaskId;
                        tmp.FirstGroupId = firstTask.GroupId;
                        tmp.FirstStepId  = firstTask.StepId;

                        list.Add(tmp);
                    }
                }
            }
            return(new PagedResultDto <SupplyScrapSubDto>(count, list));
        }