From 1205367d40c1fd07551e68e1bec9cc05a0a561a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=A6=20=E8=B5=B5?= <89237069@qq.com> Date: Mon, 23 Dec 2024 11:40:15 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=89=88=E6=9C=AC=E5=8F=91?= =?UTF-8?q?=E6=96=99=E4=BB=BB=E5=8A=A1=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AssembleIssueJobAppService.cs | 13 - .../CoatingIssueJobAppService.cs | 17 +- .../InjectionIssueJobAppService.cs | 815 +++++++++--------- .../KittingIssueJobAppService.cs | 330 ++++--- .../SparePartIssueJobAppService.cs | 44 +- .../UnplannedReceiptJobAppService.cs | 4 +- 6 files changed, 599 insertions(+), 624 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 cf7fe2f57..32b0748f3 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 @@ -304,19 +304,6 @@ public class AssembleIssueJobAppService ? "LYF" : _options.Value.StereosPassword; - - //if (assembleIssueJob.IsClaims) - //{ - // if (assembleIssueJob.ClaimsUserId != _currentUser.Id.ToString()) - // { - // throw new UserFriendlyException($"该任务已被【{assembleIssueJob.ClaimsUserName}】承接"); - // } - //} - //else - //{ - // throw new UserFriendlyException("该任务未被承接,请重新刷新页面,承接任务"); - //} - var assembleIssueJobDto = ObjectMapper.Map(assembleIssueJob); assembleIssueJobDto.Details = new List { issueJobDetailDto }; var assembleIssueNoteEditInput = await BuildAssembleIssueNoteAsync(assembleIssueJobDto).ConfigureAwait(false); diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/CoatingIssueJobs/CoatingIssueJobAppService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/CoatingIssueJobs/CoatingIssueJobAppService.cs index 1d2b539e0..59f664555 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 @@ -372,17 +372,12 @@ public class CoatingIssueJobAppService { var coatingIssueJob = await _repository.GetAsync(masterId).ConfigureAwait(false); coatingIssueJob.JobStatus = EnumJobStatus.Doing; - if (coatingIssueJob.IsClaims) - { - if (coatingIssueJob.ClaimsUserId != _currentUser.Id.ToString()) - { - throw new UserFriendlyException($"该任务已被【{coatingIssueJob.ClaimsUserName}】承接"); - } - } - else - { - throw new UserFriendlyException("该任务未被承接,请重新刷新页面,承接任务"); - } + + coatingIssueJob.ClaimsUserId = + string.IsNullOrEmpty(_options.Value.StereosUser) ? "LYF" : _options.Value.StereosUser; + coatingIssueJob.ClaimsUserName = string.IsNullOrEmpty(_options.Value.StereosPassword) + ? "LYF" + : _options.Value.StereosPassword; var coatingIssueJobDto = ObjectMapper.Map(coatingIssueJob); 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 85c0e378d..0f47d4c0b 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 @@ -338,17 +338,11 @@ public class InjectionIssueJobAppService { var injectionIssueJob = await _repository.GetAsync(masterId).ConfigureAwait(false); injectionIssueJob.JobStatus = EnumJobStatus.Doing; - if (injectionIssueJob.IsClaims) - { - if (injectionIssueJob.ClaimsUserId != _currentUser.Id.ToString()) - { - throw new UserFriendlyException($"该任务已被【{injectionIssueJob.ClaimsUserName}】承接"); - } - } - else - { - throw new UserFriendlyException("该任务未被承接,请重新刷新页面,承接任务"); - } + injectionIssueJob.ClaimsUserId = + string.IsNullOrEmpty(_options.Value.StereosUser) ? "LYF" : _options.Value.StereosUser; + injectionIssueJob.ClaimsUserName = string.IsNullOrEmpty(_options.Value.StereosPassword) + ? "LYF" + : _options.Value.StereosPassword; var injectionIssueJobDto = ObjectMapper.Map(injectionIssueJob); injectionIssueJobDto.Details = new List { issueJobDetailDto }; @@ -487,71 +481,28 @@ public class InjectionIssueJobAppService return dto; } - - - #region 私有 - - /// - /// 创建补料记录实体 - /// - /// - /// - private async Task BuildInjectionIssueNoteAsync(InjectionIssueJobDTO injectionIssueJobDto) - { - var injectionIssueNoteCreateInput = - ObjectMapper.Map(injectionIssueJobDto); - injectionIssueNoteCreateInput.JobNumber = injectionIssueJobDto.Number; - - await Task.CompletedTask.ConfigureAwait(false); - - return injectionIssueNoteCreateInput; - } + #region 立库 /// - /// 判断是不是在最底层 如果不是则把状态变更为待库移 并把库移推荐的From和To赋值 + /// 调用立体库 /// - /// + /// /// - private async Task CheckMinRowAndSetStatusAsync(InjectionIssueJobEditInput input) + private async Task DoingDimensionalStorehouseAsync(InjectionIssueJobDTO InjectionIssueJobDto) { - var jobDetailInputdetail = input.Details.FirstOrDefault(); - + var jobDetailInputdetail = InjectionIssueJobDto.Details.FirstOrDefault(); var loctionDto = await _locationAppService.GetByCodeAsync(jobDetailInputdetail.RecommendFromLocationCode) .ConfigureAwait(false); - if (loctionDto.Type == EnumLocationType.RAW && loctionDto.RowCode != 1) - { - input.JobStatus = EnumJobStatus.Wait; - } - else if (loctionDto.Type == EnumLocationType.RAW && loctionDto.RowCode == 1) + if (loctionDto.Type == EnumLocationType.DimensionalStorehouse) { - jobDetailInputdetail.TransferLibFromArriveDate = jobDetailInputdetail.RecommendFromArriveDate; - jobDetailInputdetail.TransferLibFromContainerCode = jobDetailInputdetail.RecommendFromContainerCode; - jobDetailInputdetail.TransferLibFromExpireDate = jobDetailInputdetail.RecommendFromExpireDate; - jobDetailInputdetail.TransferLibFromLocationArea = jobDetailInputdetail.RecommendFromLocationArea; - jobDetailInputdetail.TransferLibFromLocationCode = jobDetailInputdetail.RecommendFromLocationCode; - jobDetailInputdetail.TransferLibFromLocationErpCode = jobDetailInputdetail.RecommendFromLocationErpCode; - jobDetailInputdetail.TransferLibFromLocationGroup = jobDetailInputdetail.RecommendFromLocationGroup; - jobDetailInputdetail.TransferLibFromLot = jobDetailInputdetail.RecommendFromLot; - jobDetailInputdetail.TransferLibFromPackingCode = jobDetailInputdetail.RecommendFromPackingCode; - jobDetailInputdetail.TransferLibFromProduceDate = jobDetailInputdetail.RecommendFromProduceDate; - jobDetailInputdetail.TransferLibFromQty = jobDetailInputdetail.RecommendFromQty; - jobDetailInputdetail.TransferLibFromSupplierBatch = jobDetailInputdetail.RecommendFromSupplierBatch; - jobDetailInputdetail.TransferLibFromWarehouseCode = jobDetailInputdetail.RecommendFromWarehouseCode; - - jobDetailInputdetail.TransferLibToArriveDate = jobDetailInputdetail.RecommendToArriveDate; - jobDetailInputdetail.TransferLibToContainerCode = jobDetailInputdetail.RecommendToContainerCode; - jobDetailInputdetail.TransferLibToExpireDate = jobDetailInputdetail.RecommendToExpireDate; - jobDetailInputdetail.TransferLibToLot = jobDetailInputdetail.RecommendToLot; - jobDetailInputdetail.TransferLibToPackingCode = jobDetailInputdetail.RecommendToPackingCode; - jobDetailInputdetail.TransferLibToProduceDate = jobDetailInputdetail.RecommendToProduceDate; - jobDetailInputdetail.TransferLibToQty = jobDetailInputdetail.RecommendToQty; - jobDetailInputdetail.TransferLibToSupplierBatch = jobDetailInputdetail.RecommendToSupplierBatch; - jobDetailInputdetail.TransferLibToWarehouseCode = jobDetailInputdetail.TransferLibFromWarehouseCode; - jobDetailInputdetail.TransferLibToLocationArea = jobDetailInputdetail.TransferLibFromLocationArea; - jobDetailInputdetail.TransferLibToLocationCode = jobDetailInputdetail.TransferLibFromLocationCode; - jobDetailInputdetail.TransferLibToLocationErpCode = jobDetailInputdetail.TransferLibFromLocationErpCode; - jobDetailInputdetail.TransferLibToLocationGroup = jobDetailInputdetail.TransferLibFromLocationGroup; + //TODO 立体库 + var ret = await SyncIssueJobStereoAsync(new List { InjectionIssueJobDto }, + jobDetailInputdetail.RecommendToLocationCode, InjectionIssueJobDto.Id).ConfigureAwait(false); + if (ret.Code != 0) + { + throw new UserFriendlyException($"调用立体库不成功!原因:{ret.Message}"); + } } } @@ -560,7 +511,7 @@ public class InjectionIssueJobAppService /// /// /// - private async Task CheckDimensionalStorehouseAsync(InjectionIssueJobEditInput input) + private async Task UpdateJobStatusWaitByDimensionalStorehouseAsync(InjectionIssueJobEditInput input) { var jobDetailInputdetail = input.Details.FirstOrDefault(); @@ -570,125 +521,312 @@ public class InjectionIssueJobAppService if (loctionDto.Type == EnumLocationType.DimensionalStorehouse) { input.JobStatus = EnumJobStatus.Wait; + return true; } - } - - - /// - /// 修改当前任务状态 和 该任务的请求状态 - /// - /// - /// - /// - /// - /// - private async Task UpdateRequestAndjobStatusDoneAsync(InjectionIssueJob injectionIssueJob, - InjectionIssueJobDetailDTO injectionIssueJobDetailDto, decimal handledToQty) - { - if (injectionIssueJob.JobStatus is EnumJobStatus.Closed or EnumJobStatus.Cancelled or EnumJobStatus.None - or EnumJobStatus.Done) //需要考虑下 多次提交的问题 所以不判断 进行中 - { - throw new UserFriendlyException( - $"任务状态错误:编号为【{injectionIssueJob.Number}】的任务状态为【{injectionIssueJob.JobStatus.GetDisplayName()}】"); - } - - injectionIssueJob.JobStatus = EnumJobStatus.Done; - - await RemoveExpectOutAsync(injectionIssueJob, injectionIssueJobDetailDto, handledToQty).ConfigureAwait(false); - - //await _expectOutAppService.RemoveByNumberAsync(injectionIssueJob.Number).ConfigureAwait(false); - - await InjectionIssueRequestAppService.UpdateStatusCompletedAsync(injectionIssueJob.InjectionRequestNumber) - .ConfigureAwait(false); - await Task.CompletedTask.ConfigureAwait(false); + return false; } /// - /// 判断实际TO的箱码是否被占用 + /// 立体库同步 /// - /// - /// + /// + /// /// - /// - private async Task CheckPackingCodeIsUserAsync(string packingCode, string jobNumber) + [HttpPost("sync-issue-job-stereo")] + public async Task SyncIssueJobStereoAsync(List input, string pLoc, Guid uid) { - var list = await _expectOutAppService.GetListByPackingCodeAsync(packingCode).ConfigureAwait(false); - list = list.Where(p => p.JobNumber != jobNumber).ToList(); - if (list.Any()) + var ret = new ReusltObject(); + ret.Code = 0; + ret.Message = "操作成功"; + ret.OperateTime = DateTime.Now.ToString("yyyy-MM-dd"); + using var unitOfWork = _unitOfWorkManager.Begin(); + try { - throw new UserFriendlyException($"任务号【{list.First().JobNumber}】的任务,已占用【{packingCode}】箱码的库存。"); - } - } - - private async Task RemoveExpectOutAsync(InjectionIssueJob injectionIssueJob, - InjectionIssueJobDetailDTO injectionIssueJobDetailDto, - decimal handledToQty) - { - await _expectOutAppService.RemoveByNumberAndInventoryAsync(injectionIssueJob.Number, - injectionIssueJobDetailDto.ItemCode, - injectionIssueJobDetailDto.HandledToLocationCode, injectionIssueJobDetailDto.HandledToPackingCode, - injectionIssueJobDetailDto.Status, injectionIssueJobDetailDto.HandledToLot, - handledToQty).ConfigureAwait(false); - } + var IssueJobToRestoDetailDTOs = new List(); + var main = new IssueJobToRestoDTO(); + main.Uuid = uid; + main.OperatorName = string.IsNullOrEmpty(CurrentUser.UserName) ? "admin" : CurrentUser.UserName; + foreach (var job in input) + { + foreach (var jobitem in job.Details) + { + IssueJobToRestoDetailDTOs.Add(new IssueJobToRestoDetailDTO + { + Count = jobitem.RecommendFromQty, + ProductNo = jobitem.ItemCode, + NeedSite = pLoc, + WorkNo = job.InjectionRequestNumber, + TaskNo = job.Number + }); + } + } + main.Details = IssueJobToRestoDetailDTOs; + var httpclient = _httpClientFactory.CreateClient(); +#if DEBUG + var json = JsonSerializer.Serialize(main); + _options.Value.Address = "http://localhost:59094/"; //测试地址 + _options.Value.Token = ""; //测试token + _options.Value.UserName = ""; //测试用户名 + _options.Value.Password = ""; //测试密码 +#endif + //var json = JsonSerializer.Serialize(main); + _options.Value.Address = string.IsNullOrEmpty(_options.Value.Address) + ? "http://7e42682n64.goho.co:21171/" + : _options.Value.Address; //测试地址 + _options.Value.Token = + string.IsNullOrEmpty(_options.Value.Token) ? string.Empty : _options.Value.Token; //测试token + _options.Value.UserName = + string.IsNullOrEmpty(_options.Value.UserName) ? "" : _options.Value.UserName; //测试用户名 + _options.Value.Password = + string.IsNullOrEmpty(_options.Value.Password) ? "" : _options.Value.Password; //测试密码 + _options.Value.Path = string.IsNullOrEmpty(_options.Value.Path) + ? "zozocnApi/custom/receiveProductionPlan" + : _options.Value.Path; //测试密码 + _logger.LogInformation(JsonSerializer.Serialize(_options)); + var flag = DateTime.Now.ToString("yyyyMMddHHmmss"); + _logger.LogInformation($"标志{flag}开始调用高通WMS:传递值{JsonSerializer.Serialize(main)}"); + if (!string.IsNullOrEmpty(_options.Value.Token)) + { + var token = _options.Value.Token; + httpclient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); + } - #endregion - #region Agv + if (!string.IsNullOrEmpty(_options.Value.UserName) && !string.IsNullOrEmpty(_options.Value.Password)) + { + var username = _options.Value.UserName; + var password = _options.Value.Password; + httpclient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", + Convert.ToBase64String(Encoding.ASCII.GetBytes($"{username}:{password}"))); + } - /// - /// 调用AGV - /// - /// - /// - /// - /// - private async Task DoingAgvAsync(InjectionIssueJobDTO InjectionIssueJobDto, string fromLocationCode, string toLocationCode) - { - var jobDetailInputdetail = InjectionIssueJobDto.Details.FirstOrDefault(); - var locationDeliveryDto = await _locationDeliveryAppService.GetByFromLocationCodeAndToLocationCodeAsync( - fromLocationCode, toLocationCode).ConfigureAwait(false); + var client = new IssueJobToRestoClient(_options.Value.Address, httpclient, _options.Value.Path); + ret = await client.SyncIssueJobStereoAsync(main).ConfigureAwait(false); - if (locationDeliveryDto != null && locationDeliveryDto.EnumLocationDeliveryType == EnumLocationDeliveryType.Agv) + _logger.LogInformation($"标志{flag}调用高通WMS:返回值{JsonSerializer.Serialize(ret)}"); + } + catch (Exception ex) { - //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}"); - } + ret = new ReusltObject(); + ret.Code = 1; + ret.Message = ex.Message; + ret.OperateTime = DateTime.Now.ToString("yyyy-MM-dd"); + await unitOfWork.RollbackAsync().ConfigureAwait(false); } - return false; + return ret; } - /// - /// 判断是不是有Agv - /// - /// - /// - private async Task UpdateJobStatusWaitByAgvAsync(InjectionIssueJobEditInput input) + [HttpPost("receive-issue-job-stereo")] + public virtual async Task SyncReciveIssueJobStereoAsync(IssueRequestFromRestoDTO input) { - var jobDetailInputdetail = input.Details.FirstOrDefault(); - - var locationDeliveryDto = await _locationDeliveryAppService.GetByFromLocationCodeAndToLocationCodeAsync( - jobDetailInputdetail.RecommendFromLocationCode, jobDetailInputdetail.RecommendToLocationCode).ConfigureAwait(false); - + var json = JsonSerializer.Serialize(input); + var flag = DateTime.Now.ToString("yyyyMMddHHmmss"); + _logger.LogInformation($"{flag}接收到立体库确认单据内容:" + json); +#if DEBUG +#endif + var errors = new List(); + var ret = new ReusltObject + { + Code = int.Parse(GaoTongResultStatus.Success), + OperateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), + Message = "操作成功" + }; + using var unitOfWork = _unitOfWorkManager.Begin(); + try + { + if (input.Jobs.Count > 0) + { + var jobs = input.Jobs; + var numbers = jobs.Select(p => p.JobNumber); + var query = _repository.WithDetails() + .Where(p => numbers.Contains(p.Number) && p.JobStatus != EnumJobStatus.Done); + + + var entities = query.ToList(); + if (entities.Count == 0) + { + errors.Add($"任务号{string.Join(",", numbers)}不存在!"); + } + + var dtos = ObjectMapper.Map, List>(entities); + + + if (input.Jobs.Count != entities.Count) + { + errors.Add("立体库提交出库任务和WMS任务不符,请核对! \n"); + } + + foreach (var itm in dtos) + { + + var first = jobs.FirstOrDefault(p => p.JobNumber == itm.Number); + var itmDetails = itm.Details.ToList(); + var details = new List(); + foreach (var detail in first.Details) + { + var fromloc = await _locationAppService.GetByCodeAsync(detail.FromLocationCode) + .ConfigureAwait(false); + if (fromloc == null) + { + 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) + { + errors.Add($"物料号{detail.ItemCode}不在任务明细内!"); + } + + var dto = new InjectionIssueJobDetailDTO(); + dto.InjectFrom(entity); + + /* 客户说整单完成后才回传 + dto.RecommendFromQty = detail.Qty; + dto.RecommendToQty = detail.Qty; + dto.HandledFromQty = detail.Qty; + dto.HandledToQty = detail.Qty; + */ + //dto.RecommendFromQty = detail.Qty; + //dto.RecommendToQty = detail.Qty; + //dto.HandledFromQty = detail.Qty; + //dto.HandledToQty = detail.Qty; + + dto.HandledToLocationCode = toloc.Code; + dto.HandledToLocationGroup = toloc.LocationGroupCode; + dto.HandledToLocationArea = toloc.AreaCode; + dto.HandledToLocationErpCode = toloc.ErpLocationCode; + dto.HandledToLot = string.Empty; + dto.HandledToWarehouseCode = toloc.WarehouseCode; + dto.HandledToQty = detail.Qty; + dto.HandledToLot = string.Empty; + dto.HandledToPackingCode = string.Empty; + + + dto.HandledFromWarehouseCode = fromloc.WarehouseCode; + dto.HandledFromLocationCode = fromloc.Code; + dto.HandledFromLocationGroup = fromloc.LocationGroupCode; + dto.HandledFromLocationArea = fromloc.AreaCode; + dto.HandledFromLocationErpCode = fromloc.ErpLocationCode; + dto.HandledFromQty = detail.Qty; + dto.HandledFromLot = string.Empty; + dto.HandledFromPackingCode = string.Empty; + + + details.Add(dto); + await ExecuteDetailExtAsync(itm.Id, entity.Id, dto).ConfigureAwait(false); + } + + if (errors.Count > 0) + { + ret = new ReusltObject + { + Code = int.Parse(GaoTongResultStatus.Failure), + OperateTime = DateTime.Now.ToString("yyyy-MM-dd"), + Message = string.Join(",", errors.ToArray()), + Data = json + }; + } + itm.Worker = "LITK"; + itm.Details = details; + // await CompleteAsync(itm.Id, itm).ConfigureAwait(false); + _logger.LogInformation($"{flag}接收到立体库确认单据内容:" + json + "立体库任务完成"); + } + } + else + { + errors.Add("立体库确认单据里无数据! \n"); + } + } + catch (Exception ex) + { + ret = new ReusltObject + { + Code = int.Parse(GaoTongResultStatus.Failure), + OperateTime = DateTime.Now.ToString("yyyy-MM-dd"), + Message = ex.Message, + Data = json + }; + await unitOfWork.RollbackAsync(); + return ret; + } + + if (errors.Count > 0) + { + ret = new ReusltObject + { + Code = int.Parse(GaoTongResultStatus.Failure), + OperateTime = DateTime.Now.ToString("yyyy-MM-dd"), + Message = string.Join(",", errors.ToArray()), + Data = json + }; + } + + return ret; + } + + #endregion + #region Agv + + /// + /// 调用AGV + /// + /// + /// + /// + /// + 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}"); + } + } + + return false; + } + + /// + /// 判断是不是有Agv + /// + /// + /// + 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; @@ -1027,304 +1165,161 @@ public class InjectionIssueJobAppService #endregion - #region 立库 + #region 私有 /// - /// 调用立体库 + /// 创建补料记录实体 /// - /// + /// /// - private async Task DoingDimensionalStorehouseAsync(InjectionIssueJobDTO InjectionIssueJobDto) + private async Task BuildInjectionIssueNoteAsync(InjectionIssueJobDTO injectionIssueJobDto) { - var jobDetailInputdetail = InjectionIssueJobDto.Details.FirstOrDefault(); - var loctionDto = await _locationAppService.GetByCodeAsync(jobDetailInputdetail.RecommendFromLocationCode) - .ConfigureAwait(false); + var injectionIssueNoteCreateInput = + ObjectMapper.Map(injectionIssueJobDto); + injectionIssueNoteCreateInput.JobNumber = injectionIssueJobDto.Number; - if (loctionDto.Type == EnumLocationType.DimensionalStorehouse) - { - //TODO 立体库 - var ret = await SyncIssueJobStereoAsync(new List { InjectionIssueJobDto }, - jobDetailInputdetail.RecommendToLocationCode, InjectionIssueJobDto.Id).ConfigureAwait(false); - if (ret.Code != 0) - { - throw new UserFriendlyException($"调用立体库不成功!原因:{ret.Message}"); - } - } + await Task.CompletedTask.ConfigureAwait(false); + + return injectionIssueNoteCreateInput; } /// - /// 判断是不是在立体库 + /// 判断是不是在最底层 如果不是则把状态变更为待库移 并把库移推荐的From和To赋值 /// /// /// - private async Task UpdateJobStatusWaitByDimensionalStorehouseAsync(InjectionIssueJobEditInput input) + private async Task CheckMinRowAndSetStatusAsync(InjectionIssueJobEditInput input) { var jobDetailInputdetail = input.Details.FirstOrDefault(); var loctionDto = await _locationAppService.GetByCodeAsync(jobDetailInputdetail.RecommendFromLocationCode) .ConfigureAwait(false); - if (loctionDto.Type == EnumLocationType.DimensionalStorehouse) + if (loctionDto.Type == EnumLocationType.RAW && loctionDto.RowCode != 1) { input.JobStatus = EnumJobStatus.Wait; - return true; } - - return false; - } - - /// - /// 立体库同步 - /// - /// - /// - /// - [HttpPost("sync-issue-job-stereo")] - public async Task SyncIssueJobStereoAsync(List input, string pLoc, Guid uid) - { - var ret = new ReusltObject(); - ret.Code = 0; - ret.Message = "操作成功"; - ret.OperateTime = DateTime.Now.ToString("yyyy-MM-dd"); - using var unitOfWork = _unitOfWorkManager.Begin(); - try + else if (loctionDto.Type == EnumLocationType.RAW && loctionDto.RowCode == 1) { - var IssueJobToRestoDetailDTOs = new List(); - var main = new IssueJobToRestoDTO(); - main.Uuid = uid; - main.OperatorName = string.IsNullOrEmpty(CurrentUser.UserName) ? "admin" : CurrentUser.UserName; - foreach (var job in input) - { - foreach (var jobitem in job.Details) - { - IssueJobToRestoDetailDTOs.Add(new IssueJobToRestoDetailDTO - { - Count = jobitem.RecommendFromQty, - ProductNo = jobitem.ItemCode, - NeedSite = pLoc, - WorkNo = job.InjectionRequestNumber, - TaskNo = job.Number - }); - } - } - - main.Details = IssueJobToRestoDetailDTOs; - var httpclient = _httpClientFactory.CreateClient(); -#if DEBUG - - var json = JsonSerializer.Serialize(main); - _options.Value.Address = "http://localhost:59094/"; //测试地址 - _options.Value.Token = ""; //测试token - _options.Value.UserName = ""; //测试用户名 - _options.Value.Password = ""; //测试密码 - -#endif - - //var json = JsonSerializer.Serialize(main); - _options.Value.Address = string.IsNullOrEmpty(_options.Value.Address) - ? "http://7e42682n64.goho.co:21171/" - : _options.Value.Address; //测试地址 - _options.Value.Token = - string.IsNullOrEmpty(_options.Value.Token) ? string.Empty : _options.Value.Token; //测试token - _options.Value.UserName = - string.IsNullOrEmpty(_options.Value.UserName) ? "" : _options.Value.UserName; //测试用户名 - _options.Value.Password = - string.IsNullOrEmpty(_options.Value.Password) ? "" : _options.Value.Password; //测试密码 - _options.Value.Path = string.IsNullOrEmpty(_options.Value.Path) - ? "zozocnApi/custom/receiveProductionPlan" - : _options.Value.Path; //测试密码 - - _logger.LogInformation(JsonSerializer.Serialize(_options)); - - var flag = DateTime.Now.ToString("yyyyMMddHHmmss"); - _logger.LogInformation($"标志{flag}开始调用高通WMS:传递值{JsonSerializer.Serialize(main)}"); - + jobDetailInputdetail.TransferLibFromArriveDate = jobDetailInputdetail.RecommendFromArriveDate; + jobDetailInputdetail.TransferLibFromContainerCode = jobDetailInputdetail.RecommendFromContainerCode; + jobDetailInputdetail.TransferLibFromExpireDate = jobDetailInputdetail.RecommendFromExpireDate; + jobDetailInputdetail.TransferLibFromLocationArea = jobDetailInputdetail.RecommendFromLocationArea; + jobDetailInputdetail.TransferLibFromLocationCode = jobDetailInputdetail.RecommendFromLocationCode; + jobDetailInputdetail.TransferLibFromLocationErpCode = jobDetailInputdetail.RecommendFromLocationErpCode; + jobDetailInputdetail.TransferLibFromLocationGroup = jobDetailInputdetail.RecommendFromLocationGroup; + jobDetailInputdetail.TransferLibFromLot = jobDetailInputdetail.RecommendFromLot; + jobDetailInputdetail.TransferLibFromPackingCode = jobDetailInputdetail.RecommendFromPackingCode; + jobDetailInputdetail.TransferLibFromProduceDate = jobDetailInputdetail.RecommendFromProduceDate; + jobDetailInputdetail.TransferLibFromQty = jobDetailInputdetail.RecommendFromQty; + jobDetailInputdetail.TransferLibFromSupplierBatch = jobDetailInputdetail.RecommendFromSupplierBatch; + jobDetailInputdetail.TransferLibFromWarehouseCode = jobDetailInputdetail.RecommendFromWarehouseCode; - if (!string.IsNullOrEmpty(_options.Value.Token)) - { - var token = _options.Value.Token; - httpclient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); - } + jobDetailInputdetail.TransferLibToArriveDate = jobDetailInputdetail.RecommendToArriveDate; + jobDetailInputdetail.TransferLibToContainerCode = jobDetailInputdetail.RecommendToContainerCode; + jobDetailInputdetail.TransferLibToExpireDate = jobDetailInputdetail.RecommendToExpireDate; + jobDetailInputdetail.TransferLibToLot = jobDetailInputdetail.RecommendToLot; + jobDetailInputdetail.TransferLibToPackingCode = jobDetailInputdetail.RecommendToPackingCode; + jobDetailInputdetail.TransferLibToProduceDate = jobDetailInputdetail.RecommendToProduceDate; + jobDetailInputdetail.TransferLibToQty = jobDetailInputdetail.RecommendToQty; + jobDetailInputdetail.TransferLibToSupplierBatch = jobDetailInputdetail.RecommendToSupplierBatch; + jobDetailInputdetail.TransferLibToWarehouseCode = jobDetailInputdetail.TransferLibFromWarehouseCode; + jobDetailInputdetail.TransferLibToLocationArea = jobDetailInputdetail.TransferLibFromLocationArea; + jobDetailInputdetail.TransferLibToLocationCode = jobDetailInputdetail.TransferLibFromLocationCode; + jobDetailInputdetail.TransferLibToLocationErpCode = jobDetailInputdetail.TransferLibFromLocationErpCode; + jobDetailInputdetail.TransferLibToLocationGroup = jobDetailInputdetail.TransferLibFromLocationGroup; + } + } - if (!string.IsNullOrEmpty(_options.Value.UserName) && !string.IsNullOrEmpty(_options.Value.Password)) - { - var username = _options.Value.UserName; - var password = _options.Value.Password; - httpclient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", - Convert.ToBase64String(Encoding.ASCII.GetBytes($"{username}:{password}"))); - } + /// + /// 判断是不是在立体库 + /// + /// + /// + private async Task CheckDimensionalStorehouseAsync(InjectionIssueJobEditInput input) + { + var jobDetailInputdetail = input.Details.FirstOrDefault(); - var client = new IssueJobToRestoClient(_options.Value.Address, httpclient, _options.Value.Path); - ret = await client.SyncIssueJobStereoAsync(main).ConfigureAwait(false); + var loctionDto = await _locationAppService.GetByCodeAsync(jobDetailInputdetail.RecommendFromLocationCode) + .ConfigureAwait(false); - _logger.LogInformation($"标志{flag}调用高通WMS:返回值{JsonSerializer.Serialize(ret)}"); - } - catch (Exception ex) + if (loctionDto.Type == EnumLocationType.DimensionalStorehouse) { - ret = new ReusltObject(); - ret.Code = 1; - ret.Message = ex.Message; - ret.OperateTime = DateTime.Now.ToString("yyyy-MM-dd"); - await unitOfWork.RollbackAsync().ConfigureAwait(false); + input.JobStatus = EnumJobStatus.Wait; } - - return ret; } - [HttpPost("receive-issue-job-stereo")] - public virtual async Task SyncReciveIssueJobStereoAsync(IssueRequestFromRestoDTO input) + + /// + /// 修改当前任务状态 和 该任务的请求状态 + /// + /// + /// + /// + /// + /// + private async Task UpdateRequestAndjobStatusDoneAsync(InjectionIssueJob injectionIssueJob, + InjectionIssueJobDetailDTO injectionIssueJobDetailDto, decimal handledToQty) { - var json = JsonSerializer.Serialize(input); - var flag = DateTime.Now.ToString("yyyyMMddHHmmss"); - _logger.LogInformation($"{flag}接收到立体库确认单据内容:" + json); -#if DEBUG -#endif - var errors = new List(); - var ret = new ReusltObject - { - Code = int.Parse(GaoTongResultStatus.Success), - OperateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), - Message = "操作成功" - }; - using var unitOfWork = _unitOfWorkManager.Begin(); - try + if (injectionIssueJob.JobStatus is EnumJobStatus.Closed or EnumJobStatus.Cancelled or EnumJobStatus.None + or EnumJobStatus.Done) //需要考虑下 多次提交的问题 所以不判断 进行中 { - if (input.Jobs.Count > 0) - { - var jobs = input.Jobs; - var numbers = jobs.Select(p => p.JobNumber); - var query = _repository.WithDetails() - .Where(p => numbers.Contains(p.Number) && p.JobStatus != EnumJobStatus.Done); - - - var entities = query.ToList(); - if (entities.Count == 0) - { - errors.Add($"任务号{string.Join(",", numbers)}不存在!"); - } + throw new UserFriendlyException( + $"任务状态错误:编号为【{injectionIssueJob.Number}】的任务状态为【{injectionIssueJob.JobStatus.GetDisplayName()}】"); + } - var dtos = ObjectMapper.Map, List>(entities); + injectionIssueJob.JobStatus = EnumJobStatus.Done; + await RemoveExpectOutAsync(injectionIssueJob, injectionIssueJobDetailDto, handledToQty).ConfigureAwait(false); - if (input.Jobs.Count != entities.Count) - { - errors.Add("立体库提交出库任务和WMS任务不符,请核对! \n"); - } + //await _expectOutAppService.RemoveByNumberAsync(injectionIssueJob.Number).ConfigureAwait(false); - foreach (var itm in dtos) - { + await InjectionIssueRequestAppService.UpdateStatusCompletedAsync(injectionIssueJob.InjectionRequestNumber) + .ConfigureAwait(false); - var first = jobs.FirstOrDefault(p => p.JobNumber == itm.Number); - var itmDetails = itm.Details.ToList(); - var details = new List(); - foreach (var detail in first.Details) - { - var fromloc = await _locationAppService.GetByCodeAsync(detail.FromLocationCode) - .ConfigureAwait(false); - if (fromloc == null) - { - 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) - { - errors.Add($"物料号{detail.ItemCode}不在任务明细内!"); - } + await Task.CompletedTask.ConfigureAwait(false); + } - var dto = new InjectionIssueJobDetailDTO(); - dto.InjectFrom(entity); + /// + /// 判断实际TO的箱码是否被占用 + /// + /// + /// + /// + /// + private async Task CheckPackingCodeIsUserAsync(string packingCode, string jobNumber) + { + var list = await _expectOutAppService.GetListByPackingCodeAsync(packingCode).ConfigureAwait(false); + list = list.Where(p => p.JobNumber != jobNumber).ToList(); + if (list.Any()) + { + throw new UserFriendlyException($"任务号【{list.First().JobNumber}】的任务,已占用【{packingCode}】箱码的库存。"); + } + } - /* 客户说整单完成后才回传 - dto.RecommendFromQty = detail.Qty; - dto.RecommendToQty = detail.Qty; - dto.HandledFromQty = detail.Qty; - dto.HandledToQty = detail.Qty; - */ - //dto.RecommendFromQty = detail.Qty; - //dto.RecommendToQty = detail.Qty; - //dto.HandledFromQty = detail.Qty; - //dto.HandledToQty = detail.Qty; + private async Task RemoveExpectOutAsync(InjectionIssueJob injectionIssueJob, + InjectionIssueJobDetailDTO injectionIssueJobDetailDto, + decimal handledToQty) + { + await _expectOutAppService.RemoveByNumberAndInventoryAsync(injectionIssueJob.Number, + injectionIssueJobDetailDto.ItemCode, + injectionIssueJobDetailDto.HandledToLocationCode, injectionIssueJobDetailDto.HandledToPackingCode, + injectionIssueJobDetailDto.Status, injectionIssueJobDetailDto.HandledToLot, + handledToQty).ConfigureAwait(false); + } - dto.HandledToLocationCode = toloc.Code; - dto.HandledToLocationGroup = toloc.LocationGroupCode; - dto.HandledToLocationArea = toloc.AreaCode; - dto.HandledToLocationErpCode = toloc.ErpLocationCode; - dto.HandledToLot = string.Empty; - dto.HandledToWarehouseCode = toloc.WarehouseCode; - dto.HandledToQty = detail.Qty; - dto.HandledToLot = string.Empty; - dto.HandledToPackingCode = string.Empty; - dto.HandledFromWarehouseCode = fromloc.WarehouseCode; - dto.HandledFromLocationCode = fromloc.Code; - dto.HandledFromLocationGroup = fromloc.LocationGroupCode; - dto.HandledFromLocationArea = fromloc.AreaCode; - dto.HandledFromLocationErpCode = fromloc.ErpLocationCode; - dto.HandledFromQty = detail.Qty; - dto.HandledFromLot = string.Empty; - dto.HandledFromPackingCode = string.Empty; - details.Add(dto); - await ExecuteDetailExtAsync(itm.Id, entity.Id, dto).ConfigureAwait(false); - } - if (errors.Count > 0) - { - ret = new ReusltObject - { - Code = int.Parse(GaoTongResultStatus.Failure), - OperateTime = DateTime.Now.ToString("yyyy-MM-dd"), - Message = string.Join(",", errors.ToArray()), - Data = json - }; - } - itm.Worker = "LITK"; - itm.Details = details; - // await CompleteAsync(itm.Id, itm).ConfigureAwait(false); - _logger.LogInformation($"{flag}接收到立体库确认单据内容:" + json + "立体库任务完成"); - } - } - else - { - errors.Add("立体库确认单据里无数据! \n"); - } - } - catch (Exception ex) - { - ret = new ReusltObject - { - Code = int.Parse(GaoTongResultStatus.Failure), - OperateTime = DateTime.Now.ToString("yyyy-MM-dd"), - Message = ex.Message, - Data = json - }; - await unitOfWork.RollbackAsync(); - return ret; - } - if (errors.Count > 0) - { - ret = new ReusltObject - { - Code = int.Parse(GaoTongResultStatus.Failure), - OperateTime = DateTime.Now.ToString("yyyy-MM-dd"), - Message = string.Join(",", errors.ToArray()), - Data = json - }; - } - return ret; - } #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 ae7b93b9a..eca6f8c8e 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 @@ -356,17 +356,11 @@ public class KittingIssueJobAppService { var kittingIssueJob = await _repository.GetAsync(masterId).ConfigureAwait(false); kittingIssueJob.JobStatus = EnumJobStatus.Doing; - if (kittingIssueJob.IsClaims) - { - if (kittingIssueJob.ClaimsUserId != _currentUser.Id.ToString()) - { - throw new UserFriendlyException($"该任务已被【{kittingIssueJob.ClaimsUserName}】承接"); - } - } - else - { - throw new UserFriendlyException("该任务未被承接,请重新刷新页面,承接任务"); - } + kittingIssueJob.ClaimsUserId = + string.IsNullOrEmpty(_options.Value.StereosUser) ? "LYF" : _options.Value.StereosUser; + kittingIssueJob.ClaimsUserName = string.IsNullOrEmpty(_options.Value.StereosPassword) + ? "LYF" + : _options.Value.StereosPassword; var kittingIssueJobDto = ObjectMapper.Map(kittingIssueJob); kittingIssueJobDto.Details = new List { issueJobDetailDto }; @@ -502,163 +496,6 @@ public class KittingIssueJobAppService var dto = ObjectMapper.Map(list.First()); return dto; } - - - - #region 私有 - - /// - /// 创建补料记录实体 - /// - /// - /// - private async Task BuildKittingIssueNoteAsync(KittingIssueJobDTO kittingIssueJobDto) - { - var kittingIssueNoteCreateInput = - ObjectMapper.Map(kittingIssueJobDto); - kittingIssueNoteCreateInput.JobNumber = kittingIssueJobDto.Number; - - await Task.CompletedTask.ConfigureAwait(false); - - return kittingIssueNoteCreateInput; - } - - /// - /// 判断是不是在最底层 如果不是则把状态变更为待库移 并把库移推荐的From和To赋值 - /// - /// - /// - private async Task CheckMinRowAndSetStatusAsync(KittingIssueJobEditInput input) - { - var jobDetailInputdetail = input.Details.FirstOrDefault(); - - var loctionDto = await _locationAppService.GetByCodeAsync(jobDetailInputdetail.RecommendFromLocationCode) - .ConfigureAwait(false); - - if (loctionDto.Type == EnumLocationType.RAW && loctionDto.RowCode != 1) - { - input.JobStatus = EnumJobStatus.Wait; - } - else if (loctionDto.Type == EnumLocationType.RAW && loctionDto.RowCode == 1) - { - jobDetailInputdetail.TransferLibFromArriveDate = jobDetailInputdetail.RecommendFromArriveDate; - jobDetailInputdetail.TransferLibFromContainerCode = jobDetailInputdetail.RecommendFromContainerCode; - jobDetailInputdetail.TransferLibFromExpireDate = jobDetailInputdetail.RecommendFromExpireDate; - jobDetailInputdetail.TransferLibFromLocationArea = jobDetailInputdetail.RecommendFromLocationArea; - jobDetailInputdetail.TransferLibFromLocationCode = jobDetailInputdetail.RecommendFromLocationCode; - jobDetailInputdetail.TransferLibFromLocationErpCode = jobDetailInputdetail.RecommendFromLocationErpCode; - jobDetailInputdetail.TransferLibFromLocationGroup = jobDetailInputdetail.RecommendFromLocationGroup; - jobDetailInputdetail.TransferLibFromLot = jobDetailInputdetail.RecommendFromLot; - jobDetailInputdetail.TransferLibFromPackingCode = jobDetailInputdetail.RecommendFromPackingCode; - jobDetailInputdetail.TransferLibFromProduceDate = jobDetailInputdetail.RecommendFromProduceDate; - jobDetailInputdetail.TransferLibFromQty = jobDetailInputdetail.RecommendFromQty; - jobDetailInputdetail.TransferLibFromSupplierBatch = jobDetailInputdetail.RecommendFromSupplierBatch; - jobDetailInputdetail.TransferLibFromWarehouseCode = jobDetailInputdetail.RecommendFromWarehouseCode; - - jobDetailInputdetail.TransferLibToArriveDate = jobDetailInputdetail.RecommendToArriveDate; - jobDetailInputdetail.TransferLibToContainerCode = jobDetailInputdetail.RecommendToContainerCode; - jobDetailInputdetail.TransferLibToExpireDate = jobDetailInputdetail.RecommendToExpireDate; - jobDetailInputdetail.TransferLibToLot = jobDetailInputdetail.RecommendToLot; - jobDetailInputdetail.TransferLibToPackingCode = jobDetailInputdetail.RecommendToPackingCode; - jobDetailInputdetail.TransferLibToProduceDate = jobDetailInputdetail.RecommendToProduceDate; - jobDetailInputdetail.TransferLibToQty = jobDetailInputdetail.RecommendToQty; - jobDetailInputdetail.TransferLibToSupplierBatch = jobDetailInputdetail.RecommendToSupplierBatch; - jobDetailInputdetail.TransferLibToWarehouseCode = jobDetailInputdetail.TransferLibFromWarehouseCode; - jobDetailInputdetail.TransferLibToLocationArea = jobDetailInputdetail.TransferLibFromLocationArea; - jobDetailInputdetail.TransferLibToLocationCode = jobDetailInputdetail.TransferLibFromLocationCode; - jobDetailInputdetail.TransferLibToLocationErpCode = jobDetailInputdetail.TransferLibFromLocationErpCode; - jobDetailInputdetail.TransferLibToLocationGroup = jobDetailInputdetail.TransferLibFromLocationGroup; - } - } - - /// - /// 判断是不是在立体库 - /// - /// - /// - private async Task CheckDimensionalStorehouseAsync(KittingIssueJobEditInput input) - { - var jobDetailInputdetail = input.Details.FirstOrDefault(); - - var loctionDto = await _locationAppService.GetByCodeAsync(jobDetailInputdetail.RecommendFromLocationCode) - .ConfigureAwait(false); - - if (loctionDto.Type == EnumLocationType.DimensionalStorehouse) - { - input.JobStatus = EnumJobStatus.Wait; - return true; - } - else - { - return false; - } - } - - - - /// - /// 修改当前任务状态 和 该任务的请求状态 - /// - /// - /// - /// - /// - /// - private async Task UpdateRequestAndjobStatusDoneAsync(KittingIssueJob kittingIssueJob, - KittingIssueJobDetailDTO kittingIssueJobDetailDto, decimal handledToQty) - { - if (kittingIssueJob.JobStatus is EnumJobStatus.Closed or EnumJobStatus.Cancelled or EnumJobStatus.None - or EnumJobStatus.Done) //需要考虑下 多次提交的问题 所以不判断 进行中 - { - throw new UserFriendlyException( - $"任务状态错误:编号为【{kittingIssueJob.Number}】的任务状态为【{kittingIssueJob.JobStatus.GetDisplayName()}】"); - } - - kittingIssueJob.JobStatus = EnumJobStatus.Done; - - await RemoveExpectOutAsync(kittingIssueJob, kittingIssueJobDetailDto, handledToQty).ConfigureAwait(false); - - //await _expectOutAppService.RemoveByNumberAsync(kittingIssueJob.Number).ConfigureAwait(false); - - await KittingIssueRequestAppService.UpdateStatusCompletedAsync(kittingIssueJob.KittingRequestNumber,kittingIssueJob.Number) - .ConfigureAwait(false); - - await Task.CompletedTask.ConfigureAwait(false); - } - - /// - /// 判断实际TO的箱码是否被占用 - /// - /// - /// - /// - /// - private async Task CheckPackingCodeIsUserAsync(string packingCode,string jobNumber) - { - var list = await _expectOutAppService.GetListByPackingCodeAsync(packingCode).ConfigureAwait(false); - list=list.Where(p => p.JobNumber != jobNumber).ToList(); - if (list.Any()) - { - throw new UserFriendlyException($"任务号【{list.First().JobNumber}】的任务,已占用【{packingCode}】箱码的库存。"); - } - } - - private async Task RemoveExpectOutAsync(KittingIssueJob kittingIssueJob, - KittingIssueJobDetailDTO kittingIssueJobDetailDto, - decimal handledToQty) - { - await _expectOutAppService.RemoveByNumberAndInventoryAsync(kittingIssueJob.Number, - kittingIssueJobDetailDto.ItemCode, - kittingIssueJobDetailDto.HandledToLocationCode, kittingIssueJobDetailDto.HandledToPackingCode, - kittingIssueJobDetailDto.Status, kittingIssueJobDetailDto.HandledToLot, - handledToQty).ConfigureAwait(false); - } - - - - - #endregion - #region 立库 /// @@ -1342,4 +1179,161 @@ public class KittingIssueJobAppService } #endregion + + + #region 私有 + + /// + /// 创建补料记录实体 + /// + /// + /// + private async Task BuildKittingIssueNoteAsync(KittingIssueJobDTO kittingIssueJobDto) + { + var kittingIssueNoteCreateInput = + ObjectMapper.Map(kittingIssueJobDto); + kittingIssueNoteCreateInput.JobNumber = kittingIssueJobDto.Number; + + await Task.CompletedTask.ConfigureAwait(false); + + return kittingIssueNoteCreateInput; + } + + /// + /// 判断是不是在最底层 如果不是则把状态变更为待库移 并把库移推荐的From和To赋值 + /// + /// + /// + private async Task CheckMinRowAndSetStatusAsync(KittingIssueJobEditInput input) + { + var jobDetailInputdetail = input.Details.FirstOrDefault(); + + var loctionDto = await _locationAppService.GetByCodeAsync(jobDetailInputdetail.RecommendFromLocationCode) + .ConfigureAwait(false); + + if (loctionDto.Type == EnumLocationType.RAW && loctionDto.RowCode != 1) + { + input.JobStatus = EnumJobStatus.Wait; + } + else if (loctionDto.Type == EnumLocationType.RAW && loctionDto.RowCode == 1) + { + jobDetailInputdetail.TransferLibFromArriveDate = jobDetailInputdetail.RecommendFromArriveDate; + jobDetailInputdetail.TransferLibFromContainerCode = jobDetailInputdetail.RecommendFromContainerCode; + jobDetailInputdetail.TransferLibFromExpireDate = jobDetailInputdetail.RecommendFromExpireDate; + jobDetailInputdetail.TransferLibFromLocationArea = jobDetailInputdetail.RecommendFromLocationArea; + jobDetailInputdetail.TransferLibFromLocationCode = jobDetailInputdetail.RecommendFromLocationCode; + jobDetailInputdetail.TransferLibFromLocationErpCode = jobDetailInputdetail.RecommendFromLocationErpCode; + jobDetailInputdetail.TransferLibFromLocationGroup = jobDetailInputdetail.RecommendFromLocationGroup; + jobDetailInputdetail.TransferLibFromLot = jobDetailInputdetail.RecommendFromLot; + jobDetailInputdetail.TransferLibFromPackingCode = jobDetailInputdetail.RecommendFromPackingCode; + jobDetailInputdetail.TransferLibFromProduceDate = jobDetailInputdetail.RecommendFromProduceDate; + jobDetailInputdetail.TransferLibFromQty = jobDetailInputdetail.RecommendFromQty; + jobDetailInputdetail.TransferLibFromSupplierBatch = jobDetailInputdetail.RecommendFromSupplierBatch; + jobDetailInputdetail.TransferLibFromWarehouseCode = jobDetailInputdetail.RecommendFromWarehouseCode; + + jobDetailInputdetail.TransferLibToArriveDate = jobDetailInputdetail.RecommendToArriveDate; + jobDetailInputdetail.TransferLibToContainerCode = jobDetailInputdetail.RecommendToContainerCode; + jobDetailInputdetail.TransferLibToExpireDate = jobDetailInputdetail.RecommendToExpireDate; + jobDetailInputdetail.TransferLibToLot = jobDetailInputdetail.RecommendToLot; + jobDetailInputdetail.TransferLibToPackingCode = jobDetailInputdetail.RecommendToPackingCode; + jobDetailInputdetail.TransferLibToProduceDate = jobDetailInputdetail.RecommendToProduceDate; + jobDetailInputdetail.TransferLibToQty = jobDetailInputdetail.RecommendToQty; + jobDetailInputdetail.TransferLibToSupplierBatch = jobDetailInputdetail.RecommendToSupplierBatch; + jobDetailInputdetail.TransferLibToWarehouseCode = jobDetailInputdetail.TransferLibFromWarehouseCode; + jobDetailInputdetail.TransferLibToLocationArea = jobDetailInputdetail.TransferLibFromLocationArea; + jobDetailInputdetail.TransferLibToLocationCode = jobDetailInputdetail.TransferLibFromLocationCode; + jobDetailInputdetail.TransferLibToLocationErpCode = jobDetailInputdetail.TransferLibFromLocationErpCode; + jobDetailInputdetail.TransferLibToLocationGroup = jobDetailInputdetail.TransferLibFromLocationGroup; + } + } + + /// + /// 判断是不是在立体库 + /// + /// + /// + private async Task CheckDimensionalStorehouseAsync(KittingIssueJobEditInput input) + { + var jobDetailInputdetail = input.Details.FirstOrDefault(); + + var loctionDto = await _locationAppService.GetByCodeAsync(jobDetailInputdetail.RecommendFromLocationCode) + .ConfigureAwait(false); + + if (loctionDto.Type == EnumLocationType.DimensionalStorehouse) + { + input.JobStatus = EnumJobStatus.Wait; + return true; + } + else + { + return false; + } + } + + + + /// + /// 修改当前任务状态 和 该任务的请求状态 + /// + /// + /// + /// + /// + /// + private async Task UpdateRequestAndjobStatusDoneAsync(KittingIssueJob kittingIssueJob, + KittingIssueJobDetailDTO kittingIssueJobDetailDto, decimal handledToQty) + { + if (kittingIssueJob.JobStatus is EnumJobStatus.Closed or EnumJobStatus.Cancelled or EnumJobStatus.None + or EnumJobStatus.Done) //需要考虑下 多次提交的问题 所以不判断 进行中 + { + throw new UserFriendlyException( + $"任务状态错误:编号为【{kittingIssueJob.Number}】的任务状态为【{kittingIssueJob.JobStatus.GetDisplayName()}】"); + } + + kittingIssueJob.JobStatus = EnumJobStatus.Done; + + await RemoveExpectOutAsync(kittingIssueJob, kittingIssueJobDetailDto, handledToQty).ConfigureAwait(false); + + //await _expectOutAppService.RemoveByNumberAsync(kittingIssueJob.Number).ConfigureAwait(false); + + await KittingIssueRequestAppService.UpdateStatusCompletedAsync(kittingIssueJob.KittingRequestNumber,kittingIssueJob.Number) + .ConfigureAwait(false); + + await Task.CompletedTask.ConfigureAwait(false); + } + + /// + /// 判断实际TO的箱码是否被占用 + /// + /// + /// + /// + /// + private async Task CheckPackingCodeIsUserAsync(string packingCode,string jobNumber) + { + var list = await _expectOutAppService.GetListByPackingCodeAsync(packingCode).ConfigureAwait(false); + list=list.Where(p => p.JobNumber != jobNumber).ToList(); + if (list.Any()) + { + throw new UserFriendlyException($"任务号【{list.First().JobNumber}】的任务,已占用【{packingCode}】箱码的库存。"); + } + } + + private async Task RemoveExpectOutAsync(KittingIssueJob kittingIssueJob, + KittingIssueJobDetailDTO kittingIssueJobDetailDto, + decimal handledToQty) + { + await _expectOutAppService.RemoveByNumberAndInventoryAsync(kittingIssueJob.Number, + kittingIssueJobDetailDto.ItemCode, + kittingIssueJobDetailDto.HandledToLocationCode, kittingIssueJobDetailDto.HandledToPackingCode, + kittingIssueJobDetailDto.Status, kittingIssueJobDetailDto.HandledToLot, + handledToQty).ConfigureAwait(false); + } + + + + + #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 5bf972c82..f855361d9 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 @@ -353,17 +353,27 @@ public class SparePartIssueJobAppService { var sparePartIssueJob = await _repository.GetAsync(masterId).ConfigureAwait(false); sparePartIssueJob.JobStatus = EnumJobStatus.Doing; - if (sparePartIssueJob.IsClaims) - { - if (sparePartIssueJob.ClaimsUserId != _currentUser.Id.ToString()) - { - throw new UserFriendlyException($"该任务已被【{sparePartIssueJob.ClaimsUserName}】承接"); - } - } - else - { - throw new UserFriendlyException("该任务未被承接,请重新刷新页面,承接任务"); - } + sparePartIssueJob.ClaimsUserId = + string.IsNullOrEmpty(_options.Value.StereosUser) ? "LYF" : _options.Value.StereosUser; + + sparePartIssueJob.ClaimsUserName = string.IsNullOrEmpty(_options.Value.StereosPassword) + ? "LYF" + : _options.Value.StereosPassword; + + + + + //if (sparePartIssueJob.IsClaims) + //{ + // if (sparePartIssueJob.ClaimsUserId != _currentUser.Id.ToString()) + // { + // throw new UserFriendlyException($"该任务已被【{sparePartIssueJob.ClaimsUserName}】承接"); + // } + //} + //else + //{ + // throw new UserFriendlyException("该任务未被承接,请重新刷新页面,承接任务"); + //} var sparePartIssueJobDto = ObjectMapper.Map(sparePartIssueJob); sparePartIssueJobDto.Details = new List { issueJobDetailDto }; @@ -493,13 +503,10 @@ public class SparePartIssueJobAppService { throw new UserFriendlyException("未找到该箱码的任务"); } - var dto = ObjectMapper.Map(list.First()); return dto; } - - #region 立库 /// @@ -798,7 +805,6 @@ public class SparePartIssueJobAppService } #endregion - #region Agv /// @@ -808,9 +814,9 @@ public class SparePartIssueJobAppService /// /// /// - private async Task DoingAgvAsync(SparePartIssueJobDTO SparePartIssueJobDto, string fromLocationCode, string toLocationCode) + private async Task DoingAgvAsync(SparePartIssueJobDTO sparePartIssueJobDto, string fromLocationCode, string toLocationCode) { - var jobDetailInputdetail = SparePartIssueJobDto.Details.FirstOrDefault(); + var jobDetailInputdetail = sparePartIssueJobDto.Details.FirstOrDefault(); var locationDeliveryDto = await _locationDeliveryAppService.GetByFromLocationCodeAndToLocationCodeAsync( fromLocationCode, toLocationCode).ConfigureAwait(false); @@ -818,7 +824,7 @@ public class SparePartIssueJobAppService { //TODO AGV //来源永远是库位 目标永远是工位 - var ret = await CallAgvAsync(SparePartIssueJobDto, fromLocationCode, jobDetailInputdetail.Remark).ConfigureAwait(false); + var ret = await CallAgvAsync(sparePartIssueJobDto, fromLocationCode, jobDetailInputdetail.Remark).ConfigureAwait(false); #if DEBUG @@ -1184,8 +1190,6 @@ public class SparePartIssueJobAppService } #endregion - - #region 私有 /// 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 eed580955..e550968d7 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 @@ -418,8 +418,8 @@ public class UnplannedReceiptJobAppService return new AgvResultObject() { - Code = "", - Message = "", + Code = "0", + Message = "OK", ReqCode = "" }; }