From 7ee8c6580636a18326bead1c3827a80a1912c17a Mon Sep 17 00:00:00 2001 From: 18942506660 <18942506660@A18942506660> Date: Mon, 21 Oct 2024 14:32:22 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .vs/WMS.Web/DesignTimeBuild/.dtbcache.v2 | Bin 275060 -> 275060 bytes .../IProductInventoryRepositories.cs | 2 + .../Mappers/ProductInventoryMapper.cs | 17 +++++++ .../Services/ProductInventoryService.cs | 22 ++++++-- .../ProductInventoryRepositories.cs | 47 ++++++++++++++++++ 5 files changed, 85 insertions(+), 3 deletions(-) create mode 100644 src/WMS.Web.Domain/Mappers/ProductInventoryMapper.cs diff --git a/.vs/WMS.Web/DesignTimeBuild/.dtbcache.v2 b/.vs/WMS.Web/DesignTimeBuild/.dtbcache.v2 index 3594c178f647095168e7d6563f1983ba80d70430..5c42c02b2dd40e7f390c872912d167970f40f616 100644 GIT binary patch delta 3311 zcmZve33ycH6^7^Do8%k>BcP>hNfD`9tC*R|Hk8`1NZCp(MQTyBlbH-CLNE{z5QarW z76l?YT5D@tt8Lh3l;sUsUI3I%oHZJEfAL7H)d7f|n_bmVUxBK6j zBYWE(+1u7RHpf}#I5VpUgo5R<%941jA{dNURK{bWa7|fdBvu*@1uNq5aI~~05{o2i zBeju4sHQYj7LP^CB9W3{Wwf?78m)~7+)ywONe#Ky2`@NW?WB)ZyIZ{h;fiQ1nkWfZ zmV{&B^0M+^S$Q~E8Vi-h5|L;yQETzqNU$_s6HJtrMQUPkD;JAahAK)E;Y2J{5^#f+ zfzGKuqnxwT#UtDi#jOTSm{L1oa$Wtj^r(9G%h5&aH4sRfHkjH50)fY^Z8mN6eW~f& z+)Il#8+NkLv(`RmdfxPc=|$7V)Fw+wzH0ci={3_X)9a=;OuJ2Qnq2F?$J)0{p7Gn( zp0pja-!a>7-(`HKwSGOn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Jx+(2g~x3)zA5G*TU^r=Pt;VGJa_wu~1Yvk&tGqZCr@Xn{sgSzyBV{SSx zxIz)g$=dIu2A2Pr2>ReM-H{Hs8iP jVmH7b?-ZZb)Uzkuo~iby-NN*O;qGJp^n_DxZt4F3;fSWk diff --git a/src/WMS.Web.Domain/Infrastructure/IProductInventoryRepositories.cs b/src/WMS.Web.Domain/Infrastructure/IProductInventoryRepositories.cs index 99021660..fa0bcd53 100644 --- a/src/WMS.Web.Domain/Infrastructure/IProductInventoryRepositories.cs +++ b/src/WMS.Web.Domain/Infrastructure/IProductInventoryRepositories.cs @@ -29,6 +29,8 @@ namespace WMS.Web.Domain.Infrastructure /// /// Task Delete(ProductInventoryType type, bool isTransaction = true); + Task EditEntityList(List entitys, bool isTransaction = true); + Task> GetEntityList(ProductInventoryType type); /// /// 列表-分页 /// diff --git a/src/WMS.Web.Domain/Mappers/ProductInventoryMapper.cs b/src/WMS.Web.Domain/Mappers/ProductInventoryMapper.cs new file mode 100644 index 00000000..182a829a --- /dev/null +++ b/src/WMS.Web.Domain/Mappers/ProductInventoryMapper.cs @@ -0,0 +1,17 @@ +using AutoMapper; +using System; +using System.Collections.Generic; +using System.Text; +using WMS.Web.Core.Dto.Erp; +using WMS.Web.Domain.Entitys; + +namespace WMS.Web.Domain.Mappers +{ + public class ProductInventoryMapper : Profile + { + public ProductInventoryMapper() + { + CreateMap().ReverseMap(); + } + } +} diff --git a/src/WMS.Web.Domain/Services/ProductInventoryService.cs b/src/WMS.Web.Domain/Services/ProductInventoryService.cs index fce77817..94d6c0c0 100644 --- a/src/WMS.Web.Domain/Services/ProductInventoryService.cs +++ b/src/WMS.Web.Domain/Services/ProductInventoryService.cs @@ -130,6 +130,9 @@ namespace WMS.Web.Domain.Services .Select(s => s.WarehouseCodeOfJushuitan) .ToList(); if (listNames.Count() <= 0) return Result.ReSuccess(); + //获取原数据 + var yList = await _repositories.GetEntityList(ProductInventoryType.JushuiTan); + //获取领星仓库 var resStock = await _juShuiTanService.GetStock(); if (!resStock.IsSuccess) return resStock; @@ -139,6 +142,8 @@ namespace WMS.Web.Domain.Services var resInventory = await _juShuiTanService.GetInventory(ids); if (!resInventory.IsSuccess) return resStock; + + //物料 var materials_result = await _erpService.BillQueryForMaterial(); List materials = new List(); @@ -146,6 +151,7 @@ namespace WMS.Web.Domain.Services materials = materials_result.Data.ToList(); List inventoryList = new List(); + List update_List = new List(); foreach (var item in resInventory.Data) { //如果物料不匹配 过滤 @@ -167,7 +173,17 @@ namespace WMS.Web.Domain.Services Qty = item.ky_qty, BeforeQty = item.qty ?? 0 }; - inventoryList.Add(entity); + + var old_Entity = yList.FirstOrDefault(f => f.MaterialNumber.Equals(entity.MaterialNumber) && + f.OrgCode.Equals(entity.OrgCode) && f.StockCode.Equals(entity.StockCode)); + if (old_Entity != null) + { + old_Entity.Qty = entity.Qty; + old_Entity.BeforeQty = entity.BeforeQty; + update_List.Add(old_Entity); + } + else + inventoryList.Add(entity); } IDbContextTransaction _transaction = _transactionRepositories.GetTransaction(); Result res_Rollback = Result.ReSuccess(); @@ -176,7 +192,7 @@ namespace WMS.Web.Domain.Services //先删除之前的再添加 if (res_Rollback.IsSuccess) { - isSuccess = await _repositories.Delete(ProductInventoryType.LingXing, false); + isSuccess = await _repositories.EditEntityList(update_List, false); if (isSuccess == false) res_Rollback = Result.ReFailure(ResultCodes.DateWriteError); } if (res_Rollback.IsSuccess) @@ -283,7 +299,7 @@ namespace WMS.Web.Domain.Services _logger.LogInformation($"同步成品仓库存->开始 {DateTime.Now}"); var res = await this.Erp(); - if(!res.IsSuccess)return res; + if (!res.IsSuccess) return res; res = await this.JuShuiTan(); if (!res.IsSuccess) return res; diff --git a/src/WMS.Web.Repositories/ProductInventoryRepositories.cs b/src/WMS.Web.Repositories/ProductInventoryRepositories.cs index f97e08ec..ecea21f5 100644 --- a/src/WMS.Web.Repositories/ProductInventoryRepositories.cs +++ b/src/WMS.Web.Repositories/ProductInventoryRepositories.cs @@ -19,6 +19,8 @@ using WMS.Web.Core.Dto.OutStockTask; using WMS.Web.Domain.Values.Single; using WMS.Web.Core; using NPOI.SS.Formula.Functions; +using WMS.Web.Domain.Mappers; +using WMS.Web.Core.Help; namespace WMS.Web.Repositories { @@ -173,5 +175,50 @@ namespace WMS.Web.Repositories var (list, count, qty) = await GetListAsync(dto, companyId); return (list, count); } + /// + /// 批量修改 + /// + /// + /// + /// + public async Task EditEntityList(List entitys, bool isTransaction = true) + { + IDbContextTransaction _transaction = null; + if (isTransaction) + _transaction = _context.Database.BeginTransaction(); + try + { + List list = entitys.Select(s => s.Id).ToList(); + + var res = await _context.ProductInventory + .Where(f => list.Contains(f.Id)).ToListAsync(); + + _mapper.ToMapList(entitys, res); + await _context.SaveChangesAsync(); + if (_transaction != null) + _transaction.Commit(); + } + catch (Exception ex) + { + if (_transaction != null) + _transaction.Rollback(); + return false; + } + return true; + + } + /// + /// 获取数据 + /// + /// + /// + public async Task> GetEntityList(ProductInventoryType type) + { + var res = await _context.ProductInventory + .Where(f => f.Type==type) + .ToListAsync(); + + return res.Clone(); + } } }