Browse Source

更新BOM

dev_DY_CC
赵新宇 1 year ago
parent
commit
891f01cf87
  1. 6
      be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/Boms/BomAppService.cs
  2. 73
      be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain.Shared/Commons/Cache.cs
  3. 2
      be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/Boms/Bom.cs
  4. 91
      be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/Boms/BomManager.cs
  5. 13
      be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/Caches/Cache.cs
  6. 4
      be/Modules/Shared/src/Win_in.Sfs.Shared.Domain.Shared/Enums/Inventory/EnumTransType.cs
  7. 17
      be/Modules/Shared/src/Win_in.Sfs.Shared.Domain.Shared/Enums/Store/Statuses/EnumRequestStatus.cs
  8. 20
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/CustomerProductionReturnNotes/CustomerProductionReturnNotePermissions.cs
  9. 29
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/CustomerProductionReturnNotes/DTOs/CustomerProductionReturnNoteDTO.cs
  10. 9
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/CustomerProductionReturnNotes/DTOs/CustomerProductionReturnNoteDetailDTO.cs
  11. 9
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/CustomerProductionReturnNotes/ICustomerProductionReturnNoteAppService.cs
  12. 9
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/CustomerProductionReturnNotes/Inputs/CustomerProductionReturnNoteDetailInput.cs
  13. 47
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/CustomerProductionReturnNotes/Inputs/CustomerProductionReturnNoteEditInput.cs
  14. 34
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/CustomerProductionReturnNotes/Inputs/CustomerProductionReturnNoteImportInput.cs
  15. 47
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/CustomerProductionReturnNotes/CustomerProductionReturnNoteAppService.cs
  16. 34
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/CustomerProductionReturnNotes/CustomerProductionReturnNoteAutoMapperProfile.cs
  17. 1
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/StoreApplicationAutoMapperProfile.cs
  18. 33
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Notes/CustomerProductionReturnNotes/CustomerProductionReturnNote.cs
  19. 8
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Notes/CustomerProductionReturnNotes/CustomerProductionReturnNoteDetail.cs
  20. 12
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Notes/CustomerProductionReturnNotes/CustomerProductionReturnNoteManager.cs
  21. 5
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Notes/CustomerProductionReturnNotes/ICustomerProductionReturnNoteManager.cs
  22. 5
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Notes/CustomerProductionReturnNotes/ICustomerProductionReturnNoteRepository.cs
  23. 49
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.EntityFrameworkCore/Notes/CustomerProductionReturnNotes/CustomerProductionReturnNoteDbContextModelCreatingExtensions.cs
  24. 13
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.EntityFrameworkCore/Notes/CustomerProductionReturnNotes/CustomerProductionReturnNoteEfCoreRepository.cs
  25. 1
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.EntityFrameworkCore/StoreDbContextModelCreatingExtensions.cs
  26. 7
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.EntityFrameworkCore/StoreEntityFrameworkCoreModule.cs
  27. 23
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/AutoMapperProfiles/Notes/CustomerProductionReturnNoteAutoMapperProfile.cs
  28. 1
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/StoreEventAutoMapperProfile.cs
  29. 94
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Transactions/CustomerProductionReturnNoteEventHandler.cs

6
be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/Boms/BomAppService.cs

@ -25,6 +25,8 @@ public class BomAppService :
private new readonly IBomRepository _repository;
private readonly IBomManager _bomManager;
List<BomComponent> _bomList=new List<BomComponent>();
public BomAppService(IBomRepository repository
, IBomManager bomManager
, IDistributedCache<BomDTO> cache
@ -35,8 +37,12 @@ public class BomAppService :
base.CreatePolicyName = BomPermissions.Create;
base.UpdatePolicyName = BomPermissions.Update;
base.DeletePolicyName = BomPermissions.Delete;
}

73
be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain.Shared/Commons/Cache.cs

