/// <summary> /// 拣选单打印 /// </summary> /// <param name="Sender"></param> /// <param name="e"></param> private void Timerselect_Tick(object Sender, EventArgs e) { int worktype = 20; int p_id = GetprintID(); //得到打印插件ID busi_printwork list = CommPrint.GetOneprintInfo(p_id, worktype); if (null != list) //说明有数据 { List <busi_printwork> allselect = CommPrint.GetSelectPackgeList(p_id, worktype, list.data_1); //取出这个包裹号所有SKU信息 List <Myselect> myselectlist = new List <Myselect>(); foreach (var item in allselect) { Myselect p = new Myselect(); p.ID1 = item.p_Workid.ObjToInt(); p.Packgecode = item.data_1; p.Position = item.data_4; p.Number = item.data_3; p.Skus = item.data_2; p.Remarks1 = item.data_5; myselectlist.Add(p); } JXpackge pack = new JXpackge(); pack.selectlist = myselectlist; pack.packgecode = list.data_1; //将此包裹设为中间状态,防止多次取值 int a = SQLHelper.ExecuteSql("update busi_printwork set p_Status=10 where p_WorkType=20 and data_1=" + "'" + list.data_1 + "'"); if (a < 0) { Log("打印拣选设置中间状态出错!包裹号:" + list.data_1); } if (!QueueSelect.Contains(pack)) { QueueSelect.Enqueue(pack); } label9.Text = QueueSelect.Count.ToString(); //队列显示未打印数量 #region 满足打印个数条件打印,不然等待队列满足条件,或者人为手动清空队列打印 try { if (QueueSelect.Count == 14) //队列中数据大于14个包裹,直接打印 { for (int m = 0; m < 14; m++) { //List<JXpackge> ss=QueueSelect.Take<JXpackge>(14); JXpackge s = QueueSelect.Dequeue(); //出队列 Printselect.mylist = Printselect.mylist.Union(s.selectlist).ToList <Myselect>(); //放入打印list中 CommPrint.FinshSelectPrint(p_id, s.packgecode); } Printselect.Print(false); //打印 Printselect.mylist.Clear(); //移除所有元素 } label9.Text = QueueSelect.Count.ToString(); //队列显示未打印数量 } catch (Exception ex) { Log(ex.ToString()); } #endregion } }
public Printselect(Myselect pack) { packge = pack; mylist.Add(pack); }