新增基础数据接口库,MOM工艺路线模版左侧树形结构返回
This commit is contained in:
76
Tnb.BasicData/RouteTreeService.cs
Normal file
76
Tnb.BasicData/RouteTreeService.cs
Normal file
@@ -0,0 +1,76 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
17
Tnb.BasicData/Tnb.BasicData.csproj
Normal file
17
Tnb.BasicData/Tnb.BasicData.csproj
Normal file
@@ -0,0 +1,17 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<GenerateDocumentationFile>True</GenerateDocumentationFile>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\common\Tnb.Common.Core\Tnb.Common.Core.csproj" />
|
||||
<ProjectReference Include="..\system\Tnb.Systems.Interfaces\Tnb.Systems.Interfaces.csproj" />
|
||||
<ProjectReference Include="..\Tnb.BasicData.Entitys\Tnb.BasicData.Entitys.csproj" />
|
||||
<ProjectReference Include="..\Tnb.BasicData.Interfaces\Tnb.BasicData.Interfaces.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
Reference in New Issue
Block a user