Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
H
hnxtbaboot
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
杨亮
hnxtbaboot
Commits
9ceb4cf9
Commit
9ceb4cf9
authored
Oct 25, 2022
by
wuchengwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
声纹详情下载
parent
4150e3b5
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
93 additions
and
5 deletions
+93
-5
hnxtba-core/src/main/java/com/founder/controller/SwCjController.java
+37
-4
hnxtba-core/src/main/java/com/founder/utils/FileUtils.java
+55
-0
hnxtba-interface/src/main/java/com/founder/controller/ZjController.java
+1
-1
No files found.
hnxtba-core/src/main/java/com/founder/controller/SwCjController.java
View file @
9ceb4cf9
...
...
@@ -10,6 +10,7 @@ import com.founder.service.IParamService;
import
com.founder.service.ISwCjService
;
import
com.founder.service.XzxtcxService
;
import
com.founder.utils.EasyuiPage
;
import
com.founder.utils.FileUtils
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -442,6 +443,25 @@ private static Log log = LogFactory.getLog(SwCjController.class);
String
uuid
=
UUID
.
randomUUID
().
toString
().
replaceAll
(
"-"
,
""
);
tbStSw
.
setXxzjbh
(
uuid
);
tbStSw
.
setSbcs
(
"2"
);
int
swcnt
=
swCjService
.
getSwSjXxCnt
(
xyrC
.
getRybh
());
String
rybhstr
=
xyrC
.
getRybh
();
String
savePath
=
"/personphoto/"
+
rybhstr
.
substring
(
rybhstr
.
length
()
-
10
,
rybhstr
.
length
()
-
4
)
+
"/"
+
rybhstr
.
substring
(
rybhstr
.
length
()
-
3
,
rybhstr
.
length
());
// Param param = paramService.getParamById("0100");
// String zplj = param.getParamvalue();
String
zplj
=
wjxzlj
;
String
filePath
=
zplj
;
filePath
=
filePath
+
savePath
;
File
filejia0
=
new
File
(
filePath
);
if
(!
filejia0
.
exists
())
{
filejia0
.
mkdir
();
}
String
paths
=
""
;
if
(
swcnt
>=
0
){
paths
=
filePath
+
"/"
+
rybhstr
+
"_"
+
voice
.
getName
()
+
swcnt
+
".wav"
;
}
else
{
paths
=
filePath
+
"/"
+
rybhstr
+
"_"
+
voice
.
getName
()
+
"0.wav"
;
}
tbStSw
.
setWjlj
(
paths
);
Boolean
b
=
swCjService
.
saveSwSjXx
(
tbStSw
,
unitcode
);
if
(
b
)
{
//成功
...
...
@@ -785,7 +805,7 @@ private static Log log = LogFactory.getLog(SwCjController.class);
@RequestMapping
(
value
=
"/downloadfile"
)
@ResponseBody
public
void
findfile
(
HttpServletRequest
request
,
HttpServletResponse
response
,
@RequestParam
(
"filename"
)
String
filename
,
@RequestParam
(
"rybh"
)
String
rybh
)
throws
IOException
{
public
String
findfile
(
HttpServletRequest
request
,
HttpServletResponse
response
,
@RequestParam
(
"filename"
)
String
filename
,
@RequestParam
(
"rybh"
)
String
rybh
)
throws
IOException
{
ServletOutputStream
out
=
null
;
FileInputStream
ips
=
null
;
...
...
@@ -807,8 +827,21 @@ private static Log log = LogFactory.getLog(SwCjController.class);
File
file
=
new
File
(
paths
);
String
fileName
=
file
.
getName
();
if
(!
file
.
exists
())
{
//如果文件不存在就跳出
return
;
List
<
TbStSw
>
swSjXxList
=
swCjService
.
getSwSjXxList
(
rybh
);
for
(
TbStSw
sw
:
swSjXxList
)
{
log
.
info
(
"该人员编号:"
+
rybh
+
" 的文件名为:"
+
filename
);
if
(
filename
.
equals
(
sw
.
getWjmc
())){
log
.
info
(
"从数据库中获取音频文件"
);
log
.
info
(
"音频数据大小为:"
+
sw
.
getYpsj
().
length
);
file
=
FileUtils
.
byte64ToFile
(
sw
.
getYpsj
(),
paths
);
}
}
// return;
}
if
(!
file
.
exists
())
{
//讯飞和音频数据为空时不做下载操作
log
.
info
(
"该人员编号"
+
rybh
+
" 下没有音频文件"
);
return
null
;
}
ips
=
new
FileInputStream
(
file
);
response
.
setContentType
(
"multipart/form-data"
);
...
...
@@ -833,7 +866,7 @@ private static Log log = LogFactory.getLog(SwCjController.class);
e
.
printStackTrace
();
}
}
return
;
return
null
;
}
/**
...
...
hnxtba-core/src/main/java/com/founder/utils/FileUtils.java
View file @
9ceb4cf9
...
...
@@ -24,7 +24,9 @@ import org.dom4j.Document;
import
org.dom4j.io.OutputFormat
;
import
org.dom4j.io.SAXReader
;
import
org.dom4j.io.XMLWriter
;
import
org.springframework.web.multipart.MultipartFile
;
import
sun.misc.BASE64Decoder
;
import
sun.misc.BASE64Encoder
;
import
javax.imageio.ImageIO
;
import
javax.servlet.ServletContext
;
...
...
@@ -648,6 +650,59 @@ public class FileUtils {
isr
.
close
();
fis
.
close
();
}
/**
* base64转MultipartFile
*/
public
static
File
byte64ToFile
(
byte
[]
bytes
,
String
fliePath
)
throws
Exception
{
File
file
=
null
;
MultipartFile
multipartFile
=
null
;
try
{
// 将base64转成字符流
// byte[] bytes = Base64.getDecoder().decode(base64.replace("\r\n", ""));
ByteArrayInputStream
stream
=
new
ByteArrayInputStream
(
bytes
);
file
=
inputStreamToFile
(
stream
,
fliePath
);
// multipartFile = fileToMultipartFile(file);
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
());
e
.
printStackTrace
();
}
return
file
;
}
/**
* inputStream 转 File
*/
public
static
File
inputStreamToFile
(
InputStream
ins
,
String
filePath
)
throws
Exception
{
File
file
=
new
File
(
filePath
);
OutputStream
os
=
new
FileOutputStream
(
file
);
int
bytesRead
;
int
len
=
8192
;
byte
[]
buffer
=
new
byte
[
len
];
while
((
bytesRead
=
ins
.
read
(
buffer
,
0
,
len
))
!=
-
1
)
{
os
.
write
(
buffer
,
0
,
bytesRead
);
}
os
.
close
();
ins
.
close
();
return
file
;
}
/**
* // 将图片文件转化为字节数组字符串,并对其进行Base64编码处理
* @param data
* @return
*/
public
static
String
getImageStrsByByte
(
byte
[]
data
)
{
// 对字节数组Base64编码
if
(
data
==
null
||
data
.
length
<=
0
)
{
return
null
;
}
BASE64Encoder
encoder
=
new
BASE64Encoder
();
// 返回Base64编码过的字节数组字符串
return
encoder
.
encode
(
data
);
}
public
static
void
main
(
String
[]
args
)
throws
IOException
{
// parseBCP();
readFile02
();
...
...
hnxtba-interface/src/main/java/com/founder/controller/ZjController.java
View file @
9ceb4cf9
...
...
@@ -1465,7 +1465,7 @@ public class ZjController {
/**
* 足迹为推送成功的数据定时推送
*/
@Scheduled
(
cron
=
"0 0/30 * * * ?"
)
//
@Scheduled(cron = "0 0/30 * * * ?")
@RequestMapping
(
"/Tsjgtest"
)
public
void
Dsts
()
{
List
<
ZjcjDto
>
zJxxBySfts
=
zjbzxxService
.
getZJxxBySfts
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment