|
|
@@ -1,8 +1,14 @@
|
|
|
package com.lc.ibps.platform.service;
|
|
|
|
|
|
+import java.util.Collections;
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
+import com.lc.ibps.base.framework.table.ICommonDao;
|
|
|
+import com.lc.ibps.base.web.context.ContextUtil;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
@@ -17,7 +23,9 @@ public class DesktopFacadeService {
|
|
|
|
|
|
@Autowired
|
|
|
private IDesktopFacadeService desktopFacadeService;
|
|
|
-
|
|
|
+ @Autowired
|
|
|
+ private ICommonDao<?> commonDao;
|
|
|
+
|
|
|
/**
|
|
|
* 个人信息
|
|
|
*
|
|
|
@@ -198,5 +206,96 @@ public class DesktopFacadeService {
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
-
|
|
|
+ /**
|
|
|
+ * 使用参数化查询,防止 SQL 注入
|
|
|
+ * 查询考试记录
|
|
|
+ */
|
|
|
+ public Map<String, Map<String, Object>> batchQueryExamInfo(List<String> dataSourceIds) {
|
|
|
+ Map<String, Map<String, Object>> resultMap = new HashMap<>();
|
|
|
+
|
|
|
+ if (dataSourceIds == null || dataSourceIds.isEmpty()) {
|
|
|
+ return resultMap;
|
|
|
+ }
|
|
|
+ List<String> distinctIds = dataSourceIds.stream().distinct().collect(Collectors.toList());
|
|
|
+ int batchSize = 500;
|
|
|
+ for (int i = 0; i < distinctIds.size(); i += batchSize) {
|
|
|
+ int end = Math.min(i + batchSize, distinctIds.size());
|
|
|
+ List<String> batchIds = distinctIds.subList(i, end);
|
|
|
+ // 使用命名参数格式 #{p0}, #{p1}, #{p2}...
|
|
|
+ StringBuilder sqlBuilder = new StringBuilder("SELECT * FROM v_examination WHERE examId IN (");
|
|
|
+ for (int j = 0; j < batchIds.size(); j++) {
|
|
|
+ if (j > 0) {
|
|
|
+ sqlBuilder.append(",");
|
|
|
+ }
|
|
|
+ sqlBuilder.append("#{p").append(j).append("}");
|
|
|
+ }
|
|
|
+ sqlBuilder.append(")");
|
|
|
+
|
|
|
+ List<Map<String, Object>> records = (List<Map<String, Object>>) commonDao.query(sqlBuilder.toString(), batchIds.toArray());
|
|
|
+ for (Map<String, Object> record : records) {
|
|
|
+ String uniqueKey = record.get("examId") + "_" + record.get("examinee");
|
|
|
+ resultMap.put(uniqueKey, record);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return resultMap;
|
|
|
+ }
|
|
|
+
|
|
|
+ public String chargeExamPassingStatus(Map<String, Object> record) {
|
|
|
+ //List<Map<String,Object>> list = desktopFacadeDao.selectExamViewInfo(dataSourceId);
|
|
|
+ //String sql = " select * from v_examination where examId ='"+dataSourceId+"' limit 1;";
|
|
|
+ //Map<String,Object> record = commonDao.queryOne(sql);
|
|
|
+ if (record == null || record.isEmpty()) {
|
|
|
+ return "empt";//未发布考试或者非考试弹窗
|
|
|
+ }
|
|
|
+ String flag ="NotExaminedStatus";//考试已发布但是未考试完成状态
|
|
|
+ // 获取字段
|
|
|
+ Object limitDateObj =record.get("limitDate");
|
|
|
+ String examState = (String) record.get("examState");
|
|
|
+ String paperState = (String) record.get("paperState");
|
|
|
+ // 检查条件
|
|
|
+ if (limitDateObj != null && !limitDateObj.toString().isEmpty() && "已发布".equals(examState) && "已完成".equals(paperState)) {
|
|
|
+ // 获取字段值
|
|
|
+ Object totalScoreObj = record.get("totalScore");
|
|
|
+ Object qualifiedRadioObj = record.get("qualifiedRadio");
|
|
|
+ if (totalScoreObj == null || qualifiedRadioObj == null
|
|
|
+ || "".equals(totalScoreObj) || "".equals(qualifiedRadioObj)) {
|
|
|
+ // 关键字段缺失,返回未完成状态
|
|
|
+ return "NotExaminedStatus";
|
|
|
+ }
|
|
|
+
|
|
|
+ double totalScore = Double.parseDouble(record.get("totalScore").toString());
|
|
|
+ double qualifiedRadio = Double.parseDouble(record.get("qualifiedRadio").toString());
|
|
|
+ String scoringType = (String) record.get("scoringType");
|
|
|
+ Number curScore = null;
|
|
|
+ if ("平均分".equals(scoringType)) {
|
|
|
+ curScore = (Number) record.get("averageScore");
|
|
|
+ } else if ("最高分".equals(scoringType)) {
|
|
|
+ curScore = (Number) record.get("maxScore");
|
|
|
+ } else if ("最近得分".equals(scoringType)) {
|
|
|
+ curScore = (Number) record.get("recentScore");
|
|
|
+ }
|
|
|
+ if (curScore != null) {
|
|
|
+ double passScore = totalScore * qualifiedRadio / 100.0;
|
|
|
+ return curScore.doubleValue() >= passScore?flag="pass":"failure";//pass 考试已通过
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return flag;
|
|
|
+ }
|
|
|
+
|
|
|
+ public Map<String, String> chargeExamPassingFlag(Map<String, Map<String, Object>> records) {
|
|
|
+ Map<String, String> examStatusMap = new HashMap<>();
|
|
|
+ if (records == null || records.isEmpty()) {
|
|
|
+ return examStatusMap;
|
|
|
+ }
|
|
|
+ for (Map.Entry<String, Map<String, Object>> entry : records.entrySet()) {
|
|
|
+ String examId = entry.getKey();
|
|
|
+ Map<String, Object> record = entry.getValue();
|
|
|
+ // 使用 examId + examinee 作为唯一key
|
|
|
+ //String examinee = record.get("examinee") != null ? record.get("examinee").toString() : "";
|
|
|
+ //String uniqueKey = examId + "_" + examinee;
|
|
|
+ String status = chargeExamPassingStatus(record);
|
|
|
+ examStatusMap.put(examId, status);
|
|
|
+ }
|
|
|
+ return examStatusMap;
|
|
|
+ }
|
|
|
}
|