diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/AssembleIssueJobs/AssembleIssueJobAppService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/AssembleIssueJobs/AssembleIssueJobAppService.cs index 9d964a877..e9e264da5 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/AssembleIssueJobs/AssembleIssueJobAppService.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/AssembleIssueJobs/AssembleIssueJobAppService.cs @@ -210,6 +210,17 @@ public class AssembleIssueJobAppService { var assembleIssueJob = await _repository.GetAsync(masterId).ConfigureAwait(false); assembleIssueJob.JobStatus = EnumJobStatus.Doing; + if (assembleIssueJob.IsClaims) + { + if (assembleIssueJob.ClaimsUserId != _currentUser.Id.ToString()) + { + throw new UserFriendlyException($"该任务已被【{assembleIssueJob.ClaimsUserName}】承接"); + } + } + else + { + throw new UserFriendlyException("该任务未被承接,请重新刷新页面,承接任务"); + } var assembleIssueJobDto = ObjectMapper.Map(assembleIssueJob); assembleIssueJobDto.Details = new List { issueJobDetailDto }; @@ -253,6 +264,7 @@ public class AssembleIssueJobAppService } await _repository.UpdateAsync(assembleIssueJob).ConfigureAwait(false); + await CancelAcceptAsync(masterId).ConfigureAwait(false); } /// diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/CoatingIssueJobs/CoatingIssueJobAppService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/CoatingIssueJobs/CoatingIssueJobAppService.cs index f24e687d5..0f796ca16 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/CoatingIssueJobs/CoatingIssueJobAppService.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/CoatingIssueJobs/CoatingIssueJobAppService.cs @@ -7,12 +7,14 @@ using System.Text; using System.Text.Json; using System.Threading.Tasks; using Castle.Components.DictionaryAdapter; +using IdentityServer4.Extensions; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; using MyNamespace; using Volo.Abp; +using Volo.Abp.Domain.Entities; using Volo.Abp.ObjectMapping; using Volo.Abp.Uow; using Volo.Abp.Users; @@ -208,7 +210,18 @@ public class CoatingIssueJobAppService { var coatingIssueJob = await _repository.GetAsync(masterId).ConfigureAwait(false); coatingIssueJob.JobStatus = EnumJobStatus.Doing; - + if (coatingIssueJob.IsClaims) + { + if (coatingIssueJob.ClaimsUserId != _currentUser.Id.ToString()) + { + throw new UserFriendlyException($"该任务已被【{coatingIssueJob.ClaimsUserName}】承接"); + } + } + else + { + throw new UserFriendlyException("该任务未被承接,请重新刷新页面,承接任务"); + } + var coatingIssueJobDto = ObjectMapper.Map(coatingIssueJob); var fromLocationDto=await _locationAppService.GetByCodeAsync(issueJobDetailDto.HandledFromLocationCode).ConfigureAwait(false); @@ -265,6 +278,7 @@ public class CoatingIssueJobAppService } await _repository.UpdateAsync(coatingIssueJob).ConfigureAwait(false); + await CancelAcceptAsync(masterId).ConfigureAwait(false); } /// @@ -310,6 +324,11 @@ public class CoatingIssueJobAppService } } + /// + /// 承接任务 + /// + /// + /// [HttpPost("accept/{id}")] [UnitOfWork] public override async Task AcceptAsync(Guid id) diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/InjectionIssueJobs/InjectionIssueJobAppService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/InjectionIssueJobs/InjectionIssueJobAppService.cs index 9604c5cb0..7edfa7635 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/InjectionIssueJobs/InjectionIssueJobAppService.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/InjectionIssueJobs/InjectionIssueJobAppService.cs @@ -202,6 +202,17 @@ public class InjectionIssueJobAppService { var injectionIssueJob = await _repository.GetAsync(masterId).ConfigureAwait(false); injectionIssueJob.JobStatus = EnumJobStatus.Doing; + if (injectionIssueJob.IsClaims) + { + if (injectionIssueJob.ClaimsUserId != _currentUser.Id.ToString()) + { + throw new UserFriendlyException($"该任务已被【{injectionIssueJob.ClaimsUserName}】承接"); + } + } + else + { + throw new UserFriendlyException("该任务未被承接,请重新刷新页面,承接任务"); + } var injectionIssueJobDto = ObjectMapper.Map(injectionIssueJob); injectionIssueJobDto.Details = new List { issueJobDetailDto }; @@ -244,6 +255,7 @@ public class InjectionIssueJobAppService } await _repository.UpdateAsync(injectionIssueJob).ConfigureAwait(false); + await CancelAcceptAsync(masterId).ConfigureAwait(false); } /// diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/KittingIssueJobs/KittingIssueJobAppService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/KittingIssueJobs/KittingIssueJobAppService.cs index 067b61a3b..1dcea8e63 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/KittingIssueJobs/KittingIssueJobAppService.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/KittingIssueJobs/KittingIssueJobAppService.cs @@ -201,6 +201,17 @@ public class KittingIssueJobAppService { var kittingIssueJob = await _repository.GetAsync(masterId).ConfigureAwait(false); kittingIssueJob.JobStatus = EnumJobStatus.Doing; + if (kittingIssueJob.IsClaims) + { + if (kittingIssueJob.ClaimsUserId != _currentUser.Id.ToString()) + { + throw new UserFriendlyException($"该任务已被【{kittingIssueJob.ClaimsUserName}】承接"); + } + } + else + { + throw new UserFriendlyException("该任务未被承接,请重新刷新页面,承接任务"); + } var kittingIssueJobDto = ObjectMapper.Map(kittingIssueJob); kittingIssueJobDto.Details = new List { issueJobDetailDto }; @@ -243,6 +254,7 @@ public class KittingIssueJobAppService } await _repository.UpdateAsync(kittingIssueJob).ConfigureAwait(false); + await CancelAcceptAsync(masterId).ConfigureAwait(false); } /// diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/SparePartIssueJobs/SparePartIssueJobAppService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/SparePartIssueJobs/SparePartIssueJobAppService.cs index a78a1d3c9..140635d3e 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/SparePartIssueJobs/SparePartIssueJobAppService.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/SparePartIssueJobs/SparePartIssueJobAppService.cs @@ -194,6 +194,17 @@ public class SparePartIssueJobAppService { var sparePartIssueJob = await _repository.GetAsync(masterId).ConfigureAwait(false); sparePartIssueJob.JobStatus = EnumJobStatus.Doing; + if (sparePartIssueJob.IsClaims) + { + if (sparePartIssueJob.ClaimsUserId != _currentUser.Id.ToString()) + { + throw new UserFriendlyException($"该任务已被【{sparePartIssueJob.ClaimsUserName}】承接"); + } + } + else + { + throw new UserFriendlyException("该任务未被承接,请重新刷新页面,承接任务"); + } var sparePartIssueJobDto = ObjectMapper.Map(sparePartIssueJob); sparePartIssueJobDto.Details = new List { issueJobDetailDto }; @@ -236,6 +247,7 @@ public class SparePartIssueJobAppService } await _repository.UpdateAsync(sparePartIssueJob).ConfigureAwait(false); + await CancelAcceptAsync(masterId).ConfigureAwait(false); } ///