Browse Source

修改采购收货

集成Redis
郑勃旭 2 years ago
parent
commit
7784490b5d
  1. 2
      be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/WorkCenters/WorkCenter.cs
  2. 2
      be/Modules/Label/src/Win_in.Sfs.Label.Application.Contracts/InventoryLabels/InventoryLabelEditInput.cs
  3. 15
      be/Modules/Label/src/Win_in.Sfs.Label.Application/InventoryLabels/InventoryLabelAppService.cs
  4. 10
      be/Modules/Label/src/Win_in.Sfs.Label.Application/InventoryLabels/InventoryLabelAutoMapperProfile.cs
  5. 21
      be/Modules/Shared/src/Win_in.Sfs.Shared.Application/SfsCrudWithDetailsAppServiceBase.cs
  6. 2
      be/Modules/Shared/src/Win_in.Sfs.Shared.Domain/Interfaces/IHasLocationSwitch.cs
  7. 7
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Plans/SupplierAsns/ISupplierAsnAppService.cs
  8. 4
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Orders/PurchaseOrders/PurchaseOrderAppService.cs
  9. 3
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Orders/PurchaseOrders/PurchaseOrderAutoMapperProfile.cs
  10. 12
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Plans/SupplierAsns/SupplierAsnAppService.cs
  11. 4
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Bases/SfsStoreManagerBase.cs
  12. 117
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Orders/PurchaseOrderEventHandler.cs
  13. 10
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Plans/SupplierAsnEventHandler.cs

2
be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/WorkCenters/WorkCenter.cs

@ -10,7 +10,7 @@ namespace Win_in.Sfs.Basedata.Domain;
/// </summary> /// </summary>
public class WorkStation : SfsBaseDataAggregateRootBase, IHasCode, IHasName public class WorkStation : SfsBaseDataAggregateRootBase, IHasCode, IHasName
{ {
[Display(Name = "码")] [Display(Name = "工作中心代码")]
[Required(ErrorMessage = "{0}是必填项")] [Required(ErrorMessage = "{0}是必填项")]
[StringLength(SfsEfCorePropertyConst.CodeLength, ErrorMessage = "{0}最多输入{1}个字符")] [StringLength(SfsEfCorePropertyConst.CodeLength, ErrorMessage = "{0}最多输入{1}个字符")]
[IgnoreUpdate] [IgnoreUpdate]

2
be/Modules/Label/src/Win_in.Sfs.Label.Application.Contracts/InventoryLabels/InventoryLabelEditInput.cs

@ -203,6 +203,7 @@ public class InventoryLabelEditInput : SfsLabelCreateOrUpdateInputBase
/// </summary> /// </summary>
[Display(Name = "供应商零件名")] [Display(Name = "供应商零件名")]
public string SupplierItemName { get; set; } public string SupplierItemName { get; set; }
#endregion #endregion
#region Create #region Create
@ -219,5 +220,6 @@ public class InventoryLabelEditInput : SfsLabelCreateOrUpdateInputBase
[Display(Name = "标签类型")] [Display(Name = "标签类型")]
[Required(ErrorMessage = "{0}是必填项")] [Required(ErrorMessage = "{0}是必填项")]
public EnumLabelType LabelType { get; set; } public EnumLabelType LabelType { get; set; }
#endregion #endregion
} }

15
be/Modules/Label/src/Win_in.Sfs.Label.Application/InventoryLabels/InventoryLabelAppService.cs

