wangxinhui
2025-02-19 28aac1b84d301b79a0ca784e812561422fbac4a5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WIDESEAWCS_QuartzJob.Models;
using WIDESEAWCS_QuartzJob.Repository;
using WIDESEAWCS_QuartzJob.Service;
 
namespace WIDESEAWCS_Tasks
{
    public class RouterExtension : IRouterExtension
    {
        private readonly IRouterRepository _routerRepository;
 
        public RouterExtension(IRouterRepository routerRepository)
        {
            _routerRepository = routerRepository;
        }
 
        public List<Dt_Router> GetEndPoint(string startPoint, int routeType)
        {
            List<Dt_Router> routers = new List<Dt_Router>();
            try
            {
                List<Dt_Router> dt_Routers = _routerRepository.QueryData(x => x.StartPosi == startPoint && x.InOutType == routeType);
                foreach (var item in dt_Routers)
                {
                    if (item.IsEnd && !routers.Any(x => x.Id == item.Id))
                    {
                        routers.Add(item);
                    }
                    else
                    {
                        List<Dt_Router> tempRouters = GetEndPoint(item.NextPosi, routeType);
                        foreach (var router in tempRouters)
                        {
                            //如果下一个路由的起点和终点都匹配,则添加到路由列表中
                            if (router.IsEnd && !routers.Any(x => x.Id == router.Id))
                            {
                                routers.Add(router);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
 
            }
 
            return routers;
        }
    }
}