コード例 #1
0
ファイル: TaskBLL.cs プロジェクト: vijaydairyf/cow-1
        /// <summary>
        /// 产前7天任务
        /// </summary>
        public void CompleteDay7ToBorn(DairyTask task, int cowHouseId, int cowGroupId)
        {
            // 更新任务记录,标记完成
            UpdateTask(task);

            // 产生调群任务,进产房
            DairyTask groupingTask = new DairyTask();

            groupingTask.TaskType = TaskType.GroupingTask;
            DateTime time = DateTime.Now;

            groupingTask.ArrivalTime = time;
            groupingTask.InputTime   = time;
            groupingTask.EarNum      = task.EarNum;
            groupingTask.DeadLine    = time.AddDays(1.0);
            AddTask(groupingTask);

            // 取回这条任务
            DairyTask groupingTaskCopy = GetUnfinishedTasks(UserBLL.Instance.CurrentUser.Pasture.ID).Find(p => p.ArrivalTime == time && p.TaskType == TaskType.GroupingTask);
            // 关联调群记录,任务单找到如何调群
            GroupingRecord groupingRecord = new GroupingRecord();

            groupingRecord.EarNum = groupingTaskCopy.EarNum;
            groupingRecord.TaskID = groupingTaskCopy.ID;
            CowBLL cowBLL = new CowBLL();
            Cow    myCow  = cowBLL.GetCowInfo(groupingTaskCopy.EarNum);

            groupingRecord.OriginalGroupID = myCow.GroupID;
            groupingRecord.OriginalHouseID = myCow.HouseID;
            groupingRecord.TargetGroupID   = cowGroupId;
            groupingRecord.TargetHouseID   = cowHouseId;
            GroupingRecordBLL gBLL = new GroupingRecordBLL();

            gBLL.InsertGroupingRecord(groupingRecord);
        }
コード例 #2
0
ファイル: GradeBLL.cs プロジェクト: vijaydairyf/cow-1
        private Grade WrapGradeItem(DataRow gradeRow)
        {
            Grade gradeItem = new Grade();

            if (gradeRow != null)
            {
                gradeItem.EarNum        = Convert.ToInt32(gradeRow["EarNum"]);
                gradeItem.DisplayEarNum = CowBLL.ConvertEarNumToDisplayEarNum(gradeItem.EarNum);
                if (Convert.ToInt32(gradeRow["Height"]) != 0)
                {
                    gradeItem.Height = Convert.ToInt32(gradeRow["Height"]);
                }
                if (Convert.ToInt32(gradeRow["Weight"]) != 0)
                {
                    gradeItem.Weight = Convert.ToInt32(gradeRow["Weight"]);
                }
                if (Convert.ToInt32(gradeRow["Chest"]) != 0)
                {
                    gradeItem.Chest = Convert.ToInt32(gradeRow["Chest"]);
                }
                if (Convert.ToInt32(gradeRow["Score"]) != 0)
                {
                    gradeItem.Score = Convert.ToInt32(gradeRow["Score"]);
                }
                gradeItem.Description = gradeRow["Description"].ToString();
                gradeItem.MeasureDate = Convert.ToDateTime(gradeRow["MeasureDate"]);
                if (Convert.ToInt32(gradeRow["Measurer"]) != 0)
                {
                    gradeItem.Measurer = Convert.ToInt32(gradeRow["Measurer"]);
                }
            }
            return(gradeItem);
        }
コード例 #3
0
ファイル: CowInfoBLL.cs プロジェクト: vijaydairyf/cow-1
        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;
        }
コード例 #4
0
ファイル: StrayBLL.cs プロジェクト: vijaydairyf/cow-1
        /// <summary>
        /// 插入离群记录,且标记牛离群
        /// </summary>
        /// <param name="s"></param>
        public void StrayCow(Stray s)
        {
            int i = InsertStray(s);

            if (i == 0)
            {
                throw new Exception("无法插入离群记录。");
            }
            CowBLL cBLL = new CowBLL();

            cBLL.UpdateCowStrayStatus(s.EarNum, 1);
        }
