|
|
@@ -1,9 +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;
|
|
|
|
|
|
@@ -201,11 +206,44 @@ 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(String dataSourceId) {
|
|
|
+ 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);
|
|
|
+ //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";//未发布考试或者非考试弹窗
|
|
|
}
|
|
|
@@ -243,5 +281,21 @@ public class DesktopFacadeService {
|
|
|
}
|
|
|
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;
|
|
|
+ }
|
|
|
}
|