/// <summary> /// 取出队列中第一个上传任务,进行上传,上传完成后删除这条 /// </summary> public void Upload() { lock (_lockObject) { if (isbusy) { return; } else { isbusy = true; } if (CurrentUploadQueue.Count > 0) { // 取出任务上传 object o = CurrentUploadQueue.Pop(); if (o.GetType() == typeof(UploadEbBoxInfo)) { UploadEbBoxInfo box = o as UploadEbBoxInfo; bool isUpload = SAPDataService.UploadEbBoxInfo(box.LGNUM, box.EQUIP_HLA, box.HU, box.ChangeTime, box.InventoryResult, box.ErrorMsg, box.SubUser, box.TagDetailList); if (isUpload) { SqliteDataService.DeleteUploaded(box.Guid); //删除已上传成功的数据 } else { box.RetryTimes++; if (box.RetryTimes < 3) //最多重试3次 { CurrentUploadQueue.Push(o); } else { SqliteDataService.DeleteUploaded(box.Guid); //删除超过3次上传失败的数据 LogHelper.WriteLine(JsonConvert.SerializeObject(box)); //并记录日志,防止将来还需要使用 } } } else if (o.GetType() == typeof(EbBoxCheckRecordInfo)) { EbBoxCheckRecordInfo record = o as EbBoxCheckRecordInfo; LocalDataService.InsertEbCheckRecord(record, HLACommonLib.Model.ENUM.CheckType.电商收货复核); } else if (o.GetType() == typeof(EbBoxErrorRecordInfo)) { EbBoxErrorRecordInfo record = o as EbBoxErrorRecordInfo; LocalDataService.InsertEbBoxErrorRecord(record, HLACommonLib.Model.ENUM.CheckType.电商收货复核); } } isbusy = false; } }
/// <summary> /// 检查数据 /// </summary> /// <returns></returns> public override CheckResult CheckData() { CheckResult cr = new CheckResult(); if (string.IsNullOrEmpty(this.lblHU.Text.Trim())) { cr.UpdateMessage(WEI_SAO_DAO_XIANG_MA); cr.InventoryResult = false; } else { if (this.currentBox != null && this.currentBox.Count > 0) { //检查当前箱子是否是当前选择的发运日期 if (this.currentBox[0].SHIPDATE != shipDate) { cr.UpdateMessage(BU_SHU_YU_DA_QIAN_FA_YUN_RI_QI); cr.InventoryResult = false; } } } if (this.lblErrorNum.Text.Trim() != "0") { cr.UpdateMessage(EPC_WEI_ZHU_CE); cr.InventoryResult = false; } if (this.epcList.Count == 0) { cr.UpdateMessage(WEI_SAO_DAO_EPC); cr.InventoryResult = false; } if (this.boxNoList.Count > 0) { boxNoList.Clear(); cr.UpdateMessage(XIANG_MA_BU_YI_ZHI); cr.InventoryResult = false; } List <string> matnrList = new List <string>(); if (tagDetailList != null) { tagDetailList.ForEach(new Action <TagDetailInfo>((tag) => { if (!matnrList.Contains(tag.MATNR)) { matnrList.Add(tag.MATNR); } if (!lvtagList.Exists(i => i.MATNR == tag.MATNR)) { lvtagList.Add(new ListViewTagInfo( tag.MATNR, tag.ZSATNR, tag.ZCOLSN, tag.ZSIZTX, tag.CHARG, tagDetailList.FindAll(x => x.MATNR == tag.MATNR && !x.IsAddEpc).Count)); } })); } //判断当前读取的标签信息中,是否是多SKU if (matnrList.Count > 1) { isMultiSku = true; } else { isMultiSku = false; } if (this.currentBox != null) { currentBox.ForEach(new Action <EbBoxInfo>((box) => { if (!matnrList.Contains(box.PRODUCTNO)) { matnrList.Add(box.PRODUCTNO); } })); } foreach (string matnr in matnrList) { List <TagDetailInfo> scanList = tagDetailList == null ? null : tagDetailList.FindAll(i => i.MATNR == matnr); int scanCount = scanList == null ? 0 : scanList.Count; List <EbBoxInfo> currentBoxList = currentBox == null ? null : currentBox.FindAll(i => i.PRODUCTNO == matnr); int boxCount = currentBoxList == null ? 0 : currentBoxList.Sum(i => i.QTY); int diff = scanCount - boxCount; if (diff != 0) { if (currentBoxList != null && currentBoxList.Count > 0) { //存在差异,记录错误信息 cr.InventoryResult = false; EbBoxErrorRecordInfo error = new EbBoxErrorRecordInfo(); error.DIFF = diff; error.HU = currentBoxList[0].HU; error.PRODUCTNO = currentBoxList[0].PRODUCTNO; error.REMARK = cr.Message; if (scanList != null && scanList.Count > 0) { error.ZCOLSN = scanList[0].ZCOLSN; error.ZSATNR = scanList[0].ZSATNR; error.ZSIZTX = scanList[0].ZSIZTX; } else if (currentBoxList != null && currentBoxList.Count > 0) { MaterialInfo material = materialList.Find(i => i.MATNR == currentBoxList[0].PRODUCTNO); if (material != null) { error.ZCOLSN = material.ZCOLSN; error.ZSATNR = material.ZSATNR; error.ZSIZTX = material.ZSIZTX; } else { error.ZCOLSN = ""; error.ZSATNR = ""; error.ZSIZTX = ""; } } else { error.ZCOLSN = ""; error.ZSATNR = ""; error.ZSIZTX = ""; } EnqueueUploadData(error); } else { cr.InventoryResult = false; EbBoxErrorRecordInfo error = new EbBoxErrorRecordInfo(); error.DIFF = diff; error.HU = this.lblHU.Text; error.REMARK = cr.Message; if (scanList != null && scanList.Count > 0) { error.PRODUCTNO = scanList[0].MATNR; error.ZCOLSN = scanList[0].ZCOLSN; error.ZSATNR = scanList[0].ZSATNR; error.ZSIZTX = scanList[0].ZSIZTX; } else { error.PRODUCTNO = ""; error.ZCOLSN = ""; error.ZSATNR = ""; error.ZSIZTX = ""; } EnqueueUploadData(error); } } if (this.currentBox == null || this.currentBox.Count <= 0) { cr.UpdateMessage(WEI_ZHAO_DAO_DANG_QIAN_XIANG_SHU_JU); cr.InventoryResult = false; } } if (matnrList.Count == 0) { EbBoxErrorRecordInfo error = new EbBoxErrorRecordInfo(); error.DIFF = 0; error.HU = this.lblHU.Text; error.REMARK = cr.Message; error.PRODUCTNO = ""; error.ZCOLSN = ""; error.ZSATNR = ""; error.ZSIZTX = ""; EnqueueUploadData(error); } if (cr.InventoryResult) { if (isMultiSku) { //多SKU,走异常口,显示正常 cr.UpdateMessage("正常"); SetInventoryResult(3); } else { //单SKU SetInventoryResult(1); } } else { SetInventoryResult(3); } return(cr); }
private void AddErrorRecord(EbBoxErrorRecordInfo item) { grid.Rows.Insert(0, item.HU, item.ZSATNR, item.ZCOLSN, item.ZSIZTX, item.DIFF, item.REMARK); }