public ActionResult ModifyPigHouseEquipMentInfo(PigHouseModel model)
 {
     var pigHouseService = new PigHouseService();
     pig_house pigHouse = pigHouseService.Find(model.Id);
     pigHouse.RFID = model.Rfid;
     pigHouse.Number = model.Number;
     pigHouse.PigHouseTypeId = model.PigHouseTypeId;
     pigHouse.Memo = model.Memo;
     pigHouseService.Update(pigHouse);
     ViewBag.Title = "修改成功";
     return View("PigHouseMessage");
 }
Beispiel #2
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;
        }
Beispiel #3
0
        /// <summary>
        ///     查看喂食任务
        /// </summary>
        /// <param name="taskNumber">任务编号</param>
        /// <returns></returns>
        public FeedTask GetFeedTask(string taskNumber)
        {
            var taskService = new TaskService();
            var taskEmployeeService = new TaskEmployeeService();
            var pigHouseService = new PigHouseService();
            task task = taskService.FindByTaskNumber(taskNumber);
            var feedTaskQualityService = new FeedTaskQualityService();
            if (task == null)
            {
                return null;
            }
            var feedTask = new FeedTask
                               {
                                   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
                               };

            List<FeedTaskDetail> taskDetailList = (from item in feedTaskQualityService.GetPigstyByHouse(task.Id)
                                                   let keys = item.Key.Split('|')
                                                   let pigHouse = pigHouseService.Find(long.Parse(keys[0]))
                                                   let pigsty = item.Value.Remove(item.Value.Length - 1)
                                                   select new FeedTaskDetail
                                                              {
                                                                  PigHouse =
                                                                      pigHouse.pig_house_type.Name + pigHouse.Number,
                                                                  Pigsty = pigsty,
                                                                  Fodder = keys[1]
                                                              }).ToList();
            //var taskDetailList = new List<FeedTaskDetail>();
            //foreach (var item in feedTaskQualityService.GetPigstyByHouse(task.Id))
            //{
            //    string[] keys = item.Key.Split('|');
            //    pig_house pigHouse = pigHouseService.Find(long.Parse(keys[0]));
            //    string pigsty = item.Value.Remove(item.Value.Length - 1);
            //    taskDetailList.Add(new FeedTaskDetail
            //                           {
            //                               PigHouse = pigHouse.pig_house_type.Name + pigHouse.Number,
            //                               Pigsty = pigsty,
            //                               Fodder = keys[1]
            //                           });
            //}

            List<TaskCycle> taskCycleList = task.task_interval_cycle.Select(taskCycleitem => new TaskCycle
                                                                                                 {
                                                                                                     FirstExecuteDate
                                                                                                         =
                                                                                                         taskCycleitem
                                                                                                         .
                                                                                                         FirstExecuteDate,
                                                                                                     CycleDays
                                                                                                         =
                                                                                                         taskCycleitem
                                                                                                         .
                                                                                                         CycleDays
                                                                                                 }).ToList();
            if (taskDetailList.Count > 0)
            {
                feedTask.Feeddetails = taskDetailList;
            }
            if (taskCycleList.Count > 0)
            {
                feedTask.FeedTaskCycle = taskCycleList;
            }

            return feedTask;
        }
        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;
        }