马昊 2 years ago
parent
commit
8fecc9040f
  1. 2
      be/Hosts/Wms.Host/Win_in.Sfs.Wms.Store.HttpApi.Host/scripts/db.Microsoft.EntityFrameworkCore.SqlServer.StoreDbContext.sql
  2. 2
      be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/WorkCenters/WorkCenter.cs
  3. 30
      be/Modules/Inventory/src/Win_in.Sfs.Wms.Inventory.Event/appsettings.json
  4. 2
      be/Modules/Label/src/Win_in.Sfs.Label.Application.Contracts/InventoryLabels/InventoryLabelEditInput.cs
  5. 15
      be/Modules/Label/src/Win_in.Sfs.Label.Application/InventoryLabels/InventoryLabelAppService.cs
  6. 10
      be/Modules/Label/src/Win_in.Sfs.Label.Application/InventoryLabels/InventoryLabelAutoMapperProfile.cs
  7. 32
      be/Modules/Message/src/Win_in.Sfs.Message.Event/appsettings.json
  8. 22
      be/Modules/Shared/src/Win_in.Sfs.Shared.Application/SfsCrudWithDetailsAppServiceBase.cs
  9. 2
      be/Modules/Shared/src/Win_in.Sfs.Shared.Domain/Interfaces/IHasLocationSwitch.cs
  10. 2
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Orders/PurchaseOrders/DTOs/PurchaseOrderDetailDTO.cs
  11. 2
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Orders/PurchaseOrders/Inputs/PurchaseOrderDetailInput.cs
  12. 16
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Orders/PurchaseOrders/Inputs/PurchaseOrderImportInput.cs
  13. 7
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Plans/SupplierAsns/ISupplierAsnAppService.cs
  14. 12
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Bases/SfsJobAppServiceBase.cs
  15. 23
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Orders/PurchaseOrders/Project/FuWeiDongYang/FuWeiDongYang_PurchaseOrderAppService.cs
  16. 64
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Orders/PurchaseOrders/PurchaseOrderAppService.cs
  17. 12
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Orders/PurchaseOrders/PurchaseOrderAutoMapperProfile.cs
  18. 32
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Plans/SupplierAsns/SupplierAsnAppService.cs
  19. 14
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Requests/PurchaseReceiptRequests/PurchaseReceiptRequestAutoMapperProfile.cs
  20. 4
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Bases/SfsStoreManagerBase.cs
  21. 25
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Bases/SfsStoreRequestManagerBase.cs
  22. 2
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Jobs/InspectJobs/InspectJobManager.cs
  23. 12
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Jobs/SfsJobManagerBase.cs
  24. 2
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Notes/InspectNotes/InspectNoteManager.cs
  25. 2
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Notes/IssueNotes/IssueNoteManager.cs
  26. 4
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Notes/PurchaseReceiptNotes/PurchaseReceiptNoteManager.cs
  27. 2
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Notes/PurchaseReturnNotes/PurchaseReturnNoteManager.cs
  28. 2
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Notes/TransferNotes/TransferNoteManager.cs
  29. 2
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Orders/PurchaseOrders/PurchaseOrderDetail.cs
  30. 2
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Plans/CountPlans/CountPlanManager.cs
  31. 4
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.EntityFrameworkCore/Migrations/20230401163806_Added_AddPurchaseOrder.Designer.cs
  32. 6
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.EntityFrameworkCore/Migrations/20230401163806_Added_AddPurchaseOrder.cs
  33. 4
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.EntityFrameworkCore/Migrations/StoreDbContextModelSnapshot.cs
  34. 3
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/AutoMapperProfiles/Orders/PurchaseOrderAutoMapperProfile.cs
  35. 54
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Orders/PurchaseOrderEventHandler.cs
  36. 236
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Plans/SupplierAsnEventHandler.cs
  37. 3
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Requests/PurchaseReceiptRequestEventHandler.cs

2
be/Hosts/Wms.Host/Win_in.Sfs.Wms.Store.HttpApi.Host/scripts/db.Microsoft.EntityFrameworkCore.SqlServer.StoreDbContext.sql

@ -4159,7 +4159,7 @@ CREATE TABLE [Store_PurchaseOrderDetail] (
[ReceivedQty] decimal(18,6) NOT NULL, [ReceivedQty] decimal(18,6) NOT NULL,
[ReturnedQty] decimal(18,6) NOT NULL, [ReturnedQty] decimal(18,6) NOT NULL,
[PutAwayQty] decimal(18,6) NOT NULL, [PutAwayQty] decimal(18,6) NOT NULL,
[ContactUserCode] nvarchar(max) NULL, [PlanUserCode] nvarchar(max) NULL,
[Lot] nvarchar(max) NULL, [Lot] nvarchar(max) NULL,
[PlanArriveDate] datetime2 NOT NULL, [PlanArriveDate] datetime2 NOT NULL,
[Ctype] nvarchar(max) NULL, [Ctype] nvarchar(max) NULL,

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]

30
be/Modules/Inventory/src/Win_in.Sfs.Wms.Inventory.Event/appsettings.json

@ -1,17 +1,17 @@
{ {
"RabbitMQ": { //"RabbitMQ": {
"Connections": { // "Connections": {
"Default": { // "Default": {
"HostName": "127.0.0.1", // "HostName": "127.0.0.1",
"Port": 5672, // "Port": 5672,
"UserName": "admin", // "UserName": "admin",
"Password": "admin", // "Password": "admin",
"VirtualHost": "my_vhost" // "VirtualHost": "my_vhost"
} // }
}, // },
"EventBus": { // "EventBus": {
"ClientName": "Inventory", // "ClientName": "Inventory",
"ExchangeName": "InventoryMessages" // "ExchangeName": "InventoryMessages"
} // }
} //}
} }

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()

32
be/Modules/Message/src/Win_in.Sfs.Message.Event/appsettings.json

@ -1,20 +1,20 @@
{ {
"RabbitMQ": { //"RabbitMQ": {
"Connections": { // "Connections": {
"Default": { // "Default": {
"HostName": "127.0.0.1", // "HostName": "127.0.0.1",
"Port": 5672, // "Port": 5672,
"UserName": "admin", // "UserName": "admin",
"Password": "admin", // "Password": "admin",
"VirtualHost": "my_vhost" // "VirtualHost": "my_vhost"
} // }
}, // },
"EventBus": { // "EventBus": {
"ClientName": "Store", // "ClientName": "Store",
"ExchangeName": "StoreMessages" // "ExchangeName": "StoreMessages"
} // }
}, //},
"Settings": { "Settings": {
"CreateMessageJob": true "CreateMessageJob": true
} }
} }

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