@ -0,0 +1,73 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections.Generic;
namespace Win_in.Sfs.Basedata.Domain.Shared;
public class SingletonCacheList<T>
{
private static volatile SingletonCacheList<T> instance;
private static object syncRoot = new object();
private List<T> cacheList;
private SingletonCacheList()
{
cacheList = new List<T>();
}
public static SingletonCacheList<T> Instance
{
get
{
if (instance == null)
{
lock (syncRoot)
{
if (instance == null)
{
instance = new SingletonCacheList<T>();
}
}
}
return instance;
}
}
public void Add(T item)
{
cacheList.Add(item);
}
public void Remove(T item)
{
cacheList.Remove(item);
}
public bool Contains(T item)
{
return cacheList.Contains(item);
}
public T this[int index]
{
get
{
return cacheList[index];
}
set
{
cacheList[index] = value;
}
}
public int Count()
{
return cacheList.Count();
}
}

2
be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/Boms/Bom.cs

@ -83,3 +83,5 @@ public class Bom : SfsBaseDataAggregateRootBase, IHasTimeRange
/// </summary>
public EnumPlannedSplitRule PlannedSplitRule { get; set; }
}

91
be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/Boms/BomManager.cs

@ -10,6 +10,7 @@ using Volo.Abp;
using Volo.Abp.Domain.Repositories;
using Volo.Abp.Domain.Services;
using Win_in.Sfs.Basedata.Boms;
using Win_in.Sfs.Basedata.Caches;
using Win_in.Sfs.Basedata.Domain.Shared;
using Win_in.Sfs.Shared.Domain;
using Win_in.Sfs.Shared.Domain.Shared;
@ -20,11 +21,20 @@ public class BomManager : DomainService, IBomManager
{
private readonly IBomRepository _repository;
private readonly IItemBasicRepository _itemBasicRepository;
public BomManager(IBomRepository repository, IItemBasicRepository itemBasicRepository)
{
_repository = repository;
_itemBasicRepository = itemBasicRepository;
InitBomComponent();
}
private void InitBomComponent()
{
int count = _repository.CountAsync().Result;
if (Cache.Boms.Count!=count)
{
Cache.Boms=_repository.ToListAsync().Result;
}
}
/// <summary>
@ -74,7 +84,6 @@ public class BomManager : DomainService, IBomManager
}
}
return totalBoms;
}
@ -255,27 +264,7 @@ public class BomManager : DomainService, IBomManager
dimensionList.Add(rs1);
}).ConfigureAwait(false);
//List<Bom> lastBomList = new List<Bom>();
//List<Bom> dimensionBomList = new List<Bom>();
//List<Bom> treeBomList = new List<Bom>();
//foreach (var itm in dimensionList)
//{
// Bom bom = new Bom();
// bom.InjectFrom(itm);
// dimensionBomList.Add(bom);
//}
//foreach (var itm in lastList)
//{
// Bom bom = new Bom();
// bom.InjectFrom(itm);
// lastBomList.Add(bom);
//}
//foreach (var itm in treeList)
//{
// Bom bom = new Bom();
// bom.InjectFrom(itm);
// treeBomList.Add(bom);
//}
List<BomComponent> returnList=new List<BomComponent>();
switch (p_type)
{
@ -291,31 +280,7 @@ public class BomManager : DomainService, IBomManager
}
return returnList;
}
//private static List<BomComponent> BomComponents = new List<BomComponent>();
//private static List<BomComponent> GetBomComponents()
//{
// if(BomComponents.Any() && )
// var lst = await _repository.GetListAsync(p => p.Product == productCode).ConfigureAwait(false);
//}
/// <summary>
/// 层级、拆解、一维结构、树状结构
/// </summary>
/// <param name="p_component">上级组件(初始时为根元素)</param>
/// <param name="level">层级一般为1</param>
/// <param name="sumQty">累计数量</param>
/// <param name="root">根</param>
/// <param name="p_actionLast">拆解到最终零件时</param>
/// <param name="p_actionDimension">树型转成一维表用</param>
/// <returns></returns>
/// <summary>
@ -336,17 +301,6 @@ public class BomManager : DomainService, IBomManager
{
List<BomComponent> subComponents = new List<BomComponent>();
// 假设 GetComponentsByProduct 方法可获取某个物料号下的所有子零件
//if (bomList != null && bomList.Count() > 0)
//{
// = bomList.Where(p => p.Product == p_component.Component)
//}
//else
//{
// directSubComponents = await GetComponentsByProduct(p_component.Component).ConfigureAwait(false);
//}
List<BomComponent> directSubComponents =await GetComponentsByProduct(p_component.Component).ConfigureAwait(false);
if (!directSubComponents.Any() && level != 1)//不是根元素
@ -367,22 +321,11 @@ public class BomManager : DomainService, IBomManager
return subComponents;
}
private async Task<List<BomComponent>> GetComponentsByProduct(string product)
{
var list= await _repository.GetListAsync(p => p.Product == product).ConfigureAwait(false);
List<Bom> list=new List<Bom>();
list=Cache.Boms.Count > 0 ? Cache.Boms.Where(p => p.Product == product).ToList() :
await _repository.GetListAsync(p => p.Product == product).ConfigureAwait(false);
List<BomComponent> components = new List<BomComponent>();
foreach (var component in list)
{
@ -390,8 +333,6 @@ public class BomManager : DomainService, IBomManager
bomComponent.InjectFrom(component);
components.Add(bomComponent);
}
// 其他物料号的子零件信息类似添加
return components;
}

