From 84e5201d9a9720019c5ba1f4073fe2866df4fe59 Mon Sep 17 00:00:00 2001 From: mahao Date: Thu, 25 May 2023 09:41:56 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20TS=5FUNI=5FAPI=20=E6=95=B0?= =?UTF-8?q?=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- host/WmsWebApi.HttpApi.Host/appsettings.json | 6 +- .../ProductRecieve/ProductRecieveService.cs | 55 +++++++++++++++++-- .../StockMove/StockMoveService.cs | 52 ++++++++++++++++-- .../WMS/IRepository/ITSUNIAPIRepository.cs | 12 ++++ src/WmsWebApi.Domain/WMS/TS_UNI_API.cs | 9 ++- .../WmsWebApiEntityFrameworkCoreModule.cs | 4 +- .../Repositories/TSUNIAPIRepository.cs | 23 ++++++++ 7 files changed, 143 insertions(+), 18 deletions(-) create mode 100644 src/WmsWebApi.Domain/WMS/IRepository/ITSUNIAPIRepository.cs create mode 100644 src/WmsWebApi.EntityFrameworkCore/Repositories/TSUNIAPIRepository.cs diff --git a/host/WmsWebApi.HttpApi.Host/appsettings.json b/host/WmsWebApi.HttpApi.Host/appsettings.json index 1c6d571..1295475 100644 --- a/host/WmsWebApi.HttpApi.Host/appsettings.json +++ b/host/WmsWebApi.HttpApi.Host/appsettings.json @@ -14,8 +14,8 @@ "WmsWebApiJson": "Server=192.168.0.140;Database=CPAT_WMS_Json_TEST;User ID=sa;Password=Microsoft2008", "AbpBackgroundJobs": "Server=192.168.0.140;Database=CPAT_WMS_Json_TEST;User ID=sa;Password=Microsoft2008", - "AgvInLoc": "CUST", - "AgvOutLoc": "CUST" + "AgvInLoc": "B8L-1", + "AgvOutLoc": "B9ACC" }, "Redis": { "Configuration": "127.0.0.1" @@ -28,7 +28,7 @@ }, "CustomConfig": { "OtherZllConfig": { - "IsEnableErnamFilter": true, + "IsEnableErnamFilter": false, "ErnamFilters": [ "1023", "1024" ] } } diff --git a/src/WmsWebApi.Application/ProductRecieve/ProductRecieveService.cs b/src/WmsWebApi.Application/ProductRecieve/ProductRecieveService.cs index 2f8e812..f2fa417 100644 --- a/src/WmsWebApi.Application/ProductRecieve/ProductRecieveService.cs +++ b/src/WmsWebApi.Application/ProductRecieve/ProductRecieveService.cs @@ -15,8 +15,10 @@ using WmsWebApi.BackgroundJobs; using WmsWebApi.Domain; using WmsWebApi.EntityFrameworkCore; using WmsWebApi.Jsons; +using WmsWebApi.Repositories; using WmsWebApi.Wms; using WmsWebApi.WMS; +using WmsWebApi.WMS.IRepository; namespace WmsWebApi.ProductRecieve; @@ -39,6 +41,7 @@ public class ProductRecieveService : ApplicationService, IProductRecieveService private readonly IBackgroundJobRequestRetry _backgroundJobRequestRetry; private readonly IProductRecieveJsonRepository _productRecieveJsonRepository; private readonly AsyncRetryPolicy _asyncRetryPolicy; + private readonly ITSUNIAPIRepository _tSUNIAPIRepository; /// /// 是否是请求重试 @@ -56,7 +59,8 @@ public class ProductRecieveService : ApplicationService, IProductRecieveService IConfiguration configuration, IUnitOfWorkManager unitOfWorkManager, IBackgroundJobRequestRetry backgroundJobRequestRetry, - IProductRecieveJsonRepository productRecieveJsonRepository) + IProductRecieveJsonRepository productRecieveJsonRepository, + ITSUNIAPIRepository tSUNIAPIRepository) { _tsStockDetailRepository = tsStockDetailRepository; _tbProductReceiveRepository = tbProductReceiveRepository; @@ -80,6 +84,7 @@ public class ProductRecieveService : ApplicationService, IProductRecieveService { Logger.LogInformation($"执行失败,第 {retryCount} 次重试"); }); + _tSUNIAPIRepository = tSUNIAPIRepository; } [HttpPost("add/IF01")] @@ -257,6 +262,42 @@ public class ProductRecieveService : ApplicationService, IProductRecieveService TransType = 1 }; _transList.Add(tlTrans); + + //插入TS_UNI_API + listTSUNIAPI.Add(new TS_UNI_API() + { + InterfaceType = "BackFlush", + TableName = "xxwms_bk_mstr", + BillType = 201, + SubBillType = tbBill.SubBillType, + BillNum = tbBill.BillNum, + PartCode = item.PartCode, + Batch = item.Batch, + FromLoc = "", + ToLoc = tbRecieve.ToLocCode, + FromErpLoc = "", + ToErpLoc = "", + Qty = item.Qty, + State = 0, + CreateOper = "AGV", + CreateTime = DateTime.Now, + PutTime = DateTime.Now, + CustId = "", + VendId = "", + PoUnit = "", + LocUnit = "", + ValidDate = DateTime.Now, + ErpBillNum = tbBill.BillNum, + ErpLineNum = 0, + EqptCode = "", + EqptType = "B", + VendBatch = item.Batch, + SourceBillNum = tbBill.SourceBillNum, + ProcessId = 0, + GoodQty = item.Qty, + ScrapQty = 0, + InvalidQty = 0 + }); } if (!bErr) { @@ -269,6 +310,10 @@ public class ProductRecieveService : ApplicationService, IProductRecieveService await _tsStockDetailRepository.AddAsync(_stockList); if (_stockUpdateList != null && _stockUpdateList.Count() > 0) await _tmPgWmsUpdate.UpdateTsStock(_stockUpdateList); + if (listTSUNIAPI != null && listTSUNIAPI.Count() > 0) + { + await _tSUNIAPIRepository.InsertManyAsync(listTSUNIAPI); + } await _tlTransactionRepository.AddAsync(_transList); } await CurrentUnitOfWork.SaveChangesAsync(); @@ -280,14 +325,14 @@ public class ProductRecieveService : ApplicationService, IProductRecieveService result.TYPE = 'E'; result.MESSAGE = ex.Message; - if (IsRequestRetry == false) + if (IsRequestRetry == false) { //await _backgroundJobRequestRetry.AddBackgroundJobAsync(EnumActionName.ProductRecieveAdd, content.ToString()); } throw new Exception($"接口异常,请稍后重试:{ex.GetBaseException().Message}", ex); } - finally + finally { if (IsRequestRetry == false) { @@ -298,7 +343,7 @@ public class ProductRecieveService : ApplicationService, IProductRecieveService result.TYPE = 'E'; apiPRdto.ITYPE = result.MESSAGE; } - else + else { result.MESSAGE = "成功"; apiPRdto.ITYPE = "成功"; @@ -325,7 +370,7 @@ public class ProductRecieveService : ApplicationService, IProductRecieveService if (bErr == false) { - result.MESSAGE = "接收成功!"; + result.MESSAGE = "成功!"; } return result; } diff --git a/src/WmsWebApi.Application/StockMove/StockMoveService.cs b/src/WmsWebApi.Application/StockMove/StockMoveService.cs index 3d26236..e73c360 100644 --- a/src/WmsWebApi.Application/StockMove/StockMoveService.cs +++ b/src/WmsWebApi.Application/StockMove/StockMoveService.cs @@ -20,6 +20,8 @@ using WmsWebApi.Enums; using WmsWebApi.Jsons; using WmsWebApi.StockMove; using WmsWebApi.Wms; +using WmsWebApi.WMS; +using WmsWebApi.WMS.IRepository; namespace WmsWebApi.StockMove; @@ -42,6 +44,7 @@ public class StockMoveService : ApplicationService, IStockMoveService private readonly IBackgroundJobRequestRetry _backgroundJobRequestRetry; private readonly IStockMoveJsonRepository _stockMoveJsonRepository; private readonly AsyncRetryPolicy _asyncRetryPolicy; + private readonly ITSUNIAPIRepository _tSUNIAPIRepository; /// /// 是否是请求重试 @@ -59,7 +62,8 @@ public class StockMoveService : ApplicationService, IStockMoveService IConfiguration configuration, IUnitOfWorkManager unitOfWorkManager, IBackgroundJobRequestRetry backgroundJobRequestRetry, - IStockMoveJsonRepository stockMoveJsonRepository) + IStockMoveJsonRepository stockMoveJsonRepository, + ITSUNIAPIRepository tSUNIAPIRepository) { _tsStockDetailRepository = tsStockDetailRepository; _tbStockMoveRepository = tbStockMoveRepository; @@ -83,6 +87,7 @@ public class StockMoveService : ApplicationService, IStockMoveService { Logger.LogInformation($"执行失败,第 {retryCount} 次重试"); }); + _tSUNIAPIRepository = tSUNIAPIRepository; } /// @@ -131,6 +136,7 @@ public class StockMoveService : ApplicationService, IStockMoveService List _stockUpdateList = new List(); List _stockDelList = new List(); List _transList = new List(); + List listTSUNIAPI = new List(); #region 添加BILL var tbBill = new TB_BILL @@ -392,9 +398,43 @@ public class StockMoveService : ApplicationService, IStockMoveService _transList.Add(tlTrans1); _transList.Add(tlTrans2); } - - #endregion + + //插入TS_UNI_API + listTSUNIAPI.Add(new TS_UNI_API() + { + InterfaceType = "BackFlush", + TableName = "xxwms_bk_mstr", + BillType = 201, + SubBillType = tbBill.SubBillType, + BillNum = tbBill.BillNum, + PartCode = item.PartCode, + Batch = item.Batch, + FromLoc = tbStockMove.FromLocCode, + ToLoc = tbStockMove.ToLocCode, + FromErpLoc = "", + ToErpLoc = "", + Qty = item.Qty, + State = 0, + CreateOper = "AGV", + CreateTime = DateTime.Now, + PutTime = DateTime.Now, + CustId = "", + VendId = "", + PoUnit = "", + LocUnit = "", + ValidDate = DateTime.Now, + ErpBillNum = tbBill.BillNum, + ErpLineNum = 0, + EqptCode = "", + EqptType = "B", + VendBatch = item.Batch, + SourceBillNum = tbBill.SourceBillNum, + ProcessId = 0, + GoodQty = item.Qty, + ScrapQty = 0, + InvalidQty = 0 + }); } if (!bErr) { @@ -409,6 +449,10 @@ public class StockMoveService : ApplicationService, IStockMoveService await _tmPgWmsUpdate.UpdateTsStock(_stockUpdateList); if (_stockDelList != null && _stockDelList.Count() > 0) await _tmPgWmsUpdate.DeleteTsStock(_stockDelList); + if (listTSUNIAPI != null && listTSUNIAPI.Count() > 0) + { + await _tSUNIAPIRepository.InsertManyAsync(listTSUNIAPI); + } await _tlTransactionRepository.AddAsync(_transList); } await CurrentUnitOfWork.SaveChangesAsync(); @@ -436,12 +480,12 @@ public class StockMoveService : ApplicationService, IStockMoveService if (bErr) { result.TYPE = 'E'; - apiSSdto.ITYPE = result.MESSAGE; } else { apiSSdto.ITYPE = "成功"; } + apiSSdto.ITYPE = result.MESSAGE; try { await AddWmsWebApiStockMoveDTONowUnitOfWorkAsync(apiSSdto); diff --git a/src/WmsWebApi.Domain/WMS/IRepository/ITSUNIAPIRepository.cs b/src/WmsWebApi.Domain/WMS/IRepository/ITSUNIAPIRepository.cs new file mode 100644 index 0000000..c796f9a --- /dev/null +++ b/src/WmsWebApi.Domain/WMS/IRepository/ITSUNIAPIRepository.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Text; +using Volo.Abp.DependencyInjection; +using Volo.Abp.Domain.Repositories; + +namespace WmsWebApi.WMS.IRepository +{ + public interface ITSUNIAPIRepository : IRepository, ITransientDependency + { + } +} diff --git a/src/WmsWebApi.Domain/WMS/TS_UNI_API.cs b/src/WmsWebApi.Domain/WMS/TS_UNI_API.cs index ff5ad48..0f1facb 100644 --- a/src/WmsWebApi.Domain/WMS/TS_UNI_API.cs +++ b/src/WmsWebApi.Domain/WMS/TS_UNI_API.cs @@ -64,7 +64,7 @@ namespace WmsWebApi.WMS /// /// 数量 /// - public double? Qty { get; set; } + public decimal? Qty { get; set; } /// /// 状态 @@ -154,19 +154,18 @@ namespace WmsWebApi.WMS /// /// GoodQty /// - public double? GoodQty { get; set; } + public decimal? GoodQty { get; set; } /// /// ScrapQty /// - public double? ScrapQty { get; set; } + public decimal? ScrapQty { get; set; } /// /// InvalidQty /// - public double? InvalidQty { get; set; } + public decimal? InvalidQty { get; set; } #endregion - } } diff --git a/src/WmsWebApi.EntityFrameworkCore/EntityFrameworkCore/WmsWebApiEntityFrameworkCoreModule.cs b/src/WmsWebApi.EntityFrameworkCore/EntityFrameworkCore/WmsWebApiEntityFrameworkCoreModule.cs index fd7d7c1..959bad9 100644 --- a/src/WmsWebApi.EntityFrameworkCore/EntityFrameworkCore/WmsWebApiEntityFrameworkCoreModule.cs +++ b/src/WmsWebApi.EntityFrameworkCore/EntityFrameworkCore/WmsWebApiEntityFrameworkCoreModule.cs @@ -5,7 +5,9 @@ using Volo.Abp; using Volo.Abp.Dapper; using Volo.Abp.EntityFrameworkCore; using Volo.Abp.Modularity; +using WmsWebApi.Repositories; using WmsWebApi.Wms; +using WmsWebApi.WMS.IRepository; namespace WmsWebApi.EntityFrameworkCore { @@ -43,7 +45,7 @@ namespace WmsWebApi.EntityFrameworkCore context.Services.AddTransient(typeof(ITsStockDetailRepository), typeof(TsStockDetailRepository)); context.Services.AddTransient(typeof(ITLTransactionRepository), typeof(TLTransactionRepository)); context.Services.AddTransient(typeof(ITbStockMoveRepository), typeof(TbStockMoveRepository)); - + context.Services.AddTransient(typeof(ITSUNIAPIRepository), typeof(TSUNIAPIRepository)); } } } \ No newline at end of file diff --git a/src/WmsWebApi.EntityFrameworkCore/Repositories/TSUNIAPIRepository.cs b/src/WmsWebApi.EntityFrameworkCore/Repositories/TSUNIAPIRepository.cs new file mode 100644 index 0000000..573738c --- /dev/null +++ b/src/WmsWebApi.EntityFrameworkCore/Repositories/TSUNIAPIRepository.cs @@ -0,0 +1,23 @@ +using System.Collections.Generic; +using System.Threading.Tasks; +using Volo.Abp.Domain.Repositories.EntityFrameworkCore; +using Volo.Abp.EntityFrameworkCore; +using WmsWebApi.EntityFrameworkCore; +using WmsWebApi.WMS; +using WmsWebApi.WMS.IRepository; + +namespace WmsWebApi.Repositories +{ + public class TSUNIAPIRepository : EfCoreRepository, ITSUNIAPIRepository + { + public TSUNIAPIRepository(IDbContextProvider dbContextProvider) : base(dbContextProvider) + { + } + + public async Task AddAsync(List TSUNIAPIs) + { + await InsertManyAsync(TSUNIAPIs); + return TSUNIAPIs.Count; + } + } +}