Beispiel #1
0
        /// <summary>
        /// 创建新年度计划
        /// </summary>
        /// <param name="lastPlan"></param>
        /// <param name="allPlanHistories"></param>
        /// <param name="newAnnual"></param>
        /// <returns></returns>
        internal PlanDTO CreateNewYearPlan(PlanDTO lastPlan, QueryableDataServiceCollectionView<PlanHistoryDTO> allPlanHistories, AnnualDTO newAnnual)
        {
            var title = newAnnual.Year + "年度运力规划";
            // 从当前计划复制生成新年度计划
            var newPlan = new PlanDTO
            {
                Id = Guid.NewGuid(),
                Title = title,
                CreateDate = DateTime.Now,
                AnnualId = newAnnual.Id,
                Year = newAnnual.Year,
                AirlinesId = lastPlan.AirlinesId,
                AirlinesName = lastPlan.AirlinesName,
                VersionNumber = 1,
                Status = (int)PlanStatus.草稿,
                IsValid = false,
                IsFinished = false,
                PublishStatus = (int)PlanPublishStatus.待发布,
            };
            // 获取需要滚动到下一年度的计划明细项(可再次申请的计划明细不滚动到下一年度,并将对应的计划飞机置为预备状态)
            var lastPhs = allPlanHistories.Where(p => p.PlanId == lastPlan.Id).ToList();
            var planHistories = (lastPhs == null) ? null : lastPhs.Where(o => o.PlanAircraftId == null ||
                                           (o.PlanAircraftId != null && (o.ManageStatus != (int)ManageStatus.预备
                                                                       && o.ManageStatus != (int)ManageStatus.运营
                                                                       && o.ManageStatus != (int)ManageStatus.退役))).ToList();

            var resultphs = new List<PlanHistoryDTO>();
            if (planHistories != null)
                // 从当前计划往新版本计划复制运营计划
                resultphs = planHistories.Where(ph => ph.RelatedGuid == null || ph.RelatedEndDate == null)
                      .Select(q => new PlanHistoryDTO
                      {
                          PlanId = newPlan.Id,
                          Id = Guid.NewGuid(),
                          ActionCategoryId = q.ActionCategoryId,
                          AircraftTypeId = q.AircraftTypeId,
                          AirlinesId = q.AirlinesId,
                          CarryingCapacity = q.CarryingCapacity,
                          SeatingCapacity = q.SeatingCapacity,
                          RelatedGuid = q.RelatedGuid,
                          RelatedEndDate = q.RelatedEndDate,
                          IsSubmit = q.IsSubmit,
                          IsValid = q.IsValid,
                          Note = q.Note,
                          PerformAnnualId = q.PerformAnnualId,
                          PerformMonth = q.PerformMonth,
                          PlanAircraftId = q.PlanAircraftId,
                          PlanType = q.PlanType,
                          TargetCategoryId = q.TargetCategoryId,
                          AirlinesName = q.AirlinesName,
                          Regional = q.Regional,
                          AircraftTypeName = q.AircraftTypeName,
                          CaacAircraftTypeName = q.CaacAircraftTypeName,
                          ActionType = q.ActionType,
                          ActionName = q.ActionName,
                          TargetType = q.TargetType,
                          Year = q.Year,
                          ManageStatus = q.ManageStatus,
                      }).ToList();
            resultphs.ForEach(allPlanHistories.AddNew);
            return newPlan;
        }
