Esempio n. 1
0
        /// <summary>
        ///     打开子窗体之前判断是否要打开
        /// </summary>
        /// <param name="planAircraft">计划飞机</param>
        /// <param name="source">调用的来源</param>
        public void OpenEditDialog(PlanAircraftDTO planAircraft, PlanDetailCreateSource source)
        {
            editPlanAircraft = planAircraft;
            EditPlanHistory = null;
            _operationPlan = null;
            _changePlan = null;
            // 获取计划飞机在当前计划中的明细项集合
            var planDetails = new List<PlanHistoryDTO>();
            if (CurPlan != null && editPlanAircraft != null)
                planDetails = ViewPlanHistories.Where(ph => ph.PlanAircraftId == editPlanAircraft.Id).ToList();

            // 1、计划飞机在当前计划中没有明细项(新增计划明细或计划飞机为预备状态)
            if (!planDetails.Any())
                ShowEditDialog(null, source);
                // 2、计划飞机在当前计划中已有明细项
            else
            {
                if (planDetails.Count == 1)
                {
                    string content;
                    switch (source)
                    {
                        case PlanDetailCreateSource.New:
                            break;
                        case PlanDetailCreateSource.PlanAircraft:
                            content = "计划飞机在当前计划中已有引进计划明细项,是否要针对该计划飞机添加退出计划明细项?";
                            MessageConfirm("确认添加计划明细", content, (o, e) =>
                            {
                                if (e.DialogResult == true)
                                {
                                    ShowEditDialog(planDetails[0], source);
                                }
                            });
                            break;
                        case PlanDetailCreateSource.Aircraft:
                            content = planDetails[0].ActionType.Contains("变更")
                                ? "飞机在当前计划中已有变更计划明细项,是否要针对该飞机添加退出计划明细项?"
                                : "飞机在当前计划中已有退出计划明细项,是否要针对该飞机添加变更计划明细项?";
                            MessageConfirm("确认添加计划明细", content, (o, e) =>
                            {
                                if (e.DialogResult == true)
                                {
                                    ShowEditDialog(planDetails[0], source);
                                }
                            });
                            break;
                        default:
                            throw new ArgumentOutOfRangeException("source");
                    }
                }
                else
                {
                    MessageAlert("提醒", "该计划飞机已有两条明细项,不能再添加新计划明细项!");
                }
            }
        }
Esempio n. 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;
        }
Esempio n. 3
0
        private void OnAddEntity(object obj)
        {
            editPlanAircraft = null;

            OpenEditDialog(null, PlanDetailCreateSource.New);
            //将新建的实体添加到对应的注册集合中
            ViewPlanHistories.Add(EditPlanHistory);
            AllPlanHistories.AddNew(EditPlanHistory);
            SelPlanHistory = EditPlanHistory;
            ViewPlanAircrafts.AddNew(editPlanAircraft);
            SelPlanAircraft = editPlanAircraft;
        }
Esempio n. 4
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>
 /// <returns></returns>
 public PlanHistoryDTO CreatePlanHistory(PlanDTO plan,
     QueryableDataServiceCollectionView<PlanHistoryDTO> allPlanHistories, ref PlanAircraftDTO planAircraft,
     AircraftDTO aircraft, string actionType, int planType)
 {
     using (var pb = new FleetPlanServiceHelper())
     {
         return pb.CreatePlanHistory(plan, allPlanHistories, ref planAircraft, aircraft, actionType, planType,
             this);
     }
 }