Example #1
0
        public List <TraTravelInfoModel> DoQueryTrain(TraQueryTrainModel model)
        {
            ISearchTrainBll searchTrainBll       = new SearchKongTieTrainBll();                     //访问空铁无忧接口
            ISearchTrainBll policySearchTrainBll = new SearchContainPolicyTrainBll(searchTrainBll); //包装差旅政策

            return(policySearchTrainBll.SearchTrain(model));
        }
        public SearchTrainResponseViewModel SearchTrain(SearchTrainRequestViewModel request)
        {
            if (request.Cid == 0)
            {
                throw new Exception("请传入客户Id");
            }

            //2.根据Cid查询客户信息
            CustomerModel customerModel = _getCustomerServiceBll.GetCustomerByCid(request.Cid);

            string notAllowUserTrainCorpId = AppSettingsHelper.GetAppSettings(AppSettingsEnum.NotAllowUserTrain);

            if (!string.IsNullOrEmpty(customerModel.CorpID) && notAllowUserTrainCorpId.Contains(customerModel.CorpID.ToUpper()))
            {
                throw new Exception("当前公司不能使用火车票功能");
            }

            //调用查询该客户的差旅政策服务
            CorpPolicyDetailConfigModel poilConfigModel =
                _getCustomerCorpPolicyServiceBll.GetCorpPolicyById(request.PolicyId ?? 0, customerModel.CorpID, "T");

            TraQueryTrainModel queryTrainModel = new TraQueryTrainModel()
            {
                from_station  = request.FromStation,
                needdistance  = request.NeedDistance,
                purpose_codes = request.PurposeCodes,
                to_station    = request.ToStation,
                train_date    = request.TrainDate,
                CorpPolicy    = poilConfigModel,
                CorpId        = customerModel.CorpID,
                IsTraAllSeat  = customerModel.Corporation == null ? 0 : customerModel.Corporation.IsTraAllSeat
            };

            List <TraTravelInfoModel>    traTravelInfoModels = _searchTrainServiceBll.DoQueryTrain(queryTrainModel);
            SearchTrainResponseViewModel responseViewModel   = new SearchTrainResponseViewModel();

            List <TraTravelInfoViewModel> travelInfo = new List <TraTravelInfoViewModel>();
            List <string> formStation = new List <string>();
            List <string> toStation   = new List <string>();
            List <string> trainType   = new List <string>();

            foreach (var item in traTravelInfoModels)
            {
                #region 循环
                if (!string.IsNullOrEmpty(item.train_type))
                {
                    trainType.Add(item.train_type);
                }
                if (!string.IsNullOrEmpty(item.from_station_name))
                {
                    formStation.Add(item.from_station_name);
                }
                if (!string.IsNullOrEmpty(item.to_station_name))
                {
                    toStation.Add(item.to_station_name);
                }
                TraTravelInfoViewModel travelInfoViewModel = new TraTravelInfoViewModel()
                {
                    AccessByidCard   = item.access_byidcard,
                    ArriveDays       = item.arrive_days,
                    ArriveTime       = item.arrive_time,
                    CanBuyNow        = item.can_buy_now,
                    DetailList       = AutoMapperHelper.DoMapList <TraTravelInfoDetailModel, TraTravelInfoDetailViewModel>(item.DetailList).ToList(),
                    Distance         = item.distance,
                    EndStationName   = item.end_station_name,
                    FromStationCode  = item.from_station_code,
                    FromStationName  = item.from_station_name,
                    Note             = item.note,
                    RunTime          = item.run_time,
                    RunTimeMinute    = item.run_time_minute,
                    SaleDateTime     = item.sale_date_time,
                    StartStationName = item.start_station_name,
                    StartTime        = item.start_time,
                    ToStationCode    = item.to_station_code,
                    ToStationName    = item.to_station_name,
                    TrainCode        = item.train_code,
                    TrainNo          = item.train_no,
                    TrainStartDate   = Convert.ToDateTime(queryTrainModel.train_date).ToString("yyyy-MM-dd"),//item.train_start_date,
                    TrainType        = item.train_type,
                    OnTrainDate      = request.TrainDate
                };
                travelInfo.Add(travelInfoViewModel);
                #endregion
            }

            responseViewModel.TravelInfo   = travelInfo;
            responseViewModel.FormStation  = formStation.Distinct().ToList();
            responseViewModel.ToStation    = toStation.Distinct().ToList();
            responseViewModel.TrainType    = trainType.Distinct().ToList();
            responseViewModel.PolicyReason = poilConfigModel?.PolicyReason;
            return(responseViewModel);
        }