Beispiel #2
0
        /// <summary>
        /// 创建运营计划明细
        /// 同一架计划飞机在一份计划中的明细项不得超过两条,且两条不得为同种操作类型(含运营计划与变更计划)
        /// </summary>
        /// <param name="plan"></param>
        /// <param name="allPlanHistories"></param>
        /// <param name="planAircraft"></param>
        /// <param name="aircraft"></param>
        /// <param name="actionType"></param>
        /// <param name="planType"></param>
        /// <param name="service"></param>
        /// <returns></returns>
        internal PlanHistoryDTO CreatePlanHistory(PlanDTO plan, QueryableDataServiceCollectionView<PlanHistoryDTO> allPlanHistories, ref PlanAircraftDTO planAircraft, AircraftDTO aircraft, string actionType, int planType, IFleetPlanService service)
        {
            if (plan == null) return null;
            // 创建新的计划历史
            var planDetail = new PlanHistoryDTO
            {
                Id = Guid.NewGuid(),
                PlanId = plan.Id,
                AirlinesId = plan.AirlinesId,
                AirlinesName = plan.AirlinesName,
                PerformAnnualId = plan.AnnualId,
                PerformMonth = 1,
                PlanType = planType,
                ActionType = actionType,
                ManageStatus = (int)ManageStatus.计划,
                CanRequest = (int)CanRequest.未报计划,
                CanDeliver = (int)CanDeliver.未申请,
            };

            planDetail.ActionCategories = service.GetActionCategoriesForPlanHistory(planDetail);
            planDetail.AircraftCategories = service.GetAircraftCategoriesForPlanHistory(planDetail);
            planDetail.AircraftTypes = service.GetAircraftTypesForPlanHistory(planDetail);

            // 1、计划飞机为空
            if (planAircraft == null)
            {
                planAircraft = new PlanAircraftDTO
                {
                    Id = Guid.NewGuid(),
                    AirlinesId = plan.AirlinesId,
                    AirlinesName = plan.AirlinesName,
                    Status = (int)ManageStatus.计划,
                    IsOwn = true
                };
                planDetail.PlanAircraftId = planAircraft.Id;
            }
            // 2、计划飞机非空
            else
            {
                // 获取计划飞机的所有计划明细集合
                Guid planAcId = planAircraft.Id;
                var planAcPhs = allPlanHistories.Where(p => p.PlanAircraftId == planAcId).ToList();
                // 获取计划飞机在当前计划中的计划明细集合
                PlanAircraftDTO dto = planAircraft;
                var currentPhs = allPlanHistories.Where(p => p.PlanId == plan.Id).ToList();
                var planDetails = currentPhs.Where(ph => ph.PlanAircraftId == dto.Id).ToList();
                // 2.1、不是针对现有飞机的计划明细
                if (planAircraft.AircraftId == null && aircraft == null)
                {
                    if (planAcPhs.Any())
                    {
                        // 获取计划飞机的最后一条计划明细,用于复制数据
                        var planHistory =
                            planAcPhs.OrderBy(ph => ph.Year)
                               .ThenBy(ph => ph.PerformMonth)
                               .LastOrDefault();
                        if (planHistory != null)
                        {
                            // 1、计划飞机在当前计划中没有明细项,(20140106补充)是预备状态的计划飞机
                            if (!planDetails.Any())
                            {
                                planDetail.AircraftTypeId = planAircraft.AircraftTypeId;
                                planDetail.ActionCategoryId = planHistory.ActionCategoryId;
                                planDetail.ActionType = planHistory.ActionType;
                                planDetail.TargetCategoryId = planHistory.TargetCategoryId;
                                planDetail.TargetType = planHistory.TargetType;
                                planDetail.SeatingCapacity = planHistory.SeatingCapacity;
                                planDetail.CarryingCapacity = planHistory.CarryingCapacity;
                                if (planHistory.NeedRequest)
                                {
                                    planDetail.CanRequest = (int)CanRequest.未报计划;
                                    planDetail.CanDeliver = (int)CanDeliver.未申请;
                                }
                                else
                                {
                                    planDetail.CanRequest = (int)CanRequest.无需申请;
                                    planDetail.CanDeliver = (int)CanDeliver.可交付;
                                }
                                planAircraft.Status = (int)ManageStatus.计划;
                            }
                            // 2、计划飞机在当前计划中已有明细项
                            else
                            {
                                planDetail.Regional = planAircraft.Regional;
                                planDetail.AircraftTypeName = planAircraft.AircraftTypeName;
                                planDetail.CaacAircraftTypeName = planAircraft.AircraftTypeName;
                                planDetail.AircraftTypeId = planAircraft.AircraftTypeId;
                                planDetail.SeatingCapacity = -planHistory.SeatingCapacity;
                                planDetail.CarryingCapacity = -planHistory.CarryingCapacity;
                                planDetail.CanRequest = (int)CanRequest.无需申请;
                                planDetail.CanDeliver = (int)CanDeliver.可交付;
                            }
                        }
                    }
                }
                // 2.2、是针对现有飞机的计划明细,退出或变更计划,无需改变计划飞机管理状态
                else
                {
                    if (planType == 1) //为退出计划
                    {
                        planDetail.Regional = aircraft.Regional;
                        planDetail.RegNumber = aircraft.RegNumber;
                        planDetail.AircraftTypeId = planAircraft.AircraftTypeId;
                        planDetail.AircraftTypeName = planAircraft.AircraftTypeName;
                        planDetail.CaacAircraftTypeName = planAircraft.AircraftTypeName;
                        planDetail.SeatingCapacity = -aircraft.SeatingCapacity;
                        planDetail.CarryingCapacity = -aircraft.CarryingCapacity;
                        planDetail.AircraftId = aircraft.AircraftId;
                        planDetail.CanRequest = (int)CanRequest.无需申请;
                        planDetail.CanDeliver = (int)CanDeliver.可交付;
                        planDetail.ManageStatus = (int)ManageStatus.运营;
                    }
                    else if (planType == 2) //为变更计划
                    {
                        // 获取飞机的当前商业数据,赋予新创建的变更计划明细
                        var abs = aircraft.AircraftBusinesses;
                        if (abs.Any())
                        {
                            var aircraftBusiness = abs.FirstOrDefault(a => a.EndDate == null);
                            if (aircraftBusiness != null)
                            {
                                planDetail.Regional = aircraft.Regional;
                                planDetail.RegNumber = aircraft.RegNumber;
                                planDetail.TargetCategoryId = aircraftBusiness.ImportCategoryId;
                                planDetail.SeatingCapacity = aircraftBusiness.SeatingCapacity;
                                planDetail.CarryingCapacity = aircraftBusiness.CarryingCapacity;
                                planDetail.AircraftId = aircraft.AircraftId;
                                planDetail.ManageStatus = (int)ManageStatus.运营;
                            }
                        }
                    }
                }
                planDetail.PlanAircraftId = planAircraft.Id;
            }
            return planDetail;
        }
