public async Task <RouteData <OutsideStockOutRequestResult[]> > StockOut(OutsideStockOutRequestDto request) { _logger.Info($"[下发出库任务]开始下发,param={JsonConvert.SerializeObject(request)}"); RouteData <OutsideStockOutRequestResult[]> result = await _apiProxy.StockOut(request); _logger.Info($"[下发出库任务]收到下发结果,result={JsonConvert.SerializeObject(result)}"); if (!result.IsSccuess) { _logger.Error($"[下发出库任务]判定下发失败"); return(result); } if (result.Data.Length != 1) { _logger.Error($"[下发出库任务]E-2122-下发出库任务返回值不合法"); return(RouteData <OutsideStockOutRequestResult[]> .From(PubMessages.E2122_WMS_STOCKOUT_RESPONSE_INVAILD)); } request.StockOutId = result.Data[0].StockOutId; request.StockOutNo = result.Data[0].StockOutNo; _logger.Info($"[下发出库任务]下发任务回馈StockOutId={request.StockOutId},StockOutNo={request.StockOutNo}"); await _selfAccessor.StockOut(request); return(result); }
private RouteData CreateWMSStockout(Wms_mestask mesTask, OutsideWarehouseEntryMaterialDto[] suppliesInfoList) { Dictionary <long, List <Wms_WarehouseEntryMaterialInventoryDto> > map = new Dictionary <long, List <Wms_WarehouseEntryMaterialInventoryDto> >(); foreach (OutsideWarehouseEntryMaterialDto materialDto in suppliesInfoList) { //Sys_dict typeDict = _sqlClient.Queryable<Sys_dict>() // .First(x => x.DictType == PubDictType.material.ToByte().ToString() && x.DictName == materialDto.SuppliesType); //if (typeDict == null) //{ // return RouteData<Wms_material>.From(PubMessages.E1001_SUPPLIESTYPE_NOTFOUND, $"SuppliesType = {materialDto.SuppliesType}"); //} //else if (typeDict.WarehouseId == null) //{ // return RouteData<Wms_material>.From(PubMessages.E1002_SUPPLIESTYPE_WAREHOUSEID_NOTSET, $"SuppliesType = {materialDto.SuppliesType}"); //} //long warehouseId = typeDict.WarehouseId.Value; string warehouseNo = string.IsNullOrWhiteSpace(materialDto.WarehouseId) ? "A00" : materialDto.WarehouseId; //MES的WarehouseID对应WMS的WarehouseNo Wms_warehouse warehouse = WMSApiManager.GetWarehouse(warehouseNo); if (warehouse == null) { return(RouteData <Wms_material> .From(PubMessages.E1026_SUPPLIES_WAREHOUSEID_NOTFOUND, $"warehouseId = {warehouseNo}")); } long warehouseId = warehouse.WarehouseId; List <Wms_WarehouseEntryMaterialInventoryDto> warehouseMaterialList = null; if (map.ContainsKey(warehouseId)) { warehouseMaterialList = map[warehouseId]; } else { warehouseMaterialList = new List <Wms_WarehouseEntryMaterialInventoryDto>(); map.Add(warehouseId, warehouseMaterialList); } warehouseMaterialList.Add(new Wms_WarehouseEntryMaterialInventoryDto() { MaterialId = "-1", SubWarehouseEntryId = materialDto.SubWarehouseEntryId, UniqueIndex = materialDto.UniqueIndex, MaterialOnlyId = materialDto.SuppliesOnlyId, MaterialNo = materialDto.SuppliesId, MaterialName = materialDto.SuppliesName, MaterialType = materialDto.SuppliesType, Qty = materialDto.SuppliesNumber, Unit = materialDto.Unit }); } List <RouteData> result = new List <RouteData>(); foreach (KeyValuePair <long, List <Wms_WarehouseEntryMaterialInventoryDto> > keyValue in map) { try { IWMSBaseApiAccessor proxy = WMSApiManager.GetBaseApiAccessor(keyValue.Key.ToString(), _sqlClient); OutsideStockOutRequestDto request = new OutsideStockOutRequestDto() { MesTaskId = mesTask.MesTaskId, WarehouseEntryId = mesTask.WarehousingId, WarehouseEntryTime = mesTask.WarehousingTime.ToString(PubConst.Format_DateTime), WarehouseEntryType = mesTask.WarehousingType, WarehouseId = keyValue.Key, OrderNo = mesTask.ProductionPlanId, WorkNo = mesTask.TotalWorkOrder, BatchNumber = mesTask.BatchNumber, WorkAreaName = mesTask.WorkAreaName, WorkStationId = mesTask.WorkStationId, BatchPlanId = mesTask.BatchPlanId, MaterialList = keyValue.Value.ToArray(), }; _logger.LogInformation("小WMS的StockOut开始", ""); RouteData data = proxy.StockOut(request).GetAwaiter().GetResult(); _logger.LogInformation("小WMS的StockOut结束", ""); if (!data.IsSccuess) { string message = $"仓库{keyValue.Key}下发出库任务失败,Code={data.Code},Message={data.Message}"; _logger.LogError(message); result.Add(data); return(new RouteData() { Code = -1, Message = message }); } else { _logger.LogInformation($"仓库{keyValue.Key}下发出库任务成功"); } } catch (Exception ex) { string message = $"仓库{keyValue.Key}下发出库任务发生异常"; _logger.LogError(ex, message); return(new RouteData() { Code = -1, Message = message }); } } return(new RouteData()); }