Commit c4c73915 authored by YangZhaoJun1's avatar YangZhaoJun1

解决BUG

parent 104408a6
...@@ -369,6 +369,12 @@ ...@@ -369,6 +369,12 @@
<classifier>jdk15</classifier> <classifier>jdk15</classifier>
</dependency> </dependency>
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>itextpdf</artifactId>
<version>5.5.13</version>
</dependency>
</dependencies> </dependencies>
......
/working/dockervolume/edu2_data_ubuntu/eduServer# rm -rf course/* cd /working/dockervolume/edu2_data_ubuntu/eduServer
/working/dockervolume/edu2_data_ubuntu/eduServer# rm -rf temp/* rm -rf course/*
/working/dockervolume/edu2_data_ubuntu/eduServer# rm -rf upload/* rm -rf temp/*
\ No newline at end of file rm -rf upload/*
\ No newline at end of file
...@@ -107,7 +107,7 @@ public class BChapterController extends PaginationController<BChapter> { ...@@ -107,7 +107,7 @@ public class BChapterController extends PaginationController<BChapter> {
@ApiImplicitParam(name = "image", value = "图片文件", required = true, dataType = "MultipartFile") @ApiImplicitParam(name = "image", value = "图片文件", required = true, dataType = "MultipartFile")
@PreAuthorize("hasRole('ROLE_1002')") @PreAuthorize("hasRole('ROLE_1002')")
@PostMapping(value = "/uploadMdFileWithoutAuth") @PostMapping(value = "/uploadMdFileWithoutAuth")
public Map<String, Object> uploadMdFile(@RequestParam(name = "editormd-image-file") MultipartFile image) { public Map<String, Object> uploadMdFile(MultipartFile image) {
String path = global.getMD_FILE_LOCATION(); String path = global.getMD_FILE_LOCATION();
String basePath = global.getBASE_UPLOAD_SERVER_LOCATION(); String basePath = global.getBASE_UPLOAD_SERVER_LOCATION();
boolean type = false; boolean type = false;
...@@ -121,7 +121,7 @@ public class BChapterController extends PaginationController<BChapter> { ...@@ -121,7 +121,7 @@ public class BChapterController extends PaginationController<BChapter> {
result.put("message", ResultServiceEnums.UPLOAD_FILE_ERROR.getMessage()); result.put("message", ResultServiceEnums.UPLOAD_FILE_ERROR.getMessage());
result.put("url", ""); result.put("url", "");
} else { } else {
result.put("url", global.getSERVER_URL() + "/" + pic.get(UploadUtil.URL)); result.put("url", pic.get(UploadUtil.URL));
result.put("success", 1); result.put("success", 1);
result.put("message", ResultServiceEnums.SUCCESS.getMessage()); result.put("message", ResultServiceEnums.SUCCESS.getMessage());
} }
......
...@@ -150,8 +150,8 @@ public interface BChapterRepository extends BaseMapper<BChapter> { ...@@ -150,8 +150,8 @@ public interface BChapterRepository extends BaseMapper<BChapter> {
* @param studentId * @param studentId
* @return * @return
*/ */
@Update("<script>delete from b_r_student_chapter where chapter_id = #{chapterId} and student_id = #{studentId}</script>") @Update("<script>update b_r_student_chapter set score = '-1', is_complete = '0' where chapter_id = #{chapterId} and student_id = #{studentId}</script>")
int deleteScoerInfo(@Param("chapterId") String chapterId, @Param("studentId") String studentId); int updateScoerInfo(@Param("chapterId") String chapterId, @Param("studentId") String studentId);
@Select("<script>select * from b_chapter " + @Select("<script>select * from b_chapter " +
"where del_flag = 0 and flag = 1 " + "where del_flag = 0 and flag = 1 " +
...@@ -333,5 +333,12 @@ public interface BChapterRepository extends BaseMapper<BChapter> { ...@@ -333,5 +333,12 @@ public interface BChapterRepository extends BaseMapper<BChapter> {
" values " + " values " +
"(#{businessId},#{studentId},#{chapterId},#{isComplete},#{slId},#{score},#{pptFinish},#{pdfFinish},#{videoFinish},#{paperFinish})</script>") "(#{businessId},#{studentId},#{chapterId},#{isComplete},#{slId},#{score},#{pptFinish},#{pdfFinish},#{videoFinish},#{paperFinish})</script>")
int insertStudentChapter(ScoreInfoDTO scoreInfoDTO); int insertStudentChapter(ScoreInfoDTO scoreInfoDTO);
@Select("SELECT bsc.is_complete FROM b_r_student_chapter bsc \n" +
"LEFT JOIN b_student bs on bs.business_id = bsc.student_id\n" +
"LEFT JOIN s_user su on su.login_name = bs.`code`\n" +
"WHERE su.business_id = #{userId}\n" +
"and bsc.chapter_id = #{chapId}")
String queryIsCompleteByUserIdAndChapId(@Param("userId") String userId, @Param("chapId") String chapId);
} }
...@@ -117,4 +117,6 @@ public interface BChapterService{ ...@@ -117,4 +117,6 @@ public interface BChapterService{
String queryStuIdByCode(String code); String queryStuIdByCode(String code);
int updateToFinish(String type, String studentCode, String chapterId ,String slId); int updateToFinish(String type, String studentCode, String chapterId ,String slId);
String queryIsCompleteByUserIdAndChapId(String userInfoProp, String chapId);
} }
...@@ -104,22 +104,10 @@ public class BChapterServiceImpl implements BChapterService { ...@@ -104,22 +104,10 @@ public class BChapterServiceImpl implements BChapterService {
if(model.getIsTest()==null||model.getIsTest().equals("")){ if(model.getIsTest()==null||model.getIsTest().equals("")){
model.setIsTest(""); model.setIsTest("");
} }
if(model.getLessonOrSl().equals("0")) {
String state = bSlRepository.queryStateById(model.getSlId());
if(state.equals(AuditStatusEnum.PUBLISHED.getCode())){
throw new ServiceException(ResultServiceEnums.CHAPTER_IS_USED);
}
}
int sort = bChapterRepository.selectMaxSort(model.getPid(),model.getSlId(),model.getLessonId()); int sort = bChapterRepository.selectMaxSort(model.getPid(),model.getSlId(),model.getLessonId());
model.setSort(sort); model.setSort(sort);
line = bChapterRepository.insertSelective(model); line = bChapterRepository.insertSelective(model);
}else { }else {
if(model.getLessonOrSl().equals("0")) {
String state = bSlRepository.queryStateById(model.getSlId());
if(state.equals(AuditStatusEnum.PUBLISHED.getCode())){
throw new ServiceException(ResultServiceEnums.CHAPTER_IS_USED);
}
}
UserUtil.setCurrentMergeOperation(model); UserUtil.setCurrentMergeOperation(model);
line = bChapterRepository.updateByPrimaryKeySelective(model); line = bChapterRepository.updateByPrimaryKeySelective(model);
} }
...@@ -184,7 +172,7 @@ public class BChapterServiceImpl implements BChapterService { ...@@ -184,7 +172,7 @@ public class BChapterServiceImpl implements BChapterService {
@Override @Override
public void deleteScoerInfo(String chapterId, String studentCode) { public void deleteScoerInfo(String chapterId, String studentCode) {
String studentId = bStudentRepository.queryStudentIdByCode(studentCode); String studentId = bStudentRepository.queryStudentIdByCode(studentCode);
int result = bChapterRepository.deleteScoerInfo(chapterId,studentId); int result = bChapterRepository.updateScoerInfo(chapterId,studentId);
if(result<1) if(result<1)
throw new ServiceException(ResultServiceEnums.SCORE_INFO_NOT_EXISTS); throw new ServiceException(ResultServiceEnums.SCORE_INFO_NOT_EXISTS);
} }
...@@ -215,6 +203,7 @@ public class BChapterServiceImpl implements BChapterService { ...@@ -215,6 +203,7 @@ public class BChapterServiceImpl implements BChapterService {
scoreInfoDTO.setScore(score); scoreInfoDTO.setScore(score);
} }
scoreInfoDTO.setScore(-1);
scoreInfoDTO.setStudentId(stuid); scoreInfoDTO.setStudentId(stuid);
int result; int result;
//查询是否已有关联关系 //查询是否已有关联关系
...@@ -317,22 +306,22 @@ public class BChapterServiceImpl implements BChapterService { ...@@ -317,22 +306,22 @@ public class BChapterServiceImpl implements BChapterService {
if(bFile.getVideoUrl()!=null&&!bFile.getVideoUrl().equals("")){ if(bFile.getVideoUrl()!=null&&!bFile.getVideoUrl().equals("")){
String newUrl = bFile.getVideoUrl().replace(bLessonId,slId); String newUrl = bFile.getVideoUrl().replace(bLessonId,slId);
String path = newUrl.replace(leBChapter.getBusinessId(),slChapter.getBusinessId()); String path = newUrl.replace(leBChapter.getBusinessId(),slChapter.getBusinessId());
newVideo.setVideoUrl(path); newVideo.setVideoUrl(path.replace(global.getLESSON_LOCATION(), global.getSL_LOCATION()));
} }
if(bFile.getFileUrl()!=null&&!bFile.getFileUrl().equals("")){ if(bFile.getFileUrl()!=null&&!bFile.getFileUrl().equals("")){
String newUrl = bFile.getVideoUrl().replace(bLessonId,slId); String newUrl = bFile.getFileUrl().replace(bLessonId,slId);
String path = newUrl.replace(leBChapter.getBusinessId(),slChapter.getBusinessId()); String path = newUrl.replace(leBChapter.getBusinessId(),slChapter.getBusinessId());
newVideo.setFileUrl(path); newVideo.setFileUrl(path.replace(global.getLESSON_LOCATION(), global.getSL_LOCATION()));
} }
if(bFile.getPptUrl()!=null&&!bFile.getPptUrl().equals("")){ if(bFile.getPptUrl()!=null&&!bFile.getPptUrl().equals("")){
String newUrl = bFile.getVideoUrl().replace(bLessonId,slId); String newUrl = bFile.getPptUrl().replace(bLessonId,slId);
String path = newUrl.replace(leBChapter.getBusinessId(),slChapter.getBusinessId()); String path = newUrl.replace(leBChapter.getBusinessId(),slChapter.getBusinessId());
newVideo.setPptUrl(path); newVideo.setPptUrl(path.replace(global.getLESSON_LOCATION(), global.getSL_LOCATION()));
} }
if(bFile.getPdfUrl()!=null&&!bFile.getPdfUrl().equals("")){ if(bFile.getPdfUrl()!=null&&!bFile.getPdfUrl().equals("")){
String newUrl = bFile.getVideoUrl().replace(bLessonId,slId); String newUrl = bFile.getPdfUrl().replace(bLessonId,slId);
String path = newUrl.replace(leBChapter.getBusinessId(),slChapter.getBusinessId()); String path = newUrl.replace(leBChapter.getBusinessId(),slChapter.getBusinessId());
newVideo.setPdfUrl(path); newVideo.setPdfUrl(path.replace(global.getLESSON_LOCATION(), global.getSL_LOCATION()));
} }
//重命名复制之后的文件 //重命名复制之后的文件
String filePath = newPath + File.separator + leBChapter.getBusinessId(); String filePath = newPath + File.separator + leBChapter.getBusinessId();
...@@ -340,6 +329,7 @@ public class BChapterServiceImpl implements BChapterService { ...@@ -340,6 +329,7 @@ public class BChapterServiceImpl implements BChapterService {
File file = new File(filePath); File file = new File(filePath);
file.renameTo(new File(newFilePath)); file.renameTo(new File(newFilePath));
//插入对象 //插入对象
newVideo.setSlId(slId);
bFileRepository.insertSelective(newVideo); bFileRepository.insertSelective(newVideo);
} }
} }
...@@ -540,5 +530,10 @@ public class BChapterServiceImpl implements BChapterService { ...@@ -540,5 +530,10 @@ public class BChapterServiceImpl implements BChapterService {
} }
@Override
public String queryIsCompleteByUserIdAndChapId(String userId, String chapId) {
return bChapterRepository.queryIsCompleteByUserIdAndChapId(userId, chapId);
}
} }
...@@ -2,6 +2,8 @@ package org.rcisoft.business.bcode.controller; ...@@ -2,6 +2,8 @@ package org.rcisoft.business.bcode.controller;
import io.swagger.annotations.*; import io.swagger.annotations.*;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
import org.rcisoft.business.bchapter.service.BChapterService;
import org.rcisoft.business.bchapter.service.impl.BChapterServiceImpl;
import org.rcisoft.business.bcode.model.BCodeFile; import org.rcisoft.business.bcode.model.BCodeFile;
import org.rcisoft.business.bcode.service.BCodeService; import org.rcisoft.business.bcode.service.BCodeService;
import org.rcisoft.common.component.Global; import org.rcisoft.common.component.Global;
...@@ -37,6 +39,9 @@ public class BCodeController extends PaginationController { ...@@ -37,6 +39,9 @@ public class BCodeController extends PaginationController {
@Autowired @Autowired
private BCodeService bCodeServiceImpl; private BCodeService bCodeServiceImpl;
@Autowired
private BChapterService bChapterService;
@Autowired @Autowired
private Global global; private Global global;
...@@ -196,6 +201,10 @@ public class BCodeController extends PaginationController { ...@@ -196,6 +201,10 @@ public class BCodeController extends PaginationController {
+ codePath + File.separator + codePath + File.separator
+ UserUtil.getUserInfoProp(getToken(), UserUtil.USER_ID) + File.separator; + UserUtil.getUserInfoProp(getToken(), UserUtil.USER_ID) + File.separator;
File file = new File(serverPath+filePath); File file = new File(serverPath+filePath);
String finished = bChapterService.queryIsCompleteByUserIdAndChapId(UserUtil.getUserInfoProp(getToken(), UserUtil.USER_ID),chapId);
if(finished!=null&&finished.equals("1")){
throw new ServiceException(ResultServiceEnums.EXPERIMENT_FINISHED);
}
if(fileType.equals("1")&&!file.exists()){//新增文件夹 if(fileType.equals("1")&&!file.exists()){//新增文件夹
file.mkdirs(); file.mkdirs();
}else if(fileType.equals("2")&&!file.exists()){//新增文件 }else if(fileType.equals("2")&&!file.exists()){//新增文件
......
...@@ -45,7 +45,7 @@ public class BFileController extends PaginationController<BFile> { ...@@ -45,7 +45,7 @@ public class BFileController extends PaginationController<BFile> {
@PreAuthorize("hasRole('ROLE_1002')") @PreAuthorize("hasRole('ROLE_1002')")
@PostMapping(value = "/add") @PostMapping(value = "/add")
public Result add(BFile bFile) { public Result add(BFile bFile) {
PersistModel data = bFileService.persist(bFile,getToken()); PersistModel data = bFileService.persist(bFile);
return Result.builder(data, return Result.builder(data,
MessageConstant.MESSAGE_ALERT_SUCCESS, MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR, MessageConstant.MESSAGE_ALERT_ERROR,
......
...@@ -38,5 +38,6 @@ public interface BFileRepository extends BaseMapper<BFile> { ...@@ -38,5 +38,6 @@ public interface BFileRepository extends BaseMapper<BFile> {
@Select("<script>SELECT * FROM b_file WHERE chapter_id = #{chapterId} and del_flag != 1 and flag = 1 </script>") @Select("<script>SELECT * FROM b_file WHERE chapter_id = #{chapterId} and del_flag != 1 and flag = 1 </script>")
@ResultMap(value = "BaseResultMap" ) @ResultMap(value = "BaseResultMap" )
BFile queryBVideoByChapterId(String chapterId); BFile queryBVideoByChapterId(String chapterId);
} }
...@@ -38,7 +38,7 @@ public interface BFileService { ...@@ -38,7 +38,7 @@ public interface BFileService {
* @param model * @param model
* @return * @return
*/ */
PersistModel persist(BFile model, String token); PersistModel persist(BFile model);
/** /**
* 逻辑删除 * 逻辑删除
......
package org.rcisoft.business.bfile.service.impl; package org.rcisoft.business.bfile.service.impl;
import com.itextpdf.text.pdf.PdfReader;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
import org.rcisoft.business.bfile.dao.BFileRepository; import org.rcisoft.business.bfile.dao.BFileRepository;
import org.rcisoft.business.bfile.entity.BFile; import org.rcisoft.business.bfile.entity.BFile;
...@@ -26,6 +27,8 @@ import java.util.HashMap; ...@@ -26,6 +27,8 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import static org.rcisoft.core.util.CutPdfUtil.partitionPdfFile;
/** /**
* Created by gaowenfneg on 2017-10-9 14:34:56. * Created by gaowenfneg on 2017-10-9 14:34:56.
...@@ -59,7 +62,7 @@ public class BFileServiceImpl implements BFileService { ...@@ -59,7 +62,7 @@ public class BFileServiceImpl implements BFileService {
@Override @Override
public PersistModel persist(BFile model, String token){ public PersistModel persist(BFile model){
UserUtil.setCurrentPersistOperation(model); UserUtil.setCurrentPersistOperation(model);
int line = bFileRepository.insertSelective(model); int line = bFileRepository.insertSelective(model);
return new PersistModel(line); return new PersistModel(line);
...@@ -88,16 +91,16 @@ public class BFileServiceImpl implements BFileService { ...@@ -88,16 +91,16 @@ public class BFileServiceImpl implements BFileService {
if (video!=null){//此节已有视频或文件,将已有的视频或文件放置到temp目录下,然后上传新视频或文件 if (video!=null){//此节已有视频或文件,将已有的视频或文件放置到temp目录下,然后上传新视频或文件
if(bFile.getType().equals("0")&&video.getVideoUrl()!=null&&!video.getVideoUrl().equals("")){ if(bFile.getType().equals("0")&&video.getVideoUrl()!=null&&!video.getVideoUrl().equals("")){
this.removeVideoToTemp(video.getVideoUrl(),video.getVideoName(),bFile);//复制之前视频到temp文件下 this.removeVideoToTemp(bFile);//复制之前视频到temp文件下
} }
if(bFile.getType().equals("1")&&video.getFileUrl()!=null&&!video.getFileUrl().equals("")){ if(bFile.getType().equals("1")&&video.getFileUrl()!=null&&!video.getFileUrl().equals("")){
this.removeVideoToTemp(video.getFileUrl(),video.getVideoName(),bFile);//复制之前文件到temp文件下 this.removeVideoToTemp(bFile);//复制之前文件到temp文件下
} }
if(bFile.getType().equals("2")&&video.getPptUrl()!=null&&!video.getPptUrl().equals("")){ if(bFile.getType().equals("2")&&video.getPptUrl()!=null&&!video.getPptUrl().equals("")){
this.removeVideoToTemp(video.getPptUrl(),video.getVideoName(),bFile);//复制之前ppt到temp文件下 this.removeVideoToTemp(bFile);//复制之前ppt到temp文件下
} }
if(bFile.getType().equals("3")&&video.getPdfUrl()!=null&&!video.getPdfUrl().equals("")){ if(bFile.getType().equals("3")&&video.getPdfUrl()!=null&&!video.getPdfUrl().equals("")){
this.removeVideoToTemp(video.getPdfUrl(),video.getVideoName(),bFile);//复制之前pdf到temp文件下 this.removeVideoToTemp(bFile);//复制之前pdf到temp文件下
} }
BFile newVideo = this.uploadVideo(file, bFile);//上传新文件 BFile newVideo = this.uploadVideo(file, bFile);//上传新文件
newVideo.setBusinessId(video.getBusinessId()); newVideo.setBusinessId(video.getBusinessId());
...@@ -115,8 +118,16 @@ public class BFileServiceImpl implements BFileService { ...@@ -115,8 +118,16 @@ public class BFileServiceImpl implements BFileService {
}else{ }else{
BFile newVideo = this.uploadVideo(file, bFile);//上传文件 BFile newVideo = this.uploadVideo(file, bFile);//上传文件
this.persist(newVideo,token);//插入表信息 this.persist(newVideo);//插入表信息
videoUrl = newVideo.getVideoUrl(); if (bFile.getType().equals("0")){
videoUrl = newVideo.getVideoUrl();
}else if(bFile.getType().equals("1")){
videoUrl = newVideo.getFileUrl();
}else if(bFile.getType().equals("2")){
videoUrl = newVideo.getPptUrl();
}else{
videoUrl = newVideo.getPdfUrl();
}
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
...@@ -132,10 +143,9 @@ public class BFileServiceImpl implements BFileService { ...@@ -132,10 +143,9 @@ public class BFileServiceImpl implements BFileService {
/** /**
* 将原视频复制到temp/video文件下,并删除原视频 * 将原视频复制到temp/video文件下,并删除原视频
* @param url
* @param bFile * @param bFile
*/ */
private void removeVideoToTemp(String url, String fileName, BFile bFile) throws Exception{ private void removeVideoToTemp(BFile bFile) throws Exception{
String path; String path;
String pathName; String pathName;
if(bFile.getLessonId()!=null&&!bFile.getLessonId().equals("")){ if(bFile.getLessonId()!=null&&!bFile.getLessonId().equals("")){
...@@ -143,13 +153,11 @@ public class BFileServiceImpl implements BFileService { ...@@ -143,13 +153,11 @@ public class BFileServiceImpl implements BFileService {
}else{ }else{
path = global.getSL_LOCATION() + File.separator + bFile.getSlId() + File.separator; path = global.getSL_LOCATION() + File.separator + bFile.getSlId() + File.separator;
} }
boolean ppt = false;
if (bFile.getType().equals("0")){ if (bFile.getType().equals("0")){
pathName = global.getVIDEO_LOCATION();//视频路径 pathName = global.getVIDEO_LOCATION();//视频路径
}else if(bFile.getType().equals("1")){ }else if(bFile.getType().equals("1")){
pathName = global.getFILE_LOCATION();//文件路径 pathName = global.getFILE_LOCATION();//文件路径
}else if(bFile.getType().equals("2")){ }else if(bFile.getType().equals("2")){
ppt = true;
pathName = global.getPPT_LOCATION();//ppt路径 pathName = global.getPPT_LOCATION();//ppt路径
}else{ }else{
pathName = global.getPDF_LOCATION();//pdf路径 pathName = global.getPDF_LOCATION();//pdf路径
...@@ -158,43 +166,18 @@ public class BFileServiceImpl implements BFileService { ...@@ -158,43 +166,18 @@ public class BFileServiceImpl implements BFileService {
String tempPath = global.getBASE_UPLOAD_SERVER_LOCATION() + File.separator String tempPath = global.getBASE_UPLOAD_SERVER_LOCATION() + File.separator
+ global.getCOURSE_LOCATION() + File.separator + global.getCOURSE_LOCATION() + File.separator
+ global.getTEMP_LOCATION() + File.separator + global.getTEMP_LOCATION() + File.separator
+ path + bFile.getChapterId();// + File.separator + pathName; + path + bFile.getChapterId();
File filePath = new File(tempPath); File tempFilePath = new File(tempPath);
if(!filePath.exists()){ if(tempFilePath.exists()){
filePath.mkdirs(); tempFilePath.delete();
} }
if(ppt){
String pptPath = global.getBASE_UPLOAD_SERVER_LOCATION() + File.separator
+ global.getCOURSE_LOCATION() + File.separator
+ path + bFile.getChapterId() + File.separator + pathName;
File pptDirectory = new File(pptPath);
FileUtils.moveDirectory(pptDirectory,filePath);
}else{
String oldPath = global.getBASE_UPLOAD_SERVER_LOCATION() + File.separator + url;
try {
int bytesum = 0;
int byteread = 0;
File oldfile = new File(oldPath);
if (oldfile.exists()) { //文件存在时
InputStream inStream = new FileInputStream(oldPath); //读入原文件
FileOutputStream fs = new FileOutputStream(tempPath + File.separator + pathName + File.separator+fileName);
byte[] buffer = new byte[1024000];
int length;
while ( (byteread = inStream.read(buffer)) != -1) {
bytesum += byteread; //字节数 文件大小
fs.write(buffer, 0, byteread);
}
inStream.close();
fs.close();
oldfile.delete();
}
}
catch (Exception e) {
System.out.println("出错");
e.printStackTrace();
} String realFilePath = global.getBASE_UPLOAD_SERVER_LOCATION() + File.separator
} + global.getCOURSE_LOCATION() + File.separator
+ path + bFile.getChapterId() + File.separator
+ pathName;
File directory = new File(realFilePath);
FileUtils.moveDirectory(directory,tempFilePath);
} }
...@@ -266,6 +249,14 @@ public class BFileServiceImpl implements BFileService { ...@@ -266,6 +249,14 @@ public class BFileServiceImpl implements BFileService {
+ newPath + uploadFileName + ".pdf"; + newPath + uploadFileName + ".pdf";
slTask.officeToPdf(inputFile,outputFile); slTask.officeToPdf(inputFile,outputFile);
} }
if(uploadFileSuffix.equals("pdf")&&bFile.getType().equals("3")){//pdf切割
try {
slTask.cutPdf(newPath, filename, uploadFileName);
} catch (Exception e) {
e.printStackTrace();
}
}
bFile.setVideoName(name+ "." +uploadFileSuffix);//文件名 bFile.setVideoName(name+ "." +uploadFileSuffix);//文件名
...@@ -287,4 +278,27 @@ public class BFileServiceImpl implements BFileService { ...@@ -287,4 +278,27 @@ public class BFileServiceImpl implements BFileService {
public BFile queryFileUrlByChapterId(String chapterId) { public BFile queryFileUrlByChapterId(String chapterId) {
return bFileRepository.queryFileUrlByChapterId(chapterId); return bFileRepository.queryFileUrlByChapterId(chapterId);
} }
public String uploadFileToServer(MultipartFile file, BFile bFile) throws Exception{
String fileUrl = "";
//查询此节是否已有视频或文件
BFile f = bFileRepository.selectInfoByChapterId(bFile.getChapterId());
if (f!=null){
//复制文件到临时目录
this.removeVideoToTemp(bFile);
}else{
BFile newVideo = this.uploadVideo(file, bFile);//上传文件
if (bFile.getType().equals("0")){
fileUrl = newVideo.getVideoUrl();
}else if(bFile.getType().equals("1")){
fileUrl = newVideo.getFileUrl();
}else if(bFile.getType().equals("2")){
fileUrl = newVideo.getPptUrl();
}else{
fileUrl = newVideo.getPdfUrl();
}
}
return fileUrl;
}
} }
...@@ -111,7 +111,7 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -111,7 +111,7 @@ public class BLessonServiceImpl implements BLessonService {
ArrayList<String[]> values = ExcelUtil.importExcel(hwb,headers); //获取excel数据 ArrayList<String[]> values = ExcelUtil.importExcel(hwb,headers); //获取excel数据
if (values.size()<0){ if (values.size()<1){
throw new ServiceException(ResultServiceEnums.EXCEL_IMPORT_DATA_NOT_EXIST); throw new ServiceException(ResultServiceEnums.EXCEL_IMPORT_DATA_NOT_EXIST);
} }
......
...@@ -30,11 +30,12 @@ public interface BSlRepository extends BaseMapper<BSl> { ...@@ -30,11 +30,12 @@ public interface BSlRepository extends BaseMapper<BSl> {
" <where>" + " <where>" +
" sl.del_flag = '0' and sl.flag = '1' "+ " sl.del_flag = '0' and sl.flag = '1' "+
//" <if test=\"isOnline !=NULL and isOnline !=''\">AND sl.is_online like CONCAT('%',#{isOnline},'%')</if>" + //" <if test=\"isOnline !=NULL and isOnline !=''\">AND sl.is_online like CONCAT('%',#{isOnline},'%')</if>" +
" <if test=\"teacherName !=null and teacherName !=''\">AND u.name like CONCAT('%',#{teacherName},'%')</if>" + " <if test=\"teacherName !=null and teacherName !=''\">AND u.name like CONCAT('%',#{teacherName},'%') </if>" +
" <if test=\"lessonName !=null and lessonName !=''\">AND lesson.lesson_name like CONCAT('%',#{lessonName},'%')</if>" + " <if test=\"lessonName !=null and lessonName !=''\">AND lesson.lesson_name like CONCAT('%',#{lessonName},'%') </if>" +
" <if test=\"termCode !=null and termCode !=''\">AND sl.term_code like CONCAT('%',#{termCode},'%')</if>" + " <if test=\"termCode !=null and termCode !=''\">AND sl.term_code like CONCAT('%',#{termCode},'%') </if>" +
" <if test=\"auditStatus !=null and auditStatus !=''\">AND sl.audit_status = #{auditStatus}</if>" + " <if test=\"auditStatus !=null and auditStatus !=''\">AND sl.audit_status = #{auditStatus} </if>" +
" </where></script>") " </where> " +
"GROUP BY sl.business_id</script>")
@ResultMap(value = "BaseResultMap" ) @ResultMap(value = "BaseResultMap" )
List<BSl> queryBSls(Map<String, Object> param); List<BSl> queryBSls(Map<String, Object> param);
...@@ -137,7 +138,7 @@ public interface BSlRepository extends BaseMapper<BSl> { ...@@ -137,7 +138,7 @@ public interface BSlRepository extends BaseMapper<BSl> {
* @param id * @param id
* @return * @return
*/ */
@Select("<script>SELECT t1.business_id as businessId,t1.credits AS credits,t1.class_hour AS classHour,\n" + @Select("<script>SELECT DISTINCT(t1.business_id) as businessId,t1.credits AS credits,t1.class_hour AS classHour,\n" +
"t1.audit_status AS auditStatus,t8.`name` AS directionName,t8.`code` AS directionCode,t9.`name` AS termName,\n" + "t1.audit_status AS auditStatus,t8.`name` AS directionName,t8.`code` AS directionCode,t9.`name` AS termName,\n" +
"t1.`code` AS slCode,t1.sl_notes as slNotes,t1.sl_cover_url as coverUrl,\n" + "t1.`code` AS slCode,t1.sl_notes as slNotes,t1.sl_cover_url as coverUrl,\n" +
"t6.lesson_name as lessonName,t5.head_pic as teaPic,t5.`name` AS teaName,\n" + "t6.lesson_name as lessonName,t5.head_pic as teaPic,t5.`name` AS teaName,\n" +
...@@ -222,7 +223,7 @@ public interface BSlRepository extends BaseMapper<BSl> { ...@@ -222,7 +223,7 @@ public interface BSlRepository extends BaseMapper<BSl> {
"left join b_lesson bl on sl.lesson_code = bl.code " + "left join b_lesson bl on sl.lesson_code = bl.code " +
"where sl.del_flag != '1' and sl.flag = '1' and sl.audit_status = '4' " + "where sl.del_flag != '1' and sl.flag = '1' and sl.audit_status = '4' " +
"<if test=\"lessonName!=null and lessonName != ''\">" + "<if test=\"lessonName!=null and lessonName != ''\">" +
" AND bl.lesson_name LIKE CONCAT('%',#{lessonName},'%') " + " AND (bl.lesson_name LIKE CONCAT('%',#{lessonName},'%') or sl.code LIKE CONCAT('%',#{lessonName},'%')) " +
"</if>" + "</if>" +
"<if test=\"termCode!=null and termCode != ''\">" + "<if test=\"termCode!=null and termCode != ''\">" +
" AND sl.term_code LIKE CONCAT('%',#{termCode},'%') " + " AND sl.term_code LIKE CONCAT('%',#{termCode},'%') " +
......
package org.rcisoft.business.bsl.task; package org.rcisoft.business.bsl.task;
import com.itextpdf.text.pdf.PdfReader;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.rcisoft.common.component.Global;
import org.rcisoft.core.util.CutPdfUtil;
import org.rcisoft.core.util.OfficeToPdf; import org.rcisoft.core.util.OfficeToPdf;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.io.File;
/** /**
* Created by lcy on 18/1/25. * Created by lcy on 18/1/25.
*/ */
...@@ -16,8 +21,47 @@ public class SlTask { ...@@ -16,8 +21,47 @@ public class SlTask {
@Autowired @Autowired
private OfficeToPdf officeToPdf; private OfficeToPdf officeToPdf;
@Autowired
private CutPdfUtil cutPdfUtil;
@Autowired
private Global global;
@Async @Async
public void officeToPdf(String sourceFile, String destFile){ public void officeToPdf(String sourceFile, String destFile){
officeToPdf.transformToPdf(sourceFile,destFile); officeToPdf.transformToPdf(sourceFile,destFile);
} }
@Async
public void cutPdf(String newPath,String fileName, String uploadFileName) throws Exception{
int i = 0;
int j = 1;
boolean finish = false;
String filePath = global.getBASE_UPLOAD_SERVER_LOCATION() + File.separator
+ newPath+ fileName;
String newFile = global.getBASE_UPLOAD_SERVER_LOCATION() + File.separator
+ newPath + global.getCUT_PDF_LOCATION() + File.separator;
File file = new File(newFile);
if(!file.exists()){
file.mkdirs();
}
PdfReader reader = new PdfReader(filePath);
int pageNum = reader.getNumberOfPages();
if(pageNum>global.getCUT_PDF_NUM()){
do{
String outPutFile = newFile + uploadFileName + j +".pdf";
int end = i+global.getCUT_PDF_NUM();
if(end>=pageNum){
end = pageNum;
finish = true;
}
cutPdfUtil.partitionPdfFile(reader,outPutFile,i+1,end);
i+=global.getCUT_PDF_NUM();
j++;
}while (!finish);
}
reader.close();
}
} }
...@@ -153,7 +153,7 @@ public class BTeacherServiceImpl implements BTeacherService { ...@@ -153,7 +153,7 @@ public class BTeacherServiceImpl implements BTeacherService {
user.setHeadPic(global.getDEFAULT_STUDENT_LOCATION()); user.setHeadPic(global.getDEFAULT_STUDENT_LOCATION());
//4.添加用户权限 //4.添加用户权限
UserRole userRole = new UserRole(user.getBusinessId(), "cccccccc"); UserRole userRole = new UserRole(user.getBusinessId(), "bbbbbbbb");
userRole.setCommonBusinessId(); userRole.setCommonBusinessId();
//创建完Gitlab账户后,将完整的User信息和UserRole计入users和userRoles中等待插入数据库 //创建完Gitlab账户后,将完整的User信息和UserRole计入users和userRoles中等待插入数据库
......
...@@ -48,7 +48,9 @@ public class TExamInfoController extends PaginationController<TExamInfo> { ...@@ -48,7 +48,9 @@ public class TExamInfoController extends PaginationController<TExamInfo> {
@PostMapping("/add") @PostMapping("/add")
public Result add(String chapterId, HttpServletRequest request) { public Result add(String chapterId, HttpServletRequest request) {
String userId = UserUtil.getUserInfoProp(getToken(),UserUtil.USER_ID); String userId = UserUtil.getUserInfoProp(getToken(),UserUtil.USER_ID);
PersistModel data = tExamInfoServiceImpl.save(chapterId,userId,request); TExamInfo tExamInfo = new TExamInfo();
UserUtil.setCurrentPersistOperation(tExamInfo);
PersistModel data = tExamInfoServiceImpl.save(chapterId,userId,tExamInfo,request);
return Result.builder(data, return Result.builder(data,
MessageConstant.MESSAGE_ALERT_SUCCESS, MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR, MessageConstant.MESSAGE_ALERT_ERROR,
......
...@@ -36,9 +36,12 @@ public interface TExamInfoRepository extends BaseMapper<TExamInfo> { ...@@ -36,9 +36,12 @@ public interface TExamInfoRepository extends BaseMapper<TExamInfo> {
@Update("<script> update t_paper set status = '1' where business_id = #{pId} </script>") @Update("<script> update t_paper set status = '1' where business_id = #{pId} </script>")
void updateStatus( @Param("pId") String pId); void updateStatus( @Param("pId") String pId);
@Select("<script> select business_id from t_exam_info where u_id = #{userId} </script>") @Select("<script>select ei.business_id,ei.p_id from t_exam_info ei \n" +
"LEFT JOIN t_paper tp on tp.business_id = ei.p_id \n" +
"where ei.u_id = #{userId} \n" +
"and tp.chap_id = #{chapId}</script>")
@ResultMap(value = "BaseResultMap" ) @ResultMap(value = "BaseResultMap" )
TExamInfo queryIdByUserId(String userId); TExamInfo queryIdByUserId(@Param("userId") String userId, @Param("chapId") String chapId);
@Select("<script> select p_id from t_exam_info where business_id = #{examInfoId} </script>") @Select("<script> select p_id from t_exam_info where business_id = #{examInfoId} </script>")
String queryPaperIdById(String examInfoId); String queryPaperIdById(String examInfoId);
......
...@@ -21,7 +21,7 @@ public interface TExamInfoService { ...@@ -21,7 +21,7 @@ public interface TExamInfoService {
* @param chapterId * @param chapterId
* @return * @return
*/ */
PersistModel save(String chapterId, String userId, HttpServletRequest request); PersistModel save(String chapterId, String userId, TExamInfo tExamInfo, HttpServletRequest request);
/** /**
* 逻辑删除 * 逻辑删除
......
...@@ -63,18 +63,16 @@ public class TExamInfoServiceImpl implements TExamInfoService { ...@@ -63,18 +63,16 @@ public class TExamInfoServiceImpl implements TExamInfoService {
*/ */
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT) @Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT)
@Override @Override
public PersistModel save(String chapterId, String userId, HttpServletRequest request){ public PersistModel save(String chapterId, String userId,TExamInfo tExamInfo, HttpServletRequest request){
TExamInfo tExamInfo = new TExamInfo();
List<String> list = tExamInfoRepository.queryPidByChapterId(chapterId); List<String> list = tExamInfoRepository.queryPidByChapterId(chapterId);
if(list.size()>0){ if(list.size()>0){
String pId = list.get(0); String pId = list.get(0);
tExamInfo.setPId(pId); tExamInfo.setPId(pId);
tExamInfo.setUId(userId); tExamInfo.setUId(userId);
tExamInfo.setIp(IpUtil.getIpAddr(request)); tExamInfo.setIp(IpUtil.getIpAddr(request));
UserUtil.setCurrentPersistOperation(tExamInfo);
int line = tExamInfoRepository.insertSelective(tExamInfo); int line = tExamInfoRepository.insertSelective(tExamInfo);
tExamInfoRepository.updateStatus(pId); tExamInfoRepository.updateStatus(pId);
return new PersistModel(line); return new PersistModel(line,pId);
}else{ }else{
throw new ServiceException(ResultServiceEnums.NO_PAPER_EXISTS); throw new ServiceException(ResultServiceEnums.NO_PAPER_EXISTS);
} }
......
...@@ -51,16 +51,14 @@ public interface TQuestionRepository extends BaseMapper<TQuestion> { ...@@ -51,16 +51,14 @@ public interface TQuestionRepository extends BaseMapper<TQuestion> {
"</foreach></script>") "</foreach></script>")
int insertOptionsList(List<TQuestionOptions> optionList); int insertOptionsList(List<TQuestionOptions> optionList);
@Select("<script>select q.qanswer,q.qtype,q.business_id,q.qtitle,q.qdesc\n" + @Select("<script>SELECT tq.qanswer,tq.qtype,tq.business_id,tq.qtitle,tq.qdesc FROM t_question tq\n" +
"from t_paper_chapter pc \n" + "LEFT JOIN t_paper_detail tpd on tq.business_id = tpd.q_id\n" +
"left join t_paper p on p.pc_id = pc.business_id \n" + "LEFT JOIN t_paper_section tps on tps.business_id = tpd.ps_id\n" +
"left join t_paper_detail pd on pd.p_id = p.business_id \n" + "LEFT JOIN t_paper tp on tp.business_id = tps.p_id\n" +
"left join t_paper_section ps on ps.business_id = pd.ps_id \n" + "WHERE tp.business_id = #{pId}</script>"
"left join t_question q on q.business_id = pd.q_id "
+"where pc.chap_id = #{chapterId}</script>"
) )
@ResultMap(value = "BaseResultMap" ) @ResultMap(value = "BaseResultMap" )
List<TQuestion> queryQuestionsByChap_IdAndQtype( @Param("chapterId") String chapterId); List<TQuestion> queryQuestionsByChap_IdAndQtype( @Param("pId") String pId);
@Select("<script>select q_num from t_paper_chapter_section pcs " + @Select("<script>select q_num from t_paper_chapter_section pcs " +
......
...@@ -26,4 +26,6 @@ public class QuestionListAndNumDto { ...@@ -26,4 +26,6 @@ public class QuestionListAndNumDto {
private String NumOfMultiSelect; private String NumOfMultiSelect;
private String NumOfJudgment; private String NumOfJudgment;
private String isFinish;
} }
...@@ -10,6 +10,8 @@ import org.rcisoft.business.tpaperchapter.dao.TPaperChapterRepository; ...@@ -10,6 +10,8 @@ import org.rcisoft.business.tpaperchapter.dao.TPaperChapterRepository;
import org.rcisoft.business.tquestion.dto.QuestionListAndNumDto; import org.rcisoft.business.tquestion.dto.QuestionListAndNumDto;
import org.rcisoft.business.tquestion.dao.TQuestionOptionsRepository; import org.rcisoft.business.tquestion.dao.TQuestionOptionsRepository;
import org.rcisoft.business.tquestion.entity.TQuestionOptions; import org.rcisoft.business.tquestion.entity.TQuestionOptions;
import org.rcisoft.core.exception.ServiceException;
import org.rcisoft.core.result.ResultServiceEnums;
import org.rcisoft.core.service.RcRedisService; import org.rcisoft.core.service.RcRedisService;
import org.rcisoft.core.service.SerializationUtils; import org.rcisoft.core.service.SerializationUtils;
import org.rcisoft.core.util.UserUtil; import org.rcisoft.core.util.UserUtil;
...@@ -226,11 +228,16 @@ public class TQuestionServiceImpl implements TQuestionService { ...@@ -226,11 +228,16 @@ public class TQuestionServiceImpl implements TQuestionService {
if(questionListAndNum!=null) if(questionListAndNum!=null)
return questionListAndNum; return questionListAndNum;
} }
TExamInfo tExamInfo = tExamInfoRepository.queryIdByUserId(userId); String pId = "";
TExamInfo tExamInfo = tExamInfoRepository.queryIdByUserId(userId,chapterId);
String explain = tPaperChapterRepository.queryDescByChapId(chapterId); String explain = tPaperChapterRepository.queryDescByChapId(chapterId);
if(tExamInfo==null){ if(tExamInfo==null){
//占卷子 //占卷子
tExamInfoService.save(chapterId, userId,request); tExamInfo = new TExamInfo();
UserUtil.setCurrentPersistOperation(tExamInfo);
pId = String.valueOf(tExamInfoService.save(chapterId, userId,tExamInfo,request).getResult());
}else{
pId = tExamInfo.getPId();
} }
String stuId = bStudentRepository.queryStudentByUserId(userId); String stuId = bStudentRepository.queryStudentByUserId(userId);
//判断是否已做过练习 //判断是否已做过练习
...@@ -238,36 +245,43 @@ public class TQuestionServiceImpl implements TQuestionService { ...@@ -238,36 +245,43 @@ public class TQuestionServiceImpl implements TQuestionService {
List<TQuestion> choiceList = new ArrayList<>(); List<TQuestion> choiceList = new ArrayList<>();
List<TQuestion> multiSelectList = new ArrayList<>(); List<TQuestion> multiSelectList = new ArrayList<>();
List<TQuestion> judgmentList = new ArrayList<>(); List<TQuestion> judgmentList = new ArrayList<>();
List<TQuestion> questionList = tQuestionRepository.queryQuestionsByChap_IdAndQtype(chapterId); List<TQuestion> questionList = tQuestionRepository.queryQuestionsByChap_IdAndQtype(pId);
for(TQuestion question : questionList){ for(TQuestion question : questionList){
if(question!=null){ if(question==null){
if(question.getQtype().equals("1")){ throw new ServiceException(ResultServiceEnums.QUESTION_ERROR);
//获取全部选项 }
List<TQuestionOptions> options = tQuestionOptionsRepository.queryTQuestionOptions(question.getBusinessId()); if(question.getQtype().equals("1")){
question.setOptions(options); //获取全部选项
if(isFinish!=null&&isFinish.equals("1")){ List<TQuestionOptions> options = tQuestionOptionsRepository.queryTQuestionOptions(question.getBusinessId());
//获取学生选择的选项 question.setOptions(options);
String uAnswer = tExamDetailRepository.queryUAnswer(question.getBusinessId(),userId,tExamInfo.getBusinessId()); if(isFinish!=null&&isFinish.equals("1")){
question.setUanswer(uAnswer); //获取学生选择的选项
} String uAnswer = tExamDetailRepository.queryUAnswer(question.getBusinessId(),userId,tExamInfo.getBusinessId());
choiceList.add(question); if(uAnswer==null){
}else if(question.getQtype().equals("2")){ uAnswer = "";
//获取全部选项
List<TQuestionOptions> options = tQuestionOptionsRepository.queryTQuestionOptions(question.getBusinessId());
question.setOptions(options);
if(isFinish!=null&&isFinish.equals("1")){
//获取学生选择的选项
String uAnswer = tExamDetailRepository.queryUAnswer(question.getBusinessId(),userId,tExamInfo.getBusinessId());
question.setUanswer(uAnswer);
} }
multiSelectList.add(question); question.setUanswer(uAnswer);
}else { }
if(isFinish!=null&&isFinish.equals("1")){ choiceList.add(question);
String uAnswer = tExamDetailRepository.queryUAnswer(question.getBusinessId(),userId,tExamInfo.getBusinessId()); }else if(question.getQtype().equals("2")){
question.setUanswer(uAnswer); //获取全部选项
List<TQuestionOptions> options = tQuestionOptionsRepository.queryTQuestionOptions(question.getBusinessId());
question.setOptions(options);
if(isFinish!=null&&isFinish.equals("1")){
//获取学生选择的选项
String uAnswer = tExamDetailRepository.queryUAnswer(question.getBusinessId(),userId,tExamInfo.getBusinessId());
if(uAnswer==null){
uAnswer = "";
} }
judgmentList.add(question); question.setUanswer(uAnswer);
}
multiSelectList.add(question);
}else {
if(isFinish!=null&&isFinish.equals("1")){
String uAnswer = tExamDetailRepository.queryUAnswer(question.getBusinessId(),userId,tExamInfo.getBusinessId());
question.setUanswer(uAnswer);
} }
judgmentList.add(question);
} }
} }
questionListAndNum.setChoiceList(choiceList); questionListAndNum.setChoiceList(choiceList);
...@@ -275,6 +289,7 @@ public class TQuestionServiceImpl implements TQuestionService { ...@@ -275,6 +289,7 @@ public class TQuestionServiceImpl implements TQuestionService {
questionListAndNum.setJudgmentList(judgmentList); questionListAndNum.setJudgmentList(judgmentList);
questionListAndNum.setExamInfoId(tExamInfo.getBusinessId()); questionListAndNum.setExamInfoId(tExamInfo.getBusinessId());
questionListAndNum.setExplain(explain); questionListAndNum.setExplain(explain);
questionListAndNum.setIsFinish(isFinish);
questionListAndNum.setNumOfChoice(tQuestionRepository.queryNumByType("1",chapterId)); questionListAndNum.setNumOfChoice(tQuestionRepository.queryNumByType("1",chapterId));
questionListAndNum.setNumOfMultiSelect(tQuestionRepository.queryNumByType("2",chapterId)); questionListAndNum.setNumOfMultiSelect(tQuestionRepository.queryNumByType("2",chapterId));
questionListAndNum.setNumOfJudgment(tQuestionRepository.queryNumByType("3",chapterId)); questionListAndNum.setNumOfJudgment(tQuestionRepository.queryNumByType("3",chapterId));
......
...@@ -79,6 +79,14 @@ public class Global { ...@@ -79,6 +79,14 @@ public class Global {
@Value("${global.path.pdf_location}") @Value("${global.path.pdf_location}")
private String PDF_LOCATION; private String PDF_LOCATION;
/*切割pdf路径*/
@Value("${global.path.cut_pdf_location}")
private String CUT_PDF_LOCATION;
/*每次切割pdf的页数*/
@Value("${global.other.cut_pdf_num}")
private Integer CUT_PDF_NUM;
/*excel模板位置*/ /*excel模板位置*/
@Value("${global.path.excel_template_location}") @Value("${global.path.excel_template_location}")
private String EXCEL_TEMPLATE_LOCATION; private String EXCEL_TEMPLATE_LOCATION;
......
package org.rcisoft.core.model; package org.rcisoft.core.model;
import lombok.Data;
/** /**
* Created with family. * Created with family.
* author: cy * author: cy
...@@ -7,19 +9,23 @@ package org.rcisoft.core.model; ...@@ -7,19 +9,23 @@ package org.rcisoft.core.model;
* Time: 上午9:13 * Time: 上午9:13
* description: * description:
*/ */
@Data
public class PersistModel { public class PersistModel {
public PersistModel(int influence) { public PersistModel(int influence) {
this.influence = influence; this.influence = influence;
} }
public PersistModel(int influence, Object result) {
this.influence = influence;
this.result = result;
}
private int influence; private int influence;
private String influenceReason = ""; private Object result;
public String getInfluenceReason() { private String influenceReason = "";
return influenceReason;
}
......
...@@ -142,7 +142,11 @@ public enum ResultServiceEnums { ...@@ -142,7 +142,11 @@ public enum ResultServiceEnums {
PARAM_NO_QUESTION (77,"请至少添加一个问题"), PARAM_NO_QUESTION (77,"请至少添加一个问题"),
NO_PAPER_EXISTS (78,"未查询到试卷") NO_PAPER_EXISTS (78,"未查询到试卷"),
QUESTION_ERROR (79,"获取习题失败"),
EXPERIMENT_FINISHED (80,"试验已完成,不能进行更改")
; ;
private Integer code; private Integer code;
......
package org.rcisoft.core.util;
import com.itextpdf.text.Document;
import com.itextpdf.text.DocumentException;
import com.itextpdf.text.pdf.PdfCopy;
import com.itextpdf.text.pdf.PdfImportedPage;
import com.itextpdf.text.pdf.PdfReader;
import org.springframework.stereotype.Component;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Date;
/**
* Created by yangzhaojun on 2018/2/6.
*/
@Component
public class CutPdfUtil {
public static void main(String[] args) throws Exception{
Date dd = new Date();
long l1 = dd.getTime();
int i = 0;
int j = 1;
boolean finish = false;
String filePath = "E:\\pdfTest\\a9c9c7916e424c3aa44255564c31bbe9.pdf";
PdfReader reader = new PdfReader(filePath);
int pageNum = reader.getNumberOfPages();
do{
String newFile = "E:\\pdfTest\\cutPdf\\a9c9c7916e424c3aa44255564c31bbe9"+j+".pdf";
int end = i+30;
if(end>=pageNum){
end = pageNum;
finish = true;
}
partitionPdfFile(reader, newFile, i+1,end);
System.out.println("第"+j+"个pdf转换完成");
i+=30;
j++;
}while (!finish);
Date dd2 = new Date();
long l2 = dd2.getTime();
System.out.println("耗时:"+(l2 - l1));
}
/**
* 截取pdfFile的第from页至第end页,组成一个新的文件名
* @param reader
* @param newFile
* @param from
* @param end
*/
public static void partitionPdfFile(PdfReader reader,
String newFile, int from, int end) {
Document document = null;
PdfCopy copy = null;
try {
document = new Document(reader.getPageSize(1));
copy = new PdfCopy(document, new FileOutputStream(newFile));
document.open();
for(int j=from; j<=end; j++) {
document.newPage();
PdfImportedPage page = copy.getImportedPage(reader, j);
copy.addPage(page);
}
document.close();
} catch (IOException e) {
e.printStackTrace();
} catch(DocumentException e) {
e.printStackTrace();
}
}
}
...@@ -37,7 +37,7 @@ public class UploadUtil { ...@@ -37,7 +37,7 @@ public class UploadUtil {
File.separator+calendar.get(Calendar.MONTH)+ File.separator+calendar.get(Calendar.MONTH)+
File.separator+calendar.get(Calendar.DATE)+ File.separator+calendar.get(Calendar.DATE)+
File.separator; File.separator;
String realPath = basePath + userPath; String realPath = basePath + File.separator+ userPath;
//创建File对象,参数为String类型,表示目录名 //创建File对象,参数为String类型,表示目录名
File dir = new File(realPath); File dir = new File(realPath);
//判断文件是否存在 dir.exists() //判断文件是否存在 dir.exists()
......
...@@ -118,6 +118,7 @@ global: ...@@ -118,6 +118,7 @@ global:
file_location: file file_location: file
ppt_location: ppt ppt_location: ppt
pdf_location: pdf pdf_location: pdf
cut_pdf_location: cutPdf
excel_template_location: excel-template/ excel_template_location: excel-template/
cource_logo_location: /course/logo cource_logo_location: /course/logo
images_location: /images images_location: /images
...@@ -133,6 +134,7 @@ global: ...@@ -133,6 +134,7 @@ global:
is_server_linux: 5 is_server_linux: 5
max_code_length: 15 max_code_length: 15
open_office_home: D:/oppenOffice/openOffice open_office_home: D:/oppenOffice/openOffice
cut_pdf_num: 30
code: code:
admin: ROLE_1001 admin: ROLE_1001
teacher: ROLE_1002 teacher: ROLE_1002
......
...@@ -118,6 +118,7 @@ global: ...@@ -118,6 +118,7 @@ global:
file_location: file file_location: file
ppt_location: ppt ppt_location: ppt
pdf_location: pdf pdf_location: pdf
cut_pdf_location: cutPdf
excel_template_location: excel-template/ excel_template_location: excel-template/
cource_logo_location: /course/logo cource_logo_location: /course/logo
images_location: /images images_location: /images
...@@ -133,6 +134,7 @@ global: ...@@ -133,6 +134,7 @@ global:
is_server_linux: 1 is_server_linux: 1
max_code_length: 15 max_code_length: 15
open_office_home: D:/oppenOffice/openOffice open_office_home: D:/oppenOffice/openOffice
cut_pdf_num: 30
code: code:
admin: ROLE_1001 admin: ROLE_1001
teacher: ROLE_1002 teacher: ROLE_1002
......
...@@ -82,7 +82,7 @@ ...@@ -82,7 +82,7 @@
<select id="scoreReportChildList" parameterType="java.util.Map" resultMap="ScoreReportResultMap"> <select id="scoreReportChildList" parameterType="java.util.Map" resultMap="ScoreReportResultMap">
SELECT DISTINCT bc.business_id, SELECT DISTINCT bc.business_id,bc.is_test,bc.class_hour,
bc.chapter_name, bc.automatic,bc.sl_id,bc.experiment_type, bc.chapter_name, bc.automatic,bc.sl_id,bc.experiment_type,
ROUND((SELECT AVG(bsc.score) from b_r_student_chapter bsc ROUND((SELECT AVG(bsc.score) from b_r_student_chapter bsc
where bsc.chapter_id = bc.business_id and score != '-1'),2) as average, where bsc.chapter_id = bc.business_id and score != '-1'),2) as average,
...@@ -91,12 +91,12 @@ ...@@ -91,12 +91,12 @@
(SELECT MIN(bsc.score) from b_r_student_chapter bsc (SELECT MIN(bsc.score) from b_r_student_chapter bsc
where bsc.chapter_id = bc.business_id and score != '-1') as minScore, where bsc.chapter_id = bc.business_id and score != '-1') as minScore,
(SELECT COUNT(*) from b_r_student_chapter where score = '-1' (SELECT COUNT(*) from b_r_student_chapter where score = '-1'
AND sl_id = #{slId} AND chapter_id = bc.business_id) as waitingMark, AND sl_id = #{slId} AND chapter_id = bc.business_id AND is_complete = '1') as waitingMark,
(SELECT COUNT(*) from b_r_student_chapter where sl_id = #{slId} (SELECT COUNT(*) from b_r_student_chapter where sl_id = #{slId}
AND chapter_id = bc.business_id) as submit, AND chapter_id = bc.business_id AND is_complete = '1') as submit,
(SELECT COUNT(*) from b_r_sl_student brss where brss.sl_code = (SELECT COUNT(*) from b_r_sl_student brss where brss.sl_code =
(SELECT `code` from b_sl where business_id = #{slId})) as allStudent (SELECT `code` from b_sl where business_id = #{slId})) as allStudent
from b_chapter bc from b_chapter bc
where bc.pid = #{pid} where bc.pid = #{pid} order by bc.sort
</select> </select>
</mapper> </mapper>
\ No newline at end of file
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