| | |
| | | var firstWorkPlans = await workPlanAppService.GetListByFilterAsync(x => x.PipeSpecCode == input.PipeSpecCode); |
| | | |
| | | var firstWorkPlan = await workPlanAppService.GetSingleByFilterAsync(x => x.PipeSpecCode == input.PipeSpecCode); |
| | | var rawPipe_DataIdentifier = await materialProvider.FindByNameAsync("分拣原料管标识"); |
| | | var rawPipe_MaterialMode = await materialProvider.FindByNameAsync("分拣原料管型号"); |
| | | var rawPipe_DataIdentifier = await materialProvider.FindByNameAsync("原料管标识"); |
| | | var rawPipe_MaterialMode = await materialProvider.FindByNameAsync("原料管型号"); |
| | | var rawPipe_Batch = await materialProvider.FindByNameAsync("原料管批次"); |
| | | List<TraceMaterialModel> _MaterialParams = new List<TraceMaterialModel>(); |
| | | foreach (var item in workSection.MaterialParameters) |
| | | { |
| | | if (item.Name == "分拣原料管型号") |
| | | if (item.Name == "原料管型号") |
| | | { |
| | | _MaterialParams.Add(new TraceMaterialModel() |
| | | { |
| | |
| | | |
| | | }); |
| | | } |
| | | if (item.Name == "分拣原料管标识") |
| | | if (item.Name == "原料管标识") |
| | | { |
| | | _MaterialParams.Add(new TraceMaterialModel() |
| | | { |
| | |
| | | MaterialId = rawPipe_DataIdentifier.MaterialId, |
| | | MaterialDetailId = rawPipe_DataIdentifier.MaterialDetails.First().Id, |
| | | Value = firstWorkPlan.DataIdentifier, |
| | | |
| | | }); |
| | | } |
| | | if (item.Name == "原料管批次") |
| | | { |
| | | _MaterialParams.Add(new TraceMaterialModel() |
| | | { |
| | | Key = item.Key, |
| | | Quantity = 1, |
| | | MaterialId = rawPipe_Batch.MaterialId, |
| | | MaterialDetailId = rawPipe_Batch.MaterialDetails.First().Id, |
| | | Value = "111",//批次暂时写死 |
| | | |
| | | }); |
| | | } |
| | |
| | | /// <param name="_serviceProvider">服务提供者</param> |
| | | /// <returns>操作结果</returns> |
| | | /// <exception cref="UserFriendlyException">当数据不存在或状态不允许叫料时抛出</exception> |
| | | public async Task<MesOrderResponse> CallMaterialByDataIdentifier(Guid id, IServiceProvider _serviceProvider) |
| | | public async Task<MesOrderResponse> CallMaterial(CallMaterialByDataIdentifierInput input, IServiceProvider _serviceProvider, MyCurrentUser myCurrentUser) |
| | | { |
| | | if (string.IsNullOrEmpty(id.ToString())) |
| | | if (string.IsNullOrEmpty(input.Id.ToString())) |
| | | { |
| | | throw new UserFriendlyException("原料标识不能为空"); |
| | | } |
| | |
| | | |
| | | // 查找数据 |
| | | |
| | | var callMaterialOrder = await callMaterialOrderRepository.GetAsync(id); |
| | | var callMaterialOrder = await callMaterialOrderRepository.GetAsync(input.Id); |
| | | if (callMaterialOrder == null) |
| | | { |
| | | throw new UserFriendlyException($"找不到叫料记录"); |
| | |
| | | throw new UserFriendlyException($"原料标识为 '{callMaterialOrder.DataIdentifier}' 的叫料记录状态为 '{callMaterialOrder.CallMaterialStatus}',不允许叫料"); |
| | | } |
| | | |
| | | //TODO:这里调用wms的叫料接口 |
| | | |
| | | // 更新数据 |
| | | callMaterialOrder.MaterialBatch = GenerateRandomBatch();//wms返回的原料批次 |
| | | callMaterialOrder.WmsRetResult = "成功"; |
| | | callMaterialOrder.WmsTaskNo = GenerateRandomTaskNo(); |
| | | callMaterialOrder.CallMaterialStatus = Domain.Shared.Enums.CallMaterialStatusEnum.叫料完成; |
| | |
| | | await callMaterialOrderRepository.UpdateAsync(callMaterialOrder); |
| | | |
| | | //更新作业计划表 |
| | | var workPlanList = await workPlanRepository.FindByDataIdentifierAsync(callMaterialOrder.DataIdentifier); |
| | | var workPlanList = await workPlanRepository.GetListByFilterAsync(x => x.DataIdentifier == callMaterialOrder.DataIdentifier); |
| | | foreach (var item in workPlanList) |
| | | { |
| | | item.CallMaterialStatus = Domain.Shared.Enums.CallMaterialStatusEnum.叫料完成; |
| | |
| | | var callMaterialOrderRecord = new CallMaterialOrderRecord() |
| | | { |
| | | CallMaterialStatus = Domain.Shared.Enums.CallMaterialStatusEnum.叫料完成, |
| | | MaterialBatch = callMaterialOrder.MaterialBatch, |
| | | MaterialMode = callMaterialOrder.MaterialMode, |
| | | DataIdentifier = callMaterialOrder.DataIdentifier, |
| | | Quantity = 1, |
| | |
| | | // 生成前缀 |
| | | return $"WMS{timestamp}"; |
| | | } |
| | | |
| | | private string GenerateRandomBatch() |
| | | { |
| | | // 获取当前时间戳(从1970-01-01 00:00:00 UTC到现在的秒数) |
| | | long timestamp = new DateTimeOffset(DateTime.UtcNow).ToUnixTimeSeconds(); |
| | | |
| | | // 生成前缀 |
| | | return $"Batch{timestamp}"; |
| | | } |
| | | } |