品质模块

This commit is contained in:
qianjiawei
2023-06-09 17:37:42 +08:00
parent 1f75188668
commit 21115d3b29
16 changed files with 816 additions and 71 deletions

View File

@@ -8,18 +8,23 @@ namespace Tnb.QcMgr.Entities.Dto
{ {
public class CheckItemsInput public class CheckItemsInput
{ {
public string id { get; set; }
public string name { get; set; } public string name { get; set; }
public string status { get; set; } public string status { get; set; }
public List<CheckType> checktypoes { get; set; } public List<CheckTypeInput> checktypes { get; set; }
} }
public class CheckType public class CheckTypeInput
{ {
public string id { get; set; } public string id { get; set; }
public List<Item> items { get; set; } public List<ItemInput> items { get; set; }
} }
public class Item public class ItemInput
{ {
public string itemid { get; set; } 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 extype { get; set; }
public string excontent { get; set; } public string excontent { get; set; }
public string check { get; set; } public string check { get; set; }
@@ -28,5 +33,56 @@ namespace Tnb.QcMgr.Entities.Dto
public string remark { get; set; } public string remark { get; set; }
public string attachment { get; set; } public string attachment { get; set; }
public string isexec { 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<CheckTypeOut> checktypes { get; set; }
}
public class CheckTypeOut
{
public string checktypeid { get; set; }
public string checktypename { get; set; }
public List<ItemOut> 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; }
} }
} }

View File

@@ -3,31 +3,90 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Tnb.QcMgr.Entities.Dto;
namespace Tnb.QcMgr.Entities namespace Tnb.QcMgr.Entities
{ {
public class CheckPlanInput public class CheckPlanInput
{ {
public string name { get; set; } public string mainid { get; set; }
public string addid { 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 triggertype { get; set; } public string triggertype { get; set; }
public string content { get; set; } public string content { get; set; }
public List<CheckPlanTypeInput> checktypes { get; set; }
}
public class CheckPlanTypeInput
{
public string id { get; set; }
public List<PlanItemInput> 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<CheckPlanTypeOut> checktypes { get; set; }
}
public class CheckPlanTypeOut
{
public string checktypeid { get; set; }
public string checktypename { get; set; }
public List<PlanItemOut> 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; }
} }
} }

View File

@@ -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
{
}
}

View File

@@ -61,6 +61,11 @@ namespace Tnb.QcMgr.Entities
/// </summary> /// </summary>
public string? isexec { get; set; } public string? isexec { get; set; }
/// <summary>
/// 客户
/// </summary>
public string? custom { get; set; }
/// <summary> /// <summary>
/// 创建用户 /// 创建用户
/// </summary> /// </summary>

View File

@@ -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
{
/// <summary>
/// 质检方案附加信息
/// </summary>
[SugarTable("qc_check_plan_add")]
public partial class QcCheckPlanAdd : BaseEntity<string>
{
public QcCheckPlanAdd()
{
id = SnowflakeIdHelper.NextId();
}
/// <summary>
/// 触发类型
/// </summary>
public string? triggertype { get; set; }
/// <summary>
/// 触发内容
/// </summary>
public string? content { get; set; }
/// <summary>
/// 主表编号
/// </summary>
public string? mainid { get; set; }
}
}

View File

