Commit 23c5ec19 authored by 李丛阳's avatar 李丛阳

merge

parents 7c91e9f9 653cf840
......@@ -65,7 +65,7 @@ public class BChapterController extends PaginationController<BChapter> {
@ApiImplicitParam(name = "classHour", value = "课时", required = false, dataType = "varchar"),
@ApiImplicitParam(name = "experimentType", value = "实验类型,1:java单文件 2:java工程 3:html单文件 4:html工程", required = false, dataType = "varchar"),
@ApiImplicitParam(name = "lessonOrSl", value = "课程或开课;0:开课 1:课程", required = true, dataType = "varchar"),
@ApiImplicitParam(name = "isTest", value = "1:实验 2:视频 3:PPT 4:pdf 5:资料", required = false, dataType = "varchar"),
@ApiImplicitParam(name = "isTest", value = "1:实验 2:视频 3:PPT 4:pdf 5:资料 6试题", required = false, dataType = "varchar"),
@ApiImplicitParam(name = "lessonId", value = "课程ID(课程ID和开课ID只能存在一个)", required = false, dataType = "varchar")})
@PreAuthorize("hasAnyRole('ROLE_1001','ROLE_1002')")
@PostMapping(value = "/add")
......
......@@ -13,10 +13,10 @@ import org.rcisoft.core.exception.ServiceException;
import org.rcisoft.core.model.PersistModel;
import org.rcisoft.core.result.Result;
import org.rcisoft.core.result.ResultServiceEnums;
import org.rcisoft.core.util.CompileUtil;
import org.rcisoft.core.util.UserUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
......@@ -143,11 +143,12 @@ public class BCodeController extends PaginationController {
@ApiImplicitParam(name = "content", value = "内容(修改文件内容时使用该参数)", required = false, dataType = "varchar"),
@ApiImplicitParam(name = "slId", value = "开课Id", required = true, dataType = "varchar"),
@ApiImplicitParam(name = "chapId", value = "章节Id", required = true, dataType = "varchar"),
@ApiImplicitParam(name = "fileType", value = "1新增文件夹,2新增文件,3修改文件名,4删除文件,5修改文件内容", required = true, dataType = "varchar")})
@ApiImplicitParam(name = "fileType", value = "1新增文件夹,2新增文件,3修改文件名,4删除文件,5修改文件内容, 6读取文件内容", required = true, dataType = "varchar")})
@ApiOperation(value="单文件或工程各种操作", notes="单文件或工程各种操作")
@GetMapping(value = "/createOrUpdateFiles")
public Result createOrUpdateFiles(String filePath, String newFilePath, String content, String slId, String chapId, String fileType) throws Exception{
String codePath = "";
String javaCode = "";
codePath = global.getCOURSE_PROJECT_LOCATION();
String serverPath = global.getBASE_UPLOAD_SERVER_LOCATION() + File.separator
+ global.getCOURSE_LOCATION() + File.separator
......@@ -162,17 +163,31 @@ public class BCodeController extends PaginationController {
}else if(fileType.equals("2")&&!file.exists()){//新增文件
file.createNewFile();
}else if(fileType.equals("3")&&file.exists()){//修改文件名
File newFile = new File(newFilePath);
File newFile = new File(serverPath+newFilePath);
file.renameTo(newFile);
}else if(fileType.equals("4")&&file.exists()){//删除文件
file.delete();
this.deleteFile(file);
}else if(fileType.equals("5")&&file.exists()){//修改文件内容
FileUtils.write(file,content,"UTF-8");
}else if(fileType.equals("6")&&file.exists()){//读取文件内容
javaCode = FileUtils.readFileToString(file);
}
return Result.builder(new PersistModel(1),
MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR,
"");
javaCode);
}
private void deleteFile(File file) {
if (file.isFile()) {//判断是否是文件
file.delete();//删除文件
} else if (file.isDirectory()) {//否则如果它是一个目录
File[] files = file.listFiles();//声明目录下所有的文件 files[];
for (int i = 0;i < files.length;i ++) {//遍历目录下所有的文件
this.deleteFile(files[i]);//把每个文件用这个方法进行迭代
}
file.delete();//删除文件夹
}
}
......@@ -187,4 +202,28 @@ public class BCodeController extends PaginationController {
bCodeServiceImpl.queryAllStudentCode(slId,chapterId));
}
@ApiImplicitParams({@ApiImplicitParam(name = "content", value = "代码", required = true, dataType = "varchar"),
@ApiImplicitParam(name = "studentCode", value = "学号", required = true, dataType = "varchar"),
@ApiImplicitParam(name = "fileName", value = "class名", required = true, dataType = "varchar")})
@ApiOperation(value="编译代码", notes="编译代码")
@GetMapping(value = "/compileCode")
public Result compileCode(String content, String studentCode, String fileName){
String fileUrl = global.getBASE_UPLOAD_SERVER_LOCATION() + File.separator
+ global.getTEMP_LOCATION() + File.separator
+ global.getSTUDENT_CODE_LOCATION() + File.separator
+ studentCode + File.separator;
String executeResult = "";
try {
executeResult = CompileUtil.executeJavaCode(content, fileName, fileUrl);
return Result.builder(new PersistModel(1),
MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR,
executeResult);
} catch (Exception e) {
throw new ServiceException(ResultServiceEnums.COMPILING_CODE);
}
}
}
......@@ -33,5 +33,5 @@ public interface BCodeService {
String exportFiles(String slId, String studentId, String type, String slCode);
List<List<BCodeFile>> queryAllStudentCode(String slId, String chapterId);
List<BCodeFile> queryAllStudentCode(String slId, String chapterId);
}
......@@ -17,7 +17,6 @@ import org.rcisoft.business.bstudent.entity.BStudentDto;
import org.rcisoft.common.component.Global;
import org.rcisoft.core.exception.ServiceException;
import org.rcisoft.core.result.CommandResult;
import org.rcisoft.core.result.ResultExceptionEnum;
import org.rcisoft.core.result.ResultServiceEnums;
import org.rcisoft.core.service.RcRedisService;
import org.rcisoft.core.service.SerializationUtils;
......@@ -76,13 +75,13 @@ public class BCodeServiceImpl implements BCodeService {
return this.readSimpleFile(slId,chapId,CodeType.SIM_JAVA,userInfo,studentCode);
/*java 工程*/
if(examType.equals(global.getJavaProject()))
return this.readProjectFile(slId,chapId,userInfo,studentCode,global.getJavaProject());
return this.readProjectFile(slId,chapId,userInfo,studentCode);
/*html 单文件*/
if(examType.equals(global.getHtmlSimple()))
return this.readSimpleFile(slId,chapId,CodeType.SIM_HTML,userInfo,studentCode);
/*html 工程*/
if(examType.equals(global.getHtmlProject()))
return this.readProjectFile(slId,chapId,userInfo,studentCode,global.getHtmlProject());
return this.readProjectFile(slId,chapId,userInfo,studentCode);
return null;
}
......@@ -439,8 +438,7 @@ public class BCodeServiceImpl implements BCodeService {
@Override
public List<List<BCodeFile>> queryAllStudentCode(String slId, String chapterId){
List<List<BCodeFile>> list = new ArrayList<>();
public List<BCodeFile> queryAllStudentCode(String slId, String chapterId){
String codePath = "";
String suffixName = "";
BCodeFile codeFile = null;
......@@ -475,20 +473,18 @@ public class BCodeServiceImpl implements BCodeService {
String content = FileUtils.readFileToString(file);
codeFile = new BCodeFile("0", content, new Date(file.lastModified()), file.getName(), IdGen.uuid(), "0", "", studentName,null);
students.add(codeFile);
list.add(students);
}else if(file.isDirectory()){//工程的处理
List<BCodeFile> codeFiles = new ArrayList<>();
BCodeFile simpleCodeFile = null;
boolean isFile = true;
simpleCodeFile = new BCodeFile("0", "", null, file.getName(),IdGen.uuid(),"0","");
getFileList(file,codeFiles,simpleCodeFile,isFile,studentName);
list.add(codeFiles);
}
}
}catch (Exception e){
}
}
return list;
return students;
}
}
......@@ -40,7 +40,7 @@ public interface BDirectionRepository extends BaseMapper<BDirection> {
@ResultMap(value = "BaseResultMap")
List<BDirection> queryDirectionsList();
@Insert("insert into b_lesson_direction (business_id,direction_id,sl_id) values (#{businessId},#{directionId},#{slId})")
@Insert("insert into b_lesson_direction (business_id,direction_id,sl_id,lession_id) values (#{businessId},#{directionId},#{slId},#{lessionId})")
int insertBLessonDirection(BLessonDirection bDirection);
}
......@@ -47,9 +47,11 @@ public class BLesson extends IdEntity<BLesson> {
this.code = code;
}
public BLesson(String code, String lessonName) {
public BLesson(String code, String lessonName, String classHour, String credits) {
this.code = code;
this.lessonName = lessonName;
this.classHour = classHour;
this.credits = credits;
}
@Override
......
......@@ -2,6 +2,8 @@ package org.rcisoft.business.blesson.service.impl;
import com.alibaba.fastjson.JSON;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.rcisoft.business.bdirection.dao.BDirectionRepository;
import org.rcisoft.business.bdirection.entity.BDirection;
import org.rcisoft.business.blesson.dao.BLessonRepository;
import org.rcisoft.business.blesson.entity.BLesson;
import org.rcisoft.business.blesson.entity.BLessonDirection;
......@@ -40,6 +42,8 @@ public class BLessonServiceImpl implements BLessonService {
private BSlRepository bSlRepository;
@Autowired
private Global global;
@Autowired
private BDirectionRepository bDirectionRepository;
@Override
......@@ -101,8 +105,9 @@ public class BLessonServiceImpl implements BLessonService {
ArrayList<BLesson> lessons = new ArrayList<BLesson>();
ArrayList<String> repeatCode = new ArrayList<String>();
List<String> errorCode = new ArrayList<>();
ArrayList<String> direction = new ArrayList<String>();
String[] headers = {"课程编号","课程名称"};
String[] headers = {"课程编号","课程名称","课程方向","课时","学分"};
ArrayList<String[]> values = ExcelUtil.importExcel(hwb,headers); //获取excel数据
......@@ -124,12 +129,24 @@ public class BLessonServiceImpl implements BLessonService {
repeatCode.add(value[0]);
continue;
}
bLesson= new BLesson(value[0],value[1]);
BDirection b_direction = bDirectionRepository.selectOne(new BDirection(value[2]));
if (b_direction == null) {
if (!direction.contains(value[2]))
direction.add(value[2]);
continue;
}
bLesson= new BLesson(value[0],value[1],value[3],value[4]);
bLesson.setDefaultUrl(global.getDEFAULT_COURSE_LOCATION());
UserUtil.setCurrentPersistOperation(bLesson);
if(!lessons.contains(bLesson)){
lessons.add(bLesson);
BLessonDirection bDirection = new BLessonDirection();
bDirection.setDirectionId(b_direction.getBusinessId());
bDirection.setBusinessId(IdGen.uuid());
bDirection.setLessionId(bLesson.getBusinessId());
bDirectionRepository.insertBLessonDirection(bDirection);
}
}
......@@ -152,6 +169,9 @@ public class BLessonServiceImpl implements BLessonService {
if(errorCode.size()>0){
result+="以下课程编号超过15位:"+ JSON.toJSONString(errorCode)+"。";
}
if(direction.size()>0){
result+="以下课程方向编号不存在:"+ JSON.toJSONString(direction)+"。";
}
if (lessons.size()<1){
throw new ServiceException(ResultServiceEnums.EXCEL_IMPORT_DATA_NOT_EXIST.getCode(),result);
}
......
......@@ -103,7 +103,7 @@ public class BRSlStudentServiceImpl implements BRSlStudentService {
if(value[0]==null||value[0].equals("")||value[1]==null||value[1].equals("")){
continue;
}
if((bSl = bSlRepository.selectOne(new BSl(value[0])))==null) {
if((bSl = bSlRepository.selectOne(new BSl(value[0],"0","1")))==null) {
if(!slCode.contains(value[0]))
slCode.add(value[0]);
continue;
......
......@@ -124,7 +124,7 @@ public interface BSlRepository extends BaseMapper<BSl> {
"AND t3.del_flag = 0\n" +
"AND t3.flag = 1\n"+
"AND t2.audit_status != '4' "+
"<if test=\"lessonName !=null and lessonName !=''\">AND t3.lesson_name like CONCAT('%',#{lessonName},'%') </if>" +
"<if test=\"lessonName !=null and lessonName !=''\">AND (t3.lesson_name like CONCAT('%',#{lessonName},'%') or t2.`code` like CONCAT('%',#{lessonName},'%') ) </if>" +
"<if test=\"auditStatus !=null and auditStatus !=''\">AND t2.audit_status = #{auditStatus} </if>" +
" <if test=\"termCode !=null and termCode !=''\">AND t2.term_code like CONCAT('%',#{termCode},'%') </if></script>")
List<SlDTO> selectTeacherSLByCode(@Param("teacherCode") String teacherCode,
......@@ -146,7 +146,8 @@ public interface BSlRepository extends BaseMapper<BSl> {
"(select count(*) from b_chapter bc where bc.sl_id=t1.business_id and bc.is_test like CONCAT('%','2','%' )) AS video,\n" +
"(select count(*) from b_chapter bc where bc.sl_id=t1.business_id and bc.is_test like CONCAT('%','3','%' )) AS ppt,\n" +
"(select count(*) from b_chapter bc where bc.sl_id=t1.business_id and bc.is_test like CONCAT('%','4','%' )) AS pdf,\n" +
"(select count(*) from b_chapter bc where bc.sl_id=t1.business_id and bc.is_test like CONCAT('%','5','%' )) AS file\n" +
"(select count(*) from b_chapter bc where bc.sl_id=t1.business_id and bc.is_test like CONCAT('%','5','%' )) AS file,\n" +
"(select count(*) from b_chapter bc where bc.sl_id=t1.business_id and bc.is_test like CONCAT('%','6','%' )) AS questions\n" +
"FROM\n" +
"b_sl t1\n" +
"LEFT JOIN b_lesson_direction t7 ON t1.business_id = t7.sl_id\n" +
......
......@@ -29,4 +29,5 @@ public class SlDetailDTO {
private String directionCode;
private String termName;
private String auditStatus;
private String questions;
}
......@@ -30,8 +30,10 @@ public class BSl extends IdEntity<BSl> {
this.termCode = termCode;
}
public BSl(String code) {
public BSl(String code, String delFlag, String flag) {
this.code = code;
this.delFlag = delFlag;
this.flag = flag;
}
private String code;//课序号
......
......@@ -117,7 +117,7 @@ public class BSlServiceImpl implements BSlService {
throw new ServiceException(ResultServiceEnums.LESSON_NOT_EXISTA);
model.setSlCoverUrl(bLesson.getDefaultUrl());
if(bSlRepository.selectOne(new BSl(model.getCode()))!=null)
if(bSlRepository.selectOne(new BSl(model.getCode(),"0","1"))!=null)
throw new ServiceException(ResultServiceEnums.SL_EXISTS);
//3. 封装git lab
/*User user = userRepository.selectOne(new User(model.getTeacherCode()));
......@@ -170,7 +170,7 @@ public class BSlServiceImpl implements BSlService {
if(value.length>=4) {
//1. 检查数据正确性
BSl bSl = null;
BSl b = new BSl(value[0]);
BSl b = new BSl(value[0],"0","1");
BSl bSl1 = new BSl();
bSl1.setTermCode(value[3]);
bSl1.setTeacherCode(value[2]);
......@@ -186,7 +186,7 @@ public class BSlServiceImpl implements BSlService {
continue;
}
//
if ((bTeacherRepository.selectOne(new BTeacher(value[2]))) == null) {
if ((bTeacherRepository.selectOne(new BTeacher(value[2],"0","1"))) == null) {
if (!teacherCode.contains(value[2]))
teacherCode.add(value[2]);
continue;
......
......@@ -108,7 +108,7 @@ public class BSlApplyServiceImpl implements BSlApplyService {
@Override
@Transactional(propagation = Propagation.REQUIRED,readOnly = false)
public void agreeApply(ApplyDTO applyDTO,String token) throws UnsupportedEncodingException {
if(bSlRepository.selectOne(new BSl(applyDTO.getSlCode()))!=null)
if(bSlRepository.selectOne(new BSl(applyDTO.getSlCode(),"0","1"))!=null)
throw new ServiceException(ResultServiceEnums.SL_EXISTS);
if(bLessonRepository.selectOne(new BLesson(applyDTO.getCourseCode()))!=null)
throw new ServiceException(ResultServiceEnums.LESSON_EXISTS);
......
......@@ -157,6 +157,8 @@ public class BStudentServiceImpl implements BStudentService {
//判断2:MySQL数据库中是否存在该用户;
SysUser user1 =new SysUser();
user1.setLoginName(value[0]);
user1.setDelFlag("0");
user1.setFlag("1");
if (sysUserMapper.selectOne(user1) != null) {
//该用户已存在,记入codeRepeat中
valuesRepeat.add(value[0]);
......@@ -254,9 +256,10 @@ public class BStudentServiceImpl implements BStudentService {
}
BStudent bStudent = new BStudent();
bStudent.setBusinessId(id);
UserUtil.setCurrentMergeOperation(bStudent);
BStudent student = bStudentRepository.selectOne(bStudent);
sysUserMapper.deleteByCode(student.getCode());
bStudent.setDeleted();
UserUtil.setCurrentMergeOperation(bStudent);
int line = bStudentRepository.logicalDelete(bStudent);
return new PersistModel(line, MessageConstant.MESSAGE_ALERT_SUCCESS);
}
......
......@@ -22,8 +22,10 @@ public class BTeacher extends IdEntity<BTeacher> {
private static final long serialVersionUID = -4023201651225813372L;
public BTeacher(String code) {
public BTeacher(String code, String delFlag, String flag) {
this.code = code;
this.delFlag = delFlag;
this.flag = flag;
}
......@@ -53,5 +55,9 @@ public class BTeacher extends IdEntity<BTeacher> {
@Transient
private String headPic;
public BTeacher(String code) {
this.code = code;
}
}
......@@ -108,6 +108,8 @@ public class BTeacherServiceImpl implements BTeacherService {
//判断2:MySQL数据库中是否存在该用户;
SysUser user1 =new SysUser();
user1.setLoginName(value[0]);
user1.setDelFlag("0");
user1.setFlag("1");
if (sysUserMapper.selectOne(user1) != null) {
//该用户已存在,记入codeRepeat中
valuesRepeat.add(value[0]);
......
......@@ -46,12 +46,12 @@ public class TQuestionController extends PaginationController<TQuestion> {
//@ApiImplicitParams({@ApiImplicitParam(name = "businessId", value = "businessId", required = false, dataType = "varchar")})
@PostMapping
@PreAuthorize("hasRole('ROLE_1002')")
public Result add(@Valid TQuestion tQuestion, List<Map<String,Object>> questionOptions) {
public Result add(TQuestion tQuestion, List<Map<String,Object>> questionOptions) {
PersistModel data = tQuestionServiceImpl.save(tQuestion,questionOptions);
return Result.builder(data,
MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR,
tQuestion);
tQuestion);
}
@ApiOperation(value = "新增选项",notes = "新增加一个选项")
......@@ -82,10 +82,10 @@ public class TQuestionController extends PaginationController<TQuestion> {
@ApiOperation(value="删除题目", notes="根据ID删除一个题")
@ApiImplicitParams({@ApiImplicitParam(name = "id", value = "businessId", required = true, dataType = "varchar")})
@ApiImplicitParam(name = "id", value = "businessId", required = true, dataType = "varchar")
@PostMapping("/remove")
@PreAuthorize("hasRole('ROLE_1002')")
public Result delete(@PathVariable String id) {
public Result delete(String id) {
return Result.builder(new PersistModel(tQuestionServiceImpl.remove(id,getToken())),
MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR,
......
......@@ -30,12 +30,6 @@ public interface TQuestionRepository extends BaseMapper<TQuestion> {
List<TQuestion> queryTQuestionsByPagination(TQuestion tQuestion);
@Insert("<script>INSERT INTO t_question_options (business_id,qid,alias,desc) VALUES " +
"(#{businessId},#{qid},#{alias},#{slId})</script>")
void insertQuestionOptions(TQuestionOptions model);
@Select("<script>select * "
+"from t_question tq"
+"left join t_question_options tqo on tqo.qid = tq.business_id"
......@@ -50,9 +44,9 @@ public interface TQuestionRepository extends BaseMapper<TQuestion> {
int deleteByIds(String idInfoList);
@Insert("<script>INSERT INTO t_question_options " +
"(business_id,qid,desc,alias)VALUES " +
"(business_id,qid,describe,alias)VALUES " +
"<foreach collection=\"list\" item=\"item\" separator=\",\">" +
"( #{item.businessId},#{item.qid},#{item.desc},#{item.alias})" +
"( #{item.businessId},#{item.qid},#{item.describe},#{item.alias})" +
"</foreach></script>")
int insertOptionsList(List<TQuestionOptions> optionList);
}
......
......@@ -26,7 +26,7 @@ public class TQuestionOptions extends IdEntity<TQuestionOptions> {
private String alias;
private String desc;
private String describe;
}
......
......@@ -56,7 +56,7 @@ public class TQuestionServiceImpl implements TQuestionService {
tQuestionOptions.setCommonBusinessId();
tQuestionOptions.setQid(tQuestion.getQid());
tQuestionOptions.setAlias(String.valueOf(map.get("alias")));
tQuestionOptions.setDesc(String.valueOf(map.get("desc")));
tQuestionOptions.setDescribe(String.valueOf(map.get("describe")));
optionList.add(tQuestionOptions);
}
......
......@@ -131,6 +131,8 @@ public enum ResultServiceEnums {
NO_STUDENT_HOMEWORK(72,"暂无学生提交作业"),
DOWNLOAD_ERROR(73,"下载失败"),
COMPILING_CODE (74,"运行失败,请重试")
;
private Integer code;
......
package org.rcisoft.core.util;
import java.io.*;
public class CompileUtil {
/**
* @param code 代码
* @param fileName 文件名
* @param fileUrl 文件所在目录
* @return
*/
public static String executeJavaCode(String code,String fileName,String fileUrl) throws Exception {
writeCodeToFile(code,fileName,fileUrl);
File file = new File(fileUrl+fileName+".java");
while(!file.exists()) {
Thread.sleep(10);
}
File dir = new File(fileUrl);
String os = System.getProperty("os.name");
String command1,command2;
if (os.toLowerCase().startsWith("win")) {
command1 = "c:\\Windows\\System32\\cmd.exe /c javac -encoding utf-8 "+fileName+".java";
command2 = "c:\\Windows\\System32\\cmd.exe /c java "+fileName;
} else {
command1 = "javac -encoding utf-8 "+fileName+".java";
command2 = "java "+fileName;
}
Runtime r1 = Runtime.getRuntime();
Process p1 = null;
Boolean comResult1 =true;
String result="";
try {
p1 = r1.exec(command1, null, dir);
InputStreamReader ir = new InputStreamReader(p1.getInputStream(),"GBK");
LineNumberReader input = new LineNumberReader(ir);
StringBuilder sb = new StringBuilder();
boolean firstLine = true;
String line;
while ((line = input.readLine()) != null) {
comResult1 = false;
if(!firstLine){
sb.append(System.getProperty("line.separator"));
}else{
firstLine = false;
}
sb.append(line);
}
input.close();
ir.close();
// result = new String(sb.toString().getBytes("iso8859-1"),"utf-8");
result = sb.toString();
/*if(input.readLine()!=null) {
comResult1 = false;
}*/
} catch (IOException e) {
e.printStackTrace();
}
if(!comResult1) {
return result;
}
String classUrl = fileUrl+fileName+".class";
File classFile = new File(classUrl);
while(!classFile.exists()) {
Thread.sleep(10);
if(!comResult1) {
break;
}
}
Runtime r2 = Runtime.getRuntime();
Process p2 = null;
try {
p2 = r2.exec(command2, null, dir);
InputStreamReader ir = new InputStreamReader(p2.getInputStream(),"GBK");
LineNumberReader input = new LineNumberReader(ir);
StringBuilder sb = new StringBuilder();
boolean firstLine = true;
String line;
while ((line = input.readLine()) != null) {
if(!firstLine){
sb.append(System.getProperty("line.separator"));
}else{
firstLine = false;
}
sb.append(line);
}
input.close();
ir.close();
// result = new String(sb.toString().getBytes("iso8859-1"),"utf-8");
result = sb.toString();
//file.delete();
} catch (IOException e) {
e.printStackTrace();
result = "error";
}
p2.waitFor();
p2.destroy();
return result;
}
public static void writeCodeToFile(String code,String fileName,String fileUrl) throws Exception{
File file = new File(fileUrl+fileName+".java");
if(!file.getParentFile().exists()){
file.getParentFile().mkdirs();
}
Writer out = new FileWriter(file);
out.write(code);
out.close();
}
}
/*
package org.rcisoft.core.util;
import org.apache.poi.xslf.usermodel.XMLSlideShow;
import org.apache.poi.xslf.usermodel.XSLFSlide;
import org.apache.xmlbeans.XmlException;
import org.openxmlformats.schemas.drawingml.x2006.main.*;
import org.openxmlformats.schemas.presentationml.x2006.main.CTGroupShape;
import org.openxmlformats.schemas.presentationml.x2006.main.CTShape;
import org.openxmlformats.schemas.presentationml.x2006.main.CTSlide;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics2D;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import org.apache.poi.;
import javax.imageio.ImageIO;
*/
/**
* PPT转image工具类
* 使用的Apache poi-3.14的版本 依赖第三方jar包:poi-3.14-20160307.jar、poi-ooxml-3.14-20160307.jar、
* poi-ooxml-schemas-3.14-20160307.jar、poi-scratchpad-3.14-20160307.jar、xmlbeans-2.6.0.jar
* @author yds
* @date 2017-03-22
*
*//*
public class ConverPPTFileToImageUtil {
*/
/**
* 将PPTX 文件转换成image
* @param orignalPPTFileName //PPTX文件路径 如:d:/demo/demo1.pptx
* @param targetImageFileDir //转换后的图片保存路径 如:d:/demo/pptxImg
* @param imageFormatNameString //图片转化的格式字符串 ,如:"jpg"、"jpeg"、"bmp" "png" "gif" "tiff"
* @return Map<String,Object>
* key: converReturnResult 类型:boolean 转化结果 true 代表转换成功,false 代表转换失败
* key:imgNames 类型:List<String> 转换成功后图片的全部名称集合
* 注:获取“imgNames”图片名称集合时,请先判断“converReturnResult” 是否为true;如果有一张转换失败则为false
*//*
@SuppressWarnings("resource")
public static Map<String,Object> converPPTXtoImage(String orignalPPTFileName,String targetImageFileDir,
String imageFormatNameString){
Map<String,Object> map=new HashMap<String, Object>();
boolean converReturnResult=false;//是否全部转成功
List<String> imgNamesList=new ArrayList<String>();//PPT转成图片后所有名称集合
FileInputStream orignalPPTFileInputStream=null;
FileOutputStream orignalPPTFileOutStream=null;
XMLSlideShow oneSlideShow=null;
try{
try {
orignalPPTFileInputStream=new FileInputStream(orignalPPTFileName);
} catch (FileNotFoundException e) {
e.printStackTrace();
map.put("converReturnResult", converReturnResult);
return map;
}
try {
oneSlideShow=new XMLSlideShow(orignalPPTFileInputStream);
} catch (IOException e) {
e.printStackTrace();
map.put("converReturnResult", converReturnResult);
return map;
}
//获取PPT每页的尺寸大小(宽和高度)
Dimension onePPTPageSize=oneSlideShow.getPageSize();
//获取PPT文件中的所有PPT页面,并转换为一张张播放片
List<XSLFSlide> pptPageXSLFSLiseList= oneSlideShow.getSlides();
String xmlFontFormat="<xml-fragment xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" xmlns:p=\"http://schemas.openxmlformats.org/presentationml/2006/main\">"+
"<a:rPr lang=\"zh-CN\" altLang=\"en-US\" dirty=\"0\" smtClean=\"0\"> "+
"<a:latin typeface=\"+mj-ea\"/> "+
"</a:rPr>"+
"</xml-fragment>";
for (int i = 0; i < pptPageXSLFSLiseList.size(); i++) {
*/
/**
* 设置中文为宋体,解决中文乱码问题
*//*
CTSlide oneCTSlide=pptPageXSLFSLiseList.get(i).getXmlObject();
CTGroupShape oneCTGroupShape=oneCTSlide.getCSld().getSpTree();
List<CTShape> oneCTShapeList=oneCTGroupShape.getSpList();
for (CTShape ctShape : oneCTShapeList) {
CTTextBody oneCTTextBody = ctShape.getTxBody();
if(null==oneCTTextBody){
continue;
}
CTTextParagraph[] oneCTTextParagraph= oneCTTextBody.getPArray();
CTTextFont oneCTTextFont=null;
try {
oneCTTextFont=CTTextFont.Factory.parse(xmlFontFormat);
} catch (XmlException e) {
e.printStackTrace();
}
for (CTTextParagraph ctTextParagraph : oneCTTextParagraph) {
CTRegularTextRun[] onrCTRegularTextRunArray=ctTextParagraph.getRArray();
for (CTRegularTextRun ctRegularTextRun : onrCTRegularTextRunArray) {
CTTextCharacterProperties oneCTTextCharacterProperties =ctRegularTextRun.getRPr();
oneCTTextCharacterProperties.setLatin(oneCTTextFont);
}
}
}
//创建BufferedImage 对象,图像尺寸为原来的PPT的每页尺寸
BufferedImage oneBufferedImage=new BufferedImage(onePPTPageSize.width, onePPTPageSize.height, BufferedImage.TYPE_INT_RGB);
Graphics2D oneGraphics2D = oneBufferedImage.createGraphics();
//将PPT文件中的每个页面中的相关内容画到转换后的图片中
pptPageXSLFSLiseList.get(i).draw(oneGraphics2D);
*/
/**
* 设置图片的存放路径和图片格式,注意生成的文件路径为绝对路径,最终获得各个图像文件所对应的输出流的对象
*//*
try {
String imgName=(i+1)+"_"+UUID.randomUUID().toString()+"."+imageFormatNameString;
imgNamesList.add(imgName);//将图片名称添加的集合中
orignalPPTFileOutStream=new FileOutputStream(targetImageFileDir+imgName);
// orignalPPTFileOutStream=new FileOutputStream(targetImageFileDir+(i+1)+"_"+UUID.randomUUID().toString()+"."+imageFormatNameString);
} catch (FileNotFoundException e) {
e.printStackTrace();
map.put("converReturnResult", converReturnResult);
return map;
}
//将转换后的各个图片文件保存带指定的目录中
try {
ImageIO.write(oneBufferedImage, imageFormatNameString, orignalPPTFileOutStream);
} catch (IOException e) {
e.printStackTrace();
map.put("converReturnResult", converReturnResult);
return map;
}
}
} finally{
try {
if(orignalPPTFileInputStream!=null){
orignalPPTFileInputStream.close();
}
} catch (IOException e) {
e.printStackTrace();
}
try {
if(orignalPPTFileOutStream!=null){
orignalPPTFileOutStream.close();
}
} catch (IOException e) {
e.printStackTrace();
}
converReturnResult=true;
map.put("converReturnResult", converReturnResult);
map.put("imgNames", imgNamesList);
}
return map;
}
*/
/**
* 将PPT 文件转换成image
* @param orignalPPTFileName //PPT文件路径 如:d:/demo/demo1.ppt
* @param targetImageFileDir //转换后的图片保存路径 如:d:/demo/pptImg
* @param imageFormatNameString //图片转化的格式字符串 ,如:"jpg"、"jpeg"、"bmp" "png" "gif" "tiff"
* @return Map<String,Object>
* key: converReturnResult 类型:boolean 转化结果 true 代表转换成功,false 代表转换失败
* key:imgNames 类型:List<String> 转换成功后图片的全部名称集合
* 注:获取“imgNames”图片名称集合时,请先判断“converReturnResult” 是否为true;如果有一张转换失败则为false
*//*
@SuppressWarnings("resource")
public static Map<String,Object> converPPTtoImage(String orignalPPTFileName,String targetImageFileDir,
String imageFormatNameString){
Map<String,Object> map=new HashMap<String, Object>();
boolean converReturnResult=false;//是否全部转成功
List<String> imgNamesList=new ArrayList<String>();//PPT转成图片后所有名称集合
FileInputStream orignalPPTFileInputStream=null;
FileOutputStream orignalPPTFileOutStream=null;
HSLFSlideShow oneHSLFSlideShow=null;
try{
try {
orignalPPTFileInputStream=new FileInputStream(orignalPPTFileName);
} catch (FileNotFoundException e) {
e.printStackTrace();
map.put("converReturnResult", converReturnResult);
return map;
}
try {
oneHSLFSlideShow=new HSLFSlideShow(orignalPPTFileInputStream);
} catch (IOException e) {
e.printStackTrace();
map.put("converReturnResult", converReturnResult);
return map;
}
//获取PPT每页的大小(宽和高度)
Dimension onePPTPageSize= oneHSLFSlideShow.getPageSize();
//获得PPT文件中的所有的PPT页面(获得每一张幻灯片),并转为一张张的播放片
List<HSLFSlide> pptPageSlideList=oneHSLFSlideShow.getSlides();
//下面循环的主要功能是实现对PPT文件中的每一张幻灯片进行转换和操作
for (int i = 0; i <pptPageSlideList.size(); i++) {
//这几个循环只要是设置字体为宋体,防止中文乱码,
List<List<HSLFTextParagraph>> oneTextParagraphs=pptPageSlideList.get(i).getTextParagraphs();
for (List<HSLFTextParagraph> list :oneTextParagraphs) {
for (HSLFTextParagraph hslfTextParagraph : list) {
List<HSLFTextRun> HSLFTextRunList= hslfTextParagraph.getTextRuns();
for (int j = 0; j <HSLFTextRunList.size(); j++) {
*/
/*
* 如果PPT在WPS中保存过,则 HSLFTextRunList.get(j).getFontSize();的值为0或者26040,
* 因此首先识别当前文本框内的字体尺寸是否为0或者大于26040,则设置默认的字体尺寸。
*
*//*
//设置字体大小
Double size= HSLFTextRunList.get(j).getFontSize();
if((size<=0)||(size>=26040)){
HSLFTextRunList.get(j).setFontSize(20.0);
}
//设置字体样式为宋体
// String family=HSLFTextRunList.get(j).getFontFamily();
HSLFTextRunList.get(j).setFontFamily("宋体");
}
}
}
*/
/**
* 创建BufferedImage对象,图像的尺寸为原来的每页的尺寸
*//*
BufferedImage oneBufferedImage=new BufferedImage(onePPTPageSize.width, onePPTPageSize.height, BufferedImage.TYPE_INT_RGB);
Graphics2D oneGraphics2D=oneBufferedImage.createGraphics();
*/
/**
* 设置转换后的图片背景色为白色
*
*//*
oneGraphics2D.setPaint(Color.white);
oneGraphics2D.fill(new Rectangle2D.Float(0,0,onePPTPageSize.width,onePPTPageSize.height));
pptPageSlideList.get(i).draw(oneGraphics2D);
*/
/**
* 设置图片的存放路径和图片格式,注意生成的图片路径为绝对路径,最终获得各个图像文件所对应的输出流对象
*//*
try {
String imgName=(i+1)+"_"+UUID.randomUUID().toString()+"."+imageFormatNameString;
imgNamesList.add(imgName);//将图片名称添加的集合中
orignalPPTFileOutStream=new FileOutputStream(targetImageFileDir+imgName);
} catch (FileNotFoundException e) {
e.printStackTrace();
map.put("converReturnResult", converReturnResult);
return map;
}
*/
/**
* 转换后的图片文件保存的指定的目录中
*//*
try {
ImageIO.write(oneBufferedImage, imageFormatNameString, orignalPPTFileOutStream);
// throw new IOException();
} catch (IOException e) {
e.printStackTrace();
map.put("converReturnResult", converReturnResult);
return map;
}
}
}finally{
try {
if(orignalPPTFileInputStream!=null){
orignalPPTFileInputStream.close();
}
} catch (IOException e) {
e.printStackTrace();
}
try {
if(orignalPPTFileOutStream!=null){
orignalPPTFileOutStream.close();
}
} catch (IOException e) {
e.printStackTrace();
}
converReturnResult=true;
map.put("converReturnResult", converReturnResult);
map.put("imgNames", imgNamesList);
}
return map;
}
public static void main(String[] args) {
//PPT调用示例
// Map<String,Object> map= ConverPPTFileToImageUtil.converPPTtoImage("E:\\ppt\\oracle SQL语法大全(第一课).ppt", "E:\\ppt\\pptimg\\", "jpg");
//PPTX调用示例
Map<String,Object> map=ConverPPTFileToImageUtil.converPPTXtoImage("E:\\ppt\\PMS2.0界面设计培训-20130507.pptx", "E:\\ppt\\pptimg\\", "jpg");
boolean converReturnResult=(Boolean) map.get("converReturnResult");
System.out.println("converReturnResult:"+converReturnResult);
if(converReturnResult){//如果全部转换成功,则为true;如果有一张转换失败,则为fasle
@SuppressWarnings("unchecked")
List<String> imgNames=(List<String>) map.get("imgNames");
for (String imgName : imgNames) {
System.out.println(imgName);
}
}
}
}
*/
......@@ -17,7 +17,7 @@ import static javafx.scene.input.KeyCode.V;
public interface SysUserMapper extends BaseMapper<SysUser> {
@Select("<script>select * from s_user where login_name = #{username}</script>")
@Select("<script>select * from s_user where login_name = #{username} and del_flag = 0 and flag = 1</script>")
@ResultMap(value = "BaseResultMap")
List<SysUser> queryUserByName(String username);
......@@ -56,6 +56,6 @@ public interface SysUserMapper extends BaseMapper<SysUser> {
@Select("<script>select password from s_user where business_id = #{userId} </script>")
String queryPasswordById(String userId);
@Update("update s_user set password = #{password} where login_name = #{userCode}")
@Update("update s_user set password = #{password} where login_name = #{userCode} and del_flag = 0 and flag = 1")
int resetPassword( @Param("userCode") String userCode, @Param("password") String password);
}
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