/// <summary> /// 新增实际库存商品 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void onAddProduct(object sender, RoutedEventArgs e) { string inputStr = codeInputTb.Text; if (string.IsNullOrWhiteSpace(inputStr)) { MessageBox.Show("盘点任务单号不可以为空!", "温馨提示", MessageBoxButton.OK); return; } List <CommodityCode> adds = new List <CommodityCode>(); #if TESTENV CommodityEps commodityEps = new CommodityEps { CommodityCodeId = "AQACQqweBhEBAAAAVF0JmCFcsxUkKAIA", CommodityCodeName = "QR00000035", CommodityName = "止血包", EquipmentId = "AQACQqweDg8BAAAAFUD8WDEPsxV_FwQA", EquipmentName = "E00000008", GoodsLocationId = "AQACQqweJ4wBAAAAjYv6XmUPsxWWowMA", GoodsLocationName = "L00000013" }; HashSet <CommodityEps> addHs = new HashSet <CommodityEps>(); addHs.Add(commodityEps); adds = CommodityCodeBll.GetInstance().GetCommodityCode(addHs).body.objects.ToList(); #else CommodityOrder commodityOrder; string name; try { commodityOrder = JsonConvert.DeserializeObject <CommodityOrder>(inputStr); name = commodityOrder.CommodityCodeName; } catch (Exception ex) { LogUtils.Error($"数据解析失败!{inputStr} ; 异常报错为:{ex.Message}"); name = inputStr; } LoadingDataEvent(this, true); BaseData <CommodityCode> bdCommodityCode = CommodityCodeBll.GetInstance().GetCommodityCodeByName(name.ToUpper()); LoadingDataEvent(this, false); //校验是否含有数据 HttpHelper.GetInstance().ResultCheck(bdCommodityCode, out bool isSuccess); if (!isSuccess) { MessageBox.Show("获取商品信息失败" + bdCommodityCode.message, "温馨提示", MessageBoxButton.OK); return; } bdCommodityCode.body.objects[0].EquipmentId = inventoryOrder.EquipmentId; bdCommodityCode.body.objects[0].StoreHouseId = inventoryOrder.StoreHouseId; bdCommodityCode.body.objects[0].GoodsLocationId = inventoryOrder.GoodsLocationId; bdCommodityCode.body.objects[0].GoodsLocationName = inventoryOrder.GoodsLocationName; adds.Add(bdCommodityCode.body.objects[0]); #endif if (list.Where(item => item.name == adds[0].name).Count() > 0) { MessageBox.Show("此商品已经在列表中!", "温馨提示", MessageBoxButton.OK); return; } App.Current.Dispatcher.Invoke((Action)(() => { App.Current.Dispatcher.Invoke((Action)(() => { list.AddRange(adds); goodsDtllistConfirmView.Items.Refresh(); })); })); }
/// <summary> /// 根据eps json获取eps对象数据 /// </summary> /// <param name="isGetSuccess"></param> /// <returns></returns> public static HashSet <CommodityEps> GetEpcDataJson(out bool isGetSuccess) { isGetSuccess = true; //string com1 = "COM1"; string com1 = ApplicationState.GetMRfidCOM(); HashSet <string> com1HashSet = new HashSet <string>(); string log = ""; #if DUALCAB //string com4 = "COM4"; string com4 = ApplicationState.GetSRfidCOM(); HashSet <string> com4HashSet = new HashSet <string>(); #endif HashSet <CommodityEps> currentEpcDataHs = new HashSet <CommodityEps>(); //TODO:需要补充id GClient com1ClientConn = CreateClientConn(com1, "115200", out bool isCom1Connect); if (isCom1Connect) { com1HashSet = DealComData(com1ClientConn, com1, out isGetSuccess); } else { isGetSuccess = false; } #if DUALCAB GClient com4ClientConn = CreateClientConn(com4, "115200", out bool isCom4Connect); if (isCom4Connect) { com4HashSet = DealComData(com4ClientConn, com4, out isGetSuccess); } else { isGetSuccess = false; } #endif WaitHandle.WaitAll(manualEvents.ToArray()); manualEvents.Clear(); //提取com1的标签epc,并组装 foreach (string rfid in com1HashSet) { CommodityEps commodityEps = new CommodityEps { CommodityCodeName = $"RF{rfid.Substring(rfid.Length - 8)}", EquipmentId = ApplicationState.GetEquipId(), EquipmentName = ApplicationState.GetEquipName(), StoreHouseId = ApplicationState.GetHouseId(), StoreHouseName = ApplicationState.GetHouseName(), GoodsLocationName = ApplicationState.GetCabNameByRFidCom(com1), GoodsLocationId = ApplicationState.GetCabIdByRFidCom(com1) }; currentEpcDataHs.Add(commodityEps); LogUtils.Debug(commodityEps.CommodityCodeName + commodityEps.CommodityName); log += commodityEps.CommodityCodeName + " "; } #if DUALCAB //提取com4的标签epc,并组装 foreach (string rfid in com4HashSet) { CommodityEps commodityEps = new CommodityEps { CommodityCodeName = $"RF{rfid.Substring(rfid.Length - 8)}", EquipmentId = ApplicationState.GetEquipId(), EquipmentName = ApplicationState.GetEquipName(), StoreHouseId = ApplicationState.GetHouseId(), StoreHouseName = ApplicationState.GetHouseName(), GoodsLocationName = ApplicationState.GetCabNameByRFidCom(com1), GoodsLocationId = ApplicationState.GetCabIdByRFidCom(com1) }; currentEpcDataHs.Add(commodityEps); LogUtils.Debug(commodityEps.CommodityCodeName + commodityEps.CommodityName); log += commodityEps.CommodityCodeName + " "; } #endif Task.Factory.StartNew(a => { LogUtils.Debug(log); }, log); LogUtils.Debug("RFID NUM:" + currentEpcDataHs.Count()); return(currentEpcDataHs); }