Exemplo n.º 1
0
 public ActionResult AddPigHouseEquipMentInfo(PigHouseModel model)
 {
     var pigHouseService = new PigHouseService();
     var pigHouse = new pig_house
                        {
                            PigHouseTypeId = model.PigHouseTypeId,
                            Number = model.Number,
                            RFID = model.Rfid,
                            Memo = model.Memo
                        };
     pigHouseService.Insert(pigHouse);
     ViewBag.Title = "添加成功";
     return View("PigHouseMessage");
 }
Exemplo n.º 2
0
 //删除猪舍
 public bool DelPigHouse(string rfid)
 {
     var pigHouseService = new PigHouseService();
     pig_house pigHouse = pigHouseService.FindByRfid(rfid);
     try
     {
         pigHouseService.Delete(pigHouse);
     }
     catch (Exception)
     {
         return false;
     }
     return true;
 }
Exemplo n.º 3
0
        /// <summary>
        ///     根据猪舍id找猪栏下拉列表
        /// </summary>
        /// <returns></returns>
        public IEnumerable<SelectListItem> FindPigstyListByPigHouseId(string pigHouseId)
        {
            var pigHouseService = new PigHouseService();
            var pigstyService = new PigstyService();
            long id = 0;
            IEnumerable<SelectListItem> pigstySelect = new List<SelectListItem>();
            if (long.TryParse(pigHouseId, out id))
                pigstySelect =
                    pigstyService.FindByPigHouseId(id).OrderBy(m=>m.Number).Select(
                        pigstyItem => new SelectListItem
                        {
                            Text = pigstyItem.Number + "",
                            Value = pigstyItem.Id + ""
                        });

            return pigstySelect;
        }
Exemplo n.º 4
0
        public PagedList<PigHouseModel> GetPigHousePagedList(int pageIndex, int pageSize)
        {
            var pigHouseService = new PigHouseService();
            List<pig_house> pigHouses = pigHouseService.FindAll();
            List<PigHouseModel> pigHouseModels = pigHouses.Select(pigHouse => new PigHouseModel
                                                                                  {
                                                                                      PigHouseTypeId =
                                                                                          pigHouse.PigHouseTypeId,
                                                                                      Number = pigHouse.Number,
                                                                                      Rfid = pigHouse.RFID,
                                                                                      Memo = pigHouse.Memo,
                                                                                      PigHouseTypeName =
                                                                                          pigHouse.pig_house_type.Name
                                                                                  })
                                                          .OrderBy(m => m.Number)
                                                          .OrderBy(m => m.PigHouseTypeName)
                                                          .ToList();
            int count = (pageIndex - 1)*pageSize;

            return new PagedList<PigHouseModel>(pigHouseModels.Skip(count).Take(pageSize), pageIndex, pageSize,
                                                pigHouseModels.Count());
        }
Exemplo n.º 5
0
        public ActionResult CheckPigHouseEquipMentInfo(string rfid)
        {
            if (Session["CheckFeed"] == null || !(bool) Session["CheckSystemManage"])
            {
                Response.Write("<script>history.go(0);</script>");
                return View("Error");
            }

            var pigHouseService = new PigHouseService();
            pig_house pigHouse = pigHouseService.FindByRfid(rfid);
            var pigHouseModel = new PigHouseModel
                                    {
                                        Id = pigHouse.Id,
                                        PigHouseTypeId = pigHouse.PigHouseTypeId,
                                        PigHouseTypeName = pigHouse.pig_house_type.Name,
                                        Number = pigHouse.Number,
                                        Rfid = pigHouse.RFID,
                                        Memo = pigHouse.Memo
                                    };
            var listService = new ListService();
            ViewData["PigHouseType"] = listService.GetPigHouseTypeList();
            ViewBag.Title = "查看猪舍";
            return View("AddPigHouseEquipMentInfo", pigHouseModel);
        }
Exemplo n.º 6
0
 //猪舍类型
 public bool PigHouseRfidCompareByType(long typeid, int number)
 {
     var pigHouseService = new PigHouseService();
     return pigHouseService.FindByPigHouseTypeId(typeid).All(c => c.Number != number);
 }
Exemplo n.º 7
0
 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");
 }
Exemplo n.º 8
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;
        }
Exemplo n.º 9
0
 /// <summary>
 ///     获得猪舍下拉列表
 /// </summary>
 /// <returns>返回集合</returns>
 public IEnumerable<SelectListItem> GetPigHouseList()
 {
     var pigHouseSelect = new PigHouseService();
     IEnumerable<SelectListItem> pigHouseSelectList =
         pigHouseSelect.FindAll().Select(pigHouseItem => new SelectListItem
                                                             {
                                                                 Text = pigHouseItem.pig_house_type.Name +
                                                                        pigHouseItem.Number,
                                                                 Value = pigHouseItem.Id + string.Empty
                                                             }).OrderBy(m => m.Text);
     return pigHouseSelectList;
 }
