From ad6c0668e009fc4437c99718f621893e982f3f16 Mon Sep 17 00:00:00 2001 From: "boxu.zheng" Date: Thu, 20 Mar 2025 15:54:56 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4agv=EF=BC=8C=E6=8B=86?= =?UTF-8?q?=E7=AE=B1=E4=B8=9A=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AssembleIssueJobAppService.cs | 299 +++----------- .../CoatingIssueJobAppService.cs | 378 +---------------- .../InjectionIssueJobAppService.cs | 367 +---------------- .../KittingIssueJobAppService.cs | 381 +----------------- .../SparePartIssueJobAppService.cs | 365 +---------------- .../UnplannedIssueJobAppService.cs | 165 +------- .../UnplannedReceiptJobAppService.cs | 147 +------ .../IntegrationPackingNoteAppService.cs | 91 +---- .../SeparationPackingNoteAppService.cs | 171 +------- 9 files changed, 97 insertions(+), 2267 deletions(-) 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 f0b11ec1b..c32251846 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 @@ -7,22 +7,15 @@ using System.Text; using System.Text.Json; using System.Threading.Tasks; using Castle.Components.DictionaryAdapter; -using DocumentFormat.OpenXml.Bibliography; -using DocumentFormat.OpenXml.Office2016.Excel; -using DocumentFormat.OpenXml.Spreadsheet; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; -using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; using MyNamespace; using Omu.ValueInjecter; -using Org.BouncyCastle.Asn1.Ocsp; using Volo.Abp; -using Volo.Abp.Domain.Entities; using Volo.Abp.Uow; using Volo.Abp.Users; -using Win_in.Sfs.Basedata.Application; using Win_in.Sfs.Basedata.Application.Contracts; using Win_in.Sfs.Shared.Domain.Shared; using Win_in.Sfs.Shared.Domain.Shared.Enums.Store; @@ -57,7 +50,7 @@ public class AssembleIssueJobAppService private readonly ICurrentUser _currentUser; private readonly UnitOfWorkManager _unitOfWorkManager; - + private readonly ILogger _logger; @@ -78,12 +71,9 @@ public class AssembleIssueJobAppService , IOptions agvOptions , IPostionLocationAppService postionLocationAppService, ILocationDeliveryAppService locationDeliveryAppService , ITransferNoteAppService transferNoteAppService - - ) : base( + ) : base( repository, assembleIssueJobManager - - - ) + ) { _postionLocationAppService = postionLocationAppService; _locationDeliveryAppService = locationDeliveryAppService; @@ -118,7 +108,8 @@ public class AssembleIssueJobAppService { await CheckMinRowAndSetStatusAsync(input).ConfigureAwait(false); //如果是立库 就给直接承接了 - var dimensionalStorehouseflag = await UpdateJobStatusWaitByDimensionalStorehouseAsync(input).ConfigureAwait(false); + var dimensionalStorehouseflag = + await UpdateJobStatusWaitByDimensionalStorehouseAsync(input).ConfigureAwait(false); if (dimensionalStorehouseflag) { input.IsClaims = true; @@ -152,7 +143,8 @@ public class AssembleIssueJobAppService { await DoingDimensionalStorehouseAsync(assembleIssueJobDto).ConfigureAwait(false); var firstDetail = assembleIssueJobDto.Details.First(); - await DoingAgvAsync(assembleIssueJobDto, firstDetail.RecommendFromLocationCode, firstDetail.RecommendToLocationCode).ConfigureAwait(false); + await DoingAgvAsync(assembleIssueJobDto, firstDetail.RecommendFromLocationCode, + firstDetail.RecommendToLocationCode).ConfigureAwait(false); } return assembleIssueJobDtos; @@ -162,7 +154,8 @@ public class AssembleIssueJobAppService public override async Task CreateAsync(AssembleIssueJobEditInput input) { await CheckMinRowAndSetStatusAsync(input).ConfigureAwait(false); - var flagDimensionalStorehouse= await UpdateJobStatusWaitByDimensionalStorehouseAsync(input).ConfigureAwait(false); + var flagDimensionalStorehouse = + await UpdateJobStatusWaitByDimensionalStorehouseAsync(input).ConfigureAwait(false); if (flagDimensionalStorehouse == false) { await UpdateJobStatusWaitByAgvAsync(input).ConfigureAwait(false); @@ -173,7 +166,8 @@ public class AssembleIssueJobAppService if (flagDimensionalStorehouse == false) { var firstDetail = assembleIssueJobDto.Details.First(); - await DoingAgvAsync(assembleIssueJobDto, firstDetail.RecommendFromLocationCode, firstDetail.RecommendToLocationCode).ConfigureAwait(false); + await DoingAgvAsync(assembleIssueJobDto, firstDetail.RecommendFromLocationCode, + firstDetail.RecommendToLocationCode).ConfigureAwait(false); } return assembleIssueJobDto; @@ -191,8 +185,8 @@ public class AssembleIssueJobAppService if (assembleJob.JobStatus == EnumJobStatus.Open || assembleJob.JobStatus == EnumJobStatus.Partial || assembleJob.JobStatus == EnumJobStatus.Wait || - assembleJob.JobStatus == EnumJobStatus.Doing|| - assembleJob.JobStatus==EnumJobStatus.WaitAgv) + assembleJob.JobStatus == EnumJobStatus.Doing || + assembleJob.JobStatus == EnumJobStatus.WaitAgv) { await _expectOutAppService.RemoveByNumberAsync(assembleJob.Number).ConfigureAwait(false); await _transferLibRequestAppService.CancelByCallRequestNumberAsync(assembleJob.AssembleRequestNumber) @@ -207,9 +201,9 @@ public class AssembleIssueJobAppService $"{EnumJobStatus.Open.GetDisplayName()}、" + $"{EnumJobStatus.Partial.GetDisplayName()}、" + $"{EnumJobStatus.Doing.GetDisplayName()}、" + - $"{EnumJobStatus.Wait.GetDisplayName()}"+ + $"{EnumJobStatus.Wait.GetDisplayName()}" + $"{EnumJobStatus.WaitAgv.GetDisplayName()}" - ); + ); } } @@ -429,16 +423,18 @@ public class AssembleIssueJobAppService [HttpPost("get-job-by-packing/{packingCode}")] public virtual async Task GetJobByPackingCodeAsync(string packingCode) { - var list = await _repository.GetListAsync(p => p.Details.Any(r => r.RecommendFromPackingCode == packingCode)).ConfigureAwait(false); + var list = await _repository.GetListAsync(p => p.Details.Any(r => r.RecommendFromPackingCode == packingCode)) + .ConfigureAwait(false); if (list == null || list.Count < 1) { throw new UserFriendlyException("未找到该箱码的任务"); } + var dto = ObjectMapper.Map(list.First()); return dto; } - #region 业务库移 高位置库位转低位置库位 + #region 业务库移 高位置库位转低位置库位 /// /// 库移回调 @@ -448,7 +444,7 @@ public class AssembleIssueJobAppService [HttpPost("Do-Call-Back")] public async Task DoTransferLibCallbackAsync(TransferLibJobDTO dto) { - var job = await _repository.FindAsync(p => p.Number == dto.CallJobNumber,true).ConfigureAwait(false); + var job = await _repository.FindAsync(p => p.Number == dto.CallJobNumber).ConfigureAwait(false); if (job.JobStatus != EnumJobStatus.Wait) { @@ -491,9 +487,11 @@ public class AssembleIssueJobAppService jobDetail.TransferLibToSupplierBatch = transferLibNoteDetail.HandledToSupplierBatch; jobDetail.TransferLibToWarehouseCode = transferLibNoteDetail.HandledToWarehouseCode; - var jobDto=ObjectMapper.Map(job); + var jobDto = ObjectMapper.Map(job); - var isDoingAgv=await DoingAgvAsync(jobDto, transferLibNoteDetail.HandledToLocationCode, jobDetail.RecommendToLocationCode).ConfigureAwait(false); + var isDoingAgv = + await DoingAgvAsync(jobDto, transferLibNoteDetail.HandledToLocationCode, jobDetail.RecommendToLocationCode) + .ConfigureAwait(false); _logger.LogInformation("是否agv:" + isDoingAgv); @@ -512,9 +510,9 @@ public class AssembleIssueJobAppService : _options.Value.StereosPassword; } - _logger.LogInformation("任务状态:"+job.JobStatus.ToString()); + _logger.LogInformation("任务状态:" + job.JobStatus); - job = await _repository.UpdateAsync(job,true).ConfigureAwait(false); + job = await _repository.UpdateAsync(job, true).ConfigureAwait(false); _logger.LogInformation("---------------结束回调"); @@ -708,7 +706,6 @@ public class AssembleIssueJobAppService foreach (var itm in dtos) { - var first = jobs.FirstOrDefault(p => p.JobNumber == itm.Number); var itmDetails = itm.Details.ToList(); var details = new List(); @@ -720,12 +717,14 @@ public class AssembleIssueJobAppService { errors.Add($"来源库位{detail.FromLocationCode}没查到"); } + var toloc = await _locationAppService.GetByCodeAsync(detail.ToLocationCode) .ConfigureAwait(false); if (toloc == null) { errors.Add($"目标库位{detail.ToLocationCode}没查到"); } + var entity = itmDetails.FirstOrDefault(p => p.ItemCode == detail.ItemCode); if (entity == null) { @@ -781,6 +780,7 @@ public class AssembleIssueJobAppService Data = json }; } + itm.Worker = "LITK"; itm.Details = details; // await CompleteAsync(itm.Id, itm).ConfigureAwait(false); @@ -830,56 +830,24 @@ public class AssembleIssueJobAppService /// /// /// - private async Task DoingAgvAsync(AssembleIssueJobDTO assembleIssueJobDto,string fromLocationCode,string toLocationCode) + private async Task DoingAgvAsync(AssembleIssueJobDTO assembleIssueJobDto, string fromLocationCode, + string toLocationCode) { - var jobDetailInputdetail = assembleIssueJobDto.Details.FirstOrDefault(); - var locationDeliveryDto = await _locationDeliveryAppService.GetByFromLocationCodeAndToLocationCodeAsync( - fromLocationCode, toLocationCode).ConfigureAwait(false); - - if (locationDeliveryDto != null && locationDeliveryDto.EnumLocationDeliveryType == EnumLocationDeliveryType.Agv) - { - //TODO AGV - //来源永远是库位 目标永远是工位 - var ret = await CallAgvAsync(assembleIssueJobDto, fromLocationCode, jobDetailInputdetail.Remark).ConfigureAwait(false); - - if (ret.Code != 0) - { - throw new UserFriendlyException($"调用AGV不成功!原因:{ret.Message}"); - } - else - { - return true; - } - } - else - { - return false; - } + return false; } /// - /// 判断是不是有Agv + /// 判断是不是有Agv /// /// /// private async Task UpdateJobStatusWaitByAgvAsync(AssembleIssueJobEditInput input) { - var jobDetailInputdetail = input.Details.FirstOrDefault(); - - var locationDeliveryDto=await _locationDeliveryAppService.GetByFromLocationCodeAndToLocationCodeAsync( - jobDetailInputdetail.RecommendFromLocationCode, jobDetailInputdetail.RecommendToLocationCode).ConfigureAwait(false); - - if (locationDeliveryDto!=null&& locationDeliveryDto.EnumLocationDeliveryType==EnumLocationDeliveryType.Agv) - { - input.JobStatus = EnumJobStatus.WaitAgv; - return true; - } - return false; } /// - /// 调用 Agv 接口 + /// 调用 Agv 接口 /// /// /// @@ -888,157 +856,34 @@ public class AssembleIssueJobAppService [HttpPost("call-agv")] public async Task CallAgvAsync(AssembleIssueJobDTO input, string beginPosition, string endPosition) { - var res = new ReusltObject(); - List errors = new List(); - List successList = new List(); - - var jobres = await SendInterFaceAsync(input, beginPosition, endPosition).ConfigureAwait(false); - if (jobres.Code != "0") - { - _logger.LogInformation(jobres.Message); - errors.Add(jobres.Message); - } - else - { - successList.Add(jobres.Message); - } - if (errors.Count > 0) - { - res.Code = -1; - res.Message = string.Join(",", errors); - res.Data = ""; - return res; - } - return res; + return null; } - /// - /// Agv 执行完发料回调接口 - /// - /// - /// - [HttpPost("call-back-agv")] + /// + /// Agv 执行完发料回调接口 + /// + /// + /// + [HttpPost("call-back-agv")] public async Task CallBackAgvIssueAsync(AgvRequestDto request) { - _logger.LogInformation($"发料回库{JsonSerializer.Serialize(request)}"); - - if (request.Data.Count==0) - { - return ReturnMessage("-1", "请求Data明细数量不能为0"); - } - var entity=await _repository.FindAsync(p => p.Number == request.Data.First().OrderNum).ConfigureAwait(false); - - if (entity == null) - { - return ReturnMessage("-1", $"{request.Data.First().OrderNum}任务单据不存在!"); - } - var dto=ObjectMapper.Map(entity); - if (entity.JobStatus == EnumJobStatus.Done) - { - return ReturnMessage("-1", $"{entity.Number}任务单据已结束!"); - } - - try - { - foreach (var detail in entity.Details) - { - var detailDto = new AssembleIssueJobDetailDTO(); - if (!string.IsNullOrEmpty(detail.TransferLibFromLocationCode)) - { - var fromloc = new LocationDTO(); - if (detail.TransferLibFromLocationCode == detail.RecommendFromLocationCode && - detail.TransferLibToLocationCode == detail.RecommendToLocationCode) - { - //库移的最终目标 挪到 推荐的目标 - fromloc = await _locationAppService.GetByCodeAsync(detail.RecommendFromLocationCode).ConfigureAwait(false); - } - else - { - //库移的最终目标 挪到 推荐的目标 - fromloc = await _locationAppService.GetByCodeAsync(detail.TransferLibToLocationCode).ConfigureAwait(false); - } - - - var toloc = await _locationAppService.GetByCodeAsync(detail.RecommendToLocationCode).ConfigureAwait(false); - - detailDto.InjectFrom(detail); - - detailDto.HandledToLocationCode = toloc.Code; - detailDto.HandledToLocationGroup = toloc.LocationGroupCode; - detailDto.HandledToLocationArea = toloc.AreaCode; - detailDto.HandledToLocationErpCode = toloc.ErpLocationCode; - detailDto.HandledToWarehouseCode = toloc.WarehouseCode; - detailDto.HandledToQty = request.Data.First().MatQty; - detailDto.HandledToLot = detail.TransferLibToLot; - detailDto.HandledToPackingCode = detail.TransferLibToPackingCode; - - detailDto.HandledFromLocationCode = fromloc.Code; - detailDto.HandledFromLocationGroup = fromloc.LocationGroupCode; - detailDto.HandledFromLocationArea = fromloc.AreaCode; - detailDto.HandledFromLocationErpCode = fromloc.ErpLocationCode; - detailDto.HandledFromWarehouseCode = fromloc.WarehouseCode; - detailDto.HandledFromQty = request.Data.First().MatQty;//2024-12-16 和励 张旭确认的 因为没有人工干预 也没校验 一托就直接顶走了 - detailDto.HandledFromLot = detail.TransferLibToLot; - detailDto.HandledFromPackingCode = detail.TransferLibToPackingCode; - } - else - { - var fromloc = await _locationAppService.GetByCodeAsync(detail.RecommendFromLocationCode).ConfigureAwait(false); - var toloc = await _locationAppService.GetByCodeAsync(detail.RecommendToLocationCode).ConfigureAwait(false); - - detailDto.InjectFrom(detail); - - detailDto.HandledToLocationCode = toloc.Code; - detailDto.HandledToLocationGroup = toloc.LocationGroupCode; - detailDto.HandledToLocationArea = toloc.AreaCode; - detailDto.HandledToLocationErpCode = toloc.ErpLocationCode; - detailDto.HandledToWarehouseCode = toloc.WarehouseCode; - detailDto.HandledToQty = request.Data.First().MatQty; - detailDto.HandledToLot = detail.RecommendToLot; - detailDto.HandledToPackingCode = detail.RecommendToPackingCode; - - detailDto.HandledFromLocationCode = fromloc.Code; - detailDto.HandledFromLocationGroup = fromloc.LocationGroupCode; - detailDto.HandledFromLocationArea = fromloc.AreaCode; - detailDto.HandledFromLocationErpCode = fromloc.ErpLocationCode; - detailDto.HandledFromWarehouseCode = fromloc.WarehouseCode; - detailDto.HandledFromQty = request.Data.First().MatQty;//2024-12-16 和励 张旭确认的 因为没有人工干预 也没校验 一托就直接顶走了 - detailDto.HandledFromLot = detail.RecommendToLot; - detailDto.HandledFromPackingCode = detail.RecommendToPackingCode; - } - - await ExecuteDetailExtAsync(entity.Id, entity.Details.First().Id, detailDto).ConfigureAwait(false); - } - } - catch (Exception e) - { - return ReturnMessage("-1", e.Message); - } - return ReturnMessage("0", "OK"); } /// - /// 返回信息 + /// 返回信息 /// /// 0成功其他失败 /// OK成功其他错误信息 /// private AgvResultObject ReturnMessage(string code, string message) { - return new AgvResultObject() - { - Code = code, - Message = message, - ReqCode = "" - }; + return new AgvResultObject { Code = code, Message = message, ReqCode = "" }; } - - /// - /// Agv 回库 接口 + /// Agv 回库 接口 /// /// /// @@ -1054,10 +899,7 @@ public class AssembleIssueJobAppService var ret = ReturnMessage("0", "OK"); - - - using var unitOfWork = _unitOfWorkManager.Begin(); try { @@ -1074,18 +916,24 @@ public class AssembleIssueJobAppService transfer.UseOnTheWayLocation = false; transfer.Confirmed = true; var detailInput = new TransferNoteDetailInput(); - - var fromPosition = await _postionLocationAppService.GetByCodeAsync(detail.BeginPosition).ConfigureAwait(false); + + var fromPosition = await _postionLocationAppService.GetByCodeAsync(detail.BeginPosition) + .ConfigureAwait(false); if (fromPosition == null) { errors.Add($"未查询到工位{detail.BeginPosition}关联的库位"); } - var fromLocationDto = await _locationAppService.GetByCodeAsync(fromPosition.LocationCode).ConfigureAwait(false); - var tolocationDto = await _locationAppService.GetByCodeAsync(detail.EndPosition).ConfigureAwait(false); + + var fromLocationDto = await _locationAppService.GetByCodeAsync(fromPosition.LocationCode) + .ConfigureAwait(false); + var tolocationDto = + await _locationAppService.GetByCodeAsync(detail.EndPosition).ConfigureAwait(false); if (tolocationDto != null) { - tolocationDto = await _locationAppService.GetByCodeAsync(detail.EndPosition).ConfigureAwait(false); + tolocationDto = await _locationAppService.GetByCodeAsync(detail.EndPosition) + .ConfigureAwait(false); } + var item = await _itemBasicAppService.GetByCodeAsync(detail.MatCode).ConfigureAwait(false); if (item == null) { @@ -1098,11 +946,12 @@ public class AssembleIssueJobAppService detailInput.ItemName = item.Name; detailInput.ItemDesc1 = !string.IsNullOrEmpty(item.Desc1) ? item.Desc1 : string.Empty; } + if (errors.Count > 0) { return ReturnMessage("-1", string.Join(",", errors.ToArray())); - } + detailInput.ToLocationCode = tolocationDto.Code; detailInput.ToLocationGroup = tolocationDto.LocationGroupCode; detailInput.ToLocationArea = tolocationDto.AreaCode; @@ -1143,50 +992,35 @@ public class AssembleIssueJobAppService if (errors.Count > 0) { - ret = ReturnMessage("-1", string.Join(",",errors.ToArray())); + ret = ReturnMessage("-1", string.Join(",", errors.ToArray())); await unitOfWork.RollbackAsync().ConfigureAwait(false); } - return ret; - - - + return ret; } /// - /// 调用Agv接口实现 + /// 调用Agv接口实现 /// /// /// /// /// - private async Task SendInterFaceAsync(AssembleIssueJobDTO job,string beginPosition, string endPosition) + private async Task SendInterFaceAsync(AssembleIssueJobDTO job, string beginPosition, + string endPosition) { #if DEBUG - + #endif return - new AgvResultObject - { - Code = "0", - ReqCode = job.AssembleRequestNumber, - Message = "OK" - }; - - + new AgvResultObject { Code = "0", ReqCode = job.AssembleRequestNumber, Message = "OK" }; - var ret = new AgvResultObject - { - Code = "0", - ReqCode = job.AssembleRequestNumber, - Message = "OK" - }; + var ret = new AgvResultObject { Code = "0", ReqCode = job.AssembleRequestNumber, Message = "OK" }; using var unitOfWork = _unitOfWorkManager.Begin(); try { - if (job.JobStatus == EnumJobStatus.Done) { throw new UserFriendlyException($"任务{job.Number}为已完成状态,不能发起AGV任务!"); @@ -1196,6 +1030,7 @@ public class AssembleIssueJobAppService { throw new UserFriendlyException($"任务{job.Number}没有推荐库存!"); } + var first = job.Details.FirstOrDefault(); var request = new AgvRequest(); request.MatCode = first.ItemCode; @@ -1236,7 +1071,6 @@ public class AssembleIssueJobAppService var client = new AgvJobClient(_agvOptions.Value.Address, httpclient, _agvOptions.Value.Path); ret = await client.PushOutTaskAssembleAsync(request).ConfigureAwait(false); - } catch (Exception e) { @@ -1247,6 +1081,7 @@ public class AssembleIssueJobAppService await unitOfWork.RollbackAsync().ConfigureAwait(false); throw new UserFriendlyException($"接口报错 错误信息{e.Message}"); } + return ret; } 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 ed373fa31..28129a322 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 @@ -840,33 +840,6 @@ public class CoatingIssueJobAppService /// private async Task DoingAgvAsync(CoatingIssueJobDTO CoatingIssueJobDto, string fromLocationCode, string toLocationCode) { - var jobDetailInputdetail = CoatingIssueJobDto.Details.FirstOrDefault(); - var locationDeliveryDto = await _locationDeliveryAppService.GetByFromLocationCodeAndToLocationCodeAsync( - fromLocationCode, toLocationCode).ConfigureAwait(false); - - if (locationDeliveryDto != null && locationDeliveryDto.EnumLocationDeliveryType == EnumLocationDeliveryType.Agv) - { - //TODO AGV - //来源永远是库位 目标永远是工位 - var ret = await CallAgvAsync(CoatingIssueJobDto, fromLocationCode, jobDetailInputdetail.Remark).ConfigureAwait(false); - -#if DEBUG - - return true; - -#endif - - - if (ret.Code != 0) - { - throw new UserFriendlyException($"调用AGV不成功!原因:{ret.Message}"); - } - else - { - return true; - } - } - return false; } @@ -877,17 +850,6 @@ public class CoatingIssueJobAppService /// private async Task UpdateJobStatusWaitByAgvAsync(CoatingIssueJobEditInput input) { - var jobDetailInputdetail = input.Details.FirstOrDefault(); - - var locationDeliveryDto = await _locationDeliveryAppService.GetByFromLocationCodeAndToLocationCodeAsync( - jobDetailInputdetail.RecommendFromLocationCode, jobDetailInputdetail.RecommendToLocationCode).ConfigureAwait(false); - - if (locationDeliveryDto != null && locationDeliveryDto.EnumLocationDeliveryType == EnumLocationDeliveryType.Agv) - { - input.JobStatus = EnumJobStatus.WaitAgv; - return true; - } - return false; } @@ -901,28 +863,7 @@ public class CoatingIssueJobAppService [HttpPost("call-agv")] public async Task CallAgvAsync(CoatingIssueJobDTO input, string beginPosition, string endPosition) { - var res = new ReusltObject(); - List errors = new List(); - List successList = new List(); - - var jobres = await SendInterFaceAsync(input, beginPosition, endPosition).ConfigureAwait(false); - if (jobres.Code != "0") - { - _logger.LogInformation(jobres.Message); - errors.Add(jobres.Message); - } - else - { - successList.Add(jobres.Message); - } - if (errors.Count > 0) - { - res.Code = -1; - res.Message = string.Join(",", errors); - res.Data = ""; - return res; - } - return res; + return null; } /// @@ -933,100 +874,6 @@ public class CoatingIssueJobAppService [HttpPost("call-back-agv")] public async Task CallBackAgvIssueAsync(AgvRequestDto request) { - - _logger.LogInformation($"发料回库{JsonSerializer.Serialize(request)}"); - if (request.Data.Count == 0) - { - return ReturnMessage("-1", "请求Data明细数量不能为0"); - } - var entity = await _repository.FindAsync(p => p.Number == request.Data.First().OrderNum).ConfigureAwait(false); - - if (entity == null) - { - return ReturnMessage("-1", $"{request.Data.First().OrderNum}任务单据不存在!"); - } - var dto = ObjectMapper.Map(entity); - if (entity.JobStatus == EnumJobStatus.Done) - { - return ReturnMessage("-1", $"{entity.Number}任务单据已结束!"); - } - try - { - foreach (var detail in entity.Details) - { - var detailDto = new CoatingIssueJobDetailDTO(); - if (!string.IsNullOrEmpty(detail.TransferLibFromLocationCode)) - { - var fromloc = new LocationDTO(); - if (detail.TransferLibFromLocationCode == detail.RecommendFromLocationCode && - detail.TransferLibToLocationCode == detail.RecommendToLocationCode) - { - //库移的最终目标 挪到 推荐的目标 - fromloc = await _locationAppService.GetByCodeAsync(detail.RecommendFromLocationCode).ConfigureAwait(false); - } - else - { - //库移的最终目标 挪到 推荐的目标 - fromloc = await _locationAppService.GetByCodeAsync(detail.TransferLibToLocationCode).ConfigureAwait(false); - } - - - var toloc = await _locationAppService.GetByCodeAsync(detail.RecommendToLocationCode).ConfigureAwait(false); - - detailDto.InjectFrom(detail); - - detailDto.HandledToLocationCode = toloc.Code; - detailDto.HandledToLocationGroup = toloc.LocationGroupCode; - detailDto.HandledToLocationArea = toloc.AreaCode; - detailDto.HandledToLocationErpCode = toloc.ErpLocationCode; - detailDto.HandledToWarehouseCode = toloc.WarehouseCode; - detailDto.HandledToQty = request.Data.First().MatQty; - detailDto.HandledToLot = detail.TransferLibToLot; - detailDto.HandledToPackingCode = detail.TransferLibToPackingCode; - - detailDto.HandledFromLocationCode = fromloc.Code; - detailDto.HandledFromLocationGroup = fromloc.LocationGroupCode; - detailDto.HandledFromLocationArea = fromloc.AreaCode; - detailDto.HandledFromLocationErpCode = fromloc.ErpLocationCode; - detailDto.HandledFromWarehouseCode = fromloc.WarehouseCode; - detailDto.HandledFromQty = request.Data.First().MatQty;//2024-12-16 和励 张旭确认的 因为没有人工干预 也没校验 一托就直接顶走了 - detailDto.HandledFromLot = detail.TransferLibToLot; - detailDto.HandledFromPackingCode = detail.TransferLibToPackingCode; - } - else - { - var fromloc = await _locationAppService.GetByCodeAsync(detail.RecommendFromLocationCode).ConfigureAwait(false); - var toloc = await _locationAppService.GetByCodeAsync(detail.RecommendToLocationCode).ConfigureAwait(false); - - detailDto.InjectFrom(detail); - - detailDto.HandledToLocationCode = toloc.Code; - detailDto.HandledToLocationGroup = toloc.LocationGroupCode; - detailDto.HandledToLocationArea = toloc.AreaCode; - detailDto.HandledToLocationErpCode = toloc.ErpLocationCode; - detailDto.HandledToWarehouseCode = toloc.WarehouseCode; - detailDto.HandledToQty = request.Data.First().MatQty; - detailDto.HandledToLot = detail.RecommendToLot; - detailDto.HandledToPackingCode = detail.RecommendToPackingCode; - - detailDto.HandledFromLocationCode = fromloc.Code; - detailDto.HandledFromLocationGroup = fromloc.LocationGroupCode; - detailDto.HandledFromLocationArea = fromloc.AreaCode; - detailDto.HandledFromLocationErpCode = fromloc.ErpLocationCode; - detailDto.HandledFromWarehouseCode = fromloc.WarehouseCode; - detailDto.HandledFromQty = request.Data.First().MatQty;//2024-12-16 和励 张旭确认的 因为没有人工干预 也没校验 一托就直接顶走了 - detailDto.HandledFromLot = detail.RecommendToLot; - detailDto.HandledFromPackingCode = detail.RecommendToPackingCode; - } - - await ExecuteDetailExtAsync(entity.Id, entity.Details.First().Id, detailDto).ConfigureAwait(false); - } - } - catch (Exception e) - { - return ReturnMessage("-1", e.Message); - } - return ReturnMessage("0", "OK"); } /// @@ -1037,21 +884,7 @@ public class CoatingIssueJobAppService /// private AgvResultObject ReturnMessage(string code, string message) { - var result = new AgvResultObject() - { - Code = code, - Message = message, - ReqCode = "" - }; - if (code == "0") - { - _logger.LogInformation("成功:" + JsonSerializer.Serialize(result)); - } - else - { - _logger.LogInformation("失败:" + JsonSerializer.Serialize(result)); - } - return result; + return new AgvResultObject(); } /// @@ -1062,126 +895,7 @@ public class CoatingIssueJobAppService [HttpPost("call-return-back-agv")] public async Task CallReturnBackAgvAsync(AgvRequestDto request) { - var json = JsonSerializer.Serialize(request); - var flag = DateTime.Now.ToString("yyyyMMddHHmmss"); - _logger.LogInformation($"{flag}接收到AGV确认单据内容:" + json); -#if DEBUG -#endif - var errors = new List(); - var ret = new AgvResultObject - { - Code = "0", - Message = "OK", - ReqCode = "", - }; - using var unitOfWork = _unitOfWorkManager.Begin(); - try - { - if (request.Data.Count > 0) - { - var notes = request.Data; - - foreach (var detail in notes) - { - var transfer = new TransferNoteEditInput(); - transfer.CallJobNumber = detail.OrderNum; - transfer.Type = EnumTransSubType.Transfer_WIP.ToString(); - transfer.Worker = "Agv"; - transfer.UseOnTheWayLocation = false; - transfer.Confirmed = true; - var detailInput = new TransferNoteDetailInput(); - - var fromPosition = await _postionLocationAppService.GetByCodeAsync(detail.BeginPosition).ConfigureAwait(false); - if (fromPosition == null) - { - errors.Add($"未查询到工位{detail.BeginPosition}关联的库位"); - } - var fromLocationDto = await _locationAppService.GetByCodeAsync(fromPosition.LocationCode).ConfigureAwait(false); - var tolocationDto = await _locationAppService.GetByCodeAsync(detail.EndPosition).ConfigureAwait(false); - if (tolocationDto != null) - { - tolocationDto = await _locationAppService.GetByCodeAsync(detail.EndPosition).ConfigureAwait(false); - } - var item = await _itemBasicAppService.GetByCodeAsync(detail.MatCode).ConfigureAwait(false); - if (item == null) - { - errors.Add($"ERP料号{detail.MatCode}不存在!"); - } - else - { - detailInput.ItemCode = item.Code; - detailInput.Uom = item.BasicUom; - detailInput.ItemName = item.Name; - detailInput.ItemDesc1 = !string.IsNullOrEmpty(item.Desc1) ? item.Desc1 : string.Empty; - } - if (errors.Count > 0) - { - return ret = new AgvResultObject() - { - Code = "-1", - ReqCode = "", - Message = string.Join(",", errors.ToArray()) - }; - } - detailInput.ToLocationCode = tolocationDto.Code; - detailInput.ToLocationGroup = tolocationDto.LocationGroupCode; - detailInput.ToLocationArea = tolocationDto.AreaCode; - detailInput.ToLocationErpCode = tolocationDto.ErpLocationCode; - detailInput.ToWarehouseCode = tolocationDto.WarehouseCode; - - detailInput.FromLocationCode = fromLocationDto.Code; - detailInput.FromLocationGroup = fromLocationDto.LocationGroupCode; - detailInput.FromLocationArea = fromLocationDto.AreaCode; - detailInput.FromLocationErpCode = fromLocationDto.ErpLocationCode; - detailInput.FromWarehouseCode = fromLocationDto.WarehouseCode; - - detailInput.Qty = detail.MatQty; - detailInput.ToLot = detail.BatchAttr07; - detailInput.ToPackingCode = detail.PakingCode; - detailInput.FromLot = detail.BatchAttr07; - detailInput.FromPackingCode = detail.PakingCode; - detailInput.FromStatus = EnumInventoryStatus.OK; - detailInput.ToStatus = EnumInventoryStatus.OK; - detailInput.Remark = "AGV反库"; - - transfer.Details.Add(detailInput); - - - await _transferNoteAppService.CreateAsync(transfer).ConfigureAwait(false); - } - } - else - { - errors.Add("Agv确认单据里无数据! \n"); - } - } - catch (Exception ex) - { - ret = new AgvResultObject - { - Code = "-1", - ReqCode = "", - Message = ex.Message - }; - await unitOfWork.RollbackAsync().ConfigureAwait(false); - - } - - if (errors.Count > 0) - { - ret = new AgvResultObject - { - Code = "-1", - Message = string.Join(",", errors.ToArray()), - ReqCode = "" - }; - await unitOfWork.RollbackAsync().ConfigureAwait(false); - } - return ret; - - - - + return new AgvResultObject(); } @@ -1194,91 +908,7 @@ public class CoatingIssueJobAppService /// private async Task SendInterFaceAsync(CoatingIssueJobDTO job, string beginPosition, string endPosition) { -#if DEBUG - -#endif - var ret = new AgvResultObject - { - Code = "0", - ReqCode = job.CoatingRequestNumber, - Message = "OK" - }; - - //return ret;//暂时无接口直接返回 - - - - using var unitOfWork = _unitOfWorkManager.Begin(); - try - { - - if (job.JobStatus == EnumJobStatus.Done) - { - throw new UserFriendlyException($"任务{job.Number}为已完成状态,不能发起AGV任务!"); - } - - if (job.Details.Count == 0) - { - throw new UserFriendlyException($"任务{job.Number}没有推荐库存!"); - } - var first = job.Details.FirstOrDefault(); - var request = new AgvRequest(); - request.MatCode = first.ItemCode; - request.MatQty = first.RecommendFromQty; - request.OrderNum = job.Number; - request.OrderType = ((int)EnumJobType.CoatingIssueJob).ToString(); - request.BeginPosition = beginPosition; - request.EndPosition = endPosition; - request.State = "1"; - request.PakingCode = !string.IsNullOrEmpty(first.HandledFromPackingCode) ? first.HandledFromPackingCode : string.Empty; - request.Batch = ""; - - var httpclient = _httpClientFactory.CreateClient(); - _agvOptions.Value.Address = string.IsNullOrEmpty(_agvOptions.Value.Address) - ? "http://7e42682n64.goho.co:21171/" - : _agvOptions.Value.Address; //测试地址 - _agvOptions.Value.Token = - string.IsNullOrEmpty(_agvOptions.Value.Token) ? string.Empty : _agvOptions.Value.Token; //测试token - _agvOptions.Value.UserName = - string.IsNullOrEmpty(_agvOptions.Value.UserName) ? "" : _agvOptions.Value.UserName; //测试用户名 - _agvOptions.Value.Password = - string.IsNullOrEmpty(_agvOptions.Value.Password) ? "" : _agvOptions.Value.Password; //测试密码 - _agvOptions.Value.Path = string.IsNullOrEmpty(_agvOptions.Value.Path) - ? "zozocnApi/custom/receiveProductionPlan" - : _agvOptions.Value.Path; //测试密码 - var flag = DateTime.Now.ToString("yyyyMMddHHmmss"); - - if (!string.IsNullOrEmpty(_agvOptions.Value.Token)) - { - var token = _agvOptions.Value.Token; - httpclient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); - } - - if (!string.IsNullOrEmpty(_agvOptions.Value.UserName) && !string.IsNullOrEmpty(_agvOptions.Value.Password)) - { - var username = _agvOptions.Value.UserName; - var password = _agvOptions.Value.Password; - httpclient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", - Convert.ToBase64String(Encoding.ASCII.GetBytes($"{username}:{password}"))); - } - - var client = new AgvJobClient(_agvOptions.Value.Address, httpclient, _agvOptions.Value.Path); - - _logger.LogInformation($"发送Json{JsonSerializer.Serialize(request)}{DateTime.Now.ToString()}"); - - ret = await client.PushOutTaskCoatingAsync(request).ConfigureAwait(false); - - } - catch (Exception e) - { - ret = new AgvResultObject(); - ret.Code = "1"; - ret.Message = e.Message; - ret.ReqCode = job.CoatingRequestNumber; - await unitOfWork.RollbackAsync().ConfigureAwait(false); - throw new UserFriendlyException($"接口报错 错误信息{e.Message}"); - } - return ret; + return new AgvResultObject(); } #endregion 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 a0d570f9a..4bf2849da 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 @@ -804,28 +804,6 @@ public class InjectionIssueJobAppService /// private async Task DoingAgvAsync(InjectionIssueJobDTO InjectionIssueJobDto, string fromLocationCode, string toLocationCode) { - var jobDetailInputdetail = InjectionIssueJobDto.Details.FirstOrDefault(); - var locationDeliveryDto = await _locationDeliveryAppService.GetByFromLocationCodeAndToLocationCodeAsync( - fromLocationCode, toLocationCode).ConfigureAwait(false); - - if (locationDeliveryDto != null && locationDeliveryDto.EnumLocationDeliveryType == EnumLocationDeliveryType.Agv) - { - //TODO AGV - //来源永远是库位 目标永远是工位 - var ret = await CallAgvAsync(InjectionIssueJobDto, fromLocationCode, jobDetailInputdetail.Remark).ConfigureAwait(false); -#if DEBUG - return true; -#endif - if (ret.Code != 0) - { - throw new UserFriendlyException($"调用AGV不成功!原因:{ret.Message}"); - } - else - { - return true; - } - } - return false; } @@ -836,17 +814,6 @@ public class InjectionIssueJobAppService /// private async Task UpdateJobStatusWaitByAgvAsync(InjectionIssueJobEditInput input) { - var jobDetailInputdetail = input.Details.FirstOrDefault(); - - var locationDeliveryDto = await _locationDeliveryAppService.GetByFromLocationCodeAndToLocationCodeAsync( - jobDetailInputdetail.RecommendFromLocationCode, jobDetailInputdetail.RecommendToLocationCode).ConfigureAwait(false); - - if (locationDeliveryDto != null && locationDeliveryDto.EnumLocationDeliveryType == EnumLocationDeliveryType.Agv) - { - input.JobStatus = EnumJobStatus.WaitAgv; - return true; - } - return false; } @@ -860,28 +827,7 @@ public class InjectionIssueJobAppService [HttpPost("call-agv")] public async Task CallAgvAsync(InjectionIssueJobDTO input, string beginPosition, string endPosition) { - var res = new ReusltObject(); - List errors = new List(); - List successList = new List(); - - var jobres = await SendInterFaceAsync(input, beginPosition, endPosition).ConfigureAwait(false); - if (jobres.Code != "0") - { - _logger.LogInformation(jobres.Message); - errors.Add(jobres.Message); - } - else - { - successList.Add(jobres.Message); - } - if (errors.Count > 0) - { - res.Code = -1; - res.Message = string.Join(",", errors); - res.Data = ""; - return res; - } - return res; + return new ReusltObject(); } /// @@ -892,103 +838,7 @@ public class InjectionIssueJobAppService [HttpPost("call-back-agv")] public async Task CallBackAgvIssueAsync(AgvRequestDto request) { - - _logger.LogInformation($"发料回库{JsonSerializer.Serialize(request)}"); - - if (request.Data.Count == 0) - { - return ReturnMessage("-1", "请求Data明细数量不能为0"); - } - var entity = await _repository.FindAsync(p => p.Number == request.Data.First().OrderNum).ConfigureAwait(false); - - if (entity == null) - { - return ReturnMessage("-1", $"{request.Data.First().OrderNum}任务单据不存在!"); - } - var dto = ObjectMapper.Map(entity); - if (entity.JobStatus == EnumJobStatus.Done) - { - return ReturnMessage("-1", $"{entity.Number}任务单据已结束!"); - } - - try - { - foreach (var detail in entity.Details) - { - var detailDto = new InjectionIssueJobDetailDTO(); - if (!string.IsNullOrEmpty(detail.TransferLibFromLocationCode)) - { - var fromloc = new LocationDTO(); - if (detail.TransferLibFromLocationCode == detail.RecommendFromLocationCode && - detail.TransferLibToLocationCode == detail.RecommendToLocationCode) - { - //库移的最终目标 挪到 推荐的目标 - fromloc = await _locationAppService.GetByCodeAsync(detail.RecommendFromLocationCode).ConfigureAwait(false); - } - else - { - //库移的最终目标 挪到 推荐的目标 - fromloc = await _locationAppService.GetByCodeAsync(detail.TransferLibToLocationCode).ConfigureAwait(false); - } - - - var toloc = await _locationAppService.GetByCodeAsync(detail.RecommendToLocationCode).ConfigureAwait(false); - - detailDto.InjectFrom(detail); - - detailDto.HandledToLocationCode = toloc.Code; - detailDto.HandledToLocationGroup = toloc.LocationGroupCode; - detailDto.HandledToLocationArea = toloc.AreaCode; - detailDto.HandledToLocationErpCode = toloc.ErpLocationCode; - detailDto.HandledToWarehouseCode = toloc.WarehouseCode; - detailDto.HandledToQty = request.Data.First().MatQty; - detailDto.HandledToLot = detail.TransferLibToLot; - detailDto.HandledToPackingCode = detail.TransferLibToPackingCode; - - detailDto.HandledFromLocationCode = fromloc.Code; - detailDto.HandledFromLocationGroup = fromloc.LocationGroupCode; - detailDto.HandledFromLocationArea = fromloc.AreaCode; - detailDto.HandledFromLocationErpCode = fromloc.ErpLocationCode; - detailDto.HandledFromWarehouseCode = fromloc.WarehouseCode; - detailDto.HandledFromQty = request.Data.First().MatQty;//2024-12-16 和励 张旭确认的 因为没有人工干预 也没校验 一托就直接顶走了 - detailDto.HandledFromLot = detail.TransferLibToLot; - detailDto.HandledFromPackingCode = detail.TransferLibToPackingCode; - } - else - { - var fromloc = await _locationAppService.GetByCodeAsync(detail.RecommendFromLocationCode).ConfigureAwait(false); - var toloc = await _locationAppService.GetByCodeAsync(detail.RecommendToLocationCode).ConfigureAwait(false); - - detailDto.InjectFrom(detail); - - detailDto.HandledToLocationCode = toloc.Code; - detailDto.HandledToLocationGroup = toloc.LocationGroupCode; - detailDto.HandledToLocationArea = toloc.AreaCode; - detailDto.HandledToLocationErpCode = toloc.ErpLocationCode; - detailDto.HandledToWarehouseCode = toloc.WarehouseCode; - detailDto.HandledToQty = request.Data.First().MatQty; - detailDto.HandledToLot = detail.RecommendToLot; - detailDto.HandledToPackingCode = detail.RecommendToPackingCode; - - detailDto.HandledFromLocationCode = fromloc.Code; - detailDto.HandledFromLocationGroup = fromloc.LocationGroupCode; - detailDto.HandledFromLocationArea = fromloc.AreaCode; - detailDto.HandledFromLocationErpCode = fromloc.ErpLocationCode; - detailDto.HandledFromWarehouseCode = fromloc.WarehouseCode; - detailDto.HandledFromQty = request.Data.First().MatQty;//2024-12-16 和励 张旭确认的 因为没有人工干预 也没校验 一托就直接顶走了 - detailDto.HandledFromLot = detail.RecommendToLot; - detailDto.HandledFromPackingCode = detail.RecommendToPackingCode; - } - - await ExecuteDetailExtAsync(entity.Id, entity.Details.First().Id, detailDto).ConfigureAwait(false); - } - } - catch (Exception e) - { - return ReturnMessage("-1", e.Message); - } - - return ReturnMessage("0", "OK"); + return new AgvResultObject(); } /// /// 返回信息 @@ -998,12 +848,7 @@ public class InjectionIssueJobAppService /// private AgvResultObject ReturnMessage(string code, string message) { - return new AgvResultObject() - { - Code = code, - Message = message, - ReqCode = "" - }; + return new AgvResultObject(); } /// @@ -1014,127 +859,7 @@ public class InjectionIssueJobAppService [HttpPost("call-return-back-agv")] public async Task CallReturnBackAgvAsync(AgvRequestDto request) { - var json = JsonSerializer.Serialize(request); - var flag = DateTime.Now.ToString("yyyyMMddHHmmss"); - _logger.LogInformation($"{flag}接收到AGV确认单据内容:" + json); -#if DEBUG -#endif - var errors = new List(); - var ret = new AgvResultObject - { - Code = "0", - Message = "OK", - ReqCode = "", - }; - using var unitOfWork = _unitOfWorkManager.Begin(); - try - { - if (request.Data.Count > 0) - { - var notes = request.Data; - - foreach (var detail in notes) - { - var transfer = new TransferNoteEditInput(); - transfer.CallJobNumber = detail.OrderNum; - transfer.Type = EnumTransSubType.Transfer_WIP.ToString(); - transfer.Worker = "Agv"; - transfer.UseOnTheWayLocation = false; - transfer.Confirmed = true; - var detailInput = new TransferNoteDetailInput(); - - var fromPosition = await _postionLocationAppService.GetByCodeAsync(detail.BeginPosition).ConfigureAwait(false); - if (fromPosition == null) - { - errors.Add($"未查询到工位{detail.BeginPosition}关联的库位"); - } - var fromLocationDto = await _locationAppService.GetByCodeAsync(fromPosition.LocationCode).ConfigureAwait(false); - var tolocationDto = await _locationAppService.GetByCodeAsync(detail.EndPosition).ConfigureAwait(false); - if (tolocationDto != null) - { - tolocationDto = await _locationAppService.GetByCodeAsync(detail.EndPosition).ConfigureAwait(false); - } - var item = await _itemBasicAppService.GetByCodeAsync(detail.MatCode).ConfigureAwait(false); - if (item == null) - { - errors.Add($"ERP料号{detail.MatCode}不存在!"); - } - else - { - detailInput.ItemCode = item.Code; - detailInput.Uom = item.BasicUom; - detailInput.ItemName = item.Name; - detailInput.ItemDesc1 = !string.IsNullOrEmpty(item.Desc1) ? item.Desc1 : string.Empty; - } - if (errors.Count > 0) - { - return ret = new AgvResultObject() - { - Code = "-1", - ReqCode = "", - Message = string.Join(",", errors.ToArray()) - }; - } - detailInput.ToLocationCode = tolocationDto.Code; - detailInput.ToLocationGroup = tolocationDto.LocationGroupCode; - detailInput.ToLocationArea = tolocationDto.AreaCode; - detailInput.ToLocationErpCode = tolocationDto.ErpLocationCode; - detailInput.ToWarehouseCode = tolocationDto.WarehouseCode; - - detailInput.FromLocationCode = fromLocationDto.Code; - detailInput.FromLocationGroup = fromLocationDto.LocationGroupCode; - detailInput.FromLocationArea = fromLocationDto.AreaCode; - detailInput.FromLocationErpCode = fromLocationDto.ErpLocationCode; - detailInput.FromWarehouseCode = fromLocationDto.WarehouseCode; - - detailInput.Qty = detail.MatQty; - detailInput.ToLot = detail.BatchAttr07; - detailInput.ToPackingCode = detail.PakingCode; - detailInput.FromLot = detail.BatchAttr07; - detailInput.FromPackingCode = detail.PakingCode; - detailInput.FromStatus = EnumInventoryStatus.OK; - detailInput.ToStatus = EnumInventoryStatus.OK; - detailInput.Remark = "AGV反库"; - - - transfer.Details.Add(detailInput); - - - await _transferNoteAppService.CreateAsync(transfer).ConfigureAwait(false); - } - } - else - { - errors.Add("Agv确认单据里无数据! \n"); - } - } - catch (Exception ex) - { - ret = new AgvResultObject - { - Code = "-1", - ReqCode = "", - Message = ex.Message - }; - await unitOfWork.RollbackAsync().ConfigureAwait(false); - - } - - if (errors.Count > 0) - { - ret = new AgvResultObject - { - Code = "-1", - Message = string.Join(",", errors.ToArray()), - ReqCode = "" - }; - await unitOfWork.RollbackAsync().ConfigureAwait(false); - } - return ret; - - - - + return new AgvResultObject(); } @@ -1147,84 +872,7 @@ public class InjectionIssueJobAppService /// private async Task SendInterFaceAsync(InjectionIssueJobDTO job, string beginPosition, string endPosition) { -#if DEBUG - -#endif - var ret = new AgvResultObject - { - Code = "0", - ReqCode = job.InjectionRequestNumber, - Message = "OK" - }; - - return ret; - - - using var unitOfWork = _unitOfWorkManager.Begin(); - try - { - - if (job.JobStatus == EnumJobStatus.Done) - { - throw new UserFriendlyException($"任务{job.Number}为已完成状态,不能发起AGV任务!"); - } - - if (job.Details.Count == 0) - { - throw new UserFriendlyException($"任务{job.Number}没有推荐库存!"); - } - var first = job.Details.FirstOrDefault(); - var request = new AgvRequest(); - request.MatCode = first.ItemCode; - request.MatQty = first.HandledToQty; - request.OrderNum = job.Number; - request.OrderType = EnumJobType.InjectionIssueJob.ToString(); - request.BeginPosition = beginPosition; - request.EndPosition = endPosition; - - var httpclient = _httpClientFactory.CreateClient(); - _agvOptions.Value.Address = string.IsNullOrEmpty(_agvOptions.Value.Address) - ? "http://7e42682n64.goho.co:21171/" - : _agvOptions.Value.Address; //测试地址 - _agvOptions.Value.Token = - string.IsNullOrEmpty(_agvOptions.Value.Token) ? string.Empty : _agvOptions.Value.Token; //测试token - _agvOptions.Value.UserName = - string.IsNullOrEmpty(_agvOptions.Value.UserName) ? "" : _agvOptions.Value.UserName; //测试用户名 - _agvOptions.Value.Password = - string.IsNullOrEmpty(_agvOptions.Value.Password) ? "" : _agvOptions.Value.Password; //测试密码 - _agvOptions.Value.Path = string.IsNullOrEmpty(_agvOptions.Value.Path) - ? "zozocnApi/custom/receiveProductionPlan" - : _agvOptions.Value.Path; //测试密码 - var flag = DateTime.Now.ToString("yyyyMMddHHmmss"); - - if (!string.IsNullOrEmpty(_agvOptions.Value.Token)) - { - var token = _agvOptions.Value.Token; - httpclient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); - } - - if (!string.IsNullOrEmpty(_agvOptions.Value.UserName) && !string.IsNullOrEmpty(_agvOptions.Value.Password)) - { - var username = _agvOptions.Value.UserName; - var password = _agvOptions.Value.Password; - httpclient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", - Convert.ToBase64String(Encoding.ASCII.GetBytes($"{username}:{password}"))); - } - - var client = new AgvJobClient(_agvOptions.Value.Address, httpclient, _agvOptions.Value.Path); - ret = await client.PushOutTaskInjectionAsync(request).ConfigureAwait(false); - - } - catch (Exception e) - { - ret = new AgvResultObject(); - ret.Code = "1"; - ret.Message = e.Message; - ret.ReqCode = job.InjectionRequestNumber; - await unitOfWork.RollbackAsync().ConfigureAwait(false); - throw new UserFriendlyException($"接口报错 错误信息{e.Message}"); - } - return ret; + return new AgvResultObject(); } #endregion @@ -1380,9 +1028,4 @@ public class InjectionIssueJobAppService #endregion - - - - - } 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 d7b039baa..a3e597b98 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 @@ -802,32 +802,6 @@ public class KittingIssueJobAppService /// private async Task DoingAgvAsync(KittingIssueJobDTO KittingIssueJobDto, string fromLocationCode, string toLocationCode) { - var jobDetailInputdetail = KittingIssueJobDto.Details.FirstOrDefault(); - var locationDeliveryDto = await _locationDeliveryAppService.GetByFromLocationCodeAndToLocationCodeAsync( - fromLocationCode, toLocationCode).ConfigureAwait(false); - - if (locationDeliveryDto != null && locationDeliveryDto.EnumLocationDeliveryType == EnumLocationDeliveryType.Agv) - { - //TODO AGV - //来源永远是库位 目标永远是工位 - var ret = await CallAgvAsync(KittingIssueJobDto, fromLocationCode, jobDetailInputdetail.Remark).ConfigureAwait(false); - -#if DEBUG - - return true; - -#endif - - if (ret.Code != 0) - { - throw new UserFriendlyException($"调用AGV不成功!原因:{ret.Message}"); - } - else - { - return true; - } - } - return false; } @@ -838,18 +812,7 @@ public class KittingIssueJobAppService /// private async Task UpdateJobStatusWaitByAgvAsync(KittingIssueJobEditInput input) { - var jobDetailInputdetail = input.Details.FirstOrDefault(); - - var locationDeliveryDto = await _locationDeliveryAppService.GetByFromLocationCodeAndToLocationCodeAsync( - jobDetailInputdetail.RecommendFromLocationCode, jobDetailInputdetail.RecommendToLocationCode).ConfigureAwait(false); - - if (locationDeliveryDto != null && locationDeliveryDto.EnumLocationDeliveryType == EnumLocationDeliveryType.Agv) - { - input.JobStatus = EnumJobStatus.WaitAgv; - return true; - } - - return false; + return false; } /// @@ -862,28 +825,7 @@ public class KittingIssueJobAppService [HttpPost("call-agv")] public async Task CallAgvAsync(KittingIssueJobDTO input, string beginPosition, string endPosition) { - var res = new ReusltObject(); - List errors = new List(); - List successList = new List(); - - var jobres = await SendInterFaceAsync(input, beginPosition, endPosition).ConfigureAwait(false); - if (jobres.Code != "0") - { - _logger.LogInformation(jobres.Message); - errors.Add(jobres.Message); - } - else - { - successList.Add(jobres.Message); - } - if (errors.Count > 0) - { - res.Code = -1; - res.Message = string.Join(",", errors); - res.Data = ""; - return res; - } - return res; + return new ReusltObject(); } /// @@ -894,101 +836,7 @@ public class KittingIssueJobAppService [HttpPost("call-back-agv")] public async Task CallBackAgvIssueAsync(AgvRequestDto request) { - _logger.LogInformation($"发料回库{JsonSerializer.Serialize(request)}"); - - if (request.Data.Count == 0) - { - return ReturnMessage("-1", "请求Data明细数量不能为0"); - } - var entity = await _repository.FindAsync(p => p.Number == request.Data.First().OrderNum).ConfigureAwait(false); - - if (entity == null) - { - return ReturnMessage("-1", $"{request.Data.First().OrderNum}任务单据不存在!"); - } - var dto = ObjectMapper.Map(entity); - if (entity.JobStatus == EnumJobStatus.Done) - { - return ReturnMessage("-1", $"{entity.Number}任务单据已结束!"); - } - - try - { - foreach (var detail in entity.Details) - { - var detailDto = new KittingIssueJobDetailDTO(); - if (!string.IsNullOrEmpty(detail.TransferLibFromLocationCode)) - { - var fromloc = new LocationDTO(); - if (detail.TransferLibFromLocationCode == detail.RecommendFromLocationCode && - detail.TransferLibToLocationCode == detail.RecommendToLocationCode) - { - //库移的最终目标 挪到 推荐的目标 - fromloc = await _locationAppService.GetByCodeAsync(detail.RecommendFromLocationCode).ConfigureAwait(false); - } - else - { - //库移的最终目标 挪到 推荐的目标 - fromloc = await _locationAppService.GetByCodeAsync(detail.TransferLibToLocationCode).ConfigureAwait(false); - } - - - var toloc = await _locationAppService.GetByCodeAsync(detail.RecommendToLocationCode).ConfigureAwait(false); - - detailDto.InjectFrom(detail); - - detailDto.HandledToLocationCode = toloc.Code; - detailDto.HandledToLocationGroup = toloc.LocationGroupCode; - detailDto.HandledToLocationArea = toloc.AreaCode; - detailDto.HandledToLocationErpCode = toloc.ErpLocationCode; - detailDto.HandledToWarehouseCode = toloc.WarehouseCode; - detailDto.HandledToQty = request.Data.First().MatQty; - detailDto.HandledToLot = detail.TransferLibToLot; - detailDto.HandledToPackingCode = detail.TransferLibToPackingCode; - - detailDto.HandledFromLocationCode = fromloc.Code; - detailDto.HandledFromLocationGroup = fromloc.LocationGroupCode; - detailDto.HandledFromLocationArea = fromloc.AreaCode; - detailDto.HandledFromLocationErpCode = fromloc.ErpLocationCode; - detailDto.HandledFromWarehouseCode = fromloc.WarehouseCode; - detailDto.HandledFromQty = request.Data.First().MatQty;//2024-12-16 和励 张旭确认的 因为没有人工干预 也没校验 一托就直接顶走了 - detailDto.HandledFromLot = detail.TransferLibToLot; - detailDto.HandledFromPackingCode = detail.TransferLibToPackingCode; - } - else - { - var fromloc = await _locationAppService.GetByCodeAsync(detail.RecommendFromLocationCode).ConfigureAwait(false); - var toloc = await _locationAppService.GetByCodeAsync(detail.RecommendToLocationCode).ConfigureAwait(false); - - detailDto.InjectFrom(detail); - - detailDto.HandledToLocationCode = toloc.Code; - detailDto.HandledToLocationGroup = toloc.LocationGroupCode; - detailDto.HandledToLocationArea = toloc.AreaCode; - detailDto.HandledToLocationErpCode = toloc.ErpLocationCode; - detailDto.HandledToWarehouseCode = toloc.WarehouseCode; - detailDto.HandledToQty = request.Data.First().MatQty; - detailDto.HandledToLot = detail.RecommendToLot; - detailDto.HandledToPackingCode = detail.RecommendToPackingCode; - - detailDto.HandledFromLocationCode = fromloc.Code; - detailDto.HandledFromLocationGroup = fromloc.LocationGroupCode; - detailDto.HandledFromLocationArea = fromloc.AreaCode; - detailDto.HandledFromLocationErpCode = fromloc.ErpLocationCode; - detailDto.HandledFromWarehouseCode = fromloc.WarehouseCode; - detailDto.HandledFromQty = request.Data.First().MatQty;//2024-12-16 和励 张旭确认的 因为没有人工干预 也没校验 一托就直接顶走了 - detailDto.HandledFromLot = detail.RecommendToLot; - detailDto.HandledFromPackingCode = detail.RecommendToPackingCode; - } - - await ExecuteDetailExtAsync(entity.Id, entity.Details.First().Id, detailDto).ConfigureAwait(false); - } - } - catch (Exception e) - { - return ReturnMessage("-1", e.Message); - } - return ReturnMessage("0", "OK"); + return new AgvResultObject(); } /// /// 返回信息 @@ -998,22 +846,7 @@ public class KittingIssueJobAppService /// private AgvResultObject ReturnMessage(string code, string message) { - var result = new AgvResultObject() - { - Code = code, - Message = message, - ReqCode = "" - }; - if(code == "0") - { - _logger.LogInformation("成功:"+JsonSerializer.Serialize(result)); - } - else - { - _logger.LogInformation("失败:"+JsonSerializer.Serialize(result)); - } - - return result; + return new AgvResultObject(); } /// @@ -1024,126 +857,7 @@ public class KittingIssueJobAppService [HttpPost("call-return-back-agv")] public async Task CallReturnBackAgvAsync(AgvRequestDto request) { - var json = JsonSerializer.Serialize(request); - var flag = DateTime.Now.ToString("yyyyMMddHHmmss"); - _logger.LogInformation($"{flag}接收到AGV确认单据内容:" + json); -#if DEBUG -#endif - var errors = new List(); - var ret = new AgvResultObject - { - Code = "0", - Message = "OK", - ReqCode = "", - }; - using var unitOfWork = _unitOfWorkManager.Begin(); - try - { - if (request.Data.Count > 0) - { - var notes = request.Data; - - foreach (var detail in notes) - { - var transfer = new TransferNoteEditInput(); - transfer.CallJobNumber = detail.OrderNum; - transfer.Type = EnumTransSubType.Transfer_WIP.ToString(); - transfer.Worker = "Agv"; - transfer.UseOnTheWayLocation = false; - transfer.Confirmed = true; - var detailInput = new TransferNoteDetailInput(); - - var fromPosition = await _postionLocationAppService.GetByCodeAsync(detail.BeginPosition).ConfigureAwait(false); - if (fromPosition == null) - { - errors.Add($"未查询到工位{detail.BeginPosition}关联的库位"); - } - var fromLocationDto = await _locationAppService.GetByCodeAsync(fromPosition.LocationCode).ConfigureAwait(false); - var tolocationDto = await _locationAppService.GetByCodeAsync(detail.EndPosition).ConfigureAwait(false); - if (tolocationDto != null) - { - tolocationDto = await _locationAppService.GetByCodeAsync(detail.EndPosition).ConfigureAwait(false); - } - var item = await _itemBasicAppService.GetByCodeAsync(detail.MatCode).ConfigureAwait(false); - if (item == null) - { - errors.Add($"ERP料号{detail.MatCode}不存在!"); - } - else - { - detailInput.ItemCode = item.Code; - detailInput.Uom = item.BasicUom; - detailInput.ItemName = item.Name; - detailInput.ItemDesc1 = !string.IsNullOrEmpty(item.Desc1) ? item.Desc1 : string.Empty; - } - if (errors.Count > 0) - { - return ret = new AgvResultObject() - { - Code = "-1", - ReqCode = "", - Message = string.Join(",", errors.ToArray()) - }; - } - detailInput.ToLocationCode = tolocationDto.Code; - detailInput.ToLocationGroup = tolocationDto.LocationGroupCode; - detailInput.ToLocationArea = tolocationDto.AreaCode; - detailInput.ToLocationErpCode = tolocationDto.ErpLocationCode; - detailInput.ToWarehouseCode = tolocationDto.WarehouseCode; - - detailInput.FromLocationCode = fromLocationDto.Code; - detailInput.FromLocationGroup = fromLocationDto.LocationGroupCode; - detailInput.FromLocationArea = fromLocationDto.AreaCode; - detailInput.FromLocationErpCode = fromLocationDto.ErpLocationCode; - detailInput.FromWarehouseCode = fromLocationDto.WarehouseCode; - - detailInput.Qty = detail.MatQty; - detailInput.ToLot = detail.BatchAttr07; - detailInput.ToPackingCode = detail.PakingCode; - detailInput.FromLot = detail.BatchAttr07; - detailInput.FromPackingCode = detail.PakingCode; - detailInput.FromStatus = EnumInventoryStatus.OK; - detailInput.ToStatus = EnumInventoryStatus.OK; - detailInput.Remark = "AGV反库"; - - transfer.Details.Add(detailInput); - - - await _transferNoteAppService.CreateAsync(transfer).ConfigureAwait(false); - } - } - else - { - errors.Add("Agv确认单据里无数据! \n"); - } - } - catch (Exception ex) - { - ret = new AgvResultObject - { - Code = "-1", - ReqCode = "", - Message = ex.Message - }; - await unitOfWork.RollbackAsync().ConfigureAwait(false); - - } - - if (errors.Count > 0) - { - ret = new AgvResultObject - { - Code = "-1", - Message = string.Join(",", errors.ToArray()), - ReqCode = "" - }; - await unitOfWork.RollbackAsync().ConfigureAwait(false); - } - return ret; - - - - + return new AgvResultObject(); } @@ -1156,90 +870,7 @@ public class KittingIssueJobAppService /// private async Task SendInterFaceAsync(KittingIssueJobDTO job, string beginPosition, string endPosition) { -#if DEBUG - -#endif - var ret = new AgvResultObject - { - Code = "0", - ReqCode = job.KittingRequestNumber, - Message = "OK" - }; - // return ret;//暂时无接口直接返回 - - using var unitOfWork = _unitOfWorkManager.Begin(); - try - { - - if (job.JobStatus == EnumJobStatus.Done) - { - throw new UserFriendlyException($"任务{job.Number}为已完成状态,不能发起AGV任务!"); - } - - if (job.Details.Count == 0) - { - throw new UserFriendlyException($"任务{job.Number}没有推荐库存!"); - } - var first = job.Details.FirstOrDefault(); - var request = new AgvRequest(); - request.MatCode = first.ItemCode; - request.MatQty = first.RecommendFromQty; - request.OrderNum = job.Number; - request.State = "1"; - request.PakingCode = !string.IsNullOrEmpty(first.HandledFromPackingCode)?first.HandledFromPackingCode:string.Empty; - request.Batch = ""; - - - request.OrderType = ((int)EnumJobType.KittingIssueJob).ToString(); - request.BeginPosition = beginPosition; - request.EndPosition = endPosition; - - var httpclient = _httpClientFactory.CreateClient(); - _agvOptions.Value.Address = string.IsNullOrEmpty(_agvOptions.Value.Address) - ? "http://7e42682n64.goho.co:21171/" - : _agvOptions.Value.Address; //测试地址 - _agvOptions.Value.Token = - string.IsNullOrEmpty(_agvOptions.Value.Token) ? string.Empty : _agvOptions.Value.Token; //测试token - _agvOptions.Value.UserName = - string.IsNullOrEmpty(_agvOptions.Value.UserName) ? "" : _agvOptions.Value.UserName; //测试用户名 - _agvOptions.Value.Password = - string.IsNullOrEmpty(_agvOptions.Value.Password) ? "" : _agvOptions.Value.Password; //测试密码 - _agvOptions.Value.Path = string.IsNullOrEmpty(_agvOptions.Value.Path) - ? "zozocnApi/custom/receiveProductionPlan" - : _agvOptions.Value.Path; //测试密码 - var flag = DateTime.Now.ToString("yyyyMMddHHmmss"); - - if (!string.IsNullOrEmpty(_agvOptions.Value.Token)) - { - var token = _agvOptions.Value.Token; - httpclient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); - } - - if (!string.IsNullOrEmpty(_agvOptions.Value.UserName) && !string.IsNullOrEmpty(_agvOptions.Value.Password)) - { - var username = _agvOptions.Value.UserName; - var password = _agvOptions.Value.Password; - httpclient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", - Convert.ToBase64String(Encoding.ASCII.GetBytes($"{username}:{password}"))); - } - var json = JsonSerializer.Serialize(request); - var client = new AgvJobClient(_agvOptions.Value.Address, httpclient, _agvOptions.Value.Path); - - _logger.LogInformation($"{flag}发送AGV任务请求:{json }"); - - ret = await client.PushOutTaskKittingAsync(request).ConfigureAwait(false); - - } - catch (Exception e) - { - ret = new AgvResultObject(); - ret.Code = "1"; - ret.Message = e.Message; - ret.ReqCode = job.KittingRequestNumber; - await unitOfWork.RollbackAsync().ConfigureAwait(false); - throw new UserFriendlyException($"接口报错 错误信息{e.Message}"); - } - return ret; + return new AgvResultObject(); } #endregion 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 3b94d313c..1ddcc5eb5 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 @@ -801,32 +801,6 @@ public class SparePartIssueJobAppService /// private async Task DoingAgvAsync(SparePartIssueJobDTO sparePartIssueJobDto, string fromLocationCode, string toLocationCode) { - var jobDetailInputdetail = sparePartIssueJobDto.Details.FirstOrDefault(); - var locationDeliveryDto = await _locationDeliveryAppService.GetByFromLocationCodeAndToLocationCodeAsync( - fromLocationCode, toLocationCode).ConfigureAwait(false); - - if (locationDeliveryDto != null && locationDeliveryDto.EnumLocationDeliveryType == EnumLocationDeliveryType.Agv) - { - //TODO AGV - //来源永远是库位 目标永远是工位 - var ret = await CallAgvAsync(sparePartIssueJobDto, fromLocationCode, jobDetailInputdetail.Remark).ConfigureAwait(false); - -#if DEBUG - - return true; - -#endif - - if (ret.Code != 0) - { - throw new UserFriendlyException($"调用AGV不成功!原因:{ret.Message}"); - } - else - { - return true; - } - } - return false; } @@ -837,17 +811,6 @@ public class SparePartIssueJobAppService /// private async Task UpdateJobStatusWaitByAgvAsync(SparePartIssueJobEditInput input) { - var jobDetailInputdetail = input.Details.FirstOrDefault(); - - var locationDeliveryDto = await _locationDeliveryAppService.GetByFromLocationCodeAndToLocationCodeAsync( - jobDetailInputdetail.RecommendFromLocationCode, jobDetailInputdetail.RecommendToLocationCode).ConfigureAwait(false); - - if (locationDeliveryDto != null && locationDeliveryDto.EnumLocationDeliveryType == EnumLocationDeliveryType.Agv) - { - input.JobStatus = EnumJobStatus.WaitAgv; - return true; - } - return false; } @@ -861,28 +824,7 @@ public class SparePartIssueJobAppService [HttpPost("call-agv")] public async Task CallAgvAsync(SparePartIssueJobDTO input, string beginPosition, string endPosition) { - var res = new ReusltObject(); - List errors = new List(); - List successList = new List(); - - var jobres = await SendInterFaceAsync(input, beginPosition, endPosition).ConfigureAwait(false); - if (jobres.Code != "0") - { - _logger.LogInformation(jobres.Message); - errors.Add(jobres.Message); - } - else - { - successList.Add(jobres.Message); - } - if (errors.Count > 0) - { - res.Code = -1; - res.Message = string.Join(",", errors); - res.Data = ""; - return res; - } - return res; + return new ReusltObject(); } /// @@ -893,106 +835,7 @@ public class SparePartIssueJobAppService [HttpPost("call-back-agv")] public async Task CallBackAgvIssueAsync(AgvRequestDto request) { - - _logger.LogInformation($"发料回库{JsonSerializer.Serialize(request)}"); - if (request.Data.Count == 0) - { - return ReturnMessage("-1", "请求Data明细数量不能为0"); - } - var entity = await _repository.FindAsync(p => p.Number == request.Data.First().OrderNum).ConfigureAwait(false); - - if (entity == null) - { - return ReturnMessage("-1", $"{request.Data.First().OrderNum}任务单据不存在!"); - } - var dto = ObjectMapper.Map(entity); - if (entity.JobStatus == EnumJobStatus.Done) - { - return ReturnMessage("-1", $"{entity.Number}任务单据已结束!"); - } - try - { - foreach (var detail in entity.Details) - { - var detailDto = new SparePartIssueJobDetailDTO(); - if (!string.IsNullOrEmpty(detail.TransferLibFromLocationCode)) - { - var fromloc = new LocationDTO(); - if (detail.TransferLibFromLocationCode == detail.RecommendFromLocationCode && - detail.TransferLibToLocationCode == detail.RecommendToLocationCode) - { - //库移的最终目标 挪到 推荐的目标 - fromloc = await _locationAppService.GetByCodeAsync(detail.RecommendFromLocationCode).ConfigureAwait(false); - } - else - { - //库移的最终目标 挪到 推荐的目标 - fromloc = await _locationAppService.GetByCodeAsync(detail.TransferLibToLocationCode).ConfigureAwait(false); - } - - - var toloc = await _locationAppService.GetByCodeAsync(detail.RecommendToLocationCode).ConfigureAwait(false); - - detailDto.InjectFrom(detail); - - detailDto.HandledToLocationCode = toloc.Code; - detailDto.HandledToLocationGroup = toloc.LocationGroupCode; - detailDto.HandledToLocationArea = toloc.AreaCode; - detailDto.HandledToLocationErpCode = toloc.ErpLocationCode; - detailDto.HandledToWarehouseCode = toloc.WarehouseCode; - detailDto.HandledToQty = request.Data.First().MatQty; - detailDto.HandledToLot = detail.TransferLibToLot; - detailDto.HandledToPackingCode = detail.TransferLibToPackingCode; - - detailDto.HandledFromLocationCode = fromloc.Code; - detailDto.HandledFromLocationGroup = fromloc.LocationGroupCode; - detailDto.HandledFromLocationArea = fromloc.AreaCode; - detailDto.HandledFromLocationErpCode = fromloc.ErpLocationCode; - detailDto.HandledFromWarehouseCode = fromloc.WarehouseCode; - detailDto.HandledFromQty = request.Data.First().MatQty;//2024-12-16 和励 张旭确认的 因为没有人工干预 也没校验 一托就直接顶走了 - detailDto.HandledFromLot = detail.TransferLibToLot; - detailDto.HandledFromPackingCode = detail.TransferLibToPackingCode; - } - else - { - var fromloc = await _locationAppService.GetByCodeAsync(detail.RecommendFromLocationCode).ConfigureAwait(false); - var toloc = await _locationAppService.GetByCodeAsync(detail.RecommendToLocationCode).ConfigureAwait(false); - - detailDto.InjectFrom(detail); - - detailDto.HandledToLocationCode = toloc.Code; - detailDto.HandledToLocationGroup = toloc.LocationGroupCode; - detailDto.HandledToLocationArea = toloc.AreaCode; - detailDto.HandledToLocationErpCode = toloc.ErpLocationCode; - detailDto.HandledToWarehouseCode = toloc.WarehouseCode; - detailDto.HandledToQty = request.Data.First().MatQty; - detailDto.HandledToLot = detail.RecommendToLot; - detailDto.HandledToPackingCode = detail.RecommendToPackingCode; - - detailDto.HandledFromLocationCode = fromloc.Code; - detailDto.HandledFromLocationGroup = fromloc.LocationGroupCode; - detailDto.HandledFromLocationArea = fromloc.AreaCode; - detailDto.HandledFromLocationErpCode = fromloc.ErpLocationCode; - detailDto.HandledFromWarehouseCode = fromloc.WarehouseCode; - detailDto.HandledFromQty = request.Data.First().MatQty;//2024-12-16 和励 张旭确认的 因为没有人工干预 也没校验 一托就直接顶走了 - detailDto.HandledFromLot = detail.RecommendToLot; - detailDto.HandledFromPackingCode = detail.RecommendToPackingCode; - } - - await ExecuteDetailExtAsync(entity.Id, entity.Details.First().Id, detailDto).ConfigureAwait(false); - } - } - catch (Exception e) - { - return ReturnMessage("-1", e.Message); - } - - return new AgvResultObject - { - Code = "0", - Message = "OK", - ReqCode = "", - }; + return new AgvResultObject(); } /// /// 返回信息 @@ -1002,12 +845,7 @@ public class SparePartIssueJobAppService /// private AgvResultObject ReturnMessage(string code, string message) { - return new AgvResultObject() - { - Code = code, - Message = message, - ReqCode = "" - }; + return new AgvResultObject(); } /// @@ -1018,125 +856,7 @@ public class SparePartIssueJobAppService [HttpPost("call-return-back-agv")] public async Task CallReturnBackAgvAsync(AgvRequestDto request) { - var json = JsonSerializer.Serialize(request); - var flag = DateTime.Now.ToString("yyyyMMddHHmmss"); - _logger.LogInformation($"{flag}接收到AGV确认单据内容:" + json); -#if DEBUG -#endif - var errors = new List(); - var ret = new AgvResultObject - { - Code = "0", - Message = "OK", - ReqCode = "", - }; - using var unitOfWork = _unitOfWorkManager.Begin(); - try - { - if (request.Data.Count > 0) - { - var notes = request.Data; - - foreach (var detail in notes) - { - var transfer = new TransferNoteEditInput(); - transfer.CallJobNumber = detail.OrderNum; - transfer.Type = EnumTransSubType.Transfer_WIP.ToString(); - transfer.Worker = "Agv"; - transfer.UseOnTheWayLocation = false; - transfer.Confirmed = true; - var detailInput = new TransferNoteDetailInput(); - - var fromPosition = await _postionLocationAppService.GetByCodeAsync(detail.BeginPosition).ConfigureAwait(false); - if (fromPosition == null) - { - errors.Add($"未查询到工位{detail.BeginPosition}关联的库位"); - } - var fromLocationDto = await _locationAppService.GetByCodeAsync(fromPosition.LocationCode).ConfigureAwait(false); - var tolocationDto = await _locationAppService.GetByCodeAsync(detail.EndPosition).ConfigureAwait(false); - if (tolocationDto != null) - { - tolocationDto = await _locationAppService.GetByCodeAsync(detail.EndPosition).ConfigureAwait(false); - } - var item = await _itemBasicAppService.GetByCodeAsync(detail.MatCode).ConfigureAwait(false); - if (item == null) - { - errors.Add($"ERP料号{detail.MatCode}不存在!"); - } - else - { - detailInput.ItemCode = item.Code; - detailInput.Uom = item.BasicUom; - detailInput.ItemName = item.Name; - detailInput.ItemDesc1 = !string.IsNullOrEmpty(item.Desc1) ? item.Desc1 : string.Empty; - } - if (errors.Count > 0) - { - return ret = new AgvResultObject() - { - Code = "-1", - ReqCode = "", - Message = string.Join(",", errors.ToArray()) - }; - } - detailInput.ToLocationCode = tolocationDto.Code; - detailInput.ToLocationGroup = tolocationDto.LocationGroupCode; - detailInput.ToLocationArea = tolocationDto.AreaCode; - detailInput.ToLocationErpCode = tolocationDto.ErpLocationCode; - detailInput.ToWarehouseCode = tolocationDto.WarehouseCode; - - detailInput.FromLocationCode = fromLocationDto.Code; - detailInput.FromLocationGroup = fromLocationDto.LocationGroupCode; - detailInput.FromLocationArea = fromLocationDto.AreaCode; - detailInput.FromLocationErpCode = fromLocationDto.ErpLocationCode; - detailInput.FromWarehouseCode = fromLocationDto.WarehouseCode; - - detailInput.Qty = detail.MatQty; - detailInput.ToLot = detail.BatchAttr07; - detailInput.ToPackingCode = detail.PakingCode; - detailInput.FromLot = detail.BatchAttr07; - detailInput.FromPackingCode = detail.PakingCode; - detailInput.FromStatus = EnumInventoryStatus.OK; - detailInput.ToStatus = EnumInventoryStatus.OK; - detailInput.Remark = "AGV反库"; - - transfer.Details.Add(detailInput); - - - await _transferNoteAppService.CreateAsync(transfer).ConfigureAwait(false); - } - } - else - { - errors.Add("Agv确认单据里无数据! \n"); - } - } - catch (Exception ex) - { - ret = new AgvResultObject - { - Code = "-1", - ReqCode = "", - Message = ex.Message - }; - await unitOfWork.RollbackAsync().ConfigureAwait(false); - - } - - if (errors.Count > 0) - { - ret = new AgvResultObject - { - Code = "-1", - Message = string.Join(",", errors.ToArray()), - ReqCode = "" - }; - await unitOfWork.RollbackAsync().ConfigureAwait(false); - } - return ret; - - - + return new AgvResultObject(); } @@ -1150,82 +870,7 @@ public class SparePartIssueJobAppService /// private async Task SendInterFaceAsync(SparePartIssueJobDTO job, string beginPosition, string endPosition) { -#if DEBUG - -#endif - var ret = new AgvResultObject - { - Code = "0", - ReqCode = job.SparePartRequestNumber, - Message = "OK" - }; - return ret; - //暂时无接口直接返回 - using var unitOfWork = _unitOfWorkManager.Begin(); - try - { - - if (job.JobStatus == EnumJobStatus.Done) - { - throw new UserFriendlyException($"任务{job.Number}为已完成状态,不能发起AGV任务!"); - } - - if (job.Details.Count == 0) - { - throw new UserFriendlyException($"任务{job.Number}没有推荐库存!"); - } - var first = job.Details.FirstOrDefault(); - var request = new AgvRequest(); - request.MatCode = first.ItemCode; - request.MatQty = first.HandledToQty; - request.OrderNum = job.Number; - request.OrderType = EnumJobType.SparePartIssueJob.ToString(); - request.BeginPosition = beginPosition; - request.EndPosition = endPosition; - - var httpclient = _httpClientFactory.CreateClient(); - _agvOptions.Value.Address = string.IsNullOrEmpty(_agvOptions.Value.Address) - ? "http://7e42682n64.goho.co:21171/" - : _agvOptions.Value.Address; //测试地址 - _agvOptions.Value.Token = - string.IsNullOrEmpty(_agvOptions.Value.Token) ? string.Empty : _agvOptions.Value.Token; //测试token - _agvOptions.Value.UserName = - string.IsNullOrEmpty(_agvOptions.Value.UserName) ? "" : _agvOptions.Value.UserName; //测试用户名 - _agvOptions.Value.Password = - string.IsNullOrEmpty(_agvOptions.Value.Password) ? "" : _agvOptions.Value.Password; //测试密码 - _agvOptions.Value.Path = string.IsNullOrEmpty(_agvOptions.Value.Path) - ? "zozocnApi/custom/receiveProductionPlan" - : _agvOptions.Value.Path; //测试密码 - var flag = DateTime.Now.ToString("yyyyMMddHHmmss"); - - if (!string.IsNullOrEmpty(_agvOptions.Value.Token)) - { - var token = _agvOptions.Value.Token; - httpclient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); - } - - if (!string.IsNullOrEmpty(_agvOptions.Value.UserName) && !string.IsNullOrEmpty(_agvOptions.Value.Password)) - { - var username = _agvOptions.Value.UserName; - var password = _agvOptions.Value.Password; - httpclient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", - Convert.ToBase64String(Encoding.ASCII.GetBytes($"{username}:{password}"))); - } - - var client = new AgvJobClient(_agvOptions.Value.Address, httpclient, _agvOptions.Value.Path); - ret = await client.PushOutTaskSparePartAsync(request).ConfigureAwait(false); - - } - catch (Exception e) - { - ret = new AgvResultObject(); - ret.Code = "1"; - ret.Message = e.Message; - ret.ReqCode = job.SparePartRequestNumber; - await unitOfWork.RollbackAsync().ConfigureAwait(false); - throw new UserFriendlyException($"接口报错 错误信息{e.Message}"); - } - return ret; + return new AgvResultObject(); } #endregion 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 012a88931..264713fd2 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 @@ -702,28 +702,7 @@ public class UnplannedIssueJobAppService [HttpPost("call-agv")] public async Task CallAgvAsync(UnplannedIssueJob job, UnplannedIssueJobDetail detail) { - var res = new ReusltObject(); - List errors = new List(); - List successList = new List(); - - var jobres = await SendInterFaceAsync(job, detail).ConfigureAwait(false); - if (jobres.Code != "0") - { - _logger.LogInformation(jobres.Message); - errors.Add(jobres.Message); - } - else - { - successList.Add(jobres.Message); - } - if (errors.Count > 0) - { - res.Code = -1; - res.Message = string.Join(",", errors); - res.Data = ""; - return res; - } - return res; + return new ReusltObject(); } /// @@ -734,59 +713,7 @@ 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,true).ConfigureAwait(false); - if (job == null) - { - return ReturnMessage("-1", $"{agvRequest.OrderNum}未找到该任务"); - } - - if (job.JobStatus != EnumJobStatus.WaitAgv) - { - return ReturnMessage("-1", "该任务状态不是等待AGV中"); - } - var toLocationDto = await _locationAppService.GetByCodeAsync(agvRequest.EndPosition ).ConfigureAwait(false);//agvRequest.BeginPosition调试时确认 - if (toLocationDto == null) - { - return ReturnMessage("-1", $"{agvRequest.EndPosition}库位没查到!"); - } - - var detail = new UnplannedIssueJobDetail(); - detail.HandledQty = agvRequest.MatQty; - detail.HandledPackingCode = agvRequest.PakingCode; - detail.HandledLot = agvRequest.BatchAttr07; - detail.Status = EnumInventoryStatus.OK; - detail.HandledFromWarehouseCode = toLocationDto.WarehouseCode; - detail.HandledFromLocationCode = toLocationDto.Code; - detail.HandledFromLocationGroup = toLocationDto.LocationGroupCode; - detail.HandledFromLocationArea = toLocationDto.AreaCode; - detail.HandledFromLocationErpCode = toLocationDto.ErpLocationCode; - detail.ItemCode = job.ItemCode; - detail.ItemDesc1=job.ItemDesc1; - detail.ItemDesc2=job.ItemDesc2; - detail.ItemName=job.ItemName; - detail.CaseCode=job.CaseCode; - detail.Explain=job.Explain; - detail.OnceBusiCode=job.OnceBusiCode; - detail.ProjCapacityCode=job.ProjCapacityCode; - detail.Number=job.Number; - - job.Details.Add(detail); - - 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"); + return new AgvResultObject(); } /// @@ -797,12 +724,7 @@ public class UnplannedIssueJobAppService /// private AgvResultObject ReturnMessage(string code, string message) { - return new AgvResultObject() - { - Code = code, - Message = message, - ReqCode = "" - }; + return new AgvResultObject(); } @@ -816,88 +738,7 @@ public class UnplannedIssueJobAppService /// private async Task SendInterFaceAsync(UnplannedIssueJob job, UnplannedIssueJobDetail detail) { -#if DEBUG return new AgvResultObject(); -#endif - - - - - var ret = new AgvResultObject - { - Code = "0", - ReqCode = job.UnplannedIssueRequestNumber, - Message = "OK" - }; - - //return ret;//暂时无接口直接返回 - - using var unitOfWork = _unitOfWorkManager.Begin(); - try - { - - if (job.JobStatus == EnumJobStatus.Done) - { - throw new UserFriendlyException($"任务{job.Number}为已完成状态,不能发起AGV任务!"); - } - - var request = new AgvRequestUnplanned(); - request.MatCode = detail.ItemCode; - request.MatQty = detail.RecommendQty; - request.OrderNum = job.Number; - request.Batch = detail.HandledPackingCode; - request.ErpLocationCode = job.FromErpLocationCode; - request.PakingCode = detail.HandledPackingCode; - request.BeginPosition = detail.HandledFromLocationCode; - request.EndPosition = detail.HandledFromLocationCode; - request.OrderType = job.UnplannedIssueType == EnumUnplannedIssueType.Raw ? ((int)EnumJobType.UnplannedIssueJobHasPacking).ToString() :((int)EnumJobType.UnplannedIssueJobNoPacking).ToString(); ; - request.State = "1"; - request.PakingCode = !string.IsNullOrEmpty(detail.HandledPackingCode) ? detail.HandledPackingCode : string.Empty; - request.Batch = ""; - var httpclient = _httpClientFactory.CreateClient(); - _agvOptions.Value.Address = string.IsNullOrEmpty(_agvOptions.Value.Address) - ? "http://7e42682n64.goho.co:21171/" - : _agvOptions.Value.Address; //测试地址 - _agvOptions.Value.Token = - string.IsNullOrEmpty(_agvOptions.Value.Token) ? string.Empty : _agvOptions.Value.Token; //测试token - _agvOptions.Value.UserName = - string.IsNullOrEmpty(_agvOptions.Value.UserName) ? "" : _agvOptions.Value.UserName; //测试用户名 - _agvOptions.Value.Password = - string.IsNullOrEmpty(_agvOptions.Value.Password) ? "" : _agvOptions.Value.Password; //测试密码 - _agvOptions.Value.Path = string.IsNullOrEmpty(_agvOptions.Value.Path) - ? "zozocnApi/custom/receiveProductionPlan" - : _agvOptions.Value.Path; //测试密码 - var flag = DateTime.Now.ToString("yyyyMMddHHmmss"); - - if (!string.IsNullOrEmpty(_agvOptions.Value.Token)) - { - var token = _agvOptions.Value.Token; - httpclient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); - } - - if (!string.IsNullOrEmpty(_agvOptions.Value.UserName) && !string.IsNullOrEmpty(_agvOptions.Value.Password)) - { - var username = _agvOptions.Value.UserName; - var password = _agvOptions.Value.Password; - httpclient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", - Convert.ToBase64String(Encoding.ASCII.GetBytes($"{username}:{password}"))); - } - _logger.LogInformation($"发送Json{JsonSerializer.Serialize(request)}{DateTime.Now.ToString()}"); - var client = new AgvJobClient(_agvOptions.Value.Address, httpclient, _agvOptions.Value.Path); - ret = await client.PushOutTaskUnplannedAsync(request).ConfigureAwait(false); - - - } - catch (Exception e) - { - ret = new AgvResultObject(); - ret.Code = "1"; - ret.Message = e.Message; - ret.ReqCode = job.UnplannedIssueRequestNumber; - await unitOfWork.RollbackAsync().ConfigureAwait(false); - throw new UserFriendlyException($"接口报错 错误信息{e.Message}"); - } - return ret; } 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 ca77eea35..1ca22053b 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 @@ -355,28 +355,7 @@ public class UnplannedReceiptJobAppService [HttpPost("call-agv")] public async Task CallAgvAsync(UnplannedReceiptJob job,UnplannedReceiptJobDetail detail) { - var res = new ReusltObject(); - List errors = new List(); - List successList = new List(); - - var jobres = await SendInterFaceAsync(job,detail).ConfigureAwait(false); - if (jobres.Code != "0") - { - _logger.LogInformation(jobres.Message); - errors.Add(jobres.Message); - } - else - { - successList.Add(jobres.Message); - } - if (errors.Count > 0) - { - res.Code = -1; - res.Message = string.Join(",", errors); - res.Data = ""; - return res; - } - return res; + return new ReusltObject(); } /// @@ -387,41 +366,7 @@ public class UnplannedReceiptJobAppService [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) - { - return ReturnMessage("-1", $"{agvRequest.OrderNum}未找到该任务"); - } - if (job.JobStatus != EnumJobStatus.WaitAgv) - { - return ReturnMessage("-1", $"{agvRequest.OrderNum}任务状态不是等待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; - detail.HandledToWarehouseCode = toLocationDto.WarehouseCode; - detail.HandledToLocationCode = toLocationDto.Code; - 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"); + return new AgvResultObject(); } /// /// 返回信息 @@ -431,12 +376,7 @@ public class UnplannedReceiptJobAppService /// private AgvResultObject ReturnMessage(string code, string message) { - return new AgvResultObject() - { - Code = code, - Message = message, - ReqCode = "" - }; + return new AgvResultObject(); } /// @@ -447,87 +387,6 @@ public class UnplannedReceiptJobAppService /// private async Task SendInterFaceAsync(UnplannedReceiptJob job,UnplannedReceiptJobDetail detail) { -#if DEBUG return new AgvResultObject(); -#endif - - - var ret = new AgvResultObject - { - Code = "0", - ReqCode = job.UnplannedReceiptRequestNumber, - Message = "OK" - }; - //return ret;//暂时无接口直接返回 - - using var unitOfWork = _unitOfWorkManager.Begin(); - try - { - - if (job.JobStatus == EnumJobStatus.Done) - { - throw new UserFriendlyException($"任务{job.Number}为已完成状态,不能发起AGV任务!"); - } - - var request = new AgvRequestUnplanned(); - request.MatCode = detail.ItemCode; - request.MatQty = detail.RecommendQty; - request.OrderNum = job.Number; - request.Batch = detail.HandledPackingCode; - request.ErpLocationCode = job.FromErpLocationCode; - request.PakingCode = detail.HandledPackingCode; - request.EndPosition = detail.HandledToLocationCode; - - request.OrderType = job.UnplannedReceiptType == EnumUnplannedReceiptType.Raw ? ((int)EnumJobType.UnplannedReceiptJobHasPacking).ToString() : ((int)EnumJobType.UnplannedReceiptJobNoPacking).ToString(); - request.State = "1"; - request.PakingCode = !string.IsNullOrEmpty(detail.HandledPackingCode) ? detail.HandledPackingCode : string.Empty; - request.Batch = ""; - var httpclient = _httpClientFactory.CreateClient(); - _agvOptions.Value.Address = string.IsNullOrEmpty(_agvOptions.Value.Address) - ? "http://7e42682n64.goho.co:21171/" - : _agvOptions.Value.Address; //测试地址 - _agvOptions.Value.Token = - string.IsNullOrEmpty(_agvOptions.Value.Token) ? string.Empty : _agvOptions.Value.Token; //测试token - _agvOptions.Value.UserName = - string.IsNullOrEmpty(_agvOptions.Value.UserName) ? "" : _agvOptions.Value.UserName; //测试用户名 - _agvOptions.Value.Password = - string.IsNullOrEmpty(_agvOptions.Value.Password) ? "" : _agvOptions.Value.Password; //测试密码 - _agvOptions.Value.Path = string.IsNullOrEmpty(_agvOptions.Value.Path) - ? "zozocnApi/custom/receiveProductionPlan" - : _agvOptions.Value.Path; //测试密码 - var flag = DateTime.Now.ToString("yyyyMMddHHmmss"); - - if (!string.IsNullOrEmpty(_agvOptions.Value.Token)) - { - var token = _agvOptions.Value.Token; - httpclient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); - } - - if (!string.IsNullOrEmpty(_agvOptions.Value.UserName) && !string.IsNullOrEmpty(_agvOptions.Value.Password)) - { - var username = _agvOptions.Value.UserName; - var password = _agvOptions.Value.Password; - httpclient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", - Convert.ToBase64String(Encoding.ASCII.GetBytes($"{username}:{password}"))); - } - - var client = new AgvJobClient(_agvOptions.Value.Address, httpclient, _agvOptions.Value.Path); - _logger.LogInformation($"发送Json{JsonSerializer.Serialize(request)}{DateTime.Now.ToString()}"); - - - ret = await client.PushOutTaskUnplannedReceiptAsync(request).ConfigureAwait(false); - - - } - catch (Exception e) - { - ret = new AgvResultObject(); - ret.Code = "1"; - ret.Message = e.Message; - ret.ReqCode = job.UnplannedReceiptRequestNumber; - await unitOfWork.RollbackAsync().ConfigureAwait(false); - throw new UserFriendlyException($"接口报错 错误信息{e.Message}"); - } - return ret; } } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/OperationPacking/IntegrationPackingNotes/IntegrationPackingNoteAppService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/OperationPacking/IntegrationPackingNotes/IntegrationPackingNoteAppService.cs index 3de9ad21e..4c211d56e 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/OperationPacking/IntegrationPackingNotes/IntegrationPackingNoteAppService.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/OperationPacking/IntegrationPackingNotes/IntegrationPackingNoteAppService.cs @@ -73,52 +73,7 @@ public class IntegrationPackingNoteAppService : [HttpPost("")] public override async Task CreateAsync(IntegrationPackingNoteEditInput input) { - var transferLogEditInputs = new List(); - - var outDtos = await _expectOutAppService.GetListByPackingCodeAsync(input.PackingCode).ConfigureAwait(false); - var balanceMainDto = await _balanceAppService.GetByPackingCodeAsync(input.PackingCode).ConfigureAwait(false); - - if (outDtos.Any()) - { - throw new UserFriendlyException($"此库存{input.PackingCode}已经被【任务编号:{outDtos.First().JobNumber}】占用"); - } - - var entity = input.ToObject(); - var number = await GenerateNumberAsync(nameof(IntegrationPackingNote), Clock.Now).ConfigureAwait(false); - entity.Number = number; - entity.SetId(GuidGenerator.Create()); - entity.SetIdAndNumberWithDetails(GuidGenerator, entity.Number); - entity.WarehouseCode = string.Empty; - entity.Details.ForEach(p=>p.WarehouseCode=string.Empty); - - entity = await _repository.InsertAsync(entity).ConfigureAwait(false); - - var balanceDetailDtos = new List(); - foreach (var detailInput in input.Details) - { - var balanceDetailDto=await _balanceAppService.GetByPackingCodeAsync(detailInput.PackingCode).ConfigureAwait(false); - if (balanceDetailDto.LocationCode != balanceMainDto.LocationCode) - { - throw new UserFriendlyException($"箱码【{detailInput.PackingCode}】的库存需要再{balanceMainDto.LocationCode}库位上才可合并"); - } - - //库存移动 - var transferLogEditInput = - await BuildTransferLogsAsync(entity, detailInput) - .ConfigureAwait(false); - transferLogEditInputs.Add(transferLogEditInput); - balanceDetailDtos.Add(balanceDetailDto); - } - - if (balanceDetailDtos.Sum(p=>p.Qty) > input.StdPackQty) - { - throw new UserFriendlyException($"合箱数量超过标包数量"); - } - - await _transferLogAppService.AddManyAsync(transferLogEditInputs).ConfigureAwait(false); - - var dto = entity.ToObject(); - return dto; + return new IntegrationPackingNoteDTO(); } /// @@ -131,48 +86,6 @@ public class IntegrationPackingNoteAppService : IntegrationPackingNote entity, IntegrationPackingNoteDetailInput detailInput) { - var fromLocationDto = await _locationAppService.GetByCodeAsync(detailInput.LocationCode).ConfigureAwait(false); - var toLocationDto = await _locationAppService.GetByCodeAsync(entity.LocationCode).ConfigureAwait(false); - - var transferLogEditInput = new TransferLogEditInput - { - Worker = entity.Worker, - Qty = detailInput.Qty, - ItemCode = detailInput.ItemCode, - FromLocationCode = fromLocationDto.Code, - FromLocationErpCode = fromLocationDto.ErpLocationCode, - FromLocationArea = fromLocationDto.AreaCode, - FromLocationGroup = fromLocationDto.LocationGroupCode, - FromWarehouseCode = fromLocationDto.WarehouseCode, - ToLocationCode = toLocationDto.Code, - ToLocationErpCode = toLocationDto.ErpLocationCode, - ToLocationArea = toLocationDto.AreaCode, - ToLocationGroup = toLocationDto.LocationGroupCode, - ToWarehouseCode = toLocationDto.WarehouseCode, - ToPackingCode = entity.PackingCode, - Remark = entity.Remark, - ArriveDate = entity.ArriveDate, - DocNumber = string.Empty, - ExpireDate = entity.ExpireDate, - FromContainerCode = detailInput.ContainerCode, - FromLot = detailInput.Lot, - FromPackingCode = detailInput.PackingCode, - Uom = detailInput.Uom, - FromStatus = EnumInventoryStatus.OK, - JobNumber = string.Empty, - ItemDesc1 = entity.ItemDesc1, - StdPackQty = entity.StdPackQty, - TransType = EnumTransType.Transfer, - ToLot = entity.Lot, - ItemDesc2 = entity.ItemDesc2, - ItemName = entity.ItemName, - ProduceDate = entity.ProduceDate, - SupplierBatch = entity.SupplierBatch, - ToContainerCode = detailInput.ContainerCode, - ToStatus = EnumInventoryStatus.OK, - TransSubType = EnumTransSubType.Transfer_Integration, - }; - - return transferLogEditInput; + return new TransferLogEditInput(); } } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/OperationPacking/SeparationPackingNotes/SeparationPackingNoteAppService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/OperationPacking/SeparationPackingNotes/SeparationPackingNoteAppService.cs index 70e35e2d4..87f3e16a4 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/OperationPacking/SeparationPackingNotes/SeparationPackingNoteAppService.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/OperationPacking/SeparationPackingNotes/SeparationPackingNoteAppService.cs @@ -61,132 +61,7 @@ public class SeparationPackingNoteAppService : [HttpPost("")] public override async Task CreateAsync(SeparationPackingNoteEditInput input) { - var transferLogEditInputs = new List(); - - var outDtos = await _expectOutAppService.GetListByPackingCodeAsync(input.PackingCode).ConfigureAwait(false); - if (outDtos.Any()) - { - throw new UserFriendlyException($"此库存{input.PackingCode}已经被【任务编号:{outDtos.First().JobNumber}】占用"); - } - - if (input.Details.Sum(p => p.Qty) > input.Qty) - { - throw new UserFriendlyException($"拆出数量大于原箱数量"); - } - - if (input.Qty <= 0) - { - throw new UserFriendlyException($"被拆箱的数量小于或等于0"); - } - - var entity = input.ToObject(); - var number = await GenerateNumberAsync(nameof(SeparationPackingNote), Clock.Now).ConfigureAwait(false); - entity.Number = number; - entity.SetId(GuidGenerator.Create()); - entity.SetIdAndNumberWithDetails(GuidGenerator, entity.Number); - - entity = await _repository.InsertAsync(entity).ConfigureAwait(false); - - foreach (var detail in entity.Details) - { - //创建标签 - var splitPackingRecDtos = await _splitPackingRecAppService.GetListByToPackingCode(new List { input.PackingCode }).ConfigureAwait(false); - var splitPackingRecDto = splitPackingRecDtos.First(); - var inventoryLabelWithoutCodeCreateInput = new InventoryLabelWithoutCodeCreateInput - { - Qty = detail.Qty, - ItemCode = detail.ItemCode, - SupplierCode = detail.SupplierCode, - Lot = detail.Lot, - Uom = detail.Uom, - LocationErpCode = detail.LocationErpCode, - ItemDesc1 = detail.ItemDesc1, - ArriveDate = detail.ArriveDate, - StdPackQty = detail.StdPackQty, - ProdLine = string.Empty, - AsnNumber = detail.PurchaseInfo_AsnNumber, - ContainerCode = detail.ContainerCode, - ExpireDate = detail.ExpireDate, - FullBarcodeString = string.Empty, - ItemDesc2 = detail.ItemDesc2, - ItemName = detail.ItemName, - SupplierName = detail.SupplierName, - Remark = detail.Remark, - LabelStatus = LabelStatus.Enable, - LabelType = detail.LabelType, - PlanArriveDate = detail.PlanArriveDate, - PoNumber = detail.PurchaseInfo_PoNumber, - ProduceDate = detail.ProduceDate, - QLevel = string.Empty, - QualityFile = string.Empty, - RecommendLocationCode = detail.RecommendLocationCode, - RpNumber = detail.RpNumber, - Shift = string.Empty, - Specifications = string.Empty, - SupplierBatch = detail.SupplierBatch, - SupplierItemCode = detail.ItemCode, - SupplierItemName = detail.SupplierItemName, - SupplierSimpleName = detail.SupplierSimpleName, - Team = string.Empty, - }; - var inventoryLabelDto = await _inventoryLabelAppService.GenerateAndCreateAsync(inventoryLabelWithoutCodeCreateInput).ConfigureAwait(false); - var splitPackingRecEditInputs = new List() - { - new SplitPackingRecEditInput() - { - ItemCode = inventoryLabelDto.ItemCode, - SupplierCode = inventoryLabelDto.SupplierCode, - ToPackingCode = inventoryLabelDto.Code, - FromPackingCode = input.PackingCode, - LocationErpCode = inventoryLabelDto.LocationErpCode, - ItemDesc1 = inventoryLabelDto.ItemDesc1, - FromLot = input.Lot, - ToLot = inventoryLabelDto.Lot, - ArriveDate = inventoryLabelDto.ArriveDate, - ItemName = inventoryLabelDto.ItemName, - ItemDesc2 = inventoryLabelDto.ItemDesc2, - PurchaseInfo_PoNumber = inventoryLabelDto.PoNumber, - LabelType = (EnumLabelType)inventoryLabelDto.LabelType, - RecommendLocationCode = inventoryLabelDto.RecommendLocationCode, - RpNumber = inventoryLabelDto.RpNumber, - SupplierName = inventoryLabelDto.SupplierName, - Remark = inventoryLabelDto.Remark, - FromQty = input.Qty, - ToQty = inventoryLabelDto.Qty, - PurchaseInfo_AsnNumber = inventoryLabelDto.AsnNumber, - ExpireDate = inventoryLabelDto.ExpireDate, - FullBarcodeString = inventoryLabelDto.FullBarcodeString, - SupplierBatch = inventoryLabelDto.SupplierBatch, - ProduceDate = inventoryLabelDto.ProduceDate, - LabelStatus = Basedata.LabelStatus.Enable, - SupplierSimpleName = inventoryLabelDto.SupplierSimpleName, - SupplierItemCode = inventoryLabelDto.SupplierItemCode, - SupplierItemName = inventoryLabelDto.SupplierItemName, - PlanArriveDate = inventoryLabelDto.PlanArriveDate, - FromStdPackQty = input.StdPackQty, - FromUom = input.Uom, - OprType = OprTypeEnum.SplitBox, - ReceiptRecNumber = inventoryLabelDto.RpNumber, - ToStdPackQty = inventoryLabelDto.StdPackQty, - ToUom = inventoryLabelDto.Uom, - TaskOrderNumber = detail.TaskOrderNumber, - ArrivalNoticNumber = detail.ArrivalNoticNumber, - PutOnShelfNumber = detail.PutOnShelfNumber, - } - }; - await _splitPackingRecAppService.BatchInsertAsync(splitPackingRecEditInputs).ConfigureAwait(false); - detail.PackingCode = inventoryLabelDto.Code; - - //库存移动 - var transferLogEditInput = await BuildTransferLogsAsync(entity, detail, splitPackingRecEditInputs.First()).ConfigureAwait(false); - transferLogEditInputs.Add(transferLogEditInput); - } - - //await _repository.UpdateAsync(entity).ConfigureAwait(false); - var dto = entity.ToObject(); - - await _transferLogAppService.AddManyAsync(transferLogEditInputs).ConfigureAwait(false); - return dto; + return new SeparationPackingNoteDTO(); } /// @@ -201,48 +76,6 @@ public class SeparationPackingNoteAppService : SeparationPackingNoteDetail detail, SplitPackingRecEditInput splitPackingRecEditInput) { - var fromLocationDto = await _locationAppService.GetByCodeAsync(entity.LocationCode).ConfigureAwait(false); - var toLocationDto = await _locationAppService.GetByCodeAsync(detail.LocationCode).ConfigureAwait(false); - - var transferLogEditInput = new TransferLogEditInput - { - Worker = entity.Worker, - Qty = detail.Qty, - ItemCode = detail.ItemCode, - FromLocationCode = fromLocationDto.Code, - FromLocationErpCode = fromLocationDto.ErpLocationCode, - FromLocationArea = fromLocationDto.AreaCode, - FromLocationGroup = fromLocationDto.LocationGroupCode, - FromWarehouseCode = fromLocationDto.WarehouseCode, - ToLocationCode = toLocationDto.Code, - ToLocationErpCode = toLocationDto.ErpLocationCode, - ToLocationArea = toLocationDto.AreaCode, - ToLocationGroup = toLocationDto.LocationGroupCode, - ToWarehouseCode = toLocationDto.WarehouseCode, - ToPackingCode = splitPackingRecEditInput.ToPackingCode, - Remark = splitPackingRecEditInput.Remark, - ArriveDate = splitPackingRecEditInput.ArriveDate, - DocNumber = string.Empty, - ExpireDate = splitPackingRecEditInput.ExpireDate, - FromContainerCode = detail.ContainerCode, - FromLot = splitPackingRecEditInput.FromLot, - FromPackingCode = entity.PackingCode, - Uom = splitPackingRecEditInput.FromUom, - FromStatus = EnumInventoryStatus.OK, - JobNumber = string.Empty, - ItemDesc1 = splitPackingRecEditInput.ItemDesc1, - StdPackQty = splitPackingRecEditInput.FromStdPackQty, - TransType = EnumTransType.Transfer, - ToLot = splitPackingRecEditInput.ToLot, - ItemDesc2 = splitPackingRecEditInput.ItemDesc2, - ItemName = splitPackingRecEditInput.ItemName, - ProduceDate = splitPackingRecEditInput.ProduceDate, - SupplierBatch = splitPackingRecEditInput.SupplierBatch, - ToContainerCode = detail.ContainerCode, - ToStatus = EnumInventoryStatus.OK, - TransSubType = EnumTransSubType.Transfer_SplitPacking - }; - - return transferLogEditInput; + return new TransferLogEditInput(); } }