Commit 944c288c authored by YangZhaoJun1's avatar YangZhaoJun1

修改文件复制方法,解决bug

parent 92f1bdc7
......@@ -23,11 +23,16 @@ import org.rcisoft.business.blesson.entity.BLesson;
import org.rcisoft.business.blesson.entity.BLessonDirection;
import org.rcisoft.business.brooms.dao.BRoomsRepository;
import org.rcisoft.business.brooms.entity.BRooms;
import org.rcisoft.business.brslstudent.dao.BRSlStudentRepository;
import org.rcisoft.business.brslstudent.entity.BRSlStudent;
import org.rcisoft.business.bsl.dao.BSlRepository;
import org.rcisoft.business.bsl.entity.BSl;
import org.rcisoft.business.bslschedule.dao.BSlScheduleRepository;
import org.rcisoft.business.bslschedule.entity.BSlSchedule;
import org.rcisoft.business.bslschedule.util.FindTime;
import org.rcisoft.business.bstudent.dao.BStudentRepository;
import org.rcisoft.business.bstudent.entity.BStudent;
import org.rcisoft.business.bstudent.service.BStudentService;
import org.rcisoft.business.bteacher.dao.BTeacherRepository;
import org.rcisoft.business.bteacher.entity.BTeacher;
import org.rcisoft.business.bterm.dao.BTermRepository;
......@@ -96,11 +101,14 @@ public class BArrangeServiceImpl implements BArrangeService {
private SysUserMapper sysUserMapper;
@Autowired
private BClassRepository bClassRepository;
private BStudentRepository bStudentRepository;
@Autowired
private BTeacherRepository bTeacherRepository;
@Autowired
private BRSlStudentRepository brSlStudentRepository;
@Autowired
private Global global;
......@@ -648,6 +656,7 @@ public class BArrangeServiceImpl implements BArrangeService {
}
List<BSl> sls = new ArrayList<>();
List<BLessonDirection> bLessonDirections = new ArrayList<>();
List<BRSlStudent> slStudents = new ArrayList<>();
int maxSlCode = bTermRepository.queryMaxSlCodeByTermCode(termCode);
for(String subAgencyId : subAgencyIds){
//查询要开的课
......@@ -687,6 +696,17 @@ public class BArrangeServiceImpl implements BArrangeService {
bLessonDirection.setDirectionId(bLesson.getDirectionId());
bLessonDirections.add(bLessonDirection);
//构造学生选课信息
List<BStudent> students = bStudentRepository.queryStudentByEduClassCode(schedule.getClassCode());
for(BStudent student : students){
BRSlStudent brSlStudent = new BRSlStudent();
brSlStudent.setBusinessId(IdGen.uuid());
brSlStudent.setSlCode(sl.getCode());
brSlStudent.setStudentCode(student.getCode());
slStudents.add(brSlStudent);
}
//复制章节及文件目录
chapterService.addBslFormLesson(null,sl.getLessonCode(), sl.getBusinessId());
}
......@@ -697,6 +717,7 @@ public class BArrangeServiceImpl implements BArrangeService {
bSubtaskRepository.updateByPrimaryKeySelective(bSubtask);//将子任务状态置为已开课
bTermRepository.MaxSlCodeByTermCode(termCode,String.valueOf(maxSlCode));//将该学期的开课序号存入
bDirectionRepository.insertList(bLessonDirections);//批量插入课程方向
brSlStudentRepository.insertList(slStudents);//批量插入学生选课关系
//批量插入
result =bSlRepository.insertList(sls);
......
......@@ -34,6 +34,9 @@ import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import java.io.*;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
......@@ -293,12 +296,12 @@ public class BChapterServiceImpl implements BChapterService {
//复制章节的所有文件
try {
//copyFileToSl(oldPath,newPath,bLessonId,slId);
File oldFile = new File(oldPath);
copyFileToSl(oldPath,newPath);
/*File oldFile = new File(oldPath);
File newFile = new File(newPath);
FileUtils.copyDirectory(oldFile,newFile,true);
FileUtils.copyDirectory(oldFile,newFile,true);*/
} catch (IOException e) {
e.printStackTrace();
throw new ServiceException(ResultServiceEnums.COPY_FILES_ERROR);
}
//数据库操作
......@@ -352,7 +355,7 @@ public class BChapterServiceImpl implements BChapterService {
* @param oldPath
* @param newPath
*/
private void copyFileToSl(String oldPath, String newPath, String bLessonId, String slId) throws IOException {
private void copyFileToSl(String oldPath, String newPath) throws IOException {
File oldFile = new File(oldPath);
File[] fs=oldFile.listFiles();
......@@ -362,9 +365,12 @@ public class BChapterServiceImpl implements BChapterService {
}
for (File f : fs) {
if(f.isFile()){
fileCopy(f.getPath(),newPath+File.separator+f.getName()); //调用文件拷贝的方法
Path link = Paths.get(newPath+File.separator+f.getName());
Path existing = Paths.get(f.getPath());
Files.createLink(link,existing);
//fileCopy(f.getPath(),newPath+File.separator+f.getName()); //调用文件拷贝的方法
}else if(f.isDirectory()){
copyFileToSl(f.getPath(),newPath+File.separator+f.getName(), bLessonId, slId);
copyFileToSl(f.getPath(),newPath+File.separator+f.getName());
}
}
}
......
package org.rcisoft.business.bclass.dao;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.*;
import org.rcisoft.business.bclass.entity.BClass;
import org.rcisoft.core.base.BaseMapper;
import org.springframework.stereotype.Repository;
......@@ -67,5 +64,8 @@ public interface BClassRepository extends BaseMapper<BClass> {
"class_name = #{className} and business_id != #{businessId}</script>")
@ResultMap(value = "BaseResultMap" )
List<BClass> selectClassesByName(BClass bClass);
@Update("UPDATE b_class SET student_num = (student_num-1) WHERE FIND_IN_SET(`code`,#{classCodes})")
int updateStudentNumByClassCodes(String classCodes);
}
......@@ -56,11 +56,14 @@ public class BRClassStudentController extends PaginationController<BRClassStuden
}
@ApiOperation(value="excel导入", notes="excel导入")
@ApiImplicitParam(name = "importFile", value = "excel文件", required = true, dataType = "MultipartFile")
@ApiImplicitParams({
@ApiImplicitParam(name = "importFile", value = "excel文件", required = true, dataType = "MultipartFile"),
@ApiImplicitParam(name = "type", value = "0行政班,1企业班", required = true, dataType = "varchar")
})
@PreAuthorize("hasRole('ROLE_1001')")
@PostMapping(value = "excelImport")
public Result excelImport(MultipartFile importFile) throws Exception {
PersistModel data = bRClassStudentService.excelImport(MultipartFile2HSSFWorkbookConverter.convert(importFile));
public Result excelImport(MultipartFile importFile, String type) throws Exception {
PersistModel data = bRClassStudentService.excelImport(MultipartFile2HSSFWorkbookConverter.convert(importFile),type);
return Result.builder(data,
MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR,
......
......@@ -68,5 +68,13 @@ public interface BRClassStudentRepository extends BaseMapper<BRClassStudent> {
*/
@Delete("delete from b_r_class_student where student_code = #{stuCode}")
int deleteCSByStuId(String stuCode);
@Select("<script>SELECT bcs.* FROM b_r_class_student bcs " +
"LEFT JOIN b_class bc on bc.`code`=bcs.class_code " +
"LEFT JOIN b_student bs on bs.`code`=bcs.student_code " +
"WHERE bcs.student_code=#{studentCode} " +
"AND bc.type=#{type}</script>")
@ResultMap(value = "BaseResultMap" )
BRClassStudent queryClassStudent(String studentCode, String type);
}
......@@ -47,7 +47,7 @@ public interface BRClassStudentService{
* @param hwb
* @return
*/
PersistModel excelImport(HSSFWorkbook hwb) throws IOException;
PersistModel excelImport(HSSFWorkbook hwb, String type) throws IOException;
/**
* 物理删除
......
......@@ -80,7 +80,7 @@ public class BRClassStudentServiceImpl implements BRClassStudentService {
@Override
@Transactional(propagation = Propagation.REQUIRED,readOnly = false)
public PersistModel excelImport(HSSFWorkbook hwb) throws IOException {
public PersistModel excelImport(HSSFWorkbook hwb, String type) throws IOException {
ArrayList<BRClassStudent> brClassStudents = new ArrayList<BRClassStudent>();
ArrayList<String> studentCode = new ArrayList<String>();
ArrayList<String> classCode = new ArrayList<String>();
......@@ -118,9 +118,8 @@ public class BRClassStudentServiceImpl implements BRClassStudentService {
//1.3 检查班级学生是否存在
BRClassStudent classStudent = new BRClassStudent();
//classStudent.setClassCode(value[0]);
classStudent.setStudentCode(value[1]);
if((bRClassStudentRepository.selectOne(classStudent))!=null) {
if((bRClassStudentRepository.queryClassStudent(value[1],type))!=null) {
repeatCode.add(value[1]);
continue;
}
......
......@@ -40,7 +40,7 @@ public class BRooms extends IdEntity<BRooms> {
private String building;
/*教室号*/
@Length(min= 1 , max = 10, message = "长度最短为1,最长为10")
@Length(min= 1 , max = 15, message = "长度最短为1,最长为15")
@NotBlank
private String classroomNo;
......
......@@ -112,7 +112,8 @@ public interface BStudentRepository extends BaseMapper<BStudent> {
String queryStudentByUserId(String userId);
@Select("<script>SELECT t3.business_id as businessId, t3.code,t4.`name`,t6.class_name as className,\n" +
@Select("<script>SELECT t3.business_id as businessId, t3.code,t4.`name`,t6.class_name as className," +
"IFNULL(bsc.is_complete,0) as submit, " +
"(CONCAT((SELECT COUNT(*) from b_r_student_chapter " +
"where student_id = t3.business_id and sl_id = #{slId} and is_complete = '1')," +
"'/'," +
......@@ -120,19 +121,21 @@ public interface BStudentRepository extends BaseMapper<BStudent> {
") AS finishNum " +
"FROM\n" +
"b_r_sl_student t2\n" +
"LEFT JOIN b_student t3 ON t2.student_code = t3.`code`\n" +
"LEFT JOIN s_user t4 ON t3.`code` = t4.login_name\n" +
"LEFT JOIN b_student t3 ON t2.student_code = t3.`code` " +
"LEFT JOIN s_user t4 ON t3.`code` = t4.login_name " +
"LEFT JOIN b_r_class_student t5 on t5.student_code = t3.code " +
"LEFT JOIN b_class t6 on t6.code = t5.class_code " +
"WHERE\n" +
"LEFT JOIN b_r_student_chapter bsc on bsc.student_id = t3.business_id " +
"WHERE " +
"t2.sl_code = #{slCode} " +
" and t3.del_flag != 1 and t3.flag = 1" +
"<if test=\"classCode!=null and classCode != ''\">\n" +
" AND t6.code = #{classCode}\n" +
"<if test=\"classCode!=null and classCode != ''\"> " +
" AND t6.code = #{classCode} " +
"</if>" +
"<if test=\"keyWord!=null and keyWord != ''\">\n" +
" AND (t3.`code` like CONCAT('%',#{keyWord},'%') or t4.`name` like CONCAT('%',#{keyWord},'%'))\n" +
"<if test=\"keyWord!=null and keyWord != ''\"> " +
" AND (t3.`code` like CONCAT('%',#{keyWord},'%') or t4.`name` like CONCAT('%',#{keyWord},'%')) " +
"</if>" +
"GROUP BY t3.`code` " +
"order by className asc,code asc</script>")
@ResultMap(value = "BaseResultMap" )
List<BStudent> queryStudentInSl(@Param("slCode") String slCode,
......@@ -171,5 +174,19 @@ public interface BStudentRepository extends BaseMapper<BStudent> {
@Select("select * from b_grade where code = #{gradeCode} and del_flag = 0 and flag = 1")
List<BClass> checkStudentGrade(BStudent bStudent);
@Select("SELECT bs.* FROM b_student bs " +
"LEFT JOIN b_r_class_student bcs on bcs.student_code = bs.`code` " +
"LEFT JOIN b_class bc on bc.`code` = bcs.class_code " +
"WHERE FIND_IN_SET(bcs.class_code,( " +
"SELECT bec.classes_id FROM b_edu_class bec WHERE bec.`code` = 'D0001')) " +
"GROUP BY bs.`code` " +
"ORDER BY bs.`code`")
@ResultMap(value = "BaseResultMap")
List<BStudent> queryStudentByEduClassCode(String classCode);
@Select("SELECT bcs.class_code from b_student bs \n" +
"LEFT JOIN b_r_class_student bcs on bcs.student_code = bs.`code`\n" +
"WHERE bs.business_id = #{id}")
List<String> queryClassCodesById(String id);
}
......@@ -90,5 +90,8 @@ public class BStudent extends IdEntity<BStudent> {
@Transient
private String condition;//模糊查询条件
@Transient
private String submit;
}
......@@ -3,6 +3,7 @@ package org.rcisoft.business.bstudent.service.impl;
import com.alibaba.druid.util.StringUtils;
import com.alibaba.fastjson.JSON;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.rcisoft.business.bclass.dao.BClassRepository;
import org.rcisoft.business.brclassstudent.dao.BRClassStudentRepository;
import org.rcisoft.business.brclassstudent.entity.BRClassStudent;
import org.rcisoft.business.brslstudent.dao.BRSlStudentRepository;
......@@ -61,6 +62,8 @@ public class BStudentServiceImpl implements BStudentService {
private BRSlStudentRepository brSlStudentRepository;
@Autowired
private PasswordEncoder passwordEncoder;
@Autowired
private BClassRepository bClassRepository;
@Override
public BStudent selectOne(String businessId) {
......@@ -161,6 +164,7 @@ public class BStudentServiceImpl implements BStudentService {
continue;
}
value[1].trim();
if(value[1].length()<1||value[1].length()>15){
//该用户不满足要求,记入valuesShort中
nameTooLong.add(value[0]);
......@@ -298,6 +302,13 @@ public class BStudentServiceImpl implements BStudentService {
BStudent student = bStudentRepository.selectOne(bStudent);
sysUserMapper.deleteByCode(student.getCode());
List<String> classCodes = bStudentRepository.queryClassCodesById(id);
String clCode = "";
for(String classCode : classCodes){
clCode += classCode + ",";
}
bClassRepository.updateStudentNumByClassCodes(clCode);//更新班级人数-1
int line = bStudentRepository.deleteByPrimaryKey(bStudent);
brClassStudentRepository.deleteCSByStuId(student.getCode());
......
......@@ -120,6 +120,7 @@ public class BTeacherServiceImpl implements BTeacherService {
continue;
}
value[1].trim();
if(value[1].length()<1||value[1].length()>15){
//该用户不满足要求,记入valuesShort中
nameTooLong.add(value[0]);
......@@ -182,7 +183,7 @@ public class BTeacherServiceImpl implements BTeacherService {
user.setGitLabId(accountDTO.getId());
user.setGitLabUsername(accountDTO.getUsername());
user.setGitLabImpressionToken(accountDTO.getImpersonationToken());*/
user.setHeadPic(global.getDEFAULT_STUDENT_LOCATION());
user.setHeadPic(global.getDEFAULT_TEACHER_LOCATION());
//4.添加用户权限
UserRole userRole = new UserRole(user.getBusinessId(), "bbbbbbbb");
......
......@@ -198,7 +198,9 @@ public enum ResultServiceEnums {
ROOM_BUILDINGNO_TOO_LONG(105,"教室号长度过长"),
ROOM_SEAT_TOO_MANY(106,"人数过多")
ROOM_SEAT_TOO_MANY(106,"人数过多"),
COPY_FILES_ERROR(107,"复制课程相关资料失败")
;
private Integer 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