Example #3
0
        public List <TraTravelInfoModel> SearchTrain(TraQueryTrainModel query)
        {
            List <TraTravelInfoModel> traTravelInfoModels = _searchTrainBll.SearchTrain(query);

            if (string.IsNullOrEmpty(query.CorpId)) //没有公司Id的直接返回ibe航班信息
            {
                return(traTravelInfoModels);
            }
            CorpPolicyDetailConfigModel policyModel = query.CorpPolicy;

            #region 将差旅政策包装到火车车次信息

            List <TraTravelInfoModel> traTravelInfoTempList = new List <TraTravelInfoModel>();
            #region 没有差旅政策
            if (policyModel == null)
            {
                return(traTravelInfoModels);
            }
            #endregion

            #region 存在差旅政策

            List <string> qTrainTypeList = new List <string>()
            {
                "C", "D", "G"
            };//快车类型
            List <string> cTrainTypeList = new List <string>()
            {
                "K", "T", "Z", "L", "A", "Y", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9"
            };//普车类型

            List <string> seatTypeList = new List <string>()
            {
                "硬卧", "动卧", "软卧", "高级软卧"
            };


            foreach (var traTravelInfoModel in traTravelInfoModels)
            {
                if (traTravelInfoModel.DetailList == null || traTravelInfoModel.DetailList.Count == 0)
                {
                    continue;
                }
                List <TraTravelInfoDetailModel> detailList = new List <TraTravelInfoDetailModel>();
                //如果个性化设置中设置选择全部坐席 不进行政策中坐席筛选
                if ((query.IsTraAllSeat ?? 0) == 1)
                {
                    detailList.AddRange(traTravelInfoModel.DetailList);
                }
                else
                {
                    foreach (var traTravelInfoDetailModel in traTravelInfoModel.DetailList)
                    {
                        int p2 = (from n in _seatSortedList
                                  where n.Value == traTravelInfoDetailModel.SeatName
                                  select n.Key).FirstOrDefault();

                        if (!string.IsNullOrEmpty(policyModel.TPolicyValQ) &&
                            !string.IsNullOrEmpty(traTravelInfoModel.train_type) &&
                            qTrainTypeList.Contains(traTravelInfoModel.train_type) && !traTravelInfoDetailModel.SeatName.Contains("卧")) //快车限制
                        {
                            int p1 = (from n in _seatSortedList
                                      where n.Value == policyModel.TPolicyValQ
                                      select n.Key).FirstOrDefault();//标准

                            if (p1 < p2)
                            {
                                traTravelInfoDetailModel.ViolateTPolicyValQ     = "T";
                                traTravelInfoDetailModel.ViolateTPolicyValQDesc = "快车席别最高限制为" + policyModel.TPolicyValQ;
                            }
                        }
                        if (!string.IsNullOrEmpty(policyModel.TPolicyValM) &&
                            !string.IsNullOrEmpty(traTravelInfoModel.train_type) &&
                            cTrainTypeList.Contains(traTravelInfoModel.train_type) && !traTravelInfoDetailModel.SeatName.Contains("卧"))//普车限制
                        {
                            int p1 = (from n in _seatSortedList
                                      where n.Value == policyModel.TPolicyValM
                                      select n.Key).FirstOrDefault();//标准
                            if (p1 < p2)
                            {
                                traTravelInfoDetailModel.ViolateTPolicyValM     = "T";
                                traTravelInfoDetailModel.ViolateTPolicyValMDesc = "普车/其他最高限制为" + policyModel.TPolicyValM;
                            }
                        }
                        if (!string.IsNullOrEmpty(policyModel.TPolicyValS) && seatTypeList.Contains(traTravelInfoDetailModel.SeatName) && traTravelInfoDetailModel.SeatName.Contains("卧"))//卧铺限制
                        {
                            if (policyModel.TPolicyValS == "99")
                            {
                                traTravelInfoDetailModel.ViolateTPolicyValS     = "T";
                                traTravelInfoDetailModel.ViolateTPolicyValSDesc = "最高卧铺限制为不可乘坐卧铺";
                            }
                            else
                            {
                                int p1 = (from n in _seatSortedList
                                          where n.Value == policyModel.TPolicyValS
                                          select n.Key).FirstOrDefault();//标准
                                if (p1 < p2)
                                {
                                    traTravelInfoDetailModel.ViolateTPolicyValS     = "T";
                                    traTravelInfoDetailModel.ViolateTPolicyValSDesc = "最高卧铺限制为" + policyModel.TPolicyValS;
                                }
                            }
                        }

                        if (traTravelInfoDetailModel.ViolateTPolicyValQ == "T" ||
                            traTravelInfoDetailModel.ViolateTPolicyValM == "T" ||
                            traTravelInfoDetailModel.ViolateTPolicyValS == "T")
                        {
                            traTravelInfoDetailModel.IsViolate = "T";
                        }
                        else
                        {
                            detailList.Add(traTravelInfoDetailModel);
                        }
                    }
                }

                if (detailList.Count > 0)
                {
                    traTravelInfoModel.DetailList = detailList;
                    traTravelInfoTempList.Add(traTravelInfoModel);
                }
            }
            #endregion

            #endregion

            return(traTravelInfoTempList);
        }