Beispiel #3
0
        /// <summary>
        /// 创建当前新版本计划
        /// </summary>
        /// <param name="lastPlan"></param>
        /// <param name="allPlanHistories"></param>
        /// <returns></returns>
        internal PlanDTO CreateNewVersionPlan(PlanDTO lastPlan, QueryableDataServiceCollectionView<PlanHistoryDTO> allPlanHistories)
        {
            var title = lastPlan.Year + "年度运力规划";
            // 从当前计划复制生成新版本计划
            var newPlan = new PlanDTO
            {
                Id = Guid.NewGuid(),
                Title = title,
                CreateDate = DateTime.Now,
                AnnualId = lastPlan.AnnualId,
                Year = lastPlan.Year,
                AirlinesId = lastPlan.AirlinesId,
                AirlinesName = lastPlan.AirlinesName,
                VersionNumber = lastPlan.VersionNumber + 1,
                Status = 0,
                IsValid = false,
                IsFinished = false,
                PublishStatus = 0,
            };
            // 从当前计划往新版本计划复制计划明细
            var lastPhs = allPlanHistories.Where(p => p.PlanId == lastPlan.Id).ToList();
            List<PlanHistoryDTO> resultphs = lastPhs.Select(q => new PlanHistoryDTO
                                                 {
                                                     PlanId = newPlan.Id,
                                                     Id = Guid.NewGuid(),
                                                     ActionCategoryId = q.ActionCategoryId,
                                                     AircraftTypeId = q.AircraftTypeId,
                                                     AirlinesId = q.AirlinesId,
                                                     CarryingCapacity = q.CarryingCapacity,
                                                     SeatingCapacity = q.SeatingCapacity,
                                                     RelatedGuid = q.RelatedGuid,
                                                     RelatedEndDate = q.RelatedEndDate,
                                                     IsSubmit = q.IsSubmit,
                                                     IsValid = q.IsValid,
                                                     Note = q.Note,
                                                     PerformAnnualId = q.PerformAnnualId,
                                                     PerformMonth = q.PerformMonth,
                                                     PlanAircraftId = q.PlanAircraftId,
                                                     PlanType = q.PlanType,
                                                     TargetCategoryId = q.TargetCategoryId,
                                                     AirlinesName = q.AirlinesName,
                                                     CaacAircraftTypeName = q.CaacAircraftTypeName,
                                                     Regional = q.Regional,
                                                     AircraftTypeName = q.AircraftTypeName,
                                                     ActionType = q.ActionType,
                                                     ActionName = q.ActionName,
                                                     TargetType = q.TargetType,
                                                     Year = q.Year,
                                                     AircraftId = q.AircraftId,
                                                     RegNumber = q.RegNumber,
                                                     ManageStatus = q.ManageStatus,
                                                     CanRequest = q.CanRequest,
                                                     CanDeliver = q.CanDeliver,
                                                 }).ToList();

            resultphs.ForEach(allPlanHistories.AddNew);
            return newPlan;
        }