Commit c619d8e4 authored by xingyuji's avatar xingyuji

1.智评在实验提交完成时触发问题(已获取到,但被重置为-1)---BchapterServiceImpl.java;

2.实验代码文件在提交完成后的查看问题(增加判断,不限制查看)---BCodeController.java;
3.实验容器端口占用问题(查询为占用端口部分代码for循环上限错误)---BCodeLxcServiceImpl.java;
4.作业导出压缩包内容为空的问题(原因有二:一,关于根据slId查询章节及学生的sql错误导致查询为0;二,对单文件和工程的代码目录或文件复制时出现错误,现已改用Java官方提供的FileUtils提供的目录拷贝方法)---BCodeServiceImpl.java,BRLlStudentRepository.java;
5.新增课程未添加任何章节时修改学时置为0报错问题(sql语句使用SUM()函数问题,已改为COALESCE(SUM(class_hour),0))---BLessonRepository.java;
6.课程详情页右侧教师详情关于已发布课程计数问题(修改sql语句,只查出发布和结课两种状态);---BSlRepository.java;
7.删除已开的课程后再次导入同样课程,之前的学生选课信息仍然关联(删除开课的代码逻辑中,添加对学生选课记录的删除逻辑)---BSlServiceImpl.java;
8.教师查看学生实验完成率不准确问题(sql语句小问题)---BStudentRepository.java;
parent 23177175
...@@ -202,8 +202,9 @@ public class BChapterServiceImpl implements BChapterService { ...@@ -202,8 +202,9 @@ public class BChapterServiceImpl implements BChapterService {
int score = IntellEvaluation.IntellEvaluation(filePath,scoreInfoDTO.getStudentCode(),bChapter.getExperimentType()); int score = IntellEvaluation.IntellEvaluation(filePath,scoreInfoDTO.getStudentCode(),bChapter.getExperimentType());
scoreInfoDTO.setScore(score); scoreInfoDTO.setScore(score);
} }else{
scoreInfoDTO.setScore(-1); scoreInfoDTO.setScore(-1);
}
scoreInfoDTO.setStudentId(stuid); scoreInfoDTO.setStudentId(stuid);
int result; int result;
//查询是否已有关联关系 //查询是否已有关联关系
......
...@@ -202,7 +202,7 @@ public class BCodeController extends PaginationController { ...@@ -202,7 +202,7 @@ public class BCodeController extends PaginationController {
+ 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); String finished = bChapterService.queryIsCompleteByUserIdAndChapId(UserUtil.getUserInfoProp(getToken(), UserUtil.USER_ID),chapId);
if(finished!=null&&finished.equals("1")){ if(finished!=null&&finished.equals("1")&&!fileType.equals("6")){
throw new ServiceException(ResultServiceEnums.EXPERIMENT_FINISHED); throw new ServiceException(ResultServiceEnums.EXPERIMENT_FINISHED);
} }
if(fileType.equals("1")&&!file.exists()){//新增文件夹 if(fileType.equals("1")&&!file.exists()){//新增文件夹
......
...@@ -21,6 +21,7 @@ import org.springframework.stereotype.Service; ...@@ -21,6 +21,7 @@ import org.springframework.stereotype.Service;
import java.io.File; import java.io.File;
import java.util.*; import java.util.*;
import java.util.logging.Logger;
/** /**
* Created by lcy on 18/1/9. * Created by lcy on 18/1/9.
...@@ -54,6 +55,7 @@ public class BCodeLxcServiceImpl implements BCodeLxcService { ...@@ -54,6 +55,7 @@ public class BCodeLxcServiceImpl implements BCodeLxcService {
@Override @Override
public CommandResult startBCodeLxc(BCodeLxc lxc) { public CommandResult startBCodeLxc(BCodeLxc lxc) {
Logger logger = Logger.getAnonymousLogger();
CommandResult result = null; CommandResult result = null;
List<String> ports = null; List<String> ports = null;
/*初始化port 20000 - 30000 */ /*初始化port 20000 - 30000 */
...@@ -62,13 +64,19 @@ public class BCodeLxcServiceImpl implements BCodeLxcService { ...@@ -62,13 +64,19 @@ public class BCodeLxcServiceImpl implements BCodeLxcService {
Integer portSSH = global.getLxcInitPort()+10000; Integer portSSH = global.getLxcInitPort()+10000;
Integer maxPortSSH = global.getLxcMaxPort()+10000; Integer maxPortSSH = global.getLxcMaxPort()+10000;
ports = rcRedisServiceImpl.getList("lxcPorts"); ports = rcRedisServiceImpl.getList("lxcPorts");
logger.info("------------------------------------------------------------------------------------------------");
logger.info(ports.size()+"redis 端口使用数量");
if(null == ports || 0 == ports.size()) if(null == ports || 0 == ports.size())
ports = new ArrayList<>(); ports = new ArrayList<>();
else{ else{
port = this.getIdleWithPorts(ports,port,maxPort); port = this.getIdleWithPorts(ports,port,maxPort);
logger.info("<port>:"+port);
portSSH = this.getIdleWithPorts(ports,portSSH,maxPortSSH); portSSH = this.getIdleWithPorts(ports,portSSH,maxPortSSH);
logger.info("<portSSH>:"+portSSH);
} }
/*端口满了*/ /*端口满了*/
if(0 == port||0 == portSSH) { if(0 == port||0 == portSSH) {
result = new CommandResult(ResultCode.FAIL,"端口全部占用,请稍后!",lxc); result = new CommandResult(ResultCode.FAIL,"端口全部占用,请稍后!",lxc);
...@@ -150,11 +158,15 @@ public class BCodeLxcServiceImpl implements BCodeLxcService { ...@@ -150,11 +158,15 @@ public class BCodeLxcServiceImpl implements BCodeLxcService {
* @return * @return
*/ */
private synchronized Integer getIdleWithPorts(List<String> ports, Integer port, Integer maxPort) { private synchronized Integer getIdleWithPorts(List<String> ports, Integer port, Integer maxPort) {
Logger logger = Logger.getAnonymousLogger();
logger.info("------------------------getIdleWithPorts-------------------------------------");
logger.info("[portsSize:]"+ports.size());
logger.info("[port jisuan:]"+(ports.size() -1 - (maxPort - port)) );
int choosePort = 0; int choosePort = 0;
/*端口占用满了*/ /*端口占用满了*/
if(ports.size() -1 - (maxPort - port) == 0) if(ports.size() -1 - (maxPort - port) == 0)
return choosePort; return choosePort;
for(int i = port ; i < maxPort - port ; i++){ for(int i = port ; i < maxPort ; i++){
boolean flag = false; boolean flag = false;
for (int j = 0 ; j < ports.size() ; j++){ for (int j = 0 ; j < ports.size() ; j++){
if(i - Integer.parseInt(ports.get(j)) == 0) { if(i - Integer.parseInt(ports.get(j)) == 0) {
......
...@@ -365,7 +365,12 @@ public class BCodeServiceImpl implements BCodeService { ...@@ -365,7 +365,12 @@ public class BCodeServiceImpl implements BCodeService {
studentId=""; studentId="";
} }
//根据slId获得章节及学生 //根据slId获得章节及学生
students = brSlStudentRepository.queryStudentBySlId(slId,studentId); if(studentId.equals("")){//工程
students = brSlStudentRepository.queryStudentBySlId1(slId,studentId);
}else {
students = brSlStudentRepository.queryStudentBySlId2(slId,studentId);
}
//查询该课程的所有章节 //查询该课程的所有章节
//List<BChapter> chapterList = bChapterRepository.queryChapterBySlId(slId); //List<BChapter> chapterList = bChapterRepository.queryChapterBySlId(slId);
if(students.size()>=1){ if(students.size()>=1){
...@@ -399,31 +404,52 @@ public class BCodeServiceImpl implements BCodeService { ...@@ -399,31 +404,52 @@ public class BCodeServiceImpl implements BCodeService {
//学生代码文件所在目录 //学生代码文件所在目录
String codePath = SlPath + student.getChapterId() +File.separator String codePath = SlPath + student.getChapterId() +File.separator
+ codeType + student.getStudentId() + File.separator; + codeType + student.getStudentId() + File.separator;
File userFile = new File(codePath); File codeFile = new File(codePath);
//得到目录下的所有文件 if(!codeFile.exists()){
File javaFile[] = userFile.listFiles(); codeFile.mkdirs();
if(javaFile!=null) { }
for (File simpleFile : javaFile) {
//将文件复制出去
try { try {
int bytesum = 0; // if(student.getExperimentType().equals("2")||student.getExperimentType().equals("4")){
int byteread = 0; FileUtils.copyDirectory(codeFile,copyFile);
InputStream inStream = new FileInputStream(simpleFile.getPath()); //读入原文件 // }else {
FileOutputStream fs = new FileOutputStream(finalPath + simpleFile.getName()); // File javaFile[] = codeFile.listFiles();
byte[] buffer = new byte[102400]; // for(File simpleFile : javaFile){
int length; // File finalFile = new File(finalPath + simpleFile.getName());
while ((byteread = inStream.read(buffer)) != -1) { // FileUtils.copyFile(javaFile[0],finalFile);
bytesum += byteread; //字节数 文件大小 // }
fs.write(buffer, 0, byteread); //
} // }
inStream.close();
fs.close();
} catch (Exception e) { } catch (Exception e) {
System.out.println("复制时出错"); System.out.println("复制逻辑出错,可能路径不对!");
e.printStackTrace(); e.printStackTrace();
} }
}
}
// File userFile = new File(codePath);
// //得到目录下的所有文件
// File javaFile[] = userFile.listFiles();
// if(javaFile!=null) {
// for (File simpleFile : javaFile) {
// //将文件复制出去
// try {
// int bytesum = 0;
// int byteread = 0;
// InputStream inStream = new FileInputStream(simpleFile.getPath()+File.separator+"42432"); //读入原文件
// FileOutputStream fs = new FileOutputStream(finalPath + simpleFile.getName());
// byte[] buffer = new byte[102400];
// int length;
// while ((byteread = inStream.read(buffer)) != -1) {
// bytesum += byteread; //字节数 文件大小
// fs.write(buffer, 0, byteread);
// }
// inStream.close();
// fs.close();
// } catch (Exception e) {
// System.out.println("复制时出错");
// e.printStackTrace();
// }
// }
// }
} }
}else{ }else{
throw new ServiceException(ResultServiceEnums.NO_STUDENT_HOMEWORK); throw new ServiceException(ResultServiceEnums.NO_STUDENT_HOMEWORK);
......
...@@ -59,7 +59,7 @@ public interface BLessonRepository extends BaseMapper<BLesson> { ...@@ -59,7 +59,7 @@ public interface BLessonRepository extends BaseMapper<BLesson> {
@Update("<script>update b_lesson_direction set direction_id = #{directionId} where sl_id = #{slId}</script>") @Update("<script>update b_lesson_direction set direction_id = #{directionId} where sl_id = #{slId}</script>")
int updateDirectionBySlId(BLessonDirection direction); int updateDirectionBySlId(BLessonDirection direction);
@Select("SELECT SUM(class_hour) classHour FROM b_chapter where lesson_id = #{businessId} and pid != '-1'") @Select("SELECT COALESCE(SUM(class_hour),0) classHour FROM b_chapter where lesson_id = #{businessId} and pid != '-1'")
int queryClassHourByLessonId(String businessId); int queryClassHourByLessonId(String businessId);
} }
...@@ -92,9 +92,25 @@ public interface BRSlStudentRepository extends BaseMapper<BRSlStudent> { ...@@ -92,9 +92,25 @@ public interface BRSlStudentRepository extends BaseMapper<BRSlStudent> {
"and bc.sl_id = #{slId} " + "and bc.sl_id = #{slId} " +
"and bc.pid != '-1' AND bc.is_test like '%1%' " + "and bc.pid != '-1' AND bc.is_test like '%1%' " +
"and brc.is_complete = 1 " + "and brc.is_complete = 1 " +
"<if test=\"studentId !=null and studentId !=''\">" + "</script>")
"and FIND_IN_SET(su.business_id,#{studentId}) " + List<BStudentDto> queryStudentBySlId1(@Param("slId") String slId, @Param("studentId")String studentId);
"</if></script>")
List<BStudentDto> queryStudentBySlId(@Param("slId") String slId, @Param("studentId")String studentId); @Select("<script>select bc.business_id AS chapterId," +
"bc.experiment_type AS experimentType," +
"bc.sort,su.business_id AS studentId," +
"bs.`code` AS studentCode," +
"su.`name` AS studentName,\n" +
"(select sort from b_chapter where business_id = bc.pid )AS pSort " +
"from b_chapter bc \n" +
"LEFT JOIN b_r_student_chapter brc ON bc.business_id = brc.chapter_id\n" +
"LEFT JOIN b_student bs on bs.business_id = brc.student_id \n" +
"LEFT JOIN s_user su on su.login_name = bs.`code`\n" +
"where bc.del_flag = 0 and bc.flag = 1 " +
"and bc.sl_id = #{slId} " +
"and bc.pid != '-1' AND bc.is_test like '%1%' " +
"and brc.is_complete = 1 " +
"and FIND_IN_SET(brc.student_id,#{studentId}) " +
"</script>")
List<BStudentDto> queryStudentBySlId2(@Param("slId") String slId, @Param("studentId")String studentId);
} }
...@@ -156,7 +156,7 @@ public interface BSlRepository extends BaseMapper<BSl> { ...@@ -156,7 +156,7 @@ public interface BSlRepository extends BaseMapper<BSl> {
"LEFT JOIN b_term t9 ON t1.term_code = t9.`code`\n" + "LEFT JOIN b_term t9 ON t1.term_code = t9.`code`\n" +
"LEFT JOIN b_lesson t6 ON t1.lesson_code = t6.`code`\n" + "LEFT JOIN b_lesson t6 ON t1.lesson_code = t6.`code`\n" +
"LEFT JOIN (SELECT count(t3.business_id) AS t_num,t4.`name`,t2.`code`,t4.head_pic FROM b_teacher t2\n" + "LEFT JOIN (SELECT count(t3.business_id) AS t_num,t4.`name`,t2.`code`,t4.head_pic FROM b_teacher t2\n" +
"LEFT JOIN b_sl t3 ON t2.`code` = t3.teacher_code\n" + "LEFT JOIN b_sl t3 ON t2.`code` = t3.teacher_code AND (t3.audit_status='2'|| t3.audit_status='4')\n" +
"LEFT JOIN s_user t4 ON t4.login_name = t2.`code`\n" + "LEFT JOIN s_user t4 ON t4.login_name = t2.`code`\n" +
"GROUP BY t3.teacher_code) t5 ON t5.`code` = t1.teacher_code\n" + "GROUP BY t3.teacher_code) t5 ON t5.`code` = t1.teacher_code\n" +
"WHERE\n" + "WHERE\n" +
......
...@@ -279,7 +279,7 @@ public class BSlServiceImpl implements BSlService { ...@@ -279,7 +279,7 @@ public class BSlServiceImpl implements BSlService {
if(bSl==null) if(bSl==null)
throw new ServiceException(ResultServiceEnums.SL_INFO_NOT_EXISTS); throw new ServiceException(ResultServiceEnums.SL_INFO_NOT_EXISTS);
//action.deleteProject(bSl.getGitLabProjectId()); //action.deleteProject(bSl.getGitLabProjectId());
//brSlStudentRepository.deleteBatch(bSl.getCode()); brSlStudentRepository.deleteBatch(bSl.getCode());
BSl bsl = new BSl(); BSl bsl = new BSl();
bsl.setBusinessId(id); bsl.setBusinessId(id);
UserUtil.setCurrentMergeOperation(bsl); UserUtil.setCurrentMergeOperation(bsl);
......
...@@ -124,9 +124,9 @@ public interface BStudentRepository extends BaseMapper<BStudent> { ...@@ -124,9 +124,9 @@ public interface BStudentRepository extends BaseMapper<BStudent> {
String queryStudentByUserId(String userId); String queryStudentByUserId(String userId);
@Select("<script>SELECT t3.code,t4.`name`,t6.class_name as className,\n" + @Select("<script>SELECT t3.business_id as stuId, t3.code,t4.`name`,t6.class_name as className,\n" +
"(CONCAT((SELECT COUNT(*) from b_r_student_chapter " + "(CONCAT((SELECT COUNT(*) from b_r_student_chapter " +
"where student_id = t4.business_id and sl_id = #{slId} and is_complete = '1')," + "where student_id = t3.business_id and sl_id = #{slId} and is_complete = '1')," +
"'/'," + "'/'," +
"(SELECT COUNT(*) from b_chapter where is_test like CONCAT('%','1','%') and sl_id = #{slId})) \n" + "(SELECT COUNT(*) from b_chapter where is_test like CONCAT('%','1','%') and sl_id = #{slId})) \n" +
") AS finishNum " + ") AS finishNum " +
......
...@@ -36,7 +36,8 @@ public class BStudent extends IdEntity<BStudent> { ...@@ -36,7 +36,8 @@ public class BStudent extends IdEntity<BStudent> {
return code != null ? code.equals(bStudent.code) : bStudent.code == null; return code != null ? code.equals(bStudent.code) : bStudent.code == null;
} }
/*学生ID*/
private String stuId;
/*学号*/ /*学号*/
private String code; private String code;
......
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