public void FileAnalysis()
    {
        RepetitivePlanVM model = new RepetitivePlanVM();

        if (System.Web.HttpContext.Current.Session["session_filetext"] != null)
        {
            var fileText = System.Web.HttpContext.Current.Session["session_filetext"].ToString();
            //日期
            MatchCollection dateMatch = Regex.Matches(fileText, FileAnalysisReg.dateReg);
            try
            {
                if (dateMatch.Count > 1)
                {
                    model.StartDate = DateTime.Parse(dateMatch[0].Value.Replace("年", "-").Replace("月", "-").Replace("日", ""));
                    model.EndDate   = DateTime.Parse(dateMatch[1].Value.Replace("年", "-").Replace("月", "-").Replace("日", ""));
                }
                else if (dateMatch.Count == 1)
                {
                    var arr = dateMatch[0].Value.Split('至');
                    model.StartDate = DateTime.Parse(arr[0].Replace("年", "-").Replace("月", "-").Replace("日", ""));
                    model.EndDate   = DateTime.Parse(arr[1].Replace("年", "-").Replace("月", "-").Replace("日", ""));
                }
            }
            catch
            { }
            //公司名称
            if (Regex.IsMatch(fileText, FileAnalysisReg.companyReg))
            {
                try
                {
                    model.CompanyName = Regex.Match(fileText, FileAnalysisReg.companyReg).Value + "公司";
                }
                catch
                {
                }
            }
            ////地区
            //if (Regex.IsMatch(fileText, FileAnalysisReg.areaReg))
            //{
            //    model.FlightArea = Regex.Match(fileText, FileAnalysisReg.areaReg).Value;
            //}
            //任务性质
            if (Regex.IsMatch(fileText, FileAnalysisReg.taskReg))
            {
                try
                {
                    var list = fbll.GetList();

                    model.FlightType = list.Find(m => m.Description.Contains(Regex.Match(fileText, FileAnalysisReg.taskReg).Value)).TaskCode;
                }
                catch
                {
                }
            }
            //机型
            if (Regex.IsMatch(fileText, FileAnalysisReg.airplaneTypeReg))
            {
                model.AircraftType = Regex.Match(fileText, FileAnalysisReg.airplaneTypeReg).Value;
            }
            #region 临时起降点

            if (Regex.IsMatch(fileText, FileAnalysisReg.airportReg))
            {
                model.AirportText = Regex.Match(fileText, FileAnalysisReg.airportReg).Value;

                if (Regex.IsMatch(model.AirportText, FileAnalysisReg.airportReg1))
                {
                    MatchCollection airportMatches = Regex.Matches(model.AirportText, FileAnalysisReg.airportReg1);
                    foreach (Match airport in airportMatches)
                    {
                        string airportName = "", code4 = "", lngAndLat = "";
                        if (Regex.IsMatch(airport.Value, FileAnalysisReg.airportName))
                        {
                            airportName = Regex.Match(airport.Value, FileAnalysisReg.airportName).Value;
                        }
                        if (Regex.IsMatch(airport.Value, FileAnalysisReg.code4))
                        {
                            code4 = Regex.Match(airport.Value, FileAnalysisReg.code4).Value;
                        }
                        if (Regex.IsMatch(airport.Value, FileAnalysisReg.lngAndLat))
                        {
                            lngAndLat = Regex.Match(airport.Value, FileAnalysisReg.lngAndLat).Value;
                        }
                        model.airportList.Add(new AirportVM()
                        {
                            Name    = airportName,
                            Code4   = code4,
                            LatLong = lngAndLat
                        });
                    }
                }
            }

            #endregion
            #region 航线分析
            if (Regex.IsMatch(fileText, @"(?<=(\uff08\u4e00\uff09\u822a\u7ebf))[.\s\S]*?(?=(\uff08\u4e8c\uff09\u4f5c\u4e1a\u533a))"))
            {
                model.AirlineText = Regex.Match(fileText, @"(?<=(\uff08\u4e00\uff09\u822a\u7ebf))[.\s\S]*?(?=(\uff08\u4e8c\uff09\u4f5c\u4e1a\u533a))").Value;
            }
            MatchCollection areaMatch = Regex.Matches(model.AirlineText, @"(?<=[1-9\uff1a][\.\u3001\r])[^\uff1b^\u3002^\;]+");
            if (areaMatch.Count > 0)
            {
                var i = 0;
                foreach (Match area in areaMatch)
                {
                    if (i == 0)
                    {
                        i++;
                        continue;
                    }
                    try
                    {
                        var       areaval = area.Value.Split('-');
                        AirlineVM airvm   = new AirlineVM();
                        foreach (var item in areaval)
                        {
                            string airlineName = "", lngAndLat = "";
                            if (Regex.IsMatch(item, "^[\u4e00-\u9fa5_a-zA-Z0-9]+"))
                            {
                                airlineName = Regex.Match(item, "^[\u4e00-\u9fa5_a-zA-Z0-9]+").Value;
                            }
                            if (Regex.IsMatch(item, FileAnalysisReg.lngAndLat))
                            {
                                lngAndLat = Regex.Match(item, FileAnalysisReg.lngAndLat).Value;
                            }
                            airvm.pointList.Add(new PointVM()
                            {
                                Name    = airlineName,
                                LatLong = lngAndLat
                            });
                        }
                        if (airvm.pointList.Count > model.airLineMaxCol)
                        {
                            model.airLineMaxCol = airvm.pointList.Count;
                        }
                        //高度
                        if (Regex.IsMatch(area.Value, @"(?<=(\u9ad8\u5ea6))[.\s\S]*?(?=(\u7c73))"))
                        {
                            airvm.FlyHeight = Regex.Match(area.Value, @"(?<=(\u9ad8\u5ea6))[.\s\S]*?(?=(\u7c73))").Value;
                        }
                        model.airlineList.Add(airvm);
                    }
                    catch (Exception ex)
                    { }
                }
            }
            #endregion
            #region 作业区

            if (Regex.IsMatch(fileText, @"(?<=(\uff08\u4e8c\uff09\u4f5c\u4e1a\u533a))[.\s\S]*?(?=(\u4e94\u3001\u5b89\u5168\u8d23\u4efb))"))
            {
                model.WorkText = Regex.Match(fileText, @"(?<=(\uff08\u4e8c\uff09\u4f5c\u4e1a\u533a))[.\s\S]*?(?=(\u4e94\u3001\u5b89\u5168\u8d23\u4efb))").Value.Trim();
            }

            MatchCollection areaMatch1 = Regex.Matches(model.WorkText, @"(?<=[1-9\uff1a][\.\u3001\r])[^\uff1b^\u3002^\;]+");
            if (areaMatch1.Count > 0)
            {
                var i = 0;
                foreach (Match area in areaMatch1)
                {
                    if (i < 1)
                    {
                        i++;
                        continue;
                    }
                    #region 作业区(圆)
                    try
                    {
                        if (area.Value.Contains("为圆心半径") && Regex.IsMatch(area.Value, @"(?<=(\u4e3a\u5706\u5fc3\u534a\u5f84))[.\s\S]*?(?=(\u516c\u91cc\u8303\u56f4\u5185))"))
                        {
                            var    areaval = area.Value.Split('-');
                            WorkVM workvm  = new WorkVM();
                            foreach (var item in areaval)
                            {
                                string workName = "", lngAndLat = "";
                                if (Regex.IsMatch(item, "^[\u4e00-\u9fa5_a-zA-Z0-9]+"))
                                {
                                    workName = Regex.Match(item, "^[\u4e00-\u9fa5_a-zA-Z0-9]+").Value.Replace("以", "");
                                }

                                if (Regex.IsMatch(item, FileAnalysisReg.lngAndLat))
                                {
                                    lngAndLat = Regex.Match(item, FileAnalysisReg.lngAndLat).Value;
                                }
                                workvm.pointList.Add(new PointVM()
                                {
                                    Name    = workName,
                                    LatLong = lngAndLat
                                });
                            }
                            //半径
                            if (Regex.IsMatch(area.Value, @"(?<=(\u4e3a\u5706\u5fc3\u534a\u5f84))[.\s\S]*?(?=(\u516c\u91cc\u8303\u56f4\u5185))"))
                            {
                                workvm.Raidus = Regex.Match(area.Value, @"(?<=(\u4e3a\u5706\u5fc3\u534a\u5f84))[.\s\S]*?(?=(\u516c\u91cc\u8303\u56f4\u5185))").Value;
                            }
                            //高度
                            if (Regex.IsMatch(area.Value, @"(?<=(\u9ad8\u5ea6))[.\s\S]*?(?=(\u7c73))"))
                            {
                                workvm.FlyHeight = Regex.Match(area.Value, @"(?<=(\u9ad8\u5ea6))[.\s\S]*?(?=(\u7c73))").Value;
                            }
                            model.cworkList.Add(workvm);
                        }
                    }
                    catch
                    { }
                    #endregion
                    #region 作业区(点)
                    try
                    {
                        if (area.Value.Contains("连线范围"))
                        {
                            var    areaval = area.Value.Split('-');
                            WorkVM workvm  = new WorkVM();
                            foreach (var item in areaval)
                            {
                                string workName = "", lngAndLat = "";
                                if (Regex.IsMatch(item, "^[\u4e00-\u9fa5_a-zA-Z0-9]+"))
                                {
                                    workName = Regex.Match(item, "^[\u4e00-\u9fa5_a-zA-Z0-9]+").Value;
                                }

                                if (Regex.IsMatch(item, FileAnalysisReg.lngAndLat))
                                {
                                    lngAndLat = Regex.Match(item, FileAnalysisReg.lngAndLat).Value;
                                }
                                workvm.pointList.Add(new PointVM()
                                {
                                    Name    = workName,
                                    LatLong = lngAndLat
                                });
                            }
                            if (workvm.pointList.Count > model.pworkMaxCol)
                            {
                                model.pworkMaxCol = workvm.pointList.Count;
                            }

                            //高度
                            if (Regex.IsMatch(area.Value, @"(?<=(\u9ad8\u5ea6))[.\s\S]*?(?=(\u7c73))"))
                            {
                                workvm.FlyHeight = Regex.Match(area.Value, @"(?<=(\u9ad8\u5ea6))[.\s\S]*?(?=(\u7c73))").Value;
                            }
                            model.pworkList.Add(workvm);
                        }
                    }
                    catch
                    { }
                    #endregion
                    #region 作业区(线)
                    try
                    {
                        if (area.Value.Contains("航线左右") && Regex.IsMatch(area.Value, @"(?<=(\u822a\u7ebf\u5de6\u53f3))[.\s\S]*?(?=(\u516c\u91cc\u8303\u56f4\u5185))"))
                        {
                            var    areaval = area.Value.Split('-');
                            WorkVM workvm  = new WorkVM();
                            foreach (var item in areaval)
                            {
                                string airportName = "", lngAndLat = "";
                                if (Regex.IsMatch(item, "^[\u4e00-\u9fa5_a-zA-Z0-9]+"))
                                {
                                    airportName = Regex.Match(item, "^[\u4e00-\u9fa5_a-zA-Z0-9]+").Value;
                                }
                                if (Regex.IsMatch(item, FileAnalysisReg.lngAndLat))
                                {
                                    lngAndLat = Regex.Match(item, FileAnalysisReg.lngAndLat).Value;
                                }
                                workvm.pointList.Add(new PointVM()
                                {
                                    Name    = airportName,
                                    LatLong = lngAndLat
                                });
                            }
                            if (workvm.pointList.Count > model.hworkMaxCol)
                            {
                                model.hworkMaxCol = workvm.pointList.Count;
                            }
                            //距离(航线左右--公里范围)
                            if (Regex.IsMatch(area.Value, @"(?<=(\u9ad8\u5ea6))[.\s\S]*?(?=(\u7c73))"))
                            {
                                workvm.Raidus = Regex.Match(area.Value, @"(?<=(\u822a\u7ebf\u5de6\u53f3))[.\s\S]*?(?=(\u516c\u91cc\u8303\u56f4))").Value;
                            }
                            //高度
                            if (Regex.IsMatch(area.Value, @"(?<=(\u9ad8\u5ea6))[.\s\S]*?(?=(\u7c73))"))
                            {
                                workvm.FlyHeight = Regex.Match(area.Value, @"(?<=(\u9ad8\u5ea6))[.\s\S]*?(?=(\u7c73))").Value;
                            }
                            model.hworkList.Add(workvm);
                        }
                    }
                    catch
                    { }
                    #endregion
                }
                ;
            }
            #endregion
        }
        Response.Clear();
        Response.Write(JsonConvert.SerializeObject(model));
        Response.ContentType = "application/json";
        Response.End();
    }
