public ActionResult EditInspectInfo(string taskNumber, string employeeName, DateTime time)
        {
            if (Session["CheckFeed"] == null || !(bool) Session["EditInspectInfo"] ||
                !(bool) Session["CheckInspectInfo"])
            {
                Response.Write("<script>history.go(0);</script>");
                return View("Error");
            }

            InspectInfo checkInspectInfo = new InspectInfo().CheckInspectInfo(taskNumber, employeeName, time);
            if (checkInspectInfo == null)
            {
                ViewBag.Title = "查看修改失败,请重新操作";
                return View("Message");
            }

            ViewData["TaskNumber"] = checkInspectInfo.GetTaskNumberSelect(TaskTypeId);
            ViewData["pigsty"] = new ListService().GetFirstPigstyList();
            ViewData["Employee"] = new ListService().GetEmployeeList();
            ViewData["pighouse"] = new ListService().GetPigHouseList();
            ViewData["Exception"] = new ListService().GetExceptionTypeList();
            ViewData["SourceTime"] = time;
            ViewData["Name"] = checkInspectInfo.EmployeeName;
            ViewBag.Title = "修改巡查信息";
            return View("NewInspectInfo", checkInspectInfo);
        }
Beispiel #2
0
        /// <summary>
        ///     查看巡查信息
        /// </summary>
        /// <param name="taskNumber">任务编号</param>
        /// <param name="employeeName">人员名字</param>
        /// <param name="time">巡查时间</param>
        /// <returns></returns>
        public InspectInfo CheckInspectInfo(string taskNumber, string employeeName, DateTime time)
        {
            var inspectionService = new InspectionService();
            var inspectionExceptionService = new InspectionExceptionService();
            var exceptionService = new ExceptionTypeService();
            task task = new TaskService().FindByTaskNumber(taskNumber);
            var checkInspectInfo = new InspectInfo();
            checkInspectInfo.InspectDetail = new List<InspectDetail>();
            checkInspectInfo.TaskNumber = taskNumber;
            checkInspectInfo.EmployeeName = employeeName;

            if (task != null)
            {
                foreach (
                    inspection inspectionItem in
                        inspectionService.FindByTaskId(task.Id).OrderByDescending(m => m.Time).Where(
                            m => m.employee.Name.Equals(employeeName)))
                {
                    if (!time.Date.Equals(inspectionItem.Time.Date)) continue;
                    List<inspection_exception> exceptionList =
                        inspectionExceptionService.FindByInspectionId(inspectionItem.Id);
                    if (exceptionList.Count > 0)
                        foreach (var exceptionItem in inspectionExceptionService.GetPigstyInfoNums(inspectionItem))
                        {
                            checkInspectInfo.InspectDetail.Add(new InspectDetail
                                                                   {
                                                                       PigHouse =
                                                                           inspectionItem.pig_house.pig_house_type.Name
                                                                           + inspectionItem.pig_house.Number,
                                                                       Pigsty = exceptionItem.Value,
                                                                       DetailTime = inspectionItem.Time,
                                                                       InspectionException =
                                                                           exceptionService.Find(exceptionItem.Key).Name
                                                                   });
                        }
                    else
                        checkInspectInfo.InspectDetail.Add(new InspectDetail
                                                               {
                                                                   PigHouse =
                                                                       inspectionItem.pig_house.pig_house_type.Name
                                                                       + inspectionItem.pig_house.Number,
                                                                   Pigsty = "",
                                                                   DetailTime = inspectionItem.Time,
                                                                   InspectionException = "正常"
                                                               });
                }
                return checkInspectInfo;
            }
            return null;
        }
 public ActionResult EditInspectInfo(InspectInfo updateInspectInfo)
 {
     if (updateInspectInfo != null)
     {
         DateTime time = DateTime.Parse(Request.Form["SourceTime"]);
         string employeeName = Request.Form["Name"];
         if (updateInspectInfo.UpdateInspectInfo(updateInspectInfo, time, employeeName))
         {
             ViewBag.Title = "修改成功";
             return View("Message");
         }
     }
     ViewBag.Title = "查看修改失败,请重新操作";
     return View("Message");
 }
        public ActionResult CheckInspectInfo(string taskNumber, string employeeName, DateTime time)
        {
            if (Session["CheckFeed"] == null || !(bool) Session["CheckInspectInfo"])
            {
                Response.Write("<script>history.go(0);</script>");
                return View("Error");
            }

            InspectInfo checkInspectInfo = new InspectInfo().CheckInspectInfo(taskNumber, employeeName, time);
            if (checkInspectInfo != null)
            {
                ViewBag.Title = "查看巡查信息";
                return View(checkInspectInfo);
            }
            ViewBag.Title = "查看失败,请重新操作";
            return View("Message");
        }
