From 10ef17bb9948c084e1f9c699bf38884d60f60094 Mon Sep 17 00:00:00 2001 From: zxy Date: Sat, 28 Jun 2025 10:28:00 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=AF=BC=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Data/SUPPLIER_EMPLOYEE_DT.cs | 6 +- .../Data/SUPPLIER_INFO_DT.cs | 2 +- .../CheryRecurringJobInputPageController.cs | 7 ++ .../CherySupplierEmployeeService.cs | 65 ++++++++++++++++++- .../Controllers/CherySupplierInfoService.cs | 50 +++++++++++++- ...CherySupplierProProcessEquipmentService.cs | 51 ++++++++++++++- .../Datas/SupplierEmployeeDtService.cs | 5 +- .../Datas/SupplierInfoDtService.cs | 5 +- .../SupplierProProcessEquipmentDtService.cs | 6 +- 9 files changed, 184 insertions(+), 13 deletions(-) diff --git a/API/TaskManager.Entity/Data/SUPPLIER_EMPLOYEE_DT.cs b/API/TaskManager.Entity/Data/SUPPLIER_EMPLOYEE_DT.cs index 38e951c..e08a06b 100644 --- a/API/TaskManager.Entity/Data/SUPPLIER_EMPLOYEE_DT.cs +++ b/API/TaskManager.Entity/Data/SUPPLIER_EMPLOYEE_DT.cs @@ -117,7 +117,7 @@ public class SUPPLIER_EMPLOYEE_DT : BaseEntity_NoTask [Required(ErrorMessage = "供应商修改时间为必填项")] [ExporterHeader(DisplayName = "供应商修改时间")] [ImporterHeader(Name = "供应商修改时间", Format = "yyyy-MM-dd HH:mm:ss")] - public DateTime DataUpdateTime { get; set; } + public DateTime? DataUpdateTime { get; set; } /// /// 岗位代码 @@ -150,7 +150,7 @@ public class SUPPLIER_EMPLOYEE_DT : BaseEntity_NoTask [Required(ErrorMessage = "资质获取时间为必填项")] [ExporterHeader(DisplayName = "资质获取时间")] [ImporterHeader(Name = "资质获取时间", Format = "yyyy-MM-dd HH:mm:ss")] - public DateTime CheckInTime { get; set; } + public DateTime? CheckInTime { get; set; } /// /// 资质失去时间 @@ -158,5 +158,5 @@ public class SUPPLIER_EMPLOYEE_DT : BaseEntity_NoTask [Required(ErrorMessage = "资质失去时间为必填项")] [ExporterHeader(DisplayName = "资质失去时间")] [ImporterHeader(Name = "资质失去时间", Format = "yyyy-MM-dd HH:mm:ss")] - public DateTime CheckOutTime { get; set; } + public DateTime? CheckOutTime { get; set; } } \ No newline at end of file diff --git a/API/TaskManager.Entity/Data/SUPPLIER_INFO_DT.cs b/API/TaskManager.Entity/Data/SUPPLIER_INFO_DT.cs index 76e76c2..571ea5c 100644 --- a/API/TaskManager.Entity/Data/SUPPLIER_INFO_DT.cs +++ b/API/TaskManager.Entity/Data/SUPPLIER_INFO_DT.cs @@ -108,7 +108,7 @@ namespace TaskManager.Entity [Required(ErrorMessage = "供应商修改时间为必填项")] [ExporterHeader(DisplayName = "供应商修改时间")] [ImporterHeader(Name = "供应商修改时间", Format = "yyyy-MM-dd HH:mm:ss")] - public DateTime DataUpdateTime { get; set; } + public DateTime? DataUpdateTime { get; set; } /// /// 产线顺序 diff --git a/API/Wood.Service/Controllers/CheryRecurringJobInputPageController.cs b/API/Wood.Service/Controllers/CheryRecurringJobInputPageController.cs index 335aa0e..cb48147 100644 --- a/API/Wood.Service/Controllers/CheryRecurringJobInputPageController.cs +++ b/API/Wood.Service/Controllers/CheryRecurringJobInputPageController.cs @@ -205,6 +205,12 @@ namespace TaskManager.Controllers } return sb.ToString(); + } + protected virtual async Task UpdateAfter(List list) + { + + + } [NonAction] @@ -291,6 +297,7 @@ namespace TaskManager.Controllers logs.Add(log); } _jobDbContext.BulkInsert(logs, options => options.UseTableLock = true); + await UpdateAfter(records); sub.SyncedPageCount = i; if (i == totalPages) diff --git a/API/Wood.Service/Controllers/CherySupplierEmployeeService.cs b/API/Wood.Service/Controllers/CherySupplierEmployeeService.cs index 694448c..8643e30 100644 --- a/API/Wood.Service/Controllers/CherySupplierEmployeeService.cs +++ b/API/Wood.Service/Controllers/CherySupplierEmployeeService.cs @@ -1,4 +1,5 @@ -using TaskManager.Contracts.Dtos; +using Microsoft.EntityFrameworkCore; +using TaskManager.Contracts.Dtos; using TaskManager.Entity; using TaskManager.EntityFramework; @@ -13,5 +14,67 @@ namespace TaskManager.Controllers { } + protected override async Task UpdateAfter(List list) + { + + var infolist = await _jobDbContext.SUPPLIER_EMPLOYEE.ToListAsync(); + + + var query = from itm in infolist + join itm1 in list on + new + { + itm.SupplierCode, + itm.PlantId, + itm.WorkshopId, + itm.ProductionLineId, + itm.StationId, + itm.OperatorId + } + equals + new + { + itm1.SupplierCode, + itm1.PlantId, + itm1.WorkshopId, + itm1.ProductionLineId, + itm1.StationId, + itm1.OperatorId + + } + select itm; + + + if (query.Any()) + { + var entities = query.ToList(); + foreach (var entity in entities) + { + entity.ReadState = true; + entity.WriteState = true; + } + _jobDbContext.BulkUpdate(entities); + + + } + return; + + + + //_jobDbContext.SUPPLIER_INFO_DT. (entityLst, options => + //{ + // options.ColumnPrimaryKeyExpression = itm => + //new + //{ + // itm.SupplierCode, + // itm.PlantId, + // itm.WorkshopId, + // itm.ProductionLineId, + // itm.StationId + //}; options.Transaction = tran; + //} + // ); + } } + } diff --git a/API/Wood.Service/Controllers/CherySupplierInfoService.cs b/API/Wood.Service/Controllers/CherySupplierInfoService.cs index 2963d4d..a916be0 100644 --- a/API/Wood.Service/Controllers/CherySupplierInfoService.cs +++ b/API/Wood.Service/Controllers/CherySupplierInfoService.cs @@ -1,4 +1,7 @@ -using TaskManager.Contracts.Dtos; +using Microsoft.EntityFrameworkCore; +using OfficeOpenXml.FormulaParsing.Excel.Functions.Math; +using System.Security.Cryptography; +using TaskManager.Contracts.Dtos; using TaskManager.Entity; using TaskManager.EntityFramework; @@ -12,6 +15,51 @@ namespace TaskManager.Controllers public CherySupplierInfoService(HttpClient httpClient, JobDbContext jobDbContext, LogController log, IRepository repository) : base(httpClient, jobDbContext, log, repository) { + } + protected override async Task UpdateAfter(List list) + { + + var infolist =await _jobDbContext.SUPPLIER_INFO_DT.ToListAsync(); + + + var query = from itm in infolist + join itm1 in list on + new + { + itm.SupplierCode, + itm.PlantId, + itm.WorkshopId, + itm.ProductionLineId, + itm.StationId + } + equals + new + { + itm1.SupplierCode, + itm1.PlantId, + itm1.WorkshopId, + itm1.ProductionLineId, + itm1.StationId + + } + select itm; + + + if (query.Any()) + { + var entities = query.ToList(); + foreach (var entity in entities) + { + entity.ReadState = true; + entity.WriteState = true; + } + _jobDbContext.BulkUpdate(entities); + + + } + return; + + } } } diff --git a/API/Wood.Service/Controllers/CherySupplierProProcessEquipmentService.cs b/API/Wood.Service/Controllers/CherySupplierProProcessEquipmentService.cs index 505fdb9..da25f19 100644 --- a/API/Wood.Service/Controllers/CherySupplierProProcessEquipmentService.cs +++ b/API/Wood.Service/Controllers/CherySupplierProProcessEquipmentService.cs @@ -1,4 +1,5 @@ -using TaskManager.Contracts.Dtos; +using Microsoft.EntityFrameworkCore; +using TaskManager.Contracts.Dtos; using TaskManager.Entity; using TaskManager.Entity.Entitys; using TaskManager.EntityFramework; @@ -14,5 +15,53 @@ namespace TaskManager.Controllers { } + + protected override async Task UpdateAfter(List list) + { + + var infolist = await _jobDbContext.SUPPLIER_PRO_PROCESS_EQUIPMENT.ToListAsync(); + + + var query = from itm in infolist + join itm1 in list on + new + { + itm.SupplierCode, + itm.CheryProductNo, + itm.DeviceCode, + itm.DeviceType + } + equals + new + { + itm1.SupplierCode, + itm1.CheryProductNo, + itm1.DeviceCode, + itm1.DeviceType + + } + select itm; + + + if (query.Any()) + { + var entities = query.ToList(); + foreach (var entity in entities) + { + entity.ReadState = true; + entity.WriteState = true; + } + _jobDbContext.BulkUpdate(entities); + + + } + return; + + + } + + + + } } diff --git a/API/Wood.Service/Datas/SupplierEmployeeDtService.cs b/API/Wood.Service/Datas/SupplierEmployeeDtService.cs index dc6eb12..25c85b0 100644 --- a/API/Wood.Service/Datas/SupplierEmployeeDtService.cs +++ b/API/Wood.Service/Datas/SupplierEmployeeDtService.cs @@ -99,6 +99,7 @@ namespace Wood.Service.Datas empDtObj.SupplierCode = VendCode; SUPPLIER_EMPLOYEE empObj = new SUPPLIER_EMPLOYEE(); empObj.InjectFrom(empDtObj); + empObj.ReadState = true; //SUPPLIER_EMPLOYEE empObj = EntityMapper.Trans(empDtObj); @@ -107,7 +108,7 @@ namespace Wood.Service.Datas emps.Add(empObj); } - _context.BulkInsert(emps); + _context.BulkInsert(emps,options=>options.Transaction=tran); _context.BulkMerge(entityLst, options => { options.ColumnPrimaryKeyExpression = itm => new @@ -145,7 +146,7 @@ namespace Wood.Service.Datas // } //} #endregion - + _context.SaveChanges(); transaction.Commit(); return Ok(true); } diff --git a/API/Wood.Service/Datas/SupplierInfoDtService.cs b/API/Wood.Service/Datas/SupplierInfoDtService.cs index beb3a3f..64f7ffc 100644 --- a/API/Wood.Service/Datas/SupplierInfoDtService.cs +++ b/API/Wood.Service/Datas/SupplierInfoDtService.cs @@ -100,10 +100,11 @@ namespace Wood.Service.Datas SUPPLIER_INFO empObj = new SUPPLIER_INFO(); empObj.InjectFrom(empDtObj); empObj.TaskId = taskSubObj.TaskId; + empObj.ReadState = true; infos.Add(empObj); //await _supplierInfoRepository.AddAsync(empObj); } - _context.BulkInsert(infos); + _context.BulkInsert(infos,options=>options.Transaction=tran); _context.BulkMerge(entityLst, options => { options.ColumnPrimaryKeyExpression = itm => new @@ -140,7 +141,7 @@ namespace Wood.Service.Datas // } //} #endregion - + _context.SaveChanges(); transaction.Commit(); return Ok(true); } diff --git a/API/Wood.Service/Datas/SupplierProProcessEquipmentDtService.cs b/API/Wood.Service/Datas/SupplierProProcessEquipmentDtService.cs index 9739b94..7021931 100644 --- a/API/Wood.Service/Datas/SupplierProProcessEquipmentDtService.cs +++ b/API/Wood.Service/Datas/SupplierProProcessEquipmentDtService.cs @@ -97,17 +97,19 @@ namespace Wood.Service.Datas foreach (var empDtObj in entityLst) { + empDtObj.SupplierCode = VendCode; SUPPLIER_PRO_PROCESS_EQUIPMENT empObj = new SUPPLIER_PRO_PROCESS_EQUIPMENT(); empObj.InjectFrom(empDtObj); empObj.TaskId = taskSubObj.TaskId; empObj.SupplierCode = VendCode; + empObj.ReadState = true; eqs.Add(empObj); // await _supplierProProcessEquipmentRepository.AddAsync(empObj); } - _context.BulkInsert(eqs); - _context.BulkMerge(eqs, options => { options.ColumnPrimaryKeyExpression = itm => new { itm.SupplierCode, itm.CheryProductNo, itm.DeviceCode, itm.DeviceType }; options.Transaction = tran; }); + _context.BulkInsert(eqs,options=>options.Transaction=tran); + _context.BulkMerge(entityLst, options => { options.ColumnPrimaryKeyExpression = itm => new { itm.SupplierCode, itm.CheryProductNo, itm.DeviceCode, itm.DeviceType }; options.Transaction = tran; }); //foreach (var empDtObj in entityLst) //{