コード例 #5
0
ファイル: TaskBLL.cs プロジェクト: vijaydairyf/cow-1
        /// <summary>
        /// 妊检复检任务
        /// </summary>
        public void CompleteReInspection(DairyTask task, ReInspection reInspection)
        {
            // 添加复检记录
            ReInspectionBLL rBLL = new ReInspectionBLL();

            reInspection.InseminationID = this.taskDAL.GetInseminationID(reInspection.EarNum);
            rBLL.InsertReInspection(reInspection);

            //更新任务记录,标记完成
            task.Status = DairyTaskStatus.Completed;
            //task.CompleteTime = DateTime.Now;
            task.InputTime = DateTime.Now;

            UpdateTask(task);

            CowBLL cowBLL = new CowBLL();

            if (reInspection.ReInspectResult == 1)
            {
                //复检+
                //生成产前21天任务单
                DairyTask day21ToBornTask = new DairyTask();
                day21ToBornTask.EarNum    = task.EarNum;
                day21ToBornTask.PastureID = task.PastureID;
                //分配兽医

                day21ToBornTask.OperatorID = AssignTask(task.PastureID, task.EarNum, Role.FARM_DOCTOR_ID);

                day21ToBornTask.Status = DairyTaskStatus.Initial;
                float normalCalvingDays = DairyParameterBLL.GetCurrentParameterDictionary(UserBLL.Instance.CurrentUser.Pasture.ID)[FarmInfo.PN_NORMALCALVINGDAYS];
                float reInspectionDays  = DairyParameterBLL.GetCurrentParameterDictionary(UserBLL.Instance.CurrentUser.Pasture.ID)[FarmInfo.PN_DAYSOFREINSEPECTION];
                day21ToBornTask.ArrivalTime = task.ArrivalTime.AddDays(-reInspectionDays + normalCalvingDays - 14);//NormalCalvingDays是进产房天数
                day21ToBornTask.DeadLine    = day21ToBornTask.ArrivalTime.AddDays(1.0);
                day21ToBornTask.TaskType    = TaskType.Day21ToBornTask;
                day21ToBornTask.InputTime   = DateTime.Now;
                AddTask(day21ToBornTask);
                // 更新牛繁殖状态
                cowBLL.UpdateCowBreedStatus(task.EarNum, "复检+");
            }
            else
            {
                //更新牛繁殖状态
                cowBLL.UpdateCowBreedStatus(task.EarNum, "复检-");
            }
        }
コード例 #6
0
ファイル: TaskBLL.cs プロジェクト: vijaydairyf/cow-1
        /// <summary>
        /// 在产犊界面调用本方法
        /// 产生产后三任务
        /// </summary>
        /// <param name="calving"></param>
        public void CreateAfterBornTasks(Calving calving)
        {
            // 分配兽医,饲养员
            CowGroupBLL g  = new CowGroupBLL();
            CowBLL      c  = new CowBLL();
            Cow         cc = c.GetCowInfo(calving.EarNum);
            CowGroup    gg = g.GetCowGroupList(cc.FarmCode).Find(p => p.ID == cc.GroupID);

            // 产犊界面,输入产犊信息,调用本方法产生3个产后任务和犊牛饲喂任务
            DairyTask t1 = new DairyTask();

            t1.PastureID   = gg.PastureID;
            t1.EarNum      = calving.EarNum;
            t1.ArrivalTime = calving.Birthday.AddDays(3.0);
            t1.DeadLine    = t1.ArrivalTime.AddDays(1.0);
            t1.OperatorID  = gg.DoctorID;
            t1.TaskType    = TaskType.Day3AfterBornTask;
            t1.InputTime   = DateTime.Now;
            this.AddTask(t1);

            DairyTask t2 = new DairyTask();

            t2.PastureID   = gg.PastureID;
            t2.EarNum      = calving.EarNum;
            t2.ArrivalTime = calving.Birthday.AddDays(10.0);
            t2.DeadLine    = t2.ArrivalTime.AddDays(1.0);
            t2.OperatorID  = gg.DoctorID;
            t2.TaskType    = TaskType.Day10AfterBornTask;
            t2.InputTime   = DateTime.Now;
            this.AddTask(t2);

            DairyTask t3 = new DairyTask();

            t3.PastureID   = gg.PastureID;
            t3.EarNum      = calving.EarNum;
            t3.ArrivalTime = calving.Birthday.AddDays(15.0);
            t3.DeadLine    = t3.ArrivalTime.AddDays(1.0);
            t3.OperatorID  = gg.DoctorID;
            t3.TaskType    = TaskType.Day15AfterBornTask;
            t3.InputTime   = DateTime.Now;
            this.AddTask(t3);

            return;
        }
