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); }