/// <summary>
        /// 新建淘汰任务
        /// </summary>
        /// <param name="newTask"></param>
        /// <param name="taskTypeId"></param>
        /// <param name="createEmployee"></param>
        /// <returns></returns>
        public bool NewEliminateTask(EliminateTask newTask, long taskTypeId, string createEmployee)
        {
            var employeeService = new EmployeeService();
            var task = new task
            {
                TaskNumber = newTask.TaskNumber,
                StartTime = newTask.StartTime,
                EndTime = newTask.EndTime,
                CreateTime = DateTime.Now,
                CreateEmployeeId = employeeService.FindByNumber(createEmployee).Id,
                TaskStatusId = 1,
                TaskTypeId = taskTypeId,
                Memo = newTask.Memo
            };

            foreach (string employeeNumber in newTask.EmployeeNumber.Split(','))
            {
                task.task_employee.Add(new task_employee { EmployeeId = employeeService.FindByNumber(employeeNumber).Id });
            }

            var pigService = new PigService();

            foreach (var  detail in newTask.EliminateTaskDetail)
            {
                if (detail.Pig != null)
                {
                    var detailPigs = detail.Pig.Split(',');
                    foreach (var str in detailPigs)
                        task.task_pig.Add(new task_pig
                        {
                            PigId = pigService.FindByRfid(str).Id
                        });
                }
                else
                {
                    task.task_pigsty.Add(new task_pigsty
                    {
                        PigstyId = long.Parse(detail.Pigsty)
                    });
                }
            }

            var taskService = new TaskService();
            taskService.Insert(task);

            return true;
        }
Exemple #2
0
        /// <summary>
        ///     新建喂食任务
        /// </summary>
        /// <param name="newTask"></param>
        /// <param name="taskTypeId"></param>
        /// <param name="createEmployee">发布任务的员工工号</param>
        /// <returns></returns>
        public bool NewFeedTask(FeedTask newTask, long taskTypeId, string createEmployee)
        {
            if (createEmployee == null) throw new ArgumentNullException("createEmployee");
            var employeeService = new EmployeeService();

            var task = new task
                           {
                               TaskNumber = newTask.TaskNumber,
                               StartTime = newTask.StartTime,
                               EndTime = newTask.EndTime,
                               CreateTime = DateTime.Now,
                               CreateEmployeeId = employeeService.FindByNumber(createEmployee).Id,
                               TaskStatusId = 1,
                               TaskTypeId = taskTypeId,
                               Memo = newTask.Memo
                           };

            //根据工号找到对应的id
            foreach (string employeeNumber in newTask.EmployeeNumber.Split(','))
            {
                task.task_employee.Add(new task_employee {EmployeeId = employeeService.FindByNumber(employeeNumber).Id});
            }

            var pigstyService = new PigstyService();
            var fodderService = new FodderTypeService();
            foreach (FeedTaskDetail detail in newTask.Feeddetails)
            {
                string[] pigstyNum = detail.Pigsty.Split(',');
                long pighouseid = long.Parse(detail.PigHouse);
                string[] fodders = detail.Fodder.Split(',');
                List<long> fodderIds = fodders.Select(fodder => fodderService.FindByName(fodder).Id).ToList();

                foreach (string pigstydetail in pigstyNum)
                {
                    var taskPigsty = new task_pigsty();
                    int number = int.Parse(pigstydetail);
                    taskPigsty.PigstyId = pigstyService.GetPigsty(number, pighouseid).Id;

                    foreach (long fodder in fodderIds)
                    {
                        taskPigsty.feed_task_quality.Add(new feed_task_quality {FodderTypeId = fodder});
                    }
                    task.task_pigsty.Add(taskPigsty);
                }
            }

            foreach (
                task_interval_cycle taskIntervalCycle in
                    newTask.FeedTaskCycle.Select(taskcycle => new task_interval_cycle
                                                                  {
                                                                      FirstExecuteDate = taskcycle.FirstExecuteDate,
                                                                      CycleDays = taskcycle.CycleDays
                                                                  }))
            {
                task.task_interval_cycle.Add(taskIntervalCycle);
            }
            var taskService = new TaskService();
            taskService.Insert(task);

            return true;
        }
        public bool NewInspectTask(InspectTask newTask, long taskTypeId, string createEmployee)
        {
            var employeeService = new EmployeeService();

            var task = new task
                           {
                               TaskNumber = newTask.TaskNumber,
                               StartTime = newTask.StartTime,
                               EndTime = newTask.EndTime,
                               CreateTime = DateTime.Now,
                               CreateEmployeeId = employeeService.FindByNumber(createEmployee).Id,
                               TaskStatusId = 1,
                               TaskTypeId = taskTypeId,
                               Memo = newTask.Memo
                           };

            foreach (string employeeNumber in newTask.EmployeeNumber.Split(','))
            {
                task.task_employee.Add(new task_employee {EmployeeId = employeeService.FindByNumber(employeeNumber).Id});
            }

            foreach (string pigHouse in newTask.PigHouseId.Split(','))
            {
                task.task_pighouse.Add(new task_pighouse
                                           {
                                               PigHouseId = long.Parse(pigHouse)
                                           });
            }

            foreach (
                task_interval_cycle taskIntervalCycle in
                    newTask.InspectTaskCycle.Select(taskcycle => new task_interval_cycle
                                                                     {
                                                                         FirstExecuteDate = taskcycle.FirstExecuteDate,
                                                                         CycleDays = taskcycle.CycleDays
                                                                     }))
            {
                task.task_interval_cycle.Add(taskIntervalCycle);
            }
            var taskService = new TaskService();
            taskService.Insert(task);

            return true;
        }
