From 21115d3b29348c32cf14b095a4cd47aee9b9b9fc Mon Sep 17 00:00:00 2001 From: qianjiawei <1184704771@qq.com> Date: Fri, 9 Jun 2023 17:37:42 +0800 Subject: [PATCH] =?UTF-8?q?=E5=93=81=E8=B4=A8=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- QcMgr/Tnb.QcMgr.Entities/Dto/CheckItems.cs | 64 ++++++++- QcMgr/Tnb.QcMgr.Entities/Dto/CheckPlan.cs | 97 +++++++++++--- QcMgr/Tnb.QcMgr.Entities/Dto/Trigger.cs | 12 ++ .../Entity/QcCheckItemsD.cs | 7 +- .../Entity/QcCheckPlanAdd.cs | 38 ++++++ .../Tnb.QcMgr.Entities/Entity/QcCheckPlanD.cs | 93 +++++++++++-- .../Tnb.QcMgr.Entities/Entity/QcCheckPlanH.cs | 14 +- .../Entity/QcCheckPlanMaterial.cs | 58 ++++++++ .../Entity/QcCheckPlanProcess.cs | 59 ++++++++ .../Entity/QcCheckPlanWork.cs | 58 ++++++++ .../Entity/QcTriggerEvent.cs | 64 +++++++++ .../Entity/QcTriggerPlan.cs | 73 ++++++++++ .../IQcCheckItemService.cs | 7 + .../IQcCheckPlanService.cs | 10 +- QcMgr/Tnb.QcMgr/QcCheckItemService.cs | 107 +++++++++++++-- QcMgr/Tnb.QcMgr/QcCheckPlanService.cs | 126 +++++++++++++++--- 16 files changed, 816 insertions(+), 71 deletions(-) create mode 100644 QcMgr/Tnb.QcMgr.Entities/Dto/Trigger.cs create mode 100644 QcMgr/Tnb.QcMgr.Entities/Entity/QcCheckPlanAdd.cs create mode 100644 QcMgr/Tnb.QcMgr.Entities/Entity/QcCheckPlanMaterial.cs create mode 100644 QcMgr/Tnb.QcMgr.Entities/Entity/QcCheckPlanProcess.cs create mode 100644 QcMgr/Tnb.QcMgr.Entities/Entity/QcCheckPlanWork.cs create mode 100644 QcMgr/Tnb.QcMgr.Entities/Entity/QcTriggerEvent.cs create mode 100644 QcMgr/Tnb.QcMgr.Entities/Entity/QcTriggerPlan.cs diff --git a/QcMgr/Tnb.QcMgr.Entities/Dto/CheckItems.cs b/QcMgr/Tnb.QcMgr.Entities/Dto/CheckItems.cs index a2a55c08..93ecd6e9 100644 --- a/QcMgr/Tnb.QcMgr.Entities/Dto/CheckItems.cs +++ b/QcMgr/Tnb.QcMgr.Entities/Dto/CheckItems.cs @@ -8,18 +8,23 @@ namespace Tnb.QcMgr.Entities.Dto { public class CheckItemsInput { + public string id { get; set; } public string name { get; set; } public string status { get; set; } - public List checktypoes { get; set; } + public List checktypes { get; set; } } - public class CheckType + public class CheckTypeInput { public string id { get; set; } - public List items { get; set; } + public List items { get; set; } } - public class Item + public class ItemInput { public string itemid { get; set; } + public string code { get; set; } + public string name { get; set; } + public string itemdid { get; set; } + public string extype { get; set; } public string excontent { get; set; } public string check { get; set; } @@ -28,5 +33,56 @@ namespace Tnb.QcMgr.Entities.Dto public string remark { get; set; } public string attachment { get; set; } public string isexec { get; set; } + public string customer { get; set; } + } + public class CheckItemsOut + { + public string id { get; set; } + public string name { get; set; } + public string status { get; set; } + public List checktypes { get; set; } + } + public class CheckTypeOut + { + public string checktypeid { get; set; } + public string checktypename { get; set; } + public List items { get; set; } + } + public class ItemOut + { + public string itemid { get; set; } + public string code { get; set; } + public string name { get; set; } + public string itemdid { get; set; } + public Show setShow { get; set; } + public Data setData { get; set; } + + } + public class Show { + public bool extype { get; set; } + public bool excontent { get; set; } + public bool check { get; set; } + public bool errorcause { get; set; } + public bool errorlevel { get; set; } + public bool remark { get; set; } + public bool attachment { get; set; } + public bool customer { get; set; } + public bool isexec { get; set; } + } + public class Data { + public string extype { get; set; } + public string excontent { get; set; } + public string check { get; set; } + public string[] errorcause { get; set; } + public string errorlevel { get; set; } + public string remark { get; set; } + public string attachment { get; set; } + public string customer { get; set; } + public Isexec isexec { get; set; } + } + public class Isexec + { + public bool remark { get; set; } + public bool attachment { get; set; } } } diff --git a/QcMgr/Tnb.QcMgr.Entities/Dto/CheckPlan.cs b/QcMgr/Tnb.QcMgr.Entities/Dto/CheckPlan.cs index 38feac7b..684bada0 100644 --- a/QcMgr/Tnb.QcMgr.Entities/Dto/CheckPlan.cs +++ b/QcMgr/Tnb.QcMgr.Entities/Dto/CheckPlan.cs @@ -3,31 +3,90 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using Tnb.QcMgr.Entities.Dto; namespace Tnb.QcMgr.Entities { public class CheckPlanInput { - public string name { get; set; } - - public string status { get; set; } - - public string checktype { get; set; } - - public string numtype { get; set; } - - public string pagetype { get; set; } - - public string writerule { get; set; } - - public string remind { get; set; } - - public string attachment { get; set; } - - public string isaddmul { get; set; } - + public string mainid { get; set; } + public string addid { get; set; } public string triggertype { get; set; } - public string content { get; set; } + public List checktypes { get; set; } + } + public class CheckPlanTypeInput + { + public string id { get; set; } + public List items { get; set; } + } + public class PlanItemInput + { + public string itemid { get; set; } + public string extype { get; set; } + public string excontent { get; set; } + public string check { get; set; } + public string errorcause { get; set; } + public string errorlevel { get; set; } + public string remark { get; set; } + public string attachment { get; set; } + public string isexec { get; set; } + public string customer { get; set; } + } + + public class CheckPlansOut + { + public string id { get; set; } + public bool hasadd { get; set; } + public bool hasitem{ get; set; } + public string addid { get; set; } + public string triggertype { get; set; } + public string content { get; set; } + public List checktypes { get; set; } + } + public class CheckPlanTypeOut + { + public string checktypeid { get; set; } + public string checktypename { get; set; } + public List items { get; set; } + } + public class PlanItemOut + { + public string itemid { get; set; } + public string code { get; set; } + public string name { get; set; } + public string itemdid { get; set; } + public PlanItemShow setShow { get; set; } + public PlanItemData setData { get; set; } + + } + public class PlanItemShow + { + public bool extype { get; set; } + public bool excontent { get; set; } + public bool check { get; set; } + public bool errorcause { get; set; } + public bool errorlevel { get; set; } + public bool remark { get; set; } + public bool attachment { get; set; } + public bool customer { get; set; } + public bool isexec { get; set; } + } + public class PlanItemData + { + public string extype { get; set; } + public string excontent { get; set; } + public string check { get; set; } + public string[] errorcause { get; set; } + public string errorlevel { get; set; } + public string remark { get; set; } + public string attachment { get; set; } + public string customer { get; set; } + public IsexecP isexec { get; set; } + } + public class IsexecP + { + public bool remark { get; set; } + public bool attachment { get; set; } } } diff --git a/QcMgr/Tnb.QcMgr.Entities/Dto/Trigger.cs b/QcMgr/Tnb.QcMgr.Entities/Dto/Trigger.cs new file mode 100644 index 00000000..c8f54684 --- /dev/null +++ b/QcMgr/Tnb.QcMgr.Entities/Dto/Trigger.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tnb.QcMgr.Entities.Dto +{ + public class Trigger + { + } +} diff --git a/QcMgr/Tnb.QcMgr.Entities/Entity/QcCheckItemsD.cs b/QcMgr/Tnb.QcMgr.Entities/Entity/QcCheckItemsD.cs index 9e122b8e..f90e3bcb 100644 --- a/QcMgr/Tnb.QcMgr.Entities/Entity/QcCheckItemsD.cs +++ b/QcMgr/Tnb.QcMgr.Entities/Entity/QcCheckItemsD.cs @@ -60,7 +60,12 @@ namespace Tnb.QcMgr.Entities /// 执行时操作 /// public string? isexec { get; set; } - + + /// + /// 客户 + /// + public string? custom { get; set; } + /// /// 创建用户 /// diff --git a/QcMgr/Tnb.QcMgr.Entities/Entity/QcCheckPlanAdd.cs b/QcMgr/Tnb.QcMgr.Entities/Entity/QcCheckPlanAdd.cs new file mode 100644 index 00000000..57df112f --- /dev/null +++ b/QcMgr/Tnb.QcMgr.Entities/Entity/QcCheckPlanAdd.cs @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using JNPF.Common.Contracts; +using JNPF.Common.Security; +using SqlSugar; + +namespace Tnb.QcMgr.Entities +{ + /// + /// 质检方案附加信息 + /// + [SugarTable("qc_check_plan_add")] + public partial class QcCheckPlanAdd : BaseEntity + { + public QcCheckPlanAdd() + { + id = SnowflakeIdHelper.NextId(); + } + + /// + /// 触发类型 + /// + public string? triggertype { get; set; } + + /// + /// 触发内容 + /// + public string? content { get; set; } + + /// + /// 主表编号 + /// + public string? mainid { get; set; } + } +} diff --git a/QcMgr/Tnb.QcMgr.Entities/Entity/QcCheckPlanD.cs b/QcMgr/Tnb.QcMgr.Entities/Entity/QcCheckPlanD.cs index 9fede172..f21854a9 100644 --- a/QcMgr/Tnb.QcMgr.Entities/Entity/QcCheckPlanD.cs +++ b/QcMgr/Tnb.QcMgr.Entities/Entity/QcCheckPlanD.cs @@ -7,10 +7,11 @@ using JNPF.Common.Contracts; using JNPF.Common.Security; using SqlSugar; -namespace Tnb.QcMgr.Entities +namespace Tnb.QcMgr.Entities.Entity { + /// - /// 质检方案附加信息 + /// 质检方案子表 /// [SugarTable("qc_check_plan_d")] public partial class QcCheckPlanD : BaseEntity @@ -21,18 +22,84 @@ namespace Tnb.QcMgr.Entities } /// - /// 触发类型 - /// - public string? triggertype { get; set; } - - /// - /// 触发内容 - /// - public string? content { get; set; } - - /// - /// 主表编号 + /// 质检方案主表编号 /// public string? mainid { get; set; } + + /// + /// 执行项格式 + /// + public string? extype { get; set; } + + /// + /// 执行项内容 + /// + public string? excontent { get; set; } + + /// + /// 抽检类型 + /// + public string? check { get; set; } + + /// + /// 不良原因 + /// + public string? errorcause { get; set; } + + /// + /// 不良等级 + /// + public string? errorlevel { get; set; } + + /// + /// 备注 + /// + public string? remark { get; set; } + + /// + /// 附件 + /// + public string? attachment { get; set; } + + /// + /// 执行时操作 + /// + public string? isexec { get; set; } + + /// + /// 客户 + /// + public string? custom { get; set; } + + /// + /// 质检项分类编号 + /// + public string? typeid { get; set; } + + /// + /// 质检项编号 + /// + public string? itemid { get; set; } + + /// + /// 创建用户 + /// + public string? create_id { get; set; } + + /// + /// 创建时间 + /// + public DateTime? create_time { get; set; } + + /// + /// 修改用户 + /// + public string? modify_id { get; set; } + + /// + /// 修改时间 + /// + public DateTime? modify_time { get; set; } + } } diff --git a/QcMgr/Tnb.QcMgr.Entities/Entity/QcCheckPlanH.cs b/QcMgr/Tnb.QcMgr.Entities/Entity/QcCheckPlanH.cs index c1c8a1d1..f3ea5cd6 100644 --- a/QcMgr/Tnb.QcMgr.Entities/Entity/QcCheckPlanH.cs +++ b/QcMgr/Tnb.QcMgr.Entities/Entity/QcCheckPlanH.cs @@ -9,8 +9,9 @@ using SqlSugar; namespace Tnb.QcMgr.Entities { + /// - /// 质检方案主表 + /// 质检方案 /// [SugarTable("qc_check_plan_h")] public partial class QcCheckPlanH : BaseEntity @@ -19,6 +20,12 @@ namespace Tnb.QcMgr.Entities { id = SnowflakeIdHelper.NextId(); } + + /// + /// 编号 + /// + public string? code { get; set; } + /// /// 名称 /// @@ -83,5 +90,8 @@ namespace Tnb.QcMgr.Entities /// 修改时间 /// public DateTime? modify_time { get; set; } + + + } -} +} \ No newline at end of file diff --git a/QcMgr/Tnb.QcMgr.Entities/Entity/QcCheckPlanMaterial.cs b/QcMgr/Tnb.QcMgr.Entities/Entity/QcCheckPlanMaterial.cs new file mode 100644 index 00000000..a93cf8ed --- /dev/null +++ b/QcMgr/Tnb.QcMgr.Entities/Entity/QcCheckPlanMaterial.cs @@ -0,0 +1,58 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using JNPF.Common.Contracts; +using JNPF.Common.Security; +using SqlSugar; + +namespace Tnb.QcMgr.Entities +{ + /// + /// 质检方案物料关联表 + /// + [SugarTable("qc_check_plan_material")] + public partial class QcCheckPlanMaterial : BaseEntity + { + public QcCheckPlanMaterial() + { + id = SnowflakeIdHelper.NextId(); + } + /// + /// 质检方案编号 + /// + public string? planid { get; set; } + + /// + /// 物料方案编号 + /// + public string? materialid { get; set; } + + /// + /// 创建用户 + /// + public string? create_id { get; set; } + + /// + /// 创建时间 + /// + public DateTime? create_time { get; set; } + + /// + /// 修改用户 + /// + public string? modify_id { get; set; } + + /// + /// 修改时间 + /// + public DateTime? modify_time { get; set; } + + /// + /// 扩展 + /// + public string? extras { get; set; } + + } +} diff --git a/QcMgr/Tnb.QcMgr.Entities/Entity/QcCheckPlanProcess.cs b/QcMgr/Tnb.QcMgr.Entities/Entity/QcCheckPlanProcess.cs new file mode 100644 index 00000000..7712d68f --- /dev/null +++ b/QcMgr/Tnb.QcMgr.Entities/Entity/QcCheckPlanProcess.cs @@ -0,0 +1,59 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using JNPF.Common.Contracts; +using JNPF.Common.Security; +using SqlSugar; + +namespace Tnb.QcMgr.Entities +{ + /// + /// 质检方案工序关联表 + /// + [SugarTable("qc_check_plan_process")] + public partial class QcCheckPlanProcess : BaseEntity + { + public QcCheckPlanProcess() + { + id = SnowflakeIdHelper.NextId(); + } + /// + /// 方案编号 + /// + public string? planid { get; set; } + + /// + /// 工序编号 + /// + public string? processid { get; set; } + + /// + /// 创建用户 + /// + public string? create_id { get; set; } + + /// + /// 创建时间 + /// + public DateTime? create_time { get; set; } + + /// + /// 修改用户 + /// + public string? modify_id { get; set; } + + /// + /// 修改时间 + /// + public DateTime? modify_time { get; set; } + + /// + /// 扩展 + /// + public string? extras { get; set; } + + } + +} diff --git a/QcMgr/Tnb.QcMgr.Entities/Entity/QcCheckPlanWork.cs b/QcMgr/Tnb.QcMgr.Entities/Entity/QcCheckPlanWork.cs new file mode 100644 index 00000000..4493fa0f --- /dev/null +++ b/QcMgr/Tnb.QcMgr.Entities/Entity/QcCheckPlanWork.cs @@ -0,0 +1,58 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using JNPF.Common.Contracts; +using JNPF.Common.Security; +using SqlSugar; + +namespace Tnb.QcMgr.Entities.Entity +{ + /// + /// 质检方案工位关联表 + /// + [SugarTable("qc_check_plan_work")] + public partial class QcCheckPlanWork : BaseEntity + { + public QcCheckPlanWork() + { + id = SnowflakeIdHelper.NextId(); + } + /// + /// 质检方案编号 + /// + public string? planid { get; set; } + + /// + /// 工位编号 + /// + public string? workid { get; set; } + + /// + /// 创建用户 + /// + public string? create_id { get; set; } + + /// + /// 创建时间 + /// + public DateTime? create_time { get; set; } + + /// + /// 修改用户 + /// + public string? modify_id { get; set; } + + /// + /// 修改时间 + /// + public DateTime? modify_time { get; set; } + + /// + /// 扩展 + /// + public string? extras { get; set; } + + } +} \ No newline at end of file diff --git a/QcMgr/Tnb.QcMgr.Entities/Entity/QcTriggerEvent.cs b/QcMgr/Tnb.QcMgr.Entities/Entity/QcTriggerEvent.cs new file mode 100644 index 00000000..4f71db19 --- /dev/null +++ b/QcMgr/Tnb.QcMgr.Entities/Entity/QcTriggerEvent.cs @@ -0,0 +1,64 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using JNPF.Common.Contracts; +using JNPF.Common.Security; +using SqlSugar; + +namespace Tnb.QcMgr.Entities +{ + /// + /// 触发事件 + /// + [SugarTable("qc_trigger_event")] + public partial class QcTriggerEvent : BaseEntity + { + public QcTriggerEvent() + { + id = SnowflakeIdHelper.NextId(); + } + /// + /// 名称 + /// + public string? name { get; set; } + + /// + /// 编号 + /// + public string? code { get; set; } + + /// + /// 分类 + /// + public string? type { get; set; } + + /// + /// 创建用户 + /// + public string? create_id { get; set; } + + /// + /// 创建时间 + /// + public DateTime? create_time { get; set; } + + /// + /// 修改用户 + /// + public string? modify_id { get; set; } + + /// + /// 修改时间 + /// + public DateTime? modify_time { get; set; } + + /// + /// 扩展 + /// + public string? extras { get; set; } + + } + +} diff --git a/QcMgr/Tnb.QcMgr.Entities/Entity/QcTriggerPlan.cs b/QcMgr/Tnb.QcMgr.Entities/Entity/QcTriggerPlan.cs new file mode 100644 index 00000000..5eadc716 --- /dev/null +++ b/QcMgr/Tnb.QcMgr.Entities/Entity/QcTriggerPlan.cs @@ -0,0 +1,73 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using JNPF.Common.Contracts; +using JNPF.Common.Security; +using SqlSugar; + +namespace Tnb.QcMgr.Entities +{ + /// + /// 触发计划 + /// + [SugarTable("qc_trigger_plan")] + public partial class QcTriggerPlan : BaseEntity + { + public QcTriggerPlan() + { + id = SnowflakeIdHelper.NextId(); + } + /// + /// 名称 + /// + public string? name { get; set; } + + /// + /// 编号 + /// + public string? code { get; set; } + + /// + /// 触发类型 + /// + public string type { get; set; } = string.Empty; + + /// + /// 触发周期 + /// + public string? cycle { get; set; } + + /// + /// 触发事件 + /// + public string? trievent { get; set; } + + /// + /// 创建用户 + /// + public string? create_id { get; set; } + + /// + /// 创建时间 + /// + public DateTime? create_time { get; set; } + + /// + /// 修改用户 + /// + public string? modify_id { get; set; } + + /// + /// 修改时间 + /// + public DateTime? modify_time { get; set; } + + /// + /// 扩展 + /// + public string? extras { get; set; } + } + +} diff --git a/QcMgr/Tnb.QcMgr.Interfaces/IQcCheckItemService.cs b/QcMgr/Tnb.QcMgr.Interfaces/IQcCheckItemService.cs index 0744b461..651f47e5 100644 --- a/QcMgr/Tnb.QcMgr.Interfaces/IQcCheckItemService.cs +++ b/QcMgr/Tnb.QcMgr.Interfaces/IQcCheckItemService.cs @@ -22,5 +22,12 @@ namespace Tnb.QcMgr.Interfaces /// /// public Task SaveData(CheckItemsInput CheckItemsInput); + + /// + /// 获取质检项清单 + /// + /// + /// + public Task GetCheckItems(CheckItemsInput CheckItemsInput); } } diff --git a/QcMgr/Tnb.QcMgr.Interfaces/IQcCheckPlanService.cs b/QcMgr/Tnb.QcMgr.Interfaces/IQcCheckPlanService.cs index d30b3b0b..bff66934 100644 --- a/QcMgr/Tnb.QcMgr.Interfaces/IQcCheckPlanService.cs +++ b/QcMgr/Tnb.QcMgr.Interfaces/IQcCheckPlanService.cs @@ -4,16 +4,24 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using Tnb.QcMgr.Entities; +using Tnb.QcMgr.Entities.Dto; namespace Tnb.QcMgr.Interfaces { public interface IQcCheckPlanService { /// - /// 保存质检方案 + /// 保存质检方案质检项和附加信息 /// /// /// public Task SaveData(CheckPlanInput CheckPlanInput); + + /// + /// 获取方案质检项附加信息 + /// + /// + /// + public Task GetCheckItems(string id); } } diff --git a/QcMgr/Tnb.QcMgr/QcCheckItemService.cs b/QcMgr/Tnb.QcMgr/QcCheckItemService.cs index 92342c9b..7fd75691 100644 --- a/QcMgr/Tnb.QcMgr/QcCheckItemService.cs +++ b/QcMgr/Tnb.QcMgr/QcCheckItemService.cs @@ -11,6 +11,7 @@ using JNPF.Common.Enums; using JNPF.DependencyInjection; using JNPF.DynamicApiController; using JNPF.FriendlyException; +using JNPF.JsonSerialization; using JNPF.VisualDev; using JNPF.VisualDev.Interfaces; using Microsoft.AspNetCore.Identity; @@ -34,7 +35,7 @@ namespace Tnb.QcMgr [OverideVisualDev(ModuleId)] public class QcCheckItemService : IOverideVisualDevService, IQcCheckItemService, IDynamicApiController, ITransient { - private const string ModuleId = "26500755139349"; + private const string ModuleId = "26477150883109"; private readonly ISqlSugarRepository _repository; private readonly IUserManager _userManager; public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc(); @@ -50,7 +51,7 @@ namespace Tnb.QcMgr var db = _repository.AsSugarClient(); var QcCheckItemsH=await db.Queryable< QcCheckItemsH >().Where(p=>p.id==id).FirstAsync(); var QcCheckItemsRs = await db.Queryable().Where(p => p.itemshid == id).ToListAsync() ; - var QcCheckItemsDs=await db.Queryable().Where(p=> QcCheckItemsRs.Select(p=>p.id).ToList().Contains( p.id)).ToListAsync() ; + var QcCheckItemsDs = await db.Queryable().Where(p => QcCheckItemsRs.Select(p => p.itemsdid).ToList().Contains(p.id)).ToListAsync(); await db.Ado.BeginTranAsync(); await db.Deleteable(QcCheckItemsH).ExecuteCommandAsync(); await db.Deleteable(QcCheckItemsRs).ExecuteCommandAsync(); @@ -83,21 +84,98 @@ namespace Tnb.QcMgr if (CheckItemOut.items == null) { CheckItemOut.items = new List(); - CheckItemOut.items.Add(new CheckItem { itemid = data.id, name = data.name, code = data.code }); + CheckItemOut.items.Add(new CheckItem { itemid = data.id, name = data.name!, code = data.code! }); } else - CheckItemOut.items.Add(new CheckItem { itemid = data.id, name = data.name, code = data.code }); + CheckItemOut.items.Add(new CheckItem { itemid = data.id, name = data.name!, code = data.code! }); } else { - CheckItemOuts.Add(new CheckItemOut { checktypeid = data.type, checktypename = data.typename, items = new List() }); + CheckItemOuts.Add(new CheckItemOut { checktypeid = data.type!, checktypename = data.typename!, items = new List() }); var CheckItemOut = CheckItemOuts.Where(p => p.checktypeid == data.type).First(); - CheckItemOut.items.Add(new CheckItem() { itemid = data.id, name = data.name, code = data.code }); + CheckItemOut.items.Add(new CheckItem() { itemid = data.id, name = data.name!, code = data.code! }); } } return CheckItemOuts; } + /// + /// 获取质检项清单 + /// + /// + /// + [HttpPost] + public async Task GetCheckItems(CheckItemsInput CheckItemsInput) + { + var db = _repository.AsSugarClient(); + var QcCheckItems = await db.Queryable().ToListAsync(); + var QcCheckTypes = await db.Queryable().ToListAsync(); + var QcCheckItemsH = await db.Queryable().Where(p => p.id == CheckItemsInput.id).FirstAsync(); + List QcCheckItemsRs = null; + List QcCheckItemsDs = null; + if (QcCheckItemsH != null) + { + QcCheckItemsRs = await db.Queryable().Where(p => p.itemshid == QcCheckItemsH.id).ToListAsync(); + if (QcCheckItemsRs != null) + QcCheckItemsDs = await db.Queryable().Where(p => QcCheckItemsRs.Select(p => p.itemsdid).ToList().Contains(p.id)).ToListAsync(); + } + else + throw Oops.Oh(ErrorCode.COM1005); + var CheckItemsOut = new CheckItemsOut(); + CheckItemsOut.id = QcCheckItemsH.id; + CheckItemsOut.name = QcCheckItemsH.name!; + CheckItemsOut.status = QcCheckItemsH.status!; + CheckItemsOut.checktypes = new List(); + if (QcCheckItemsRs != null && QcCheckItemsDs != null) + { + foreach (var QcCheckItemsR in QcCheckItemsRs) + { + if (CheckItemsOut.checktypes.Where(p => p.checktypeid == QcCheckItemsR.typeid).ToList().Count == 0) + { + CheckTypeOut checkType = new CheckTypeOut(); + checkType.checktypeid = QcCheckItemsR.typeid!; + checkType.checktypename = QcCheckTypes.Where(p => p.id == QcCheckItemsR.typeid).First().name!; + checkType.items = new List(); + CheckItemsOut.checktypes.Add(checkType); + } + var item = QcCheckItemsDs.Where(p => p.id == QcCheckItemsR.itemsdid).FirstOrDefault(); + if (item != null) + { + ItemOut Item = new ItemOut(); + Item.itemid = QcCheckItemsR.itemid!; + Item.itemdid = item.id!; + Item.code = QcCheckItems.Where(p => p.id == QcCheckItemsR.itemid).First().code!; + Item.name = QcCheckItems.Where(p => p.id == QcCheckItemsR.itemid).First().name!; + Item.setData = new Data(); + Item.setData.extype = item.extype!; + Item.setData.excontent = item.excontent!; + Item.setData.check = item.check!; + if (!string.IsNullOrEmpty(item.errorcause)) + Item.setData.errorcause = item.errorcause!.Replace("[", "").Replace("]", "").Split(',', StringSplitOptions.RemoveEmptyEntries); + Item.setData.errorlevel = item.errorlevel!; + Item.setData.remark = item.remark!; + Item.setData.attachment = item.attachment!; + Item.setData.customer = item.custom!; + if (!string.IsNullOrEmpty(item.isexec)) + Item.setData.isexec = JSON.Deserialize(item.isexec!); + Item.setShow = new Show(); + Item.setShow.extype = !string.IsNullOrEmpty(Item.setData.extype); + Item.setShow.excontent = !string.IsNullOrEmpty(Item.setData.excontent); + Item.setShow.check = !string.IsNullOrEmpty(Item.setData.check); + Item.setShow.errorcause = Item.setData.errorcause == null ? false : true; + Item.setShow.errorlevel = !string.IsNullOrEmpty(Item.setData.errorlevel); + Item.setShow.remark = !string.IsNullOrEmpty(Item.setData.remark); + Item.setShow.attachment = !string.IsNullOrEmpty(Item.setData.attachment); + Item.setShow.customer = !string.IsNullOrEmpty(Item.setData.customer); + Item.setShow.isexec = Item.setData.isexec == null ? false : true; + CheckItemsOut.checktypes.Where(p => p.checktypeid == QcCheckItemsR.typeid).First().items.Add(Item); + } + } + } + return CheckItemsOut; + } + + /// /// 保存质检项清单 /// @@ -109,7 +187,8 @@ namespace Tnb.QcMgr var db = _repository.AsSugarClient(); try { - + if (!string.IsNullOrEmpty(CheckItemsInput.id)) + await Delete(CheckItemsInput.id); QcCheckItemsH QcCheckItemsH = new QcCheckItemsH(); QcCheckItemsH.name = CheckItemsInput.name; QcCheckItemsH.status = CheckItemsInput.status; @@ -117,8 +196,7 @@ namespace Tnb.QcMgr QcCheckItemsH.create_id = _userManager.UserId; List QcCheckItemsRs = new List(); List QcCheckItemsDs = new List(); - - foreach (var checktype in CheckItemsInput.checktypoes) + foreach (var checktype in CheckItemsInput.checktypes) { foreach (var item in checktype.items) { @@ -127,11 +205,12 @@ namespace Tnb.QcMgr extype = item.extype, excontent = item.excontent, check = item.check, - errorcause = item.errorcause, + errorcause = item.errorcause.Replace("\"","").Trim(), errorlevel = item.errorlevel, remark = item.remark, attachment = item.attachment, - isexec = item.isexec + isexec = item.isexec, + custom=item.customer }; QcCheckItemsDs.Add(QcCheckItemsD); var QcCheckItemsR = new QcCheckItemsR() @@ -145,6 +224,12 @@ namespace Tnb.QcMgr QcCheckItemsRs.Add(QcCheckItemsR); } } + QcCheckItemsDs.ForEach(p => + { + p.create_id = _userManager.UserId; + p.create_time = DateTime.Now; + + }); await db.Ado.BeginTranAsync(); await db.Insertable(QcCheckItemsH).ExecuteCommandAsync(); await db.Insertable(QcCheckItemsRs).ExecuteCommandAsync(); diff --git a/QcMgr/Tnb.QcMgr/QcCheckPlanService.cs b/QcMgr/Tnb.QcMgr/QcCheckPlanService.cs index fafd9639..e5fe01aa 100644 --- a/QcMgr/Tnb.QcMgr/QcCheckPlanService.cs +++ b/QcMgr/Tnb.QcMgr/QcCheckPlanService.cs @@ -10,11 +10,13 @@ using JNPF.Common.Enums; using JNPF.DependencyInjection; using JNPF.DynamicApiController; using JNPF.FriendlyException; +using JNPF.JsonSerialization; using JNPF.VisualDev; using Microsoft.AspNetCore.Mvc; using SqlSugar; using Tnb.QcMgr.Entities; using Tnb.QcMgr.Entities.Dto; +using Tnb.QcMgr.Entities.Entity; using Tnb.QcMgr.Interfaces; namespace Tnb.QcMgr @@ -33,38 +35,122 @@ namespace Tnb.QcMgr { _repository = repository; _userManager = userManager; - } /// - /// 保存质检方案 + /// 获取方案质检项附加信息 /// /// /// + [HttpPost] + public async Task GetCheckItems(string id) + { + var db = _repository.AsSugarClient(); + var QcCheckItems = await db.Queryable().ToListAsync(); + var QcCheckTypes = await db.Queryable().ToListAsync(); + var QcCheckPlanAdd = await db.Queryable().Where(p => p.mainid == id).FirstAsync(); + var QcCheckPlanDs = await db.Queryable().Where(p => p.mainid == id).ToListAsync(); + var CheckPlansOut = new CheckPlansOut(); + CheckPlansOut.id= id; + CheckPlansOut.hasadd = false; + CheckPlansOut.hasitem = false; + if (QcCheckPlanAdd != null) + { + CheckPlansOut.hasadd = true; + CheckPlansOut.addid = QcCheckPlanAdd.id; + CheckPlansOut.triggertype = QcCheckPlanAdd.triggertype!; + CheckPlansOut.content = QcCheckPlanAdd.content!; + } + if (QcCheckPlanDs != null&& QcCheckPlanDs.Count>0) + { + CheckPlansOut.hasitem = true; + CheckPlansOut.checktypes = new List(); + foreach (var QcCheckPlanD in QcCheckPlanDs) + { + if (CheckPlansOut.checktypes.Where(p => p.checktypeid == QcCheckPlanD.typeid).ToList().Count == 0) + { + CheckPlanTypeOut checkType = new CheckPlanTypeOut(); + checkType.checktypeid = QcCheckPlanD.typeid!; + checkType.checktypename = QcCheckTypes.Where(p => p.id == QcCheckPlanD.typeid).First().name!; + checkType.items = new List(); + CheckPlansOut.checktypes.Add(checkType); + } + PlanItemOut Item = new PlanItemOut(); + Item.itemid = QcCheckPlanD.itemid!; + Item.itemdid = QcCheckPlanD.id!; + Item.code = QcCheckItems.Where(p => p.id == QcCheckPlanD.itemid).First().code!; + Item.name = QcCheckItems.Where(p => p.id == QcCheckPlanD.itemid).First().name!; + Item.setData = new PlanItemData(); + Item.setData.extype = QcCheckPlanD.extype!; + Item.setData.excontent = QcCheckPlanD.excontent!; + Item.setData.check = QcCheckPlanD.check!; + if (!string.IsNullOrEmpty(QcCheckPlanD.errorcause)) + Item.setData.errorcause = QcCheckPlanD.errorcause!.Replace("[", "").Replace("]", "").Split(',', StringSplitOptions.RemoveEmptyEntries); + Item.setData.errorlevel = QcCheckPlanD.errorlevel!; + Item.setData.remark = QcCheckPlanD.remark!; + Item.setData.attachment = QcCheckPlanD.attachment!; + Item.setData.customer = QcCheckPlanD.custom!; + if (!string.IsNullOrEmpty(QcCheckPlanD.isexec)) + Item.setData.isexec = JSON.Deserialize(QcCheckPlanD.isexec!); + Item.setShow = new PlanItemShow(); + Item.setShow.extype = !string.IsNullOrEmpty(Item.setData.extype); + Item.setShow.excontent = !string.IsNullOrEmpty(Item.setData.excontent); + Item.setShow.check = !string.IsNullOrEmpty(Item.setData.check); + Item.setShow.errorcause = Item.setData.errorcause == null ? false : true; + Item.setShow.errorlevel = !string.IsNullOrEmpty(Item.setData.errorlevel); + Item.setShow.remark = !string.IsNullOrEmpty(Item.setData.remark); + Item.setShow.attachment = !string.IsNullOrEmpty(Item.setData.attachment); + Item.setShow.customer = !string.IsNullOrEmpty(Item.setData.customer); + Item.setShow.isexec = Item.setData.isexec == null ? false : true; + CheckPlansOut.checktypes.Where(p => p.checktypeid == QcCheckPlanD.typeid).First().items.Add(Item); + } + } + return CheckPlansOut; + } + + /// + /// 保存质检方案质检项和附加信息 + /// + /// + /// + [HttpPost] public async Task SaveData(CheckPlanInput CheckPlanInput) { var db = _repository.AsSugarClient(); try { - QcCheckPlanH QcCheckPlanH = new QcCheckPlanH(); - QcCheckPlanH.name = CheckPlanInput.name; - QcCheckPlanH.status = CheckPlanInput.status; - QcCheckPlanH.checktype = CheckPlanInput.checktype; - QcCheckPlanH.numtype = CheckPlanInput.numtype; - QcCheckPlanH.pagetype = CheckPlanInput.pagetype; - QcCheckPlanH.writerule = CheckPlanInput.writerule; - QcCheckPlanH.remind = CheckPlanInput.remind; - QcCheckPlanH.attachment = CheckPlanInput.attachment; - QcCheckPlanH.isaddmul = CheckPlanInput.isaddmul; - QcCheckPlanH.create_time = DateTime.Now; - QcCheckPlanH.create_id = _userManager.UserId; - QcCheckPlanD QcCheckPlanD = new QcCheckPlanD(); - QcCheckPlanD.mainid = QcCheckPlanH.id; - QcCheckPlanD.triggertype = CheckPlanInput.triggertype; - QcCheckPlanD.content = CheckPlanInput.content; + if (string.IsNullOrEmpty(CheckPlanInput.mainid)) + return; + await db.Deleteable(p => p.mainid == CheckPlanInput.mainid).ExecuteCommandAsync(); + await db.Deleteable(p => p.mainid == CheckPlanInput.mainid).ExecuteCommandAsync(); + QcCheckPlanAdd QcCheckPlanAdd = new QcCheckPlanAdd(); + QcCheckPlanAdd.mainid = CheckPlanInput.mainid; + QcCheckPlanAdd.triggertype = CheckPlanInput.triggertype; + QcCheckPlanAdd.content = CheckPlanInput.content; + List QcCheckPlanDs = new List(); + foreach (var checktype in CheckPlanInput.checktypes) + { + foreach (var item in checktype.items) + { + QcCheckPlanD QcCheckPlanD = new QcCheckPlanD(); + QcCheckPlanD.mainid = CheckPlanInput.mainid; + QcCheckPlanD.typeid = checktype.id; + QcCheckPlanD.itemid = item.itemid; + QcCheckPlanD.extype = item.extype; + QcCheckPlanD.excontent = item.excontent; + QcCheckPlanD.check = item.check; + QcCheckPlanD.errorcause = item.errorcause; + QcCheckPlanD.errorlevel = item.errorlevel; + QcCheckPlanD.remark = item.remark; + QcCheckPlanD.attachment = item.attachment; + QcCheckPlanD.isexec = item.isexec; + QcCheckPlanD.custom = item.customer; + QcCheckPlanDs.Add(QcCheckPlanD); + } + } await db.Ado.BeginTranAsync(); - await db.Insertable(QcCheckPlanH).ExecuteCommandAsync(); - await db.Insertable(QcCheckPlanD).ExecuteCommandAsync(); + await db.Insertable(QcCheckPlanDs).ExecuteCommandAsync(); + await db.Insertable(QcCheckPlanAdd).ExecuteCommandAsync(); await db.Ado.CommitTranAsync(); } catch (Exception ex)