Beispiel #1
0
 public PagedList<PigInfo> GetpigPageList(PagedList<pig> pigInfos, int pageIndex, int pageSize)
 {
     var pigService = new PigService();
     var pigList = new List<PigInfo>();
     var salePigService = new SalePigService();
     var transferService = new TransferService();
     foreach (pig pig in pigInfos)
     {
         //transfer transfer = transferService.FindByPigId(pig.Id).OrderByDescending(m => m.Time).FirstOrDefault();
         transfer transfer = transferService.FindByPigId(pig.Id).OrderByDescending(m => m.Id).FirstOrDefault();
         string pigHouse = "";
         string pigsty = "";
         string pigState = "";
         if (transfer != null)
         {
             pigHouse = transfer.pigsty.pig_house.pig_house_type.Name + transfer.pigsty.pig_house.Number + "舍";
             pigsty = transfer.pigsty.Number + "";
         }
         var salepig = salePigService.FindByPigId(pig.Id).FirstOrDefault();
         if (pig.State == false) pigState = "正常";
         else if (salepig != null)
         {
             if (salepig.sale.SaleType == "销售")
                 pigState = "出售";
             else if (salepig.sale.SaleType == "淘汰") pigState = "淘汰";
             else if (salepig.sale.SaleType == "死亡") pigState = "死亡";
             else pigState = "异常";
         }
         else
             pigState = "异常";
         pigList.Add(new PigInfo
                         {
                             Number = pig.Number,
                             Rfid = pig.RFID,
                             EarNumber = pig.EarNumber == null ? "" : pig.EarNumber.ToString(),
                             Birthday = pig.Birthday,
                             PigType = pig.pig_type.Name,
                             Memo = pig.Memo,
                             PigHouse = pigHouse,
                             Pigsty = pigsty,
                             state = pigState
                         });
     }
     return new PagedList<PigInfo>(pigList, pageIndex, pageSize, pigInfos.TotalItemCount);
 }
Beispiel #2
0
        /// <summary>
        ///     查看生猪个体防疫记录
        /// </summary>
        /// <param name="pigNumber"></param>
        /// <param name="pageIndex"> </param>
        /// <param name="pageSize"> </param>
        /// <returns></returns>
        public PigInfo CheckPreventionRecord(string pigNumber, int pageIndex, int pageSize)
        {
            var pigService = new PigService();
            pig pig = pigService.FindByNumber(pigNumber);
            var transferPigsty = new TransferService();
            var taskPreventionService = new TaskPreventionService();
            var preventionService = new PreventionService();
            var preventionInfos = new List<PreventionInfo>();
            var salePigService = new SalePigService();
            List<transfer> transferPigstyList = transferPigsty.FindByPigId(pig.Id).OrderBy(m => m.Time).ToList();
            transfer transfer = transferPigstyList.LastOrDefault();
            sale_pig salePig = salePigService.FindByPigId(pig.Id).FirstOrDefault();
            DateTime? temp = null;
            string pigHouse = "", pigsty = "";
            if (transfer != null)
            {
                pigHouse = transfer.pigsty.pig_house.pig_house_type.Name + transfer.pigsty.pig_house.Number;
                pigsty = transfer.pigsty.Number + "";
            }
            if (salePig != null)
            {
                temp = salePig.Time;
            }
            var pigInfo = new PigInfo
                              {
                                  Number = pigNumber,
                                  Birthday = pig.Birthday,
                                  PigType = pig.pig_type.Name,
                                  PigHouse = pigHouse,
                                  Pigsty = pigsty
                              };
                if (transferPigstyList.Count == 1)
                {
                    foreach (prevention preventionItem in
                        preventionService.FindByPistyId(transferPigstyList[0].PigstyId).Where(
                            m => m.Time > transferPigstyList[0].Time))
                    {
                        if (temp != null) if (temp > preventionItem.Time) continue;
                        task_prevention firstOrDefault =
                            taskPreventionService.FindByTaskId(preventionItem.TaskId).FirstOrDefault();
                        if (firstOrDefault != null)
                            preventionInfos.Add(new PreventionInfo
                                                    {
                                                        DiseaseName = firstOrDefault.prevention_type.Name,
                                                        Medicine = firstOrDefault.prevention_type.medicine.Name,
                                                        Time = preventionItem.Time
                                                    });
                    }
                }
                for (int i = 0; i < transferPigstyList.Count; i++)
                {
                    DateTime startTime = transferPigstyList[i].Time;
                    DateTime endTime = DateTime.Now;
                    if (i + 1 < transferPigstyList.Count)
                        endTime = transferPigstyList[i + 1].Time;
                    foreach (prevention preventionItem in
                        preventionService.FindByPistyId(transferPigstyList[i].PigstyId).Where(
                            m => m.Time > startTime && m.Time < endTime))
                    {
                        if (temp != null) if (temp > preventionItem.Time) continue;
                        task_prevention firstOrDefault =
                            taskPreventionService.FindByTaskId(preventionItem.TaskId).FirstOrDefault();
                        if (firstOrDefault != null)
                            preventionInfos.Add(new PreventionInfo
                                                    {
                                                        DiseaseName = firstOrDefault.prevention_type.Name,
                                                        Medicine = firstOrDefault.prevention_type.medicine.Name,
                                                        Time = preventionItem.Time
                                                    });
                    }
                }

            pigInfo.PreventionRecord =
                new PagedList<PreventionInfo>(preventionInfos.OrderByDescending(m => m.Time).ToList(), pageIndex,
                                              pageSize)
                    {
                        Capacity = preventionInfos.Count,
                        PageSize = pageSize,
                        CurrentPageIndex = pageIndex,
                        TotalItemCount = preventionInfos.Count
                    };
            return pigInfo;
        }
