记得上下班打卡 | git大法好,push需谨慎

Commit 6690db6a authored by jiangxiulong's avatar jiangxiulong

打印

parent 0d351c23
//package com.liquidnet.client.admin.web.controller.zhengzai.kylin;
//
//import org.apache.commons.io.IOUtils;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//
//import java.io.FileInputStream;
//import java.io.IOException;
//
//import javax.print.Doc;
//import javax.print.DocFlavor;
//import javax.print.DocPrintJob;
//import javax.print.PrintException;
//import javax.print.PrintService;
//import javax.print.PrintServiceLookup;
//import javax.print.SimpleDoc;
//import javax.print.attribute.DocAttributeSet;
//import javax.print.attribute.HashDocAttributeSet;
//import javax.print.attribute.HashPrintRequestAttributeSet;
//import javax.print.attribute.PrintRequestAttributeSet;
//import javax.print.attribute.standard.Copies;
//import javax.print.attribute.standard.MediaPrintableArea;
//import javax.print.attribute.standard.OrientationRequested;
//import javax.print.attribute.standard.PrintQuality;
//
//import java.awt.Color;
//import java.awt.Graphics;
//import java.awt.image.BufferedImage;
//import java.io.File;
//import java.io.FileOutputStream;
//import java.io.OutputStream;
//import java.util.ArrayList;
//import java.util.List;
//
//
//import com.sun.image.codec.jpeg.JPEGCodec;
//import com.sun.image.codec.jpeg.JPEGImageEncoder;
//
///**
// * <p>
// * xx 服务实现类
// * </p>
// *
// * @author jiangxiulong
// * @since 2021-07-05 7:50 下午
// */
//public class ExpressPrintController {
// private static final Logger logger = LoggerFactory.getLogger(ExpressPrintController.class);
//
// private int m_nImageHeight = 40; // 条码的高度像素数
//
// String[][] code128 = {{" ", " ", "00", "212222", "11011001100"},
// {"!", "!", "01", "222122", "11001101100"},
// {"\"", "\"", "02", "222221", "11001100110"},
// {"#", "#", "03", "121223", "10010011000"},
// {"$", "$", "04", "121322", "10010001100"},
// {"%", "%", "05", "131222", "10001001100"},
// {"&", "&", "06", "122213", "10011001000"},
// {"'", "'", "07", "122312", "10011000100",},
// {"(", "(", "08", "132212", "10001100100"},
// {")", ")", "09", "221213", "11001001000"},
// {"*", "*", "10", "221312", "11001000100"},
// {"+", "+", "11", "231212", "11000100100"},
// {",", ",", "12", "112232", "10110011100"},
// {"-", "-", "13", "122132", "10011011100"},
// {".", ".", "14", "122231", "10011001110"},
// {"/", "/", "15", "113222", "10111001100"},
// {"0", "0", "16", "123122", "10011101100"},
// {"1", "1", "17", "123221", "10011100110"},
// {"2", "2", "18", "223211", "11001110010",},
// {"3", "3", "19", "221132", "11001011100"},
// {"4", "4", "20", "221231", "11001001110",},
// {"5", "5", "21", "213212", "11011100100"},
// {"6", "6", "22", "223112", "11001110100"},
// {"7", "7", "23", "312131", "11101101110"},
// {"8", "8", "24", "311222", "11101001100"},
// {"9", "9", "25", "321122", "11100101100"},
// {":", ":", "26", "321221", "11100100110"},
// {";", ";", "27", "312212", "11101100100"},
// {"<", "<", "28", "322112", "11100110100"},
// {"=", "=", "29", "322211", "11100110010"},
// {">", ">", "30", "212123", "11011011000"},
// {"?", "?", "31", "212321", "11011000110"},
// {"@", "@", "32", "232121", "11000110110"},
// {"A", "A", "33", "111323", "10100011000"},
// {"B", "B", "34", "131123", "10001011000"},
// {"C", "C", "35", "131321", "10001000110"},
// {"D", "D", "36", "112313", "10110001000"},
// {"E", "E", "37", "132113", "10001101000"},
// {"F", "F", "38", "132311", "10001100010"},
// {"G", "G", "39", "211313", "11010001000"},
// {"H", "H", "40", "231113", "11000101000"},
// {"I", "I", "41", "231311", "11000100010"},
// {"J", "J", "42", "112133", "10110111000"},
// {"K", "K", "43", "112331", "10110001110"},
// {"L", "L", "44", "132131", "10001101110"},
// {"M", "M", "45", "113123", "10111011000"},
// {"N", "N", "46", "113321", "10111000110"},
// {"O", "O", "47", "133121", "10001110110"},
// {"P", "P", "48", "313121", "11101110110"},
// {"Q", "Q", "49", "211331", "11010001110"},
// {"R", "R", "50", "231131", "11000101110"},
// {"S", "S", "51", "213113", "11011101000"},
// {"T", "T", "52", "213311", "11011100010"},
// {"U", "U", "53", "213131", "11011101110"},
// {"V", "V", "54", "311123", "11101011000"},
// {"W", "W", "55", "311321", "11101000110"},
// {"X", "X", "56", "331121", "11100010110"},
// {"Y", "Y", "57", "312113", "11101101000"},
// {"Z", "Z", "58", "312311", "11101100010"},
// {"[", "[", "59", "332111", "11100011010"},
// {"\\", "\\", "60", "314111", "11101111010"},
// {"]", "]", "61", "221411", "11001000010"},
// {"^", "^", "62", "431111", "11110001010"},
// {"_", "_", "63", "111224", "10100110000"},
// {"NUL", "`", "64", "111422", "10100001100"},
// {"SOH", "a", "65", "121124", "10010110000"},
// {"STX", "b", "66", "121421", "10010000110"},
// {"ETX", "c", "67", "141122", "10000101100"},
// {"EOT", "d", "68", "141221", "10000100110"},
// {"ENQ", "e", "69", "112214", "10110010000"},
// {"ACK", "f", "70", "112412", "10110000100"},
// {"BEL", "g", "71", "122114", "10011010000"},
// {"BS", "h", "72", "122411", "10011000010"},
// {"HT", "i", "73", "142112", "10000110100"},
// {"LF", "j", "74", "142211", "10000110010"},
// {"VT", "k", "75", "241211", "11000010010"},
// {"FF", "I", "76", "221114", "11001010000"},
// {"CR", "m", "77", "413111", "11110111010"},
// {"SO", "n", "78", "241112", "11000010100"},
// {"SI", "o", "79", "134111", "10001111010"},
// {"DLE", "p", "80", "111242", "10100111100"},
// {"DC1", "q", "81", "121142", "10010111100"},
// {"DC2", "r", "82", "121241", "10010011110"},
// {"DC3", "s", "83", "114212", "10111100100"},
// {"DC4", "t", "84", "124112", "10011110100"},
// {"NAK", "u", "85", "124211", "10011110010"},
// {"SYN", "v", "86", "411212", "11110100100"},
// {"ETB", "w", "87", "421112", "11110010100"},
// {"CAN", "x", "88", "421211", "11110010010"},
// {"EM", "y", "89", "212141", "11011011110"},
// {"SUB", "z", "90", "214121", "11011110110"},
// {"ESC", "{", "91", "412121", "11110110110"},
// {"FS", "|", "92", "111143", "10101111000"},
// {"GS", "},", "93", "111341", "10100011110"},
// {"RS", "~", "94", "131141", "10001011110"},
// {"US", "DEL", "95", "114113", "10111101000"},
// {"FNC3", "FNC3", "96", "114311", "10111100010"},
// {"FNC2", "FNC2", "97", "411113", "11110101000"},
// {"SHIFT", "SHIFT", "98", "411311", "11110100010"},
// {"CODEC", "CODEC", "99", "113141", "10111011110"},
// {"CODEB", "FNC4", "CODEB", "114131", "10111101110"},
// {"FNC4", "CODEA", "CODEA", "311141", "11101011110"},
// {"FNC1", "FNC1", "FNC1", "411131", "11110101110"},
// {"StartA", "StartA", "StartA", "211412", "11010000100"},
// {"StartB", "StartB", "StartB", "211214", "11010010000"},
// {"StartC", "StartC", "StartC", "211232", "11010011100"},
// {"Stop", "Stop", "Stop", "2331112", "1100011101011"},};
//
// /**
// * 打印图片
// *
// * @param fileName
// * @param count
// */
// public static void drawImage(String fileName, int count) {
// FileInputStream fin = null;
// try {
// DocFlavor dof = null;
// if (fileName.endsWith(".gif")) {
// dof = DocFlavor.INPUT_STREAM.GIF;
// } else if (fileName.endsWith(".jpg")) {
// dof = DocFlavor.INPUT_STREAM.JPEG;
// } else if (fileName.endsWith(".png")) {
// dof = DocFlavor.INPUT_STREAM.PNG;
// }
//
// PrintService ps = PrintServiceLookup.lookupDefaultPrintService();
//
// PrintRequestAttributeSet pras = new HashPrintRequestAttributeSet();
// pras.add(OrientationRequested.PORTRAIT);
//
// pras.add(new Copies(count));
// pras.add(PrintQuality.HIGH);
// DocAttributeSet das = new HashDocAttributeSet();
//
// // 设置打印纸张的大小(以毫米为单位)
// das.add(new MediaPrintableArea(0, 0, 210, 296, MediaPrintableArea.MM));
// fin = new FileInputStream(fileName);
//
// Doc doc = new SimpleDoc(fin, dof, das);
//
// DocPrintJob job = ps.createPrintJob();
//
// job.print(doc, pras);
// fin.close();
// logger.info("打印成功!文件:" + fileName + "数量为:" + count);
// } catch (IOException ie) {
// ie.printStackTrace();
// } catch (PrintException pe) {
// pe.printStackTrace();
// } finally {
// IOUtils.closeQuietly(fin);
// }
// }
//
// /**
// * 生产Code128的条形码的code
// *
// * @param barCode
// * @param encode
// * @return
// */
// public String getCode(String barCode, String encode) {
// String _Text = "";// 返回的参数
// List<Integer> _TextNumb = new ArrayList<Integer>();// 2截取位的组合
// int _Examine = 105; // 首位
// // 编码不能是奇数
// if (!((barCode.length() & 1) == 0))
// return "";
// while (barCode.length() != 0) {
// int _Temp = 0;
// try {
// // Code128 编码必须为数字
// _Temp = Integer.valueOf(barCode.substring(0, 2));
// } catch (Exception e) {
// e.printStackTrace();
// return "";
// }
// // 获得条纹
// _Text += getValue(barCode, barCode.substring(0, 2), _Temp);
// _TextNumb.add(_Temp);
// // 条码截取2个就需要去掉用过的前二位
// barCode = barCode.substring(2);
// }
// if (_TextNumb.size() == 0) {
// return "";
// }
// _Text = getValue(_Examine) + _Text; // 获取开始位
// for (int i = 0; i != _TextNumb.size(); i++) {
// _Examine += _TextNumb.get(i) * (i + 1);
// }
// _Examine = _Examine % 103; // 获得校验位
// _Text += getValue(_Examine); // 获取校验位
// _Text += "1100011101011"; // 结束位
// return _Text;
// }
//
// /**
// * 根据编号获得条纹
// *
// * @param encode
// * @param p_Value
// * @param p_SetID
// * @return
// */
// private String getValue(String encode, String p_Value, int p_SetID) {
// return code128[p_SetID][4];
// }
//
// /**
// * 根据编号获得条纹
// * @param p_CodeId
// * @return
// */
// private String getValue(int p_CodeId) {
// return code128[p_CodeId][4];
// }
//
// /**
// * 生成条码
// * @param barString 条码模式字符串
// * @param Height 生成的条码高度
// * @param path 条码图形
// */
// public void kiCode128C(String barString, int Height, String path) {
// try {
// File myPNG = new File(path);
// OutputStream out = new FileOutputStream(myPNG);
// if (null == barString || null == out || 0 == barString.length())
// return;
// int nImageWidth = 0;
// char[] cs = barString.toCharArray();
// for (int i = 0; i != cs.length; i++) {
// nImageWidth = cs.length;
// }
// BufferedImage bi = new BufferedImage(nImageWidth, m_nImageHeight,
// BufferedImage.TYPE_INT_RGB);
// Graphics g = bi.getGraphics();
// for (int i = 0; i < cs.length; i++) {
// if ("1".equals(cs[i] + "")) {
// g.setColor(Color.BLACK);
// g.fillRect(i, 0, 1, m_nImageHeight);
// } else {
// g.setColor(Color.WHITE);
// g.fillRect(i, 0, 1, m_nImageHeight);
// }
// }
// JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
// encoder.encode(bi);
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
//
// /**
// * test
// *
// * @param args
// */
// public static void main(String[] args) {
// // 打印图片
// // new ExpressPrintController().drawImage("/Users/jiangxiulong/Desktop/图片余篇图片/WX20210705-200856@2x.png", 1);
// // 生成条形码
// String barCode = new ExpressPrintController().getCode("118842807789", "");
// new ExpressPrintController().kiCode128C(barCode, 50, "/Users/jiangxiulong/Desktop/图片余篇图片/code128C.jpg");
// // 生成二维码
// }
//
//}
package com.liquidnet.client.admin.web.controller.zhengzai.kylin;
import org.apache.commons.io.IOUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.FileInputStream;
import java.io.IOException;
import javax.print.Doc;
import javax.print.DocFlavor;
import javax.print.DocPrintJob;
import javax.print.PrintException;
import javax.print.PrintService;
import javax.print.PrintServiceLookup;
import javax.print.SimpleDoc;
import javax.print.attribute.DocAttributeSet;
import javax.print.attribute.HashDocAttributeSet;
import javax.print.attribute.HashPrintRequestAttributeSet;
import javax.print.attribute.PrintRequestAttributeSet;
import javax.print.attribute.standard.Copies;
import javax.print.attribute.standard.MediaPrintableArea;
import javax.print.attribute.standard.OrientationRequested;
import javax.print.attribute.standard.PrintQuality;
/**
* <p>
* xx 服务实现类
* </p>
*
* @author jiangxiulong
* @since 2021-07-05 7:50 下午
*/
public class ExpressPrintController {
private static final Logger logger = LoggerFactory.getLogger(ExpressPrintController.class);
/**
* 打印图片
*
* @param fileName
* @param count
*/
public static void drawImage(String fileName, int count) {
FileInputStream fin = null;
try {
DocFlavor dof = null;
if (fileName.endsWith(".gif")) {
dof = DocFlavor.INPUT_STREAM.GIF;
} else if (fileName.endsWith(".jpg")) {
dof = DocFlavor.INPUT_STREAM.JPEG;
} else if (fileName.endsWith(".png")) {
dof = DocFlavor.INPUT_STREAM.PNG;
}
PrintService ps = PrintServiceLookup.lookupDefaultPrintService();
PrintRequestAttributeSet pras = new HashPrintRequestAttributeSet();
pras.add(OrientationRequested.PORTRAIT);
pras.add(new Copies(count));
pras.add(PrintQuality.HIGH);
DocAttributeSet das = new HashDocAttributeSet();
// 设置打印纸张的大小(以毫米为单位)
das.add(new MediaPrintableArea(0, 0, 210, 296, MediaPrintableArea.MM));
fin = new FileInputStream(fileName);
Doc doc = new SimpleDoc(fin, dof, das);
DocPrintJob job = ps.createPrintJob();
job.print(doc, pras);
fin.close();
logger.info("打印成功!文件:" + fileName + "数量为:" + count);
} catch (IOException ie) {
ie.printStackTrace();
} catch (PrintException pe) {
pe.printStackTrace();
} finally {
IOUtils.closeQuietly(fin);
}
}
/**
* test
*
* @param args
*/
public static void main(String[] args) {
// 打印图片
// new ExpressPrintController().drawImage("/Users/jiangxiulong/Desktop/图片余篇图片/WX20210705-200856@2x.png", 1);
}
}
......@@ -228,4 +228,21 @@ public class PerformancesExpressController extends BaseController {
}
}
/**
* 打印快递单
*/
@RequiresPermissions("kylin:performancesExpress:print")
@PostMapping("/print")
@ResponseBody
// public AjaxResult print(@RequestParam("ids") String performanceId) {
public AjaxResult print() {
try {
// performancesExpressServiceImpl.batchCancelOrder(performanceId);
performancesExpressServiceImpl.print();
return success();
} catch (Exception e) {
return error(e.getMessage());
}
}
}
......@@ -39,6 +39,7 @@
var performanceOrderListFlag = [[${@permission.hasPermi('kylin:performancesExpress:performanceOrderList')}]];
var batchPlaceOrderFlag = [[${@permission.hasPermi('kylin:performancesExpress:batchPlaceOrder')}]];
var batchCancelOrderFlag = [[${@permission.hasPermi('kylin:performancesExpress:batchCancelOrder')}]];
var printFlag = [[${@permission.hasPermi('kylin:performancesExpress:print')}]];
var prefix = ctx + "kylin/performancesExpress";
$(function () {
......@@ -47,6 +48,7 @@
detailUrl: prefix + "/performanceOrderList/{id}",
batchPlaceOrderUrl: prefix + "/batchPlaceOrder",
batchCancelOrderUrl: prefix + "/batchCancelOrder",
printUrl: prefix + "/print",
modalName: "演出快递",
columns: [
{
......@@ -85,6 +87,7 @@
actions.push('<a class="btn btn-success btn-xs ' + performanceOrderListFlag + '" href="javascript:void(0)" onclick="$.operate.detailTab(\'' + row.performancesId + '\')"><i class="fa fa-edit"></i>查看</a> ');
actions.push('<a class="btn btn-danger btn-xs ' + batchPlaceOrderFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.performancesId + '\', \'确定批量下单吗?\', table.options.batchPlaceOrderUrl)"></i>下单</a> ');
actions.push('<a class="btn btn-warning btn-xs ' + batchCancelOrderFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.performancesId + '\', \'确定批量取消吗?\', table.options.batchCancelOrderUrl)"></i>取消</a> ');
actions.push('<a class="btn btn-warning btn-xs ' + printFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.performancesId + '\', \'确定批量打印吗?\', table.options.printUrl)"></i>打印</a> ');
return actions.join('');
}
}]
......
......@@ -70,6 +70,31 @@
<artifactId>json</artifactId>
<version>20090211</version>
</dependency>
<dependency>
<groupId>gui.ava</groupId>
<artifactId>html2image</artifactId>
<version>2.0.1</version>
<exclusions>
<exclusion>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
</exclusion>
<exclusion>
<groupId>net.sourceforge.nekohtml</groupId>
<artifactId>nekohtml</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.syncthemall</groupId>
<artifactId>boilerpipe</artifactId>
<version>1.2.1</version>
</dependency>
<dependency>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
<version>1.4.01</version>
</dependency>
</dependencies>
</project>
\ No newline at end of file
package com.liquidnet.client.admin.zhengzai.admin.service.impl.utils;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.EncodeHintType;
import com.google.zxing.MultiFormatWriter;
import com.google.zxing.client.j2se.MatrixToImageWriter;
import com.google.zxing.common.BitMatrix;
import com.google.zxing.oned.Code128Writer;
import com.google.zxing.qrcode.QRCodeWriter;
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
import gui.ava.html.Html2Image;
import org.apache.commons.io.IOUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import javax.imageio.ImageIO;
import javax.print.*;
import javax.print.attribute.DocAttributeSet;
import javax.print.attribute.HashDocAttributeSet;
import javax.print.attribute.HashPrintRequestAttributeSet;
import javax.print.attribute.PrintRequestAttributeSet;
import javax.print.attribute.standard.Copies;
import javax.print.attribute.standard.MediaPrintableArea;
import javax.print.attribute.standard.OrientationRequested;
import javax.print.attribute.standard.PrintQuality;
import javax.servlet.ServletOutputStream;
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
/**
* <p>
* xx 服务实现类
* </p>
*
* @author jiangxiulong
* @since 2021-07-15 6:57 下午
*/
@Component
public class CodeUtil {
private static final Logger logger = LoggerFactory.getLogger(CodeUtil.class);
public static String getQRCode(String content, int width, int height) {
if (!StringUtils.isEmpty(content)) {
ServletOutputStream stream = null;
HashMap<EncodeHintType, Comparable> hints = new HashMap<>();
hints.put(EncodeHintType.CHARACTER_SET, "utf-8");
hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.H);
hints.put(EncodeHintType.MARGIN, 0);
try {
QRCodeWriter writer = new QRCodeWriter();
BitMatrix bitMatrix = writer.encode(content, BarcodeFormat.QR_CODE, width, height, hints);
BufferedImage bufferedImage = MatrixToImageWriter.toBufferedImage(bitMatrix);
ByteArrayOutputStream os = new ByteArrayOutputStream();
// ImageIO.write(bufferedImage, "png", os);
String htmlPath = System.getProperty("user.dir").concat("/liquidnet-bus-client/liquidnet-client-admin/liquidnet-client-admin-zhengzai/src/main/java/com/liquidnet/client/admin/zhengzai/admin/service/impl/utils/tmphtml/qrcode/out.png");
ImageIO.write(bufferedImage, "png", new File(htmlPath));
return htmlPath;
// BASE64Encoder encoder = new BASE64Encoder();
// String resultImage = new String("data:image/png;base64," + encoder.encode(os.toByteArray()));
//
// return resultImage;
} catch (Exception e) {
} finally {
if (stream != null) {
try {
stream.flush();
stream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
return null;
}
public static String getBarCode(String content, int width, int height) {
try {
Map<EncodeHintType, Object> hints = new HashMap<>();
hints.put(EncodeHintType.CHARACTER_SET, "utf-8");
hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.H);
hints.put(EncodeHintType.MARGIN, 0);
int realWidth = getBarCodeNoPaddingWidth(width, content, width);
BitMatrix bitMatrix = new MultiFormatWriter().encode(content, BarcodeFormat.CODE_128, realWidth, height, hints);
BufferedImage bufferedImage = MatrixToImageWriter.toBufferedImage(bitMatrix);
ByteArrayOutputStream os = new ByteArrayOutputStream();
// ImageIO.write(bufferedImage, "png", os);
String htmlPath = System.getProperty("user.dir").concat("/liquidnet-bus-client/liquidnet-client-admin/liquidnet-client-admin-zhengzai/src/main/java/com/liquidnet/client/admin/zhengzai/admin/service/impl/utils/tmphtml/qrcode/out1.png");
ImageIO.write(bufferedImage, "png", new File(htmlPath));
return htmlPath;
// BASE64Encoder encoder = new BASE64Encoder();
// String resultImage = new String("data:image/png;base64," + encoder.encode(os.toByteArray()));
// return resultImage;
} catch (Exception e) {
return null;
}
}
/**
* 打印图片
*
* @param fileName
* @param count
*/
public static void drawImage(String fileName, int count) {
FileInputStream fin = null;
try {
DocFlavor dof = null;
if (fileName.endsWith(".gif")) {
dof = DocFlavor.INPUT_STREAM.GIF;
} else if (fileName.endsWith(".jpg")) {
dof = DocFlavor.INPUT_STREAM.JPEG;
} else if (fileName.endsWith(".png")) {
dof = DocFlavor.INPUT_STREAM.PNG;
}
PrintService ps = PrintServiceLookup.lookupDefaultPrintService();
PrintRequestAttributeSet pras = new HashPrintRequestAttributeSet();
pras.add(OrientationRequested.PORTRAIT);
pras.add(new Copies(count));
pras.add(PrintQuality.HIGH);
DocAttributeSet das = new HashDocAttributeSet();
// 设置打印纸张的大小(以毫米为单位)
das.add(new MediaPrintableArea(0, 0, 210, 296, MediaPrintableArea.MM));
fin = new FileInputStream(fileName);
Doc doc = new SimpleDoc(fin, dof, das);
DocPrintJob job = ps.createPrintJob();
job.print(doc, pras);
fin.close();
logger.info("打印成功!文件:" + fileName + "数量为:" + count);
} catch (IOException ie) {
ie.printStackTrace();
} catch (PrintException pe) {
pe.printStackTrace();
} finally {
IOUtils.closeQuietly(fin);
}
}
public static int getBarCodeNoPaddingWidth(int expectWidth, String contents, int maxWidth) {
boolean[] code = new Code128Writer().encode(contents);
int inputWidth = code.length;
double outputWidth = (double) Math.max(expectWidth, inputWidth);
double multiple = outputWidth / inputWidth;
//优先取大的
int returnVal = 0;
int ceil = (int) Math.ceil(multiple);
if (inputWidth * ceil <= maxWidth) {
returnVal = inputWidth * ceil;
} else {
int floor = (int) Math.floor(multiple);
returnVal = inputWidth * floor;
}
return returnVal;
}
// public static void html2img(String htmlstr)
public static void html2img()
{
String qrCode = getQRCode("2453657424", 25, 25);
System.out.println(qrCode);
String barCode = getBarCode("2453657424", 90, 13);
System.out.println(barCode);
String htmlPath = System.getProperty("user.dir").concat("/liquidnet-bus-client/liquidnet-client-admin/liquidnet-client-admin-zhengzai/src/main/java/com/liquidnet/client/admin/zhengzai/admin/service/impl/utils/tmphtml/shunfeng1.html");
// String replaceStr = htmlPath.replace("images/yiweima.png", barCode);
// String replace = replaceStr.replace("images/erweima.png", qrCode);
String html = "<!DOCTYPE html>\n" +
"<html lang=\"en\">\n" +
"<head>\n" +
"\t<meta charset=\"utf-8\">\n" +
"\t<meta name=\"renderer\" content=\"webkit\">\n" +
"\t<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\">\n" +
"\t<meta http-equiv=\"Cache-Control\" content=\"no-transform\">\n" +
"\t<meta http-equiv=\"Access-Control-Allow-Origin\" content=\"*\" />\n" +
"\t<meta content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0\" name=\"viewport\">\n" +
"\t<meta name=\"apple-mobile-web-app-capable\" content=\"yes\" />\n" +
"\t<meta name=\"apple-mobile-web-app-status-bar-style\" content=\"black\" />\n" +
"\t<meta name=\"format-detection\" content=\"telephone=yes\" /><!-- 点击链接打电话 -->\n" +
"\t<meta name=\"format-detection\" content=\"address=no\" />\n" +
"\t<meta name=\"keywords\" content=\"\">\n" +
"\t<meta name=\"description\" content=\"\">\n" +
"\t<link rel=\"icon\" type=\"image/png\" sizes=\"12x12\" href=\"https://img.zhengzai.tv/static/img/logo_small.png\">\n" +
"</head>\n" +
"<body>\n" +
"\t<!-- 顺丰快递面单打印,尺寸:100mm*150mm模版 -->\n" +
"\t<div\n" +
"\t\tid=\"shunfeng-express\"\n" +
"\t\tstyle=\"width: 96mm;\n" +
"\t\t\theight: 150mm;\n" +
"\t\t\tpadding-top: 5mm;\n" +
"\t\t\tborder: 1px solid #000;\n" +
"\t\t\ttext-align: center;\"\n" +
"\t>\n" +
"\t\t<!-- 1. 运单打印系统来源及时间等 -->\n" +
"\t\t<div \n" +
"\t\t\tclass=\"sourceAndPrintTime\"\n" +
"\t\t\tstyle=\"width: 100%;\n" +
"\t\t\t\tfont-family: 宋体;\n" +
"\t\t\t\tfont-size: 4pt;\n" +
"\t\t\t\tdisplay: flex;\n" +
"\t\t\t\tflex-direction: row;\n" +
"\t\t\t\tjustify-content: space-between;\n" +
"\t\t\t\talign-items: flex-end;\"\n" +
"\t\t>\n" +
"\t\t\t<!-- 1.1 打印系统来源(太长放不下了,所以去掉了) -->\n" +
"\t\t\t<!-- <div class=\"source\">\n" +
"\t\t\t\tSCP顺丰云打印\n" +
"\t\t\t</div> -->\n" +
"\t\t\t<!-- 1.2 打印次数/时间 -->\n" +
"\t\t\t<div\n" +
"\t\t\t\tclass=\"printTime\"\n" +
"\t\t\t\tstyle=\"width: 80%;\n" +
"\t\t\t\t\tfont-family: 宋体;\n" +
"\t\t\t\t\tfont-size: 4pt;\n" +
"\t\t\t\t\tdisplay: flex;\n" +
"\t\t\t\t\tflex-direction: row;\n" +
"\t\t\t\t\tjustify-content: center;\n" +
"\t\t\t\t\talign-items: flex-end;\"\n" +
"\t\t\t>\n" +
"\t\t\t\t第一次打印 2020-05-05 12:00 第8/10个\n" +
"\t\t\t</div>\n" +
"\t\t\t<!-- 3 时效类型 -->\n" +
"\t\t\t<div\n" +
"\t\t\t\tclass=\"timeOfDeliveryType\"\n" +
"\t\t\t\tstyle=\"font-family: 黑体;\n" +
"\t\t\t\t\tfont-size: 18pt;\n" +
"\t\t\t\t\tfont-weight: bolder;\n" +
"\t\t\t\t\tmargin-right: 2mm;\"\n" +
"\t\t\t>\n" +
"\t\t\t\t<!-- 3.1 特快即日、特快A、特快、标快、标快陆运、特惠、电商标快 -->\n" +
"\t\t\t\t特快\n" +
"\t\t\t</div>\n" +
"\t\t</div>\n" +
"\n" +
"\n" +
"\t\t<!-- 2. 条码区 -->\n" +
"\t\t<div class=\"barCodeArea\">\n" +
"\t\t\t<!-- 2.1 条码 -->\n" +
"\t\t\t<div class=\"barCode\">\n" +
"\t\t\t\t<img src=\"/usr/local/var/www/liquidnet-bus-v1/liquidnet-bus-client/liquidnet-client-admin/liquidnet-client-admin-zhengzai/src/main/java/com/liquidnet/client/admin/zhengzai/admin/service/impl/utils/tmphtml/qrcode/out1.png\" style=\"width: 90%; height: 13mm; margin: 0 5mm;\">\n" +
"\t\t\t</div>\n" +
"\t\t\t<!-- 2.2 子母件单号、汉字、件数标识、 -->\n" +
"\t\t\t<div\n" +
"\t\t\t\tclass=\"childAndParentParts\"\n" +
"\t\t\t\tstyle=\"font-family: 黑体;\n" +
"\t\t\t\t\tfont-size: 10pt;\n" +
"\t\t\t\t\tdisplay: flex;\n" +
"\t\t\t\t\tflex-direction: column;\"\n" +
"\t\t\t>\n" +
"\t\t\t\t<div>\n" +
"\t\t\t\t\t子单号:SF1 010 874 393 776\n" +
"\t\t\t\t</div>\n" +
"\t\t\t\t<div>\n" +
"\t\t\t\t\t母单号:SF1 010 874 393 776\n" +
"\t\t\t\t</div>\n" +
"\t\t\t</div>\n" +
"\t\t</div>\n" +
"\n" +
"\t\t<!-- 4\t目的地 -->\n" +
"\t\t<!-- 4.1 路由信息 暂无-->\n" +
"\t\t<div \n" +
"\t\t\tclass=\"destinationArea\"\n" +
"\t\t\tstyle=\"margin: 0 auto;\n" +
"\t\t\t\tborder: 1px solid #000;\n" +
"\t\t\t\tborder-bottom: none;\n" +
"\t\t\t\twidth: 92mm;\"\n" +
"\t\t>\n" +
"\t\t\t<!-- 2.3 运单号 -->\n" +
"\t\t\t<div\n" +
"\t\t\t\tclass=\"expressNumber\"\n" +
"\t\t\t\tstyle=\"font-size: 22pt; font-weight: bold;\"\n" +
"\t\t\t>\n" +
"\t\t\t\t755W-BA-0123456789\n" +
"\t\t\t</div>\n" +
"\t\t\t<!-- 5\t收方信息 -->\t\n" +
"\t\t\t<div class=\"destinationInfo\" style=\"text-align: left;\">\n" +
"\t\t\t\t<!-- 5.1 收 -->\n" +
"\t\t\t\t<div class=\"imgShou\" style=\"display: inline-block; width: 9mm; text-align: center;\">\n" +
"\t\t\t\t\t<img src=\"images/iconShou.png\" style=\"width:7mm; height:7mm\">\n" +
"\t\t\t\t</div>\n" +
"\t\t\t\t<!-- 5.2 收件人姓名/电话/地址 -->\n" +
"\t\t\t\t<div\n" +
"\t\t\t\t\tclass=\"recipientInfo\"\n" +
"\t\t\t\t\tstyle=\"display: inline-block; width: 62mm; font-family: 宋体; font-size: 9pt; text-align: left;\"\n" +
"\t\t\t\t>\n" +
"\t\t\t\t\t<div>\n" +
"\t\t\t\t\t\t<span>收货姓名</span>\n" +
"\t\t\t\t\t\t<span>18510980989</span>\n" +
"\t\t\t\t\t</div>\n" +
"\t\t\t\t\t<div>\n" +
"\t\t\t\t\t\t<span>收货地址北京市朝阳区摩登天空测试地址</span>\n" +
"\t\t\t\t\t</div>\n" +
"\t\t\t\t</div>\n" +
"\t\t\t\t<!-- 5.3 单元区域编码 暂无-->\n" +
"\t\t\t\t<!-- 6\t代收货款 -->\n" +
"\t\t\t\t<div class=\"iconCOD\" style=\"display: inline-block;\">\n" +
"\t\t\t\t\t<!-- 6.1 COD -->\n" +
"\t\t\t\t\t<img src=\"images/COD.jpg\" style=\"width: 17mm; height:9mm\">\n" +
"\t\t\t\t</div>\n" +
"\t\t\t</div>\n" +
"\t\t</div>\n" +
"\n" +
"\t\t<table\n" +
"\t\t\tclass=\"QrCodeArea\"\n" +
"\t\t\tborder=\"1\"\n" +
"\t\t\tstyle=\"margin: 0 auto; border: 1px solid #000; width: 92.5mm; border-collapse:collapse;\"\n" +
"\t\t>\n" +
"\t\t\t<tr>\n" +
"\t\t\t\t<td class=\"daofuInfo\" style=\"font-family: 宋体; font-size: 9pt;\">\n" +
"\t\t\t\t\t到付22元\n" +
"\t\t\t\t</td>\n" +
"\t\t\t\t<td rowspan=\"3\" class=\"QrCode\">\n" +
"\t\t\t\t\t<img src=\"/usr/local/var/www/liquidnet-bus-v1/liquidnet-bus-client/liquidnet-client-admin/liquidnet-client-admin-zhengzai/src/main/java/com/liquidnet/client/admin/zhengzai/admin/service/impl/utils/tmphtml/qrcode/out.png\" style=\"width: 25mm; height: 25mm\">\n" +
"\t\t\t\t</td>\n" +
"\t\t\t\t<!-- 13\t已验视 -->\n" +
"\t\t\t\t<td\n" +
"\t\t\t\t\trowspan=\"3\"\n" +
"\t\t\t\t\tclass=\"yiyanshiInfo\"\n" +
"\t\t\t\t\tstyle=\"font-family: 黑体; font-size: 22pt; font-weight: bold; color: #272727b3; writing-mode: vertical-lr;\"\n" +
"\t\t\t\t>\n" +
"\t\t\t\t\t已验视\n" +
"\t\t\t\t</td>\n" +
"\t\t\t\t<!-- 产品名称\t限时限时KC24字段 -->\n" +
"\t\t\t\t<td\n" +
"\t\t\t\t\trowspan=\"2\"\n" +
"\t\t\t\t\tclass=\"limitTime\"\n" +
"\t\t\t\t\tstyle=\"font-family: 宋体; font-size: 12pt; width: 20mm;\"\n" +
"\t\t\t\t>\n" +
"\t\t\t\t\t限时\n" +
"\t\t\t\t\tKC24\n" +
"\t\t\t\t</td>\n" +
"\t\t\t</tr>\n" +
"\t\t\t<tr>\n" +
"\t\t\t\t<td rowspan=\"2\" class=\"jigangInfo\" style=\"font-family: 黑体; font-size: 22pt; font-weight: bold;\">\n" +
"\t\t\t\t\tA22\n" +
"\t\t\t\t</td>\n" +
"\t\t\t</tr>\n" +
"\t\t\t<tr>\n" +
"\t\t\t\t<td class=\"\">\n" +
"\t\t\t\t\t1A\n" +
"\t\t\t\t</td>\n" +
"\t\t\t</tr>\n" +
"\t\t</table>\n" +
"\n" +
"\t\t<!-- 14\t寄方信息 -->\n" +
"\t\t<div\n" +
"\t\t\tclass=\"jiInfo\"\n" +
"\t\t\tstyle=\"border-left: 1px solid #000;\n" +
"\t\t\t\tborder-right: 1px solid #000;\n" +
"\t\t\t\twidth: 92mm;\n" +
"\t\t\t\tmargin: 0 auto;\n" +
"\t\t\t\ttext-align: left;\"\n" +
"\t\t>\n" +
"\t\t\t<div\n" +
"\t\t\t\tclass=\"imgShou\"\n" +
"\t\t\t\tstyle=\"display: inline-block; width: 9mm; text-align: center;\"\n" +
"\t\t\t>\n" +
"\t\t\t\t<img src=\"images/iconJi.png\" style=\"width:7mm; height:7mm\">\n" +
"\t\t\t</div>\n" +
"\t\t\t<!-- 14.1 寄件人人姓名/电话/地址 -->\n" +
"\t\t\t<div\n" +
"\t\t\t\tclass=\"recipientInfo\" \n" +
"\t\t\t\tstyle=\"display: inline-block; width: 62mm; font-family: 宋体; font-size: 9pt; text-align: left;\"\n" +
"\t\t\t>\n" +
"\t\t\t\t<div>\n" +
"\t\t\t\t\t<span>寄件人姓名</span>\n" +
"\t\t\t\t\t<span>18510980989</span>\n" +
"\t\t\t\t</div>\n" +
"\t\t\t\t<div>\n" +
"\t\t\t\t\t<span>寄件地址北京市朝阳区摩登天空测试地址</span>\n" +
"\t\t\t\t</div>\n" +
"\t\t\t</div>\n" +
"\t\t</div>\n" +
"\t\t\n" +
"\t\t<table\n" +
"\t\t\tclass=\"otherInfo\"\n" +
"\t\t\tborder=\"1\"\n" +
"\t\t\tstyle=\"\n" +
"\t\t\t\tmargin: 0 auto;\n" +
"\t\t\t\tborder: 1px solid #000;\n" +
"\t\t\t\twidth: 92.5mm;\n" +
"\t\t\t\tfont-family: 宋体;\n" +
"\t\t\t\tfont-size: 9pt;\n" +
"\t\t\t\ttext-align: left;\n" +
"\t\t\t\tborder-collapse:collapse;\"\n" +
"\t\t>\n" +
"\t\t\t<tr>\n" +
"\t\t\t\t<!-- 15\t托寄物 -->\n" +
"\t\t\t\t<td rowspan=\"2\">\n" +
"\t\t\t\t\t托寄物:\n" +
"\t\t\t\t</td>\n" +
"\t\t\t\t<!-- 16\t增值服务 -->\n" +
"\t\t\t\t<td>\n" +
"\t\t\t\t\t增值服务:\n" +
"\t\t\t\t</td>\n" +
"\t\t\t</tr>\n" +
"\t\t\t<!-- 17\t其他信息 -->\n" +
"\t\t\t<tr>\n" +
"\t\t\t\t<!-- 17. 1重量 -->\n" +
"\t\t\t\t<!-- 17.2 付款方式、费用等 -->\n" +
"\t\t\t\t<td>\n" +
"\t\t\t\t\t<div>计费重量:1kg</div>\n" +
"\t\t\t\t\t<div>实际重量: 1kg</div>\n" +
"\t\t\t\t\t<div>费用合计:22元</div>\n" +
"\t\t\t\t\t<div>付款方式:寄付现结</div>\n" +
"\t\t\t\t</td>\n" +
"\t\t\t</tr>\n" +
"\t\t\t<tr>\n" +
"\t\t\t\t<!-- 18\t客户自定义区 -->\n" +
"\t\t\t\t<td>\n" +
"\t\t\t\t\t客户自定义区\n" +
"\t\t\t\t\t备注\n" +
"\t\t\t\t\t转寄协议客户\n" +
"\t\t\t\t\t订单等信息\n" +
"\t\t\t\t</td>\n" +
"\t\t\t\t<!-- 19\t图标区域 -->\n" +
"\t\t\t\t<td>\n" +
"\t\t\t\t\t图标区域\n" +
"\t\t\t\t\t贴纸信息\n" +
"\t\t\t\t</td>\n" +
"\t\t\t</tr>\n" +
"\t\t</table>\n" +
"\t\t\n" +
"\t</div>\n" +
"</body>\n" +
"\n" +
"\n" +
"</html>";
Html2Image html2Image = Html2Image.fromHtml(html);
html2Image.getImageRenderer().saveImage("/Users/jiangxiulong/Desktop/aaa.png");
}
public static void main(String[] args) {
html2img();
// 打印图片
drawImage("/Users/jiangxiulong/Desktop/aaa.png", 1);
}
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta http-equiv="Cache-Control" content="no-transform">
<meta http-equiv="Access-Control-Allow-Origin" content="*" />
<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport">
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<meta name="format-detection" content="telephone=yes" /><!-- 点击链接打电话 -->
<meta name="format-detection" content="address=no" />
<meta name="keywords" content="">
<meta name="description" content="">
<link rel="icon" type="image/png" sizes="12x12" href="https://img.zhengzai.tv/static/img/logo_small.png">
</head>
<body>
<!-- 顺丰快递面单打印,尺寸:100mm*150mm模版 -->
<div
id="shunfeng-express"
style="width: 96mm;
height: 150mm;
padding-top: 5mm;
border: 1px solid #000;
text-align: center;"
>
<!-- 1. 运单打印系统来源及时间等 -->
<div
class="sourceAndPrintTime"
style="width: 100%;
font-family: 宋体;
font-size: 4pt;
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: flex-end;"
>
<!-- 1.1 打印系统来源(太长放不下了,所以去掉了) -->
<!-- <div class="source">
SCP顺丰云打印
</div> -->
<!-- 1.2 打印次数/时间 -->
<div
class="printTime"
style="width: 80%;
font-family: 宋体;
font-size: 4pt;
display: flex;
flex-direction: row;
justify-content: center;
align-items: flex-end;"
>
第一次打印 2020-05-05 12:00 第8/10个
</div>
<!-- 3 时效类型 -->
<div
class="timeOfDeliveryType"
style="font-family: 黑体;
font-size: 18pt;
font-weight: bolder;
margin-right: 2mm;"
>
<!-- 3.1 特快即日、特快A、特快、标快、标快陆运、特惠、电商标快 -->
特快
</div>
</div>
<!-- 2. 条码区 -->
<div class="barCodeArea">
<!-- 2.1 条码 -->
<div class="barCode">
<img src="/usr/local/var/www/liquidnet-bus-v1/liquidnet-bus-client/liquidnet-client-admin/liquidnet-client-admin-zhengzai/src/main/java/com/liquidnet/client/admin/zhengzai/admin/service/impl/utils/tmphtml/qrcode/out1.png" style="width: 90%; height: 13mm; margin: 0 5mm;">
</div>
<!-- 2.2 子母件单号、汉字、件数标识、 -->
<div
class="childAndParentParts"
style="font-family: 黑体;
font-size: 10pt;
display: flex;
flex-direction: column;"
>
<div>
子单号:SF1 010 874 393 776
</div>
<div>
母单号:SF1 010 874 393 776
</div>
</div>
</div>
<!-- 4 目的地 -->
<!-- 4.1 路由信息 暂无-->
<div
class="destinationArea"
style="margin: 0 auto;
border: 1px solid #000;
border-bottom: none;
width: 92mm;"
>
<!-- 2.3 运单号 -->
<div
class="expressNumber"
style="font-size: 22pt; font-weight: bold;"
>
755W-BA-0123456789
</div>
<!-- 5 收方信息 -->
<div class="destinationInfo" style="text-align: left;">
<!-- 5.1 收 -->
<div class="imgShou" style="display: inline-block; width: 9mm; text-align: center;">
<img src="images/iconShou.png" style="width:7mm; height:7mm">
</div>
<!-- 5.2 收件人姓名/电话/地址 -->
<div
class="recipientInfo"
style="display: inline-block; width: 62mm; font-family: 宋体; font-size: 9pt; text-align: left;"
>
<div>
<span>收货姓名</span>
<span>18510980989</span>
</div>
<div>
<span>收货地址北京市朝阳区摩登天空测试地址</span>
</div>
</div>
<!-- 5.3 单元区域编码 暂无-->
<!-- 6 代收货款 -->
<div class="iconCOD" style="display: inline-block;">
<!-- 6.1 COD -->
<img src="images/COD.jpg" style="width: 17mm; height:9mm">
</div>
</div>
</div>
<table
class="QrCodeArea"
border="1"
style="margin: 0 auto; border: 1px solid #000; width: 92.5mm; border-collapse:collapse;"
>
<tr>
<td class="daofuInfo" style="font-family: 宋体; font-size: 9pt;">
到付22元
</td>
<td rowspan="3" class="QrCode">
<img src="/usr/local/var/www/liquidnet-bus-v1/liquidnet-bus-client/liquidnet-client-admin/liquidnet-client-admin-zhengzai/src/main/java/com/liquidnet/client/admin/zhengzai/admin/service/impl/utils/tmphtml/qrcode/out.png" style="width: 25mm; height: 25mm">
</td>
<!-- 13 已验视 -->
<td
rowspan="3"
class="yiyanshiInfo"
style="font-family: 黑体; font-size: 22pt; font-weight: bold; color: #272727b3; writing-mode: vertical-lr;"
>
已验视
</td>
<!-- 产品名称 限时限时KC24字段 -->
<td
rowspan="2"
class="limitTime"
style="font-family: 宋体; font-size: 12pt; width: 20mm;"
>
限时
KC24
</td>
</tr>
<tr>
<td rowspan="2" class="jigangInfo" style="font-family: 黑体; font-size: 22pt; font-weight: bold;">
A22
</td>
</tr>
<tr>
<td class="">
1A
</td>
</tr>
</table>
<!-- 14 寄方信息 -->
<div
class="jiInfo"
style="border-left: 1px solid #000;
border-right: 1px solid #000;
width: 92mm;
margin: 0 auto;
text-align: left;"
>
<div
class="imgShou"
style="display: inline-block; width: 9mm; text-align: center;"
>
<img src="images/iconJi.png" style="width:7mm; height:7mm">
</div>
<!-- 14.1 寄件人人姓名/电话/地址 -->
<div
class="recipientInfo"
style="display: inline-block; width: 62mm; font-family: 宋体; font-size: 9pt; text-align: left;"
>
<div>
<span>寄件人姓名</span>
<span>18510980989</span>
</div>
<div>
<span>寄件地址北京市朝阳区摩登天空测试地址</span>
</div>
</div>
</div>
<table
class="otherInfo"
border="1"
style="
margin: 0 auto;
border: 1px solid #000;
width: 92.5mm;
font-family: 宋体;
font-size: 9pt;
text-align: left;
border-collapse:collapse;"
>
<tr>
<!-- 15 托寄物 -->
<td rowspan="2">
托寄物:
</td>
<!-- 16 增值服务 -->
<td>
增值服务:
</td>
</tr>
<!-- 17 其他信息 -->
<tr>
<!-- 17. 1重量 -->
<!-- 17.2 付款方式、费用等 -->
<td>
<div>计费重量:1kg</div>
<div>实际重量: 1kg</div>
<div>费用合计:22元</div>
<div>付款方式:寄付现结</div>
</td>
</tr>
<tr>
<!-- 18 客户自定义区 -->
<td>
客户自定义区
备注
转寄协议客户
订单等信息
</td>
<!-- 19 图标区域 -->
<td>
图标区域
贴纸信息
</td>
</tr>
</table>
</div>
</body>
</html>
\ No newline at end of file
......@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.liquidnet.client.admin.common.utils.StringUtils;
import com.liquidnet.client.admin.zhengzai.admin.service.impl.utils.CodeUtil;
import com.liquidnet.client.admin.zhengzai.kylin.utils.DataUtils;
import com.liquidnet.client.admin.zhengzai.kylin.utils.ShunfengSignUtils;
import com.liquidnet.commons.lang.util.*;
......@@ -20,6 +21,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.jms.JmsProperties;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
......@@ -96,6 +98,9 @@ public class PerformancesExpressServiceImpl extends ServiceImpl<KylinOrderExpres
@Autowired
private DataUtils dataUtils;
@Autowired
private CodeUtil codeUtil;
public List<PerformanceExpressPerformanceListAdminDao> getPerformancesList(PerformanceExpressSearchAdminParam performanceExpressSearchAdminParam) {
List<PerformanceExpressPerformanceListAdminDao> voList = new ArrayList();
try {
......@@ -557,4 +562,256 @@ public class PerformancesExpressServiceImpl extends ServiceImpl<KylinOrderExpres
}
} while (count >= limitNum);
}
public void print() {
String html = "<!DOCTYPE html>\n" +
"<html lang=\"en\">\n" +
"<body>\n" +
"\t<!-- 顺丰快递面单打印,尺寸:100mm*150mm模版 -->\n" +
"\t<div\n" +
"\t\tid=\"shunfeng-express\"\n" +
"\t\tstyle=\"width: 96mm;\n" +
"\t\t\theight: 150mm;\n" +
"\t\t\tpadding-top: 5mm;\n" +
"\t\t\tborder: 1px solid #000;\n" +
"\t\t\ttext-align: center;\"\n" +
"\t>\n" +
"\t\t<!-- 1. 运单打印系统来源及时间等 -->\n" +
"\t\t<div \n" +
"\t\t\tclass=\"sourceAndPrintTime\"\n" +
"\t\t\tstyle=\"width: 100%;\n" +
"\t\t\t\tfont-family: 宋体;\n" +
"\t\t\t\tfont-size: 4pt;\n" +
"\t\t\t\tdisplay: flex;\n" +
"\t\t\t\tflex-direction: row;\n" +
"\t\t\t\tjustify-content: space-between;\n" +
"\t\t\t\talign-items: flex-end;\"\n" +
"\t\t>\n" +
"\t\t\t<!-- 1.1 打印系统来源(太长放不下了,所以去掉了) -->\n" +
"\t\t\t<!-- <div class=\"source\">\n" +
"\t\t\t\tSCP顺丰云打印\n" +
"\t\t\t</div> -->\n" +
"\t\t\t<!-- 1.2 打印次数/时间 -->\n" +
"\t\t\t<div\n" +
"\t\t\t\tclass=\"printTime\"\n" +
"\t\t\t\tstyle=\"width: 50%;\n" +
"\t\t\t\t\tfont-family: 宋体;\n" +
"\t\t\t\t\tfont-size: 4pt;\n" +
"\t\t\t\t\tdisplay: flex;\n" +
"\t\t\t\t\tflex-direction: row;\n" +
"\t\t\t\t\tjustify-content: center;\n" +
"\t\t\t\t\talign-items: flex-end;\"\n" +
"\t\t\t>\n" +
"\t\t\t\t第一次打印 2020-05-05 12:00 第8/10个\n" +
"\t\t\t</div>\n" +
"\t\t\t<!-- 3 时效类型 -->\n" +
"\t\t\t<div\n" +
"\t\t\t\tclass=\"timeOfDeliveryType\"\n" +
"\t\t\t\tstyle=\"font-family: 黑体;\n" +
"\t\t\t\t\tfont-size: 18pt;\n" +
"\t\t\t\t\tfont-weight: bolder;\n" +
"\t\t\t\t\tmargin-right: 2mm;\"\n" +
"\t\t\t>\n" +
"\t\t\t\t<!-- 3.1 特快即日、特快A、特快、标快、标快陆运、特惠、电商标快 -->\n" +
"\t\t\t\t特快\n" +
"\t\t\t</div>\n" +
"\t\t</div>\n" +
"\n" +
"\n" +
"\t\t<!-- 2. 条码区 -->\n" +
"\t\t<div class=\"barCodeArea\">\n" +
"\t\t\t<!-- 2.1 条码 -->\n" +
"\t\t\t<div class=\"barCode\">\n" +
"\t\t\t\t<img src=\"https://img.zhengzai.tv/static/img/logo_small.png\" style=\"width: 90%; height: 13mm; margin: 0 5mm;\">\n" +
"\t\t\t</div>\n" +
"\t\t\t<!-- 2.2 子母件单号、汉字、件数标识、 -->\n" +
"\t\t\t<div\n" +
"\t\t\t\tclass=\"childAndParentParts\"\n" +
"\t\t\t\tstyle=\"font-family: 黑体;\n" +
"\t\t\t\t\tfont-size: 10pt;\n" +
"\t\t\t\t\tdisplay: flex;\n" +
"\t\t\t\t\tflex-direction: column;\"\n" +
"\t\t\t>\n" +
"\t\t\t\t<div>\n" +
"\t\t\t\t\t子单号:SF1 010 874 393 776\n" +
"\t\t\t\t</div>\n" +
"\t\t\t\t<div>\n" +
"\t\t\t\t\t母单号:SF1 010 874 393 776\n" +
"\t\t\t\t</div>\n" +
"\t\t\t</div>\n" +
"\t\t</div>\n" +
"\n" +
"\t\t<!-- 4\t目的地 -->\n" +
"\t\t<!-- 4.1 路由信息 暂无-->\n" +
"\t\t<div \n" +
"\t\t\tclass=\"destinationArea\"\n" +
"\t\t\tstyle=\"margin: 0 auto;\n" +
"\t\t\t\tborder: 1px solid #000;\n" +
"\t\t\t\tborder-bottom: none;\n" +
"\t\t\t\twidth: 92mm;\"\n" +
"\t\t>\n" +
"\t\t\t<!-- 2.3 运单号 -->\n" +
"\t\t\t<div\n" +
"\t\t\t\tclass=\"expressNumber\"\n" +
"\t\t\t\tstyle=\"font-size: 22pt; font-weight: bold;\"\n" +
"\t\t\t>\n" +
"\t\t\t\t755W-BA-0123456789\n" +
"\t\t\t</div>\n" +
"\t\t\t<!-- 5\t收方信息 -->\t\n" +
"\t\t\t<div class=\"destinationInfo\" style=\"text-align: left;\">\n" +
"\t\t\t\t<!-- 5.1 收 -->\n" +
"\t\t\t\t<div class=\"imgShou\" style=\"display: inline-block; width: 9mm; text-align: center;\">\n" +
"\t\t\t\t\t<img src=\"./images/iconShou.png\" style=\"width:7mm; height:7mm\">\n" +
"\t\t\t\t</div>\n" +
"\t\t\t\t<!-- 5.2 收件人姓名/电话/地址 -->\n" +
"\t\t\t\t<div\n" +
"\t\t\t\t\tclass=\"recipientInfo\"\n" +
"\t\t\t\t\tstyle=\"display: inline-block; width: 62mm; font-family: 宋体; font-size: 9pt; text-align: left;\"\n" +
"\t\t\t\t>\n" +
"\t\t\t\t\t<div>\n" +
"\t\t\t\t\t\t<span>收货姓名</span>\n" +
"\t\t\t\t\t\t<span>18510980989</span>\n" +
"\t\t\t\t\t</div>\n" +
"\t\t\t\t\t<div>\n" +
"\t\t\t\t\t\t<span>收货地址北京市朝阳区摩登天空测试地址</span>\n" +
"\t\t\t\t\t</div>\n" +
"\t\t\t\t</div>\n" +
"\t\t\t\t<!-- 5.3 单元区域编码 暂无-->\n" +
"\t\t\t\t<!-- 6\t代收货款 -->\n" +
"\t\t\t\t<div class=\"iconCOD\" style=\"display: inline-block;\">\n" +
"\t\t\t\t\t<!-- 6.1 COD -->\n" +
"\t\t\t\t\t<img src=\"./images/COD.jpg\" style=\"width: 17mm; height:9mm\">\n" +
"\t\t\t\t</div>\n" +
"\t\t\t</div>\n" +
"\t\t</div>\n" +
"\n" +
"\t\t<table\n" +
"\t\t\tclass=\"QrCodeArea\"\n" +
"\t\t\tborder=\"1\"\n" +
"\t\t\tstyle=\"margin: 0 auto; border: 1px solid #000; width: 92.5mm; border-collapse:collapse;\"\n" +
"\t\t>\n" +
"\t\t\t<tr>\n" +
"\t\t\t\t<td class=\"daofuInfo\" style=\"font-family: 宋体; font-size: 9pt;\">\n" +
"\t\t\t\t\t到付22元\n" +
"\t\t\t\t</td>\n" +
"\t\t\t\t<td rowspan=\"3\" class=\"QrCode\">\n" +
"\t\t\t\t\t<img src=\"./images/erweima.png\" style=\"width: 25mm; height: 25mm\">\n" +
"\t\t\t\t</td>\n" +
"\t\t\t\t<!-- 13\t已验视 -->\n" +
"\t\t\t\t<td\n" +
"\t\t\t\t\trowspan=\"3\"\n" +
"\t\t\t\t\tclass=\"yiyanshiInfo\"\n" +
"\t\t\t\t\tstyle=\"font-family: 黑体; font-size: 22pt; font-weight: bold; color: #272727b3; writing-mode: vertical-lr;\"\n" +
"\t\t\t\t>\n" +
"\t\t\t\t\t已验视\n" +
"\t\t\t\t</td>\n" +
"\t\t\t\t<!-- 产品名称\t限时限时KC24字段 -->\n" +
"\t\t\t\t<td\n" +
"\t\t\t\t\trowspan=\"2\"\n" +
"\t\t\t\t\tclass=\"limitTime\"\n" +
"\t\t\t\t\tstyle=\"font-family: 宋体; font-size: 12pt; width: 20mm;\"\n" +
"\t\t\t\t>\n" +
"\t\t\t\t\t限时\n" +
"\t\t\t\t\tKC24\n" +
"\t\t\t\t</td>\n" +
"\t\t\t</tr>\n" +
"\t\t\t<tr>\n" +
"\t\t\t\t<td rowspan=\"2\" class=\"jigangInfo\" style=\"font-family: 黑体; font-size: 22pt; font-weight: bold;\">\n" +
"\t\t\t\t\tA22\n" +
"\t\t\t\t</td>\n" +
"\t\t\t</tr>\n" +
"\t\t\t<tr>\n" +
"\t\t\t\t<td class=\"\">\n" +
"\t\t\t\t\t1A\n" +
"\t\t\t\t</td>\n" +
"\t\t\t</tr>\n" +
"\t\t</table>\n" +
"\n" +
"\t\t<!-- 14\t寄方信息 -->\n" +
"\t\t<div\n" +
"\t\t\tclass=\"jiInfo\"\n" +
"\t\t\tstyle=\"border-left: 1px solid #000;\n" +
"\t\t\t\tborder-right: 1px solid #000;\n" +
"\t\t\t\twidth: 92mm;\n" +
"\t\t\t\tmargin: 0 auto;\n" +
"\t\t\t\ttext-align: left;\"\n" +
"\t\t>\n" +
"\t\t\t<div\n" +
"\t\t\t\tclass=\"imgShou\"\n" +
"\t\t\t\tstyle=\"display: inline-block; width: 9mm; text-align: center;\"\n" +
"\t\t\t>\n" +
"\t\t\t\t<img src=\"./images/iconJi.png\" style=\"width:7mm; height:7mm\">\n" +
"\t\t\t</div>\n" +
"\t\t\t<!-- 14.1 寄件人人姓名/电话/地址 -->\n" +
"\t\t\t<div\n" +
"\t\t\t\tclass=\"recipientInfo\" \n" +
"\t\t\t\tstyle=\"display: inline-block; width: 62mm; font-family: 宋体; font-size: 9pt; text-align: left;\"\n" +
"\t\t\t>\n" +
"\t\t\t\t<div>\n" +
"\t\t\t\t\t<span>寄件人姓名</span>\n" +
"\t\t\t\t\t<span>18510980989</span>\n" +
"\t\t\t\t</div>\n" +
"\t\t\t\t<div>\n" +
"\t\t\t\t\t<span>寄件地址北京市朝阳区摩登天空测试地址</span>\n" +
"\t\t\t\t</div>\n" +
"\t\t\t</div>\n" +
"\t\t</div>\n" +
"\t\t\n" +
"\t\t<table\n" +
"\t\t\tclass=\"otherInfo\"\n" +
"\t\t\tborder=\"1\"\n" +
"\t\t\tstyle=\"\n" +
"\t\t\t\tmargin: 0 auto;\n" +
"\t\t\t\tborder: 1px solid #000;\n" +
"\t\t\t\twidth: 92.5mm;\n" +
"\t\t\t\tfont-family: 宋体;\n" +
"\t\t\t\tfont-size: 9pt;\n" +
"\t\t\t\ttext-align: left;\n" +
"\t\t\t\tborder-collapse:collapse;\"\n" +
"\t\t>\n" +
"\t\t\t<tr>\n" +
"\t\t\t\t<!-- 15\t托寄物 -->\n" +
"\t\t\t\t<td rowspan=\"2\">\n" +
"\t\t\t\t\t托寄物:\n" +
"\t\t\t\t</td>\n" +
"\t\t\t\t<!-- 16\t增值服务 -->\n" +
"\t\t\t\t<td>\n" +
"\t\t\t\t\t增值服务:\n" +
"\t\t\t\t</td>\n" +
"\t\t\t</tr>\n" +
"\t\t\t<!-- 17\t其他信息 -->\n" +
"\t\t\t<tr>\n" +
"\t\t\t\t<!-- 17. 1重量 -->\n" +
"\t\t\t\t<!-- 17.2 付款方式、费用等 -->\n" +
"\t\t\t\t<td>\n" +
"\t\t\t\t\t<div>计费重量:1kg</div>\n" +
"\t\t\t\t\t<div>实际重量: 1kg</div>\n" +
"\t\t\t\t\t<div>费用合计:22元</div>\n" +
"\t\t\t\t\t<div>付款方式:寄付现结</div>\n" +
"\t\t\t\t</td>\n" +
"\t\t\t</tr>\n" +
"\t\t\t<tr>\n" +
"\t\t\t\t<!-- 18\t客户自定义区 -->\n" +
"\t\t\t\t<td>\n" +
"\t\t\t\t\t客户自定义区\n" +
"\t\t\t\t\t备注\n" +
"\t\t\t\t\t转寄协议客户\n" +
"\t\t\t\t\t订单等信息\n" +
"\t\t\t\t</td>\n" +
"\t\t\t\t<!-- 19\t图标区域 -->\n" +
"\t\t\t\t<td>\n" +
"\t\t\t\t\t图标区域\n" +
"\t\t\t\t\t贴纸信息\n" +
"\t\t\t\t</td>\n" +
"\t\t\t</tr>\n" +
"\t\t</table>\n" +
"\t\t\n" +
"\t</div>\n" +
"</body>\n" +
"\n" +
"\n" +
"</html>";
// codeUtil.html2img(html);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment