public string SaleDataImport(TaskImportModel taskImportModel, string memo)
        {
            int taskflag = 0; //标志,判断当天是否有销售任务
            long employeeId = _employeeService.FindByNumber(taskImportModel.EmployeeNumber).Id;
            List<task_employee> taskEmployee = _taskEmployeeService.FindByEmployeeId(employeeId);
            if (taskEmployee != null)
            {
                long taskId = JudgeHaveTask(taskEmployee, taskImportModel.TaskType, taskImportModel);
                if (taskId != 0)
                {
                    taskImportModel.TaskNumber = _taskService.Find(taskId).TaskNumber;
                    taskflag = 1;
                }
            }
            //若有当天的销售的任务,才插入数据库
            if (taskflag == 1)
            {
                int saleflag = 0; //用来判断销售单是否已存在于sale这张表中
                List<sale> salelistflags = _saleService.FindAll();
                foreach (sale salelistflag in salelistflags)
                {
                    if (salelistflag.EmployeeId == _taskService.FindByTaskNumber(taskImportModel.TaskNumber).Id &&
                        salelistflag.EmployeeId == employeeId)
                    {
                        saleflag = 1;
                    }
                }
                //如果sale中还没有该员工的销售单,则将其插入
                if (saleflag == 0)
                {
                    var sale = new sale
                                   {
                                       EmployeeId = employeeId,
                                       TaskId = _taskService.FindByTaskNumber(taskImportModel.TaskNumber).Id
                                   };
                    _saleService.Insert(sale);
                }
                foreach (RawDataDetail detail in taskImportModel.RawDataDetails)
                {
                    long saleId = 0;
                    List<sale> saleslist = _saleService.FindAll();
                    //首先从sale表中获得该人员的销售id
                    foreach (sale salelist in saleslist)
                    {
                        if (salelist.EmployeeId == employeeId &&
                            salelist.TaskId == _taskService.FindByTaskNumber(taskImportModel.TaskNumber).Id)
                        {
                            saleId = salelist.Id;
                        }
                    }
                    //将所有的猪的销售Id插入到salepig表中
                    if (detail.PigHouseId != 0 && detail.PigstyId != 0 && detail.PigId != 0)
                    {
                        var salepig = new sale_pig
                                          {
                                              SaleId = saleId,
                                              PigId = detail.PigId,
                                              Time = detail.Time,
                                              Memo = memo
                                          };
                        _salePigService.Insert(salepig);
                        pig pig = _pigService.Find(detail.PigId);
                        pig.State = true;
                        _pigService.Update(pig);
                        sale modifysale = new sale();
                        modifysale.TaskId = _taskService.FindByTaskNumber(taskImportModel.TaskNumber).Id;
                        modifysale.EmployeeId = employeeId;
                        modifysale.SaleType = "销售";
                        _saleService.Insert(modifysale);
                    }
                }
                //修改任务状态
                task task = _taskService.FindByTaskNumber(taskImportModel.TaskNumber);
                if (task.EndTime != null)
                {
                    if (task.EndTime <= taskImportModel.EndTime)
                    {
                        task.TaskStatusId = 3;
                    }
                    else
                    {
                        task.TaskStatusId = 2;
                    }
                }
                else
                {
                    task.TaskStatusId = 3;
                }
                _taskService.Update(task);
            }
            else
            {
                return "请确保" + taskImportModel.EmployeeName + "的任务是否选择正确,或者该员工没有" + taskImportModel.TaskType + "的任务";
            }

            return "";
        }
        /// <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;
        }
        public string EliminateDataImport(TaskImportModel taskImportModel, string memo)
        {
            int taskflag = 0; //标志,判断当天是否有淘汰任务
            long employeeId = _employeeService.FindByNumber(taskImportModel.EmployeeNumber).Id;
            List<task_employee> taskEmployee = _taskEmployeeService.FindByEmployeeId(employeeId);
            if (taskEmployee != null)
            {
                long taskId = JudgeHaveTask(taskEmployee, taskImportModel.TaskType, taskImportModel);
                if (taskId != 0)
                {
                    taskImportModel.TaskNumber = _taskService.Find(taskId).TaskNumber;
                    taskflag = 1;
                }
            }
            //若有当天的淘汰的任务,才修改生猪的状态
            if (taskflag == 1)
            {
                foreach (RawDataDetail detail in taskImportModel.RawDataDetails)
                {
                    pig modifypig = _pigService.Find(detail.PigId);
                    modifypig.State = true;
                    _pigService.Update(modifypig);
                    sale modifysale = new sale();
                    modifysale.TaskId = _taskService.FindByTaskNumber(taskImportModel.TaskNumber).Id;
                    modifysale.EmployeeId = employeeId;
                    modifysale.SaleType = "淘汰";
                    _saleService.Insert(modifysale);

                }
                    //修改任务状态
                    task task = _taskService.FindByTaskNumber(taskImportModel.TaskNumber);
                    if (task.EndTime != null)
                    {
                        if (task.EndTime <= taskImportModel.EndTime)
                        {
                            task.TaskStatusId = 3;
                        }
                        else
                        {
                            task.TaskStatusId = 2;
                        }
                    }
                    else
                    {
                        task.TaskStatusId = 3;
                    }
                    _taskService.Update(task);

            }
            else
            {
                return "请确保" + taskImportModel.EmployeeName + "的任务是否选择正确,或者该员工没有" + taskImportModel.TaskType + "的任务";
            }

            return "";
        }