Merge branch 'master' of https://codeup.aliyun.com/62ce7bca487c500c27f70a79/OPS/WMS-Api
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
using AutoMapper;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Storage;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WMS.Web.Core.Dto;
|
||||
@@ -64,9 +66,36 @@ namespace WMS.Web.Repositories
|
||||
/// </summary>
|
||||
/// <param name="dto"></param>
|
||||
/// <returns></returns>
|
||||
public Task<(List<ChangeBoxRecordQueryInfoResponse> list, int total)> GetListAsync(ChangeBoxRecordQueryRequest dto)
|
||||
public async Task<(List<ChangeBoxRecordQueryInfoResponse> list, int total)> GetListAsync(ChangeBoxRecordQueryRequest dto)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
var query = _context.ChangeBoxRecord
|
||||
.OrderByDescending(o => o.Id)
|
||||
.Where(adv => 1 == 1);
|
||||
|
||||
if (dto.CreateBeginDate != null)
|
||||
query = query.Where(w => w.CreateTime >= dto.CreateBeginDate);
|
||||
if (dto.CreateEndDate != null)
|
||||
query = query.Where(w => w.CreateTime <= dto.CreateEndDate);
|
||||
//组装
|
||||
int total = await query.CountAsync();
|
||||
var list = await query.Select(s => new ChangeBoxRecordQueryInfoResponse()
|
||||
{
|
||||
#region dto组装
|
||||
MaterialName = "",
|
||||
MaterialNumber = "",
|
||||
Specifications = "",
|
||||
Stock = "",
|
||||
SerialNumber = "",
|
||||
SrcBox = "",
|
||||
DestBox = "",
|
||||
SrcSubStock = "",
|
||||
DestSubStock = "",
|
||||
Creator = "",
|
||||
CreateTime =s.CreateTime
|
||||
#endregion
|
||||
|
||||
}).Skip((dto.PageNo - 1) * dto.PageSize).Take(dto.PageSize).ToListAsync();
|
||||
return (list, total);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,9 +9,11 @@ using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using WMS.Web.Core.Help;
|
||||
using WMS.Web.Domain.IService;
|
||||
using WMS.Web.Domain.IService.Public;
|
||||
using WMS.Web.Domain.Mappers;
|
||||
using WMS.Web.Domain.Options;
|
||||
using WMS.Web.Domain.Services;
|
||||
using WMS.Web.Domain.Services.Public;
|
||||
|
||||
namespace WMS.Web.Repositories.DependencyInjection
|
||||
@@ -185,6 +187,9 @@ namespace WMS.Web.Repositories.DependencyInjection
|
||||
Services.AddTransient<IHttpClientService, HttpClientService>();
|
||||
Services.AddTransient<ISingleDataService, SingleDataService>();
|
||||
Services.AddTransient<IErpService, ErpService>();
|
||||
|
||||
Services.AddTransient<IChangeMoveBoxService, ChangeMoveBoxService>();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,6 +32,8 @@ namespace Microsoft.Extensions.DependencyInjection
|
||||
{
|
||||
services.AddHttpContextAccessor();
|
||||
|
||||
services.AddTransient<ITransactionRepositories, TransactionRepositories>();
|
||||
|
||||
services.AddTransient<IInStockRepositories, InStockRepositories>();
|
||||
|
||||
services.AddTransient<IChangeBoxRecordRepositories, ChangeBoxRecordRepositories>();
|
||||
|
||||
47
src/WMS.Web.Repositories/TransactionRepositories.cs
Normal file
47
src/WMS.Web.Repositories/TransactionRepositories.cs
Normal file
@@ -0,0 +1,47 @@
|
||||
using Microsoft.EntityFrameworkCore.Storage;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using WMS.Web.Domain.Infrastructure;
|
||||
using WMS.Web.Repositories.Configuration;
|
||||
|
||||
namespace WMS.Web.Repositories
|
||||
{
|
||||
public class TransactionRepositories: ITransactionRepositories
|
||||
{
|
||||
private RepositoryDbContext _context;
|
||||
|
||||
|
||||
public TransactionRepositories(RepositoryDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
public IDbContextTransaction GetTransaction()
|
||||
{
|
||||
return _context.Database.BeginTransaction();
|
||||
}
|
||||
|
||||
public bool CommitTransaction(bool isRollback, IDbContextTransaction transaction)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (transaction == null)
|
||||
return true;
|
||||
|
||||
if (isRollback)
|
||||
{
|
||||
transaction.Rollback();
|
||||
return false;
|
||||
}
|
||||
transaction.Commit();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
transaction.Rollback();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user