13
be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/Caches/Cache.cs

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Win_in.Sfs.Basedata.Domain;
namespace Win_in.Sfs.Basedata.Caches;
public static class Cache
{
public static List<Bom> Boms = new List<Bom>();
}

4
be/Modules/Shared/src/Win_in.Sfs.Shared.Domain.Shared/Enums/Inventory/EnumTransType.cs

@ -157,4 +157,8 @@ public enum EnumTransType
/// </summary>
[Display(Name = "初始化")]
Initial = 99,
}

17
be/Modules/Shared/src/Win_in.Sfs.Shared.Domain.Shared/Enums/Store/Statuses/EnumRequestStatus.cs

@ -63,4 +63,21 @@ public enum EnumRequestStatus
/// </summary>
[Display(Name = "部分完成")]
Partial = 9,
/// <summary>
/// 部分完成
/// </summary>
[Display(Name = "已过时")]
Deprecated = 10,
/// <summary>
/// 有更新
/// </summary>
[Display(Name = "有更新")]
Updated = 10,
}

20
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/CustomerProductionReturnNotes/CustomerProductionReturnNotePermissions.cs

@ -0,0 +1,20 @@
using Volo.Abp.Authorization.Permissions;
using Win_in.Sfs.Wms.Store.Domain;
namespace Win_in.Sfs.Wms.Store.Application.Contracts;
public static class CustomerProductionReturnNotePermissions
{
public const string Default = StorePermissions.GroupName + "." + nameof(CustomerProductionReturnNote);
public const string Create = Default + "." + StorePermissions.CreateStr;
public const string Update = Default + "." + StorePermissions.UpdateStr;
public const string Delete = Default + "." + StorePermissions.DeleteStr;
public static void AddCustomerProductionReturnNotePermission(this PermissionGroupDefinition permissionGroup)
{
var CustomerProductionReturnNotePermission = permissionGroup.AddPermission(Default, StorePermissionDefinitionProvider.L(nameof(CustomerProductionReturnNote)));
CustomerProductionReturnNotePermission.AddChild(Create, StorePermissionDefinitionProvider.L(StorePermissions.CreateStr));
CustomerProductionReturnNotePermission.AddChild(Update, StorePermissionDefinitionProvider.L(StorePermissions.UpdateStr));
CustomerProductionReturnNotePermission.AddChild(Delete, StorePermissionDefinitionProvider.L(StorePermissions.DeleteStr));
}
}

29
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/CustomerProductionReturnNotes/DTOs/CustomerProductionReturnNoteDTO.cs

@ -0,0 +1,29 @@
using System;
using System.ComponentModel.DataAnnotations;
namespace Win_in.Sfs.Wms.Store.Application.Contracts;
/// <summary>
/// 退库记录-实体DTO
/// </summary>
[Display(Name = "退库记录")]
public class CustomerProductionReturnNoteDTO : SfsStoreDTOBase<CustomerProductionReturnNoteDetailDTO>
{
/// <summary>
/// 任务ID
/// </summary>
[Display(Name = "任务ID")]
public string JobNumber { get; set; }
/// <summary>
/// 退料单号
/// </summary>
[Display(Name = "退料单号")]
public string ProductionReturnRequestNumber { get; set; }
/// <summary>
/// 退料时间
/// </summary>
[Display(Name = "退料时间")]
public DateTime ReturnTime { get; set; }
}

