private string getPrintContentCode(string MFPlansId, string YBBQ) { IPQCRouteCheckHelper ipqc = new IPQCRouteCheckHelper(); DataTable dt = ipqc.GetSteptInfo(MFPlansId); if (dt.Rows.Count > 0) { StringBuilder sb = new StringBuilder(); sb.Append("{\"result\":0,\"msg\":\"获取成功\",\"data\":"); DataRow dr = dt.Rows[0]; IPQCCheckPrintModel model = new IPQCCheckPrintModel(); model.ProductDescribe = Convert.ToString(dr["ProductDescription"]); model.ProductShortName = Convert.ToString(dr["ProductShortName"]); model.POName = Convert.ToString(dr["BillNo"]); model.YBBQ = YBBQ; model.MOName = Convert.ToString(dr["MOName"]); model.SteptName = Convert.ToString(dr["SpecificationName"]); PrintCodeConvert pc = new PrintCodeConvert(); string Msg = pc.GetPrintIPQCRouteCodeConvertStr(model); return("{\"result\":1,\"msg\":\"" + Msg + "\"}"); } else { return("{\"result\":-1,\"msg\":\"获取失败\"}"); } }
//打印IPQC首捡 public string GetPrintIPQCCodeConvertStr(IPQCCheckPrintModel 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(); //设置倍高 result = result.Concat(Encoding.Default.GetBytes("IPQC首检")).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.POName, 12) + "┃物料┃" + CutByteString(PrintData.ProductShortName, 14) + "┃\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.MOName, 12) + "┃工序┃" + CutByteString(PrintData.SteptName, 18) + "┃\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)); } }