@ -60,17 +60,14 @@ public class InventoryLabelAppService
[HttpPost("many")] [HttpPost("many")]
public virtual async Task<List<InventoryLabelDto>> CreateManyAsync(List<InventoryLabelEditInput> inputs) public virtual async Task<List<InventoryLabelDto>> CreateManyAsync(List<InventoryLabelEditInput> inputs)
{ {
var codes = inputs.Select(p => p.Code).ToList(); List<InventoryLabelDto> inventoryLabelDtos = new List<InventoryLabelDto>();
var existEntities = await GetByCodesAsync(codes).ConfigureAwait(false);
if (existEntities.Any()) foreach (var input in inputs)
{ {
var existCodes = existEntities.Select(p => p.Code).ToList(); inventoryLabelDtos.Add(await CreateAsync(input));
throw new UserFriendlyException($"{existCodes.JoinAsString(",")} 已存在");
} }
var entities = ObjectMapper.Map<List<InventoryLabelEditInput>, List<InventoryLabel>>(inputs);
await Repository.InsertManyAsync(entities).ConfigureAwait(false); return inventoryLabelDtos;
var dtos = ObjectMapper.Map<List<InventoryLabel>, List<InventoryLabelDto>>(entities);
return dtos;
} }
[HttpPost("generate-and-create")] [HttpPost("generate-and-create")]

10
be/Modules/Label/src/Win_in.Sfs.Label.Application/InventoryLabels/InventoryLabelAutoMapperProfile.cs

@ -22,6 +22,16 @@ public class InventoryLabelAutoMapperProfile : Profile
.Ignore(x => x.Remark) .Ignore(x => x.Remark)
.Ignore(x => x.ExtraProperties); .Ignore(x => x.ExtraProperties);
CreateMap<InventoryLabelEditInput, InventoryLabel>()
.IgnoreAuditedObjectProperties()
.MapQualityInfoDto()
.MapPurchaseInfoDto()
.MapProductionInfoDto()
.Ignore(x=>x.Id)
.Ignore(x => x.ConcurrencyStamp)
;
CreateMap<InventoryLabelImportInput, InventoryLabel>() CreateMap<InventoryLabelImportInput, InventoryLabel>()
.IgnoreAuditedObjectProperties() .IgnoreAuditedObjectProperties()
.MapPurchaseInfoDto() .MapPurchaseInfoDto()

21
be/Modules/Shared/src/Win_in.Sfs.Shared.Application/SfsCrudWithDetailsAppServiceBase.cs

