Commit 3b364888 张东亮

打印机多cid打印

1 个父辈 58dffb44
...@@ -75,14 +75,21 @@ namespace ShelfPrinter ...@@ -75,14 +75,21 @@ namespace ShelfPrinter
} }
void printLabel(Label_LZ label_LZ) void printLabel(Label_LZ label_LZ)
{ {
print.LoadLabel(labelName); try
Dictionary<string, string> text = new Dictionary<string, string>(); {
text.Add("lh", label_LZ.pn); print.LoadLabel(labelName);
text.Add("jt", label_LZ.station); Dictionary<string, string> text = new Dictionary<string, string>();
text.Add("xb", label_LZ.line); text.Add("lh", label_LZ.pn);
text.Add("sj", label_LZ.shijian); text.Add("jt", label_LZ.station);
text.Add("zb", label_LZ.slot); text.Add("xb", label_LZ.line);
pictureBox1.Image = print.Print(text); text.Add("sj", label_LZ.shijian);
text.Add("zb", label_LZ.slot);
pictureBox1.Image = print.Print(text);
}catch(Exception ex)
{
LogUtil.error("printLabel", ex);
}
} }
Dictionary<string, string> printview(Label_LZ label_LZ) Dictionary<string, string> printview(Label_LZ label_LZ)
{ {
...@@ -120,6 +127,7 @@ namespace ShelfPrinter ...@@ -120,6 +127,7 @@ namespace ShelfPrinter
{ {
printLabel(new Label_LZ(textBox1.Text, textBox3.Text, textBox4.Text, textBox2.Text,textBox5.Text,textBox6.Text)); printLabel(new Label_LZ(textBox1.Text, textBox3.Text, textBox4.Text, textBox2.Text,textBox5.Text,textBox6.Text));
} }
string[] cids = ConfigAppSettings.GetValue("cid", "01#02").Split('#');
object handleObj = new object(); object handleObj = new object();
private void timer1_Tick(object sender, EventArgs e) private void timer1_Tick(object sender, EventArgs e)
{ {
...@@ -127,37 +135,41 @@ namespace ShelfPrinter ...@@ -127,37 +135,41 @@ namespace ShelfPrinter
{ {
try try
{ {
Label_LZ labels = SServerManager.GetPrintInfo(); foreach (var item in cids)
if (labels != null)
{ {
lblLabelInfo.Text = ""; Label_LZ labels = SServerManager.GetPrintInfo(item);
// if (printerStatus.Equals(Asa.PrintLabel.PrinterStatus.Idle)) if (labels != null)
{ {
timer1.Enabled = false; // if (printerStatus.Equals(Asa.PrintLabel.PrinterStatus.Idle))
//foreach (var item in labels)
{ {
lblLabelInfo.Text = $"打印任务:{labels.ToStr()}"; timer1.Enabled = false;
printLabel(new Label_LZ(labels.pn, labels.side, labels.station, labels.line)); //foreach (var item in labels)
while (printerStatus.Equals(Asa.PrintLabel.PrinterStatus.Printing)
|| printerStatus.Equals(Asa.PrintLabel.PrinterStatus.Print))
{ {
Thread.Sleep(300); lblLabelInfo.Text = $"打印任务[{item}]:{labels.ToStr()}";
} printLabel(new Label_LZ(labels.pn, labels.side, labels.station, labels.line));
LogUtil.info($"自动打印[{printerStatus.ToString()}]:{labels.ToStr()}"); while (printerStatus.Equals(Asa.PrintLabel.PrinterStatus.Printing)
while (true) || printerStatus.Equals(Asa.PrintLabel.PrinterStatus.Print))
{ {
if (SServerManager.FinishPrint()) Thread.Sleep(300);
break; }
Thread.Sleep(1000); LogUtil.info($"自动打印[{printerStatus.ToString()}]:{labels.ToStr()}");
while (true)
{
if (SServerManager.FinishPrint(item))
break;
Thread.Sleep(1000);
}
} }
timer1.Enabled = true;
} }
timer1.Enabled = true; //else
//{
// lblLabelInfo.Text = "无法打印标签,因打印机不空闲";
//}
} }
//else lblLabelInfo.Text = "";
//{
// lblLabelInfo.Text = "无法打印标签,因打印机不空闲";
//}
} }
} }
catch (Exception ex) catch (Exception ex)
{ {
......
...@@ -200,13 +200,13 @@ namespace OnlineStore.DeviceLibrary ...@@ -200,13 +200,13 @@ namespace OnlineStore.DeviceLibrary
} }
#region 料架打印机接口 #region 料架打印机接口
static string Addr_GetPrintInfo = ConfigAppSettings.GetValue("Addr_GetPrintInfo", "/service/store/innerBox/rack/getPrintInfo"); static string Addr_GetPrintInfo = ConfigAppSettings.GetValue("Addr_GetPrintInfo", "/service/store/innerBox/rack/getPrintInfo");
public static Label_LZ GetPrintInfo() public static Label_LZ GetPrintInfo(string cid)
{ {
try try
{ {
string msg = ""; string msg = "";
Dictionary<string, string> map = new Dictionary<string, string>(); Dictionary<string, string> map = new Dictionary<string, string>();
map.Add("cid", ConfigAppSettings.GetValue("cid", "01")); map.Add("cid", cid);
string server = GetAddr(Addr_GetPrintInfo, map); string server = GetAddr(Addr_GetPrintInfo, map);
DateTime startTime = DateTime.Now; DateTime startTime = DateTime.Now;
string resultStr = HttpHelper.Get(server); string resultStr = HttpHelper.Get(server);
...@@ -219,13 +219,12 @@ namespace OnlineStore.DeviceLibrary ...@@ -219,13 +219,12 @@ namespace OnlineStore.DeviceLibrary
{ {
// code: 0为正常,其他为异常, msg: 消息, data: 为空 // code: 0为正常,其他为异常, msg: 消息, data: 为空
msg = $" GetPrintInfo 【{resultStr}】"; msg = $" GetPrintInfo 【{resultStr}】";
LogUtil.error(msg);
return null; return null;
} }
else else
{ {
msg = $" GetPrintInfo【{resultStr}】"; msg = $" GetPrintInfo【{resultStr}】";
LogUtil.debug(msg); LogUtil.info(msg);
if (string.IsNullOrEmpty(serverResult.data.pn)) return null; if (string.IsNullOrEmpty(serverResult.data.pn)) return null;
else else
return serverResult.data; return serverResult.data;
...@@ -239,13 +238,13 @@ namespace OnlineStore.DeviceLibrary ...@@ -239,13 +238,13 @@ namespace OnlineStore.DeviceLibrary
} }
static string Addr_FinishPrint = ConfigAppSettings.GetValue("Addr_FinishPrint", "/service/store/innerBox/rack/finishPrint"); static string Addr_FinishPrint = ConfigAppSettings.GetValue("Addr_FinishPrint", "/service/store/innerBox/rack/finishPrint");
public static bool FinishPrint() public static bool FinishPrint(string cid)
{ {
try try
{ {
string msg = ""; string msg = "";
Dictionary<string, string> map = new Dictionary<string, string>(); Dictionary<string, string> map = new Dictionary<string, string>();
map.Add("cid", ConfigAppSettings.GetValue("cid","01")); map.Add("cid", cid);
string server = GetAddr(Addr_FinishPrint, map); string server = GetAddr(Addr_FinishPrint, map);
DateTime startTime = DateTime.Now; DateTime startTime = DateTime.Now;
string resultStr = HttpHelper.Get(server); string resultStr = HttpHelper.Get(server);
...@@ -263,7 +262,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -263,7 +262,7 @@ namespace OnlineStore.DeviceLibrary
} }
else else
{ {
msg = $" GetFeederInfo【{resultStr}】"; msg = $" FinishPrint【{resultStr}】";
LogUtil.debug(msg); LogUtil.debug(msg);
return false; return false;
} }
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!