/// <summary>
        ///     更新任务的人员
        /// </summary>
        /// <param name="task">任务类</param>
        /// <param name="numbers">员工名字的字符串数组</param>
        public void UpdateByNumber(task task, string[] numbers)
        {
            int oldLen = task.task_employee.Count;
            int newLen = numbers.Length;
            int leastLength = oldLen < newLen ? oldLen : newLen;

            var employeeService = new EmployeeService();
            var taskEmployeeService = new TaskEmployeeService();

            for (int i = 0; i < leastLength; i++)
            {
                task_employee updateitem = taskEmployeeService.FindByTaskId(task.Id)[i];
                updateitem.EmployeeId = employeeService.FindByNumber(numbers[i]).Id;
                taskEmployeeService.Update(updateitem);
            }

            for (int i = leastLength; i < oldLen; i++)
            {
                taskEmployeeService.Delete(taskEmployeeService.Find(task.task_employee.ElementAt(i).Id));
            }

            for (int i = leastLength; i < newLen; i++)
            {
                taskEmployeeService.Insert(new task_employee
                                               {
                                                   TaskId = task.Id,
                                                   EmployeeId = employeeService.FindByNumber(numbers[i]).Id
                                               });
            }
        }
Beispiel #2
0
        /// <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();
        }
Beispiel #3
0
 /// <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;
 }
        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;
        }
        public FodderTakeModel GetFodderDetail(FodderTakeModel model)
        {
            //初始化
            var newFodderDetails = new List<FodderDetail>();
            //var newFodderDetail=new FodderDetail();
            //newFodderDetails.Add(newFodderDetail);
            model.TaskDetail = newFodderDetails;

            var pigstyService = new PigstyService();
            var tasktypeService = new TaskTypeService();
            var taskEmployeeService = new TaskEmployeeService();
            var taskpigstyservice = new TaskPigstyService();
            var feedTaskQualityService = new FeedTaskQualityService();
            var taskIntervalCycleService = new TaskIntervalCycleService();
            int taskflag = 0;
            long employeeTaskId = 0;
            var taskService = new TaskService();
            List<task_employee> alltask = taskEmployeeService.FindByEmployeeId(model.ActualEmployeeId);
            //根据任务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; //标志
                                employeeTaskId = task.TaskId;
                                break;
                            }
                        }
                    }
                }
            }
            if (taskflag == 1)
            {
                List<task_pigsty> taskPisties = taskpigstyservice.FindByTaskId(employeeTaskId);

                //遍历该任务的所有的猪栏,并将其对应的饲料添加到model.TaskDetail中
                int i;
                foreach (task_pigsty taskPigsty in taskPisties)
                {
                    List<feed_task_quality> taskQuality = feedTaskQualityService.FindByFeedTaskPigstyId(taskPigsty.Id);
                    if (model.TaskDetail.Count == 0)
                    {
                        var fodderDetail = new FodderDetail
                                               {
                                                   FodderTypeName = taskQuality[0].fodder_type.Name,
                                                   //Quality = taskQuality[0].Quality * pigstyService.GetPignumbers(Convert.ToInt64(taskPigsty.PigstyId)),
                                                   //UnitName = taskQuality[0].unit.Name,
                                                   FodderTypeId = taskQuality[0].FodderTypeId,
                                                   //UnitId = taskQuality[0].UnitId
                                               };
                        model.TaskDetail.Add(fodderDetail);
                    }
                    else
                    {
                        int knt = 0; //判断该猪栏的饲料是否跟
                        for (i = 0; i < model.TaskDetail.Count; i++)
                        {
                            if (model.TaskDetail[i].FodderTypeName == taskQuality[0].fodder_type.Name)
                            {
                                //model.TaskDetail[i].Quality = taskQuality[0].Quality*
                                //                              pigstyService.GetPignumbers(
                                //                                  Convert.ToInt64(taskPigsty.PigstyId)) +
                                //                              model.TaskDetail[i].Quality;
                                knt = 1;
                            }
                        }
                        if (knt == 0)
                        {
                            var fodderDetail = new FodderDetail
                                                   {
                                                       FodderTypeName = taskQuality[0].fodder_type.Name,
                                                       //Quality = taskQuality[0].Quality * pigstyService.GetPignumbers(Convert.ToInt64(taskPigsty.PigstyId)),
                                                       //UnitName = taskQuality[0].unit.Name,
                                                       FodderTypeId = taskQuality[0].FodderTypeId,
                                                       //UnitId = taskQuality[0].UnitId
                                                   };
                            model.TaskDetail.Add(fodderDetail);
                        }
                    }
                }
                model.TaskNumber = taskService.Find(employeeTaskId).TaskNumber;
                //任务的全部人员
                List<task_employee> allemployees = taskEmployeeService.FindByTaskId(employeeTaskId);
                string reAllEmployeeName = "";
                for (i = 0; i < allemployees.Count - 1; i++)
                {
                    reAllEmployeeName = reAllEmployeeName + allemployees[i].employee.Name + ",";
                }
                reAllEmployeeName = reAllEmployeeName + allemployees[i].employee.Name;
                model.TaskEmployeeName = reAllEmployeeName;
            }
            return model;
        }