Beispiel #5
0
        /// <summary>
        ///     新建巡查信息
        /// </summary>
        /// <param name="newInfo">巡查页面类</param>
        /// <returns></returns>
        public bool CreateInspectInfo(InspectInfo newInfo)
        {
            if (newInfo == null) return false;
            var inspectionService = new InspectionService();
            var taskStatusTypeService = new TaskStatusTypeService();
            var taskService = new TaskService();
            Dictionary<long, Dictionary<long, long>> pigstyAndexception = SortPigstyAndexception(newInfo);
            foreach (var inspectDetail in pigstyAndexception)
            {
                InspectDetail newInfoDetail =
                    newInfo.InspectDetail.FirstOrDefault(m => m.PigHouse.Equals(inspectDetail.Key + ""));
                if (newInfoDetail == null) continue;
                var inspection = new inspection
                                     {
                                         TaskId = long.Parse(newInfo.TaskNumber),
                                         EmployeeId = long.Parse(newInfo.EmployeeName),
                                         PigHouseId = inspectDetail.Key,
                                         Time = newInfoDetail.DetailTime,
                                         Memo = newInfo.Meno
                                     };

                foreach (var pigsty in inspectDetail.Value)
                {
                    inspection.inspection_exception.Add(new inspection_exception
                                                            {
                                                                PigstyId = pigsty.Key,
                                                                ExceptionTypeId = pigsty.Value
                                                            });
                }

                inspectionService.Insert(inspection);
            }
            task_status_type taskStatusType = taskStatusTypeService.FindByName("正在进行");
            task task = taskService.Find(long.Parse(newInfo.TaskNumber));
            if (taskStatusType != null && task != null)
            {
                task.TaskStatusId = taskStatusType.Id;
                taskService.Update(task);
            }
            return true;
        }
Beispiel #6
0
        /// <summary>
        ///     更新修改巡查信息
        /// </summary>
        /// <param name="updateInfo">巡查页面类</param>
        /// <returns></returns>
        public bool UpdateInspectInfo(InspectInfo updateInfo, DateTime time, string employeeName)
        {
            var inspectionService = new InspectionService();
            var inspectionExceptionService = new InspectionExceptionService();
            var taskService = new TaskService();
            int count = 0;
            task task = taskService.FindByTaskNumber(updateInfo.TaskNumber);
            if (task == null) return false;
            var pigHouse = new HashSet<long>();
            foreach (InspectDetail detail in updateInfo.InspectDetail)
                pigHouse.Add(long.Parse(detail.PigHouse));
            foreach (
                inspection inspection in
                    inspectionService.FindByTaskId(task.Id).Where(m => m.employee.Name.Equals(employeeName)))
            {
                if (!time.Date.Equals(inspection.Time.Date)) continue;
                if (count < pigHouse.Count)
                {
                    inspection.PigHouseId = pigHouse.ElementAtOrDefault(count);
                    inspection.Time = updateInfo.InspectDetail[count].DetailTime;
                    inspection.Memo = updateInfo.Meno;
                    inspectionService.Update(inspection);
                }
                else
                {
                    inspectionExceptionService.ClearInspectionException(inspection);
                    inspectionService = new InspectionService();
                    inspectionService.Delete(inspectionService.Find(inspection));
                }
                count++;
            }
            for (; count < pigHouse.Count; count++)
            {
                inspectionService.Insert(new inspection
                                             {
                                                 TaskId = task.Id,
                                                 EmployeeId = long.Parse(updateInfo.EmployeeName),
                                                 PigHouseId = long.Parse(updateInfo.InspectDetail[count].PigHouse),
                                                 Time = updateInfo.InspectDetail[count].DetailTime,
                                                 Memo = updateInfo.Meno
                                             });
            }

            Dictionary<long, Dictionary<long, long>> pigstyAndexception = SortPigstyAndexception(updateInfo);
            foreach (var exception in pigstyAndexception)
            {
                count = 0;
                inspection inspection =
                    inspectionService.FindByTaskId(task.Id).FirstOrDefault(m => m.employee.Name.Equals(employeeName)
                                                                                && m.Time.Date.Equals(time.Date) &&
                                                                                m.PigHouseId == exception.Key);
                if (inspection == null) continue;
                foreach (var l in exception.Value)
                {
                    if (count < inspection.inspection_exception.Count)
                    {
                        inspection_exception inspectionException =
                            inspectionExceptionService.FindByInspectionId(inspection.Id).ElementAtOrDefault(count);
                        if (inspectionException == null) continue;
                        inspectionException.PigstyId = l.Key;
                        inspectionException.ExceptionTypeId = l.Value;
                        inspectionExceptionService.Update(inspectionException);
                        count++;
                    }
                    else
                    {
                        var inspectionException = new inspection_exception
                                                      {
                                                          InspectionId = inspection.Id,
                                                          PigstyId = l.Key,
                                                          ExceptionTypeId = l.Value
                                                      };
                        inspectionExceptionService.Insert(inspectionException);
                    }
                }
                for (; count < inspection.inspection_exception.Count; count++)
                {
                    inspection_exception inspectionException =
                        inspectionExceptionService.FindByInspectionId(inspection.Id).FirstOrDefault();
                    if (inspectionException == null) continue;
                    inspectionExceptionService = new InspectionExceptionService();
                    inspectionExceptionService.Delete(inspectionExceptionService.Find(inspectionException.Id));
                }
            }

            return true;
        }
