From d2eec1e3ccecf838598b904d94219a4c7a3859da Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E9=83=91=E6=B8=A4=E6=97=AD=5BIrelia=5D?= <366601522@qq.com>
Date: Mon, 3 Apr 2023 00:33:03 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=20=E9=87=87=E8=B4=AD?=
=?UTF-8?q?=E6=94=B6=E8=B4=A7=20=E4=BE=9B=E5=BA=94=E5=95=86=E5=8F=91?=
=?UTF-8?q?=E8=B4=A7?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Win_in.Sfs.Core.HttpApi.Host.csproj | 4 +-
.../ClosedXmlExportImportService.cs | 1 +
.../SfsCrudWithDetailsAppServiceBase.cs | 37 ++++--
.../Win_in.Sfs.Shared.Application.csproj | 1 +
.../SupplierAsns/SupplierAsnAppService.cs | 1 +
.../SupplierAsnAutoMapperProfile.cs | 11 +-
.../Orders/PurchaseOrderAutoMapperProfile.cs | 46 +++++++
.../Orders/PurchaseOrderEventHandler.cs | 118 ++++++++++++++++--
.../Plans/SupplierAsnEventHandler.cs | 5 +-
.../StoreEventAutoMapperProfile.cs | 9 +-
.../settings/appsettings.Development.json | 8 +-
11 files changed, 196 insertions(+), 45 deletions(-)
create mode 100644 be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/AutoMapperProfiles/Orders/PurchaseOrderAutoMapperProfile.cs
diff --git a/be/Hosts/Core.Host/Win_in.Sfs.Core.Host/Win_in.Sfs.Core.HttpApi.Host.csproj b/be/Hosts/Core.Host/Win_in.Sfs.Core.Host/Win_in.Sfs.Core.HttpApi.Host.csproj
index c7dd04001..1227e3c48 100644
--- a/be/Hosts/Core.Host/Win_in.Sfs.Core.Host/Win_in.Sfs.Core.HttpApi.Host.csproj
+++ b/be/Hosts/Core.Host/Win_in.Sfs.Core.Host/Win_in.Sfs.Core.HttpApi.Host.csproj
@@ -81,8 +81,8 @@
-
+
diff --git a/be/Modules/Shared/src/Win_in.Sfs.Shared.Application/ExportAndImport/ClosedXmlExportImportService.cs b/be/Modules/Shared/src/Win_in.Sfs.Shared.Application/ExportAndImport/ClosedXmlExportImportService.cs
index c5e494509..61c84d4e9 100644
--- a/be/Modules/Shared/src/Win_in.Sfs.Shared.Application/ExportAndImport/ClosedXmlExportImportService.cs
+++ b/be/Modules/Shared/src/Win_in.Sfs.Shared.Application/ExportAndImport/ClosedXmlExportImportService.cs
@@ -13,6 +13,7 @@ using DocumentFormat.OpenXml;
using Irony;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
+using Volo.Abp.Uow;
using Win_in.Sfs.Shared.Application.Contracts;
using Win_in.Sfs.Shared.Application.Contracts.ExportAndImport;
using Win_in.Sfs.Shared.Domain.Shared;
diff --git a/be/Modules/Shared/src/Win_in.Sfs.Shared.Application/SfsCrudWithDetailsAppServiceBase.cs b/be/Modules/Shared/src/Win_in.Sfs.Shared.Application/SfsCrudWithDetailsAppServiceBase.cs
index 51af35d79..dfdd4e0dc 100644
--- a/be/Modules/Shared/src/Win_in.Sfs.Shared.Application/SfsCrudWithDetailsAppServiceBase.cs
+++ b/be/Modules/Shared/src/Win_in.Sfs.Shared.Application/SfsCrudWithDetailsAppServiceBase.cs
@@ -29,11 +29,13 @@ using Volo.Abp.Domain.Entities.Auditing;
using Volo.Abp.Domain.Repositories;
using Volo.Abp.EventBus.Local;
using Volo.Abp.SettingManagement;
+using Volo.Abp.Uow;
using Win_in.Sfs.Basedata.Application.Contracts;
using Win_in.Sfs.Shared.Application.Contracts;
using Win_in.Sfs.Shared.Application.Contracts.ExportAndImport;
using Win_in.Sfs.Shared.Domain;
using Win_in.Sfs.Shared.Domain.Shared;
+using Win_in.Sfs.Shared.Event;
namespace Win_in.Sfs.Shared.Application;
@@ -71,6 +73,8 @@ public abstract class SfsCrudWithDetailsAppServiceBase LazyServiceProvider.LazyGetRequiredService();
+ protected ILocalEventBus LocalEventBus => LazyServiceProvider.LazyGetRequiredService();
+
///
///
///
@@ -556,6 +560,8 @@ public abstract class SfsCrudWithDetailsAppServiceBase> Publish()
- //{
- // try
- // {
- // await LocalEventBus.PublishAsync(new SfsCreatedEntityEventData>(entities)).ConfigureAwait(false);
- // }
- // catch (Exception ex)
- // {
- // Logger.LogDebug($"{typeof(TEntity).Name} Created Event:{ex.Message}", null);
- // Console.WriteLine(ex.Source);
- // throw;
- // }
- //}
+ ///
+ /// 导入数据后 发布事件
+ ///
+ ///
+ ///
+ private async Task PublishCreatedAsync(List entities)
+ {
+ try
+ {
+ await LocalEventBus.PublishAsync(new SfsCreatedEntityEventData>(entities),true).ConfigureAwait(false);
+ }
+ catch (Exception ex)
+ {
+ Logger.LogDebug($"{typeof(TEntity).Name} Created Event:{ex.Message}", null);
+ Console.WriteLine(ex.Source);
+ throw;
+ }
+ }
///
/// 用来重写 导入数据时可以加工数据
diff --git a/be/Modules/Shared/src/Win_in.Sfs.Shared.Application/Win_in.Sfs.Shared.Application.csproj b/be/Modules/Shared/src/Win_in.Sfs.Shared.Application/Win_in.Sfs.Shared.Application.csproj
index e42d0c1a5..7dca9b96c 100644
--- a/be/Modules/Shared/src/Win_in.Sfs.Shared.Application/Win_in.Sfs.Shared.Application.csproj
+++ b/be/Modules/Shared/src/Win_in.Sfs.Shared.Application/Win_in.Sfs.Shared.Application.csproj
@@ -40,6 +40,7 @@
+
diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Plans/SupplierAsns/SupplierAsnAppService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Plans/SupplierAsns/SupplierAsnAppService.cs
index 13b3d5312..bc8da32bf 100644
--- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Plans/SupplierAsns/SupplierAsnAppService.cs
+++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Plans/SupplierAsns/SupplierAsnAppService.cs
@@ -64,6 +64,7 @@ public class SupplierAsnAppService :
return ObjectMapper.Map(resultEntity);
}
+
private async Task CreateFromFileAsync(SupplierAsnEditInput input)
{
var entity = ObjectMapper.Map(input);
diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Plans/SupplierAsns/SupplierAsnAutoMapperProfile.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Plans/SupplierAsns/SupplierAsnAutoMapperProfile.cs
index 4462091cc..b64c1621f 100644
--- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Plans/SupplierAsns/SupplierAsnAutoMapperProfile.cs
+++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Plans/SupplierAsns/SupplierAsnAutoMapperProfile.cs
@@ -15,20 +15,17 @@ public partial class StoreApplicationAutoMapperProfile : Profile
CreateMap()
.IgnoreAuditedObjectProperties()
.Ignore(x => x.Number)
- .Ignore(x => x.RpNumber)
- .Ignore(x => x.PoNumber)
- .Ignore(x => x.SupplierCode)
- .Ignore(x => x.Details)
- .Ignore(x => x.ActiveDate)
.Ignore(x => x.Id);
- CreateMap();
+ CreateMap()
+ ;
CreateMap()
.IgnoreAuditedObjectProperties()
.Ignore(x => x.MasterID)
.Ignore(x => x.TenantId)
.Ignore(x => x.Number)
- .Ignore(x => x.Id);
+ .Ignore(x => x.Id)
+ ;
}
}
diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/AutoMapperProfiles/Orders/PurchaseOrderAutoMapperProfile.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/AutoMapperProfiles/Orders/PurchaseOrderAutoMapperProfile.cs
new file mode 100644
index 000000000..2bc2d8145
--- /dev/null
+++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/AutoMapperProfiles/Orders/PurchaseOrderAutoMapperProfile.cs
@@ -0,0 +1,46 @@
+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.Event;
+
+public partial class StoreEventAutoMapperProfile : Profile
+{
+ private void PurchaseOrderAutoMapperProfile()
+ {
+ // 采购订单 > 发货单
+ #region SupplierAsn, PurchaseOrderCreateInput
+
+ CreateMap()
+ .Ignore(x => x.Status)
+ .Ignore(x => x.TruckNumber)
+ .Ignore(x => x.DockCode)
+ .Ignore(x => x.ShipDate)
+ .Ignore(x => x.PlanArriveDate)
+ .Ignore(x => x.TimeWindow)
+ .Ignore(x => x.Ctype)
+ .Ignore(x => x.PlanUserCode)
+ .Ignore(x => x.CreateType)
+ .Ignore(x => x.RpNumber)
+ .Ignore(x => x.PoNumber)
+ ;
+
+ #endregion
+
+ // 采购订单-详情 > 发货单-详情
+ #region PurchaseOrderDetail, SupplierAsnDetailInput
+
+ CreateMap()
+ .Ignore(x => x.PoNumber)
+ .Ignore(x => x.RecommendErpCode)
+ .Ignore(x => x.PlanUserCode)
+ .Ignore(x => x.PackingCode)
+ .Ignore(x => x.ContainerCode)
+ .Ignore(x => x.SupplierBatch)
+ .Ignore(x => x.ArriveDate)
+ ;
+
+ #endregion
+ }
+}
diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Orders/PurchaseOrderEventHandler.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Orders/PurchaseOrderEventHandler.cs
index 2f14b127c..c316d8ee7 100644
--- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Orders/PurchaseOrderEventHandler.cs
+++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Orders/PurchaseOrderEventHandler.cs
@@ -1,20 +1,47 @@
+using System;
using System.Collections.Generic;
+using System.Linq;
using System.Threading.Tasks;
-using Volo.Abp.Domain.Entities;
using Volo.Abp.EventBus;
using Volo.Abp.Uow;
+using Win_in.Sfs.Basedata.Application.Contracts;
+using Win_in.Sfs.Label.Application.Contracts;
+using Win_in.Sfs.Label.Domain.Shared;
+using Win_in.Sfs.Shared.Domain;
+using Win_in.Sfs.Shared.Domain.Shared;
using Win_in.Sfs.Shared.Event;
+using Win_in.Sfs.Wms.Inventory.Domain.Acl.ItemBasic;
using Win_in.Sfs.Wms.Store.Application.Contracts;
using Win_in.Sfs.Wms.Store.Domain;
namespace Win_in.Sfs.Wms.Store.Event.Orders;
public class PurchaseOrderEventHandler
-: StoreEventHandlerBase
-, ILocalEventHandler>
-, ILocalEventHandler>>
+ : StoreEventHandlerBase
+ , ILocalEventHandler>
+ , ILocalEventHandler>>
{
- private const EnumExchangeDataType ExchangeDataType = EnumExchangeDataType.PurchaseOrder;
+ private readonly ISupplierAsnAppService _supplierAsnAppService;
+ private readonly ILabelDefinitionAppService _labelDefinitionAppService;
+ private readonly IItemBasicAppService _itemBasicAppService;
+ private readonly IItemPackAppService _itemPackAppService;
+ private readonly ISupplierItemAppService _supplierItemAppService;
+ private readonly IDockAppService _dockAppService;
+
+ public PurchaseOrderEventHandler(ISupplierAsnAppService supplierAsnAppService,
+ ILabelDefinitionAppService labelDefinitionAppService,
+ IItemBasicAppService itemBasicAppService,
+ IItemPackAppService itemPackAppService,
+ ISupplierItemAppService supplierItemAppService,
+ IDockAppService dockAppService)
+ {
+ _supplierAsnAppService = supplierAsnAppService;
+ _labelDefinitionAppService = labelDefinitionAppService;
+ _itemBasicAppService = itemBasicAppService;
+ _itemPackAppService = itemPackAppService;
+ _supplierItemAppService = supplierItemAppService;
+ _dockAppService = dockAppService;
+ }
//创建采购订单
[UnitOfWork]
@@ -22,7 +49,7 @@ public class PurchaseOrderEventHandler
{
var entity = eventData.Entity;
- await CreateSupplierAsn(entity);
+ await CreateSupplierAsnAsync(entity).ConfigureAwait(false);
}
//批量创建
@@ -31,17 +58,86 @@ public class PurchaseOrderEventHandler
{
var entities = eventData.Entity;
- entities.ForEach(async p =>
+ foreach (var entity in entities)
{
- await CreateSupplierAsn(p).ConfigureAwait(false);
- });
+ await CreateSupplierAsnAsync(entity).ConfigureAwait(false);
+ }
}
- #region 业务 创建采购订单后>创建收货单
+ #region 业务 创建采购订单后 > 创建收货单
- private async Task CreateSupplierAsn(PurchaseOrder purchaseOrder)
+ //创建供应商到货
+ private async Task CreateSupplierAsnAsync(PurchaseOrder purchaseOrder)
{
+ var supplierAsnDto = await BuildSupplierAsnAsync(purchaseOrder).ConfigureAwait(false);
+
+ await _supplierAsnAppService.CreateAsync(supplierAsnDto).ConfigureAwait(false);
+ }
+
+ //构造供应商到货DTO
+ private async Task BuildSupplierAsnAsync(PurchaseOrder purchaseOrder)
+ {
+ var supplierAsnEditInput= ObjectMapper.Map(purchaseOrder);
+
+ //收货口 //todo 处理有问题是否要和供应商关联
+ var dock = await _dockAppService.GetAllListByFilterAsync(
+ new SfsBaseDataRequestInputBase() { Condition = new Condition(), MaxResultCount = 99, SkipCount = 0, Sorting = string.Empty }, true).ConfigureAwait(false);
+ supplierAsnEditInput.DockCode = dock.First().Code;
+
+ //要货单号
+ supplierAsnEditInput.RpNumber = "无";
+
+ //生效日期
+ supplierAsnEditInput.ActiveDate = Clock.Now;
+
+ //一次性返回所有箱码
+ var generateManyAsync =await _labelDefinitionAppService
+ .GenerateManyAsync(EnumLabelType.PurchaseLabel.ToString(), Clock.Now.ToString(SharedConst.TimeFormat),
+ supplierAsnEditInput.Details.Count).ConfigureAwait(false);
+
+ //所有的物品Code
+ var itemCodes = purchaseOrder.Details.GroupBy(p => p.ItemCode).Select(p => p.Key);
+
+ //一次性返回所有物品信息
+ var itemBasicDtos=await _itemBasicAppService.GetByCodesAsync(itemCodes).ConfigureAwait(false);
+ var ItemPacks = new List();//一次性返回所有物品包装信息
+ var supplierItemDtos = new List();//一次性返回所有供应商物品信息
+
+ foreach (var itemCode in itemCodes)//查询
+ {
+ var itemPackDtos = await _itemPackAppService.GetListByItemCodeAsync(itemCode).ConfigureAwait(false);
+ var itemPackDto = itemPackDtos.First();
+ var supplierItem = await _supplierItemAppService.GetBySupplierCodeAndItemCodeAsync(purchaseOrder.SupplierCode, itemCode).ConfigureAwait(false);
+ ItemPacks.Add(itemPackDto);
+ supplierItemDtos.Add(supplierItem);
+ }
+
+ //赋值 详情表
+ supplierAsnEditInput.Details.ForEach(detail =>
+ {
+ //添加箱码
+ var pakcingCode=generateManyAsync.First();
+ detail.PackingCode = pakcingCode;
+ generateManyAsync.Remove(pakcingCode);
+
+ //添加物品信息
+ var itemBasicDto= itemBasicDtos.First(p=>p.Code==detail.ItemCode);
+ detail.ItemName= itemBasicDto.Name;
+ detail.ItemDesc1 = itemBasicDto.Desc1;
+ detail.ItemDesc2= itemBasicDto.Desc2;
+
+ //标包
+ var itemPack = ItemPacks.First(p => p.ItemCode == detail.ItemCode); //todo 一个物品多个包装?怎么取值
+ detail.StdPackQty = itemPack.Qty;
+
+ //供应商物品
+ var supplierItemDto=supplierItemDtos.First(p =>
+ p.ItemCode == detail.ItemCode && p.SupplierCode == supplierAsnEditInput.SupplierCode);
+ detail.SupplierPackQty = supplierItemDto.SupplierPackQty;
+ detail.SupplierPackUom= supplierItemDto.SupplierPackUom;
+ });
+ return supplierAsnEditInput;
}
#endregion
diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Plans/SupplierAsnEventHandler.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Plans/SupplierAsnEventHandler.cs
index b48d6d66a..ba415296d 100644
--- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Plans/SupplierAsnEventHandler.cs
+++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Plans/SupplierAsnEventHandler.cs
@@ -57,9 +57,6 @@ public class SupplierAsnEventHandler
switch (entity.CreateType)
{
case EnumSupplierAsnCreateType.Import:
- //创建采购订单
- await CreatePurchaseOrderAsync(entity).ConfigureAwait(false);
-
//创建标签
await CreateLabelAsync(entity).ConfigureAwait(false);
break;
@@ -72,7 +69,7 @@ public class SupplierAsnEventHandler
}
//创建收货请求(到货通知)
- await CreatePurchaseReceiptRequestAsync(entity).ConfigureAwait(false);
+ //await CreatePurchaseReceiptRequestAsync(entity).ConfigureAwait(false);
}
///
diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/StoreEventAutoMapperProfile.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/StoreEventAutoMapperProfile.cs
index fbe43f51b..45026f517 100644
--- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/StoreEventAutoMapperProfile.cs
+++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/StoreEventAutoMapperProfile.cs
@@ -6,6 +6,11 @@ public partial class StoreEventAutoMapperProfile : Profile
{
public StoreEventAutoMapperProfile()
{
+ #region Orders
+ //采购订单
+ PurchaseOrderAutoMapperProfile();
+ #endregion
+
PurchaseReceiptRequestAutoMapperProfile();
InspectRequestAutoMapperProfile();
BackFlushNoteAutoMapperProfile();
@@ -44,13 +49,9 @@ public partial class StoreEventAutoMapperProfile : Profile
TransferRequestAutoMapperProfile();
TransferNoteAutoMapperProfile();
NoOkConvertOkNoteAutoMapperProfile();
-
ScrapRequestMapperProfile();
-
ProductReceiptRequestMapperProfile();
-
CountAdjustRequestAutoMapperProfile();
-
InventoryInitialNoteAutoMapperProfile();
#region Jobs
diff --git a/build/src/docker/publish/settings/appsettings.Development.json b/build/src/docker/publish/settings/appsettings.Development.json
index 79477a30d..b07d270f1 100644
--- a/build/src/docker/publish/settings/appsettings.Development.json
+++ b/build/src/docker/publish/settings/appsettings.Development.json
@@ -113,13 +113,13 @@
"BaseUrl": "http://dev.ccwin-in.com:21293/"
},
"BaseData": {
- "BaseUrl": "http://dev.ccwin-in.com:59094/"
+ "BaseUrl": "http://dev.ccwin-in.com:21294/"
},
"Default": {
"BaseUrl": "http://dev.ccwin-in.com:21293"
},
"FileStorage": {
- "BaseUrl": "http://dev.ccwin-in.com:59092/"
+ "BaseUrl": "http://dev.ccwin-in.com:21292/"
},
"Inventory": {
"BaseUrl": "http://localhost:59095/"
@@ -128,10 +128,10 @@
"BaseUrl": "http://localhost:59095/"
},
"Label": {
- "BaseUrl": "http://dev.ccwin-in.com:59092/"
+ "BaseUrl": "http://dev.ccwin-in.com:21292/"
},
"Message": {
- "BaseUrl": "http://dev.ccwin-in.com:59092/"
+ "BaseUrl": "http://dev.ccwin-in.com:21292/"
},
"Store": {
"BaseUrl": "http://localhost:59095/"