Exemplo n.º 1
0
 private void OnChange()
 {
     if (_changePlan == null && editPlanAircraft != null)
     {
         var aircraft =
             Aircrafts.SourceCollection.Cast<AircraftDTO>()
                 .FirstOrDefault(p => p.AircraftId == editPlanAircraft.AircraftId);
         _changePlan = _service.CreatePlanHistory(CurPlan, AllPlanHistories, ref editPlanAircraft, aircraft, "变更",
             2);
     }
     EditPlanHistory = _changePlan;
     IsChangeable = true;
 }
Exemplo n.º 2
0
        /// <summary>
        /// 创建新的运营历史
        /// </summary>
        /// <param name="planDetail">计划明细</param>
        /// <param name="aircraft">飞机</param>
        private static void CreateOperationHistory(PlanHistoryDTO planDetail, ref AircraftDTO aircraft)
        {
            var id = planDetail.ApprovalHistoryId == null ? Guid.Empty : Guid.Parse(planDetail.ApprovalHistoryId.ToString());
            var operationHistory = new OperationHistoryDTO
            {
                OperationHistoryId = id,

                AirlinesId = planDetail.AirlinesId,
                AirlinesName = planDetail.AirlinesName,
                AircraftId = aircraft.AircraftId,
                RegNumber = "B-",
                ImportCategoryId = aircraft.ImportCategoryId,
                ImportActionType = aircraft.ImportCategoryName,
                Status = (int)OperationStatus.草稿,
            };
            if (planDetail.PlanType == 1) planDetail.RelatedGuid = operationHistory.OperationHistoryId;
            aircraft.OperationHistories.Add(operationHistory);
            // 更改运营历史状态
            operationHistory.Status = (int)OperationStatus.草稿;
        }
Exemplo n.º 3
0
        internal void AddNewRequestDetail(PlanHistoryDTO planHistory)
        {
            var requestDetail = new ApprovalHistoryDTO
            {
                Id = Guid.NewGuid(),
                RequestId = SelRequest.Id,
                ImportCategoryId = planHistory.TargetCategoryId,
                AirlinesId = planHistory.AirlinesId,
                RequestDeliverAnnualId = planHistory.PerformAnnualId,
                RequestDeliverMonth = planHistory.PerformMonth,
                SeatingCapacity = planHistory.SeatingCapacity,
                CarryingCapacity = planHistory.CarryingCapacity,
                AircraftType = planHistory.AircraftTypeName,
                AircraftRegional = planHistory.Regional,
                AirlineName = planHistory.AirlinesName,
                ImportCategoryName = planHistory.ActionType + ":" + planHistory.ActionName,
            };
            var annual =
                Annuals.SourceCollection.Cast<AnnualDTO>()
                    .FirstOrDefault(p => p.Id == requestDetail.RequestDeliverAnnualId);
            if (annual != null) requestDetail.RequestDeliverAnnualName = annual.Year;
            if (planHistory.PlanAircraftId != null)
                requestDetail.PlanAircraftId = Guid.Parse(planHistory.PlanAircraftId.ToString());

            // 把申请明细赋给关联的计划明细
            if (planHistory.CanRequest == (int) CanRequest.可再次申请 && planHistory.ApprovalHistoryId != null &&
                _approvalHistoryCaches != null)
            {
                _approvalHistoryCaches.Add(new ApprovalHistoryCache
                {
                    PlanHistoryId = planHistory.Id,
                    ApprovalHistoryId = Guid.Parse(planHistory.ApprovalHistoryId.ToString()),
                }); //用于撤销操作
            }
            planHistory.ApprovalHistoryId = requestDetail.Id;

            // 计划飞机管理状态修改为申请:
            var planAircraft =
                PlanAircrafts.SourceCollection.Cast<PlanAircraftDTO>()
                    .FirstOrDefault(p => p.Id == planHistory.PlanAircraftId);
            if (planAircraft != null) planAircraft.Status = (int) ManageStatus.申请;

            planHistory.CanRequest = (int) CanRequest.已申请;
            planHistory.CanDeliver = (int) CanDeliver.未批准;

            SelRequest.ApprovalHistories.Add(requestDetail);
            RefreshCommandState();
        }
