From 3918b0148f123ef55a2c117e07a9945e158cc146 Mon Sep 17 00:00:00 2001 From: lvzb <35200379@qq.com> Date: Fri, 26 Apr 2024 14:30:00 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E5=AF=BC=E5=85=A5=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../IItemStoreRelationAppService.cs | 1 + .../ItemStoreRelationAppService.cs | 14 ++ .../DTOs/CountJobDependentDetailDTO.cs | 8 + .../CountJobs/Inputs/CountJobImportInput.cs | 54 +++++ .../Jobs/CountJobs/CountJobAppService.cs | 194 +++++++++++++++++- .../CountJobs/CountJobAutoMapperProfile.cs | 10 + .../Jobs/CountJobs/CountJob.cs | 2 +- .../Jobs/CountJobs/CountJobDependentDetail.cs | 6 + .../Jobs/CountJobs/CountJobManager.cs | 132 +++++++++++- .../Jobs/CountJobs/ICountJobManager.cs | 2 + 10 files changed, 419 insertions(+), 4 deletions(-) create mode 100644 be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Jobs/CountJobs/Inputs/CountJobImportInput.cs diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/ItemStoreRelations/IItemStoreRelationAppService.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/ItemStoreRelations/IItemStoreRelationAppService.cs index 7d4113c45..34bbb5c8c 100644 --- a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/ItemStoreRelations/IItemStoreRelationAppService.cs +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/ItemStoreRelations/IItemStoreRelationAppService.cs @@ -21,4 +21,5 @@ public interface IItemStoreRelationAppService : ISfsBaseDataAppServiceBase GetFirstAsync(ItemAndLocationRequestInput itemAndLocations); Task GetFirstAsync(string itemCode, string locationCode); + Task GetByItemAndLocationAsync(string itemCode, string value, EnumStoreRelationType storeRelationType); } diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/ItemStoreRelations/ItemStoreRelationAppService.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/ItemStoreRelations/ItemStoreRelationAppService.cs index f7da4b279..204a4638e 100644 --- a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/ItemStoreRelations/ItemStoreRelationAppService.cs +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/ItemStoreRelations/ItemStoreRelationAppService.cs @@ -99,6 +99,20 @@ public class ItemStoreRelationAppService : SfsBaseDataAppServiceBase GetByItemAndLocationAsync(string itemCode,string value, EnumStoreRelationType storeRelationType) + { + var entitie= await _repository.FirstOrDefaultAsync(p => p.ItemCode == itemCode&&p.StoreValue== value && p.Enabled == true && p.StoreRelationType == storeRelationType).ConfigureAwait(false); + if (entitie != null) + { + var dtos = ObjectMapper.Map(entitie); + return dtos; + } + else + { + return null; + } + } /// /// 当前库位 允许的 零件关系 /// diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Jobs/CountJobs/DTOs/CountJobDependentDetailDTO.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Jobs/CountJobs/DTOs/CountJobDependentDetailDTO.cs index 5b4288f53..e8c35f78b 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Jobs/CountJobs/DTOs/CountJobDependentDetailDTO.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Jobs/CountJobs/DTOs/CountJobDependentDetailDTO.cs @@ -1,5 +1,6 @@ using System; using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; using Win_in.Sfs.Shared.Domain; namespace Win_in.Sfs.Wms.Store.Application.Contracts; @@ -59,4 +60,11 @@ public class CountJobDependentDetailDTO : SfsJobDetailDTOBase, IHasCountResult /// [Display(Name = "盘点描述")] public string CountDescription { get; set; } + + /// + /// 是否删除 + /// + [Display(Name = "是否删除")] + + public bool IsDelete { get; set; } } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Jobs/CountJobs/Inputs/CountJobImportInput.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Jobs/CountJobs/Inputs/CountJobImportInput.cs new file mode 100644 index 000000000..f6a3f05b5 --- /dev/null +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Jobs/CountJobs/Inputs/CountJobImportInput.cs @@ -0,0 +1,54 @@ +using System.ComponentModel.DataAnnotations; +using Win_in.Sfs.Shared.Domain.Shared; + +namespace Win_in.Sfs.Wms.Store.Application.Contracts; +[Display(Name = "盘点任务")] +public class CountJobImportInput : SfsStoreImportInputBase +{ + /// + /// 盘点任务单号 + /// + [Display(Name = "盘点任务单号")] + [Key] + [Required] + public string CountJobNumber { get; set; } + + /// + /// 物品代码 + /// + [Display(Name = "物料号")] + [Required(ErrorMessage = "{0}是必填项")] + public string ItemCode { get; set; } + + /// + /// 物品名称 + /// + [Display(Name = "物品名称")] + public string ItemName { get; set; } + + /// + /// 箱码 + /// + [Display(Name = "箱码")] + public string PackingCode { get; set; } + + /// + /// 库存状态 + /// + [Display(Name = "库存状态")] + [Required(ErrorMessage = "{0}是必填项", AllowEmptyStrings = true)] + public EnumInventoryStatus Status { get; set; } + + /// + /// 批次 + /// + [Display(Name = "批次")] + public string Lot { get; set; } + + /// + /// 盘点数量 + /// + [Display(Name = "盘点数量")] + [Required(ErrorMessage = "{0}是必填项")] + public decimal CountQty { get; set; } +} diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/CountJobs/CountJobAppService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/CountJobs/CountJobAppService.cs index aa6121da5..f644c244f 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/CountJobs/CountJobAppService.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/CountJobs/CountJobAppService.cs @@ -1,14 +1,21 @@ using System; using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; using System.Linq; +using System.Text; using System.Threading.Tasks; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Logging; using Volo.Abp; using Volo.Abp.Domain.Repositories; using Volo.Abp.Validation; +using Win_in.Sfs.Basedata.Application.Contracts; +using Win_in.Sfs.Shared.Application.Contracts; +using Win_in.Sfs.Shared.Domain; using Win_in.Sfs.Shared.Domain.Shared; +using Win_in.Sfs.Wms.Inventory.Application.Contracts; using Win_in.Sfs.Wms.Store.Application.Contracts; using Win_in.Sfs.Wms.Store.Domain; using Win_in.Sfs.Wms.Store.Domain.Shared; @@ -26,17 +33,201 @@ public class CountJobAppService ICountJobAppService { private readonly ICountJobManager _countJobManager; - + private readonly IItemBasicAppService _itemBasicAppService; + private readonly IItemStoreRelationAppService _itemStoreRelationAppService; + private readonly IBalanceAppService _balanceAppService; //private readonly ILocationCapacityAppService _locationCapacityAppService; public CountJobAppService( ICountJobRepository repository , ICountJobManager countJobManager + , IItemBasicAppService itemBasicAppService + , IItemStoreRelationAppService itemStoreRelationAppService + , IBalanceAppService balanceAppService ) : base(repository, countJobManager) { + _itemBasicAppService = itemBasicAppService; _countJobManager = countJobManager; + _itemStoreRelationAppService = itemStoreRelationAppService; + _balanceAppService= balanceAppService; } + #region 导入 + /// + /// 导入数据具体实现,可重写 + /// + protected override async Task ImportInternalAsync(SfsImportRequestInput requestInput, byte[] inputFileBytes) + { + IList modelList = null; + var modelDict = new Dictionary>(); + var entityDict = new Dictionary(); + try + { + var hasDetails = typeof(CountJob).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(); + List depDetails = new List(); + // 如果没有验证错误或允许部分导入 + var jobnumber = modelDict.First().Key.CountJobNumber; + var job = await _repository.FindAsync(r => r.Number == jobnumber).ConfigureAwait(false); + if (!modelDict.SelectMany(o => o.Value).Any() || requestInput.IsAllowPartImport) + { + + foreach (var item in modelDict) + { + var model = item.Key; + var validationRresults = item.Value; + var depDetail = ObjectMapper.Map(model); + await ValidateImportModelAsync(model, validationRresults, job, depDetail).ConfigureAwait(false); + depDetails.Add(depDetail); + } + } + if (!modelDict.SelectMany(o => o.Value).Any()) + { + if (depDetails.Any()) + { + await _countJobManager.ImportAsync(job,depDetails, CurrentUser).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) + }; + } + } + } + /// + /// 导入验证 + /// + /// + /// + /// + /// + /// + protected async Task ValidateImportModelAsync(CountJobImportInput model, + List validationRresult, CountJob job, CountJobDependentDetail depDetail) + { + _ = new Dictionary(); + CheckJobNumberAsync(model, validationRresult, job.Number); + _ = await CheckItemBasicAsync(model, validationRresult, depDetail).ConfigureAwait(false); + _ = await CheckItemStoreRelationAsync(model, validationRresult,job.LocationCode).ConfigureAwait(false); + _ = await CheckPackingCodeAsync(model, validationRresult, job.LocationCode).ConfigureAwait(false); + } + protected async Task CheckItemBasicAsync(CountJobImportInput importInput, + List validationRresult, CountJobDependentDetail depDetail) + { + var item = await _itemBasicAppService.GetByCodeAsync(importInput.ItemCode).ConfigureAwait(false); + if (item == null) + { + validationRresult.Add(new ValidationResult($"物品代码{importInput.ItemCode}不存在", new[] { "物品代码" })); + } + else if (item.StdPackQty == 0) + { + validationRresult.Add( + new ValidationResult($"物品代码{importInput.ItemCode}的物品信息中标准包装等于0或不存在", new[] { "标准包装" })); + } + else + { + depDetail.ItemName = item.Name; + depDetail.ItemDesc1 = item.Desc1; + depDetail.ItemDesc2 = item.Desc2; + depDetail.StdPackQty = item.StdPackQty; + depDetail.Uom = item.BasicUom; + } + return item; + } + + protected async Task CheckItemStoreRelationAsync(CountJobImportInput importInput,List validationRresult,string locationCode) + { + var item = await _itemStoreRelationAppService.GetByItemAndLocationAsync(importInput.ItemCode,locationCode,EnumStoreRelationType.Location).ConfigureAwait(false); + if (item == null) + { + validationRresult.Add(new ValidationResult($"零件与库位{locationCode}对应关系不存在", new[] { "物品代码" })); + } + return item; + } + protected async Task CheckPackingCodeAsync(CountJobImportInput importInput, List validationRresult, string locationCode) + { + var item = await _balanceAppService.GetByPackingCodeAsync(importInput.PackingCode).ConfigureAwait(false); + if (item != null) + { + if (item.LocationCode != locationCode) + { + validationRresult.Add(new ValidationResult($"箱码已经在库位{item.LocationCode}存在不能盘点", new[] { "箱码" })); + } + if(item.Lot!= importInput.Lot) + { + validationRresult.Add(new ValidationResult($"批次与库存中批次{item.Lot}不匹配不能盘点", new[] { "批次" })); + } + } + return item; + } + protected void CheckJobNumberAsync(CountJobImportInput importInput, List validationRresult,string jobNumber) + { + if (importInput.CountJobNumber != jobNumber) + { + validationRresult.Add(new ValidationResult($"盘点任务单号{importInput.CountJobNumber}与其它有冲突,只允许导入一个任务单号数据", new[] { "盘点任务单号" })); + } + } + #endregion /// /// 根据条件新增job接口 /// @@ -88,6 +279,7 @@ public class CountJobAppService } var entity = ObjectMapper.Map(dto); entity.Number = checkEntity.Number; + await _countJobManager.CompleteAsync(entity, CurrentUser).ConfigureAwait(false); return dto; } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/CountJobs/CountJobAutoMapperProfile.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/CountJobs/CountJobAutoMapperProfile.cs index 8becdf0d2..400b8612b 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/CountJobs/CountJobAutoMapperProfile.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/CountJobs/CountJobAutoMapperProfile.cs @@ -1,5 +1,8 @@ +using System.Collections.Generic; using AutoMapper; +using AutoMapper.Internal.Mappers; using Volo.Abp.AutoMapper; +using Win_in.Sfs.Shared.Domain.Shared; using Win_in.Sfs.Wms.Store.Application.Contracts; using Win_in.Sfs.Wms.Store.Domain; @@ -88,5 +91,12 @@ public partial class StoreApplicationAutoMapperProfile : Profile ; CreateMap() .ReverseMap(); + CreateMap< CountJobImportInput, CountJobDependentDetail>() + .IgnoreAuditedObjectProperties() + .Ignore(x => x.MasterID) + .Ignore(x => x.TenantId) + .Ignore(x => x.Number) + .Ignore(x => x.Id) + ; } } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Jobs/CountJobs/CountJob.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Jobs/CountJobs/CountJob.cs index 85ddb2187..274bdf2cb 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Jobs/CountJobs/CountJob.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Jobs/CountJobs/CountJob.cs @@ -95,7 +95,7 @@ public class CountJob : SfsJobAggregateRootBase detail.ExpireDate = expireDate; detail.LocationCode = locationCode; - detail.CountQty = qty; + detail.CountQty = detail.CountQty +qty; detail.CountTime = time; detail.CountOperator = oper; detail.CountDescription = desc; diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Jobs/CountJobs/CountJobDependentDetail.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Jobs/CountJobs/CountJobDependentDetail.cs index 2e83fcba1..51b16c59a 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Jobs/CountJobs/CountJobDependentDetail.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Jobs/CountJobs/CountJobDependentDetail.cs @@ -1,5 +1,6 @@ using System; using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; using Win_in.Sfs.Shared.Domain; namespace Win_in.Sfs.Wms.Store.Domain; @@ -51,5 +52,10 @@ public class CountJobDependentDetail : SfsJobDetailEntityBase, IHasCountResult, /// 盘点描述 /// public string CountDescription { get; set; } + /// + /// 是否删除 + /// + [NotMapped] + public bool IsDelete { get; set; } } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Jobs/CountJobs/CountJobManager.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Jobs/CountJobs/CountJobManager.cs index 102df0668..e56660a5e 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Jobs/CountJobs/CountJobManager.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Jobs/CountJobs/CountJobManager.cs @@ -4,6 +4,7 @@ using System.ComponentModel.DataAnnotations; using System.Linq; using System.Linq.Expressions; using System.Threading.Tasks; +using DocumentFormat.OpenXml.Drawing; using Microsoft.EntityFrameworkCore; using Volo.Abp; using Volo.Abp.ObjectMapping; @@ -132,6 +133,74 @@ public class CountJobManager : SfsJobManagerBase, ICou return await _repository.UpdateAsync(entity).ConfigureAwait(false); } + /// + /// 导入盘点任务明细是调用 + /// + /// + /// + /// + /// + public async Task ImportAsync( CountJob entity, List depDetails, ICurrentUser user) + { + //修改子表数据 + string locationCode = entity.Details.First().LocationCode; + string locationArea = entity.Details.First().LocationArea; + string locationGroup = entity.Details.First().LocationGroup; + string locationErpCode = entity.Details.First().LocationErpCode; + string warehouseCode = entity.Details.First().WarehouseCode; + foreach (var depDetail in depDetails) + { + decimal countCount = depDetail.CountQty; + depDetail.LocationCode = locationCode; + depDetail.LocationArea = locationArea; + depDetail.LocationGroup = locationGroup; + depDetail.LocationErpCode = locationErpCode; + depDetail.WarehouseCode = warehouseCode; + depDetail.InventoryStage = entity.InventoryStage; + if (!string.IsNullOrEmpty(depDetail.PackingCode)) + { + var oldDepDetail = entity.DepDetails.FirstOrDefault(r => r.ItemCode == depDetail.ItemCode && r.PackingCode == depDetail.PackingCode && r.LocationCode == locationCode && r.InventoryStage == entity.InventoryStage && r.Lot == depDetail.Lot); + if (oldDepDetail != null) + { + countCount = depDetail.CountQty - oldDepDetail.CountQty; + entity.DepDetails.Remove(oldDepDetail); + } + } + var jobDepDetail = ObjectMapper.Map(depDetail); + jobDepDetail.SetIdAndNumber(GuidGenerator, entity.Id, entity.Number); + jobDepDetail.CountLabel = GuidGenerator.Create().ToString(); + entity.DepDetails.Add(jobDepDetail); + var detail = entity.Details.FirstOrDefault(r => r.ItemCode == depDetail.ItemCode && r.PackingCode == depDetail.PackingCode && r.LocationCode == locationCode && r.InventoryStage == entity.InventoryStage && r.Lot == depDetail.Lot); + if (detail == null) + { + var jobDetail = ObjectMapper.Map(depDetail); + jobDetail.ArriveDate = DateTime.Now; + jobDetail.ProduceDate = DateTime.Now; + jobDetail.ExpireDate = DateTime.Parse("9999-12-31 23:59:59.9999999"); + jobDetail.InventoryQty = 0; + var detailNumber = await GetNumber().ConfigureAwait(false); + jobDetail.SetIdAndNumber(GuidGenerator, entity.Id, detailNumber); + jobDetail.CountLabel = GuidGenerator.Create().ToString(); + entity.Details.Add(jobDetail); + } + else + { + jobDepDetail.ArriveDate = detail.ArriveDate; + jobDepDetail.ProduceDate = detail.ProduceDate; + jobDepDetail.ExpireDate = detail.ExpireDate; + await entity.SetDetail(detail.Id, detail.SupplierBatch, detail.ArriveDate, detail.ProduceDate, detail.ExpireDate, detail.LocationCode, countCount, detail.CountTime, detail.CountOperator, detail.CountDescription) + .ConfigureAwait(false); + } + } + //移除原有明细里没有,并且第二次扫描以处的项目 + entity.Details.RemoveAll(r => r.InventoryQty == 0 && r.CountQty == 0 && r.InventoryStage == entity.InventoryStage); + + entity.CompleteUserId = user.Id; + entity.CompleteUserName = user.Name; + entity.CompleteTime = Clock.Now; + await PublishCompletedAsync(entity).ConfigureAwait(false); + return await _repository.UpdateAsync(entity).ConfigureAwait(false); + } /// /// 根据之前定义的条件生成盘点计划 /// @@ -163,8 +232,13 @@ public class CountJobManager : SfsJobManagerBase, ICou return jobList; } - - private async Task SetDetailsAsync(CountJob input, CountJob entity) + /// + /// 此方法弃用 + /// + /// + /// + /// + private async Task SetDetailsAsync_back(CountJob input, CountJob entity) { //将任务里所有可盘数量置为0 input.Details.ForEach(r => @@ -219,6 +293,60 @@ public class CountJobManager : SfsJobManagerBase, ICou entity.Details.RemoveAll(r => r.InventoryQty == 0 && r.CountQty == 0&& r.InventoryStage == entity.InventoryStage); } + + private async Task SetDetailsAsync(CountJob input, CountJob entity) + { + //遍历扫描明细 + foreach (var depDetail in input.DepDetails.Where(r => r.InventoryStage == entity.InventoryStage)) + { + decimal countCount = depDetail.CountQty; + var detail = entity.Details.FirstOrDefault(r => r.ItemCode == depDetail.ItemCode && r.PackingCode == depDetail.PackingCode && r.LocationCode == depDetail.LocationCode && r.InventoryStage == entity.InventoryStage&&r.Lot==depDetail.Lot); + var oldDepDetail = entity.DepDetails.FirstOrDefault(r => r.ItemCode == depDetail.ItemCode && r.PackingCode == depDetail.PackingCode && r.LocationCode == depDetail.LocationCode && r.InventoryStage == entity.InventoryStage && r.Lot == depDetail.Lot); + if (depDetail.IsDelete) + { + countCount = -oldDepDetail.CountQty; + entity.DepDetails.Remove(oldDepDetail); + } + else + { + if (oldDepDetail != null && depDetail.Id == oldDepDetail.Id) + { + countCount = depDetail.CountQty - oldDepDetail.CountQty; + entity.DepDetails.Remove(oldDepDetail); + } + + var jobDepDetail = ObjectMapper.Map(depDetail); + var number = entity.Number; + jobDepDetail.SetIdAndNumber(GuidGenerator, entity.Id, number); + jobDepDetail.CountLabel = GuidGenerator.Create().ToString(); + entity.DepDetails.Add(jobDepDetail); + + if (detail == null) + { + var jobDetail = ObjectMapper.Map(depDetail); + jobDetail.ArriveDate = DateTime.Now; + jobDetail.ProduceDate = DateTime.Now; + jobDetail.ExpireDate = DateTime.Parse("9999-12-31 23:59:59.9999999"); + jobDetail.InventoryQty = 0; + var detailNumber = await GetNumber().ConfigureAwait(false); + jobDetail.SetIdAndNumber(GuidGenerator, entity.Id, detailNumber); + jobDetail.CountLabel = GuidGenerator.Create().ToString(); + entity.Details.Add(jobDetail); + } + else + { + jobDepDetail.ArriveDate = detail.ArriveDate; + jobDepDetail.ProduceDate = detail.ProduceDate; + jobDepDetail.ExpireDate = detail.ExpireDate; + await entity.SetDetail(detail.Id, detail.SupplierBatch, detail.ArriveDate, detail.ProduceDate, detail.ExpireDate, detail.LocationCode, countCount, detail.CountTime, detail.CountOperator, detail.CountDescription) + .ConfigureAwait(false); + } + } + } + //移除原有明细里没有,并且第二次扫描以处的项目 + entity.Details.RemoveAll(r => r.InventoryQty == 0 && r.CountQty == 0 && r.InventoryStage == entity.InventoryStage); + } + public override void CheckDetails(CountJob entity, AbpValidationResult result) { var details = entity.Details; diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Jobs/CountJobs/ICountJobManager.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Jobs/CountJobs/ICountJobManager.cs index 19b46538a..7db5a0c54 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Jobs/CountJobs/ICountJobManager.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Jobs/CountJobs/ICountJobManager.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using System.Linq.Expressions; using System.Threading.Tasks; +using Volo.Abp.Users; using Win_in.Sfs.Shared.Domain.Shared; namespace Win_in.Sfs.Wms.Store.Domain; @@ -13,4 +14,5 @@ public interface ICountJobManager : IJobManager Task> CreateWithConditionAsync(CountPlan entity, List partCondition, List locCondition, List statusList); Task> ResetStatusByNumberAsync(List numbers); + Task ImportAsync(CountJob entity,List depDetails, ICurrentUser user); } From e0833e41e917cfb899cbdfff002f741c16a2d0ac Mon Sep 17 00:00:00 2001 From: lvzb <35200379@qq.com> Date: Fri, 26 Apr 2024 15:23:30 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E9=9D=9E=E7=94=9F=E4=BA=A7=E9=A2=86?= =?UTF-8?q?=E9=80=80=E6=96=99=E6=8E=A5=E5=8F=A3=E4=BF=AE=E6=94=B9=EF=BC=8C?= =?UTF-8?q?=E6=93=8D=E4=BD=9C=E4=BA=BA=E4=BC=A0=E8=AF=B7=E6=B1=82username?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Outgoing/UnplannedIssueNoteConverter.cs | 17 +++++++++++++---- .../Outgoing/UnplannedReceiptNoteConverter.cs | 17 ++++++++++++++--- .../UnplannedIssueNoteExchangeDto.cs | 9 +++++++++ .../UnplannedReceiptNoteExchangeDto.cs | 8 ++++++++ ...s.Wms.DataExchange.Application.Contracts.xml | 10 ++++++++++ 5 files changed, 54 insertions(+), 7 deletions(-) diff --git a/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.TyrpAgent/Outgoing/UnplannedIssueNoteConverter.cs b/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.TyrpAgent/Outgoing/UnplannedIssueNoteConverter.cs index 05a75e3d7..05b6beeee 100644 --- a/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.TyrpAgent/Outgoing/UnplannedIssueNoteConverter.cs +++ b/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.TyrpAgent/Outgoing/UnplannedIssueNoteConverter.cs @@ -22,19 +22,22 @@ public class UnplannedIssueNoteConverter : IOutgoingConverter private readonly IDepartmentAppService _departmentAppService; private readonly IObjectMapper _objectMapper; private readonly ISfsUserAppService _sfsUserAppService; + private readonly IUnplannedIssueRequestAppService _unplannedIssueRequestAppService; public UnplannedIssueNoteConverter( IOutgoingFromWmsManager outgoingFromWmsManager , IOutgoingToExternalManager outgoingToExternalManager , IDepartmentAppService departmentAppService , IObjectMapper objectMapper - , ISfsUserAppService sfsUserAppService) + , ISfsUserAppService sfsUserAppService, +IUnplannedIssueRequestAppService unplannedIssueRequestAppService) { _outgoingFromWmsManager = outgoingFromWmsManager; _outgoingToExternalManager = outgoingToExternalManager; _departmentAppService = departmentAppService; _objectMapper = objectMapper; _sfsUserAppService = sfsUserAppService; + _unplannedIssueRequestAppService = unplannedIssueRequestAppService; } /// @@ -54,6 +57,12 @@ public class UnplannedIssueNoteConverter : IOutgoingConverter var exchangeReceipt = _objectMapper.Map(wmsReceipt); var department = await _departmentAppService.GetByUsernameAsync(exchangeReceipt.Worker).ConfigureAwait(false); var departmentCode = department == null ? "" : department.Code; + var requset = await _unplannedIssueRequestAppService.GetByNumberAsync(exchangeReceipt.UnplannedIssueRequestNumber).ConfigureAwait(false); + string worker = requset?.Worker; + if (!string.IsNullOrEmpty(worker)) + { + worker = await _sfsUserAppService.GetUserNameByUserAsync(requset.Worker).ConfigureAwait(false); + } //if (Guid.TryParse(exchangeReceipt.CreatorId.ToString(), out Guid guid)) //{ // var username = await _sfsUserAppService.GetUserNameById(guid).ConfigureAwait(false); @@ -63,7 +72,7 @@ public class UnplannedIssueNoteConverter : IOutgoingConverter // } //} - var purchaseOrder = BuildDataInterface(exchangeReceipt, tyrpNumber, departmentCode); + var purchaseOrder = BuildDataInterface(exchangeReceipt, tyrpNumber, departmentCode, worker); var outgoingToExternal = new OutgoingToExternal() { DataType = EnumOutgoingDataType.UnplannedIssue.ToString(), @@ -123,7 +132,7 @@ public class UnplannedIssueNoteConverter : IOutgoingConverter /// /// /// - private Wmsoutm BuildDataInterface(UnplannedIssueNoteExchangeDto exchangeOrder,string tyrpNumber,string departmentCode) + private Wmsoutm BuildDataInterface(UnplannedIssueNoteExchangeDto exchangeOrder,string tyrpNumber,string departmentCode,string worker) { string billtype = "4013"; if (exchangeOrder.UnplannedIssueType== EnumUnplannedIssueType.Wip) @@ -137,7 +146,7 @@ public class UnplannedIssueNoteConverter : IOutgoingConverter wmsoutm_dt_w = DateTime.Now.ToString("yyyyMMdd HH:mm:ss"), wmsoutm_stat = "Y", wmsoutm_tyrp_dt = "", - wmsoutm_user = exchangeOrder.Worker.Length >= 6 ? exchangeOrder.Worker.Substring(exchangeOrder.Worker.Length- 6) : exchangeOrder.Worker, + wmsoutm_user = worker.Length >= 6 ? worker.Substring(worker.Length- 6) : worker, wmsoutm_dept = departmentCode,//根据Worker从UserDepartment中获取 // wmsoutm_date = exchangeOrder.ActiveDate.ToString("yyyyMMdd"), wmsoutm_date = DateTime.Now.ToString("yyyyMMdd"), diff --git a/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.TyrpAgent/Outgoing/UnplannedReceiptNoteConverter.cs b/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.TyrpAgent/Outgoing/UnplannedReceiptNoteConverter.cs index 1a5cb0d4d..e6cf534ed 100644 --- a/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.TyrpAgent/Outgoing/UnplannedReceiptNoteConverter.cs +++ b/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.TyrpAgent/Outgoing/UnplannedReceiptNoteConverter.cs @@ -23,6 +23,7 @@ public class UnplannedReceiptNoteConverter : IOutgoingConverter private readonly IDepartmentAppService _departmentAppService; private readonly IObjectMapper _objectMapper; private readonly ISfsUserAppService _sfsUserAppService; + private readonly IUnplannedReceiptRequestAppService _unplannedReceiptRequestAppService; public UnplannedReceiptNoteConverter( IOutgoingFromWmsManager outgoingFromWmsManager @@ -30,6 +31,9 @@ public class UnplannedReceiptNoteConverter : IOutgoingConverter , IDepartmentAppService departmentAppService , IObjectMapper objectMapper , ISfsUserAppService sfsUserAppService +, +IUnplannedReceiptRequestAppService unplannedReceiptRequestAppService + ) { _outgoingFromWmsManager = outgoingFromWmsManager; @@ -37,6 +41,7 @@ public class UnplannedReceiptNoteConverter : IOutgoingConverter _departmentAppService = departmentAppService; _objectMapper = objectMapper; _sfsUserAppService = sfsUserAppService; + _unplannedReceiptRequestAppService = unplannedReceiptRequestAppService; } /// @@ -56,6 +61,12 @@ public class UnplannedReceiptNoteConverter : IOutgoingConverter var exchangeReceipt = _objectMapper.Map(wmsReceipt); var department = await _departmentAppService.GetByUsernameAsync(exchangeReceipt.Worker).ConfigureAwait(false); var departmentCode = department == null ? "" : department.Code; + var requset = await _unplannedReceiptRequestAppService.GetByNumberAsync(exchangeReceipt.UnplannedReceiptRequestNumber).ConfigureAwait(false); + string worker = requset?.Worker; + if (!string.IsNullOrEmpty(worker)) + { + worker = await _sfsUserAppService.GetUserNameByUserAsync(requset.Worker).ConfigureAwait(false); + } //if (Guid.TryParse(exchangeReceipt.CreatorId.ToString(), out Guid guid)) //{ // var username = await _sfsUserAppService.GetUserNameById(guid).ConfigureAwait(false); @@ -64,7 +75,7 @@ public class UnplannedReceiptNoteConverter : IOutgoingConverter // exchangeReceipt.Worker = username; // } //} - var purchaseOrder = BuildDataInterface(exchangeReceipt, tyrpNumber, departmentCode); + var purchaseOrder = BuildDataInterface(exchangeReceipt, tyrpNumber, departmentCode, worker); var outgoingToExternal = new OutgoingToExternal() { DataType = EnumOutgoingDataType.UnplannedReceipt.ToString(), @@ -124,7 +135,7 @@ public class UnplannedReceiptNoteConverter : IOutgoingConverter /// /// /// - private Wmsoutm BuildDataInterface(UnplannedReceiptNoteExchangeDto exchangeOrder, string tyrpNumber,string departmentCode) + private Wmsoutm BuildDataInterface(UnplannedReceiptNoteExchangeDto exchangeOrder, string tyrpNumber,string departmentCode,string worker) { string billtype = "4014"; if (exchangeOrder.UnplannedReceiptType == EnumUnplannedReceiptType.Wip) @@ -138,7 +149,7 @@ public class UnplannedReceiptNoteConverter : IOutgoingConverter wmsoutm_dt_w = DateTime.Now.ToString("yyyyMMdd HH:mm:ss"), wmsoutm_stat = "Y", wmsoutm_tyrp_dt = "", - wmsoutm_user = exchangeOrder.Worker.Length>=6? exchangeOrder.Worker.Substring(exchangeOrder.Worker.Length-6) : exchangeOrder.Worker, + wmsoutm_user = worker.Length>=6? worker.Substring(worker.Length-6) : worker, wmsoutm_dept = departmentCode,//根据Worker从UserDepartment中获取 //wmsoutm_date = exchangeOrder.ActiveDate.ToString("yyyyMMdd"), wmsoutm_date = DateTime.Now.ToString("yyyyMMdd"), diff --git a/be/DataExchange/src/Win_in.Sfs.Wms.DataExchange.Application.Contracts/WMS/UnplannedIssueNote/UnplannedIssueNoteExchangeDto.cs b/be/DataExchange/src/Win_in.Sfs.Wms.DataExchange.Application.Contracts/WMS/UnplannedIssueNote/UnplannedIssueNoteExchangeDto.cs index b27945058..8ce513ce2 100644 --- a/be/DataExchange/src/Win_in.Sfs.Wms.DataExchange.Application.Contracts/WMS/UnplannedIssueNote/UnplannedIssueNoteExchangeDto.cs +++ b/be/DataExchange/src/Win_in.Sfs.Wms.DataExchange.Application.Contracts/WMS/UnplannedIssueNote/UnplannedIssueNoteExchangeDto.cs @@ -1,4 +1,8 @@ using System; +using IdentityServer4.Models; +using System.ComponentModel.DataAnnotations; +using System.Xml.Linq; +using Win_in.Sfs.Shared.Domain; using Win_in.Sfs.Shared.Domain.Shared.Enums.Store; namespace Win_in.Sfs.Wms.DataExchange.WMS.UnplannedIssueNote; @@ -27,4 +31,9 @@ public class UnplannedIssueNoteExchangeDto /// 领料类别 /// public EnumUnplannedIssueType UnplannedIssueType { get; set; } + + /// + /// 计划外出库请求单号 + /// + public string UnplannedIssueRequestNumber { get; set; } } diff --git a/be/DataExchange/src/Win_in.Sfs.Wms.DataExchange.Application.Contracts/WMS/UnplannedReceiptNote/UnplannedReceiptNoteExchangeDto.cs b/be/DataExchange/src/Win_in.Sfs.Wms.DataExchange.Application.Contracts/WMS/UnplannedReceiptNote/UnplannedReceiptNoteExchangeDto.cs index abae086af..e21240614 100644 --- a/be/DataExchange/src/Win_in.Sfs.Wms.DataExchange.Application.Contracts/WMS/UnplannedReceiptNote/UnplannedReceiptNoteExchangeDto.cs +++ b/be/DataExchange/src/Win_in.Sfs.Wms.DataExchange.Application.Contracts/WMS/UnplannedReceiptNote/UnplannedReceiptNoteExchangeDto.cs @@ -1,4 +1,8 @@ using System; +using IdentityServer4.Models; +using System.ComponentModel.DataAnnotations; +using System.Xml.Linq; +using Win_in.Sfs.Shared.Domain; using Win_in.Sfs.Shared.Domain.Shared.Enums.Store; namespace Win_in.Sfs.Wms.DataExchange.WMS.UnplannedReceiptNote; @@ -28,5 +32,9 @@ public class UnplannedReceiptNoteExchangeDto /// 退料类别 /// public EnumUnplannedReceiptType UnplannedReceiptType { get; set; } + /// + /// 计划外入库请求单号 + /// + public string UnplannedReceiptRequestNumber { get; set; } } diff --git a/be/DataExchange/src/Win_in.Sfs.Wms.DataExchange.Application.Contracts/Win_in.Sfs.Wms.DataExchange.Application.Contracts.xml b/be/DataExchange/src/Win_in.Sfs.Wms.DataExchange.Application.Contracts/Win_in.Sfs.Wms.DataExchange.Application.Contracts.xml index c979bbb94..a9660cc25 100644 --- a/be/DataExchange/src/Win_in.Sfs.Wms.DataExchange.Application.Contracts/Win_in.Sfs.Wms.DataExchange.Application.Contracts.xml +++ b/be/DataExchange/src/Win_in.Sfs.Wms.DataExchange.Application.Contracts/Win_in.Sfs.Wms.DataExchange.Application.Contracts.xml @@ -1801,6 +1801,11 @@ 领料类别 + + + 计划外出库请求单号 + + 单据号 @@ -1861,6 +1866,11 @@ 退料类别 + + + 计划外入库请求单号 + + 用户号码 From 73f2040f362c3cbdfb4836c5322b886014c81369 Mon Sep 17 00:00:00 2001 From: lvzb <35200379@qq.com> Date: Mon, 29 Apr 2024 10:52:56 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E7=9B=98=E7=82=B9=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Outgoing/CountAdjustNoteConverter.cs | 6 ++-- .../Jobs/CountJobs/CountJobManager.cs | 36 ++++++++++--------- 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.TyrpAgent/Outgoing/CountAdjustNoteConverter.cs b/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.TyrpAgent/Outgoing/CountAdjustNoteConverter.cs index a5990abd1..0463e5d8a 100644 --- a/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.TyrpAgent/Outgoing/CountAdjustNoteConverter.cs +++ b/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.TyrpAgent/Outgoing/CountAdjustNoteConverter.cs @@ -75,7 +75,7 @@ public class CountAdjustNoteConverter : IOutgoingConverter DestinationDataId = "", }; outgoingToExternal.SetEffectiveDate(outgoingFromWms.EffectiveDate); - var exchangeIssue = await BuildPurchaseReceiptExchangeDtoAsync(wmsCountAdjust, detail).ConfigureAwait(false); + var exchangeIssue = BuildPurchaseReceiptExchangeDtoAsync(wmsCountAdjust, detail); outgoingToExternal.SourceDataContent = JsonSerializer.Serialize(exchangeIssue); var arrive = BuildWip(exchangeIssue, departmentCode); outgoingToExternal.DestinationDataContent = JsonSerializer.Serialize(arrive); @@ -103,7 +103,7 @@ public class CountAdjustNoteConverter : IOutgoingConverter DestinationDataId = "", }; outgoingToExternal.SetEffectiveDate(outgoingFromWms.EffectiveDate); - var exchangeIssue = await BuildPurchaseReceiptExchangeDtoAsync(wmsCountAdjust, detail).ConfigureAwait(false); + var exchangeIssue = BuildPurchaseReceiptExchangeDtoAsync(wmsCountAdjust, detail); outgoingToExternal.SourceDataContent = JsonSerializer.Serialize(exchangeIssue); var arrive = BuildIssue(exchangeIssue, departmentCode); outgoingToExternal.DestinationDataContent = JsonSerializer.Serialize(arrive); @@ -159,7 +159,7 @@ public class CountAdjustNoteConverter : IOutgoingConverter }; return counta; } - private async Task BuildPurchaseReceiptExchangeDtoAsync( + private CountAdjustNoteExchangeDto BuildPurchaseReceiptExchangeDtoAsync( CountAdjustNoteDTO wmsCountAdjust, CountAdjustNoteDetailExchangeDto wmsCountAdjustDetail) { var exchangeCountAdjust = _objectMapper.Map(wmsCountAdjust); diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Jobs/CountJobs/CountJobManager.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Jobs/CountJobs/CountJobManager.cs index e56660a5e..3297f432b 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Jobs/CountJobs/CountJobManager.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Jobs/CountJobs/CountJobManager.cs @@ -320,28 +320,30 @@ public class CountJobManager : SfsJobManagerBase, ICou jobDepDetail.SetIdAndNumber(GuidGenerator, entity.Id, number); jobDepDetail.CountLabel = GuidGenerator.Create().ToString(); entity.DepDetails.Add(jobDepDetail); - - if (detail == null) - { - var jobDetail = ObjectMapper.Map(depDetail); - jobDetail.ArriveDate = DateTime.Now; - jobDetail.ProduceDate = DateTime.Now; - jobDetail.ExpireDate = DateTime.Parse("9999-12-31 23:59:59.9999999"); - jobDetail.InventoryQty = 0; - var detailNumber = await GetNumber().ConfigureAwait(false); - jobDetail.SetIdAndNumber(GuidGenerator, entity.Id, detailNumber); - jobDetail.CountLabel = GuidGenerator.Create().ToString(); - entity.Details.Add(jobDetail); - } - else + if (detail != null) { jobDepDetail.ArriveDate = detail.ArriveDate; jobDepDetail.ProduceDate = detail.ProduceDate; jobDepDetail.ExpireDate = detail.ExpireDate; - await entity.SetDetail(detail.Id, detail.SupplierBatch, detail.ArriveDate, detail.ProduceDate, detail.ExpireDate, detail.LocationCode, countCount, detail.CountTime, detail.CountOperator, detail.CountDescription) - .ConfigureAwait(false); } - } + } + if (detail == null) + { + var jobDetail = ObjectMapper.Map(depDetail); + jobDetail.ArriveDate = DateTime.Now; + jobDetail.ProduceDate = DateTime.Now; + jobDetail.ExpireDate = DateTime.Parse("9999-12-31 23:59:59.9999999"); + jobDetail.InventoryQty = 0; + var detailNumber = await GetNumber().ConfigureAwait(false); + jobDetail.SetIdAndNumber(GuidGenerator, entity.Id, detailNumber); + jobDetail.CountLabel = GuidGenerator.Create().ToString(); + entity.Details.Add(jobDetail); + } + else + { + await entity.SetDetail(detail.Id, detail.SupplierBatch, detail.ArriveDate, detail.ProduceDate, detail.ExpireDate, detail.LocationCode, countCount, detail.CountTime, detail.CountOperator, detail.CountDescription) + .ConfigureAwait(false); + } } //移除原有明细里没有,并且第二次扫描以处的项目 entity.Details.RemoveAll(r => r.InventoryQty == 0 && r.CountQty == 0 && r.InventoryStage == entity.InventoryStage); From eae8a7a1269ba601993eb6a117e9b9f5353f73dd Mon Sep 17 00:00:00 2001 From: lvzb <35200379@qq.com> Date: Mon, 29 Apr 2024 14:17:43 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E7=9B=98=E7=82=B9=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CountJobs/Inputs/CountJobImportInput.cs | 4 ++-- .../Jobs/CountJobs/CountJobAppService.cs | 23 +++++++++++-------- .../Plans/CountPlans/CountPlanManager.cs | 3 ++- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Jobs/CountJobs/Inputs/CountJobImportInput.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Jobs/CountJobs/Inputs/CountJobImportInput.cs index f6a3f05b5..75b1e526a 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Jobs/CountJobs/Inputs/CountJobImportInput.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Jobs/CountJobs/Inputs/CountJobImportInput.cs @@ -30,7 +30,7 @@ public class CountJobImportInput : SfsStoreImportInputBase /// 箱码 /// [Display(Name = "箱码")] - public string PackingCode { get; set; } + public string PackingCode { get; set; } = ""; /// /// 库存状态 @@ -43,7 +43,7 @@ public class CountJobImportInput : SfsStoreImportInputBase /// 批次 /// [Display(Name = "批次")] - public string Lot { get; set; } + public string Lot { get; set; } = ""; /// /// 盘点数量 diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/CountJobs/CountJobAppService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/CountJobs/CountJobAppService.cs index f644c244f..754c7856b 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/CountJobs/CountJobAppService.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/CountJobs/CountJobAppService.cs @@ -206,19 +206,24 @@ public class CountJobAppService } protected async Task CheckPackingCodeAsync(CountJobImportInput importInput, List validationRresult, string locationCode) { - var item = await _balanceAppService.GetByPackingCodeAsync(importInput.PackingCode).ConfigureAwait(false); - if (item != null) + if (!string.IsNullOrEmpty(importInput.PackingCode)) { - if (item.LocationCode != locationCode) + var item = await _balanceAppService.GetByPackingCodeAsync(importInput.PackingCode).ConfigureAwait(false); + if (item != null) { - validationRresult.Add(new ValidationResult($"箱码已经在库位{item.LocationCode}存在不能盘点", new[] { "箱码" })); - } - if(item.Lot!= importInput.Lot) - { - validationRresult.Add(new ValidationResult($"批次与库存中批次{item.Lot}不匹配不能盘点", new[] { "批次" })); + if (item.LocationCode != locationCode) + { + validationRresult.Add(new ValidationResult($"箱码已经在库位{item.LocationCode}存在不能盘点", new[] { "箱码" })); + } + if (item.Lot != importInput.Lot) + { + validationRresult.Add(new ValidationResult($"批次与库存中批次{item.Lot}不匹配不能盘点", new[] { "批次" })); + } } + return item; } - return item; + + return null; } protected void CheckJobNumberAsync(CountJobImportInput importInput, List validationRresult,string jobNumber) { diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Plans/CountPlans/CountPlanManager.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Plans/CountPlans/CountPlanManager.cs index c3fc2bd91..f60603fae 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Plans/CountPlans/CountPlanManager.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Plans/CountPlans/CountPlanManager.cs @@ -321,7 +321,8 @@ public class CountPlanManager : SfsStoreRequestManagerBase p.CountLabel == planDetail.CountLabel); + //var entityDetail = entity.Details.FirstOrDefault(p => p.CountLabel == planDetail.CountLabel); + var entityDetail = entity.Details.FirstOrDefault(p => p.ItemCode == planDetail.ItemCode && p.PackingCode == planDetail.PackingCode&& p.Lot == planDetail.Lot &&p.LocationCode == planDetail.LocationCode); if (entityDetail == null) { entityDetail = ObjectMapper.Map(planDetail);