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 32b0748f3..f78a44b90 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 @@ -907,8 +907,28 @@ public class AssembleIssueJobAppService [HttpPost("call-back-agv")] public async Task CallBackAgvIssueAsync(AgvRequestDto request) { + List errors = new List(); + if(request.Data.Count==0) + { + return new AgvResultObject + { + Code = "-1", + Message = "请求明细数量不能为0", + ReqCode = "", + }; + } + var entity=await _repository.FindAsync(p => p.Number == request.Data.First().OrderNum).ConfigureAwait(false); var dto=ObjectMapper.Map(entity); + if (entity.JobStatus == EnumJobStatus.Done) + { + return new AgvResultObject + { + Code = "-1", + Message = $"{entity.Number}任务已结束", + ReqCode = "", + }; + } foreach (var detail in entity.Details) { diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/UnplannedIssueJobs/UnplannedIssueJobAppService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/UnplannedIssueJobs/UnplannedIssueJobAppService.cs index d0988cdef..392a66530 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/UnplannedIssueJobs/UnplannedIssueJobAppService.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/UnplannedIssueJobs/UnplannedIssueJobAppService.cs @@ -477,128 +477,6 @@ public class UnplannedIssueJobAppService var job = await _repository.GetAsync(id).ConfigureAwait(false); var isHasAgvFlag = false; - - //var details = ObjectMapper.Map, List>(detailDtos); - //var job = await _repository.FindAsync(p => p.Number == jobNumber).ConfigureAwait(false); - //var isHasAgvFlag = false; - - //if (job == null) - //{ - // throw new UserFriendlyException($"{jobNumber}【任务】不存在"); - //} - - //if (job.JobStatus != EnumJobStatus.Doing) - //{ - // throw new UserFriendlyException($"{jobNumber}【任务】不是【执行】状态"); - //} - - //if (detailDtos.Count(p => p.ItemCode != job.ItemCode) > 0) - //{ - // throw new UserFriendlyException("请确认ERP料号是否正确"); - //} - - //if (detailDtos.Sum(p => p.HandledQty) > job.Qty) - //{ - // throw new UserFriendlyException("实际数量大于申请数量"); - //} - - //foreach (var detail in details) - //{ - // var locationDto = await _locationAppService.GetByCodeAsync(detail.HandledToLocationCode).ConfigureAwait(false); - // var itemBasicDto = await _itemBasicAppService.GetByCodeAsync(detail.ItemCode).ConfigureAwait(false); - - // detail.HandledToLocationArea = locationDto.AreaCode; - // detail.HandledToLocationErpCode = locationDto.ErpLocationCode; - // detail.HandledToLocationGroup = locationDto.LocationGroupCode; - // detail.HandledToLocationCode = locationDto.Code; - // detail.Status = EnumInventoryStatus.OK; - // detail.HandledArriveDate = DateTime.Now; - // detail.HandledProduceDate = DateTime.Now; - // detail.Uom = itemBasicDto.BasicUom; - // detail.ItemName = itemBasicDto.Name; - // detail.ItemDesc1 = itemBasicDto.Desc1; - // detail.ItemDesc2 = itemBasicDto.Desc2; - // detail.StdPackQty = itemBasicDto.StdPackQty; - // #region 过期时间 - - // if (itemBasicDto.ValidityUnit == EnumValidityUnit.Day) - // { - // detail.HandledExpireDate = detail.HandledArriveDate.AddDays(itemBasicDto.Validity); - // } - // else if (itemBasicDto.ValidityUnit == EnumValidityUnit.WeeK) - // { - // detail.HandledExpireDate = detail.HandledArriveDate.AddDays(itemBasicDto.Validity * 7); - // } - // else if (itemBasicDto.ValidityUnit == EnumValidityUnit.Month) - // { - // detail.HandledExpireDate = detail.HandledArriveDate.AddDays(itemBasicDto.Validity * 30); - // } - // else if (itemBasicDto.ValidityUnit == EnumValidityUnit.Infinite) - // { - // detail.HandledExpireDate = DateTime.MaxValue; - // } - - // #endregion - - // if (locationDto.ErpLocationCode != job.FromErpLocationCode) - // { - // throw new UserFriendlyException($"库位【{locationDto.ErpLocationCode}】不在【{job.FromErpLocationCode}】储位下"); - // } - - // if (locationDto.Type == EnumLocationType.DimensionalStorehouse) - // { - // throw new UserFriendlyException("立库功能暂未开放"); - // } - - // var dto = await _locationDeliveryAppService.GetByFromLocationCodeAndToLocationCodeAsync(detail.HandledToLocationCode, detail.HandledToLocationCode).ConfigureAwait(false); - // if (dto != null) - // { - // await CallAgvAsync(job, detail).ConfigureAwait(false); - // isHasAgvFlag = true; - // } - //} - - //job.Details = details; - //job.CompleteUserName = worker; - //job.JobStatus = EnumJobStatus.Done; - //job.CompleteTime = DateTime.Now; - //job.Worker = worker; - - //if (isHasAgvFlag) - //{ - // job.JobStatus = EnumJobStatus.WaitAgv; - //} - - //job = await _repository.UpdateAsync(job).ConfigureAwait(false); - - //if (!isHasAgvFlag)//没有AGV就执行 - //{ - // await LocalEventBus.PublishAsync(new SfsCompletedEntityEventData(job), false) - // .ConfigureAwait(false); - // await UpdateRequestStatusAsync(job.UnplannedReceiptRequestNumber).ConfigureAwait(false); - //} - - - - - - - - - - - - - - - - - - - - - - if (dto.Details.Count > 0) { @@ -801,8 +679,13 @@ public class UnplannedIssueJobAppService } else { - + handleDto = ObjectMapper.Map(job); } + + + + + //}; @@ -850,20 +733,35 @@ public class UnplannedIssueJobAppService [HttpPost("call-back-agv")] public async Task CallBackAgvAsync(AgvRequestUnplannedDto request) { + + if (request.Data.Count == 0) + { + return ReturnMessage("-1", "请求明细Data数量不能为0"); + } + var agvRequest = request.Data.First(); var job = await _repository.FindAsync(p => p.Number == agvRequest.OrderNum).ConfigureAwait(false); if (job == null) { - throw new UserFriendlyException("未找到该任务"); + + return ReturnMessage("-1", $"{agvRequest.OrderNum}未找到该任务"); + } if (job.JobStatus != EnumJobStatus.WaitAgv) { - throw new UserFriendlyException("该任务状态不是等待AGV中"); + + return ReturnMessage("-1", "该任务状态不是等待AGV中"); + } + - var toLocationDto = await _locationAppService.GetByCodeAsync(agvRequest.EndPosition).ConfigureAwait(false); + var toLocationDto = await _locationAppService.GetByCodeAsync(agvRequest.EndPosition ).ConfigureAwait(false);//agvRequest.BeginPosition调试时确认 + if (toLocationDto == null) + { + return ReturnMessage("-1", $"{agvRequest.EndPosition}库位没查到!"); + } var detail = job.Details.First(); detail.HandledQty = agvRequest.MatQty; @@ -873,37 +771,34 @@ public class UnplannedIssueJobAppService detail.HandledFromLocationGroup = toLocationDto.LocationGroupCode; detail.HandledFromLocationArea = toLocationDto.AreaCode; detail.HandledFromLocationErpCode = toLocationDto.ErpLocationCode; - + job.JobStatus= EnumJobStatus.Done; job = await _repository.UpdateAsync(job).ConfigureAwait(false); await LocalEventBus.PublishAsync(new SfsCompletedEntityEventData(job), false) .ConfigureAwait(false); await UpdateRequestStatusAsync(job.UnplannedIssueRequestNumber).ConfigureAwait(false);//await ExecuteDetailExtAsync(itm.Id, entity.Id, dto).ConfigureAwait(false); + return ReturnMessage("0", "OK"); + } + + /// + /// 返回信息 + /// + /// 0成功其他失败 + /// OK成功其他错误信息 + /// + private AgvResultObject ReturnMessage(string code, string message) + { return new AgvResultObject() { - Code = "", - Message = "", + Code = code, + Message = message, ReqCode = "" }; } - ///// - ///// Agv 回库 接口 - ///// - ///// - ///// - //[HttpPost("call-return-back-agv")] - //public async Task CallReturnBackAgvAsync(AgvRequestDto request) - //{ - - - - - - - //} + /// /// 调用Agv接口实现 diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/UnplannedReceiptJobs/UnplannedReceiptJobAppService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/UnplannedReceiptJobs/UnplannedReceiptJobAppService.cs index e550968d7..64da11afc 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/UnplannedReceiptJobs/UnplannedReceiptJobAppService.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/UnplannedReceiptJobs/UnplannedReceiptJobAppService.cs @@ -387,21 +387,26 @@ public class UnplannedReceiptJobAppService [HttpPost("call-back-agv")] public async Task CallBackAgvAsync(AgvRequestUnplannedDto request) { - var agvRequest = request.Data.First(); + if (request.Data.Count == 0) + { + return ReturnMessage("-1", "请求明细Data数量不能为0"); + } + var agvRequest = request.Data.First(); var job = await _repository.FindAsync(p => p.Number == agvRequest.OrderNum).ConfigureAwait(false); if (job == null) { - throw new UserFriendlyException("未找到该任务"); + return ReturnMessage("-1", $"{agvRequest.OrderNum}未找到该任务"); } - if (job.JobStatus != EnumJobStatus.WaitAgv) { - throw new UserFriendlyException("该任务状态不是等待AGV中"); + return ReturnMessage("-1", "该任务状态不是等待AGV中"); } - var toLocationDto = await _locationAppService.GetByCodeAsync(agvRequest.EndPosition).ConfigureAwait(false); - + if (toLocationDto == null) + { + return ReturnMessage("-1", $"{agvRequest.EndPosition}库位没查到!"); + } var detail = job.Details.First(); detail.HandledQty = agvRequest.MatQty; detail.HandledPackingCode = agvRequest.PakingCode; @@ -410,16 +415,26 @@ public class UnplannedReceiptJobAppService detail.HandledToLocationGroup = toLocationDto.LocationGroupCode; detail.HandledToLocationArea = toLocationDto.AreaCode; detail.HandledToLocationErpCode = toLocationDto.ErpLocationCode; - + job.JobStatus = EnumJobStatus.Done; job = await _repository.UpdateAsync(job).ConfigureAwait(false); await LocalEventBus.PublishAsync(new SfsCompletedEntityEventData(job), false) .ConfigureAwait(false); await UpdateRequestStatusAsync(job.UnplannedReceiptRequestNumber).ConfigureAwait(false);//await ExecuteDetailExtAsync(itm.Id, entity.Id, dto).ConfigureAwait(false); + return ReturnMessage("0", "OK"); + } + /// + /// 返回信息 + /// + /// 0成功其他失败 + /// OK成功其他错误信息 + /// + private AgvResultObject ReturnMessage(string code, string message) + { return new AgvResultObject() { - Code = "0", - Message = "OK", + Code = code, + Message = message, ReqCode = "" }; }