/// <summary> /// 队列全部打印 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button1_Click(object sender, EventArgs e) { try { label9.Text = QueueSelect.Count.ToString(); //队列显示未打印数量 int p_id = GetprintID(); if (QueueSelect.Count < 14) //队列中数据小于14个包裹,直接打印 { int mycount = QueueSelect.Count; for (int m = 0; m < mycount; m++) { string packgecode = QueueSelect.Dequeue(); //出队列 JXpackge s = PrintListSelect[packgecode]; Printselect.mylist = Printselect.mylist.Union(s.selectlist).ToList <Myselect>(); //放入打印list中 CommPrint.FinshSelectPrint(p_id, s.packgecode); PrintListSelect.Remove(packgecode); } Printselect.Print(false); //打印 Printselect.mylist.Clear(); //移除所有元素 } label9.Text = QueueSelect.Count.ToString(); //队列显示未打印数量 } catch (Exception ex) { Log(ex.ToString()); } }
/// <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 } }
/// <summary> /// yamato打印, /// </summary> /// <param name="Sender"></param> /// <param name="e"></param> private void Timeryamato_Tick(object Sender, EventArgs e) { int worktype = 50; int p_id = GetprintID(); //得到打印插件ID //1.得到需要打印的包裹号 List <busi_printwork> list = CommPrint.GetprintInfo(p_id, worktype); //worktype =50 if (list.Count > 0) //有数据要打印 { foreach (var item in list) { if (!Queueyamato.Contains(item.p_Workid)) //data_10存的是包裹号 { Queueyamato.Enqueue(item.p_Workid); PrintListYamato.Add(item.p_Workid, item); } } } if (PrintListYamato.Count > 0)//字典中有数据 { try { long workid = Queueyamato.Peek(); busi_printwork mypackge = PrintListYamato[workid]; //取出队列中对象 //打印yamato Myamato pyamato = CommPrint.GetPrintyamato(mypackge); if (null == pyamato) { throw new Exception("系统中不存在此店铺名或者此包裹" + mypackge.data_10); } PrintYamato printer = new PrintYamato(pyamato); printer.Print(true); bool isok = CommPrint.FinshPrint(p_id, mypackge); //设置已打印的状态 if (!isok) { Log(mypackge.data_1 + "打印失败!"); } else { //打印完成清除出队列 Queueyamato.Dequeue(); PrintListYamato.Remove(workid); Hasprintcount++; label7.Text = Hasprintcount.ToString(); Log(mypackge.data_1 + "包裹号已打印。Yamato" + DateTime.Now.ToString()); } } catch (Exception ex) { Log(ex.ToString()); } } }
/// <summary> /// 包裹打印 /// </summary> /// <param name="Sender"></param> /// <param name="e"></param> private void Timerpackge_Tick(object Sender, EventArgs e) { int worktype = 30; int p_id = GetprintID(); //得到打印插件ID //1.得到需要打印的包裹号 List <busi_printwork> list = CommPrint.GetprintInfo(p_id, worktype); if (list.Count > 0)//有数据要打印 { foreach (var item in list) { if (!Queuepackge.Contains(item.p_Workid)) { Queuepackge.Enqueue(item.p_Workid); PrintListpackge.Add(item.p_Workid, item); } } } if (PrintListpackge.Count > 0)//队列中有数据 { try { long workid = Queuepackge.Peek(); busi_printwork mypackge = PrintListpackge[workid]; //取出队列中对象 //打印包裹 packgeInfoViewModel mymodel = CommPrint.GetPrintpackge(mypackge); if (null == mymodel) { throw new Exception("系统中不存在此店铺名或者此包裹" + mypackge.data_1); } PrintPackge printer = new PrintPackge(mymodel); printer.Print(true); bool isok = CommPrint.FinshPrint(p_id, mypackge); if (!isok) { Log(mypackge.data_1 + "打印失败!"); } else { //打印完成清除出队列 Queuepackge.Dequeue(); PrintListpackge.Remove(workid); Hasprintcount++; label7.Text = Hasprintcount.ToString(); Log(mypackge.data_1 + "包裹号已打印。" + DateTime.Now.ToString()); } } catch (Exception ex) { Log(ex.ToString()); } } }
/// <summary> /// 转运单打印 /// </summary> /// <param name="Sender"></param> /// <param name="e"></param> private void Timerzhuanyun_Tick(object Sender, EventArgs e) { int worktype = 40; int p_id = GetprintID(); //得到打印插件ID //1.得到需要打印的包裹号 List <busi_printwork> list = CommPrint.GetprintInfo(p_id, worktype); if (list.Count > 0)//有数据要打印 { foreach (var item in list) { if (!Queuezhuanyun.Contains(item.p_Workid)) { Queuezhuanyun.Enqueue(item.p_Workid); PrintListzhuanyun.Add(item.p_Workid, item); } } } if (PrintListzhuanyun.Count > 0)//队列中有数据 { try { long workid = Queuezhuanyun.Peek(); busi_printwork mypackge = PrintListzhuanyun[workid]; //取出队列中对象 zhuanyunInfo zhuanyun = new zhuanyunInfo(); zhuanyun.workid = mypackge.p_Workid.ObjToInt(); zhuanyun.zhuanyuncode = mypackge.data_1; //打印转运单 Printzhuanyun printer = new Printzhuanyun(zhuanyun); printer.Print(true); bool isok = CommPrint.FinshPrint(p_id, mypackge); if (!isok) { Log(mypackge.data_1 + "打印失败!"); } else { //打印完成清除出队列 Queuezhuanyun.Dequeue(); PrintListzhuanyun.Remove(workid); Hasprintcount++; label7.Text = Hasprintcount.ToString(); Log(mypackge.data_1 + "转运单已打印。" + DateTime.Now.ToString()); } } catch (Exception ex) { Log(ex.ToString()); } } }
/// <summary> /// Upacket打印 /// </summary> /// <param name="Sender"></param> /// <param name="e"></param> private void TimerUpacket_Tick(object Sender, EventArgs e) { int worktype = 70; int p_id = GetprintID(); //得到打印插件ID //1.得到需要打印的包裹号 List <busi_printwork> list = CommPrint.GetprintInfo(p_id, worktype); if (list.Count > 0)//有数据要打印 { foreach (var item in list) { if (!Queueupacket.Contains(item)) { Queueupacket.Enqueue(item); } } } if (Queueupacket.Count > 0)//队列中有数据 { try { busi_printwork mypackge = Queueupacket.Peek(); //取出队列中对象 //打印yamato MyUpacket pupacket = CommPrint.GetPrintUpacket(mypackge); if (null == pupacket) { throw new Exception("系统中不存在此店铺名或者此包裹" + mypackge.data_10); } PrintUpacket printer = new PrintUpacket(pupacket); printer.Print(true); //打印完成清除出队列 Queueupacket.Dequeue(); bool isok = CommPrint.FinshPrint(p_id, mypackge); if (!isok) { Log(mypackge.data_1 + "打印失败!"); } else { Hasprintcount++; label7.Text = Hasprintcount.ToString(); Log(mypackge.data_1 + "包裹号已打印。Upacket" + DateTime.Now.ToString()); } } catch (Exception ex) { Log(ex.ToString()); } } }