9
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/CustomerProductionReturnNotes/DTOs/CustomerProductionReturnNoteDetailDTO.cs

@ -0,0 +1,9 @@
namespace Win_in.Sfs.Wms.Store.Application.Contracts;
/// <summary>
/// 退库记录-明细表-实体DTO
/// </summary>
public class CustomerProductionReturnNoteDetailDTO : SfsStoreRecommendToDetailWithFromToDTOBase
{
}

9
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/CustomerProductionReturnNotes/ICustomerProductionReturnNoteAppService.cs

@ -0,0 +1,9 @@
using System.Threading.Tasks;
namespace Win_in.Sfs.Wms.Store.Application.Contracts;
public interface ICustomerProductionReturnNoteAppService :
ISfsStoreMasterReadOnlyAppServiceBase<CustomerProductionReturnNoteDTO, SfsStoreRequestInputBase, CustomerProductionReturnNoteDetailDTO, SfsStoreRequestInputBase>
{
Task<CustomerProductionReturnNoteDTO> CreateAsync(CustomerProductionReturnNoteEditInput input);
}

9
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/CustomerProductionReturnNotes/Inputs/CustomerProductionReturnNoteDetailInput.cs

@ -0,0 +1,9 @@
namespace Win_in.Sfs.Wms.Store.Application.Contracts;
/// <summary>
/// 退库记录-明细表-实体DTO
/// </summary>
public class CustomerProductionReturnNoteDetailInput : SfsStoreRecommendToDetailWithFromToDTOBase
{
}

47
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/CustomerProductionReturnNotes/Inputs/CustomerProductionReturnNoteEditInput.cs

@ -0,0 +1,47 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using Win_in.Sfs.Shared.Domain;
namespace Win_in.Sfs.Wms.Store.Application.Contracts;
/// <summary>
/// 退库记录-新增和更新基础DTO
/// </summary>
public class CustomerProductionReturnNoteEditInput : SfsStoreCreateOrUpdateInputBase
{
#region Base
/// <summary>
/// 任务ID
/// </summary>
[Display(Name = "任务ID")]
public string JobNumber { get; set; }
/// <summary>
/// 退料时间
/// </summary>
[Display(Name = "退料时间")]
public DateTime ReturnTime { get; set; }
/// <summary>
/// 退料申请单号
/// </summary>
[Display(Name = "退料申请单号")]
public string ProductionReturnRequestNumber { get; set; }
#endregion
#region Create
/// <summary>
/// 退库记录单号
/// </summary>
[Display(Name = "退库记录单号")]
[StringLength(SfsEfCorePropertyConst.CodeLength, ErrorMessage = "{0}最多输入{1}个字符")]
public string Number { get; set; }
/// <summary>
/// 明细列表
/// </summary>
[Display(Name = "明细列表")]
public List<CustomerProductionReturnNoteDetailInput> Details { get; set; }
#endregion
}

34
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/CustomerProductionReturnNotes/Inputs/CustomerProductionReturnNoteImportInput.cs

@ -0,0 +1,34 @@
using System;
using System.ComponentModel.DataAnnotations;
namespace Win_in.Sfs.Wms.Store.Application.Contracts;
/// <summary>
/// 退库记录-实体DTO
/// </summary>
public class CustomerProductionReturnNoteImportInput : SfsStoreImportInputBase
{
/// <summary>
/// 任务ID
/// </summary>
[Display(Name = "任务ID")]
public string JobNumber { get; set; }
/// <summary>
/// 退料时间
/// </summary>
[Display(Name = "退料时间")]
public DateTime ReturnTime { get; set; }
/// <summary>
/// 退料单号
/// </summary>
[Display(Name = "退料单号")]
public string ProductionReturnRequestNumber { get; set; }
/// <summary>
/// 采购订单号
/// </summary>
[Display(Name = "采购订单号")]
public string PoNumber { get; set; }
}

47
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/CustomerProductionReturnNotes/CustomerProductionReturnNoteAppService.cs

