示例#1
0
        /// <summary>
        ///     查看喂食信息
        /// </summary>
        /// <param name="employeename">选中喂食信息的喂食人员</param>
        /// <param name="taskNumber">喂食任务编号</param>
        /// <param name="time">喂食时间</param>
        /// <returns></returns>
        public FeedInfo CheckFeedInfo(string employeename, string taskNumber, DateTime time)
        {
            var checkFeedInfo = new FeedInfo();
            var feedService = new FeedService();
            var fodderTakeService = new FodderTakeService();
            var employeeService = new EmployeeService();
            //var taskService = new TaskService();
            checkFeedInfo.TaskNumber = taskNumber;
            checkFeedInfo.EmployeeName = employeename;
            checkFeedInfo.TakeDetail = new List<FodderTakeDetail>();
            checkFeedInfo.FeedPig = new List<FeedInfoDetail>();
            employee firstOrDefault = employeeService.FindByName(employeename).FirstOrDefault();
            if (firstOrDefault != null)
                foreach (fodder_take fodderTake in fodderTakeService.FindByEmployeeId(firstOrDefault.Id))
                    //task firstOrDefault = taskService.FindByTaskNumber(taskNumber);
                    //if (firstOrDefault != null)
                    //foreach (fodder_take fodderTake in fodderTakeService.FindByTaskId(firstOrDefault.Id))
                {
                    string num = fodderTake.task.TaskNumber;
                    if (!time.Date.Equals(fodderTake.Time.Date) && num != taskNumber) continue;
                    checkFeedInfo.TakeDetail.Add(new FodderTakeDetail
                                                     {
                                                         FodderType = fodderTake.fodder_type.Name,
                                                         Quantity = fodderTake.Quantity,
                                                         Unit = fodderTake.unit.Name,
                                                         TakeTime = fodderTake.Time
                                                     });
                }

            employee orDefault = employeeService.FindByName(employeename).FirstOrDefault();
            if (orDefault != null)
                foreach (feed feedItem in feedService.FindByEmployeeId(orDefault.Id))
                {
                    string num = feedItem.task.TaskNumber;
                    if (!time.Date.Equals(feedItem.Time.Date) && num != taskNumber) continue;
                    checkFeedInfo.FeedPig.Add(new FeedInfoDetail
                                                  {
                                                      DetailTime = feedItem.Time,
                                                      PigHouse =
                                                          feedItem.pigsty.pig_house.pig_house_type.Name +
                                                          feedItem.pigsty.pig_house.Number,
                                                      Pigsty = feedItem.pigsty.Number + string.Empty
                                                      //FodderType = feedItem.fodder_type.Name,
                                                      //Quantity = feedItem.Quality,
                                                      //Unit = feedItem.unit.Name
                                                  });
                    checkFeedInfo.Meno = feedItem.Memo;
                }
            return checkFeedInfo;
        }
示例#2
0
 /// <summary>
 /// 删除对应的喂食信息
 /// </summary>
 /// <param name="employeename">喂食人员姓名</param>
 /// <param name="taskNumber">任务编号</param>
 /// <param name="time">喂食时间</param>
 /// <returns></returns>
 public bool DelFeed(string employeename, string taskNumber, DateTime time)
 {
     var feedService = new FeedService();
     var employeeService = new EmployeeService();
     employee orDefault = employeeService.FindByName(employeename).FirstOrDefault();
     if (orDefault != null)
         foreach (feed feedItem in feedService.FindByEmployeeId(orDefault.Id))
         {
             string num = feedItem.task.TaskNumber;
             if (!time.Date.Equals(feedItem.Time.Date) && num == taskNumber) continue;
             feedService.Delete(feedService.Find(feedItem.Id));
         }
     else
         return false;
     return true;
 }
示例#3
0
 /// <summary>
 ///     根据喂饲任务类型id得到所有的喂饲人员编号和名字
 /// </summary>
 /// <returns>所有的喂饲人员编号和名字</returns>
 public string GetFeedTaskEmployee()
 {
     var taskTypeService = new TaskTypeService();
     var feedService = new FeedService();
     try
     {
         long feedTaskTypeId = taskTypeService.FindByName("喂饲").Id;
         return feedService.GetFeedTaskEmployeeNameAndNumber(feedTaskTypeId);
     }
     catch (Exception)
     {
         return null;
     }
 }
