16 changed files with 298 additions and 3 deletions
@ -0,0 +1,13 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Text; |
||||
|
using System.Threading.Tasks; |
||||
|
|
||||
|
namespace Win_in.Sfs.Wms.Store.Domain.Shared.SplitPackings; |
||||
|
public enum NodeTypeEnum |
||||
|
{ |
||||
|
ToBox = 1, |
||||
|
|
||||
|
FromBox = 2 |
||||
|
} |
@ -0,0 +1,19 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Text; |
||||
|
using System.Threading.Tasks; |
||||
|
|
||||
|
namespace Win_in.Sfs.Wms.Store.Domain.Shared.SplitPackings; |
||||
|
public enum OprTypeEnum |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// 拆箱
|
||||
|
/// </summary>
|
||||
|
SplitBox = 1, |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 合箱
|
||||
|
/// </summary>
|
||||
|
MergeBox = 2 |
||||
|
} |
@ -0,0 +1,13 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Text; |
||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp.Domain.Services; |
||||
|
using Win_in.Sfs.Wms.Store.Domain; |
||||
|
|
||||
|
namespace Win_in.Sfs.Wms.Store.SplitPackings; |
||||
|
public interface ISplitPackingRecManager : IDomainService |
||||
|
{ |
||||
|
Task<bool> DoSplitPacking(List<SplitPackingRec> input); |
||||
|
} |
@ -0,0 +1,9 @@ |
|||||
|
using Win_in.Sfs.Shared.Domain; |
||||
|
|
||||
|
namespace Win_in.Sfs.Wms.Store.Domain; |
||||
|
|
||||
|
public interface ISplitPackingRecRepository : ISfsStoreRepositoryBase<SplitPackingRec> |
||||
|
{ |
||||
|
} |
||||
|
|
||||
|
|
@ -0,0 +1,76 @@ |
|||||
|
using System; |
||||
|
using System.ComponentModel.DataAnnotations; |
||||
|
using System.ComponentModel.DataAnnotations.Schema; |
||||
|
using Win_in.Sfs.Shared.Domain; |
||||
|
using Win_in.Sfs.Shared.Domain.Shared; |
||||
|
using Win_in.Sfs.Wms.Store.Domain.Shared.SplitPackings; |
||||
|
|
||||
|
namespace Win_in.Sfs.Wms.Store.Domain; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 采购标签
|
||||
|
/// </summary>
|
||||
|
public class SplitPackingRec : SfsAggregateRootBase |
||||
|
, IHasItem |
||||
|
, IHasQty |
||||
|
, IHasStdPack |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// 操作类型
|
||||
|
/// </summary>
|
||||
|
public OprTypeEnum OprType { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
///
|
||||
|
/// </summary>
|
||||
|
public string GroupCode { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
///
|
||||
|
/// </summary>
|
||||
|
public long OprLevel { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
///
|
||||
|
/// </summary>
|
||||
|
public NodeTypeEnum NodeType { get; set; } |
||||
|
|
||||
|
public Guid? ParentId { get; set; } |
||||
|
|
||||
|
public string PackingCode { get; set; } |
||||
|
|
||||
|
public string RootPackingCode { get; set; } |
||||
|
|
||||
|
//public string FullBarcodeString { get; set; }
|
||||
|
|
||||
|
public string ItemCode { get; set; } |
||||
|
|
||||
|
public string ItemName { get; set; } |
||||
|
|
||||
|
public string ItemDesc1 { get; set; } |
||||
|
|
||||
|
public string ItemDesc2 { get; set; } |
||||
|
|
||||
|
public string Lot { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 标包数量
|
||||
|
/// </summary>
|
||||
|
[Display(Name = "标包数量")] |
||||
|
[Column(TypeName = "decimal(18,6)")] |
||||
|
public decimal StdPackQty { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 计量单位
|
||||
|
/// </summary>
|
||||
|
[Display(Name = "计量单位")] |
||||
|
[MaxLength(SfsPropertyConst.CodeLength)] |
||||
|
public string Uom { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 数量
|
||||
|
/// </summary>
|
||||
|
[Display(Name = "数量")] |
||||
|
[Column(TypeName = "decimal(18,6)")] |
||||
|
public decimal Qty { get; set; } |
||||
|
} |
@ -0,0 +1,53 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Text; |
||||
|
using System.Threading.Tasks; |
||||
|
using Microsoft.EntityFrameworkCore; |
||||
|
using Volo.Abp.Domain.Services; |
||||
|
using Win_in.Sfs.Wms.Store.Domain; |
||||
|
|
||||
|
namespace Win_in.Sfs.Wms.Store.SplitPackings; |
||||
|
public class SplitPackingRecManager : DomainService, ISplitPackingRecManager |
||||
|
{ |
||||
|
private readonly ISplitPackingRecRepository _repository; |
||||
|
|
||||
|
public SplitPackingRecManager(ISplitPackingRecRepository repository) |
||||
|
{ |
||||
|
_repository = repository; |
||||
|
} |
||||
|
|
||||
|
public async Task<bool> DoSplitPacking(List<SplitPackingRec> input) |
||||
|
{ |
||||
|
string groupCode = Guid.NewGuid().ToString(); |
||||
|
long maxOprLevel; |
||||
|
Guid? parentId; |
||||
|
string rootPackingCode; |
||||
|
SplitPackingRec fromRec = input.First(itm => itm.NodeType == Domain.Shared.SplitPackings.NodeTypeEnum.FromBox); |
||||
|
var query = await _repository.GetQueryableAsync().ConfigureAwait(false); |
||||
|
var hasData = await query.AnyAsync(itm => itm.PackingCode == fromRec.PackingCode).ConfigureAwait(false); |
||||
|
if (hasData) |
||||
|
{ |
||||
|
maxOprLevel = await query.Where(itm => itm.PackingCode == fromRec.PackingCode).MaxAsync(itm => itm.OprLevel).ConfigureAwait(false); |
||||
|
SplitPackingRec lastRec = await query.FirstAsync(itm => itm.PackingCode == fromRec.PackingCode && itm.OprLevel == maxOprLevel).ConfigureAwait(false); |
||||
|
parentId = lastRec.Id; |
||||
|
rootPackingCode = lastRec.RootPackingCode; |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
maxOprLevel = 1; |
||||
|
parentId = null; |
||||
|
rootPackingCode = fromRec.PackingCode; |
||||
|
} |
||||
|
|
||||
|
foreach (SplitPackingRec item in input) |
||||
|
{ |
||||
|
item.GroupCode = groupCode; |
||||
|
item.OprLevel = maxOprLevel + 1; |
||||
|
item.ParentId = parentId; |
||||
|
item.RootPackingCode = rootPackingCode; |
||||
|
} |
||||
|
await _repository.InsertManyAsync(input).ConfigureAwait(false); |
||||
|
return true; |
||||
|
} |
||||
|
} |
@ -0,0 +1,45 @@ |
|||||
|
using Microsoft.EntityFrameworkCore; |
||||
|
using Volo.Abp.EntityFrameworkCore.Modeling; |
||||
|
using Win_in.Sfs.Label.Domain; |
||||
|
using Win_in.Sfs.Shared.Domain.Shared; |
||||
|
using Win_in.Sfs.Shared.EntityFrameworkCore; |
||||
|
using Win_in.Sfs.Wms.Store.Domain; |
||||
|
|
||||
|
namespace Win_in.Sfs.Wms.Store.EntityFrameworkCore; |
||||
|
|
||||
|
public static class SplitPackingRecDbContextModelCreatingExtensions |
||||
|
{ |
||||
|
public static void ConfigureSplitPackingRec(this ModelBuilder builder, StoreModelBuilderConfigurationOptions options) |
||||
|
{ |
||||
|
builder.Entity<SplitPackingRec>(b => |
||||
|
{ |
||||
|
//Configure table & schema name
|
||||
|
b.ToTable(options.TablePrefix + nameof(SplitPackingRec), options.Schema); |
||||
|
//Configure ABP properties
|
||||
|
b.ConfigureByConvention(); |
||||
|
//Configure Sfs base properties
|
||||
|
b.ConfigureSfsBase(); |
||||
|
|
||||
|
//Properties
|
||||
|
b.Property(q => q.OprType).IsRequired(); |
||||
|
b.Property(q => q.GroupCode).IsRequired().HasMaxLength(36); |
||||
|
b.Property(q => q.OprLevel).IsRequired(); |
||||
|
b.Property(q => q.NodeType).IsRequired(); |
||||
|
//b.Property(q => q.ParentId)
|
||||
|
b.Property(q => q.PackingCode).IsRequired().HasMaxLength(SfsPropertyConst.CodeLength); |
||||
|
b.Property(q => q.RootPackingCode).IsRequired().HasMaxLength(SfsPropertyConst.CodeLength); |
||||
|
b.Property(q => q.ItemCode).IsRequired().HasMaxLength(SfsPropertyConst.CodeLength); |
||||
|
b.Property(q => q.ItemName).IsRequired().HasMaxLength(SfsPropertyConst.NameLength); |
||||
|
b.Property(q => q.ItemDesc1).IsRequired().HasMaxLength(SfsPropertyConst.DescLength); |
||||
|
b.Property(q => q.ItemDesc2).IsRequired().HasMaxLength(SfsPropertyConst.DescLength); |
||||
|
b.Property(q => q.Lot).IsRequired().HasMaxLength(SfsPropertyConst.CodeLength); |
||||
|
b.Property(q => q.StdPackQty).HasPrecision(18, 4); |
||||
|
b.Property(q => q.Uom).HasMaxLength(50); |
||||
|
b.Property(q => q.Qty).IsRequired().HasPrecision(18,4); |
||||
|
//Indexes
|
||||
|
b.HasIndex(q => new { PackingCode = q.PackingCode }); |
||||
|
b.HasIndex(q => new { PackingCode = q.PackingCode, OprLevel = q.OprLevel }); |
||||
|
|
||||
|
}); |
||||
|
} |
||||
|
} |
@ -0,0 +1,12 @@ |
|||||
|
using Volo.Abp.EntityFrameworkCore; |
||||
|
using Win_in.Sfs.Label.Domain; |
||||
|
using Win_in.Sfs.Wms.Store.Domain; |
||||
|
|
||||
|
namespace Win_in.Sfs.Wms.Store.EntityFrameworkCore; |
||||
|
|
||||
|
public class SplitPackingRecEfCoreRepository : SfsStoreEfCoreRepositoryBase<StoreDbContext, SplitPackingRec>, ISplitPackingRecRepository |
||||
|
{ |
||||
|
public SplitPackingRecEfCoreRepository(IDbContextProvider<StoreDbContext> dbContextProvider) : base(dbContextProvider) |
||||
|
{ |
||||
|
} |
||||
|
} |
Binary file not shown.
Loading…
Reference in new issue