From 600cd6d9001e62dec9c427cbbe07066c068032a6 Mon Sep 17 00:00:00 2001 From: "DEVICE8\\12494" Date: Wed, 31 May 2023 10:34:59 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E6=A8=A1=E5=85=B7=E4=BF=9D=E5=85=BB?= =?UTF-8?q?=E6=89=A7=E8=A1=8C=E4=B8=9A=E5=8A=A1=E4=BB=A3=E7=A0=81=E8=B0=83?= =?UTF-8?q?=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Consts/MoldUseStatus.cs | 6 +- .../Entity/ToolMoldMaintainItem.cs | 6 +- .../Entity/ToolMoldMaintainItemRecord.cs | 46 +++++ .../Entity/ToolMoldMaintainRunRecord.cs | 30 +-- .../Entity/ToolMoldMaintainRunRecordD.cs | 42 +++++ .../Tnb.EquipMgr.Entities/Entity/ToolMolds.cs | 4 + .../ToolMoldMaintainGroupService.cs | 100 +++++++++- .../ToolMoldMaintainRunService.cs | 173 +++++++++++------- 8 files changed, 314 insertions(+), 93 deletions(-) create mode 100644 EquipMgr/Tnb.EquipMgr.Entities/Entity/ToolMoldMaintainItemRecord.cs create mode 100644 EquipMgr/Tnb.EquipMgr.Entities/Entity/ToolMoldMaintainRunRecordD.cs diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Consts/MoldUseStatus.cs b/EquipMgr/Tnb.EquipMgr.Entities/Consts/MoldUseStatus.cs index db9570c7..a27c20bf 100644 --- a/EquipMgr/Tnb.EquipMgr.Entities/Consts/MoldUseStatus.cs +++ b/EquipMgr/Tnb.EquipMgr.Entities/Consts/MoldUseStatus.cs @@ -11,6 +11,10 @@ namespace Tnb.EquipMgr.Entities.Consts /// /// 模具使用状态在库状态ID /// - public const string MOLDUSESTATUSZKID = "26149307089941"; + public const string MOLD_USE_STATUS_ZK_ID = "26149307089941"; + /// + /// 模具使用状态-保养Id + /// + public const string MOLD_USE_STATUS_MAINTAIN_ID = "26149311082005"; } } diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Entity/ToolMoldMaintainItem.cs b/EquipMgr/Tnb.EquipMgr.Entities/Entity/ToolMoldMaintainItem.cs index b4d9e4e4..a6aa168a 100644 --- a/EquipMgr/Tnb.EquipMgr.Entities/Entity/ToolMoldMaintainItem.cs +++ b/EquipMgr/Tnb.EquipMgr.Entities/Entity/ToolMoldMaintainItem.cs @@ -66,6 +66,10 @@ public partial class ToolMoldMaintainItem : BaseEntity /// /// 保养项完成状态 0,未完成,1,已完成 /// - public int? status { get; set; } + public int status { get; set; } = 0; + /// + /// 模具id + /// + public string mold_id { get; set; } } diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Entity/ToolMoldMaintainItemRecord.cs b/EquipMgr/Tnb.EquipMgr.Entities/Entity/ToolMoldMaintainItemRecord.cs new file mode 100644 index 00000000..34f90a71 --- /dev/null +++ b/EquipMgr/Tnb.EquipMgr.Entities/Entity/ToolMoldMaintainItemRecord.cs @@ -0,0 +1,46 @@ +using JNPF.Common.Contracts; +using JNPF.Common.Security; +using SqlSugar; + +namespace Tnb.EquipMgr.Entities; + +/// +/// 模具保养 +/// +[SugarTable("tool_mold_maintain_item_record")] +public partial class ToolMoldMaintainItemRecord : BaseEntity +{ + public ToolMoldMaintainItemRecord() + { + id = SnowflakeIdHelper.NextId(); + } + /// + /// 保养项 保养状态 0 未完成,1 已完成 + /// + public int status { get; set; } + + /// + /// 保养组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; } + /// + /// 模具ID + /// + public string mold_id { get; set; } + +} diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Entity/ToolMoldMaintainRunRecord.cs b/EquipMgr/Tnb.EquipMgr.Entities/Entity/ToolMoldMaintainRunRecord.cs index 6f2679d2..4f4b51bf 100644 --- a/EquipMgr/Tnb.EquipMgr.Entities/Entity/ToolMoldMaintainRunRecord.cs +++ b/EquipMgr/Tnb.EquipMgr.Entities/Entity/ToolMoldMaintainRunRecord.cs @@ -59,26 +59,6 @@ public partial class ToolMoldMaintainRunRecord : BaseEntity /// public string? eqp_name { get; set; } - /// - /// 保养组编码 - /// - public string? group_code { get; set; } - - /// - /// 保养组名称 - /// - public string? group_name { get; set; } - - /// - /// 保养项编号 - /// - public string? check_item_code { get; set; } - - /// - /// 保养项名称 - /// - public string? check_item_name { get; set; } - /// /// 计划开始时间 /// @@ -94,4 +74,14 @@ public partial class ToolMoldMaintainRunRecord : BaseEntity /// public decimal? plan_time { get; set; } + /// + /// 维保人 + /// + public string? maintain_person { get; set; } + + /// + /// 异常记录 + /// + public string? exception_record { get; set; } + } diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Entity/ToolMoldMaintainRunRecordD.cs b/EquipMgr/Tnb.EquipMgr.Entities/Entity/ToolMoldMaintainRunRecordD.cs new file mode 100644 index 00000000..04a23a42 --- /dev/null +++ b/EquipMgr/Tnb.EquipMgr.Entities/Entity/ToolMoldMaintainRunRecordD.cs @@ -0,0 +1,42 @@ +using JNPF.Common.Contracts; +using JNPF.Common.Security; +using SqlSugar; + +namespace Tnb.EquipMgr.Entities; + +/// +/// 模具保养计划记录表子表 +/// +[SugarTable("tool_mold_maintain_run_record_d")] +public partial class ToolMoldMaintainRunRecordD : BaseEntity +{ + public ToolMoldMaintainRunRecordD() + { + id = SnowflakeIdHelper.NextId(); + } + /// + /// 模具编号 + /// + public string? mold_id { get; set; } + + /// + /// 保养组编码 + /// + public string? group_id { get; set; } + + /// + /// 保养组名称 + /// + public string? group_name { get; set; } + + /// + /// 保养项编号 + /// + public string? check_item_id { get; set; } + + /// + /// 保养项名称 + /// + public string? check_item_name { get; set; } + +} diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Entity/ToolMolds.cs b/EquipMgr/Tnb.EquipMgr.Entities/Entity/ToolMolds.cs index b0f50a5b..c93b2913 100644 --- a/EquipMgr/Tnb.EquipMgr.Entities/Entity/ToolMolds.cs +++ b/EquipMgr/Tnb.EquipMgr.Entities/Entity/ToolMolds.cs @@ -133,5 +133,9 @@ public partial class ToolMolds : BaseEntity /// 模具型号 /// public string? mold_type_code { get; set; } + /// + /// 关联保养项信息 + /// + public string item_json { get; set; } } diff --git a/EquipMgr/Tnb.EquipMgr/ToolMoldMaintainGroupService.cs b/EquipMgr/Tnb.EquipMgr/ToolMoldMaintainGroupService.cs index 20d67e21..4cfb0c2d 100644 --- a/EquipMgr/Tnb.EquipMgr/ToolMoldMaintainGroupService.cs +++ b/EquipMgr/Tnb.EquipMgr/ToolMoldMaintainGroupService.cs @@ -19,6 +19,8 @@ using JNPF.Common.Contracts; using Tnb.EquipMgr.Entities; using Tnb.EquipMgr.Entities.Dto; using Tnb.EquipMgr.Interfaces; +using Senparc.Weixin.MP.AdvancedAPIs.GroupMessage; +using Aop.Api.Domain; namespace Tnb.EquipMgr { @@ -79,8 +81,60 @@ namespace Tnb.EquipMgr /// /// [HttpPost] - public async Task RelevanceMaintianGroupAndItem(MoldMaintainGroupItemInput input) => - await Relevance(input, nameof(ToolMoldMaintainGroupItem.item_group_id), nameof(ToolMoldMaintainGroupItem.item_id), it => it.item_group_id == input.id); + public async Task RelevanceMaintianGroupAndItem(MoldMaintainGroupItemInput input) + { + try + { + await _db.Ado.BeginTranAsync(); + + if (input.ids == null || input.ids.Count == 0) throw new ArgumentException($"parameter {nameof(input.ids)} not be null or count not be zero"); + await Relevance(input, nameof(ToolMoldMaintainGroupItem.item_group_id), nameof(ToolMoldMaintainGroupItem.item_id), it => it.item_group_id == input.id); + List itemRecords = new(); + var grpIds = await _db.Queryable().Where(it => input.ids.Contains(it.item_id)).Select(it => it.item_group_id).Distinct().ToListAsync(); + if (grpIds?.Count > 0) + { + var grps = await _db.Queryable().Where(it => grpIds.Contains(it.id)).ToListAsync(); + foreach (var grp in grps) + { + var molds = await _db.Queryable().Where(it => it.item_group_id == grp.id).ToListAsync(); + if (molds?.Count > 0) + { + foreach (var mold in molds) + { + var dbItIds = await _db.Queryable().Where(it => it.mold_id == mold.id && it.item_group_id == grp.id && input.ids.Contains(it.id)).Select(it => it.item_id).ToListAsync(); + input.ids = input.ids.Except(dbItIds).ToList(); + if (input.ids?.Count > 0) + { + var items = await _db.Queryable().Where(it => input.ids.Contains(it.id)).ToListAsync(); + if (items?.Count > 0) + { + foreach (var item in items) + { + ToolMoldMaintainItemRecord record = new(); + record.mold_id = mold.id; + record.item_group_id = grp.id; + record.item_group_name = grp.name; + record.item_id = item.id; + record.item_name = item.name; + record.status = 0; + itemRecords.Add(record); + } + } + } + } + } + } + await _db.Insertable(itemRecords).ExecuteCommandAsync(); + } + + await _db.Ado.CommitTranAsync(); + } + catch (Exception ex) + { + await _db.Ado.RollbackTranAsync(); + throw; + } + } /// /// 关联项目组与模具 @@ -88,8 +142,45 @@ namespace Tnb.EquipMgr /// /// [HttpPost] - public async Task RelevanceMaintianGroupAndMold(MoldMaintainGroupItemRelationInput input) => + public async Task RelevanceMaintianGroupAndMold(MoldMaintainGroupItemRelationInput input) + { await Relevance(input, nameof(ToolMoldMaintainGroupRelation.item_group_id), nameof(ToolMoldMaintainGroupRelation.mold_id), it => it.item_group_id == input.id); + List itemRecords = new(); + foreach (var moldId in input.ids) + { + var grpIds = await _db.Queryable().Where(it => it.mold_id == moldId).Select(it => it.item_group_id).Distinct().ToListAsync(); + if (grpIds?.Count > 0) + { + var grps = await _db.Queryable().Where(it => grpIds.Contains(it.id)).ToListAsync(); + foreach (var grp in grps) + { + var itemIds = await _db.Queryable().Where(it => it.item_group_id == grp.id).Select(it => it.item_id).ToListAsync(); + if (itemIds?.Count > 0) + { + var dbItemIds = await _db.Queryable().Where(it => it.mold_id == moldId && it.item_group_id == grp.id && itemIds.Contains(it.item_id)).Select(it => it.item_id).ToListAsync(); + itemIds = itemIds.Except(dbItemIds).ToList(); + if (itemIds?.Count > 0) + { + var items = await _db.Queryable().Where(it => itemIds.Contains(it.id)).ToListAsync(); + foreach (var item in items) + { + ToolMoldMaintainItemRecord record = new(); + record.mold_id = moldId; + record.item_group_id = grp.id; + record.item_group_name = grp.name; + record.item_id = item.id; + record.item_name = item.name; + record.status = 0; + itemRecords.Add(record); + } + } + } + } + } + } + await _db.Insertable(itemRecords).ExecuteCommandAsync(); + + } /// /// 删除项目组与模具检查项信息 /// @@ -98,14 +189,15 @@ namespace Tnb.EquipMgr [HttpPost] public async Task Delete(MoldMaintainDelInput input) { - if (input.table_name == "item") { await Delete(it => it.item_group_id == input.id && input.ids.Contains(it.item_id)); + await Delete(it => it.item_group_id == input.id && input.ids.Contains(it.item_id)); } else { await Delete(it => it.item_group_id == input.id && input.ids.Contains(it.mold_id)); + await Delete(it => it.item_group_id == input.id && input.ids.Contains(it.mold_id)); } } diff --git a/EquipMgr/Tnb.EquipMgr/ToolMoldMaintainRunService.cs b/EquipMgr/Tnb.EquipMgr/ToolMoldMaintainRunService.cs index 970ce20d..ce87a030 100644 --- a/EquipMgr/Tnb.EquipMgr/ToolMoldMaintainRunService.cs +++ b/EquipMgr/Tnb.EquipMgr/ToolMoldMaintainRunService.cs @@ -5,6 +5,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using Aspose.Cells.Drawing; +using DingTalk.Api.Request; using JNPF.Common.Core.Manager; using JNPF.Common.Enums; using JNPF.Common.Extension; @@ -14,6 +15,7 @@ using JNPF.FriendlyException; using JNPF.Logging; using JNPF.Systems.Interfaces.System; using Microsoft.AspNetCore.Mvc; +using Newtonsoft.Json; using SqlSugar; using StackExchange.Profiling.Internal; using Tnb.BasicData; @@ -51,8 +53,8 @@ namespace Tnb.EquipMgr [HttpGet] public async Task GetMaintainInfoFromByPlanId([FromRoute] string planId) { - dynamic info = new ExpandoObject(); - var planMoldRelation = await _db.Queryable() + List result = new(); + var planMoldRelations = await _db.Queryable() .LeftJoin((a, b) => a.maintain_plan_id == b.id)//ToolMoldMaintainPlan .LeftJoin((a, b, c) => b.plan_code == c.plan_code) .Where(a => a.maintain_plan_id == planId) @@ -61,27 +63,35 @@ namespace Tnb.EquipMgr mold_id = a.mold_id, plan_start_time = c.plan_start_time, }) - .FirstAsync(); - if (planMoldRelation != null) + .ToListAsync(); + if (planMoldRelations?.Count > 0) { - var mold = await _db.Queryable().FirstAsync(it => it.id == planMoldRelation.mold_id); - if (mold != null) + var mids = planMoldRelations.Select(x => x.mold_id).ToList(); + var molds = await _db.Queryable().Where(it => mids.Contains(it.id)).ToListAsync(); + if (molds?.Count > 0) { - 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; - info.plan_start_time = planMoldRelation.plan_start_time; - var moldEqpRelation = await _db.Queryable().FirstAsync(it => it.mold_id == mold.id); - if (moldEqpRelation != null) + for (int i = 0, cnt = molds.Count; i < cnt; i++) { - var eqp = await _db.Queryable().FirstAsync(it => it.id == moldEqpRelation.equipment_id); - info.eqp_code = eqp.code; - info.eqp_name = eqp.name; + var mold = molds[i]; + dynamic info = new ExpandoObject(); + info.mold_id = mold.id; + 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; + info.plan_start_time = planMoldRelations[i].plan_start_time; + var moldEqpRelation = await _db.Queryable().FirstAsync(it => it.mold_id == mold.id); + if (moldEqpRelation != null) + { + var eqp = await _db.Queryable().FirstAsync(it => it.id == moldEqpRelation.equipment_id); + info.eqp_code = eqp.code; + info.eqp_name = eqp.name; + } + result.Add(info); } } } - return info; + return result; } /// /// 根据模具ID获取,保养组及项目信息 @@ -92,23 +102,32 @@ namespace Tnb.EquipMgr public async Task GetCheckItemAndGrpByMoldId([FromRoute] string moldId) { if (moldId.IsNullOrEmpty()) throw new ArgumentException($"parameter {nameof(moldId)} not be null or empty"); - - var itemGroupRelation = await _db.Queryable().FirstAsync(it => it.mold_id == moldId); - if (itemGroupRelation != 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(); + + var checkItems = await _db.Queryable().Where(it => it.mold_id == moldId).Select(it => new + { + item_group_id = it.item_group_id, + item_group_name = it.item_group_name, + item_id = it.item_id, + item_name = it.item_name, + status = it.status, + }).ToListAsync(); + + //var checkItems = await _db.Queryable((a, b, c, d) => new JoinQueryInfos + // ( + // JoinType.Inner, a.item_group_id == b.id, + // JoinType.Inner, b.id == c.item_group_id, + // JoinType.Inner, c.item_id == d.id + // )) + // .Where(a => a.mold_id == moldId) + // .Select((a, b, c, d) => new + // { + // item_group_id = b.id, + // item_group_name = b.name, + // item_id = d.id, + // item_name = d.name, + // status = d.status, + // }).ToListAsync(); return checkItems; } return Enumerable.Empty(); @@ -127,48 +146,67 @@ namespace Tnb.EquipMgr [HttpPost] public async Task MaintainStart(MoldMaintainRunUpInput input) { + if (input == null) throw new ArgumentNullException("input"); try { await _db.Ado.BeginTranAsync(); var dic = await _dictionaryDataService.GetDicByTypeId(DictConst.MaintainStatusTypeId); - var plan = await _db.Queryable().FirstAsync(it => it.id == input.plan_id); - if (plan != null) + var mold = await _db.Queryable().FirstAsync(it => it.id == input.mold_id); + if (mold != null) { - plan.status = DictConst.MoldMaintainStatusDBYCode; - var row = await _db.Updateable(plan).ExecuteCommandAsync(); - if (row < 1) throw Oops.Oh(ErrorCode.COM1001); - ToolMoldMaintainRunRecord record = new(); - record.plan_code = plan.plan_code; - record.mode = plan.mode; - record.plan_status = dic.ContainsKey(plan.plan_code) ? dic[plan.plan_code].ToString() : ""; - record.designer = _userManager.RealName; - record.designer_time = DateTime.Now; - var moldPlanRelation = await _db.Queryable().FirstAsync(it => it.maintain_plan_id == input.plan_id); - if (moldPlanRelation != null) + mold.mold_status = MoldUseStatus.MOLD_USE_STATUS_MAINTAIN_ID; + var isOk = await _db.Updateable(mold).Where(it => it.id == input.mold_id).ExecuteCommandHasChangeAsync(); + if (!isOk) throw Oops.Oh(ErrorCode.COM1001); + var plan = await _db.Queryable().LeftJoin((a, b) => a.maintain_plan_id == b.id) + .Where(a => a.mold_id == input.mold_id).Select((a, b) => b).FirstAsync(); + + if (plan is not null) { - var mold = await _db.Queryable().FirstAsync(it => it.id == moldPlanRelation.mold_id); - record.mold_code = mold?.mold_code; - record.mold_name = mold?.mold_name; - var moldGroupRelation = await _db.Queryable().FirstAsync(it => it.mold_id == mold.id); - if (moldGroupRelation != null) - { - var maintainGroup = await _db.Queryable().FirstAsync(it => it.id == moldGroupRelation.item_group_id); - record.group_name = maintainGroup.name; - var itemGrpRelation = await _db.Queryable().FirstAsync(it => it.item_group_id == maintainGroup.id); - if (itemGrpRelation != null) + //插入保养计划记录 + ToolMoldMaintainRunRecord record = new(); + record.plan_code = plan.plan_code; + record.mode = plan.mode; + record.plan_status = dic.ContainsKey(plan.plan_code) ? dic[plan.plan_code].ToString() : ""; + record.designer = _userManager.RealName; + record.designer_time = DateTime.Now; + record.mold_code = mold.mold_code; + record.mold_name = mold.mold_name; + record.plan_start_time = DateTime.Now; + var row = await _db.Insertable(record).ExecuteCommandAsync(); + if (row < 1) throw Oops.Oh(ErrorCode.COM1001); + + var maintainInfos = await _db.Queryable() + .LeftJoin((a, b) => a.item_group_id == b.id) + .LeftJoin((a, b, c) => b.id == c.item_group_id) + .LeftJoin((a, b, c, d) => c.item_id == d.id) + .Where(a => a.mold_id == input.mold_id) + .Select((a, b, c, d) => new { - var checkItem = await _db.Queryable().FirstAsync(it => it.id == itemGrpRelation.item_id); - record.check_item_name = checkItem.name; + group_id = b.id, + group_name = b.name, + check_item_id = d.id, + check_item_name = d.name + }) + .ToListAsync(); + if (maintainInfos?.Count > 0) + { + List recordDs = new(); + foreach (var info in maintainInfos) + { + ToolMoldMaintainRunRecordD record_d = new(); + record_d.group_id = info.group_id; + record_d.group_name = info.group_name; + record_d.check_item_id = info.check_item_id; + record_d.check_item_name = info.check_item_name; + recordDs.Add(record_d); } + row = await _db.Insertable(recordDs).ExecuteCommandAsync(); + if (row < 1) throw Oops.Oh(ErrorCode.COM1001); } } - record.plan_start_time = DateTime.Now; - row = await _db.Insertable(record).ExecuteCommandAsync(); - if (row < 1) throw Oops.Oh(ErrorCode.COM1001); - - await _db.Ado.CommitTranAsync(); } + await _db.Ado.CommitTranAsync(); } catch (Exception ex) { @@ -183,9 +221,10 @@ namespace Tnb.EquipMgr { 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(); + var row = await _db.Updateable().SetColumns(it => new ToolMoldMaintainItemRecord { status = 1 }).Where(it => input.itemIds.Contains(it.id)).ExecuteCommandAsync(); if (row < 1) throw Oops.Oh(ErrorCode.COM1001); } + /// /// 模具保养计划执行-保养完成 /// @@ -204,18 +243,18 @@ namespace Tnb.EquipMgr var itemIds = await _db.Queryable().Where(it => grpIds.Contains(it.item_group_id)).Select(it => it.item_id).ToListAsync(); if (itemIds?.Count > 0) { - var items = await _db.Queryable().Where(it => itemIds.Contains(it.id) && it.status.HasValue && it.status.Value == 1).ToListAsync(); + var items = await _db.Queryable().Where(it => it.mold_id == input.mold_id && it.status == 1).ToListAsync(); if (items?.Count < itemIds.Count) { throw new AppFriendlyException("当前模具有未完成的保养项目", 500); } - var row = await _db.Updateable().SetColumns(it => new ToolMolds { mold_status = MoldUseStatus.MOLDUSESTATUSZKID }).Where(it => it.id == input.mold_id).ExecuteCommandAsync(); + var row = await _db.Updateable().SetColumns(it => new ToolMolds { mold_status = MoldUseStatus.MOLD_USE_STATUS_ZK_ID }).Where(it => it.id == input.mold_id).ExecuteCommandAsync(); if (row < 1) throw Oops.Oh(ErrorCode.COM1001); var allMoldStatus = await _db.Queryable().InnerJoin((a, b) => a.mold_id == b.id) .Where((a, b) => a.maintain_plan_id == input.plan_id) .Select((a, b) => b.mold_status) .ToListAsync(); - if (allMoldStatus?.Count > 0 && allMoldStatus.All(x => x == MoldUseStatus.MOLDUSESTATUSZKID)) + if (allMoldStatus?.Count > 0 && allMoldStatus.All(x => x == MoldUseStatus.MOLD_USE_STATUS_ZK_ID)) { row = await _db.Updateable().SetColumns(it => new ToolMoldMaintainPlan { status = MoldPlanMaintainStatus.MOLDPLAN_MAINTAIN_STATUS_COMPLETED_CODE }).Where(it => it.id == input.plan_id).ExecuteCommandAsync(); } From 38a62de63a174e8a78fd5452ee6475551512fc7c Mon Sep 17 00:00:00 2001 From: "DEVICE8\\12494" Date: Wed, 31 May 2023 14:34:31 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=AF=B9=E8=B1=A1?= =?UTF-8?q?=E6=B7=B1=E6=8B=B7=E8=B4=9D=E9=80=9A=E7=94=A8=E5=87=BD=E6=95=B0?= =?UTF-8?q?,=E6=96=B0=E5=A2=9Ewms=E8=BD=BD=E5=85=B7=E6=9B=B4=E6=8D=A2?= =?UTF-8?q?=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Dto/ExChangeCarryInput.cs | 24 +++ .../Entity/WmsCarryCode.cs | 4 +- .../Entity/WmsCarryD.cs | 4 +- .../Entity/WmsCarryH.cs | 17 ++- .../Entity/WmsCarryMat.cs | 4 +- .../Entity/WmsCarryReplaceCode.cs | 9 +- .../Entity/WmsCarryReplaceH.cs | 2 +- .../Enums/EnumCarryStatus.cs | 20 +++ .../Enums/EnumOutStatus.cs | 21 +++ .../Tnb.WarehouseMgr.Interfaces/Class1.cs | 7 - .../IWmsCarryEntity.cs | 13 ++ .../IWmsCarryService.cs | 17 +++ WarehouseMgr/Tnb.WarehouseMgr/Class1.cs | 7 - .../Tnb.WarehouseMgr/WmsCarryService.cs | 137 ++++++++++++++++++ common/Tnb.Common/Utils/DeepCopyHelper.cs | 76 ++++++++++ 15 files changed, 333 insertions(+), 29 deletions(-) create mode 100644 WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/ExChangeCarryInput.cs create mode 100644 WarehouseMgr/Tnb.WarehouseMgr.Entities/Enums/EnumCarryStatus.cs create mode 100644 WarehouseMgr/Tnb.WarehouseMgr.Entities/Enums/EnumOutStatus.cs delete mode 100644 WarehouseMgr/Tnb.WarehouseMgr.Interfaces/Class1.cs create mode 100644 WarehouseMgr/Tnb.WarehouseMgr.Interfaces/IWmsCarryEntity.cs create mode 100644 WarehouseMgr/Tnb.WarehouseMgr.Interfaces/IWmsCarryService.cs delete mode 100644 WarehouseMgr/Tnb.WarehouseMgr/Class1.cs create mode 100644 WarehouseMgr/Tnb.WarehouseMgr/WmsCarryService.cs create mode 100644 common/Tnb.Common/Utils/DeepCopyHelper.cs diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/ExChangeCarryInput.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/ExChangeCarryInput.cs new file mode 100644 index 00000000..cc68bf46 --- /dev/null +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/ExChangeCarryInput.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tnb.WarehouseMgr.Entities.Dto +{ + /// + /// 更换载具输入参数 + /// + + public class ExChangeCarryInput + { + /// + /// 老载具ID + /// + public string old_carry_id { get; set; } + /// + /// 新载具ID + /// + public string new_carry_id { get; set; } + } +} diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryCode.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryCode.cs index b71ca2b2..84d8360b 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryCode.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryCode.cs @@ -97,12 +97,12 @@ public partial class WmsCarryCode : BaseEntity /// /// 创建用户 /// - public string create_id { get; set; } = string.Empty; + public string? create_id { get; set; } /// /// 创建时间 /// - public DateTime create_time { get; set; } = DateTime.Now; + public DateTime? create_time { get; set; } /// /// 修改用户 diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryD.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryD.cs index 0bfbdd28..553c5500 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryD.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryD.cs @@ -42,12 +42,12 @@ public partial class WmsCarryD : BaseEntity /// /// 创建用户 /// - public string create_id { get; set; } = string.Empty; + public string? create_id { get; set; } /// /// 创建时间 /// - public DateTime create_time { get; set; } = DateTime.Now; + public DateTime? create_time { get; set; } /// /// 最后修改人员ID diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryH.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryH.cs index 30b9e324..76092322 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryH.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryH.cs @@ -42,7 +42,7 @@ public partial class WmsCarryH : BaseEntity /// /// 载具状态 /// - public string carry_status { get; set; } = string.Empty; + public int carry_status { get; set; }; /// /// 载具分类ID @@ -114,4 +114,19 @@ public partial class WmsCarryH : BaseEntity /// public DateTime? timestamp { get; set; } + /// + /// 打包号 + /// + public string? bale_num { get; set; } + + /// + /// 齐套搭配方案ID + /// + public string? collocation_scheme_id { get; set; } + + /// + /// 齐套搭配方案编号 + /// + public string? collocation_scheme_code { get; set; } + } diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryMat.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryMat.cs index e1d544cc..283918af 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryMat.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryMat.cs @@ -82,12 +82,12 @@ public partial class WmsCarryMat : BaseEntity /// /// 时间戳 /// - public DateTime time_stamp { get; set; } = DateTime.Now; + public DateTime? time_stamp { get; set; } /// /// 创建用户 /// - public string create_id { get; set; } = string.Empty; + public string? create_id { get; set; } /// /// 创建时间 diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryReplaceCode.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryReplaceCode.cs index 2575f6af..1656af9f 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryReplaceCode.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryReplaceCode.cs @@ -77,12 +77,12 @@ public partial class WmsCarryReplaceCode : BaseEntity /// /// 创建用户 /// - public string create_id { get; set; } = string.Empty; + public string? create_id { get; set; } /// /// 创建时间 /// - public DateTime create_time { get; set; } = DateTime.Now; + public DateTime? create_time { get; set; } /// /// 修改用户 @@ -94,9 +94,4 @@ public partial class WmsCarryReplaceCode : BaseEntity /// public DateTime? modify_time { get; set; } - /// - /// 行号 - /// - public int no { get; set; } - } diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryReplaceH.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryReplaceH.cs index f2d39eae..1ebfc67c 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryReplaceH.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryReplaceH.cs @@ -17,7 +17,7 @@ public partial class WmsCarryReplaceH : BaseEntity /// /// 租户ID /// - public string tenant_id { get; set; } = string.Empty; + public string? tenant_id { get; set; } /// /// 所属组织ID diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Enums/EnumCarryStatus.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Enums/EnumCarryStatus.cs new file mode 100644 index 00000000..c7bbef14 --- /dev/null +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Enums/EnumCarryStatus.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tnb.WarehouseMgr.Entities.Enums +{ + /// + /// 载具状态枚举 + /// + public enum EnumCarryStatus + { + 空闲 = 0, + 占用 = 1, + 齐套 = 3, + 寄存 = 4, + 齐套分拣 = 5, + } +} diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Enums/EnumOutStatus.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Enums/EnumOutStatus.cs new file mode 100644 index 00000000..f13e2e51 --- /dev/null +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Enums/EnumOutStatus.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tnb.WarehouseMgr.Entities.Enums +{ + /// + /// 出库状态 + /// + public enum EnumOutStatus + { + 正常 = 0, + 全部出 = 1, + 分拣出 = 2, + 齐套出 = 3, + 寄存出 = 4, + 齐套分拣出 = 5, + } +} diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Interfaces/Class1.cs b/WarehouseMgr/Tnb.WarehouseMgr.Interfaces/Class1.cs deleted file mode 100644 index 8c120287..00000000 --- a/WarehouseMgr/Tnb.WarehouseMgr.Interfaces/Class1.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Tnb.WarehouseMgr.Interfaces -{ - public class Class1 - { - - } -} \ No newline at end of file diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Interfaces/IWmsCarryEntity.cs b/WarehouseMgr/Tnb.WarehouseMgr.Interfaces/IWmsCarryEntity.cs new file mode 100644 index 00000000..f2d71a03 --- /dev/null +++ b/WarehouseMgr/Tnb.WarehouseMgr.Interfaces/IWmsCarryEntity.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tnb.WarehouseMgr.Interfaces +{ + public class IWmsCarryEntity + { + string carry_id { get; set; } + } +} diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Interfaces/IWmsCarryService.cs b/WarehouseMgr/Tnb.WarehouseMgr.Interfaces/IWmsCarryService.cs new file mode 100644 index 00000000..4eeff321 --- /dev/null +++ b/WarehouseMgr/Tnb.WarehouseMgr.Interfaces/IWmsCarryService.cs @@ -0,0 +1,17 @@ +using Tnb.WarehouseMgr.Entities; + +namespace Tnb.WarehouseMgr.Interfaces +{ + /// + /// 载具服务接口 + /// + public interface IWmsCarryService + { + /// + /// 更新空载具 + /// + /// + /// + Task UpdateNullCarry(WmsCarryH carryObj); + } +} \ No newline at end of file diff --git a/WarehouseMgr/Tnb.WarehouseMgr/Class1.cs b/WarehouseMgr/Tnb.WarehouseMgr/Class1.cs deleted file mode 100644 index b5b0a256..00000000 --- a/WarehouseMgr/Tnb.WarehouseMgr/Class1.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Tnb.WarehouseMgr -{ - public class Class1 - { - - } -} \ No newline at end of file diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryService.cs new file mode 100644 index 00000000..5fede318 --- /dev/null +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryService.cs @@ -0,0 +1,137 @@ +using JNPF.Common.Core.Manager; +using JNPF.Common.Enums; +using JNPF.DependencyInjection; +using JNPF.DynamicApiController; +using JNPF.FriendlyException; +using Microsoft.AspNetCore.Mvc; +using SqlSugar; +using Tnb.Common.Utils; +using Tnb.WarehouseMgr.Entities; +using Tnb.WarehouseMgr.Entities.Dto; +using Tnb.WarehouseMgr.Entities.Enums; +using Tnb.WarehouseMgr.Interfaces; + +namespace Tnb.WarehouseMgr +{ + /// + /// 载具服务 + /// + [ApiDescriptionSettings(Tag = ModuleConsts.Tag, Area = ModuleConsts.Area, Order = 700)] + [Route("api/[area]/[controller]/[action]")] + + public class WmsCarryService : IWmsCarryService, IDynamicApiController, ITransient + { + private readonly ISqlSugarClient _db; + private readonly IUserManager _userManager; + public WmsCarryService(ISqlSugarRepository repository, IUserManager userManager) + { + _db = repository.AsSugarClient(); + _userManager = userManager; + } + /// + /// 更换载具 + /// + /// + /// 输入参数: + ///
{ + ///
old_carry_id:老载具id + ///
new_carry_id:新载具ID + ///
} + /// + /// + /// + [HttpPost] + public async Task Exchange(ExChangeCarryInput input) + { + var row = -1; + if (input == null) throw new ArgumentNullException("input"); + var oldCarry = await _db.Queryable().FirstAsync(it => it.id == input.old_carry_id && it.is_lock == 0 && it.status == 0 && it.carry_status != 0); + var newCarry = await _db.Queryable().FirstAsync(it => it.id == input.new_carry_id && it.is_lock == 0 && it.status == 0 && it.carry_status == 0); + if (oldCarry != null && newCarry != null) + { + var subCarrys = await _db.Queryable().Where(it => it.carry_id == oldCarry.id).ToListAsync(); + if (subCarrys?.Count > 0) + { + List newSubCarrys = DeepCopyHelper.DeepCopyList(subCarrys); + if (newSubCarrys?.Count > 0) + { + newSubCarrys.ForEach(x => x.carry_id = newCarry.id); + row = await _db.Insertable(newSubCarrys).ExecuteCommandAsync(); + } + if (row > 0) + { + row = await _db.Deleteable(subCarrys).ExecuteCommandAsync(); + } + } + var subCarryMats = await _db.Queryable().Where(it => it.carry_id == oldCarry.id).ToListAsync(); + if (subCarryMats?.Count > 0) + { + List newCarryMats = DeepCopyHelper.DeepCopyList(subCarryMats); + if (newCarryMats?.Count > 0) + { + newCarryMats.ForEach(x => x.carry_id = newCarry.id); + row = await _db.Insertable(newCarryMats).ExecuteCommandAsync(); + } + if (row > 0) + { + row = await _db.Deleteable(subCarryMats).ExecuteCommandAsync(); + } + } + var subCarryCodes = await _db.Queryable().Where(it => it.carry_id == oldCarry.id).ToListAsync(); + if (subCarryCodes?.Count > 0) + { + List newCarrayCodes = DeepCopyHelper.DeepCopyList(subCarryCodes); + if (newCarrayCodes?.Count > 0) + { + newCarrayCodes.ForEach(x => x.carry_id = newCarry.id); + row = await _db.Insertable(newCarrayCodes).ExecuteCommandAsync(); + } + if (row > 0) + { + row = await _db.Deleteable(subCarryCodes).ExecuteCommandAsync(); + } + } + if (row > 0) + { + newCarry.carry_name = oldCarry.carry_name; + newCarry.status = oldCarry.status; + newCarry.carry_status = oldCarry.carry_status; + newCarry.carrystd_id = oldCarry.carrystd_id; + newCarry.location_id = oldCarry.location_id; + newCarry.carry_code = oldCarry.location_code; + newCarry.is_lock = oldCarry.is_lock; + newCarry.out_status = oldCarry.out_status; + newCarry.is_check = oldCarry.is_check; + newCarry.bale_num = oldCarry.bale_num; + newCarry.collocation_scheme_id = oldCarry.collocation_scheme_id; + newCarry.collocation_scheme_code = oldCarry.collocation_scheme_code; + newCarry.source_id = oldCarry.source_id; + newCarry.source_code = oldCarry.source_code; + newCarry.create_id = _userManager.UserId; + newCarry.create_time = DateTime.Now; + row = await _db.Updateable(newCarry).ExecuteCommandAsync(); + row = await UpdateNullCarry(oldCarry); + } + } + if (row < 1) throw Oops.Oh(ErrorCode.COM1001); + } + + public Task UpdateNullCarry(WmsCarryH carryObj) + { + carryObj.carry_name = null; + carryObj.status = 0; + carryObj.carry_status = 0; + carryObj.carrystd_id = null; + carryObj.location_id = null; + carryObj.carry_code = null; + carryObj.out_status = null; + carryObj.is_check = 0; + carryObj.bale_num = null; + carryObj.collocation_scheme_id = null; + carryObj.collocation_scheme_code = null; + carryObj.source_id = null; + carryObj.source_code = null; + return _db.Updateable(carryObj).ExecuteCommandAsync(); + } + } +} \ No newline at end of file diff --git a/common/Tnb.Common/Utils/DeepCopyHelper.cs b/common/Tnb.Common/Utils/DeepCopyHelper.cs new file mode 100644 index 00000000..1c4cc78c --- /dev/null +++ b/common/Tnb.Common/Utils/DeepCopyHelper.cs @@ -0,0 +1,76 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Linq.Expressions; +using System.Reflection; +using System.Text; +using System.Threading.Tasks; + +namespace Tnb.Common.Utils +{ + public class DeepCopyHelper where T : class, new() // 需要无参构造函数,构造表达式树的时候需要利用无参构造函数创建对象 + { + /// + /// 映射表达式,泛型缓存每个类型存一份 + /// + private static readonly Func s_CopyFunc = null; + + /// + /// 静态构造函数,每个泛型类型会且只会执行一次 + /// + static DeepCopyHelper() + { + BindingFlags bindingFlags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; + ParameterExpression parameterExpression = Expression.Parameter(typeof(T), "m"); // 参数m :m => + List memberBindingList = new List(); + foreach (var item in typeof(T).GetProperties(bindingFlags)) + { + if (!item.CanWrite) // 只读属性不拷贝 + { + continue; + } + MemberExpression property = Expression.Property(parameterExpression, item); // m.Name + MemberBinding memberBinding = Expression.Bind(item, property); // Name = m.Name + memberBindingList.Add(memberBinding); + } + foreach (var item in typeof(T).GetFields(bindingFlags)) + { + MemberExpression property = Expression.Field(parameterExpression, item); + MemberBinding memberBinding = Expression.Bind(item, property); + memberBindingList.Add(memberBinding); + } + MemberInitExpression memberInitExpression = Expression.MemberInit(Expression.New(typeof(T)), memberBindingList.ToArray());// new T() {Name = m.Name} + Expression> lambda = Expression.Lambda>(memberInitExpression, new ParameterExpression[] + { + parameterExpression + }); // m => new T() {Name = m.Name} + + s_CopyFunc = lambda.Compile(); + } + + /// + /// 对象拷贝(拷贝private/public:实例成员、属性、静态成员) + /// + /// 源 + /// + public static T DeepCopy(T data) + { + return s_CopyFunc(data); + } + + /// + /// 集合拷贝(拷贝private/public:实例成员、属性、静态成员) + /// + /// 源 + /// + public static List DeepCopyList(List data) + { + if (data == null || data.Count < 1) + { + return Enumerable.Empty().ToList(); + } + return data.Select(a => DeepCopy(a)).ToList(); + } + } + +} From 90576189664d49f98d1e0951788b5e2b829b584c Mon Sep 17 00:00:00 2001 From: zhoukeda <1315948824@qq.com> Date: Wed, 31 May 2023 14:46:11 +0800 Subject: [PATCH 3/4] bug --- BasicData/Tnb.BasicData/BasMaterialService.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/BasicData/Tnb.BasicData/BasMaterialService.cs b/BasicData/Tnb.BasicData/BasMaterialService.cs index 20179695..831b10d5 100644 --- a/BasicData/Tnb.BasicData/BasMaterialService.cs +++ b/BasicData/Tnb.BasicData/BasMaterialService.cs @@ -90,8 +90,8 @@ namespace Tnb.BasicData BasEbomH ebom = await db.Queryable().Where(x => x.id == queryInput.ebom_id).SingleAsync(); ids.Add(ebom.material_id); var result = await db.Queryable() - .LeftJoin((a, b) => a.unit_id == b.EnCode) - .LeftJoin((a, b, c) => b.DictionaryTypeId == c.Id && c.EnCode == DictConst.MeasurementUnit && c.DeleteMark == null) + .LeftJoin((a, b) => b.EnCode == DictConst.MeasurementUnit && b.DeleteMark == null) + .LeftJoin((a, b, c) => c.DictionaryTypeId == b.Id && a.unit_id == c.EnCode) .WhereIF(!string.IsNullOrEmpty(queryInput.material_info), (a, b, c) => a.code.Contains(queryInput.material_info) || a.name.Contains(queryInput.material_info)) .WhereIF(!string.IsNullOrEmpty(queryInput.ebom_id), (a, b, c) => ids.Contains(a.id)) .Select((a, b, c) => new MaterialSelectOutput() @@ -101,7 +101,7 @@ namespace Tnb.BasicData name = a.name, descrip = a.descrip, unit_id = a.unit_id, - unit_name = b.FullName, + unit_name = c.FullName, }).ToPagedListAsync(queryInput.currentPage, queryInput.pageSize); return PageResult.SqlSugarPageResult(result); @@ -110,8 +110,8 @@ namespace Tnb.BasicData else { var result = await db.Queryable() - .LeftJoin((a, b) => a.unit_id == b.EnCode) - .LeftJoin((a, b, c) => b.DictionaryTypeId == c.Id && c.EnCode == DictConst.MeasurementUnit && c.DeleteMark == null) + .LeftJoin((a, b) => b.EnCode == DictConst.MeasurementUnit && b.DeleteMark == null) + .LeftJoin((a, b, c) => c.DictionaryTypeId == b.Id && a.unit_id == c.EnCode) .WhereIF(!string.IsNullOrEmpty(queryInput.material_info), (a, b, c) => a.code.Contains(queryInput.material_info) || a.name.Contains(queryInput.material_info)) .Select((a, b, c) => new MaterialSelectOutput() { @@ -120,7 +120,7 @@ namespace Tnb.BasicData name = a.name, descrip = a.descrip, unit_id = a.unit_id, - unit_name = b.FullName, + unit_name = c.FullName, }).ToPagedListAsync(queryInput.currentPage, queryInput.pageSize); return PageResult.SqlSugarPageResult(result); From 52a16b0228c5c3828366c467f3af763e7ca44924 Mon Sep 17 00:00:00 2001 From: zhoukeda <1315948824@qq.com> Date: Wed, 31 May 2023 17:10:15 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E8=AE=BE=E5=A4=87=E6=A1=A3=E6=A1=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Consts/DictConst.cs | 4 + .../Dto/EquipFileQueryOutput.cs | 14 +++ .../Dto/EquipMaintainRecordQueryOutput.cs | 21 +++++ .../Dto/EquipQueryInput.cs | 19 +++++ .../Dto/EquipRepairRecordQueryOutput.cs | 16 ++++ .../Dto/EquipSparePartsInput.cs | 9 ++ .../Dto/EquipSparePartsQueryOutput.cs | 13 +++ .../Dto/EquipSpotInsRecordQueryOutput.cs | 20 +++++ .../EquipTechnologyParameterQueryOutput.cs | 10 +++ .../Dto/SubEquipQueryOutput.cs | 18 ++++ .../Entity/EqpEquipSpareParts.cs | 52 ++++++++++++ .../Entity/EqpSpareParts.cs | 67 +++++++++++++++ .../Entity/EqpSubEquip.cs | 62 ++++++++++++++ .../Entity/EqpTechnologyParameter.cs | 62 ++++++++++++++ .../IEqpEquipFileService.cs | 6 ++ .../IEqpEquipSparePartsService.cs | 20 +++++ .../IEqpMaintainRecordService.cs | 6 ++ .../IEqpRepairApplyService.cs | 6 ++ .../IEqpSubEquipService.cs | 13 +++ .../IEqpTechnologyParameterService.cs | 12 +++ .../IEquSpotInsRecordService.cs | 6 ++ EquipMgr/Tnb.EquipMgr/EqpEquipFileService.cs | 35 +++++++- .../Tnb.EquipMgr/EqpEquipSparePartsService.cs | 85 +++++++++++++++++++ .../Tnb.EquipMgr/EqpRepairApplyService.cs | 33 +++++++ .../Tnb.EquipMgr/EqpRepairOutApplyService.cs | 1 - EquipMgr/Tnb.EquipMgr/EqpSubEquipService.cs | 67 +++++++++++++++ .../EqpTechnologyParameterService.cs | 52 ++++++++++++ .../Tnb.EquipMgr/EquMaintainRecordService.cs | 38 +++++++++ .../Tnb.EquipMgr/EquSpotInsRecordService.cs | 35 ++++++++ .../Entity/WmsCarryH.cs | 2 +- 30 files changed, 801 insertions(+), 3 deletions(-) create mode 100644 EquipMgr/Tnb.EquipMgr.Entities/Dto/EquipFileQueryOutput.cs create mode 100644 EquipMgr/Tnb.EquipMgr.Entities/Dto/EquipMaintainRecordQueryOutput.cs create mode 100644 EquipMgr/Tnb.EquipMgr.Entities/Dto/EquipQueryInput.cs create mode 100644 EquipMgr/Tnb.EquipMgr.Entities/Dto/EquipRepairRecordQueryOutput.cs create mode 100644 EquipMgr/Tnb.EquipMgr.Entities/Dto/EquipSparePartsInput.cs create mode 100644 EquipMgr/Tnb.EquipMgr.Entities/Dto/EquipSparePartsQueryOutput.cs create mode 100644 EquipMgr/Tnb.EquipMgr.Entities/Dto/EquipSpotInsRecordQueryOutput.cs create mode 100644 EquipMgr/Tnb.EquipMgr.Entities/Dto/EquipTechnologyParameterQueryOutput.cs create mode 100644 EquipMgr/Tnb.EquipMgr.Entities/Dto/SubEquipQueryOutput.cs create mode 100644 EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpEquipSpareParts.cs create mode 100644 EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpSpareParts.cs create mode 100644 EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpSubEquip.cs create mode 100644 EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpTechnologyParameter.cs create mode 100644 EquipMgr/Tnb.EquipMgr.Interfaces/IEqpEquipSparePartsService.cs create mode 100644 EquipMgr/Tnb.EquipMgr.Interfaces/IEqpSubEquipService.cs create mode 100644 EquipMgr/Tnb.EquipMgr.Interfaces/IEqpTechnologyParameterService.cs create mode 100644 EquipMgr/Tnb.EquipMgr/EqpEquipSparePartsService.cs create mode 100644 EquipMgr/Tnb.EquipMgr/EqpSubEquipService.cs create mode 100644 EquipMgr/Tnb.EquipMgr/EqpTechnologyParameterService.cs diff --git a/BasicData/Tnb.BasicData.Entities/Consts/DictConst.cs b/BasicData/Tnb.BasicData.Entities/Consts/DictConst.cs index eecc7bef..11e85654 100644 --- a/BasicData/Tnb.BasicData.Entities/Consts/DictConst.cs +++ b/BasicData/Tnb.BasicData.Entities/Consts/DictConst.cs @@ -11,6 +11,10 @@ public static class DictConst /// 区域类型-工位Code ///
public const string RegionCategoryStationCode = "workstation"; + /// + /// 备品备件类型 + /// + public const string SparePartsType = "SparePartsType"; #endregion diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Dto/EquipFileQueryOutput.cs b/EquipMgr/Tnb.EquipMgr.Entities/Dto/EquipFileQueryOutput.cs new file mode 100644 index 00000000..2b280b55 --- /dev/null +++ b/EquipMgr/Tnb.EquipMgr.Entities/Dto/EquipFileQueryOutput.cs @@ -0,0 +1,14 @@ +namespace Tnb.EquipMgr.Entities.Dto +{ + public class EquipFileQueryOutput + { + public string id { get; set; } + public string attachment { get; set; } + public string create_id { get; set; } + public string create_id_id { get; set; } + public string create_time { get; set; } + public string equip_id { get; set; } + public string equip_id_id { get; set; } + public string file_name { get; set; } + } +} \ No newline at end of file diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Dto/EquipMaintainRecordQueryOutput.cs b/EquipMgr/Tnb.EquipMgr.Entities/Dto/EquipMaintainRecordQueryOutput.cs new file mode 100644 index 00000000..a8978a55 --- /dev/null +++ b/EquipMgr/Tnb.EquipMgr.Entities/Dto/EquipMaintainRecordQueryOutput.cs @@ -0,0 +1,21 @@ +namespace Tnb.EquipMgr.Entities.Dto +{ + public class EquipMaintainRecordQueryOutput + { + public string id { get; set; } + public string attachment { get; set; } + public string create_time { get; set; } + public string equip_id { get; set; } + public string equip_id_id { get; set; } + public string execute_time { get; set; } + public string execute_user_id { get; set; } + public string repeat_remark { get; set; } + public string repeat_result { get; set; } + public string repeat_time { get; set; } + public string repeat_user_id { get; set; } + public string result { get; set; } + public string result_remark { get; set; } + public string maintain_tem_equip_id { get; set; } + public string status { get; set; } + } +} \ No newline at end of file diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Dto/EquipQueryInput.cs b/EquipMgr/Tnb.EquipMgr.Entities/Dto/EquipQueryInput.cs new file mode 100644 index 00000000..80af62d9 --- /dev/null +++ b/EquipMgr/Tnb.EquipMgr.Entities/Dto/EquipQueryInput.cs @@ -0,0 +1,19 @@ +namespace Tnb.EquipMgr.Entities.Dto +{ + public class EquipQueryInput + { + public string equip_id { get; set; } + + /// + /// 当前页码:pageIndex. + /// + public virtual int currentPage { get; set; } = 1; + + /// + /// 每页行数. + /// + public virtual int pageSize { get; set; } = 50; + + public string queryJson { get; set; } + } +} \ No newline at end of file diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Dto/EquipRepairRecordQueryOutput.cs b/EquipMgr/Tnb.EquipMgr.Entities/Dto/EquipRepairRecordQueryOutput.cs new file mode 100644 index 00000000..ba539654 --- /dev/null +++ b/EquipMgr/Tnb.EquipMgr.Entities/Dto/EquipRepairRecordQueryOutput.cs @@ -0,0 +1,16 @@ +namespace Tnb.EquipMgr.Entities.Dto +{ + public class EquipRepairRecordQueryOutput + { + public string id { get; set; } + public string code { get; set; } + public string name { get; set; } + public string equip_id { get; set; } + public string apply_user_id { get; set; } + public string is_ugent { get; set; } + public string description { get; set; } + public string complete_time { get; set; } + public string repairer_id { get; set; } + public string repair_description { get; set; } + } +} \ No newline at end of file diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Dto/EquipSparePartsInput.cs b/EquipMgr/Tnb.EquipMgr.Entities/Dto/EquipSparePartsInput.cs new file mode 100644 index 00000000..69b222b3 --- /dev/null +++ b/EquipMgr/Tnb.EquipMgr.Entities/Dto/EquipSparePartsInput.cs @@ -0,0 +1,9 @@ +namespace Tnb.EquipMgr.Entities.Dto +{ + public class EquipSparePartsInput + { + public string equip_id { get; set; } + + public List spare_parts_ids { get; set; } + } +} \ No newline at end of file diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Dto/EquipSparePartsQueryOutput.cs b/EquipMgr/Tnb.EquipMgr.Entities/Dto/EquipSparePartsQueryOutput.cs new file mode 100644 index 00000000..2e35315d --- /dev/null +++ b/EquipMgr/Tnb.EquipMgr.Entities/Dto/EquipSparePartsQueryOutput.cs @@ -0,0 +1,13 @@ +namespace Tnb.EquipMgr.Entities.Dto +{ + public class EquipSparePartsQueryOutput + { + public string id { get; set; } + public string type_code { get; set; } + public string type_name { get; set; } + public string code { get; set; } + public string name { get; set; } + public string specification { get; set; } + + } +} \ No newline at end of file diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Dto/EquipSpotInsRecordQueryOutput.cs b/EquipMgr/Tnb.EquipMgr.Entities/Dto/EquipSpotInsRecordQueryOutput.cs new file mode 100644 index 00000000..b0162c36 --- /dev/null +++ b/EquipMgr/Tnb.EquipMgr.Entities/Dto/EquipSpotInsRecordQueryOutput.cs @@ -0,0 +1,20 @@ +namespace Tnb.EquipMgr.Entities.Dto +{ + public class EquipSpotInsRecordQueryOutput + { + public string id { get; set; } + public string attachment { get; set; } + public string create_time { get; set; } + public string equip_id { get; set; } + public string repeat_remark { get; set; } + public string repeat_result { get; set; } + public string repeat_time { get; set; } + public string repeat_user_id { get; set; } + public string result { get; set; } + public string result_remark { get; set; } + public string spot_ins_tem_equip_id { get; set; } + public string spot_record_date_time { get; set; } + public string spot_record_user_id { get; set; } + public string status { get; set; } + } +} \ No newline at end of file diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Dto/EquipTechnologyParameterQueryOutput.cs b/EquipMgr/Tnb.EquipMgr.Entities/Dto/EquipTechnologyParameterQueryOutput.cs new file mode 100644 index 00000000..d1e91278 --- /dev/null +++ b/EquipMgr/Tnb.EquipMgr.Entities/Dto/EquipTechnologyParameterQueryOutput.cs @@ -0,0 +1,10 @@ +namespace Tnb.EquipMgr.Entities.Dto +{ + public class EquipTechnologyParameterQueryOutput + { + public string id { get; set; } + public string name { get; set; } + public string definition { get; set; } + public string remark { get; set; } + } +} \ No newline at end of file diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Dto/SubEquipQueryOutput.cs b/EquipMgr/Tnb.EquipMgr.Entities/Dto/SubEquipQueryOutput.cs new file mode 100644 index 00000000..32200413 --- /dev/null +++ b/EquipMgr/Tnb.EquipMgr.Entities/Dto/SubEquipQueryOutput.cs @@ -0,0 +1,18 @@ +namespace Tnb.EquipMgr.Entities.Dto +{ + public class SubEquipQueryOutput + { + public string code { get; set; } + public string create_id { get; set; } + public string create_id_id { get; set; } + public string create_time { get; set; } + public string equip_id { get; set; } + public string equip_id_id { get; set; } + public string id { get; set; } + public string modify_id { get; set; } + public string modify_time { get; set; } + public string name { get; set; } + public string org_id { get; set; } + public string specification { get; set; } + } +} \ No newline at end of file diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpEquipSpareParts.cs b/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpEquipSpareParts.cs new file mode 100644 index 00000000..64136645 --- /dev/null +++ b/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpEquipSpareParts.cs @@ -0,0 +1,52 @@ +using JNPF.Common.Contracts; +using JNPF.Common.Security; +using SqlSugar; + +namespace Tnb.EquipMgr.Entities; + +/// +/// 设备备品备件关联表 +/// +[SugarTable("eqp_equip_spare_parts")] +public partial class EqpEquipSpareParts : BaseEntity +{ + public EqpEquipSpareParts() + { + id = SnowflakeIdHelper.NextId(); + } + /// + /// 设备id + /// + public string equip_id { get; set; } = string.Empty; + + /// + /// 备品备件id + /// + public string spare_parts_id { get; set; } = string.Empty; + + /// + /// 创建用户 + /// + 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? org_id { get; set; } + +} \ No newline at end of file diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpSpareParts.cs b/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpSpareParts.cs new file mode 100644 index 00000000..264d8ea1 --- /dev/null +++ b/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpSpareParts.cs @@ -0,0 +1,67 @@ +using JNPF.Common.Contracts; +using JNPF.Common.Security; +using SqlSugar; + +namespace Tnb.EquipMgr.Entities; + +/// +/// 备品备件 +/// +[SugarTable("eqp_spare_parts")] +public partial class EqpSpareParts : BaseEntity +{ + public EqpSpareParts() + { + id = SnowflakeIdHelper.NextId(); + } + /// + /// 类型id + /// + public string type_id { get; set; } = string.Empty; + + /// + /// 编码 + /// + public string code { get; set; } = string.Empty; + + /// + /// 名称 + /// + public string name { get; set; } = string.Empty; + + /// + /// 规格型号 + /// + public string? specification { 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? org_id { get; set; } + + /// + /// 备注 + /// + public string? remark { get; set; } + +} \ No newline at end of file diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpSubEquip.cs b/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpSubEquip.cs new file mode 100644 index 00000000..6d4ee06f --- /dev/null +++ b/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpSubEquip.cs @@ -0,0 +1,62 @@ +using JNPF.Common.Contracts; +using JNPF.Common.Security; +using SqlSugar; + +namespace Tnb.EquipMgr.Entities; + +/// +/// 设备子设备关联表 +/// +[SugarTable("eqp_sub_equip")] +public partial class EqpSubEquip : BaseEntity +{ + public EqpSubEquip() + { + id = SnowflakeIdHelper.NextId(); + } + /// + /// 编码 + /// + public string code { get; set; } = string.Empty; + + /// + /// 名称 + /// + public string name { get; set; } = string.Empty; + + /// + /// 规格型号 + /// + public string? specification { 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? org_id { get; set; } + + /// + /// 设备id + /// + public string equip_id { get; set; } = string.Empty; + +} \ No newline at end of file diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpTechnologyParameter.cs b/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpTechnologyParameter.cs new file mode 100644 index 00000000..18494867 --- /dev/null +++ b/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpTechnologyParameter.cs @@ -0,0 +1,62 @@ +using JNPF.Common.Contracts; +using JNPF.Common.Security; +using SqlSugar; + +namespace Tnb.EquipMgr.Entities; + +/// +/// 设备技术参数 +/// +[SugarTable("eqp_technology_parameter")] +public partial class EqpTechnologyParameter : BaseEntity +{ + public EqpTechnologyParameter() + { + id = SnowflakeIdHelper.NextId(); + } + /// + /// 名称 + /// + public string name { get; set; } = string.Empty; + + /// + /// 定义 + /// + public string definition { get; set; } = string.Empty; + + /// + /// 备注 + /// + 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? org_id { get; set; } + + /// + /// 设备id + /// + public string equip_id { get; set; } = string.Empty; + +} \ No newline at end of file diff --git a/EquipMgr/Tnb.EquipMgr.Interfaces/IEqpEquipFileService.cs b/EquipMgr/Tnb.EquipMgr.Interfaces/IEqpEquipFileService.cs index 6f685177..3d47193f 100644 --- a/EquipMgr/Tnb.EquipMgr.Interfaces/IEqpEquipFileService.cs +++ b/EquipMgr/Tnb.EquipMgr.Interfaces/IEqpEquipFileService.cs @@ -11,5 +11,11 @@ namespace Tnb.EquipMgr.Interfaces ///// ///// //public Task Upload(string equip_id,IFormFile file); + + /// + /// 根据设备id获取设备附件 + /// + /// + public Task GetEquipFileList(EquipQueryInput input); } } \ No newline at end of file diff --git a/EquipMgr/Tnb.EquipMgr.Interfaces/IEqpEquipSparePartsService.cs b/EquipMgr/Tnb.EquipMgr.Interfaces/IEqpEquipSparePartsService.cs new file mode 100644 index 00000000..38a1bcb0 --- /dev/null +++ b/EquipMgr/Tnb.EquipMgr.Interfaces/IEqpEquipSparePartsService.cs @@ -0,0 +1,20 @@ +using Tnb.EquipMgr.Entities.Dto; + +namespace Tnb.EquipMgr.Interfaces +{ + public interface IEqpEquipSparePartsService + { + /// + /// 新增备品备件 + /// + /// + /// + public Task AddEquipSpareParts(EquipSparePartsInput input); + + /// + /// 根据设备id获取备品备件 + /// + /// + public Task GetEquipSparePartsList(EquipQueryInput input); + } +} \ No newline at end of file diff --git a/EquipMgr/Tnb.EquipMgr.Interfaces/IEqpMaintainRecordService.cs b/EquipMgr/Tnb.EquipMgr.Interfaces/IEqpMaintainRecordService.cs index 387129b3..3ca7ee5a 100644 --- a/EquipMgr/Tnb.EquipMgr.Interfaces/IEqpMaintainRecordService.cs +++ b/EquipMgr/Tnb.EquipMgr.Interfaces/IEqpMaintainRecordService.cs @@ -25,6 +25,12 @@ namespace Tnb.EquipMgr.Interfaces /// /// public Task RepeatMaintain(MaintainRecordRepeatInput input); + + /// + /// 根据设备id获取设备保养记录 + /// + /// + public Task GetMaintainRecordList(EquipQueryInput input); } } \ No newline at end of file diff --git a/EquipMgr/Tnb.EquipMgr.Interfaces/IEqpRepairApplyService.cs b/EquipMgr/Tnb.EquipMgr.Interfaces/IEqpRepairApplyService.cs index eee44398..f23044b1 100644 --- a/EquipMgr/Tnb.EquipMgr.Interfaces/IEqpRepairApplyService.cs +++ b/EquipMgr/Tnb.EquipMgr.Interfaces/IEqpRepairApplyService.cs @@ -53,5 +53,11 @@ namespace Tnb.EquipMgr.Interfaces ///
/// public Task GetRepairApplyDetail(Dictionary dic); + + /// + /// 根据设备id获取维修记录 + /// + /// + public Task GetRepairRecordList(EquipQueryInput input); } } \ No newline at end of file diff --git a/EquipMgr/Tnb.EquipMgr.Interfaces/IEqpSubEquipService.cs b/EquipMgr/Tnb.EquipMgr.Interfaces/IEqpSubEquipService.cs new file mode 100644 index 00000000..45b03060 --- /dev/null +++ b/EquipMgr/Tnb.EquipMgr.Interfaces/IEqpSubEquipService.cs @@ -0,0 +1,13 @@ +using Tnb.EquipMgr.Entities.Dto; + +namespace Tnb.EquipMgr.Interfaces +{ + public interface IEqpSubEquipService + { + /// + /// 根据设备id获取子设备 + /// + /// + public Task GetSubEquipList(EquipQueryInput input); + } +} \ No newline at end of file diff --git a/EquipMgr/Tnb.EquipMgr.Interfaces/IEqpTechnologyParameterService.cs b/EquipMgr/Tnb.EquipMgr.Interfaces/IEqpTechnologyParameterService.cs new file mode 100644 index 00000000..2c5212c7 --- /dev/null +++ b/EquipMgr/Tnb.EquipMgr.Interfaces/IEqpTechnologyParameterService.cs @@ -0,0 +1,12 @@ +using Tnb.EquipMgr.Entities.Dto; +namespace Tnb.EquipMgr.Interfaces +{ + public interface IEqpTechnologyParameterService + { + /// + /// 根据设备id获取技术参数 + /// + /// + public Task GetEquipTechnologyParameterList(EquipQueryInput input); + } +} \ No newline at end of file diff --git a/EquipMgr/Tnb.EquipMgr.Interfaces/IEquSpotInsRecordService.cs b/EquipMgr/Tnb.EquipMgr.Interfaces/IEquSpotInsRecordService.cs index b639f300..43c849fc 100644 --- a/EquipMgr/Tnb.EquipMgr.Interfaces/IEquSpotInsRecordService.cs +++ b/EquipMgr/Tnb.EquipMgr.Interfaces/IEquSpotInsRecordService.cs @@ -25,6 +25,12 @@ namespace Tnb.EquipMgr.Interfaces /// /// public Task RepeatSpotIns(SpotInsRecordRepeatInput input); + + /// + /// 根据设备id获取点巡检记录 + /// + /// + public Task GetSpotInsRecordList(EquipQueryInput input); } } \ No newline at end of file diff --git a/EquipMgr/Tnb.EquipMgr/EqpEquipFileService.cs b/EquipMgr/Tnb.EquipMgr/EqpEquipFileService.cs index 3367ffc3..adc74cac 100644 --- a/EquipMgr/Tnb.EquipMgr/EqpEquipFileService.cs +++ b/EquipMgr/Tnb.EquipMgr/EqpEquipFileService.cs @@ -1,12 +1,14 @@ using JNPF.Common.Core.Manager; using JNPF.Common.Dtos.VisualDev; using JNPF.Common.Enums; +using JNPF.Common.Filter; using JNPF.Common.Models; using JNPF.DependencyInjection; using JNPF.DynamicApiController; using JNPF.FriendlyException; using JNPF.Logging; using JNPF.Systems.Common; +using JNPF.Systems.Entitys.Permission; using JNPF.Systems.Interfaces.Common; using JNPF.VisualDev; using JNPF.VisualDev.Entitys; @@ -56,7 +58,8 @@ namespace Tnb.EquipMgr equip_id = equip_id, create_id = _userManager.UserId, create_time = DateTime.Now, - attachment = JsonConvert.SerializeObject(attachment) + attachment = JsonConvert.SerializeObject(attachment), + org_id = _userManager.GetUserInfo().Result.organizeId, }; await _repository.InsertAsync(eqpEquipFile); @@ -71,5 +74,35 @@ namespace Tnb.EquipMgr return msg; } + + [HttpPost] + public async Task GetEquipFileList(EquipQueryInput input) + { + var db = _repository.AsSugarClient(); + Dictionary queryJson = new Dictionary(); + if (!string.IsNullOrEmpty(input.queryJson)) + { + queryJson = JsonConvert.DeserializeObject>(input.queryJson); + } + var result = await db.Queryable() + .LeftJoin((a, b) => a.create_id == b.Id) + .LeftJoin((a, b,c) => a.modify_id == c.Id) + .LeftJoin((a, b,c,d) => a.equip_id == d.id) + .Where((a,b,c,d)=>a.equip_id==input.equip_id) + .WhereIF(queryJson.ContainsKey("file_name"),(a,b,c,d)=>a.file_name.Contains(queryJson["file_name"])) + .Select((a, b, c,d) => new EquipFileQueryOutput + { + id = a.id, + attachment = a.attachment, + create_id = b.RealName, + create_id_id = a.create_id, + create_time = a.create_time.Value.ToString("yyyy-MM-dd"), + equip_id=d.name, + equip_id_id= a.equip_id, + file_name=a.file_name, + }).ToPagedListAsync(input.currentPage, input.pageSize); + + return PageResult.SqlSugarPageResult(result); + } } } \ No newline at end of file diff --git a/EquipMgr/Tnb.EquipMgr/EqpEquipSparePartsService.cs b/EquipMgr/Tnb.EquipMgr/EqpEquipSparePartsService.cs new file mode 100644 index 00000000..59dc823d --- /dev/null +++ b/EquipMgr/Tnb.EquipMgr/EqpEquipSparePartsService.cs @@ -0,0 +1,85 @@ +using JNPF.Common.Core.Manager; +using JNPF.Common.Filter; +using JNPF.Common.Security; +using JNPF.DependencyInjection; +using JNPF.DynamicApiController; +using JNPF.Systems.Entitys.Permission; +using JNPF.Systems.Entitys.System; +using Microsoft.AspNetCore.Mvc; +using Newtonsoft.Json; +using SqlSugar; +using Tnb.EquipMgr.Entities; +using Tnb.EquipMgr.Entities.Dto; +using Tnb.EquipMgr.Interfaces; + +namespace Tnb.EquipMgr +{ + /// 设备备品备件 + ///
+ [ApiDescriptionSettings(Tag = ModuleConsts.Tag, Area = ModuleConsts.Area, Order = 700)] + [Route("api/[area]/[controller]/[action]")] + public class EqpEquipSparePartsService : IEqpEquipSparePartsService, IDynamicApiController, ITransient + { + private readonly ISqlSugarRepository _repository; + private readonly IUserManager _userManager; + + public EqpEquipSparePartsService(ISqlSugarRepository repository, IUserManager userManager) + { + _userManager = userManager; + _repository = repository; + } + + [HttpPost] + public async Task AddEquipSpareParts(EquipSparePartsInput input) + { + List oldList = await _repository.GetListAsync(x => x.equip_id == input.equip_id); + List list = new List(); + string orgId = _userManager.GetUserInfo().Result.organizeId; + foreach (var spare_parts_id in input.spare_parts_ids) + { + if (oldList.Any(x => x.spare_parts_id == spare_parts_id)) + continue; + list.Add(new EqpEquipSpareParts() + { + id = SnowflakeIdHelper.NextId(), + equip_id = input.equip_id, + spare_parts_id = spare_parts_id, + create_id = _userManager.UserId, + create_time = DateTime.Now, + org_id = orgId, + }); + } + + await _repository.InsertRangeAsync(list); + } + + [HttpPost] + public async Task GetEquipSparePartsList(EquipQueryInput input) + { + var db = _repository.AsSugarClient(); + Dictionary queryJson = new Dictionary(); + if (!string.IsNullOrEmpty(input.queryJson)) + { + queryJson = JsonConvert.DeserializeObject>(input.queryJson); + } + var result = await db.Queryable() + .LeftJoin((a,b)=>a.spare_parts_id==b.id) + .LeftJoin((a, b, c) => c.EnCode == Tnb.BasicData.DictConst.SparePartsType && c.DeleteMark == null) + .LeftJoin((a, b,c,d) => d.DictionaryTypeId == c.Id && b.type_id == d.EnCode) + .Where((a,b,c,d)=>a.equip_id==input.equip_id) + .WhereIF(queryJson.ContainsKey("code"),(a,b,c,d)=>b.code.Contains(queryJson["code"])) + .WhereIF(queryJson.ContainsKey("name"),(a,b,c,d)=>b.name.Contains(queryJson["name"])) + .Select((a, b, c,d) => new EquipSparePartsQueryOutput + { + id = a.id, + type_code = d.EnCode, + type_name = d.FullName, + code = b.code, + name = b.name, + specification = b.specification + }).ToPagedListAsync(input.currentPage, input.pageSize); + + return PageResult.SqlSugarPageResult(result); + } + } +} \ No newline at end of file diff --git a/EquipMgr/Tnb.EquipMgr/EqpRepairApplyService.cs b/EquipMgr/Tnb.EquipMgr/EqpRepairApplyService.cs index 79cc078a..18f17524 100644 --- a/EquipMgr/Tnb.EquipMgr/EqpRepairApplyService.cs +++ b/EquipMgr/Tnb.EquipMgr/EqpRepairApplyService.cs @@ -1,10 +1,13 @@ using JNPF.Common.Core.Manager; using JNPF.Common.Enums; +using JNPF.Common.Filter; using JNPF.Common.Security; using JNPF.DependencyInjection; using JNPF.DynamicApiController; using JNPF.FriendlyException; +using JNPF.Systems.Entitys.Permission; using Microsoft.AspNetCore.Mvc; +using Newtonsoft.Json; using SqlSugar; using Tnb.EquipMgr.Entities; using Tnb.EquipMgr.Entities.Dto; @@ -129,5 +132,35 @@ namespace Tnb.EquipMgr eqpRepairOutApply = eqpRepairOutApply, }; } + + [HttpPost] + public async Task GetRepairRecordList(EquipQueryInput input) + { + var db = _repository.AsSugarClient(); + Dictionary queryJson = new Dictionary(); + if (!string.IsNullOrEmpty(input.queryJson)) + { + queryJson = JsonConvert.DeserializeObject>(input.queryJson); + } + var result = await db.Queryable() + .LeftJoin((a,b)=>a.apply_user_id==b.Id) + .LeftJoin((a,b,c)=>a.repairer_id==c.Id) + .Where(a=>a.equip_id==input.equip_id) + .Select((a,b,c) => new EquipRepairRecordQueryOutput + { + id = a.id, + equip_id = a.equip_id, + code = a.code, + name = a.name, + apply_user_id =b.RealName, + is_ugent = a.is_ugent==1 ? "是" : "否", + description = a.description, + repair_description = a.repair_description, + complete_time = a.complete_time.Value.ToString("yyyy-MM-dd HH:mm"), + repairer_id = c.RealName + }).ToPagedListAsync(input.currentPage, input.pageSize); + + return PageResult.SqlSugarPageResult(result); + } } } \ No newline at end of file diff --git a/EquipMgr/Tnb.EquipMgr/EqpRepairOutApplyService.cs b/EquipMgr/Tnb.EquipMgr/EqpRepairOutApplyService.cs index 3d6f461a..400d3677 100644 --- a/EquipMgr/Tnb.EquipMgr/EqpRepairOutApplyService.cs +++ b/EquipMgr/Tnb.EquipMgr/EqpRepairOutApplyService.cs @@ -100,7 +100,6 @@ namespace Tnb.EquipMgr if(!result.IsSuccess) throw Oops.Oh(ErrorCode.COM1008); - //todo 退回流程 if (result.IsSuccess) { if (string.IsNullOrEmpty(input.id)) diff --git a/EquipMgr/Tnb.EquipMgr/EqpSubEquipService.cs b/EquipMgr/Tnb.EquipMgr/EqpSubEquipService.cs new file mode 100644 index 00000000..f7059e63 --- /dev/null +++ b/EquipMgr/Tnb.EquipMgr/EqpSubEquipService.cs @@ -0,0 +1,67 @@ +using JNPF.Common.Core.Manager; +using JNPF.Common.Filter; +using JNPF.DependencyInjection; +using JNPF.DynamicApiController; +using JNPF.Systems.Entitys.Permission; +using Microsoft.AspNetCore.Mvc; +using Newtonsoft.Json; +using SqlSugar; +using Tnb.EquipMgr.Entities; +using Tnb.EquipMgr.Entities.Dto; +using Tnb.EquipMgr.Interfaces; + +namespace Tnb.EquipMgr +{ + /// + /// 设备保养计划执行管理 + /// + [ApiDescriptionSettings(Tag = ModuleConsts.Tag, Area = ModuleConsts.Area, Order = 700)] + [Route("api/[area]/[controller]/[action]")] + public class EqpSubEquipService : IEqpSubEquipService, IDynamicApiController, ITransient + { + private readonly ISqlSugarRepository _repository; + private readonly IUserManager _userManager; + + public EqpSubEquipService(ISqlSugarRepository repository, + IUserManager userManager) + { + _repository = repository; + _userManager = userManager; + } + + [HttpPost] + public async Task GetSubEquipList(EquipQueryInput input) + { + var db = _repository.AsSugarClient(); + Dictionary queryJson = new Dictionary(); + if (!string.IsNullOrEmpty(input.queryJson)) + { + queryJson = JsonConvert.DeserializeObject>(input.queryJson); + } + var result = await db.Queryable() + .LeftJoin((a, b) => a.create_id == b.Id) + .LeftJoin((a, b,c) => a.modify_id == c.Id) + .LeftJoin((a, b,c,d) => a.equip_id == d.id) + .Where((a,b,c,d)=>a.equip_id==input.equip_id) + .WhereIF(queryJson.ContainsKey("code"),(a,b,c,d)=>a.code.Contains(queryJson["code"])) + .WhereIF(queryJson.ContainsKey("name"),(a,b,c,d)=>a.name.Contains(queryJson["name"])) + .Select((a, b, c,d) => new SubEquipQueryOutput + { + id = a.id, + create_id = b.RealName, + create_id_id = a.create_id, + create_time = a.create_time.Value.ToString("yyyy-MM-dd"), + equip_id=d.name, + equip_id_id= a.equip_id, + code = a.code, + modify_id = c.RealName, + modify_time = a.modify_time.Value.ToString("yyyy-MM-dd"), + name = a.name, + org_id = a.org_id, + specification = a.specification, + }).ToPagedListAsync(input.currentPage, input.pageSize); + + return PageResult.SqlSugarPageResult(result); + } + } +} \ No newline at end of file diff --git a/EquipMgr/Tnb.EquipMgr/EqpTechnologyParameterService.cs b/EquipMgr/Tnb.EquipMgr/EqpTechnologyParameterService.cs new file mode 100644 index 00000000..b36da391 --- /dev/null +++ b/EquipMgr/Tnb.EquipMgr/EqpTechnologyParameterService.cs @@ -0,0 +1,52 @@ +using JNPF.Common.Core.Manager; +using JNPF.Common.Filter; +using JNPF.DependencyInjection; +using JNPF.DynamicApiController; +using Microsoft.AspNetCore.Mvc; +using Newtonsoft.Json; +using SqlSugar; +using Tnb.EquipMgr.Entities; +using Tnb.EquipMgr.Entities.Dto; +using Tnb.EquipMgr.Interfaces; + +namespace Tnb.EquipMgr +{ + /// 设备备品备件 + ///
+ [ApiDescriptionSettings(Tag = ModuleConsts.Tag, Area = ModuleConsts.Area, Order = 700)] + [Route("api/[area]/[controller]/[action]")] + public class EqpTechnologyParameterService : IEqpTechnologyParameterService, IDynamicApiController, ITransient + { + private readonly ISqlSugarRepository _repository; + private readonly IUserManager _userManager; + + public EqpTechnologyParameterService(ISqlSugarRepository repository, IUserManager userManager) + { + _userManager = userManager; + _repository = repository; + } + + [HttpPost] + public async Task GetEquipTechnologyParameterList(EquipQueryInput input) + { + var db = _repository.AsSugarClient(); + Dictionary queryJson = new Dictionary(); + if (!string.IsNullOrEmpty(input.queryJson)) + { + queryJson = JsonConvert.DeserializeObject>(input.queryJson); + } + var result = await db.Queryable() + .Where(a=>a.equip_id==input.equip_id) + .WhereIF(queryJson.ContainsKey("name"),a=>a.name.Contains(queryJson["name"])) + .Select(a => new EquipTechnologyParameterQueryOutput + { + id = a.id, + name = a.name, + definition = a.definition, + remark = a.remark + }).ToPagedListAsync(input.currentPage, input.pageSize); + + return PageResult.SqlSugarPageResult(result); + } + } +} \ No newline at end of file diff --git a/EquipMgr/Tnb.EquipMgr/EquMaintainRecordService.cs b/EquipMgr/Tnb.EquipMgr/EquMaintainRecordService.cs index 0d526d9b..62c6dc6f 100644 --- a/EquipMgr/Tnb.EquipMgr/EquMaintainRecordService.cs +++ b/EquipMgr/Tnb.EquipMgr/EquMaintainRecordService.cs @@ -1,9 +1,11 @@ using JNPF.Common.Core.Manager; using JNPF.Common.Dtos.VisualDev; using JNPF.Common.Enums; +using JNPF.Common.Filter; using JNPF.DependencyInjection; using JNPF.DynamicApiController; using JNPF.FriendlyException; +using JNPF.Systems.Entitys.Permission; using JNPF.VisualDev; using JNPF.VisualDev.Entitys; using JNPF.VisualDev.Interfaces; @@ -142,5 +144,41 @@ namespace Tnb.EquipMgr if(!result.IsSuccess) throw Oops.Oh(ErrorCode.COM1008); return result.IsSuccess ? "复核成功" : result.ErrorMessage; } + + [HttpPost] + public async Task GetMaintainRecordList(EquipQueryInput input) + { + var db = _repository.AsSugarClient(); + Dictionary queryJson = new Dictionary(); + if (!string.IsNullOrEmpty(input.queryJson)) + { + queryJson = JsonConvert.DeserializeObject>(input.queryJson); + } + var result = await db.Queryable() + .LeftJoin((a,b)=>a.equip_id==b.id) + .LeftJoin((a,b,c)=>a.execute_user_id==c.Id) + .LeftJoin((a,b,c,d)=>a.repeat_user_id==d.Id) + .Where(a=>a.equip_id==input.equip_id) + .Select((a,b,c,d) => new EquipMaintainRecordQueryOutput + { + id = a.id, + attachment = a.attachment, + create_time = a.create_time.Value.ToString("yyyy-MM-dd HH:mm"), + equip_id = b.code, + equip_id_id = a.equip_id, + repeat_remark = a.repeat_remark, + repeat_result = a.repeat_result=="1"?"合格":"不合格", + repeat_time = a.repeat_time.Value.ToString("yyyy-MM-dd HH:mm"), + repeat_user_id = d.RealName, + result = a.result=="1"?"合格":"不合格", + result_remark = a.result_remark, + maintain_tem_equip_id = a.maintain_tem_equip_id, + execute_time = a.execute_time.Value.ToString("yyyy-MM-dd HH:mm"), + execute_user_id = c.RealName, + status = SqlFunc.IF(a.status.Equals("1")).Return("待执行").ElseIF(a.status.Equals("2")).Return("待复核").ElseIF(a.status.Equals("3")).Return("已完成").End("") + }).ToPagedListAsync(input.currentPage, input.pageSize); + + return PageResult.SqlSugarPageResult(result); + } } } \ No newline at end of file diff --git a/EquipMgr/Tnb.EquipMgr/EquSpotInsRecordService.cs b/EquipMgr/Tnb.EquipMgr/EquSpotInsRecordService.cs index cf3a76aa..f3b10465 100644 --- a/EquipMgr/Tnb.EquipMgr/EquSpotInsRecordService.cs +++ b/EquipMgr/Tnb.EquipMgr/EquSpotInsRecordService.cs @@ -1,9 +1,11 @@ using JNPF.Common.Core.Manager; using JNPF.Common.Dtos.VisualDev; using JNPF.Common.Enums; +using JNPF.Common.Filter; using JNPF.DependencyInjection; using JNPF.DynamicApiController; using JNPF.FriendlyException; +using JNPF.Systems.Entitys.Permission; using JNPF.VisualDev; using JNPF.VisualDev.Entitys; using JNPF.VisualDev.Interfaces; @@ -126,5 +128,38 @@ namespace Tnb.EquipMgr status = SpotInsRecordExecutionStatus.COMPLETED }, x => x.id == input.id); } + + [HttpPost] + public async Task GetSpotInsRecordList(EquipQueryInput input) + { + var db = _repository.AsSugarClient(); + Dictionary queryJson = new Dictionary(); + if (!string.IsNullOrEmpty(input.queryJson)) + { + queryJson = JsonConvert.DeserializeObject>(input.queryJson); + } + var result = await db.Queryable() + .LeftJoin((a,b)=>a.repeat_user_id==b.Id) + .Where(a=>a.equip_id==input.equip_id) + .Select((a,b) => new EquipSpotInsRecordQueryOutput + { + id = a.id, + attachment = a.attachment, + create_time = a.create_time.Value.ToString("yyyy-MM-dd HH:mm"), + equip_id = a.equip_id, + repeat_remark = a.repeat_remark, + repeat_result = a.repeat_result=="1"?"合格":"不合格", + repeat_time = a.repeat_time.Value.ToString("yyyy-MM-dd HH:mm"), + repeat_user_id = b.RealName, + result = a.result=="1"?"合格":"不合格", + result_remark = a.result_remark, + spot_ins_tem_equip_id = a.spot_ins_tem_equip_id, + spot_record_date_time = a.spot_record_date_time.Value.ToString("yyyy-MM-dd HH:mm"), + spot_record_user_id = a.spot_record_user_id, + status = SqlFunc.IF(a.status.Equals("1")).Return("待执行").ElseIF(a.status.Equals("2")).Return("待复核").ElseIF(a.status.Equals("3")).Return("已完成").End("") + }).ToPagedListAsync(input.currentPage, input.pageSize); + + return PageResult.SqlSugarPageResult(result); + } } } \ No newline at end of file diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryH.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryH.cs index 76092322..3bdce8b2 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryH.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryH.cs @@ -42,7 +42,7 @@ public partial class WmsCarryH : BaseEntity /// /// 载具状态 /// - public int carry_status { get; set; }; + public int carry_status { get; set; } /// /// 载具分类ID