/// <summary>
        ///     新建淘汰信息
        /// </summary>
        /// <param name="newInfo"></param>
        /// <returns></returns>
        public bool CreateEliminateInfo(EliminateInfo newInfo)
        {
            var salesService = new SaleService();
            var taskStatusTypeService = new TaskStatusTypeService();
            var taskService = new TaskService();
            var pigService = new PigService();
            var pigInfo = new PigInfo();
            var newSale = new sale
            {
                TaskId = long.Parse(newInfo.TaskNumber),
                EmployeeId = long.Parse(newInfo.EmployeeName),
                SaleType = "淘汰",
                Memo = newInfo.Meno
            };

            foreach (Detail salesPigInfo in newInfo.EliminateInfoPigDetail)
            {
                newSale.sale_pig.Add(new sale_pig
                {
                    Time = salesPigInfo.DetailTime,
                    PigId = long.Parse(salesPigInfo.Pig)
                });
                pigInfo.SetState(long.Parse(salesPigInfo.Pig), true);
            }
            salesService.Insert(newSale);
            task_status_type taskStatusType = taskStatusTypeService.FindByName("已完成");
            task task = taskService.Find(long.Parse(newInfo.TaskNumber));
            if (taskStatusType != null && task != null)
            {
                task.TaskStatusId = taskStatusType.Id;
                taskService.Update(task);
            }
            return true;
        }
 /// <summary>
 ///     查看转栏信息
 /// </summary>
 /// <param name="taskNumber">任务编号</param>
 /// <returns></returns>
 public TransferPigstyInfo CheckTransferPigstyInfo(string taskNumber)
 {
     var checkTransferPigstyInfo = new TransferPigstyInfo
                                       {TransferPigstyInfoDetail = new List<TransferPigstyInfoDetail>()};
     var taskEmployee = new TaskEmployeeService();
     var taskService = new TaskService();
     var transferService = new TransferService();
     task transferPigstyTask = taskService.FindByTaskNumber(taskNumber);
     if (transferPigstyTask != null)
     {
         checkTransferPigstyInfo.TaskNumber = taskNumber;
         checkTransferPigstyInfo.EmployeeName = taskEmployee.GetEmployeeNames(transferPigstyTask.Id);
         transfer firstOrDefault = transferService.FindByTaskId(transferPigstyTask.Id).FirstOrDefault();
         if (firstOrDefault != null)
             checkTransferPigstyInfo.Meno = firstOrDefault.Memo;
         foreach (
             transfer transfer in
                 transferService.FindByTaskId(transferPigstyTask.Id).OrderByDescending(m => m.Time))
         {
             transfer lastPigsty = transferService.GetLastTransfer(transfer.PigId, transferPigstyTask.Id);
             if (lastPigsty != null && lastPigsty.pigsty.Id != transfer.pigsty.Id)
                 checkTransferPigstyInfo.TransferPigstyInfoDetail.Add(new TransferPigstyInfoDetail
                                                                          {
                                                                              SourcePigHouse =
                                                                                  lastPigsty.pigsty.pig_house.
                                                                                             pig_house_type.Name +
                                                                                  lastPigsty.pigsty.pig_house.
                                                                                             Number,
                                                                              SourcePigsty =
                                                                                  lastPigsty.pigsty.Number + "",
                                                                              Pig = transfer.pig.Number,
                                                                              TargetPigHouse =
                                                                                  transfer.pigsty.pig_house.
                                                                                           pig_house_type.Name +
                                                                                  transfer.pigsty.pig_house.
                                                                                           Number,
                                                                              TargetPigsty =
                                                                                  transfer.pigsty.Number + "",
                                                                              TransferPigstyTime = transfer.Time
                                                                          });
             else
                 checkTransferPigstyInfo.TransferPigstyInfoDetail.Add(new TransferPigstyInfoDetail
                                                                          {
                                                                              SourcePigHouse = "",
                                                                              SourcePigsty = "",
                                                                              Pig = transfer.pig.Number,
                                                                              TargetPigHouse =
                                                                                  transfer.pigsty.pig_house.
                                                                                           pig_house_type.Name +
                                                                                  transfer.pigsty.pig_house.
                                                                                           Number,
                                                                              TargetPigsty =
                                                                                  transfer.pigsty.Number + "",
                                                                              TransferPigstyTime = transfer.Time
                                                                          });
         }
     }
     return checkTransferPigstyInfo;
 }
