| | |
| | | /// <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}"; |
| | | } |
| | | } |