|
|
|
@ -50,6 +50,7 @@ namespace Aucma.Core.PrintTo.ViewModels
|
|
|
|
|
|
|
|
|
|
_orderCode = order_code;
|
|
|
|
|
ProductCode = productCode;
|
|
|
|
|
ProductName = productName;
|
|
|
|
|
//MaterialName = materialName;
|
|
|
|
|
//MaterialCode= materialCode;
|
|
|
|
|
PrintAmount = printAmount;
|
|
|
|
@ -99,6 +100,12 @@ namespace Aucma.Core.PrintTo.ViewModels
|
|
|
|
|
public string ProductCode { get => _productCode; set => SetProperty(ref _productCode, value); }
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 产品名称
|
|
|
|
|
private string _productName;
|
|
|
|
|
|
|
|
|
|
public string ProductName { get => _productName; set => SetProperty(ref _productName, value); }
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 型号简码
|
|
|
|
|
private string _materialName;
|
|
|
|
|
|
|
|
|
@ -193,9 +200,9 @@ namespace Aucma.Core.PrintTo.ViewModels
|
|
|
|
|
{
|
|
|
|
|
isPrint = false;
|
|
|
|
|
// 非阻塞打印
|
|
|
|
|
Task.Run(async () =>
|
|
|
|
|
Task.Run(() =>
|
|
|
|
|
{
|
|
|
|
|
await Print();
|
|
|
|
|
Print();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -253,7 +260,7 @@ namespace Aucma.Core.PrintTo.ViewModels
|
|
|
|
|
tmpList.Clear();
|
|
|
|
|
BaseBomInfo baseBomInfo = null;
|
|
|
|
|
List<BaseBomInfo> orderBomInfoList = await _baseBomInfoServices.QueryAsync();
|
|
|
|
|
if (printType==1)//箱壳
|
|
|
|
|
if (printType== 500)//箱壳
|
|
|
|
|
{
|
|
|
|
|
GetParentID(orderBomInfoList, productCode);
|
|
|
|
|
//OrderBomInfo obj = await _orderBomInfoServices.FirstAsync(d => d.MaterialCode == materialCode);
|
|
|
|
@ -262,7 +269,7 @@ namespace Aucma.Core.PrintTo.ViewModels
|
|
|
|
|
MessageBox.Show("无法查询打印条码数据", "系统提醒");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
baseBomInfo= tmpList.FirstOrDefault(d=>d.MaterialType=="200");
|
|
|
|
|
baseBomInfo= tmpList.FirstOrDefault(d=>d.MaterialType== "600");
|
|
|
|
|
}
|
|
|
|
|
if (printType == 2)//内胆
|
|
|
|
|
{
|
|
|
|
@ -287,7 +294,7 @@ namespace Aucma.Core.PrintTo.ViewModels
|
|
|
|
|
|
|
|
|
|
#region 打印
|
|
|
|
|
|
|
|
|
|
public async Task<bool> Print()
|
|
|
|
|
public void Print()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
@ -308,7 +315,7 @@ namespace Aucma.Core.PrintTo.ViewModels
|
|
|
|
|
string barCode = string.Empty;
|
|
|
|
|
if (_printType== 500)
|
|
|
|
|
{
|
|
|
|
|
string rowNum = await GetMaxNumAsync(item.MaterialCode,"B");//最大值+1
|
|
|
|
|
string rowNum = GetMaxNumAsync(item.MaterialCode,"B").Result;//最大值+1
|
|
|
|
|
barCode = $"B{DateTime.Now.ToString("yyMMdd")}{item.MaterialCode}{rowNum}";
|
|
|
|
|
PrintProgress = $"[{PrintAmount}/{i}] {barCode}";
|
|
|
|
|
printBarCode.MaterialBarcode = barCode;
|
|
|
|
@ -317,7 +324,7 @@ namespace Aucma.Core.PrintTo.ViewModels
|
|
|
|
|
}
|
|
|
|
|
if (_printType == 200)
|
|
|
|
|
{
|
|
|
|
|
string rowNum = await GetMaxNumAsync(item.MaterialCode, "L");//最大值+1
|
|
|
|
|
string rowNum = GetMaxNumAsync(item.MaterialCode, "L").Result;//最大值+1
|
|
|
|
|
barCode = $"L{DateTime.Now.ToString("yyMMdd")}{item.MaterialCode}{rowNum}";
|
|
|
|
|
PrintProgress = $"[{PrintAmount}/{i}] {barCode}";
|
|
|
|
|
printBarCode.MaterialBarcode = barCode;
|
|
|
|
@ -340,7 +347,6 @@ namespace Aucma.Core.PrintTo.ViewModels
|
|
|
|
|
barReport.SetParameterValue("BoxBarData.Order_No", _orderCode);//订单号
|
|
|
|
|
barReport.SetParameterValue("BoxBarData.Order_Material_Name", PrintName);//物料简码
|
|
|
|
|
barReport.SetParameterValue("BoxBarData.Bar_Code", barCode);//二维码
|
|
|
|
|
|
|
|
|
|
//barReport.Prepare();
|
|
|
|
|
//string BarPath = System.Environment.CurrentDirectory + @"\pdf\" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".pdf";
|
|
|
|
|
//barReport.Export(new PDFExport(), BarPath);
|
|
|
|
@ -358,14 +364,18 @@ namespace Aucma.Core.PrintTo.ViewModels
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("条码生成异常");//抛出异常,回滚事务,事务退出
|
|
|
|
|
}
|
|
|
|
|
var num= await _printBarCodeServices.AddAsync(printBarCode);
|
|
|
|
|
var num= _printBarCodeServices.AddAsync(printBarCode).Result;
|
|
|
|
|
if (num<=0)
|
|
|
|
|
{
|
|
|
|
|
ErrorNum++;
|
|
|
|
|
BarcodesPrinted.Enqueue(BarcodesUnprinted.Dequeue());
|
|
|
|
|
Thread.Sleep(1000);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ErrorNum++;
|
|
|
|
|
log.Error($"打印保存出错:{printBarCode.ToJson()}");
|
|
|
|
|
}
|
|
|
|
|
BarcodesPrinted.Enqueue(BarcodesUnprinted.Dequeue());
|
|
|
|
|
Thread.Sleep(1000);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
@ -378,12 +388,11 @@ namespace Aucma.Core.PrintTo.ViewModels
|
|
|
|
|
}
|
|
|
|
|
//打印完成
|
|
|
|
|
SetCompletetd();
|
|
|
|
|
return await Task.FromResult(true);
|
|
|
|
|
Thread.Sleep (3000);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
log.Error($"打印出错:{ex.Message}");
|
|
|
|
|
return await Task.FromResult(false);
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
@ -407,11 +416,12 @@ namespace Aucma.Core.PrintTo.ViewModels
|
|
|
|
|
{
|
|
|
|
|
return "0001";
|
|
|
|
|
}
|
|
|
|
|
list.ForEach(item =>
|
|
|
|
|
foreach (var item in list)
|
|
|
|
|
{
|
|
|
|
|
int num = Convert.ToInt32(item.MaterialBarcode.Substring(item.MaterialBarcode.Length - 1, 4));
|
|
|
|
|
string code = item.MaterialBarcode.Substring(item.MaterialBarcode.Length - 4);
|
|
|
|
|
int num = Convert.ToInt32(code);
|
|
|
|
|
tempList.Add(num);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
string maxStr = (tempList.Max() + 1).ToString();
|
|
|
|
|
string rowNum = maxStr.PadLeft(4, '0');
|
|
|
|
|
return rowNum;
|
|
|
|
|