Exemple #4
0
        /// <summary>
        ///     新建销售任务
        /// </summary>
        /// <param name="newTask">销售任务</param>
        /// <param name="taskTypeId">任务类型id</param>
        /// <param name="createEmployee">发布任务的员工工号</param>
        /// <returns>返回新建任务是否成功</returns>
        public bool NewSaleTask(SaleTask newTask, long taskTypeId, string createEmployee)
        {
            var employeeService = new EmployeeService();
            var task = new task
                           {
                               TaskNumber = newTask.TaskNumber,
                               StartTime = newTask.StartTime,
                               EndTime = newTask.EndTime,
                               CreateTime = DateTime.Now,
                               CreateEmployeeId = employeeService.FindByNumber(createEmployee).Id,
                               TaskStatusId = 1,
                               TaskTypeId = taskTypeId,
                               Memo = newTask.Memo
                           };

            foreach (string employeeNumber in newTask.EmployeeNumber.Split(','))
            {
                task.task_employee.Add(new task_employee {EmployeeId = employeeService.FindByNumber(employeeNumber).Id});
            }

            var customerService = new CustomerService();
            customer customer = customerService.FindByName(newTask.Customer) ?? customerService.Insert(new customer
                                                                                                           {
                                                                                                               Name =
                                                                                                                   newTask
                                                                                                                   .
                                                                                                                   Customer
                                                                                                           });
            task.CustomerId = customer.Id;

            foreach (SaleDetail detail in newTask.SaleDetailList)
            {
                task.sale_task_quality.Add(new sale_task_quality
                                               {
                                                   PigTypeId = long.Parse(detail.PigType),
                                                   Price = detail.Price,
                                                   Quality = detail.Quantity
                                               });
            }

            var taskService = new TaskService();
            taskService.Insert(task);

            return true;
        }
        /// <summary>
        ///     新建转栏任务
        /// </summary>
        /// <param name="newTask">转栏任务</param>
        /// <param name="taskTypeId">任务类型id</param>
        /// <param name="createEmployee">发布任务的员工工号</param>
        /// <returns>返回新建任务是否成功</returns>
        public bool NewTransferTask(TransferTask newTask, long taskTypeId, string createEmployee)
        {
            var employeeService = new EmployeeService();

            var task = new task
                           {
                               TaskNumber = newTask.TaskNumber,
                               StartTime = newTask.StartTime,
                               EndTime = newTask.EndTime,
                               CreateTime = DateTime.Now,
                               CreateEmployeeId = employeeService.FindByNumber(createEmployee).Id,
                               TaskStatusId = 1,
                               TaskTypeId = taskTypeId,
                               Memo = newTask.Memo
                           };

            foreach (string employeeNumber in newTask.EmployeeNumber.Split(','))
            {
                task.task_employee.Add(new task_employee {EmployeeId = employeeService.FindByNumber(employeeNumber).Id});
            }

            var pigService = new PigService();

            foreach (string pigNumber in newTask.TransferFrom.SelectMany(taskDetail => taskDetail.Pig.Split(',')))
            {
                task.task_pig.Add(new task_pig
                                      {
                                          PigId = pigService.FindByNumber(pigNumber).Id
                                      });
            }

            var pigstyService = new PigstyService();

            foreach (TaskDetail taskDetail in TransferTo)
            {
                string pigHouse = taskDetail.PigHouse;

                foreach (string pigstyNumber in taskDetail.Pigsty.Split(','))
                {
                    task.task_pigsty.Add(new task_pigsty
                                             {
                                                 PigstyId =
                                                     pigstyService.GetPigsty(int.Parse(pigstyNumber),
                                                                             long.Parse(pigHouse)).Id
                                             });
                }
            }

            var taskService = new TaskService();
            taskService.Insert(task);

            return true;
        }
        /// <summary>
        ///     新建销售任务
        /// </summary>
        /// <param name="newTask">销售任务</param>
        /// <param name="taskTypeId">任务类型id</param>
        /// <param name="createEmployee">发布任务的员工工号</param>
        /// <returns>返回新建任务是否成功</returns>
        public bool NewAddPigTask(AddPigTask newTask, long taskTypeId, string createEmployee)
        {
            var employeeService = new EmployeeService();

            var task = new task
                           {
                               TaskNumber = newTask.TaskNumber,
                               StartTime = newTask.StartTime,
                               EndTime = newTask.EndTime,
                               CreateTime = DateTime.Now,
                               CreateEmployeeId = employeeService.FindByNumber(createEmployee).Id,
                               TaskStatusId = 1,
                               TaskTypeId = taskTypeId,
                               Memo = newTask.Memo
                           };

            foreach (string employeeNumber in newTask.EmployeeNumber.Split(','))
            {
                task.task_employee.Add(new task_employee {EmployeeId = employeeService.FindByNumber(employeeNumber).Id});
            }

            var pigstyService = new PigstyService();
            foreach (TaskDetail detail in newTask.TaskDetails)
            {
                string[] pigstyNum = detail.Pigsty.Split(new[] {','});
                long pighouseid = long.Parse(detail.PigHouse);
                foreach (string pigstydetail in pigstyNum)
                {
                    var taskPigsty = new task_pigsty();
                    int number = int.Parse(pigstydetail);
                    taskPigsty.PigstyId = pigstyService.GetPigsty(number, pighouseid).Id;
                    task.task_pigsty.Add(taskPigsty);
                }
            }

            var taskService = new TaskService();
            taskService.Insert(task);

            return true;
        }