コード例 #7
0
ファイル: TaskBLL.cs プロジェクト: vijaydairyf/cow-1
        /// <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, "已配未检");
        }
コード例 #8
0
ファイル: TaskBLL.cs プロジェクト: vijaydairyf/cow-1
        /// <summary>
        /// 分群任务
        /// </summary>
        public void CompleteGrouping(DairyTask task)
        {
            //各种事件触发产生分群要求,产生任务单
            //饲养员按要求操作,回填完成时间
            task.Status       = DairyTaskStatus.Completed;
            task.CompleteTime = DateTime.Now;
            task.InputTime    = DateTime.Now;
            UpdateTask(task);


            //更新牛的牛群号,牛舍号
            CowBLL            cowBLL = new CowBLL();
            Cow               myCow  = cowBLL.GetCowInfo(task.EarNum);
            GroupingRecordBLL gBLL   = new GroupingRecordBLL();
            GroupingRecord    record = gBLL.GetGroupingRecordByTaskID(task.ID);

            myCow.GroupID = record.TargetGroupID;
            myCow.HouseID = record.TargetHouseID;
            cowBLL.UpdateCowGroupAndHouse(myCow.EarNum, myCow.GroupID, myCow.HouseID);
        }
コード例 #9
0
ファイル: TaskBLL.cs プロジェクト: vijaydairyf/cow-1
        /// <summary>
        /// 取牧场某牛的饲养员、配种员或兽医的责任人ID
        /// </summary>
        /// <param name="pastureID">牧场ID</param>
        /// <param name="earNum">耳号</param>
        /// <param name="roleID">角色ID</param>
        /// <returns></returns>
        public int AssignTask(int pastureID, int earNum, int roleID)
        {
            int         userID;
            CowGroupBLL g        = new CowGroupBLL();
            CowBLL      c        = new CowBLL();
            Cow         cc       = c.GetCowInfo(earNum);
            CowGroup    cowGroup = g.GetCowGroupList(pastureID).Find(p => p.ID == cc.GroupID);

            if (cowGroup != null && cowGroup.InsemOperatorID != 0)
            {
                userID = cowGroup.InsemOperatorID;
            }
            else
            {
                //牛群未分配,则分配给场长
                userID = UserBLL.Instance.GetUsers(UserBLL.Instance.CurrentUser.Pasture.ID, Role.FARM_ADMIN_ID)[0].ID;
            }

            return(userID);
        }
コード例 #10
0
ファイル: CowInfoBLL.cs プロジェクト: vijaydairyf/cow-1
        /// <summary>
        /// 取本轮配种记录列表
        /// </summary>
        /// <param name="earNum"></param>
        /// <returns></returns>
        public static List <Insemination> GetInseminationListOfCurrentBreedPeriod(int earNum)
        {
            InseminationBLL bllInsem      = new InseminationBLL();
            DateTime        latestCalTime = new DateTime(1900, 1, 1);
            Calving         cal           = GetLatestCalving(earNum);

            if (cal != null)
            {
                latestCalTime = cal.Birthday;
            }
            else
            {
                CowBLL cb    = new CowBLL();
                Cow    myCow = cb.GetCowInfo(earNum);
                latestCalTime = myCow.BirthDate;
            }
            List <Insemination> list = bllInsem.GetInseminationList(earNum, latestCalTime);

            return(list);
        }
