提交 b13b0dea authored 作者: zhoushaopan's avatar zhoushaopan

[二维码]修改

上级 fb39871f
......@@ -5,6 +5,7 @@ import com.google.zxing.client.j2se.BufferedImageLuminanceSource;
import com.google.zxing.client.j2se.MatrixToImageWriter;
import com.google.zxing.common.BitMatrix;
import com.google.zxing.common.HybridBinarizer;
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
import com.tykj.dev.device.task.repository.TaskDao;
import com.tykj.dev.device.task.service.TaskService;
import com.tykj.dev.device.task.subject.bto.TaskBto;
......@@ -42,9 +43,9 @@ public class ZXingUtil {
/** 二维码上传位置 */
// private static String codePath = "src/";
/** 二维码宽度 */
private static Integer width = 100;
private static Integer width = 50;
/** 二维码高度 */
private static Integer height = 100;
private static Integer height = 50;
@Autowired
private TaskDao taskDao;
......@@ -94,6 +95,8 @@ public class ZXingUtil {
public static String encode(Integer taskId) throws WriterException, IOException {
Map<EncodeHintType, Object> encodeHints = new HashMap<EncodeHintType, Object>();
encodeHints.put(EncodeHintType.CHARACTER_SET, "UTF-8");
encodeHints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.M);
encodeHints.put(EncodeHintType.MARGIN, 0);
BitMatrix bitMatrix = new MultiFormatWriter().encode(String.valueOf(taskId),
BarcodeFormat.QR_CODE, width, height, encodeHints);
String filepath = ResourceUtils.getURL("classpath:").getPath() + UUID.randomUUID() + ".png";
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论