Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
D
device-back
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
1
议题
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Matrix
device-back
Commits
9d1e0213
提交
9d1e0213
authored
7月 20, 2021
作者:
zhoushaopan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[二维码]识别二维码
上级
b13b0dea
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
52 行增加
和
3 行删除
+52
-3
ZxingController.java
...com/tykj/dev/device/zxing/controller/ZxingController.java
+32
-0
ZXingUtil.java
...c/main/java/com/tykj/dev/device/zxing/util/ZXingUtil.java
+4
-3
ZxingFile.java
...src/main/java/com/tykj/dev/device/zxing/vo/ZxingFile.java
+16
-0
没有找到文件。
dev-zxing/src/main/java/com/tykj/dev/device/zxing/controller/ZxingController.java
0 → 100644
浏览文件 @
9d1e0213
package
com
.
tykj
.
dev
.
device
.
zxing
.
controller
;
import
com.google.zxing.NotFoundException
;
import
com.tykj.dev.device.zxing.util.ZXingUtil
;
import
com.tykj.dev.device.zxing.vo.ZxingFile
;
import
com.tykj.dev.device.zxing.vo.ZxingTaskVo
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.multipart.MultipartFile
;
import
java.io.IOException
;
/**
* DATE:2021-7-20
* Author:zsp
*/
@RestController
@RequestMapping
(
"/zxing"
)
public
class
ZxingController
{
@Autowired
private
ZXingUtil
zXingUtil
;
@PostMapping
(
"/decode"
)
public
ZxingTaskVo
decode
(
@RequestBody
ZxingFile
file
)
throws
NotFoundException
,
IOException
{
ZxingTaskVo
taskVo
=
zXingUtil
.
decode
(
file
.
getFilePath
());
return
taskVo
;
}
}
dev-zxing/src/main/java/com/tykj/dev/device/zxing/util/ZXingUtil.java
浏览文件 @
9d1e0213
...
@@ -52,7 +52,7 @@ public class ZXingUtil {
...
@@ -52,7 +52,7 @@ public class ZXingUtil {
/**
/**
* 解析二维码
* 解析二维码
*
*
* @param file 文件名
* @param file
Path
文件名
* @return 二维码内容
* @return 二维码内容
* @throws IOException
* @throws IOException
* @throws NotFoundException
* @throws NotFoundException
...
@@ -68,8 +68,8 @@ public class ZXingUtil {
...
@@ -68,8 +68,8 @@ public class ZXingUtil {
// Result result = new MultiFormatReader().decode(bitmap, decodeHints);
// Result result = new MultiFormatReader().decode(bitmap, decodeHints);
// return result.getText();
// return result.getText();
// }
// }
public
ZxingTaskVo
decode
(
MultipartFile
file
)
throws
IOException
,
com
.
google
.
zxing
.
NotFoundException
{
public
ZxingTaskVo
decode
(
String
filePath
)
throws
IOException
,
com
.
google
.
zxing
.
NotFoundException
{
BufferedImage
bufferedImage
=
ImageIO
.
read
(
new
FileInputStream
(
(
File
)
file
));
BufferedImage
bufferedImage
=
ImageIO
.
read
(
new
FileInputStream
(
filePath
));
LuminanceSource
source
=
new
BufferedImageLuminanceSource
(
bufferedImage
);
LuminanceSource
source
=
new
BufferedImageLuminanceSource
(
bufferedImage
);
Binarizer
binarizer
=
new
HybridBinarizer
(
source
);
Binarizer
binarizer
=
new
HybridBinarizer
(
source
);
BinaryBitmap
bitmap
=
new
BinaryBitmap
(
binarizer
);
BinaryBitmap
bitmap
=
new
BinaryBitmap
(
binarizer
);
...
@@ -96,6 +96,7 @@ public class ZXingUtil {
...
@@ -96,6 +96,7 @@ public class ZXingUtil {
Map
<
EncodeHintType
,
Object
>
encodeHints
=
new
HashMap
<
EncodeHintType
,
Object
>();
Map
<
EncodeHintType
,
Object
>
encodeHints
=
new
HashMap
<
EncodeHintType
,
Object
>();
encodeHints
.
put
(
EncodeHintType
.
CHARACTER_SET
,
"UTF-8"
);
encodeHints
.
put
(
EncodeHintType
.
CHARACTER_SET
,
"UTF-8"
);
encodeHints
.
put
(
EncodeHintType
.
ERROR_CORRECTION
,
ErrorCorrectionLevel
.
M
);
encodeHints
.
put
(
EncodeHintType
.
ERROR_CORRECTION
,
ErrorCorrectionLevel
.
M
);
// encodeHints.put(EncodeHintType.MARGIN, 0);
encodeHints
.
put
(
EncodeHintType
.
MARGIN
,
0
);
encodeHints
.
put
(
EncodeHintType
.
MARGIN
,
0
);
BitMatrix
bitMatrix
=
new
MultiFormatWriter
().
encode
(
String
.
valueOf
(
taskId
),
BitMatrix
bitMatrix
=
new
MultiFormatWriter
().
encode
(
String
.
valueOf
(
taskId
),
BarcodeFormat
.
QR_CODE
,
width
,
height
,
encodeHints
);
BarcodeFormat
.
QR_CODE
,
width
,
height
,
encodeHints
);
...
...
dev-zxing/src/main/java/com/tykj/dev/device/zxing/vo/ZxingFile.java
0 → 100644
浏览文件 @
9d1e0213
package
com
.
tykj
.
dev
.
device
.
zxing
.
vo
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
/**
* DATE:2021-7-20
* Author:zsp
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public
class
ZxingFile
{
private
String
filePath
;
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论