コード例 #11
0
ファイル: InseminationBLL.cs プロジェクト: vijaydairyf/cow-1
        /// <summary>
        /// 插入假配种记录,为入群用
        /// </summary>
        /// <param name="earNum"></param>
        /// <param name="date"></param>
        /// <returns></returns>
        public int InsertFakeInsemination(int earNum, DateTime date)
        {
            Insemination i = new Insemination();

            i.EarNum      = earNum;
            i.OperateDate = date;
            CowBLL      cb   = new CowBLL();
            CowGroupBLL gBLL = new CowGroupBLL();

            i.operatorID       = 0;//gBLL.GetCowGroupInfo(cb.GetCowInfo(earNum).GroupID).InsemOperatorID;
            i.InseminationNum  = 1;
            i.EstrusFindPerson = "孙悟空";
            i.EstrusDate       = date;
            i.EstrusFindType   = 0;
            i.Description      = "";
            i.SemenNum         = "NA";
            i.SemenType        = 0;
            i.Description      = "";
            i.EstrusType       = 0;
            return(InsertInseminationInfo(i));
        }
コード例 #12
0
ファイル: TaskBLL.cs プロジェクト: vijaydairyf/cow-1
        /// <summary>
        /// 妊检初检任务
        /// </summary>
        public void CompleteInitialInspection(DairyTask task, InitialInspection initialInspetion)
        {
            //添加初检记录
            InitialInspectionBLL iBLL = new InitialInspectionBLL();

            initialInspetion.InseminationID = this.taskDAL.GetInseminationID(initialInspetion.EarNum);
            iBLL.InsertInitialInspection(initialInspetion);

            // 更新初检任务记录
            UpdateTask(task);

            CowBLL cowBLL = new CowBLL();

            if (initialInspetion.InspectResult == 1)
            {
                //初检+
                //生成新复检任务单
                DairyTask reinspectionTask = new DairyTask();
                reinspectionTask.EarNum    = task.EarNum;
                reinspectionTask.PastureID = task.PastureID;
                //分配配种员
                reinspectionTask.OperatorID = task.OperatorID;//复检和初检同一人

                reinspectionTask.Status = DairyTaskStatus.Initial;
                float initialInspectionDays = DairyParameterBLL.GetCurrentParameterDictionary(UserBLL.Instance.CurrentUser.Pasture.ID)[FarmInfo.PN_DAYSOFINITIALINSPECTION];
                float reInspectionDays      = DairyParameterBLL.GetCurrentParameterDictionary(UserBLL.Instance.CurrentUser.Pasture.ID)[FarmInfo.PN_DAYSOFREINSEPECTION];
                reinspectionTask.ArrivalTime = task.ArrivalTime.AddDays(reInspectionDays - initialInspectionDays);
                reinspectionTask.DeadLine    = reinspectionTask.ArrivalTime.AddDays(3.0);
                reinspectionTask.TaskType    = TaskType.ReInspectionTask;
                reinspectionTask.InputTime   = DateTime.Now;
                AddTask(reinspectionTask);
                //更新牛繁殖状态
                cowBLL.UpdateCowBreedStatus(task.EarNum, "初检+");
            }
            else
            {
                //更新牛繁殖状态
                cowBLL.UpdateCowBreedStatus(task.EarNum, "初检-");
            }
        }
コード例 #13
0
ファイル: TaskBLL.cs プロジェクト: vijaydairyf/cow-1
        /// <summary>
        /// 产后10天任务
        /// </summary>
        public void CompleteDay10AfterBorn(DairyTask task, int cowHouseId, int cowGroupId)
        {
            //此任务单在,产犊界面/事件中产生,或者流产早产;流产等会取消之前的未完成产前任务单
            //更新任务记录,标记完成
            task.Status       = DairyTaskStatus.Completed;
            task.CompleteTime = DateTime.Now;
            UpdateTask(task);

            //牛调群至,初产牛群或高产牛群
            DairyTask groupingTask = new DairyTask();

            groupingTask.TaskType = TaskType.GroupingTask;
            DateTime time = DateTime.Now;

            groupingTask.ArrivalTime = time;
            groupingTask.EarNum      = task.EarNum;
            groupingTask.DeadLine    = time.AddDays(1.0);
            AddTask(groupingTask);
            //取回这条任务
            DairyTask groupingTaskCopy = GetUnfinishedTasks(UserBLL.Instance.CurrentUser.Pasture.ID).Find(p => p.ArrivalTime == time && p.TaskType == TaskType.GroupingTask);
            //关联调群记录,任务单找到如何调群
            GroupingRecord groupingRecord = new GroupingRecord();

            groupingRecord.EarNum = groupingTaskCopy.EarNum;
            groupingRecord.TaskID = groupingTaskCopy.ID;
            CowBLL cowBLL = new CowBLL();
            Cow    myCow  = cowBLL.GetCowInfo(groupingTaskCopy.EarNum);

            groupingRecord.OriginalGroupID = myCow.GroupID;
            groupingRecord.OriginalHouseID = myCow.HouseID;
            groupingRecord.TargetGroupID   = cowGroupId;
            groupingRecord.TargetHouseID   = cowHouseId;
            GroupingRecordBLL gBLL = new GroupingRecordBLL();

            gBLL.InsertGroupingRecord(groupingRecord);
        }
