Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
platform
Project
Project
Details
Activity
Releases
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
王琮
platform
Commits
ca0354e0
Commit
ca0354e0
authored
Nov 02, 2021
by
王琮
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加打包接口
parent
6045c471
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
146 additions
and
2 deletions
+146
-2
QuestionnaireCtrl.java
src/main/java/com/tiptimes/ctrl/QuestionnaireCtrl.java
+117
-2
FileDao.java
src/main/java/com/tiptimes/dao/FileDao.java
+2
-0
Answer.java
src/main/java/com/tiptimes/model/Answer.java
+9
-0
FileService.java
src/main/java/com/tiptimes/service/FileService.java
+4
-0
FileServiceImpl.java
src/main/java/com/tiptimes/service/impl/FileServiceImpl.java
+10
-0
File.xml
src/main/resources/mapper/File.xml
+4
-0
No files found.
src/main/java/com/tiptimes/ctrl/QuestionnaireCtrl.java
View file @
ca0354e0
package
com
.
tiptimes
.
ctrl
;
import
com.tiptimes.model.Answer
;
import
com.tiptimes.model.File
;
import
com.tiptimes.model.Questionnaire
;
import
com.tiptimes.model.Record
;
import
com.tiptimes.model.Review
;
import
com.tiptimes.service.FileService
;
import
com.tiptimes.service.QuestionnaireService
;
import
com.tiptimes.util.CompressUtils
;
import
com.tiptimes.util.FileUtil
;
import
com.tiptimes.util.UUIDUtils
;
import
org.apache.commons.io.FileUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.RequestBody
;
...
...
@@ -11,10 +17,17 @@ import org.springframework.web.bind.annotation.RequestMapping;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.ByteArrayOutputStream
;
import
java.io.FileInputStream
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.OutputStream
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Properties
;
@Controller
@RequestMapping
({
"/questionnaire"
})
...
...
@@ -22,6 +35,11 @@ public class QuestionnaireCtrl {
@Autowired
private
QuestionnaireService
questionnaireService
;
@Autowired
private
FileService
fileServer
;
private
static
String
fileUrl
=
""
;
public
QuestionnaireCtrl
()
{
}
...
...
@@ -105,12 +123,14 @@ public class QuestionnaireCtrl {
/**
* 根据上报id查看上报数据详情
* @param
recordId 记录id
* @param
questionnaireUuid 问卷
* @return
*/
@RequestMapping
({
"/selectDetails"
})
@ResponseBody
public
Map
<
String
,
Object
>
selectDetails
(
Long
recordId
){
public
Map
<
String
,
Object
>
selectDetails
(
Long
questionnaireUuid
,
HttpServletRequest
request
){
Long
recordId
=
this
.
questionnaireService
.
selectRecordId
(
questionnaireUuid
,
request
.
getSession
().
getAttribute
(
"realID"
).
toString
());
//1.根据记录id查询上报数据详情
List
<
Answer
>
answerList
=
this
.
questionnaireService
.
selectAnswerByRecordId
(
recordId
);
//2.根据记录id查询审核备注详情
...
...
@@ -182,5 +202,100 @@ public class QuestionnaireCtrl {
map
.
put
(
"data"
,
data
);
return
map
;
}
@RequestMapping
({
"downZipByFileId"
})
public
String
downZipByFileId
(
Long
id
,
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
IOException
{
String
forwardName
=
"/user/file"
;
//1.根据选项查询文件列表
String
forderName
=
UUIDUtils
.
getUUID
();
String
tempPath
=
this
.
getfileUrl
();
String
zipName
=
"上传文件"
;
String
fileName
;
String
myPath
=
tempPath
+
forderName
+
"/"
+
zipName
+
"/"
;
java
.
io
.
File
fileForExists
=
new
java
.
io
.
File
(
myPath
);
if
(!
fileForExists
.
exists
())
{
FileUtil
.
mkdirFolders
(
myPath
);
}
List
<
String
>
fileID
=
this
.
fileServer
.
selectFileId
(
id
);
for
(
int
i
=
0
;
i
<
fileID
.
size
();++
i
)
{
File
file
=
this
.
fileServer
.
selectFileByFileID
(
fileID
.
get
(
i
));
try
{
if
(
file
!=
null
)
{
String
fileNum
=
file
.
getFileNum
();
fileName
=
file
.
getFileName
();
String
originPath
=
""
;
if
(
fileNum
.
startsWith
(
"http"
))
{
originPath
=
fileNum
;
}
else
{
originPath
=
this
.
getfileUrl
()
+
fileNum
;
}
String
targetPath
=
myPath
+
fileName
;
StringBuffer
fileNameForRepeat
=
new
StringBuffer
();
fileNameForRepeat
.
append
(
fileName
.
substring
(
0
,
fileName
.
lastIndexOf
(
"."
)));
fileNameForRepeat
.
append
(
"_"
+
i
);
fileNameForRepeat
.
append
(
fileName
.
substring
(
fileName
.
lastIndexOf
(
"."
)));
String
targetPathForRepeat
=
myPath
+
fileNameForRepeat
;
FileUtil
.
copyFileByPath
(
originPath
,
targetPath
,
targetPathForRepeat
);
}
}
catch
(
Exception
var22
)
{
System
.
out
.
println
(
var22
);
}
}
String
zipPath
=
tempPath
+
forderName
;
java
.
io
.
File
zipFile
=
new
java
.
io
.
File
(
zipPath
);
zipName
=
forderName
+
".zip"
;
(
new
CompressUtils
(
new
java
.
io
.
File
(
tempPath
,
zipName
))).
zipFiles
(
zipFile
);
FileUtils
.
deleteDirectory
(
new
java
.
io
.
File
(
zipPath
));
try
{
String
zipPathExist
=
tempPath
+
zipName
;
java
.
io
.
File
zipFileDownLoad
=
new
java
.
io
.
File
(
zipPathExist
);
if
(
zipFileDownLoad
.
exists
())
{
FileInputStream
in
=
new
FileInputStream
(
zipFileDownLoad
);
ByteArrayOutputStream
out
=
new
ByteArrayOutputStream
(
1024
);
byte
[]
temp
=
new
byte
[
1024
];
boolean
var33
=
false
;
int
size
;
while
((
size
=
in
.
read
(
temp
))
!=
-
1
)
{
out
.
write
(
temp
,
0
,
size
);
}
in
.
close
();
byte
[]
data
=
out
.
toByteArray
();
out
.
close
();
fileName
=
new
String
(
zipName
.
getBytes
(),
"ISO8859-1"
);
response
.
setHeader
(
"Content-Disposition"
,
"attachment; filename=\""
+
fileName
+
"\""
);
response
.
addHeader
(
"Content-Length"
,
""
+
data
.
length
);
response
.
setContentType
(
"application/x-zip-compressed;charset=ISO8859-1"
);
OutputStream
outputStream
=
response
.
getOutputStream
();
outputStream
.
write
(
data
);
outputStream
.
flush
();
outputStream
.
close
();
zipFileDownLoad
.
delete
();
}
else
{
System
.
out
.
println
(
"下载的文件不存在"
);
}
}
catch
(
Exception
var23
)
{
var23
.
printStackTrace
();
}
return
null
;
}
private
String
getfileUrl
()
throws
IOException
{
if
(
""
.
equals
(
fileUrl
))
{
Properties
props
=
new
Properties
();
InputStream
inputStream
=
this
.
getClass
().
getClassLoader
().
getResourceAsStream
(
"file.properties"
);
props
.
load
(
inputStream
);
System
.
out
.
println
(
props
.
getProperty
(
"fileUrl"
));
fileUrl
=
props
.
getProperty
(
"fileUrl"
);
java
.
io
.
File
tempFile
=
new
java
.
io
.
File
(
fileUrl
);
if
(!
tempFile
.
exists
())
{
tempFile
.
mkdirs
();
}
inputStream
.
close
();
}
return
fileUrl
;
}
}
src/main/java/com/tiptimes/dao/FileDao.java
View file @
ca0354e0
...
...
@@ -16,4 +16,6 @@ public interface FileDao {
List
<
File
>
listFileByFileID
(
String
var1
);
List
<
String
>
listFileNameByFileID
(
String
var1
);
List
<
String
>
selectFileId
(
Long
optionId
);
}
src/main/java/com/tiptimes/model/Answer.java
View file @
ca0354e0
...
...
@@ -6,6 +6,15 @@ public class Answer {//上报数据表(每条上报记录的详细数据表)
private
String
value
;
//选项填报数据
private
int
group
;
//分组(同一组表示一条记录,用于多条数据区分)
private
int
recordId
;
//上报记录id
private
String
remark
;
//备注
public
String
getRemark
()
{
return
remark
;
}
public
void
setRemark
(
String
remark
)
{
this
.
remark
=
remark
;
}
public
Long
getId
()
{
return
id
;
...
...
src/main/java/com/tiptimes/service/FileService.java
View file @
ca0354e0
...
...
@@ -2,12 +2,16 @@ package com.tiptimes.service;
import
com.tiptimes.model.File
;
import
java.util.List
;
public
interface
FileService
{
File
selectFileByFileID
(
String
paramString
);
void
saveFile
(
File
paramFile
);
String
updateFile
(
String
paramString1
,
String
paramString2
);
//根据选项id查询文件对应id
List
<
String
>
selectFileId
(
Long
optionId
);
}
...
...
src/main/java/com/tiptimes/service/impl/FileServiceImpl.java
View file @
ca0354e0
...
...
@@ -45,4 +45,14 @@ public class FileServiceImpl implements FileService {
return
""
;
}
/**
*
* @param optionId
* @return
*/
@Override
public
List
<
String
>
selectFileId
(
Long
optionId
)
{
return
fileDao
.
selectFileId
(
optionId
);
}
}
src/main/resources/mapper/File.xml
View file @
ca0354e0
...
...
@@ -46,4 +46,8 @@
where pf.FileID=#{fileID}
AND pf.UserLifeCycle=0
</select>
<select
id=
"selectFileId"
resultType=
"java.lang.String"
>
select `value` from t_answer where options_id=#{optionId}
</select>
</mapper>
\ No newline at end of file
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