示例#4
0
 /// <summary>
 ///     查看生猪个体喂食记录
 /// </summary>
 /// <param name="pigNumber"></param>
 /// <param name="pageIndex"> </param>
 /// <param name="pageSize"> </param>
 /// <returns></returns>
 public PigInfo CheckFeedRecord(string pigNumber, int pageIndex, int pageSize)
 {
     var pigService = new PigService();
     var salePigService = new SalePigService();
     pig pig = pigService.FindByNumber(pigNumber);
     var transferPigsty = new TransferService();
     var feedService = new FeedService();
     List<transfer> transferPigstyList = transferPigsty.FindByPigId(pig.Id).OrderBy(m => m.Time).ToList();
     transfer transfer = transferPigstyList.LastOrDefault();
     var feedInfos = new List<FodderTakeDetail>();
     string pigHouse = "", pigsty = "";
     DateTime? temp = null;
     sale_pig salePig = salePigService.FindByPigId(pig.Id).FirstOrDefault();
     if (transfer != null)
     {
         pigHouse = transfer.pigsty.pig_house.pig_house_type.Name + transfer.pigsty.pig_house.Number;
         pigsty = transfer.pigsty.Number + "";
     }
     var pigInfo = new PigInfo
                       {
                           Number = pigNumber,
                           Birthday = pig.Birthday,
                           PigType = pig.pig_type.Name,
                           PigHouse = pigHouse,
                           Pigsty = pigsty
                       };
     if (salePig != null)
     {
         temp = salePig.Time;
     }
     if (transferPigstyList.Count == 1)
     {
         foreach (feed feedItem in
             feedService.FindByPigstyId(transferPigstyList[0].PigstyId).Where(
                 m => m.Time > transferPigstyList[0].Time))
         {
             if (temp != null) if (feedItem.Time > temp) continue;
             feedInfos.Add(new FodderTakeDetail
                               {
                                   FodderType =
                                       feedItem.task.task_pigsty.FirstOrDefault(
                                           m => m.PigstyId == feedItem.PigstyId)
                                               .feed_task_quality.FirstOrDefault()
                                               .fodder_type.Name,
                                   TakeTime = feedItem.Time
                               });
         }
     }
     for (int i = 0; i < transferPigstyList.Count - 1; i++)
     {
         DateTime startTime = transferPigstyList[i].Time;
         DateTime endTime = transferPigstyList[i + 1].Time;
         foreach (feed feedItem in
             feedService.FindByPigstyId(transferPigstyList[i].PigstyId).Where(
                 m => m.Time > startTime && m.Time < endTime))
         {
             if (temp != null) if (feedItem.Time > temp) continue;
             feedInfos.Add(new FodderTakeDetail
                               {
                                   // FodderType = feedItem.task.fodder_take.Where(m => m.Time > startTime && m.Time < endTime).FirstOrDefault().fodder_type.Name,
                                   FodderType =
                                       feedItem.task.task_pigsty.FirstOrDefault(
                                           m => m.PigstyId == feedItem.PigstyId)
                                               .feed_task_quality.FirstOrDefault()
                                               .fodder_type.Name,
                                   TakeTime = feedItem.Time
                               });
         }
     }
     pigInfo.FeedRecord = new PagedList<FodderTakeDetail>(feedInfos.OrderByDescending(m => m.TakeTime).ToList(),
                                                          pageIndex, pageSize)
                              {
                                  Capacity = feedInfos.Count,
                                  CurrentPageIndex = pageIndex,
                                  PageSize = pageSize,
                                  TotalItemCount = feedInfos.Count
                              };
     return pigInfo;
 }