@@ -7,10 +7,11 @@ using JNPF.Common.Contracts;
using JNPF.Common.Security; using JNPF.Common.Security;
using SqlSugar; using SqlSugar;
namespace Tnb.QcMgr.Entities namespace Tnb.QcMgr.Entities.Entity
{ {
/// <summary> /// <summary>
/// 质检方案附加信息 /// 质检方案子表
/// </summary> /// </summary>
[SugarTable("qc_check_plan_d")] [SugarTable("qc_check_plan_d")]
public partial class QcCheckPlanD : BaseEntity<string> public partial class QcCheckPlanD : BaseEntity<string>
@@ -21,18 +22,84 @@ namespace Tnb.QcMgr.Entities
} }
/// <summary> /// <summary>
/// 触发类型 /// 质检方案主表编号
/// </summary>
public string? triggertype { get; set; }
/// <summary>
/// 触发内容
/// </summary>
public string? content { get; set; }
/// <summary>
/// 主表编号
/// </summary> /// </summary>
public string? mainid { get; set; } public string? mainid { get; set; }
/// <summary>
/// 执行项格式
/// </summary>
public string? extype { get; set; }
/// <summary>
/// 执行项内容
/// </summary>
public string? excontent { get; set; }
/// <summary>
/// 抽检类型
/// </summary>
public string? check { get; set; }
/// <summary>
/// 不良原因
/// </summary>
public string? errorcause { get; set; }
/// <summary>
/// 不良等级
/// </summary>
public string? errorlevel { get; set; }
/// <summary>
/// 备注
/// </summary>
public string? remark { get; set; }
/// <summary>
/// 附件
/// </summary>
public string? attachment { get; set; }
/// <summary>
/// 执行时操作
/// </summary>
public string? isexec { get; set; }
/// <summary>
/// 客户
/// </summary>
public string? custom { get; set; }
/// <summary>
/// 质检项分类编号
/// </summary>
public string? typeid { get; set; }
/// <summary>
/// 质检项编号
/// </summary>
public string? itemid { get; set; }
/// <summary>
/// 创建用户
/// </summary>
public string? create_id { get; set; }
/// <summary>
/// 创建时间
/// </summary>
public DateTime? create_time { get; set; }
/// <summary>
/// 修改用户
/// </summary>
public string? modify_id { get; set; }
/// <summary>
/// 修改时间
/// </summary>
public DateTime? modify_time { get; set; }
} }
} }

View File

@@ -9,8 +9,9 @@ using SqlSugar;
namespace Tnb.QcMgr.Entities namespace Tnb.QcMgr.Entities
{ {
/// <summary> /// <summary>
/// 质检方案主表 /// 质检方案
/// </summary> /// </summary>
[SugarTable("qc_check_plan_h")] [SugarTable("qc_check_plan_h")]
public partial class QcCheckPlanH : BaseEntity<string> public partial class QcCheckPlanH : BaseEntity<string>
@@ -19,6 +20,12 @@ namespace Tnb.QcMgr.Entities
{ {
id = SnowflakeIdHelper.NextId(); id = SnowflakeIdHelper.NextId();
} }
/// <summary>
/// 编号
/// </summary>
public string? code { get; set; }
/// <summary> /// <summary>
/// 名称 /// 名称
/// </summary> /// </summary>
@@ -83,5 +90,8 @@ namespace Tnb.QcMgr.Entities
/// 修改时间 /// 修改时间
/// </summary> /// </summary>
public DateTime? modify_time { get; set; } public DateTime? modify_time { get; set; }
} }
} }

View File

@@ -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
{
/// <summary>
/// 质检方案物料关联表
/// </summary>
[SugarTable("qc_check_plan_material")]
public partial class QcCheckPlanMaterial : BaseEntity<string>
{
public QcCheckPlanMaterial()
{
id = SnowflakeIdHelper.NextId();
}
/// <summary>
/// 质检方案编号
/// </summary>
public string? planid { get; set; }
/// <summary>
/// 物料方案编号
/// </summary>
public string? materialid { get; set; }
/// <summary>
/// 创建用户
/// </summary>
public string? create_id { get; set; }
/// <summary>
/// 创建时间
/// </summary>
public DateTime? create_time { get; set; }
/// <summary>
/// 修改用户
/// </summary>
public string? modify_id { get; set; }
/// <summary>
/// 修改时间
/// </summary>
public DateTime? modify_time { get; set; }
/// <summary>
/// 扩展
/// </summary>
public string? extras { get; set; }
}
}

View File

@@ -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
{
/// <summary>
/// 质检方案工序关联表
/// </summary>
[SugarTable("qc_check_plan_process")]
public partial class QcCheckPlanProcess : BaseEntity<string>
{
public QcCheckPlanProcess()
{
id = SnowflakeIdHelper.NextId();
}
/// <summary>
/// 方案编号
/// </summary>
public string? planid { get; set; }
/// <summary>
/// 工序编号
/// </summary>
public string? processid { get; set; }
/// <summary>
/// 创建用户
/// </summary>
public string? create_id { get; set; }
/// <summary>
/// 创建时间
/// </summary>
public DateTime? create_time { get; set; }
/// <summary>
/// 修改用户
/// </summary>
public string? modify_id { get; set; }
/// <summary>
/// 修改时间
/// </summary>
public DateTime? modify_time { get; set; }
/// <summary>
/// 扩展
/// </summary>
public string? extras { get; set; }
}
}

