|
@@ -13,22 +13,32 @@ import org.apache.poi.ss.usermodel.Sheet;
|
|
|
import org.apache.poi.ss.usermodel.Workbook;
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.data.mongodb.core.MongoTemplate;
|
|
|
+import org.springframework.data.mongodb.core.query.Criteria;
|
|
|
+import org.springframework.data.mongodb.core.query.Query;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import cn.com.qmth.examcloud.core.questions.base.enums.PaperType;
|
|
|
import cn.com.qmth.examcloud.core.questions.base.question.enums.QuesStructType;
|
|
|
import cn.com.qmth.examcloud.core.questions.dao.CourseRepo;
|
|
|
+import cn.com.qmth.examcloud.core.questions.dao.PaperDetailRepo;
|
|
|
import cn.com.qmth.examcloud.core.questions.dao.PaperDetailUnitRepo;
|
|
|
import cn.com.qmth.examcloud.core.questions.dao.PaperRepo;
|
|
|
import cn.com.qmth.examcloud.core.questions.dao.QuesTypeNameRepo;
|
|
|
import cn.com.qmth.examcloud.core.questions.dao.entity.Course;
|
|
|
import cn.com.qmth.examcloud.core.questions.dao.entity.Paper;
|
|
|
+import cn.com.qmth.examcloud.core.questions.dao.entity.PaperDetail;
|
|
|
+import cn.com.qmth.examcloud.core.questions.dao.entity.PaperDetailStruct;
|
|
|
import cn.com.qmth.examcloud.core.questions.dao.entity.PaperDetailUnit;
|
|
|
+import cn.com.qmth.examcloud.core.questions.dao.entity.PaperStruct;
|
|
|
import cn.com.qmth.examcloud.core.questions.dao.entity.QuesTypeName;
|
|
|
import cn.com.qmth.examcloud.core.questions.dao.entity.Question;
|
|
|
+import cn.com.qmth.examcloud.core.questions.dao.entity.dto.PaperDetailUnitStructDto;
|
|
|
import cn.com.qmth.examcloud.core.questions.dao.QuesRepo;
|
|
|
import cn.com.qmth.examcloud.core.questions.service.PaperDetailUnitService;
|
|
|
import cn.com.qmth.examcloud.core.questions.service.temp.vo.DdExcelDto;
|
|
|
+import cn.com.qmth.examcloud.core.questions.service.temp.vo.DdPaperDto;
|
|
|
+import cn.com.qmth.examcloud.core.questions.service.temp.vo.DdPaperStructDto;
|
|
|
import cn.com.qmth.examcloud.question.core.question.QuestionType;
|
|
|
|
|
|
@Service("ddExcelService")
|
|
@@ -51,8 +61,13 @@ public class DdExcelService {
|
|
|
|
|
|
@Autowired
|
|
|
private QuesTypeNameRepo quesTypeRepo;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ MongoTemplate mongoTemplate;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ PaperDetailRepo paperDetailRepo;
|
|
|
|
|
|
-
|
|
|
public void insertQueryName(String orgId){
|
|
|
//查询所有课程
|
|
|
long startCourseTime = System.currentTimeMillis();
|
|
@@ -132,6 +147,8 @@ public class DdExcelService {
|
|
|
return map;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
public void exporExcel(String orgId) throws Exception{
|
|
|
//导出Excel集合
|
|
|
List<DdExcelDto> ddExcelDtos = new ArrayList<DdExcelDto>();
|
|
@@ -374,9 +391,161 @@ public class DdExcelService {
|
|
|
System.out.println(otherMap);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 导出试卷详情
|
|
|
+ * @param orgId
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ public void exportPaperExcel(String orgId) throws Exception {
|
|
|
+ System.out.println("开始导出试卷具体信息。。。。");
|
|
|
+ //导出Excel对象集合
|
|
|
+ List<DdPaperDto> excelDtoList = new ArrayList<DdPaperDto>();
|
|
|
+ //查询所有课程
|
|
|
+ List<Course> courses = courseRepo.findByOrgId(orgId);
|
|
|
+ System.out.println("查询课程总数:"+ courses.size());
|
|
|
+ if(courses != null && courses.size()>0){
|
|
|
+ int i = 1;
|
|
|
+ for(Course course : courses){
|
|
|
+ //根据课程查询试卷
|
|
|
+ Query query = new Query();
|
|
|
+ query.addCriteria(Criteria.where("orgId").is(orgId));
|
|
|
+ query.addCriteria(Criteria.where("paperType").is(PaperType.GENERATE));
|
|
|
+ query.addCriteria(Criteria.where("course.enable").is("true"));
|
|
|
+ query.addCriteria(Criteria.where("course.code").is(course.getCode()));
|
|
|
+ List<Paper> paperList = this.mongoTemplate.find(query, Paper.class);
|
|
|
+ System.out.println(course.getCode() + "课程下的组卷试卷数量:" + paperList.size());
|
|
|
+ if(paperList != null && paperList.size()>0){
|
|
|
+ int j = 1;
|
|
|
+ for(Paper paper : paperList){
|
|
|
+ //查询大题集合
|
|
|
+ List<PaperDetail> details = paperDetailRepo.findByPaperOrderByNumber(paper);
|
|
|
+ if(details != null && details.size()>0){
|
|
|
+ for(PaperDetail detail:details){
|
|
|
+ DdPaperDto ddPaperDto = new DdPaperDto();
|
|
|
+ ddPaperDto.setCode(paper.getCourse().getCode());
|
|
|
+ ddPaperDto.setDetailName(detail.getName());
|
|
|
+ ddPaperDto.setName(paper.getCourse().getName());
|
|
|
+ ddPaperDto.setNumber(detail.getUnitCount());
|
|
|
+ ddPaperDto.setPaperName(paper.getName());
|
|
|
+ excelDtoList.add(ddPaperDto);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ System.out.println("处理完第"+ j + "套试卷。。。");
|
|
|
+ j++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ System.out.println("处理完第"+ i + "个课程。。。");
|
|
|
+ i++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //生成Excel对象
|
|
|
+ File ddExcelFile = new File("H:\\ddPaperDto.xlsx");
|
|
|
+ Workbook workBook = new XSSFWorkbook(ddExcelFile);
|
|
|
+ //获取第一个工作页
|
|
|
+ Sheet sheet = workBook.getSheetAt(0);
|
|
|
+ //向Excle中写入数据,从第2行开始
|
|
|
+ for(int i = 0;i<excelDtoList.size();i++){
|
|
|
+ //创建一行:从第1行开始,跳过表头
|
|
|
+ Row row = sheet.createRow(i+1);
|
|
|
+ DdPaperDto excelDto = excelDtoList.get(i);
|
|
|
+ //每列赋值
|
|
|
+ row.createCell(0).setCellValue(excelDto.getCode());
|
|
|
+ row.createCell(1).setCellValue(excelDto.getName());
|
|
|
+ row.createCell(2).setCellValue(excelDto.getPaperName());
|
|
|
+ row.createCell(3).setCellValue(excelDto.getDetailName());
|
|
|
+ row.createCell(4).setCellValue(excelDto.getNumber());
|
|
|
+ }
|
|
|
+ File file = new File("H:\\ddPaperDtoNew.xlsx");
|
|
|
+ OutputStream out = new FileOutputStream(file);
|
|
|
+ workBook.write(out);
|
|
|
+ out.close();
|
|
|
+ System.out.println("结束...");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 导出试卷结构
|
|
|
+ * @param orgId
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ public void exportPaperStructExcel(String orgId) throws Exception{
|
|
|
+ System.out.println("开始导出试卷结构");
|
|
|
+ //导出Excel对象集合
|
|
|
+ List<DdPaperStructDto> excelDtoList = new ArrayList<DdPaperStructDto>();
|
|
|
+ //查询所有课程
|
|
|
+ List<Course> courses = courseRepo.findByOrgId(orgId);
|
|
|
+ System.out.println("查询课程总数:"+ courses.size());
|
|
|
+ if(courses != null && courses.size()>0){
|
|
|
+ int i = 1;
|
|
|
+ for(Course course : courses){
|
|
|
+ Query query = new Query();
|
|
|
+ query.addCriteria(Criteria.where("orgId").is(orgId));
|
|
|
+ query.addCriteria(Criteria.where("type").is("EXACT"));
|
|
|
+ query.addCriteria(Criteria.where("courseNo").is(course.getCode()));
|
|
|
+ List<PaperStruct> paperStructList = this.mongoTemplate.find(query, PaperStruct.class);
|
|
|
+ System.out.println(course.getCode() + "课程下的试卷结构数量:" + paperStructList.size());
|
|
|
+ if(paperStructList != null && paperStructList.size()>0){
|
|
|
+ for(PaperStruct paperStruct:paperStructList){
|
|
|
+ //得到大题集合
|
|
|
+ List<PaperDetailStruct> paperDetailStructs = paperStruct.getPaperDetailStructs();
|
|
|
+ if(paperDetailStructs != null && paperDetailStructs.size()>0){
|
|
|
+ for(PaperDetailStruct paperDetailStruct:paperDetailStructs){
|
|
|
+ //得到大题下的小题集合
|
|
|
+ List<PaperDetailUnitStructDto> unitStructs = paperDetailStruct.getUnitStructs();
|
|
|
+ if(unitStructs != null && unitStructs.size()>0){
|
|
|
+ for(PaperDetailUnitStructDto unitStructDto:unitStructs){
|
|
|
+ DdPaperStructDto excelDto = new DdPaperStructDto();
|
|
|
+ excelDto.setCode(paperStruct.getCourseNo());
|
|
|
+ excelDto.setDetailName(paperDetailStruct.getName());
|
|
|
+ excelDto.setName(course.getName());
|
|
|
+ excelDto.setNumber(unitStructDto.getCount());
|
|
|
+ excelDto.setQuesNames(unitStructDto.getQuesNames().toString());
|
|
|
+ excelDto.setQuesType(unitStructDto.getQuestionType().getName());
|
|
|
+ excelDtoList.add(excelDto);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ System.out.println("处理完第:" + i + "个课程。");
|
|
|
+ System.out.println("生成对象个数:" + excelDtoList.size());
|
|
|
+ i++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //生成Excel对象
|
|
|
+ File ddExcelFile = new File("H:\\ddPaperStructDto.xlsx");
|
|
|
+ Workbook workBook = new XSSFWorkbook(ddExcelFile);
|
|
|
+ //获取第一个工作页
|
|
|
+ Sheet sheet = workBook.getSheetAt(0);
|
|
|
+ //向Excle中写入数据,从第2行开始
|
|
|
+ for(int i = 0;i<excelDtoList.size();i++){
|
|
|
+ //创建一行:从第1行开始,跳过表头
|
|
|
+ Row row = sheet.createRow(i+1);
|
|
|
+ DdPaperStructDto excelDto = excelDtoList.get(i);
|
|
|
+ //每列赋值
|
|
|
+ row.createCell(0).setCellValue(excelDto.getCode());
|
|
|
+ row.createCell(1).setCellValue(excelDto.getName());
|
|
|
+ row.createCell(2).setCellValue(excelDto.getDetailName());
|
|
|
+ row.createCell(3).setCellValue(excelDto.getQuesNames());
|
|
|
+ row.createCell(4).setCellValue(excelDto.getNumber());
|
|
|
+ row.createCell(5).setCellValue(excelDto.getQuesType());
|
|
|
+ }
|
|
|
+ File file = new File("H:\\ddPaperStructDtoNew.xlsx");
|
|
|
+ OutputStream out = new FileOutputStream(file);
|
|
|
+ workBook.write(out);
|
|
|
+ out.close();
|
|
|
+ System.out.println("结束...");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
public static void main(String[] args){
|
|
|
- File ddExcelFile = new File("H:\\ddExcelDto.xlsx");
|
|
|
- System.out.println(ddExcelFile);
|
|
|
+// File ddExcelFile = new File("H:\\ddExcelDto.xlsx");
|
|
|
+ List<String> ss = new ArrayList<String>();
|
|
|
+ ss.add("单选");
|
|
|
+ ss.add("单选题");
|
|
|
+ ss.add("选择题");
|
|
|
+ System.out.println(ss);
|
|
|
+ System.out.println(ss.toString());
|
|
|
}
|
|
|
|
|
|
}
|