|
@@ -37,10 +37,6 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.LinkedMultiValueMap;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
-import java.io.File;
|
|
|
-import java.io.FileInputStream;
|
|
|
-import java.io.IOException;
|
|
|
-import java.nio.charset.StandardCharsets;
|
|
|
import java.io.*;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
@@ -275,15 +271,14 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
String type = (String) jsonObjectVariable.get("type");
|
|
|
Long attachmentId = (Long) jsonObjectVariable.get("attachmentId");
|
|
|
BasicAttachment basicAttachment = basicAttachmentService.getById(attachmentId);
|
|
|
- String htmlContent = new String(commonService.getFileByte(basicAttachment.getPath(), false), StandardCharsets.UTF_8);
|
|
|
- log.info("htmlContent:{}", htmlContent);
|
|
|
+ commonService.getFile(basicAttachment.getPath(), false);
|
|
|
+// log.info("htmlContent:{}", htmlContent);
|
|
|
if (Objects.nonNull(type) && Objects.equals(type.toUpperCase(), "SIGN")) {//签到表
|
|
|
signVariableBackupCount = (Integer) jsonObjectVariable.get("backupCount");
|
|
|
+ createSignBook(basicAttachment, basicSchool.getName(), examDetailCourse, examStudentList, variablePdfList);
|
|
|
} else if (Objects.nonNull(type) && Objects.equals(type.toUpperCase(), "PACKAG")) {//卷袋贴
|
|
|
packagVariableBackupCount = (Integer) jsonObjectVariable.get("backupCount");
|
|
|
}
|
|
|
-// createSignBook(basicAttachment, htmlContent, examDetailCourse, basicSchool.getName(), examStudentList, variablePdfList);
|
|
|
- createSignBook(basicAttachment, examDetailCourse, basicSchool.getName(), examStudentList, variablePdfList);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -317,30 +312,30 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
@Override
|
|
|
- public Map<String,Object> executeExaminationLogic(Map<String, Object> map) throws Exception {
|
|
|
+ public Map<String, Object> executeExaminationLogic(Map<String, Object> map) throws Exception {
|
|
|
// printPlanId, courseCode, paperNumber, examPlace, examRoom, packageCode,
|
|
|
Long printPlanId = null;
|
|
|
- if (map.get("printPlanId") != null){
|
|
|
+ if (map.get("printPlanId") != null) {
|
|
|
printPlanId = SystemConstant.convertIdToLong(String.valueOf(map.get("printPlanId")));
|
|
|
}
|
|
|
String courseCode = null;
|
|
|
- if (map.get("courseCode") != null){
|
|
|
+ if (map.get("courseCode") != null) {
|
|
|
courseCode = String.valueOf(map.get("courseCode"));
|
|
|
}
|
|
|
String paperNumber = null;
|
|
|
- if (map.get("paperNumber") != null){
|
|
|
+ if (map.get("paperNumber") != null) {
|
|
|
paperNumber = String.valueOf(map.get("paperNumber"));
|
|
|
}
|
|
|
String examPlace = null;
|
|
|
- if (map.get("examPlace") != null){
|
|
|
+ if (map.get("examPlace") != null) {
|
|
|
examPlace = String.valueOf(map.get("examPlace"));
|
|
|
}
|
|
|
String examRoom = null;
|
|
|
- if (map.get("examRoom") != null){
|
|
|
+ if (map.get("examRoom") != null) {
|
|
|
examRoom = String.valueOf(map.get("examRoom"));
|
|
|
}
|
|
|
String packageCode = null;
|
|
|
- if (map.get("packageCode") != null){
|
|
|
+ if (map.get("packageCode") != null) {
|
|
|
packageCode = String.valueOf(map.get("packageCode"));
|
|
|
}
|
|
|
|
|
@@ -354,7 +349,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
System.out.println("examinationResultList = " + JSON.toJSONString(examinationResultList));
|
|
|
|
|
|
OutputStream outputStream = new ByteArrayOutputStream();
|
|
|
- ExcelUtil.excelMake(ExaminationResult.class,examinationResultList,outputStream);
|
|
|
+ ExcelUtil.excelMake(ExaminationResult.class, examinationResultList, outputStream);
|
|
|
|
|
|
InputStream in = ConvertUtil.parse(outputStream);
|
|
|
|
|
@@ -371,7 +366,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
Long userId = tbTask.getCreateId();
|
|
|
ExamPrintPlan examPrintPlan = examPrintPlanService.getById(printPlanId);
|
|
|
|
|
|
- if (examPrintPlan == null){
|
|
|
+ if (examPrintPlan == null) {
|
|
|
throw ExceptionResultEnum.ERROR.exception("印刷计划不存在printPlanId : " + printPlanId);
|
|
|
}
|
|
|
String printPlanName = examPrintPlan.getName();
|
|
@@ -505,11 +500,11 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
|
|
|
|
|
|
// 组装exam_detail数据
|
|
|
- examDetailService.disposeExamDetailByExaminationExcel(dataList,userId);
|
|
|
+ examDetailService.disposeExamDetailByExaminationExcel(dataList, userId);
|
|
|
// 组装exam_detail_course数据
|
|
|
- examDetailService.disposeExamDetailCourseByExaminationExcel(dataList,userId);
|
|
|
+ examDetailService.disposeExamDetailCourseByExaminationExcel(dataList, userId);
|
|
|
// 组装exam_student数据
|
|
|
- examDetailService.disposeExamStudentByExaminationExcel(dataList,userId);
|
|
|
+ examDetailService.disposeExamStudentByExaminationExcel(dataList, userId);
|
|
|
return null;
|
|
|
}
|
|
|
|
|
@@ -517,148 +512,27 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
* 创建签到表
|
|
|
*
|
|
|
* @param basicAttachment
|
|
|
- * @param examDetailCourse
|
|
|
* @param schoolName
|
|
|
+ * @param examDetailCourse
|
|
|
* @param examStudentList
|
|
|
* @param variablePdfList
|
|
|
* @throws IOException
|
|
|
*/
|
|
|
- private void createSignBook(BasicAttachment basicAttachment,
|
|
|
-// String htmlContent,
|
|
|
- ExamDetailCourse examDetailCourse, String schoolName, List<ExamStudent> examStudentList, List<String> variablePdfList) throws IOException {
|
|
|
- /**html
|
|
|
- htmlContent = htmlContent.replaceAll("\\$\\{examDetailCourseId\\}", examDetailCourse.getId() + "");
|
|
|
- htmlContent = htmlContent.replaceAll("\\$\\{schoolName\\}", schoolName);
|
|
|
- htmlContent = htmlContent.replaceAll("\\$\\{courseName\\}", examDetailCourse.getCourseName());
|
|
|
- htmlContent = htmlContent.replaceAll("\\$\\{courseCode\\}", examDetailCourse.getCourseCode());
|
|
|
-
|
|
|
- // htmlMap.put("examName", exam.getExamName());
|
|
|
- // htmlMap.put("examRoom", examDetailMap.get("examRoom"));
|
|
|
- // htmlMap.put("examRoomId", examDetailMap.get("examRoomId"));
|
|
|
- // htmlMap.put("startTime", examDetailMap.get("startTime"));
|
|
|
- // htmlMap.put("endTime", examDetailMap.get("endTime"));
|
|
|
- // htmlMap.put("sceneNumberId", examDetailMap.get("sceneNumberId"));
|
|
|
-
|
|
|
- htmlContent = htmlContent.replaceAll("\\$\\{paperCode\\}", examDetailCourse.getPaperNumber());
|
|
|
- htmlContent = htmlContent.replaceAll("\\$\\{paperCodeImg\\}", GoogleBarCodeUtil.createBarCode(examDetailCourse.getPaperNumber(), false));
|
|
|
-
|
|
|
- // List<Map> students = tcPExamStudentService.clientStudentByDetailId(examDetailId);
|
|
|
-
|
|
|
- // List<String> extendColumnList = students.stream().map(m -> m.get("extendColumn").toString()).distinct().collect(Collectors.toList());
|
|
|
- // Set<String> classTeacher = new HashSet();
|
|
|
- // if (extendColumnList != null && extendColumnList.size() > 0) {
|
|
|
- // for (String s : extendColumnList) {
|
|
|
- // List<Map> mapList = JSONObject.parseArray(s, Map.class);
|
|
|
- // for (Map map : mapList) {
|
|
|
- // if (Objects.equals("classTeacher", map.get("code").toString())) {
|
|
|
- // classTeacher.add(map.get("value").toString());
|
|
|
- // }
|
|
|
- // }
|
|
|
- // }
|
|
|
- // }
|
|
|
-
|
|
|
- // htmlMap.put("classTeacher", String.join(",", classTeacher));
|
|
|
-
|
|
|
- int totalCount = examStudentList.size();
|
|
|
- if (totalCount > 0) {
|
|
|
- // List<Map> subList = new ArrayList<>();
|
|
|
- int pageCount = totalCount % 80 == 0 ? totalCount / 80 : totalCount / 80 + 1;
|
|
|
- for (int i = 0; i < pageCount; i++) {
|
|
|
- Map subMap = new HashMap();
|
|
|
- subMap.put("index", i + 1);
|
|
|
- int studentCount;
|
|
|
- List<ExamStudent> subStudents;
|
|
|
- if (pageCount == 1) {
|
|
|
- studentCount = totalCount;
|
|
|
- subStudents = examStudentList;
|
|
|
- } else if (pageCount > 1 && i == pageCount - 1) {
|
|
|
- studentCount = totalCount - (pageCount - 1) * 80;
|
|
|
- subStudents = examStudentList.subList(80 * i, examStudentList.size());
|
|
|
- } else {
|
|
|
- studentCount = 80;
|
|
|
- subStudents = examStudentList.subList(80 * i, 80 * (i + 1));
|
|
|
- }
|
|
|
- subMap.put("studentCount", studentCount);
|
|
|
- List<ExamStudentDto> examStudentList1 = new ArrayList<>();
|
|
|
- List<ExamStudentDto> examStudentList2 = new ArrayList<>();
|
|
|
-
|
|
|
- Gson gson = new Gson();
|
|
|
- int mod = subStudents.size() % 2;
|
|
|
- int htmlTableCount = mod == 0 ? subStudents.size() / 2 : subStudents.size() / 2 + 1;
|
|
|
- for (int j = 0; j < htmlTableCount; j++) {
|
|
|
- ExamStudentDto examStudentDto = gson.fromJson(gson.toJson(subStudents.get(j)), ExamStudentDto.class);
|
|
|
- examStudentDto.setIndex(j + 1);
|
|
|
- examStudentList1.add(examStudentDto);
|
|
|
- // Map map = subStudents.get(j);
|
|
|
- // TcPExamStudent tcPExamStudent = new TcPExamStudent();
|
|
|
- // tcPExamStudent.setIndex(j + 1);
|
|
|
- // tcPExamStudent.setSiteNumber(String.valueOf(map.get("siteNumber")));
|
|
|
- // tcPExamStudent.setStudentCode(String.valueOf(map.get("studentCode")));
|
|
|
- // tcPExamStudent.setName(String.valueOf(map.get("name")));
|
|
|
- // tcPExamStudent.setExtendColumn(getClassName(map.get("extendColumn").toString()));
|
|
|
- // tcPExamStudentList1.add(tcPExamStudent);
|
|
|
- }
|
|
|
- for (int j = htmlTableCount; j < subStudents.size(); j++) {
|
|
|
- ExamStudentDto examStudentDto = gson.fromJson(gson.toJson(subStudents.get(j)), ExamStudentDto.class);
|
|
|
- examStudentDto.setIndex(j + 1);
|
|
|
- examStudentList2.add(examStudentDto);
|
|
|
- // Map map = students.get(j);
|
|
|
- // TcPExamStudent tcPExamStudent = new TcPExamStudent();
|
|
|
- // tcPExamStudent.setIndex(j + 1);
|
|
|
- // tcPExamStudent.setSiteNumber(String.valueOf(map.get("siteNumber")));
|
|
|
- // tcPExamStudent.setStudentCode(String.valueOf(map.get("studentCode")));
|
|
|
- // tcPExamStudent.setName(String.valueOf(map.get("name")));
|
|
|
- // tcPExamStudent.setExtendColumn(getClassName(map.get("extendColumn").toString()));
|
|
|
- // tcPExamStudentList2.add(tcPExamStudent);
|
|
|
- }
|
|
|
- if (examStudentList1.size() > examStudentList2.size()) {
|
|
|
- for (int j = subStudents.size() - htmlTableCount; j < examStudentList1.size(); j++) {
|
|
|
- examStudentList2.add(new ExamStudentDto());
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // subMap.put("studentList1", examStudentList1);
|
|
|
- // subMap.put("studentList2", examStudentList2);
|
|
|
-
|
|
|
- // htmlContent = htmlContent.replaceAll("\\$\\{studentList1\\}", examStudentList1);
|
|
|
- // htmlContent = htmlContent.replaceAll("\\$\\{studentList2\\}", examStudentList2);
|
|
|
-
|
|
|
- // subList.add(subMap);
|
|
|
- }
|
|
|
- // htmlMap.put("subList", subList);
|
|
|
- }
|
|
|
- basicAttachmentService.saveAttachmentPdf(basicAttachment, variablePdfList);
|
|
|
- **/
|
|
|
-
|
|
|
+ private void createSignBook(BasicAttachment basicAttachment, String schoolName, ExamDetailCourse examDetailCourse, List<ExamStudent> examStudentList, List<String> variablePdfList) throws IOException {
|
|
|
Map<String, Object> htmlMap = new HashMap<>();
|
|
|
htmlMap.put("examDetailCourseId", examDetailCourse.getId());
|
|
|
htmlMap.put("schoolName", schoolName);
|
|
|
|
|
|
htmlMap.put("courseName", examDetailCourse.getCourseName());
|
|
|
htmlMap.put("courseCode", examDetailCourse.getCourseCode());
|
|
|
-// htmlMap.put("examName", exam.getExamName());
|
|
|
-// htmlMap.put("examRoom", examDetailMap.get("examRoom"));
|
|
|
-// htmlMap.put("examRoomId", examDetailMap.get("examRoomId"));
|
|
|
-// htmlMap.put("startTime", examDetailMap.get("startTime"));
|
|
|
-// htmlMap.put("endTime", examDetailMap.get("endTime"));
|
|
|
-// htmlMap.put("sceneNumberId", examDetailMap.get("sceneNumberId"));
|
|
|
+ htmlMap.put("examName", "测试exam1");
|
|
|
+ htmlMap.put("examRoom", "测试examRoom1");
|
|
|
+ htmlMap.put("classTeacher", "测试老师1");
|
|
|
+ htmlMap.put("startTime", "2021-04-13 00:00:00");
|
|
|
+ htmlMap.put("endTime", "2021-04-14 00:00:00");
|
|
|
htmlMap.put("paperCode", examDetailCourse.getPaperNumber());
|
|
|
htmlMap.put("paperCodeImg", GoogleBarCodeUtil.createBarCode(examDetailCourse.getPaperNumber(), false));
|
|
|
|
|
|
-// List<String> extendColumnList = students.stream().map(m -> m.get("extendColumn").toString()).distinct().collect(Collectors.toList());
|
|
|
-// Set<String> classTeacher = new HashSet();
|
|
|
-// if (extendColumnList != null && extendColumnList.size() > 0) {
|
|
|
-// for (String s : extendColumnList) {
|
|
|
-// List<Map> mapList = JSONObject.parseArray(s, Map.class);
|
|
|
-// for (Map map : mapList) {
|
|
|
-// if (Objects.equals("classTeacher", map.get("code").toString())) {
|
|
|
-// classTeacher.add(map.get("value").toString());
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-// htmlMap.put("classTeacher", String.join(",", classTeacher));
|
|
|
-
|
|
|
int totalCount = examStudentList.size();
|
|
|
if (totalCount > 0) {
|
|
|
List<Map> subList = new ArrayList<>();
|
|
@@ -689,40 +563,29 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
ExamStudentDto examStudentDto = gson.fromJson(gson.toJson(subStudents.get(j)), ExamStudentDto.class);
|
|
|
examStudentDto.setIndex(j + 1);
|
|
|
examStudentList1.add(examStudentDto);
|
|
|
-// Map map = subStudents.get(j);
|
|
|
-// TcPExamStudent tcPExamStudent = new TcPExamStudent();
|
|
|
-// tcPExamStudent.setIndex(j + 1);
|
|
|
-// tcPExamStudent.setSiteNumber(String.valueOf(map.get("siteNumber")));
|
|
|
-// tcPExamStudent.setStudentCode(String.valueOf(map.get("studentCode")));
|
|
|
-// tcPExamStudent.setName(String.valueOf(map.get("name")));
|
|
|
-// tcPExamStudent.setExtendColumn(getClassName(map.get("extendColumn").toString()));
|
|
|
-// tcPExamStudentList1.add(tcPExamStudent);
|
|
|
}
|
|
|
for (int j = htmlTableCount; j < subStudents.size(); j++) {
|
|
|
ExamStudentDto examStudentDto = gson.fromJson(gson.toJson(subStudents.get(j)), ExamStudentDto.class);
|
|
|
examStudentDto.setIndex(j + 1);
|
|
|
examStudentList2.add(examStudentDto);
|
|
|
-// Map map = students.get(j);
|
|
|
-// TcPExamStudent tcPExamStudent = new TcPExamStudent();
|
|
|
-// tcPExamStudent.setIndex(j + 1);
|
|
|
-// tcPExamStudent.setSiteNumber(String.valueOf(map.get("siteNumber")));
|
|
|
-// tcPExamStudent.setStudentCode(String.valueOf(map.get("studentCode")));
|
|
|
-// tcPExamStudent.setName(String.valueOf(map.get("name")));
|
|
|
-// tcPExamStudent.setExtendColumn(getClassName(map.get("extendColumn").toString()));
|
|
|
-// tcPExamStudentList2.add(tcPExamStudent);
|
|
|
}
|
|
|
if (examStudentList1.size() > examStudentList2.size()) {
|
|
|
for (int j = subStudents.size() - htmlTableCount; j < examStudentList1.size(); j++) {
|
|
|
examStudentList2.add(new ExamStudentDto());
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
subMap.put("studentList1", examStudentList1);
|
|
|
subMap.put("studentList2", examStudentList2);
|
|
|
subList.add(subMap);
|
|
|
}
|
|
|
htmlMap.put("subList", subList);
|
|
|
}
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(basicAttachment.getPath());
|
|
|
+ String path = (String) jsonObject.get("path");
|
|
|
+ String ftlPath = path.substring(0, path.lastIndexOf("/"));
|
|
|
+ String ftlName = path.substring(path.lastIndexOf("/") + 1, path.lastIndexOf("."));
|
|
|
+ htmlMap.computeIfAbsent("ftlPath", v -> ftlPath);
|
|
|
+ htmlMap.computeIfAbsent("ftlName", v -> ftlName);
|
|
|
freemarkerUtil.createSignBook(htmlMap);
|
|
|
}
|
|
|
|
|
@@ -777,7 +640,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
if (Objects.nonNull(object.get("attachmentId"))) {
|
|
|
Long attachmentId = Long.parseLong(String.valueOf(object.get("attachmentId")));
|
|
|
BasicAttachment basicAttachment = basicAttachmentService.getById(attachmentId);
|
|
|
- String filePath = commonService.getFile(basicAttachment.getPath(), false);
|
|
|
+ String filePath = commonService.getFile(basicAttachment.getPath(), false).getPath();
|
|
|
pdfList[0].add(filePath);
|
|
|
for (int j = 1; j <= backupCount; j++) {
|
|
|
pdfList[1].add(filePath);
|