Exemple #3
0
        /// <summary>
        ///     查看治疗信息
        /// </summary>
        /// <param name="employeename">治疗人员</param>
        /// <param name="taskNumber">任务编号</param>
        /// <param name="order">疗程号</param>
        /// <returns></returns>
        public CureInfo CheckCureInfo(string employeename, string taskNumber, int order)
        {
            var curePigService = new CurePigService();
            var cureTaskCourseService = new CureTaskCourseService();
            var cureMethodService = new CureMethodService();
            var transferService = new TransferService();
            var taskService = new TaskService();
            var cureMedicineService = new CureMedicineService();
            cure_task_course cureTaskCourse =
                cureTaskCourseService.FindByTaskId(taskService.FindByTaskNumber(taskNumber).Id).FirstOrDefault(
                    m => m.Order == order);
            var checkCureInfo = new CureInfo
                                    {
                                        TaskNumber = taskNumber,
                                        Order = order,
                                        EmployeeName = employeename,
                                        CureDetail = new List<CureDetail>(),
                                        PigDetail = new List<Detail>()
                                    };
            if (cureTaskCourse == null) return checkCureInfo;

            foreach (
                cure_pig curePig in
                    curePigService.FindByCureTaskCourseId(cureTaskCourse.Id).Where(
                        m => m.employee.Name.Equals(employeename)))
            {
                transfer firstOrDefault =
                    transferService.FindByPigId(curePig.PigId).OrderByDescending(m => m.Time).FirstOrDefault();
                if (firstOrDefault != null)
                    checkCureInfo.PigDetail.Add(new Detail
                                                    {
                                                        PigHouse = firstOrDefault.pigsty.pig_house.pig_house_type.Name
                                                                   + firstOrDefault.pigsty.pig_house.Number,
                                                        Pigsty = firstOrDefault.pigsty.Number + "",
                                                        Pig = firstOrDefault.pig.Number,
                                                        DetailTime = (DateTime) curePig.CureTime
                                                    });
            }
            foreach (cure_method cureMethod in cureMethodService.FindByCureTaskCourseId(cureTaskCourse.Id))
            {
                var medicineList = new List<CureMedicineDetail>();
                foreach (cure_medicine cureMedicine in cureMedicineService.FindByCureMethoId(cureMethod.Id))
                {
                    medicineList.Add(new CureMedicineDetail
                                         {
                                             Medicine = cureMedicine.medicine.Name,
                                             Quality = cureMedicine.Quality,
                                             Unit = cureMedicine.unit.Name
                                         });
                }
                checkCureInfo.CureDetail.Add(new CureDetail
                                                 {
                                                     CureType = cureMethod.cure_type.Name,
                                                     CureMedicineDetail = medicineList
                                                 });
            }
            return checkCureInfo;
        }
 /// <summary>
 ///     根据任务编号删除转栏信息
 /// </summary>
 /// <param name="taskNumber">任务编号</param>
 /// <returns></returns>
 public bool DelTransfer(string taskNumber)
 {
     var taskService = new TaskService();
     long taskId = taskService.FindByTaskNumber(taskNumber).Id;
     var transferService = new TransferService();
     foreach (transfer transfer in transferService.FindByTaskId(taskId))
     {
         transferService = new TransferService();
         transferService.Delete(transferService.Find(transfer.Id));
     }
     return true;
 }
        /// <summary>
        ///     查看巡查信息
        /// </summary>
        /// <param name="taskNumber">任务编号</param>
        /// <param name="employeeName">人员名字</param>
        /// <param name="time">巡查时间</param>
        /// <returns></returns>
        public InspectInfo CheckInspectInfo(string taskNumber, string employeeName, DateTime time)
        {
            var inspectionService = new InspectionService();
            var inspectionExceptionService = new InspectionExceptionService();
            var exceptionService = new ExceptionTypeService();
            task task = new TaskService().FindByTaskNumber(taskNumber);
            var checkInspectInfo = new InspectInfo();
            checkInspectInfo.InspectDetail = new List<InspectDetail>();
            checkInspectInfo.TaskNumber = taskNumber;
            checkInspectInfo.EmployeeName = employeeName;

            if (task != null)
            {
                foreach (
                    inspection inspectionItem in
                        inspectionService.FindByTaskId(task.Id).OrderByDescending(m => m.Time).Where(
                            m => m.employee.Name.Equals(employeeName)))
                {
                    if (!time.Date.Equals(inspectionItem.Time.Date)) continue;
                    List<inspection_exception> exceptionList =
                        inspectionExceptionService.FindByInspectionId(inspectionItem.Id);
                    if (exceptionList.Count > 0)
                        foreach (var exceptionItem in inspectionExceptionService.GetPigstyInfoNums(inspectionItem))
                        {
                            checkInspectInfo.InspectDetail.Add(new InspectDetail
                                                                   {
                                                                       PigHouse =
                                                                           inspectionItem.pig_house.pig_house_type.Name
                                                                           + inspectionItem.pig_house.Number,
                                                                       Pigsty = exceptionItem.Value,
                                                                       DetailTime = inspectionItem.Time,
                                                                       InspectionException =
                                                                           exceptionService.Find(exceptionItem.Key).Name
                                                                   });
                        }
                    else
                        checkInspectInfo.InspectDetail.Add(new InspectDetail
                                                               {
                                                                   PigHouse =
                                                                       inspectionItem.pig_house.pig_house_type.Name
                                                                       + inspectionItem.pig_house.Number,
                                                                   Pigsty = "",
                                                                   DetailTime = inspectionItem.Time,
                                                                   InspectionException = "正常"
                                                               });
                }
                return checkInspectInfo;
            }
            return null;
        }
        /// <summary>
        /// 获得指定任务人员的姓名和编号
        /// </summary>
        /// <param name="tasktypeid">任务类型id</param>
        /// <returns>返回指定任务人员的姓名和编号</returns>
        public string GetFeedTaskEmployeeNameAndNumber(long tasktypeid)
        {
            int i;
            var stremployeenumber = new StringBuilder();
            var taskService = new TaskService();
            var taskEmployeeService = new TaskEmployeeService();
            List<task> tasks = taskService.FindByTaskTypeId(tasktypeid);
            List<task_employee> taskEmployees =
                tasks.SelectMany(task => taskEmployeeService.FindByTaskId(task.Id)).ToList();

            for (i = 0; i < taskEmployees.Count - 1; i++)
            {
                stremployeenumber.Append(taskEmployees[i].employee.Number + ":" + taskEmployees[i].employee.Name + ",");
            }
            stremployeenumber.Append(taskEmployees[i].employee.Number + ":" + taskEmployees[i].employee.Name);
            return stremployeenumber.ToString();
        }
