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; // 返回插入的记录数 } } }