Exemplo n.º 4
0
 /// <summary>
 /// 创建新飞机
 /// </summary>
 /// <param name="planDetail">计划明细</param>
 private static AircraftDTO CreateAircraft(PlanHistoryDTO planDetail)
 {
     var aircraft = new AircraftDTO
     {
         AircraftId = Guid.NewGuid(),
         AircraftTypeId = planDetail.AircraftTypeId,
         AircraftTypeName = planDetail.AircraftTypeName,
         AirlinesId = planDetail.AirlinesId,
         AirlinesName = planDetail.AirlinesName,
         CreateDate = DateTime.Now,
         IsOperation = true,
         RegNumber = "B-",
         SeatingCapacity = planDetail.SeatingCapacity,
         CarryingCapacity = planDetail.CarryingCapacity,
         ImportCategoryId = planDetail.ActionCategoryId,
         ImportCategoryName = planDetail.ActionType + "-" + planDetail.ActionName,
     };
     planDetail.AircraftId = aircraft.AircraftId;
     CreateOperationHistory(planDetail, ref aircraft);
     CreateAircraftBusiness(planDetail, ref aircraft);
     return aircraft;
 }
Exemplo n.º 5
0
        /// <summary>
        /// 创建新的商业数据历史
        /// </summary>
        /// <param name="planDetail"></param>
        /// <param name="aircraft">飞机</param>
        private static void CreateAircraftBusiness(PlanHistoryDTO planDetail, ref AircraftDTO aircraft)
        {
            var aircraftBusiness = new AircraftBusinessDTO
            {
                AircraftBusinessId = Guid.NewGuid(),
                AircraftId = aircraft.AircraftId,
                AircraftTypeId = aircraft.AircraftTypeId,
                ImportCategoryId = aircraft.ImportCategoryId,
                SeatingCapacity = aircraft.SeatingCapacity,
                CarryingCapacity = aircraft.CarryingCapacity,
                Status = (int)OperationStatus.草稿,
                Regional = planDetail.Regional,
                StartDate = DateTime.Now,
            };

            if (planDetail.PlanType == 2) planDetail.RelatedGuid = aircraftBusiness.AircraftBusinessId;
            aircraft.AircraftBusinesses.Add(aircraftBusiness);
            // 更改商业数据历史状态
            aircraftBusiness.Status = (int)OperationStatus.草稿;
        }
Exemplo n.º 6
0
        /// <summary>
        ///     移除计划明细项
        /// </summary>
        /// <param name="planDetail"></param>
        public void RemovePlanDetail(PlanHistoryDTO planDetail)
        {
            if (planDetail != null)
            {
                // 获取计划飞机
                var planAircraft = ViewPlanAircrafts.FirstOrDefault(p => p.Id == planDetail.PlanAircraftId);
                // 获取计划飞机的明细项集合
                if (planAircraft != null)
                {
                    var planHistories =
                        AllPlanHistories.Where(ph => ph.PlanAircraftId == planAircraft.Id).ToList();

                    // 获取计划飞机在当前计划中的明细项集合
                    var planDetails = ViewPlanHistories.Where(ph => ph.PlanAircraftId == planAircraft.Id).ToList();

                    // 1、已有飞机(只有变更与退出计划)
                    if (planAircraft.AircraftId != null)
                    {
                        // 1.1、计划飞机在当前计划中只有一条明细项
                        if (planDetails.Count == 1)
                            planAircraft.Status = (int) ManageStatus.运营;
                            // 1.2、计划飞机在当前计划中超过一条明细项,即一条变更、一条退出
                        else
                        {
                            // 移除的是变更计划,计划飞机改为运营状态(可能之前也是运营状态)
                            if (planDetail.ActionType == "变更")
                                planAircraft.Status = (int) ManageStatus.运营;
                            // 移除的是退出计划,不做任何改变
                        }
                    }
                        // 2、没有飞机(只有引进与退出计划)
                        // 2.1、计划飞机相关的明细项数量为1
                        // 删除相关计划飞机。
                    else if (planHistories.Count == 1)
                    {
                        ViewPlanAircrafts.Remove(planAircraft);
                    }
                        // 2.2、计划飞机相关的计划历史数量不为1(即超过1)
                        // 2.2.1、计划飞机在当前计划中只有一条明细项
                        // 计划飞机的管理状态改为预备
                    else if (planDetails.Count == 1)
                    {
                        planAircraft.Status = (int) ManageStatus.预备;
                    }
                    // 2.2.2、计划飞机在当前计划中超过一条明细项,即一条引进、一条退出
                    // 不改变计划飞机状态

                    AllPlanHistories.Remove(planDetail);
                    ViewPlanHistories.Remove(planDetail);
                }
            }
            RefreshCommandState();
        }
