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
2cbf362f
Commit
2cbf362f
authored
Oct 23, 2019
by
luzhuang
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/meiteng' into meiteng
parents
1481e70a
12bf4565
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
75 additions
and
28 deletions
+75
-28
BChapterServiceImpl.java
...t/business/bchapter/service/impl/BChapterServiceImpl.java
+51
-15
BRecommendRepository.java
...rg/rcisoft/business/blesson/dao/BRecommendRepository.java
+1
-1
BViewrangeRepository.java
...rg/rcisoft/business/blesson/dao/BViewrangeRepository.java
+1
-1
BLessonServiceImpl.java
...oft/business/blesson/service/impl/BLessonServiceImpl.java
+13
-8
MTCotactApiRequestClient.java
...isoft/common/util/outClient/MTCotactApiRequestClient.java
+1
-0
ResultServiceEnums.java
...main/java/org/rcisoft/core/result/ResultServiceEnums.java
+1
-0
OfficeToPdf.java
src/main/java/org/rcisoft/core/util/OfficeToPdf.java
+5
-1
application-mt.yml
src/main/resources/application-mt.yml
+2
-2
No files found.
src/main/java/org/rcisoft/business/bchapter/service/impl/BChapterServiceImpl.java
View file @
2cbf362f
...
...
@@ -307,40 +307,61 @@ public class BChapterServiceImpl implements BChapterService {
public
String
changeFile
(
BFile
bFile
){
String
filePath
=
global
.
getBASE_UPLOAD_SERVER_LOCATION
()+
"/"
+
global
.
getCOURSE_LOCATION
()+
"/"
+
bFile
.
getLessonId
();
String
returnBasePath
=
global
.
getRETURN_UPLOAD_SERVER_LOCATION
()+
"/"
+
global
.
getCOURSE_LOCATION
()+
bFile
.
getLessonId
();
String
name
=
bFile
.
getVideoUrl
().
substring
(
bFile
.
getVideoUrl
().
lastIndexOf
(
"/"
)+
1
);
String
filePath
=
global
.
getBASE_UPLOAD_SERVER_LOCATION
()
+
global
.
getCOURSE_LOCATION
()+
File
.
separator
+
bFile
.
getLessonId
();
String
returnBasePath
=
global
.
getRETURN_UPLOAD_SERVER_LOCATION
()+
global
.
getCOURSE_LOCATION
()+
File
.
separator
+
bFile
.
getLessonId
();
File
file
=
new
File
(
filePath
);
//2. pdf 本地是否存在, word ppt 转换后的pdf是否存在
File
fileOld
=
new
File
(
filePath
+
"/"
+
bFile
.
getFileName
());
String
newName
=
bFile
.
getFileName
().
substring
(
0
,
bFile
.
getFileName
().
indexOf
(
"."
))
+
"-pdf.pdf"
;
log
.
debug
(
"------------------z1-----------------------------"
+
filePath
);
File
fileOld
=
new
File
(
filePath
+
File
.
separator
+
name
);
log
.
debug
(
"------------------z2-----------------------------"
+
fileOld
);
String
newName
=
name
.
substring
(
0
,
name
.
indexOf
(
"."
))
+
"-pdf.pdf"
;
log
.
debug
(
"------------------z3-----------------------------"
+
newName
);
//转换后的路径
File
fileNew
=
new
File
(
filePath
+
"/"
+
newName
);
File
fileNew
=
new
File
(
filePath
+
File
.
separator
+
newName
);
log
.
debug
(
"------------------z4-----------------------------"
+
fileNew
.
getPath
());
if
(
"3"
.
equals
(
bFile
.
getType
()))
{
log
.
debug
(
"------------------z5-----------------------------"
);
if
(
fileOld
.
exists
())
{
return
returnBasePath
+
"/"
+
bFile
.
getFileName
();
log
.
debug
(
"------------------z6-----------------------------"
+
fileOld
);
return
returnBasePath
+
File
.
separator
+
name
;
}
else
{
String
downLoadName
=
downLoadFile
(
bFile
,
file
,
filePath
);
return
returnBasePath
+
"/"
+
downLoadName
;
log
.
debug
(
"------------------z7-----------------------------"
+
downLoadName
);
return
returnBasePath
+
File
.
separator
+
downLoadName
;
}
}
//3. pdf不存在,下载 , 删除word ppt,重新下载,转换
if
(
"2"
.
equals
(
bFile
.
getType
())
||
"4"
.
equals
(
bFile
.
getType
()))
{
log
.
debug
(
"------------------z8-----------------------------"
);
if
(
fileNew
.
exists
())
{
return
returnBasePath
+
"/"
+
newName
;
log
.
debug
(
"------------------z9-----------------------------"
);
return
returnBasePath
+
File
.
separator
+
newName
;
}
else
{
log
.
debug
(
"------------------z10-----------------------------"
);
fileOld
.
delete
();
log
.
debug
(
"------------------z11-----------------------------"
);
String
downLoadFileUrl
=
downLoadFile
(
bFile
,
file
,
filePath
);
int
result
=
officeToPdf
.
transformToPdf
(
downLoadFileUrl
,
filePath
+
"/"
+
newName
);
log
.
debug
(
"------------------z12-----------------------------downLoadFileUrl:"
+
filePath
+
File
.
separator
+
downLoadFileUrl
);
log
.
debug
(
"------------------z12-----------------------------filePath:"
+
filePath
+
File
.
separator
+
newName
);
int
result
=
officeToPdf
.
transformToPdf
(
filePath
+
File
.
separator
+
downLoadFileUrl
,
filePath
+
File
.
separator
+
newName
);
log
.
debug
(
"------------------z13-----------------------------"
);
if
(
result
<
1
)
{
log
.
error
(
"文件转换异常"
);
throw
new
ServiceException
(
ResultServiceEnums
.
CHANGE_FILE_ERROR
);
}
//4. 更新在 bfile 表 , ppt和word 存一下转换之后的url filePath
if
(
StringUtils
.
isNotEmpty
(
bFile
.
getChapterId
())){
bFile
.
setFileUrl
(
filePath
+
"/"
+
newName
);
log
.
debug
(
"------------------z14-----------------------------"
);
bFile
.
setFileUrl
(
filePath
+
File
.
separator
+
newName
);
log
.
debug
(
"------------------z15-----------------------------"
);
bFileRepository
.
updateByPrimaryKeySelective
(
bFile
);
}
return
returnBasePath
+
"/"
+
newName
;
log
.
debug
(
"------------------z16-----------------------------"
);
return
returnBasePath
+
File
.
separator
+
newName
;
}
}
else
{
return
null
;
...
...
@@ -350,8 +371,12 @@ public class BChapterServiceImpl implements BChapterService {
//下载
public
String
downLoadFile
(
BFile
bFile
,
File
file
,
String
filePath
)
{
String
name
=
bFile
.
getVideoUrl
().
substring
(
bFile
.
getVideoUrl
().
lastIndexOf
(
"/"
)+
1
);
log
.
debug
(
"------------------D1-----------------------------"
+
filePath
);
//判断文件夹是否存在
if
(!
file
.
exists
())
{
log
.
debug
(
"------------------D2-----------------------------"
);
//如果文件夹不存在,则创建新的的文件夹
file
.
mkdirs
();
}
...
...
@@ -361,25 +386,34 @@ public class BChapterServiceImpl implements BChapterService {
try
{
// 建立链接
URL
httpUrl
=
new
URL
(
bFile
.
getVideoUrl
());
log
.
debug
(
"------------------D3-----------------------------"
);
conn
=
(
HttpURLConnection
)
httpUrl
.
openConnection
();
log
.
debug
(
"------------------D4-----------------------------"
);
//以Post方式提交表单,默认get方式
conn
.
setRequestMethod
(
"GET"
);
conn
.
setDoInput
(
true
);
conn
.
setDoOutput
(
true
);
log
.
debug
(
"------------------D5-----------------------------"
);
// post方式不能使用缓存
conn
.
setUseCaches
(
false
);
log
.
debug
(
"------------------D6-----------------------------"
);
//连接指定的资源
conn
.
connect
();
//获取网络输入流
inputStream
=
conn
.
getInputStream
();
log
.
debug
(
"------------------D7-----------------------------"
);
BufferedInputStream
bis
=
new
BufferedInputStream
(
inputStream
);
log
.
debug
(
"------------------D8-----------------------------"
);
//判断文件的保存路径后面是否以/结尾
if
(!
filePath
.
endsWith
(
"/"
))
{
filePath
+=
"/"
;
if
(!
filePath
.
endsWith
(
File
.
separator
))
{
log
.
debug
(
"------------------D9-----------------------------"
,
filePath
);
filePath
+=
File
.
separator
;
}
//写入到文件(注意文件保存路径的后面一定要加上文件的名称)
fileOut
=
new
FileOutputStream
(
filePath
+
bFile
.
getFileName
());
fileOut
=
new
FileOutputStream
(
filePath
+
name
);
log
.
debug
(
"------------------D10-----------------------------"
);
BufferedOutputStream
bos
=
new
BufferedOutputStream
(
fileOut
);
log
.
debug
(
"------------------D11-----------------------------"
);
byte
[]
buf
=
new
byte
[
4096
];
int
length
=
bis
.
read
(
buf
);
//保存文件
...
...
@@ -390,11 +424,13 @@ public class BChapterServiceImpl implements BChapterService {
bos
.
close
();
bis
.
close
();
conn
.
disconnect
();
log
.
debug
(
"------------------D12-----------------------------"
);
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
()
+
"下载文件异常"
);
throw
new
ServiceException
(
ResultServiceEnums
.
DOWNLOAD_ERROR
);
}
return
bFile
.
getFileName
();
log
.
debug
(
"------------------D13-----------------------------"
+
name
);
return
name
;
}
@Override
...
...
src/main/java/org/rcisoft/business/blesson/dao/BRecommendRepository.java
View file @
2cbf362f
...
...
@@ -90,7 +90,7 @@ public interface BRecommendRepository extends BaseMapper<BRecommend> {
" and brs.type = '1' "
+
" <if test=\"departs != null and departs.size() > 0 \"> "
+
" and brs.target_id in "
+
" <foreach item='item' index='index' collection='departs' open='(' separator=',' close=')'> #{item.
departI
d} </foreach> "
+
" <foreach item='item' index='index' collection='departs' open='(' separator=',' close=')'> #{item.
i
d} </foreach> "
+
" </if> "
+
" and br.lesson_id = #{lessonId}</script>"
)
...
...
src/main/java/org/rcisoft/business/blesson/dao/BViewrangeRepository.java
View file @
2cbf362f
...
...
@@ -35,7 +35,7 @@ public interface BViewrangeRepository extends BaseMapper<BViewrange> {
" <if test='delFlag != null'>del_flag=#{delFlag},</if> "
,
" <if test='flag != null'>flag=#{flag},</if> "
,
" <if test='remarks != null'>remarks=#{remarks},</if> "
,
" <if test='lesson
_i
d != null'>lesson_id=#{lessonId},</if> "
,
" <if test='lesson
I
d != null'>lesson_id=#{lessonId},</if> "
,
" <if test='type != null'>type=#{type},</if> "
,
" <if test='corp_id != null'>corp_id=#{corp_id},</if> "
,
" </set>"
,
...
...
src/main/java/org/rcisoft/business/blesson/service/impl/BLessonServiceImpl.java
View file @
2cbf362f
...
...
@@ -79,6 +79,10 @@ public class BLessonServiceImpl implements BLessonService {
@Transactional
(
propagation
=
Propagation
.
REQUIRED
,
readOnly
=
false
)
public
BLesson
selectOne
(
CurUser
curUser
,
String
lessonId
)
{
BLesson
bLesson
=
bLessonRepository
.
selectInfoById
(
lessonId
);
if
(
bLesson
==
null
){
throw
new
ServiceException
(
ResultServiceEnums
.
NOT_LESSON_ERROR
);
}
if
(
"1"
.
equals
(
bLesson
.
getLessonType
())){
List
<
BTrainFile
>
bTrainFileList
=
bTrainFileRepository
.
queryByLessonId
(
bLesson
.
getBusinessId
());
bLesson
.
setBTrainFileList
(
bTrainFileList
);
...
...
@@ -91,9 +95,6 @@ public class BLessonServiceImpl implements BLessonService {
bLesson
.
setViewRangePersonList
(
selectPersonByLessonIds
);
//查询该课程推荐的所有部门
List
<
BViewRangeSonDTO
>
selectDepartByLessonIds
=
bViewrangeRepository
.
selectDepartByLessonId
(
curUser
.
getCorpId
(),
lessonId
);
if
(
selectDepartByLessonIds
!=
null
&&
selectDepartByLessonIds
.
size
()
>
0
){
for
(
FindDepartByNameDTO
depart
:
departs
)
{
for
(
BViewRangeSonDTO
selectDepartByLessonId
:
selectDepartByLessonIds
)
{
...
...
@@ -104,7 +105,6 @@ public class BLessonServiceImpl implements BLessonService {
}
bLesson
.
setViewRangeDepartList
(
selectDepartByLessonIds
);
}
return
bLesson
;
}
...
...
@@ -471,13 +471,19 @@ public class BLessonServiceImpl implements BLessonService {
// if (StringUtils.isEmpty(param.getViewParam())){
// param.setViewParam("");
// }
List
<
FindDepartByNameDTO
>
departs
=
cotactApiRequestClient
.
deptListDeptInfoByName
(
param
.
getCorpId
(),
param
.
getViewParam
());
String
viewParam
=
param
.
getViewParam
();
if
(
StringUtils
.
isEmpty
(
viewParam
)){
viewParam
=
""
;
}
List
<
FindDepartByNameDTO
>
departs
=
cotactApiRequestClient
.
deptListDeptInfoByName
(
param
.
getCorpId
(),
viewParam
);
//查询结果放入DTO中
param
.
setDeparts
(
departs
);
//查询该课程推荐的所有人
List
<
FindLessonRecommendRspDTO
>
findLessonPersonRecommend
=
bRecommendRepository
.
queryRecommendPersonByLessonId
(
param
);
List
<
FindLessonRecommendRspDTO
>
findLessonPersonRecommend
=
new
ArrayList
<>();
findLessonPersonRecommend
=
bRecommendRepository
.
queryRecommendPersonByLessonId
(
param
);
//查询该课程推荐的所有部门
List
<
FindLessonRecommendRspDTO
>
findLessonDepartRecommend
=
bRecommendRepository
.
queryRecommendDepartByLessonId
(
param
);
List
<
FindLessonRecommendRspDTO
>
findLessonDepartRecommend
=
new
ArrayList
<>();
findLessonDepartRecommend
=
bRecommendRepository
.
queryRecommendDepartByLessonId
(
param
);
if
(
departs
!=
null
&&
departs
.
size
()
>
0
&&
findLessonDepartRecommend
!=
null
&&
findLessonDepartRecommend
.
size
()
>
0
)
{
for
(
FindDepartByNameDTO
depart
:
departs
)
{
...
...
@@ -489,7 +495,6 @@ public class BLessonServiceImpl implements BLessonService {
}
findLessonPersonRecommend
.
addAll
(
findLessonDepartRecommend
);
}
return
findLessonPersonRecommend
;
}
...
...
src/main/java/org/rcisoft/common/util/outClient/MTCotactApiRequestClient.java
View file @
2cbf362f
...
...
@@ -14,6 +14,7 @@ import org.rcisoft.common.util.feignDto.*;
import
org.rcisoft.core.exception.ServiceException
;
import
org.rcisoft.core.result.ResultServiceEnums
;
import
org.rcisoft.core.result.Ret
;
import
org.rcisoft.core.util.UserUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Component
;
...
...
src/main/java/org/rcisoft/core/result/ResultServiceEnums.java
View file @
2cbf362f
...
...
@@ -220,6 +220,7 @@ public enum ResultServiceEnums {
NOT_RECOMMEND
(
118
,
"该课程未推荐"
),
NO_DATA
(
119
,
"该数据不存在"
),
CHANGE_FILE_ERROR
(
120
,
"文件转换失败"
),
NOT_LESSON_ERROR
(
121
,
"该课程不存在"
),
;
...
...
src/main/java/org/rcisoft/core/util/OfficeToPdf.java
View file @
2cbf362f
...
...
@@ -90,19 +90,23 @@ public class OfficeToPdf {
if
(!
inputFile
.
exists
())
{
return
-
1
;
// 找不到源文件, 则返回-1
}
log
.
debug
(
"----------ZH------------"
);
// 如果目标路径不存在, 则新建该路径
File
outputFile
=
new
File
(
destFile
);
if
(!
outputFile
.
getParentFile
().
exists
())
{
outputFile
.
getParentFile
().
mkdirs
();
}
log
.
debug
(
"----------ZH------------"
);
// connect to an OpenOffice.org instance running on port 8100
connection
=
new
SocketOpenOfficeConnection
(
global
.
getLibreofficeIp
(),
global
.
getLibreofficePort
());
connection
.
connect
();
// convert
log
.
debug
(
"----------ZH------------"
);
DocumentConverter
converter
=
new
OpenOfficeDocumentConverter
(
connection
);
DocumentFormatRegistry
factory
=
new
BasicDocumentFormatRegistry
();
log
.
debug
(
"----------ZH------------"
);
DocumentFormat
inputDocumentFormat
=
factory
.
getFormatByFileExtension
(
FileUtil
.
getFilePostfix
(
sourceFile
));
DocumentFormat
outputDocumentFormat
=
factory
...
...
@@ -120,7 +124,7 @@ public class OfficeToPdf {
if
(
connection
!=
null
)
{
connection
.
disconnect
();
}
else
{
throw
new
ServiceException
(
ResultServiceEnums
.
UPLOAD
_ERROR
);
throw
new
ServiceException
(
ResultServiceEnums
.
CHANGE_FILE
_ERROR
);
}
}
return
1
;
...
...
src/main/resources/application-mt.yml
View file @
2cbf362f
...
...
@@ -74,7 +74,7 @@ global:
licPath
:
/lk/license.lic
pubPath
:
/lk/publicCerts.store
path
:
base_upload_server_location
:
/working/
resource/
eduServer/
base_upload_server_location
:
/working/eduServer/
return_upload_server_location
:
http://192.168.5.201:18080/eduServer/
course_location
:
course
lesson_location
:
lesson
...
...
@@ -93,7 +93,7 @@ global:
cut_pdf_num
:
30
libreoffice
:
ip
:
mt_
offic
e
ip
:
mt_
libr
e
port
:
8997
mt
:
api
:
http://192.168.5.201/api/
...
...
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