|
|
@ -370,48 +370,4 @@ public class AgencyController { |
|
|
|
return new Result<List<SonOrgResultDTO>>().ok(agencyService.getSonAgencyId(orgId,type)); |
|
|
|
} |
|
|
|
|
|
|
|
@PostMapping("qr") |
|
|
|
public void qr(){ |
|
|
|
try { |
|
|
|
write(); |
|
|
|
} catch (IOException e) { |
|
|
|
e.printStackTrace(); |
|
|
|
} catch (WriterException e) { |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public static void write() throws IOException, WriterException { |
|
|
|
String filePath = "/Users/liujianjun/Downloads"; |
|
|
|
String fileName = "qr.png"; |
|
|
|
//二维码内容场景一:json数据
|
|
|
|
JSONObject json = new JSONObject(); |
|
|
|
json.put("baidu","http://www.baidu.com");//二维码一般就是存储链接
|
|
|
|
// json.put("author", "lzz");//还可存储值(员工工号,员工姓名,年会二维码门票)
|
|
|
|
String content = json.toJSONString();//json 内容
|
|
|
|
//二维码内容场景二:直接某个超链接
|
|
|
|
// content="http://www.baidu.com";//直接某个超链接
|
|
|
|
int width = 200; // 图像宽度
|
|
|
|
int height = 200; // 图像高度
|
|
|
|
String format = "png";// 图像类型
|
|
|
|
Map<EncodeHintType, Object> hints = new HashMap<EncodeHintType, Object>(); |
|
|
|
|
|
|
|
hints.put(EncodeHintType.CHARACTER_SET, "UTF-8"); |
|
|
|
BitMatrix bitMatrix = new MultiFormatWriter().encode(content, |
|
|
|
BarcodeFormat.QR_CODE, width, height, hints);// 生成矩阵
|
|
|
|
Path path = FileSystems.getDefault().getPath(filePath, fileName); |
|
|
|
MatrixToImageWriter.writeToPath(bitMatrix, format, path);// 输出图像
|
|
|
|
System.out.println("输出成功."); |
|
|
|
} |
|
|
|
|
|
|
|
public static void main(String[] args) { |
|
|
|
try { |
|
|
|
write(); |
|
|
|
} catch (IOException e) { |
|
|
|
e.printStackTrace(); |
|
|
|
} catch (WriterException e) { |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|