Exemplo n.º 7
0
        /// <summary>
        ///     执行比较命令。
        /// </summary>
        /// <param name="sender"></param>
        public void OnCompare(object sender)
        {
            var planHistories = new List<PlanHistoryDTO>();
            var comparePlanHistories = new List<PlanHistoryDTO>();
            //遍历原始计划,用原始计划与对比的计划进行对比
            PlanHistories.OrderBy(p => p.Year).ThenBy(p => p.PerformMonth).ToList().ForEach(p =>
            {
                if (
                    ComparePlanHistories.Any(
                        c => c.PlanAircraftId == p.PlanAircraftId && c.ActionCategoryId == p.ActionCategoryId))
                {
                    var comparedPlanHistory =
                        ComparePlanHistories.First(
                            c => c.PlanAircraftId == p.PlanAircraftId && c.ActionCategoryId == p.ActionCategoryId);
                    var clonePlanHistory = p.Clone(); //克隆出一份新的计划历史,用于处理颜色的改变,而不会影响到原有的值
                    var cloneComparedPlanHistory = comparedPlanHistory.Clone(); //克隆出一份新的计划历史,用于处理颜色的改变,而不会影响到原有的值
                    //判断是否发生变更
                    ModifyPlanHistory(clonePlanHistory, cloneComparedPlanHistory);
                    planHistories.Add(clonePlanHistory);
                    comparePlanHistories.Add(cloneComparedPlanHistory);
                }
                else //如果原始计划有计划历史,而对比的计划没有相应的计划历史,则新增一条新的计划历史到计划中
                {
                    var newPlanHistory = new PlanHistoryDTO
                    {
                        PlanHistoryCompareStatus = PlanHistoryCompareStatus.Added
                    };
                    var clonePlanHistory = p.Clone();
                    clonePlanHistory.PlanHistoryCompareStatus = PlanHistoryCompareStatus.Added;
                    planHistories.Add(clonePlanHistory);
                    comparePlanHistories.Add(newPlanHistory);
                }
            });

            //遍历对比计划,用对比的计划与原始的计划进行对比
            ComparePlanHistories.OrderBy(p => p.Year).ThenBy(p => p.PerformMonth).ToList().ForEach(p =>
            {
                if (
                    PlanHistories.All(
                        c => c.PlanAircraftId != p.PlanAircraftId || c.ActionCategoryId != p.ActionCategoryId))
                {
                    var removedPlanHistory = new PlanHistoryDTO
                    {
                        PlanHistoryCompareStatus = PlanHistoryCompareStatus.Removed
                    };
                    var cloneComparedPlanHistory = p.Clone(); //克隆出一份新的计划历史,用于处理颜色的改变,而不会影响到原有的值
                    cloneComparedPlanHistory.PlanHistoryCompareStatus = PlanHistoryCompareStatus.Removed;
                    planHistories.Add(removedPlanHistory);
                    comparePlanHistories.Add(cloneComparedPlanHistory);
                }
            });
            ComparePlanHistories = comparePlanHistories;
            PlanHistories = planHistories;
        }
Exemplo n.º 8
0
 /// <summary>
 ///     移除运力增减计划明细
 /// </summary>
 /// <param name="planDetail">
 ///     <see cref="IFleetPlanService" />
 /// </param>
 public void RemovePlanDetail(PlanHistoryDTO planDetail)
 {
     using (var pb = new FleetPlanServiceHelper())
     {
         //pb.RemovePlanDetail(planDetail, this);
     }
 }
