You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
78 lines
2.5 KiB
78 lines
2.5 KiB
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
|
|
{
|
|
/// <summary>
|
|
/// 日物料需求计划风险确认
|
|
/// </summary>
|
|
public class CherySupplierConDateService : CheryRecurringJobInputPageController<SUPPLIER_CON_DATE, SUPPLIER_CON_DATE_DETAIL_DTO>
|
|
{
|
|
public CherySupplierConDateService(HttpClient httpClient, JobDbContext jobDbContext, LogController log, IRepository<SUPPLIER_CON_DATE> repository) : base(httpClient, jobDbContext, log, repository)
|
|
{
|
|
}
|
|
/// <summary>
|
|
/// 确认提交
|
|
/// </summary>
|
|
/// <param name="entites"></param>
|
|
/// <returns></returns>
|
|
[HttpPost]
|
|
public async Task<ActionResult> Confirm([FromBody] List<SUPPLIER_CON_DATE> entites)
|
|
{
|
|
|
|
var taskId = Guid.NewGuid();
|
|
var task = new TaskSub();
|
|
task.TaskId = taskId;
|
|
task.TaskName = "采购订单风险确认";
|
|
task.Subscriber = Client;
|
|
task.TableName = "SUPPLIER_CON_DATE";
|
|
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 = "修改成功!" });
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|