|
|
@ -152,47 +152,58 @@ namespace Wood.Service.Datas |
|
|
|
var tran = transaction.GetDbTransaction(); |
|
|
|
try |
|
|
|
{ |
|
|
|
#region 数据库操作
|
|
|
|
|
|
|
|
//添加任务
|
|
|
|
//TaskSub taskSubObj = _commonService.BuildTaskSub(1, _taskName);
|
|
|
|
//await _taskSubRepository.AddAsync(taskSubObj);
|
|
|
|
TaskSub taskSubObj = _commonService.BuildTaskSub(1, _taskName); |
|
|
|
await _context.TaskSub.AddAsync(taskSubObj); |
|
|
|
await _taskSubRepository.AddAsync(taskSubObj); |
|
|
|
|
|
|
|
entity.SupplierCode = VendCode; |
|
|
|
entity.ReadState = true; |
|
|
|
entity.WriteState = false; |
|
|
|
entity.TaskId = taskSubObj.TaskId; |
|
|
|
//添加任务明细
|
|
|
|
SUPPLIER_PRO_PROCESS_EQUIPMENT empObj = new SUPPLIER_PRO_PROCESS_EQUIPMENT(); |
|
|
|
empObj.InjectFrom(entity); |
|
|
|
|
|
|
|
empObj.SupplierCode = entity.SupplierCode; |
|
|
|
empObj.SupplierName = entity.SupplierName; |
|
|
|
empObj.CheryProductNo = entity.CheryProductNo; |
|
|
|
empObj.CheryProductName = entity.CheryProductName; |
|
|
|
empObj.VendorProductNo = entity.VendorProductNo; |
|
|
|
empObj.VendorProductName = entity.VendorProductName; |
|
|
|
empObj.DeviceType = entity.DeviceType; |
|
|
|
empObj.DeviceCode = entity.DeviceCode; |
|
|
|
empObj.DeviceName = entity.DeviceName; |
|
|
|
empObj.Manufacturer = entity.Manufacturer; |
|
|
|
empObj.ModelNumber = entity.ModelNumber; |
|
|
|
empObj.SerialNumber = entity.SerialNumber; |
|
|
|
empObj.ProductionDate = entity.ProductionDate; |
|
|
|
empObj.Material = entity.Material; |
|
|
|
empObj.CurrentLocation = entity.CurrentLocation; |
|
|
|
empObj.DeviceStatus = entity.DeviceStatus; |
|
|
|
empObj.CavityCount = entity.CavityCount; |
|
|
|
empObj.MoldSize = entity.MoldSize; |
|
|
|
empObj.DesignLifeUnits = entity.DesignLifeUnits; |
|
|
|
empObj.DesignLifeValue = entity.DesignLifeValue; |
|
|
|
empObj.CurrentUsageCount = entity.CurrentUsageCount; |
|
|
|
empObj.OverhaulCount = entity.OverhaulCount; |
|
|
|
empObj.CoolingChannelLayout = entity.CoolingChannelLayout; |
|
|
|
empObj.DetectionAccuracy = entity.DetectionAccuracy; |
|
|
|
empObj.CalibrationDate = entity.CalibrationDate; |
|
|
|
empObj.CalibrationDueDays = entity.CalibrationDueDays; |
|
|
|
empObj.ToleranceRange = entity.ToleranceRange; |
|
|
|
empObj.WearThreshold = entity.WearThreshold; |
|
|
|
empObj.DetectionRange = entity.DetectionRange; |
|
|
|
empObj.UnitType = entity.UnitType; |
|
|
|
empObj.SupplierCode = VendCode; |
|
|
|
//EntityMapper<SUPPLIER_PRO_PROCESS_EQUIPMENT_DT, SUPPLIER_PRO_PROCESS_EQUIPMENT>.Trans(entity);
|
|
|
|
empObj.TaskId = taskSubObj.TaskId; |
|
|
|
await _context.AddAsync(empObj); |
|
|
|
|
|
|
|
//await _supplierProProcessEquipmentRepository.AddAsync(empObj);
|
|
|
|
|
|
|
|
empObj.ReadState = true; |
|
|
|
|
|
|
|
await _context.BulkMergeAsync(new List<SUPPLIER_PRO_PROCESS_EQUIPMENT_DT> { entity }, options => { options.ColumnPrimaryKeyExpression = itm => |
|
|
|
new { itm.SupplierCode, itm.CheryProductNo, itm.DeviceCode, itm.DeviceType}; options.Transaction = tran; } |
|
|
|
); |
|
|
|
|
|
|
|
await _context.BulkInsertAsync(new List<SUPPLIER_PRO_PROCESS_EQUIPMENT>() { empObj }); |
|
|
|
_context.SaveChanges(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//var firstObj = _context.Set<SUPPLIER_PRO_PROCESS_EQUIPMENT_DT>().FirstOrDefault(
|
|
|
|
// itm => itm.SupplierCode == entity.SupplierCode
|
|
|
|
// && itm.CheryProductNo == entity.CheryProductNo
|
|
|
|
// && itm.DeviceCode == entity.DeviceCode
|
|
|
|
// && itm.DeviceType == entity.DeviceType
|
|
|
|
// );
|
|
|
|
//if (firstObj == null)
|
|
|
|
//{
|
|
|
|
// var ret = await base.Create(entity);
|
|
|
|
//}
|
|
|
|
//else
|
|
|
|
//{
|
|
|
|
// throw new Exception("数据库已经存在,不能重复插入");
|
|
|
|
//}
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
transaction.Commit(); |
|
|
|
return Ok(true); |
|
|
|
} |
|
|
@ -210,26 +221,68 @@ namespace Wood.Service.Datas |
|
|
|
try |
|
|
|
{ |
|
|
|
#region 数据库操作
|
|
|
|
|
|
|
|
//添加任务
|
|
|
|
TaskSub taskSubObj = _commonService.BuildTaskSub(1, _taskName); |
|
|
|
await _taskSubRepository.AddAsync(taskSubObj); |
|
|
|
|
|
|
|
entity.SupplierCode = VendCode; |
|
|
|
entity.ReadState = true; |
|
|
|
entity.WriteState = false; |
|
|
|
entity.TaskId = taskSubObj.TaskId; |
|
|
|
//添加任务明细
|
|
|
|
SUPPLIER_PRO_PROCESS_EQUIPMENT empObj = new SUPPLIER_PRO_PROCESS_EQUIPMENT(); |
|
|
|
empObj.InjectFrom(entity); |
|
|
|
|
|
|
|
empObj.SupplierCode = entity.SupplierCode; |
|
|
|
empObj.SupplierName = entity.SupplierName; |
|
|
|
empObj.CheryProductNo = entity.CheryProductNo; |
|
|
|
empObj.CheryProductName = entity.CheryProductName; |
|
|
|
empObj.VendorProductNo = entity.VendorProductNo; |
|
|
|
empObj.VendorProductName = entity.VendorProductName; |
|
|
|
empObj.DeviceType = entity.DeviceType; |
|
|
|
empObj.DeviceCode = entity.DeviceCode; |
|
|
|
empObj.DeviceName = entity.DeviceName; |
|
|
|
empObj.Manufacturer = entity.Manufacturer; |
|
|
|
empObj.ModelNumber = entity.ModelNumber; |
|
|
|
empObj.SerialNumber = entity.SerialNumber; |
|
|
|
empObj.ProductionDate = entity.ProductionDate; |
|
|
|
empObj.Material = entity.Material; |
|
|
|
empObj.CurrentLocation = entity.CurrentLocation; |
|
|
|
empObj.DeviceStatus = entity.DeviceStatus; |
|
|
|
empObj.CavityCount = entity.CavityCount; |
|
|
|
empObj.MoldSize = entity.MoldSize; |
|
|
|
empObj.DesignLifeUnits = entity.DesignLifeUnits; |
|
|
|
empObj.DesignLifeValue = entity.DesignLifeValue; |
|
|
|
empObj.CurrentUsageCount = entity.CurrentUsageCount; |
|
|
|
empObj.OverhaulCount = entity.OverhaulCount; |
|
|
|
empObj.CoolingChannelLayout = entity.CoolingChannelLayout; |
|
|
|
empObj.DetectionAccuracy = entity.DetectionAccuracy; |
|
|
|
empObj.CalibrationDate = entity.CalibrationDate; |
|
|
|
empObj.CalibrationDueDays = entity.CalibrationDueDays; |
|
|
|
empObj.ToleranceRange = entity.ToleranceRange; |
|
|
|
empObj.WearThreshold = entity.WearThreshold; |
|
|
|
empObj.DetectionRange = entity.DetectionRange; |
|
|
|
empObj.UnitType = entity.UnitType; |
|
|
|
|
|
|
|
empObj.SupplierCode = VendCode; |
|
|
|
empObj.TaskId = taskSubObj.TaskId; |
|
|
|
await _context.AddAsync(empObj); |
|
|
|
empObj.ReadState = true; |
|
|
|
|
|
|
|
|
|
|
|
await _context.BulkInsertAsync(new List<SUPPLIER_PRO_PROCESS_EQUIPMENT>(){ empObj}); |
|
|
|
_context.SaveChanges(); |
|
|
|
|
|
|
|
//await _supplierProProcessEquipmentRepository.AddAsync(empObj);
|
|
|
|
|
|
|
|
|
|
|
|
await _context.BulkMergeAsync(new List<SUPPLIER_PRO_PROCESS_EQUIPMENT_DT> { entity }, options => { |
|
|
|
await _context.BulkMergeAsync(new List<SUPPLIER_PRO_PROCESS_EQUIPMENT_DT> { entity }, options => |
|
|
|
{ |
|
|
|
options.ColumnPrimaryKeyExpression = itm => |
|
|
|
new { itm.SupplierCode, itm.CheryProductNo, itm.DeviceCode, itm.DeviceType }; options.Transaction = tran; |
|
|
|
} |
|
|
|
); |
|
|
|
|
|
|
|
_context.SaveChanges(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|