Exemplo n.º 9
0
 /// <summary>
 ///     完成运力增减计划
 /// </summary>
 /// <param name="planDetail">计划明细</param>
 /// <param name="aircraft">飞机</param>
 /// <param name="editAircraft">飞机</param>
 /// <returns>
 ///     <see cref="IFleetPlanService" />
 /// </returns>
 public void CompletePlan(PlanHistoryDTO planDetail, AircraftDTO aircraft, ref AircraftDTO editAircraft)
 {
     using (var pb = new FleetPlanServiceHelper())
     {
         pb.CompletePlan(planDetail, aircraft, ref editAircraft, this);
     }
 }
Exemplo n.º 10
0
 /// <summary>
 ///     获取计划明细中集合属性AircraftTypes的值
 /// </summary>
 /// <param name="ph"></param>
 /// <returns></returns>
 public ObservableCollection<AircraftTyDTO> GetAircraftTypesForPlanHistory(PlanHistoryDTO ph)
 {
     var aircraftTypes = ph.Regional != null
         ? AircraftTypes.Where(p => p.Regional == ph.Regional).ToList()
         : AircraftTypes.ToList();
     var aircraftTys = new ObservableCollection<AircraftTyDTO>();
     aircraftTypes.ForEach(p => aircraftTys.Add(new AircraftTyDTO
     {
         Id = p.Id,
         Name = p.Name,
         AircraftCategoryId = p.AircraftCategoryId,
         Regional = p.Regional,
         CaacAircraftTypeName = p.CaacAircraftTypeName,
     }));
     return aircraftTys;
 }
Exemplo n.º 11
0
        /// <summary>
        ///     当计划明细中活动类型发生变化的时候,需要改变相应属性:目标类型、净增座位、净增商载
        /// </summary>
        /// <param name="ph"></param>
        public void OnChangedActionCategory(PlanHistoryDTO ph)
        {
            var actionCategory = ActionCategories.FirstOrDefault(ac => ac.Id == ph.ActionCategoryId);
            if (actionCategory != null)
            {
                if (actionCategory.ActionType == "退出")
                {
                    if (ph.PlanAircraftId != null && ph.AircraftId != null)
                    {
                        if (ph.SeatingCapacity > 0)
                            ph.SeatingCapacity = -ph.SeatingCapacity;
                        if (ph.CarryingCapacity > 0)
                            ph.CarryingCapacity = -ph.CarryingCapacity;
                    }
                }

                if (actionCategory.ActionType == "引进" || actionCategory.ActionType == "退出")
                {
                    if (ph.TargetCategoryId == ph.ActionCategoryId) return;
                    ph.TargetCategoryId = ph.ActionCategoryId;
                }
                else
                {
                    ActionCategoryDTO actionCategoryDto;
                    // 改变目标引进方式
                    switch (actionCategory.ActionName)
                    {
                        case "一般改装":
                            if (ph.PlanAircraftId != null && ph.AircraftId != null)
                            {
                                var aircraftImport = ph.AircraftImportCategoryId == null
                                    ? Guid.Empty
                                    : Guid.Parse(ph.AircraftImportCategoryId.ToString());
                                if (ph.TargetCategoryId == aircraftImport) return;
                                ph.TargetCategoryId = aircraftImport;
                            }
                            break;
                        case "客改货":
                            if (ph.PlanAircraftId != null && ph.AircraftId != null)
                            {
                                var aircraftImport = ph.AircraftImportCategoryId == null
                                    ? Guid.Empty
                                    : Guid.Parse(ph.AircraftImportCategoryId.ToString());
                                if (ph.TargetCategoryId == aircraftImport) return;
                                ph.TargetCategoryId = aircraftImport;
                                ph.AircraftTypeId = Guid.Empty;
                            }
                            break;
                        case "货改客":
                            if (ph.PlanAircraftId != null && ph.AircraftId != null)
                            {
                                var aircraftImport = ph.AircraftImportCategoryId == null
                                    ? Guid.Empty
                                    : Guid.Parse(ph.AircraftImportCategoryId.ToString());
                                if (ph.TargetCategoryId == aircraftImport) return;
                                ph.TargetCategoryId = aircraftImport;
                                ph.AircraftTypeId = Guid.Empty;
                            }
                            break;
                        case "售后融资租赁":
                            actionCategoryDto = ActionCategories.FirstOrDefault(a => a.ActionName == "融资租赁");
                            if (actionCategoryDto != null)
                            {
                                if (ph.TargetCategoryId == actionCategoryDto.Id) return;
                                ph.TargetCategoryId = actionCategoryDto.Id;
                            }

                            break;
                        case "售后经营租赁":
                            actionCategoryDto = ActionCategories.FirstOrDefault(a => a.ActionName == "经营租赁");
                            if (actionCategoryDto != null)
                            {
                                if (ph.TargetCategoryId == actionCategoryDto.Id) return;
                                ph.TargetCategoryId = actionCategoryDto.Id;
                            }
                            break;
                        case "租转购":
                            actionCategoryDto = ActionCategories.FirstOrDefault(a => a.ActionName == "购买");
                            if (actionCategoryDto != null)
                            {
                                if (ph.TargetCategoryId == actionCategoryDto.Id) return;
                                ph.TargetCategoryId = actionCategoryDto.Id;
                            }
                            break;
                    }
                }
            }
        }