View File

@@ -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
{
/// <summary>
/// 质检方案工位关联表
/// </summary>
[SugarTable("qc_check_plan_work")]
public partial class QcCheckPlanWork : BaseEntity<string>
{
public QcCheckPlanWork()
{
id = SnowflakeIdHelper.NextId();
}
/// <summary>
/// 质检方案编号
/// </summary>
public string? planid { get; set; }
/// <summary>
/// 工位编号
/// </summary>
public string? workid { get; set; }
/// <summary>
/// 创建用户
/// </summary>
public string? create_id { get; set; }
/// <summary>
/// 创建时间
/// </summary>
public DateTime? create_time { get; set; }
/// <summary>
/// 修改用户
/// </summary>
public string? modify_id { get; set; }
/// <summary>
/// 修改时间
/// </summary>
public DateTime? modify_time { get; set; }
/// <summary>
/// 扩展
/// </summary>
public string? extras { get; set; }
}
}

View File

@@ -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
{
/// <summary>
/// 触发事件
/// </summary>
[SugarTable("qc_trigger_event")]
public partial class QcTriggerEvent : BaseEntity<string>
{
public QcTriggerEvent()
{
id = SnowflakeIdHelper.NextId();
}
/// <summary>
/// 名称
/// </summary>
public string? name { get; set; }
/// <summary>
/// 编号
/// </summary>
public string? code { get; set; }
/// <summary>
/// 分类
/// </summary>
public string? type { get; set; }
/// <summary>
/// 创建用户
/// </summary>
public string? create_id { get; set; }
/// <summary>
/// 创建时间
/// </summary>
public DateTime? create_time { get; set; }
/// <summary>
/// 修改用户
/// </summary>
public string? modify_id { get; set; }
/// <summary>
/// 修改时间
/// </summary>
public DateTime? modify_time { get; set; }
/// <summary>
/// 扩展
/// </summary>
public string? extras { get; set; }
}
}

View File

@@ -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
{
/// <summary>
/// 触发计划
/// </summary>
[SugarTable("qc_trigger_plan")]
public partial class QcTriggerPlan : BaseEntity<string>
{
public QcTriggerPlan()
{
id = SnowflakeIdHelper.NextId();
}
/// <summary>
/// 名称
/// </summary>
public string? name { get; set; }
/// <summary>
/// 编号
/// </summary>
public string? code { get; set; }
/// <summary>
/// 触发类型
/// </summary>
public string type { get; set; } = string.Empty;
/// <summary>
/// 触发周期
/// </summary>
public string? cycle { get; set; }
/// <summary>
/// 触发事件
/// </summary>
public string? trievent { get; set; }
/// <summary>
/// 创建用户
/// </summary>
public string? create_id { get; set; }
/// <summary>
/// 创建时间
/// </summary>
public DateTime? create_time { get; set; }
/// <summary>
/// 修改用户
/// </summary>
public string? modify_id { get; set; }
/// <summary>
/// 修改时间
/// </summary>
public DateTime? modify_time { get; set; }
/// <summary>
/// 扩展
/// </summary>
public string? extras { get; set; }
}
}

View File

@@ -22,5 +22,12 @@ namespace Tnb.QcMgr.Interfaces
/// <param name="CheckItemInput"></param> /// <param name="CheckItemInput"></param>
/// <returns></returns> /// <returns></returns>
public Task SaveData(CheckItemsInput CheckItemsInput); public Task SaveData(CheckItemsInput CheckItemsInput);
/// <summary>
/// 获取质检项清单
/// </summary>
/// <param name="CheckItemInput"></param>
/// <returns></returns>
public Task<dynamic> GetCheckItems(CheckItemsInput CheckItemsInput);
} }
} }

View File

@@ -4,16 +4,24 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Tnb.QcMgr.Entities; using Tnb.QcMgr.Entities;
using Tnb.QcMgr.Entities.Dto;
namespace Tnb.QcMgr.Interfaces namespace Tnb.QcMgr.Interfaces
{ {
public interface IQcCheckPlanService public interface IQcCheckPlanService
{ {
/// <summary> /// <summary>
/// 保存质检方案 /// 保存质检方案质检项和附加信息
/// </summary> /// </summary>
/// <param name="CheckPlanInput"></param> /// <param name="CheckPlanInput"></param>
/// <returns></returns> /// <returns></returns>
public Task SaveData(CheckPlanInput CheckPlanInput); public Task SaveData(CheckPlanInput CheckPlanInput);
/// <summary>
/// 获取方案质检项附加信息
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public Task<dynamic> GetCheckItems(string id);
} }
} }

