| | |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using WIDESEAWCS_Core; |
| | | using WIDESEAWCS_Core.BaseServices; |
| | | using WIDESEAWCS_Core.Enums; |
| | | using WIDESEAWCS_IBasicInfoRepository; |
| | | using WIDESEAWCS_IBasicInfoService; |
| | | using WIDESEAWCS_Model.Models; |
| | |
| | | return routers; |
| | | } |
| | | |
| | | |
| | | public List<string> QueryAllPositions(string deviceCode) |
| | | { |
| | | List<string> positions = new List<string>(); |
| | | try |
| | | { |
| | | List<string> inRouterPositions = BaseDal.QueryData(x => x.ChildPosiDeviceCode == deviceCode && x.InOutType == RouterInOutType.In).GroupBy(x => x.StartPosi).Select(x => x.Key).ToList(); |
| | | |
| | | List<string> outRouterPositions = BaseDal.QueryData(x => x.ChildPosiDeviceCode == deviceCode && x.InOutType == RouterInOutType.Out).GroupBy(x => x.ChildPosi).Select(x => x.Key).ToList(); |
| | | |
| | | positions.AddRange(inRouterPositions); |
| | | positions.AddRange(outRouterPositions); |
| | | return positions.GroupBy(x => x).Select(x => x.Key).ToList(); |
| | | } |
| | | catch |
| | | { |
| | | |
| | | } |
| | | return positions; |
| | | } |
| | | |
| | | public WebResponseContent GetAllWholeRouters() |
| | | { |
| | | WebResponseContent content = new(); |
| | | try |
| | | { |
| | | List<object> data = new List<object>(); |
| | | List<Dt_Router> dt_Routers = BaseDal.QueryData(x => x.IsEnd, new Dictionary<string, OrderByType> { { nameof(Dt_Router.IsEnd), OrderByType.Desc } }); |
| | | |
| | | foreach (var item in dt_Routers) |
| | | { |
| | | string routes = $"{item.ChildPosi},"; |
| | | string str = GetPreviousRoutes(item.StartPosi); |
| | | if (!string.IsNullOrEmpty(str)) |
| | | { |
| | | if (str.EndsWith(",")) |
| | | str = str.Substring(0, str.Length - 1); |
| | | routes += str; |
| | | } |
| | | if (item.InOutType == RouterInOutType.In) |
| | | { |
| | | List<string> itemRouters = routes.Split(",").Reverse().ToList(); |
| | | object obj = new { type = RouterInOutType.In, routes = itemRouters }; |
| | | data.Add(obj); |
| | | } |
| | | else |
| | | { |
| | | List<string> itemRouters = routes.Split(",").Reverse().ToList(); |
| | | object obj = new { type = RouterInOutType.Out, routes = itemRouters }; |
| | | data.Add(obj); |
| | | } |
| | | } |
| | | |
| | | content = WebResponseContent.Instance.OK(data: data); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | |
| | | } |
| | | return content; |
| | | } |
| | | |
| | | public string GetPreviousRoutes(string startPosi) |
| | | { |
| | | string routers = string.Empty; |
| | | if (!string.IsNullOrEmpty(startPosi)) |
| | | { |
| | | if (!routers.EndsWith(",")) |
| | | routers += $"{startPosi},"; |
| | | else |
| | | routers += $"{startPosi}"; |
| | | } |
| | | List<Dt_Router> preRouters = BaseDal.QueryData(x => x.NextPosi == startPosi, new Dictionary<string, OrderByType> { { nameof(Dt_Router.IsEnd), OrderByType.Desc } }); |
| | | foreach (var item in preRouters) |
| | | { |
| | | string str = GetPreviousRoutes(item.StartPosi); |
| | | if (!string.IsNullOrEmpty(str)) |
| | | { |
| | | if (routers.EndsWith(",")) |
| | | routers += $"{str}"; |
| | | else |
| | | routers += $"{str},"; |
| | | } |
| | | } |
| | | return routers; |
| | | } |
| | | } |
| | | } |