Example #4
0
        public List <TraTravelInfoModel> SearchTrain(TraQueryTrainModel model)
        {
            RequestInterfaceHelper <TraQueryTrainModel> .SupplementInPutModel(model, "train_query");

            string   jsonstr = "jsonStr=" + JsonHelper.SerializeObject(model);
            DateTime date    = DateTime.Now;

            LogHelper.WriteLog("行程查询接口:" + date + "||||||" + jsonstr, "SearchTrain");
            string post = PostHelper.PostUrl(postUrl, jsonstr, Encoding.UTF8);

            LogHelper.WriteLog("行程查询接口返回:" + date + "||||||" + post, "SearchTrain");


            TraQueryTrainResponseModel trainResponseModel =
                JsonHelper.DeserializeJsonToObject <TraQueryTrainResponseModel>(post);

            if (trainResponseModel.code == 200)
            {
                List <TraTravelInfoModel> resultList = new List <TraTravelInfoModel>();

                #region 对象转换

                if (trainResponseModel.code == 200)
                {
                    foreach (var m in trainResponseModel.data)
                    {
                        TraTravelInfoModel infoModel =
                            AutoMapperHelper.DoMap <TraQueryTrainResponseDateModel, TraTravelInfoModel>(m);

                        resultList.Add(infoModel);
                        infoModel.DetailList = new List <TraTravelInfoDetailModel>();
                        //F
                        if (m.dw_num != "--" && m.dw_num != "*" && !string.IsNullOrEmpty(m.dw_price) &&
                            m.dw_price.Trim() != "" && m.dw_price.Trim() != "0")
                        {
                            var exa = TrainTypeEnum.DW;
                            exa.SeatPrice = m.dwx_price;
                            exa.SeatCount = m.dw_num;
                            infoModel.DetailList.Add(exa);
                        }
                        //9
                        if (m.swz_num != "--" && m.swz_num != "*" && !string.IsNullOrEmpty(m.swz_price) &&
                            m.swz_price.Trim() != "" && m.swz_price.Trim() != "0")
                        {
                            var exa = TrainTypeEnum.SWZ;
                            exa.SeatPrice = m.swz_price;
                            exa.SeatCount = m.swz_num;
                            infoModel.DetailList.Add(exa);
                        }
                        //P
                        if (m.tdz_num != "--" && m.tdz_num != "*" && !string.IsNullOrEmpty(m.tdz_price) &&
                            m.tdz_price.Trim() != "" && m.tdz_price.Trim() != "0")
                        {
                            var exa = TrainTypeEnum.TDZ;
                            exa.SeatPrice = m.tdz_price;
                            exa.SeatCount = m.tdz_num;
                            infoModel.DetailList.Add(exa);
                        }

                        //M
                        if (m.ydz_num != "--" && m.ydz_num != "*" && !string.IsNullOrEmpty(m.ydz_price) &&
                            m.ydz_price.Trim() != "" && m.ydz_price.Trim() != "0")
                        {
                            var exa = TrainTypeEnum.YDZ;
                            exa.SeatPrice = m.ydz_price;
                            exa.SeatCount = m.ydz_num;
                            infoModel.DetailList.Add(exa);
                        }
                        //O
                        if (m.edz_num != "--" && m.edz_num != "*" && !string.IsNullOrEmpty(m.edz_price) &&
                            m.edz_price.Trim() != "" && m.edz_price.Trim() != "0")
                        {
                            var exa = TrainTypeEnum.EDZ;
                            exa.SeatPrice = m.edz_price;
                            exa.SeatCount = m.edz_num;
                            infoModel.DetailList.Add(exa);
                        }

                        //6
                        if (m.gjrw_num != "--" && m.gjrw_num != "*" && !string.IsNullOrEmpty(m.gjrw_price) &&
                            m.gjrw_price.Trim() != "" && m.gjrw_price.Trim() != "0")
                        {
                            var exa = TrainTypeEnum.GJRW;
                            exa.SeatPrice = m.gjrw_price;
                            exa.SeatCount = m.gjrw_num;
                            infoModel.DetailList.Add(exa);
                        }

                        //4
                        if (m.rw_num != "--" && m.rw_num != "*" && !string.IsNullOrEmpty(m.rw_price) &&
                            m.rw_price.Trim() != "" && m.rw_price.Trim() != "0")
                        {
                            var exa = TrainTypeEnum.RW;
                            exa.SeatPrice = m.rwx_price;
                            exa.SeatCount = m.rw_num;
                            infoModel.DetailList.Add(exa);
                        }

                        //3
                        if (m.yw_num != "--" && m.yw_num != "*" && !string.IsNullOrEmpty(m.yw_price) &&
                            m.yw_price.Trim() != "" && m.yw_price.Trim() != "0")
                        {
                            var exa = TrainTypeEnum.YW;
                            exa.SeatPrice = m.ywx_price;
                            exa.SeatCount = m.yw_num;
                            infoModel.DetailList.Add(exa);
                        }



                        //2
                        if (m.rz_num != "--" && m.rz_num != "*" && !string.IsNullOrEmpty(m.rz_price) &&
                            m.rz_price.Trim() != "" && m.rz_price.Trim() != "0")
                        {
                            var exa = TrainTypeEnum.RZ;
                            exa.SeatPrice = m.rz_price;
                            exa.SeatCount = m.rz_num;
                            infoModel.DetailList.Add(exa);
                        }


                        //1
                        if (m.yz_num != "--" && m.yz_num != "*" && !string.IsNullOrEmpty(m.yz_price) &&
                            m.yz_price.Trim() != "" && m.yz_price.Trim() != "0")
                        {
                            var exa = TrainTypeEnum.YZ;
                            exa.SeatPrice = m.yz_price;
                            exa.SeatCount = m.yz_num;
                            infoModel.DetailList.Add(exa);
                        }



                        //暂无
                        if (m.qtxb_num != "--" && m.qtxb_num != "*" && !string.IsNullOrEmpty(m.qtxb_price) &&
                            m.qtxb_price.Trim() != "" && m.qtxb_price.Trim() != "0")
                        {
                            var exa = TrainTypeEnum.QTXB;
                            exa.SeatPrice = m.qtxb_price;
                            exa.SeatCount = m.qtxb_num;
                            infoModel.DetailList.Add(exa);
                        }

                        //无座
                        if (m.wz_num != "--" && m.wz_num != "*" && !string.IsNullOrEmpty(m.wz_price) &&
                            m.wz_price.Trim() != "" && m.wz_price.Trim() != "0")
                        {
                            var exa = TrainTypeEnum.WZ;
                            exa.SeatPrice = m.wz_price;
                            exa.SeatCount = m.wz_num;
                            infoModel.DetailList.Add(exa);
                        }

                        if (infoModel.DetailList.Count == 0)
                        {
                            resultList.Remove(infoModel);
                        }
                        else
                        {
                            infoModel.DetailList = infoModel.DetailList.OrderBy(a => a.SeatIndex).ToList();
                        }
                    }
                    return(resultList);
                }

                #endregion
            }


            throw new Exception("查询未成功,原因是: " + trainResponseModel.msg);
        }