@ -6,13 +6,16 @@ using System.Linq;
using System.Linq.Dynamic.Core; using System.Linq.Dynamic.Core;
using System.Linq.Expressions; using System.Linq.Expressions;
using System.Reflection; using System.Reflection;
using System.Security.Principal;
using System.Text.Json; using System.Text.Json;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using AutoMapper.Internal; using AutoMapper.Internal;
using DocumentFormat.OpenXml.Math; using DocumentFormat.OpenXml.Math;
using DocumentFormat.OpenXml.Office2010.ExcelAc;
using DocumentFormat.OpenXml.Spreadsheet; using DocumentFormat.OpenXml.Spreadsheet;
using DocumentFormat.OpenXml.Vml.Office; using DocumentFormat.OpenXml.Vml.Office;
using DocumentFormat.OpenXml.Wordprocessing;
using EFCore.BulkExtensions; using EFCore.BulkExtensions;
using JetBrains.Annotations; using JetBrains.Annotations;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
@ -328,12 +331,13 @@ public abstract class SfsCrudWithDetailsAppServiceBase<TEntity, TEntityDto, TReq
/// </summary> /// </summary>
[HttpPost("import")] [HttpPost("import")]
[Consumes("multipart/form-data")] [Consumes("multipart/form-data")]
[UnitOfWork]
public virtual async Task<IActionResult> ImportAsync([FromForm] SfsImportRequestInput requestInput, [Required] IFormFile file) public virtual async Task<IActionResult> ImportAsync([FromForm] SfsImportRequestInput requestInput, [Required] IFormFile file)
{ {
using var ms = new MemoryStream(); using var ms = new MemoryStream();
await file.OpenReadStream().CopyToAsync(ms).ConfigureAwait(false); await file.OpenReadStream().CopyToAsync(ms).ConfigureAwait(false);
var inputFileBytes = ms.GetAllBytes(); var inputFileBytes = ms.GetAllBytes();
var result = await ImportInternalAsync(requestInput, inputFileBytes).ConfigureAwait(false); var result = await ImportInternalAsync(requestInput, inputFileBytes);
var bytes = result.FileContents; var bytes = result.FileContents;
result.FileContents = null; result.FileContents = null;
@ -506,6 +510,7 @@ public abstract class SfsCrudWithDetailsAppServiceBase<TEntity, TEntityDto, TReq
/// <summary> /// <summary>
/// 导入数据具体实现,可重写 /// 导入数据具体实现,可重写
/// </summary> /// </summary>
[UnitOfWork]
protected virtual async Task<SfsImportResult> ImportInternalAsync(SfsImportRequestInput requestInput, byte[] inputFileBytes) protected virtual async Task<SfsImportResult> ImportInternalAsync(SfsImportRequestInput requestInput, byte[] inputFileBytes)
{ {
try try
@ -550,7 +555,7 @@ public abstract class SfsCrudWithDetailsAppServiceBase<TEntity, TEntityDto, TReq
// 批量更新 // 批量更新
if (entityDict.Any()) if (entityDict.Any())
{ {
entityDict=await ImportProcessingEntityAsync(entityDict); entityDict=await ImportProcessingEntityAsync(entityDict).ConfigureAwait(false);
// 调用批量验证 // 调用批量验证
var entityListStatus = await ValidateImportEntities(entityDict).ConfigureAwait(false); var entityListStatus = await ValidateImportEntities(entityDict).ConfigureAwait(false);
@ -559,9 +564,9 @@ public abstract class SfsCrudWithDetailsAppServiceBase<TEntity, TEntityDto, TReq
await SaveImportAsync(entityDict).ConfigureAwait(false); await SaveImportAsync(entityDict).ConfigureAwait(false);
} }
} }
//将需要新增的数据进行发布
await PublishCreatedAsync(entityDict.Keys.ToList()); var addList= entityDict.Where(p => p.Value == EntityState.Added).Select(p=>p.Key).ToList();
await PublishCreatedAsync(addList).ConfigureAwait(false);
// 创建导入报告 // 创建导入报告
var reportFile = ExportImportService.GetImportReport(inputFileBytes, modelDict); var reportFile = ExportImportService.GetImportReport(inputFileBytes, modelDict);
// 创建返回值 // 创建返回值
@ -581,7 +586,7 @@ public abstract class SfsCrudWithDetailsAppServiceBase<TEntity, TEntityDto, TReq
} }
/// <summary> /// <summary>
/// 导入数据后 发布事件 /// 发布新增事件
/// </summary> /// </summary>
/// <param name="entities"></param> /// <param name="entities"></param>
/// <returns></returns> /// <returns></returns>
@ -589,7 +594,7 @@ public abstract class SfsCrudWithDetailsAppServiceBase<TEntity, TEntityDto, TReq
{ {
try try
{ {
await LocalEventBus.PublishAsync(new SfsCreatedEntityEventData<List<TEntity>>(entities),true).ConfigureAwait(false); await LocalEventBus.PublishAsync(new SfsCreatedEntityEventData<List<TEntity>>(entities),false).ConfigureAwait(false);
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -612,6 +617,7 @@ public abstract class SfsCrudWithDetailsAppServiceBase<TEntity, TEntityDto, TReq
/// <summary> /// <summary>
/// 导入保存到数据库,可重写 /// 导入保存到数据库,可重写
/// </summary> /// </summary>
protected virtual async Task SaveImportAsync(Dictionary<TEntity, EntityState> dict) protected virtual async Task SaveImportAsync(Dictionary<TEntity, EntityState> dict)
{ {
var entityList = dict.Keys.ToList(); var entityList = dict.Keys.ToList();
@ -636,6 +642,7 @@ public abstract class SfsCrudWithDetailsAppServiceBase<TEntity, TEntityDto, TReq
SetOutputIdentity = true, SetOutputIdentity = true,
PreserveInsertOrder = true PreserveInsertOrder = true
}; };
await context.BulkInsertOrUpdateAsync(entityList, bulkConfig).ConfigureAwait(false); await context.BulkInsertOrUpdateAsync(entityList, bulkConfig).ConfigureAwait(false);
await context.BulkInsertAsync(list).ConfigureAwait(false); await context.BulkInsertAsync(list).ConfigureAwait(false);
} }

2
be/Modules/Shared/src/Win_in.Sfs.Shared.Domain/Interfaces/IHasLocationSwitch.cs

@ -7,7 +7,7 @@ public interface IHasLocationSwitch
public bool EnableMixStatus { get; set; } // 可以混状态 public bool EnableMixStatus { get; set; } // 可以混状态
public bool EnableNegative { get; set; } // 可以负库存 public bool EnableNegative { get; set; } // 可以负库存
public bool EnableKeepZero { get; set; } // 可以保留零库存 public bool EnableKeepZero { get; set; } // 可以保留零库存
public bool EnableOpportunityCount { get; set; } // 可以机会盘点 public bool EnableOpportunityCount { get; set; } // 可以机会盘点(动态盘点)
public bool EnablePick { get; set; } // 可以领料 public bool EnablePick { get; set; } // 可以领料
public bool EnableOverPick { get; set; } // 可以过量领料 public bool EnableOverPick { get; set; } // 可以过量领料
public bool EnableWholeStore { get; set; } // 可以整包存储 public bool EnableWholeStore { get; set; } // 可以整包存储

7
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Plans/SupplierAsns/ISupplierAsnAppService.cs

@ -24,4 +24,11 @@ public interface ISupplierAsnAppService
Task<List<SupplierAsnDTO>> GetForTodayUnReceivedListAsync(); Task<List<SupplierAsnDTO>> GetForTodayUnReceivedListAsync();
Task<List<SupplierAsnDTO>> GetByStartTimeEndTimeAsync(DateTime startTime, DateTime endTime); Task<List<SupplierAsnDTO>> GetByStartTimeEndTimeAsync(DateTime startTime, DateTime endTime);
/// <summary>
/// 生成ASN订单号
/// </summary>
/// <param name="activeDate"></param>
/// <returns></returns>
Task<string> GenerateSupplierAsnNumberAsync(DateTime activeDate);
} }

