/// <summary> /// 查看转栏信息 /// </summary> /// <param name="taskNumber">任务编号</param> /// <returns></returns> public TransferPigstyInfo CheckTransferPigstyInfo(string taskNumber) { var checkTransferPigstyInfo = new TransferPigstyInfo {TransferPigstyInfoDetail = new List<TransferPigstyInfoDetail>()}; var taskEmployee = new TaskEmployeeService(); var taskService = new TaskService(); var transferService = new TransferService(); task transferPigstyTask = taskService.FindByTaskNumber(taskNumber); if (transferPigstyTask != null) { checkTransferPigstyInfo.TaskNumber = taskNumber; checkTransferPigstyInfo.EmployeeName = taskEmployee.GetEmployeeNames(transferPigstyTask.Id); transfer firstOrDefault = transferService.FindByTaskId(transferPigstyTask.Id).FirstOrDefault(); if (firstOrDefault != null) checkTransferPigstyInfo.Meno = firstOrDefault.Memo; foreach ( transfer transfer in transferService.FindByTaskId(transferPigstyTask.Id).OrderByDescending(m => m.Time)) { transfer lastPigsty = transferService.GetLastTransfer(transfer.PigId, transferPigstyTask.Id); if (lastPigsty != null && lastPigsty.pigsty.Id != transfer.pigsty.Id) checkTransferPigstyInfo.TransferPigstyInfoDetail.Add(new TransferPigstyInfoDetail { SourcePigHouse = lastPigsty.pigsty.pig_house. pig_house_type.Name + lastPigsty.pigsty.pig_house. Number, SourcePigsty = lastPigsty.pigsty.Number + "", Pig = transfer.pig.Number, TargetPigHouse = transfer.pigsty.pig_house. pig_house_type.Name + transfer.pigsty.pig_house. Number, TargetPigsty = transfer.pigsty.Number + "", TransferPigstyTime = transfer.Time }); else checkTransferPigstyInfo.TransferPigstyInfoDetail.Add(new TransferPigstyInfoDetail { SourcePigHouse = "", SourcePigsty = "", Pig = transfer.pig.Number, TargetPigHouse = transfer.pigsty.pig_house. pig_house_type.Name + transfer.pigsty.pig_house. Number, TargetPigsty = transfer.pigsty.Number + "", TransferPigstyTime = transfer.Time }); } } return checkTransferPigstyInfo; }
public InspectTask GetInspectTask(string taskNumber) { var taskService = new TaskService(); task task = taskService.FindByTaskNumber(taskNumber); if (task == null) { return null; } var taskEmployeeService = new TaskEmployeeService(); var taskPigHouseService = new TaskPigHouseService(); var checkTask = new InspectTask { TaskNumber = task.TaskNumber, StartTime = task.StartTime, EndTime = task.EndTime, EmployeeName = taskEmployeeService.GetEmployeeNames(task.Id), EmployeeNumber = taskEmployeeService.GetEmployeeNumbers(task.Id), PigHouse = taskPigHouseService.GetPigHouseTypeAndNumsByTaskId(task.Id), PigHouseId = taskPigHouseService.GetPigHouseIds(task.Id), Status = task.task_status_type.Name, Memo = task.Memo }; List<TaskCycle> taskCycle = task.task_interval_cycle.Select(taskCycleitem => new TaskCycle { FirstExecuteDate = taskCycleitem . FirstExecuteDate, CycleDays = taskCycleitem . CycleDays }).ToList(); if (taskCycle.Count != 0) { checkTask.InspectTaskCycle = taskCycle; } return checkTask; }
/// <summary> /// 查看销售任务 /// </summary> /// <param name="taskNumber">任务编号</param> /// <returns></returns> public SaleTask GetSaleTask(string taskNumber) { var taskService = new TaskService(); var taskEmployeeService = new TaskEmployeeService(); var pigTypeService = new PigTypeService(); task task = taskService.FindByTaskNumber(taskNumber); if (task == null) { return null; } var customerService = new CustomerService(); var checkTask = new SaleTask { TaskNumber = task.TaskNumber, StartTime = task.StartTime, EndTime = task.EndTime, EmployeeName = taskEmployeeService.GetEmployeeNames(task.Id), EmployeeNumber = taskEmployeeService.GetEmployeeNumbers(task.Id), Customer = customerService.Find(task.CustomerId).Name, Status = task.task_status_type.Name, Memo = task.Memo }; List<SaleDetail> saleDetailList = task.sale_task_quality.Select(item => new SaleDetail { PigType = pigTypeService.Find( item.PigTypeId).Name, Price = item.Price, Quantity = item.Quality }).ToList(); if (saleDetailList.Count != 0) { checkTask.SaleDetailList = saleDetailList; } return checkTask; }
/// <summary> /// 查看淘汰任务 /// </summary> /// <param name="taskNumber">任务编号</param> /// <returns></returns> public EliminateTask GetEliminateTask(string taskNumber) { var taskService = new TaskService(); var taskEmployeeService = new TaskEmployeeService(); task task = taskService.FindByTaskNumber(taskNumber); if (task == null) { return null; } var customerService = new CustomerService(); var checkTask = new EliminateTask { TaskNumber = task.TaskNumber, StartTime = task.StartTime, EndTime = task.EndTime, EmployeeName = taskEmployeeService.GetEmployeeNames(task.Id), EmployeeNumber = taskEmployeeService.GetEmployeeNumbers(task.Id), Status = task.task_status_type.Name, Memo = task.Memo }; var transferService = new TransferService(); var pigstyDic = new Dictionary<long, StringBuilder>(); foreach (task_pig item in task.task_pig) { transfer transfer = transferService.GetLastTransfer(item.PigId, task.Id); if (transfer == null) { continue; } long pigsty = transfer.PigstyId; if (!pigstyDic.ContainsKey(pigsty)) { pigstyDic.Add(pigsty, new StringBuilder().Append(transfer.pig.Number)); } else { pigstyDic[pigsty].Append("," + transfer.pig.Number); } } foreach (task_pigsty item in task.task_pigsty) { long pigsty = item.PigstyId; pigstyDic.Add(pigsty, new StringBuilder().Append("")); } var pigHouseService = new PigHouseService(); var pigstyService = new PigstyService(); if (pigstyDic.Count != 0) { checkTask.EliminateTaskDetail = (from builder in pigstyDic let pigHouse = pigHouseService.FindbyPigstyId(builder.Key) select new TaskDetail { PigHouse = pigHouse.pig_house_type.Name + pigHouse.Number, Pigsty = pigstyService.Find(builder.Key).Number + "", Pig = builder.Value.ToString() }).ToList(); } return checkTask; }
/// <summary> /// 根据任务id找到人员名字 /// </summary> /// <param name="taskId">任务id</param> /// <returns>人员名字的字符串</returns> public string GetTaskEmployee(int taskId) { var taskEmployeeService = new TaskEmployeeService(); return taskEmployeeService.GetEmployeeNames(taskId); }
/// <summary> /// 查看喂食任务 /// </summary> /// <param name="taskNumber">任务编号</param> /// <returns></returns> public FeedTask GetFeedTask(string taskNumber) { var taskService = new TaskService(); var taskEmployeeService = new TaskEmployeeService(); var pigHouseService = new PigHouseService(); task task = taskService.FindByTaskNumber(taskNumber); var feedTaskQualityService = new FeedTaskQualityService(); if (task == null) { return null; } var feedTask = new FeedTask { TaskNumber = task.TaskNumber, StartTime = task.StartTime, EndTime = task.EndTime, EmployeeName = taskEmployeeService.GetEmployeeNames(task.Id), EmployeeNumber = taskEmployeeService.GetEmployeeNumbers(task.Id), Status = task.task_status_type.Name, Memo = task.Memo }; List<FeedTaskDetail> taskDetailList = (from item in feedTaskQualityService.GetPigstyByHouse(task.Id) let keys = item.Key.Split('|') let pigHouse = pigHouseService.Find(long.Parse(keys[0])) let pigsty = item.Value.Remove(item.Value.Length - 1) select new FeedTaskDetail { PigHouse = pigHouse.pig_house_type.Name + pigHouse.Number, Pigsty = pigsty, Fodder = keys[1] }).ToList(); //var taskDetailList = new List<FeedTaskDetail>(); //foreach (var item in feedTaskQualityService.GetPigstyByHouse(task.Id)) //{ // string[] keys = item.Key.Split('|'); // pig_house pigHouse = pigHouseService.Find(long.Parse(keys[0])); // string pigsty = item.Value.Remove(item.Value.Length - 1); // taskDetailList.Add(new FeedTaskDetail // { // PigHouse = pigHouse.pig_house_type.Name + pigHouse.Number, // Pigsty = pigsty, // Fodder = keys[1] // }); //} List<TaskCycle> taskCycleList = task.task_interval_cycle.Select(taskCycleitem => new TaskCycle { FirstExecuteDate = taskCycleitem . FirstExecuteDate, CycleDays = taskCycleitem . CycleDays }).ToList(); if (taskDetailList.Count > 0) { feedTask.Feeddetails = taskDetailList; } if (taskCycleList.Count > 0) { feedTask.FeedTaskCycle = taskCycleList; } return feedTask; }
/// <summary> /// 转栏息管理列表 /// </summary> /// <returns></returns> public IEnumerable<Info> GetTransferPigstyInfoList() { var transferService = new TransferService(); var taskService = new TaskService(); var taskEmployeeService = new TaskEmployeeService(); var transferInfoList = new List<Info>(); IOrderedEnumerable<transfer> transferServiceAll = transferService.FindAll().OrderByDescending(m => m.Time); long taskId = 0; foreach (transfer transferInfoitem in transferServiceAll) { if (taskId == transferInfoitem.TaskId || transferInfoitem.task.TaskTypeId == 7) continue; transferInfoList.Add(new Info { TaskNumber = taskService.Find(transferInfoitem.TaskId).TaskNumber, EmployeeName = taskEmployeeService.GetEmployeeNames( taskService.Find(transferInfoitem.TaskId).Id), Time = transferInfoitem.Time, Meno = transferInfoitem.Memo }); taskId = transferInfoitem.TaskId; } return transferInfoList; }
/// <summary> /// 获得指定任务类型的所有任务 /// </summary> /// <param name="taskTypeId">任务类型Id</param> /// <returns>返回任务集合</returns> public IEnumerable<Task> GetTaskList(long taskTypeId) { var taskService = new TaskService(); var taskStatusTypeService = new TaskStatusTypeService(); var taskEmployeeService = new TaskEmployeeService(); IEnumerable<Task> tasklist = taskService.FindByTaskTypeId(taskTypeId).Select(item => new Task { TaskNumber = item. TaskNumber, EmployeeName = taskEmployeeService . GetEmployeeNames ( item.Id), StartTime = item. StartTime, EndTime = item. EndTime, Status = taskStatusTypeService . Find( item. TaskStatusId) .Name, Memo = item.Memo }); return tasklist; }
public TransferTask GetTransferTask(string taskNumber) { var taskService = new TaskService(); var taskEmployeeService = new TaskEmployeeService(); task task = taskService.FindByTaskNumber(taskNumber); if (task == null) { return null; } var checkTask = new TransferTask { TaskNumber = task.TaskNumber, StartTime = task.StartTime, EndTime = task.EndTime, EmployeeName = taskEmployeeService.GetEmployeeNames(task.Id), EmployeeNumber = taskEmployeeService.GetEmployeeNumbers(task.Id), Status = task.task_status_type.Name, Memo = task.Memo }; var transferService = new TransferService(); var pigstyDic = new Dictionary<long, StringBuilder>(); foreach (task_pig item in task.task_pig) { transfer transfer = transferService.GetLastTransfer(item.PigId, task.Id); if (transfer == null) { continue; } long pigsty = transfer.PigstyId; if (!pigstyDic.ContainsKey(pigsty)) { pigstyDic.Add(pigsty, new StringBuilder().Append(transfer.pig.Number)); } else { pigstyDic[pigsty].Append("," + transfer.pig.Number); } } var pigHouseService = new PigHouseService(); var pigstyService = new PigstyService(); if (pigstyDic.Count != 0) { List<TaskDetail> transferFromList = (from builder in pigstyDic let pigHouse = pigHouseService.FindbyPigstyId(builder.Key) select new TaskDetail { PigHouse = pigHouse.pig_house_type.Name + pigHouse.Number, Pigsty = pigstyService.Find(builder.Key).Number + "", Pig = builder.Value.ToString() }).ToList(); checkTask.TransferFrom = transferFromList; } var transferToList = new List<TaskDetail>(); var pigHouseDic = new Dictionary<string, StringBuilder>(); foreach (task_pigsty taskPigsty in task.task_pigsty) { pig_house pigHouse = pigHouseService.FindbyPigstyId(taskPigsty.PigstyId); if (pigHouse == null) { continue; } string pigHouseStr = pigHouse.pig_house_type.Name + pigHouse.Number; if (!pigHouseDic.ContainsKey(pigHouseStr)) { pigHouseDic.Add(pigHouseStr, new StringBuilder().Append(taskPigsty.pigsty.Number)); } else { pigHouseDic[pigHouseStr].Append("," + taskPigsty.pigsty.Number); } } if (pigHouseDic.Count != 0) { transferToList.AddRange(pigHouseDic.Select(builder => new TaskDetail { PigHouse = builder.Key, Pigsty = builder.Value.ToString() })); checkTask.TransferTo = transferToList; } return checkTask; }
public PagedList<Task> GetTaskPagedList(long taskTypeId, int pageIndex, int pageSize, string check, int searchItem) { var taskService = new TaskService(); var taskStatusTypeService = new TaskStatusTypeService(); var taskEmployeeService = new TaskEmployeeService(); PagedList<task> tasks = taskService.GetTaskPagedList(taskTypeId, pageIndex, pageSize, check, searchItem); IEnumerable<Task> taskList = tasks.Select(item => new Task { TaskNumber = item. TaskNumber, EmployeeName = taskEmployeeService . GetEmployeeNames ( item.Id), StartTime = item. StartTime, EndTime = item. EndTime, Status = taskStatusTypeService . Find( item. TaskStatusId) .Name, Memo = item.Memo }); return new PagedList<Task>(taskList, pageIndex, pageSize, tasks.TotalItemCount); }
public ActionResult NewTransferPigstyInfo() { if (Session["CheckFeed"] == null || !(bool) Session["AddTransferPigstyInfo"] || !(bool) Session["CheckTransferPigstyInfo"]) { Response.Write("<script>history.go(0);</script>"); return View("Error"); } var newTransferPigstyInfo = new TransferPigstyInfo(); var taskEmployee = new TaskEmployeeService(); IEnumerable<SelectListItem> taskNumberList = newTransferPigstyInfo.GetTaskNumberSelect(TaskTypeId); if (!taskNumberList.Any()) { const string returnstring = "任务为空,请先添加任务"; Response.Write("<script language='JavaScript'>alert('" + returnstring + ".');history.go(-1);</script>"); return Content(""); } SelectListItem firstOrDefault = newTransferPigstyInfo.GetTaskNumberSelect(TaskTypeId).FirstOrDefault(); if (firstOrDefault != null) newTransferPigstyInfo.EmployeeName = taskEmployee.GetEmployeeNames(long.Parse(firstOrDefault.Value)); ViewData["pigsty"] = new ListService().GetFirstPigstyList(); ViewData["pighouse"] = new ListService().GetPigHouseList(); ViewData["pig"] = new ListService().GetFirstPigList(); ViewData["taskNumber"] = newTransferPigstyInfo.GetTaskNumberSelect(TaskTypeId); ViewBag.Title = "新建转栏信息"; return View(newTransferPigstyInfo); }
/// <summary> /// 查看喂食任务 /// </summary> /// <param name="taskNumber">任务编号</param> /// <returns></returns> public AddPigTask GetAddPigTask(string taskNumber) { var taskService = new TaskService(); var taskEmployeeService = new TaskEmployeeService(); task task = taskService.FindByTaskNumber(taskNumber); if (task == null) { return null; } var checkTask = new AddPigTask { TaskNumber = task.TaskNumber, StartTime = task.StartTime, EndTime = task.EndTime, EmployeeName = taskEmployeeService.GetEmployeeNames(task.Id), EmployeeNumber = taskEmployeeService.GetEmployeeNumbers(task.Id), Status = task.task_status_type.Name, Memo = task.Memo }; var pigHouseService = new PigHouseService(); var taskPigstyService = new TaskPigstyService(); List<task_pigsty> taskPigsties = task.task_pigsty.ToList(); List<TaskDetail> taskDetailList = taskPigstyService.GetPigHouseIds(taskPigsties).Select(pigHouseid => new TaskDetail { PigHouse = pigHouseService . Find (pigHouseid) . pig_house_type . Name + pigHouseService . Find (pigHouseid) . Number, Pigsty = taskPigstyService . GetPigstyNums (task .Id, pigHouseid), PigNum = taskPigstyService . GetPigstyCapacitySum (task .Id, pigHouseid) }).ToList(); if (taskDetailList.Count != 0) { checkTask.TaskDetails = taskDetailList; } return checkTask; }
public object GetCureTask(string taskNumber) { var taskService = new TaskService(); var taskEmployeeService = new TaskEmployeeService(); task task = taskService.FindByTaskNumber(taskNumber); if (task == null) { return null; } var checkTask = new CureTask { TaskNumber = task.TaskNumber, StartTime = task.StartTime, EndTime = task.EndTime, EmployeeName = taskEmployeeService.GetEmployeeNames(task.Id), EmployeeNumber = taskEmployeeService.GetEmployeeNumbers(task.Id), Status = task.task_status_type.Name, Memo = task.Memo }; var transferService = new TransferService(); var pigstyDic = new Dictionary<long, StringBuilder>(); foreach (task_pig item in task.task_pig) { transfer transfer = transferService.GetLastTransfer(item.PigId, task.Id); if (transfer == null) { continue; } long pigsty = transfer.PigstyId; if (!pigstyDic.ContainsKey(pigsty)) { pigstyDic.Add(pigsty, new StringBuilder().Append(transfer.pig.Number)); } else { pigstyDic[pigsty].Append("," + transfer.pig.Number); } } var pigHouseService = new PigHouseService(); var pigstyService = new PigstyService(); if (pigstyDic.Count != 0) { checkTask.CureDetail = (from builder in pigstyDic let pigHouse = pigHouseService.FindbyPigstyId(builder.Key) select new TaskDetail { PigHouse = pigHouse.pig_house_type.Name + pigHouse.Number, Pigsty = pigstyService.Find(builder.Key).Number + "", Pig = builder.Value.ToString() }).ToList(); } List<CureCourse> courseList = (from cureCourse in task.cure_task_course let methodList = (from cureMethod in cureCourse.cure_task_method let medicineList = cureMethod.cure_task_medicine.Select( cureTaskMedicine => new Medicine { MedicineName = cureTaskMedicine. medicine.Name, Quality = cureTaskMedicine. Quality, Unit = cureTaskMedicine. unit.Name }).ToList() select new CureMethod { CureMedicine = medicineList, CureType = cureMethod.cure_type.Name }).ToList() select new CureCourse { CureOrder = cureCourse.Order, CureTime = cureCourse.Time, CureMethod = methodList }).ToList(); if (courseList[0].CureMethod.Count != 0 && courseList[0].CureMethod[0].CureMedicine.Count != 0) { checkTask.CureCourse = courseList; } return checkTask; }
public PreventionDiseaseTask GetPreventionDiseaseTask(string taskNumber) { var taskService = new TaskService(); task task = taskService.FindByTaskNumber(taskNumber); if (task == null) { return null; } var taskEmployeeService = new TaskEmployeeService(); List<task_pigsty> taskPigsties = task.task_pigsty.ToList(); var checkTask = new PreventionDiseaseTask { TaskNumber = task.TaskNumber, StartTime = task.StartTime, EndTime = task.EndTime, EmployeeName = taskEmployeeService.GetEmployeeNames(task.Id), EmployeeNumber = taskEmployeeService.GetEmployeeNumbers(task.Id), Status = task.task_status_type.Name, Memo = task.Memo }; task_prevention taskPrevention = task.task_prevention.FirstOrDefault(); if (taskPrevention != null) { checkTask.DiseaseName = taskPrevention.prevention_type.Name; checkTask.Medicine.MedicineName = new MedicineService().Find(taskPrevention.prevention_type.MedicineId).Name; checkTask.Medicine.Quality = taskPrevention.prevention_type.Quality; checkTask.Medicine.Unit = new UnitService().Find(taskPrevention.prevention_type.UnitId).Name; } var pigHouseService = new PigHouseService(); var taskPigstyService = new TaskPigstyService(); var taskPigService = new TaskPigService(); List<TaskDetail> details = taskPigstyService.GetPigHouseIds(taskPigsties).Select(pigHouseid => new TaskDetail { PigHouse = pigHouseService . Find (pigHouseid) . pig_house_type . Name + pigHouseService . Find (pigHouseid) . Number, Pigsty = taskPigstyService . GetPigstyNums (task .Id, pigHouseid), Pig = taskPigService.GetMumPigBypigStys( taskPigstyService.GetPigstyNums(task.Id, pigHouseid) , pigHouseid) }).ToList(); foreach (var munPigHouseId in taskPigService.GetPigHouseByMum(task.Id)) { details.Add(new TaskDetail() { PigHouse = pigHouseService.Find(munPigHouseId).pig_house_type.Name+pigHouseService.Find(munPigHouseId).Number, Pigsty = taskPigService.GetPigstyNumsByMum(task.Id, munPigHouseId), Pig = "母猪" }); } if (details.Count != 0) { checkTask.Taskdetails = details; } return checkTask; }