public OutsideStockInResponseResult ConfirmBalanceMES(OutsideStockInResponse obj) { OutsideStockInResponseResult retModel = new OutsideStockInResponseResult(); retModel.WarehousingId = obj.WarehousingId; retModel.IsNormalExecution = true; _eventBus.Post(new KeyValuePair <OutsideStockInResponse, OutsideStockInResponseResult>(obj, retModel), TimeSpan.Zero); return(retModel); }
/// <summary> /// 入库完成 /// </summary> /// <param name="inStockInfo"></param> /// <returns></returns> public async Task <OutsideStockInResponseResult> WarehousingFinish(OutsideStockInResponse inStockInfo) { MESService.WarehousingFinishResponse1 reuslt = await _apiProxy.WarehousingFinishAsync( new MESService.WarehousingFinishRequest() { arg0 = inStockInfo.WarehousingId, arg1 = inStockInfo.WarehousingEntryNumber.ToString(), arg2 = inStockInfo.WarehousingEntryFinishList } ); return(JsonConvert.DeserializeObject <OutsideStockInResponseResult>(reuslt.@return)); }
public async Task <string> WarehousingFinish(string warehouseId, string warehouseName) { OutsideStockInResponseWarehouse[] list = new OutsideStockInResponseWarehouse[] { new OutsideStockInResponseWarehouse() { WarehouseId = warehouseId, WarehouseName = warehouseName, WarehousePosition = "A", WarehousingFinishTime = DateTime.Now.ToString("yyyyMMddHHmmss"), SuppliesKinds = 2, SuppliesInfoList = new List <OutsideMaterialResult>() { new OutsideMaterialResult() { SuppliesId = "B001", SuppliesName = "物料001", SuppliesNumber = "10", RefreshStock = "12" }, new OutsideMaterialResult() { SuppliesId = "B002", SuppliesName = "物料002", SuppliesNumber = "20", RefreshStock = "22" } } } }; OutsideStockInResponse inStockInfo = new OutsideStockInResponse(); inStockInfo.WarehousingId = "RK" + DateTime.Now.ToString("yyyyMMddHHmmss"); inStockInfo.WarehousingEntryNumber = 3; inStockInfo.WarehousingEntryFinishList = JsonConvert.SerializeObject(list); //string reuslt = await _apiProxy.WarehousingFinishAsync(inStockInfo.WarehousingId, inStockInfo.WarehousingEntryNumber, inStockInfo.WarehousingEntryFinishList); var result = await _apiProxy.WarehousingFinishAsync( new MESService.WarehousingFinishRequest() { arg0 = inStockInfo.WarehousingId, arg1 = inStockInfo.WarehousingEntryNumber.ToString(), arg2 = inStockInfo.WarehousingEntryFinishList, } ); return(JsonConvert.SerializeObject(result)); }
/// <summary> /// 通知MES入库完成 /// </summary> /// <param name="stockOutId"></param> /// <param name="result"></param> /// <returns></returns> public static async Task <RouteData> NofityStockIn(this ISqlSugarClient client, Wms_mestask mesTask) { mesTask.ModifiedDate = DateTime.Now; mesTask.WorkStatus = MESTaskWorkStatus.WorkComplated; mesTask.NotifyStatus = MESTaskNotifyStatus.WaitResponse; try { List <Wms_stockin> stockIns = await client.Queryable <Wms_stockin>().Where(x => x.MesTaskId == mesTask.MesTaskId).ToListAsync(); List <OutsideStockInResponseWarehouse> warehouseList = new List <OutsideStockInResponseWarehouse>(); foreach (Wms_stockin stockIn in stockIns) { OutsideStockInResponseWarehouse warehouse = warehouseList.FirstOrDefault(x => x.WarehouseId == stockIn.WarehouseId.ToString()); if (warehouse == null) { Wms_warehouse warehouseData = WMSApiManager.GetWarehouse(stockIn.WarehouseId); warehouse = new OutsideStockInResponseWarehouse() { //WarehouseId = stockIn.WarehouseId.ToString(), WarehouseId = warehouseData?.WarehouseNo, WarehouseName = warehouseData?.WarehouseName, WarehousePosition = "", WarehousingFinishTime = stockIn.ModifiedDate.Value.ToString("yyyy-MM-dd HH:mm:ss"), }; warehouseList.Add(warehouse); } List <Wms_stockindetail> stockInDetails = await client.Queryable <Wms_stockindetail>().Where(x => x.StockInId == stockIn.StockInId).ToListAsync(); foreach (Wms_stockindetail stockInDetail in stockInDetails) { OutsideMaterialResult material = new OutsideMaterialResult() { UniqueIndex = stockInDetail.UniqueIndex, SuppliesId = stockInDetail.MaterialNo.ToString(), SuppliesName = stockInDetail.MaterialName, SuppliesNumber = stockInDetail.ActInQty.ToString(), RefreshStock = stockInDetail.ActInQty.ToString(), ErrorId = stockInDetail.ErrorId, ErrorInfo = stockInDetail.ErrorInfo }; warehouse.SuppliesInfoList.Add(material); warehouse.SuppliesKinds = warehouse.SuppliesInfoList.Count; } } OutsideStockInResponse response = new OutsideStockInResponse() { WarehousingId = mesTask.WarehousingId, WarehousingEntryNumber = warehouseList.Count, WarehousingEntryFinishList = JsonConvert.SerializeObject(warehouseList) }; SelfReservoirAreaManager._logger.Info($"[通知MES入库完成]开始通知MES,param={JsonConvert.SerializeObject(response)}"); OutsideStockInResponseResult result = await MESApiAccessor.Instance.WarehousingFinish(response); SelfReservoirAreaManager._logger.Info($"[通知MES入库完成]通知MES成功,result={JsonConvert.SerializeObject(result)}"); if (String.IsNullOrWhiteSpace(result.IsNormalExecution)) { mesTask.NotifyStatus = MESTaskNotifyStatus.Responsed; } else { mesTask.Remark = $"Error={result.IsNormalExecution}"; mesTask.NotifyStatus = MESTaskNotifyStatus.Failed; } } catch (Exception ex) { mesTask.Remark = $"InnerError={ex.Message}"; mesTask.NotifyStatus = MESTaskNotifyStatus.Failed; //_logger.LogError(ex, "入库完成通知时发生异常"); //逻辑继续,寻找其它时机重新通知 SelfReservoirAreaManager._logger.Error($"[通知MES入库完成]通知MES时发生异常,{ex.ToString()}"); } if (client.Updateable(mesTask).ExecuteCommand() == 0) { SelfReservoirAreaManager._logger.Error($"[通知MES入库完成]E-0002-更新状态失败"); return(YL.Core.Dto.RouteData.From(PubMessages.E0002_UPDATE_COUNT_FAIL)); } SelfReservoirAreaManager._logger.Info($"[通知MES入库完成]更新状态成功,NotifyStatus={mesTask.NotifyStatus}"); if (mesTask.NotifyStatus == MESTaskNotifyStatus.Responsed) { return(new RouteData()); } else { return(YL.Core.Dto.RouteData.From(PubMessages.E3001_MES_STOCKIN_NOFITY_FAIL)); } }