From 2fc0dfc0bd47398f29a99e361fb2d12addfe9c2e Mon Sep 17 00:00:00 2001
From: zhoukeda <1315948824@qq.com>
Date: Tue, 6 Jun 2023 17:14:58 +0800
Subject: [PATCH] =?UTF-8?q?=E5=B7=A5=E8=89=BA=E6=A0=87=E5=87=86=E6=8E=A5?=
=?UTF-8?q?=E5=8F=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Dto/ProcessChildDataInput.cs | 13 ++
.../Dto/ProcessParamTypeChildrenOutput.cs | 18 +++
.../Entity/PerProcessStandardsD.cs | 42 ++++++
.../IPerProcessParamTypeService.cs | 28 ++++
.../Tnb.PerMgr/PerProcessParamTypeService.cs | 131 ++++++++++++++++++
PerMgr/Tnb.PerMgr/Tnb.PerMgr.csproj | 1 +
6 files changed, 233 insertions(+)
create mode 100644 PerMgr/Tnb.PerMgr.Entities/Dto/ProcessChildDataInput.cs
create mode 100644 PerMgr/Tnb.PerMgr.Entities/Dto/ProcessParamTypeChildrenOutput.cs
create mode 100644 PerMgr/Tnb.PerMgr.Entities/Entity/PerProcessStandardsD.cs
create mode 100644 PerMgr/Tnb.PerMgr.Interfaces/IPerProcessParamTypeService.cs
create mode 100644 PerMgr/Tnb.PerMgr/PerProcessParamTypeService.cs
diff --git a/PerMgr/Tnb.PerMgr.Entities/Dto/ProcessChildDataInput.cs b/PerMgr/Tnb.PerMgr.Entities/Dto/ProcessChildDataInput.cs
new file mode 100644
index 00000000..1e8b577e
--- /dev/null
+++ b/PerMgr/Tnb.PerMgr.Entities/Dto/ProcessChildDataInput.cs
@@ -0,0 +1,13 @@
+namespace Tnb.PerMgr.Entities.Dto
+{
+ public class ProcessChildDataInput
+ {
+
+ public string process_standards_id { get; set; }
+ ///
+ /// 工艺参数id
+ ///
+ public string process_param_id { get; set; }
+ public decimal value { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/PerMgr/Tnb.PerMgr.Entities/Dto/ProcessParamTypeChildrenOutput.cs b/PerMgr/Tnb.PerMgr.Entities/Dto/ProcessParamTypeChildrenOutput.cs
new file mode 100644
index 00000000..1725773c
--- /dev/null
+++ b/PerMgr/Tnb.PerMgr.Entities/Dto/ProcessParamTypeChildrenOutput.cs
@@ -0,0 +1,18 @@
+namespace Tnb.PerMgr.Entities.Dto
+{
+ public class ProcessParamTypeChildrenOutput
+ {
+ ///
+ /// 工艺标准子表id
+ ///
+ public string id { get; set; }
+ ///
+ /// 工艺参数id
+ ///
+ public string process_param_id { get; set; }
+ public string name { get; set; }
+ public decimal? value { get; set; }
+ public decimal upper_value { get; set; }
+ public decimal lower_value { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/PerMgr/Tnb.PerMgr.Entities/Entity/PerProcessStandardsD.cs b/PerMgr/Tnb.PerMgr.Entities/Entity/PerProcessStandardsD.cs
new file mode 100644
index 00000000..bbf44f4a
--- /dev/null
+++ b/PerMgr/Tnb.PerMgr.Entities/Entity/PerProcessStandardsD.cs
@@ -0,0 +1,42 @@
+using JNPF.Common.Contracts;
+using JNPF.Common.Security;
+using SqlSugar;
+
+namespace Tnb.PerMgr.Entities;
+
+///
+/// 工艺标准子表
+///
+[SugarTable("per_process_standards_d")]
+public partial class PerProcessStandardsD : BaseEntity
+{
+ public PerProcessStandardsD()
+ {
+ id = SnowflakeIdHelper.NextId();
+ }
+ ///
+ /// 工艺标准主表id
+ ///
+ public string process_standards_id { get; set; } = string.Empty;
+
+ ///
+ /// 工艺参数id
+ ///
+ public string process_param_id { get; set; } = string.Empty;
+
+ ///
+ /// 设定值
+ ///
+ public decimal value { get; set; }
+
+ ///
+ /// 上限
+ ///
+ public decimal? upper_value { get; set; }
+
+ ///
+ /// 下限
+ ///
+ public decimal? lower_value { get; set; }
+
+}
\ No newline at end of file
diff --git a/PerMgr/Tnb.PerMgr.Interfaces/IPerProcessParamTypeService.cs b/PerMgr/Tnb.PerMgr.Interfaces/IPerProcessParamTypeService.cs
new file mode 100644
index 00000000..1b334363
--- /dev/null
+++ b/PerMgr/Tnb.PerMgr.Interfaces/IPerProcessParamTypeService.cs
@@ -0,0 +1,28 @@
+using Tnb.PerMgr.Entities.Dto;
+namespace Tnb.PerMgr.Interfaces
+{
+ public interface IPerProcessParamTypeService
+ {
+ ///
+ /// 根据设备id获取工艺参数类型和对应工艺参数
+ ///
+ ///
+ ///
+ public Task GetProcessParamType(Dictionary dic);
+
+ ///
+ /// 保存工艺参数子表
+ ///
+ ///
+ ///
+ public Task SaveData(List input);
+
+
+ ///
+ /// 根据id获取修改信息
+ ///
+ ///
+ ///
+ public Task GetProcessStandardsChildrenInfo(Dictionary dic);
+ }
+}
\ No newline at end of file
diff --git a/PerMgr/Tnb.PerMgr/PerProcessParamTypeService.cs b/PerMgr/Tnb.PerMgr/PerProcessParamTypeService.cs
new file mode 100644
index 00000000..efcc1955
--- /dev/null
+++ b/PerMgr/Tnb.PerMgr/PerProcessParamTypeService.cs
@@ -0,0 +1,131 @@
+using JNPF.Common.Core.Manager;
+using JNPF.Common.Enums;
+using JNPF.DependencyInjection;
+using JNPF.DynamicApiController;
+using JNPF.FriendlyException;
+using Microsoft.AspNetCore.Mvc;
+using SqlSugar;
+using Tnb.EquipMgr.Entities;
+using Tnb.PerMgr.Entities;
+using Tnb.PerMgr.Entities.Dto;
+using Tnb.PerMgr.Interfaces;
+
+namespace Tnb.PerMgr
+{
+ ///
+ /// 工艺参数类型
+ ///
+ [ApiDescriptionSettings
+ (Tag = ModuleConsts.Tag, Area = ModuleConsts.Area, Order = 700)]
+ [Route("api/[area]/[controller]/[action]")]
+ public class PerProcessParamTypeService : IPerProcessParamTypeService, IDynamicApiController, ITransient
+ {
+ private readonly ISqlSugarRepository _repository;
+ private readonly IUserManager _userManager;
+
+ public PerProcessParamTypeService(ISqlSugarRepository repository, IUserManager userManager)
+ {
+ _userManager = userManager;
+ _repository = repository;
+ }
+
+ [HttpPost]
+ public async Task GetProcessParamType(Dictionary dic)
+ {
+ string equipId = dic["equip_id"];
+ var db = _repository.AsSugarClient();
+ var equipment = await db.Queryable().Where(x => x.id == equipId).SingleAsync();
+ string equipTypeId = equipment?.equip_type_id;
+
+ //List perProcessParamTypes = await _repository.GetListAsync(x => x.equip_type_id == equipTypeId);
+ var result = await db.Queryable()
+ .Where(x => x.equip_type_id == equipTypeId)
+ .OrderBy(x=>x.ordinal)
+ .Select(x => new
+ {
+ tab_id = x.id,
+ tab_name = x.name,
+ children = SqlFunc.Subqueryable()
+ .LeftJoin((y,z)=>y.tolerance_category_id==z.id)
+ .Where(y=>y.process_param_type_id==x.id)
+ .OrderBy((y,z)=>y.ordinal)
+ .ToList((y,z)=>new ProcessParamTypeChildrenOutput
+ {
+ process_param_id = y.id,
+ name = y.name,
+ upper_value = z.upper_value,
+ lower_value = z.lower_value
+ }),
+ }).ToListAsync();
+
+
+ return result;
+
+ }
+
+ [HttpPost]
+ public async Task SaveData(List input)
+ {
+ var db = _repository.AsSugarClient();
+ DbResult result = await db.Ado.UseTranAsync(async () =>
+ {
+
+ List list = new List();
+ if (input != null && input.Count > 0)
+ {
+ foreach (var item in input)
+ {
+ list.Add(new PerProcessStandardsD()
+ {
+ process_standards_id = item.process_standards_id,
+ process_param_id = item.process_param_id,
+ value = item.value
+ });
+ }
+
+ await db.Insertable(list).ExecuteCommandAsync();
+ }
+
+ });
+ if(!result.IsSuccess) throw Oops.Oh(ErrorCode.COM1008);
+
+ return result.IsSuccess ? "保存成功" : result.ErrorMessage;
+ }
+
+ [HttpPost]
+ public async Task GetProcessStandardsChildrenInfo(Dictionary dic)
+ {
+ string id = dic["id"];
+ var db = _repository.AsSugarClient();
+ var perProcessStandardsH = await db.Queryable().SingleAsync(x => x.id == id);
+ var equipment = await db.Queryable().Where(x => x.id == perProcessStandardsH.equip_id).SingleAsync();
+ string equipTypeId = equipment?.equip_type_id;
+
+ var result = await db.Queryable()
+ .Where(a => a.equip_type_id == equipTypeId)
+ .OrderBy(a=>a.ordinal)
+ .Select(a => new
+ {
+ tab_id = a.id,
+ tab_name = a.name,
+ children = SqlFunc.Subqueryable()
+ .LeftJoin((b,c)=>b.process_param_id==c.id)
+ .LeftJoin((b,c,d)=>c.tolerance_category_id==d.id)
+ .Where((b,c,d)=>c.process_param_type_id==a.id && b.process_standards_id==id)
+ .OrderBy((b,c,d)=>c.ordinal)
+ .ToList((b,c,d)=>new ProcessParamTypeChildrenOutput
+ {
+ id = b.id,
+ process_param_id = c.id,
+ name = c.name,
+ value = b.value,
+ upper_value = d.upper_value,
+ lower_value = d.lower_value
+ }),
+ }).ToListAsync();
+
+
+ return result;
+ }
+ }
+}
\ No newline at end of file
diff --git a/PerMgr/Tnb.PerMgr/Tnb.PerMgr.csproj b/PerMgr/Tnb.PerMgr/Tnb.PerMgr.csproj
index 720e38c1..ddd2d646 100644
--- a/PerMgr/Tnb.PerMgr/Tnb.PerMgr.csproj
+++ b/PerMgr/Tnb.PerMgr/Tnb.PerMgr.csproj
@@ -7,6 +7,7 @@
+