@ -0,0 +1,47 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Win_in.Sfs.Wms.Store.Application.Contracts;
using Win_in.Sfs.Wms.Store.Domain;
using Win_in.Sfs.Wms.Store.Domain.Shared;
namespace Win_in.Sfs.Wms.Store.Application;
/// <summary>
/// 退库记录
/// </summary>
[Authorize]
[Route($"{StoreConsts.RootPath}customer-production-return-note")]
public class CustomerProductionReturnNoteAppService :
SfsStoreWithDetailsAppServiceBase<CustomerProductionReturnNote, CustomerProductionReturnNoteDTO, SfsStoreRequestInputBase, CustomerProductionReturnNoteEditInput,
CustomerProductionReturnNoteDetail, CustomerProductionReturnNoteDetailDTO, SfsStoreRequestInputBase, CustomerProductionReturnNoteImportInput>,
ICustomerProductionReturnNoteAppService
{
private readonly ICustomerProductionReturnNoteManager _CustomerProductionReturnNoteManager;
public CustomerProductionReturnNoteAppService(
ICustomerProductionReturnNoteRepository repository
, ICustomerProductionReturnNoteManager CustomerProductionReturnNoteManager
) : base(repository)
{
_CustomerProductionReturnNoteManager = CustomerProductionReturnNoteManager;
}
/// <summary>
/// 新增实体
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("")]
//[Authorize(CustomerProductionReturnNotePermissions.Create)]
public override async Task<CustomerProductionReturnNoteDTO> CreateAsync(CustomerProductionReturnNoteEditInput input)
{
var entity = ObjectMapper.Map<CustomerProductionReturnNoteEditInput, CustomerProductionReturnNote>(input);
await _CustomerProductionReturnNoteManager.CreateAsync(entity).ConfigureAwait(false);
var dto = ObjectMapper.Map<CustomerProductionReturnNote, CustomerProductionReturnNoteDTO>(entity);
return dto;
}
}

34
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/CustomerProductionReturnNotes/CustomerProductionReturnNoteAutoMapperProfile.cs

@ -0,0 +1,34 @@
using AutoMapper;
using Volo.Abp.AutoMapper;
using Win_in.Sfs.Wms.Store.Application.Contracts;
using Win_in.Sfs.Wms.Store.Domain;
namespace Win_in.Sfs.Wms.Store.Application;
public partial class StoreApplicationAutoMapperProfile : Profile
{
private void CustomerProductionReturnNoteAutoMapperProfile()
{
CreateMap<CustomerProductionReturnNote, CustomerProductionReturnNoteDTO>()
.ReverseMap();
CreateMap<CustomerProductionReturnNoteDetail, CustomerProductionReturnNoteDetailDTO>();
CreateMap<CustomerProductionReturnNoteEditInput, CustomerProductionReturnNote>();
CreateMap<CustomerProductionReturnNoteDetailInput, CustomerProductionReturnNoteDetail>()
.IgnoreAuditedObjectProperties()
.Ignore(x => x.MasterID)
.Ignore(x => x.TenantId)
.Ignore(x => x.Number)
.Ignore(x => x.Id);
CreateMap<CustomerProductionReturnNoteEditInput, CustomerProductionReturnNote>()
.IgnoreAuditedObjectProperties()
.Ignore(x => x.TenantId)
.Ignore(x => x.Number)
.Ignore(x => x.Id)
.Ignore(x=>x.Remark)
.Ignore(x=>x.ExtraProperties)
;
}
}

1
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/StoreApplicationAutoMapperProfile.cs

@ -96,6 +96,7 @@ public partial class StoreApplicationAutoMapperProfile : Profile
MesNoteAutoMapperProfile();
MesRecordAutoMapperProfile();
InjectioModelPlanAutoMapperProfile();
CustomerProductionReturnNoteAutoMapperProfile();
#endregion

33
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Notes/CustomerProductionReturnNotes/CustomerProductionReturnNote.cs