@ -12,8 +12,10 @@ 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;
@ -329,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;
@ -507,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)
{ {
IList<TImportInput> modelList = null; IList<TImportInput> modelList = null;
@ -552,18 +556,20 @@ public abstract class SfsCrudWithDetailsAppServiceBase<TEntity, TEntityDto, TReq
// 批量更新 // 批量更新
if (entityDict.Any()) if (entityDict.Any())
{ {
entityDict = await ImportProcessingEntityAsync(entityDict); //加工数据
entityDict=await ImportProcessingEntityAsync(entityDict);
// 调用批量验证 // 调用批量验证
var entityListStatus = await ValidateImportEntities(entityDict).ConfigureAwait(false); var entityListStatus = await ValidateImportEntities(entityDict).ConfigureAwait(false);
if (entityListStatus) if (entityListStatus)
{ {
//将需要新增的数据进行发布
var addList = entityDict.Where(p => p.Value == EntityState.Added).Select(p => p.Key).ToList();
//一定要 先发布 在导入 否则没有事务性了 只针对于导入
await PublishCreatedAsync(addList).ConfigureAwait(false);
await SaveImportAsync(entityDict).ConfigureAwait(false); await SaveImportAsync(entityDict).ConfigureAwait(false);
} }
} }
await PublishCreatedAsync(entityDict.Keys.ToList());
// 创建导入报告 // 创建导入报告
var reportFile = ExportImportService.GetImportReport(inputFileBytes, modelDict); var reportFile = ExportImportService.GetImportReport(inputFileBytes, modelDict);
// 创建返回值 // 创建返回值
@ -620,7 +626,7 @@ public abstract class SfsCrudWithDetailsAppServiceBase<TEntity, TEntityDto, TReq
} }
/// <summary> /// <summary>
/// 导入数据后 发布事件 /// 发布新增事件
/// </summary> /// </summary>
/// <param name="entities"></param> /// <param name="entities"></param>
/// <returns></returns> /// <returns></returns>
@ -628,7 +634,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)
{ {
@ -651,6 +657,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();
@ -675,6 +682,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; } // 可以整包存储

2
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Orders/PurchaseOrders/DTOs/PurchaseOrderDetailDTO.cs

@ -85,7 +85,7 @@ public class PurchaseOrderDetailDTO : SfsStoreDetailWithQtyDTOBase
/// 筹措员代码 /// 筹措员代码
/// </summary> /// </summary>
[Display(Name = "明细-筹措员代码")] [Display(Name = "明细-筹措员代码")]
public string ContactUserCode { get; set; } public string PlanUserCode { get; set; }
/// <summary> /// <summary>
/// 生产批次 /// 生产批次

2
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Orders/PurchaseOrders/Inputs/PurchaseOrderDetailInput.cs

@ -66,7 +66,7 @@ public class PurchaseOrderDetailInput : SfsStoreDetailWithQtyInputBase
/// 筹措员代码 /// 筹措员代码
/// </summary> /// </summary>
[Display(Name = "明细-筹措员代码")] [Display(Name = "明细-筹措员代码")]
public string ContactUserCode { get; set; } public string PlanUserCode { get; set; }
/// <summary> /// <summary>
/// 生产批次 /// 生产批次

16
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Orders/PurchaseOrders/Inputs/PurchaseOrderImportInput.cs

@ -21,6 +21,7 @@ public class PurchaseOrderImportInput : SfsStoreImportInputBase
[Display(Name = "采购订单号")] [Display(Name = "采购订单号")]
[Key] [Key]
public string Number { get; set; } public string Number { get; set; }
/// <summary> /// <summary>
/// 供应商代码 /// 供应商代码
/// </summary> /// </summary>
@ -31,7 +32,6 @@ public class PurchaseOrderImportInput : SfsStoreImportInputBase
/// 订单类型 /// 订单类型
/// </summary> /// </summary>
[Display(Name = "订单类型")] [Display(Name = "订单类型")]
public string PoType { get; set; } public string PoType { get; set; }
/// <summary> /// <summary>
@ -68,8 +68,8 @@ public class PurchaseOrderImportInput : SfsStoreImportInputBase
/// 版本 /// 版本
/// </summary> /// </summary>
[Display(Name = "版本")] [Display(Name = "版本")]
public string Version { get; set; } public string Version { get; set; }
/// <summary> /// <summary>
/// 税率 /// 税率
/// </summary> /// </summary>
@ -82,6 +82,7 @@ public class PurchaseOrderImportInput : SfsStoreImportInputBase
/// </summary> /// </summary>
[Display(Name = "仓库代码")] [Display(Name = "仓库代码")]
public string WarehouseCode { get; set; } public string WarehouseCode { get; set; }
/// <summary> /// <summary>
/// 明细-订单行 /// 明细-订单行
/// </summary> /// </summary>
@ -106,6 +107,7 @@ public class PurchaseOrderImportInput : SfsStoreImportInputBase
/// </summary> /// </summary>
[Display(Name = "明细-数量计量单位")] [Display(Name = "明细-数量计量单位")]
public string Uom { get; set; } public string Uom { get; set; }
/// <summary> /// <summary>
/// 明细-标准包装数量 /// 明细-标准包装数量
/// </summary> /// </summary>
@ -133,11 +135,18 @@ public class PurchaseOrderImportInput : SfsStoreImportInputBase
[Required(ErrorMessage = "{0}是必填项")] [Required(ErrorMessage = "{0}是必填项")]
public decimal ConvertRate { get; set; } public decimal ConvertRate { get; set; }
/// <summary>
/// ERP库位
/// </summary>
[Display(Name = "明细-ERP库位")]
[Required(ErrorMessage = "{0}是必填项")]
public string LocationErpCode { get; set; }
/// <summary> /// <summary>
/// 筹措员代码 /// 筹措员代码
/// </summary> /// </summary>
[Display(Name = "明细-筹措员代码")] [Display(Name = "明细-筹措员代码")]
public string ContactUserCode { get; set; } public string PlanUserCode { get; set; }
/// <summary> /// <summary>
/// 生产批次 /// 生产批次
@ -204,5 +213,4 @@ public class PurchaseOrderImportInput : SfsStoreImportInputBase
/// </summary> /// </summary>
[Display(Name = "联系人邮箱")] [Display(Name = "联系人邮箱")]
public string ContactEmail { get; set; } public string ContactEmail { 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);
} }

12
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Bases/SfsJobAppServiceBase.cs

