Exemplo n.º 1
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.º 2
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.º 3
0
 public ActionResult ModifyPigstyEquipMentInfo(PigstyModel model)
 {
     var pigstyService = new PigstyService();
     pigsty pigsty = pigstyService.Find(model.Id);
     pigsty.RFID = model.Rfid;
     pigsty.Number = model.Number;
     pigsty.PigHouseId = model.PigHouseId;
     pigsty.Memo = model.Memo;
     pigsty.Capacity = model.Capacity;
     pigstyService.Update(pigsty);
     ViewBag.Title = "修改成功";
     return View("PigstyMessage");
 }
Exemplo n.º 4
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;
        }