@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using Win_in.Sfs.Shared.Domain.Entities;
namespace Win_in.Sfs.Wms.Store.Domain;
/// <summary>
/// 退库记录
/// </summary>
public class CustomerProductionReturnNote : SfsStoreAggregateRootBase<CustomerProductionReturnNoteDetail>, IHasJobNumber
{
/// <summary>
/// 任务ID
/// </summary>
[IgnoreUpdate]
public string JobNumber { get; set; }
/// <summary>
/// 退料单号
/// </summary>
public string ProductionReturnRequestNumber { get; set; }
/// <summary>
/// 退料时间
/// </summary>
public DateTime ReturnTime { get; set; }
/// <summary>
/// 明细列表
/// </summary>
[IgnoreUpdate]
public override List<CustomerProductionReturnNoteDetail> Details { get; set; } = new List<CustomerProductionReturnNoteDetail>();
}

8
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Notes/CustomerProductionReturnNotes/CustomerProductionReturnNoteDetail.cs

@ -0,0 +1,8 @@
namespace Win_in.Sfs.Wms.Store.Domain;
/// <summary>
/// 退库记录-明细表
/// </summary>
public class CustomerProductionReturnNoteDetail : SfsStoreRecommendToDetailWithFromToEntityBase
{
}

12
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Notes/CustomerProductionReturnNotes/CustomerProductionReturnNoteManager.cs

@ -0,0 +1,12 @@
namespace Win_in.Sfs.Wms.Store.Domain;
public class CustomerProductionReturnNoteManager : SfsStoreManagerBase<CustomerProductionReturnNote, CustomerProductionReturnNoteDetail>,
ICustomerProductionReturnNoteManager
{
public CustomerProductionReturnNoteManager(
ICustomerProductionReturnNoteRepository repository
) : base(repository)
{
}
}

5
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Notes/CustomerProductionReturnNotes/ICustomerProductionReturnNoteManager.cs

@ -0,0 +1,5 @@
namespace Win_in.Sfs.Wms.Store.Domain;
public interface ICustomerProductionReturnNoteManager : ISfsStoreManager<CustomerProductionReturnNote, CustomerProductionReturnNoteDetail>
{
}

5
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Notes/CustomerProductionReturnNotes/ICustomerProductionReturnNoteRepository.cs

@ -0,0 +1,5 @@
namespace Win_in.Sfs.Wms.Store.Domain;
public interface ICustomerProductionReturnNoteRepository : ISfsStoreRepositoryBase<CustomerProductionReturnNote>
{
}

49
be/Modules/Store/src/Win_in.Sfs.Wms.Store.EntityFrameworkCore/Notes/CustomerProductionReturnNotes/CustomerProductionReturnNoteDbContextModelCreatingExtensions.cs

@ -0,0 +1,49 @@
using Microsoft.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore.Modeling;
using Win_in.Sfs.Shared.Domain.Shared;
using Win_in.Sfs.Wms.Store.Domain;
namespace Win_in.Sfs.Wms.Store.EntityFrameworkCore;
public static class CustomerProductionReturnNoteDbContextModelCreatingExtensions
{
public static void ConfigureCustomerProductionReturnNote(this ModelBuilder builder, StoreModelBuilderConfigurationOptions options)
{
builder.Entity<CustomerProductionReturnNote>(b =>
{
//Configure table & schema name
b.ToTable(options.TablePrefix + nameof(CustomerProductionReturnNote), options.Schema);
//Configure ABP properties
b.ConfigureByConvention();
//Configure Sfs base properties
b.ConfigureSfsStoreBase();
//Properties
b.Property(q => q.JobNumber).HasMaxLength(SfsPropertyConst.CodeLength);
b.Property(q => q.ProductionReturnRequestNumber).HasMaxLength(SfsPropertyConst.CodeLength);
//Relations
b.HasMany(q => q.Details).WithOne().HasForeignKey(d => d.MasterID).IsRequired();
//Indexes
b.HasIndex(q => new { q.Number }).IsUnique();
});
builder.Entity<CustomerProductionReturnNoteDetail>(b =>
{
//Configure table & schema name
b.ToTable(options.TablePrefix + nameof(CustomerProductionReturnNoteDetail), options.Schema);
//Configure ABP properties
b.ConfigureByConvention();
//Configure Sfs base properties
b.ConfigureSfsStoreBase();
//Configure Sfs store detail properties
b.ConfigureSfsStoreDetailBase();
//Properties
b.Property(q => q.FromStatus).HasMaxLength(SfsPropertyConst.NameLength).HasConversion<string>();
b.Property(q => q.ToStatus).HasMaxLength(SfsPropertyConst.NameLength).HasConversion<string>();
//Relations
//Indexes
b.HasIndex(q => new { q.Number, q.ItemCode, q.FromPackingCode, q.ToPackingCode, q.FromLocationCode, q.ToLocationCode }).IsUnique();
});
}
}

