haogh 6 달 전
부모
커밋
8017221f7f
1개의 변경된 파일49개의 추가작업 그리고 43개의 파일을 삭제
  1. 49 43
      src/cn/hmsoft/art/control/ex/interview/ExamInterviewExportControl.java

+ 49 - 43
src/cn/hmsoft/art/control/ex/interview/ExamInterviewExportControl.java

@@ -2,15 +2,10 @@ package cn.hmsoft.art.control.ex.interview;
 
 import java.io.File;
 import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
 import java.util.stream.Collectors;
 
+import cn.hmsoft.log.LogHelper;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
@@ -97,16 +92,16 @@ public class ExamInterviewExportControl extends ArtControl {
 	
 	/**
 	 * @Description: 央美评委分数打印
-	 * @param room_id
-	 * @param start_num
-	 * @param end_num
-	 * @param time_type
+	 * @param room_id 考场ID
+	 * @param start_num 开始序号
+	 * @param end_num   结束序号
+	 * @param time_type  时段 1:上午,2:下午,3:晚上
 	 * @date 2023-12-29 05:48:29 
 	 */  
 	@RequestMapping("exam/judge/score/print/ym")
 	public Ajax printJudgeScoreYm(int room_id, int start_num, int end_num, Integer time_type) {
-		Map<String,Object> map = new HashMap<String,Object>();
-		List<DataRecord> drList = null;
+		Map<String,Object> map = new HashMap<>();
+		List<DataRecord> drList;
 		if(time_type != null) {
 			drList = this.daoStd.listhaveScoreStdEcho(room_id, start_num, end_num, time_type);
 		} else {
@@ -168,14 +163,18 @@ public class ExamInterviewExportControl extends ArtControl {
 			map.put("max_seq", (end_num + 20 >=max_seq) ? max_seq : end_num + 20); //20个一打印
 			return new Ajax(map);
 		} catch (Exception e) {
-			e.printStackTrace();
+			LogHelper.error(e.getMessage());
 			return new Ajax(map);
 		} finally {
 			try {
-				doc.close();
-				pdfDoc.close();
-			} catch (Exception e) {
-
+                if (doc != null) {
+                    doc.close();
+                }
+                if (pdfDoc != null) {
+                    pdfDoc.close();
+                }
+            } catch (Exception e) {
+				LogHelper.error(e.getMessage());
 			}
 		}
 		
@@ -187,19 +186,19 @@ public class ExamInterviewExportControl extends ArtControl {
 		LyGroup group = this.daoRoom.find(LyGroup.class, room.getLy_group_id());
 		int start_num = records.get(0).getI01();
 		int end_num = records.get(records.size() - 1).getI01();
-//		List<CfSubject> subjectTitle = this.daoExport.listRoomSubjectDis(room_id);
 		List<CfSubject> subjectList = filterSubject(subjectArray);
-		float[] cols = new float[subjectList.size()*3+3];
-		for(int i = 0; i<cols.length; i++) {
-			cols[i] = 1f;
-		}
+		float[] cols = new float[subjectList.size() * 3 + 3];
+        Arrays.fill(cols, 1f);
+
 		Table table = new Table(cols);
 		table.setWidthPercent(100);
 		table.setFont(PdfDefaultFont).setFontSize(18);
-		for(int x=0;x<3;x++) {
-			table.addCell(new Cell().add("序号").setTextAlignment(TextAlignment.CENTER).setVerticalAlignment(VerticalAlignment.MIDDLE).setFontSize(10).setHeight(28));
-			for(int i = 0;i<subjectList.size(); i++) 
-				table.addCell(new Cell().add(subjectArray.get(i).getSubject_name()).setTextAlignment(TextAlignment.CENTER).setVerticalAlignment(VerticalAlignment.MIDDLE).setFontSize(10).setHeight(28));
+		for (int x = 0; x < 3; x++) {
+			table.addCell(
+					new Cell().add("序号").setTextAlignment(TextAlignment.CENTER).setVerticalAlignment(VerticalAlignment.MIDDLE).setFontSize(10).setHeight(28));
+			for (int i = 0; i < subjectList.size(); i++)
+				table.addCell(new Cell().add(subjectArray.get(i).getSubject_name()).setTextAlignment(TextAlignment.CENTER)
+						.setVerticalAlignment(VerticalAlignment.MIDDLE).setFontSize(10).setHeight(28));
 		}	
 		
 		List<DataRecord> dataRecords = this.daoExport.listJudgeScoreZx(room_id, exJudgeRoom.getJudge_id(), start_num, end_num);
@@ -207,9 +206,11 @@ public class ExamInterviewExportControl extends ArtControl {
 			//第一列
 			if(records.size() >= i+1) {
 				List<DataRecord> resultList = getRecordList(dataRecords, records.get(i).getI01());
-				table.addCell(new Cell().add(resultList != null && resultList.size()>0 ? resultList.get(0).getI05().toString() : " ").setTextAlignment(TextAlignment.CENTER).setVerticalAlignment(VerticalAlignment.MIDDLE).setFontSize(10).setHeight(28));
-				for(DataRecord dr : resultList) {
-					table.addCell(new Cell().add(StringHelper.isNotEmpty(dr.getS02()) ? dr.getS02().toString() : " ").setTextAlignment(TextAlignment.CENTER).setVerticalAlignment(VerticalAlignment.MIDDLE).setFontSize(10).setHeight(28));
+				table.addCell(new Cell().add(!resultList.isEmpty() ? resultList.get(0).getI05().toString() : " ")
+						.setTextAlignment(TextAlignment.CENTER).setVerticalAlignment(VerticalAlignment.MIDDLE).setFontSize(10).setHeight(28));
+				for (DataRecord dr : resultList) {
+					table.addCell(new Cell().add(StringHelper.isNotEmpty(dr.getS02()) ? dr.getS02() : " ")
+							.setTextAlignment(TextAlignment.CENTER).setVerticalAlignment(VerticalAlignment.MIDDLE).setFontSize(10).setHeight(28));
 				}
 			} else {
 				table.addCell(new Cell().add(" ").setTextAlignment(TextAlignment.CENTER).setVerticalAlignment(VerticalAlignment.MIDDLE).setFontSize(10).setHeight(28));
@@ -220,24 +221,28 @@ public class ExamInterviewExportControl extends ArtControl {
 			
 			//第二列
 			if(records.size() >= i+24) {
-				List<DataRecord> resultList = getRecordList(dataRecords, records.get(i+23).getI01());
-				table.addCell(new Cell().add(resultList != null && resultList.size()>0 ? resultList.get(0).getI05().toString() : " ").setTextAlignment(TextAlignment.CENTER).setVerticalAlignment(VerticalAlignment.MIDDLE).setFontSize(10).setHeight(28));
-				for(DataRecord dr : resultList) {
-					table.addCell(new Cell().add(StringHelper.isNotEmpty(dr.getS02()) ? dr.getS02().toString() : " ").setTextAlignment(TextAlignment.CENTER).setVerticalAlignment(VerticalAlignment.MIDDLE).setFontSize(10).setHeight(28));
+				List<DataRecord> resultList = getRecordList(dataRecords, records.get(i + 23).getI01());
+				table.addCell(new Cell().add(!resultList.isEmpty() ? resultList.get(0).getI05().toString() : " ").setTextAlignment(TextAlignment.CENTER)
+						.setVerticalAlignment(VerticalAlignment.MIDDLE).setFontSize(10).setHeight(28));
+				for (DataRecord dr : resultList) {
+					table.addCell(new Cell().add(StringHelper.isNotEmpty(dr.getS02()) ? dr.getS02() : " ").setTextAlignment(TextAlignment.CENTER)
+							.setVerticalAlignment(VerticalAlignment.MIDDLE).setFontSize(10).setHeight(28));
 				}
 			} else {
-				table.addCell(new Cell().add(" ").setTextAlignment(TextAlignment.CENTER).setVerticalAlignment(VerticalAlignment.MIDDLE).setFontSize(10).setHeight(28));
-				for(int j = 0;j<subjectList.size();j++) {
-					table.addCell(new Cell().add(" ").setTextAlignment(TextAlignment.CENTER).setVerticalAlignment(VerticalAlignment.MIDDLE).setFontSize(10).setHeight(28));
+				table.addCell(new Cell().add(" ").setTextAlignment(TextAlignment.CENTER).setVerticalAlignment(VerticalAlignment.MIDDLE).setFontSize(10)
+						.setHeight(28));
+				for (int j = 0; j < subjectList.size(); j++) {
+					table.addCell(new Cell().add(" ").setTextAlignment(TextAlignment.CENTER).setVerticalAlignment(VerticalAlignment.MIDDLE).setFontSize(10)
+							.setHeight(28));
 				}
 			}
 			
 			//第三列
 			if(records.size() >= i+47) {
 				List<DataRecord> resultList = getRecordList(dataRecords, records.get(i+46).getI01());
-				table.addCell(new Cell().add(resultList != null && resultList.size()>0 ? resultList.get(0).getI05().toString() : " ").setTextAlignment(TextAlignment.CENTER).setVerticalAlignment(VerticalAlignment.MIDDLE).setFontSize(10).setHeight(28));
+				table.addCell(new Cell().add(!resultList.isEmpty() ? resultList.get(0).getI05().toString() : " ").setTextAlignment(TextAlignment.CENTER).setVerticalAlignment(VerticalAlignment.MIDDLE).setFontSize(10).setHeight(28));
 				for(DataRecord dr : resultList) {
-					table.addCell(new Cell().add(StringHelper.isNotEmpty(dr.getS02()) ? dr.getS02().toString() : " ").setTextAlignment(TextAlignment.CENTER).setVerticalAlignment(VerticalAlignment.MIDDLE).setFontSize(10).setHeight(28));
+					table.addCell(new Cell().add(StringHelper.isNotEmpty(dr.getS02()) ? dr.getS02() : " ").setTextAlignment(TextAlignment.CENTER).setVerticalAlignment(VerticalAlignment.MIDDLE).setFontSize(10).setHeight(28));
 				}
 			} else {
 				table.addCell(new Cell().add(" ").setTextAlignment(TextAlignment.CENTER).setVerticalAlignment(VerticalAlignment.MIDDLE).setFontSize(10).setHeight(28));
@@ -247,10 +252,11 @@ public class ExamInterviewExportControl extends ArtControl {
 			}
 			
 		}
-		
-		 doc.setMargins(0, 20, 0, 20);
-        Paragraph p1 = new Paragraph(ArtParamHelper.SchoolName + "【" +group.getShow_aspect_name() +"】" + "评分表").setFont(PdfDefaultFont).setFontSize(18).setTextAlignment(TextAlignment.CENTER);
-        doc.add(p1);
+
+		doc.setMargins(0, 20, 0, 20);
+		Paragraph p1 = new Paragraph(ArtParamHelper.SchoolName + "【" + group.getShow_aspect_name() + "】" + "评分表").setFont(PdfDefaultFont).setFontSize(18)
+				.setTextAlignment(TextAlignment.CENTER);
+		doc.add(p1);
         
     	float[] docTitle = new float[8];
     	docTitle[0] = 1f;