Exemplo n.º 12
0
 /// <summary>
 ///     获取计划明细中集合属性AircraftCategories的值
 /// </summary>
 /// <param name="ph"></param>
 public ObservableCollection<AircraftCateDTO> GetAircraftCategoriesForPlanHistory(PlanHistoryDTO ph)
 {
     List<AircraftCategoryDTO> aircraftCategories;
     if (ph.ActionName == "客改货")
         aircraftCategories = AircraftCategories.Where(p => p.Category == "货机").ToList();
     else if (ph.ActionName == "货改客")
         aircraftCategories = AircraftCategories.Where(p => p.Category == "客机").ToList();
     else aircraftCategories = AircraftCategories.ToList();
     var aircraftCates = new ObservableCollection<AircraftCateDTO>();
     aircraftCategories.ForEach(p => aircraftCates.Add(new AircraftCateDTO
     {
         Id = p.Id,
         Category = p.Category,
         Regional = p.Regional,
     }));
     return aircraftCates;
 }
Exemplo n.º 13
0
 /// <summary>
 ///     获取计划明细中集合属性ActionCategories的值
 /// </summary>
 /// <param name="ph"></param>
 public ObservableCollection<ActionCateDTO> GetActionCategoriesForPlanHistory(PlanHistoryDTO ph)
 {
     List<ActionCategoryDTO> actioncategories;
     if (ph.PlanType == 1 && ph.ActionType == "引进")
         actioncategories = ActionCategories.Where(p => p.ActionType == "引进").ToList();
     else if (ph.PlanType == 1 && ph.ActionType == "退出")
         actioncategories = ActionCategories.Where(p => p.ActionType == "退出").ToList();
     else if (ph.PlanType == 2 && ph.ActionType == "变更")
         actioncategories = ActionCategories.Where(p => p.ActionType == "变更").ToList();
     else actioncategories = ActionCategories.ToList();
     var actionCates = new ObservableCollection<ActionCateDTO>();
     actioncategories.ForEach(p => actionCates.Add(new ActionCateDTO
     {
         Id = p.Id,
         ActionType = p.ActionType,
         ActionName = p.ActionName,
         NeedRequest = p.NeedRequest,
     }));
     return actionCates;
 }