13
be/Modules/Store/src/Win_in.Sfs.Wms.Store.EntityFrameworkCore/Notes/CustomerProductionReturnNotes/CustomerProductionReturnNoteEfCoreRepository.cs

@ -0,0 +1,13 @@
using Volo.Abp.EntityFrameworkCore;
using Win_in.Sfs.Wms.Store.Domain;
namespace Win_in.Sfs.Wms.Store.EntityFrameworkCore;
public class CustomerProductionReturnNoteEfCoreRepository : SfsStoreEfCoreRepositoryBase<StoreDbContext, CustomerProductionReturnNote>, ICustomerProductionReturnNoteRepository
{
public CustomerProductionReturnNoteEfCoreRepository(IDbContextProvider<StoreDbContext> dbContextProvider) : base(dbContextProvider)
{
}
}

1
be/Modules/Store/src/Win_in.Sfs.Wms.Store.EntityFrameworkCore/StoreDbContextModelCreatingExtensions.cs

@ -108,6 +108,7 @@ public static class StoreDbContextModelCreatingExtensions
builder.ConfigureMesNote(options);
builder.ConfigureMesRecord(options);
builder.ConfigureInjectioModelPlan(options);
builder.ConfigureCustomerProductionReturnNote(options);
#endregion
#region Jobs

7
be/Modules/Store/src/Win_in.Sfs.Wms.Store.EntityFrameworkCore/StoreEntityFrameworkCoreModule.cs

@ -124,10 +124,11 @@ public class StoreEntityFrameworkCoreModule : AbpModule
context.Services.AddTransient<INoOkConvertOkNoteRepository, NoOkConvertOkNoteEfCoreRepository>();
context.Services.AddTransient<IWipWarehouseAdjustNoteRepository, WipWarehouseAdjustNoteEfCoreRepository>();
context.Services.AddTransient<ICoatingIssueNoteRepository, CoatingIssueNoteEfCoreRepository>();
context.Services.AddTransient<ICustomerProductionReturnNoteRepository, CustomerProductionReturnNoteEfCoreRepository>();
context.Services.AddTransient<IMesNoteRepository, MesNoteEfCoreRepository>();
context.Services.AddTransient<IMesRecordRepository, MesRecordEfCoreRepository>();
#endregion
#region Jobs
@ -329,6 +330,8 @@ public class StoreEntityFrameworkCoreModule : AbpModule
options.Entity<MesRecord>(orderOptions =>
orderOptions.DefaultWithDetailsFunc = query => query.Include(o => o.Details));
options.Entity<CustomerProductionReturnNote>(orderOptions =>
orderOptions.DefaultWithDetailsFunc = query => query.Include(o => o.Details));
#endregion
#region Jobs

23
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/AutoMapperProfiles/Notes/CustomerProductionReturnNoteAutoMapperProfile.cs

@ -0,0 +1,23 @@
using AutoMapper;
using Volo.Abp.AutoMapper;
using Win_in.Sfs.Wms.Inventory.Application.Contracts;
using Win_in.Sfs.Wms.Store.Domain;
namespace Win_in.Sfs.Wms.Store.Event;
public partial class StoreEventAutoMapperProfile : Profile
{
private void CustomerProductionReturnNoteAutoMapperProfile()
{
CreateMap<CustomerProductionReturnNoteDetail, TransferLogEditInput>()
.ForMember(x => x.DocNumber, y => y.MapFrom(t => t.Number))
.Ignore(x => x.JobNumber)
.Ignore(x => x.Worker)
.Ignore(x => x.TransType)
.Ignore(x => x.ExtraProperties)
.Ignore(x => x.TransSubType)
;
}
}

