From cf7c43230d3dc170d3d16557c07983a4f92976bf Mon Sep 17 00:00:00 2001 From: "DEVICE8\\12494" Date: Mon, 29 May 2023 12:07:48 +0800 Subject: [PATCH] 1 --- .../Consts/DictConst.cs | 8 +-- .../Dto/MoldMaintainPlanRunQueryOutput.cs | 72 +++++++++++++++++++ .../Dto/MoldMaintainRunUpInput.cs | 8 +++ .../Entity/ToolMoldMaintainItem.cs | 4 ++ .../ToolMoldMaintainRuleService.cs | 2 +- .../ToolMoldMaintainRunService.cs | 42 +++++++---- .../Tnb.ProductionMgr/PrdMoTaskService.cs | 35 +++++++-- 7 files changed, 147 insertions(+), 24 deletions(-) create mode 100644 EquipMgr/Tnb.EquipMgr.Entities/Dto/MoldMaintainPlanRunQueryOutput.cs diff --git a/BasicData/Tnb.BasicData.Entities/Consts/DictConst.cs b/BasicData/Tnb.BasicData.Entities/Consts/DictConst.cs index f110eb49..eecc7bef 100644 --- a/BasicData/Tnb.BasicData.Entities/Consts/DictConst.cs +++ b/BasicData/Tnb.BasicData.Entities/Consts/DictConst.cs @@ -90,10 +90,6 @@ public static class DictConst /// 模具保养状态-待保养编码 /// public const string MoldMaintainStatusDBYCode = "UnMaintain"; - /// - /// 模具保养状态TypeId - /// - public const string MoldMaintainStatusTypeId = "26171564065301"; @@ -114,6 +110,10 @@ public static class DictConst /// public const string MaintainStatusTypeId = "26171564065301"; /// + /// 模具保养状态TypeId + /// + public const string MoldMaintainStatusTypeId = "26149299883285"; + /// /// 保养状态待保养Code /// public const string UnMaintainStatusCode = "UnMaintain"; diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Dto/MoldMaintainPlanRunQueryOutput.cs b/EquipMgr/Tnb.EquipMgr.Entities/Dto/MoldMaintainPlanRunQueryOutput.cs new file mode 100644 index 00000000..5a80c60a --- /dev/null +++ b/EquipMgr/Tnb.EquipMgr.Entities/Dto/MoldMaintainPlanRunQueryOutput.cs @@ -0,0 +1,72 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tnb.EquipMgr.Entities.Dto +{ + /// + /// 模具保养计划执行查询输出参数 + /// + public class MoldMaintainPlanRunQueryOutput + { + /// + /// 保养开始时间 + /// + public string? start_time { get; set; } + /// + /// 模具编码 + /// + public string mold_code { get; set; } + /// + /// 模具名称 + /// + public string mold_name { get; set; } + /// + /// 保养完成打磨次 + /// + public int? maintain_qty { get; set; } + /// + /// 模具状态 + /// + public string mold_status { get; set; } + /// + /// 设备编码 + /// + public string eqp_code { get; set; } + /// + /// 设备名称 + /// + public string eqp_name { get; set; } + /// + /// 保养人 + /// + public string operator_name { get; set; } + /// + /// 保养项信息 + /// + public List check_items { get; set; } + + } + + public class CheckItemInfo + { + /// + /// 项目组id + /// + public string item_group_id { get; set; } + /// + /// 项目组名称 + /// + public string item_group_name { get; set; } + /// + /// 保养项id + /// + public string item_id { get; set; } + /// + /// 保养项名称 + /// + public string item_name { get; set; } + } +} diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Dto/MoldMaintainRunUpInput.cs b/EquipMgr/Tnb.EquipMgr.Entities/Dto/MoldMaintainRunUpInput.cs index 7861402d..99baa593 100644 --- a/EquipMgr/Tnb.EquipMgr.Entities/Dto/MoldMaintainRunUpInput.cs +++ b/EquipMgr/Tnb.EquipMgr.Entities/Dto/MoldMaintainRunUpInput.cs @@ -15,5 +15,13 @@ namespace Tnb.EquipMgr.Entities.Dto /// 执行计划id /// public string plan_id { get; set; } + /// + /// 保养项Ids + /// + public ListitemIds { get; set; } + /// + /// 保养项状态 0,未完成 1,已完成 + /// + public int? status { get; set; } } } diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Entity/ToolMoldMaintainItem.cs b/EquipMgr/Tnb.EquipMgr.Entities/Entity/ToolMoldMaintainItem.cs index a661a5ec..b4d9e4e4 100644 --- a/EquipMgr/Tnb.EquipMgr.Entities/Entity/ToolMoldMaintainItem.cs +++ b/EquipMgr/Tnb.EquipMgr.Entities/Entity/ToolMoldMaintainItem.cs @@ -63,5 +63,9 @@ public partial class ToolMoldMaintainItem : BaseEntity /// 修改时间 /// public DateTime? modify_time { get; set; } + /// + /// 保养项完成状态 0,未完成,1,已完成 + /// + public int? status { get; set; } } diff --git a/EquipMgr/Tnb.EquipMgr/ToolMoldMaintainRuleService.cs b/EquipMgr/Tnb.EquipMgr/ToolMoldMaintainRuleService.cs index 54165647..b0923bc0 100644 --- a/EquipMgr/Tnb.EquipMgr/ToolMoldMaintainRuleService.cs +++ b/EquipMgr/Tnb.EquipMgr/ToolMoldMaintainRuleService.cs @@ -142,7 +142,7 @@ namespace Tnb.EquipMgr var maintainRules = await _db.Queryable().Where(it => input.ruleIds.Contains(it.id)).ToListAsync(); var ruleMoldRelations = await _db.Queryable().Where(it=>input.ruleIds.Contains(it.rule_id)).ToListAsync(); - if (maintainRules?.Count > 0) + if (ruleMoldRelations?.Count > 0) { List maintainPlans = new(); List maintainPlanRelations = new(); diff --git a/EquipMgr/Tnb.EquipMgr/ToolMoldMaintainRunService.cs b/EquipMgr/Tnb.EquipMgr/ToolMoldMaintainRunService.cs index a172f95c..8918748b 100644 --- a/EquipMgr/Tnb.EquipMgr/ToolMoldMaintainRunService.cs +++ b/EquipMgr/Tnb.EquipMgr/ToolMoldMaintainRunService.cs @@ -21,6 +21,9 @@ using Tnb.EquipMgr.Interfaces; namespace Tnb.EquipMgr { + /// + /// 模具维修任务执行 + /// [ApiDescriptionSettings(Tag = ModuleConsts.Tag, Area = ModuleConsts.Area, Order = 700)] [Route("api/[area]/[controller]/[action]")] @@ -55,6 +58,8 @@ namespace Tnb.EquipMgr { info.mold_code = mold.mold_code; info.mold_name = mold.mold_name; + info.mold_status = (await _dictionaryDataService.GetInfo(mold.mold_status))?.FullName; + info.maintain_qty = mold.maintain_qty; var moldEqpRelation = await _db.Queryable().FirstAsync(it => it.mold_id == mold.id); if (moldEqpRelation != null) { @@ -65,19 +70,22 @@ namespace Tnb.EquipMgr var itemGroupRelation = await _db.Queryable().FirstAsync(it => it.mold_id == mold.id); if (itemGroupRelation != null) { - var itemGroup = await _db.Queryable().FirstAsync(it => it.id == itemGroupRelation.item_group_id); - if (itemGroup != null) + var checkItems = await _db.Queryable((a, b, c) => new JoinQueryInfos + ( + JoinType.Left, a.id == b.item_group_id, + JoinType.Left, b.item_id == c.id + )) + .Where(a => a.id == itemGroupRelation.item_group_id) + .Select((a, b, c) => new + { + item_group_id = a.id, + item_group_name = a.name, + item_id = c.id, + item_name = c.name, + }).ToListAsync(); + if (checkItems?.Count > 0) { - info.item_group_name = itemGroup.name; - } - var itemRelation = await _db.Queryable().FirstAsync(it => it.item_group_id == itemGroupRelation.item_group_id); - if (itemRelation != null) - { - var checkItem = await _db.Queryable().FirstAsync(it => it.id == itemRelation.item_id); - if (checkItem != null) - { - info.item_name = checkItem.name; - } + info.check_items = checkItems; } } } @@ -148,6 +156,14 @@ namespace Tnb.EquipMgr } } + + public async Task MaintainItemFinish(MoldMaintainRunUpInput input) + { + if (input == null) throw new ArgumentNullException("input"); + if (input.itemIds == null || input.itemIds.Count == 0) throw new ArgumentException($"parameter {nameof(input.itemIds)} not be null or empty"); + var row = await _db.Updateable().SetColumns(it => new ToolMoldMaintainItem { status = input.status }).Where(it => input.itemIds.Contains(it.id)).ExecuteCommandAsync(); + if (row < 1) throw Oops.Oh(ErrorCode.COM1001); + } /// /// 模具保养计划执行-保养完成 /// @@ -156,7 +172,9 @@ namespace Tnb.EquipMgr [HttpPost] public async Task MaintainFinish(MoldMaintainRunUpInput input) { + if (input == null) throw new ArgumentNullException("input"); } + } } diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs index 34116c7c..bf27e4ff 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs @@ -804,8 +804,8 @@ namespace Tnb.ProductionMgr { throw new ArgumentException($"{nameof(input.Behavior)} not be null or empty"); } - var taskList = await _db.Queryable().Where(it => input.TaskIds.Contains(it.id) && it.mo_task_status == DictConst.ToBeScheduledEncode).ToListAsync(); - if (taskList?.Count > 0) + //var taskList = await _db.Queryable().Where(it => input.TaskIds.Contains(it.id) && it.mo_task_status == DictConst.ToBeScheduledEncode).ToListAsync(); + //if (taskList?.Count > 0) { string SetTaskStatus(PrdTaskBehavior behavior) => behavior switch { @@ -912,7 +912,10 @@ namespace Tnb.ProductionMgr } } } - row = await db.Insertable(taskLogEntities).ExecuteCommandAsync(); + if (taskLogEntities?.Count > 0) + { + row = await db.Insertable(taskLogEntities).ExecuteCommandAsync(); + } List prdReportLogs = new(); List prdTaskDefectLogs = new(); @@ -924,6 +927,7 @@ namespace Tnb.ProductionMgr var material = (await db.Queryable().FirstAsync(it => it.id == taskInfo.material_id)); var mo = await db.Queryable().FirstAsync(it => it.id == taskInfo.mo_id); var record = taskInfo.Adapt(); + record.id = SnowflakeIdHelper.NextId(); record.masterial_code = material?.code; record.masterial_name = material?.name; record.plan_start_date = taskInfo.estimated_start_date; @@ -938,6 +942,7 @@ namespace Tnb.ProductionMgr //组装自检报废对象 var sacipRecord = new PrdMoTaskDefectRecord(); + sacipRecord.id = SnowflakeIdHelper.NextId(); sacipRecord.material_code = material?.code!; sacipRecord.material_name = material?.name!; sacipRecord.eqp_code = (await db.Queryable().FirstAsync(it => it.id == taskInfo.eqp_id))?.code!; @@ -956,12 +961,28 @@ namespace Tnb.ProductionMgr prdTaskDefectLogs.Add(sacipRecord); } } - row = await db.Insertable(prdReportLogs).ExecuteCommandAsync(); - row = await db.Insertable(prdTaskDefectLogs).ExecuteCommandAsync(); + var reportTaskIds = prdReportLogs.Select(it => it.mo_task_id).ToList(); + if (reportTaskIds?.Count > 0) + { + var items = await db.Queryable().Where(it => reportTaskIds.Contains(it.mo_task_id)).ToListAsync(); + if (items == null || items.Count < 1) + { + row = await db.Insertable(prdReportLogs).ExecuteCommandAsync(); + } + } + var defectTaskIds = prdTaskDefectLogs.Select(it => it.mo_task_id).ToList(); + if (defectTaskIds?.Count > 0) + { + var items = await db.Queryable().Where(it => defectTaskIds.Contains(it.mo_task_id)).ToListAsync(); + if (items == null || items.Count < 1) + { + row = await db.Insertable(prdTaskDefectLogs).ExecuteCommandAsync(); + } + } } } - else - throw new AppFriendlyException("只有待下发状态的任务才可下发", 500); + //else + // throw new AppFriendlyException("只有待下发状态的任务才可下发", 500); return (row > 0); }