Example #5
0
        public ResponseBaseViewModel <SearchTrainResponseViewModel> GetQueryTrain([FromBody] SearchTrainRequestViewModel request)
        {
            factory = new QueryTrainFactory();
            domain  = factory.CreateDomainObj();

            TraQueryTrainModel queryTrainModel = new TraQueryTrainModel()
            {
                from_station  = request.FromStation,
                needdistance  = request.NeedDistance,
                purpose_codes = request.PurposeCodes,
                to_station    = request.ToStation,
                train_date    = request.TrainDate
            };



            var obj = domain.DoQueryTrain(queryTrainModel);

            #region 格式变换
            //生成新的格式
            SearchTrainResponseViewModel exa = new SearchTrainResponseViewModel();
            List <string> formStation        = new List <string>();
            List <string> toStation          = new List <string>();
            List <string> trainType          = new List <string>();
            //遍历
            foreach (var item in obj)
            {
                trainType.Add(item.train_type);
                formStation.Add(item.from_station_name);
                toStation.Add(item.to_station_name);
            }
            //去重
            HashSet <string> hTrainType   = new HashSet <string>(trainType);
            HashSet <string> hFormStation = new HashSet <string>(formStation);
            HashSet <string> hToStation   = new HashSet <string>(toStation);
            //引用
            List <TraTravelInfoViewModel> travelInfo = new List <TraTravelInfoViewModel>();
            foreach (var item in obj)
            {
                TraTravelInfoViewModel travelInfoViewModel = new TraTravelInfoViewModel()
                {
                    AccessByidCard   = item.access_byidcard,
                    ArriveDays       = item.arrive_days,
                    ArriveTime       = item.arrive_time,
                    CanBuyNow        = item.can_buy_now,
                    DetailList       = AutoMapperHelper.DoMapList <TraTravelInfoDetailModel, TraTravelInfoDetailViewModel>(item.DetailList).ToList(),
                    Distance         = item.distance,
                    EndStationName   = item.end_station_name,
                    FromStationCode  = item.from_station_code,
                    FromStationName  = item.from_station_name,
                    Note             = item.note,
                    RunTime          = item.run_time,
                    RunTimeMinute    = item.run_time_minute,
                    SaleDateTime     = item.sale_date_time,
                    StartStationName = item.start_station_name,
                    StartTime        = item.start_time,
                    ToStationCode    = item.to_station_code,
                    ToStationName    = item.to_station_name,
                    TrainCode        = item.train_code,
                    TrainNo          = item.train_no,
                    TrainStartDate   = Convert.ToDateTime(queryTrainModel.train_date).ToString("yyyy-MM-dd"),//item.train_start_date,
                    TrainType        = item.train_type
                };
                travelInfo.Add(travelInfoViewModel);
            }



            exa.TravelInfo  = travelInfo;
            exa.FormStation = hFormStation.ToList();
            exa.ToStation   = hToStation.ToList();
            exa.TrainType   = hTrainType.ToList();
            #endregion

            var UIModel = new ResponseBaseViewModel <SearchTrainResponseViewModel>();
            var Flag    = new ResponseCodeViewModel();
            UIModel.Flag = Flag;
            UIModel.Data = exa;
            if (exa.TravelInfo.Count > 0)
            {
                UIModel.Flag.Code = 0;
            }

            return(UIModel);
        }