4 changed files with 137 additions and 10 deletions
@ -0,0 +1,73 @@ |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using Microsoft.EntityFrameworkCore.Storage; |
|||
using TaskManager.Contracts.Dtos; |
|||
using TaskManager.Entity; |
|||
using TaskManager.Entity.Entitys; |
|||
using TaskManager.EntityFramework; |
|||
|
|||
namespace TaskManager.Controllers |
|||
{ |
|||
public class SupplierPoService : CheryRecurringJobInputPageController<SUPPLIER_CON_PO, SUPPLIER_CON_PO_DETAIL_DTO> |
|||
{ |
|||
public SupplierPoService(HttpClient httpClient, JobDbContext jobDbContext, LogController log, IRepository<SUPPLIER_PO> repository) : base(httpClient, jobDbContext, log, repository) |
|||
{ |
|||
} |
|||
/// <summary>
|
|||
/// 确认提交
|
|||
/// </summary>
|
|||
/// <param name="entites"></param>
|
|||
/// <returns></returns>
|
|||
[HttpPost] |
|||
public async Task<ActionResult> Confirm([FromBody] List<SUPPLIER_CON_PO> entites) |
|||
{ |
|||
|
|||
var taskId = Guid.NewGuid(); |
|||
var task = new TaskSub(); |
|||
task.TaskId = taskId; |
|||
task.TaskName = TaskName; |
|||
task.Subscriber = Client; |
|||
task.TableName = "SUPPLIER_CON_PO"; |
|||
task.DataCount = entites.Count; |
|||
task.Domain = "1"; |
|||
task.Site = "1"; |
|||
task.FailedCount = 0; |
|||
task.CreateTime = DateTime.Now; |
|||
task.CreateUser = "admin"; |
|||
task.CreationTime = DateTime.Now; |
|||
task.SyncedPageCount = 0; |
|||
|
|||
entites.ForEach(p => |
|||
{ |
|||
p.ReadState = true; |
|||
p.TaskId = taskId; |
|||
|
|||
}); |
|||
|
|||
using (var transaction = await _jobDbContext.Database.BeginTransactionAsync()) |
|||
{ |
|||
var tran = transaction.GetDbTransaction(); |
|||
try |
|||
{ |
|||
await _jobDbContext.BulkUpdateAsync(entites, options => { options.Transaction = tran; }); |
|||
await _jobDbContext.AddAsync(task); |
|||
_jobDbContext.SaveChanges(); |
|||
|
|||
// 提交事务
|
|||
await transaction.CommitAsync(); |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
await transaction.RollbackAsync(); |
|||
return new JsonResult(new { Code = 400, Message = ex.Message }); |
|||
} |
|||
} |
|||
return new JsonResult(new { Code = 200, Message = "修改成功!" }); |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
} |
|||
} |
@ -1,15 +1,75 @@ |
|||
using TaskManager.Contracts.Dtos; |
|||
using System.Data.Common; |
|||
using TaskManager.Contracts.Dtos; |
|||
using TaskManager.Controllers; |
|||
using TaskManager.Entity; |
|||
using TaskManager.Entity.Entitys; |
|||
using TaskManager.EntityFramework; |
|||
|
|||
|
|||
namespace TaskManager.Controllers |
|||
{ |
|||
/// <summary>
|
|||
/// 采购订单
|
|||
/// </summary>
|
|||
public class CherySupplierPoService : CheryRecurringJobOutPageController<SUPPLIER_PO, SUPPLIER_PO_DETAIL_DTO> |
|||
{ |
|||
public CherySupplierPoService(HttpClient httpClient, JobDbContext jobDbContext, LogController log, IRepository<SUPPLIER_PO> repository) : base(httpClient, jobDbContext, log, repository) |
|||
{ |
|||
} |
|||
protected override async Task ConfirmDataInsertAsync(List<SUPPLIER_PO> plist, JobDbContext dbContext, DbTransaction dbTransaction) |
|||
{ |
|||
if (plist.Count > 0) |
|||
{ |
|||
List<SUPPLIER_CON_PO> list = new List<SUPPLIER_CON_PO>(); |
|||
plist.ForEach(p => |
|||
{ |
|||
var con = new SUPPLIER_CON_PO(); |
|||
|
|||
con.SupplierCode = "8EG"; |
|||
con.PurchaseOrder =p.PurchaseOrder ; |
|||
con.SerialNumber =p.SerialNumber ; |
|||
con.QuantityMeet =p.QuantityDelivery ; |
|||
con.FeedbackResults ="" ; |
|||
con.VentureType ="" ; |
|||
con.VentureSpecific ="" ; |
|||
con.Measures =""; |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
//con.SupplierCode = "8EG";
|
|||
//con.ReleaseEdition = p.ReleaseEdition;
|
|||
//con.MaterialCode = p.MaterialCode;
|
|||
//con.PlantId = p.PlantId;
|
|||
//con.FeedbackResults = "0";
|
|||
//con.VentureType = "1";
|
|||
//con.VentureSpecific = "1";
|
|||
//con.Measures = "1";
|
|||
//con.StartMonth = p.StartMonth;
|
|||
//con.QuantityMeet1 = p.QuantityDemand1;
|
|||
//con.QuantityMeet2 = p.QuantityDemand2;
|
|||
//con.QuantityMeet3 = p.QuantityDemand3;
|
|||
//con.QuantityMeet4 = p.QuantityDemand4;
|
|||
//con.QuantityMeet5 = p.QuantityDemand5;
|
|||
//con.QuantityMeet6 = p.QuantityDemand6;
|
|||
//con.QuantityMeet7 = p.QuantityDemand7;
|
|||
//con.QuantityMeet8 = p.QuantityDemand8;
|
|||
//con.QuantityMeet9 = p.QuantityDemand9;
|
|||
//con.QuantityMeet10 = p.QuantityDemand10;
|
|||
//con.QuantityMeet11 = p.QuantityDemand11;
|
|||
//con.QuantityMeet12 = p.QuantityDemand12;
|
|||
list.Add(con); |
|||
}); |
|||
|
|||
await dbContext.BulkInsertAsync(list, options => { options.Transaction = dbTransaction; options.UseTableLock = false; }); |
|||
} |
|||
return; |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
} |
|||
} |
|||
|
@ -1,6 +0,0 @@ |
|||
namespace TaskManager.Controllers |
|||
{ |
|||
public class SupplierPoService |
|||
{ |
|||
} |
|||
} |
Loading…
Reference in new issue