From 967c013d16b4cb7978646b28d5b0d0eeee54fb02 Mon Sep 17 00:00:00 2001 From: "DEVICE8\\12494" Date: Tue, 25 Apr 2023 15:54:27 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=9F=E4=BA=A7=E7=AE=A1=E7=90=86=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=EF=BC=8C=E5=90=8C=E7=BB=84=E5=B7=A5=E5=8D=95=E4=B8=8B?= =?UTF-8?q?=E5=8F=91=EF=BC=8C=E5=8F=96=E6=B6=88=E5=90=8C=E7=BB=84=E5=B7=A5?= =?UTF-8?q?=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Consts/DictionaryConstants.cs | 7 +- .../Dto/PrdManage/EquipmentListOutput.cs | 31 +++ .../Entity/EqpEquipment.cs | 223 ++++++++++++++++++ .../Tnb.ProductionMgr.Entitys/Entity/PrdMo.cs | 7 +- .../Entity/PrdTask.cs | 2 +- .../Tnb.ProductionMgr/PrdMoService.cs | 106 +++++++-- visualdev/Tnb.VisualDev/RunService.cs | 93 +++++++- 7 files changed, 447 insertions(+), 22 deletions(-) create mode 100644 ProductionMgr/Tnb.ProductionMgr.Entitys/Dto/PrdManage/EquipmentListOutput.cs create mode 100644 ProductionMgr/Tnb.ProductionMgr.Entitys/Entity/EqpEquipment.cs diff --git a/ProductionMgr/Tnb.ProductionMgr.Entitys/Consts/DictionaryConstants.cs b/ProductionMgr/Tnb.ProductionMgr.Entitys/Consts/DictionaryConstants.cs index 46c93d21..903c5d76 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Entitys/Consts/DictionaryConstants.cs +++ b/ProductionMgr/Tnb.ProductionMgr.Entitys/Consts/DictionaryConstants.cs @@ -12,8 +12,11 @@ namespace Tnb.ProductionMgr.Entitys.新文件夹 /// 生产任务状态TypeId /// public const string PrdTaskStatusTypeId = "25572555259157"; + /// + /// 工单状态 已下发字典Id + /// + public const string IssueId = "25019232867093"; - } /// /// 工单状态 @@ -29,4 +32,6 @@ namespace Tnb.ProductionMgr.Entitys.新文件夹 /// public const string WaitProductId = "25019244276501"; } + + } diff --git a/ProductionMgr/Tnb.ProductionMgr.Entitys/Dto/PrdManage/EquipmentListOutput.cs b/ProductionMgr/Tnb.ProductionMgr.Entitys/Dto/PrdManage/EquipmentListOutput.cs new file mode 100644 index 00000000..de4f87f6 --- /dev/null +++ b/ProductionMgr/Tnb.ProductionMgr.Entitys/Dto/PrdManage/EquipmentListOutput.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tnb.ProductionMgr.Entitys.Entity; + +namespace Tnb.ProductionMgr.Entitys.Dto.PrdManage +{ + /// + /// 设备列表输出参数 + /// + public class EquipmentListOutput : EqpEquipment + { + /// + /// 任务单数量 + /// + public int task_list_qty { get; set; } + /// + /// 吨位 + /// + public double tonnage { get; set; } + /// + /// 最早开始时间 + /// + public DateTime? first_date { get; set; } + + + + } +} diff --git a/ProductionMgr/Tnb.ProductionMgr.Entitys/Entity/EqpEquipment.cs b/ProductionMgr/Tnb.ProductionMgr.Entitys/Entity/EqpEquipment.cs new file mode 100644 index 00000000..d98420a2 --- /dev/null +++ b/ProductionMgr/Tnb.ProductionMgr.Entitys/Entity/EqpEquipment.cs @@ -0,0 +1,223 @@ +using System; +using System.Linq; +using System.Text; +using SqlSugar; + +namespace Tnb.ProductionMgr.Entitys.Entity +{ + /// + ///设备登记 + /// + [SugarTable("eqp_equipment")] + public partial class EqpEquipment + { + public EqpEquipment(){ + + + } + /// + /// Desc:自增ID + /// Default: + /// Nullable:False + /// + [SugarColumn(IsPrimaryKey=true)] + public string id {get;set;} + + /// + /// Desc:设备代码 + /// Default: + /// Nullable:False + /// + public string eqp_code {get;set;} + + /// + /// Desc:设备名称 + /// Default: + /// Nullable:False + /// + public string eqp_name {get;set;} + + /// + /// Desc:设备类型代码 + /// Default: + /// Nullable:False + /// + public string eqp_type_code {get;set;} + + /// + /// Desc:验收状态(合格:Qualified/不合格:Unqualified) + /// Default: + /// Nullable:False + /// + public string accept_status {get;set;} + + /// + /// Desc:使用部门代码 + /// Default: + /// Nullable:False + /// + public string use_department_code {get;set;} + + /// + /// Desc:安装日期 + /// Default: + /// Nullable:False + /// + public string install_date {get;set;} + + /// + /// Desc:创建时间 + /// Default: + /// Nullable:True + /// + public DateTime? create_time {get;set;} + + /// + /// Desc:修改时间 + /// Default: + /// Nullable:True + /// + public DateTime? modify_time {get;set;} + + /// + /// Desc:扩展字段 + /// Default: + /// Nullable:True + /// + public string extras {get;set;} + + /// + /// Desc:模具Id + /// Default: + /// Nullable:True + /// + public string mold_id {get;set;} + + /// + /// Desc:所属组织ID + /// Default:NULL::character varying + /// Nullable:True + /// + public string org_id {get;set;} + + /// + /// Desc:设备类型ID,EQP_EQUIPMENTTYPE.ID + /// Default:NULL::character varying + /// Nullable:True + /// + public string eqp_type_id {get;set;} + + /// + /// Desc:设备生产日期 + /// Default:NULL::character varying + /// Nullable:True + /// + public string product_date {get;set;} + + /// + /// Desc:设备生产厂家 + /// Default:NULL::character varying + /// Nullable:True + /// + public string supplier_code {get;set;} + + /// + /// Desc:正式使用日期 + /// Default:NULL::character varying + /// Nullable:True + /// + public string use_date {get;set;} + + /// + /// Desc:验收日期 + /// Default:NULL::character varying + /// Nullable:True + /// + public string accept_date {get;set;} + + /// + /// Desc:管理部门 + /// Default:NULL::character varying + /// Nullable:True + /// + public string manage_department_code {get;set;} + + /// + /// Desc:工段(车间)代码 + /// Default:NULL::character varying + /// Nullable:True + /// + public string segment_code {get;set;} + + /// + /// Desc:工位代码 + /// Default:NULL::character varying + /// Nullable:True + /// + public string station_code {get;set;} + + /// + /// Desc:质检代码,良率计算 + /// Default:NULL::character varying + /// Nullable:True + /// + public string quality_station_code {get;set;} + + /// + /// Desc:生产节拍 + /// Default:NULL::character varying + /// Nullable:True + /// + public string process_time {get;set;} + + /// + /// Desc:时间单位: 秒:s 分钟:m 小时:h + /// Default:NULL::character varying + /// Nullable:True + /// + public string time_unit {get;set;} + + /// + /// Desc:设备当前状态,状态代码 + /// Default:NULL::character varying + /// Nullable:True + /// + public string current_status {get;set;} + + /// + /// Desc:技术性能 + /// Default:NULL::character varying + /// Nullable:True + /// + public string techno_logy {get;set;} + + /// + /// Desc:备注 + /// Default:NULL::character varying + /// Nullable:True + /// + public string remark {get;set;} + + /// + /// Desc:时间戳 + /// Default:NULL::character varying + /// Nullable:True + /// + public string timestamp {get;set;} + + /// + /// Desc:创建用户 + /// Default:NULL::character varying + /// Nullable:True + /// + public string create_id {get;set;} + + /// + /// Desc:修改用户 + /// Default:NULL::character varying + /// Nullable:True + /// + public string modify_id {get;set;} + + } +} diff --git a/ProductionMgr/Tnb.ProductionMgr.Entitys/Entity/PrdMo.cs b/ProductionMgr/Tnb.ProductionMgr.Entitys/Entity/PrdMo.cs index 006a3e6f..9822dba2 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Entitys/Entity/PrdMo.cs +++ b/ProductionMgr/Tnb.ProductionMgr.Entitys/Entity/PrdMo.cs @@ -30,10 +30,13 @@ namespace Tnb.ProductionMgr.Entitys.Entity /// Nullable:False /// public string mo_code { get; set; } + /// /// 产品ID /// - //public string item_id { get; set; } + public string item_id { get; set; } + + /// /// Desc:产品代码, BAS_MATERIA.MATERIALCODE BAS_ITEM.ITEMCODE @@ -320,7 +323,7 @@ namespace Tnb.ProductionMgr.Entitys.Entity /// Default:NULL::character varying /// Nullable:True /// - public string mo_group_no { get; set; } + public string mo_task_no { get; set; } } } diff --git a/ProductionMgr/Tnb.ProductionMgr.Entitys/Entity/PrdTask.cs b/ProductionMgr/Tnb.ProductionMgr.Entitys/Entity/PrdTask.cs index 48e25b0a..5c2b561f 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Entitys/Entity/PrdTask.cs +++ b/ProductionMgr/Tnb.ProductionMgr.Entitys/Entity/PrdTask.cs @@ -120,7 +120,7 @@ namespace Tnb.ProductionMgr.Entitys.Entity /// Default: /// Nullable:True /// - public decimal? tonnage { get; set; } + public double tonnage { get; set; } /// /// Desc:已排产数 diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMoService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMoService.cs index 73ebf359..c8d2e4f9 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdMoService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdMoService.cs @@ -6,6 +6,7 @@ using JNPF.Common.Filter; using JNPF.Common.Security; using JNPF.DependencyInjection; using JNPF.DynamicApiController; +using JNPF.FriendlyException; using JNPF.Logging; using JNPF.Systems.Entitys.System; using JNPF.Systems.Interfaces.System; @@ -13,6 +14,7 @@ using Mapster; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using NPOI.OpenXmlFormats.Shared; +using Senparc.Weixin.Work.AdvancedAPIs.OaDataOpen; using SqlSugar; using Tnb.ProductionMgr.Entitys.Dto.PrdManage; using Tnb.ProductionMgr.Entitys.Dto.WorkOrder; @@ -26,8 +28,8 @@ namespace Tnb.ProductionPlanMgr /// /// 生产计划管理 /// - [ApiDescriptionSettings(Tag = "ProductionMgr", Name = "WorkOrderCreate", Order = 700)] - [Route("api/production/[controller]")] + [ApiDescriptionSettings(Tag = "ProductionMgr", Area = "production", Order = 700)] + [Route("api/[area]/[controller]/[action]")] public class PrdMoService : IPrdMoService, IDynamicApiController, ITransient { private readonly ISqlSugarRepository _repository; @@ -59,9 +61,18 @@ namespace Tnb.ProductionPlanMgr { throw new ArgumentNullException(nameof(input)); } + var db = _repository.AsSugarClient(); + //获取同组工单的Id,一起下发 + var combineMoCodes = await db.Queryable().Where(it => input.WorkOrderIds.Contains(it.id)).Select(it => it.combine_mo_code).ToListAsync(); + if (combineMoCodes?.Count > 0) + { + var moIds = await db.Queryable().Where(it => combineMoCodes.Contains(it.combine_mo_code) && !input.WorkOrderIds.Contains(it.id)).Select(it => it.id).ToListAsync(); + input.WorkOrderIds = input.WorkOrderIds.Concat(moIds).ToList(); + } + var row = await db.Updateable() - .SetColumns(it => new PrdMo { mo_status = "25019232867093" }) + .SetColumns(it => new PrdMo { mo_status = DictionaryConstants.IssueId }) .Where(it => input.WorkOrderIds.Contains(it.id)) .ExecuteCommandAsync(); return (row > 0); @@ -74,31 +85,73 @@ namespace Tnb.ProductionPlanMgr [HttpPost("relevancy")] public async Task RelevancySameGroupMo(MoCrInput input) { - var row = -1; + (bool executeRes, string errMsg) multi = (true, ""); var list = await _repository.AsSugarClient().Queryable() - .InnerJoin((a, b) => a.item_code == b.item_code) + .InnerJoin((a, b) => a.item_code == b.item_id) .Where((a, b) => input.WorkOrderIds.Contains(a.id)) .Select((a, b) => new { planDate = a.plan_start_date, - moldId = b.id, + mold_code = b.mold_code, }).ToListAsync(); + var planDateAll = true; + var moldIdAll = true; if (list?.Count > 0) { var planDate = list.FirstOrDefault()?.planDate; - var moId = list.FirstOrDefault()?.moldId; + var moldCode = list.FirstOrDefault()?.mold_code; - var all = list.Skip(1).All(x => x.planDate == planDate && x.moldId == moId); - if (all) + planDateAll = list.Skip(1).All(x => x.planDate == planDate); + moldIdAll = list.Skip(1).All(x => x.mold_code == moldCode); + if (planDateAll && moldIdAll) { var groupId = SnowflakeIdHelper.NextId(); - row = await _repository.AsSugarClient().Updateable() - .SetColumns(c => new PrdMo { mo_group_no = groupId }) + multi.executeRes = await _repository.AsSugarClient().Updateable() + .SetColumns(c => new PrdMo { combine_mo_code = groupId }) .Where(it => input.WorkOrderIds.Contains(it.id)) - .ExecuteCommandAsync(); + .ExecuteCommandHasChangeAsync(); + } + else + { + multi.executeRes = false; + if (!planDateAll) + { + throw new AppFriendlyException("计划开始日期不一致", null); + } + if (!moldIdAll) + { + throw new AppFriendlyException("未关联到同一模具下", null); + } + } + + } + else + { + multi.executeRes = false; + if (!planDateAll) + { + throw new AppFriendlyException("计划开始日期不一致", null); + } + if (!moldIdAll) + { + throw new AppFriendlyException("未关联到同一模具下", null); } } - return row > 0; + return multi; + } + + /// + /// 取消关联 + /// + /// 取消关联输入参数 + /// + [HttpPost("CanelRelevancy")] + public async Task CanelRelevancy(MoCrInput input) + { + return await _repository.AsSugarClient().Updateable() + .SetColumns(c => new PrdMo { combine_mo_code = "" }) + .Where(it => input.WorkOrderIds.Contains(it.id)) + .ExecuteCommandHasChangeAsync(); } @@ -139,7 +192,7 @@ namespace Tnb.ProductionPlanMgr { await db.Ado.BeginTranAsync(); - + row = await db.Storageable(entity).ExecuteCommandAsync(); var taskLogEntity = input.Adapt(); taskLogEntity.id ??= SnowflakeIdHelper.NextId(); @@ -236,13 +289,36 @@ namespace Tnb.ProductionPlanMgr mold_code = a.mold_code, mold_name = a.mold_name, item_name = b.item_name, - item_code = b.item_code, cavity_qty = a.cavity_qty, + item_code = b.item_code, }) .ToListAsync(); return list; } + /// + /// 根据模具Id获取设备列表 + /// + /// + /// + [HttpGet("equipments/{moldId}")] + public async Task GetEquipmentListByMoldId(string moldId) + { + var items = await _repository.AsSugarClient().Queryable() + .InnerJoin((a, b) => a.id == b.eqp_id) + .Where((a, b) => a.mold_id == moldId) + .Select((a, b) => new + { + eqp_code = a.eqp_code, + eqp_type_code = a.eqp_type_code, + tonnage = b.tonnage, + task_list_qty = SqlFunc.Subqueryable().Where(it => it.eqp_id == a.id).Count(), + first_date = SqlFunc.Subqueryable().Where(it => it.eqp_id == a.id).OrderByDesc(o => o.estimated_end_date).Select(it => it.estimated_end_date) + }).ToListAsync(); + return items; + + } + /// /// 工单调整-生产任务重新排序 /// diff --git a/visualdev/Tnb.VisualDev/RunService.cs b/visualdev/Tnb.VisualDev/RunService.cs index 73ee49bc..26bfe6de 100644 --- a/visualdev/Tnb.VisualDev/RunService.cs +++ b/visualdev/Tnb.VisualDev/RunService.cs @@ -2886,9 +2886,27 @@ public class RunService : IRunService, ITransient // 多选时为模糊查询 if (model.multiple) { - conModels.Add(new ConditionalCollections() + if (jarr?.Children() != null && jarr?.Children().ToList().Count > 1) { - ConditionalList = new List>() + var values = jarr.ToList().Select(t => t.Value()).ToList(); + var condition = new ConditionalCollections(); + condition.ConditionalList = new List>(values.Count); + values.ForEach(x => + { + condition.ConditionalList.Add(new KeyValuePair(WhereType.Or, new ConditionalModel + { + FieldName = item.Key, + ConditionalType = ConditionalType.Like, + FieldValue = x, + })); + }); + conModels.Add(condition); + } + else + { + conModels.Add(new ConditionalCollections() + { + ConditionalList = new List>() { new KeyValuePair(WhereType.And, new ConditionalModel { @@ -2897,7 +2915,9 @@ public class RunService : IRunService, ITransient FieldValue = itemValue }) } - }); + }); + } + } //modified by ly on 20230407 else if (jarr?.Children() != null && jarr?.Children().ToList().Count > 1) @@ -2940,6 +2960,73 @@ public class RunService : IRunService, ITransient } } + break; + case JnpfKeyConst.TAB: //modifed by ly on 20230425 + { + var itemValue = item.Value.ToString().Contains("[") ? item.Value.ToJsonString() : item.Value.ToString(); + //modified by ly on 20230407 + JArray jarr = null; + if (itemValue!.Contains("[")) + { + jarr = JArray.Parse(itemValue); + } + + // 多选时为模糊查询 + if (model.multiple) + { + conModels.Add(new ConditionalCollections() + { + ConditionalList = new List>() + { + new KeyValuePair(WhereType.And, new ConditionalModel + { + FieldName = item.Key, + ConditionalType = ConditionalType.Like, + FieldValue = itemValue + }) + } + }); + } + //modified by ly on 20230407 + else if (jarr?.Children() != null && jarr?.Children().ToList().Count > 1) + { + var values = jarr.ToList().Select(t => t.Value()).ToList(); + var condition = new ConditionalCollections(); + condition.ConditionalList = new List>(values.Count); + values.ForEach(x => + { + condition.ConditionalList.Add(new KeyValuePair(WhereType.Or, new ConditionalModel + { + FieldName = item.Key, + ConditionalType = ConditionalType.Equal, + FieldValue = x, + })); + }); + conModels.Add(condition); + } + else + { + //modified by ly on 20230407 + if (itemValue.IsMatch(@"\[(.+)\]")) + { + itemValue = Regex.Match(itemValue, @"\[(.+)\]").Groups[1].Value; + itemValue = itemValue.Trim('"'); + } + + conModels.Add(new ConditionalCollections() + { + ConditionalList = new List>() + { + new KeyValuePair(WhereType.And, new ConditionalModel + { + FieldName = item.Key, + ConditionalType = ConditionalType.Equal, + FieldValue = itemValue + }) + } + }); + } + } break; default: {