From 404819d101104015a818f4fac3bda7cf5532eb16 Mon Sep 17 00:00:00 2001 From: 18942506660 <18942506660@A18942506660> Date: Thu, 26 Oct 2023 14:19:18 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=96=B0=E5=A2=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../IChangeBoxRecordRepositories.cs | 4 ++ .../IMoveBoxRecordRepositories.cs | 4 ++ .../Infrastructure/IOutStockRepositories.cs | 4 ++ .../IOutStockTaskRepositories.cs | 4 ++ .../Infrastructure/ITakeStockRepositories.cs | 4 ++ .../ChangeBoxRecordRepositories.cs | 34 ++++++++++++++++- .../MoveBoxRecordRepositories.cs | 37 +++++++++++++++++++ .../OutStockRepositories.cs | 37 +++++++++++++++++++ .../OutStockTaskRepositories.cs | 37 +++++++++++++++++++ .../TakeStockRepositories.cs | 37 +++++++++++++++++++ 10 files changed, 201 insertions(+), 1 deletion(-) diff --git a/src/WMS.Web.Domain/Infrastructure/IChangeBoxRecordRepositories.cs b/src/WMS.Web.Domain/Infrastructure/IChangeBoxRecordRepositories.cs index bb0f698a..797c2e2e 100644 --- a/src/WMS.Web.Domain/Infrastructure/IChangeBoxRecordRepositories.cs +++ b/src/WMS.Web.Domain/Infrastructure/IChangeBoxRecordRepositories.cs @@ -1,10 +1,14 @@ using System; using System.Collections.Generic; using System.Text; +using System.Threading.Tasks; +using WMS.Web.Domain.Entitys; namespace WMS.Web.Domain.Infrastructure { public interface IChangeBoxRecordRepositories { + // 新增 + Task Add(ChangeBoxRecord entity, bool isTransaction = true); } } diff --git a/src/WMS.Web.Domain/Infrastructure/IMoveBoxRecordRepositories.cs b/src/WMS.Web.Domain/Infrastructure/IMoveBoxRecordRepositories.cs index 7e74fced..cc9f6cf2 100644 --- a/src/WMS.Web.Domain/Infrastructure/IMoveBoxRecordRepositories.cs +++ b/src/WMS.Web.Domain/Infrastructure/IMoveBoxRecordRepositories.cs @@ -1,10 +1,14 @@ using System; using System.Collections.Generic; using System.Text; +using System.Threading.Tasks; +using WMS.Web.Domain.Entitys; namespace WMS.Web.Domain.Infrastructure { public interface IMoveBoxRecordRepositories { + // 新增 + Task Add(MoveBoxRecord entity, bool isTransaction = true); } } diff --git a/src/WMS.Web.Domain/Infrastructure/IOutStockRepositories.cs b/src/WMS.Web.Domain/Infrastructure/IOutStockRepositories.cs index dd454704..71369778 100644 --- a/src/WMS.Web.Domain/Infrastructure/IOutStockRepositories.cs +++ b/src/WMS.Web.Domain/Infrastructure/IOutStockRepositories.cs @@ -1,10 +1,14 @@ using System; using System.Collections.Generic; using System.Text; +using System.Threading.Tasks; +using WMS.Web.Domain.Entitys; namespace WMS.Web.Domain.Infrastructure { public interface IOutStockRepositories { + // 新增 + Task Add(OutStock entity, bool isTransaction = true); } } diff --git a/src/WMS.Web.Domain/Infrastructure/IOutStockTaskRepositories.cs b/src/WMS.Web.Domain/Infrastructure/IOutStockTaskRepositories.cs index 75e181a9..8fdfb566 100644 --- a/src/WMS.Web.Domain/Infrastructure/IOutStockTaskRepositories.cs +++ b/src/WMS.Web.Domain/Infrastructure/IOutStockTaskRepositories.cs @@ -1,10 +1,14 @@ using System; using System.Collections.Generic; using System.Text; +using System.Threading.Tasks; +using WMS.Web.Domain.Entitys; namespace WMS.Web.Domain.Infrastructure { public interface IOutStockTaskRepositories { + // 新增 + Task Add(OutStockTask entity, bool isTransaction = true); } } diff --git a/src/WMS.Web.Domain/Infrastructure/ITakeStockRepositories.cs b/src/WMS.Web.Domain/Infrastructure/ITakeStockRepositories.cs index fcd8ae2c..e43f0388 100644 --- a/src/WMS.Web.Domain/Infrastructure/ITakeStockRepositories.cs +++ b/src/WMS.Web.Domain/Infrastructure/ITakeStockRepositories.cs @@ -1,10 +1,14 @@ using System; using System.Collections.Generic; using System.Text; +using System.Threading.Tasks; +using WMS.Web.Domain.Entitys; namespace WMS.Web.Domain.Infrastructure { public interface ITakeStockRepositories { + // 新增 + Task Add(TakeStock entity, bool isTransaction = true); } } diff --git a/src/WMS.Web.Repositories/ChangeBoxRecordRepositories.cs b/src/WMS.Web.Repositories/ChangeBoxRecordRepositories.cs index 1d4266ab..6aa37b38 100644 --- a/src/WMS.Web.Repositories/ChangeBoxRecordRepositories.cs +++ b/src/WMS.Web.Repositories/ChangeBoxRecordRepositories.cs @@ -1,13 +1,16 @@ using AutoMapper; +using Microsoft.EntityFrameworkCore.Storage; using System; using System.Collections.Generic; using System.Text; +using System.Threading.Tasks; +using WMS.Web.Domain.Entitys; using WMS.Web.Domain.Infrastructure; using WMS.Web.Repositories.Configuration; namespace WMS.Web.Repositories { - public class ChangeBoxRecordRepositories: IChangeBoxRecordRepositories + public class ChangeBoxRecordRepositories : IChangeBoxRecordRepositories { private readonly IMapper _mapper; private readonly IServiceProvider _serviceProvider; @@ -20,5 +23,34 @@ namespace WMS.Web.Repositories _mapper = mapper; _serviceProvider = serviceProvider; } + + public async Task Add(ChangeBoxRecord entity, bool isTransaction = true) + { + IDbContextTransaction _transaction = null; + if (isTransaction) + _transaction = _context.Database.BeginTransaction(); + try + { + await _context.ChangeBoxRecord.AddAsync(entity); + await _context.SaveChangesAsync(); + + //if (string.IsNullOrEmpty(entity.OutSourcFeedNo)) + //{ + // entity.GenerateNo(); + // await _context.SaveChangesAsync(); + //} + + if (_transaction != null) + _transaction.Commit(); + return entity; + } + catch (Exception ex) + { + if (_transaction != null) + _transaction.Rollback(); + return null; + } + + } } } diff --git a/src/WMS.Web.Repositories/MoveBoxRecordRepositories.cs b/src/WMS.Web.Repositories/MoveBoxRecordRepositories.cs index 7ca4bb7a..94355151 100644 --- a/src/WMS.Web.Repositories/MoveBoxRecordRepositories.cs +++ b/src/WMS.Web.Repositories/MoveBoxRecordRepositories.cs @@ -1,7 +1,10 @@ using AutoMapper; +using Microsoft.EntityFrameworkCore.Storage; using System; using System.Collections.Generic; using System.Text; +using System.Threading.Tasks; +using WMS.Web.Domain.Entitys; using WMS.Web.Domain.Infrastructure; using WMS.Web.Repositories.Configuration; @@ -20,5 +23,39 @@ namespace WMS.Web.Repositories _mapper = mapper; _serviceProvider = serviceProvider; } + /// + /// 新增 + /// + /// + /// + /// + public async Task Add(MoveBoxRecord entity, bool isTransaction = true) + { + IDbContextTransaction _transaction = null; + if (isTransaction) + _transaction = _context.Database.BeginTransaction(); + try + { + await _context.MoveBoxRecord.AddAsync(entity); + await _context.SaveChangesAsync(); + + //if (string.IsNullOrEmpty(entity.OutSourcFeedNo)) + //{ + // entity.GenerateNo(); + // await _context.SaveChangesAsync(); + //} + + if (_transaction != null) + _transaction.Commit(); + return entity; + } + catch (Exception ex) + { + if (_transaction != null) + _transaction.Rollback(); + return null; + } + + } } } diff --git a/src/WMS.Web.Repositories/OutStockRepositories.cs b/src/WMS.Web.Repositories/OutStockRepositories.cs index 934513e9..c5721bb3 100644 --- a/src/WMS.Web.Repositories/OutStockRepositories.cs +++ b/src/WMS.Web.Repositories/OutStockRepositories.cs @@ -1,7 +1,10 @@ using AutoMapper; +using Microsoft.EntityFrameworkCore.Storage; using System; using System.Collections.Generic; using System.Text; +using System.Threading.Tasks; +using WMS.Web.Domain.Entitys; using WMS.Web.Domain.Infrastructure; using WMS.Web.Repositories.Configuration; @@ -20,5 +23,39 @@ namespace WMS.Web.Repositories _mapper = mapper; _serviceProvider = serviceProvider; } + /// + /// 新增 + /// + /// + /// + /// + public async Task Add(OutStock entity, bool isTransaction = true) + { + IDbContextTransaction _transaction = null; + if (isTransaction) + _transaction = _context.Database.BeginTransaction(); + try + { + await _context.OutStock.AddAsync(entity); + await _context.SaveChangesAsync(); + + //if (string.IsNullOrEmpty(entity.OutSourcFeedNo)) + //{ + // entity.GenerateNo(); + // await _context.SaveChangesAsync(); + //} + + if (_transaction != null) + _transaction.Commit(); + return entity; + } + catch (Exception ex) + { + if (_transaction != null) + _transaction.Rollback(); + return null; + } + + } } } diff --git a/src/WMS.Web.Repositories/OutStockTaskRepositories.cs b/src/WMS.Web.Repositories/OutStockTaskRepositories.cs index 46fd376a..5a5ff771 100644 --- a/src/WMS.Web.Repositories/OutStockTaskRepositories.cs +++ b/src/WMS.Web.Repositories/OutStockTaskRepositories.cs @@ -1,7 +1,10 @@ using AutoMapper; +using Microsoft.EntityFrameworkCore.Storage; using System; using System.Collections.Generic; using System.Text; +using System.Threading.Tasks; +using WMS.Web.Domain.Entitys; using WMS.Web.Domain.Infrastructure; using WMS.Web.Repositories.Configuration; @@ -20,5 +23,39 @@ namespace WMS.Web.Repositories _mapper = mapper; _serviceProvider = serviceProvider; } + /// + /// 新增 + /// + /// + /// + /// + public async Task Add(OutStockTask entity, bool isTransaction = true) + { + IDbContextTransaction _transaction = null; + if (isTransaction) + _transaction = _context.Database.BeginTransaction(); + try + { + await _context.OutStockTask.AddAsync(entity); + await _context.SaveChangesAsync(); + + //if (string.IsNullOrEmpty(entity.OutSourcFeedNo)) + //{ + // entity.GenerateNo(); + // await _context.SaveChangesAsync(); + //} + + if (_transaction != null) + _transaction.Commit(); + return entity; + } + catch (Exception ex) + { + if (_transaction != null) + _transaction.Rollback(); + return null; + } + + } } } diff --git a/src/WMS.Web.Repositories/TakeStockRepositories.cs b/src/WMS.Web.Repositories/TakeStockRepositories.cs index aa5bd93e..09542d0c 100644 --- a/src/WMS.Web.Repositories/TakeStockRepositories.cs +++ b/src/WMS.Web.Repositories/TakeStockRepositories.cs @@ -1,7 +1,10 @@ using AutoMapper; +using Microsoft.EntityFrameworkCore.Storage; using System; using System.Collections.Generic; using System.Text; +using System.Threading.Tasks; +using WMS.Web.Domain.Entitys; using WMS.Web.Domain.Infrastructure; using WMS.Web.Repositories.Configuration; @@ -20,5 +23,39 @@ namespace WMS.Web.Repositories _mapper = mapper; _serviceProvider = serviceProvider; } + /// + /// 新增 + /// + /// + /// + /// + public async Task Add(TakeStock entity, bool isTransaction = true) + { + IDbContextTransaction _transaction = null; + if (isTransaction) + _transaction = _context.Database.BeginTransaction(); + try + { + await _context.TakeStock.AddAsync(entity); + await _context.SaveChangesAsync(); + + //if (string.IsNullOrEmpty(entity.OutSourcFeedNo)) + //{ + // entity.GenerateNo(); + // await _context.SaveChangesAsync(); + //} + + if (_transaction != null) + _transaction.Commit(); + return entity; + } + catch (Exception ex) + { + if (_transaction != null) + _transaction.Rollback(); + return null; + } + + } } } From 163c24d02c8f471144f767967e2e9185af116b2a Mon Sep 17 00:00:00 2001 From: 18942506660 <18942506660@A18942506660> Date: Thu, 26 Oct 2023 14:20:31 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/WMS.Web.Domain/Entitys/OutStock.cs | 2 +- src/WMS.Web.Domain/Entitys/OutStockTask.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/WMS.Web.Domain/Entitys/OutStock.cs b/src/WMS.Web.Domain/Entitys/OutStock.cs index f8fc409a..45a4f0a7 100644 --- a/src/WMS.Web.Domain/Entitys/OutStock.cs +++ b/src/WMS.Web.Domain/Entitys/OutStock.cs @@ -29,7 +29,7 @@ namespace WMS.Web.Domain.Entitys /// 单据类型 /// [Column("Type")] - public OrderType Type { get; set; } = OrderType.Sal; + public OrderType Type { get; set; } = OrderType.Sal_Out; /// /// 创建人 diff --git a/src/WMS.Web.Domain/Entitys/OutStockTask.cs b/src/WMS.Web.Domain/Entitys/OutStockTask.cs index 08bc3081..00a82828 100644 --- a/src/WMS.Web.Domain/Entitys/OutStockTask.cs +++ b/src/WMS.Web.Domain/Entitys/OutStockTask.cs @@ -34,7 +34,7 @@ namespace WMS.Web.Domain.Entitys /// 单据类型 /// [Column("Type")] - public OrderType Type { get; set; } = OrderType.Sal; + public OrderType Type { get; set; } = OrderType.Sal_Out; /// /// 操作人(出库人) ///