1
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/StoreEventAutoMapperProfile.cs

@ -88,6 +88,7 @@ public partial class StoreEventAutoMapperProfile : Profile
PutawayNoteAutoMapperProfile();
RecycledMaterialReceiptNoteAutoMapperProfile();
ScrapNoteAutoMapperProfile();
CustomerProductionReturnNoteAutoMapperProfile() ;
UnplannedIssueNoteAutoMapperProfile();
UnplannedIssueRequestAutoMapperProfile();

94
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Transactions/CustomerProductionReturnNoteEventHandler.cs

@ -0,0 +1,94 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Volo.Abp.EventBus;
using Volo.Abp.Uow;
using Win_in.Sfs.Shared.Domain.Shared;
using Win_in.Sfs.Shared.Event;
using Win_in.Sfs.Wms.Inventory.Application.Contracts;
using Win_in.Sfs.Wms.Store.Application.Contracts;
using Win_in.Sfs.Wms.Store.Domain;
using Win_in.Sfs.Wms.Store.Event.Transaction;
namespace Win_in.Sfs.Wms.Store.Event.Transactions;
public class CustomerProductionReturnNoteEventHandler
: StoreInventoryEventHandlerBase
, ILocalEventHandler<SfsCreatedEntityEventData<CustomerProductionReturnNote>>
, ILocalEventHandler<SfsCreatedEntityEventData<List<CustomerProductionReturnNote>>>
{
private const EnumTransType TransType = EnumTransType.CustomerReturn;
private readonly IProductionReturnRequestAppService _productionReturnRequestApp;
public CustomerProductionReturnNoteEventHandler(IProductionReturnRequestAppService productionReturnRequestApp)
{
this._productionReturnRequestApp = productionReturnRequestApp;
}
[UnitOfWork]
public virtual async Task HandleEventAsync(SfsCreatedEntityEventData<CustomerProductionReturnNote> eventData)
{
var entity = eventData.Entity;
await AddTransactionsAsync(entity).ConfigureAwait(false);
if (!string.IsNullOrEmpty(entity.ProductionReturnRequestNumber))
{
await _productionReturnRequestApp.CompleteByNumberAsync(entity.ProductionReturnRequestNumber).ConfigureAwait(false);
}
}
private async Task AddTransactionsAsync(CustomerProductionReturnNote CustomerProductionReturnNote)
{
var inboundTransactions = new List<TransferLogEditInput>();
inboundTransactions.AddRange(BuildTransferLogs(CustomerProductionReturnNote));
await TransferLogAppService.AddManyAsync(inboundTransactions).ConfigureAwait(false);
}
[UnitOfWork]
public virtual async Task HandleEventAsync(SfsCreatedEntityEventData<List<CustomerProductionReturnNote>> eventData)
{
var entities = eventData.Entity;
await AddTransactionsAsync(entities).ConfigureAwait(false);
}
private async Task AddTransactionsAsync(List<CustomerProductionReturnNote> CustomerProductionReturnNotes)
{
var inboundTransactions = new List<TransferLogEditInput>();
//如果要做库存事务汇总,可以修改此处
foreach (var CustomerProductionReturnNote in CustomerProductionReturnNotes)
{
inboundTransactions.AddRange(BuildTransferLogs(CustomerProductionReturnNote));
}
await TransferLogAppService.AddManyAsync(inboundTransactions).ConfigureAwait(false);
}
private List<TransferLogEditInput> BuildTransferLogs(CustomerProductionReturnNote CustomerProductionReturnNote)
{
var transferLogs = new List<TransferLogEditInput>();
foreach (var detail in CustomerProductionReturnNote.Details.Where(detail => detail.Qty != 0))
{
var transferLog = ObjectMapper.Map<CustomerProductionReturnNoteDetail, TransferLogEditInput>(detail);
transferLog.TransType = TransType;
transferLog.Worker = CustomerProductionReturnNote.Worker;
transferLog.DocNumber = CustomerProductionReturnNote.Number;
transferLog.JobNumber = CustomerProductionReturnNote.JobNumber;
transferLogs.Add(transferLog);
}
return transferLogs;
}
}
Loading…
Cancel
Save