示例#5
0
        /// <summary>
        ///     修改喂食信息
        /// </summary>
        /// <param name="feedInfo">已修改的喂食信息页面类</param>
        /// <param name="time">原时间</param>
        /// <param name="employeeName">原喂食人员名字</param>
        /// <returns></returns>
        public bool UpdateFeedInfo(FeedInfo feedInfo, DateTime time, string employeeName)
        {
            var feedService = new FeedService();
            var fodderTakeService = new FodderTakeService();
            var employeeService = new EmployeeService();
            var taskService = new TaskService();
            int i = 0, j = 0;
            employee firstOrDefault = employeeService.FindByName(employeeName).FirstOrDefault();
            //var firstOrDefault = taskService.FindByTaskNumber(feedInfo.TaskNumber);
            if (firstOrDefault != null)
            {
                foreach (fodder_take fodderTake in fodderTakeService.FindByEmployeeId(firstOrDefault.Id))
                {
                    string num = fodderTake.task.TaskNumber;
                    if (!time.Date.Equals(fodderTake.Time.Date) && num != feedInfo.TaskNumber) continue;
                    if (i < feedInfo.TakeDetail.Count)
                    {
                        fodderTake.EmployeeId = long.Parse(feedInfo.EmployeeName);
                        fodderTake.FodderTypeId = long.Parse(feedInfo.TakeDetail[i].FodderType);
                        fodderTake.Quantity = feedInfo.TakeDetail[i].Quantity;
                        fodderTake.UnitId = long.Parse(feedInfo.TakeDetail[i].Unit);
                        fodderTake.Time = feedInfo.TakeDetail[i].TakeTime;
                        fodderTakeService.Update(fodderTake);
                        i++;
                    }
                    else
                    {
                        fodderTakeService = new FodderTakeService();
                        fodderTakeService.Delete(fodderTakeService.Find(fodderTake.Id));
                    }
                }
                for (; i < feedInfo.TakeDetail.Count; i++)
                {
                    string num = feedInfo.TaskNumber ?? null;
                    long id = taskService.FindByTaskNumber(num).Id;

                    fodderTakeService.Insert(new fodder_take
                                                 {
                                                     TaskId = id,
                                                     EmployeeId = long.Parse(feedInfo.EmployeeName),
                                                     FodderTypeId = long.Parse(feedInfo.TakeDetail[i].FodderType),
                                                     Quantity = feedInfo.TakeDetail[i].Quantity,
                                                     UnitId = long.Parse(feedInfo.TakeDetail[i].Unit),
                                                     Time = feedInfo.TakeDetail[i].TakeTime
                                                 });
                }
                employee orDefault = employeeService.Find(long.Parse(feedInfo.EmployeeName));
                if (orDefault != null)
                    foreach (feed feedItem in feedService.FindByEmployeeId(orDefault.Id))
                    {
                        string num = feedItem.task.TaskNumber;
                        if (!time.Date.Equals(feedItem.Time.Date) && num != feedInfo.TaskNumber) continue;
                        if (j < feedInfo.FeedPig.Count)
                        {
                            feedItem.EmployeeId = long.Parse(feedInfo.EmployeeName);
                            //feedItem.FodderTypeId = long.Parse(feedInfo.FeedPig[j].FodderType);
                            //feedItem.Quality = feedInfo.FeedPig[j].Quantity;
                            //feedItem.UnitId = long.Parse(feedInfo.FeedPig[j].Unit);
                            feedItem.PigstyId = long.Parse(feedInfo.FeedPig[j].Pigsty);
                            feedItem.Time = feedInfo.FeedPig[j].DetailTime;
                            feedItem.Memo = feedInfo.Meno;
                            feedService.Update(feedItem);
                            j++;
                        }
                        else
                        {
                            feedService = new FeedService();
                            feedService.Delete(feedService.Find(feedItem.Id));
                        }
                    }
                for (; j < feedInfo.FeedPig.Count; j++)
                {
                    string num = feedInfo.TaskNumber ?? null;
                    long id = taskService.FindByTaskNumber(num).Id;
                    feedService.Insert(new feed
                                           {
                                               TaskId = id,
                                               EmployeeId = long.Parse(feedInfo.EmployeeName),
                                               PigstyId = long.Parse(feedInfo.FeedPig[j].Pigsty),
                                               //FodderTypeId = long.Parse(feedInfo.FeedPig[j].FodderType),
                                               //Quality = feedInfo.FeedPig[j].Quantity,
                                               //UnitId = long.Parse(feedInfo.FeedPig[j].Unit),
                                               Time = feedInfo.FeedPig[j].DetailTime,
                                               Memo = feedInfo.Meno
                                           });
                }
            }
            else
            {
                return false;
            }
            return true;
        }
