diff --git a/src/WMS.Web.Api/Controllers/TestController.cs b/src/WMS.Web.Api/Controllers/TestController.cs index d225d5bf..b2e70e2c 100644 --- a/src/WMS.Web.Api/Controllers/TestController.cs +++ b/src/WMS.Web.Api/Controllers/TestController.cs @@ -29,10 +29,12 @@ namespace WMS.Web.Api.Controllers private readonly IBoxService _boxService; private readonly IOutStockTaskRepositories _outStockTaskRepositories; private readonly IOutStockTaskService _outStockTaskService; - public TestController(IErpService erpService, IInStockTaskService inStockTaskService, + private readonly IBoxInventoryRepositories _boxInventoryRepositories; + public TestController(IErpService erpService, IInStockTaskService inStockTaskService, IBoxInventoryRepositories boxInventoryRepositories, IBasicsRepositories transactionRepositories, IOpsService opsService, IBoxService boxService, IOutStockTaskRepositories outStockTaskRepositories, IOutStockTaskService outStockTaskService) { + _boxInventoryRepositories = boxInventoryRepositories; this._erpService = erpService; this._inStockTaskService = inStockTaskService; this._transactionRepositories = transactionRepositories; @@ -80,11 +82,46 @@ namespace WMS.Web.Api.Controllers [Route("tf")] public async Task TestTF() { - //var result = await this._erpService.BillQueryForOrg(); - var result = await this._erpService.BillQueryForBillType(); - if (!result.IsSuccess) - return ""; - return JsonConvert.SerializeObject(result.Data); + ////var result = await this._erpService.BillQueryForOrg(); + //var result = await this._erpService.BillQueryForBillType(); + //if (!result.IsSuccess) + // return ""; + //return JsonConvert.SerializeObject(result.Data); + + + var tttt = new List() { "ABCD14200999" }; + var boxInventorys = await _boxInventoryRepositories.Get(142); + + var data = new List(); + + //var entity = new BoxInventory(); + //entity.Id = 34; + //entity.BoxId = 142; + //entity.OrgCode = "101"; + //entity.StockCode = "CK003"; + //entity.SubStockId = 2949; + + //var det = new BoxInventoryDetails(); + + //det.Id = 266; + //det.Fid = 34; + //det.MaterialId = 4799560; + //det.SerialNumbers = new List() { "ABCD143001", "ABCD142002" }; + //det.Qty = 2; + //entity.Details.Add(det); + + boxInventorys.Details.ForEach(x=> + { + x.SerialNumbers.RemoveAll(t => tttt.Contains(t)); + //x.SerialNumbers.AddRange(tttt); + x.Qty = 3; + }); + + data.Add(boxInventorys); + var result= await _boxInventoryRepositories.UpdateRange(data); + return ""; + + } diff --git a/src/WMS.Web.Domain/Services/BoxInventoryService.cs b/src/WMS.Web.Domain/Services/BoxInventoryService.cs index dcc5812f..e7490fb9 100644 --- a/src/WMS.Web.Domain/Services/BoxInventoryService.cs +++ b/src/WMS.Web.Domain/Services/BoxInventoryService.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; using System.Linq; using System.Text; +using System.Text.Json; using System.Threading.Tasks; using WMS.Web.Core.Dto.Inventory; using WMS.Web.Core.Internal.Results; diff --git a/src/WMS.Web.Domain/Services/InStockService.cs b/src/WMS.Web.Domain/Services/InStockService.cs index 0c2e85f5..1d1583f0 100644 --- a/src/WMS.Web.Domain/Services/InStockService.cs +++ b/src/WMS.Web.Domain/Services/InStockService.cs @@ -372,7 +372,6 @@ namespace WMS.Web.Domain.Services } } - string g_json = JsonSerializer.Serialize(ganenrateChangeBoxs); //改箱保存操作 var changeBoxSave_Result = await _changeMoveBoxService.ChangeBoxSave(ganenrateChangeBoxs, loginInfo, isTransaction); if (!changeBoxSave_Result.IsSuccess) diff --git a/src/WMS.Web.Repositories/BoxInventoryRepositories.cs b/src/WMS.Web.Repositories/BoxInventoryRepositories.cs index 9f9edf80..797ee01c 100644 --- a/src/WMS.Web.Repositories/BoxInventoryRepositories.cs +++ b/src/WMS.Web.Repositories/BoxInventoryRepositories.cs @@ -188,7 +188,7 @@ namespace WMS.Web.Repositories List list = entitys.Select(s => s.Id).ToList(); var res = await _context.BoxInventory.Include(x => x.Details).Where(f => list.Contains(f.Id)).ToListAsync(); _mapper.Map(entitys, res); - await _context.SaveChangesAsync(); + var tt= await _context.SaveChangesAsync(); if (_transaction != null) _transaction.Commit(); } diff --git a/src/WMS.Web.Repositories/Configuration/RepositoryDbContext.cs b/src/WMS.Web.Repositories/Configuration/RepositoryDbContext.cs index fd1000db..49a86fdb 100644 --- a/src/WMS.Web.Repositories/Configuration/RepositoryDbContext.cs +++ b/src/WMS.Web.Repositories/Configuration/RepositoryDbContext.cs @@ -1,9 +1,11 @@ using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.ChangeTracking; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Debug; using Newtonsoft.Json; using System; using System.Collections.Generic; +using System.Linq; using System.Text; using System.Text.Json; using WMS.Web.Domain.Entitys; @@ -264,7 +266,11 @@ namespace WMS.Web.Repositories.Configuration ent.HasKey(x => x.Id); ent.Property(f => f.SerialNumbers).HasConversion( v => JsonConvert.SerializeObject(v), - v => JsonConvert.DeserializeObject>(v)); + v => JsonConvert.DeserializeObject>(v), + new ValueComparer>( + (c1,c2)=>c1.SequenceEqual(c2), + c=>c.Aggregate(0,(a,v)=>HashCode.Combine(a,v.GetHashCode())), + c=>(List)c.ToList())); }); # endregion