| | |
| | | using CMS.Plugin.TraceManagement.Abstractions; |
| | | using CMS.Plugin.ProductManagement.Abstractions.Models; |
| | | using CMS.Plugin.MaterialManagement.Abstractions; |
| | | using CMS.Plugin.HIAWms.Application.Contracts.Services; |
| | | using CMS.Plugin.HIAWms.Application.Contracts.Dtos.CommonDto; |
| | | using System.Collections.Generic; |
| | | using CMS.Plugin.HIAWms.Abstractions; |
| | | using Newtonsoft.Json; |
| | | using CmsQueryExtensions; |
| | | |
| | | namespace CMS.Plugin.PipeLineLems.Application.Implements; |
| | | |
| | |
| | | /// <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($"找不到叫料记录"); |
| | |
| | | // 验证状态 |
| | | if (callMaterialOrder.CallMaterialStatus != Domain.Shared.Enums.CallMaterialStatusEnum.未执行) |
| | | { |
| | | throw new UserFriendlyException($"原料标识为 '{callMaterialOrder.DataIdentifier}' 的叫料记录状态为 '{callMaterialOrder.CallMaterialStatus}',不允许叫料"); |
| | | //throw new UserFriendlyException($"原料标识为 '{callMaterialOrder.DataIdentifier}' 的叫料记录状态为 '{callMaterialOrder.CallMaterialStatus}',不允许叫料"); |
| | | } |
| | | |
| | | //TODO:这里调用wms的叫料接口 |
| | | try |
| | | { |
| | | List<LMesCallMaterialInput> param = new List<LMesCallMaterialInput>() { |
| | | new LMesCallMaterialInput(){ |
| | | DataIdentifier=callMaterialOrder.DataIdentifier, |
| | | MaterialMode="Q235B-Φ89×4", |
| | | } |
| | | }; |
| | | string baseUrl = @"http://127.0.0.1:18000/api/v1/HIAWms/"; |
| | | string url = baseUrl + "lMesOperate/LMesCallMaterial"; |
| | | string json = JsonConvert.SerializeObject(param); |
| | | var result = HttpApiRequest.HttpPost(url, json); |
| | | var res = JsonConvert.DeserializeObject<CmsApiResponse<List<MyCallMaterialOutput>>>(result); |
| | | if (res.Code == 200) |
| | | { |
| | | var retData = res.Data; |
| | | callMaterialOrder.MaterialBatch = retData[0].MaterialBatch; |
| | | } |
| | | else { |
| | | throw new UserFriendlyException(res.Message); |
| | | } |
| | | } |
| | | catch (Exception) |
| | | { |
| | | |
| | | throw; |
| | | } |
| | | |
| | | |
| | | // 更新数据 |
| | | callMaterialOrder.MaterialBatch = GenerateRandomBatch();//wms返回的原料批次 |