Exemple #7
0
        /// <summary>
        ///     查看销售信息
        /// </summary>
        /// <param name="taskNumber">任务编号</param>
        /// <returns></returns>
        public SalesInfo CheckSalesInfo(string taskNumber)
        {
            var checkSalesInfo = new SalesInfo();
            var salesService = new SaleService();
            checkSalesInfo.SalesInfoPigDetail = new List<Detail>();
            checkSalesInfo.SalesInfoDetail = new List<SalesInfoDetail>();
            var saleTaskQualityService = new SaleTaskQualityService();
            var transferService = new TransferService();
            task task = new TaskService().FindByTaskNumber(taskNumber);
            if (task == null) return null;
            sale sale = salesService.FindByTaskId(task.Id).FirstOrDefault();
            if (sale == null) return null;
            checkSalesInfo.TaskNumber = taskNumber;
            checkSalesInfo.EmployeeName = sale.employee.Name;
            checkSalesInfo.Meno = sale.Memo;
            checkSalesInfo.Customer = task.customer.Name;
            foreach (sale_task_quality saleTaskItem in saleTaskQualityService.FindByTaskId(task.Id))
            {
                checkSalesInfo.SalesInfoDetail.Add(new SalesInfoDetail
                                                       {
                                                           PigType = saleTaskItem.pig_type.Name,
                                                           Price = saleTaskItem.Price,
                                                           Quantity = saleTaskItem.Quality
                                                       });
            }

            foreach (sale_pig salePigItem in sale.sale_pig)
            {
                transfer firstOrDefault =
                    transferService.FindByPigId(salePigItem.PigId).OrderByDescending(m => m.Time).FirstOrDefault();
                if (firstOrDefault != null)
                    if (salePigItem.Time != null)
                        checkSalesInfo.SalesInfoPigDetail.Add(new Detail
                                                                  {
                                                                      PigHouse =
                                                                          firstOrDefault.pigsty.pig_house.pig_house_type
                                                                                        .
                                                                                         Name
                                                                          + firstOrDefault.pigsty.pig_house.Number,
                                                                      Pigsty = firstOrDefault.pigsty.Number + "",
                                                                      Pig = salePigItem.pig.Number,
                                                                      DetailTime = (DateTime) salePigItem.Time
                                                                  });
            }
            return checkSalesInfo;
        }
 /// <summary>
 /// 删除防疫信息
 /// </summary>
 /// <param name="taskNumber">任务编号</param>
 /// <param name="employee">人名</param>
 /// <returns></returns>
 public bool DelPrevention(string taskNumber, string employee)
 {
     var preventionService = new PreventionService();
     var taskService = new TaskService();
     task task = taskService.FindByTaskNumber(taskNumber);
     if (task != null)
     {
         foreach (
             prevention prevention in
                 preventionService.FindByTaskId(task.Id).Where(m => m.employee.Name.Equals(employee)))
         {
             preventionService = new PreventionService();
             preventionService.Delete(preventionService.Find(prevention.Id));
         }
         return true;
     }
     return false;
 }
        public InspectTask GetInspectTask(string taskNumber)
        {
            var taskService = new TaskService();
            task task = taskService.FindByTaskNumber(taskNumber);

            if (task == null)
            {
                return null;
            }
            var taskEmployeeService = new TaskEmployeeService();
            var taskPigHouseService = new TaskPigHouseService();
            var checkTask = new InspectTask
                                {
                                    TaskNumber = task.TaskNumber,
                                    StartTime = task.StartTime,
                                    EndTime = task.EndTime,
                                    EmployeeName = taskEmployeeService.GetEmployeeNames(task.Id),
                                    EmployeeNumber = taskEmployeeService.GetEmployeeNumbers(task.Id),
                                    PigHouse = taskPigHouseService.GetPigHouseTypeAndNumsByTaskId(task.Id),
                                    PigHouseId = taskPigHouseService.GetPigHouseIds(task.Id),
                                    Status = task.task_status_type.Name,
                                    Memo = task.Memo
                                };

            List<TaskCycle> taskCycle = task.task_interval_cycle.Select(taskCycleitem => new TaskCycle
                                                                                             {
                                                                                                 FirstExecuteDate
                                                                                                     =
                                                                                                     taskCycleitem
                                                                                                     .
                                                                                                     FirstExecuteDate,
                                                                                                 CycleDays
                                                                                                     =
                                                                                                     taskCycleitem
                                                                                                     .
                                                                                                     CycleDays
                                                                                             }).ToList();
            if (taskCycle.Count != 0)
            {
                checkTask.InspectTaskCycle = taskCycle;
            }
            return checkTask;
        }
 /// <summary>
 ///     治疗任务的姓名的下拉列表框
 /// </summary>
 /// <returns></returns>
 public IEnumerable<SelectListItem> GetCureTaskEmployee()
 {
     var taskService = new TaskService();
     var tasktypeService = new TaskTypeService();
     var taskEmployeeService = new TaskEmployeeService();
     long curetaskid = tasktypeService.FindByName("治疗").Id;
     List<task> tasks = taskService.FindByTaskTypeId(curetaskid);
     List<task_employee> taskEmployees =
         tasks.SelectMany(task => taskEmployeeService.FindByTaskId(task.Id)).ToList();
     if (taskEmployees.Count >= 2)
     {
         for (int i = 0; i < taskEmployees.Count; i++)
         {
             task_employee employee = taskEmployees[i];
             for (int j = i + 1; j < taskEmployees.Count; j++)
             {
                 if (taskEmployees[j].employee.Name.Equals(employee.employee.Name))
                 {
                     taskEmployees.Remove(taskEmployees[j]);
                 }
             }
         }
     }
     IEnumerable<SelectListItem> feedTaskEmployeelist = taskEmployees.Select(taskEmployee => new SelectListItem
                                                                                                 {
                                                                                                     Text =
                                                                                                         taskEmployee
                                                                                                         .
                                                                                                         employee
                                                                                                         .Name,
                                                                                                     Value =
                                                                                                         taskEmployee
                                                                                                             .
                                                                                                             employee
                                                                                                             .Id +
                                                                                                         string.
                                                                                                             Empty,
                                                                                                 })
                                                                     .OrderBy(m => m.Text);
     return feedTaskEmployeelist;
 }