Beispiel #7
0
        /// <summary>
        ///     将页面的巡查类分类,以猪舍id为key,包含以猪栏id为key,异常类型id为值的字典集合
        /// </summary>
        /// <param name="info">页面的巡查</param>
        /// <returns></returns>
        public Dictionary<long, Dictionary<long, long>> SortPigstyAndexception(InspectInfo info)
        {
            var pigstyAndexception = new Dictionary<long, Dictionary<long, long>>();
            var pigstyService = new PigstyService();
            foreach (InspectDetail inspectDetail in info.InspectDetail)
            {
                var dic = new Dictionary<long, long>();
                if (inspectDetail.Pigsty != null)
                    foreach (string str in inspectDetail.Pigsty.Split(','))
                    {
                        if (str.Length > 0)
                        {
                            pigsty pigstyStr = pigstyService.GetPigsty(int.Parse(str),
                                                                       long.Parse(inspectDetail.PigHouse));
                            if (dic.ContainsKey(pigstyStr.Id)) continue;
                            dic.Add(pigstyStr.Id, long.Parse(inspectDetail.InspectionException));
                        }
                    }
                if (pigstyAndexception.ContainsKey(long.Parse(inspectDetail.PigHouse)))
                    foreach (var l in dic)
                    {
                        pigstyAndexception[long.Parse(inspectDetail.PigHouse)].Add(l.Key, l.Value);
                    }

                else
                    pigstyAndexception.Add(long.Parse(inspectDetail.PigHouse), dic);
            }
            return pigstyAndexception;
        }
 public ActionResult NewInspectInfo(InspectInfo newInfo)
 {
     if (newInfo != null)
     {
         if (newInfo.CreateInspectInfo(newInfo))
         {
             ViewBag.Title = "新建成功";
             return View("Message");
         }
     }
     ViewBag.Title = "新建失败,请重新操作";
     return View("Message");
 }
        public ActionResult NewInspectInfo()
        {
            if (Session["CheckFeed"] == null || !(bool) Session["AddInspectInfo"] || !(bool) Session["CheckInspectInfo"])
            {
                Response.Write("<script>history.go(0);</script>");
                return View("Error");
            }

            var newInfo = new InspectInfo();
            IEnumerable<SelectListItem> taskNumberList = newInfo.GetTaskNumberSelect(TaskTypeId);
            if (!taskNumberList.Any())
            {
                const string returnstring = "任务为空,请先添加任务";
                Response.Write("<script language='JavaScript'>alert('" + returnstring + ".');history.go(-1);</script>");
                return Content("");
            }
            ViewData["TaskNumber"] = newInfo.GetTaskNumberSelect(TaskTypeId);
            ViewData["pigsty"] = new ListService().GetFirstPigstyList();
            ViewData["Employee"] = new ListService().GetEmployeeList();
            ViewData["pighouse"] = new ListService().GetPigHouseList();
            ViewData["Exception"] = new ListService().GetExceptionTypeList();
            ViewBag.Title = "新建巡查信息";
            return View(newInfo);
        }
        public ActionResult InspectInfo(int pageIndex = 1)
        {
            if (Session["CheckFeed"] == null || !(bool) Session["CheckInspectInfo"])
            {
                Response.Write("<script>history.go(0);</script>");
                return View("Error");
            }

            var inspectInfoList = new InspectInfo();
            const int pageSize = 25;

            PagedList<Info> infoPagerList;
            if (Request.Form["CheckEmployee"] != null)
            {
                //Session["InspectChoose"] = Request.Form["SearchChose"];
                Session["check"] = Request.Form["CheckEmployee"];
                Session["chooseid"] = Request.Form["SearchChose"];
                infoPagerList =
                    inspectInfoList.GetInfoPagedList(
                        inspectInfoList.GetInfoList(inspectInfoList.GetInspectInfoList(), Request.Form["CheckEmployee"],
                                                    Request.Form["SearchChose"]),
                        pageIndex, pageSize);
                //  Session["SearchInspect"] = Request.Form["CheckEmployee"];
            }
            else if (Session["check"] != null && Session["chooseid"] != null && Request.HttpMethod == "POST")
            {
                infoPagerList =
                    inspectInfoList.GetInfoPagedList(
                        inspectInfoList.GetInfoList(inspectInfoList.GetInspectInfoList(),
                                                    Session["check"] as string, Session["chooseid"] as string),
                        pageIndex, pageSize);
            }
            else
            {
                //Session["InspectChoose"] = new ListService().GetInfoSearchList().FirstOrDefault().Value;
                Session["check"] = "";
                Session["chooseid"] = "";
                infoPagerList = inspectInfoList.GetInfoPagedList(inspectInfoList.GetInspectInfoList(), pageIndex,
                                                                 pageSize);
            }

            if (Request.IsAjaxRequest())
            {
                return PartialView("UCJqInfoList", infoPagerList);
            }
            ViewData["Search"] = new ListService().GetInfoSearchList();
            return View(infoPagerList);
        }