Exemplo n.º 14
0
 /// <summary>
 ///     判断计划历史是否发生变更
 /// </summary>
 /// <param name="planHistory"></param>
 /// <param name="comparedPlanHistory"></param>
 private void ModifyPlanHistory(PlanHistoryDTO planHistory, PlanHistoryDTO comparedPlanHistory)
 {
     if (planHistory.SeatingCapacity != comparedPlanHistory.SeatingCapacity)
     {
         planHistory.PlanHistoryCompareStatus = PlanHistoryCompareStatus.Modified;
     }
     else if (planHistory.PerformMonth != comparedPlanHistory.PerformMonth)
     {
         planHistory.PlanHistoryCompareStatus = PlanHistoryCompareStatus.Modified;
     }
     else if (planHistory.IsValid != comparedPlanHistory.IsValid)
     {
         planHistory.PlanHistoryCompareStatus = PlanHistoryCompareStatus.Modified;
     }
     else if (planHistory.IsSubmit != comparedPlanHistory.IsSubmit)
     {
         planHistory.PlanHistoryCompareStatus = PlanHistoryCompareStatus.Modified;
     }
     else if (planHistory.Note != comparedPlanHistory.Note)
     {
         planHistory.PlanHistoryCompareStatus = PlanHistoryCompareStatus.Modified;
     }
     else if (planHistory.PlanAircraftId != comparedPlanHistory.PlanAircraftId)
     {
         planHistory.PlanHistoryCompareStatus = PlanHistoryCompareStatus.Modified;
     }
     else if (planHistory.PlanId != comparedPlanHistory.PlanId)
     {
         planHistory.PlanHistoryCompareStatus = PlanHistoryCompareStatus.Modified;
     }
     else if (planHistory.ActionCategoryId != comparedPlanHistory.ActionCategoryId)
     {
         planHistory.PlanHistoryCompareStatus = PlanHistoryCompareStatus.Modified;
     }
     else if (planHistory.TargetCategoryId != comparedPlanHistory.TargetCategoryId)
     {
         planHistory.PlanHistoryCompareStatus = PlanHistoryCompareStatus.Modified;
     }
     else if (planHistory.AircraftTypeId != comparedPlanHistory.AircraftTypeId)
     {
         planHistory.PlanHistoryCompareStatus = PlanHistoryCompareStatus.Modified;
     }
     else if (planHistory.AirlinesId != comparedPlanHistory.AirlinesId)
     {
         planHistory.PlanHistoryCompareStatus = PlanHistoryCompareStatus.Modified;
     }
     else if (planHistory.PerformAnnualId != comparedPlanHistory.PerformAnnualId)
     {
         planHistory.PlanHistoryCompareStatus = PlanHistoryCompareStatus.Modified;
     }
     comparedPlanHistory.PlanHistoryCompareStatus = planHistory.PlanHistoryCompareStatus;
 }
Exemplo n.º 15
0
 private void OnOperation()
 {
     if (_operationPlan == null && editPlanAircraft != null)
     {
         var aircraft =
             Aircrafts.SourceCollection.Cast<AircraftDTO>()
                 .FirstOrDefault(p => p.AircraftId == editPlanAircraft.AircraftId);
         // 针对运营飞机的运营计划只能是退出
         _operationPlan = _service.CreatePlanHistory(CurPlan, AllPlanHistories, ref editPlanAircraft, aircraft,
             "退出", 1);
     }
     EditPlanHistory = _operationPlan;
     IsChangeable = false;
 }
Exemplo n.º 16
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;
        }
Exemplo n.º 17
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("提醒", "该计划飞机已有两条明细项,不能再添加新计划明细项!");
                }
            }
        }