Exemple #11
0
        /// <summary>
        ///     查看销售任务
        /// </summary>
        /// <param name="taskNumber">任务编号</param>
        /// <returns></returns>
        public SaleTask GetSaleTask(string taskNumber)
        {
            var taskService = new TaskService();
            var taskEmployeeService = new TaskEmployeeService();
            var pigTypeService = new PigTypeService();

            task task = taskService.FindByTaskNumber(taskNumber);

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

            var customerService = new CustomerService();
            var checkTask = new SaleTask
                                {
                                    TaskNumber = task.TaskNumber,
                                    StartTime = task.StartTime,
                                    EndTime = task.EndTime,
                                    EmployeeName = taskEmployeeService.GetEmployeeNames(task.Id),
                                    EmployeeNumber = taskEmployeeService.GetEmployeeNumbers(task.Id),
                                    Customer = customerService.Find(task.CustomerId).Name,
                                    Status = task.task_status_type.Name,
                                    Memo = task.Memo
                                };

            List<SaleDetail> saleDetailList = task.sale_task_quality.Select(item => new SaleDetail
                                                                                        {
                                                                                            PigType =
                                                                                                pigTypeService.Find(
                                                                                                    item.PigTypeId).Name,
                                                                                            Price = item.Price,
                                                                                            Quantity = item.Quality
                                                                                        }).ToList();

            if (saleDetailList.Count != 0)
            {
                checkTask.SaleDetailList = saleDetailList;
            }
            return checkTask;
        }
 public ActionResult FodderTakeConfirm(FodderTakeModel model)
 {
     var fodderTakeService = new FodderTakeService();
     var taskService = new TaskService();
     FodderTakeModel newModel = new FodderDetail().GetFodderDetail(model);
     foreach (FodderDetail actualDetail in model.ActualDetail)
     {
         var newFodderTake = new fodder_take
                                 {
                                     EmployeeId = model.ActualEmployeeId,
                                     TaskId = taskService.FindByTaskNumber(newModel.TaskNumber).Id,
                                     FodderTypeId = actualDetail.FodderTypeId,
                                     Quantity = actualDetail.Quality,
                                     UnitId = actualDetail.UnitId,
                                     Time = Convert.ToDateTime(DateTime.Now),
                                     Memo = model.Memo
                                 };
         fodderTakeService.Insert(newFodderTake);
     }
     return View();
 }
        /// <summary>
        ///     查看防疫信息
        /// </summary>
        /// <param name="taskNumber">任务编号</param>
        /// <returns></returns>
        public PreventionInfo CheckPreventionInfo(string taskNumber, string employeeName)
        {
            var preventionService = new PreventionService();
            var checkPreventionInfo = new PreventionInfo();
            checkPreventionInfo.PreventionInfoDetail = new List<Detail>();
            var taskService = new TaskService();
            task task = taskService.FindByTaskNumber(taskNumber);
            if (task == null) return null;
            task_prevention firstOrDefault = task.task_prevention.FirstOrDefault();
            if (firstOrDefault != null)
            {
                checkPreventionInfo.TaskNumber = taskNumber;
                checkPreventionInfo.EmployeeName = employeeName;
                checkPreventionInfo.DiseaseName = firstOrDefault.prevention_type.Name;
                checkPreventionInfo.Medicine = firstOrDefault.prevention_type.medicine.Name;
                checkPreventionInfo.Quality = firstOrDefault.prevention_type.Quality;
                checkPreventionInfo.Unit = firstOrDefault.prevention_type.unit1.Name;
            }

            foreach (
                prevention preventionItem in
                    preventionService.FindByTaskId(task.Id).Where(m => m.employee.Name.Equals(employeeName)))
            {
                checkPreventionInfo.PreventionInfoDetail.Add(new Detail
                                                                 {
                                                                     PigHouse =
                                                                         preventionItem.pigsty.pig_house.pig_house_type.
                                                                                        Name
                                                                         + preventionItem.pigsty.pig_house.Number,
                                                                     Pigsty = preventionItem.pigsty.Number + "",
                                                                     DetailTime = preventionItem.Time
                                                                 });
            }

            return checkPreventionInfo;
        }
        /// <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;
        }
 /// <summary>
 ///     新建防疫信息
 /// </summary>
 /// <param name="newInfo"></param>
 /// <returns></returns>
 public bool CreateTransferPigstyInfo(PreventionInfo newInfo)
 {
     if (newInfo == null) return false;
     var preventionService = new PreventionService();
     var taskStatusTypeService = new TaskStatusTypeService();
     var taskService = new TaskService();
     foreach (Detail newInfoItem in newInfo.PreventionInfoDetail)
     {
         preventionService.Insert(new prevention
                                      {
                                          TaskId = long.Parse(newInfo.TaskNumber),
                                          EmployeeId = long.Parse(newInfo.EmployeeName),
                                          PigstyId = long.Parse(newInfoItem.Pigsty),
                                          Time = newInfoItem.DetailTime,
                                          Memo = newInfo.Meno
                                      });
     }
     task_status_type taskStatusType = taskStatusTypeService.FindByName("已完成");
     task task = taskService.Find(long.Parse(newInfo.TaskNumber));
     if (taskStatusType != null && task != null)
     {
         task.TaskStatusId = taskStatusType.Id;
         taskService.Update(task);
     }
     return true;
 }
        /// <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;
        }
        public bool UpdateEliminateTask(EliminateTask updateTask)
        {
            var taskService = new TaskService();
            var taskStatusTypeService = new TaskStatusTypeService();
            task task = taskService.FindByTaskNumber(updateTask.TaskNumber);
            if (task == null)
            {
                return false;
            }
            task.StartTime = updateTask.StartTime;
            task.EndTime = updateTask.EndTime;
            task.Memo = updateTask.Memo;

            new TaskEmployeeService().UpdateByNumberStr(task, updateTask.EmployeeNumber);
            var pigService = new PigService();
            int oldLen = task.task_pig.Count+task.task_pigsty.Count;
            int newLen = updateTask.EliminateTaskDetail.Count;
            int leastLength = oldLen < newLen ? oldLen : newLen;

            for (int i = 0; i < leastLength; i++)
            {
                if (updateTask.EliminateTaskDetail[i].Pig!=null)
                task.task_pig.ElementAt(i).PigId = pigService.FindByRfid(updateTask.EliminateTaskDetail[i].Pig).Id;
                else
                    task.task_pigsty.ElementAt(i).PigstyId = long.Parse(updateTask.EliminateTaskDetail[i].Pigsty);
            }

            var taskPigService = new TaskPigService();

            for (int i = leastLength; i < oldLen; i++)
            {
                if (task.task_pig.Count>0)
                taskPigService.Delete(taskPigService.Find(task.task_pig.ElementAt(i).Id));
                else if (task.task_pigsty.Count > 0)
                    taskPigService.Delete(taskPigService.Find(task.task_pigsty.ElementAt(i).Id));
            }

            for (int i = leastLength; i < newLen; i++)
            {
                if (updateTask.EliminateTaskDetail[i].Pig!=null)
                task.task_pig.Add(new task_pig
                {
                    PigId = pigService.FindByRfid(updateTask.EliminateTaskDetail[i].Pig).Id
                });
                else
                    task.task_pigsty.Add(new task_pigsty
                    {
                         PigstyId = long.Parse(updateTask.EliminateTaskDetail[i].Pigsty)
                    });
            }

            try
            {

                task.TaskStatusId = long.Parse(updateTask.Status);
                taskService.Update(task);
                return true;
            }
            catch (Exception)
            {
                return false;
            }
        }
        public MedicineTakeModel GetCureTaskByEmployeeId(long employeeId)
        {
            var medicineTakeModel = new MedicineTakeModel();

            var tasktypeService = new TaskTypeService();
            var taskEmployeeService = new TaskEmployeeService();
            var taskService = new TaskService();
            var cureTaskMethodService = new CureTaskMethodService();
            var cureTaskCourseService = new CureTaskCourseService();
            var cureTaskMedicineService = new CureTaskMedicineService();
            int taskflag = 0;
            long employeeTaskId = 0;
            long cureCourseId = 0;
            List<task_employee> alltask = taskEmployeeService.FindByEmployeeId(employeeId);
            //根据任务id找到任务类型,若是当天的治疗任务,记录taskid
            foreach (task_employee task in alltask)
            {
                long tasktypeid = taskService.Find(task.TaskId).TaskTypeId;
                string tasktype = tasktypeService.Find(tasktypeid).Name;
                if (tasktype == "治疗")
                {
                    //判断当前记录的时间是否和任务中某一个疗程的开始时间相同,若是,则代表当天有治疗任务
                    List<cure_task_course> cureTaskCourses = cureTaskCourseService.FindByTaskId(task.TaskId);
                    foreach (cure_task_course cureTaskCourse in cureTaskCourses)
                    {
                        if (cureTaskCourse.Time.ToShortDateString() == DateTime.Now.ToShortDateString())
                        {
                            taskflag = 1;
                            employeeTaskId = task.TaskId;
                            cureCourseId = cureTaskCourse.Id;
                            medicineTakeModel.TaskCourseId = cureCourseId;
                        }
                    }
                }
            }
            if (taskflag == 1)
            {
                List<cure_task_method> cureTaskMethods = cureTaskMethodService.FindByCureTaskCourseId(cureCourseId);
                var cureDetails = new List<CureDetail>();
                CureDetail cureDetail = null;
                medicineTakeModel.CureTaskType = cureDetails;
                foreach (cure_task_method cureTaskMethod in cureTaskMethods)
                {
                    cureDetail = new CureDetail();
                    cureDetail.CureType = cureTaskMethod.cure_type.Name;
                    cureDetails.Add(cureDetail);
                    var cureMedicineDetails = new List<CureMedicineDetail>();
                    cureDetail.CureMedicineDetail = cureMedicineDetails;
                    CureMedicineDetail cureMedicineDetail = null;
                    List<cure_task_medicine> cureTaskMedicines =
                        cureTaskMedicineService.FindByCureTaskMethodId(cureTaskMethod.Id);
                    foreach (cure_task_medicine cureTaskMedicine in cureTaskMedicines)
                    {
                        cureMedicineDetail = new CureMedicineDetail();
                        cureMedicineDetail.Medicine = cureTaskMedicine.medicine.Name;
                        cureMedicineDetail.Quality = cureTaskMedicine.Quality;
                        cureMedicineDetail.Unit = cureTaskMedicine.unit.Name;
                        cureMedicineDetails.Add(cureMedicineDetail);
                    }
                }

                medicineTakeModel.TaskNumber = taskService.Find(employeeTaskId).TaskNumber;
                List<task_employee> allemployees = taskEmployeeService.FindByTaskId(employeeTaskId);
                int i;
                string reAllEmployeeName = "";
                for (i = 0; i < allemployees.Count - 1; i++)
                {
                    reAllEmployeeName = reAllEmployeeName + allemployees[i].employee.Name + ",";
                }
                reAllEmployeeName = reAllEmployeeName + allemployees[i].employee.Name;
                medicineTakeModel.EmloyeeName = reAllEmployeeName;
            }
            return medicineTakeModel;
        }
