|
@@ -28,7 +28,8 @@ public class ExportPaperByAllQuestions {
|
|
|
private static Logger logger = LogManager.getLogger(Export.class);
|
|
|
private static String excelDir;
|
|
|
private static String quesDir;
|
|
|
-
|
|
|
+ private static List<CourseInfo> codes;
|
|
|
+
|
|
|
private static Map<String, String> quesTypes = new HashMap<String, String>();
|
|
|
static {
|
|
|
quesTypes.put("11", "单选题");
|
|
@@ -41,7 +42,7 @@ public class ExportPaperByAllQuestions {
|
|
|
quesTypes.put("14", "选词填空");
|
|
|
quesTypes.put("15", "完形填空");
|
|
|
quesTypes.put("61", "分析题");
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
|
|
|
public static void main(String[] args) {
|
|
@@ -49,7 +50,7 @@ public class ExportPaperByAllQuestions {
|
|
|
try {
|
|
|
dispose();
|
|
|
} catch (Exception e) {
|
|
|
- logger.error(e.getCause(),e);
|
|
|
+ logger.error(e.getCause(), e);
|
|
|
}
|
|
|
logger.debug("export end...");
|
|
|
}
|
|
@@ -66,7 +67,7 @@ public class ExportPaperByAllQuestions {
|
|
|
}
|
|
|
File quesFolder = new File(quesDir);
|
|
|
quesFolder.mkdir();
|
|
|
- List<CourseInfo> codes = readCourseCode();
|
|
|
+ codes = readCourseCode();
|
|
|
if (codes == null || codes.size() == 0) {
|
|
|
logger.debug("no data export");
|
|
|
return;
|
|
@@ -82,6 +83,7 @@ public class ExportPaperByAllQuestions {
|
|
|
pro.put("user", "qspad");
|
|
|
pro.put("password", "qspad1");
|
|
|
connect = driver.connect("jdbc:oracle:thin:@202.114.196.115:1521:qspad", pro);
|
|
|
+ fillCourseInfo(connect);
|
|
|
for (CourseInfo code : codes) {
|
|
|
exportPaper(connect, code);
|
|
|
}
|
|
@@ -102,7 +104,8 @@ public class ExportPaperByAllQuestions {
|
|
|
int rows = sheet.getLastRowNum();
|
|
|
for (int i = 1; i <= rows; i++) {
|
|
|
XSSFRow row = sheet.getRow(i);
|
|
|
- list.add(new CourseInfo(row.getCell(2).getStringCellValue(), row.getCell(0).getStringCellValue(), row.getCell(1).getStringCellValue()));
|
|
|
+ list.add(
|
|
|
+ new CourseInfo(null, row.getCell(0).getStringCellValue(), row.getCell(1).getStringCellValue()));
|
|
|
}
|
|
|
} finally {
|
|
|
if (wb != null) {
|
|
@@ -112,6 +115,43 @@ public class ExportPaperByAllQuestions {
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
+ private static void fillCourseInfo(Connection connect) throws SQLException, IOException {
|
|
|
+ Map<String, CourseInfo> courseMaps = new HashMap();
|
|
|
+ for (CourseInfo code : codes) {
|
|
|
+ courseMaps.put(code.getCode(), code);
|
|
|
+ }
|
|
|
+ PreparedStatement preState = null;
|
|
|
+ ResultSet resultSet = null;
|
|
|
+
|
|
|
+ try {
|
|
|
+ String sql = "SELECT c.id,c.name,c.code FROM PE_TCH_COURSE c WHERE c.code in (";
|
|
|
+ for (CourseInfo c : codes) {
|
|
|
+ sql = sql + "'" + c.getCode() + "',";
|
|
|
+ }
|
|
|
+ sql = sql + "'607816a3f8461343b1ea5a04')";
|
|
|
+ preState = connect.prepareStatement(sql);
|
|
|
+
|
|
|
+ resultSet = preState.executeQuery();
|
|
|
+ List<CourseInfo> list = new ArrayList<CourseInfo>();
|
|
|
+ while (resultSet.next()) {
|
|
|
+ String code=resultSet.getString("code");
|
|
|
+ CourseInfo tq = new CourseInfo();
|
|
|
+ tq.setId(resultSet.getString("id"));
|
|
|
+ tq.setName(courseMaps.get(code).getName());
|
|
|
+ tq.setCode(code);
|
|
|
+ list.add(tq);
|
|
|
+ }
|
|
|
+ codes = list;
|
|
|
+ } finally {
|
|
|
+ if (resultSet != null) {
|
|
|
+ resultSet.close();
|
|
|
+ }
|
|
|
+ if (preState != null) {
|
|
|
+ preState.close();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private static void exportPaper(Connection connect, CourseInfo course) throws SQLException, IOException {
|
|
|
PreparedStatement preState = null;
|
|
|
ResultSet resultSet = null;
|
|
@@ -119,7 +159,7 @@ public class ExportPaperByAllQuestions {
|
|
|
try {
|
|
|
TestPaper tp = new TestPaper();
|
|
|
tp.setId("none");
|
|
|
- tp.setName(course.getName()+"试题库试卷");
|
|
|
+ tp.setName(course.getName() + "试题库试卷");
|
|
|
tp.setTestPaperContentId("none");
|
|
|
tp.setScore(0.0);
|
|
|
List<SheetData> sheets = new ArrayList<SheetData>();
|
|
@@ -138,32 +178,32 @@ public class ExportPaperByAllQuestions {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
private static void fillScore(List<SheetData> sheets) {
|
|
|
- SheetData s1=sheets.get(1);
|
|
|
- List<Object[]> data1=s1.getData();
|
|
|
- Map<String,Integer> sc=new HashMap<String,Integer>();
|
|
|
- for(Object[] obs:data1) {
|
|
|
- String pid=(String)obs[5];
|
|
|
- if(!"00000000000000000000000000000000".equals(pid)) {
|
|
|
- Integer scr=sc.get(pid);
|
|
|
- if(scr==null) {
|
|
|
+ SheetData s1 = sheets.get(1);
|
|
|
+ List<Object[]> data1 = s1.getData();
|
|
|
+ Map<String, Integer> sc = new HashMap<String, Integer>();
|
|
|
+ for (Object[] obs : data1) {
|
|
|
+ String pid = (String) obs[5];
|
|
|
+ if (!"00000000000000000000000000000000".equals(pid)) {
|
|
|
+ Integer scr = sc.get(pid);
|
|
|
+ if (scr == null) {
|
|
|
sc.put(pid, 1);
|
|
|
- }else {
|
|
|
- sc.put(pid, scr+1);
|
|
|
+ } else {
|
|
|
+ sc.put(pid, scr + 1);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- for(Object[] obs:data1) {
|
|
|
- String id=(String)obs[0];
|
|
|
- if(sc.get(id)!=null) {
|
|
|
- obs[4]=sc.get(id)+".0";
|
|
|
+ for (Object[] obs : data1) {
|
|
|
+ String id = (String) obs[0];
|
|
|
+ if (sc.get(id) != null) {
|
|
|
+ obs[4] = sc.get(id) + ".0";
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- SheetData s0=sheets.get(0);
|
|
|
- List<Object[]> data0=s0.getData();
|
|
|
- data0.get(0)[3]=(data1.size()-sc.size())+".0";
|
|
|
+
|
|
|
+ SheetData s0 = sheets.get(0);
|
|
|
+ List<Object[]> data0 = s0.getData();
|
|
|
+ data0.get(0)[3] = (data1.size() - sc.size()) + ".0";
|
|
|
}
|
|
|
|
|
|
public static void fillPaperData(List<SheetData> sheets, TestPaper tp, List<String> header) {
|
|
@@ -187,10 +227,10 @@ public class ExportPaperByAllQuestions {
|
|
|
ResultSet resultSet = null;
|
|
|
|
|
|
try {
|
|
|
- String sql = "SELECT t.question_type_enum qtype,q.ID id,t.question_type_enum dNumber,q.sequence number1,'1' score,q.PARENT_ID parent_id,q.QUESTION_TYPE_ENUM type,q.JSON" +
|
|
|
- " FROM QUESTION_CONTENT q,question_info t" +
|
|
|
- " where t.id(+)=q.question_info_id" +
|
|
|
- " and t.batch_type='1' and t.course_id='"+courseId+"' order by q.parent_id,t.question_type_enum,q.sequence";
|
|
|
+ String sql = "SELECT t.question_type_enum qtype,q.ID id,t.question_type_enum dNumber,q.sequence number1,'1' score,q.PARENT_ID parent_id,q.QUESTION_TYPE_ENUM type,q.JSON"
|
|
|
+ + " FROM QUESTION_CONTENT q,question_info t" + " where t.id(+)=q.question_info_id"
|
|
|
+ + " and t.batch_type='1' and t.course_id='" + courseId
|
|
|
+ + "' order by q.parent_id,t.question_type_enum,q.sequence";
|
|
|
preState = connect.prepareStatement(sql);
|
|
|
|
|
|
resultSet = preState.executeQuery();
|