Beispiel #1
0
        /// <summary>
        ///     查看喂食任务
        /// </summary>
        /// <param name="taskNumber">任务编号</param>
        /// <returns></returns>
        public AddPigTask GetAddPigTask(string taskNumber)
        {
            var taskService = new TaskService();
            var taskEmployeeService = new TaskEmployeeService();

            task task = taskService.FindByTaskNumber(taskNumber);

            if (task == null)
            {
                return null;
            }

            var checkTask = new AddPigTask
                                {
                                    TaskNumber = task.TaskNumber,
                                    StartTime = task.StartTime,
                                    EndTime = task.EndTime,
                                    EmployeeName = taskEmployeeService.GetEmployeeNames(task.Id),
                                    EmployeeNumber = taskEmployeeService.GetEmployeeNumbers(task.Id),
                                    Status = task.task_status_type.Name,
                                    Memo = task.Memo
                                };

            var pigHouseService = new PigHouseService();
            var taskPigstyService = new TaskPigstyService();
            List<task_pigsty> taskPigsties = task.task_pigsty.ToList();
            List<TaskDetail> taskDetailList =
                taskPigstyService.GetPigHouseIds(taskPigsties).Select(pigHouseid => new TaskDetail
                                                                                        {
                                                                                            PigHouse =
                                                                                                pigHouseService
                                                                                                    .
                                                                                                    Find
                                                                                                    (pigHouseid)
                                                                                                    .
                                                                                                    pig_house_type
                                                                                                    .
                                                                                                    Name +
                                                                                                pigHouseService
                                                                                                    .
                                                                                                    Find
                                                                                                    (pigHouseid)
                                                                                                    .
                                                                                                    Number,
                                                                                            Pigsty =
                                                                                                taskPigstyService
                                                                                                .
                                                                                                GetPigstyNums
                                                                                                (task
                                                                                                     .Id,
                                                                                                 pigHouseid),
                                                                                            PigNum =
                                                                                                taskPigstyService
                                                                                                .
                                                                                                GetPigstyCapacitySum
                                                                                                (task
                                                                                                     .Id,
                                                                                                 pigHouseid)
                                                                                        }).ToList();

            if (taskDetailList.Count != 0)
            {
                checkTask.TaskDetails = taskDetailList;
            }

            return checkTask;
        }
        public PreventionDiseaseTask GetPreventionDiseaseTask(string taskNumber)
        {
            var taskService = new TaskService();
            task task = taskService.FindByTaskNumber(taskNumber);

            if (task == null)
            {
                return null;
            }

            var taskEmployeeService = new TaskEmployeeService();
            List<task_pigsty> taskPigsties = task.task_pigsty.ToList();
            var checkTask = new PreventionDiseaseTask
                                {
                                    TaskNumber = task.TaskNumber,
                                    StartTime = task.StartTime,
                                    EndTime = task.EndTime,
                                    EmployeeName = taskEmployeeService.GetEmployeeNames(task.Id),
                                    EmployeeNumber = taskEmployeeService.GetEmployeeNumbers(task.Id),
                                    Status = task.task_status_type.Name,
                                    Memo = task.Memo
                                };

            task_prevention taskPrevention = task.task_prevention.FirstOrDefault();

            if (taskPrevention != null)
            {
                checkTask.DiseaseName = taskPrevention.prevention_type.Name;
                checkTask.Medicine.MedicineName =
                    new MedicineService().Find(taskPrevention.prevention_type.MedicineId).Name;
                checkTask.Medicine.Quality = taskPrevention.prevention_type.Quality;
                checkTask.Medicine.Unit = new UnitService().Find(taskPrevention.prevention_type.UnitId).Name;
            }

            var pigHouseService = new PigHouseService();
            var taskPigstyService = new TaskPigstyService();
            var taskPigService = new TaskPigService();
            List<TaskDetail> details =
                taskPigstyService.GetPigHouseIds(taskPigsties).Select(pigHouseid => new TaskDetail
                                                                                        {
                                                                                            PigHouse =
                                                                                                pigHouseService
                                                                                                    .
                                                                                                    Find
                                                                                                    (pigHouseid)
                                                                                                    .
                                                                                                    pig_house_type
                                                                                                    .
                                                                                                    Name +
                                                                                                pigHouseService
                                                                                                    .
                                                                                                    Find
                                                                                                    (pigHouseid)
                                                                                                    .
                                                                                                    Number,
                                                                                            Pigsty =
                                                                                                taskPigstyService
                                                                                                .
                                                                                                GetPigstyNums
                                                                                                (task
                                                                                                     .Id,
                                                                                                 pigHouseid),
                                                                                            Pig = taskPigService.GetMumPigBypigStys(
                                                                                            taskPigstyService.GetPigstyNums(task.Id, pigHouseid)
                                                                                            , pigHouseid)
                                                                                        }).ToList();

            foreach (var munPigHouseId in taskPigService.GetPigHouseByMum(task.Id))
            {

                details.Add(new TaskDetail()
                {
                    PigHouse = pigHouseService.Find(munPigHouseId).pig_house_type.Name+pigHouseService.Find(munPigHouseId).Number,
                    Pigsty = taskPigService.GetPigstyNumsByMum(task.Id, munPigHouseId),
                    Pig = "母猪"
                });
            }

            if (details.Count != 0)
            {
                checkTask.Taskdetails = details;
            }
            return checkTask;
        }