Exemple #19
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;
        }
Exemple #20
0
        /// <summary>
        ///     修改喂食任务
        /// </summary>
        /// <param name="updateTask"></param>
        /// <returns></returns>
        public bool UpdateFeedTask(FeedTask updateTask)
        {
            var taskService = new TaskService();
            var pigstyService = new PigstyService();
            var taskQualityService = new FeedTaskQualityService();
            var taskIntervalCycleService = new TaskIntervalCycleService();
            task task = taskService.FindByTaskNumber(updateTask.TaskNumber);
            task.StartTime = updateTask.StartTime;
            task.EndTime = updateTask.EndTime;
            task.TaskStatusId = long.Parse(updateTask.Status);
            task.Memo = updateTask.Memo;

            //修改喂食任务的喂食人员
            new TaskEmployeeService().UpdateByNumberStr(task, updateTask.EmployeeNumber);

            var pigstyFodders = new Dictionary<long, string>();

            foreach (FeedTaskDetail detail in updateTask.Feeddetails)
            {
                string fodder = detail.Fodder;
                foreach (string s in detail.Pigsty.Split(','))
                {
                    pigstyFodders.Add(pigstyService.GetPigsty(int.Parse(s), long.Parse(detail.PigHouse)).Id, fodder);
                }
            }

            int oldLen = task.task_pigsty.Count;
            int newLen = pigstyFodders.Count;
            int leastLen = oldLen < newLen ? oldLen : newLen;

            var fodderTypeService = new FodderTypeService();

            for (int i = 0; i < leastLen; i++)
            {
                KeyValuePair<long, string> pigstyFodder = pigstyFodders.ElementAt(i);
                task.task_pigsty.ElementAt(i).PigstyId = pigstyFodder.Key;
                string[] fodders = pigstyFodder.Value.Split(',');
                int oldLength = task.task_pigsty.ElementAt(i).feed_task_quality.Count;
                int newLength = fodders.Count();
                int leastLength = oldLength < newLength ? oldLength : newLength;

                for (int j = 0; j < leastLength; j++)
                {
                    task.task_pigsty.ElementAt(i).feed_task_quality.ElementAt(j).FodderTypeId =
                        fodderTypeService.FindByName(fodders[j]).Id;
                }
                for (int j = leastLength; j < oldLength; j++)
                {
                    taskQualityService.Delete(
                        taskQualityService.Find(task.task_pigsty.ElementAt(i).feed_task_quality.ElementAt(j).Id));
                }
                for (int j = leastLength; j < newLength; j++)
                {
                    task.task_pigsty.ElementAt(i).feed_task_quality.Add(new feed_task_quality
                                                                            {
                                                                                FodderTypeId =
                                                                                    fodderTypeService.FindByName(
                                                                                        fodders[j]).Id
                                                                            });
                }
            }

            var taskPigstyService = new TaskPigstyService();

            for (int i = leastLen; i < oldLen; i++)
            {
                task_pigsty taskPigsty = task.task_pigsty.ElementAt(i);
                foreach (feed_task_quality feedTaskQuality in taskPigsty.feed_task_quality)
                {
                    taskQualityService.Delete(taskQualityService.Find(feedTaskQuality.Id));
                }
                taskPigstyService.Delete(taskPigstyService.Find(taskPigsty.Id));
            }

            for (int i = leastLen; i < newLen; i++)
            {
                KeyValuePair<long, string> pigstyFodder = pigstyFodders.ElementAt(i);
                var taskPigsty = new task_pigsty
                                     {
                                         PigstyId = pigstyFodder.Key
                                     };
                foreach (string item in pigstyFodder.Value.Split(','))
                {
                    taskPigsty.feed_task_quality.Add(new feed_task_quality
                                                         {
                                                             FodderTypeId = fodderTypeService.FindByName(item).Id
                                                         });
                }
                task.task_pigsty.Add(taskPigsty);
            }

            taskService.Update(task);
            for (int i = 0; i < updateTask.FeedTaskCycle.Count; i++)
            {
                if (i < task.task_interval_cycle.Count)
                {
                    task_interval_cycle updateitem = taskIntervalCycleService.FindByTaskId(task.Id)[i];
                    updateitem.CycleDays = updateTask.FeedTaskCycle.ToList()[i].CycleDays;
                    updateitem.FirstExecuteDate = updateTask.FeedTaskCycle.ToList()[i].FirstExecuteDate;
                    taskIntervalCycleService.Update(updateitem);
                }
                else
                {
                    var updateitem = new task_interval_cycle
                                         {
                                             TaskId = task.Id,
                                             CycleDays = updateTask.FeedTaskCycle.ToList()[i].CycleDays,
                                             FirstExecuteDate = updateTask.FeedTaskCycle.ToList()[i].FirstExecuteDate
                                         };
                    taskIntervalCycleService.Insert(updateitem);
                }
            }
            taskIntervalCycleService.DelTaskIntervalCycle(task, updateTask.FeedTaskCycle.Count);
            return true;
        }
 /// <summary>
 ///     根据id查找当天是否有治疗任务
 /// </summary>
 /// <param name="employeeId">人员id</param>
 /// <returns>返回是否当天有治疗任务</returns>
 public string GetCureTaskById(long employeeId)
 {
     var tasktypeService = new TaskTypeService();
     var taskEmployeeService = new TaskEmployeeService();
     var taskService = new TaskService();
     var cureTaskCourseService = new CureTaskCourseService();
     int taskflag = 0;
     List<task_employee> alltask = taskEmployeeService.FindByEmployeeId(employeeId);
     //根据任务id找到任务类型,若是当天的治疗任务,记录taskid
     foreach (task_employee task in alltask)
     {
         long tasktypeid = taskService.Find(task.TaskId).TaskTypeId;
         string tasktype = tasktypeService.Find(tasktypeid).Name;
         if (tasktype == "治疗")
         {
             //判断当前记录的时间是否和任务中某一个疗程的开始时间相同,若是,则代表当天有治疗任务
             List<cure_task_course> cureTaskCourses = cureTaskCourseService.FindByTaskId(task.TaskId);
             foreach (cure_task_course cureTaskCourse in cureTaskCourses)
             {
                 if (cureTaskCourse.Time.ToShortDateString() == DateTime.Now.ToShortDateString())
                 {
                     taskflag = 1;
                 }
             }
         }
     }
     if (taskflag == 1)
     {
         return "1";
     }
     return "2";
 }
        public ActionResult NewDeadInfo()
        {
            if (Session["CheckDeadInfo"] == null || !(bool)Session["AddDeadInfo"] || !(bool)Session["CheckDeadInfo"])
            {
                Response.Write("<script>history.go(0);</script>");
                return View("Error");
            }

            var newInfo = new DeadInfo();
            var taskService = new TaskService();
            if (!newInfo.GetTaskNumberSelect(TaskTypeId).Any())
            {
                const string returnstring = "淘汰任务的生产信息已全部导入";
                Response.Write("<script language='JavaScript'>alert('" + returnstring + ".');history.go(-1);</script>");
                return Content("");
            }

            SelectListItem firstOrDefault = newInfo.GetTaskNumberSelect(TaskTypeId).FirstOrDefault();
            var pighouse = new ListService().GetPigHouseList();
            var pigsty = new ListService().FindPigstyListByPigHouseId(pighouse.FirstOrDefault().Value);

            ViewData["TaskNumber"] = newInfo.GetTaskNumberSelect(TaskTypeId);
            ViewData["Employee"] = new ListService().GetEmployeeList();
            ViewData["pighouse"] = pighouse;
            ViewData["pigsty"] = pigsty;
            ViewData["pig"] = new ListService().FindPigListByPigstyId(pigsty.FirstOrDefault().Value);
            ViewBag.Title = "新建死亡信息";
            return View(newInfo);
        }
        public bool UpdateInspectTask(InspectTask updateTask)
        {
            var taskService = new TaskService();
            task task = taskService.FindByTaskNumber(updateTask.TaskNumber);
            task.StartTime = updateTask.StartTime;
            task.EndTime = updateTask.EndTime;
            task.Memo = updateTask.Memo;
            taskService.Update(task);

            //修改喂食任务的喂食人员
            new TaskEmployeeService().UpdateByNumberStr(task, updateTask.EmployeeNumber);
            new TaskPigHouseService().UpdateByPigHouseStr(task, updateTask.PigHouseId);

            var taskIntervalCycleService = new TaskIntervalCycleService();
            for (int i = 0; i < updateTask.InspectTaskCycle.Count; i++)
            {
                if (i < task.task_interval_cycle.Count)
                {
                    task_interval_cycle updateitem = taskIntervalCycleService.FindByTaskId(task.Id)[i];
                    updateitem.CycleDays = updateTask.InspectTaskCycle.ToList()[i].CycleDays;
                    updateitem.FirstExecuteDate = updateTask.InspectTaskCycle.ToList()[i].FirstExecuteDate;
                    taskIntervalCycleService.Update(updateitem);
                }
                else
                {
                    var updateitem = new task_interval_cycle
                                         {
                                             TaskId = task.Id,
                                             CycleDays = updateTask.InspectTaskCycle.ToList()[i].CycleDays,
                                             FirstExecuteDate = updateTask.InspectTaskCycle.ToList()[i].FirstExecuteDate
                                         };
                    taskIntervalCycleService.Insert(updateitem);
                }
            }
            taskIntervalCycleService.DelTaskIntervalCycle(task, updateTask.InspectTaskCycle.Count);
            return true;
        }