Beispiel #3
0
 /// <summary>
 ///     全部生猪列表
 /// </summary>
 /// <returns></returns>
 //public PagedList<PigInfo> GetPigList(int pageIndex, int pageSize)
 //{
 //    //return GetALLPigList(pageIndex, pageSize);
 //    var pigService = new PigService();
 //    var pigList = new List<PigInfo>();
 //    var salePigService = new SalePigService();
 //    var transferService = new TransferService();
 //    PagedList<pig> pigInfos = pigService.FindByPigPage(pageIndex, pageSize);
 //    foreach (pig pig in pigInfos)
 //    {
 //        //transfer transfer = transferService.FindByPigId(pig.Id).OrderByDescending(m => m.Time).FirstOrDefault();
 //        transfer transfer = transferService.FindByPigId(pig.Id).OrderByDescending(m => m.Id).FirstOrDefault();
 //        string pigHouse = "";
 //        string pigsty = "";
 //        string pigState="";
 //        if (transfer != null)
 //        {
 //            pigHouse = transfer.pigsty.pig_house.pig_house_type.Name + transfer.pigsty.pig_house.Number+"舍";
 //            pigsty = transfer.pigsty.Number + "";
 //        }
 //        if (pig.State == false) pigState = "正常";
 //        else if (salePigService.FindByPigId(pig.Id) != null) pigState = "出售";
 //        else
 //            pigState = "异常";
 //        pigList.Add(new PigInfo
 //                        {
 //                            Number=pig.Number,
 //                            Rfid=pig.RFID,
 //                            EarNumber = pig.EarNumber == null ? "" : pig.EarNumber.ToString(),
 //                            Birthday = pig.Birthday,
 //                            PigType = pig.pig_type.Name,
 //                            Memo = pig.Memo,
 //                            PigHouse = pigHouse,
 //                            Pigsty = pigsty,
 //                            state=pigState
 //                        });
 //    }
 //    return new PagedList<PigInfo>(pigList, pageIndex, pageSize, pigInfos.TotalItemCount);
 //}
 public PagedList<PigInfo> GetPigList(int pageIndex, int pageSize)
 {
     var pigService = new PigService();
     var pigList = new List<PigInfo>();
     var salePigService = new SalePigService();
     var transferService = new TransferService();
     PagedList<pig> pigInfos = pigService.FindByPigPage(pageIndex, pageSize);
     PagedList<transfer> transferList = transferService.FindByAllPage(pageIndex, pageSize);
     foreach (transfer tranfer in transferList)
     {
         pig pig = pigService.Find(tranfer.PigId);
         string pigState = "";
         var salepig = salePigService.FindByPigId(pig.Id).FirstOrDefault();
         if (pig.State == false) pigState = "正常";
         else if (salepig != null)
         {
             if (salepig.sale.SaleType=="销售")
             pigState = "出售";
             else if (salepig.sale.SaleType == "淘汰") pigState = "淘汰";
             else if (salepig.sale.SaleType == "死亡") pigState = "死亡";
             else pigState = "异常";
         }
         else
             pigState = "异常";
         pigList.Add(new PigInfo
                         {
                             Number = pig.Number,
                             Rfid = pig.RFID,
                             EarNumber = pig.EarNumber == null ? "" : pig.EarNumber.ToString(),
                             Birthday = pig.Birthday,
                             PigType = pig.pig_type.Name,
                             Memo = pig.Memo,
                             PigHouse =
                                 tranfer.pigsty.pig_house.pig_house_type.Name + tranfer.pigsty.pig_house.Number +
                                 "舍",
                             Pigsty = tranfer.pigsty.Number + "",
                             state = pigState
                         });
     }
     return new PagedList<PigInfo>(pigList, pageIndex, pageSize, pigInfos.TotalItemCount);
 }
Beispiel #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;
 }