Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
education
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
李丛阳
education
Commits
b405aa43
Commit
b405aa43
authored
Dec 16, 2019
by
zhangqingle
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
怎加文件验证
parent
187cefd2
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
114 additions
and
6 deletions
+114
-6
pom.xml
pom.xml
+11
-2
BChapterServiceImpl.java
...t/business/bchapter/service/impl/BChapterServiceImpl.java
+10
-3
BLessonPersonRepository.java
...rcisoft/business/blesson/dao/BLessonPersonRepository.java
+1
-1
ResultServiceEnums.java
...main/java/org/rcisoft/core/result/ResultServiceEnums.java
+1
-0
FileReadableUtil.java
src/main/java/org/rcisoft/core/util/FileReadableUtil.java
+91
-0
No files found.
pom.xml
View file @
b405aa43
...
...
@@ -321,12 +321,12 @@
<dependency>
<groupId>
org.apache.poi
</groupId>
<artifactId>
poi
</artifactId>
<version>
3.1
5
</version>
<version>
3.1
7
</version>
</dependency>
<dependency>
<groupId>
org.apache.poi
</groupId>
<artifactId>
poi-ooxml
</artifactId>
<version>
3.1
0-FINAL
</version>
<version>
3.1
5
</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.ant/ant -->
...
...
@@ -454,6 +454,15 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>
org.apache.tika
</groupId>
<artifactId>
tika-parsers
</artifactId>
<version>
1.17
</version>
</dependency>
</dependencies>
...
...
src/main/java/org/rcisoft/business/bchapter/service/impl/BChapterServiceImpl.java
View file @
b405aa43
...
...
@@ -36,6 +36,7 @@ import org.rcisoft.core.aop.PageUtil;
import
org.rcisoft.core.exception.ServiceException
;
import
org.rcisoft.core.model.PersistModel
;
import
org.rcisoft.core.result.ResultServiceEnums
;
import
org.rcisoft.core.util.FileReadableUtil
;
import
org.rcisoft.core.util.LogUtil
;
import
org.rcisoft.core.util.OfficeToPdf
;
import
org.rcisoft.core.util.UserUtil
;
...
...
@@ -634,9 +635,9 @@ public class BChapterServiceImpl implements BChapterService {
//2. pdf 本地是否存在, word ppt 转换后的pdf是否存在
LogUtil
.
fileChangeLog
(
"------------------获取原路径文件-----------------------------"
+
filePath
);
File
fileOld
=
new
File
(
filePath
+
File
.
separator
+
name
);
LogUtil
.
fileChangeLog
(
"------------------
获取文件名
-----------------------------"
+
fileOld
);
String
newName
=
name
.
substring
(
0
,
name
.
i
ndexOf
(
"."
))
+
"-pdf.pdf"
;
LogUtil
.
fileChangeLog
(
"------------------
获取新路径文件
-----------------------------"
+
newName
);
LogUtil
.
fileChangeLog
(
"------------------
原文件路径
-----------------------------"
+
fileOld
);
String
newName
=
name
.
substring
(
0
,
name
.
lastI
ndexOf
(
"."
))
+
"-pdf.pdf"
;
LogUtil
.
fileChangeLog
(
"------------------
新文件名
-----------------------------"
+
newName
);
//转换后的路径
File
fileNew
=
new
File
(
filePath
+
File
.
separator
+
newName
);
LogUtil
.
fileChangeLog
(
"------------------判断文件类型-----------------------------"
+
fileNew
.
getPath
());
...
...
@@ -647,6 +648,7 @@ public class BChapterServiceImpl implements BChapterService {
return
returnBasePath
+
File
.
separator
+
name
;
}
else
{
String
downLoadName
=
downLoadFile
(
bFile
,
file
,
filePath
);
FileReadableUtil
.
fileReadable
(
filePath
+
File
.
separator
+
downLoadName
);
LogUtil
.
fileChangeLog
(
"------------------返回下载后路径-----------------------------"
+
downLoadName
);
return
returnBasePath
+
File
.
separator
+
downLoadName
;
}
...
...
@@ -662,6 +664,11 @@ public class BChapterServiceImpl implements BChapterService {
fileOld
.
delete
();
LogUtil
.
fileChangeLog
(
"------------------设置下载路径----------------------------"
);
String
downLoadFileUrl
=
downLoadFile
(
bFile
,
file
,
filePath
);
//判断文件是否可读
LogUtil
.
fileChangeLog
(
"------------------判断文件是否可读-----------------------------"
+
filePath
+
File
.
separator
+
name
);
FileReadableUtil
.
fileReadable
(
filePath
+
File
.
separator
+
downLoadFileUrl
);
LogUtil
.
fileChangeLog
(
"-----------------------------------------------downLoadFileUrl:"
+
filePath
+
File
.
separator
+
downLoadFileUrl
);
LogUtil
.
fileChangeLog
(
"-----------------------------------------------filePath:"
+
filePath
+
File
.
separator
+
newName
);
int
result
=
officeToPdf
.
transformToPdf
(
filePath
+
File
.
separator
+
downLoadFileUrl
,
filePath
+
File
.
separator
+
newName
);
...
...
src/main/java/org/rcisoft/business/blesson/dao/BLessonPersonRepository.java
View file @
b405aa43
...
...
@@ -165,7 +165,7 @@ public interface BLessonPersonRepository extends BaseMapper<BLessonPerson> {
@ResultMap
(
value
=
"BaseResultMap"
)
List
<
BLessonPerson
>
selectPersonIdByLessonId
(
AppointLessonDTO
param
);
@Select
(
"<script>select business_id,person_id,lesson_id , learn_progress, is_finish, finish_date from b_lesson_person where 1=1 "
+
@Select
(
"<script>select business_id,person_id,lesson_id , learn_progress, is_finish, finish_date
, ever_finished
from b_lesson_person where 1=1 "
+
"and lesson_id = #{lessonId} "
+
"<if test= \" chapterId !=null and chapterId !=''\"> and chapter_id ={chapterId} </if> "
+
"</script>"
)
...
...
src/main/java/org/rcisoft/core/result/ResultServiceEnums.java
View file @
b405aa43
...
...
@@ -251,6 +251,7 @@ public enum ResultServiceEnums {
FILE_NOT_NULL
(
151
,
"文件内容不能为空"
),
VALUE_NOT_NULL
(
152
,
"积分不能为空"
),
TRAIN_SIGNED
(
153
,
"您已签到,请勿重复签到"
),
FILE_UNREADABLE
(
154
,
"该文件无法识别,可能已加密或损坏,请修正当前文件或上传其他文件"
),
;
private
Integer
code
;
...
...
src/main/java/org/rcisoft/core/util/FileReadableUtil.java
0 → 100644
View file @
b405aa43
package
org
.
rcisoft
.
core
.
util
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.pdfbox.io.RandomAccessBuffer
;
import
org.apache.pdfbox.pdfparser.PDFParser
;
import
org.apache.poi.POIXMLDocument
;
import
org.apache.poi.hslf.usermodel.HSLFSlideShow
;
import
org.apache.poi.hwpf.extractor.WordExtractor
;
import
org.apache.poi.openxml4j.opc.OPCPackage
;
import
org.rcisoft.core.exception.ServiceException
;
import
org.rcisoft.core.result.ResultServiceEnums
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.InputStream
;
@Slf4j
public
class
FileReadableUtil
{
public
static
void
main
(
String
[]
args
)
{
String
filePath
=
"C:\\Users\\三\\Desktop\\素材\\2000页.docx"
;
fileReadable
(
filePath
);
}
public
static
void
fileReadable
(
String
path
)
{
LogUtil
.
fileChangeLog
(
"-----------FileReadableUtil-路径------------"
+
path
);
File
file
=
new
File
(
path
);
InputStream
is
=
null
;
HSLFSlideShow
slideShow
=
null
;
WordExtractor
ex
=
null
;
RandomAccessBuffer
randomAccessBuffer
=
null
;
OPCPackage
opcPackage
=
null
;
try
{
if
(
path
.
endsWith
(
".doc"
))
{
is
=
new
FileInputStream
(
new
File
(
path
));
ex
=
new
WordExtractor
(
is
);
}
else
if
(
path
.
endsWith
(
"ppt"
))
{
is
=
new
FileInputStream
(
file
);
slideShow
=
new
HSLFSlideShow
(
is
);
}
else
if
(
path
.
endsWith
(
"pdf"
))
{
is
=
new
FileInputStream
(
file
);
randomAccessBuffer
=
new
RandomAccessBuffer
(
is
);
PDFParser
parser
=
new
PDFParser
(
randomAccessBuffer
);
parser
.
parse
();
}
else
if
(
path
.
endsWith
(
"docx"
)
||
path
.
endsWith
(
"pptx"
))
{
opcPackage
=
POIXMLDocument
.
openPackage
(
path
);
}
}
catch
(
Exception
e
)
{
log
.
error
(
"文件不可读---"
+
e
);
throw
new
ServiceException
(
ResultServiceEnums
.
FILE_UNREADABLE
);
}
finally
{
try
{
if
(
is
!=
null
){
is
.
close
();
}
}
catch
(
Exception
e
){
log
.
error
(
"关闭 InputStream 输出流错误!"
,
e
);
}
try
{
if
(
ex
!=
null
){
ex
.
close
();
}
}
catch
(
Exception
e
){
log
.
error
(
"关闭 WordExtractor 输出流错误!"
,
e
);
}
try
{
if
(
randomAccessBuffer
!=
null
){
randomAccessBuffer
.
close
();
}
}
catch
(
Exception
e
){
log
.
error
(
"关闭 RandomAccessBuffer 输出流错误!"
,
e
);
}
try
{
if
(
opcPackage
!=
null
){
opcPackage
.
close
();
}
}
catch
(
Exception
e
){
log
.
error
(
"关闭 OPCPackage 输出流错误!"
,
e
);
}
try
{
if
(
slideShow
!=
null
){
slideShow
.
close
();
}
}
catch
(
Exception
e
){
log
.
error
(
"关闭 HSLFSlideShow 输出流错误!"
,
e
);
}
}
}
}
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