diff --git a/be/DataExchange/src/Win_in.Sfs.Wms.DataExchange.Agent/AgentModule.cs b/be/DataExchange/src/Win_in.Sfs.Wms.DataExchange.Agent/AgentModule.cs index 900b4cf8d..59cf323ef 100644 --- a/be/DataExchange/src/Win_in.Sfs.Wms.DataExchange.Agent/AgentModule.cs +++ b/be/DataExchange/src/Win_in.Sfs.Wms.DataExchange.Agent/AgentModule.cs @@ -149,7 +149,7 @@ public class AgentModule : AbpModule public override void OnApplicationInitialization( ApplicationInitializationContext context) { - //context.AddBackgroundWorkerAsync(); + context.AddBackgroundWorkerAsync(); // context.AddBackgroundWorkerAsync(); } } diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/Dicts/DTOs/DictDTO.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/Dicts/DTOs/DictDTO.cs index 0fa4d81dc..0fd5b89bc 100644 --- a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/Dicts/DTOs/DictDTO.cs +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/Dicts/DTOs/DictDTO.cs @@ -30,5 +30,5 @@ public class DictDTO : SfsBaseDataDTOBase, IHasCode, IHasName /// 字典项列表 /// [Display(Name = "字典项列表")] - public virtual ICollection Items { get; set; } = new List(); + public List Items { get; set; } = new List(); } diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/Dicts/Inputs/DictEditInput.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/Dicts/Inputs/DictEditInput.cs index 556038abe..1f19a6306 100644 --- a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/Dicts/Inputs/DictEditInput.cs +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/Dicts/Inputs/DictEditInput.cs @@ -24,7 +24,7 @@ public class DictEditInput : SfsBaseDataCreateOrUpdateInputBase /// 字典项列表 /// [Display(Name = "字典项列表")] - public virtual ICollection Items { get; set; } = new List(); + public List Items { get; set; } = new List(); #endregion #region Create diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/Dicts/DictAppService.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/Dicts/DictAppService.cs index 9cfc2c39b..828a8bba0 100644 --- a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/Dicts/DictAppService.cs +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/Dicts/DictAppService.cs @@ -10,11 +10,18 @@ using Win_in.Sfs.Basedata.Domain.Shared; namespace Win_in.Sfs.Basedata.Application; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; using System.Linq; - +using System.Text; +using DocumentFormat.OpenXml.Office2010.ExcelAc; using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Logging; +using Volo.Abp.Domain.Entities; using Volo.Abp.Domain.Repositories; using Win_in.Sfs.Shared; +using Win_in.Sfs.Shared.Application.Contracts; +using Win_in.Sfs.Shared.Domain; [Authorize] [Route($"{BasedataConsts.RootPath}dict")] @@ -81,4 +88,114 @@ public class DictAppService : SfsBaseDataWithCodeAppServiceBase(entity); } + + /// + /// 导入数据具体实现,可重写 + /// + protected override async Task ImportInternalAsync(SfsImportRequestInput requestInput, byte[] inputFileBytes) + { + IList modelList = null; + var modelDict = new Dictionary>(); + var entityDict = new Dictionary(); + try + { + var hasDetails = typeof(Dict).GetInterfaces().Any(o => o.IsGenericType && o.GetGenericTypeDefinition() == typeof(IMasterEntity<>)); + modelDict = ExportImportService.ImportHaveValidationResult(inputFileBytes); + foreach (var modelDictItem in modelDict) + { + // DataAnnotations 静态验证 + var validationRresults = modelDictItem.Value; + var model = modelDictItem.Key; + Validator.TryValidateObject(model, new ValidationContext(model, null, null), validationRresults); + } + modelList = modelDict.Keys.ToList(); + // 如果没有验证错误或允许部分导入 + if (!modelDict.SelectMany(o => o.Value).Any() || requestInput.IsAllowPartImport) + { + var dictCodes = modelList.Select(p => p.Code).Distinct().ToList(); + foreach (var detail in dictCodes) + { + var dictDetail = modelList.FirstOrDefault(p => p.Code == detail); + + Dict dictItem = new Dict(); + dictItem.SetId(GuidGenerator.Create()); + dictItem.Code = dictDetail.Code; + dictItem.Name = dictDetail.Name; + dictItem.Description = dictDetail.Description; + foreach (var item in modelList.Where(p=>p.Code==detail)) + { + DictItem dictItemDetail = new DictItem(); + dictItemDetail.SetId(GuidGenerator.Create()); + dictItemDetail.Code = item.Item_Code; + dictItemDetail.Name = item.Item_Name; + dictItemDetail.Value = item.Item_Value; + dictItemDetail.Description = item.Item_Description; + dictItemDetail.Enabled = true; + dictItemDetail.MasterId = dictItem.Id; + dictItem.Items.Add(dictItemDetail); + } + + await _repository.InsertAsync(dictItem).ConfigureAwait(false); + } + } + + // 创建导入报告 + var reportFile = ExportImportService.GetImportReport(inputFileBytes, modelDict); + // 创建返回值 + return new SfsImportResult + { + TotalNum = modelList.Count, + ErrorNum = modelDict.Count(o => o.Value.Any()), + FileName = reportFile.FileDownloadName, + FileContents = reportFile.FileContents + }; + } + catch (Exception ex) + { + Console.WriteLine("---------------------------------"); + Console.WriteLine($"####导入验证错误:"); + Console.WriteLine($"{ex.Message}"); + Console.WriteLine("---------------------------------"); + Logger.LogException(ex); + if (modelList != null) + { + try + { + foreach (var item in modelDict) + { + var model = item.Key; + var validationRresults = item.Value; + validationRresults.Add(new ValidationResult($"无法添加,{ex.Message}", new string[] { "异常" })); + } + + // 创建导入报告 + var reportFile = ExportImportService.GetImportReport(inputFileBytes, modelDict); + return new SfsImportResult + { + TotalNum = modelList.Count, + ErrorNum = modelDict.Count(o => o.Value.Any()), + FileName = reportFile.FileDownloadName, + FileContents = reportFile.FileContents + }; + } + catch (Exception) + { + return new SfsImportResult() + { + ExceptionMessage = ex.Message, + FileContents = Encoding.Default.GetBytes(ex.Message) + }; + } + } + else + { + return new SfsImportResult() + { + ExceptionMessage = ex.Message, + FileContents = Encoding.Default.GetBytes(ex.Message) + }; + } + } + } + } diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/Dicts/DictAutoMapperProfile.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/Dicts/DictAutoMapperProfile.cs index b64bfb41d..4085c7f9a 100644 --- a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/Dicts/DictAutoMapperProfile.cs +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/Dicts/DictAutoMapperProfile.cs @@ -37,13 +37,12 @@ public partial class BasedataApplicationAutoMapperProfile : Profile .Ignore(x => x.Id); CreateMap() - .IgnoreAuditedObjectProperties() - ; + .IgnoreAuditedObjectProperties(); CreateMap() - .IgnoreAuditedObjectProperties() - .Ignore(x => x.ConcurrencyStamp) - .Ignore(x => x.Id); + .IgnoreAuditedObjectProperties() + .Ignore(x => x.Id) + .Ignore(x => x.ConcurrencyStamp); } } diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/SplitPackings/SplitPackingRecAppService.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/SplitPackings/SplitPackingRecAppService.cs index a9eb98bd0..755982761 100644 --- a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/SplitPackings/SplitPackingRecAppService.cs +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/SplitPackings/SplitPackingRecAppService.cs @@ -124,6 +124,7 @@ public class SplitPackingRecAppService : var lst = await Repository.GetListAsync(itm => itm.PurchaseInfo_PoNumber == entity.PurchaseInfo_PoNumber).ConfigureAwait(false); ret = ObjectMapper.Map, List>(lst); + ret = ret.OrderByDescending(itm => itm.CreationTime).ToList(); return ret; } diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/Dicts/Dict.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/Dicts/Dict.cs index d1f1080e2..9537519b0 100644 --- a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/Dicts/Dict.cs +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/Dicts/Dict.cs @@ -31,5 +31,5 @@ public class Dict : SfsBaseDataAggregateRootBase, IHasCode /// /// 字典项列表 /// - public virtual ICollection Items { get; set; } = new List(); + public List Items { get; set; } = new List(); } diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/SplitPackings/SplitPackingRecManager.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/SplitPackings/SplitPackingRecManager.cs index 300f6dba1..0a95da7df 100644 --- a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/SplitPackings/SplitPackingRecManager.cs +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/SplitPackings/SplitPackingRecManager.cs @@ -48,7 +48,7 @@ public class SplitPackingRecManager : DomainService, ISplitPackingRecManager } if (item.ToTopPackingCode.IsNullOrEmpty()) { - item.ToTopPackingCode = item.ToPackingCode; + item.ToTopPackingCode = item.FromPackingCode;// ToPackingCode; } } #endregion @@ -57,7 +57,7 @@ public class SplitPackingRecManager : DomainService, ISplitPackingRecManager { //设置顶级箱码 item.FromTopPackingCode = GetTopPackingCode(query, item.FromPackingCode); - item.ToTopPackingCode = GetTopPackingCode(query, item.ToPackingCode); + item.ToTopPackingCode = GetTopPackingCode(query, item.FromPackingCode); //ToPackingCode if (item.FromTopPackingCode.IsNullOrEmpty()) { item.FromTopPackingCode = item.FromPackingCode; @@ -77,8 +77,8 @@ public class SplitPackingRecManager : DomainService, ISplitPackingRecManager SplitPackingRec newObj = CommonHelper.CloneObj(item); newObj.SetId(GuidGenerator.Create()); newObj.OprType = OprTypeEnum.Other; - newObj.FromPackingCode = newObj.ToPackingCode; - newObj.FromTopPackingCode = newObj.ToTopPackingCode; + newObj.FromPackingCode = newObj.ToPackingCode; //克隆赋值 + newObj.FromTopPackingCode = newObj.ToTopPackingCode; //克隆赋值 newObj.FromStdPackQty = newObj.ToStdPackQty; newObj.FromUom = newObj.ToUom; newObj.FromQty = newObj.ToQty; diff --git a/be/Modules/Inventory/src/Win_in.Sfs.Wms.Inventory.Domain/Transactions/TransactionExtensions.cs b/be/Modules/Inventory/src/Win_in.Sfs.Wms.Inventory.Domain/Transactions/TransactionExtensions.cs index 3acbe303c..b0f582249 100644 --- a/be/Modules/Inventory/src/Win_in.Sfs.Wms.Inventory.Domain/Transactions/TransactionExtensions.cs +++ b/be/Modules/Inventory/src/Win_in.Sfs.Wms.Inventory.Domain/Transactions/TransactionExtensions.cs @@ -30,12 +30,16 @@ public static class TransactionExtensions { if (!location.EnableNegative) { + if (existQty != 0) + { + existQty = -transaction.Qty+ existQty; + } throw new UserFriendlyException($"{location.Code} 库位不允许负库存。{Environment.NewLine}" + $"箱码: {transaction.PackingCode}{Environment.NewLine}" + $"ERP料号: {transaction.ItemCode}{Environment.NewLine}" + $"批次: {transaction.Lot}{Environment.NewLine}" + $"状态: {transaction.Status}{Environment.NewLine}" + - $"出库数量 {transaction.Qty}{Environment.NewLine}" + + $"出库数量 {-transaction.Qty}{Environment.NewLine}" + $"库存余额数量 {existQty}"); } 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 7c9416a5d..29c506d6b 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 @@ -739,7 +739,7 @@ public abstract class SfsCrudWithDetailsAppServiceBase /// /// - /// + /// protected virtual async Task ValidateImportEntityAsync(TImportInput model, TEntity entity, List validationRresult) { await Task.CompletedTask.ConfigureAwait(false); diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Requests/DeliverRequests/Inputs/DeliverRequestImportInput.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Requests/DeliverRequests/Inputs/DeliverRequestImportInput.cs index 1d48f2443..917c5b910 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Requests/DeliverRequests/Inputs/DeliverRequestImportInput.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Requests/DeliverRequests/Inputs/DeliverRequestImportInput.cs @@ -1,16 +1,32 @@ using System; using System.ComponentModel.DataAnnotations; +using Win_in.Sfs.Shared.Domain.Shared; namespace Win_in.Sfs.Wms.Store.Application.Contracts; [Display(Name = "发货申请")] public class DeliverRequestImportInput : SfsStoreImportInputBase { + /// + /// 单据号 + /// + [Display(Name = "单据号")] + [Required] + [Key] + public string Number { get; set; } + /// + /// 发货类型 + /// + [Display(Name = "发货类型")] + [Required] + [Key] + public EnumDeliverRequestType DeliverRequestType { get; set; } /// /// 发货时间 /// [Display(Name = "发货时间")] [Required] + [Key] public DateTime DeliverTime { get; set; } /// @@ -18,6 +34,7 @@ public class DeliverRequestImportInput : SfsStoreImportInputBase /// [Display(Name = "客户")] [Required] + [Key] public string CustomerCode { get; set; } /// @@ -62,11 +79,11 @@ public class DeliverRequestImportInput : SfsStoreImportInputBase public class DeliverRequestFisImportInput : SfsStoreImportInputBase { /// - /// 发货时间 + /// 发货类型 /// - [Display(Name = "发货时间")] + [Display(Name = "发货类型")] [Required] - public DateTime DeliverTime { get; set; } + public EnumDeliverRequestType DeliverRequestType { get; set; } /// /// 客户 @@ -74,7 +91,12 @@ public class DeliverRequestFisImportInput : SfsStoreImportInputBase [Display(Name = "客户")] [Required] public string CustomerCode { get; set; } - + /// + /// 发货时间 + /// + [Display(Name = "发货时间")] + [Required] + public DateTime DeliverTime { get; set; } /// /// ERP料号 /// @@ -95,18 +117,19 @@ public class DeliverRequestFisImportInput : SfsStoreImportInputBase [Display(Name = "发货库区")] [Required] public string AreaCode { get; set; } - /// - /// 起始底盘号 + /// Mes发货单号 /// - [Display(Name = "订单号")] - [Required] - public string FromVinCode { get; set; } - - ///// - ///// 截止底盘号 - ///// - //[Display(Name = "截止底盘号")] - //[Required] - //public string ToVinCode { get; set; } + [Display(Name = "Mes发货单号")] + public string MesDeliveryNo { get; set; } + /// + /// Mes发货计划号 + /// + [Display(Name = "Mes发货计划号")] + public string MesDeliveryPlan { get; set; } + /// + /// 底盘号 + /// + [Display(Name = "底盘号")] + public string IdentityNo { get; set; } } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/InspectJobs/InspectJobAppService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/InspectJobs/InspectJobAppService.cs index 35ec8c85c..7d8fc7e2d 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/InspectJobs/InspectJobAppService.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/InspectJobs/InspectJobAppService.cs @@ -43,7 +43,7 @@ public class InspectJobAppService var result = await _inspectJobManager.AddAsync(entity).ConfigureAwait(false); var dto = ObjectMapper.Map(result); - + return dto; } @@ -55,18 +55,27 @@ public class InspectJobAppService public virtual async Task CompleteSummaryDetailStatusAsync(Guid id, Guid summaryDetailId, InspectJobCompleteSummaryDetailInput input) { - if (input.FilesList != null && input.FilesList.Any()) + try { - var dict = await _fileAppService.CreateManyHasDictAsync(input.FilesList).ConfigureAwait(false); - input.InspectReport = JsonSerializer.Serialize(dict); - } + if (input.FilesList != null && input.FilesList.Any()) + { + var dict = await _fileAppService.CreateManyHasDictAsync(input.FilesList).ConfigureAwait(false); + input.InspectReport = JsonSerializer.Serialize(dict); + } - var summaryDetail = ObjectMapper.Map(input); + var summaryDetail = ObjectMapper.Map(input); - var entity = await _inspectJobManager - .CompleteSummaryDetailStatusAsync(id, summaryDetailId, summaryDetail, CurrentUser).ConfigureAwait(false); + var entity = await _inspectJobManager + .CompleteSummaryDetailStatusAsync(id, summaryDetailId, summaryDetail, CurrentUser).ConfigureAwait(false); + + return ObjectMapper.Map(entity); + } + catch (Exception ex) + { + + throw new UserFriendlyException($"{ex.Message}"); + } - return ObjectMapper.Map(entity); } /// diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/PutawayNotes/PutawayNoteAppService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/PutawayNotes/PutawayNoteAppService.cs index 51e7f6963..14876bc10 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/PutawayNotes/PutawayNoteAppService.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/PutawayNotes/PutawayNoteAppService.cs @@ -32,6 +32,7 @@ public class PutawayNoteAppService : public readonly IPurchaseOrderManager _purchaseOrderManager; public readonly IPurchasePriceSheetAppService _purchasePriceSheetAppService; public readonly IErpLocationItemAppService _erpLocationItemAppService; + public readonly IItemBasicAppService _itemBasicAppService; public PutawayNoteAppService( IPutawayNoteRepository repository, @@ -40,14 +41,16 @@ public class PutawayNoteAppService : IInspectJobAppService inspectJobAppService, IPurchaseOrderManager purchaseOrderManager, IPurchasePriceSheetAppService purchasePriceSheetAppService, - IErpLocationItemAppService erpLocationItemAppService) : base(repository) + IErpLocationItemAppService erpLocationItemAppService, + IItemBasicAppService itemBasicAppService) : base(repository) { _putawayNoteManager = putawayNoteManager; _purchaseReceiptNoteAppService = purchaseReceiptNoteAppService; _inspectJobAppService = inspectJobAppService; _purchaseOrderManager = purchaseOrderManager; _purchasePriceSheetAppService = purchasePriceSheetAppService; - _erpLocationItemAppService= erpLocationItemAppService; + _erpLocationItemAppService = erpLocationItemAppService; + _itemBasicAppService = itemBasicAppService; } /// @@ -61,33 +64,37 @@ public class PutawayNoteAppService : { foreach (var detail in input.Details) { - var isClosed = await _purchaseOrderManager.CheckIsCloseAsync(input.Number,input.SupplierCode, detail.ItemCode).ConfigureAwait(false); - if (isClosed) - { - throw new UserFriendlyException($"物品名称【{detail.ItemCode}】的订单明细行以关闭无法执行采购上架!"); - } + var isClosed = await _purchaseOrderManager.CheckIsCloseAsync(input.Number, input.SupplierCode, detail.ItemCode).ConfigureAwait(false); + if (isClosed) + { + throw new UserFriendlyException($"物品名称【{detail.ItemCode}】的订单明细行以关闭无法执行采购上架!"); + } + var item = await _itemBasicAppService.GetByCodeAsync(detail.ItemCode).ConfigureAwait(false); + if (!item.CanMake) + { var isprice = await _purchasePriceSheetAppService.CheckPurPriceAsync(input.SupplierCode, detail.ItemCode).ConfigureAwait(false); if (isprice) { throw new UserFriendlyException($"供应商【{input.SupplierCode}】物品名称【{detail.ItemCode}】无采购价格无法执行采购上架!"); } - var erpLocationItem = await _erpLocationItemAppService.CheckItemErpLocationIsAvailable(detail.ItemCode, detail.ToLocationErpCode).ConfigureAwait(false); + } + var erpLocationItem = await _erpLocationItemAppService.CheckItemErpLocationIsAvailable(detail.ItemCode, detail.ToLocationErpCode).ConfigureAwait(false); - if (erpLocationItem == null) - { - throw new UserFriendlyException($"未找到物品【{detail.ItemCode}】与ERP储位【{detail.ToLocationErpCode}】的开账信息"); - } - var purchasereDetail = await _purchaseReceiptNoteAppService - .GetDetailByItemAndPackingAsync(detail.ItemCode, detail.ToPackingCode).ConfigureAwait(false); - if (purchasereDetail != null) + if (erpLocationItem == null) + { + throw new UserFriendlyException($"未找到物品【{detail.ItemCode}】与ERP储位【{detail.ToLocationErpCode}】的开账信息"); + } + var purchasereDetail = await _purchaseReceiptNoteAppService + .GetDetailByItemAndPackingAsync(detail.ItemCode, detail.ToPackingCode).ConfigureAwait(false); + if (purchasereDetail != null) + { + var inspectJobDto = await _inspectJobAppService + .GetInspectNoteDetailByPackingCodeAsync(detail.ToPackingCode).ConfigureAwait(false); + if (inspectJobDto.JobStatus != EnumJobStatus.Done) { - var inspectJobDto = await _inspectJobAppService - .GetInspectNoteDetailByPackingCodeAsync(detail.ToPackingCode).ConfigureAwait(false); - if (inspectJobDto.JobStatus != EnumJobStatus.Done) - { - throw new UserFriendlyException($"包含【{detail.ToPackingCode}】箱码的报检单,尚未完成质检"); - } + throw new UserFriendlyException($"包含【{detail.ToPackingCode}】箱码的报检单,尚未完成质检"); } + } } var entity = ObjectMapper.Map(input); diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Requests/ContainerRequests/ContainerRequestAppService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Requests/ContainerRequests/ContainerRequestAppService.cs index a57e2b4a0..ea3f8b328 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Requests/ContainerRequests/ContainerRequestAppService.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Requests/ContainerRequests/ContainerRequestAppService.cs @@ -78,7 +78,7 @@ public class ContainerRequestAppService : /// private async Task SetRequestAutoPropertiesAsync(ContainerRequestEditInput entity) { - var tranType = await _transactionTypeAppService.GetByTransTypeAsync(EnumTransType.Issue, EnumTransSubType.None).ConfigureAwait(false); + var tranType = await _transactionTypeAppService.GetByTransTypeAsync(EnumTransType.TransferLib, EnumTransSubType.Transfer_Warehouse).ConfigureAwait(false); Check.NotNull(tranType, "事务类型", "事务类型不存在"); diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Requests/DeliverRequests/DeliverRequestAppService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Requests/DeliverRequests/DeliverRequestAppService.cs index ee7e8d81f..8d712414e 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Requests/DeliverRequests/DeliverRequestAppService.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Requests/DeliverRequests/DeliverRequestAppService.cs @@ -10,8 +10,10 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; using Volo.Abp; using Volo.Abp.Application.Dtos; +using Volo.Abp.Domain.Entities; using Volo.Abp.Domain.Entities.Events.Distributed; using Volo.Abp.ObjectMapping; +using Win_in.Sfs.Basedata.Application; using Win_in.Sfs.Basedata.Application.Contracts; using Win_in.Sfs.Shared.Application.Contracts; using Win_in.Sfs.Shared.Domain; @@ -34,18 +36,122 @@ public class DeliverRequestAppService : private readonly IAreaAppService _areaApp; private readonly ICustomerAppService _customerApp; private readonly ICustomerAddressAppService _customerAddressApp; + private readonly IItemBasicAppService _itemBasicAppService; public DeliverRequestAppService( IDeliverRequestRepository repository , IDeliverRequestManager deliverRequestManager , IAreaAppService areaApp , ICustomerAppService customerApp - , ICustomerAddressAppService customerAddressApp) + , ICustomerAddressAppService customerAddressApp, +IItemBasicAppService itemBasicAppService) : base(repository, deliverRequestManager) { _deliverRequestManager = deliverRequestManager; _areaApp = areaApp; _customerApp = customerApp; _customerAddressApp = customerAddressApp; + _itemBasicAppService = itemBasicAppService; + } + + protected override async Task> ImportProcessingEntityAsync(Dictionary dictionary) + { + var addList = dictionary.Where(p => p.Value == EntityState.Added).Select(p => p.Key); + foreach (var request in addList) + { + request.Worker = CurrentUser.GetUserName(); + request.CreatorId = CurrentUser.Id; + request.Remark = "成品发运手动导入"; + request.ActiveDate = DateTime.Now; + await SetRequestAutoPropertiesAsync(request).ConfigureAwait(false); + var detailGroupCount= request.Details.GroupBy(r => new { r.AreaCode, r.MesDeliveryNo, r.MesDeliveryPlan }).Count(); + if (detailGroupCount != 1) + { + throw new UserFriendlyException($"同一发货类型、发货时间、客户的发货区域、Mes发货单号、Mes发货计划号必须相同!"); + } + if (request.Details.Count != request.Details.Select(r => r.ItemCode).Distinct().Count()) + { + throw new UserFriendlyException($"同一发货类型、发货时间、客户的存在相同零件号!"); + } + foreach (var detail in request.Details) + { + var itemBasicDto = await _itemBasicAppService.GetByCodeAsync(detail.ItemCode).ConfigureAwait(false); + CheckItemBasic(itemBasicDto, detail.ItemCode); + detail.ItemDesc1 = itemBasicDto.Desc1; + detail.ItemDesc2 = itemBasicDto.Desc2; + detail.ItemName = itemBasicDto.Name; + detail.Uom = itemBasicDto.BasicUom; + detail.StdPackQty = itemBasicDto.StdPackQty; + } + } + + return dictionary; + } + protected override async Task SaveImportAsync(Dictionary dict) + { + var addList = dict.Where(p => p.Value == EntityState.Added).Select(p => p.Key).ToList(); + foreach (var item in addList) + { + await SetRequestAutoPropertiesAsync(item).ConfigureAwait(false); + } + + await _deliverRequestManager.CreateManyAsync(addList).ConfigureAwait(false); + } + private static void CheckItemBasic(ItemBasicDTO itemcBasicDto, string itemCode) + { + if (itemcBasicDto == null) + { + throw new UserFriendlyException($"ERP料号为【{itemCode}】不存在"); + } + } + /// + /// 验证 + /// + /// + /// + /// + protected override async Task ValidateImportModelAsync(DeliverRequestImportInput model, List validationRresult) + { + if (model.DeliverRequestType == EnumDeliverRequestType.FIS) + { + + if (string.IsNullOrEmpty(model.IdentityNo)) + { + validationRresult.Add(new ValidationResult($"ERP料号{model.ItemCode}为FIS发货必须填写底盘号", new string[] { "底盘号" })); + } + if (string.IsNullOrEmpty(model.MesDeliveryNo)) + { + validationRresult.Add(new ValidationResult($"ERP料号{model.ItemCode}为FIS发货必须填写MES发货单号", new string[] { "MES发货单号" })); + } + if (!string.IsNullOrEmpty(model.MesDeliveryPlan)) + { + validationRresult.Add(new ValidationResult($"ERP料号{model.ItemCode}为FIS发货MES发货计划单号应该为空", new string[] { "MES发货计划单号" })); + } + } + if (model.DeliverRequestType == EnumDeliverRequestType.Normal ) + { + if (string.IsNullOrEmpty(model.MesDeliveryPlan)) + { + validationRresult.Add(new ValidationResult($"ERP料号{model.ItemCode}为看板发货必须填写MES发货计划单号", new string[] { "MES发货计划单号" })); + } + if(!string.IsNullOrEmpty(model.IdentityNo)|| !string.IsNullOrEmpty(model.MesDeliveryNo)) + { + validationRresult.Add(new ValidationResult($"ERP料号{model.ItemCode}为看板发货底盘号和MES发货单号应该为空", new string[] { "底盘号" , "MES发货单号" })); + } + } + var area = await _areaApp.GetByCodeAsync(model.AreaCode).ConfigureAwait(false); + + if (area != null) + { + if (!area.Name.Contains("成品"))//因为区域里没有类型,只能用名称判断 + { + validationRresult.Add(new ValidationResult($"发货区域{model.AreaCode}不是成品储位", new string[] { "发货区域" })); + } + } + else + { + validationRresult.Add(new ValidationResult($"发货区域{model.AreaCode}不存在", new string[] { "发货区域" })); + } + await Task.CompletedTask.ConfigureAwait(false); } /// /// 处理请求 diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Requests/DeliverRequests/DeliverRequestAutoMapperProfile.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Requests/DeliverRequests/DeliverRequestAutoMapperProfile.cs index 6b40d01c6..da3b0fcf0 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Requests/DeliverRequests/DeliverRequestAutoMapperProfile.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Requests/DeliverRequests/DeliverRequestAutoMapperProfile.cs @@ -29,7 +29,7 @@ public partial class StoreApplicationAutoMapperProfile : Profile CreateMap() - .ForMember(x => x.DeliverRequestType, y => y.MapFrom(t => EnumDeliverRequestType.Normal)) + // .ForMember(x => x.DeliverRequestType, y => y.MapFrom(t => EnumDeliverRequestType.Normal)) .Ignore(x => x.CustomerAddressCode) .Ignore(x => x.DeliverPlanNumber) .Ignore(x => x.ActiveDate) @@ -62,7 +62,7 @@ public partial class StoreApplicationAutoMapperProfile : Profile .Ignore(x => x.Remark); CreateMap() - .ForMember(x => x.DeliverRequestType, y => y.MapFrom(t => EnumDeliverRequestType.FIS)) + // .ForMember(x => x.DeliverRequestType, y => y.MapFrom(t => EnumDeliverRequestType.FIS)) .Ignore(x => x.CustomerAddressCode) .Ignore(x => x.DeliverPlanNumber) .Ignore(x => x.ActiveDate) @@ -96,7 +96,7 @@ public partial class StoreApplicationAutoMapperProfile : Profile .Ignore(x => x.IdentityNo) .Ignore(x => x.MesDeliveryNo) .Ignore(x => x.MesDeliveryPlan) - .AfterMap((x, y) => y.SetProperty(nameof(x.FromVinCode), x.FromVinCode)) + // .AfterMap((x, y) => y.SetProperty(nameof(x.FromVinCode), x.FromVinCode)) //.AfterMap((x, y) => y.SetProperty(nameof(x.ToVinCode), x.ToVinCode)) ; } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Requests/DeliverRequests/DeliverRequestFisAppService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Requests/DeliverRequests/DeliverRequestFisAppService.cs index 67eac6b97..63d701e4f 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Requests/DeliverRequests/DeliverRequestFisAppService.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Requests/DeliverRequests/DeliverRequestFisAppService.cs @@ -397,7 +397,7 @@ public class DeliverRequestFisAppService : { await Task.CompletedTask.ConfigureAwait(false); - detail.SetProperty(nameof(input.FromVinCode), input.FromVinCode); + // detail.SetProperty(nameof(input.FromVinCode), input.FromVinCode); //detail.SetProperty(nameof(input.ToVinCode), input.ToVinCode); } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Jobs/InspectJobs/InspectJobManager.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Jobs/InspectJobs/InspectJobManager.cs index 818a6c84d..2c3081d5b 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Jobs/InspectJobs/InspectJobManager.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Jobs/InspectJobs/InspectJobManager.cs @@ -197,7 +197,7 @@ public class InspectJobManager : SfsJobManagerBase #endregion - await LocalEventBus.PublishAsync(new SfsUpdateEntitySummaryDetailEventData(CopyJob)) + await LocalEventBus.PublishAsync(new SfsUpdateEntitySummaryDetailEventData(CopyJob),false) .ConfigureAwait(false); return summaryDetailEntity; diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/AutoMapperProfiles/Requests/ThirdLocationRequestAutoMapperProfile.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/AutoMapperProfiles/Requests/ThirdLocationRequestAutoMapperProfile.cs index 1960a1e7c..1ed9f4fe5 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/AutoMapperProfiles/Requests/ThirdLocationRequestAutoMapperProfile.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/AutoMapperProfiles/Requests/ThirdLocationRequestAutoMapperProfile.cs @@ -79,8 +79,7 @@ public partial class StoreEventAutoMapperProfile : Profile .Ignore(x => x.PlannedSplitRule) .Ignore(x => x.DeliveryQty) .Ignore(x => x.Status) - .Ignore(x => x.RecommendContainerCode) - .Ignore(x => x.StdPackQty) + .Ignore(x => x.RecommendContainerCode) .Ignore(x => x.RecommendPackingCode) .Ignore(x => x.HandledContainerCode) .Ignore(x => x.HandledPackingCode) diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Jobs/PurchaseReceiptJobEventHandler.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Jobs/PurchaseReceiptJobEventHandler.cs index b3326c416..10cb54325 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Jobs/PurchaseReceiptJobEventHandler.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Jobs/PurchaseReceiptJobEventHandler.cs @@ -68,6 +68,12 @@ public class PurchaseReceiptJobEventHandler : createInput.Details.Where(p => p.PurchaseReceiptInspectStatus == EnumPurchaseReceiptInspect.NOK); foreach (var detailInput in noOkNoteDetailInputs) { + detailInput.LocationCode = holdLocation.Code; + detailInput.LocationArea = holdLocation.AreaCode; + detailInput.LocationErpCode = holdLocation.ErpLocationCode; + detailInput.LocationGroup = holdLocation.LocationGroupCode; + detailInput.WarehouseCode = holdLocation.WarehouseCode; + detailInput.HandledToLocationCode = holdLocation.Code; detailInput.HandledToLocationArea = holdLocation.AreaCode; detailInput.HandledToLocationErpCode = holdLocation.ErpLocationCode; detailInput.HandledToLocationGroup = holdLocation.LocationGroupCode; diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Transactions/DeliverNoteEventHandler.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Transactions/DeliverNoteEventHandler.cs index d08b6cd95..5b0d1e0d6 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Transactions/DeliverNoteEventHandler.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Transactions/DeliverNoteEventHandler.cs @@ -20,6 +20,7 @@ namespace Win_in.Sfs.Wms.Store.Event.Transactions; public class DeliverNoteEventHandler : StoreInventoryEventHandlerBase , ILocalEventHandler> + , ILocalEventHandler>> { private const EnumTransType TransType = EnumTransType.Deliver; private readonly IDeliverRequestAppService _deliverRequestApp; @@ -49,7 +50,24 @@ public class DeliverNoteEventHandler await SetRequestStatusAsync(entity).ConfigureAwait(false); } + /// + /// 创建后 + /// + /// + /// + [UnitOfWork] + public virtual async Task HandleEventAsync(SfsCreatedEntityEventData> eventDatas) + { + var entitys = eventDatas.Entity; + var transferLogs = new List(); + foreach (var entity in entitys) + { + transferLogs.AddRange(BuildTransferLogs(entity)); + await SetRequestStatusAsync(entity).ConfigureAwait(false); + } + await TransferLogAppService.AddManyAsync(transferLogs).ConfigureAwait(false); + } #region 私有 private async Task AddTransactionsAsync(DeliverNote deliverNote)