From ea4d9ee0f074866186c209ded4f70757a4fedcd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E6=AD=A3=E6=98=93?= Date: Fri, 17 Oct 2025 18:28:49 +0800 Subject: [PATCH] 123 --- ZR.Service/mes/wms/WmPolishRecordService.cs | 33 +++++++++++++-------- 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/ZR.Service/mes/wms/WmPolishRecordService.cs b/ZR.Service/mes/wms/WmPolishRecordService.cs index 0650404c..7dfb4725 100644 --- a/ZR.Service/mes/wms/WmPolishRecordService.cs +++ b/ZR.Service/mes/wms/WmPolishRecordService.cs @@ -1,4 +1,5 @@ using Infrastructure.Attribute; +using JinianNet.JNTemplate; using SqlSugar; using System; using System.Linq; @@ -517,21 +518,29 @@ namespace ZR.Service.mes.wms } #endregion - - // 批量插入到 wm_polish_record 表 - //如果有这个时间段的数据,要删除 - List delwmPolishRecords = Context - .Queryable() - .Where(it => it.Code == "自动") - .Where(it => it.ActionTime >= parm.StartTime) - .ToList(); - Context.Deleteable(delwmPolishRecords).ExecuteCommand(); - if (wmPolishRecords.Any()) + try { - Context.Insertable(wmPolishRecords).ExecuteCommand(); + Context.Ado.BeginTran(); + // 批量插入到 wm_polish_record 表 + //如果有这个时间段的数据,要删除 + Context.Deleteable() + .Where(it => it.Code == "自动") + .Where(it => it.ActionTime >= parm.StartTime) + .ExecuteCommand(); + if (wmPolishRecords.Any()) + { + Context.Fastest().BulkCopy(wmPolishRecords); + //Context.Insertable(wmPolishRecords).ExecuteCommand(); + } + Context.Ado.CommitTran(); + return wmPolishRecords.Count; // 返回插入的记录数 + } + catch (Exception) + { + Context.Ado.RollbackTran(); + throw; } - return wmPolishRecords.Count; // 返回插入的记录数 } } }