示例#1
0
 public void UpdateAccessoryEntry(WorkOrderAccessoryEntry entry)
 {
     throw new NotImplementedException();
 }
示例#2
0
        private void AccessoryEntryProcess(CompleteInput input, WorkOrderBill bill, CompleteOutput output)
        {
            if (input.Accessories != null)
            {
                //新增
                foreach (var accessory in input.Accessories)
                {
                    var entry = bill.AccessoryEntry.FirstOrDefault(x => x.AccessoryId == accessory.AccessoryId);
                    if (entry == null)
                    {
                        entry             = new WorkOrderAccessoryEntry();
                        entry.AccessoryId = accessory.AccessoryId;
                        entry.Count       = accessory.Count;
                        entry.NewSerials  = entry.OldSerials;
                        entry.BillId      = bill.Id;
                        Accessory accessoryEntity = _accessoryRepository.Get(accessory.AccessoryId);
                        _workOrderAccessoryEntryRepository.Insert(entry);
                        int currentCount = _inventoryDomainService.GetAccessoryCountByUser(bill.AssignedPerson, accessoryEntity);
                        if (currentCount >= entry.Count)
                        {
                            //扣减库存
                            _inventoryDomainService.UpdateStaffInventory(bill.AssignedPerson, entry.Accessory, entry.Count * (-1));
                        }
                        else
                        {
                            //库存不足
                            output.Successed = false;
                            string msg = string.Format("配件【{0}】持有量不足,缺少{1}{2}\r\n", entry.Accessory.Name, entry.Count - currentCount, entry.Accessory.Unit);
                            output.Error = output.Error + msg;
                        }
                    }
                }
            }
            //删除分录
            for (int i = bill.AccessoryEntry.Count - 1; i >= 0; i--)
            {
                WorkOrderAccessoryEntry accessoryEntry = bill.AccessoryEntry.ElementAt(i);


                if (input.Accessories == null)
                {
                    //增加配件持有数量
                    _inventoryDomainService.UpdateStaffInventory(bill.AssignedPerson, accessoryEntry.Accessory, accessoryEntry.Count);
                    //删除分录
                    _workOrderAccessoryEntryRepository.Delete(accessoryEntry);


                    i--;
                }
                else
                {
                    var entryInput = input.Accessories.FirstOrDefault(x => x.AccessoryId == accessoryEntry.AccessoryId);
                    if (entryInput == null)
                    {
                        //增加配件持有数量
                        _inventoryDomainService.UpdateStaffInventory(bill.AssignedPerson, accessoryEntry.Accessory, accessoryEntry.Count);
                        //删除分录
                        _workOrderAccessoryEntryRepository.Delete(accessoryEntry);


                        i--;
                    }
                    else
                    {
                        //增加配件持有数量
                        _inventoryDomainService.UpdateStaffInventory(bill.AssignedPerson, accessoryEntry.Accessory, accessoryEntry.Count);

                        //检查库存量
                        int currentCount = _inventoryDomainService.GetAccessoryCountByUser(bill.AssignedPerson, accessoryEntry.Accessory);
                        if (currentCount >= entryInput.Count)
                        {
                            //更新分录
                            accessoryEntry.Count      = entryInput.Count;
                            accessoryEntry.NewSerials = entryInput.NewSerials;
                            accessoryEntry.OldSerials = entryInput.OldSerials;
                            //扣减
                            _inventoryDomainService.UpdateStaffInventory(bill.AssignedPerson, accessoryEntry.Accessory, accessoryEntry.Count * (-1));
                        }
                        else
                        {
                            //库存不足
                            output.Successed = false;
                            string msg = string.Format("配件【{0}】持有量不足,缺少{1} {2}\r\n", accessoryEntry.Accessory.Name, accessoryEntry.Count - currentCount, accessoryEntry.Accessory.Unit);
                            output.Error = output.Error + msg;
                        }
                        //i--;
                    }
                }
            }
        }
示例#3
0
 public void DeleteAccessory(WorkOrderAccessoryEntry id)
 {
     throw new NotImplementedException();
 }