76 lines
2.9 KiB
C#
76 lines
2.9 KiB
C#
using System.CodeDom;
|
|
using Aspose.Cells;
|
|
using JNPF.Common.Core.Manager;
|
|
using JNPF.DependencyInjection;
|
|
using JNPF.DynamicApiController;
|
|
using JNPF.Systems.Entitys.System;
|
|
using JNPF.Systems.Interfaces.System;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Spire.Presentation;
|
|
using SqlSugar;
|
|
using Tnb.BasicData.Entitys.Entity;
|
|
using Tnb.BasicData.Entitys.Model;
|
|
|
|
namespace Tnb.BasicData
|
|
{
|
|
/// <summary>
|
|
/// MOM基础数据服务
|
|
/// </summary>
|
|
[ApiDescriptionSettings(Tag = "BasicData", Name = "RouteLineTemplate", Order = 700)]
|
|
[Route("api/Route/[controller]")]
|
|
public class RouteTreeService : IDynamicApiController, ITransient
|
|
{
|
|
private readonly ISqlSugarRepository<BasRoute> _repository;
|
|
private readonly DataBaseManager _dbManager;
|
|
private readonly IDictionaryDataService _dictionaryDataService;
|
|
|
|
public RouteTreeService(
|
|
IDictionaryDataService dictionaryDataService,
|
|
ISqlSugarRepository<BasRoute> repository,
|
|
DataBaseManager dbManager)
|
|
{
|
|
_dictionaryDataService = dictionaryDataService;
|
|
_repository = repository;
|
|
_dbManager = dbManager;
|
|
}
|
|
/// <summary>
|
|
/// 返回工艺路线树形结构
|
|
/// </summary>
|
|
/// <returns>工艺路线模版树形结构</returns>
|
|
[AllowAnonymous]
|
|
[HttpGet("route-tree")]
|
|
public async Task<List<RouteTree>> GetRouteTreeList()
|
|
{
|
|
var dictaryDataList = await _dictionaryDataService.GetList("24950639717653");
|
|
var dictaryData = dictaryDataList.ToDictionary(x => x.EnCode, x => x.FullName);
|
|
SqlSugarScope sugarClient = null!;
|
|
var result = new List<RouteTree>();
|
|
var momDbLink = await _repository.AsSugarClient().Queryable<DbLinkEntity>().FirstAsync(x => x.FullName == "tnb_mom");
|
|
if (momDbLink != null)
|
|
{
|
|
sugarClient = _dbManager.ChangeDataBase(momDbLink);
|
|
}
|
|
|
|
var list = await sugarClient.Queryable<BasRoute>().ToListAsync();
|
|
if (list?.Count > 0)
|
|
{
|
|
var routeGroups = list.GroupBy(g => g.RouteType);
|
|
foreach (var routeGroup in routeGroups)
|
|
{
|
|
var routeTree = new RouteTree();
|
|
routeTree.RouteType = dictaryData.ContainsKey(routeGroup.Key) ? dictaryData[routeGroup.Key] : "";
|
|
var routeNameGroup = routeGroup.GroupBy(g => new { g.RouteName, g.RouteCode });
|
|
|
|
routeTree.RouteName = routeNameGroup.Select(x => new RouteName
|
|
{
|
|
Tag = $"{x.Key.RouteName}|{x.Key.RouteCode}",
|
|
RouteVersion = x.Select(t => t.Version).ToList(),
|
|
}).ToList();
|
|
result.Add(routeTree);
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
}
|
|
} |