|
|
|
@ -36,18 +36,16 @@ namespace Aucma.Core.PrintTo.ViewModels
|
|
|
|
|
|
|
|
|
|
public PrintToDevViewModel(string productCode, string materialCode, string materialName, int printAmount, string? barCode = null)
|
|
|
|
|
{
|
|
|
|
|
_orderBomInfoServices = App.ServiceProvider.GetService<IOrderBomInfoServices>();
|
|
|
|
|
ProductCode = productCode;
|
|
|
|
|
MaterialName = materialName;
|
|
|
|
|
PrintAmount = printAmount;
|
|
|
|
|
_orderBomInfoServices = App.ServiceProvider.GetService<IOrderBomInfoServices>();
|
|
|
|
|
MaxProgress = 100;
|
|
|
|
|
Progress = 0;
|
|
|
|
|
//PrintProgress = $"[100/4] B23060512345678910001";
|
|
|
|
|
State = "Green";
|
|
|
|
|
ErrorNum = 0;
|
|
|
|
|
printState = PrintState.Printing;
|
|
|
|
|
isPrint=true;
|
|
|
|
|
//StopOrStart = "暂停";
|
|
|
|
|
SuspendEnabled = "False";
|
|
|
|
|
OperateEnabled = "True";
|
|
|
|
|
// 非阻塞打印
|
|
|
|
|
Task.Run(async () =>
|
|
|
|
@ -149,38 +147,19 @@ namespace Aucma.Core.PrintTo.ViewModels
|
|
|
|
|
[RelayCommand]
|
|
|
|
|
public void StartOperate()
|
|
|
|
|
{
|
|
|
|
|
System.Windows.Application.Current.Dispatcher.Invoke((Action)(() =>
|
|
|
|
|
printState = PrintState.Printing;
|
|
|
|
|
SuspendEnabled = "True";
|
|
|
|
|
OperateEnabled = "False";
|
|
|
|
|
State = "Green";
|
|
|
|
|
if (isPrint)//首次打印
|
|
|
|
|
{
|
|
|
|
|
if (printState == PrintState.Completetd)
|
|
|
|
|
isPrint = false;
|
|
|
|
|
// 非阻塞打印
|
|
|
|
|
Task.Run(async () =>
|
|
|
|
|
{
|
|
|
|
|
isPrint = false;
|
|
|
|
|
StopOrStart = "已完成";
|
|
|
|
|
MessageBox.Show("打印已完成", "系统提醒");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//if (isPrint&& printState == PrintState.Printing)
|
|
|
|
|
//{
|
|
|
|
|
|
|
|
|
|
// if (MessageBox.Show("确定要暂停打印吗?", "系统提醒", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No) == MessageBoxResult.Yes)
|
|
|
|
|
// {
|
|
|
|
|
// isPrint = false;
|
|
|
|
|
// printState = PrintState.Paused;
|
|
|
|
|
// StopOrStart = "继续";
|
|
|
|
|
// }
|
|
|
|
|
//}
|
|
|
|
|
//else
|
|
|
|
|
//{
|
|
|
|
|
// if (MessageBox.Show("确定要继续打印吗?", "系统提醒", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No) == MessageBoxResult.Yes)
|
|
|
|
|
// {
|
|
|
|
|
// isPrint = true;
|
|
|
|
|
// printState = PrintState.Printing;
|
|
|
|
|
// State = "Green";
|
|
|
|
|
// StopOrStart = "暂停";
|
|
|
|
|
// }
|
|
|
|
|
//}
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
await Print();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region 暂停
|
|
|
|
@ -205,7 +184,7 @@ namespace Aucma.Core.PrintTo.ViewModels
|
|
|
|
|
{
|
|
|
|
|
var window = parameter as Window;
|
|
|
|
|
if (window == null) return;
|
|
|
|
|
|
|
|
|
|
isPrint = true;
|
|
|
|
|
if (printState == PrintState.Completetd)
|
|
|
|
|
{
|
|
|
|
|
WeakReferenceMessenger.Default.Send<string>("Refresh");//刷新窗口
|
|
|
|
@ -239,27 +218,28 @@ namespace Aucma.Core.PrintTo.ViewModels
|
|
|
|
|
var boxList = await _orderBomInfoServices.QueryAsync(d => d.ParentId == orderNo&&d.MaterialName.Contains("箱体"));
|
|
|
|
|
if (boxList.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
MaxProgress = boxList.Count;
|
|
|
|
|
MessageBox.Show("无法查询打印条码数据", "系统提醒");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
var list = await _orderBomInfoServices.QueryAsync(d => d.ParentId == orderNo && d.MaterialName.Contains("内胆"));
|
|
|
|
|
if (list.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
MaxProgress = list.Count;
|
|
|
|
|
MessageBox.Show("无法查询打印条码数据", "系统提醒");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
list.ForEach(d => BarcodesUnprinted.Enqueue(d));
|
|
|
|
|
await Print(printer);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 打印
|
|
|
|
|
|
|
|
|
|
public Task Print(string printer)
|
|
|
|
|
|
|
|
|
|
public Task Print()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
string printer = Appsettings.app("Printer", "PrinterName");
|
|
|
|
|
int printNum = BarcodesUnprinted.Count;//打印数
|
|
|
|
|
int i = 0;
|
|
|
|
|
MaxProgress = printNum;
|
|
|
|
@ -269,6 +249,7 @@ namespace Aucma.Core.PrintTo.ViewModels
|
|
|
|
|
if (printState == PrintState.Paused)
|
|
|
|
|
{
|
|
|
|
|
SetPaused();
|
|
|
|
|
Thread.Sleep(1 * 1000);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (printState == PrintState.Completetd) break;
|
|
|
|
@ -276,7 +257,6 @@ namespace Aucma.Core.PrintTo.ViewModels
|
|
|
|
|
{
|
|
|
|
|
var item = BarcodesUnprinted.Peek();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
////对接打印机
|
|
|
|
|
//Report barReport = new Report();
|
|
|
|
|
//barReport.Load(System.Environment.CurrentDirectory + @"\Report\MaterialBar.frx");//打印报表位置
|
|
|
|
@ -286,7 +266,7 @@ namespace Aucma.Core.PrintTo.ViewModels
|
|
|
|
|
//barReport.PrintSettings.Printer = printer; // 设置打印机名称
|
|
|
|
|
//barReport.PrintSettings.Copies = 1; // 设置打印份数
|
|
|
|
|
// //barReport.PrintSettings.PageRange = "1-3"; // 设置打印页范围
|
|
|
|
|
|
|
|
|
|
//barReport.SetParameterValue("BoxBarData.Id", item);
|
|
|
|
|
//barReport.SetParameterValue("BoxBarData.Order_No", orderNo);//订单码
|
|
|
|
|
//barReport.SetParameterValue("BoxBarData.Order_Material_Name", materialName);//物料名称
|
|
|
|
|
//barReport.SetParameterValue("BoxBarData.Bar_Code", barCode);//二维码
|
|
|
|
@ -300,13 +280,13 @@ namespace Aucma.Core.PrintTo.ViewModels
|
|
|
|
|
if (item.MaterialName.Contains("箱体"))
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine(item.MaterialName);
|
|
|
|
|
PrintProgress = $"[{printNum}/{i}] B{DateTime.Now.ToString("yyMMdd")}1234567890000{i + 1}";
|
|
|
|
|
PrintProgress = $"[{printNum}/{i}] B{DateTime.Now.ToString("yyMMdd")}item.MaterialCode{i + 1}";
|
|
|
|
|
Console.WriteLine($"B{DateTime.Now.ToString("yyMMdd")}{item.MaterialCode}{i + 1}");
|
|
|
|
|
}
|
|
|
|
|
if (item.MaterialName.Contains("内胆"))
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine(item.MaterialName);
|
|
|
|
|
PrintProgress = $"[{printNum}/{i}] B{DateTime.Now.ToString("yyMMdd")}{item.MaterialCode}0000{i + 1}";
|
|
|
|
|
PrintProgress = $"[{printNum}/{i}] L{DateTime.Now.ToString("yyMMdd")}{item.MaterialCode}0000{i + 1}";
|
|
|
|
|
Console.WriteLine($"L{DateTime.Now.ToString("yyMMdd")}{item.MaterialCode}0000{i + 1}");
|
|
|
|
|
}
|
|
|
|
|
BarcodesPrinted.Enqueue(BarcodesUnprinted.Dequeue());
|
|
|
|
@ -330,6 +310,10 @@ namespace Aucma.Core.PrintTo.ViewModels
|
|
|
|
|
log.Error($"打印出错:{ex.Message}");
|
|
|
|
|
return Task.FromResult(false);
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
isPrint = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
@ -343,8 +327,10 @@ namespace Aucma.Core.PrintTo.ViewModels
|
|
|
|
|
printState = PrintState.Paused;
|
|
|
|
|
|
|
|
|
|
State = "yellow";
|
|
|
|
|
//StopOrStart = "继续";
|
|
|
|
|
isPrint = false;
|
|
|
|
|
|
|
|
|
|
SuspendEnabled = "False";
|
|
|
|
|
OperateEnabled = "True";
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|