From c619620da618750fe78d66bc7fc6d9d8c85952b3 Mon Sep 17 00:00:00 2001 From: zhoukeda <1315948824@qq.com> Date: Thu, 8 Jun 2023 17:36:22 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E5=B7=A5=E8=89=BA=E6=A0=87=E5=87=86?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Tnb.EquipMgr/EquMaintainRecordService.cs | 2 +- .../Dto/ProcessChildDataInput.cs | 6 + .../Dto/ProcessParamTypeChildrenOutput.cs | 2 + .../Dto/ProcessParamTypeDaqListOutput.cs | 8 + .../Entity/PerProcessParamEditRecord.cs | 67 ++++++++ .../Entity/PerProcessStandardsD.cs | 10 ++ .../IPerProcessStandardsService.cs | 8 + .../Tnb.PerMgr/PerProcessParamTypeService.cs | 73 +++++++- .../Tnb.PerMgr/PerProcessStandardsService.cs | 159 ++++++++++++++++++ 9 files changed, 327 insertions(+), 8 deletions(-) create mode 100644 PerMgr/Tnb.PerMgr.Entities/Dto/ProcessParamTypeDaqListOutput.cs create mode 100644 PerMgr/Tnb.PerMgr.Entities/Entity/PerProcessParamEditRecord.cs diff --git a/EquipMgr/Tnb.EquipMgr/EquMaintainRecordService.cs b/EquipMgr/Tnb.EquipMgr/EquMaintainRecordService.cs index 62c6dc6f..4beaf951 100644 --- a/EquipMgr/Tnb.EquipMgr/EquMaintainRecordService.cs +++ b/EquipMgr/Tnb.EquipMgr/EquMaintainRecordService.cs @@ -79,7 +79,7 @@ namespace Tnb.EquipMgr { await _repository.AsSugarClient().Updateable() .SetColumns(x=>x.result==item["result"]) - .SetColumns(x=>x.maintain_descrip==item["maintain_descrip"]) + .SetColumnsIF(item.ContainsKey("maintain_descrip"),x=>x.maintain_descrip==item["maintain_descrip"]) .Where(x=>x.id==item["id"]) .ExecuteCommandAsync(); } diff --git a/PerMgr/Tnb.PerMgr.Entities/Dto/ProcessChildDataInput.cs b/PerMgr/Tnb.PerMgr.Entities/Dto/ProcessChildDataInput.cs index 1e8b577e..9c9b4ea0 100644 --- a/PerMgr/Tnb.PerMgr.Entities/Dto/ProcessChildDataInput.cs +++ b/PerMgr/Tnb.PerMgr.Entities/Dto/ProcessChildDataInput.cs @@ -3,11 +3,17 @@ namespace Tnb.PerMgr.Entities.Dto public class ProcessChildDataInput { + public string id { get; set; } public string process_standards_id { get; set; } /// /// 工艺参数id /// public string process_param_id { get; set; } + /// + /// 工艺参数类型id + /// + public string process_param_type_id { get; set; } public decimal value { get; set; } + public string daq_id { 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 index 1725773c..c11cf8ea 100644 --- a/PerMgr/Tnb.PerMgr.Entities/Dto/ProcessParamTypeChildrenOutput.cs +++ b/PerMgr/Tnb.PerMgr.Entities/Dto/ProcessParamTypeChildrenOutput.cs @@ -14,5 +14,7 @@ namespace Tnb.PerMgr.Entities.Dto public decimal? value { get; set; } public decimal upper_value { get; set; } public decimal lower_value { get; set; } + + public string daq_id { get; set; } } } \ No newline at end of file diff --git a/PerMgr/Tnb.PerMgr.Entities/Dto/ProcessParamTypeDaqListOutput.cs b/PerMgr/Tnb.PerMgr.Entities/Dto/ProcessParamTypeDaqListOutput.cs new file mode 100644 index 00000000..1aa5c6e7 --- /dev/null +++ b/PerMgr/Tnb.PerMgr.Entities/Dto/ProcessParamTypeDaqListOutput.cs @@ -0,0 +1,8 @@ +namespace Tnb.PerMgr.Entities.Dto +{ + public class ProcessParamTypeDaqListOutput + { + public string id { get; set; } + public string label_name { get; set; } + } +} \ No newline at end of file diff --git a/PerMgr/Tnb.PerMgr.Entities/Entity/PerProcessParamEditRecord.cs b/PerMgr/Tnb.PerMgr.Entities/Entity/PerProcessParamEditRecord.cs new file mode 100644 index 00000000..0be7c529 --- /dev/null +++ b/PerMgr/Tnb.PerMgr.Entities/Entity/PerProcessParamEditRecord.cs @@ -0,0 +1,67 @@ +using JNPF.Common.Contracts; +using JNPF.Common.Security; +using SqlSugar; + +namespace Tnb.PerMgr.Entities; + +/// +/// 工艺参数设定值修改记录 +/// +[SugarTable("per_process_param_edit_record")] +public partial class PerProcessParamEditRecord : BaseEntity +{ + public PerProcessParamEditRecord() + { + id = SnowflakeIdHelper.NextId(); + } + /// + /// 工艺参数id + /// + public string process_param_id { get; set; } = string.Empty; + + /// + /// 修改前值 + /// + public decimal old_value { get; set; } + + /// + /// 修改后值 + /// + public decimal new_value { get; set; } + + /// + /// 修改用户 + /// + public string modify_id { get; set; } = string.Empty; + + /// + /// 修改时间 + /// + public DateTime modify_time { get; set; } = DateTime.Now; + + /// + /// 所属组织 + /// + public string? org_id { get; set; } + + /// + /// 工艺参数名 + /// + public string? process_param_name { get; set; } + + /// + /// 设备id + /// + public string equip_id { get; set; } = string.Empty; + + /// + /// 流程任务Id + /// + public string? f_flowtaskid { get; set; } + + /// + /// 流程引擎Id + /// + public string? f_flowid { 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 index bbf44f4a..d49222ac 100644 --- a/PerMgr/Tnb.PerMgr.Entities/Entity/PerProcessStandardsD.cs +++ b/PerMgr/Tnb.PerMgr.Entities/Entity/PerProcessStandardsD.cs @@ -18,6 +18,11 @@ public partial class PerProcessStandardsD : BaseEntity /// 工艺标准主表id /// public string process_standards_id { get; set; } = string.Empty; + + /// + /// 工艺参数类型id + /// + public string process_param_type_id { get; set; } = string.Empty; /// /// 工艺参数id @@ -38,5 +43,10 @@ public partial class PerProcessStandardsD : BaseEntity /// 下限 /// public decimal? lower_value { get; set; } + + /// + /// 数据采集id + /// + public string? daq_id { get; set; } } \ No newline at end of file diff --git a/PerMgr/Tnb.PerMgr.Interfaces/IPerProcessStandardsService.cs b/PerMgr/Tnb.PerMgr.Interfaces/IPerProcessStandardsService.cs index 6014b32c..aca8bcf1 100644 --- a/PerMgr/Tnb.PerMgr.Interfaces/IPerProcessStandardsService.cs +++ b/PerMgr/Tnb.PerMgr.Interfaces/IPerProcessStandardsService.cs @@ -1,3 +1,4 @@ +using JNPF.Common.Models; using Microsoft.AspNetCore.Mvc; namespace Tnb.PerMgr.Interfaces @@ -9,5 +10,12 @@ namespace Tnb.PerMgr.Interfaces /// /// public Task ExportTemplate(); + + + /// + /// 导入 + /// + /// + public Task Import(string id,ChunkModel input); } } \ No newline at end of file diff --git a/PerMgr/Tnb.PerMgr/PerProcessParamTypeService.cs b/PerMgr/Tnb.PerMgr/PerProcessParamTypeService.cs index efcc1955..bd9a1651 100644 --- a/PerMgr/Tnb.PerMgr/PerProcessParamTypeService.cs +++ b/PerMgr/Tnb.PerMgr/PerProcessParamTypeService.cs @@ -45,6 +45,11 @@ namespace Tnb.PerMgr { tab_id = x.id, tab_name = x.name, + daq_list = SqlFunc.Subqueryable().Where(a=>a.equip_id==equipId).ToList(a=>new ProcessParamTypeDaqListOutput + { + id = a.id, + label_name = a.label_name, + }), children = SqlFunc.Subqueryable() .LeftJoin((y,z)=>y.tolerance_category_id==z.id) .Where(y=>y.process_param_type_id==x.id) @@ -71,19 +76,67 @@ namespace Tnb.PerMgr { List list = new List(); + List insertIds = new List(); if (input != null && input.Count > 0) { foreach (var item in input) { - list.Add(new PerProcessStandardsD() + PerProcessStandardsD processStandardsD = await db.Queryable().Where(x => + x.process_param_id == item.process_param_id && x.process_standards_id == item.process_standards_id && + item.process_param_type_id == x.process_param_type_id).FirstAsync(); + + if (processStandardsD != null) { - process_standards_id = item.process_standards_id, - process_param_id = item.process_param_id, - value = item.value - }); + PerProcessStandardsH perProcessStandardsH = await db.Queryable().SingleAsync(x => x.id == processStandardsD.process_standards_id); + PerProcessParam processParam = await db.Queryable().SingleAsync(x => x.id == processStandardsD.process_param_id); + + if (processStandardsD.value != item.value) + { + PerProcessParamEditRecord record = new PerProcessParamEditRecord + { + process_param_id = item.process_param_id, + old_value = processStandardsD.value, + new_value = item.value, + modify_id = _userManager.UserId, + modify_time = DateTime.Now, + org_id = _userManager.GetUserInfo().Result.organizeId, + equip_id = perProcessStandardsH.equip_id, + process_param_name = processParam.name + }; + db.Insertable(record).ExecuteCommandAsync(); + } + + } + + if (string.IsNullOrEmpty(item.id)) + { + PerProcessStandardsD insertObj = new PerProcessStandardsD() + { + value = item.value, + process_param_id = item.process_param_id, + process_standards_id = item.process_standards_id, + process_param_type_id = item.process_param_type_id, + daq_id = item.daq_id, + }; + + insertIds.Add(insertObj.id); + await db.Insertable(insertObj).ExecuteCommandAsync(); + } + else + { + await db.Updateable() + .SetColumns(x=>x.value==item.value) + .SetColumns(x=>x.daq_id==item.daq_id) + .Where(x=>x.id==item.id).ExecuteCommandAsync(); + } + } - await db.Insertable(list).ExecuteCommandAsync(); + List notDeleteIds = input.Select(x => x.id).ToList(); + notDeleteIds.AddRange(insertIds); + await db.Deleteable().Where(x => !notDeleteIds.Contains(x.id)).ExecuteCommandAsync(); + + } }); @@ -108,6 +161,11 @@ namespace Tnb.PerMgr { tab_id = a.id, tab_name = a.name, + daq_list = SqlFunc.Subqueryable().Where(e=>e.equip_id==perProcessStandardsH.equip_id).ToList(e=>new ProcessParamTypeDaqListOutput + { + id = e.id, + label_name = e.label_name, + }), children = SqlFunc.Subqueryable() .LeftJoin((b,c)=>b.process_param_id==c.id) .LeftJoin((b,c,d)=>c.tolerance_category_id==d.id) @@ -120,7 +178,8 @@ namespace Tnb.PerMgr name = c.name, value = b.value, upper_value = d.upper_value, - lower_value = d.lower_value + lower_value = d.lower_value, + daq_id = b.daq_id }), }).ToListAsync(); diff --git a/PerMgr/Tnb.PerMgr/PerProcessStandardsService.cs b/PerMgr/Tnb.PerMgr/PerProcessStandardsService.cs index 72ea3b0d..43e5d881 100644 --- a/PerMgr/Tnb.PerMgr/PerProcessStandardsService.cs +++ b/PerMgr/Tnb.PerMgr/PerProcessStandardsService.cs @@ -1,7 +1,9 @@ +using System.Data; using JNPF; using JNPF.Common.Core.Manager; using JNPF.Common.Enums; using JNPF.Common.Helper; +using JNPF.Common.Models; using JNPF.Common.Security; using JNPF.DependencyInjection; using JNPF.DynamicApiController; @@ -9,6 +11,7 @@ using JNPF.FriendlyException; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; +using NPOI.HSSF.UserModel; using NPOI.SS.UserModel; using NPOI.SS.Util; using NPOI.XSSF.UserModel; @@ -90,5 +93,161 @@ namespace Tnb.PerMgr } } + + [HttpPost] + public async Task Import([FromForm]string id, [FromForm]ChunkModel input) + { + int rowIndex = 1; + bool flag = false; + try + { + using (Stream stream = input.file.OpenReadStream()) + { + IWorkbook workbook = null; + // 2007版本 + if (input.fileName.IndexOf(".xlsx") > 0) + workbook = new XSSFWorkbook(stream); + else if (input.fileName.IndexOf(".xls") > 0) + workbook = new HSSFWorkbook(stream); + + ISheet sheet = workbook.GetSheetAt(0); + + if (sheet.LastRowNum <= 1) + throw Oops.Bah("无导入数据"); + + var db = _repository.AsSugarClient(); + List perProcessParamTypes = await db.Queryable().ToListAsync(); + List perProcessParams = await db.Queryable().ToListAsync(); + int errorColumnIndex = 5; + + ICellStyle style = workbook.CreateCellStyle(); + IFont font = workbook.CreateFont(); + font.Color = IndexedColors.Red.Index; // 将字体颜色设置为红色 + style.SetFont(font); + + List list = new List() { }; + for (rowIndex = 1; rowIndex < sheet.LastRowNum; rowIndex++) + { + IRow row = sheet.GetRow(rowIndex); + ICell cell0 = row.GetCell(0); + ICell cell1 = row.GetCell(1); + ICell cell2 = row.GetCell(2); + + PerProcessStandardsD item = new PerProcessStandardsD(); + PerProcessParamType perProcessParamType = perProcessParamTypes.FirstOrDefault(x => x.name == cell0.StringCellValue); + if (perProcessParamType != null) + { + item.process_param_type_id = perProcessParamType.id; + } + else + { + ICell errorCell = row.GetCell(errorColumnIndex) ?? row.CreateCell(errorColumnIndex); + errorCell.SetCellValue("无该工艺参数类型"); + errorCell.CellStyle = style; + flag = true; + } + + PerProcessParam perProcessParam = perProcessParams.FirstOrDefault(x => x.name == cell1.StringCellValue); + if (perProcessParam != null) + { + item.process_param_id = perProcessParam.id; + } + else + { + ICell errorCell = row.GetCell(errorColumnIndex) ?? row.CreateCell(errorColumnIndex); + errorCell.SetCellValue(errorCell.StringCellValue+",无该工艺参数"); + errorCell.CellStyle = style; + flag = true; + } + if (!TrySetNumberCellValue(cell2, ref item)) + { + ICell errorCell = row.GetCell(errorColumnIndex) ?? row.CreateCell(errorColumnIndex); + errorCell.SetCellValue(errorCell.StringCellValue+",设定值不是数字"); + errorCell.CellStyle = style; + flag = true; + } + else + { + list.Add(item); + } + } + + foreach (var item in list) + { + PerProcessStandardsD oldData = await _repository.AsSugarClient().Queryable() + .FirstAsync(x => + x.process_param_id == item.process_param_id && + x.process_param_type_id == item.process_param_type_id && x.process_standards_id == id); + if (oldData!=null) + { + if (oldData.value != item.value) + { + await _repository.AsSugarClient().Updateable() + .SetColumns(x => x.value == item.value).ExecuteCommandAsync(); + + PerProcessStandardsH perProcessStandardsH = await _repository.AsSugarClient().Queryable().SingleAsync(x => x.id == oldData.process_standards_id); + PerProcessParam processParam = await _repository.AsSugarClient().Queryable().SingleAsync(x => x.id == oldData.process_param_id); + + await _repository.AsSugarClient().Updateable() + .SetColumns(x=>x.value==item.value) + .Where(x=>x.id==oldData.id).ExecuteCommandAsync(); + + PerProcessParamEditRecord record = new PerProcessParamEditRecord + { + process_param_id = item.process_param_id, + old_value = oldData.value, + new_value = item.value, + modify_id = _userManager.UserId, + modify_time = DateTime.Now, + org_id = _userManager.GetUserInfo().Result.organizeId, + equip_id = perProcessStandardsH.equip_id, + process_param_name = processParam.name + }; + await _repository.AsSugarClient().Insertable(record).ExecuteCommandAsync(); + } + } + else + { + await _repository.AsSugarClient().Insertable(item).ExecuteCommandAsync(); + } + } + + + if (flag) + { + MemoryStream ms = new MemoryStream(); + + workbook.Write(ms); + MemoryStream ms2 = new MemoryStream(ms.ToArray()); + ms2.Position = 0; + FileStreamResult fileStreamResult = new FileStreamResult(ms2, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet") { FileDownloadName = "导入报错说明.xlsx" }; + return fileStreamResult; + } + else + { + return new JsonResult("导入成功"); + } + } + } + catch (Exception e) + { + throw Oops.Bah("导入失败"); + } + + } + + + private bool TrySetNumberCellValue(ICell cell,ref PerProcessStandardsD item) + { + try + { + item.value = cell.CellType == CellType.Numeric ? (decimal)cell.NumericCellValue : cell.CellType == CellType.String ? Convert.ToDecimal(cell.StringCellValue) : 0; + return true; + } + catch (Exception e) + { + return false; + } + } } } \ No newline at end of file From ac7646eecf01e5ac8f2e96d7d6043b1632d5b407 Mon Sep 17 00:00:00 2001 From: zhoukeda <1315948824@qq.com> Date: Fri, 9 Jun 2023 11:04:05 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E5=B7=A5=E8=89=BA=E6=A0=87=E5=87=86?= =?UTF-8?q?=E5=AF=BC=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../IPerProcessStandardsService.cs | 2 +- .../Tnb.PerMgr/PerProcessStandardsService.cs | 55 +++++++++++++++---- PerMgr/Tnb.PerMgr/Tnb.PerMgr.csproj | 1 + 3 files changed, 45 insertions(+), 13 deletions(-) diff --git a/PerMgr/Tnb.PerMgr.Interfaces/IPerProcessStandardsService.cs b/PerMgr/Tnb.PerMgr.Interfaces/IPerProcessStandardsService.cs index aca8bcf1..c3208c25 100644 --- a/PerMgr/Tnb.PerMgr.Interfaces/IPerProcessStandardsService.cs +++ b/PerMgr/Tnb.PerMgr.Interfaces/IPerProcessStandardsService.cs @@ -16,6 +16,6 @@ namespace Tnb.PerMgr.Interfaces /// 导入 /// /// - public Task Import(string id,ChunkModel input); + public Task> Import(string id,ChunkModel input); } } \ No newline at end of file diff --git a/PerMgr/Tnb.PerMgr/PerProcessStandardsService.cs b/PerMgr/Tnb.PerMgr/PerProcessStandardsService.cs index 43e5d881..d92d02c0 100644 --- a/PerMgr/Tnb.PerMgr/PerProcessStandardsService.cs +++ b/PerMgr/Tnb.PerMgr/PerProcessStandardsService.cs @@ -1,6 +1,8 @@ using System.Data; using JNPF; +using JNPF.Common.Configuration; using JNPF.Common.Core.Manager; +using JNPF.Common.Core.Manager.Files; using JNPF.Common.Enums; using JNPF.Common.Helper; using JNPF.Common.Models; @@ -8,6 +10,7 @@ using JNPF.Common.Security; using JNPF.DependencyInjection; using JNPF.DynamicApiController; using JNPF.FriendlyException; +using JNPF.Systems.Common; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; @@ -31,11 +34,18 @@ namespace Tnb.PerMgr { private readonly ISqlSugarRepository _repository; private readonly IUserManager _userManager; + private readonly FileManager _fileManager; + private readonly FileService _fileService; - public PerProcessStandardsService(ISqlSugarRepository repository, IUserManager userManager) + public PerProcessStandardsService(ISqlSugarRepository repository, + FileService fileService, + FileManager fileManager, + IUserManager userManager) { _userManager = userManager; _repository = repository; + _fileManager = fileManager; + _fileService = fileService; } [AllowAnonymous] @@ -95,15 +105,16 @@ namespace Tnb.PerMgr } [HttpPost] - public async Task Import([FromForm]string id, [FromForm]ChunkModel input) + public async Task> Import([FromForm]string id, [FromForm]ChunkModel input) { int rowIndex = 1; bool flag = false; + IWorkbook workbook = null; try { using (Stream stream = input.file.OpenReadStream()) { - IWorkbook workbook = null; + // 2007版本 if (input.fileName.IndexOf(".xlsx") > 0) workbook = new XSSFWorkbook(stream); @@ -134,6 +145,7 @@ namespace Tnb.PerMgr ICell cell2 = row.GetCell(2); PerProcessStandardsD item = new PerProcessStandardsD(); + item.process_standards_id = id; PerProcessParamType perProcessParamType = perProcessParamTypes.FirstOrDefault(x => x.name == cell0.StringCellValue); if (perProcessParamType != null) { @@ -142,7 +154,7 @@ namespace Tnb.PerMgr else { ICell errorCell = row.GetCell(errorColumnIndex) ?? row.CreateCell(errorColumnIndex); - errorCell.SetCellValue("无该工艺参数类型"); + errorCell.SetCellValue(",无该工艺参数类型"); errorCell.CellStyle = style; flag = true; } @@ -170,6 +182,12 @@ namespace Tnb.PerMgr { list.Add(item); } + + + if (row.GetCell(errorColumnIndex) != null) + { + row.GetCell(errorColumnIndex).SetCellValue(row.GetCell(errorColumnIndex).StringCellValue.Substring(1)); + } } foreach (var item in list) @@ -182,8 +200,6 @@ namespace Tnb.PerMgr { if (oldData.value != item.value) { - await _repository.AsSugarClient().Updateable() - .SetColumns(x => x.value == item.value).ExecuteCommandAsync(); PerProcessStandardsH perProcessStandardsH = await _repository.AsSugarClient().Queryable().SingleAsync(x => x.id == oldData.process_standards_id); PerProcessParam processParam = await _repository.AsSugarClient().Queryable().SingleAsync(x => x.id == oldData.process_param_id); @@ -212,28 +228,43 @@ namespace Tnb.PerMgr } } - if (flag) { MemoryStream ms = new MemoryStream(); - + workbook.Write(ms); MemoryStream ms2 = new MemoryStream(ms.ToArray()); ms2.Position = 0; - FileStreamResult fileStreamResult = new FileStreamResult(ms2, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet") { FileDownloadName = "导入报错说明.xlsx" }; - return fileStreamResult; + // FileStreamResult fileStreamResult = new FileStreamResult(ms2, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet") { FileDownloadName = "导入报错说明.xlsx" }; + // return fileStreamResult; + string fileName = $"工艺标准导入报错{DateTime.Now.Ticks}.xlsx"; + await _fileManager.UploadFileByType(ms2, FileVariable.TemporaryFilePath, fileName); + return new Dictionary() + { + ["isSuccess"] = "false", + ["msg"] = "部分数据导入失败", + ["fileName"] = fileName, + }; } else { - return new JsonResult("导入成功"); + return new Dictionary() + { + ["isSuccess"] = "true", + ["msg"] = "导入成功", + }; } + } } catch (Exception e) - { + { + Console.WriteLine(e.Message); + JNPF.Logging.Log.Error("工艺标准导入失败", e); throw Oops.Bah("导入失败"); } + } diff --git a/PerMgr/Tnb.PerMgr/Tnb.PerMgr.csproj b/PerMgr/Tnb.PerMgr/Tnb.PerMgr.csproj index ddd2d646..70b75e15 100644 --- a/PerMgr/Tnb.PerMgr/Tnb.PerMgr.csproj +++ b/PerMgr/Tnb.PerMgr/Tnb.PerMgr.csproj @@ -8,6 +8,7 @@ + From 1f751886685d175896dc60feca1b8e27b13109fd Mon Sep 17 00:00:00 2001 From: zhoukeda <1315948824@qq.com> Date: Fri, 9 Jun 2023 11:22:40 +0800 Subject: [PATCH 3/5] bug --- PerMgr/Tnb.PerMgr/PerProcessStandardsService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PerMgr/Tnb.PerMgr/PerProcessStandardsService.cs b/PerMgr/Tnb.PerMgr/PerProcessStandardsService.cs index d92d02c0..4c6ea01f 100644 --- a/PerMgr/Tnb.PerMgr/PerProcessStandardsService.cs +++ b/PerMgr/Tnb.PerMgr/PerProcessStandardsService.cs @@ -137,7 +137,7 @@ namespace Tnb.PerMgr style.SetFont(font); List list = new List() { }; - for (rowIndex = 1; rowIndex < sheet.LastRowNum; rowIndex++) + for (rowIndex = 1; rowIndex <= sheet.LastRowNum; rowIndex++) { IRow row = sheet.GetRow(rowIndex); ICell cell0 = row.GetCell(0); 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 4/5] =?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) From 66b8eb1ac388d70c743d0c95b97f13d190769339 Mon Sep 17 00:00:00 2001 From: qianjiawei <1184704771@qq.com> Date: Mon, 12 Jun 2023 15:01:37 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E8=B4=A8=E6=A3=80=E6=96=B9=E6=A1=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- QcMgr/Tnb.QcMgr.Entities/Dto/Trigger.cs | 10 ++++++- .../IQcCheckPlanService.cs | 8 ++++++ QcMgr/Tnb.QcMgr/QcCheckPlanService.cs | 28 +++++++++++++++++++ 3 files changed, 45 insertions(+), 1 deletion(-) diff --git a/QcMgr/Tnb.QcMgr.Entities/Dto/Trigger.cs b/QcMgr/Tnb.QcMgr.Entities/Dto/Trigger.cs index c8f54684..00f73cb9 100644 --- a/QcMgr/Tnb.QcMgr.Entities/Dto/Trigger.cs +++ b/QcMgr/Tnb.QcMgr.Entities/Dto/Trigger.cs @@ -3,10 +3,18 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using NPOI.SS.Formula.PTG; namespace Tnb.QcMgr.Entities.Dto { - public class Trigger + public class TriggerPlan { + public string id { get; set; } + public string name { get; set; } + public string code { get; set; } + public string type { get; set; } + public string cycle { get; set; } + public string[] trievent { get; set; } + public string[] trieventid { get; set; } } } diff --git a/QcMgr/Tnb.QcMgr.Interfaces/IQcCheckPlanService.cs b/QcMgr/Tnb.QcMgr.Interfaces/IQcCheckPlanService.cs index bff66934..14102ccc 100644 --- a/QcMgr/Tnb.QcMgr.Interfaces/IQcCheckPlanService.cs +++ b/QcMgr/Tnb.QcMgr.Interfaces/IQcCheckPlanService.cs @@ -23,5 +23,13 @@ namespace Tnb.QcMgr.Interfaces /// /// public Task GetCheckItems(string id); + + /// + /// 获取触发计划清单 + /// + /// + /// + public Task GetTriggerPlans(); + } } diff --git a/QcMgr/Tnb.QcMgr/QcCheckPlanService.cs b/QcMgr/Tnb.QcMgr/QcCheckPlanService.cs index e5fe01aa..1332a3ef 100644 --- a/QcMgr/Tnb.QcMgr/QcCheckPlanService.cs +++ b/QcMgr/Tnb.QcMgr/QcCheckPlanService.cs @@ -1,4 +1,5 @@ using System; +using System.ArrayExtensions; using System.Collections.Generic; using System.Linq; using System.Reflection; @@ -108,6 +109,33 @@ namespace Tnb.QcMgr return CheckPlansOut; } + /// + /// 获取触发计划清单 + /// + /// + /// + [HttpPost] + public async Task GetTriggerPlans() + { + var db = _repository.AsSugarClient(); + var QcTriggerPlans = await db.Queryable().ToListAsync(); + var QcTriggerEvents = await db.Queryable().ToListAsync(); + List TriggerPlans = new List(); + foreach (var triggerPlan in QcTriggerPlans) + { + TriggerPlan TriggerPlan = new TriggerPlan(); + TriggerPlan.id = triggerPlan.id; + TriggerPlan.name = triggerPlan.name!; + 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(); + TriggerPlans.Add(TriggerPlan); + } + return TriggerPlans; + } + /// /// 保存质检方案质检项和附加信息 ///