|
@@ -1,13 +1,5 @@
|
|
|
package com.qmth.test.image;
|
|
|
|
|
|
-import com.qmth.test.image.model.*;
|
|
|
-import com.qmth.test.image.model.Image;
|
|
|
-import org.apache.commons.dbcp.BasicDataSource;
|
|
|
-import org.apache.commons.lang.StringUtils;
|
|
|
-import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
-import org.springframework.jdbc.support.rowset.SqlRowSet;
|
|
|
-
|
|
|
-import javax.imageio.ImageIO;
|
|
|
import java.awt.*;
|
|
|
import java.awt.image.BufferedImage;
|
|
|
import java.io.File;
|
|
@@ -18,6 +10,16 @@ import java.text.DecimalFormat;
|
|
|
import java.util.*;
|
|
|
import java.util.List;
|
|
|
|
|
|
+import javax.imageio.ImageIO;
|
|
|
+
|
|
|
+import org.apache.commons.dbcp.BasicDataSource;
|
|
|
+import org.apache.commons.lang.StringUtils;
|
|
|
+import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
+import org.springframework.jdbc.support.rowset.SqlRowSet;
|
|
|
+
|
|
|
+import com.qmth.test.image.model.*;
|
|
|
+import com.qmth.test.image.model.Image;
|
|
|
+
|
|
|
public class SheetTrack {
|
|
|
|
|
|
private static Properties p = new Properties();
|
|
@@ -36,34 +38,85 @@ public class SheetTrack {
|
|
|
|
|
|
int examId = Integer.parseInt(p.getProperty("examId"));
|
|
|
Set<String> subjects = findSubjectCode(examId);
|
|
|
- System.out.println("examId=" + examId + ", subject count=" + subjects.size());
|
|
|
+ Set<String> examNumbers = findExamNumbers();
|
|
|
+ System.out.println("examId=" + examId + ", subject count=" + subjects.size() + ", student count="
|
|
|
+ + examNumbers.size());
|
|
|
for (String subjectCode : subjects) {
|
|
|
- process(examId, subjectCode);
|
|
|
+ for (String examNumber : examNumbers) {
|
|
|
+ processStudent(examId, subjectCode, examNumber);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private static void process(int examId, String subjectCode) throws IOException {
|
|
|
+ // private static void process(int examId, String subjectCode) throws
|
|
|
+ // IOException {
|
|
|
+ // List<Integer> groups = new ArrayList<>();
|
|
|
+ // List<Question> questions = new ArrayList<>();
|
|
|
+ // buildGroupQuestion(examId, subjectCode, groups, questions);
|
|
|
+ //
|
|
|
+ // int totalCount = 0;
|
|
|
+ // SqlRowSet crs = template
|
|
|
+ // .queryForRowSet(
|
|
|
+ // "select count(*) as count from eb_exam_student where exam_id=? and subject_code=? and is_upload=1 and is_absent=0 and is_breach=0",
|
|
|
+ // examId, subjectCode);
|
|
|
+ // while (crs.next()) {
|
|
|
+ // totalCount = crs.getInt("count");
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ // int count = 0;
|
|
|
+ // SqlRowSet rs = template
|
|
|
+ // .queryForRowSet(
|
|
|
+ // "select s.id,b.id as campus_id,s.exam_number,s.sheet_count,s.slice_count,s.subjective_score,s.subjective_score_list "
|
|
|
+ // +
|
|
|
+ // "from eb_exam_student s,b_campus b where s.school_id=b.school_id and s.campus_name=b.name and s.exam_id=? "
|
|
|
+ // +
|
|
|
+ // "and s.subject_code=? and s.is_upload=1 and s.is_absent=0 and s.is_breach=0 "
|
|
|
+ // // + "and s.exam_number='402414432'"
|
|
|
+ // , examId, subjectCode);
|
|
|
+ // while (rs.next()) {
|
|
|
+ // Student s = new Student();
|
|
|
+ // s.examId = examId;
|
|
|
+ // s.subjectCode = subjectCode;
|
|
|
+ // s.id = rs.getInt("id");
|
|
|
+ // s.campusId = rs.getInt("campus_id");
|
|
|
+ // s.examNumber = rs.getString("exam_number");
|
|
|
+ // s.sheetCount = rs.getInt("sheet_count");
|
|
|
+ // s.sliceCount = rs.getInt("slice_count");
|
|
|
+ // s.score = rs.getDouble("subjective_score");
|
|
|
+ // s.scoreDetail = rs.getString("subjective_score_list");
|
|
|
+ // s.scoreList = s.getScoreList();
|
|
|
+ // s.groups = groups;
|
|
|
+ // s.questions = questions;
|
|
|
+ //
|
|
|
+ // List<Tag> tags = new LinkedList<>();
|
|
|
+ // for (Integer groupNumber : groups) {
|
|
|
+ // tags.addAll(buildGroupTag(s, groupNumber, questions));
|
|
|
+ // }
|
|
|
+ // processSheet(p.getProperty("output.path"), s, transform(s, tags));
|
|
|
+ //
|
|
|
+ // count++;
|
|
|
+ // // if (count % 10 == 0) {
|
|
|
+ // System.out.print("\r" + "examId=" + examId + ", subjectCode=" +
|
|
|
+ // subjectCode + ": " + count + "/"
|
|
|
+ // + totalCount);
|
|
|
+ // // }
|
|
|
+ // }
|
|
|
+ // System.out.print("\r" + "examId=" + examId + ", subjectCode=" +
|
|
|
+ // subjectCode + ": " + count + "/" + totalCount);
|
|
|
+ // }
|
|
|
+
|
|
|
+ private static void processStudent(int examId, String subjectCode, String examNumber) throws IOException {
|
|
|
List<Integer> groups = new ArrayList<>();
|
|
|
List<Question> questions = new ArrayList<>();
|
|
|
buildGroupQuestion(examId, subjectCode, groups, questions);
|
|
|
|
|
|
- int totalCount = 0;
|
|
|
- SqlRowSet crs = template
|
|
|
- .queryForRowSet(
|
|
|
- "select count(*) as count from eb_exam_student where exam_id=? and subject_code=? and is_upload=1 and is_absent=0 and is_breach=0",
|
|
|
- examId, subjectCode);
|
|
|
- while (crs.next()) {
|
|
|
- totalCount = crs.getInt("count");
|
|
|
- }
|
|
|
-
|
|
|
int count = 0;
|
|
|
SqlRowSet rs = template
|
|
|
.queryForRowSet(
|
|
|
"select s.id,b.id as campus_id,s.exam_number,s.sheet_count,s.slice_count,s.subjective_score,s.subjective_score_list "
|
|
|
+ "from eb_exam_student s,b_campus b where s.school_id=b.school_id and s.campus_name=b.name and s.exam_id=? "
|
|
|
+ "and s.subject_code=? and s.is_upload=1 and s.is_absent=0 and s.is_breach=0 "
|
|
|
- // + "and s.exam_number='402414432'"
|
|
|
- , examId, subjectCode);
|
|
|
+ + "and s.exam_number=? ", examId, subjectCode, examNumber);
|
|
|
while (rs.next()) {
|
|
|
Student s = new Student();
|
|
|
s.examId = examId;
|
|
@@ -78,20 +131,16 @@ public class SheetTrack {
|
|
|
s.scoreList = s.getScoreList();
|
|
|
s.groups = groups;
|
|
|
s.questions = questions;
|
|
|
-
|
|
|
+ s.markerName = new HashMap<Integer, String>();
|
|
|
List<Tag> tags = new LinkedList<>();
|
|
|
for (Integer groupNumber : groups) {
|
|
|
tags.addAll(buildGroupTag(s, groupNumber, questions));
|
|
|
}
|
|
|
- processSheet(p.getProperty("output.path"), s, transform(s, tags));
|
|
|
+ processSheet(p.getProperty("output.path"), s, new ArrayList<Track>());
|
|
|
|
|
|
count++;
|
|
|
- // if (count % 10 == 0) {
|
|
|
- System.out.print("\r" + "examId=" + examId + ", subjectCode=" + subjectCode + ": " + count + "/"
|
|
|
- + totalCount);
|
|
|
- // }
|
|
|
}
|
|
|
- System.out.print("\r" + "examId=" + examId + ", subjectCode=" + subjectCode + ": " + count + "/" + totalCount);
|
|
|
+ System.out.print("\r" + "examId=" + examId + ", subjectCode=" + subjectCode + ": " + count);
|
|
|
}
|
|
|
|
|
|
private static void processSheet(String outputPath, Student s, List<Track> tracks) throws IOException {
|
|
@@ -143,7 +192,8 @@ public class SheetTrack {
|
|
|
}
|
|
|
Question q = s.questions.get(i);
|
|
|
double score = s.scoreList.get(i);
|
|
|
- String content = q.mainNumber + "-" + q.subNumber + ":" + format.format(score);
|
|
|
+ String content = q.mainNumber + "-" + q.subNumber + ":" + format.format(score) + " "
|
|
|
+ + s.markerName.get(q.groupNumber);
|
|
|
maxWidth = Math.max(maxWidth, content.length() * fontSize);
|
|
|
g.drawString(content, left, top);
|
|
|
}
|
|
@@ -223,21 +273,20 @@ public class SheetTrack {
|
|
|
totalScore += s.scoreList.get(i);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
return findTags(findLibrary(s, groupNumber, totalScore));
|
|
|
}
|
|
|
|
|
|
private static Library findLibrary(Student s, int groupNumber, double totalScore) {
|
|
|
- SqlRowSet rs = template.queryForRowSet(
|
|
|
- "select id,marker_score from m_library where student_id=? and group_number=?", s.id, groupNumber);
|
|
|
+ SqlRowSet rs = template
|
|
|
+ .queryForRowSet(
|
|
|
+ "select m.name from eb_marker m where m.id in (select marker_id from m_library where student_id=? and group_number=?)",
|
|
|
+ s.id, groupNumber);
|
|
|
+ String name = "";
|
|
|
while (rs.next()) {
|
|
|
- double score = rs.getDouble("marker_score");
|
|
|
- if (score == totalScore) {
|
|
|
- Library library = new Library();
|
|
|
- library.id = rs.getInt("id");
|
|
|
- library.markerScore = score;
|
|
|
- return library;
|
|
|
- }
|
|
|
+ name = name + "," + rs.getString("name");
|
|
|
}
|
|
|
+ s.markerName.put(groupNumber, name);
|
|
|
return null;
|
|
|
}
|
|
|
|
|
@@ -300,6 +349,15 @@ public class SheetTrack {
|
|
|
return subjects;
|
|
|
}
|
|
|
|
|
|
+ private static Set<String> findExamNumbers() {
|
|
|
+ String config = p.getProperty("examNumbers");
|
|
|
+ Set<String> examNumbers = new HashSet<>();
|
|
|
+ if (StringUtils.isNotBlank(config)) {
|
|
|
+ Collections.addAll(examNumbers, config.split(","));
|
|
|
+ }
|
|
|
+ return examNumbers;
|
|
|
+ }
|
|
|
+
|
|
|
private static void init(InputStream ins) throws IOException {
|
|
|
p.load(ins);
|
|
|
|