From 5365efa279fbea2bf958cbb55bedbb580111448a Mon Sep 17 00:00:00 2001 From: qianjiawei <1184704771@qq.com> Date: Tue, 12 Sep 2023 17:33:25 +0800 Subject: [PATCH] =?UTF-8?q?andon=E5=91=BC=E5=8F=AB=20aql=20=E6=A8=A1?= =?UTF-8?q?=E5=85=B7=E4=BF=9D=E5=85=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ToolMoldMaintainRunService.cs | 67 +++++++++++++++ .../Dto/PrdManage/AndonRecordInput.cs | 21 +++++ .../Entity/AndonBreakDown.cs | 31 +++++++ .../Entity/AndonRecords.cs | 40 +++++++++ .../IAndonService.cs | 16 ++++ .../Tnb.ProductionMgr/AndonService.cs | 86 +++++++++++++++++++ .../Entity/QcAqlSampleCode.cs | 43 ++++++++++ .../Entity/QcAqlSamplePlan.cs | 53 ++++++++++++ QcMgr/Tnb.QcMgr/QcSpcService.cs | 4 + 9 files changed, 361 insertions(+) create mode 100644 ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/AndonRecordInput.cs create mode 100644 ProductionMgr/Tnb.ProductionMgr.Entities/Entity/AndonBreakDown.cs create mode 100644 ProductionMgr/Tnb.ProductionMgr.Entities/Entity/AndonRecords.cs create mode 100644 ProductionMgr/Tnb.ProductionMgr.Interfaces/IAndonService.cs create mode 100644 ProductionMgr/Tnb.ProductionMgr/AndonService.cs create mode 100644 QcMgr/Tnb.QcMgr.Entities/Entity/QcAqlSampleCode.cs create mode 100644 QcMgr/Tnb.QcMgr.Entities/Entity/QcAqlSamplePlan.cs diff --git a/EquipMgr/Tnb.EquipMgr/ToolMoldMaintainRunService.cs b/EquipMgr/Tnb.EquipMgr/ToolMoldMaintainRunService.cs index 72038c0d..e2587d04 100644 --- a/EquipMgr/Tnb.EquipMgr/ToolMoldMaintainRunService.cs +++ b/EquipMgr/Tnb.EquipMgr/ToolMoldMaintainRunService.cs @@ -2,8 +2,10 @@ using System.Collections.Generic; using System.Dynamic; using System.Linq; +using System.Reactive.Joins; using System.Text; using System.Threading.Tasks; +using Aop.Api.Domain; using Aspose.Cells.Drawing; using DingTalk.Api.Request; using JNPF.Common.Core.Manager; @@ -13,7 +15,10 @@ using JNPF.DependencyInjection; using JNPF.DynamicApiController; using JNPF.FriendlyException; using JNPF.Logging; +using JNPF.Systems.Entitys.Permission; +using JNPF.Systems.Entitys.System; using JNPF.Systems.Interfaces.System; +using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Newtonsoft.Json; using SqlSugar; @@ -93,6 +98,68 @@ namespace Tnb.EquipMgr } return result; } + + [HttpGet] + public async Task GetMaintainInfo() + { + List result = new(); + var plans = await _db.Queryable().ToListAsync(); + var ToolMolds = await _db.Queryable().ToListAsync(); + var ToolMoldsEquipments = await _db.Queryable().ToListAsync(); + var EqpEquipments = await _db.Queryable().ToListAsync(); + var dic = await _db.Queryable().Where(p => p.DictionaryTypeId == "26149299883285").ToListAsync(); + var users = await _db.Queryable().ToListAsync(); + foreach (var plan in plans) + { + 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 == plan.id) + .Select((a, b, c) => new + { + mold_id = a.mold_id, + plan_start_time = c.plan_start_time, + }).ToListAsync(); + if (planMoldRelations?.Count > 0) + { + var mids = planMoldRelations.Select(x => x.mold_id).ToList(); + var molds = ToolMolds.Where(it => mids.Contains(it.id)).ToList(); + if (molds?.Count > 0) + { + List infos = new List { }; + for (int i = 0, cnt = molds.Count; i < cnt; i++) + { + 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 = dic.Where(p => p.Id == mold.mold_status).Any() ? dic.Where(p => p.Id == mold.mold_status).First().FullName : ""; + info.maintain_qty = mold.maintain_qty; + info.plan_start_time = planMoldRelations[i].plan_start_time == null ? "" : ((DateTime)planMoldRelations[i].plan_start_time).ToString("yyyy-MM-dd"); + info.createtime = plan.create_time == null ? "" : ((DateTime)plan.create_time).ToString("yyyy-MM-dd"); + info.status = plan.status == "UnMaintain" ? "待保养" : "已完成"; + info.createuser = string.IsNullOrEmpty(plan.create_id) ? "" : users.Where(p => p.Id == plan.create_id).First().RealName; + info.plan_id = plan.id; + var moldEqpRelation = ToolMoldsEquipments.Where(it => it.mold_id == mold.id).FirstOrDefault(); + if (moldEqpRelation != null) + { + var eqp = EqpEquipments.Where(it => it.id == moldEqpRelation.equipment_id).FirstOrDefault(); + if (eqp != null) + { + info.eqp_code = eqp.code; + info.eqp_name = eqp.name; + } + } + result.Add(info); + } + } + } + + } + return result; + } + /// /// 根据计划Id、模具ID获取,保养组及项目信息 /// diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/AndonRecordInput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/AndonRecordInput.cs new file mode 100644 index 00000000..c9100230 --- /dev/null +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/AndonRecordInput.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tnb.ProductionMgr.Entities.Dto.PrdManage +{ + public class AndonRecordInput + { + /// + /// 关联工单 + /// + public string? mo_id { get; set; } + + /// + /// 故障 + /// + public string? breakdown { get; set; } + } +} diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/AndonBreakDown.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/AndonBreakDown.cs new file mode 100644 index 00000000..38142fc2 --- /dev/null +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/AndonBreakDown.cs @@ -0,0 +1,31 @@ +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.ProductionMgr.Entities +{ + [SugarTable("andon_breakdown")] + public partial class AndonBreakDown : BaseEntity + { + public AndonBreakDown() + { + id = SnowflakeIdHelper.NextId(); + } + public string? name { get; set; } + public string? code { get; set; } + public string? description { get; set; } + + public string? type_id { get; set; } + public string? remark { get; set; } + public string? create_id { get; set; } + public DateTime? create_time { get; set; } + public string? modify_id { get; set; } + public DateTime? modify_time { get; set; } + + } +} \ No newline at end of file diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/AndonRecords.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/AndonRecords.cs new file mode 100644 index 00000000..68b8deb0 --- /dev/null +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/AndonRecords.cs @@ -0,0 +1,40 @@ +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.ProductionMgr.Entities +{ + [SugarTable("andon_records")] + public partial class AndonRecords : BaseEntity + { + public AndonRecords() + { + id = SnowflakeIdHelper.NextId(); + } + /// + /// 关联工单 + /// + public string? mo_id { get; set; } + + /// + /// 故障类别 + /// + public string? breakdown_type { get; set; } + + /// + /// 故障 + /// + public string? breakdown { 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? remark { get; set; } + } +} diff --git a/ProductionMgr/Tnb.ProductionMgr.Interfaces/IAndonService.cs b/ProductionMgr/Tnb.ProductionMgr.Interfaces/IAndonService.cs new file mode 100644 index 00000000..4f296f36 --- /dev/null +++ b/ProductionMgr/Tnb.ProductionMgr.Interfaces/IAndonService.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tnb.ProductionMgr.Entities.Dto.PrdManage; + +namespace Tnb.ProductionMgr.Interfaces +{ + public interface IAndonService + { + public Task GetPrdTask(string stationId); + + public Task SaveData(AndonRecordInput AndonRecordInput); + } +} diff --git a/ProductionMgr/Tnb.ProductionMgr/AndonService.cs b/ProductionMgr/Tnb.ProductionMgr/AndonService.cs new file mode 100644 index 00000000..c1bfbf66 --- /dev/null +++ b/ProductionMgr/Tnb.ProductionMgr/AndonService.cs @@ -0,0 +1,86 @@ +using System; +using System.Collections.Generic; +using System.Dynamic; +using System.Linq; +using System.Numerics; +using System.Reactive.Joins; +using System.Text; +using System.Threading.Tasks; +using Aop.Api.Domain; +using Aspose.Cells.Drawing; +using JNPF.Common.Core.Manager; +using JNPF.DependencyInjection; +using JNPF.DynamicApiController; +using JNPF.Message.Service; +using JNPF.Systems.Interfaces.System; +using JNPF.TaskScheduler; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using SqlSugar; +using Tnb.BasicData.Entities; +using Tnb.EquipMgr.Interfaces; +using Tnb.ProductionMgr.Entities; +using Tnb.ProductionMgr.Entities.Dto.PrdManage; +using Tnb.ProductionMgr.Entities.Entity; +using Tnb.ProductionMgr.Interfaces; + +namespace Tnb.ProductionMgr +{ + [ApiDescriptionSettings(Tag = ModuleConst.Tag, Area = ModuleConst.Area, Order = 700)] + [Route("api/[area]/[controller]/[action]")] + public class AndonService : IAndonService, IDynamicApiController, ITransient + { + private readonly ISqlSugarClient _db; + private readonly IUserManager _userManager; + public AndonService(ISqlSugarRepository repository,IUserManager userManager) + { + _userManager = userManager; + _db = repository.AsSugarClient(); + } + [HttpGet] + public async Task GetPrdTask(string stationId) + { + Dictionary dic = new Dictionary(); + dic.Add("ToBeStarted", "待开工"); + dic.Add("InProgress", "进行中"); + dic.Add("Closed", "关闭"); + dic.Add("Complated", "完工"); + dic.Add("ToBeScheduled", "待下发"); + dic.Add("Pause", "暂停"); + dic.Add("Exception", "异常"); + dic.Add("Revoke", "撤销"); + List result = new(); + var List = await _db.Queryable() + .WhereIF(!string.IsNullOrEmpty(stationId), p => p.workstation_id == stationId) + .ToListAsync(); + var materials = await _db.Queryable().ToListAsync(); + foreach (var data in List) + { + dynamic info = new ExpandoObject(); + info.id = data.id; + info.material_id = materials.Where(p => p.id == data.material_id).Any() ? materials.Where(p => p.id == data.material_id).First().name : ""; + info.material_id_id = data.material_id; + info.status = dic.Where(p => p.Key == data.mo_task_status).Any() ? dic.Where(p => p.Key == data.mo_task_status).First().Value : ""; + info.mo_code = data.mo_task_code; + info.mo_type = data.schedule_type == 1 ? "注塑工单" : "组装工单"; + info.plan_gty = data.plan_qty; + info.plan_start_date = data.estimated_start_date == null ? "" : ((DateTime)data.estimated_start_date!).ToString("yyyy-MM-dd"); + info.plan_end_date = data.estimated_end_date == null ? "" : ((DateTime)data.estimated_end_date!).ToString("yyyy-MM-dd"); + result.Add(info); + } + return result; + } + [HttpPost] + public async Task SaveData(AndonRecordInput AndonRecordInput) + { + var list = _db.Queryable().ToList(); + AndonRecords andonRecord = new AndonRecords(); + andonRecord.mo_id = AndonRecordInput.mo_id; + andonRecord.breakdown_type = list.Where(p => p.id == AndonRecordInput.breakdown).Any() ? list.Where(p => p.id == AndonRecordInput.breakdown).First().type_id : ""; + andonRecord.breakdown = AndonRecordInput.breakdown; + andonRecord.create_time = DateTime.Now; + andonRecord.create_id = _userManager.UserId; + await _db.Insertable(andonRecord).ExecuteCommandAsync(); + } + } +} diff --git a/QcMgr/Tnb.QcMgr.Entities/Entity/QcAqlSampleCode.cs b/QcMgr/Tnb.QcMgr.Entities/Entity/QcAqlSampleCode.cs new file mode 100644 index 00000000..40291e15 --- /dev/null +++ b/QcMgr/Tnb.QcMgr.Entities/Entity/QcAqlSampleCode.cs @@ -0,0 +1,43 @@ +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_aql_sample_code")] + public partial class QcAqlSampleCode : BaseEntity + { + public QcAqlSampleCode() + { + id = SnowflakeIdHelper.NextId(); + } + /// + /// 检验水平 + /// + public string? checklevel { get; set; } + + /// + /// 最小值 + /// + public int? min { get; set; } + + /// + /// 最大值 + /// + public int? max { get; set; } + + /// + /// 字码 + /// + public string? code { get; set; } + + } +} diff --git a/QcMgr/Tnb.QcMgr.Entities/Entity/QcAqlSamplePlan.cs b/QcMgr/Tnb.QcMgr.Entities/Entity/QcAqlSamplePlan.cs new file mode 100644 index 00000000..a17387ae --- /dev/null +++ b/QcMgr/Tnb.QcMgr.Entities/Entity/QcAqlSamplePlan.cs @@ -0,0 +1,53 @@ +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 +{ + /// + /// aql抽样方案 + /// + [SugarTable("qc_aql_sample_plan")] + public partial class QcAqlSamplePlan : BaseEntity + { + public QcAqlSamplePlan() + { + id = SnowflakeIdHelper.NextId(); + } + /// + /// 检验类型 + /// + public string? checktype { get; set; } + + /// + /// 字码 + /// + public string? code { get; set; } + + /// + /// 样本量 + /// + public int? samplesize { get; set; } + + /// + /// aql值 + /// + public decimal? aqlvalue { get; set; } + + /// + /// 接受 + /// + public int? ac { get; set; } + + /// + /// 拒收 + /// + public int? re { get; set; } + + } +} diff --git a/QcMgr/Tnb.QcMgr/QcSpcService.cs b/QcMgr/Tnb.QcMgr/QcSpcService.cs index 36753845..70a74eb1 100644 --- a/QcMgr/Tnb.QcMgr/QcSpcService.cs +++ b/QcMgr/Tnb.QcMgr/QcSpcService.cs @@ -10,6 +10,7 @@ using JNPF.Common.Enums; using JNPF.DependencyInjection; using JNPF.DynamicApiController; using JNPF.FriendlyException; +using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Spire.Xls.Core; using SqlSugar; @@ -377,5 +378,8 @@ namespace Tnb.QcMgr } return floats.Average(); } + + + } }