Ejemplo n.º 1
0
        //[Microsoft.AspNetCore.Mvc.ServiceFilter(typeof(WorkFlowRunFilterAttribute))]
        public async Task <InitWorkFlowOutput> Create(SupplyCreateInput input)
        {
            var ret    = new InitWorkFlowOutput();
            var Supply = new SupplyBase();

            input.MapTo(Supply);
            var id = Guid.NewGuid();

            Supply.Id            = id;
            Supply.Status        = (int)SupplyStatus.在库;
            Supply.CreatorUserId = AbpSession.UserId;
            Supply.PutInDate     = input.PutInDate;
            if (input.FileList != null)
            {
                var fileList = new List <AbpFileListInput>();
                foreach (var item in input.FileList)
                {
                    fileList.Add(new AbpFileListInput()
                    {
                        Id = item.Id, Sort = item.Sort
                    });
                }
                await _abpFileRelationAppService.CreateAsync(new CreateFileRelationsInput()
                {
                    BusinessId   = id.ToString(),
                    BusinessType = (int)AbpFileBusinessType.用品附件,
                    Files        = fileList
                });
            }
            await _supplyRepository.InsertAsync(Supply);

            ret.InStanceId = id.ToString();
            return(ret);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 固化采购入库
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task PutIn(RegisterSupplyPurchasePlanInput input)
        {
            var model = await _curingProcurementPlanRepository.GetAsync(input.PlanId);

            foreach (var item in input.Supplys.Where(r => !r.HasDo))
            {
                var supplyModel = new SupplyBase()
                {
                    Id      = Guid.NewGuid(),
                    Code    = "",
                    Name    = item.Name,
                    Version = item.Version,
                    Money   = item.Money,
                    //UserId = item.UserId,
                    Type          = model.Type.ToInt(),
                    Unit          = item.Unit,
                    CreatorUserId = AbpSession.UserId,
                    ExpiryDate    = item.ExpiryDate,
                    PutInDate     = DateTime.Now,
                };

                var supplyPurchaseResult = new SupplyPurchaseResult()
                {
                    Id                   = Guid.NewGuid(),
                    SupplyId             = supplyModel.Id,
                    SupplyPurchasePlanId = input.PlanId,
                };

                supplyModel.Status = (int)SupplyStatus.在库;
                await _supplyBaseRepository.InsertAsync(supplyModel);
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// 批量新增用品
 /// </summary>
 /// <param name="input"></param>
 /// <returns></returns>
 public async Task CreateList(List <SupplyCreateInput> input)
 {
     if (input != null)
     {
         foreach (var x in input)
         {
             var Supply = new SupplyBase();
             x.MapTo(Supply);
             var id = Guid.NewGuid();
             Supply.Id            = id;
             Supply.Status        = (int)SupplyStatus.在库;
             Supply.CreatorUserId = AbpSession.UserId;
             await _supplyRepository.InsertAsync(Supply);
         }
     }
 }
Ejemplo n.º 4
0
        public async Task CreateOrUpdate(CreateMenuInitInput <List <UserSupplyBatchCreateInput> > input)
        {
            var currentUserId = AbpSession.UserId.Value;
            var menuInit      = await _userMenuInitRepository.FirstOrDefaultAsync(r => r.MenuId == input.MenuId && r.UserId == currentUserId);

            if (menuInit == null)
            {
                var init = new UserMenuInit()
                {
                    MenuId = input.MenuId, UserId = currentUserId, Status = input.HasComplateInit ? -1 : 0
                };
                _userMenuInitRepository.Insert(init);
            }
            else
            {
                if (input.HasComplateInit)
                {
                    menuInit.Status = -1;
                    _userMenuInitRepository.Update(menuInit);
                }
            }
            if (input.List.Count > 50)
            {
                throw new UserFriendlyException((int)ErrorCode.DataAccessErr, "批量修改最大支持50条数据");
            }
            var uids = input.List.Where(ite => ite.Id.HasValue).Select(ite => ite.Id).ToList();
            var sids = input.List.Where(ite => ite.SupplyId.HasValue).Select(ite => ite.SupplyId).ToList();

            //删除没有的数据
            //_userSupplyRepository.Delete(ite => ite.CreatorUserId == AbpSession.UserId.Value && !uids.Contains(ite.Id));
            //_supplyBaseRepository.Delete(ite => ite.CreatorUserId == AbpSession.UserId.Value && !sids.Contains(ite.Id));

            foreach (var item in input.List)
            {
                if (item.Id.HasValue)
                {
                    if (!item.SupplyId.HasValue)
                    {
                        throw new UserFriendlyException((int)ErrorCode.DataAccessErr, "用品数据异常");
                    }
                    var model = await _supplyBaseRepository.GetAsync(item.SupplyId.Value);

                    model.CreatorUserId = AbpSession.UserId;
                    model.Unit          = item.Unit;
                    model.Money         = item.Money;
                    model.Version       = item.Version;
                    model.Name          = item.Name;
                    model.Type          = item.Type;
                    model.UserId        = item.Supply_UserId;
                    model.ExpiryDate    = item.EndTime;

                    //model.Status = (int)SupplyStatus.被领用;

                    var usersupplyModel = await _userSupplyRepository.GetAsync(item.Id.Value);

                    usersupplyModel.StartTime = item.StartTime;
                    usersupplyModel.EndTime   = item.EndTime;
                    // usersupplyModel.Status = (int)UserSupplyStatus.使用中;
                }
                else
                {
                    var supplyId = Guid.NewGuid();
                    var model    = new SupplyBase()
                    {
                        Id            = supplyId,
                        Code          = "",
                        Unit          = item.Unit,
                        Money         = item.Money,
                        Name          = item.Name,
                        Type          = item.Type,
                        Version       = item.Version,
                        CreatorUserId = AbpSession.UserId,
                        ExpiryDate    = item.EndTime,
                        ProductDate   = DateTime.Now,
                        UserId        = item.Supply_UserId,
                        Status        = (int)SupplyStatus.被领用
                    };
                    await _supplyBaseRepository.InsertAsync(model);

                    var usersupplyModel = new UserSupply()
                    {
                        SupplyId  = supplyId,
                        StartTime = item.StartTime,
                        EndTime   = item.EndTime,
                        Id        = Guid.NewGuid(),
                        UserId    = AbpSession.UserId.Value,
                        Status    = (int)UserSupplyStatus.使用中
                    };
                    await _userSupplyRepository.InsertAsync(usersupplyModel);
                }
            }
        }