修改ebom相关名称
This commit is contained in:
@@ -0,0 +1,84 @@
|
|||||||
|
namespace Tnb.BasicData.Entitys.Dto
|
||||||
|
{
|
||||||
|
public class EbomTreeOutput
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 物料名称
|
||||||
|
/// </summary>
|
||||||
|
public string material_id { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 规格描述
|
||||||
|
/// </summary>
|
||||||
|
public string material_id_extras { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 物料id
|
||||||
|
/// </summary>
|
||||||
|
public string material_id_id { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 最小包装
|
||||||
|
/// </summary>
|
||||||
|
public decimal? material_id_minpacking { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 备注
|
||||||
|
/// </summary>
|
||||||
|
public string material_id_remark { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 单位
|
||||||
|
/// </summary>
|
||||||
|
public string material_id_unitid { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 是否有下级
|
||||||
|
/// </summary>
|
||||||
|
public bool hasChildren { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Desc:投料管控
|
||||||
|
/// Default:NULL::character varying
|
||||||
|
/// Nullable:True
|
||||||
|
/// </summary>
|
||||||
|
public string feeding_control {get;set;}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Desc:损耗率
|
||||||
|
/// Default:NULL::character varying
|
||||||
|
/// Nullable:True
|
||||||
|
/// </summary>
|
||||||
|
public string loss_rate {get;set;}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Desc:数量
|
||||||
|
/// Default:NULL::character varying
|
||||||
|
/// Nullable:True
|
||||||
|
/// </summary>
|
||||||
|
public string quantity {get;set;}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Desc:需要称量
|
||||||
|
/// Default:NULL::character varying
|
||||||
|
/// Nullable:True
|
||||||
|
/// </summary>
|
||||||
|
public string require_weight {get;set;}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Desc:替代物料
|
||||||
|
/// Default:NULL::character varying
|
||||||
|
/// Nullable:True
|
||||||
|
/// </summary>
|
||||||
|
public string substitute_material {get;set;}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Desc:工艺路线
|
||||||
|
/// Default:NULL::character varying
|
||||||
|
/// Nullable:True
|
||||||
|
/// </summary>
|
||||||
|
public string routing {get;set;}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Desc:版本号
|
||||||
|
/// Default:NULL::character varying
|
||||||
|
/// Nullable:True
|
||||||
|
/// </summary>
|
||||||
|
public string version {get;set;}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
namespace Tnb.BasicData.Entitys.Dto
|
namespace Tnb.BasicData.Entitys.Dto
|
||||||
{
|
{
|
||||||
public class ParentMaterialTreeQueryInput
|
public class EbomTreeQueryInput
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 物料清单id
|
/// 物料清单id
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string parentMaterialId { get; set; }
|
public string ebomId { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 物料id
|
/// 物料id
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
namespace Tnb.BasicData.Entitys.Dto
|
|
||||||
{
|
|
||||||
public class ParentMaterialTreeOutput
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 物料名称
|
|
||||||
/// </summary>
|
|
||||||
public string material_id { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 规格描述
|
|
||||||
/// </summary>
|
|
||||||
public string material_id_extras { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 物料id
|
|
||||||
/// </summary>
|
|
||||||
public string material_id_id { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 最小包装
|
|
||||||
/// </summary>
|
|
||||||
public decimal? material_id_minpacking { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 备注
|
|
||||||
/// </summary>
|
|
||||||
public string material_id_remark { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 单位
|
|
||||||
/// </summary>
|
|
||||||
public string material_id_unitid { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 是否有下级
|
|
||||||
/// </summary>
|
|
||||||
public bool hasChildren { get; set; }
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -6,10 +6,10 @@ namespace Tnb.BasicData.Entitys.Entity
|
|||||||
///<summary>
|
///<summary>
|
||||||
///物料清单子表
|
///物料清单子表
|
||||||
///</summary>
|
///</summary>
|
||||||
[SugarTable("bas_parent_material_items")]
|
[SugarTable("bas_ebom_d")]
|
||||||
public class BasParentMaterialItems : BaseEntity<string>
|
public class BasEbomD : BaseEntity<string>
|
||||||
{
|
{
|
||||||
public BasParentMaterialItems(){
|
public BasEbomD(){
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -34,8 +34,8 @@ namespace Tnb.BasicData.Entitys.Entity
|
|||||||
/// Default:NULL::character varying
|
/// Default:NULL::character varying
|
||||||
/// Nullable:True
|
/// Nullable:True
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[SugarColumn(ColumnName="parent_material_id")]
|
[SugarColumn(ColumnName="ebom_id")]
|
||||||
public string ParentMaterialId {get;set;}
|
public string EbomId {get;set;}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Desc:物料编号/名称
|
/// Desc:物料编号/名称
|
||||||
@@ -6,10 +6,10 @@ namespace Tnb.BasicData.Entitys.Entity
|
|||||||
///<summary>
|
///<summary>
|
||||||
///物料清单父表
|
///物料清单父表
|
||||||
///</summary>
|
///</summary>
|
||||||
[SugarTable("bas_parent_material")]
|
[SugarTable("bas_ebom_h")]
|
||||||
public class BasParentMaterial : BaseEntity<string>
|
public class BasEbomH : BaseEntity<string>
|
||||||
{
|
{
|
||||||
public BasParentMaterial(){
|
public BasEbomH(){
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -7,82 +7,119 @@ using Tnb.Common.Contracts;
|
|||||||
|
|
||||||
namespace Tnb.BasicData.Entitys.Entity
|
namespace Tnb.BasicData.Entitys.Entity
|
||||||
{
|
{
|
||||||
/// <summary>
|
///<summary>
|
||||||
/// 工艺路线资料
|
///工艺路线
|
||||||
///</summary>
|
///</summary>
|
||||||
[SugarTable("bas_route")]
|
[SugarTable("bas_route")]
|
||||||
public class BasRoute : BaseEntity<string>
|
public class BasRoute : BaseEntity<string>
|
||||||
{
|
{
|
||||||
/// <summary>
|
public BasRoute(){
|
||||||
/// 工艺路线代码
|
|
||||||
///</summary>
|
|
||||||
[SugarColumn(ColumnName = "route_code")]
|
}
|
||||||
public string RouteCode { get; set; }
|
/// <summary>
|
||||||
/// <summary>
|
/// Desc:主键
|
||||||
/// 工艺路线名称
|
/// Default:
|
||||||
///</summary>
|
/// Nullable:False
|
||||||
[SugarColumn(ColumnName = "route_name")]
|
/// </summary>
|
||||||
public string RouteName { get; set; }
|
[SugarColumn(IsPrimaryKey=true,ColumnName="id")]
|
||||||
/// <summary>
|
public string Id {get;set;}
|
||||||
/// 工艺路线版本
|
|
||||||
///</summary>
|
/// <summary>
|
||||||
[SugarColumn(ColumnName = "version")]
|
/// Desc:编号
|
||||||
public string Version { get; set; }
|
/// Default:
|
||||||
/// <summary>
|
/// Nullable:False
|
||||||
/// 工艺路线类型: 标准途程:Standard 返工途程:Rework 试制途程:Trial 返修途程:RMA
|
/// </summary>
|
||||||
///</summary>
|
[SugarColumn(ColumnName="code")]
|
||||||
[SugarColumn(ColumnName = "route_type")]
|
public string Code {get;set;}
|
||||||
public string RouteType { get; set; }
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 创建时间
|
/// Desc:名称
|
||||||
///</summary>
|
/// Default:
|
||||||
[SugarColumn(ColumnName = "create_time")]
|
/// Nullable:False
|
||||||
public DateTime CreateTime { get; set; }
|
/// </summary>
|
||||||
/// <summary>
|
[SugarColumn(ColumnName="name")]
|
||||||
/// 修改时间
|
public string Name {get;set;}
|
||||||
///</summary>
|
|
||||||
[SugarColumn(ColumnName = "modify_time")]
|
/// <summary>
|
||||||
public DateTime? ModifyTime { get; set; }
|
/// Desc:有效开始时间
|
||||||
/// <summary>
|
/// Default:
|
||||||
/// 扩展字段
|
/// Nullable:True
|
||||||
///</summary>
|
/// </summary>
|
||||||
[SugarColumn(ColumnName = "extras")]
|
[SugarColumn(ColumnName="start_time")]
|
||||||
public string? Extras { get; set; }
|
public DateTime? StartTime {get;set;}
|
||||||
/// <summary>
|
|
||||||
/// 租户ID
|
/// <summary>
|
||||||
/// 默认值: NULL::character varying
|
/// Desc:有效结束时间
|
||||||
///</summary>
|
/// Default:
|
||||||
[SugarColumn(ColumnName = "tenant_id")]
|
/// Nullable:True
|
||||||
public string? TenantId { get; set; }
|
/// </summary>
|
||||||
/// <summary>
|
[SugarColumn(ColumnName="end_time")]
|
||||||
/// 所属组织ID
|
public DateTime? EndTime {get;set;}
|
||||||
/// 默认值: NULL::character varying
|
|
||||||
///</summary>
|
/// <summary>
|
||||||
[SugarColumn(ColumnName = "org_id")]
|
/// Desc:0 未发布 1 已发布
|
||||||
public string? OrgId { get; set; }
|
/// Default:
|
||||||
/// <summary>
|
/// Nullable:False
|
||||||
/// 备注
|
/// </summary>
|
||||||
/// 默认值: NULL::character varying
|
[SugarColumn(ColumnName="status")]
|
||||||
///</summary>
|
public string Status {get;set;}
|
||||||
[SugarColumn(ColumnName = "remark")]
|
|
||||||
public string? Remark { get; set; }
|
/// <summary>
|
||||||
/// <summary>
|
/// Desc:创建时间
|
||||||
/// 时间戳(用于并发控制)
|
/// Default:
|
||||||
/// 默认值: NULL::character varying
|
/// Nullable:True
|
||||||
///</summary>
|
/// </summary>
|
||||||
[SugarColumn(ColumnName = "timestamp")]
|
[SugarColumn(ColumnName="create_time")]
|
||||||
public string? Timestamp { get; set; }
|
public DateTime? CreateTime {get;set;}
|
||||||
/// <summary>
|
|
||||||
/// 创建用户
|
/// <summary>
|
||||||
/// 默认值: NULL::character varying
|
/// Desc:修改时间
|
||||||
///</summary>
|
/// Default:
|
||||||
[SugarColumn(ColumnName = "create_id")]
|
/// Nullable:True
|
||||||
public string? CreateId { get; set; }
|
/// </summary>
|
||||||
/// <summary>
|
[SugarColumn(ColumnName="modify_time")]
|
||||||
/// 修改用户
|
public DateTime? ModifyTime {get;set;}
|
||||||
/// 默认值: NULL::character varying
|
|
||||||
///</summary>
|
/// <summary>
|
||||||
[SugarColumn(ColumnName = "modify_id")]
|
/// Desc:是否永远有效
|
||||||
public string? ModifyId { get; set; }
|
/// Default:
|
||||||
|
/// Nullable:False
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(ColumnName="is_always_valid")]
|
||||||
|
public int IsAlwaysValid {get;set;}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Desc:所属组织ID
|
||||||
|
/// Default:NULL::character varying
|
||||||
|
/// Nullable:True
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(ColumnName="org_id")]
|
||||||
|
public string OrgId {get;set;}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Desc:创建用户
|
||||||
|
/// Default:NULL::character varying
|
||||||
|
/// Nullable:True
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(ColumnName="create_id")]
|
||||||
|
public string CreateId {get;set;}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Desc:修改用户
|
||||||
|
/// Default:NULL::character varying
|
||||||
|
/// Nullable:True
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(ColumnName="modify_id")]
|
||||||
|
public string ModifyId {get;set;}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Desc:备注
|
||||||
|
/// Default:NULL::character varying
|
||||||
|
/// Nullable:True
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(ColumnName="remark")]
|
||||||
|
public string Remark {get;set;}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,15 +14,15 @@ namespace Tnb.BasicData
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 物料清单
|
/// 物料清单
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[ApiDescriptionSettings(Tag = "BasicData", Name = "ParentMaterial", Order = 701)]
|
[ApiDescriptionSettings(Tag = "BasicData", Name = "Ebom", Order = 701)]
|
||||||
[Route("api/basic/[controller]")]
|
[Route("api/basic/[controller]")]
|
||||||
public class ParentMaterialService : IDynamicApiController, ITransient
|
public class EbomService : IDynamicApiController, ITransient
|
||||||
{
|
{
|
||||||
private readonly ISqlSugarRepository<BasMaterial> _repository;
|
private readonly ISqlSugarRepository<BasMaterial> _repository;
|
||||||
private readonly DataBaseManager _dbManager;
|
private readonly DataBaseManager _dbManager;
|
||||||
private readonly IDictionaryDataService _dictionaryDataService;
|
private readonly IDictionaryDataService _dictionaryDataService;
|
||||||
|
|
||||||
public ParentMaterialService(
|
public EbomService(
|
||||||
ISqlSugarRepository<BasMaterial> repository,DataBaseManager dbManager,IDictionaryDataService dictionaryDataService)
|
ISqlSugarRepository<BasMaterial> repository,DataBaseManager dbManager,IDictionaryDataService dictionaryDataService)
|
||||||
{
|
{
|
||||||
_repository = repository;
|
_repository = repository;
|
||||||
@@ -36,7 +36,7 @@ namespace Tnb.BasicData
|
|||||||
/// <param name="input">获取物料清单树.</param>
|
/// <param name="input">获取物料清单树.</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpPost("[action]")]
|
[HttpPost("[action]")]
|
||||||
public async Task<dynamic> GetTree(ParentMaterialTreeQueryInput queryInput)
|
public async Task<dynamic> GetTree(EbomTreeQueryInput queryInput)
|
||||||
{
|
{
|
||||||
var db = _repository.AsSugarClient();
|
var db = _repository.AsSugarClient();
|
||||||
var dic = await _dictionaryDataService.GetDicByKey(DicTypeKey.MeasurementUnit);
|
var dic = await _dictionaryDataService.GetDicByKey(DicTypeKey.MeasurementUnit);
|
||||||
@@ -49,11 +49,12 @@ namespace Tnb.BasicData
|
|||||||
|
|
||||||
if (string.IsNullOrEmpty(queryInput.materialId))
|
if (string.IsNullOrEmpty(queryInput.materialId))
|
||||||
{
|
{
|
||||||
var data = await db.Queryable<BasParentMaterialItems>()
|
var data = await db.Queryable<BasEbomD>()
|
||||||
.LeftJoin<BasParentMaterial>((a,b)=>a.ParentMaterialId==b.Id)
|
.LeftJoin<BasEbomH>((a,b)=>a.EbomId==b.Id)
|
||||||
.LeftJoin<BasMaterial>((a,b,c)=>a.MaterialId==c.Id)
|
.LeftJoin<BasMaterial>((a,b,c)=>a.MaterialId==c.Id)
|
||||||
.Where((a,b,c)=>a.ParentMaterialId==queryInput.parentMaterialId)
|
.LeftJoin<BasEbomH>((a,b,c,d)=>a.MaterialId==d.MaterialId)
|
||||||
.Select((a,b,c)=>new ParentMaterialTreeOutput
|
.Where((a,b,c)=>a.EbomId==queryInput.ebomId)
|
||||||
|
.Select((a,b,c,d)=>new EbomTreeOutput
|
||||||
{
|
{
|
||||||
material_id = c.MaterialName,
|
material_id = c.MaterialName,
|
||||||
material_id_extras = c.Extras,
|
material_id_extras = c.Extras,
|
||||||
@@ -61,7 +62,14 @@ namespace Tnb.BasicData
|
|||||||
material_id_minpacking = c.Minpacking,
|
material_id_minpacking = c.Minpacking,
|
||||||
material_id_remark = c.Remark,
|
material_id_remark = c.Remark,
|
||||||
material_id_unitid = c.Unitid,
|
material_id_unitid = c.Unitid,
|
||||||
hasChildren = SqlFunc.Subqueryable<BasParentMaterial>().Where(x=>x.MaterialId==a.MaterialId).Any(),
|
feeding_control = a.FeedingControl,
|
||||||
|
loss_rate = a.LossRate,
|
||||||
|
quantity = a.Quantity,
|
||||||
|
require_weight = a.RequireWeight,
|
||||||
|
substitute_material = a.SubstituteMaterial,
|
||||||
|
routing = d.Routing,
|
||||||
|
version = d.Version,
|
||||||
|
hasChildren = SqlFunc.Subqueryable<BasEbomH>().Where(x=>x.MaterialId==a.MaterialId).Any(),
|
||||||
}).Mapper(it =>
|
}).Mapper(it =>
|
||||||
{
|
{
|
||||||
it.material_id_unitid = dic[it.material_id_unitid].ToString();
|
it.material_id_unitid = dic[it.material_id_unitid].ToString();
|
||||||
@@ -70,11 +78,12 @@ namespace Tnb.BasicData
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var data = await db.Queryable<BasParentMaterialItems>()
|
var data = await db.Queryable<BasEbomD>()
|
||||||
.LeftJoin<BasParentMaterial>((a,b)=>a.ParentMaterialId==b.Id)
|
.LeftJoin<BasEbomH>((a,b)=>a.EbomId==b.Id)
|
||||||
.LeftJoin<BasMaterial>((a,b,c)=>a.MaterialId==c.Id)
|
.LeftJoin<BasMaterial>((a,b,c)=>a.MaterialId==c.Id)
|
||||||
.Where((a,b,c)=>b.MaterialId==queryInput.materialId && a.ParentMaterialId==b.Id)
|
.LeftJoin<BasEbomH>((a,b,c,d)=>a.MaterialId==d.MaterialId)
|
||||||
.Select((a,b,c)=>new ParentMaterialTreeOutput
|
.Where((a,b,c)=>b.MaterialId==queryInput.materialId && a.EbomId==b.Id)
|
||||||
|
.Select((a,b,c,d)=>new EbomTreeOutput
|
||||||
{
|
{
|
||||||
material_id = c.MaterialName,
|
material_id = c.MaterialName,
|
||||||
material_id_extras = c.Extras,
|
material_id_extras = c.Extras,
|
||||||
@@ -82,7 +91,14 @@ namespace Tnb.BasicData
|
|||||||
material_id_minpacking = c.Minpacking,
|
material_id_minpacking = c.Minpacking,
|
||||||
material_id_remark = c.Remark,
|
material_id_remark = c.Remark,
|
||||||
material_id_unitid = c.Unitid,
|
material_id_unitid = c.Unitid,
|
||||||
hasChildren = SqlFunc.Subqueryable<BasParentMaterial>().Where(x=>x.MaterialId==a.MaterialId).Any(),
|
feeding_control = a.FeedingControl,
|
||||||
|
loss_rate = a.LossRate,
|
||||||
|
quantity = a.Quantity,
|
||||||
|
require_weight = a.RequireWeight,
|
||||||
|
substitute_material = a.SubstituteMaterial,
|
||||||
|
routing = d.Routing,
|
||||||
|
version = d.Version,
|
||||||
|
hasChildren = SqlFunc.Subqueryable<BasEbomH>().Where(x=>x.MaterialId==a.MaterialId).Any(),
|
||||||
}).Mapper(it =>
|
}).Mapper(it =>
|
||||||
{
|
{
|
||||||
it.material_id_unitid = dic[it.material_id_unitid].ToString();
|
it.material_id_unitid = dic[it.material_id_unitid].ToString();
|
||||||
@@ -92,5 +108,32 @@ namespace Tnb.BasicData
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpPost("[action]")]
|
||||||
|
public async Task<Dictionary<string,string>> GetEbomVersionAndRouteName(string materialId)
|
||||||
|
{
|
||||||
|
var db = _repository.AsSugarClient();
|
||||||
|
|
||||||
|
var momDbLink = await _repository.AsSugarClient().Queryable<DbLinkEntity>().FirstAsync(x => x.FullName == DbName.TNBMON);
|
||||||
|
if (momDbLink != null)
|
||||||
|
{
|
||||||
|
db = _dbManager.ChangeDataBase(momDbLink);
|
||||||
|
}
|
||||||
|
|
||||||
|
var ebom = await db.Queryable<BasEbomH>()
|
||||||
|
.LeftJoin<BasRoute>((a,b)=>a.Routing==b.Id)
|
||||||
|
.Where((a,b) => a.MaterialId == materialId)
|
||||||
|
.Select((a,b)=>new
|
||||||
|
{
|
||||||
|
a.Version,
|
||||||
|
b.Name,
|
||||||
|
}).SingleAsync();
|
||||||
|
return new Dictionary<string,string>()
|
||||||
|
{
|
||||||
|
["version"] = ebom?.Version,
|
||||||
|
["routeName"] = ebom?.Name
|
||||||
|
,
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,142 +1,142 @@
|
|||||||
using System.CodeDom;
|
// using System.CodeDom;
|
||||||
using Aop.Api.Domain;
|
// using Aop.Api.Domain;
|
||||||
using Aop.Api.Request;
|
// using Aop.Api.Request;
|
||||||
using Aspose.Cells;
|
// using Aspose.Cells;
|
||||||
using JNPF.Common.Core.Manager;
|
// using JNPF.Common.Core.Manager;
|
||||||
using JNPF.Common.Security;
|
// using JNPF.Common.Security;
|
||||||
using JNPF.DependencyInjection;
|
// using JNPF.DependencyInjection;
|
||||||
using JNPF.DynamicApiController;
|
// using JNPF.DynamicApiController;
|
||||||
using JNPF.Systems.Entitys.System;
|
// using JNPF.Systems.Entitys.System;
|
||||||
using JNPF.Systems.Interfaces.System;
|
// using JNPF.Systems.Interfaces.System;
|
||||||
using JNPF.VisualDev;
|
// using JNPF.VisualDev;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
// using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
// using Microsoft.AspNetCore.Mvc;
|
||||||
using NPOI.SS.Formula.Functions;
|
// using NPOI.SS.Formula.Functions;
|
||||||
using Spire.Presentation;
|
// using Spire.Presentation;
|
||||||
using SqlSugar;
|
// using SqlSugar;
|
||||||
using Tnb.BasicData.Entitys.Dto.ProcessManage;
|
// using Tnb.BasicData.Entitys.Dto.ProcessManage;
|
||||||
using Tnb.BasicData.Entitys.Entity;
|
// using Tnb.BasicData.Entitys.Entity;
|
||||||
using Tnb.BasicData.Entitys.Model;
|
// using Tnb.BasicData.Entitys.Model;
|
||||||
|
//
|
||||||
namespace Tnb.BasicData
|
// namespace Tnb.BasicData
|
||||||
{
|
// {
|
||||||
/// <summary>
|
// /// <summary>
|
||||||
/// MOM基础数据-工艺管理
|
// /// MOM基础数据-工艺管理
|
||||||
/// </summary>
|
// /// </summary>
|
||||||
|
//
|
||||||
[ApiDescriptionSettings(Tag = "BasicData", Name = "ProcessManage", Order = 700)]
|
// [ApiDescriptionSettings(Tag = "BasicData", Name = "ProcessManage", Order = 700)]
|
||||||
[Route("api/basic/[controller]")]
|
// [Route("api/basic/[controller]")]
|
||||||
public class ProcessManageService : IOverideVisualDevService, IDynamicApiController, ITransient
|
// public class ProcessManageService : IOverideVisualDevService, IDynamicApiController, ITransient
|
||||||
{
|
// {
|
||||||
private readonly ISqlSugarRepository<BasRoute> _repository;
|
// private readonly ISqlSugarRepository<BasRoute> _repository;
|
||||||
private readonly DataBaseManager _dbManager;
|
// private readonly DataBaseManager _dbManager;
|
||||||
private readonly IDictionaryDataService _dictionaryDataService;
|
// private readonly IDictionaryDataService _dictionaryDataService;
|
||||||
private readonly string _dictionaryTypeId;
|
// private readonly string _dictionaryTypeId;
|
||||||
|
//
|
||||||
public ProcessManageService(
|
// public ProcessManageService(
|
||||||
IDictionaryDataService dictionaryDataService,
|
// IDictionaryDataService dictionaryDataService,
|
||||||
ISqlSugarRepository<BasRoute> repository,
|
// ISqlSugarRepository<BasRoute> repository,
|
||||||
DataBaseManager dbManager)
|
// DataBaseManager dbManager)
|
||||||
{
|
// {
|
||||||
_dictionaryDataService = dictionaryDataService;
|
// _dictionaryDataService = dictionaryDataService;
|
||||||
_repository = repository;
|
// _repository = repository;
|
||||||
_dbManager = dbManager;
|
// _dbManager = dbManager;
|
||||||
_dictionaryTypeId = "24950639717653";
|
// _dictionaryTypeId = "24950639717653";
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public OverideVisualDevFunc OverideFuncs => new OverideVisualDevFunc();
|
// public OverideVisualDevFunc OverideFuncs => new OverideVisualDevFunc();
|
||||||
|
//
|
||||||
/// <summary>
|
// /// <summary>
|
||||||
/// 获取工艺路线树形结构
|
// /// 获取工艺路线树形结构
|
||||||
/// </summary>
|
// /// </summary>
|
||||||
/// <returns>工艺路线模版树形结构</returns>
|
// /// <returns>工艺路线模版树形结构</returns>
|
||||||
/// <remarks>
|
// /// <remarks>
|
||||||
///<br/> [{
|
// ///<br/> [{
|
||||||
///<br/> "RouteType": 工艺路线类型,
|
// ///<br/> "RouteType": 工艺路线类型,
|
||||||
///<br/> "Name": 工艺路线类型名称,
|
// ///<br/> "Name": 工艺路线类型名称,
|
||||||
///<br/> "RouteName": 工艺路线名称,
|
// ///<br/> "RouteName": 工艺路线名称,
|
||||||
///<br/> "RouteCode": 工艺路线代码,
|
// ///<br/> "RouteCode": 工艺路线代码,
|
||||||
///<br/> "Version": 工艺路线版本,
|
// ///<br/> "Version": 工艺路线版本,
|
||||||
///<br/> "id": "25325800913429",
|
// ///<br/> "id": "25325800913429",
|
||||||
///<br/> "parentId": null,
|
// ///<br/> "parentId": null,
|
||||||
///<br/> "hasChildren": true,
|
// ///<br/> "hasChildren": true,
|
||||||
///<br/> "children": [{
|
// ///<br/> "children": [{
|
||||||
///<br/> "RouteType": 工艺路线类型,
|
// ///<br/> "RouteType": 工艺路线类型,
|
||||||
///<br/> "Name": 工艺路线名称|工艺路线版本,
|
// ///<br/> "Name": 工艺路线名称|工艺路线版本,
|
||||||
///<br/> "RouteName": "显示器集成",
|
// ///<br/> "RouteName": "显示器集成",
|
||||||
///<br/> "RouteCode": 工艺路线代码,
|
// ///<br/> "RouteCode": 工艺路线代码,
|
||||||
///<br/> "Version": 工艺路线版本,
|
// ///<br/> "Version": 工艺路线版本,
|
||||||
///<br/> "id": 当前节点Id,不用可以忽略,
|
// ///<br/> "id": 当前节点Id,不用可以忽略,
|
||||||
///<br/> "parentId": "父节点Id,不用可以忽略",
|
// ///<br/> "parentId": "父节点Id,不用可以忽略",
|
||||||
///<br/> "hasChildren": 是否包含子节点,true/false,
|
// ///<br/> "hasChildren": 是否包含子节点,true/false,
|
||||||
///<br/> "children": [{
|
// ///<br/> "children": [{
|
||||||
///<br/> "Version": 工艺路线版本,
|
// ///<br/> "Version": 工艺路线版本,
|
||||||
///<br/> }
|
// ///<br/> }
|
||||||
///<br/> ],
|
// ///<br/> ],
|
||||||
///<br/> "num": 子节点数量,不用可以忽略,
|
// ///<br/> "num": 子节点数量,不用可以忽略,
|
||||||
///<br/> "isLeaf": 是否页节点,不用可以忽略 true/false
|
// ///<br/> "isLeaf": 是否页节点,不用可以忽略 true/false
|
||||||
///<br/> }
|
// ///<br/> }
|
||||||
///<br/> ]
|
// ///<br/> ]
|
||||||
///<br/>}
|
// ///<br/>}
|
||||||
///<br/>]
|
// ///<br/>]
|
||||||
/// </remarks>
|
// /// </remarks>
|
||||||
[HttpGet("route-tree")]
|
// [HttpGet("route-tree")]
|
||||||
public async Task<dynamic> GetRouteTreeList()
|
// public async Task<dynamic> GetRouteTreeList()
|
||||||
{
|
// {
|
||||||
var result = new List<RouteLineTreeOutput>();
|
// var result = new List<RouteLineTreeOutput>();
|
||||||
var dictaryDataList = await _dictionaryDataService.GetList(_dictionaryTypeId);
|
// var dictaryDataList = await _dictionaryDataService.GetList(_dictionaryTypeId);
|
||||||
var dictaryData = dictaryDataList.ToDictionary(x => x.EnCode, x => x.FullName);
|
// var dictaryData = dictaryDataList.ToDictionary(x => x.EnCode, x => x.FullName);
|
||||||
SqlSugarScope sugarClient = null!;
|
// SqlSugarScope sugarClient = null!;
|
||||||
var momDbLink = await _repository.AsSugarClient().Queryable<DbLinkEntity>().FirstAsync(x => x.FullName == "tnb_mom");
|
// var momDbLink = await _repository.AsSugarClient().Queryable<DbLinkEntity>().FirstAsync(x => x.FullName == "tnb_mom");
|
||||||
if (momDbLink != null)
|
// if (momDbLink != null)
|
||||||
{
|
// {
|
||||||
sugarClient = _dbManager.ChangeDataBase(momDbLink);
|
// sugarClient = _dbManager.ChangeDataBase(momDbLink);
|
||||||
}
|
// }
|
||||||
var list = await sugarClient.Queryable<BasRoute>().ToListAsync();
|
// var list = await sugarClient.Queryable<BasRoute>().ToListAsync();
|
||||||
if (list?.Count > 0)
|
// if (list?.Count > 0)
|
||||||
{
|
// {
|
||||||
var routeGroups = list.GroupBy(g => g.RouteType);
|
// var routeGroups = list.GroupBy(g => g.RouteType);
|
||||||
var dic1 = routeGroups.ToDictionary(x => x.Key, x => Tuple.Create(new RouteLineTreeOutput
|
// var dic1 = routeGroups.ToDictionary(x => x.Key, x => Tuple.Create(new RouteLineTreeOutput
|
||||||
{
|
// {
|
||||||
id = SnowflakeIdHelper.NextId(),
|
// id = SnowflakeIdHelper.NextId(),
|
||||||
RouteType = x.Key,
|
// RouteType = x.Key,
|
||||||
Name = dictaryData.ContainsKey(x.Key) ? dictaryData[x.Key] : string.Empty
|
// Name = dictaryData.ContainsKey(x.Key) ? dictaryData[x.Key] : string.Empty
|
||||||
}, x.GroupBy(g => new { g.RouteName, g.RouteCode })));
|
// }, x.GroupBy(g => new { g.RouteName, g.RouteCode })));
|
||||||
result.AddRange(dic1.Values.Select(t => t.Item1));
|
// result.AddRange(dic1.Values.Select(t => t.Item1));
|
||||||
foreach (var routeGroup in routeGroups)
|
// foreach (var routeGroup in routeGroups)
|
||||||
{
|
// {
|
||||||
if (dic1.ContainsKey(routeGroup.Key))
|
// if (dic1.ContainsKey(routeGroup.Key))
|
||||||
{
|
// {
|
||||||
var nodes = new List<RouteLineTreeOutput>();
|
// var nodes = new List<RouteLineTreeOutput>();
|
||||||
foreach (var item in dic1[routeGroup.Key].Item2)
|
// foreach (var item in dic1[routeGroup.Key].Item2)
|
||||||
{
|
// {
|
||||||
var node = new RouteLineTreeOutput();
|
// var node = new RouteLineTreeOutput();
|
||||||
node.id = SnowflakeIdHelper.NextId();
|
// node.id = SnowflakeIdHelper.NextId();
|
||||||
node.parentId = dic1[routeGroup.Key].Item1.id;
|
// node.parentId = dic1[routeGroup.Key].Item1.id;
|
||||||
node.Name = $"{item.Key.RouteName}|{item.Key.RouteCode}";
|
// node.Name = $"{item.Key.RouteName}|{item.Key.RouteCode}";
|
||||||
node.RouteName = item.Key.RouteName;
|
// node.RouteName = item.Key.RouteName;
|
||||||
node.RouteCode = item.Key.RouteCode;
|
// node.RouteCode = item.Key.RouteCode;
|
||||||
nodes.Add(node);
|
// nodes.Add(node);
|
||||||
}
|
// }
|
||||||
result.AddRange(nodes);
|
// result.AddRange(nodes);
|
||||||
var dic2 = nodes.ToDictionary(x => x.Name, x => x.id);
|
// var dic2 = nodes.ToDictionary(x => x.Name, x => x.id);
|
||||||
foreach (var item in dic1[routeGroup.Key].Item2)
|
// foreach (var item in dic1[routeGroup.Key].Item2)
|
||||||
{
|
// {
|
||||||
if (dic2.ContainsKey($"{item.Key.RouteName}|{item.Key.RouteCode}"))
|
// if (dic2.ContainsKey($"{item.Key.RouteName}|{item.Key.RouteCode}"))
|
||||||
{
|
// {
|
||||||
result.AddRange(item.Select(x => new RouteLineTreeOutput
|
// result.AddRange(item.Select(x => new RouteLineTreeOutput
|
||||||
{
|
// {
|
||||||
id = SnowflakeIdHelper.NextId(),
|
// id = SnowflakeIdHelper.NextId(),
|
||||||
parentId = dic2[$"{item.Key.RouteName}|{item.Key.RouteCode}"],
|
// parentId = dic2[$"{item.Key.RouteName}|{item.Key.RouteCode}"],
|
||||||
Name = x.Version,
|
// Name = x.Version,
|
||||||
Version = x.Version,
|
// Version = x.Version,
|
||||||
}));
|
// }));
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
return new { list = result.ToTree() };
|
// return new { list = result.ToTree() };
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
Reference in New Issue
Block a user