4
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Orders/PurchaseOrders/PurchaseOrderAppService.cs

@ -3,14 +3,18 @@ using System.Collections.Generic;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using DocumentFormat.OpenXml.Office2010.ExcelAc;
using DocumentFormat.OpenXml.Spreadsheet;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Volo.Abp; using Volo.Abp;
using Volo.Abp.Uow;
using Win_in.Sfs.Basedata.Application.Contracts; using Win_in.Sfs.Basedata.Application.Contracts;
using Win_in.Sfs.Shared.Application.Contracts; using Win_in.Sfs.Shared.Application.Contracts;
using Win_in.Sfs.Shared.Domain.Shared; using Win_in.Sfs.Shared.Domain.Shared;
using Win_in.Sfs.Shared.Event;
using Win_in.Sfs.Wms.Store.Application.Contracts; using Win_in.Sfs.Wms.Store.Application.Contracts;
using Win_in.Sfs.Wms.Store.Domain; using Win_in.Sfs.Wms.Store.Domain;
using Win_in.Sfs.Wms.Store.Domain.Shared; using Win_in.Sfs.Wms.Store.Domain.Shared;

3
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Orders/PurchaseOrders/PurchaseOrderAutoMapperProfile.cs

@ -28,7 +28,8 @@ public partial class StoreApplicationAutoMapperProfile : Profile
.Ignore(x => x.MasterID) .Ignore(x => x.MasterID)
.Ignore(x => x.TenantId) .Ignore(x => x.TenantId)
.Ignore(x => x.Number) .Ignore(x => x.Number)
.Ignore(x => x.Id); .Ignore(x => x.Id)
;
CreateMap<PurchaseOrderImportInput, PurchaseOrder>() CreateMap<PurchaseOrderImportInput, PurchaseOrder>()
.IgnoreAuditedObjectProperties() .IgnoreAuditedObjectProperties()

12
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Plans/SupplierAsns/SupplierAsnAppService.cs

