Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
D
device-back
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
1
议题
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Matrix
device-back
Commits
308cff5b
提交
308cff5b
authored
7月 20, 2021
作者:
zhoushaopan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[二维码]修改
上级
c3a45dfc
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
43 行增加
和
8 行删除
+43
-8
TaskDao.java
...ain/java/com/tykj/dev/device/task/repository/TaskDao.java
+3
-0
ZXingUtil.java
...c/main/java/com/tykj/dev/device/zxing/util/ZXingUtil.java
+21
-8
ZxingTaskVo.java
...c/main/java/com/tykj/dev/device/zxing/vo/ZxingTaskVo.java
+19
-0
没有找到文件。
dev-task/src/main/java/com/tykj/dev/device/task/repository/TaskDao.java
浏览文件 @
308cff5b
...
...
@@ -82,4 +82,7 @@ public interface TaskDao extends JpaRepository<Task, Integer>, JpaSpecificationE
List
<
Task
>
findAllByBusinessTypeAndCustomInfoAndBillStatus
(
Integer
businessType
,
String
customInfo
,
Integer
billStatus
);
List
<
Task
>
findAllByBusinessTypeAndBillIdIn
(
Integer
businessType
,
List
<
Integer
>
billIds
);
//zsp
Task
findByParentTaskId
(
Integer
parentTaskId
);
}
dev-zxing/src/main/java/com/tykj/dev/device/zxing/util/ZXingUtil.java
浏览文件 @
308cff5b
...
...
@@ -5,10 +5,17 @@ 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.tykj.dev.device.task.repository.TaskDao
;
import
com.tykj.dev.device.task.service.TaskService
;
import
com.tykj.dev.device.task.subject.bto.TaskBto
;
import
com.tykj.dev.device.task.subject.domin.Task
;
import
com.tykj.dev.device.zxing.vo.ZxingTaskVo
;
import
javassist.NotFoundException
;
import
org.apache.tomcat.util.http.fileupload.FileUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.ResourceUtils
;
import
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.multipart.MultipartRequest
;
...
...
@@ -28,16 +35,19 @@ import java.util.UUID;
* DATE:2021-7-20
* Author:zsp
*/
@Service
public
class
ZXingUtil
{
/** 二维码上传位置 */
private
static
String
codePath
=
"src/"
;
//
private static String codePath = "src/";
/** 二维码宽度 */
private
static
Integer
width
=
5
0
;
private
static
Integer
width
=
10
0
;
/** 二维码高度 */
private
static
Integer
height
=
5
0
;
private
static
Integer
height
=
10
0
;
@Autowired
private
TaskDao
taskDao
;
/**
* 解析二维码
*
...
...
@@ -57,7 +67,7 @@ public class ZXingUtil {
// Result result = new MultiFormatReader().decode(bitmap, decodeHints);
// return result.getText();
// }
public
static
String
decode
(
MultipartFile
file
)
throws
IOException
,
com
.
google
.
zxing
.
NotFoundException
{
public
ZxingTaskVo
decode
(
MultipartFile
file
)
throws
IOException
,
com
.
google
.
zxing
.
NotFoundException
{
BufferedImage
bufferedImage
=
ImageIO
.
read
(
new
FileInputStream
((
File
)
file
));
LuminanceSource
source
=
new
BufferedImageLuminanceSource
(
bufferedImage
);
Binarizer
binarizer
=
new
HybridBinarizer
(
source
);
...
...
@@ -65,7 +75,12 @@ public class ZXingUtil {
HashMap
<
DecodeHintType
,
Object
>
decodeHints
=
new
HashMap
<
DecodeHintType
,
Object
>();
decodeHints
.
put
(
DecodeHintType
.
CHARACTER_SET
,
"UTF-8"
);
Result
result
=
new
MultiFormatReader
().
decode
(
bitmap
,
decodeHints
);
return
result
.
getText
();
ZxingTaskVo
zxingTaskVo
=
null
;
if
(
result
.
getText
()
!=
null
){
Task
task
=
taskDao
.
findByParentTaskId
(
Integer
.
valueOf
(
result
.
getText
()));
zxingTaskVo
=
new
ZxingTaskVo
(
task
.
getParentTaskId
(),
task
.
getId
());
}
return
zxingTaskVo
;
}
/**
...
...
@@ -100,7 +115,6 @@ public class ZXingUtil {
InputStream
in
=
null
;
byte
[]
data
=
null
;
// 读取图片字节数组
try
{
in
=
new
FileInputStream
(
imgFile
);
...
...
@@ -113,8 +127,7 @@ public class ZXingUtil {
}
// 对字节数组Base64编码
BASE64Encoder
encoder
=
new
BASE64Encoder
();
return
encoder
.
encode
(
data
);
// 返回Base64编码过的字节数组字符串
return
encoder
.
encode
(
data
);
// 返回Base64编码过的字节数组字符串
}
}
dev-zxing/src/main/java/com/tykj/dev/device/zxing/vo/ZxingTaskVo.java
0 → 100644
浏览文件 @
308cff5b
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
ZxingTaskVo
{
private
Integer
taskId
;
private
Integer
childTaskId
;
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论