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
f4fc0d1b
Commit
f4fc0d1b
authored
Dec 17, 2019
by
zhangqingle
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加培训文件可读验证,增加收藏时间
parent
eb47ad80
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
130 additions
and
45 deletions
+130
-45
BChapterController.java
...soft/business/bchapter/controller/BChapterController.java
+12
-0
FileTypeEnum.java
...ava/org/rcisoft/business/bchapter/enums/FileTypeEnum.java
+1
-0
BChapterService.java
...rg/rcisoft/business/bchapter/service/BChapterService.java
+7
-0
BChapterServiceImpl.java
...t/business/bchapter/service/impl/BChapterServiceImpl.java
+25
-7
BDiscussServiceImpl.java
...t/business/bdiscuss/service/impl/BDiscussServiceImpl.java
+12
-13
BLessonRepository.java
...a/org/rcisoft/business/blesson/dao/BLessonRepository.java
+3
-1
BCollect.java
...in/java/org/rcisoft/business/blesson/entity/BCollect.java
+1
-1
BLessonServiceImpl.java
...oft/business/blesson/service/impl/BLessonServiceImpl.java
+23
-6
ResultServiceEnums.java
...main/java/org/rcisoft/core/result/ResultServiceEnums.java
+1
-0
FileReadableUtil.java
src/main/java/org/rcisoft/core/util/FileReadableUtil.java
+37
-10
OfficeToPdf.java
src/main/java/org/rcisoft/core/util/OfficeToPdf.java
+7
-0
BCollectMapper.xml
...sources/mapper/business/blesson/mapper/BCollectMapper.xml
+1
-7
No files found.
src/main/java/org/rcisoft/business/bchapter/controller/BChapterController.java
View file @
f4fc0d1b
...
...
@@ -154,6 +154,18 @@ public class BChapterController extends PaginationController<BChapter> {
newFileUrl
);
}
@ApiOperation
(
value
=
"209 判断文件是否可读"
,
notes
=
"判断文件是否可读(培训 需要预览的附件)"
)
@GetMapping
(
"/fileReadable"
)
public
Result
fileReadable
(
CurUser
curUser
,
@Valid
BFile
file
,
BindingResult
br
)
throws
IOException
{
String
res
=
bChapterService
.
fileReadable
(
file
);
return
Result
.
builder
(
new
PersistModel
(
1
),
MessageConstant
.
MESSAGE_ALERT_SUCCESS
,
MessageConstant
.
MESSAGE_ALERT_ERROR
,
res
);
}
// @ApiOperation(value = "209 查询章节带进度(外部分享)", notes = "查询章节带进度(外部分享)", response = QueryChapterListResDTO.class)
// @GetMapping(value = "/queryShareBChaptersWithProgress")
// public Result queryShareBChaptersWithProgress(CurUser curUser, @RequestParam String lessonId, BindingResult br) {
...
...
src/main/java/org/rcisoft/business/bchapter/enums/FileTypeEnum.java
View file @
f4fc0d1b
...
...
@@ -7,6 +7,7 @@ public enum FileTypeEnum {
PPT
(
"2"
),
PDF
(
"3"
),
WORD
(
"4"
),
TXT
(
"6"
),
;
FileTypeEnum
(
String
code
)
{
...
...
src/main/java/org/rcisoft/business/bchapter/service/BChapterService.java
View file @
f4fc0d1b
...
...
@@ -104,6 +104,13 @@ public interface BChapterService{
*/
String
getDownLoadUrl
(
BFile
bFile
);
/**
* 判断文件是否
* @param bFile
* @return
*/
String
fileReadable
(
BFile
bFile
);
/**
* 打分
* @param scoreInfoDTOS
...
...
src/main/java/org/rcisoft/business/bchapter/service/impl/BChapterServiceImpl.java
View file @
f4fc0d1b
...
...
@@ -625,6 +625,25 @@ public class BChapterServiceImpl implements BChapterService {
}
}
@Override
public
String
fileReadable
(
BFile
bFile
)
{
String
flag
=
"1"
;
String
name
=
bFile
.
getVideoUrl
().
substring
(
bFile
.
getVideoUrl
().
lastIndexOf
(
"/"
)
+
1
);
String
filePath
=
global
.
getBASE_UPLOAD_SERVER_LOCATION
()
+
global
.
getCOURSE_LOCATION
()
+
File
.
separator
+
"temp"
;
File
file
=
new
File
(
filePath
);
File
fileOld
=
new
File
(
filePath
+
File
.
separator
+
name
);
if
(
fileOld
.
exists
())
{
LogUtil
.
fileChangeLog
(
"------------------文件名重复-------------------------"
+
fileOld
);
throw
new
ServiceException
(
ResultServiceEnums
.
DUP_FILE
);
}
else
{
LogUtil
.
fileChangeLog
(
"------------------下载-------------------------"
+
fileOld
);
String
downLoadName
=
downLoadFile
(
bFile
,
file
,
filePath
);
LogUtil
.
fileChangeLog
(
"------------------判断可读-------------------------"
+
fileOld
);
FileReadableUtil
.
fileReadable
(
filePath
+
File
.
separator
+
downLoadName
);
}
return
flag
;
}
public
String
changeFile
(
BFile
bFile
)
{
LogUtil
.
fileChangeLog
(
"****************request + begin***********"
+
DateFormatUtils
.
format
(
new
Date
(),
"HH:mm:ss"
));
...
...
@@ -654,8 +673,8 @@ public class BChapterServiceImpl implements BChapterService {
}
}
//3. pdf不存在,下载 , 删除word ppt,重新下载,转换
if
(
FileTypeEnum
.
PPT
.
getCode
().
equals
(
bFile
.
getType
())
||
FileTypeEnum
.
WORD
.
getCode
().
equals
(
bFile
.
getType
()))
{
LogUtil
.
fileChangeLog
(
"------------------文件为ppt或word----------------------------"
);
if
(
FileTypeEnum
.
PPT
.
getCode
().
equals
(
bFile
.
getType
())
||
FileTypeEnum
.
WORD
.
getCode
().
equals
(
bFile
.
getType
())
||
FileTypeEnum
.
TXT
.
getCode
().
equals
(
bFile
.
getType
())
)
{
LogUtil
.
fileChangeLog
(
"------------------文件为ppt或word
或txt
----------------------------"
);
if
(
fileNew
.
exists
())
{
LogUtil
.
fileChangeLog
(
"------------------转换后文件存在直接返回-----------------------------"
);
return
returnBasePath
+
File
.
separator
+
newName
;
...
...
@@ -663,15 +682,14 @@ public class BChapterServiceImpl implements BChapterService {
LogUtil
.
fileChangeLog
(
"------------------删除老文件----------------------------"
);
fileOld
.
delete
();
LogUtil
.
fileChangeLog
(
"------------------设置下载路径----------------------------"
);
String
downLoadFile
Url
=
downLoadFile
(
bFile
,
file
,
filePath
);
String
downLoadFile
Name
=
downLoadFile
(
bFile
,
file
,
filePath
);
//判断文件是否可读
LogUtil
.
fileChangeLog
(
"------------------判断文件是否可读-----------------------------"
+
filePath
+
File
.
separator
+
name
);
FileReadableUtil
.
fileReadable
(
filePath
+
File
.
separator
+
downLoadFileUrl
);
LogUtil
.
fileChangeLog
(
"-----------------------------------------------downLoadFileUrl:"
+
filePath
+
File
.
separator
+
downLoadFileUrl
);
FileReadableUtil
.
fileReadable
(
filePath
+
File
.
separator
+
downLoadFileName
);
LogUtil
.
fileChangeLog
(
"-----------------------------------------------downLoadFileUrl:"
+
filePath
+
File
.
separator
+
downLoadFileName
);
LogUtil
.
fileChangeLog
(
"-----------------------------------------------filePath:"
+
filePath
+
File
.
separator
+
newName
);
int
result
=
officeToPdf
.
transformToPdf
(
filePath
+
File
.
separator
+
downLoadFile
Url
,
filePath
+
File
.
separator
+
newName
);
int
result
=
officeToPdf
.
transformToPdf
(
filePath
+
File
.
separator
+
downLoadFile
Name
,
filePath
+
File
.
separator
+
newName
);
LogUtil
.
fileChangeLog
(
"------------------转换完毕-----------------------------"
);
if
(
result
<
1
)
{
log
.
error
(
"文件转换异常"
);
...
...
src/main/java/org/rcisoft/business/bdiscuss/service/impl/BDiscussServiceImpl.java
View file @
f4fc0d1b
...
...
@@ -122,19 +122,18 @@ public class BDiscussServiceImpl implements BDiscussService {
}
if
(
StringUtils
.
isBlank
(
bDiscuss
.
getLevel
())
&&
"1"
.
equals
(
bDiscuss
.
getLevel
())
&&
"1"
.
equals
(
messageFBPL
.
getFlag
())){
try
{
BNotice
bNotice
=
new
BNotice
();
bNotice
.
setInfoType
(
InfoTypeEnum
.
REPLY_DISCUSS
.
getValue
());
bNotice
.
setLessonId
(
bDiscuss
.
getLessonId
());
bNotice
.
setSenderId
(
curUser
.
getUserId
());
bNotice
.
setCorpId
(
curUser
.
getCorpId
());
// 获取课程信息
BLesson
bLesson
=
lessonRepository
.
selectByPrimaryKey
(
bDiscuss
.
getLessonId
());
bNotice
.
setRecipientIds
(
new
ArrayList
<>(
Arrays
.
asList
(
bLesson
.
getLecturerId
())));
String
lessonType
=
LessonTypeEnum
.
LESSON
.
getCode
().
equals
(
bLesson
.
getLessonType
())
?
"线上课程"
:
"线下培训"
;
String
urlType
=
LessonTypeEnum
.
LESSON
.
getCode
().
equals
(
bLesson
.
getLessonType
())
?
UrlTypeEnum
.
LESSON
.
getName
()
:
UrlTypeEnum
.
TRAIN
.
getName
();
bNotice
.
setInfoText
(
sysUserServiceImpl
.
getNameById
(
bDiscuss
.
getStudentId
()).
getName
()
+
"评论了您主讲的"
+
lessonType
+
"\""
+
bLesson
.
getLessonName
()+
"\""
);
// 发消息
BNotice
bNotice
=
new
BNotice
();
bNotice
.
setInfoType
(
InfoTypeEnum
.
REPLY_DISCUSS
.
getValue
());
bNotice
.
setLessonId
(
bDiscuss
.
getLessonId
());
bNotice
.
setSenderId
(
curUser
.
getUserId
());
bNotice
.
setCorpId
(
curUser
.
getCorpId
());
// 获取课程信息
BLesson
bLesson
=
lessonRepository
.
selectByPrimaryKey
(
bDiscuss
.
getLessonId
());
bNotice
.
setRecipientIds
(
new
ArrayList
<>(
Arrays
.
asList
(
bLesson
.
getLecturerId
())));
String
lessonType
=
LessonTypeEnum
.
LESSON
.
getCode
().
equals
(
bLesson
.
getLessonType
())
?
"线上课程"
:
"线下培训"
;
String
urlType
=
LessonTypeEnum
.
LESSON
.
getCode
().
equals
(
bLesson
.
getLessonType
())
?
UrlTypeEnum
.
LESSON
.
getName
()
:
UrlTypeEnum
.
TRAIN
.
getName
();
bNotice
.
setInfoText
(
sysUserServiceImpl
.
getNameById
(
bDiscuss
.
getStudentId
()).
getName
()
+
"评论了您主讲的"
+
lessonType
+
"\""
+
bLesson
.
getLessonName
()+
"\""
);
// 发消息
client
.
send
(
bNotice
,
InfoTypeEnum
.
REPLY_DISCUSS
.
getLable
(),
MessageEnum
.
FBPL
.
getName
(),
urlType
);
}
catch
(
Exception
e
){
log
.
info
(
"发送通知失败,"
+
e
);
...
...
src/main/java/org/rcisoft/business/blesson/dao/BLessonRepository.java
View file @
f4fc0d1b
...
...
@@ -1120,7 +1120,9 @@ public interface BLessonRepository extends BaseMapper<BLesson> {
"and bl.del_flag = 0 and bl.flag = 1 "
+
"and bl.corp_id = #{curUser.corpId} "
+
" <if test=\"lessonType!=null and lessonType != ''\">and bl.lesson_type = #{lessonType}</if>"
+
"AND bc.person_id = #{curUser.userId} </script>"
)
" AND bc.person_id = #{curUser.userId} "
+
" order by bc.collect_date desc "
+
" </script>"
)
@ResultMap
(
value
=
"BaseResultMap"
)
List
<
BLesson
>
selectMyCollect
(
@Param
(
"lessonType"
)
String
lessonType
,
@Param
(
"curUser"
)
CurUser
curUser
);
...
...
src/main/java/org/rcisoft/business/blesson/entity/BCollect.java
View file @
f4fc0d1b
...
...
@@ -28,6 +28,6 @@ public class BCollect{
private
String
lessonId
;
private
Date
collectDate
;
}
src/main/java/org/rcisoft/business/blesson/service/impl/BLessonServiceImpl.java
View file @
f4fc0d1b
...
...
@@ -1146,6 +1146,7 @@ public class BLessonServiceImpl implements BLessonService {
BCollect
bCollect
=
new
BCollect
();
bCollect
.
setLessonId
(
lessonId
);
bCollect
.
setPersonId
(
curUser
.
getUserId
());
bCollect
.
setCollectDate
(
new
Date
());
int
line
=
bCollectRepository
.
insertSelective
(
bCollect
);
//重新统计课程收藏数
bLessonRepository
.
collectNumberReCount
(
lessonId
);
...
...
@@ -1257,11 +1258,7 @@ public class BLessonServiceImpl implements BLessonService {
if
(
one
.
size
()
>
0
)
{
return
new
PersistModel
(
1
);
}
BCollect
bCollect
=
new
BCollect
();
bCollect
.
setBusinessId
(
IdGen
.
uuid
());
bCollect
.
setLessonId
(
lessonId
);
bCollect
.
setPersonId
(
curUser
.
getUserId
());
BCollect
bCollect
=
new
BCollect
(
IdGen
.
uuid
(),
curUser
.
getUserId
(),
lessonId
,
new
Date
());
int
line
=
bCollectRepository
.
insert
(
bCollect
);
//更新课程表收藏个数
bLessonRepository
.
collectNumberReCount
(
lessonId
);
...
...
@@ -1392,7 +1389,27 @@ public class BLessonServiceImpl implements BLessonService {
@Override
@Transactional
(
propagation
=
Propagation
.
REQUIRED
,
readOnly
=
false
)
public
List
<
BLesson
>
queryCollectByPagination
(
PageUtil
pageUtil
,
String
lessonType
,
CurUser
curUser
)
{
return
bLessonRepository
.
selectMyCollect
(
lessonType
,
curUser
);
List
<
BLesson
>
bLessonList
=
bLessonRepository
.
selectMyCollect
(
lessonType
,
curUser
);
Date
now
=
new
Date
();
if
(
LessonTypeEnum
.
TRAIN
.
getCode
().
equals
(
lessonType
)){
bLessonList
.
forEach
(
bLesson
->
{
setDateState
(
bLesson
);
if
(
bLesson
.
getTrainStartDate
()
==
null
||
bLesson
.
getTrainOverDate
()
==
null
||
bLesson
.
getTrainSignTime
()
==
null
)
{
return
;
}
Long
time
=
Long
.
parseLong
(
bLesson
.
getTrainSignTime
())
*
60
*
1000
;
Date
signStart
=
new
Date
(
bLesson
.
getTrainStartDate
().
getTime
()
-
time
);
if
(
now
.
before
(
signStart
))
{
bLesson
.
setTrainType
(
"0"
);
}
else
if
(
bLesson
.
getTrainOverDate
().
before
(
now
))
{
bLesson
.
setTrainType
(
"2"
);
}
else
{
bLesson
.
setTrainType
(
"1"
);
}
});
}
return
bLessonList
;
}
@Override
...
...
src/main/java/org/rcisoft/core/result/ResultServiceEnums.java
View file @
f4fc0d1b
...
...
@@ -252,6 +252,7 @@ public enum ResultServiceEnums {
VALUE_NOT_NULL
(
152
,
"积分不能为空"
),
TRAIN_SIGNED
(
153
,
"您已签到,请勿重复签到"
),
FILE_UNREADABLE
(
154
,
"该文件无法识别,可能已加密或损坏,请修正当前文件或上传其他文件"
),
DUP_FILE
(
155
,
"文件重复"
),
;
private
Integer
code
;
...
...
src/main/java/org/rcisoft/core/util/FileReadableUtil.java
View file @
f4fc0d1b
package
org
.
rcisoft
.
core
.
util
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.io.FileUtils
;
import
org.apache.pdfbox.io.RandomAccessBuffer
;
import
org.apache.pdfbox.pdfparser.PDFParser
;
import
org.apache.poi.POIXMLDocument
;
...
...
@@ -10,9 +11,7 @@ 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
;
import
java.io.*
;
@Slf4j
public
class
FileReadableUtil
{
...
...
@@ -49,12 +48,6 @@ public class FileReadableUtil {
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
){
...
...
@@ -84,8 +77,42 @@ public class FileReadableUtil {
}
catch
(
Exception
e
){
log
.
error
(
"关闭 HSLFSlideShow 输出流错误!"
,
e
);
}
}
try
{
if
(
is
!=
null
){
is
.
close
();
}
}
catch
(
Exception
e
){
log
.
error
(
"关闭 InputStream 输出流错误!"
,
e
);
}
}
public
File
TXTHandler
(
File
file
)
{
//或GBK
String
code
=
"gb2312"
;
byte
[]
head
=
new
byte
[
3
];
try
{
InputStream
inputStream
=
new
FileInputStream
(
file
);
inputStream
.
read
(
head
);
if
(
head
[
0
]
==
-
1
&&
head
[
1
]
==
-
2
)
{
code
=
"UTF-16"
;
}
else
if
(
head
[
0
]
==
-
2
&&
head
[
1
]
==
-
1
)
{
code
=
"Unicode"
;
}
else
if
(
head
[
0
]
==
-
17
&&
head
[
1
]
==
-
69
&&
head
[
2
]
==
-
65
)
{
code
=
"UTF-8"
;
}
inputStream
.
close
();
System
.
out
.
println
(
code
);
if
(
code
.
equals
(
"UTF-8"
))
{
return
file
;
}
String
str
=
FileUtils
.
readFileToString
(
file
,
code
);
FileUtils
.
writeStringToFile
(
file
,
str
,
"UTF-8"
);
}
catch
(
FileNotFoundException
e
)
{
e
.
printStackTrace
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
return
file
;
}
}
src/main/java/org/rcisoft/core/util/OfficeToPdf.java
View file @
f4fc0d1b
...
...
@@ -131,6 +131,13 @@ public class OfficeToPdf {
if
(!
inputFile
.
exists
())
{
return
-
1
;
// 找不到源文件, 则返回-1
}
//若为txt 设置txt编码集
if
(
sourceFile
.
substring
(
sourceFile
.
lastIndexOf
(
"."
)).
equalsIgnoreCase
(
".txt"
))
{
LogUtil
.
fileChangeLog
(
"------------------设置txt编码集-----------------------------"
);
new
FileReadableUtil
().
TXTHandler
(
inputFile
);
}
LogUtil
.
fileChangeLog
(
"----------如果目标路径不存在, 则新建该路径------------"
);
// 如果目标路径不存在, 则新建该路径
File
outputFile
=
new
File
(
destFile
);
...
...
src/main/resources/mapper/business/blesson/mapper/BCollectMapper.xml
View file @
f4fc0d1b
...
...
@@ -3,13 +3,7 @@
<mapper
namespace=
"org.rcisoft.business.blesson.dao.BCollectRepository"
>
<resultMap
id=
"BaseResultMap"
type=
"org.rcisoft.business.blesson.entity.BCollect"
>
<id
column=
"business_id"
jdbcType=
"VARCHAR"
property=
"businessId"
/>
<result
column=
"create_by"
jdbcType=
"VARCHAR"
property=
"createBy"
/>
<result
column=
"create_date"
jdbcType=
"TIMESTAMP"
property=
"createDate"
/>
<result
column=
"update_by"
jdbcType=
"VARCHAR"
property=
"updateBy"
/>
<result
column=
"update_date"
jdbcType=
"TIMESTAMP"
property=
"updateDate"
/>
<result
column=
"del_flag"
jdbcType=
"VARCHAR"
property=
"delFlag"
/>
<result
column=
"flag"
jdbcType=
"VARCHAR"
property=
"flag"
/>
<result
column=
"remarks"
jdbcType=
"VARCHAR"
property=
"remarks"
/>
<result
column=
"collect_date"
jdbcType=
"TIMESTAMP"
property=
"collectDate"
/>
<result
column=
"person_id"
jdbcType=
"VARCHAR"
property=
"personId"
/>
<result
column=
"lesson_id"
jdbcType=
"VARCHAR"
property=
"lessonId"
/>
</resultMap>
...
...
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