/// <summary> /// 获取第parityNum胎次的日产奶list /// </summary> /// <param name="earNum">耳号</param> /// <param name="parityNum">第胎次,从1开始计算</param> /// <returns></returns> public List <IndividualProdcutionTotal> GetIndividualDayProdcutionList(int earNum, int parityNum) { DateTime startDate, endDate; CowInfo cowInfo = new CowInfo(earNum); int parity = cowInfo.Parity; //ORDER BY D.Birthday DESC 降序的 List <Calving> calvingList = CowInfo.GetCowCalvingRecords(earNum); if (parityNum > parity | parityNum < 1) { throw new ArgumentException("此牛仅有" + parity.ToString() + "个胎次,不能有此记录"); } else { startDate = calvingList[parity - parityNum].Birthday.Date; if (parityNum < parity) { endDate = calvingList[parity - parityNum + 1].Birthday.Date; } else { //最后一胎 endDate = DateTime.Now.Date; } } return(GetIndividualDayProdcutionList(earNum, startDate, endDate)); }
public CowInfo(Cow cow) { myCow = cow; this.earNum = cow.EarNum; this.calvingList = CowInfo.GetCowCalvingRecords(this.earNum); this.dryMilkList = CowInfo.GetDryMilkRecords(this.earNum); this.parity = this.calvingList.Count; }
public CowInfo(int earNum) { CowBLL cb = new CowBLL(); this.earNum = earNum; myCow = cb.GetCowInfo(earNum); this.calvingList = CowInfo.GetCowCalvingRecords(earNum); this.dryMilkList = CowInfo.GetDryMilkRecords(earNum); this.parity = this.calvingList.Count; }
/// <summary> /// 点击[繁殖-发情配种],增加发情/配种任务 /// </summary> public void CompleteInsemination(DairyTask task, Insemination insemination) { CowInfo cow = new CowInfo(insemination.EarNum); // 添加任务记录,添加即已完成 Todo task.Status = DairyTaskStatus.Completed; task.InputTime = DateTime.Now; taskDAL.InsertTask(task); // 删除无效的妊检任务单 RemovePreviousInspectionTasks(insemination.EarNum, true); RemovePreviousInspectionTasks(insemination.EarNum, false); // 产生新妊检任务单 DairyTask initialInspectionTask = new DairyTask(); initialInspectionTask.TaskType = TaskType.InitialInspectionTask; initialInspectionTask.Status = DairyTaskStatus.Initial; initialInspectionTask.ArrivalTime = task.CompleteTime.AddDays(DairyParameterBLL.GetCurrentParameterDictionary(cow.FarmCode)[FarmInfo.PN_DAYSOFINITIALINSPECTION]); // 3 days to complete task initialInspectionTask.DeadLine = initialInspectionTask.ArrivalTime.AddDays(3.0); initialInspectionTask.EarNum = insemination.EarNum; // 分配配种员 initialInspectionTask.OperatorID = AssignTask(task.PastureID, task.EarNum, Role.FARM_INSEMINATOR_ID); initialInspectionTask.RoleID = task.RoleID; initialInspectionTask.PastureID = task.PastureID; initialInspectionTask.InputTime = DateTime.Now; taskDAL.InsertTask(initialInspectionTask); // 添加配种记录 InseminationBLL insemBLL = new InseminationBLL(); insemBLL.InsertInseminationInfo(insemination); // 更新牛繁殖状态 CowBLL cowBLL = new CowBLL(); cowBLL.UpdateCowBreedStatus(insemination.EarNum, "已配未检"); }
/// <summary> /// 获取牛类型 /// </summary> /// <param name="myCow"></param> /// <returns></returns> public static string GetCowType(CowInfo myCow) { string cowType; //set cow type if (myCow.Gender == "公") { cowType = "公牛"; } else { TimeSpan span = DateTime.Now.Subtract(myCow.BirthDate); //to-do:把天数换成参数配置中的数; if (span.TotalDays < Cow.DAYS_OF_CALF) { cowType = "犊牛"; } else { if (span.TotalDays < (Cow.DAYS_OF_COW_MONTH * Cow.MONTHS_OF_NULLPARITY)) { cowType = "育成牛"; } else { if (myCow.Parity > 0) { cowType = "经产牛"; } else { cowType = "青年牛"; } } } } return(cowType); }
public FarmInfo(int pastureID) { cowList = cowBll.GetCowList(pastureID); foreach (Cow item in cowList) { CowInfo cowInfo = new CowInfo(item); cowInfoList.Add(cowInfo); switch (item.Status) { case "未配": countOfUnInseminated++; break; case "已配未检": countOfInseminated++; break; case "初检-": countOfIntialInspectNegative++; break; case "初检+": countOfIntialInspectPositive++; break; case "复检-": countOfReInspectNegative++; break; case "复检+": countOfReInspectPositive++; break; case "禁配": countOfForbidden++; break; default: break; } //switch (cowInfo.CowType) //{ // case "公牛": // bulls.Add(cowInfo); // break; // case "犊牛": // countOfCows++; // calfs.Add(cowInfo); // break; // case "育成牛": // countOfCows++; // bredCattleCows.Add(cowInfo); // break; // case "青年牛": // nullParityCows.Add(cowInfo); // countOfCows++; // break; // case "经产牛": // multiParityCows.Add(cowInfo); // countOfCows++; // break; // default: // countOfOther++; // countOfCows++; // break; //} } }