Exemple #7
0
        public bool NewCureTask(CureTask newTask, long taskTypeId, string createEmployee)
        {
            var employeeService = new EmployeeService();

            var task = new task
                           {
                               TaskNumber = newTask.TaskNumber,
                               StartTime = newTask.StartTime,
                               EndTime = newTask.EndTime,
                               CreateTime = DateTime.Now,
                               CreateEmployeeId = employeeService.FindByNumber(createEmployee).Id,
                               TaskStatusId = 1,
                               TaskTypeId = taskTypeId,
                               Memo = newTask.Memo
                           };

            foreach (string employeeNumber in newTask.EmployeeNumber.Split(','))
            {
                task.task_employee.Add(new task_employee {EmployeeId = employeeService.FindByNumber(employeeNumber).Id});
            }

            var pigService = new PigService();

            foreach (string pigNumber in newTask.CureDetail.SelectMany(taskDetail => taskDetail.Pig.Split(',')))
            {
                task.task_pig.Add(new task_pig
                                      {
                                          PigId = pigService.FindByNumber(pigNumber).Id
                                      });
            }

            foreach (CureCourse cureCourse in newTask.CureCourse)
            {
                var cureMethodList = new Collection<cure_task_method>();
                foreach (CureMethod cureMethod in cureCourse.CureMethod)
                {
                    var medicineList = new Collection<cure_task_medicine>();
                    foreach (Medicine medicine in cureMethod.CureMedicine.Where(medicine => !(medicine.Quality <= 0)))
                    {
                        medicineList.Add(new cure_task_medicine
                                             {
                                                 MedicineId = long.Parse(medicine.MedicineName),
                                                 Quality = medicine.Quality,
                                                 UnitId = long.Parse(medicine.Unit)
                                             });
                    }
                    cureMethodList.Add(new cure_task_method
                                           {
                                               CureTypeId = long.Parse(cureMethod.CureType),
                                               cure_task_medicine = medicineList
                                           });
                }
                task.cure_task_course.Add(new cure_task_course
                                              {
                                                  Order = cureCourse.CureOrder + 1,
                                                  Time = cureCourse.CureTime,
                                                  cure_task_method = cureMethodList
                                              });
            }

            var taskService = new TaskService();
            taskService.Insert(task);

            return true;
        }
        public bool NewPreventionDiseaseTask(PreventionDiseaseTask newTask, long taskTypeId, string createEmployee)
        {
            var employeeService = new EmployeeService();

            var task = new task
                           {
                               TaskNumber = newTask.TaskNumber,
                               StartTime = newTask.StartTime,
                               EndTime = newTask.EndTime,
                               CreateTime = DateTime.Now,
                               CreateEmployeeId = employeeService.FindByNumber(createEmployee).Id,
                               TaskStatusId = 1,
                               TaskTypeId = taskTypeId,
                               Memo = newTask.Memo,
                           };

            foreach (string employeeNumber in newTask.EmployeeNumber.Split(','))
            {
                task.task_employee.Add(new task_employee {EmployeeId = employeeService.FindByNumber(employeeNumber).Id});
            }

            var pigstyService = new PigstyService();
            var transferService = new TransferService();
            foreach (TaskDetail detail in newTask.Taskdetails)
            {
                string[] pigstyNum = detail.Pigsty.Split(new[] {','});
                long pighouseid = long.Parse(detail.PigHouse);
                foreach (string pigstydetail in pigstyNum)
                {
                    var taskPigsty = new task_pigsty();
                    int number = int.Parse(pigstydetail);
                    if (detail.Pig == "2") {
                        taskPigsty.PigstyId = pigstyService.GetPigsty(number, pighouseid).Id;
                       var  munPigList=transferService.FindByMunPig(taskPigsty.PigstyId);

                       foreach (var munPig in munPigList)
                           task.task_pig.Add(new task_pig() {
                               PigId = munPig.PigId
                             });
                    }
                    else
                    {
                        taskPigsty.PigstyId = pigstyService.GetPigsty(number, pighouseid).Id;
                        task.task_pigsty.Add(taskPigsty);
                    }
                }
            }

            task.task_prevention.Add(new task_prevention
                                         {
                                             PreventionTypeId = long.Parse(newTask.DiseaseName)
                                         });

            var taskService = new TaskService();
            taskService.Insert(task);

            return true;
        }