コード例 #14
0
ファイル: HouseBLL.cs プロジェクト: vijaydairyf/cow-1
        public int GetCowNumberInHouse(House house)
        {
            CowBLL cb = new CowBLL();

            return(cb.GetCowNumberInHouse(house.PastureID, house.ID));
        }
コード例 #15
0
ファイル: TaskBLL.cs プロジェクト: vijaydairyf/cow-1
        /// <summary>
        /// 封装任务项
        /// </summary>
        /// <param name="row">数据行</param>
        /// <returns>任务</returns>
        public DairyTask WrapTaskItem(DataRow row)
        {
            DairyTask t = new DairyTask();

            if (row != null)
            {
                t.ID          = Convert.ToInt32(row["ID"]);
                t.ArrivalTime = Convert.ToDateTime(row["StartTime"]);
                t.DeadLine    = Convert.ToDateTime(row["DeadLine"]);
                switch (Convert.ToInt32(row["TaskStatus"]))
                {
                case 0:
                    t.Status = DairyTaskStatus.Initial;
                    break;

                case 1:
                    t.Status = DairyTaskStatus.Completed;
                    break;

                default:
                    break;
                }

                int taskTypeNum = Convert.ToInt32(row["TaskType"]);
                switch (taskTypeNum)
                {
                case 0:
                    t.TaskType = TaskType.InseminationTask;
                    break;

                case 1:
                    t.TaskType = TaskType.InitialInspectionTask;
                    break;

                case 2:
                    t.TaskType = TaskType.ReInspectionTask;
                    break;

                case 3:
                    t.TaskType = TaskType.Day21ToBornTask;
                    break;

                case 4:
                    t.TaskType = TaskType.Day7ToBornTask;
                    break;

                case 5:
                    t.TaskType = TaskType.Day3AfterBornTask;
                    break;

                case 6:
                    t.TaskType = TaskType.Day10AfterBornTask;
                    break;

                case 7:
                    t.TaskType = TaskType.Day15AfterBornTask;
                    break;

                case 8:
                    t.TaskType = TaskType.ImmuneTask;
                    break;

                case 9:
                    t.TaskType = TaskType.QuarantineTask;
                    break;

                case 10:
                    t.TaskType = TaskType.GroupingTask;
                    break;

                case 11:
                    t.TaskType = TaskType.CalfTask;
                    break;

                default:
                    break;
                }
                if (row["RoleID"] != DBNull.Value)
                {
                    t.RoleID = Convert.ToInt32(row["RoleID"]);
                }
                if (row["OperatorID"] != DBNull.Value)
                {
                    t.OperatorID = Convert.ToInt32(row["OperatorID"]);
                }
                if (row["FinishedTime"] != DBNull.Value)
                {
                    t.CompleteTime = Convert.ToDateTime(row["FinishedTime"]);
                }
                if (row["InputTime"] != DBNull.Value)
                {
                    t.InputTime = Convert.ToDateTime(row["InputTime"]);
                }
                if (row["EarNum"] != DBNull.Value)
                {
                    t.EarNum        = Convert.ToInt32(row["EarNum"]);
                    t.DisplayEarNum = CowBLL.ConvertEarNumToDisplayEarNum(t.EarNum);
                }
                if (row["PastureID"] != DBNull.Value)
                {
                    t.PastureID = Convert.ToInt32(row["PastureID"]);
                }
            }
            return(t);
        }