//包装-首捡/巡检 public string GetPrintFQCPackCodeConvertStr(FQCPackPrintModel PrintData) { try { byte[] result = new byte[] { }; result = new byte[] { 0x1B, 0x40 }; //打印机复位 result = result.Concat(new byte[] { 0x1B, 0x33, 0x00 }).ToArray(); //设置行间距为0 result = result.Concat(new byte[] { 0x1B, 0x61, 0x01 }).ToArray(); //设置居中 result = result.Concat(new byte[] { 0x1D, 0x21, 0x01 }).ToArray(); //设置倍高 if (PrintData.PackType == "1") { result = result.Concat(Encoding.Default.GetBytes("包装首捡")).ToArray(); } else { result = result.Concat(Encoding.Default.GetBytes("包装巡检")).ToArray(); } result = result.Concat(new byte[] { 0x0D }).ToArray(); //回车并打印 result = result.Concat(new byte[] { 0x1d, 0x48, 0x02 }).ToArray(); //设置02条码内容打印在条码下方 00不打印 result = result.Concat(new byte[] { 0x1D, 0x77, 0x02 }).ToArray(); //设置条码宽度 1 2 3 4 result = result.Concat(new byte[] { 0x1D, 0x68, 0x20 }).ToArray(); //设置条码高度 result = result.Concat(new byte[] { 0x1D, 0x66, 0x00 }).ToArray(); //设置条码字体 result = result.Concat(new byte[] { 0x1D, 0x6B, 0x45, 0x0D }).ToArray(); result = result.Concat(Encoding.Default.GetBytes(PrintData.YBBQ)).ToArray(); string ProductDescribe = CutByteString(PrintData.ProductDescribe, 34); result = result.Concat(new byte[] { 0x1B, 0x61, 0x00 }).ToArray(); //左对齐 result = result.Concat(new byte[] { 0x1B, 0x21, 0x00 }).ToArray(); // 还原默认字体大小,取消下划线,取消粗体模式 result = result.Concat(new byte[] { 0x1d, 0x21, 0x00 }).ToArray(); //设置不倍高 result = result.Concat(Encoding.Default.GetBytes("┏━━┳━━━━━━┳━━┳━━━━━━━━━┓\n")).ToArray(); result = result.Concat(Encoding.Default.GetBytes("┃工单┃" + CutByteString(PrintData.MOName, 12) + "┃物料┃" + CutByteString(PrintData.ProductShortName, 18) + "┃\n")).ToArray(); result = result.Concat(Encoding.Default.GetBytes("┣━━┻━┳━━━━┻━━┻━━━━━━━━━┫\n")).ToArray(); result = result.Concat(Encoding.Default.GetBytes("┃物料描述┃" + ProductDescribe + " ┃\n")).ToArray(); result = result.Concat(Encoding.Default.GetBytes("┣━━━━╋━━━━━━┳━━┳━━━━━━━┫\n")).ToArray(); result = result.Concat(Encoding.Default.GetBytes("┃销售订单┃" + CutByteString(PrintData.BillNo, 12) + "┃行号┃" + CutByteString(PrintData.SteptName, 14) + "┃\n")).ToArray(); result = result.Concat(Encoding.Default.GetBytes("┗━━━━┻━━━━━━┻━━┻━━━━━━━┛\n")).ToArray(); result = result.Concat(new byte[] { 0x1B, 0x61, 0x01 }).ToArray(); //设置居中 result = result.Concat(new byte[] { 0x1D, 0x21, 0x01 }).ToArray(); //设置倍高 result = result.Concat(Encoding.Default.GetBytes("打印日期:" + DateTime.Now.ToString("yyyy-MM-dd") + " \n\n\n")).ToArray(); return(Convert.ToBase64String(result)); } catch (Exception) { byte[] result = new byte[] { }; result = result.Concat(Encoding.Default.GetBytes("打印发生意外,请联系管理员")).ToArray(); return(Convert.ToBase64String(result)); } }
/// <summary> /// /// </summary> /// <param name="MFPlansId"></param> /// <param name="YBBQ"></param> /// <returns></returns> private string getPrintContentCode(string YBBQ) { FQCCheckPackHelper ipqc = new FQCCheckPackHelper(); string FQCCheckId = ipqc.GetFQCCheclIdByScanSn(YBBQ); if (string.IsNullOrEmpty(FQCCheckId)) { return("{\"result\":-1,\"msg\":\"生成标签失败\"}"); } DataTable dt = ipqc.getFQCCheckDataByFQCCheckId(FQCCheckId); if (dt.Rows.Count > 0) { DataRow dr = dt.Rows[0]; FQCPackPrintModel model = new FQCPackPrintModel(); model.ProductDescribe = Convert.ToString(dr["ProductDescription"]); model.ProductShortName = Convert.ToString(dr["ProductShortName"]); model.BillNo = Convert.ToString(dr["BillNo"]); model.LineNo = Convert.ToString(dr["SOEntry"]); model.YBBQ = YBBQ; model.MOName = Convert.ToString(dr["MOName"]); model.SteptName = Convert.ToString(dr["SpecificationName"]); model.PackType = Convert.ToString(dr["CheckType"]); PrintCodeConvert pc = new PrintCodeConvert(); string Msg = pc.GetPrintFQCPackCodeConvertStr(model); return("{\"result\":0,\"msg\":\"" + Msg + "\"}"); } else { return("{\"result\":-1,\"msg\":\"获取失败\"}"); } }