| | |
| | | using Microsoft.AspNetCore.Http.HttpResults; |
| | | using Newtonsoft.Json; |
| | | using System.Diagnostics; |
| | | using WIDESEA_Common.Constants; |
| | | using WIDESEA_Common.LocationEnum; |
| | | using WIDESEA_Common.StockEnum; |
| | |
| | | /// </summary> |
| | | public async Task<WebResponseContent> InboundFinishTaskAsync(CreateTaskDto taskDto) |
| | | { |
| | | var stopwatch = Stopwatch.StartNew(); |
| | | try |
| | | { |
| | | var task = await BaseDal.QueryFirstAsync(s => s.PalletCode == taskDto.PalletCode); |
| | |
| | | } |
| | | else |
| | | { |
| | | |
| | | |
| | | // 判断是不是极卷库任务 |
| | | if (taskDto.WarehouseId == (int)WarehouseEnum.FJ1 || taskDto.WarehouseId == (int)WarehouseEnum.ZJ1) |
| | | { |
| | |
| | | return WebResponseContent.Instance.Error("任务完成失败"); |
| | | |
| | | // 根据库存Remark选择静置设备,查MES动态凭证 |
| | | //string deviceName = stockInfo.Remark == "GW_1" ? "高温静置1" |
| | | // : stockInfo.Remark == "GW_2" ? "高温静置2" |
| | | // : "常温静置1"; |
| | | //var mesConfig = _mesDeviceConfigService.GetByDeviceName(deviceName); |
| | | //string equipmentCode = mesConfig?.EquipmentCode ?? StockConstants.MES_EQUIPMENT_CODE; |
| | | //string resourceCode = mesConfig?.ResourceCode ?? StockConstants.MES_RESOURCE_CODE; |
| | | //string token = mesConfig?.Token; |
| | | string deviceName = stockInfo.Remark == "GW_1" ? "高温静置1" |
| | | : stockInfo.Remark == "GW_2" ? "高温静置2" |
| | | : "常温静置1"; |
| | | var mesConfig = _mesDeviceConfigService.GetByDeviceName(deviceName); |
| | | string equipmentCode = mesConfig?.EquipmentCode ?? StockConstants.MES_EQUIPMENT_CODE; |
| | | string resourceCode = mesConfig?.ResourceCode ?? StockConstants.MES_RESOURCE_CODE; |
| | | string token = mesConfig?.Token; |
| | | |
| | | // 调用MES托盘进站 |
| | | //var inboundRequest = new InboundInContainerRequest |
| | | //{ |
| | | // EquipmentCode = equipmentCode, |
| | | // ResourceCode = resourceCode, |
| | | // LocalTime = DateTime.Now, |
| | | // ContainerCode = taskDto.PalletCode |
| | | //}; |
| | | //string requestJson = inboundRequest.ToJson(); |
| | | //var inboundResult = string.IsNullOrWhiteSpace(token) |
| | | // ? _mesService.InboundInContainer(inboundRequest) |
| | | // : _mesService.InboundInContainer(inboundRequest, token); |
| | | //stopwatch.Stop(); |
| | | //await _mesLogService.LogAsync(new MesApiLogDto |
| | | //{ |
| | | // ApiType = "InboundInContainer", |
| | | // RequestJson = requestJson, |
| | | // ResponseJson = JsonConvert.SerializeObject(inboundResult), |
| | | // IsSuccess = inboundResult.IsSuccess, |
| | | // ErrorMessage = inboundResult.ErrorMessage, |
| | | // ElapsedMs = (int)stopwatch.ElapsedMilliseconds, |
| | | // Creator = "systeam" |
| | | //}); |
| | | //if (inboundResult == null || inboundResult.Data == null || !inboundResult.Data.IsSuccess) |
| | | //{ |
| | | // return content.Error($"任务完成失败:MES进站失败: {inboundResult?.Data?.Msg ?? inboundResult?.ErrorMessage ?? "未知错误"}"); |
| | | //} |
| | | // 异步调用MES托盘进站,不阻塞主逻辑 |
| | | var inboundRequest = new InboundInContainerRequest |
| | | { |
| | | EquipmentCode = equipmentCode, |
| | | ResourceCode = resourceCode, |
| | | LocalTime = DateTime.Now, |
| | | ContainerCode = taskDto.PalletCode |
| | | }; |
| | | string requestJson = inboundRequest.ToJson(); |
| | | var palletCode = taskDto.PalletCode; |
| | | |
| | | _mesUploadHelper.FireAndForget( |
| | | palletCode, |
| | | MesUploadStatusEnum.进站上传成功, |
| | | "InboundInContainer", |
| | | requestJson, |
| | | () => |
| | | { |
| | | var result = string.IsNullOrWhiteSpace(token) |
| | | ? _mesService.InboundInContainer(inboundRequest) |
| | | : _mesService.InboundInContainer(inboundRequest, token); |
| | | return ( |
| | | result?.Data?.IsSuccess ?? false, |
| | | JsonConvert.SerializeObject(result), |
| | | result?.Data?.Msg ?? result?.ErrorMessage ?? "未知错误" |
| | | ); |
| | | }); |
| | | |
| | | return await CompleteTaskAsync(task, "入库完成"); |
| | | }); |
| | | } |