Exemplo n.º 18
0
        /// <summary>
        /// 完成计划项
        /// </summary>
        /// <param name="planDetail"></param>
        /// <param name="aircraft"></param>
        /// <param name="editAircraft"></param>
        /// <param name="service"></param>
        /// <returns></returns>
        internal void CompletePlan(PlanHistoryDTO planDetail, AircraftDTO aircraft, ref AircraftDTO editAircraft, IFleetPlanService service)
        {
            OperationHistoryDTO operationHistory;
            if (planDetail == null)
            {
                throw new ArgumentNullException("planDetail");
            }
            var actionName = planDetail.ActionName;
            if (actionName == null)
            {
                return;
            }
            // 根据引进方式调用不同的操作
            switch (actionName)
            {
                case "购买":
                    // 创建新飞机
                    editAircraft = CreateAircraft(planDetail);
                    break;
                case "融资租赁":
                    // 创建新飞机
                    editAircraft = CreateAircraft(planDetail);
                    break;
                case "经营租赁":
                    // 创建新飞机
                    editAircraft = CreateAircraft(planDetail);
                    break;
                case "湿租":
                    // 创建新飞机
                    editAircraft = CreateAircraft(planDetail);
                    break;
                case "经营租赁续租":
                    // 创建新运营历史
                    if (aircraft != null)
                    {
                        editAircraft = aircraft;
                        CreateOperationHistory(planDetail, ref editAircraft);
                    }
                    break;
                case "湿租续租":
                    // 创建新运营历史
                    if (aircraft != null)
                    {
                        editAircraft = aircraft;
                        CreateOperationHistory(planDetail, ref editAircraft);
                    }
                    break;
                case "出售":
                    // 更改运营历史状态
                    if (aircraft != null)
                    {
                        editAircraft = aircraft;
                        operationHistory = editAircraft.OperationHistories.LastOrDefault(oh => oh.EndDate == null);
                        if (operationHistory != null)
                        {
                            operationHistory.Status = (int)OperationStatus.草稿;
                            var actionCategoryDto =
                                service.GetActionCategories(null)
                                    .SourceCollection.Cast<ActionCategoryDTO>()
                                    .FirstOrDefault(ac => ac.ActionName == "出售");
                            if (actionCategoryDto != null)
                                operationHistory.ExportCategoryId = actionCategoryDto.Id;

                            if (planDetail.PlanType == 1) planDetail.RelatedGuid = operationHistory.OperationHistoryId;
                        }
                    }
                    break;
                case "出租":
                    // 更改运营历史状态
                    if (aircraft != null)
                    {
                        editAircraft = aircraft;
                        operationHistory = editAircraft.OperationHistories.LastOrDefault(oh => oh.EndDate == null);
                        if (operationHistory != null)
                        {
                            operationHistory.Status = (int)OperationStatus.草稿;
                            var actionCategoryDto =
                                service.GetActionCategories(null)
                                    .SourceCollection.Cast<ActionCategoryDTO>()
                                    .FirstOrDefault(ac => ac.ActionName == "出租");
                            if (actionCategoryDto != null)
                                operationHistory.ExportCategoryId = actionCategoryDto.Id;

                            if (planDetail.PlanType == 1) planDetail.RelatedGuid = operationHistory.OperationHistoryId;
                        }
                    }
                    break;
                case "退租":
                    // 更改运营历史状态
                    if (aircraft != null)
                    {
                        editAircraft = aircraft;
                        operationHistory = editAircraft.OperationHistories.LastOrDefault(oh => oh.EndDate == null);
                        if (operationHistory != null)
                        {
                            operationHistory.Status = (int)OperationStatus.草稿;
                            var actionCategoryDto =
                                service.GetActionCategories(null)
                                    .SourceCollection.Cast<ActionCategoryDTO>()
                                    .FirstOrDefault(ac => ac.ActionName == "退租");
                            if (actionCategoryDto != null)
                                operationHistory.ExportCategoryId = actionCategoryDto.Id;

                            if (planDetail.PlanType == 1) planDetail.RelatedGuid = operationHistory.OperationHistoryId;
                        }
                    }
                    break;
                case "退役":
                    // 更改运营历史状态
                    if (aircraft != null)
                    {
                        editAircraft = aircraft;
                        operationHistory = editAircraft.OperationHistories.LastOrDefault(oh => oh.EndDate == null);
                        if (operationHistory != null)
                        {
                            operationHistory.Status = (int)OperationStatus.草稿;
                            var actionCategoryDto =
                                service.GetActionCategories(null)
                                    .SourceCollection.Cast<ActionCategoryDTO>()
                                    .FirstOrDefault(ac => ac.ActionName == "退役");
                            if (actionCategoryDto != null)
                                operationHistory.ExportCategoryId = actionCategoryDto.Id;

                            if (planDetail.PlanType == 1) planDetail.RelatedGuid = operationHistory.OperationHistoryId;
                        }
                    }
                    break;
                case "货改客":
                    // 创建商业数据历史
                    if (aircraft != null)
                    {
                        editAircraft = aircraft;
                        CreateAircraftBusiness(planDetail, ref editAircraft);
                    }
                    break;
                case "客改货":
                    // 创建商业数据历史
                    if (aircraft != null)
                    {
                        editAircraft = aircraft;
                        CreateAircraftBusiness(planDetail, ref editAircraft);
                    }
                    break;
                case "售后经营租赁":
                    // 创建商业数据历史
                    if (aircraft != null)
                    {
                        editAircraft = aircraft;
                        CreateAircraftBusiness(planDetail, ref editAircraft);
                    }
                    break;
                case "售后融资租赁":
                    // 创建商业数据历史
                    if (aircraft != null)
                    {
                        editAircraft = aircraft;
                        CreateAircraftBusiness(planDetail, ref editAircraft);
                    }
                    break;
                case "一般改装":
                    // 创建商业数据历史
                    if (aircraft != null)
                    {
                        editAircraft = aircraft;
                        CreateAircraftBusiness(planDetail, ref editAircraft);
                    }
                    break;
                case "租转购":
                    // 创建商业数据历史
                    if (aircraft != null)
                    {
                        editAircraft = aircraft;
                        CreateAircraftBusiness(planDetail, ref editAircraft);
                    }
                    break;
            }
            //更改计划飞机状态
            planDetail.ManageStatus = (int)ManageStatus.运营; //TODO 修改计划飞机的状态(前台或后台处理)
        }
