diff --git a/src/WMS.Web.Api/wwwroot/WMS.Web.Core.xml b/src/WMS.Web.Api/wwwroot/WMS.Web.Core.xml index 0c81503c..39a67bf0 100644 --- a/src/WMS.Web.Api/wwwroot/WMS.Web.Core.xml +++ b/src/WMS.Web.Api/wwwroot/WMS.Web.Core.xml @@ -3541,10 +3541,10 @@ 出库数量 - - - 箱信息和对应的出库数量 - + + + 箱Id + diff --git a/src/WMS.Web.Api/wwwroot/WMS.Web.Domain.xml b/src/WMS.Web.Api/wwwroot/WMS.Web.Domain.xml index 371ae633..0ddb9a8d 100644 --- a/src/WMS.Web.Api/wwwroot/WMS.Web.Domain.xml +++ b/src/WMS.Web.Api/wwwroot/WMS.Web.Domain.xml @@ -1016,16 +1016,6 @@ 单据头Id - - - 销售订单号 - - - - - 来源单号 - - 物料Id @@ -1051,6 +1041,46 @@ 出库数量 + + + 对应erp明细 同一个物料 存在于不同的来源单中(合并后出现多条) + + + + + 对应金蝶的明细 + + + + + 主键 订单编号 + + + + + 任务单明细Id + + + + + 对应金蝶单据明细id(销售出库同步金蝶下推使用) + + + + + 来源单号 + + + + + 销售订单号 + + + + + 出库数量 + + erp出库任务单 diff --git a/src/WMS.Web.Domain/Entitys/OutStockDetails.cs b/src/WMS.Web.Domain/Entitys/OutStockDetails.cs index 4c642628..fb14fb41 100644 --- a/src/WMS.Web.Domain/Entitys/OutStockDetails.cs +++ b/src/WMS.Web.Domain/Entitys/OutStockDetails.cs @@ -25,17 +25,6 @@ namespace WMS.Web.Domain.Entitys /// [Column("Fid")] public int Fid { get; set; } - - /// - /// 销售订单号 - /// - [Column("SaleBillNo")] - public List SaleBillNos { get; set; } - /// - /// 来源单号 - /// - [Column("SourceBillNo")] - public List SourceBillNos { get; set; } /// /// 物料Id /// @@ -61,5 +50,10 @@ namespace WMS.Web.Domain.Entitys /// [Column("Qty")] public decimal Qty { get; set; } + + /// + /// 对应erp明细 同一个物料 存在于不同的来源单中(合并后出现多条) + /// + public List ErpDetails { get; set; } = new List(); } } diff --git a/src/WMS.Web.Domain/Entitys/OutStockErpDetails.cs b/src/WMS.Web.Domain/Entitys/OutStockErpDetails.cs new file mode 100644 index 00000000..da6e13af --- /dev/null +++ b/src/WMS.Web.Domain/Entitys/OutStockErpDetails.cs @@ -0,0 +1,48 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations.Schema; +using System.Text; +using WMS.Web.Core; + +namespace WMS.Web.Domain.Entitys +{ + /// + /// 对应金蝶的明细 + /// + [Serializable] + [Table("t_erp_outstock_erp_details")] + public class OutStockErpDetails : EntityBase + { + public OutStockErpDetails() { } + /// + /// 主键 订单编号 + /// + [Column("Id")] + public override int Id { get; set; } + /// + /// 任务单明细Id + /// + [Column("DetailId")] + public int DetailId { get; set; } + /// + /// 对应金蝶单据明细id(销售出库同步金蝶下推使用) + /// + [Column("Erp_DetailId")] + public int Erp_DetailId { get; set; } + /// + /// 来源单号 + /// + [Column("SourceBillNo")] + public string SourceBillNo { get; set; } + /// + /// 销售订单号 + /// + [Column("SaleBillNo")] + public string SaleBillNo { get; set; } + /// + /// 出库数量 + /// + [Column("Qty")] + public decimal Qty { get; set; } + } +} diff --git a/src/WMS.Web.Domain/Services/SerialNumberService.cs b/src/WMS.Web.Domain/Services/SerialNumberService.cs index 5b903615..3b2f6f5d 100644 --- a/src/WMS.Web.Domain/Services/SerialNumberService.cs +++ b/src/WMS.Web.Domain/Services/SerialNumberService.cs @@ -204,14 +204,14 @@ namespace WMS.Web.Domain.Services OperateTime = DateTime.Now, OperateType = OutStockTypeConvert(outStock.Type), OperateUser = userName, - Remark = "来源单号:" + string.Join(",", outstockDetail.SourceBillNos) + "\r\n" + "出库单号:" + outStock.BillNo + Remark = "来源单号:" + string.Join(",", outstockDetail.ErpDetails.Select(s=>s.SourceBillNo)) + "\r\n" + "出库单号:" + outStock.BillNo }; if (outStock.Type == OutStockType.Sal) { var detail = outStock.Details.FirstOrDefault(f => f.MaterialId == entity.MaterialId); var res_c = await _erpService.BillQueryForCustomer(); var customer = res_c.Data.FirstOrDefault(f => f.Id == outStock.ReceiptCustomerId); - op.Remark += "\r\n" + "销售订单号:" + string.Join(",", detail.SaleBillNos); + op.Remark += "\r\n" + "销售订单号:" + string.Join(",", detail.ErpDetails.Select(s => s.SaleBillNo)); op.Remark += "\r\n" + "客户:" + customer?.Name; } sList.Add(op); diff --git a/src/WMS.Web.Repositories/Configuration/RepositoryDbContext.cs b/src/WMS.Web.Repositories/Configuration/RepositoryDbContext.cs index ddd8e34f..d834d9d5 100644 --- a/src/WMS.Web.Repositories/Configuration/RepositoryDbContext.cs +++ b/src/WMS.Web.Repositories/Configuration/RepositoryDbContext.cs @@ -99,13 +99,16 @@ namespace WMS.Web.Repositories.Configuration v => JsonConvert.SerializeObject(v), v => JsonConvert.DeserializeObject>(v)); - ent.Property(f => f.SourceBillNos).HasConversion( - v => JsonConvert.SerializeObject(v), - v => JsonConvert.DeserializeObject>(v)); + ent.HasMany(p => p.ErpDetails) + .WithOne() + .HasForeignKey(p => p.DetailId) + .OnDelete(DeleteBehavior.Cascade); + }); - ent.Property(f => f.SaleBillNos).HasConversion( - v => JsonConvert.SerializeObject(v), - v => JsonConvert.DeserializeObject>(v)); + builder.Entity(ent => + { + ent.ToTable("t_erp_outstock_erp_details"); + ent.HasKey(x => x.Id); }); #endregion @@ -292,6 +295,7 @@ namespace WMS.Web.Repositories.Configuration public DbSet OutStockTask { get; set; } public DbSet TakeStock { get; set; } public DbSet OutStockDetails { get; set; } + public DbSet OutStockErpDetails { get; set; } public DbSet OutStockTaskDetails { get; set; } public DbSet OutStockTaskErpDetails { get; set; } public DbSet TakeStockDetails { get; set; } diff --git a/src/WMS.Web.Repositories/OutStockRepositories.cs b/src/WMS.Web.Repositories/OutStockRepositories.cs index a2ebf5d5..0f40f96f 100644 --- a/src/WMS.Web.Repositories/OutStockRepositories.cs +++ b/src/WMS.Web.Repositories/OutStockRepositories.cs @@ -118,7 +118,7 @@ namespace WMS.Web.Repositories #endregion - var query = _context.OutStockDetails + var query = _context.OutStockDetails.Include(x => x.ErpDetails) .GroupJoin(_context.OutStock, detail => detail.Fid, order => order.Id, (detail, orders) => new { detail, orders }) .SelectMany(x => x.orders.DefaultIfEmpty(), (p, order) => new { p.detail, order }) .OrderByDescending(o => o.order.Id) @@ -164,8 +164,8 @@ namespace WMS.Web.Repositories CreateTime = s.order.CreateTime.DateToStringSeconds(), SuccessSync = s.order.SuccessSync, Stock = _singleDataService.GetSingleData(SingleAction.Stocks, _loginRepositories.CompanyId, s.detail.StockCode), - SourceBillNo =string.Join(",",s.detail.SourceBillNos), - SaleBillNo = string.Join(",", s.detail.SaleBillNos), + SourceBillNo = string.Join(",", s.detail.ErpDetails.Select(s => s.SourceBillNo)), + SaleBillNo = string.Join(",", s.detail.ErpDetails.Select(s => s.SaleBillNo)), DeliveryOrg = _erpBasicDataExtendService.GetOrgName(orgs, s.order.DeliveryOrgId), ReceiptCustomer = s.order.Type == OutStockType.Sal ? _erpBasicDataExtendService.GetCustomerName(customers, s.order.ReceiptCustomerId) @@ -196,12 +196,12 @@ namespace WMS.Web.Repositories List list = entitys.Select(s => s.Id).ToList(); var res = await _context.OutStock - .Include(s => s.Details) + .Include(s => s.Details).ThenInclude(s => s.ErpDetails) .Where(f => list.Contains(f.Id)).ToListAsync(); _mapper.ToMapList(entitys, res); _mapper.ToMapList(entitys.SelectMany(s => s.Details).ToList(), res.SelectMany(s => s.Details).ToList()); - + _mapper.ToMapList(entitys.SelectMany(s => s.Details).SelectMany(s => s.ErpDetails).ToList(), res.SelectMany(s => s.Details).SelectMany(s => s.ErpDetails).ToList()); await _context.SaveChangesAsync(); if (_transaction != null) _transaction.Commit(); @@ -223,7 +223,7 @@ namespace WMS.Web.Repositories public async Task> GetEntityList(List ids) { var res = await _context.OutStock - .Include(s => s.Details) + .Include(s => s.Details).ThenInclude(s => s.ErpDetails) .Where(f => ids.Contains(f.Id)) .ToListAsync(); @@ -244,12 +244,13 @@ namespace WMS.Web.Repositories try { var res = await _context.OutStock - .Include(s => s.Details) + .Include(s => s.Details).ThenInclude(s => s.ErpDetails) .FirstOrDefaultAsync(f => f.Id == entity.Id); if (res == null) return null; _mapper.Map(entity, res); _mapper.ToMapList(entity.Details, res.Details); + _mapper.ToMapList(entity.Details.SelectMany(s => s.ErpDetails).ToList(), res.Details.SelectMany(s => s.ErpDetails).ToList()); await _context.SaveChangesAsync(); if (_transaction != null) @@ -272,7 +273,7 @@ namespace WMS.Web.Repositories public async Task GetByTaskId(int taskId) { var res = await _context.OutStock - .Include(s => s.Details) + .Include(s => s.Details).ThenInclude(s => s.ErpDetails) .FirstOrDefaultAsync(f => taskId == f.TaskId); return res.Clone(); diff --git a/src/WMS.Web.Repositories/OutStockTaskRepositories.cs b/src/WMS.Web.Repositories/OutStockTaskRepositories.cs index 2e699e5f..375031f7 100644 --- a/src/WMS.Web.Repositories/OutStockTaskRepositories.cs +++ b/src/WMS.Web.Repositories/OutStockTaskRepositories.cs @@ -125,12 +125,12 @@ namespace WMS.Web.Repositories List list = entitys.Select(s => s.Id).ToList(); var res = await _context.OutStockTask - .Include(s => s.Details) + .Include(s => s.Details).ThenInclude(s => s.ErpDetails) .Where(f => list.Contains(f.Id)).ToListAsync(); _mapper.ToMapList(entitys, res); _mapper.ToMapList(entitys.SelectMany(s => s.Details).ToList(), res.SelectMany(s => s.Details).ToList()); - + _mapper.ToMapList(entitys.SelectMany(s => s.Details).SelectMany(s => s.ErpDetails).ToList(), res.SelectMany(s => s.Details).SelectMany(s => s.ErpDetails).ToList()); await _context.SaveChangesAsync(); if (_transaction != null) _transaction.Commit();