仓储-提交
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using AutoMapper;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Storage;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -8,6 +9,7 @@ using System.Threading.Tasks;
|
||||
using WMS.Web.Core;
|
||||
using WMS.Web.Core.Dto;
|
||||
using WMS.Web.Core.Internal.Results;
|
||||
using WMS.Web.Domain.Entitys;
|
||||
using WMS.Web.Domain.Infrastructure;
|
||||
using WMS.Web.Repositories.Configuration;
|
||||
|
||||
@@ -16,7 +18,7 @@ namespace WMS.Web.Repositories
|
||||
/// <summary>
|
||||
/// 入库任务表-仓储
|
||||
/// </summary>
|
||||
public class InStockTaskRepositories: IInStockTaskRepositories
|
||||
public class InStockTaskRepositories : IInStockTaskRepositories
|
||||
{
|
||||
private readonly IMapper _mapper;
|
||||
private readonly IServiceProvider _serviceProvider;
|
||||
@@ -55,27 +57,94 @@ namespace WMS.Web.Repositories
|
||||
DetailsId = s.detail.Id,
|
||||
BillNo = s.order.BillNo,
|
||||
Type = s.order.Type.GetRemark(),
|
||||
Status=s.order.Status.GetRemark(),
|
||||
Status = s.order.Status.GetRemark(),
|
||||
SourceBillNo = s.detail.SourceBillNo,
|
||||
Supplier = "",
|
||||
Org = "",
|
||||
MaterialName = "",
|
||||
MaterialNumber = "",
|
||||
Specifications = "",
|
||||
FactoryPrice=s.detail.FactoryPrice,
|
||||
FactoryPrice = s.detail.FactoryPrice,
|
||||
Stock = "",
|
||||
AccruedQty = s.detail.AccruedQty,
|
||||
ReceiveQty = s.detail.ReceiveQty,
|
||||
RealityQty = s.detail.RealityQty,
|
||||
Receiver = "",
|
||||
ReceiveTime=s.order.ReceiveTime,
|
||||
Operator="",
|
||||
OperateTime=s.order.OperateTime,
|
||||
ReceiveTime = s.order.ReceiveTime,
|
||||
Operator = "",
|
||||
OperateTime = s.order.OperateTime,
|
||||
CreateTime = s.detail.CreateTime,
|
||||
}).OrderByDescending(x => x.Id).Skip((dto.PageNo - 1) * dto.PageSize).Take(dto.PageSize).ToListAsync();
|
||||
|
||||
response.Data = list;
|
||||
return response;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 批量添加
|
||||
/// </summary>
|
||||
/// <param name="entitys"></param>
|
||||
/// <param name="isTransaction"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> AddRange(List<InStockTask> entitys, bool isTransaction = true)
|
||||
{
|
||||
IDbContextTransaction _transaction = null;
|
||||
if (isTransaction)
|
||||
_transaction = _context.Database.BeginTransaction();
|
||||
try
|
||||
{
|
||||
if (entitys != null && entitys.Count != 0)
|
||||
{
|
||||
await _context.InStockTask.AddRangeAsync(entitys);
|
||||
await _context.SaveChangesAsync();
|
||||
foreach (var item in entitys)
|
||||
{
|
||||
if (string.IsNullOrEmpty(item.BillNo))
|
||||
//自动生成单据编号
|
||||
item.MakeBillNo(item.Id);
|
||||
}
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
if (_transaction != null)
|
||||
_transaction.Commit();
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
if (_transaction != null)
|
||||
_transaction.Rollback();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加
|
||||
/// </summary>
|
||||
/// <param name="dto"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<InStockTask> Add(InStockTask entity, bool isTransaction = true)
|
||||
{
|
||||
IDbContextTransaction _transaction = null;
|
||||
if (isTransaction)
|
||||
_transaction = _context.Database.BeginTransaction();
|
||||
|
||||
try
|
||||
{
|
||||
//创建单据编号
|
||||
entity.MakeBillNo(entity.Id);
|
||||
await _context.InStockTask.AddAsync(entity);
|
||||
var res = await _context.SaveChangesAsync();
|
||||
if (_transaction != null)
|
||||
_transaction.Commit();
|
||||
return entity;
|
||||
}
|
||||
catch
|
||||
{
|
||||
if (_transaction != null)
|
||||
_transaction.Rollback();
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user