@ -65,6 +65,18 @@ public class SupplierAsnAppService :
return ObjectMapper.Map<SupplierAsn, SupplierAsnDTO>(resultEntity); return ObjectMapper.Map<SupplierAsn, SupplierAsnDTO>(resultEntity);
} }
/// <summary>
/// 生成ASN订单号
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("generate-supplierasn-number")]
public async Task<string> GenerateSupplierAsnNumberAsync(DateTime activeDate)
{
return await _supplierAsnManager.GenerateNumberAsync(nameof(SupplierAsn), Clock.Normalize(activeDate))
.ConfigureAwait(false);
}
private async Task<SupplierAsnDTO> CreateFromFileAsync(SupplierAsnEditInput input) private async Task<SupplierAsnDTO> CreateFromFileAsync(SupplierAsnEditInput input)
{ {
var entity = ObjectMapper.Map<SupplierAsnEditInput, SupplierAsn>(input); var entity = ObjectMapper.Map<SupplierAsnEditInput, SupplierAsn>(input);

4
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Bases/SfsStoreManagerBase.cs

@ -121,7 +121,7 @@ public abstract class SfsStoreManagerBase<TEntity, TDetailEntity>
{ {
try try
{ {
await LocalEventBus.PublishAsync(new SfsCreatedEntityEventData<TEntity>(entity)).ConfigureAwait(false); await LocalEventBus.PublishAsync(new SfsCreatedEntityEventData<TEntity>(entity),false).ConfigureAwait(false);
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -136,7 +136,7 @@ public abstract class SfsStoreManagerBase<TEntity, TDetailEntity>
{ {
try try
{ {
await LocalEventBus.PublishAsync(new SfsCreatedEntityEventData<List<TEntity>>(entities)).ConfigureAwait(false); await LocalEventBus.PublishAsync(new SfsCreatedEntityEventData<List<TEntity>>(entities),false).ConfigureAwait(false);
} }
catch (Exception ex) catch (Exception ex)
{ {

117
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Orders/PurchaseOrderEventHandler.cs

@ -1,7 +1,10 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Net.Http;
using System.Threading.Tasks; using System.Threading.Tasks;
using Castle.Components.DictionaryAdapter;
using Volo.Abp;
using Volo.Abp.EventBus; using Volo.Abp.EventBus;
using Volo.Abp.Uow; using Volo.Abp.Uow;
using Win_in.Sfs.Basedata.Application.Contracts; using Win_in.Sfs.Basedata.Application.Contracts;
@ -13,6 +16,8 @@ using Win_in.Sfs.Shared.Event;
using Win_in.Sfs.Wms.Inventory.Domain.Acl.ItemBasic; using Win_in.Sfs.Wms.Inventory.Domain.Acl.ItemBasic;
using Win_in.Sfs.Wms.Store.Application.Contracts; using Win_in.Sfs.Wms.Store.Application.Contracts;
using Win_in.Sfs.Wms.Store.Domain; using Win_in.Sfs.Wms.Store.Domain;
using static Win_in.Sfs.Wms.Store.Domain.Shared.StoreSettings;
using SupplierAsn = Win_in.Sfs.Wms.Store.Domain.SupplierAsn;
namespace Win_in.Sfs.Wms.Store.Event.Orders; namespace Win_in.Sfs.Wms.Store.Event.Orders;
@ -27,13 +32,19 @@ public class PurchaseOrderEventHandler
private readonly IItemPackAppService _itemPackAppService; private readonly IItemPackAppService _itemPackAppService;
private readonly ISupplierItemAppService _supplierItemAppService; private readonly ISupplierItemAppService _supplierItemAppService;
private readonly IDockAppService _dockAppService; private readonly IDockAppService _dockAppService;
private readonly IInventoryLabelAppService _inventoryLabelAppService;
private readonly ISupplierAppService _supplierAppService;
public PurchaseOrderEventHandler(ISupplierAsnAppService supplierAsnAppService, public PurchaseOrderEventHandler(ISupplierAsnAppService supplierAsnAppService,
ILabelDefinitionAppService labelDefinitionAppService, ILabelDefinitionAppService labelDefinitionAppService,
IItemBasicAppService itemBasicAppService, IItemBasicAppService itemBasicAppService,
IItemPackAppService itemPackAppService, IItemPackAppService itemPackAppService,
ISupplierItemAppService supplierItemAppService, ISupplierItemAppService supplierItemAppService,
IDockAppService dockAppService) IDockAppService dockAppService,
IInventoryLabelAppService inventoryLabelAppService,
IPurchaseOrderManager purchaseOrderManager,
ISupplierAppService supplierAppService)
{ {
_supplierAsnAppService = supplierAsnAppService; _supplierAsnAppService = supplierAsnAppService;
_labelDefinitionAppService = labelDefinitionAppService; _labelDefinitionAppService = labelDefinitionAppService;
@ -41,6 +52,8 @@ public class PurchaseOrderEventHandler
_itemPackAppService = itemPackAppService; _itemPackAppService = itemPackAppService;
_supplierItemAppService = supplierItemAppService; _supplierItemAppService = supplierItemAppService;
_dockAppService = dockAppService; _dockAppService = dockAppService;
_inventoryLabelAppService = inventoryLabelAppService;
_supplierAppService = supplierAppService;
} }
//创建采购订单 //创建采购订单
@ -81,7 +94,7 @@ public class PurchaseOrderEventHandler
//收货口 //todo 处理有问题是否要和供应商关联 //收货口 //todo 处理有问题是否要和供应商关联
var dock = await _dockAppService.GetAllListByFilterAsync( var dock = await _dockAppService.GetAllListByFilterAsync(
new SfsBaseDataRequestInputBase() { Condition = new Condition(), MaxResultCount = 99, SkipCount = 0, Sorting = string.Empty }, true).ConfigureAwait(false); new SfsBaseDataRequestInputBase() { Condition = new Condition(){Filters = new List<Filter>()}, MaxResultCount = 99, SkipCount = 0, Sorting = string.Empty }, true).ConfigureAwait(false);
supplierAsnEditInput.DockCode = dock.First().Code; supplierAsnEditInput.DockCode = dock.First().Code;
//要货单号 //要货单号
@ -90,10 +103,8 @@ public class PurchaseOrderEventHandler
//生效日期 //生效日期
supplierAsnEditInput.ActiveDate = Clock.Now; supplierAsnEditInput.ActiveDate = Clock.Now;
//一次性返回所有箱码 //发货单号
var generateManyAsync =await _labelDefinitionAppService supplierAsnEditInput.Number = await _supplierAsnAppService.GenerateSupplierAsnNumberAsync(supplierAsnEditInput.ActiveDate).ConfigureAwait(false);
.GenerateManyAsync(EnumLabelType.PurchaseLabel.ToString(), Clock.Now.ToString(SharedConst.TimeFormat),
supplierAsnEditInput.Details.Count).ConfigureAwait(false);
//所有的物品Code //所有的物品Code
var itemCodes = purchaseOrder.Details.GroupBy(p => p.ItemCode).Select(p => p.Key); var itemCodes = purchaseOrder.Details.GroupBy(p => p.ItemCode).Select(p => p.Key);
@ -103,6 +114,11 @@ public class PurchaseOrderEventHandler
var ItemPacks = new List<ItemPackDTO>();//一次性返回所有物品包装信息 var ItemPacks = new List<ItemPackDTO>();//一次性返回所有物品包装信息
var supplierItemDtos = new List<SupplierItemDTO>();//一次性返回所有供应商物品信息 var supplierItemDtos = new List<SupplierItemDTO>();//一次性返回所有供应商物品信息
//一次性返回所有箱码
var generateManyAsync = await _labelDefinitionAppService
.GenerateManyAsync(EnumLabelType.PurchaseLabel.ToString(), Clock.Now.ToString(SharedConst.TimeFormat),
supplierAsnEditInput.Details.Count).ConfigureAwait(false);
foreach (var itemCode in itemCodes)//查询 foreach (var itemCode in itemCodes)//查询
{ {
var itemPackDtos = await _itemPackAppService.GetListByItemCodeAsync(itemCode).ConfigureAwait(false); var itemPackDtos = await _itemPackAppService.GetListByItemCodeAsync(itemCode).ConfigureAwait(false);
@ -116,7 +132,7 @@ public class PurchaseOrderEventHandler
supplierAsnEditInput.Details.ForEach(detail => supplierAsnEditInput.Details.ForEach(detail =>
{ {
//添加箱码 //添加箱码
var pakcingCode=generateManyAsync.First(); var pakcingCode = generateManyAsync.First();
detail.PackingCode = pakcingCode; detail.PackingCode = pakcingCode;
generateManyAsync.Remove(pakcingCode); generateManyAsync.Remove(pakcingCode);
@ -137,8 +153,95 @@ public class PurchaseOrderEventHandler
detail.SupplierPackUom= supplierItemDto.SupplierPackUom; detail.SupplierPackUom= supplierItemDto.SupplierPackUom;
}); });
//赋值箱码 创建箱码
var supplierDto= await _supplierAppService.GetByCodeAsync(supplierAsnEditInput.SupplierCode).ConfigureAwait(false);
await CreateLabelAsync(supplierAsnEditInput, supplierDto,itemBasicDtos,supplierItemDtos).ConfigureAwait(false);
return supplierAsnEditInput; return supplierAsnEditInput;
} }
//创建 发货标签
private async Task CreateLabelAsync(SupplierAsnEditInput supplierAsnEditInput, SupplierDTO supplierDtos,
List<ItemBasicDTO> itemBasicDtos, List<SupplierItemDTO> supplierItemDtos)
{
var inventoryLabelDtos = new List<InventoryLabelEditInput>();
foreach (var supplierAsnDetail in supplierAsnEditInput.Details)
{
var supplierDto= supplierDtos;
var itemBasicDto = itemBasicDtos.First(p => p.Code == supplierAsnDetail.ItemCode);
var supplierItemDto= supplierItemDtos.First(p =>
p.ItemCode == supplierAsnDetail.ItemCode && p.SupplierCode == supplierAsnEditInput.SupplierCode);
var inputLabel = await BuildInventoryLabelCreateInputAsync(supplierAsnEditInput, supplierAsnDetail,supplierDto, itemBasicDto,supplierItemDto).ConfigureAwait(false);
inventoryLabelDtos.Add(inputLabel);
await _inventoryLabelAppService.CreateAsync(inputLabel).ConfigureAwait(false);
}
}
//构造 采购标签
private async Task<InventoryLabelEditInput> BuildInventoryLabelCreateInputAsync(SupplierAsnEditInput supplierAsn,
SupplierAsnDetailInput supplierAsnDetail,
SupplierDTO supplierDto,
ItemBasicDTO itemBasicDto,
SupplierItemDTO supplierItemDto
)
{
if (itemBasicDto == null)
{
throw new UserFriendlyException($"{supplierAsnDetail.ItemCode}物品信息为空");
}
if (supplierDto == null)
{
throw new UserFriendlyException($"{supplierAsn.SupplierCode}供应商为空");
}
if (supplierItemDto == null)
{
throw new UserFriendlyException($"{supplierAsn.SupplierCode}供应商零件或{supplierItemDto.ItemCode}物品信息为空");
}
var inputLabel = new InventoryLabelEditInput()
{
LabelType = EnumLabelType.PurchaseLabel,
ArriveDate = DateTime.Now,
Qty = supplierAsnDetail.Qty,
PoNumber = supplierAsnDetail.PoNumber,
Uom = supplierAsnDetail.Uom,
ItemDesc2 = itemBasicDto.Desc2,
AsnNumber = supplierAsn.Number,
ItemCode = supplierAsnDetail.ItemCode,
ItemName = supplierAsnDetail.ItemName,
ItemDesc1 = itemBasicDto.Desc1,
SupplierBatch = supplierAsnDetail.SupplierBatch,
ProduceDate = supplierAsnDetail.ProduceDate,
ExpireDate = DateTime.Now.AddDays(itemBasicDto.GetValidateDays()),
FullBarcodeString = supplierAsnDetail.PackingCode,
ExtraProperties = { },
LabelStatus = LabelStatus.Enable,
LocationErpCode = supplierAsnDetail.RecommendErpCode,
Lot = supplierAsnDetail.Lot,
RecommendLocationCode = supplierAsnDetail.RecommendErpCode,
Remark = supplierAsnDetail.Remark,
Specifications = itemBasicDto.Color,
StdPackQty = supplierAsnDetail.StdPackQty,
SupplierCode = supplierAsn.SupplierCode,
SupplierItemCode = supplierItemDto.SupplierItemCode,
SupplierItemName = supplierItemDto.ItemName,
SupplierName = supplierDto.Name,
SupplierSimpleName = supplierDto.ShortName,
Team = null,
ProdLine = null,
QLevel = null,
QualityFile = null,
RpNumber = null,
Shift = null,
ContainerCode = null,
Code = supplierAsnDetail.PackingCode
};
return inputLabel;
}
#endregion #endregion
} }

10
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Plans/SupplierAsnEventHandler.cs

@ -23,7 +23,7 @@ public class SupplierAsnEventHandler
, ILocalEventHandler<SfsCreatedEntityEventData<List<SupplierAsn>>> , ILocalEventHandler<SfsCreatedEntityEventData<List<SupplierAsn>>>
{ {
private readonly IPurchaseReceiptRequestAppService _purchaseReceiptRequestAppService; //private readonly IPurchaseReceiptRequestAppService _purchaseReceiptRequestAppService;
private readonly IPurchaseOrderAppService _purchaseOrderAppService; private readonly IPurchaseOrderAppService _purchaseOrderAppService;
private readonly ISupplierItemAppService _supplierItemAppService; private readonly ISupplierItemAppService _supplierItemAppService;
private readonly IInventoryLabelAppService _inventoryLabelService; private readonly IInventoryLabelAppService _inventoryLabelService;
@ -37,7 +37,7 @@ public class SupplierAsnEventHandler
ISupplierAppService supplierAppService ISupplierAppService supplierAppService
) )
{ {
_purchaseReceiptRequestAppService = purchaseReceiptRequestAppService; //_purchaseReceiptRequestAppService = purchaseReceiptRequestAppService;
_purchaseOrderAppService = purchaseOrderAppService; _purchaseOrderAppService = purchaseOrderAppService;
_supplierItemAppService = supplierItemAppService; _supplierItemAppService = supplierItemAppService;
_inventoryLabelService = inventoryLabelService; _inventoryLabelService = inventoryLabelService;
@ -58,7 +58,7 @@ public class SupplierAsnEventHandler
{ {
case EnumSupplierAsnCreateType.Import: case EnumSupplierAsnCreateType.Import:
//创建标签 //创建标签
await CreateLabelAsync(entity).ConfigureAwait(false); //await CreateLabelAsync(entity).ConfigureAwait(false);
break; break;
case EnumSupplierAsnCreateType.AppService: case EnumSupplierAsnCreateType.AppService:
case EnumSupplierAsnCreateType.ExternalInterface: case EnumSupplierAsnCreateType.ExternalInterface:
@ -92,7 +92,7 @@ public class SupplierAsnEventHandler
await CreatePurchaseOrderAsync(supplierAsn).ConfigureAwait(false); await CreatePurchaseOrderAsync(supplierAsn).ConfigureAwait(false);
//创建标签 //创建标签
await CreateLabelAsync(supplierAsn).ConfigureAwait(false); //await CreateLabelAsync(supplierAsn).ConfigureAwait(false);
break; break;
case EnumSupplierAsnCreateType.AppService: case EnumSupplierAsnCreateType.AppService:
case EnumSupplierAsnCreateType.ExternalInterface: case EnumSupplierAsnCreateType.ExternalInterface:
@ -122,7 +122,7 @@ public class SupplierAsnEventHandler
{ {
var input = BuildPurchaseReceiptRequestCreateInput(supplierAsn); var input = BuildPurchaseReceiptRequestCreateInput(supplierAsn);
await _purchaseReceiptRequestAppService.CreateAsync(input).ConfigureAwait(false); //await _purchaseReceiptRequestAppService.CreateAsync(input).ConfigureAwait(false);
} }
} }

Loading…
Cancel
Save