Exemplo n.º 2
0
    /// <summary>
    /// 临时计划
    /// </summary>

    private void GetData1()
    {
        var          planid = Request.Form["id"];
        FlightPlanVM model  = new FlightPlanVM();
        var          data   = bll.Get(Guid.Parse(planid));

        if (data != null)
        {
            model.FillObject(data);
            var filemasterList = bll.GetFileFlightPlanMasterList(u => u.FlightPlanID.Equals(planid)).Select(u => u.MasterID);
            var masterList     = rpbll.GetFileMasterList(u => filemasterList.Contains(u.ID));
            var airlinelist    = masterList.Where(u => u.WorkType.Equals("airline"));
            if (airlinelist != null && airlinelist.Any())
            {
                foreach (var item in airlinelist)
                {
                    var airlinevm = new AirlineVM();
                    airlinevm.FlyHeight = item.FlyHeight;
                    var detailList = rpbll.GetFileDetailList(o => o.MasterID == item.ID);
                    airlinevm.pointList.AddRange(detailList.Select(u => new PointVM()
                    {
                        Name    = u.PointName,
                        LatLong = (!string.IsNullOrEmpty(u.Latitude) && !string.IsNullOrEmpty(u.Longitude)) ? string.Concat("N", SpecialFunctions.ConvertDigitalToDegrees(u.Latitude), "E", SpecialFunctions.ConvertDigitalToDegrees(u.Longitude)) : ""
                    }));
                    if (airlinevm.pointList.Count > model.airLineMaxCol)
                    {
                        model.airLineMaxCol = airlinevm.pointList.Count;
                    }
                    model.airlineList.Add(airlinevm);
                    model.airlineworkList.Add(item.ID);
                }
                ;
            }
            var worklist = masterList.Where(u => u.WorkType.Equals("circle") || u.WorkType.Equals("airlinelr") || u.WorkType.Equals("area"));
            if (worklist != null && worklist.Any())
            {
                foreach (var item in worklist)
                {
                    var workvm = new WorkVM();
                    workvm.FlyHeight = item.FlyHeight;
                    workvm.Raidus    = (item.RaidusMile ?? 0).ToString();
                    var detailList = rpbll.GetFileDetailList(o => o.MasterID == item.ID);
                    workvm.pointList.AddRange(detailList.Select(u => new PointVM()
                    {
                        Name    = u.PointName,
                        LatLong = (!string.IsNullOrEmpty(u.Latitude) && !string.IsNullOrEmpty(u.Longitude)) ? string.Concat("N", SpecialFunctions.ConvertDigitalToDegrees(u.Latitude), "E", SpecialFunctions.ConvertDigitalToDegrees(u.Longitude)) : ""
                    }));

                    switch (item.WorkType.ToLower())
                    {
                    case "circle":
                        model.cworkList.Add(workvm);
                        model.airlineworkList.Add(item.ID);
                        break;

                    case "airlinelr":
                        if (workvm.pointList.Count > model.hworkMaxCol)
                        {
                            model.hworkMaxCol = workvm.pointList.Count;
                        }
                        model.hworkList.Add(workvm);
                        model.airlineworkList.Add(item.ID);
                        break;

                    case "area":
                        if (workvm.pointList.Count > model.pworkMaxCol)
                        {
                            model.pworkMaxCol = workvm.pointList.Count;
                        }
                        model.pworkList.Add(workvm);
                        model.airlineworkList.Add(item.ID);
                        break;

                    default:
                        break;
                    }
                }
                ;
            }
        }
        Response.Write(JsonConvert.SerializeObject(model));
        Response.ContentType = "application/json";
        Response.End();
    }