@ -6,6 +6,7 @@ using Microsoft.AspNetCore.Mvc;
using Volo.Abp; using Volo.Abp;
using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Dtos;
using Volo.Abp.Domain.Entities; using Volo.Abp.Domain.Entities;
using Volo.Abp.Uow;
using Volo.Abp.Validation; using Volo.Abp.Validation;
using Win_in.Sfs.Shared.Application; using Win_in.Sfs.Shared.Application;
using Win_in.Sfs.Shared.Application.Contracts; using Win_in.Sfs.Shared.Application.Contracts;
@ -51,6 +52,7 @@ public abstract class SfsJobAppServiceBase<TEntity, TDetail, TEntityDto, TReques
/// <param name="input">任务Input</param> /// <param name="input">任务Input</param>
/// <returns></returns> /// <returns></returns>
[HttpPost("")] [HttpPost("")]
[UnitOfWork]
public override async Task<TEntityDto> CreateAsync(TCreateInput input) public override async Task<TEntityDto> CreateAsync(TCreateInput input)
{ {
var entity = input.ToObject<TEntity>(); var entity = input.ToObject<TEntity>();
@ -66,6 +68,7 @@ public abstract class SfsJobAppServiceBase<TEntity, TDetail, TEntityDto, TReques
/// <param name="inputs">任务Input列表</param> /// <param name="inputs">任务Input列表</param>
/// <returns></returns> /// <returns></returns>
[HttpPost("add-many")] [HttpPost("add-many")]
[UnitOfWork]
public virtual async Task<List<TEntityDto>> CreateManyAsync(List<TCreateInput> inputs) public virtual async Task<List<TEntityDto>> CreateManyAsync(List<TCreateInput> inputs)
{ {
var entities = inputs.ToObject<List<TEntity>>(); var entities = inputs.ToObject<List<TEntity>>();
@ -80,6 +83,7 @@ public abstract class SfsJobAppServiceBase<TEntity, TDetail, TEntityDto, TReques
/// <param name="id"></param> /// <param name="id"></param>
/// <returns></returns> /// <returns></returns>
[HttpPost("cancel/{id}")] [HttpPost("cancel/{id}")]
[UnitOfWork]
public virtual async Task CancelAsync(Guid id) public virtual async Task CancelAsync(Guid id)
{ {
var entity = await GetEntityAsync(id).ConfigureAwait(false); var entity = await GetEntityAsync(id).ConfigureAwait(false);
@ -92,6 +96,7 @@ public abstract class SfsJobAppServiceBase<TEntity, TDetail, TEntityDto, TReques
/// <param name="id"></param> /// <param name="id"></param>
/// <returns></returns> /// <returns></returns>
[HttpPost("accept/{id}")] [HttpPost("accept/{id}")]
[UnitOfWork]
public virtual async Task AcceptAsync(Guid id) public virtual async Task AcceptAsync(Guid id)
{ {
var entity = await GetEntityAsync(id).ConfigureAwait(false); var entity = await GetEntityAsync(id).ConfigureAwait(false);
@ -104,6 +109,7 @@ public abstract class SfsJobAppServiceBase<TEntity, TDetail, TEntityDto, TReques
/// <param name="id"></param> /// <param name="id"></param>
/// <returns></returns> /// <returns></returns>
[HttpPost("open/{id}")] [HttpPost("open/{id}")]
[UnitOfWork]
public virtual async Task OpenAsync(Guid id) public virtual async Task OpenAsync(Guid id)
{ {
var entity = await GetEntityAsync(id).ConfigureAwait(false); var entity = await GetEntityAsync(id).ConfigureAwait(false);
@ -116,6 +122,7 @@ public abstract class SfsJobAppServiceBase<TEntity, TDetail, TEntityDto, TReques
/// <param name="id"></param> /// <param name="id"></param>
/// <returns></returns> /// <returns></returns>
[HttpPost("close/{id}")] [HttpPost("close/{id}")]
[UnitOfWork]
public virtual async Task CloseAsync(Guid id) public virtual async Task CloseAsync(Guid id)
{ {
var entity = await GetEntityAsync(id).ConfigureAwait(false); var entity = await GetEntityAsync(id).ConfigureAwait(false);
@ -128,6 +135,7 @@ public abstract class SfsJobAppServiceBase<TEntity, TDetail, TEntityDto, TReques
/// <param name="id"></param> /// <param name="id"></param>
/// <returns></returns> /// <returns></returns>
[HttpPost("cancel-accept/{id}")] [HttpPost("cancel-accept/{id}")]
[UnitOfWork]
public virtual async Task CancelAcceptAsync(Guid id) public virtual async Task CancelAcceptAsync(Guid id)
{ {
var entity = await GetEntityAsync(id).ConfigureAwait(false); var entity = await GetEntityAsync(id).ConfigureAwait(false);
@ -141,6 +149,7 @@ public abstract class SfsJobAppServiceBase<TEntity, TDetail, TEntityDto, TReques
/// <param name="dto"></param> /// <param name="dto"></param>
/// <returns></returns> /// <returns></returns>
[HttpPost("handle/{id}")] [HttpPost("handle/{id}")]
[UnitOfWork]
public virtual async Task<TEntityDto> CompleteAsync(Guid id, TEntityDto dto) public virtual async Task<TEntityDto> CompleteAsync(Guid id, TEntityDto dto)
{ {
var handleEntity = ObjectMapper.Map<TEntityDto, TEntity>(dto); var handleEntity = ObjectMapper.Map<TEntityDto, TEntity>(dto);
@ -157,6 +166,7 @@ public abstract class SfsJobAppServiceBase<TEntity, TDetail, TEntityDto, TReques
/// <param name="input"></param> /// <param name="input"></param>
/// <returns></returns> /// <returns></returns>
[HttpPost("check")] [HttpPost("check")]
[UnitOfWork]
public virtual async Task CheckAsync(string jobNumber, TEntityDto dto, TCheckInput input) public virtual async Task CheckAsync(string jobNumber, TEntityDto dto, TCheckInput input)
{ {
await Task.CompletedTask.ConfigureAwait(false); await Task.CompletedTask.ConfigureAwait(false);
@ -182,6 +192,7 @@ public abstract class SfsJobAppServiceBase<TEntity, TDetail, TEntityDto, TReques
/// <param name="itemCode"></param> /// <param name="itemCode"></param>
/// <returns></returns> /// <returns></returns>
[HttpGet("check-job-exist-by-packing")] [HttpGet("check-job-exist-by-packing")]
[UnitOfWork]
public virtual async Task<List<TEntityDto>> CheckJobExistByPackingCode(string packingCode, string itemCode) public virtual async Task<List<TEntityDto>> CheckJobExistByPackingCode(string packingCode, string itemCode)
{ {
var entities = await _jobManager.GetWorkingListByPackingAsync(packingCode).ConfigureAwait(false); var entities = await _jobManager.GetWorkingListByPackingAsync(packingCode).ConfigureAwait(false);
@ -196,6 +207,7 @@ public abstract class SfsJobAppServiceBase<TEntity, TDetail, TEntityDto, TReques
/// <param name="itemCode"></param> /// <param name="itemCode"></param>
/// <returns></returns> /// <returns></returns>
[HttpGet("check-job-exist-by-container")] [HttpGet("check-job-exist-by-container")]
[UnitOfWork]
public virtual async Task<List<TEntityDto>> CheckJobExistByContainerCode(string containerCode, string itemCode) public virtual async Task<List<TEntityDto>> CheckJobExistByContainerCode(string containerCode, string itemCode)
{ {
var entities = await _jobManager.GetWorkingListByContainerAsync(containerCode).ConfigureAwait(false); var entities = await _jobManager.GetWorkingListByContainerAsync(containerCode).ConfigureAwait(false);

23
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Orders/PurchaseOrders/Project/FuWeiDongYang/FuWeiDongYang_PurchaseOrderAppService.cs

@ -1,23 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Win_in.Sfs.Basedata.Application.Contracts;
using Win_in.Sfs.Wms.Store.Application;
using Win_in.Sfs.Wms.Store.Application.Contracts;
using Win_in.Sfs.Wms.Store.Domain;
using Win_in.Sfs.Wms.Store.Domain.Shared;
using Win_in.Sfs.Wms.Store.Project;
namespace Win_in.Sfs.Wms.Store.Orders.PurchaseOrders.Project.FuWeiDongYang;
[Route($"{ProjectStoreConsts.RootPath}purchase-order-fuweidongyang")]
public class FuWeiDongYang_PurchaseOrderAppService:PurchaseOrderAppService
{
public FuWeiDongYang_PurchaseOrderAppService(IPurchaseOrderRepository repository, IPurchaseOrderManager purchaseOrderManager, ISupplierAppService supplierAppService) : base(repository, purchaseOrderManager, supplierAppService)
{
}
}

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

@ -3,14 +3,19 @@ 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 Volo.Abp.Users;
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;
@ -28,21 +33,57 @@ public class PurchaseOrderAppService :
private new readonly IPurchaseOrderRepository _repository; private new readonly IPurchaseOrderRepository _repository;
private readonly IPurchaseOrderManager _purchaseOrderManager; private readonly IPurchaseOrderManager _purchaseOrderManager;
private readonly ISupplierAppService _supplierAppService; private readonly ISupplierAppService _supplierAppService;
private readonly IItemBasicAppService _itemBasicAppService;
public PurchaseOrderAppService( public PurchaseOrderAppService(
IPurchaseOrderRepository repository, IPurchaseOrderRepository repository,
IPurchaseOrderManager purchaseOrderManager IPurchaseOrderManager purchaseOrderManager,
, ISupplierAppService supplierAppService ISupplierAppService supplierAppService,
) : base(repository) IItemBasicAppService itemBasicAppService) : base(repository)
{ {
_repository = repository; _repository = repository;
_purchaseOrderManager = purchaseOrderManager; _purchaseOrderManager = purchaseOrderManager;
_supplierAppService = supplierAppService; _supplierAppService = supplierAppService;
_itemBasicAppService = itemBasicAppService;
base.CreatePolicyName = PurchaseOrderPermissions.Create; base.CreatePolicyName = PurchaseOrderPermissions.Create;
base.UpdatePolicyName = PurchaseOrderPermissions.Update; base.UpdatePolicyName = PurchaseOrderPermissions.Update;
base.DeletePolicyName = PurchaseOrderPermissions.Delete; base.DeletePolicyName = PurchaseOrderPermissions.Delete;
} }
#region 东阳使用
/// <summary>
/// 用来重写 导入数据时可以加工数据
/// </summary>
/// <param name="dictionary"></param>
/// <returns></returns>
protected override async Task<Dictionary<PurchaseOrder, EntityState>> ImportProcessingEntityAsync(
Dictionary<PurchaseOrder, EntityState> dictionary)
{
var addList= dictionary.Where(p => p.Value == EntityState.Added).Select(p => p.Key);
foreach (var PurchaseOrder in addList)
{
PurchaseOrder.CreatorId = CurrentUser.Id;
PurchaseOrder.Worker = CurrentUser.Name;
foreach (var detail in PurchaseOrder.Details)
{
var itemBasicDto= await _itemBasicAppService.GetByCodeAsync(detail.ItemCode).ConfigureAwait(false);
detail.ItemName= itemBasicDto.Name;
detail.ItemDesc1 = itemBasicDto.Desc1;
detail.ItemDesc2 = itemBasicDto.Desc2;
}
}
return dictionary;
}
#endregion
/// <summary> /// <summary>
/// 【创建】采购订单 /// 【创建】采购订单
/// </summary> /// </summary>
@ -88,23 +129,6 @@ public class PurchaseOrderAppService :
return ObjectMapper.Map<List<PurchaseOrder>, List<PurchaseOrderDTO>>(entityList); return ObjectMapper.Map<List<PurchaseOrder>, List<PurchaseOrderDTO>>(entityList);
} }
/// <summary>
/// 用来重写 导入数据时可以加工数据
/// </summary>
/// <param name="dictionary"></param>
/// <returns></returns>
protected override Task<Dictionary<PurchaseOrder, EntityState>> ImportProcessingEntityAsync(
Dictionary<PurchaseOrder, EntityState> dictionary)
{
return base.ImportProcessingEntityAsync(dictionary);
}
[HttpPost("{id}/detail")] [HttpPost("{id}/detail")]
public virtual async Task UpdateDetailsAsync(string number, List<PurchaseOrderDetailUpdateInput> inputs) public virtual async Task UpdateDetailsAsync(string number, List<PurchaseOrderDetailUpdateInput> inputs)

12
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()
@ -46,16 +47,13 @@ public partial class StoreApplicationAutoMapperProfile : Profile
.Ignore(x => x.ReceivedQty) .Ignore(x => x.ReceivedQty)
.Ignore(x => x.ReturnedQty) .Ignore(x => x.ReturnedQty)
.Ignore(x => x.PutAwayQty) .Ignore(x => x.PutAwayQty)
.Ignore(x => x.ItemName).Ignore(x => x.ItemDesc1).Ignore(x => x.ItemDesc2) .Ignore(x => x.ItemName)
.Ignore(x => x.LocationErpCode) .Ignore(x => x.ItemDesc1)
.Ignore(x => x.ItemDesc2)
.Ignore(x => x.ProjectCode) .Ignore(x => x.ProjectCode)
.Ignore(x => x.LineStatus) .Ignore(x => x.LineStatus)
.Ignore(x => x.TenantId) .Ignore(x => x.TenantId)
.Ignore(x => x.MasterID) .Ignore(x => x.MasterID)
.Ignore(x => x.ShippedQty)
.Ignore(x => x.ReceivedQty)
.Ignore(x => x.ReturnedQty)
.Ignore(x => x.PutAwayQty)
.Ignore(x => x.Id); .Ignore(x => x.Id);
} }
} }

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

@ -7,6 +7,7 @@ using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Volo.Abp.Uow;
using Win_in.Sfs.Basedata.Application.Contracts; using Win_in.Sfs.Basedata.Application.Contracts;
using Win_in.Sfs.Label.Application.Contracts; using Win_in.Sfs.Label.Application.Contracts;
using Win_in.Sfs.Label.Domain.Shared; using Win_in.Sfs.Label.Domain.Shared;
@ -35,13 +36,12 @@ public class SupplierAsnAppService :
private readonly ISupplierItemAppService _supplierItemAppService; private readonly ISupplierItemAppService _supplierItemAppService;
public SupplierAsnAppService( public SupplierAsnAppService(
ISupplierAsnRepository repository ISupplierAsnRepository repository,
, ISupplierAsnManager supplierAsnManager ISupplierAsnManager supplierAsnManager,
, ISupplierAppService supplierAppService ISupplierAppService supplierAppService,
, IDockAppService dockAppService IDockAppService dockAppService,
, ILabelDefinitionAppService labelDefinitionAppService ILabelDefinitionAppService labelDefinitionAppService,
, ISupplierItemAppService supplierItemAppService ISupplierItemAppService supplierItemAppService) : base(repository)
) : base(repository)
{ {
_repository = repository; _repository = repository;
_supplierAsnManager = supplierAsnManager; _supplierAsnManager = supplierAsnManager;
@ -50,12 +50,16 @@ public class SupplierAsnAppService :
_labelDefinitionAppService = labelDefinitionAppService; _labelDefinitionAppService = labelDefinitionAppService;
_supplierItemAppService = supplierItemAppService; _supplierItemAppService = supplierItemAppService;
} }
#region 东阳使用
/// <summary> /// <summary>
/// 【创建】收货请求 (到货单、到货通知) /// 【创建】收货请求 (到货单、到货通知)
/// </summary> /// </summary>
/// <param name="input"></param> /// <param name="input"></param>
/// <returns></returns> /// <returns></returns>
[HttpPost("")] [HttpPost("")]
[UnitOfWork]
public override async Task<SupplierAsnDTO> CreateAsync(SupplierAsnEditInput input) public override async Task<SupplierAsnDTO> CreateAsync(SupplierAsnEditInput input)
{ {
var inputEntity = ObjectMapper.Map<SupplierAsnEditInput, SupplierAsn>(input); var inputEntity = ObjectMapper.Map<SupplierAsnEditInput, SupplierAsn>(input);
@ -65,6 +69,20 @@ public class SupplierAsnAppService :
return ObjectMapper.Map<SupplierAsn, SupplierAsnDTO>(resultEntity); return ObjectMapper.Map<SupplierAsn, SupplierAsnDTO>(resultEntity);
} }
#endregion
/// <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);

14
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Requests/PurchaseReceiptRequests/PurchaseReceiptRequestAutoMapperProfile.cs

@ -42,5 +42,19 @@ public partial class StoreApplicationAutoMapperProfile : Profile
.Ignore(x => x.CreatorId) .Ignore(x => x.CreatorId)
.Ignore(x => x.TenantId) .Ignore(x => x.TenantId)
.Ignore(x => x.Id); .Ignore(x => x.Id);
CreateMap<PurchaseReceiptRequestEditInput, PurchaseReceiptRequest>()
.IgnoreAuditedObjectProperties()
.Ignore(x => x.ExtraProperties)
.Ignore(x => x.ConcurrencyStamp)
.Ignore(x => x.Id)
.Ignore(x => x.TenantId)
;
CreateMap<PurchaseReceiptRequestDetailInput, PurchaseReceiptRequestDetail>()
.IgnoreAuditedObjectProperties()
.Ignore(x => x.Id)
.Ignore(x => x.TenantId)
;
} }
} }

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)
{ {

25
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Bases/SfsStoreRequestManagerBase.cs

@ -25,6 +25,7 @@ public abstract class SfsStoreRequestManagerBase<TEntity, TDetailEntity>
/// </summary> /// </summary>
/// <param name="entity"></param> /// <param name="entity"></param>
/// <returns></returns> /// <returns></returns>
[UnitOfWork]
public override async Task<TEntity> CreateAsync(TEntity entity) public override async Task<TEntity> CreateAsync(TEntity entity)
{ {
entity.SetIdAndNumberWithDetails(GuidGenerator, await GenerateNumberAsync(typeof(TEntity).Name, entity.ActiveDate).ConfigureAwait(false)); entity.SetIdAndNumberWithDetails(GuidGenerator, await GenerateNumberAsync(typeof(TEntity).Name, entity.ActiveDate).ConfigureAwait(false));
@ -40,6 +41,7 @@ public abstract class SfsStoreRequestManagerBase<TEntity, TDetailEntity>
} }
} }
[UnitOfWork]
public override async Task<List<TEntity>> CreateManyAsync(List<TEntity> entities) public override async Task<List<TEntity>> CreateManyAsync(List<TEntity> entities)
{ {
var results = new List<TEntity>(); var results = new List<TEntity>();
@ -83,11 +85,12 @@ public abstract class SfsStoreRequestManagerBase<TEntity, TDetailEntity>
} }
} }
[UnitOfWork]
private async Task PublishSubmittedAsync(TEntity entity) private async Task PublishSubmittedAsync(TEntity entity)
{ {
try try
{ {
await LocalEventBus.PublishAsync(new SfsSubmittedEntityEventData<TEntity>(entity)).ConfigureAwait(false); await LocalEventBus.PublishAsync(new SfsSubmittedEntityEventData<TEntity>(entity),false).ConfigureAwait(false);
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -118,11 +121,12 @@ public abstract class SfsStoreRequestManagerBase<TEntity, TDetailEntity>
} }
} }
[UnitOfWork]
private async Task PublishAgreedAsync(TEntity entity) private async Task PublishAgreedAsync(TEntity entity)
{ {
try try
{ {
await LocalEventBus.PublishAsync(new SfsAgreedEntityEventData<TEntity>(entity)).ConfigureAwait(false); await LocalEventBus.PublishAsync(new SfsAgreedEntityEventData<TEntity>(entity),false).ConfigureAwait(false);
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -146,11 +150,12 @@ public abstract class SfsStoreRequestManagerBase<TEntity, TDetailEntity>
return await Repository.UpdateAsync(entity).ConfigureAwait(false); return await Repository.UpdateAsync(entity).ConfigureAwait(false);
} }
[UnitOfWork]
private async Task PublishRefusedAsync(TEntity entity) private async Task PublishRefusedAsync(TEntity entity)
{ {
try try
{ {
await LocalEventBus.PublishAsync(new SfsRefusedEntityEventData<TEntity>(entity)).ConfigureAwait(false); await LocalEventBus.PublishAsync(new SfsRefusedEntityEventData<TEntity>(entity),false).ConfigureAwait(false);
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -174,11 +179,12 @@ public abstract class SfsStoreRequestManagerBase<TEntity, TDetailEntity>
return await AddOrUpdateAsync(entity).ConfigureAwait(false); return await AddOrUpdateAsync(entity).ConfigureAwait(false);
} }
[UnitOfWork]
protected virtual async Task PublishHandledAsync(TEntity entity) protected virtual async Task PublishHandledAsync(TEntity entity)
{ {
try try
{ {
await LocalEventBus.PublishAsync(new SfsHandledEntityEventData<TEntity>(entity)).ConfigureAwait(false); await LocalEventBus.PublishAsync(new SfsHandledEntityEventData<TEntity>(entity), false).ConfigureAwait(false);
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -197,11 +203,12 @@ public abstract class SfsStoreRequestManagerBase<TEntity, TDetailEntity>
return await Repository.UpdateAsync(entity).ConfigureAwait(false); return await Repository.UpdateAsync(entity).ConfigureAwait(false);
} }
[UnitOfWork]
private async Task PublishCompletedAsync(TEntity entity) private async Task PublishCompletedAsync(TEntity entity)
{ {
try try
{ {
await LocalEventBus.PublishAsync(new SfsCompletedEntityEventData<TEntity>(entity)).ConfigureAwait(false); await LocalEventBus.PublishAsync(new SfsCompletedEntityEventData<TEntity>(entity), false).ConfigureAwait(false);
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -220,11 +227,12 @@ public abstract class SfsStoreRequestManagerBase<TEntity, TDetailEntity>
return await Repository.UpdateAsync(entity).ConfigureAwait(false); return await Repository.UpdateAsync(entity).ConfigureAwait(false);
} }
[UnitOfWork]
private async Task PublishCancelledAsync(TEntity entity) private async Task PublishCancelledAsync(TEntity entity)
{ {
try try
{ {
await LocalEventBus.PublishAsync(new SfsCancelledEntityEventData<TEntity>(entity)).ConfigureAwait(false); await LocalEventBus.PublishAsync(new SfsCancelledEntityEventData<TEntity>(entity), false).ConfigureAwait(false);
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -235,6 +243,7 @@ public abstract class SfsStoreRequestManagerBase<TEntity, TDetailEntity>
} }
} }
[UnitOfWork]
public virtual async Task<TEntity> AbortAsync(TEntity entity) public virtual async Task<TEntity> AbortAsync(TEntity entity)
{ {
entity.Abort(); entity.Abort();
@ -242,11 +251,12 @@ public abstract class SfsStoreRequestManagerBase<TEntity, TDetailEntity>
return await Repository.UpdateAsync(entity).ConfigureAwait(false); return await Repository.UpdateAsync(entity).ConfigureAwait(false);
} }
[UnitOfWork]
private async Task PublishAbortedAsync(TEntity entity) private async Task PublishAbortedAsync(TEntity entity)
{ {
try try
{ {
await LocalEventBus.PublishAsync(new SfsAbortedEntityEventData<TEntity>(entity)).ConfigureAwait(false); await LocalEventBus.PublishAsync(new SfsAbortedEntityEventData<TEntity>(entity), false).ConfigureAwait(false);
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -257,6 +267,7 @@ public abstract class SfsStoreRequestManagerBase<TEntity, TDetailEntity>
} }
} }
[UnitOfWork]
protected async Task<TEntity> AddOrUpdateAsync(TEntity entity) protected async Task<TEntity> AddOrUpdateAsync(TEntity entity)
{ {
var isExist = await Repository.AnyAsync(p => p.Id == entity.Id).ConfigureAwait(false); var isExist = await Repository.AnyAsync(p => p.Id == entity.Id).ConfigureAwait(false);

2
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Jobs/InspectJobs/InspectJobManager.cs

@ -174,7 +174,7 @@ public class InspectJobManager : SfsJobManagerBase<InspectJob, InspectJobDetail>
#endregion #endregion
await LocalEventBus.PublishAsync(new SfsUpdateEntitySummaryDetailEventData<InspectJob>(CopyJob)).ConfigureAwait(false); await LocalEventBus.PublishAsync(new SfsUpdateEntitySummaryDetailEventData<InspectJob>(CopyJob),false).ConfigureAwait(false);
return summaryDetailEntity; return summaryDetailEntity;
} }

12
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Jobs/SfsJobManagerBase.cs

@ -288,7 +288,7 @@ public abstract class SfsJobManagerBase<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)
{ {
@ -302,7 +302,7 @@ public abstract class SfsJobManagerBase<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)
{ {
@ -316,7 +316,7 @@ public abstract class SfsJobManagerBase<TEntity, TDetailEntity>
{ {
try try
{ {
await LocalEventBus.PublishAsync(new SfsCompletedEntityEventData<TEntity>(entity)).ConfigureAwait(false); await LocalEventBus.PublishAsync(new SfsCompletedEntityEventData<TEntity>(entity), false).ConfigureAwait(false);
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -330,7 +330,7 @@ public abstract class SfsJobManagerBase<TEntity, TDetailEntity>
{ {
try try
{ {
await LocalEventBus.PublishAsync(new SfsCancelledEntityEventData<TEntity>(entity)).ConfigureAwait(false); await LocalEventBus.PublishAsync(new SfsCancelledEntityEventData<TEntity>(entity), false).ConfigureAwait(false);
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -344,7 +344,7 @@ public abstract class SfsJobManagerBase<TEntity, TDetailEntity>
{ {
try try
{ {
await LocalEventBus.PublishAsync(new SfsOpenedEntityEventData<TEntity>(entity)).ConfigureAwait(false); await LocalEventBus.PublishAsync(new SfsOpenedEntityEventData<TEntity>(entity), false).ConfigureAwait(false);
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -358,7 +358,7 @@ public abstract class SfsJobManagerBase<TEntity, TDetailEntity>
{ {
try try
{ {
await LocalEventBus.PublishAsync(new SfsClosedEntityEventData<TEntity>(entity)).ConfigureAwait(false); await LocalEventBus.PublishAsync(new SfsClosedEntityEventData<TEntity>(entity), false).ConfigureAwait(false);
} }
catch (Exception ex) catch (Exception ex)
{ {

2
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Notes/InspectNotes/InspectNoteManager.cs

@ -54,7 +54,7 @@ public class InspectNoteManager : SfsStoreManagerBase<InspectNote, InspectNoteDe
inspectNote.Worker = entity.Worker; inspectNote.Worker = entity.Worker;
await Repository.UpdateAsync(entity).ConfigureAwait(false); await Repository.UpdateAsync(entity).ConfigureAwait(false);
await LocalEventBus.PublishAsync(new SfsUpdateEntityDetailEventData<InspectNote>(inspectNote)).ConfigureAwait(false); await LocalEventBus.PublishAsync(new SfsUpdateEntityDetailEventData<InspectNote>(inspectNote), false).ConfigureAwait(false);
return entity; return entity;
} }

2
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Notes/IssueNotes/IssueNoteManager.cs

@ -30,7 +30,7 @@ public class IssueNoteManager : SfsStoreManagerBase<IssueNote, IssueNoteDetail>,
{ {
try try
{ {
await LocalEventBus.PublishAsync(new SfsConfirmedEntityEventData<IssueNote>(entity)).ConfigureAwait(false); await LocalEventBus.PublishAsync(new SfsConfirmedEntityEventData<IssueNote>(entity), false).ConfigureAwait(false);
} }
catch (Exception ex) catch (Exception ex)
{ {

4
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Notes/PurchaseReceiptNotes/PurchaseReceiptNoteManager.cs

@ -53,7 +53,7 @@ public class PurchaseReceiptNoteManager : SfsStoreManagerBase<PurchaseReceiptNot
}; };
try try
{ {
await LocalEventBus.PublishAsync(purchaseReceiptNoteAddDetailEventData).ConfigureAwait(false); await LocalEventBus.PublishAsync(purchaseReceiptNoteAddDetailEventData, false).ConfigureAwait(false);
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -73,7 +73,7 @@ public class PurchaseReceiptNoteManager : SfsStoreManagerBase<PurchaseReceiptNot
}; };
try try
{ {
await LocalEventBus.PublishAsync(purchaseReceiptNoteAddDetailEventData).ConfigureAwait(false); await LocalEventBus.PublishAsync(purchaseReceiptNoteAddDetailEventData, false).ConfigureAwait(false);
} }
catch (Exception ex) catch (Exception ex)
{ {

2
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Notes/PurchaseReturnNotes/PurchaseReturnNoteManager.cs

@ -26,7 +26,7 @@ public class PurchaseReturnNoteManager : SfsStoreManagerBase<PurchaseReturnNote,
}; };
try try
{ {
await LocalEventBus.PublishAsync(purchaseReceiptNoteAddDetailEventData).ConfigureAwait(false); await LocalEventBus.PublishAsync(purchaseReceiptNoteAddDetailEventData, false).ConfigureAwait(false);
} }
catch (Exception ex) catch (Exception ex)
{ {

2
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Notes/TransferNotes/TransferNoteManager.cs

@ -34,7 +34,7 @@ public class TransferNoteManager : SfsStoreManagerBase<TransferNote, TransferNot
{ {
try try
{ {
await LocalEventBus.PublishAsync(new SfsConfirmedEntityEventData<TransferNote>(entity)).ConfigureAwait(false); await LocalEventBus.PublishAsync(new SfsConfirmedEntityEventData<TransferNote>(entity), false).ConfigureAwait(false);
} }
catch (Exception ex) catch (Exception ex)
{ {

2
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Orders/PurchaseOrders/PurchaseOrderDetail.cs

@ -72,7 +72,7 @@ public class PurchaseOrderDetail : SfsStoreDetailWithQtyEntityBase
/// 筹措员代码 /// 筹措员代码
/// </summary> /// </summary>
[Display(Name = "明细-筹措员代码")] [Display(Name = "明细-筹措员代码")]
public string ContactUserCode { get; set; } public string PlanUserCode { get; set; }
/// <summary> /// <summary>
/// 生产批次 /// 生产批次

2
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Plans/CountPlans/CountPlanManager.cs

@ -75,7 +75,7 @@ public class CountPlanManager : SfsStoreRequestManagerBase<CountPlan, CountPlanD
{ {
try try
{ {
await LocalEventBus.PublishAsync(new SfsStageChangedEntityEventData<CountPlan>(entity)).ConfigureAwait(false); await LocalEventBus.PublishAsync(new SfsStageChangedEntityEventData<CountPlan>(entity), false).ConfigureAwait(false);
} }
catch (Exception ex) catch (Exception ex)
{ {

4
be/Modules/Store/src/Win_in.Sfs.Wms.Store.EntityFrameworkCore/Migrations/20230401163806_Added_AddPurchaseOrder.Designer.cs

@ -1,4 +1,4 @@
// <auto-generated /> // <auto-generated />
using System; using System;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Infrastructure;
@ -12461,7 +12461,7 @@ namespace Win_in.Sfs.Wms.Store.Migrations
b.Property<Guid>("Id") b.Property<Guid>("Id")
.HasColumnType("uniqueidentifier"); .HasColumnType("uniqueidentifier");
b.Property<string>("ContactUserCode") b.Property<string>("PlanUserCode")
.HasColumnType("nvarchar(max)"); .HasColumnType("nvarchar(max)");
b.Property<decimal>("ConvertRate") b.Property<decimal>("ConvertRate")

6
be/Modules/Store/src/Win_in.Sfs.Wms.Store.EntityFrameworkCore/Migrations/20230401163806_Added_AddPurchaseOrder.cs

@ -1,4 +1,4 @@
using System; using System;
using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable #nullable disable
@ -1856,7 +1856,7 @@ namespace Win_in.Sfs.Wms.Store.Migrations
oldNullable: true); oldNullable: true);
migrationBuilder.AddColumn<string>( migrationBuilder.AddColumn<string>(
name: "ContactUserCode", name: "PlanUserCode",
table: "Store_PurchaseOrderDetail", table: "Store_PurchaseOrderDetail",
type: "nvarchar(max)", type: "nvarchar(max)",
nullable: true); nullable: true);
@ -4337,7 +4337,7 @@ namespace Win_in.Sfs.Wms.Store.Migrations
table: "Store_PurchaseReceiptNoteDetail"); table: "Store_PurchaseReceiptNoteDetail");
migrationBuilder.DropColumn( migrationBuilder.DropColumn(
name: "ContactUserCode", name: "PlanUserCode",
table: "Store_PurchaseOrderDetail"); table: "Store_PurchaseOrderDetail");
migrationBuilder.DropColumn( migrationBuilder.DropColumn(

4
be/Modules/Store/src/Win_in.Sfs.Wms.Store.EntityFrameworkCore/Migrations/StoreDbContextModelSnapshot.cs

@ -1,4 +1,4 @@
// <auto-generated /> // <auto-generated />
using System; using System;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Infrastructure;
@ -12459,7 +12459,7 @@ namespace Win_in.Sfs.Wms.Store.Migrations
b.Property<Guid>("Id") b.Property<Guid>("Id")
.HasColumnType("uniqueidentifier"); .HasColumnType("uniqueidentifier");
b.Property<string>("ContactUserCode") b.Property<string>("PlanUserCode")
.HasColumnType("nvarchar(max)"); .HasColumnType("nvarchar(max)");
b.Property<decimal>("ConvertRate") b.Property<decimal>("ConvertRate")

3
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/AutoMapperProfiles/Orders/PurchaseOrderAutoMapperProfile.cs

@ -33,12 +33,11 @@ public partial class StoreEventAutoMapperProfile : Profile
CreateMap<PurchaseOrderDetail, SupplierAsnDetailInput>() CreateMap<PurchaseOrderDetail, SupplierAsnDetailInput>()
.Ignore(x => x.PoNumber) .Ignore(x => x.PoNumber)
.Ignore(x => x.RecommendErpCode)
.Ignore(x => x.PlanUserCode)
.Ignore(x => x.PackingCode) .Ignore(x => x.PackingCode)
.Ignore(x => x.ContainerCode) .Ignore(x => x.ContainerCode)
.Ignore(x => x.SupplierBatch) .Ignore(x => x.SupplierBatch)
.Ignore(x => x.ArriveDate) .Ignore(x => x.ArriveDate)
.Ignore(x=>x.RecommendErpCode)
; ;
#endregion #endregion

54
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,21 @@ 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;
private readonly ISupplierTimeWindowAppService _supplierTimeWindowAppService;
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,
ISupplierTimeWindowAppService supplierTimeWindowAppService)
{ {
_supplierAsnAppService = supplierAsnAppService; _supplierAsnAppService = supplierAsnAppService;
_labelDefinitionAppService = labelDefinitionAppService; _labelDefinitionAppService = labelDefinitionAppService;
@ -41,6 +54,9 @@ public class PurchaseOrderEventHandler
_itemPackAppService = itemPackAppService; _itemPackAppService = itemPackAppService;
_supplierItemAppService = supplierItemAppService; _supplierItemAppService = supplierItemAppService;
_dockAppService = dockAppService; _dockAppService = dockAppService;
_inventoryLabelAppService = inventoryLabelAppService;
_supplierAppService = supplierAppService;
_supplierTimeWindowAppService = supplierTimeWindowAppService;
} }
//创建采购订单 //创建采购订单
@ -81,19 +97,30 @@ 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;
//赋值采购订单编号
supplierAsnEditInput.PoNumber = purchaseOrder.Number;
//要货单号 //要货单号
supplierAsnEditInput.RpNumber = "无"; supplierAsnEditInput.RpNumber = "无";
//创建方式 //todo 后期修改为 采购订单中的参数
supplierAsnEditInput.CreateType = EnumSupplierAsnCreateType.Import;
//供应商时间窗口
var supplierTimeWindowDtos=await _supplierTimeWindowAppService.GetListBySupplierCodeAsync(purchaseOrder.SupplierCode).ConfigureAwait(false);
var dayOfWeek = new List<string>() { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
var chineseWeek= dayOfWeek[Clock.Now.DayOfWeek.GetHashCode()]; //中文星期
var dateTimeWindowDto=supplierTimeWindowDtos.First(p => p.Week == chineseWeek);
supplierAsnEditInput.TimeWindow = dateTimeWindowDto.TimeSlot;
//生效日期 //生效日期
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 +130,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);
@ -115,8 +147,10 @@ public class PurchaseOrderEventHandler
//赋值 详情表 //赋值 详情表
supplierAsnEditInput.Details.ForEach(detail => supplierAsnEditInput.Details.ForEach(detail =>
{ {
var purchaseOrderDetail= purchaseOrder.Details.First(p => p.ItemCode == detail.ItemCode);
//添加箱码 //添加箱码
var pakcingCode=generateManyAsync.First(); var pakcingCode = generateManyAsync.First();
detail.PackingCode = pakcingCode; detail.PackingCode = pakcingCode;
generateManyAsync.Remove(pakcingCode); generateManyAsync.Remove(pakcingCode);
@ -135,6 +169,12 @@ public class PurchaseOrderEventHandler
p.ItemCode == detail.ItemCode && p.SupplierCode == supplierAsnEditInput.SupplierCode); p.ItemCode == detail.ItemCode && p.SupplierCode == supplierAsnEditInput.SupplierCode);
detail.SupplierPackQty = supplierItemDto.SupplierPackQty; detail.SupplierPackQty = supplierItemDto.SupplierPackQty;
detail.SupplierPackUom= supplierItemDto.SupplierPackUom; detail.SupplierPackUom= supplierItemDto.SupplierPackUom;
//订单行
detail.PoLine = purchaseOrderDetail.PoLine;
//推荐ERP库位
detail.RecommendErpCode = purchaseOrderDetail.LocationErpCode;
}); });
return supplierAsnEditInput; return supplierAsnEditInput;

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

@ -13,6 +13,7 @@ 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;
using static Win_in.Sfs.Wms.Store.Domain.Shared.StoreSettings;
using SupplierAsn = Win_in.Sfs.Wms.Store.Domain.SupplierAsn; using SupplierAsn = Win_in.Sfs.Wms.Store.Domain.SupplierAsn;
namespace Win_in.Sfs.Wms.Store.Event.Stores; namespace Win_in.Sfs.Wms.Store.Event.Stores;
@ -54,22 +55,11 @@ public class SupplierAsnEventHandler
{ {
var entity = eventData.Entity; var entity = eventData.Entity;
switch (entity.CreateType) //更新采购订单收货数量
{ await UpdatePurchaseOrderAsync(entity).ConfigureAwait(false);
case EnumSupplierAsnCreateType.Import:
//创建标签
await CreateLabelAsync(entity).ConfigureAwait(false);
break;
case EnumSupplierAsnCreateType.AppService:
case EnumSupplierAsnCreateType.ExternalInterface:
default:
//更新订单已收货数量
await UpdatePurchaseOrderAsync(entity).ConfigureAwait(false);
break;
}
//创建收货请求(到货通知) //创建收货请求(到货通知)
//await CreatePurchaseReceiptRequestAsync(entity).ConfigureAwait(false); await CreatePurchaseReceiptRequestAsync(entity).ConfigureAwait(false);
} }
/// <summary> /// <summary>
@ -84,23 +74,8 @@ public class SupplierAsnEventHandler
foreach (var supplierAsn in entityList) foreach (var supplierAsn in entityList)
{ {
switch (supplierAsn.CreateType) //更新采购订单收货数量
{ await UpdatePurchaseOrderAsync(supplierAsn).ConfigureAwait(false);
case EnumSupplierAsnCreateType.Import:
//创建采购订单
await CreatePurchaseOrderAsync(supplierAsn).ConfigureAwait(false);
//创建标签
await CreateLabelAsync(supplierAsn).ConfigureAwait(false);
break;
case EnumSupplierAsnCreateType.AppService:
case EnumSupplierAsnCreateType.ExternalInterface:
default:
//更新订单已收货数量
await UpdatePurchaseOrderAsync(supplierAsn).ConfigureAwait(false);
break;
}
//创建收货请求(到货通知) //创建收货请求(到货通知)
await CreatePurchaseReceiptRequestAsync(supplierAsn).ConfigureAwait(false); await CreatePurchaseReceiptRequestAsync(supplierAsn).ConfigureAwait(false);
@ -109,12 +84,7 @@ public class SupplierAsnEventHandler
#region 私有 #region 私有
#region 收货请求 // 创建 收货请求(到货通知)
/// <summary>
/// 创建 收货请求(到货通知)
/// </summary>
/// <param name="supplierAsn"></param>
private async Task CreatePurchaseReceiptRequestAsync(SupplierAsn supplierAsn) private async Task CreatePurchaseReceiptRequestAsync(SupplierAsn supplierAsn)
{ {
//开关控制 创建收货请求(到货通知) //开关控制 创建收货请求(到货通知)
@ -126,205 +96,33 @@ public class SupplierAsnEventHandler
} }
} }
/// <summary> // 构造 收货请求
/// 构造 收货请求
/// </summary>
/// <param name="supplierAsn"></param>
/// <returns></returns>
private PurchaseReceiptRequestEditInput BuildPurchaseReceiptRequestCreateInput(SupplierAsn supplierAsn) private PurchaseReceiptRequestEditInput BuildPurchaseReceiptRequestCreateInput(SupplierAsn supplierAsn)
{ {
var input = ObjectMapper.Map<SupplierAsn, PurchaseReceiptRequestEditInput>(supplierAsn); var input = ObjectMapper.Map<SupplierAsn, PurchaseReceiptRequestEditInput>(supplierAsn);
return input; return input;
} }
#endregion // 更新采购订单中的发货数量
private async Task UpdatePurchaseOrderAsync(SupplierAsn entity)
#region 采购订单
/// <summary>
/// 创建 采购订单
/// </summary>
/// <param name="supplierAsn"></param>
private async Task<PurchaseOrderDTO> CreatePurchaseOrderAsync(SupplierAsn supplierAsn)
{
//开关控制 创建采购订单
if (await SettingManager.IsTrueAsync(StoreSettings.SupplierAsn.AutoCreatePurchaseOrder).ConfigureAwait(false))
{
var createInput = await BulidPurchaseOrderAsync(supplierAsn).ConfigureAwait(false);
return await _purchaseOrderAppService.CreateAsync(createInput).ConfigureAwait(false);
}
return null;
}
/// <summary>
/// 构造 采购订单
/// </summary>
/// <param name="inputEntity"></param>
/// <returns></returns>
private async Task<PurchaseOrderEditInput> BulidPurchaseOrderAsync(SupplierAsn inputEntity)
{ {
await Task.CompletedTask.ConfigureAwait(false); var purchaseOrderDetailUpdateInputs = new List<PurchaseOrderDetailUpdateInput>();
//创建采购订单
var purchaseOrderCreateInput = ObjectMapper.Map<SupplierAsn, PurchaseOrderEditInput>(inputEntity);
var group = inputEntity.Details.GroupBy(p => new { p.ItemCode, p.RecommendErpCode, p.PoLine, p.ProjectCode }); foreach (var detail in entity.Details)
foreach (var groupKey in group)
{ {
//样板数据 var purchaseOrderDetailUpdateInput=new PurchaseOrderDetailUpdateInput()
var templateData = inputEntity.Details.First(p =>
groupKey.Key.ItemCode == p.ItemCode &&
groupKey.Key.RecommendErpCode == p.RecommendErpCode &&
p.PoLine == groupKey.Key.PoLine &&
p.ProjectCode == groupKey.Key.ProjectCode);
//汇总数量
var sumQty = inputEntity.Details.Where(p =>
groupKey.Key.ItemCode == p.ItemCode &&
groupKey.Key.RecommendErpCode == p.RecommendErpCode &&
p.PoLine == groupKey.Key.PoLine &&
p.ProjectCode == groupKey.Key.ProjectCode)
.Sum(p => p.Qty);
//创建明细
var purchaseOrderDetailInput = new PurchaseOrderDetailInput()
{ {
ItemCode = groupKey.Key.ItemCode, PoLine = detail.PoLine,
Qty = sumQty, ItemCode = detail.ItemCode,
Uom = templateData.Uom, ShippedQty = detail.Qty,
ItemName = templateData.ItemName,
Remark = templateData.Remark,
ItemDesc2 = templateData.ItemDesc2,
ItemDesc1 = templateData.ItemDesc1,
LocationErpCode = groupKey.Key.RecommendErpCode,
StdPackQty = templateData.StdPackQty,
ConvertRate = 0,
IsConsignment = true,
LineStatus = EnumOrderStatus.Open,
PoLine = templateData.PoLine,
ProjectCode = templateData.ProjectCode,
SupplierPackQty = templateData.SupplierPackQty,
SupplierPackUom = templateData.SupplierPackUom,
ShippedQty = sumQty,
}; };
purchaseOrderCreateInput.Details.Add(purchaseOrderDetailInput); purchaseOrderDetailUpdateInputs.Add(purchaseOrderDetailUpdateInput);
}
return purchaseOrderCreateInput;
}
#endregion
#region 创建标签
/// <summary>
/// 创建 采购收货标签
/// </summary>
/// <returns></returns>
private async Task<List<InventoryLabelDto>> CreateLabelAsync(SupplierAsn supplierAsn)
{
List<InventoryLabelDto> inventoryLabelDtos = new List<InventoryLabelDto>();
foreach (var supplierAsnDetail in supplierAsn.Details)
{
var inputLabel = await BuildInventoryLabelCreateInputAsync(supplierAsn, supplierAsnDetail).ConfigureAwait(false);
var labelDto = await _inventoryLabelService.CreateAsync(inputLabel).ConfigureAwait(false);
inventoryLabelDtos.Add(labelDto);
}
return inventoryLabelDtos;
}
/// <summary>
/// 创建 构造标签
/// </summary>
/// <param name="supplierAsn"></param>
/// <param name="supplierAsnDetail"></param>
/// <returns></returns>
private async Task<InventoryLabelEditInput> BuildInventoryLabelCreateInputAsync(SupplierAsn supplierAsn, SupplierAsnDetail supplierAsnDetail)
{
var itemDto = await ItemBasicAclService.GetByCodeAsync(supplierAsnDetail.ItemCode).ConfigureAwait(false);
var supplierItem =
await _supplierItemAppService.GetBySupplierCodeAndItemCodeAsync(supplierAsn.SupplierCode,
itemDto.Code).ConfigureAwait(false);
var supplier = await _supplierAppService.GetByCodeAsync(supplierAsn.SupplierCode).ConfigureAwait(false);
if (itemDto == null)
{
throw new UserFriendlyException($"{supplierAsnDetail.ItemCode}零件信息为空");
}
if (supplier == null)
{
throw new UserFriendlyException($"{supplierAsn.SupplierCode}供应商为空");
}
if (supplierItem == null)
{
throw new UserFriendlyException($"{supplierAsn.SupplierCode}供应商零件或{itemDto.Code}零件信息为空");
} }
var inputLabel = new InventoryLabelEditInput()
{
LabelType = EnumLabelType.PurchaseLabel,
ArriveDate = DateTime.Now,
Qty = supplierAsnDetail.Qty,
PoNumber = supplierAsnDetail.PoNumber,
Uom = supplierAsnDetail.Uom,
ItemDesc2 = itemDto.Desc2,
AsnNumber = supplierAsnDetail.Number,
ItemCode = supplierAsnDetail.ItemCode,
ItemName = supplierAsnDetail.ItemName,
ItemDesc1 = itemDto.Desc1,
SupplierBatch = supplierAsnDetail.SupplierBatch,
ProduceDate = supplierAsnDetail.ProduceDate,
ExpireDate = DateTime.Now.AddDays(itemDto.GetValidateDays()),
FullBarcodeString = supplierAsnDetail.PackingCode,
ExtraProperties = { },
LabelStatus = LabelStatus.Enable,
LocationErpCode = supplierAsnDetail.RecommendErpCode,
Lot = supplierAsnDetail.Lot,
RecommendLocationCode = supplierAsnDetail.RecommendErpCode,
Remark = supplierAsnDetail.Remark,
Specifications = itemDto.Color,
StdPackQty = supplierAsnDetail.StdPackQty,
SupplierCode = supplierAsn.SupplierCode,
SupplierItemCode = supplierItem.SupplierItemCode,
SupplierItemName = supplierItem.ItemName,
SupplierName = supplier.Name,
SupplierSimpleName = supplier.ShortName,
Team = null,
ProdLine = null,
QLevel = null,
QualityFile = null,
RpNumber = null,
Shift = null,
ContainerCode = null,
Code = supplierAsnDetail.PackingCode
};
return inputLabel;
}
#endregion
private async Task UpdatePurchaseOrderAsync(SupplierAsn entity)
{
var purchaseOrderDetailUpdateInputs = entity.Details
.Select(BuildPurchaseOrderDetailUpdateInput).ToList();
await _purchaseOrderAppService.UpdateDetailsAsync(entity.PoNumber, purchaseOrderDetailUpdateInputs).ConfigureAwait(false); await _purchaseOrderAppService.UpdateDetailsAsync(entity.PoNumber, purchaseOrderDetailUpdateInputs).ConfigureAwait(false);
} }
private static PurchaseOrderDetailUpdateInput BuildPurchaseOrderDetailUpdateInput(SupplierAsnDetail supplierAsnDetail)
{
return new PurchaseOrderDetailUpdateInput()
{
PoLine = supplierAsnDetail.PoLine,
ItemCode = supplierAsnDetail.ItemCode,
ShippedQty = supplierAsnDetail.Qty,
};
}
#endregion #endregion
} }

3
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Requests/PurchaseReceiptRequestEventHandler.cs

@ -4,6 +4,7 @@ using System.Threading.Tasks;
using Volo.Abp; using Volo.Abp;
using Volo.Abp.EventBus; using Volo.Abp.EventBus;
using Volo.Abp.SettingManagement; using Volo.Abp.SettingManagement;
using Volo.Abp.Uow;
using Win_in.Sfs.Basedata.Application.Contracts; using Win_in.Sfs.Basedata.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.Shared.Event;
@ -35,6 +36,7 @@ public class PurchaseReceiptRequestEventHandler
/// </summary> /// </summary>
/// <param name="eventData"></param> /// <param name="eventData"></param>
/// <returns></returns> /// <returns></returns>
[UnitOfWork]
public virtual async Task HandleEventAsync(SfsCancelledEntityEventData<PurchaseReceiptRequest> eventData) public virtual async Task HandleEventAsync(SfsCancelledEntityEventData<PurchaseReceiptRequest> eventData)
{ {
var entity = eventData.Entity; var entity = eventData.Entity;
@ -46,6 +48,7 @@ public class PurchaseReceiptRequestEventHandler
/// </summary> /// </summary>
/// <param name="eventData"></param> /// <param name="eventData"></param>
/// <returns></returns> /// <returns></returns>
[UnitOfWork]
public virtual async Task HandleEventAsync(SfsAgreedEntityEventData<PurchaseReceiptRequest> eventData) public virtual async Task HandleEventAsync(SfsAgreedEntityEventData<PurchaseReceiptRequest> eventData)
{ {
await CreatePurchaseReceiptJob(eventData.Entity).ConfigureAwait(false); await CreatePurchaseReceiptJob(eventData.Entity).ConfigureAwait(false);

Loading…
Cancel
Save