Exemplo n.º 19
0
        public void ShowEditDialog(PlanHistoryDTO existDetail, PlanDetailCreateSource source)
        {
            switch (source)
            {
                case PlanDetailCreateSource.New:
                    IsPlanTypeVisible = Visibility.Collapsed;
                    _operationPlan = _service.CreatePlanHistory(CurPlan, AllPlanHistories, ref editPlanAircraft, null,
                        "引进", 1); //此时EditPlanAircraft=null
                    EditPlanHistory = _operationPlan;
                    IsChangeable = true;
                    break;
                case PlanDetailCreateSource.PlanAircraft:
                    IsPlanTypeVisible = Visibility.Collapsed;
                    // 计划飞机已有的明细项肯定是引进计划,只能添加退出计划
                    _operationPlan = _service.CreatePlanHistory(CurPlan, AllPlanHistories, ref editPlanAircraft, null,
                        existDetail != null ? "退出" : "引进", 1); //existDetail=null为计划飞机是预备状态的情况
                    EditPlanHistory = _operationPlan;
                    ViewPlanHistories.Add(EditPlanHistory);
                    AllPlanHistories.AddNew(EditPlanHistory);
                    //这时不能修改机型和座机
                    IsChangeable = false;
                    break;
                case PlanDetailCreateSource.Aircraft:
                    IsPlanTypeVisible = Visibility.Visible;
                    // 1、计划飞机已有明细项
                    if (existDetail != null)
                    {
                        // 已有的是变更计划,只能添加退出计划
                        if (existDetail.ActionType == "变更")
                        {
                            IsChangeEnabled = false;
                            IsOperation = true;
                            IsChange = false;
                            OnOperation();
                            ViewPlanHistories.Add(EditPlanHistory);
                            AllPlanHistories.AddNew(EditPlanHistory);
                        }
                            // 已有的是退出计划,只能添加变更计划
                        else
                        {
                            IsOperationEnabled = false;
                            IsOperation = false;
                            IsChange = true;
                            OnOperation(); //生成之后,不让用户编辑,起到保存原计划历史的机型的作用,在取消时,能够用来恢复计划飞机数据
                            OnChange();
                            ViewPlanHistories.Add(EditPlanHistory);
                            AllPlanHistories.AddNew(EditPlanHistory);
                        }
                    }
                        // 2、计划飞机没有明细项
                    else
                    {
                        IsChangeEnabled = true;
                        IsOperationEnabled = true;
                        if (!IsOperation) IsOperation = true;
                        OnOperation();
                        ViewPlanHistories.Add(EditPlanHistory);
                        AllPlanHistories.AddNew(EditPlanHistory);
                    }
                    break;
                default:
                    throw new ArgumentOutOfRangeException("source");
            }

            editDialog.ShowDialog();
        }
Exemplo n.º 20
0
 /// <summary>
 /// 打开子窗体之前先设置好子窗体中的编辑属性
 /// </summary>
 /// <param name="planHistory">计划明细</param>
 internal void OpenEditDialog(PlanHistoryDTO planHistory)
 {
     ShowEditDialog();
 }