Beispiel #1
0
 /// <summary>
 /// 下达工单
 /// </summary>
 /// <param name="bill"></param>
 public void Release(WorkOrderBill bill)
 {
     //下达前校验
     BeforeDispatchAsync(bill);
     bill.BillStatus   = BillStatus.Dispatch;
     bill.DispatchTime = DateTime.Now;
     _unitOfWorkManager.Current.Completed += (sender, args) => {
         /* TODO: 给接单人发送待办消息*/
     };
 }
Beispiel #2
0
 /// <summary>
 /// 审核前处理
 /// </summary>
 /// <param name="bill"></param>
 private void BeforeAudit(WorkOrderBill bill)
 {
     if (bill.BillStatus.Equals(BillStatus.Accept))
     {
     }
     else
     {
         throw new Exception("工单没有提交禁止审核");
     }
 }
Beispiel #3
0
 /// <summary>
 /// 提交前处理
 /// </summary>
 /// <param name="bill"></param>
 private void BeforeSubmit(WorkOrderBill bill)
 {
     if (bill.BillStatus.Equals(BillStatus.Save) || bill.BillStatus.Equals(BillStatus.Accept))
     {
     }
     else
     {
         throw new AbpException("只有保存和提交状态的工单才能提交");
     }
 }
Beispiel #4
0
 public void Complete(WorkOrderBill bill)
 {
     bill.BillStatus = BillStatus.Complete;
     //var workOrder=_workOrderRepository.GetAllIncluding()
     //    .Where(e => e.Id == bill.Id)
     //    .FirstOrDefault();
     //workOrder.FaultEntry.Add(new WorkOrderFaultEntry { ParentId = bill.Id, FaultId = 3 });
     //var en=workOrder.FaultEntry.FirstOrDefault(x => x.Id == 3);
     //_workOrderFaultEntryRepository.Delete(en);
     //workOrder.FaultEntry.Remove(en);
 }
Beispiel #5
0
        private void Accept(WorkOrderBill workOrder)
        {
            _workOrderManager.Accept(workOrder);
            //记录受理活动
            var user           = AsyncHelper.RunSync(() => UserManager.GetUserByIdAsync(UserManager.AbpSession.UserId.Value));
            var acceptActivity = new Activity()
            {
                Bill = workOrder, Operater = user, Name = "受理", Log = string.Format("【{0}】受理了工单。", user.Name)
            };

            _workOrderManager.AddActivity(acceptActivity);
        }
Beispiel #6
0
        private void Close(WorkOrderBill bill)
        {
            _workOrderManager.Close(bill);
            //记录关闭活动
            var user          = AsyncHelper.RunSync(() => UserManager.GetUserByIdAsync(UserManager.AbpSession.UserId.Value));
            var closeActivity = new Activity()
            {
                Bill = bill, Operater = user, Log = string.Format("关闭")
            };

            _workOrderManager.AddActivity(closeActivity);
        }
Beispiel #7
0
 private void FaultEntryProcess(CompleteInput input, WorkOrderBill bill, CompleteOutput output)
 {
     if (input.Faults != null)
     {
         foreach (var fault in input.Faults)
         {
             var fe = bill.FaultEntry.FirstOrDefault(x => x.FaultId == fault.FaultId);
             if (fe == null)
             {
                 //新增分录
                 fe          = new WorkOrderFaultEntry();
                 fe.ParentId = bill.Id;
                 fe.FaultId  = fault.FaultId;
                 //fe.FaultReasonId = fault.FaultReasonId;
                 //fe.FaultMeasureId = fault.FaultMeasureId;
                 _workOrderFaultEntryRepository.Insert(fe);
             }
         }
     }
     for (int i = bill.FaultEntry.Count - 1; i >= 0; i--)
     {
         var entry      = bill.FaultEntry.ElementAt(i);
         var entryInput = input.Faults.FirstOrDefault(x => x.FaultId == entry.FaultId);
         if (entryInput != null)
         {
             //修改
             entry.FaultId = entryInput.FaultId;
         }
         else
         {
             if (input.Faults == null)
             {
                 //删除分录
                 _workOrderFaultEntryRepository.Delete(entry.Id);
                 bill.FaultEntry.Remove(entry);
                 i--;
             }
             else
             {
                 if (entryInput == null)
                 {
                     //删除分录
                     _workOrderFaultEntryRepository.Delete(entry.Id);
                     bill.FaultEntry.Remove(entry);
                     i--;
                 }
             }
         }
     }
 }