示例#6
0
        /// <summary>
        ///     喂食信息管理列表
        /// </summary>
        /// <returns></returns>
        public IEnumerable<Info> GetFeedInfoList()
        {
            var feedService = new FeedService();
            var taskService = new TaskService();
            var employeeService = new EmployeeService();
            string taskNumber = "";
            task task = null;
            var feedInfoList = new List<Info>();
            var employeeIds = new HashSet<long>();
            foreach (feed employeeId in feedService.FindAll())
            {
                employeeIds.Add(employeeId.EmployeeId);
            }

            foreach (long employeeId in employeeIds)
            {
                feed item = feedService.FindByEmployeeId(employeeId).OrderByDescending(m => m.Time).FirstOrDefault();
                if (item != null) task = taskService.Find(item.TaskId);
                taskNumber = task != null ? task.TaskNumber : "";

                if (item != null)
                {
                    feedInfoList.Add(new Info
                                         {
                                             TaskNumber = taskNumber,
                                             EmployeeName =
                                                 employeeService.Find(
                                                     item.
                                                         EmployeeId).Name,
                                             Time = item.Time,
                                             Meno = item.Memo
                                         });
                    foreach (
                        feed feedInfoitem in feedService.FindByEmployeeId(employeeId).OrderByDescending(m => m.Time))
                    {
                        task = taskService.Find(feedInfoitem.TaskId);
                        taskNumber = task != null ? task.TaskNumber : "";

                        if (item.Time.Date.Equals(feedInfoitem.Time.Date) && item.TaskId == feedInfoitem.TaskId)
                            continue;
                        feedInfoList.Add(new Info
                                             {
                                                 TaskNumber = taskNumber,
                                                 EmployeeName =
                                                     employeeService.Find(
                                                         feedInfoitem.
                                                             EmployeeId).Name,
                                                 Time = feedInfoitem.Time,
                                                 Meno = feedInfoitem.Memo
                                             });
                        item = feedInfoitem;
                    }
                }
            }

            return feedInfoList.OrderByDescending(m => m.Time);
        }
示例#7
0
        /// <summary>
        ///     新建喂食信息
        /// </summary>
        /// <param name="newFeedInfo"></param>
        /// y
        /// <returns></returns>
        public bool CreateFeedInfo(FeedInfo newFeedInfo)
        {
            var employeeService = new EmployeeService();
            var feedService = new FeedService();
            var fodderTakeService = new FodderTakeService();
            var taskService = new TaskService();
            var fodderTypeService = new FodderTypeService();
            var unitService = new UnitService();
            var taskStatusTypeService = new TaskStatusTypeService();
            long taskId = long.Parse(TaskNumber);
            foreach (FodderTakeDetail takedetail in newFeedInfo.TakeDetail)
            {
                employee firstOrDefault = employeeService.Find(long.Parse(newFeedInfo.EmployeeName));
                if (firstOrDefault != null)
                {
                    var take = new fodder_take
                                   {
                                       TaskId = taskId,
                                       EmployeeId = firstOrDefault.Id,
                                       //FodderTypeId = fodderTypeService.Find(long.Parse(takedetail.FodderType)).Id,
                                       //Quantity = takedetail.Quantity,
                                       //UnitId = unitService.Find(long.Parse(takedetail.Unit)).Id,
                                       Time = takedetail.TakeTime
                                   };
                    fodderTakeService.Insert(take);
                }
            }

            foreach (FeedInfoDetail feedPigDetail in FeedPig)
            {
                var feedinfo = new feed {TaskId = taskId};
                employee firstOrDefault = employeeService.Find(long.Parse(newFeedInfo.EmployeeName));
                if (firstOrDefault != null)
                    feedinfo.EmployeeId = firstOrDefault.Id;
                feedinfo.PigstyId = long.Parse(feedPigDetail.Pigsty);
                //feedinfo.FodderTypeId = long.Parse(feedPigDetail.FodderType);
                //feedinfo.Quality = feedPigDetail.Quantity;
                //feedinfo.UnitId = long.Parse(feedPigDetail.Unit);
                feedinfo.Memo = newFeedInfo.Meno;
                feedinfo.Time = feedPigDetail.DetailTime;
                feedService.Insert(feedinfo);
            }
            task_status_type taskStatusType = taskStatusTypeService.FindByName("正在进行");
            task task = taskService.Find(long.Parse(newFeedInfo.TaskNumber));
            if (taskStatusType != null && task != null)
            {
                task.TaskStatusId = taskStatusType.Id;
                taskService.Update(task);
            }

            return true;
        }