From dc032c01c632c3bc74cf2d53308ecdad3b5378f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E6=AD=A3=E6=98=93?= Date: Tue, 18 Mar 2025 13:09:27 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B2=B9=E6=BC=86=E5=AE=9E=E9=AA=8C=E5=AE=A4?= =?UTF-8?q?=E6=89=B9=E9=87=8F=E5=B7=A5=E5=8D=95=E8=8E=B7=E5=8F=96=EF=BC=88?= =?UTF-8?q?=E6=9C=AA=E5=85=A8=E9=83=A8=E5=AE=8C=E6=88=90=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ZR.Service/mes/ql/IService/IPLBatchService.cs | 3 + ZR.Service/mes/ql/PLBatchService.cs | 117 ++++++++++++++++++ 2 files changed, 120 insertions(+) diff --git a/ZR.Service/mes/ql/IService/IPLBatchService.cs b/ZR.Service/mes/ql/IService/IPLBatchService.cs index af5d6302..b3f7d86c 100644 --- a/ZR.Service/mes/ql/IService/IPLBatchService.cs +++ b/ZR.Service/mes/ql/IService/IPLBatchService.cs @@ -16,5 +16,8 @@ namespace ZR.Service.mes.ql.IService public int UpdatePLBatchRecords(List list); + public int CreatePLBatchRecordsByWorkOrder(DateTime actionDate); + + } } diff --git a/ZR.Service/mes/ql/PLBatchService.cs b/ZR.Service/mes/ql/PLBatchService.cs index ddce4e4c..5a5c76be 100644 --- a/ZR.Service/mes/ql/PLBatchService.cs +++ b/ZR.Service/mes/ql/PLBatchService.cs @@ -1,6 +1,8 @@ using Infrastructure.Attribute; using SqlSugar; using System; +using System.Globalization; +using ZR.Model.MES.pro; using ZR.Model.MES.ql; using ZR.Service.mes.ql.IService; @@ -46,6 +48,87 @@ namespace ZR.Service.mes.ql return ret; } + /// + /// 根据生成日期,自动更新 + /// + /// 操作日期 + /// + /// + public int CreatePLBatchRecordsByWorkOrder(DateTime actionDate) + { + try + { + Context.Ado.BeginTran(); + // 查询工单 + int year = actionDate.Year; + int week = GetWeekOfYear(actionDate); + int date = ConvertDayOfWeekToCustomFormat(actionDate.DayOfWeek); + var predicate = Expressionable + .Create() + .And(it => it.Year == year) + .And(it => it.Week == week) + .And(it => it.Date == date) + //.And(it => it.Remark2.Contains("调试")) + .And(it => it.Remark3 == "是") + .ToExpression(); + List workOrderList = Context.Queryable() + .Where(predicate) + .OrderBy(it => it.Sort) + .ToList(); + foreach(ProWorkorder_v2 workorder in workOrderList) + { + + } + + + Context.Ado.CommitTran(); + return 1; + } + catch (Exception) + { + Context.Ado.RollbackTran(); + throw; + } + } + + /// + /// 根据工单创建批量检测数据 + /// + /// + /// + /// + /// + public List CreatePLBatchRecordsByWorkOrder(ProWorkorder_v2 workorder) + { + PLBatch t1 = GetDefaultPLBatch(); + PLBatch t2 = GetDefaultPLBatch(); + PLBatch t3 = GetDefaultPLBatch(); + PLBatch t4 = GetDefaultPLBatch(); + PLBatch t5 = GetDefaultPLBatch(); + PLBatch t6 = GetDefaultPLBatch(); + t1.Value01 = "15°"; t1.Value07 = "0"; t1.Value09 = "R1"; t1.Value14 = "底漆"; t1.Value19 = "2"; + t2.Value01 = "25°"; t2.Value07 = "0"; t2.Value09 = "R2"; t2.Value14 = "色漆"; t2.Value19 = "2"; + t3.Value01 = "45°"; t3.Value07 = "0"; t3.Value09 = "R3"; t3.Value14 = "云母"; t3.Value19 = "2"; + t4.Value01 = "75°"; t4.Value07 = "0"; t4.Value09 = "R4"; t4.Value14 = "清漆"; t4.Value19 = "2"; + t5.Value01 = "110°"; t5.Value07 = "0"; t5.Value09 = "R5"; t5.Value14 = "总膜厚"; t5.Value19 = "2"; + t6.Value01 = ""; t6.Value07 = "0"; t6.Value09 = "R6"; t6.Value14 = ""; t6.Value19 = "2"; + t2.IdGroup = t1.IdGroup; + t3.IdGroup = t1.IdGroup; + t4.IdGroup = t1.IdGroup; + t5.IdGroup = t1.IdGroup; + t6.IdGroup = t1.IdGroup; + List list = new() + { + t1, + t2, + t3, + t4, + t5, + t6 + }; + return list; + } + /// /// 删除批处理数据 /// @@ -132,5 +215,39 @@ namespace ZR.Service.mes.ql UpdatedTime = DateTime.Now, }; } + + + /// + /// 获取今天是本年的第几周 + /// + /// + /// + static int GetWeekOfYear(DateTime date) + { + // 使用ISO 8601标准计算一年中的第几周 + return CultureInfo.InvariantCulture.Calendar.GetWeekOfYear( + date, + CalendarWeekRule.FirstFourDayWeek, // 每年的第一周必须至少有4天属于该年 + DayOfWeek.Monday + ); // 设置一周的第一天为星期一 + } + + /// + /// 获取星期几的数字(7为周日) + /// + /// + /// + static int ConvertDayOfWeekToCustomFormat(DayOfWeek dayOfWeek) + { + // 将 DayOfWeek 枚举值转换为自定义格式:周一为1,周日为7 + if (dayOfWeek == DayOfWeek.Sunday) + { + return 7; + } + else + { + return (int)dayOfWeek + 1; + } + } } }