Beispiel #8
0
        private void ReturnVisit(WorkOrderBill workOrder)
        {
            //记录回访活动
            var user = AsyncHelper.RunSync(() => UserManager.GetUserByIdAsync(UserManager.AbpSession.UserId.Value));
            var returnVisitActivity = new Activity()
            {
                Bill = workOrder, Operater = user, Log = string.Format("回访")
            };

            _workOrderManager.AddActivity(returnVisitActivity);


            _workOrderManager.ReturnVisit(workOrder);
        }
Beispiel #9
0
        private void PhotoProcess(CompleteInput input, WorkOrderBill bill, CompleteOutput output)
        {
            if (input.Photos != null)
            {
                foreach (var photo in input.Photos)
                {
                    var newPhoto = bill.Photos.FirstOrDefault(x => x.FilePath == photo.FilePath);
                    if (newPhoto == null)
                    {
                        //新增分录
                        newPhoto          = new WorkOrderPhoto();
                        newPhoto.Bill     = bill;
                        newPhoto.FilePath = photo.FilePath;
                        _workOrderPhotoRepository.Insert(newPhoto);
                    }
                }
            }
            //删除照片
            for (int i = bill.Photos.Count - 1; i >= 0; i--)
            {
                WorkOrderPhoto photo = bill.Photos.ElementAt(i);

                if (input.Photos == null)
                {
                    //删除分录
                    _workOrderPhotoRepository.Delete(photo);
                    i--;
                }
                else
                {
                    var photoInput = input.Photos.FirstOrDefault(x => x.FilePath == photo.FilePath);
                    if (photoInput == null)
                    {
                        //删除分录
                        _workOrderPhotoRepository.Delete(photo);
                        i--;
                    }
                }
            }
        }
Beispiel #10
0
 private void PhotoProcess(ReportInput input, WorkOrderBill bill)
 {
     for (int i = bill.Photos.Count - 1; i >= 0; i--)
     {
         WorkOrderPhoto photo = bill.Photos.ElementAt(i);
         //删除分录
         _workOrderPhotoRepository.Delete(photo);
         // i--;
     }
     if (input.Photos == null)
     {
         return;
     }
     foreach (var photo in input.Photos)
     {
         var newPhoto = new WorkOrderPhoto()
         {
             FilePath = photo,
             Bill     = bill
         };
         _workOrderPhotoRepository.Insert(newPhoto);
     }
 }
Beispiel #11
0
        /// <summary>
        /// 派工前处理
        /// </summary>
        /// <param name="bill"></param>
        private async void  BeforeDispatchAsync(WorkOrderBill bill)
        {
            //只有审核和完工汇报状态下的工单才能下达
            if (bill.BillStatus.Equals(BillStatus.Accept) ||
                bill.BillStatus.Equals(BillStatus.Dispatch))
            {
            }
            else
            {
                throw new AbpException("只有受理和派工状态的单据可以派工");
            }

            if (bill.AssignedPerson == null)
            {
                throw new AbpException("没有指定接单人");
            }

            var user = await _userManager.GetUserByIdAsync(bill.AssignedPersonId.Value);

            if (!user.IsActive)
            {
                throw new AbpException("接单人没有激活");
            }
        }
Beispiel #12
0
 public void Accept(WorkOrderBill bill)
 {
     bill.BillStatus = BillStatus.Accept;
 }
Beispiel #13
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--;
                    }
                }
            }
        }
Beispiel #14
0
 public void ReturnVisit(WorkOrderBill bill)
 {
     bill.BillStatus = BillStatus.ReturnVisit;
 }
Beispiel #15
0
 public void Dispatch(WorkOrderBill bill, User user)
 {
     bill.BillStatus     = BillStatus.Dispatch;
     bill.DispatchTime   = DateTime.Now;
     bill.AssignedPerson = user;
 }
Beispiel #16
0
 /// <summary>
 /// 提交工单
 /// </summary>
 /// <param name="bill"></param>
 public void Submit(WorkOrderBill bill)
 {
     BeforeSubmit(bill);
     _workOrderRepository.InsertOrUpdate(bill);
 }
Beispiel #17
0
 /// <summary>
 /// 新建工单
 /// </summary>
 /// <param name="bill"></param>
 /// <returns></returns>
 public void  Create(WorkOrderBill bill)
 {
     bill.BillStatus = BillStatus.Save;
     _workOrderRepository.InsertAndGetId(bill);
 }
Beispiel #18
0
 public WorkOrderAccessoryEntry AddAccessoryEntry(WorkOrderBill bill, Accessory accessory, int count, int backCount)
 {
     throw new NotImplementedException();
 }
Beispiel #19
0
 public void Cancel(WorkOrderBill bill)
 {
     bill.BillStatus = BillStatus.Cancel;
 }
Beispiel #20
0
 public void Close(WorkOrderBill bill)
 {
     //throw new NotImplementedException();
     bill.BillStatus = BillStatus.Close;
 }