View File

@@ -11,6 +11,7 @@ using JNPF.Common.Enums;
using JNPF.DependencyInjection; using JNPF.DependencyInjection;
using JNPF.DynamicApiController; using JNPF.DynamicApiController;
using JNPF.FriendlyException; using JNPF.FriendlyException;
using JNPF.JsonSerialization;
using JNPF.VisualDev; using JNPF.VisualDev;
using JNPF.VisualDev.Interfaces; using JNPF.VisualDev.Interfaces;
using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Identity;
@@ -34,7 +35,7 @@ namespace Tnb.QcMgr
[OverideVisualDev(ModuleId)] [OverideVisualDev(ModuleId)]
public class QcCheckItemService : IOverideVisualDevService, IQcCheckItemService, IDynamicApiController, ITransient public class QcCheckItemService : IOverideVisualDevService, IQcCheckItemService, IDynamicApiController, ITransient
{ {
private const string ModuleId = "26500755139349"; private const string ModuleId = "26477150883109";
private readonly ISqlSugarRepository<QcCheckItemsH> _repository; private readonly ISqlSugarRepository<QcCheckItemsH> _repository;
private readonly IUserManager _userManager; private readonly IUserManager _userManager;
public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc(); public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc();
@@ -50,7 +51,7 @@ namespace Tnb.QcMgr
var db = _repository.AsSugarClient(); var db = _repository.AsSugarClient();
var QcCheckItemsH=await db.Queryable< QcCheckItemsH >().Where(p=>p.id==id).FirstAsync(); var QcCheckItemsH=await db.Queryable< QcCheckItemsH >().Where(p=>p.id==id).FirstAsync();
var QcCheckItemsRs = await db.Queryable<QcCheckItemsR>().Where(p => p.itemshid == id).ToListAsync() ; var QcCheckItemsRs = await db.Queryable<QcCheckItemsR>().Where(p => p.itemshid == id).ToListAsync() ;
var QcCheckItemsDs=await db.Queryable<QcCheckItemsD>().Where(p=> QcCheckItemsRs.Select(p=>p.id).ToList().Contains( p.id)).ToListAsync() ; var QcCheckItemsDs = await db.Queryable<QcCheckItemsD>().Where(p => QcCheckItemsRs.Select(p => p.itemsdid).ToList().Contains(p.id)).ToListAsync();
await db.Ado.BeginTranAsync(); await db.Ado.BeginTranAsync();
await db.Deleteable(QcCheckItemsH).ExecuteCommandAsync(); await db.Deleteable(QcCheckItemsH).ExecuteCommandAsync();
await db.Deleteable(QcCheckItemsRs).ExecuteCommandAsync(); await db.Deleteable(QcCheckItemsRs).ExecuteCommandAsync();
@@ -83,21 +84,98 @@ namespace Tnb.QcMgr
if (CheckItemOut.items == null) if (CheckItemOut.items == null)
{ {
CheckItemOut.items = new List<CheckItem>(); CheckItemOut.items = new List<CheckItem>();
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 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 else
{ {
CheckItemOuts.Add(new CheckItemOut { checktypeid = data.type, checktypename = data.typename, items = new List<CheckItem>() }); CheckItemOuts.Add(new CheckItemOut { checktypeid = data.type!, checktypename = data.typename!, items = new List<CheckItem>() });
var CheckItemOut = CheckItemOuts.Where(p => p.checktypeid == data.type).First(); 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; return CheckItemOuts;
} }
/// <summary>
/// 获取质检项清单
/// </summary>
/// <param name="CheckItemInput"></param>
/// <returns></returns>
[HttpPost]
public async Task<dynamic> GetCheckItems(CheckItemsInput CheckItemsInput)
{
var db = _repository.AsSugarClient();
var QcCheckItems = await db.Queryable<QcCheckItem>().ToListAsync();
var QcCheckTypes = await db.Queryable<QcCheckType>().ToListAsync();
var QcCheckItemsH = await db.Queryable<QcCheckItemsH>().Where(p => p.id == CheckItemsInput.id).FirstAsync();
List<QcCheckItemsR> QcCheckItemsRs = null;
List<QcCheckItemsD> QcCheckItemsDs = null;
if (QcCheckItemsH != null)
{
QcCheckItemsRs = await db.Queryable<QcCheckItemsR>().Where(p => p.itemshid == QcCheckItemsH.id).ToListAsync();
if (QcCheckItemsRs != null)
QcCheckItemsDs = await db.Queryable<QcCheckItemsD>().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<CheckTypeOut>();
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<ItemOut>();
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<Isexec>(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;
}
/// <summary> /// <summary>
/// 保存质检项清单 /// 保存质检项清单
/// </summary> /// </summary>
@@ -109,7 +187,8 @@ namespace Tnb.QcMgr
var db = _repository.AsSugarClient(); var db = _repository.AsSugarClient();
try try
{ {
if (!string.IsNullOrEmpty(CheckItemsInput.id))
await Delete(CheckItemsInput.id);
QcCheckItemsH QcCheckItemsH = new QcCheckItemsH(); QcCheckItemsH QcCheckItemsH = new QcCheckItemsH();
QcCheckItemsH.name = CheckItemsInput.name; QcCheckItemsH.name = CheckItemsInput.name;
QcCheckItemsH.status = CheckItemsInput.status; QcCheckItemsH.status = CheckItemsInput.status;
@@ -117,8 +196,7 @@ namespace Tnb.QcMgr
QcCheckItemsH.create_id = _userManager.UserId; QcCheckItemsH.create_id = _userManager.UserId;
List<QcCheckItemsR> QcCheckItemsRs = new List<QcCheckItemsR>(); List<QcCheckItemsR> QcCheckItemsRs = new List<QcCheckItemsR>();
List<QcCheckItemsD> QcCheckItemsDs = new List<QcCheckItemsD>(); List<QcCheckItemsD> QcCheckItemsDs = new List<QcCheckItemsD>();
foreach (var checktype in CheckItemsInput.checktypes)
foreach (var checktype in CheckItemsInput.checktypoes)
{ {
foreach (var item in checktype.items) foreach (var item in checktype.items)
{ {
@@ -127,11 +205,12 @@ namespace Tnb.QcMgr
extype = item.extype, extype = item.extype,
excontent = item.excontent, excontent = item.excontent,
check = item.check, check = item.check,
errorcause = item.errorcause, errorcause = item.errorcause.Replace("\"","").Trim(),
errorlevel = item.errorlevel, errorlevel = item.errorlevel,
remark = item.remark, remark = item.remark,
attachment = item.attachment, attachment = item.attachment,
isexec = item.isexec isexec = item.isexec,
custom=item.customer
}; };
QcCheckItemsDs.Add(QcCheckItemsD); QcCheckItemsDs.Add(QcCheckItemsD);
var QcCheckItemsR = new QcCheckItemsR() var QcCheckItemsR = new QcCheckItemsR()
@@ -145,6 +224,12 @@ namespace Tnb.QcMgr
QcCheckItemsRs.Add(QcCheckItemsR); QcCheckItemsRs.Add(QcCheckItemsR);
} }
} }
QcCheckItemsDs.ForEach(p =>
{
p.create_id = _userManager.UserId;
p.create_time = DateTime.Now;
});
await db.Ado.BeginTranAsync(); await db.Ado.BeginTranAsync();
await db.Insertable(QcCheckItemsH).ExecuteCommandAsync(); await db.Insertable(QcCheckItemsH).ExecuteCommandAsync();
await db.Insertable(QcCheckItemsRs).ExecuteCommandAsync(); await db.Insertable(QcCheckItemsRs).ExecuteCommandAsync();

View File

@@ -10,11 +10,13 @@ using JNPF.Common.Enums;
using JNPF.DependencyInjection; using JNPF.DependencyInjection;
using JNPF.DynamicApiController; using JNPF.DynamicApiController;
using JNPF.FriendlyException; using JNPF.FriendlyException;
using JNPF.JsonSerialization;
using JNPF.VisualDev; using JNPF.VisualDev;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using SqlSugar; using SqlSugar;
using Tnb.QcMgr.Entities; using Tnb.QcMgr.Entities;
using Tnb.QcMgr.Entities.Dto; using Tnb.QcMgr.Entities.Dto;
using Tnb.QcMgr.Entities.Entity;
using Tnb.QcMgr.Interfaces; using Tnb.QcMgr.Interfaces;
namespace Tnb.QcMgr namespace Tnb.QcMgr
@@ -33,38 +35,122 @@ namespace Tnb.QcMgr
{ {
_repository = repository; _repository = repository;
_userManager = userManager; _userManager = userManager;
} }
/// <summary> /// <summary>
/// 保存质检方案 /// 获取方案质检项附加信息
/// </summary> /// </summary>
/// <param name="CheckPlanInput"></param> /// <param name="CheckPlanInput"></param>
/// <returns></returns> /// <returns></returns>
[HttpPost]
public async Task<dynamic> GetCheckItems(string id)
{
var db = _repository.AsSugarClient();
var QcCheckItems = await db.Queryable<QcCheckItem>().ToListAsync();
var QcCheckTypes = await db.Queryable<QcCheckType>().ToListAsync();
var QcCheckPlanAdd = await db.Queryable<QcCheckPlanAdd>().Where(p => p.mainid == id).FirstAsync();
var QcCheckPlanDs = await db.Queryable<QcCheckPlanD>().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<CheckPlanTypeOut>();
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<PlanItemOut>();
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<IsexecP>(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;
}
/// <summary>
/// 保存质检方案质检项和附加信息
/// </summary>
/// <param name="CheckPlanInput"></param>
/// <returns></returns>
[HttpPost]
public async Task SaveData(CheckPlanInput CheckPlanInput) public async Task SaveData(CheckPlanInput CheckPlanInput)
{ {
var db = _repository.AsSugarClient(); var db = _repository.AsSugarClient();
try try
{ {
QcCheckPlanH QcCheckPlanH = new QcCheckPlanH(); if (string.IsNullOrEmpty(CheckPlanInput.mainid))
QcCheckPlanH.name = CheckPlanInput.name; return;
QcCheckPlanH.status = CheckPlanInput.status; await db.Deleteable<QcCheckPlanD>(p => p.mainid == CheckPlanInput.mainid).ExecuteCommandAsync();
QcCheckPlanH.checktype = CheckPlanInput.checktype; await db.Deleteable<QcCheckPlanAdd>(p => p.mainid == CheckPlanInput.mainid).ExecuteCommandAsync();
QcCheckPlanH.numtype = CheckPlanInput.numtype; QcCheckPlanAdd QcCheckPlanAdd = new QcCheckPlanAdd();
QcCheckPlanH.pagetype = CheckPlanInput.pagetype; QcCheckPlanAdd.mainid = CheckPlanInput.mainid;
QcCheckPlanH.writerule = CheckPlanInput.writerule; QcCheckPlanAdd.triggertype = CheckPlanInput.triggertype;
QcCheckPlanH.remind = CheckPlanInput.remind; QcCheckPlanAdd.content = CheckPlanInput.content;
QcCheckPlanH.attachment = CheckPlanInput.attachment; List<QcCheckPlanD> QcCheckPlanDs = new List<QcCheckPlanD>();
QcCheckPlanH.isaddmul = CheckPlanInput.isaddmul; foreach (var checktype in CheckPlanInput.checktypes)
QcCheckPlanH.create_time = DateTime.Now; {
QcCheckPlanH.create_id = _userManager.UserId; foreach (var item in checktype.items)
QcCheckPlanD QcCheckPlanD = new QcCheckPlanD(); {
QcCheckPlanD.mainid = QcCheckPlanH.id; QcCheckPlanD QcCheckPlanD = new QcCheckPlanD();
QcCheckPlanD.triggertype = CheckPlanInput.triggertype; QcCheckPlanD.mainid = CheckPlanInput.mainid;
QcCheckPlanD.content = CheckPlanInput.content; 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.Ado.BeginTranAsync();
await db.Insertable(QcCheckPlanH).ExecuteCommandAsync(); await db.Insertable(QcCheckPlanDs).ExecuteCommandAsync();
await db.Insertable(QcCheckPlanD).ExecuteCommandAsync(); await db.Insertable(QcCheckPlanAdd).ExecuteCommandAsync();
await db.Ado.CommitTranAsync(); await db.Ado.CommitTranAsync();
} }
catch (Exception ex) catch (Exception ex)