using BWP.WinFormControl;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using BO.Utils;
|
|
using BO.Utils.BillRpc;
|
|
using BO.BO.Bill;
|
|
using System.IO;
|
|
|
|
namespace WeighAndGrading
|
|
{
|
|
public static class WeightGradePrint
|
|
{
|
|
public static PrintEntity CreatePrintEntity(DateTime date, GradeAndWeight_Detail detail)
|
|
{
|
|
string goodsName;
|
|
if (detail.Technics_Name == "烫褪")
|
|
{
|
|
goodsName = "带皮白条"; //"带皮白条";
|
|
}
|
|
else
|
|
{
|
|
goodsName = "去皮白条"; //"去皮白条";
|
|
}
|
|
var entity = new PrintEntity();
|
|
entity.AccountingUnit_Name = "青岛万福集团股份有限公司";
|
|
entity.Goods_Name = goodsName;
|
|
entity.Date = date;
|
|
entity.Checker = "";
|
|
entity.StoreCondition = "0-4℃";
|
|
entity.Place = "青岛莱西市";
|
|
entity.TelNumber = "0532-88488888";
|
|
if (string.IsNullOrWhiteSpace(detail.BarCode))
|
|
{
|
|
// int order = LocalGradeAndWeightBL.GetOrderIndex(date, detail);
|
|
// if (add)
|
|
// order += 1;
|
|
entity.BarCode = string.Format("260912011{0:yyyyMMdd}{1:000}{2:000}", entity.Date, detail.Order, detail.OrderIndex);
|
|
}
|
|
else
|
|
{
|
|
entity.BarCode = detail.BarCode;
|
|
}
|
|
entity._2DQRCode = string.Format(ButcherAppContext.Context.UrlConfig.OutAddress + "?code={0}", entity.BarCode);
|
|
return entity;
|
|
}
|
|
|
|
static int id = 1;
|
|
public static void Print(PrintEntity entity)
|
|
{
|
|
var dic = new Dictionary<string, string>();
|
|
dic.Add("$Goods_Name", entity.Goods_Name);
|
|
dic.Add("$Date", entity.Date.ToString("yyyy/MM/dd"));
|
|
var imgUrl = string.Format("TempImg\\_img{0}.png", id);
|
|
try
|
|
{
|
|
BwpClientPrint.BwpClientWebPrint.Create2DPic(entity._2DQRCode, imgUrl, 100);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
var name = string.Format("saveError{0:yyyyMMdd}.log", DateTime.Today);
|
|
if (!File.Exists(name))
|
|
File.Create(name);
|
|
File.AppendAllText(name, ex.Message);
|
|
throw;
|
|
}
|
|
dic.Add("$ImageUrl", imgUrl);
|
|
BwpClientPrint.BwpClientWebPrint.Print("GradeWeightPrint.html", dic);
|
|
if (id == 30)
|
|
id = 0;
|
|
id++;
|
|
AfterPrint();
|
|
}
|
|
|
|
static DirectoryInfo TempImage = null;
|
|
private static void AfterPrint()
|
|
{
|
|
if (TempImage == null)
|
|
TempImage = new DirectoryInfo("TempImg");
|
|
var files = TempImage.GetFiles();
|
|
if (files.Length > 20)
|
|
{
|
|
var last = files.OrderBy(x => x.CreationTime).First().FullName;
|
|
File.Delete(last);
|
|
}
|
|
}
|
|
}
|
|
|
|
public class PrintEntity
|
|
{
|
|
public string AccountingUnit_Name { get; set; }
|
|
|
|
public string Goods_Name { get; set; }
|
|
|
|
public DateTime Date { get; set; }
|
|
|
|
public string Checker { get; set; }
|
|
|
|
public string StoreCondition { get; set; }
|
|
|
|
public string Place { get; set; }
|
|
|
|
public string TelNumber { get; set; }
|
|
|
|
public string Address { get; set; }
|
|
|
|
public string BarCode { get; set; }
|
|
|
|
public string _2DQRCode { get; set; }
|
|
}
|
|
}
|