예제 #1
0
        public JsonResult LoadTask(string taskID)
        {
            TaskBLL   bll = new TaskBLL();
            DairyTask v;

            v = bll.GetTaskByID(Int32.Parse(taskID));
            string displayEarNum = CowBLL.ConvertEarNumToDisplayEarNum(v.EarNum);

            GroupingRecordBLL grbBLL   = new GroupingRecordBLL();
            GroupingRecord    gr       = grbBLL.GetGroupingRecordByTaskID(Int32.Parse(taskID));
            CowGroupBLL       cgBLL    = new CowGroupBLL();
            HouseBLL          hBLL     = new HouseBLL();
            CowGroup          oldgroup = cgBLL.GetCowGroupInfo(gr.OriginalGroupID);
            CowGroup          newgroup = cgBLL.GetCowGroupInfo(gr.TargetGroupID);
            House             oldhouse = hBLL.GetHouseByID(UserBLL.Instance.CurrentUser.Pasture.ID, gr.OriginalHouseID);
            House             newhouse = hBLL.GetHouseByID(UserBLL.Instance.CurrentUser.Pasture.ID, gr.TargetHouseID);

            return(Json(new
            {
                EarNum = v.EarNum,
                DisplayEarNum = displayEarNum,
                ArrivalTime = v.ArrivalTime.ToString("yyyy-MM-dd"),
                Operator = v.OperatorID,
                OldGroup = oldgroup.Name,
                OldHouse = oldhouse.Name,
                NewGroup = newgroup.Name,
                NewHouse = newhouse.Name
            }, JsonRequestBehavior.AllowGet));
        }
예제 #2
0
        /// <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);
        }
예제 #3
0
        public GroupingRecord WrapGroupingRecord(DataRow row)
        {
            GroupingRecord r = new GroupingRecord();

            r.TaskID          = Convert.ToInt32(row["TaskID"]);
            r.EarNum          = Convert.ToInt32(row["EarNum"]);
            r.TargetGroupID   = Convert.ToInt32(row["TargetGroupID"]);
            r.TargetHouseID   = Convert.ToInt32(row["TargetHouseID"]);
            r.OriginalGroupID = Convert.ToInt32(row["OriginalGroupID"]);
            r.OriginalHouseID = Convert.ToInt32(row["OriginalHouseID"]);
            return(r);
        }
예제 #4
0
        /// <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);
        }
예제 #5
0
        /// <summary>
        /// 插入转群任务
        /// </summary>
        /// <returns></returns>
        public JsonResult InsertChangeGroupTask()
        {
            bool    bResult    = false;
            int     earNum     = CowBLL.ConvertDislayEarNumToEarNum(Request["DisplayEarNum"].ToString(), UserBLL.Instance.CurrentUser.Pasture.ID);
            int     pastureID  = UserBLL.Instance.CurrentUser.Pasture.ID;
            TaskBLL bllTask    = new TaskBLL();
            int     operatorID = bllTask.AssignTask(pastureID, earNum, Role.FARM_FEEDER_ID);

            if (earNum != 0)
            {
                DairyTask t = new DairyTask
                {
                    EarNum      = earNum,
                    TaskType    = TaskType.GroupingTask,
                    Status      = DairyTaskStatus.Initial,
                    PastureID   = pastureID,
                    OperatorID  = operatorID,
                    ArrivalTime = DateTime.Now, //转群当天要做
                    InputTime   = DateTime.Now,
                    DeadLine    = DateTime.Now.AddDays(15)
                };

                bResult = bllTask.AddTask(t);

                GroupingRecord gRecord = new GroupingRecord
                {
                    TaskID          = t.ID,
                    EarNum          = t.EarNum,
                    TargetGroupID   = Convert.ToInt32(Request["TargetGroupID"]),
                    TargetHouseID   = Convert.ToInt32(Request["TargetHouseID"]),
                    OriginalGroupID = Convert.ToInt32(Request["OriginalGroupID"]),
                    OriginalHouseID = Convert.ToInt32(Request["OriginalHouseID"])
                };

                GroupingRecordBLL bllGroupingRecord = new GroupingRecordBLL();
                bllGroupingRecord.InsertGroupingRecord(gRecord);
            }

            return(Json(bResult, JsonRequestBehavior.AllowGet));
        }
예제 #6
0
        /// <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);
        }
예제 #7
0
 public int InsertGroupingRecord(GroupingRecord record)
 {
     return(groupingDAL.InsertGroupingRecord(record.TaskID, record.EarNum, record.TargetGroupID, record.TargetHouseID, record.OriginalGroupID, record.OriginalHouseID));
 }