Commit 2cbf362f authored by luzhuang's avatar luzhuang

Merge remote-tracking branch 'origin/meiteng' into meiteng

parents 1481e70a 12bf4565
...@@ -307,40 +307,61 @@ public class BChapterServiceImpl implements BChapterService { ...@@ -307,40 +307,61 @@ public class BChapterServiceImpl implements BChapterService {
public String changeFile(BFile bFile){ public String changeFile(BFile bFile){
String filePath = global.getBASE_UPLOAD_SERVER_LOCATION()+"/"+global.getCOURSE_LOCATION()+"/"+bFile.getLessonId(); String name = bFile.getVideoUrl().substring(bFile.getVideoUrl().lastIndexOf("/")+1);
String returnBasePath = global.getRETURN_UPLOAD_SERVER_LOCATION()+"/"+global.getCOURSE_LOCATION()+bFile.getLessonId();
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); File file=new File(filePath);
//2. pdf 本地是否存在, word ppt 转换后的pdf是否存在 //2. pdf 本地是否存在, word ppt 转换后的pdf是否存在
File fileOld = new File(filePath + "/" + bFile.getFileName()); log.debug("------------------z1-----------------------------"+filePath);
String newName = bFile.getFileName().substring(0, bFile.getFileName().indexOf(".")) + "-pdf.pdf"; 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())) { if ("3".equals(bFile.getType())) {
log.debug("------------------z5-----------------------------");
if (fileOld.exists()) { if (fileOld.exists()) {
return returnBasePath + "/" + bFile.getFileName(); log.debug("------------------z6-----------------------------"+fileOld);
return returnBasePath + File.separator + name;
} else { } else {
String downLoadName = downLoadFile(bFile, file, filePath); String downLoadName = downLoadFile(bFile, file, filePath);
return returnBasePath + "/" + downLoadName; log.debug("------------------z7-----------------------------"+downLoadName);
return returnBasePath + File.separator + downLoadName;
} }
} }
//3. pdf不存在,下载 , 删除word ppt,重新下载,转换 //3. pdf不存在,下载 , 删除word ppt,重新下载,转换
if ("2".equals(bFile.getType()) || "4".equals(bFile.getType())) { if ("2".equals(bFile.getType()) || "4".equals(bFile.getType())) {
log.debug("------------------z8-----------------------------");
if (fileNew.exists()) { if (fileNew.exists()) {
return returnBasePath + "/" + newName; log.debug("------------------z9-----------------------------");
return returnBasePath + File.separator + newName;
} else { } else {
log.debug("------------------z10-----------------------------");
fileOld.delete(); fileOld.delete();
log.debug("------------------z11-----------------------------");
String downLoadFileUrl = downLoadFile(bFile, file, filePath); 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) { if (result < 1) {
log.error("文件转换异常"); log.error("文件转换异常");
throw new ServiceException(ResultServiceEnums.CHANGE_FILE_ERROR); throw new ServiceException(ResultServiceEnums.CHANGE_FILE_ERROR);
} }
//4. 更新在 bfile 表 , ppt和word 存一下转换之后的url filePath //4. 更新在 bfile 表 , ppt和word 存一下转换之后的url filePath
if (StringUtils.isNotEmpty(bFile.getChapterId())){ if (StringUtils.isNotEmpty(bFile.getChapterId())){
bFile.setFileUrl(filePath+"/"+newName); log.debug("------------------z14-----------------------------");
bFile.setFileUrl(filePath+File.separator+newName);
log.debug("------------------z15-----------------------------");
bFileRepository.updateByPrimaryKeySelective(bFile); bFileRepository.updateByPrimaryKeySelective(bFile);
} }
return returnBasePath+"/"+newName; log.debug("------------------z16-----------------------------");
return returnBasePath+File.separator+newName;
} }
} else { } else {
return null; return null;
...@@ -350,8 +371,12 @@ public class BChapterServiceImpl implements BChapterService { ...@@ -350,8 +371,12 @@ public class BChapterServiceImpl implements BChapterService {
//下载 //下载
public String downLoadFile(BFile bFile, File file, String filePath) { 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()) { if (!file.exists()) {
log.debug("------------------D2-----------------------------");
//如果文件夹不存在,则创建新的的文件夹 //如果文件夹不存在,则创建新的的文件夹
file.mkdirs(); file.mkdirs();
} }
...@@ -361,25 +386,34 @@ public class BChapterServiceImpl implements BChapterService { ...@@ -361,25 +386,34 @@ public class BChapterServiceImpl implements BChapterService {
try { try {
// 建立链接 // 建立链接
URL httpUrl = new URL(bFile.getVideoUrl()); URL httpUrl = new URL(bFile.getVideoUrl());
log.debug("------------------D3-----------------------------");
conn = (HttpURLConnection) httpUrl.openConnection(); conn = (HttpURLConnection) httpUrl.openConnection();
log.debug("------------------D4-----------------------------");
//以Post方式提交表单,默认get方式 //以Post方式提交表单,默认get方式
conn.setRequestMethod("GET"); conn.setRequestMethod("GET");
conn.setDoInput(true); conn.setDoInput(true);
conn.setDoOutput(true); conn.setDoOutput(true);
log.debug("------------------D5-----------------------------");
// post方式不能使用缓存 // post方式不能使用缓存
conn.setUseCaches(false); conn.setUseCaches(false);
log.debug("------------------D6-----------------------------");
//连接指定的资源 //连接指定的资源
conn.connect(); conn.connect();
//获取网络输入流 //获取网络输入流
inputStream = conn.getInputStream(); inputStream = conn.getInputStream();
log.debug("------------------D7-----------------------------");
BufferedInputStream bis = new BufferedInputStream(inputStream); BufferedInputStream bis = new BufferedInputStream(inputStream);
log.debug("------------------D8-----------------------------");
//判断文件的保存路径后面是否以/结尾 //判断文件的保存路径后面是否以/结尾
if (!filePath.endsWith("/")) { if (!filePath.endsWith(File.separator)) {
filePath += "/"; 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); BufferedOutputStream bos = new BufferedOutputStream(fileOut);
log.debug("------------------D11-----------------------------");
byte[] buf = new byte[4096]; byte[] buf = new byte[4096];
int length = bis.read(buf); int length = bis.read(buf);
//保存文件 //保存文件
...@@ -390,11 +424,13 @@ public class BChapterServiceImpl implements BChapterService { ...@@ -390,11 +424,13 @@ public class BChapterServiceImpl implements BChapterService {
bos.close(); bos.close();
bis.close(); bis.close();
conn.disconnect(); conn.disconnect();
log.debug("------------------D12-----------------------------");
} catch (Exception e) { } catch (Exception e) {
log.error(e.getMessage() + "下载文件异常"); log.error(e.getMessage() + "下载文件异常");
throw new ServiceException(ResultServiceEnums.DOWNLOAD_ERROR); throw new ServiceException(ResultServiceEnums.DOWNLOAD_ERROR);
} }
return bFile.getFileName(); log.debug("------------------D13-----------------------------"+name);
return name;
} }
@Override @Override
......
...@@ -90,7 +90,7 @@ public interface BRecommendRepository extends BaseMapper<BRecommend> { ...@@ -90,7 +90,7 @@ public interface BRecommendRepository extends BaseMapper<BRecommend> {
" and brs.type = '1' "+ " and brs.type = '1' "+
" <if test=\"departs != null and departs.size() > 0 \"> " + " <if test=\"departs != null and departs.size() > 0 \"> " +
" and brs.target_id in " + " and brs.target_id in " +
" <foreach item='item' index='index' collection='departs' open='(' separator=',' close=')'> #{item.departId} </foreach> " + " <foreach item='item' index='index' collection='departs' open='(' separator=',' close=')'> #{item.id} </foreach> " +
" </if> " + " </if> " +
" and br.lesson_id = #{lessonId}</script>") " and br.lesson_id = #{lessonId}</script>")
......
...@@ -35,7 +35,7 @@ public interface BViewrangeRepository extends BaseMapper<BViewrange> { ...@@ -35,7 +35,7 @@ public interface BViewrangeRepository extends BaseMapper<BViewrange> {
" <if test='delFlag != null'>del_flag=#{delFlag},</if> ", " <if test='delFlag != null'>del_flag=#{delFlag},</if> ",
" <if test='flag != null'>flag=#{flag},</if> ", " <if test='flag != null'>flag=#{flag},</if> ",
" <if test='remarks != null'>remarks=#{remarks},</if> ", " <if test='remarks != null'>remarks=#{remarks},</if> ",
" <if test='lesson_id != null'>lesson_id=#{lessonId},</if> ", " <if test='lessonId != null'>lesson_id=#{lessonId},</if> ",
" <if test='type != null'>type=#{type},</if> ", " <if test='type != null'>type=#{type},</if> ",
" <if test='corp_id != null'>corp_id=#{corp_id},</if> ", " <if test='corp_id != null'>corp_id=#{corp_id},</if> ",
" </set>", " </set>",
......
...@@ -79,6 +79,10 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -79,6 +79,10 @@ public class BLessonServiceImpl implements BLessonService {
@Transactional(propagation = Propagation.REQUIRED,readOnly = false) @Transactional(propagation = Propagation.REQUIRED,readOnly = false)
public BLesson selectOne(CurUser curUser,String lessonId) { public BLesson selectOne(CurUser curUser,String lessonId) {
BLesson bLesson = bLessonRepository.selectInfoById(lessonId); BLesson bLesson = bLessonRepository.selectInfoById(lessonId);
if (bLesson == null ){
throw new ServiceException(ResultServiceEnums.NOT_LESSON_ERROR);
}
if ("1".equals(bLesson.getLessonType())){ if ("1".equals(bLesson.getLessonType())){
List<BTrainFile> bTrainFileList = bTrainFileRepository.queryByLessonId(bLesson.getBusinessId()); List<BTrainFile> bTrainFileList = bTrainFileRepository.queryByLessonId(bLesson.getBusinessId());
bLesson.setBTrainFileList(bTrainFileList); bLesson.setBTrainFileList(bTrainFileList);
...@@ -91,9 +95,6 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -91,9 +95,6 @@ public class BLessonServiceImpl implements BLessonService {
bLesson.setViewRangePersonList(selectPersonByLessonIds); bLesson.setViewRangePersonList(selectPersonByLessonIds);
//查询该课程推荐的所有部门 //查询该课程推荐的所有部门
List<BViewRangeSonDTO> selectDepartByLessonIds = bViewrangeRepository.selectDepartByLessonId(curUser.getCorpId(),lessonId); List<BViewRangeSonDTO> selectDepartByLessonIds = bViewrangeRepository.selectDepartByLessonId(curUser.getCorpId(),lessonId);
if ( selectDepartByLessonIds != null && selectDepartByLessonIds.size() > 0){ if ( selectDepartByLessonIds != null && selectDepartByLessonIds.size() > 0){
for (FindDepartByNameDTO depart : departs) { for (FindDepartByNameDTO depart : departs) {
for (BViewRangeSonDTO selectDepartByLessonId : selectDepartByLessonIds) { for (BViewRangeSonDTO selectDepartByLessonId : selectDepartByLessonIds) {
...@@ -104,7 +105,6 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -104,7 +105,6 @@ public class BLessonServiceImpl implements BLessonService {
} }
bLesson.setViewRangeDepartList(selectDepartByLessonIds); bLesson.setViewRangeDepartList(selectDepartByLessonIds);
} }
return bLesson; return bLesson;
} }
...@@ -471,13 +471,19 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -471,13 +471,19 @@ public class BLessonServiceImpl implements BLessonService {
// if (StringUtils.isEmpty(param.getViewParam())){ // if (StringUtils.isEmpty(param.getViewParam())){
// param.setViewParam(""); // 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中 //查询结果放入DTO中
param.setDeparts(departs); 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) { if (departs != null && departs.size() > 0 && findLessonDepartRecommend != null && findLessonDepartRecommend.size() > 0) {
for (FindDepartByNameDTO depart : departs) { for (FindDepartByNameDTO depart : departs) {
...@@ -489,7 +495,6 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -489,7 +495,6 @@ public class BLessonServiceImpl implements BLessonService {
} }
findLessonPersonRecommend.addAll(findLessonDepartRecommend); findLessonPersonRecommend.addAll(findLessonDepartRecommend);
} }
return findLessonPersonRecommend; return findLessonPersonRecommend;
} }
......
...@@ -14,6 +14,7 @@ import org.rcisoft.common.util.feignDto.*; ...@@ -14,6 +14,7 @@ import org.rcisoft.common.util.feignDto.*;
import org.rcisoft.core.exception.ServiceException; import org.rcisoft.core.exception.ServiceException;
import org.rcisoft.core.result.ResultServiceEnums; import org.rcisoft.core.result.ResultServiceEnums;
import org.rcisoft.core.result.Ret; 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.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
......
...@@ -220,6 +220,7 @@ public enum ResultServiceEnums { ...@@ -220,6 +220,7 @@ public enum ResultServiceEnums {
NOT_RECOMMEND(118,"该课程未推荐"), NOT_RECOMMEND(118,"该课程未推荐"),
NO_DATA(119,"该数据不存在"), NO_DATA(119,"该数据不存在"),
CHANGE_FILE_ERROR(120,"文件转换失败"), CHANGE_FILE_ERROR(120,"文件转换失败"),
NOT_LESSON_ERROR(121,"该课程不存在"),
; ;
......
...@@ -90,19 +90,23 @@ public class OfficeToPdf { ...@@ -90,19 +90,23 @@ public class OfficeToPdf {
if (!inputFile.exists()) { if (!inputFile.exists()) {
return -1;// 找不到源文件, 则返回-1 return -1;// 找不到源文件, 则返回-1
} }
log.debug("----------ZH------------");
// 如果目标路径不存在, 则新建该路径 // 如果目标路径不存在, 则新建该路径
File outputFile = new File(destFile); File outputFile = new File(destFile);
if (!outputFile.getParentFile().exists()) { if (!outputFile.getParentFile().exists()) {
outputFile.getParentFile().mkdirs(); outputFile.getParentFile().mkdirs();
} }
log.debug("----------ZH------------");
// connect to an OpenOffice.org instance running on port 8100 // connect to an OpenOffice.org instance running on port 8100
connection = new SocketOpenOfficeConnection( connection = new SocketOpenOfficeConnection(
global.getLibreofficeIp(), global.getLibreofficePort()); global.getLibreofficeIp(), global.getLibreofficePort());
connection.connect(); connection.connect();
// convert // convert
log.debug("----------ZH------------");
DocumentConverter converter = new OpenOfficeDocumentConverter( DocumentConverter converter = new OpenOfficeDocumentConverter(
connection); connection);
DocumentFormatRegistry factory = new BasicDocumentFormatRegistry(); DocumentFormatRegistry factory = new BasicDocumentFormatRegistry();
log.debug("----------ZH------------");
DocumentFormat inputDocumentFormat = factory DocumentFormat inputDocumentFormat = factory
.getFormatByFileExtension(FileUtil.getFilePostfix(sourceFile)); .getFormatByFileExtension(FileUtil.getFilePostfix(sourceFile));
DocumentFormat outputDocumentFormat = factory DocumentFormat outputDocumentFormat = factory
...@@ -120,7 +124,7 @@ public class OfficeToPdf { ...@@ -120,7 +124,7 @@ public class OfficeToPdf {
if(connection!=null) { if(connection!=null) {
connection.disconnect(); connection.disconnect();
}else{ }else{
throw new ServiceException(ResultServiceEnums.UPLOAD_ERROR); throw new ServiceException(ResultServiceEnums.CHANGE_FILE_ERROR);
} }
} }
return 1; return 1;
......
...@@ -74,7 +74,7 @@ global: ...@@ -74,7 +74,7 @@ global:
licPath: /lk/license.lic licPath: /lk/license.lic
pubPath: /lk/publicCerts.store pubPath: /lk/publicCerts.store
path: 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/ return_upload_server_location: http://192.168.5.201:18080/eduServer/
course_location: course course_location: course
lesson_location: lesson lesson_location: lesson
...@@ -93,7 +93,7 @@ global: ...@@ -93,7 +93,7 @@ global:
cut_pdf_num: 30 cut_pdf_num: 30
libreoffice: libreoffice:
ip: mt_office ip: mt_libre
port: 8997 port: 8997
mt: mt:
api: http://192.168.5.201/api/ api: http://192.168.5.201/api/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment