Commit 9cdc52f3 authored by YangZhaoJun1's avatar YangZhaoJun1

重新转换ppt接口

parent be0ebdae
......@@ -14,7 +14,7 @@ public interface BSubtaskRepository extends BaseMapper<BSubtask> {
// @Select("SELECT DISTINCT(`status`) from b_subtask\n" +
// "where arrange_id = \n" +
// "(SELECT arrange_id FROM b_subtask where business_id = #{subTaskId})")
@Select("SELECT DISTINCT(status) from b_subtask where arrange_id = #{0}")
@Select("SELECT DISTINCT(status) from b_subtask where arrange_id = #{0} and del_flag = 0")
List<String> querySubTaskStatusById(String arrangeId);
@Select("SELECT arrange_id FROM b_subtask where business_id = #{subTaskId}")
......
......@@ -274,79 +274,92 @@ public class BChapterServiceImpl implements BChapterService {
chapterList.add(sl_chapter);
}
for (int i=0;i<chapterList.size();i++){
if(!chapterList.get(i).getPid().equals("-1")){
//取出map中存放的新的章ID作为父节点ID
chapterList.get(i).setPid(String.valueOf(map.get(chapterList.get(i).getLPid())));
}
}
if(chapterList.size()>0){
for (int i=0;i<chapterList.size();i++){
if(!chapterList.get(i).getPid().equals("-1")){
//取出map中存放的新的章ID作为父节点ID
chapterList.get(i).setPid(String.valueOf(map.get(chapterList.get(i).getLPid())));
}
}
result = bChapterRepository.insertChapterList(chapterList);
}
String oldPath = global.getBASE_UPLOAD_SERVER_LOCATION()+File.separator
+global.getCOURSE_LOCATION()+File.separator
+global.getLESSON_LOCATION()+File.separator
+bLessonId;
String newPath = global.getBASE_UPLOAD_SERVER_LOCATION()+File.separator
+global.getCOURSE_LOCATION()+File.separator
+global.getSL_LOCATION()+File.separator
+slId;
//复制章节的所有文件
try {
copyFileToSl(oldPath,newPath);
String oldPath = global.getBASE_UPLOAD_SERVER_LOCATION()+File.separator
+global.getCOURSE_LOCATION()+File.separator
+global.getLESSON_LOCATION()+File.separator
+bLessonId;
String newPath = global.getBASE_UPLOAD_SERVER_LOCATION()+File.separator
+global.getCOURSE_LOCATION()+File.separator
+global.getSL_LOCATION()+File.separator
+slId;
//复制章节的所有文件
try {
File file = new File(oldPath);
if(file.exists()){
copyFileToSl(oldPath,newPath);
}
/*File oldFile = new File(oldPath);
File newFile = new File(newPath);
FileUtils.copyDirectory(oldFile,newFile,true);*/
} catch (IOException e) {
throw new ServiceException(ResultServiceEnums.COPY_FILES_ERROR);
}
} catch (IOException e) {
throw new ServiceException(ResultServiceEnums.COPY_FILES_ERROR);
}
//数据库操作
for (BChapter leBChapter : lessonList){
for(BChapter slChapter : chapterList){
if(leBChapter.getSPid().equals(slChapter.getSPid())&&!leBChapter.getPid().equals("-1")){
BFile bFile = bFileRepository.queryBVideoByChapterId(leBChapter.getBusinessId());
BFile newVideo = new BFile();
newVideo.setChapterId(slChapter.getBusinessId());
UserUtil.setCurrentPersistOperation(newVideo);
//将节的ID替换成新的
if(bFile !=null){
newVideo.setVideoName(bFile.getVideoName());
if(bFile.getVideoUrl()!=null&&!bFile.getVideoUrl().equals("")){
String newUrl = bFile.getVideoUrl().replace(bLessonId,slId);
String path = newUrl.replace(leBChapter.getBusinessId(),slChapter.getBusinessId());
newVideo.setVideoUrl(path.replace(global.getLESSON_LOCATION(), global.getSL_LOCATION()));
}
if(bFile.getFileUrl()!=null&&!bFile.getFileUrl().equals("")){
String newUrl = bFile.getFileUrl().replace(bLessonId,slId);
String path = newUrl.replace(leBChapter.getBusinessId(),slChapter.getBusinessId());
newVideo.setFileUrl(path.replace(global.getLESSON_LOCATION(), global.getSL_LOCATION()));
}
if(bFile.getPptUrl()!=null&&!bFile.getPptUrl().equals("")){
String newUrl = bFile.getPptUrl().replace(bLessonId,slId);
String path = newUrl.replace(leBChapter.getBusinessId(),slChapter.getBusinessId());
newVideo.setPptUrl(path.replace(global.getLESSON_LOCATION(), global.getSL_LOCATION()));
}
if(bFile.getPdfUrl()!=null&&!bFile.getPdfUrl().equals("")){
String newUrl = bFile.getPdfUrl().replace(bLessonId,slId);
String path = newUrl.replace(leBChapter.getBusinessId(),slChapter.getBusinessId());
newVideo.setPdfUrl(path.replace(global.getLESSON_LOCATION(), global.getSL_LOCATION()));
//数据库操作
for (BChapter leBChapter : lessonList){
for(BChapter slChapter : chapterList){
if(leBChapter.getSPid().equals(slChapter.getSPid())&&!leBChapter.getPid().equals("-1")){
BFile bFile = bFileRepository.queryBVideoByChapterId(leBChapter.getBusinessId());
BFile newVideo = new BFile();
newVideo.setChapterId(slChapter.getBusinessId());
UserUtil.setCurrentPersistOperation(newVideo);
//将节的ID替换成新的
if(bFile !=null){
newVideo.setVideoName(bFile.getVideoName());
if(bFile.getVideoUrl()!=null&&!bFile.getVideoUrl().equals("")){
String newUrl = bFile.getVideoUrl().replace(bLessonId,slId);
String path = newUrl.replace(leBChapter.getBusinessId(),slChapter.getBusinessId());
newVideo.setVideoUrl(path.replace(global.getLESSON_LOCATION(), global.getSL_LOCATION()));
}
if(bFile.getFileUrl()!=null&&!bFile.getFileUrl().equals("")){
String newUrl = bFile.getFileUrl().replace(bLessonId,slId);
String path = newUrl.replace(leBChapter.getBusinessId(),slChapter.getBusinessId());
newVideo.setFileUrl(path.replace(global.getLESSON_LOCATION(), global.getSL_LOCATION()));
}
if(bFile.getPptUrl()!=null&&!bFile.getPptUrl().equals("")){
String newUrl = bFile.getPptUrl().replace(bLessonId,slId);
String path = newUrl.replace(leBChapter.getBusinessId(),slChapter.getBusinessId());
newVideo.setPptUrl(path.replace(global.getLESSON_LOCATION(), global.getSL_LOCATION()));
}
if(bFile.getPdfUrl()!=null&&!bFile.getPdfUrl().equals("")){
String newUrl = bFile.getPdfUrl().replace(bLessonId,slId);
String path = newUrl.replace(leBChapter.getBusinessId(),slChapter.getBusinessId());
newVideo.setPdfUrl(path.replace(global.getLESSON_LOCATION(), global.getSL_LOCATION()));
}
//重命名复制之后的文件
String filePath = newPath + File.separator + leBChapter.getBusinessId();
String newFilePath = newPath + File.separator + slChapter.getBusinessId();
File file = new File(filePath);
file.renameTo(new File(newFilePath));
//插入对象
newVideo.setSlId(slId);
bFileRepository.insertSelective(newVideo);
}
//重命名复制之后的文件
String filePath = newPath + File.separator + leBChapter.getBusinessId();
String newFilePath = newPath + File.separator + slChapter.getBusinessId();
File file = new File(filePath);
file.renameTo(new File(newFilePath));
//插入对象
newVideo.setSlId(slId);
bFileRepository.insertSelective(newVideo);
}
}
}
}
return result;
}
......
......@@ -192,5 +192,19 @@ public class BFileController extends PaginationController<BFile> {
"");
}
@ApiOperation(value="重新转换ppt", notes="重新转换ppt")
@ApiImplicitParams({@ApiImplicitParam(name = "businessId", value = "课程或开课的ID", required = true, dataType = "varchar"),
@ApiImplicitParam(name = "type", value = "'0'开课,'1'课程", required = true, dataType = "varchar")})
@GetMapping(value = "/reConversionPPTWithoutAuth")
public Result reConversionPPTWithoutAuth(String businessId, String type) {
return Result.builder(new PersistModel(1),
MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR,
bFileService.reConversionPPT(businessId,type));
}
}
......@@ -57,4 +57,6 @@ public interface BFileService {
* @param file
*/
public void uploadLicense(MultipartFile file) throws IOException;
List<String> reConversionPPT(String businessId, String type);
}
......@@ -25,6 +25,10 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import java.io.*;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -85,6 +89,7 @@ public class BFileServiceImpl implements BFileService {
}
@Override
@Transactional(propagation = Propagation.REQUIRED,readOnly = false)
public String uploadVideoToServer(List<MultipartFile> list, BFile bFile, String token) {
String videoUrl = "";
......@@ -228,7 +233,6 @@ public class BFileServiceImpl implements BFileService {
if(!outFile.exists()){//判断保存路径是否存在,不存在新建
outFile.mkdirs();
}
//上传文件
String uploadFile = file.getOriginalFilename();
......@@ -318,8 +322,54 @@ public class BFileServiceImpl implements BFileService {
return;
}
/**
* 重新转换ppt
* @param businessId
* @param type 0开课 1课程
* @return
*/
@Override
public List<String> reConversionPPT(String businessId, String type) {
List<String> failPPTPath = new ArrayList<>();
try {
String basePath = global.getSL_LOCATION();
if(type.equals("1")){
basePath = global.getLESSON_LOCATION();
}
String path = global.getBASE_UPLOAD_SERVER_LOCATION() + File.separator
+ global.getCOURSE_LOCATION() + File.separator
+ basePath + File.separator + businessId;
File file = new File(path);
failPPTPath = this.changePPTToPDF(file,failPPTPath);
} catch (IOException e) {
e.printStackTrace();
}
return failPPTPath;
}
private List<String> changePPTToPDF(File slFile, List<String> failPPTPath) throws IOException {
for (File chapterFile : slFile.listFiles()) {
String pptPath = chapterFile.getPath()+File.separator+"ppt";
File pptFile = new File(pptPath);
if(pptFile.exists()){
File[] pptFiles = pptFile.listFiles();
if(pptFiles.length==1&&pptFiles[0].getName().endsWith("ppt")){
failPPTPath.add(pptFiles[0].getPath());
String inputFile = pptFiles[0].getPath();
String outputFile = pptFiles[0].getPath().substring(0,pptFiles[0].getPath().lastIndexOf(".")) + ".pdf";
slTask.officeToPdf(inputFile,outputFile);
}
}
}
return failPPTPath;
}
public String uploadFileToServer(MultipartFile file, BFile bFile) throws Exception{
/*public String uploadFileToServer(MultipartFile file, BFile bFile) throws Exception{
String fileUrl = "";
//查询此节是否已有视频或文件
BFile f = bFileRepository.selectInfoByChapterId(bFile.getChapterId());
......@@ -339,7 +389,7 @@ public class BFileServiceImpl implements BFileService {
}
}
return fileUrl;
}
}*/
......
......@@ -130,18 +130,20 @@ public class BGradeServiceImpl implements BGradeService {
newGrades.add(grade);
}
bGradeRepository.insertList(newGrades);
}
//查询是否有本年的年级
}else{
//查询是否有本年的年级
// List<BGrade> bGrades = bGradeRepository.queryBGradeByNowYear(nowYear);
String nowYearCode = grades.get(0).getCode();
if(!nowYearCode.equals(nowYear)){//没有就新增
BGrade grade = new BGrade();
grade.setCode(nowYear);
grade.setName(nowYear+"级");
UserUtil.setCurrentPersistOperation(grade);
bGradeRepository.insertSelective(grade);
String nowYearCode = grades.get(0).getCode();
if(!nowYearCode.equals(nowYear)){//没有就新增
BGrade grade = new BGrade();
grade.setCode(nowYear);
grade.setName(nowYear+"级");
UserUtil.setCurrentPersistOperation(grade);
bGradeRepository.insertSelective(grade);
}
}
grades = bGradeRepository.queryFirstFiveBGrades(bGrade);
return grades;
}
......
package org.rcisoft.business.brclassstudent.dao;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.*;
import org.rcisoft.business.brclassstudent.entity.BRClassStudent;
import org.rcisoft.core.base.BaseMapper;
import org.springframework.security.access.method.P;
import org.springframework.stereotype.Repository;
import java.util.List;
......@@ -75,6 +73,6 @@ public interface BRClassStudentRepository extends BaseMapper<BRClassStudent> {
"WHERE bcs.student_code=#{studentCode} " +
"AND bc.type=#{type}</script>")
@ResultMap(value = "BaseResultMap" )
BRClassStudent queryClassStudent(String studentCode, String type);
BRClassStudent queryClassStudent(@Param("studentCode") String studentCode, @Param("type") String type);
}
......@@ -33,7 +33,6 @@ public interface BStudentRepository extends BaseMapper<BStudent> {
"LEFT JOIN b_grade bg ON b.grade_code = bg.`code`\n" +
"where b.del_flag != 1 and b.flag = 1 "+
"<if test=\"condition!=null and condition != ''\">and u.`name` like CONCAT('%',#{condition},'%') or b.`code` like CONCAT('%',#{condition},'%') </if>"+
//"order by b.grade_code desc" +
"order by b.create_date desc" +
"</script>")
@ResultMap(value = "BaseResultMap" )
......@@ -64,6 +63,7 @@ public interface BStudentRepository extends BaseMapper<BStudent> {
"<if test=\"classCode!=null and classCode != ''\">\n" +
" AND t6.code = #{classCode}\n" +
"</if>" +
"group by t3.code " +
"order by className asc,code asc</script>")
@ResultMap(value = "BaseResultMap" )
List<BStudent> queryStudentBySlCode(@Param("slCode") String slCode, @Param("classCode") String classCode);
......@@ -178,7 +178,7 @@ public interface BStudentRepository extends BaseMapper<BStudent> {
"LEFT JOIN b_r_class_student bcs on bcs.student_code = bs.`code` " +
"LEFT JOIN b_class bc on bc.`code` = bcs.class_code " +
"WHERE FIND_IN_SET(bcs.class_code,( " +
"SELECT bec.classes_id FROM b_edu_class bec WHERE bec.`code` = 'D0001')) " +
"SELECT bec.classes_id FROM b_edu_class bec WHERE bec.`code` = #{classCode})) " +
"GROUP BY bs.`code` " +
"ORDER BY bs.`code`")
@ResultMap(value = "BaseResultMap")
......
......@@ -70,11 +70,13 @@ public interface BTermRepository extends BaseMapper<BTerm> {
@ResultMap(value = "BaseResultMap" )
BTerm queryCurrentTerm(String termCode);
@Select("select * from b_term " +
"WHERE (#{startDate} BETWEEN start_date AND end_date) " +
@Select("<script>select * from b_term " +
"WHERE ((#{startDate} BETWEEN start_date AND end_date) " +
"OR (#{endDate} BETWEEN start_date AND end_date) " +
"OR (start_date BETWEEN #{startDate} AND #{endDate}) " +
"OR (end_date BETWEEN #{startDate} AND #{endDate})")
"OR (end_date BETWEEN #{startDate} AND #{endDate})) " +
"<if test=\"businessId !=null and businessId != '' \">and business_id != #{businessId} </if>" +
"</script>")
@ResultMap(value = "BaseResultMap" )
List<BTerm> queryBTermsByStartDateOrEndDate(BTerm model);
......
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