using Microsoft.EntityFrameworkCore; using Serilog; using WMS_GIRAF_Interface.Data; using WMS_GIRAF_Interface.Entities; using WMS_GIRAF_Interface.Repositories.Interface; namespace WMS_GIRAF_Interface.Repositories.Implement; public class IoControlRepository(MichelinDbContext context, ILogger logger):IIoControlRepository { //获取Io Control 表数据 /// /// 获取io control数据 /// /// /// public IO_CONTROL? GetIoControlTaskByManageId(int manageId) { var ioControlInfo = context.IoControl.FirstOrDefault(x => x.MANAGE_ID == manageId); return ioControlInfo; } public bool AddIoControlTask(IO_CONTROL? ioControl ,out int? controlId) { try { controlId = 0; if (ioControl == null) { throw new ArgumentNullException(nameof(ioControl)); return false; } context.IoControl.Add(ioControl); context.SaveChanges(); Log.Information($"Catch io control task info ({ioControl.STOCK_BARCODE});"); IO_CONTROL? checkIoControlTask = context.IoControl.FirstOrDefault(x => x.STOCK_BARCODE == ioControl.STOCK_BARCODE); controlId = checkIoControlTask != null ? checkIoControlTask.CONTROL_ID : 0; return true; } catch (Exception e) { if (ioControl != null) Log.Error($"插入控制数据出现问题:胎号信息:{ioControl.STOCK_BARCODE};错误信息:{e.Message}"); throw; } } }