Exemple #24
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;
        }
 /// <summary>
 ///     喂饲任务的任务编号的下拉列表框
 /// </summary>
 /// <returns></returns>
 public IEnumerable<SelectListItem> GetFeedTaskNumber()
 {
     var taskService = new TaskService();
     var tasktypeService = new TaskTypeService();
     long feedtaskid = tasktypeService.FindByName("喂饲").Id;
     List<task> feedtasks = taskService.FindByTaskTypeId(feedtaskid);
     IEnumerable<SelectListItem> feedTaskSelect = feedtasks.Select(feedtask => new SelectListItem
                                                                                   {
                                                                                       Text = feedtask.TaskNumber,
                                                                                       Value =
                                                                                           feedtask.Id +
                                                                                           string.Empty,
                                                                                   }).OrderBy(m => m.Text);
     return feedTaskSelect;
 }
 /// <summary>
 ///     删除淘汰的相关信息
 /// </summary>
 /// <param name="taskNumber">任务编号</param>
 /// <returns></returns>
 public bool DelEliminateInfo(string taskNumber)
 {
     var salesService = new SaleService();
     var salePigService = new SalePigService();
     var taskStatusTypeService = new TaskStatusTypeService();
     var pigInfo = new PigInfo();
     task task = new TaskService().FindByTaskNumber(taskNumber);
     if (task == null) return false;
     foreach (sale sale in salesService.FindByTaskId(task.Id))
     {
         foreach (sale_pig EliminatePig in salePigService.FindBySaleId(sale.Id))
         {
             salePigService = new SalePigService();
             salePigService.Delete(salePigService.Find(EliminatePig.Id));
             pigInfo.SetState(EliminatePig.Id, false);
         }
         salesService = new SaleService();
         salesService.Delete(salesService.Find(sale.Id));
     }
      task_status_type taskStatusType = taskStatusTypeService.FindByName("已完成");
      task.TaskStatusId = taskStatusType.Id;
     return true;
 }
        /// <summary>
        ///     修改防疫信息
        /// </summary>
        /// <param name="updateInfo">防疫页面信息</param>
        /// <returns></returns>
        public bool UpdatePreventionInfo(PreventionInfo updateInfo)
        {
            var preventionService = new PreventionService();
            var taskService = new TaskService();
            task task = taskService.FindByTaskNumber(updateInfo.TaskNumber);
            int count = 0;
            if (task != null)
            {
                foreach (prevention prevention in preventionService.FindByTaskId(task.Id))
                {
                    if (count < updateInfo.PreventionInfoDetail.Count)
                    {
                        prevention.PigstyId = long.Parse(updateInfo.PreventionInfoDetail[count].Pigsty);
                        prevention.EmployeeId = long.Parse(updateInfo.EmployeeName);
                        prevention.Time = updateInfo.PreventionInfoDetail[count].DetailTime;
                        prevention.Memo = updateInfo.Meno;
                        preventionService.Update(prevention);
                    }
                    else
                    {
                        preventionService = new PreventionService();
                        preventionService.Delete(preventionService.Find(prevention.Id));
                    }
                    count++;
                }
                for (; count < updateInfo.PreventionInfoDetail.Count; count++)
                {
                    preventionService.Insert(new prevention
                                                 {
                                                     PigstyId =
                                                         long.Parse(updateInfo.PreventionInfoDetail[count].Pigsty),
                                                     EmployeeId = long.Parse(updateInfo.EmployeeName),
                                                     Time = updateInfo.PreventionInfoDetail[count].DetailTime,
                                                     Memo = updateInfo.Meno
                                                 });
                }
                return true;
            }

            return false;
        }
        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;
        }
        /// <summary>
        ///     根据id返回是否有喂饲任务
        /// </summary>
        /// <param name="employeeId">人员id</param>
        /// <returns>返回是否有喂饲任务</returns>
        public string GetFeedTaskById(long employeeId)
        {
            var tasktypeService = new TaskTypeService();
            var taskEmployeeService = new TaskEmployeeService();
            var taskIntervalCycleService = new TaskIntervalCycleService();
            int taskflag = 0;

            var taskService = new TaskService();
            List<task_employee> alltask = taskEmployeeService.FindByEmployeeId(employeeId);
            //根据任务id找到任务类型,若是当天的喂饲任务,记录taskid
            foreach (task_employee task in alltask)
            {
                long tasktypeid = taskService.Find(task.TaskId).TaskTypeId;
                string tasktype = tasktypeService.Find(tasktypeid).Name;
                if (tasktype == "喂饲")
                {
                    List<task_interval_cycle> taskInterval = taskIntervalCycleService.FindByTaskId(task.TaskId);
                    foreach (task_interval_cycle taskinterval in taskInterval)
                    {
                        for (int i = 0; i < 1000; i++)
                        {
                            //根据任务的循环时间匹配是否有当天的任务
                            if (
                                taskinterval.FirstExecuteDate.AddDays(Convert.ToDouble(taskinterval.CycleDays * i))
                                            .
                                             ToShortDateString() == DateTime.Now.ToShortDateString())
                            {
                                taskflag = 1; //标志
                                break;
                            }
                        }
                    }
                }
            }
            if (taskflag == 0)
            {
                return "今天该员工没有喂饲任务";
            }
            return "";
        }
        /// <summary>
        ///     更新修改淘汰信息
        /// </summary>
        /// <param name="updateInfo">淘汰信息页面类</param>
        /// <returns></returns>
        public bool UpdateEliminateInfo(EliminateInfo updateInfo)
        {
            var salesService = new SaleService();
            var salePigService = new SalePigService();
            task task = new TaskService().FindByTaskNumber(updateInfo.TaskNumber);
            var pigInfo = new PigInfo();
            int count = 0;
            if (task == null) return false;
            foreach (sale sale in salesService.FindByTaskId(task.Id))
            {
                sale.EmployeeId = long.Parse(updateInfo.EmployeeName);
                sale.Memo = updateInfo.Meno;
                salesService.Update(sale);
                List<sale_pig> saleList = salePigService.FindBySaleId(sale.Id);
                foreach (sale_pig salePig in saleList)
                {
                    pigInfo.SetState(salePig.PigId, false);
                    if (count < updateInfo.EliminateInfoPigDetail.Count)
                    {
                        salePig.PigId =
                            long.Parse(updateInfo.EliminateInfoPigDetail[count].Pig);
                        salePig.Time = updateInfo.EliminateInfoPigDetail[count].DetailTime;
                        salePigService.Update(salePig);
                        pigInfo.SetState(long.Parse(updateInfo.EliminateInfoPigDetail[count].Pig), true);
                    }
                    else
                    {
                        salePigService = new SalePigService();
                        salePigService.Delete(salePigService.Find(salePig.Id));
                    }
                    count++;
                }
                for (; count < updateInfo.EliminateInfoPigDetail.Count; count++)
                {
                    salePigService.Insert(new sale_pig
                    {
                        SaleId = sale.Id,
                        PigId = long.Parse(updateInfo.EliminateInfoPigDetail[count].Pig),
                        Time = updateInfo.EliminateInfoPigDetail[count].DetailTime
                    });
                    pigInfo.SetState(long.Parse(updateInfo.EliminateInfoPigDetail[count].Pig), true);
                }
            }

            return true;
        }