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.
112 lines
3.4 KiB
112 lines
3.4 KiB
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.EntityFrameworkCore;
|
|
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 CherySupplierConPoService : CheryRecurringJobInputPageController<SUPPLIER_CON_PO, SUPPLIER_CON_PO_DETAIL_DTO>
|
|
{
|
|
public CherySupplierConPoService(HttpClient httpClient, JobDbContext jobDbContext, LogController log, IRepository<SUPPLIER_CON_PO> repository) : base(httpClient, jobDbContext, log, repository)
|
|
{
|
|
}
|
|
|
|
[HttpGet]
|
|
public async Task<SUPPLIER_CON_DATE> GetDetialByID(String id)
|
|
{
|
|
|
|
SUPPLIER_CON_DATE first = new SUPPLIER_CON_DATE();
|
|
var m = await _jobDbContext.SUPPLIER_CON_DATE.FirstOrDefaultAsync(p => p.Id == id);
|
|
if (m != null)
|
|
{
|
|
return m;
|
|
}
|
|
return first;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <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 = "采购订单风险确认";
|
|
task.Subscriber = "Chery";
|
|
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 = "确认成功!" });
|
|
}
|
|
/// <summary>
|
|
/// 批量修改
|
|
/// </summary>
|
|
/// <param name="entites"></param>
|
|
/// <returns></returns>
|
|
[HttpPost]
|
|
public async Task<ActionResult> BatchUpdate([FromBody] List<SUPPLIER_CON_PO> entites)
|
|
{
|
|
await _jobDbContext.BulkUpdateAsync(entites, options => { options.ColumnPrimaryKeyExpression = p => p.UId; options.UseTableLock = false; });
|
|
|
|
return new JsonResult(new { Code = 200, Message = "批量修改成功!" });
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|