Exemplo n.º 10
0
        public TransferTask GetTransferTask(string taskNumber)
        {
            var taskService = new TaskService();
            var taskEmployeeService = new TaskEmployeeService();

            task task = taskService.FindByTaskNumber(taskNumber);

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

            var checkTask = new TransferTask
                                {
                                    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 transferService = new TransferService();
            var pigstyDic = new Dictionary<long, StringBuilder>();

            foreach (task_pig item in task.task_pig)
            {
                transfer transfer = transferService.GetLastTransfer(item.PigId, task.Id);
                if (transfer == null)
                {
                    continue;
                }
                long pigsty = transfer.PigstyId;

                if (!pigstyDic.ContainsKey(pigsty))
                {
                    pigstyDic.Add(pigsty, new StringBuilder().Append(transfer.pig.Number));
                }
                else
                {
                    pigstyDic[pigsty].Append("," + transfer.pig.Number);
                }
            }

            var pigHouseService = new PigHouseService();
            var pigstyService = new PigstyService();
            if (pigstyDic.Count != 0)
            {
                List<TaskDetail> transferFromList = (from builder in pigstyDic
                                                     let pigHouse = pigHouseService.FindbyPigstyId(builder.Key)
                                                     select new TaskDetail
                                                                {
                                                                    PigHouse =
                                                                        pigHouse.pig_house_type.Name + pigHouse.Number,
                                                                    Pigsty = pigstyService.Find(builder.Key).Number + "",
                                                                    Pig = builder.Value.ToString()
                                                                }).ToList();

                checkTask.TransferFrom = transferFromList;
            }

            var transferToList = new List<TaskDetail>();
            var pigHouseDic = new Dictionary<string, StringBuilder>();

            foreach (task_pigsty taskPigsty in task.task_pigsty)
            {
                pig_house pigHouse = pigHouseService.FindbyPigstyId(taskPigsty.PigstyId);

                if (pigHouse == null)
                {
                    continue;
                }
                string pigHouseStr = pigHouse.pig_house_type.Name + pigHouse.Number;

                if (!pigHouseDic.ContainsKey(pigHouseStr))
                {
                    pigHouseDic.Add(pigHouseStr, new StringBuilder().Append(taskPigsty.pigsty.Number));
                }
                else
                {
                    pigHouseDic[pigHouseStr].Append("," + taskPigsty.pigsty.Number);
                }
            }

            if (pigHouseDic.Count != 0)
            {
                transferToList.AddRange(pigHouseDic.Select(builder => new TaskDetail
                                                                          {
                                                                              PigHouse = builder.Key,
                                                                              Pigsty = builder.Value.ToString()
                                                                          }));

                checkTask.TransferTo = transferToList;
            }

            return checkTask;
        }
Exemplo n.º 11
0
        public object GetCureTask(string taskNumber)
        {
            var taskService = new TaskService();
            var taskEmployeeService = new TaskEmployeeService();

            task task = taskService.FindByTaskNumber(taskNumber);

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

            var checkTask = new CureTask
                                {
                                    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 transferService = new TransferService();
            var pigstyDic = new Dictionary<long, StringBuilder>();

            foreach (task_pig item in task.task_pig)
            {
                transfer transfer = transferService.GetLastTransfer(item.PigId, task.Id);
                if (transfer == null)
                {
                    continue;
                }
                long pigsty = transfer.PigstyId;

                if (!pigstyDic.ContainsKey(pigsty))
                {
                    pigstyDic.Add(pigsty, new StringBuilder().Append(transfer.pig.Number));
                }
                else
                {
                    pigstyDic[pigsty].Append("," + transfer.pig.Number);
                }
            }

            var pigHouseService = new PigHouseService();
            var pigstyService = new PigstyService();
            if (pigstyDic.Count != 0)
            {
                checkTask.CureDetail = (from builder in pigstyDic
                                        let pigHouse = pigHouseService.FindbyPigstyId(builder.Key)
                                        select new TaskDetail
                                                   {
                                                       PigHouse =
                                                           pigHouse.pig_house_type.Name + pigHouse.Number,
                                                       Pigsty = pigstyService.Find(builder.Key).Number + "",
                                                       Pig = builder.Value.ToString()
                                                   }).ToList();
            }

            List<CureCourse> courseList = (from cureCourse in task.cure_task_course
                                           let methodList = (from cureMethod in cureCourse.cure_task_method
                                                             let medicineList =
                                                                 cureMethod.cure_task_medicine.Select(
                                                                     cureTaskMedicine => new Medicine
                                                                                             {
                                                                                                 MedicineName =
                                                                                                     cureTaskMedicine.
                                                                                                     medicine.Name,
                                                                                                 Quality =
                                                                                                     cureTaskMedicine.
                                                                                                     Quality,
                                                                                                 Unit =
                                                                                                     cureTaskMedicine.
                                                                                                     unit.Name
                                                                                             }).ToList()
                                                             select new CureMethod
                                                                        {
                                                                            CureMedicine = medicineList,
                                                                            CureType = cureMethod.cure_type.Name
                                                                        }).ToList()
                                           select new CureCourse
                                                      {
                                                          CureOrder = cureCourse.Order,
                                                          CureTime = cureCourse.Time,
                                                          CureMethod = methodList
                                                      }).ToList();

            if (courseList[0].CureMethod.Count != 0 && courseList[0].CureMethod[0].CureMedicine.Count != 0)
            {
                checkTask.CureCourse = courseList;
            }

            return checkTask;
        }
Exemplo n.º 12
0
 /// <summary>
 ///     猪舍id为1猪栏下拉列表
 /// </summary>
 /// <returns></returns>
 public IEnumerable<SelectListItem> GetFirstPigstyList()
 {
     var pigHouseService = new PigHouseService();
     var pigstyService = new PigstyService();
     IEnumerable<SelectListItem> pigstySelect = new List<SelectListItem>();
     pig_house firstOrDefault = pigHouseService.FindAll().FirstOrDefault();
     if (firstOrDefault != null)
     {
         pigstySelect =
             pigstyService.FindByPigHouseId(firstOrDefault.Id).OrderBy(m=>m.Number).Select(
                 pigstyItem => new SelectListItem
                                   {
                                       Text = pigstyItem.Number + "",
                                       Value = pigstyItem.Id + ""
                                   });
     }
     return pigstySelect;
 }
Exemplo n.º 13
0
        /// <summary>
        ///     查看淘汰任务
        /// </summary>
        /// <param name="taskNumber">任务编号</param>
        /// <returns></returns>
        public EliminateTask GetEliminateTask(string taskNumber)
        {
            var taskService = new TaskService();
            var taskEmployeeService = new TaskEmployeeService();

            task task = taskService.FindByTaskNumber(taskNumber);

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

            var customerService = new CustomerService();
            var checkTask = new EliminateTask
            {
                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 transferService = new TransferService();
            var pigstyDic = new Dictionary<long, StringBuilder>();

            foreach (task_pig item in task.task_pig)
            {
                transfer transfer = transferService.GetLastTransfer(item.PigId, task.Id);
                if (transfer == null)
                {
                    continue;
                }
                long pigsty = transfer.PigstyId;

                if (!pigstyDic.ContainsKey(pigsty))
                {
                    pigstyDic.Add(pigsty, new StringBuilder().Append(transfer.pig.Number));
                }
                else
                {
                    pigstyDic[pigsty].Append("," + transfer.pig.Number);
                }
            }

            foreach (task_pigsty item in task.task_pigsty)
            {

                long pigsty = item.PigstyId;

                    pigstyDic.Add(pigsty, new StringBuilder().Append(""));

            }
            var pigHouseService = new PigHouseService();
            var pigstyService = new PigstyService();
            if (pigstyDic.Count != 0)
            {
                checkTask.EliminateTaskDetail = (from builder in pigstyDic
                                        let pigHouse = pigHouseService.FindbyPigstyId(builder.Key)
                                        select new TaskDetail
                                        {
                                            PigHouse =
                                                pigHouse.pig_house_type.Name + pigHouse.Number,
                                            Pigsty = pigstyService.Find(builder.Key).Number + "",
                                            Pig = builder.Value.ToString()
                                        }).ToList();
            }

            return checkTask;
        }
Exemplo n.º 14
0
 //猪舍RFID
 public bool PigHouseRfidCompare(string rfid)
 {
     var pigHouseService = new PigHouseService();
     if (pigHouseService.FindByRfid(rfid) != null)
     {
         return false;
     }
     return true;
 }
Exemplo n.º 15
0
 //猪舍编号
 public bool PigHouseNumberCompare(int number, long housetypeid)
 {
     var pigHouseService = new PigHouseService();
     List<pig_house> pigHouses = pigHouseService.FindByPigHouseTypeId(housetypeid);
     int flag = 1;
     foreach (pig_house pigHouse in pigHouses)
     {
         if (pigHouse.Number == number)
         {
             flag = 0;
         }
     }
     if (flag == 0)
     {
         return false;
     }
     return true;
 }
Exemplo n.º 16
0
        public string GetPigHouse()
        {
            var pigHouseService = new PigHouseService();

            return pigHouseService.GetPigHouseStr();
        }
Exemplo n.º 17
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;
        }
Exemplo n.º 18
0
 /// <summary>
 ///     猪栏id为1的猪下拉列表
 /// </summary>
 /// <returns></returns>
 public IEnumerable<SelectListItem> GetFirstPigList()
 {
     var pigHouseService = new PigHouseService();
     var pigstyService = new PigstyService();
     var transferService = new TransferService();
     var pigSelect = new List<SelectListItem>();
     pig_house pigHouse = pigHouseService.FindAll().FirstOrDefault();
     if (pigHouse != null)
     {
         pigsty pigsty = pigstyService.FindByPigHouseId(pigHouse.Id).FirstOrDefault();
         if (pigsty != null)
         {
             string[] strPig = transferService.GetPigIdAndNum(pigsty.Id).Split(',');
             if (strPig[0] != "")
                 pigSelect.AddRange(
                     strPig.Select(strPigItem => strPigItem.Split(':')).Select(pig => new SelectListItem
                                                                                          {
                                                                                              Text = pig[1],
                                                                                              Value = pig[0]
                                                                                          }).OrderBy(m => m.Text));
         }
     }
     return pigSelect;
 }
        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;
        }