diff --git a/QcMgr/Tnb.QcMgr.Entities/Dto/CheckItems.cs b/QcMgr/Tnb.QcMgr.Entities/Dto/CheckItems.cs index 93ecd6e9..a4cd4289 100644 --- a/QcMgr/Tnb.QcMgr.Entities/Dto/CheckItems.cs +++ b/QcMgr/Tnb.QcMgr.Entities/Dto/CheckItems.cs @@ -71,10 +71,10 @@ namespace Tnb.QcMgr.Entities.Dto } public class Data { public string extype { get; set; } - public string excontent { get; set; } + public Excontent excontent { get; set; } public string check { get; set; } public string[] errorcause { get; set; } - public string errorlevel { get; set; } + public string[] errorlevel { get; set; } public string remark { get; set; } public string attachment { get; set; } public string customer { get; set; } diff --git a/QcMgr/Tnb.QcMgr.Entities/Dto/CheckPlan.cs b/QcMgr/Tnb.QcMgr.Entities/Dto/CheckPlan.cs index 684bada0..154b2e31 100644 --- a/QcMgr/Tnb.QcMgr.Entities/Dto/CheckPlan.cs +++ b/QcMgr/Tnb.QcMgr.Entities/Dto/CheckPlan.cs @@ -75,10 +75,10 @@ namespace Tnb.QcMgr.Entities public class PlanItemData { public string extype { get; set; } - public string excontent { get; set; } + public Excontent excontent { get; set; } public string check { get; set; } public string[] errorcause { get; set; } - public string errorlevel { get; set; } + public string[] errorlevel { get; set; } public string remark { get; set; } public string attachment { get; set; } public string customer { get; set; } diff --git a/QcMgr/Tnb.QcMgr.Entities/Dto/CheckTask.cs b/QcMgr/Tnb.QcMgr.Entities/Dto/CheckTask.cs new file mode 100644 index 00000000..bf8b874d --- /dev/null +++ b/QcMgr/Tnb.QcMgr.Entities/Dto/CheckTask.cs @@ -0,0 +1,115 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tnb.QcMgr.Entities.Dto +{ + public class CheckTaskOut + { + public string mainid { get; set; } + public string workid { get; set; } + public string workname { get; set; } + public string wareid { get; set; } + public List checktypes { get; set; } + } + public class CheckExecTypeOut + { + public string checktypeid { get; set; } + public string checktypename { get; set; } + public List items { get; set; } + } + public class ExecItemOut + { + public string itemid { get; set; } + public string code { get; set; } + public string name { get; set; } + public string itemdid { get; set; } + public ExecItemShow setShow { get; set; } + public ExecItemData setData { get; set; } + + } + public class ExecItemShow + { + 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 ExecItemData + { + public string extype { get; set; } + public Excontent excontent { get; set; } + public string check { get; set; } + public List errorcause { get; set; } + public List errorlevel { get; set; } + public string remark { get; set; } + public string attachment { get; set; } + public string customer { get; set; } + public IsexecE isexec { get; set; } + } + public class Excontent + { + public string excontentType { get; set; } + public string excontentNum { get; set; } + public string amongMaxNum { get; set; } + public string amongMinNum { get; set; } + public string amongMinUnit { get; set; } + public string gapValue { get; set; } + public string greaterThanValue { get; set; } + public string lessThanValue { get; set; } + public string excontentText { get; set; } + public List excontentOptions { get; set; } + } + public class ExcontentOption + { + public string value { get; set; } + } + public class Error + { + public string id { get; set; } + public string name { get; set; } + } + public class IsexecE + { + public bool remark { get; set; } + public bool attachment { get; set; } + } + + public class CheckTaskInput + { + public string mainid { get; set; } + public string checknum { get; set; } + public string status { get; set; } + public string result { get; set; } + + public List checktypes { get; set; } + } + public class CheckExexTypeInput + { + public string id { get; set; } + public List items { get; set; } + } + public class ExecItemInput + { + public string itemdid { get; set; } + + 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 string result { get; set; } + } +} diff --git a/QcMgr/Tnb.QcMgr.Entities/Entity/QcCheckExecD.cs b/QcMgr/Tnb.QcMgr.Entities/Entity/QcCheckExecD.cs new file mode 100644 index 00000000..8f679d56 --- /dev/null +++ b/QcMgr/Tnb.QcMgr.Entities/Entity/QcCheckExecD.cs @@ -0,0 +1,108 @@ +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_exec_d")] + public partial class QcCheckExecD : BaseEntity + { + public QcCheckExecD() + { + id = SnowflakeIdHelper.NextId(); + } + /// + /// 质检执行主表编号 + /// + 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; } + + /// + /// 结论 + /// + public string? result { get; set; } + + } + +} diff --git a/QcMgr/Tnb.QcMgr.Entities/Entity/QcCheckExecH.cs b/QcMgr/Tnb.QcMgr.Entities/Entity/QcCheckExecH.cs new file mode 100644 index 00000000..8107f4c3 --- /dev/null +++ b/QcMgr/Tnb.QcMgr.Entities/Entity/QcCheckExecH.cs @@ -0,0 +1,102 @@ +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_exec_h")] + public partial class QcCheckExecH : BaseEntity + { + public QcCheckExecH() + { + id = SnowflakeIdHelper.NextId(); + } + /// + /// 物料编号 + /// + public string? materialid { get; set; } + + /// + /// 质检类型 + /// + public string? checktype { get; set; } + + /// + /// 工序编号 + /// + public string? processid { get; set; } + + /// + /// 工位编号 + /// + public string? workid { get; set; } + + /// + /// 仓库库位编号 + /// + public string? wareid { get; set; } + + /// + /// 抽样数 + /// + public string? checknum { get; set; } + + /// + /// 状态 + /// + public string? status { get; set; } + + /// + /// 结论 + /// + public string? result { get; set; } + + /// + /// 任务生成时间 + /// + public string? tasktime { get; set; } + + /// + /// 质检人 + /// + public string? execuser { get; set; } + + /// + /// 执行时间 + /// + public string? exectime { get; set; } + + /// + /// 扩展 + /// + public string? extras { 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/QcErrorCause.cs b/QcMgr/Tnb.QcMgr.Entities/Entity/QcErrorCause.cs new file mode 100644 index 00000000..8391c1d6 --- /dev/null +++ b/QcMgr/Tnb.QcMgr.Entities/Entity/QcErrorCause.cs @@ -0,0 +1,69 @@ +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_error_cause")] + public partial class QcErrorCause : BaseEntity + { + public QcErrorCause() + { + id = SnowflakeIdHelper.NextId(); + } + /// + /// 编号 + /// + public string? code { get; set; } + + /// + /// 名称 + /// + public string? name { get; set; } + + /// + /// 状态 + /// + public string? status { get; set; } + + /// + /// 备注 + /// + public string? remark { 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/QcErrorLevel.cs b/QcMgr/Tnb.QcMgr.Entities/Entity/QcErrorLevel.cs new file mode 100644 index 00000000..e3978c78 --- /dev/null +++ b/QcMgr/Tnb.QcMgr.Entities/Entity/QcErrorLevel.cs @@ -0,0 +1,67 @@ +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_error_level")] + public partial class QcErrorLevel : BaseEntity + { + public QcErrorLevel() + { + id = SnowflakeIdHelper.NextId(); + } + /// + /// 编号 + /// + public string? code { get; set; } + + /// + /// 名称 + /// + public string? name { get; set; } + + /// + /// 状态 + /// + public string? status { get; set; } + + /// + /// 备注 + /// + public string? remark { 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/IQcCheckTaskService.cs b/QcMgr/Tnb.QcMgr.Interfaces/IQcCheckTaskService.cs new file mode 100644 index 00000000..f2ba5df5 --- /dev/null +++ b/QcMgr/Tnb.QcMgr.Interfaces/IQcCheckTaskService.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tnb.QcMgr.Entities.Dto; + +namespace Tnb.QcMgr.Interfaces +{ + public interface IQcCheckTaskService + { + /// + /// 获取任务执行明细 + /// + /// + /// + public Task GetTaskItems(string id); + + /// + /// 执行任务 + /// + /// + /// + public Task SaveData(CheckTaskInput CheckTaskInput); + } +} diff --git a/QcMgr/Tnb.QcMgr/QcCheckItemService.cs b/QcMgr/Tnb.QcMgr/QcCheckItemService.cs index 7fd75691..fa8583a3 100644 --- a/QcMgr/Tnb.QcMgr/QcCheckItemService.cs +++ b/QcMgr/Tnb.QcMgr/QcCheckItemService.cs @@ -148,11 +148,12 @@ namespace Tnb.QcMgr 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.excontent = JSON.Deserialize(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!; + if (!string.IsNullOrEmpty(item.errorlevel)) + Item.setData.errorlevel = item.errorlevel!.Replace("[", "").Replace("]", "").Split(',', StringSplitOptions.RemoveEmptyEntries); Item.setData.remark = item.remark!; Item.setData.attachment = item.attachment!; Item.setData.customer = item.custom!; @@ -160,10 +161,10 @@ namespace Tnb.QcMgr 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.excontent = !string.IsNullOrEmpty(item.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.errorlevel = Item.setData.errorlevel == null ? false : true; Item.setShow.remark = !string.IsNullOrEmpty(Item.setData.remark); Item.setShow.attachment = !string.IsNullOrEmpty(Item.setData.attachment); Item.setShow.customer = !string.IsNullOrEmpty(Item.setData.customer); @@ -206,7 +207,7 @@ namespace Tnb.QcMgr excontent = item.excontent, check = item.check, errorcause = item.errorcause.Replace("\"","").Trim(), - errorlevel = item.errorlevel, + errorlevel = item.errorlevel.Replace("\"", "").Trim(), remark = item.remark, attachment = item.attachment, isexec = item.isexec, diff --git a/QcMgr/Tnb.QcMgr/QcCheckPlanService.cs b/QcMgr/Tnb.QcMgr/QcCheckPlanService.cs index 1332a3ef..19fd21ad 100644 --- a/QcMgr/Tnb.QcMgr/QcCheckPlanService.cs +++ b/QcMgr/Tnb.QcMgr/QcCheckPlanService.cs @@ -83,11 +83,12 @@ namespace Tnb.QcMgr 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.excontent = JSON.Deserialize(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!; + if (!string.IsNullOrEmpty(QcCheckPlanD.errorlevel)) + Item.setData.errorlevel = QcCheckPlanD.errorlevel!.Replace("[", "").Replace("]", "").Split(',', StringSplitOptions.RemoveEmptyEntries); Item.setData.remark = QcCheckPlanD.remark!; Item.setData.attachment = QcCheckPlanD.attachment!; Item.setData.customer = QcCheckPlanD.custom!; @@ -95,10 +96,10 @@ namespace Tnb.QcMgr 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.excontent = !string.IsNullOrEmpty(QcCheckPlanD.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.errorlevel = Item.setData.errorlevel == null ? false : true; Item.setShow.remark = !string.IsNullOrEmpty(Item.setData.remark); Item.setShow.attachment = !string.IsNullOrEmpty(Item.setData.attachment); Item.setShow.customer = !string.IsNullOrEmpty(Item.setData.customer); @@ -129,8 +130,11 @@ namespace Tnb.QcMgr TriggerPlan.code = triggerPlan.code!; TriggerPlan.type = triggerPlan.type!; TriggerPlan.cycle = triggerPlan.cycle!; - TriggerPlan.trieventid = triggerPlan.trievent!.Replace("[", "").Replace("]", "").Replace("\r\n", "").Replace("\"", "").Replace(" ","").Split(',', StringSplitOptions.RemoveEmptyEntries); - TriggerPlan.trievent = QcTriggerEvents.Where(p => TriggerPlan.trieventid.Contains(p.id)).Select(p => p.name!).ToArray(); + if (!string.IsNullOrEmpty(triggerPlan.trievent)) + { + TriggerPlan.trieventid = triggerPlan.trievent!.Replace("[", "").Replace("]", "").Replace("\r\n", "").Replace("\"", "").Replace(" ", "").Split(',', StringSplitOptions.RemoveEmptyEntries); + TriggerPlan.trievent = QcTriggerEvents.Where(p => TriggerPlan.trieventid.Contains(p.id)).Select(p => p.name!).ToArray(); + } TriggerPlans.Add(TriggerPlan); } return TriggerPlans; @@ -167,8 +171,8 @@ namespace Tnb.QcMgr QcCheckPlanD.extype = item.extype; QcCheckPlanD.excontent = item.excontent; QcCheckPlanD.check = item.check; - QcCheckPlanD.errorcause = item.errorcause; - QcCheckPlanD.errorlevel = item.errorlevel; + QcCheckPlanD.errorcause = item.errorcause.Replace("\"", "").Trim(); + QcCheckPlanD.errorlevel = item.errorlevel.Replace("\"", "").Trim(); QcCheckPlanD.remark = item.remark; QcCheckPlanD.attachment = item.attachment; QcCheckPlanD.isexec = item.isexec; diff --git a/QcMgr/Tnb.QcMgr/QcCheckTaskService.cs b/QcMgr/Tnb.QcMgr/QcCheckTaskService.cs new file mode 100644 index 00000000..86996e65 --- /dev/null +++ b/QcMgr/Tnb.QcMgr/QcCheckTaskService.cs @@ -0,0 +1,192 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Aspose.Cells.Drawing; +using JNPF.Common.Core.Manager; +using JNPF.Common.Enums; +using JNPF.DependencyInjection; +using JNPF.DynamicApiController; +using JNPF.FriendlyException; +using JNPF.JsonSerialization; +using JNPF.Systems.Entitys.Permission; +using Microsoft.AspNetCore.Identity; +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 +{ + /// + /// 质检任务模块 + /// + [ApiDescriptionSettings(Tag = ModuleConsts.Tag, Area = ModuleConsts.Area, Order = 800)] + [Route("api/[area]/[controller]/[action]")] + public class QcCheckTaskService : IQcCheckTaskService, IDynamicApiController, ITransient + { + private readonly ISqlSugarRepository _repository; + private readonly IUserManager _userManager; + public QcCheckTaskService(ISqlSugarRepository repository, IUserManager userManager) + { + _repository = repository; + _userManager = userManager; + } + /// + /// 获取任务执行明细 + /// + /// + /// + [HttpGet] + public async Task GetTaskItems(string id) + { + var db = _repository.AsSugarClient(); + + string planid = "26813180898837"; + var lists= await db.Queryable().Where(p => p.mainid == id).ToListAsync(); + if (lists.Count == 0) + { + var QcCheckPlanDs = await db.Queryable().Where(p => p.mainid == planid).ToListAsync(); + List NewQcCheckExecDs = new List(); + foreach (var QcCheckPlanD in QcCheckPlanDs) + { + QcCheckExecD QcCheckExecD = new QcCheckExecD(); + QcCheckExecD.mainid = id; + QcCheckExecD.extype = QcCheckPlanD.extype; + QcCheckExecD.excontent = QcCheckPlanD.excontent; + QcCheckExecD.check = QcCheckPlanD.check; + QcCheckExecD.errorcause = QcCheckPlanD.errorcause; + QcCheckExecD.errorlevel = QcCheckPlanD.errorlevel; + QcCheckExecD.remark = QcCheckPlanD.remark; + QcCheckExecD.attachment = QcCheckPlanD.attachment; + QcCheckExecD.isexec = QcCheckPlanD.isexec; + QcCheckExecD.custom = QcCheckPlanD.custom; + QcCheckExecD.typeid = QcCheckPlanD.typeid; + QcCheckExecD.itemid = QcCheckPlanD.itemid; + NewQcCheckExecDs.Add(QcCheckExecD); + } + await db.Insertable(NewQcCheckExecDs).ExecuteCommandAsync(); + } + var QcCheckExecH = await db.Queryable().Where(p => p.id == id).FirstAsync(); + var QcCheckExecDs = await db.Queryable().Where(p => p.mainid == id).ToListAsync(); + var QcCheckItems = await db.Queryable().ToListAsync(); + var QcCheckTypes = await db.Queryable().ToListAsync(); + var QcErrorCauses = await db.Queryable().ToListAsync(); + var QcErrorLevels = await db.Queryable().ToListAsync(); + + CheckTaskOut CheckTaskOut = new CheckTaskOut(); + CheckTaskOut.mainid = id; + CheckTaskOut.wareid = QcCheckExecH.wareid!; + CheckTaskOut.workid = QcCheckExecH.workid!; + if (!string.IsNullOrEmpty(CheckTaskOut.workid)) + CheckTaskOut.workname = db.Queryable().Where(p => p.Id == CheckTaskOut.workid).First().FullName; + CheckTaskOut.checktypes = new List(); + foreach (var QcCheckExecD in QcCheckExecDs) + { + if (CheckTaskOut.checktypes.Where(p => p.checktypeid == QcCheckExecD.typeid).ToList().Count == 0) + { + CheckExecTypeOut checkType = new CheckExecTypeOut(); + checkType.checktypeid = QcCheckExecD.typeid!; + checkType.checktypename = QcCheckTypes.Where(p => p.id == QcCheckExecD.typeid).First().name!; + checkType.items = new List(); + CheckTaskOut.checktypes.Add(checkType); + } + ExecItemOut Item = new ExecItemOut(); + Item.itemid = QcCheckExecD.itemid!; + Item.itemdid = QcCheckExecD.id!; + Item.code = QcCheckItems.Where(p => p.id == QcCheckExecD.itemid).First().code!; + Item.name = QcCheckItems.Where(p => p.id == QcCheckExecD.itemid).First().name!; + Item.setData = new ExecItemData(); + Item.setData.extype = QcCheckExecD.extype!; + Item.setData.excontent = JSON.Deserialize(QcCheckExecD.excontent!); + Item.setData.check = QcCheckExecD.check!; + if (!string.IsNullOrEmpty(QcCheckExecD.errorcause)) + { + var strs = QcCheckExecD.errorcause!.Replace("[", "").Replace("]", "").Split(',', StringSplitOptions.RemoveEmptyEntries); + Item.setData.errorcause = new List(); + foreach (var str in strs) + { + Item.setData.errorcause.Add(new Error { id = str, name = QcErrorCauses.Where(p => p.id == str).First().name! }); + } + } + if (!string.IsNullOrEmpty(QcCheckExecD.errorlevel)) + { + var strs = QcCheckExecD.errorlevel!.Replace("[", "").Replace("]", "").Split(',', StringSplitOptions.RemoveEmptyEntries); + Item.setData.errorlevel = new List(); + foreach (var str in strs) + { + Item.setData.errorlevel.Add(new Error { id = str, name = QcErrorLevels.Where(p => p.id == str).First().name! }); + } + } + Item.setData.remark = QcCheckExecD.remark!; + Item.setData.attachment = QcCheckExecD.attachment!; + Item.setData.customer = QcCheckExecD.custom!; + if (!string.IsNullOrEmpty(QcCheckExecD.isexec)) + Item.setData.isexec = JSON.Deserialize(QcCheckExecD.isexec!); + Item.setShow = new ExecItemShow(); + Item.setShow.extype = !string.IsNullOrEmpty(Item.setData.extype); + Item.setShow.excontent = !string.IsNullOrEmpty(QcCheckExecD.excontent); + Item.setShow.check = !string.IsNullOrEmpty(Item.setData.check); + Item.setShow.errorcause = Item.setData.errorcause.Count == 0 ? false : true; + Item.setShow.errorlevel = Item.setData.errorlevel.Count == 0 ? false : true; + 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; + CheckTaskOut.checktypes.Where(p => p.checktypeid == QcCheckExecD.typeid).First().items.Add(Item); + } + return CheckTaskOut; + } + + /// + /// 执行任务 + /// + /// + /// + [HttpPost] + public async Task SaveData(CheckTaskInput CheckTaskInput) + { + var db = _repository.AsSugarClient(); + try + { + var QcCheckExecH = await db.Queryable().Where(p => p.id == CheckTaskInput.mainid).FirstAsync(); + QcCheckExecH.checknum = CheckTaskInput.checknum; + QcCheckExecH.status = CheckTaskInput.status; + QcCheckExecH.result = CheckTaskInput.result; + QcCheckExecH.execuser = _userManager.UserId; + QcCheckExecH.exectime = DateTime.Now.ToString(); + var QcCheckExecDs = await db.Queryable().Where(p => p.mainid == CheckTaskInput.mainid).ToListAsync(); + foreach (var checktype in CheckTaskInput.checktypes) + { + foreach (var item in checktype.items) + { + var QcCheckExecD = QcCheckExecDs.Where(p => p.id == item.itemdid).FirstOrDefault(); + if (QcCheckExecD == null) + continue; + QcCheckExecD.excontent = item.excontent; + QcCheckExecD.check = item.check; + QcCheckExecD.errorcause = item.errorcause; + QcCheckExecD.errorlevel = item.errorlevel; + QcCheckExecD.remark = item.remark; + QcCheckExecD.attachment = item.attachment; + QcCheckExecD.isexec = item.isexec; + QcCheckExecD.custom = item.customer; + QcCheckExecD.result = item.result; + } + } + await db.Ado.BeginTranAsync(); + await db.Updateable(QcCheckExecH).ExecuteCommandAsync(); + await db.Updateable(QcCheckExecDs).ExecuteCommandAsync(); + await db.Ado.CommitTranAsync(); + } + catch (Exception ex) + { + + throw Oops.Oh(ErrorCode.COM1000); + } + } + } +}