Commit 0e76f13c authored by ryzeycy's avatar ryzeycy

xx

parent 2bd72f88
package com.example.pdfgenerator.controller;
import com.example.pdfgenerator.Dto.BasicReportParameters;
import com.example.pdfgenerator.Dto.ClassBasicReportParameters;
import com.example.pdfgenerator.Dto.RetryCommand;
import com.example.pdfgenerator.config.MyDataSourceConfig;
import com.qcloud.cos.COSClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import java.util.stream.Collectors;
@RestController
@RequestMapping("/pdf")
public class GeneratorAllTypePdfByProvinceController {
private static final Logger logger = LoggerFactory.getLogger(GeneratorAllTypePdfByProvinceController.class);
@Autowired
private COSClient cosClient;
private static final String bucketName = "schoolreportpdf-1317275686";
private static Map<String, String> fileToUrl = new HashMap<>();
JdbcTemplate reportJdbcTemplate = MyDataSourceConfig.getReportJdbcTemplate();
@RequestMapping("/GeneratorByProvinceName")
public ResponseEntity generatorName(@RequestParam("examId") String examId, @RequestParam(value = "provinceName", required = false) String provinceName, @RequestParam(value = "schoolName", required = false) String schoolName) throws IOException, InterruptedException {
String suffix = examId.trim().replace("TDA", "").replace("G3", "").replace("G2", "").replace("G10", "").replace("G11", "").replace("G12", "").trim();
String synthesisSchoolSubjectReportSql = "select \n" +
"school,exam_id,province,region1 as region,sub_subject\n" +
"from \n" +
"base_school_subject_tda" + suffix + " \n" +
" where subject_type = '常规' \n";
String synthesisSchoolReportSql = "select \n" +
"school,exam_id,province,region1 as region\n" +
"from \n" +
"base_school_subject_tda" + suffix + " where subject_type = '常规' \n";
String synthesisClassSubjectReportSql = "SELECT\n" +
"\tclass as class_name,\n" +
"\tsub_subject,\n" +
"\tschool,\n" +
"\tprovince,\n" +
"\tregion1 as region,\n" +
"\texam_id\n" +
"FROM\n" +
"\tbase_student_subject_tda" + suffix + "\n" +
"where\n" +
"subject_type = '常规' \n ";
String synthesisClassReportSql = "SELECT\n" +
"\tclass AS class_name,\n" +
"\tschool,\n" +
"\texam_id,\n" +
"\tprovince,\n" +
"\tregion1 as region \n" +
"FROM\n" +
"\tbase_class_subject_tda" + suffix + "\n" +
"WHERE\n" +
"\tsubject_type = '常规'\n";
if (provinceName != null) {
List<String> provinceList = Arrays.asList(provinceName.split("#"));
String appendStatement = " and province in (";
for (String s : provinceList) {
appendStatement = appendStatement + "'" + s + "',";
}
appendStatement = appendStatement.substring(0, appendStatement.length() - 1) + ") ";
synthesisSchoolSubjectReportSql = synthesisSchoolSubjectReportSql + " " + appendStatement;
synthesisSchoolReportSql = synthesisSchoolReportSql + " " + appendStatement;
synthesisClassSubjectReportSql = synthesisClassSubjectReportSql + " " + appendStatement;
synthesisClassReportSql = synthesisClassReportSql + " " + appendStatement;
}
if (schoolName != null) {
List<String> schoolList = Arrays.asList(schoolName.split("#"));
String appendStatement = " and school in (";
for (String s : schoolList) {
appendStatement = appendStatement + "'" + s + "',";
}
appendStatement = appendStatement.substring(0, appendStatement.length() - 1) + ") ";
synthesisSchoolSubjectReportSql = synthesisSchoolSubjectReportSql + " " + appendStatement;
synthesisSchoolReportSql = synthesisSchoolReportSql + " " + appendStatement;
synthesisClassSubjectReportSql = synthesisClassSubjectReportSql + " " + appendStatement;
synthesisClassReportSql = synthesisClassReportSql + " " + appendStatement;
}
synthesisSchoolSubjectReportSql = synthesisSchoolSubjectReportSql + " group by school,exam_id,province,region1,sub_subject";
synthesisSchoolReportSql = synthesisSchoolReportSql + " " + " group by school,exam_id,province,region1";
synthesisClassSubjectReportSql = synthesisClassSubjectReportSql + " " + "\tGROUP BY\n" + "\tclass,\n" + "\tsub_subject,\n" + "\tschool,\n" + "\tprovince,\n" + "\tregion1,\n" + "\texam_id";
synthesisClassReportSql = synthesisClassReportSql + " " + " GROUP BY\n" + "\tclass,\n" + "\tschool,\n" + "\texam_id,\n" + "\tprovince,\n" + "\tregion1\n";
// System.out.println(1);
// System.out.println(synthesisSchoolSubjectReportSql);
//
// System.out.println(2);
// System.out.println(synthesisSchoolReportSql);
//
// System.out.println(3);
// System.out.println(synthesisClassSubjectReportSql);
//
// System.out.println(4);
// System.out.println(synthesisClassReportSql);
List<BasicReportParameters> synthesisSchoolSubjectReportParameters = this.reportJdbcTemplate.query(synthesisSchoolSubjectReportSql, new Object[]{}, new BeanPropertyRowMapper<>(BasicReportParameters.class));
for (BasicReportParameters parameter : synthesisSchoolSubjectReportParameters) {
if (parameter.getRegion().equals("改革") || parameter.getRegion().equals("改革A") || parameter.getRegion().equals("改革3+3") || parameter.getRegion().equals("改革3+1+2")) {
String command = "node /myworkSpace/puppeteer2.js \"http://schoolreport.cssat.cn/pdf/subject?province=condition5&school=condition1&examId=condition4&region=conditionC&subSubject=condition6&subjectType=常规\" pdf";
String fileName = "/myworkSpace/subject/" + parameter.getRegion() + parameter.getProvince() + parameter.getSchool() + parameter.getSubSubject() + parameter.getExamId() + ".pdf";
command = command.replace("condition1", parameter.getSchool()).replace("condition5", parameter.getProvince()).replace("conditionC", parameter.getRegion()).replace("condition4", parameter.getExamId()).replace("condition6", parameter.getSubSubject())
.concat(" ").concat(fileName);
parameter.setCommand(command);
parameter.setPrefix("/myworkSpace/subject/");
fileToUrl.put(fileName.replace("/myworkSpace/subject/", ""), "PdfSubject/" + fileName.replace("/myworkSpace/subject/", ""));
} else {
String command = "node /myworkSpace/puppeteer2.js \"http://schoolreport.cssat.cn/pdf/subject?province=condition5&school=condition1&examId=condition4&region=非改革&branch=condition3&subSubject=condition6&subjectType=常规\" pdf";
String fileName = "/myworkSpace/subject/" + parameter.getRegion() + parameter.getProvince() + parameter.getSchool() + parameter.getSubSubject() + parameter.getExamId() + ".pdf";
command = command.replace("condition1", parameter.getSchool()).replace("condition5", parameter.getProvince()).replace("condition3", parameter.getRegion()).replace("condition4", parameter.getExamId()).replace("condition6", parameter.getSubSubject())
.concat(" ").concat(fileName);
parameter.setCommand(command);
parameter.setPrefix("/myworkSpace/subject/");
fileToUrl.put(fileName.replace("/myworkSpace/subject/", ""), "PdfSubject/" + fileName.replace("/myworkSpace/subject/", ""));
}
}
List<BasicReportParameters> synthesisSchoolReportParameters = this.reportJdbcTemplate.query(synthesisSchoolReportSql, new Object[]{}, new BeanPropertyRowMapper<>(BasicReportParameters.class));
for (BasicReportParameters synthesisSchoolReportParameter : synthesisSchoolReportParameters) {
if (synthesisSchoolReportParameter.getRegion().equals("改革") || synthesisSchoolReportParameter.getRegion().equals("改革A") || synthesisSchoolReportParameter.getRegion().equals("改革3+3") || synthesisSchoolReportParameter.getRegion().equals("改革3+1+2")) {
String command = "node /myworkSpace/puppeteer.js \"http://schoolreport.cssat.cn/pdf/basic?province=condition5&school=condition1&examId=condition4&region=conditionC&subjectType=常规\" pdf ";
String fileName = "/myworkSpace/basic/" + synthesisSchoolReportParameter.getRegion() + synthesisSchoolReportParameter.getProvince() + synthesisSchoolReportParameter.getSchool() + synthesisSchoolReportParameter.getExamId() + ".pdf";
command = command.replace("condition1", synthesisSchoolReportParameter.getSchool()).replace("condition5", synthesisSchoolReportParameter.getProvince()).replace("conditionC", synthesisSchoolReportParameter.getRegion()).replace("condition4", synthesisSchoolReportParameter.getExamId())
.concat(" ").concat(fileName);
synthesisSchoolReportParameter.setCommand(command);
synthesisSchoolReportParameter.setPrefix("/myworkSpace/basic/");
fileToUrl.put(fileName.replace("/myworkSpace/basic/", ""), "PdfDir/" + fileName.replace("/myworkSpace/basic/", ""));
} else {
String command = "node /myworkSpace/puppeteer.js \"http://schoolreport.cssat.cn/pdf/basic?province=condition5&school=condition1&examId=condition4&region=非改革&branch=condition3&subjectType=常规\" pdf ";
String fileName = "/myworkSpace/basic/" + synthesisSchoolReportParameter.getRegion() + synthesisSchoolReportParameter.getProvince() + synthesisSchoolReportParameter.getSchool() + synthesisSchoolReportParameter.getExamId() + ".pdf";
command = command.replace("condition1", synthesisSchoolReportParameter.getSchool()).replace("condition5", synthesisSchoolReportParameter.getProvince()).replace("condition3", synthesisSchoolReportParameter.getRegion()).replace("condition4", synthesisSchoolReportParameter.getExamId())
.concat(" ").concat(fileName);
synthesisSchoolReportParameter.setCommand(command);
synthesisSchoolReportParameter.setPrefix("/myworkSpace/basic/");
fileToUrl.put(fileName.replace("/myworkSpace/basic/", ""), "PdfDir/" + fileName.replace("/myworkSpace/basic/", ""));
}
}
List<ClassBasicReportParameters> synthesisClassSubjectReportParameters = this.reportJdbcTemplate.query(synthesisClassSubjectReportSql, new Object[]{}, new BeanPropertyRowMapper<>(ClassBasicReportParameters.class));
for (ClassBasicReportParameters synthesisClassSubjectReportParameter : synthesisClassSubjectReportParameters) {
if (synthesisClassSubjectReportParameter.getRegion().equals("改革") || synthesisClassSubjectReportParameter.getRegion().equals("改革A") || synthesisClassSubjectReportParameter.getRegion().equals("改革3+3") || synthesisClassSubjectReportParameter.getRegion().equals("改革3+1+2")) {
String command = "node /myworkSpace/pdfOfClassSubjectGen.js \"http://schoolreport.cssat.cn/pdf/classSubject?province=condition5&school=condition1&examId=condition4&region=conditionC&subSubject=condition6&subjectType=常规&className=conditionA\" pdf";
String fileName = "/myworkSpace/Class/subject/" + synthesisClassSubjectReportParameter.getRegion() + synthesisClassSubjectReportParameter.getProvince() + synthesisClassSubjectReportParameter.getSchool() + synthesisClassSubjectReportParameter.getSubSubject() + synthesisClassSubjectReportParameter.getExamId() + synthesisClassSubjectReportParameter.getSubSubject() + synthesisClassSubjectReportParameter.getClassName().replace(" ", "") + ".pdf";
command = command.replace("condition1", synthesisClassSubjectReportParameter.getSchool()).replace("condition5", synthesisClassSubjectReportParameter.getProvince()).replace("conditionC", synthesisClassSubjectReportParameter.getRegion()).replace("condition4", synthesisClassSubjectReportParameter.getExamId()).replace("condition6", synthesisClassSubjectReportParameter.getSubSubject()).replace("conditionA", synthesisClassSubjectReportParameter.getClassName())
.concat(" ").concat(fileName);
fileToUrl.put(fileName.replace("/myworkSpace/Class/subject/", ""), "/class/" + synthesisClassSubjectReportParameter.getExamId() + "/" + synthesisClassSubjectReportParameter.getProvince() + "/" + synthesisClassSubjectReportParameter.getSchool() + "/班级学科报告/" + synthesisClassSubjectReportParameter.getClassName() + "/" + synthesisClassSubjectReportParameter.getSubSubject() + "/" + fileName.replace("/myworkSpace/Class/subject/", ""));
synthesisClassSubjectReportParameter.setCommand(command);
synthesisClassSubjectReportParameter.setPrefix("/myworkSpace/Class/subject/");
} else {
String command = "node /myworkSpace/pdfOfClassSubjectGen.js \"http://schoolreport.cssat.cn/pdf/classSubject?province=condition5&school=condition1&examId=condition4&region=非改革&branch=condition3&subSubject=condition6&subjectType=常规&className=conditionA\" pdf";
String fileName = "/myworkSpace/Class/subject/" + synthesisClassSubjectReportParameter.getRegion() + synthesisClassSubjectReportParameter.getProvince() + synthesisClassSubjectReportParameter.getSchool() + synthesisClassSubjectReportParameter.getSubSubject() + synthesisClassSubjectReportParameter.getExamId() + synthesisClassSubjectReportParameter.getSubSubject() + synthesisClassSubjectReportParameter.getClassName().replace(" ", "") + ".pdf";
command = command.replace("condition1", synthesisClassSubjectReportParameter.getSchool()).replace("condition5", synthesisClassSubjectReportParameter.getProvince()).replace("condition3", synthesisClassSubjectReportParameter.getRegion()).replace("condition4", synthesisClassSubjectReportParameter.getExamId()).replace("condition6", synthesisClassSubjectReportParameter.getSubSubject()).replace("conditionA", synthesisClassSubjectReportParameter.getClassName())
.concat(" ").concat(fileName);
fileToUrl.put(fileName.replace("/myworkSpace/Class/subject/", ""), "/class/" + synthesisClassSubjectReportParameter.getExamId() + "/" + synthesisClassSubjectReportParameter.getProvince() + "/" + synthesisClassSubjectReportParameter.getSchool() + "/班级学科报告/" + synthesisClassSubjectReportParameter.getClassName() + "/" + synthesisClassSubjectReportParameter.getSubSubject() + "/" + fileName.replace("/myworkSpace/Class/subject/", ""));
synthesisClassSubjectReportParameter.setCommand(command);
synthesisClassSubjectReportParameter.setPrefix("/myworkSpace/Class/subject/");
}
}
List<ClassBasicReportParameters> synthesisClassReportParameters = this.reportJdbcTemplate.query(synthesisClassReportSql, new Object[]{}, new BeanPropertyRowMapper<>(ClassBasicReportParameters.class));
for (ClassBasicReportParameters synthesisClassReportParameter : synthesisClassReportParameters) {
if (synthesisClassReportParameter.getRegion().equals("改革") || synthesisClassReportParameter.getRegion().equals("改革A") || synthesisClassReportParameter.getRegion().equals("改革3+3") || synthesisClassReportParameter.getRegion().equals("改革3+1+2")) {
String command = "node /myworkSpace/pdfOfClassBasicGen.js \"http://schoolreport.cssat.cn/pdf/classBasic?province=condition5&school=condition1&examId=condition4&region=conditionC&subjectType=常规&className=conditionA\" pdf ";
String fileName = "/myworkSpace/Class/Basic/" + synthesisClassReportParameter.getRegion() + synthesisClassReportParameter.getProvince() + synthesisClassReportParameter.getSchool() + synthesisClassReportParameter.getClassName() + synthesisClassReportParameter.getExamId() + ".pdf";
command = command.replace("condition1", synthesisClassReportParameter.getSchool()).replace("condition5", synthesisClassReportParameter.getProvince()).replace("conditionC", synthesisClassReportParameter.getRegion()).replace("condition4", synthesisClassReportParameter.getExamId()).replace("conditionA", synthesisClassReportParameter.getClassName())
.concat(" ").concat(fileName);
fileToUrl.put(fileName.replace("/myworkSpace/Class/Basic/", ""), "/class/" + synthesisClassReportParameter.getExamId() + "/" + synthesisClassReportParameter.getProvince() + "/" + synthesisClassReportParameter.getSchool() + "/班级综合报告/" + synthesisClassReportParameter.getClassName() + "/" + fileName.replace("/myworkSpace/Class/Basic/", ""));
synthesisClassReportParameter.setCommand(command);
synthesisClassReportParameter.setPrefix("/myworkSpace/Class/Basic/");
} else {
String command = "node/myworkSpace/pdfOfClassBasicGen.js \"http://schoolreport.cssat.cn/pdf/classBasic?province=condition5&school=condition1&examId=condition4&region=非改革&branch=condition3&subjectType=常规&className=conditionA\" pdf ";
String fileName = "/myworkSpace/Class/Basic/" + synthesisClassReportParameter.getRegion() + synthesisClassReportParameter.getProvince() + synthesisClassReportParameter.getSchool() + synthesisClassReportParameter.getClassName() + synthesisClassReportParameter.getExamId() + ".pdf";
command = command.replace("condition1", synthesisClassReportParameter.getSchool()).replace("condition5", synthesisClassReportParameter.getProvince()).replace("condition3", synthesisClassReportParameter.getRegion()).replace("condition4", synthesisClassReportParameter.getExamId()).replace("conditionA", synthesisClassReportParameter.getClassName())
.concat(" ").concat(fileName);
fileToUrl.put(fileName.replace("/myworkSpace/Class/Basic/", ""), "/class/" + synthesisClassReportParameter.getExamId() + "/" + synthesisClassReportParameter.getProvince() + "/" + synthesisClassReportParameter.getSchool() + "/班级综合报告/" + synthesisClassReportParameter.getClassName() + "/" + fileName.replace("/myworkSpace/Class/Basic/", ""));
synthesisClassReportParameter.setCommand(command);
synthesisClassReportParameter.setPrefix("/myworkSpace/Class/Basic/");
}
}
// for (String s : fileToUrl.keySet()) {
// System.out.println("file="+s+"==mapto=="+"key="+fileToUrl.get(s));
//package com.example.pdfgenerator.controller;
//
//import com.example.pdfgenerator.Dto.BasicReportParameters;
//import com.example.pdfgenerator.Dto.ClassBasicReportParameters;
//import com.example.pdfgenerator.Dto.RetryCommand;
//import com.example.pdfgenerator.config.MyDataSourceConfig;
//import com.qcloud.cos.COSClient;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.http.ResponseEntity;
//import org.springframework.jdbc.core.BeanPropertyRowMapper;
//import org.springframework.jdbc.core.JdbcTemplate;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RequestParam;
//import org.springframework.web.bind.annotation.RestController;
//
//import java.io.BufferedReader;
//import java.io.IOException;
//import java.io.InputStreamReader;
//import java.util.*;
//import java.util.stream.Collectors;
//
//
//@RestController
//@RequestMapping("/pdf")
//public class GeneratorAllTypePdfByProvinceController {
//
// private static final Logger logger = LoggerFactory.getLogger(GeneratorAllTypePdfByProvinceController.class);
//
// @Autowired
// private COSClient cosClient;
//
// private static final String bucketName = "schoolreportpdf-1317275686";
//
//
// private static Map<String, String> fileToUrl = new HashMap<>();
//
// JdbcTemplate reportJdbcTemplate = MyDataSourceConfig.getReportJdbcTemplate();
//
//
// @RequestMapping("/GeneratorByProvinceName")
// public ResponseEntity generatorName(@RequestParam("examId") String examId, @RequestParam(value = "provinceName", required = false) String provinceName, @RequestParam(value = "schoolName", required = false) String schoolName) throws IOException, InterruptedException {
//
// String suffix = examId.trim().replace("TDA", "").replace("G3", "").replace("G2", "").replace("G10", "").replace("G11", "").replace("G12", "").trim();
//
// String synthesisSchoolSubjectReportSql = "select \n" +
// "school,exam_id,province,region1 as region,sub_subject\n" +
// "from \n" +
// "base_school_subject_tda" + suffix + " \n" +
// " where subject_type = '常规' \n";
//
// String synthesisSchoolReportSql = "select \n" +
// "school,exam_id,province,region1 as region\n" +
// "from \n" +
// "base_school_subject_tda" + suffix + " where subject_type = '常规' \n";
//
// String synthesisClassSubjectReportSql = "SELECT\n" +
// "\tclass as class_name,\n" +
// "\tsub_subject,\n" +
// "\tschool,\n" +
// "\tprovince,\n" +
// "\tregion1 as region,\n" +
// "\texam_id\n" +
// "FROM\n" +
// "\tbase_student_subject_tda" + suffix + "\n" +
// "where\n" +
// "subject_type = '常规' \n ";
//
// String synthesisClassReportSql = "SELECT\n" +
// "\tclass AS class_name,\n" +
// "\tschool,\n" +
// "\texam_id,\n" +
// "\tprovince,\n" +
// "\tregion1 as region \n" +
// "FROM\n" +
// "\tbase_class_subject_tda" + suffix + "\n" +
// "WHERE\n" +
// "\tsubject_type = '常规'\n";
//
// if (provinceName != null) {
//
// List<String> provinceList = Arrays.asList(provinceName.split("#"));
//
// String appendStatement = " and province in (";
//
// for (String s : provinceList) {
// appendStatement = appendStatement + "'" + s + "',";
// }
//
// appendStatement = appendStatement.substring(0, appendStatement.length() - 1) + ") ";
//
// synthesisSchoolSubjectReportSql = synthesisSchoolSubjectReportSql + " " + appendStatement;
// synthesisSchoolReportSql = synthesisSchoolReportSql + " " + appendStatement;
// synthesisClassSubjectReportSql = synthesisClassSubjectReportSql + " " + appendStatement;
// synthesisClassReportSql = synthesisClassReportSql + " " + appendStatement;
//
//
// }
Map<String, List<BasicReportParameters>> schoolReport = synthesisSchoolReportParameters.stream().collect(Collectors.groupingBy(BasicReportParameters::getProvince));
Map<String, List<BasicReportParameters>> schoolSubjectReport = synthesisSchoolSubjectReportParameters.stream().collect(Collectors.groupingBy(BasicReportParameters::getProvince));
Map<String, List<ClassBasicReportParameters>> classReport = synthesisClassReportParameters.stream().collect(Collectors.groupingBy(ClassBasicReportParameters::getProvince));
Map<String, List<ClassBasicReportParameters>> classSubjectReport = synthesisClassSubjectReportParameters.stream().collect(Collectors.groupingBy(ClassBasicReportParameters::getProvince));
// 分组开始执行记录
for (String key : schoolReport.keySet()) {
logger.info("province:" + key + "Gen");
List<BasicReportParameters> schoolBasicReport = schoolReport.get(key);
List<BasicReportParameters> schoolSubject = schoolSubjectReport.get(key);
List<ClassBasicReportParameters> classBasicReport = classReport.get(key);
List<ClassBasicReportParameters> classSubject = classSubjectReport.get(key);
for (BasicReportParameters schoolLevel : schoolBasicReport) {
List<RetryCommand> retryCommands = new ArrayList<>();
logger.info("school:" + schoolLevel.getSchool() + "loading");
Map<String, List<BasicReportParameters>> schoolMap = schoolSubject.stream().collect(Collectors.groupingBy(BasicReportParameters::getSchool));
Map<String, List<ClassBasicReportParameters>> classBasic = classBasicReport.stream().collect(Collectors.groupingBy(ClassBasicReportParameters::getSchool));
final Map<String, List<ClassBasicReportParameters>> subjectClass = classSubject.stream().collect(Collectors.groupingBy(ClassBasicReportParameters::getSchool));
List<BasicReportParameters> schoolSelf = schoolMap.get(schoolLevel.getSchool());
logger.info("basicReport:loading");
logger.info("exitCode:" + schoolLevel.getSchool());
// ProcessBuilder processBuilder = new ProcessBuilder();
// processBuilder.command("bash", "-c", schoolLevel.getCommand());
// processBuilder.redirectErrorStream(true); // 合并标准输出和错误输出
// Process process = null;
// try {
// process = processBuilder.start();
// } catch (IOException e) {
// throw new RuntimeException(e);
// }
// BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
// String line;
// while (true) {
// try {
// if (!((line = reader.readLine()) != null)) break;
// } catch (IOException e) {
// throw new RuntimeException(e);
// }
// }
//// while ((line = reader.readLine()) != null) {
//// // 如果输出了 "DONE",表示生成完毕
//// if ("DONE".equals(line)) {
//// break; // 跳出循环
//// }
//
// if (schoolName != null) {
// List<String> schoolList = Arrays.asList(schoolName.split("#"));
//
// String appendStatement = " and school in (";
//
// for (String s : schoolList) {
// appendStatement = appendStatement + "'" + s + "',";
// }
//
// appendStatement = appendStatement.substring(0, appendStatement.length() - 1) + ") ";
//
// synthesisSchoolSubjectReportSql = synthesisSchoolSubjectReportSql + " " + appendStatement;
// synthesisSchoolReportSql = synthesisSchoolReportSql + " " + appendStatement;
// synthesisClassSubjectReportSql = synthesisClassSubjectReportSql + " " + appendStatement;
// synthesisClassReportSql = synthesisClassReportSql + " " + appendStatement;
//
// }
//
// synthesisSchoolSubjectReportSql = synthesisSchoolSubjectReportSql + " group by school,exam_id,province,region1,sub_subject";
//
// synthesisSchoolReportSql = synthesisSchoolReportSql + " " + " group by school,exam_id,province,region1";
//
// synthesisClassSubjectReportSql = synthesisClassSubjectReportSql + " " + "\tGROUP BY\n" + "\tclass,\n" + "\tsub_subject,\n" + "\tschool,\n" + "\tprovince,\n" + "\tregion1,\n" + "\texam_id";
//
// synthesisClassReportSql = synthesisClassReportSql + " " + " GROUP BY\n" + "\tclass,\n" + "\tschool,\n" + "\texam_id,\n" + "\tprovince,\n" + "\tregion1\n";
//
//// System.out.println(1);
//// System.out.println(synthesisSchoolSubjectReportSql);
////
//// System.out.println(2);
//// System.out.println(synthesisSchoolReportSql);
////
//// System.out.println(3);
//// System.out.println(synthesisClassSubjectReportSql);
////
//// System.out.println(4);
//// System.out.println(synthesisClassReportSql);
//
// List<BasicReportParameters> synthesisSchoolSubjectReportParameters = this.reportJdbcTemplate.query(synthesisSchoolSubjectReportSql, new Object[]{}, new BeanPropertyRowMapper<>(BasicReportParameters.class));
//
// for (BasicReportParameters parameter : synthesisSchoolSubjectReportParameters) {
// if (parameter.getRegion().equals("改革") || parameter.getRegion().equals("改革A") || parameter.getRegion().equals("改革3+3") || parameter.getRegion().equals("改革3+1+2")) {
// String command = "node /myworkSpace/puppeteer2.js \"http://schoolreport.cssat.cn/pdf/subject?province=condition5&school=condition1&examId=condition4&region=conditionC&subSubject=condition6&subjectType=常规\" pdf";
// String fileName = "/myworkSpace/subject/" + parameter.getRegion() + parameter.getProvince() + parameter.getSchool() + parameter.getSubSubject() + parameter.getExamId() + ".pdf";
// command = command.replace("condition1", parameter.getSchool()).replace("condition5", parameter.getProvince()).replace("conditionC", parameter.getRegion()).replace("condition4", parameter.getExamId()).replace("condition6", parameter.getSubSubject())
// .concat(" ").concat(fileName);
// parameter.setCommand(command);
// parameter.setPrefix("/myworkSpace/subject/");
// fileToUrl.put(fileName.replace("/myworkSpace/subject/", ""), "PdfSubject/" + fileName.replace("/myworkSpace/subject/", ""));
//
// } else {
// String command = "node /myworkSpace/puppeteer2.js \"http://schoolreport.cssat.cn/pdf/subject?province=condition5&school=condition1&examId=condition4&region=非改革&branch=condition3&subSubject=condition6&subjectType=常规\" pdf";
// String fileName = "/myworkSpace/subject/" + parameter.getRegion() + parameter.getProvince() + parameter.getSchool() + parameter.getSubSubject() + parameter.getExamId() + ".pdf";
// command = command.replace("condition1", parameter.getSchool()).replace("condition5", parameter.getProvince()).replace("condition3", parameter.getRegion()).replace("condition4", parameter.getExamId()).replace("condition6", parameter.getSubSubject())
// .concat(" ").concat(fileName);
// parameter.setCommand(command);
// parameter.setPrefix("/myworkSpace/subject/");
// fileToUrl.put(fileName.replace("/myworkSpace/subject/", ""), "PdfSubject/" + fileName.replace("/myworkSpace/subject/", ""));
// }
// }
//
// List<BasicReportParameters> synthesisSchoolReportParameters = this.reportJdbcTemplate.query(synthesisSchoolReportSql, new Object[]{}, new BeanPropertyRowMapper<>(BasicReportParameters.class));
//
// for (BasicReportParameters synthesisSchoolReportParameter : synthesisSchoolReportParameters) {
// if (synthesisSchoolReportParameter.getRegion().equals("改革") || synthesisSchoolReportParameter.getRegion().equals("改革A") || synthesisSchoolReportParameter.getRegion().equals("改革3+3") || synthesisSchoolReportParameter.getRegion().equals("改革3+1+2")) {
// String command = "node /myworkSpace/puppeteer.js \"http://schoolreport.cssat.cn/pdf/basic?province=condition5&school=condition1&examId=condition4&region=conditionC&subjectType=常规\" pdf ";
// String fileName = "/myworkSpace/basic/" + synthesisSchoolReportParameter.getRegion() + synthesisSchoolReportParameter.getProvince() + synthesisSchoolReportParameter.getSchool() + synthesisSchoolReportParameter.getExamId() + ".pdf";
// command = command.replace("condition1", synthesisSchoolReportParameter.getSchool()).replace("condition5", synthesisSchoolReportParameter.getProvince()).replace("conditionC", synthesisSchoolReportParameter.getRegion()).replace("condition4", synthesisSchoolReportParameter.getExamId())
// .concat(" ").concat(fileName);
// synthesisSchoolReportParameter.setCommand(command);
// synthesisSchoolReportParameter.setPrefix("/myworkSpace/basic/");
// fileToUrl.put(fileName.replace("/myworkSpace/basic/", ""), "PdfDir/" + fileName.replace("/myworkSpace/basic/", ""));
// } else {
// String command = "node /myworkSpace/puppeteer.js \"http://schoolreport.cssat.cn/pdf/basic?province=condition5&school=condition1&examId=condition4&region=非改革&branch=condition3&subjectType=常规\" pdf ";
// String fileName = "/myworkSpace/basic/" + synthesisSchoolReportParameter.getRegion() + synthesisSchoolReportParameter.getProvince() + synthesisSchoolReportParameter.getSchool() + synthesisSchoolReportParameter.getExamId() + ".pdf";
// command = command.replace("condition1", synthesisSchoolReportParameter.getSchool()).replace("condition5", synthesisSchoolReportParameter.getProvince()).replace("condition3", synthesisSchoolReportParameter.getRegion()).replace("condition4", synthesisSchoolReportParameter.getExamId())
// .concat(" ").concat(fileName);
// synthesisSchoolReportParameter.setCommand(command);
// synthesisSchoolReportParameter.setPrefix("/myworkSpace/basic/");
// fileToUrl.put(fileName.replace("/myworkSpace/basic/", ""), "PdfDir/" + fileName.replace("/myworkSpace/basic/", ""));
//
// }
// }
//
// List<ClassBasicReportParameters> synthesisClassSubjectReportParameters = this.reportJdbcTemplate.query(synthesisClassSubjectReportSql, new Object[]{}, new BeanPropertyRowMapper<>(ClassBasicReportParameters.class));
//
// for (ClassBasicReportParameters synthesisClassSubjectReportParameter : synthesisClassSubjectReportParameters) {
//
// if (synthesisClassSubjectReportParameter.getRegion().equals("改革") || synthesisClassSubjectReportParameter.getRegion().equals("改革A") || synthesisClassSubjectReportParameter.getRegion().equals("改革3+3") || synthesisClassSubjectReportParameter.getRegion().equals("改革3+1+2")) {
// String command = "node /myworkSpace/pdfOfClassSubjectGen.js \"http://schoolreport.cssat.cn/pdf/classSubject?province=condition5&school=condition1&examId=condition4&region=conditionC&subSubject=condition6&subjectType=常规&className=conditionA\" pdf";
// String fileName = "/myworkSpace/Class/subject/" + synthesisClassSubjectReportParameter.getRegion() + synthesisClassSubjectReportParameter.getProvince() + synthesisClassSubjectReportParameter.getSchool() + synthesisClassSubjectReportParameter.getSubSubject() + synthesisClassSubjectReportParameter.getExamId() + synthesisClassSubjectReportParameter.getSubSubject() + synthesisClassSubjectReportParameter.getClassName().replace(" ", "") + ".pdf";
// command = command.replace("condition1", synthesisClassSubjectReportParameter.getSchool()).replace("condition5", synthesisClassSubjectReportParameter.getProvince()).replace("conditionC", synthesisClassSubjectReportParameter.getRegion()).replace("condition4", synthesisClassSubjectReportParameter.getExamId()).replace("condition6", synthesisClassSubjectReportParameter.getSubSubject()).replace("conditionA", synthesisClassSubjectReportParameter.getClassName())
// .concat(" ").concat(fileName);
// fileToUrl.put(fileName.replace("/myworkSpace/Class/subject/", ""), "/class/" + synthesisClassSubjectReportParameter.getExamId() + "/" + synthesisClassSubjectReportParameter.getProvince() + "/" + synthesisClassSubjectReportParameter.getSchool() + "/班级学科报告/" + synthesisClassSubjectReportParameter.getClassName() + "/" + synthesisClassSubjectReportParameter.getSubSubject() + "/" + fileName.replace("/myworkSpace/Class/subject/", ""));
// synthesisClassSubjectReportParameter.setCommand(command);
// synthesisClassSubjectReportParameter.setPrefix("/myworkSpace/Class/subject/");
// } else {
// String command = "node /myworkSpace/pdfOfClassSubjectGen.js \"http://schoolreport.cssat.cn/pdf/classSubject?province=condition5&school=condition1&examId=condition4&region=非改革&branch=condition3&subSubject=condition6&subjectType=常规&className=conditionA\" pdf";
//
// String fileName = "/myworkSpace/Class/subject/" + synthesisClassSubjectReportParameter.getRegion() + synthesisClassSubjectReportParameter.getProvince() + synthesisClassSubjectReportParameter.getSchool() + synthesisClassSubjectReportParameter.getSubSubject() + synthesisClassSubjectReportParameter.getExamId() + synthesisClassSubjectReportParameter.getSubSubject() + synthesisClassSubjectReportParameter.getClassName().replace(" ", "") + ".pdf";
// command = command.replace("condition1", synthesisClassSubjectReportParameter.getSchool()).replace("condition5", synthesisClassSubjectReportParameter.getProvince()).replace("condition3", synthesisClassSubjectReportParameter.getRegion()).replace("condition4", synthesisClassSubjectReportParameter.getExamId()).replace("condition6", synthesisClassSubjectReportParameter.getSubSubject()).replace("conditionA", synthesisClassSubjectReportParameter.getClassName())
// .concat(" ").concat(fileName);
// fileToUrl.put(fileName.replace("/myworkSpace/Class/subject/", ""), "/class/" + synthesisClassSubjectReportParameter.getExamId() + "/" + synthesisClassSubjectReportParameter.getProvince() + "/" + synthesisClassSubjectReportParameter.getSchool() + "/班级学科报告/" + synthesisClassSubjectReportParameter.getClassName() + "/" + synthesisClassSubjectReportParameter.getSubSubject() + "/" + fileName.replace("/myworkSpace/Class/subject/", ""));
// synthesisClassSubjectReportParameter.setCommand(command);
// synthesisClassSubjectReportParameter.setPrefix("/myworkSpace/Class/subject/");
// }
// }
//
// List<ClassBasicReportParameters> synthesisClassReportParameters = this.reportJdbcTemplate.query(synthesisClassReportSql, new Object[]{}, new BeanPropertyRowMapper<>(ClassBasicReportParameters.class));
//
// for (ClassBasicReportParameters synthesisClassReportParameter : synthesisClassReportParameters) {
//
// if (synthesisClassReportParameter.getRegion().equals("改革") || synthesisClassReportParameter.getRegion().equals("改革A") || synthesisClassReportParameter.getRegion().equals("改革3+3") || synthesisClassReportParameter.getRegion().equals("改革3+1+2")) {
//
// String command = "node /myworkSpace/pdfOfClassBasicGen.js \"http://schoolreport.cssat.cn/pdf/classBasic?province=condition5&school=condition1&examId=condition4&region=conditionC&subjectType=常规&className=conditionA\" pdf ";
//
// String fileName = "/myworkSpace/Class/Basic/" + synthesisClassReportParameter.getRegion() + synthesisClassReportParameter.getProvince() + synthesisClassReportParameter.getSchool() + synthesisClassReportParameter.getClassName() + synthesisClassReportParameter.getExamId() + ".pdf";
//
// command = command.replace("condition1", synthesisClassReportParameter.getSchool()).replace("condition5", synthesisClassReportParameter.getProvince()).replace("conditionC", synthesisClassReportParameter.getRegion()).replace("condition4", synthesisClassReportParameter.getExamId()).replace("conditionA", synthesisClassReportParameter.getClassName())
// .concat(" ").concat(fileName);
//
// fileToUrl.put(fileName.replace("/myworkSpace/Class/Basic/", ""), "/class/" + synthesisClassReportParameter.getExamId() + "/" + synthesisClassReportParameter.getProvince() + "/" + synthesisClassReportParameter.getSchool() + "/班级综合报告/" + synthesisClassReportParameter.getClassName() + "/" + fileName.replace("/myworkSpace/Class/Basic/", ""));
//
// synthesisClassReportParameter.setCommand(command);
//
// synthesisClassReportParameter.setPrefix("/myworkSpace/Class/Basic/");
//
// } else {
//
// String command = "node/myworkSpace/pdfOfClassBasicGen.js \"http://schoolreport.cssat.cn/pdf/classBasic?province=condition5&school=condition1&examId=condition4&region=非改革&branch=condition3&subjectType=常规&className=conditionA\" pdf ";
//
// String fileName = "/myworkSpace/Class/Basic/" + synthesisClassReportParameter.getRegion() + synthesisClassReportParameter.getProvince() + synthesisClassReportParameter.getSchool() + synthesisClassReportParameter.getClassName() + synthesisClassReportParameter.getExamId() + ".pdf";
//
// command = command.replace("condition1", synthesisClassReportParameter.getSchool()).replace("condition5", synthesisClassReportParameter.getProvince()).replace("condition3", synthesisClassReportParameter.getRegion()).replace("condition4", synthesisClassReportParameter.getExamId()).replace("conditionA", synthesisClassReportParameter.getClassName())
// .concat(" ").concat(fileName);
//
// fileToUrl.put(fileName.replace("/myworkSpace/Class/Basic/", ""), "/class/" + synthesisClassReportParameter.getExamId() + "/" + synthesisClassReportParameter.getProvince() + "/" + synthesisClassReportParameter.getSchool() + "/班级综合报告/" + synthesisClassReportParameter.getClassName() + "/" + fileName.replace("/myworkSpace/Class/Basic/", ""));
//
// synthesisClassReportParameter.setCommand(command);
//
// synthesisClassReportParameter.setPrefix("/myworkSpace/Class/Basic/");
//
// }
// }
//
//// for (String s : fileToUrl.keySet()) {
//// System.out.println("file="+s+"==mapto=="+"key="+fileToUrl.get(s));
//// }
//
// Map<String, List<BasicReportParameters>> schoolReport = synthesisSchoolReportParameters.stream().collect(Collectors.groupingBy(BasicReportParameters::getProvince));
//
// Map<String, List<BasicReportParameters>> schoolSubjectReport = synthesisSchoolSubjectReportParameters.stream().collect(Collectors.groupingBy(BasicReportParameters::getProvince));
//
// Map<String, List<ClassBasicReportParameters>> classReport = synthesisClassReportParameters.stream().collect(Collectors.groupingBy(ClassBasicReportParameters::getProvince));
//
// Map<String, List<ClassBasicReportParameters>> classSubjectReport = synthesisClassSubjectReportParameters.stream().collect(Collectors.groupingBy(ClassBasicReportParameters::getProvince));
//
//// 分组开始执行记录
// for (String key : schoolReport.keySet()) {
// logger.info("province:" + key + "Gen");
// List<BasicReportParameters> schoolBasicReport = schoolReport.get(key);
// List<BasicReportParameters> schoolSubject = schoolSubjectReport.get(key);
// List<ClassBasicReportParameters> classBasicReport = classReport.get(key);
// List<ClassBasicReportParameters> classSubject = classSubjectReport.get(key);
// for (BasicReportParameters schoolLevel : schoolBasicReport) {
// List<RetryCommand> retryCommands = new ArrayList<>();
// logger.info("school:" + schoolLevel.getSchool() + "loading");
// Map<String, List<BasicReportParameters>> schoolMap = schoolSubject.stream().collect(Collectors.groupingBy(BasicReportParameters::getSchool));
// Map<String, List<ClassBasicReportParameters>> classBasic = classBasicReport.stream().collect(Collectors.groupingBy(ClassBasicReportParameters::getSchool));
// final Map<String, List<ClassBasicReportParameters>> subjectClass = classSubject.stream().collect(Collectors.groupingBy(ClassBasicReportParameters::getSchool));
// List<BasicReportParameters> schoolSelf = schoolMap.get(schoolLevel.getSchool());
// logger.info("basicReport:loading");
// logger.info("exitCode:" + schoolLevel.getSchool());
//// ProcessBuilder processBuilder = new ProcessBuilder();
//// processBuilder.command("bash", "-c", schoolLevel.getCommand());
//// processBuilder.redirectErrorStream(true); // 合并标准输出和错误输出
//// Process process = null;
//// try {
//// process = processBuilder.start();
//// } catch (IOException e) {
//// throw new RuntimeException(e);
//// }
//// BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
//// String line;
//// while (true) {
//// try {
//// if (!((line = reader.readLine()) != null)) break;
//// } catch (IOException e) {
//// throw new RuntimeException(e);
//// }
//// }
////// while ((line = reader.readLine()) != null) {
////// // 如果输出了 "DONE",表示生成完毕
////// if ("DONE".equals(line)) {
////// break; // 跳出循环
////// }
////// }
//// try {
//// int exitCode = process.waitFor();
//// } catch (InterruptedException e) {
//// throw new RuntimeException(e);
//// }
// //上传文件
//// File basicFile = new File("/myworkSpace/basic/");
//// File[] basicFiles = basicFile.listFiles();
//// assert basicFiles != null;
//// for (File file : basicFiles) {
//// PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, fileToUrl.get(file.getName()), file);
//// try {
//// PutObjectResult putObjectResult = cosClient.putObject(putObjectRequest);
//// logger.info(putObjectResult.getRequestId());
//// file.delete();
//// } catch (CosServiceException e) {
//// logger.info("cos服务出现问题");
//// e.printStackTrace();
//// } catch (CosClientException e) {
//// logger.info("cos客户端出现问题"+file.getName()+"文件上传有误,重新上传");
//// RetryCommand retryCommand = new RetryCommand();
//// retryCommand.setRetryCommand(schoolLevel.getCommand());
//// retryCommand.setParams(schoolLevel);
//// retryCommands.add(retryCommand);
//// e.printStackTrace();
//// }
//// }
// for (BasicReportParameters parameters : schoolSelf) {
// logger.info("subjectReport:loading");
//
//// String subSubject = parameters.getSubSubject();
//// if (!subSubject.equals("生物") && !subSubject.equals("历史")) {
//// continue;
//// }
// logger.info("exitCode:" + parameters.getSubSubject());
//// ProcessBuilder processBuilderSubject = new ProcessBuilder();
//// processBuilderSubject.command("bash", "-c", parameters.getCommand());
//// processBuilderSubject.redirectErrorStream(true); // 合并标准输出和错误输出
//// Process processSubject = null;
//// try {
//// processSubject = processBuilderSubject.start();
//// } catch (IOException e) {
//// throw new RuntimeException(e);
//// }
// try {
// int exitCode = process.waitFor();
// } catch (InterruptedException e) {
// throw new RuntimeException(e);
//// BufferedReader readerSubject = new BufferedReader(new InputStreamReader(processSubject.getInputStream()));
//// String lineSubject;
//// while (true) {
//// try {
//// if (!((lineSubject = readerSubject.readLine()) != null)) break;
//// } catch (IOException e) {
//// throw new RuntimeException(e);
//// }
//// }
////// while ((lineSubject = readerSubject.readLine()) != null) {
////// // 如果输出了 "DONE",表示生成完毕
////// if ("DONE".equals(lineSubject)) {
////// break; // 跳出循环
////// }
////// }
//// try {
//// int exitCodeSubject = processSubject.waitFor();
//// } catch (InterruptedException e) {
//// throw new RuntimeException(e);
//// }
//// File subjectFile = new File("/myworkSpace/subject/");
//// File[] subjectFiles = subjectFile.listFiles();
//// assert subjectFiles != null;
//// for (File file : subjectFiles) {
//// PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, fileToUrl.get(file.getName()), file);
//// try {
//// PutObjectResult putObjectResult = cosClient.putObject(putObjectRequest);
//// logger.info(putObjectResult.getRequestId());
//// file.delete();
//// } catch (CosServiceException e) {
//// logger.info("cos服务出现问题");
//// e.printStackTrace();
//// } catch (CosClientException e) {
//// logger.info("cos客户端出现问题"+file.getName()+"文件上传有误,重新上传");
//// RetryCommand retryCommand = new RetryCommand();
//// retryCommand.setParams(parameters);
//// retryCommand.setRetryCommand(parameters.getCommand());
//// retryCommands.add(retryCommand);
//// e.printStackTrace();
//// }
//// }
// }
//上传文件
// File basicFile = new File("/myworkSpace/basic/");
// File[] basicFiles = basicFile.listFiles();
// assert basicFiles != null;
// for (File file : basicFiles) {
// PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, fileToUrl.get(file.getName()), file);
// try {
// PutObjectResult putObjectResult = cosClient.putObject(putObjectRequest);
// logger.info(putObjectResult.getRequestId());
// file.delete();
// } catch (CosServiceException e) {
// logger.info("cos服务出现问题");
// e.printStackTrace();
// } catch (CosClientException e) {
// logger.info("cos客户端出现问题"+file.getName()+"文件上传有误,重新上传");
// RetryCommand retryCommand = new RetryCommand();
// retryCommand.setRetryCommand(schoolLevel.getCommand());
// retryCommand.setParams(schoolLevel);
// retryCommands.add(retryCommand);
// e.printStackTrace();
// }
// }
for (BasicReportParameters parameters : schoolSelf) {
logger.info("subjectReport:loading");
// String subSubject = parameters.getSubSubject();
// if (!subSubject.equals("生物") && !subSubject.equals("历史")) {
// continue;
// }
logger.info("exitCode:" + parameters.getSubSubject());
// ProcessBuilder processBuilderSubject = new ProcessBuilder();
// processBuilderSubject.command("bash", "-c", parameters.getCommand());
// processBuilderSubject.redirectErrorStream(true); // 合并标准输出和错误输出
// Process processSubject = null;
// List<ClassBasicReportParameters> args = classBasic.get(schoolLevel.getSchool());
// List<ClassBasicReportParameters> params = subjectClass.get(schoolLevel.getSchool());
// for (ClassBasicReportParameters arg : args) {
// logger.info("classBasic:loading");
// logger.info("exitCode:" + arg.getClassName());
// ProcessBuilder processBuilderClass = new ProcessBuilder();
// processBuilderClass.command("bash", "-c", arg.getCommand());
// processBuilderClass.redirectErrorStream(true); // 合并标准输出和错误输出
// Process processClass = null;
// try {
// processSubject = processBuilderSubject.start();
// processClass = processBuilderClass.start();
// } catch (IOException e) {
// throw new RuntimeException(e);
// }
// BufferedReader readerSubject = new BufferedReader(new InputStreamReader(processSubject.getInputStream()));
// String lineSubject;
// BufferedReader readerClass = new BufferedReader(new InputStreamReader(processClass.getInputStream()));
// String lineClass;
// while (true) {
// try {
// if (!((lineSubject = readerSubject.readLine()) != null)) break;
// if (!((lineClass = readerClass.readLine()) != null)) break;
// } catch (IOException e) {
// throw new RuntimeException(e);
// }
// }
//// while ((lineSubject = readerSubject.readLine()) != null) {
//// while ((lineClass = readerClass.readLine()) != null) {
//// // 如果输出了 "DONE",表示生成完毕
//// if ("DONE".equals(lineSubject)) {
//// if ("DONE".equals(lineClass)) {
//// break; // 跳出循环
//// }
//// }
// try {
// int exitCodeSubject = processSubject.waitFor();
// int exitCodeSubject = processClass.waitFor();
// } catch (InterruptedException e) {
// throw new RuntimeException(e);
// }
// File subjectFile = new File("/myworkSpace/subject/");
// File[] subjectFiles = subjectFile.listFiles();
// assert subjectFiles != null;
// for (File file : subjectFiles) {
// PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, fileToUrl.get(file.getName()), file);
// try {
// PutObjectResult putObjectResult = cosClient.putObject(putObjectRequest);
// logger.info(putObjectResult.getRequestId());
// file.delete();
// } catch (CosServiceException e) {
// logger.info("cos服务出现问题");
// e.printStackTrace();
// } catch (CosClientException e) {
// logger.info("cos客户端出现问题"+file.getName()+"文件上传有误,重新上传");
// RetryCommand retryCommand = new RetryCommand();
// retryCommand.setParams(parameters);
// retryCommand.setRetryCommand(parameters.getCommand());
// retryCommands.add(retryCommand);
// e.printStackTrace();
// }
// }
}
List<ClassBasicReportParameters> args = classBasic.get(schoolLevel.getSchool());
List<ClassBasicReportParameters> params = subjectClass.get(schoolLevel.getSchool());
for (ClassBasicReportParameters arg : args) {
logger.info("classBasic:loading");
logger.info("exitCode:" + arg.getClassName());
ProcessBuilder processBuilderClass = new ProcessBuilder();
processBuilderClass.command("bash", "-c", arg.getCommand());
processBuilderClass.redirectErrorStream(true); // 合并标准输出和错误输出
Process processClass = null;
try {
processClass = processBuilderClass.start();
} catch (IOException e) {
throw new RuntimeException(e);
}
BufferedReader readerClass = new BufferedReader(new InputStreamReader(processClass.getInputStream()));
String lineClass;
while (true) {
try {
if (!((lineClass = readerClass.readLine()) != null)) break;
} catch (IOException e) {
throw new RuntimeException(e);
}
}
// while ((lineClass = readerClass.readLine()) != null) {
// // 如果输出了 "DONE",表示生成完毕
// if ("DONE".equals(lineClass)) {
// break; // 跳出循环
// }
// }
try {
int exitCodeSubject = processClass.waitFor();
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
// File classBasicFile = new File("/myworkSpace/Class/Basic/");
// File[] classBasicFiles = classBasicFile.listFiles();
// assert classBasicFiles != null;
// for (File file : classBasicFiles) {
// PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, fileToUrl.get(file.getName()), file);
// try {
// PutObjectResult putObjectResult = cosClient.putObject(putObjectRequest);
// logger.info(putObjectResult.getRequestId());
// file.delete();
// } catch (CosServiceException e) {
// logger.info("cos服务出现问题");
// e.printStackTrace();
// } catch (CosClientException e) {
// logger.info("cos客户端出现问题"+file.getName()+"文件上传有误,重新上传");
// RetryCommand retryCommand = new RetryCommand();
// retryCommand.setParams(arg);
// retryCommand.setRetryCommand(arg.getCommand());
// retryCommands.add(retryCommand);
// e.printStackTrace();
// }
//// File classBasicFile = new File("/myworkSpace/Class/Basic/");
//// File[] classBasicFiles = classBasicFile.listFiles();
//// assert classBasicFiles != null;
//// for (File file : classBasicFiles) {
//// PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, fileToUrl.get(file.getName()), file);
//// try {
//// PutObjectResult putObjectResult = cosClient.putObject(putObjectRequest);
//// logger.info(putObjectResult.getRequestId());
//// file.delete();
//// } catch (CosServiceException e) {
//// logger.info("cos服务出现问题");
//// e.printStackTrace();
//// } catch (CosClientException e) {
//// logger.info("cos客户端出现问题"+file.getName()+"文件上传有误,重新上传");
//// RetryCommand retryCommand = new RetryCommand();
//// retryCommand.setParams(arg);
//// retryCommand.setRetryCommand(arg.getCommand());
//// retryCommands.add(retryCommand);
//// e.printStackTrace();
//// }
//// }
// final Map<String, List<ClassBasicReportParameters>> collect = params.stream().collect(Collectors.groupingBy(ClassBasicReportParameters::getClassName));
// List<ClassBasicReportParameters> list = collect.get(arg.getClassName());
// for (ClassBasicReportParameters classBasicReportParameters : list) {
//// String subSubject = classBasicReportParameters.getSubSubject();
//// if (!subSubject.equals("历史")) {
//// continue;
//// }
////
//// logger.info("classSubject:loading");
//// logger.info("exitCode:" + classBasicReportParameters.getSubSubject());
//// ProcessBuilder processBuilderClassSubject = new ProcessBuilder();
//// processBuilderClassSubject.command("bash", "-c", classBasicReportParameters.getCommand());
//// processBuilderClassSubject.redirectErrorStream(true); // 合并标准输出和错误输出
//// Process processClassSubject = null;
//// try {
//// processClassSubject = processBuilderClassSubject.start();
//// } catch (IOException e) {
//// throw new RuntimeException(e);
//// }
//// BufferedReader readerClassSubject = new BufferedReader(new InputStreamReader(processClassSubject.getInputStream()));
//// String lineClassSubject;
//// while (true) {
//// try {
//// if (!((lineClassSubject = readerClassSubject.readLine()) != null)) break;
//// } catch (IOException e) {
//// throw new RuntimeException(e);
//// }
//// }
////// while ((lineClassSubject = readerClassSubject.readLine()) != null) {
////// // 如果输出了 "DONE",表示生成完毕
////// if ("DONE".equals(lineClassSubject)) {
////// break; // 跳出循环
////// }
////// }
//// try {
//// int exitCodeSubjectClass = processClassSubject.waitFor();
//// } catch (InterruptedException e) {
//// throw new RuntimeException(e);
//// }
//// File classSubjectFile = new File("/myworkSpace/Class/subject/");
//// File[] classSubjectFiles = classSubjectFile.listFiles();
//// assert classSubjectFiles != null;
//// for (File file : classSubjectFiles) {
//// logger.info(file.getName()+"=file—>key="+fileToUrl.get(file.getName()));
//// PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, fileToUrl.get(file.getName()), file);
//// try {
//// PutObjectResult putObjectResult = cosClient.putObject(putObjectRequest);
//// logger.info(putObjectResult.getRequestId());
//// file.delete();
//// } catch (CosServiceException e) {
//// logger.info("cos服务出现问题");
//// e.printStackTrace();
//// } catch (CosClientException e) {
//// logger.info("cos客户端出现问题"+file.getName()+"文件上传有误,重新上传");
//// RetryCommand retryCommand = new RetryCommand();
//// retryCommand.setParams(classBasicReportParameters);
//// retryCommand.setRetryCommand(classBasicReportParameters.getCommand());
//// retryCommands.add(retryCommand);
//// e.printStackTrace();
//// }
//// }
// }
// }
//
// if (retryCommands.size() != 0) {
// logger.info("size" + retryCommands.size());
// for (RetryCommand retryCommand : retryCommands) {
// String command = retryCommand.getRetryCommand();
// Object arguments = retryCommand.getParams();
// String filePrefix = "";
// if (arguments instanceof BasicReportParameters) {
// BasicReportParameters parametersOne = (BasicReportParameters) arguments;
// filePrefix = parametersOne.getPrefix();
// }
final Map<String, List<ClassBasicReportParameters>> collect = params.stream().collect(Collectors.groupingBy(ClassBasicReportParameters::getClassName));
List<ClassBasicReportParameters> list = collect.get(arg.getClassName());
for (ClassBasicReportParameters classBasicReportParameters : list) {
// String subSubject = classBasicReportParameters.getSubSubject();
// if (!subSubject.equals("历史")) {
// continue;
// if (arguments instanceof ClassBasicReportParameters) {
// ClassBasicReportParameters parametersTwo = (ClassBasicReportParameters) arguments;
// filePrefix = parametersTwo.getPrefix();
// }
//
// logger.info("classSubject:loading");
// logger.info("exitCode:" + classBasicReportParameters.getSubSubject());
// logger.info("RetryCommand:ls");
// ProcessBuilder processBuilderClassSubject = new ProcessBuilder();
// processBuilderClassSubject.command("bash", "-c", classBasicReportParameters.getCommand());
// processBuilderClassSubject.command("bash", "-c", command);
// processBuilderClassSubject.redirectErrorStream(true); // 合并标准输出和错误输出
// Process processClassSubject = null;
// try {
......@@ -475,108 +545,38 @@ public class GeneratorAllTypePdfByProvinceController {
// } catch (InterruptedException e) {
// throw new RuntimeException(e);
// }
// File classSubjectFile = new File("/myworkSpace/Class/subject/");
// File[] classSubjectFiles = classSubjectFile.listFiles();
// assert classSubjectFiles != null;
// for (File file : classSubjectFiles) {
// logger.info(file.getName()+"=file—>key="+fileToUrl.get(file.getName()));
// PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, fileToUrl.get(file.getName()), file);
// try {
// PutObjectResult putObjectResult = cosClient.putObject(putObjectRequest);
// logger.info(putObjectResult.getRequestId());
// file.delete();
// } catch (CosServiceException e) {
// logger.info("cos服务出现问题");
// e.printStackTrace();
// } catch (CosClientException e) {
// logger.info("cos客户端出现问题"+file.getName()+"文件上传有误,重新上传");
// RetryCommand retryCommand = new RetryCommand();
// retryCommand.setParams(classBasicReportParameters);
// retryCommand.setRetryCommand(classBasicReportParameters.getCommand());
// retryCommands.add(retryCommand);
// e.printStackTrace();
// }
// }
}
}
if (retryCommands.size() != 0) {
logger.info("size" + retryCommands.size());
for (RetryCommand retryCommand : retryCommands) {
String command = retryCommand.getRetryCommand();
Object arguments = retryCommand.getParams();
String filePrefix = "";
if (arguments instanceof BasicReportParameters) {
BasicReportParameters parametersOne = (BasicReportParameters) arguments;
filePrefix = parametersOne.getPrefix();
}
if (arguments instanceof ClassBasicReportParameters) {
ClassBasicReportParameters parametersTwo = (ClassBasicReportParameters) arguments;
filePrefix = parametersTwo.getPrefix();
}
logger.info("RetryCommand:ls");
ProcessBuilder processBuilderClassSubject = new ProcessBuilder();
processBuilderClassSubject.command("bash", "-c", command);
processBuilderClassSubject.redirectErrorStream(true); // 合并标准输出和错误输出
Process processClassSubject = null;
try {
processClassSubject = processBuilderClassSubject.start();
} catch (IOException e) {
throw new RuntimeException(e);
}
BufferedReader readerClassSubject = new BufferedReader(new InputStreamReader(processClassSubject.getInputStream()));
String lineClassSubject;
while (true) {
try {
if (!((lineClassSubject = readerClassSubject.readLine()) != null)) break;
} catch (IOException e) {
throw new RuntimeException(e);
}
}
// while ((lineClassSubject = readerClassSubject.readLine()) != null) {
// // 如果输出了 "DONE",表示生成完毕
// if ("DONE".equals(lineClassSubject)) {
// break; // 跳出循环
// }
// }
try {
int exitCodeSubjectClass = processClassSubject.waitFor();
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
// File classSubjectFile = new File(filePrefix);
// File[] classSubjectFiles = classSubjectFile.listFiles();
// assert classSubjectFiles != null;
// for (File file : classSubjectFiles) {
// logger.info(file.getName()+"=file—>key="+fileToUrl.get(file.getName()));
// PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, fileToUrl.get(file.getName()), file);
// try {
// PutObjectResult putObjectResult = cosClient.putObject(putObjectRequest);
// logger.info(putObjectResult.getRequestId());
// file.delete();
// } catch (CosServiceException e) {
// logger.info("cos服务出现问题");
// e.printStackTrace();
// } catch (CosClientException e) {
// logger.info("cos客户端出现问题"+file.getName()+"文件上传有误,重新上传");
// }
// }
}
}
//插入数据
int rowsAffected = reportJdbcTemplate.update("UPDATE school_report_task_generate SET status = ? WHERE exam_id = ? AND region = ? AND province = ? AND school = ?", 1, schoolLevel.getExamId(), schoolLevel.getRegion(), schoolLevel.getProvince(), schoolLevel.getSchool());
logger.info("Rows affected:" + rowsAffected);
}
}
return ResponseEntity.ok("操作成功");
}
}
//// File classSubjectFile = new File(filePrefix);
//// File[] classSubjectFiles = classSubjectFile.listFiles();
//// assert classSubjectFiles != null;
//// for (File file : classSubjectFiles) {
//// logger.info(file.getName()+"=file—>key="+fileToUrl.get(file.getName()));
//// PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, fileToUrl.get(file.getName()), file);
//// try {
//// PutObjectResult putObjectResult = cosClient.putObject(putObjectRequest);
//// logger.info(putObjectResult.getRequestId());
//// file.delete();
//// } catch (CosServiceException e) {
//// logger.info("cos服务出现问题");
//// e.printStackTrace();
//// } catch (CosClientException e) {
//// logger.info("cos客户端出现问题"+file.getName()+"文件上传有误,重新上传");
//// }
//// }
//
// }
//
// }
//
// //插入数据
// int rowsAffected = reportJdbcTemplate.update("UPDATE school_report_task_generate SET status = ? WHERE exam_id = ? AND region = ? AND province = ? AND school = ?", 1, schoolLevel.getExamId(), schoolLevel.getRegion(), schoolLevel.getProvince(), schoolLevel.getSchool());
//
// logger.info("Rows affected:" + rowsAffected);
// }
// }
//
//
// return ResponseEntity.ok("操作成功");
//
// }
//
//}
......@@ -23,7 +23,7 @@ import java.util.stream.Collectors;
@RestController
@RequestMapping("/pdf321312")
@RequestMapping("/pdf")
public class GeneratorAllTypePdfByProvinceXxController {
private static final Logger logger = LoggerFactory.getLogger(GeneratorAllTypePdfByProvinceXxController.class);
......
......@@ -21,57 +21,54 @@ import java.util.stream.Collectors;
@SpringBootTest
public class ClassIncrement {
// province_ques_type_excellent
@Test
public void GeProvinceQuesTypeSituation(){
String sql = "select region1" +
" as region,province from base_province_subject_tda20251023_mix where subject_type = '常规' group by region1,province";
public void GeProvinceQuesTypeSituation() {
String suffix = "202512";
String sql = "select region1" +
" as region,province from base_province_subject_tda"+suffix+"_mix where subject_type = '常规' group by region1,province";
JdbcTemplate jdbcTemplate = MyDataSourceConfig.getReportJdbcTemplate();
List<Params> params = jdbcTemplate.query(sql,new Object[]{},new BeanPropertyRowMapper<>(Params.class));
List<Params> params = jdbcTemplate.query(sql, new Object[]{}, new BeanPropertyRowMapper<>(Params.class));
for (Params param : params) {
ProcessProvinceExcellentQuesTypeSituation(param.getProvince(),param.getRegion(),jdbcTemplate);
ProcessProvinceExcellentQuesTypeSituation(param.getProvince(), param.getRegion(), jdbcTemplate,suffix);
}
}
private void ProcessProvinceExcellentQuesTypeSituation(String province, String region, JdbcTemplate jdbcTemplate) {
private void ProcessProvinceExcellentQuesTypeSituation(String province, String region, JdbcTemplate jdbcTemplate, String suffix) {
String sql = "select\n" +
String sql = "select\n" +
"ques_type,\n" +
"stu_qt_score_rate,\n" +
"sub_subject,\n" +
"stu_id\n" +
"from\n" +
"base_student_ques_type_tda20251023_mix\n" +
"base_student_ques_type_tda"+suffix+"_mix\n" +
"where\n" +
"region1 = '"+region+"'\n" +
"AND province = '"+province+"'\n" +
"\t\t\tAND subject_type = '常规' \n" +
"\t\t\tAND exam_id = 'TDA20251023G12'\n";
List<DtoArgs> list = jdbcTemplate.query(sql,new Object[]{},new BeanPropertyRowMapper<>(DtoArgs.class));
"region1 = '" + region + "'\n" +
"AND province = '" + province + "'\n" +
"\t\t\tAND subject_type = '常规' \n";
List<DtoArgs> list = jdbcTemplate.query(sql, new Object[]{}, new BeanPropertyRowMapper<>(DtoArgs.class));
Map<String, List<DtoArgs>> collect = list.stream().collect(Collectors.groupingBy(DtoArgs::getSubSubject));
for(String subject : collect.keySet()){
for (String subject : collect.keySet()) {
String sql2 = "SELECT\n" +
"\tstu_id \n" +
"FROM\n" +
"\tbase_student_subject_tda20251023_mix \n" +
"\tbase_student_subject_tda"+suffix+"_mix \n" +
"WHERE\n" +
"\tstu_subject_score_rate_province_pct_rank >= ( 1-0.27 ) \n" +
"\tAND region1 = '"+region+"' \n" +
"\tAND province = '"+province+"' \n" +
"\tAND region1 = '" + region + "' \n" +
"\tAND province = '" + province + "' \n" +
"\tAND subject_type = '常规' \n" +
"\tAND exam_id = 'TDA20251023G12' \n" +
"\tAND sub_subject = '"+subject+"'";
"\tAND sub_subject = '" + subject + "'";
List<String> excellentIds = jdbcTemplate.queryForList(sql2,String.class);
List<String> excellentIds = jdbcTemplate.queryForList(sql2, String.class);
//单科
List<DtoArgs> quesTypeList = collect.get(subject);
List<DtoArgs> quesTypeList = collect.get(subject);
//本省优生 各种题型的得分率数据
List<DtoArgs> excellentStuList = quesTypeList.stream().filter(x->excellentIds.contains(x.getStuId())).collect(Collectors.toList());
List<DtoArgs> excellentStuList = quesTypeList.stream().filter(x -> excellentIds.contains(x.getStuId())).collect(Collectors.toList());
Map<String, List<DtoArgs>> excellentGroupByQuesType = excellentStuList.stream().collect(Collectors.groupingBy(DtoArgs::getQuesType));
......@@ -79,44 +76,46 @@ public class ClassIncrement {
//进行插入数据
List<DtoArgs> finalList = excellentGroupByQuesType.get(ques_type);
Double typeRateMean = finalList.stream().mapToDouble(DtoArgs::getStuQtScoreRate).sum();
Double resultMean = typeRateMean/finalList.size();
if(Double.isNaN(resultMean)||Double.isInfinite(resultMean)){
Double resultMean = typeRateMean / finalList.size();
if (Double.isNaN(resultMean) || Double.isInfinite(resultMean)) {
resultMean = 0.0;
}
System.out.println(resultMean);
HashMap params = new HashMap(){{
put("province",province);
put("subSubject",subject);
put("region",region);
put("quesType",ques_type);
HashMap params = new HashMap() {{
put("province", province);
put("subSubject", subject);
put("region", region);
put("quesType", ques_type);
}};
params.put("Mean",resultMean);
params.put("Mean", resultMean);
NamedParameterJdbcTemplate namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(jdbcTemplate);
namedParameterJdbcTemplate.update("insert into province_ques_type_excellent20251023(region,province,sub_subject,mean,ques_type) value (:region,:province,:subSubject,:Mean,:quesType)",new MapSqlParameterSource(params));
namedParameterJdbcTemplate.update("insert into province_ques_type_excellent"+suffix+"(region,province,sub_subject,mean,ques_type) value (:region,:province,:subSubject,:Mean,:quesType)", new MapSqlParameterSource(params));
}
}
}
// province_excellent_difficult
@Test
public void GeProvinceExcellentDifficultySituations(){
public void GeProvinceExcellentDifficultySituations() {
String suffix = "202512";
String sql = "select region1 as region,province from base_province_subject_tda20251023_mix where subject_type = '常规' group by region1,province";
String sql = "select region1 as region,province from base_province_subject_tda" + suffix + "_mix where subject_type = '常规' group by region1,province";
JdbcTemplate jdbcTemplate = MyDataSourceConfig.getReportJdbcTemplate();
List<Params> params = jdbcTemplate.query(sql,new Object[]{},new BeanPropertyRowMapper<>(Params.class));
List<Params> params = jdbcTemplate.query(sql, new Object[]{}, new BeanPropertyRowMapper<>(Params.class));
for (Params param : params) {
ProcessProvinceExcellentQuestTypeDifficultyLevel(param.getProvince(),param.getRegion(),jdbcTemplate);
ProcessProvinceExcellentQuestTypeDifficultyLevel(param.getProvince(), param.getRegion(), jdbcTemplate, suffix);
}
}
private void ProcessProvinceExcellentQuestTypeDifficultyLevel(String province, String region, JdbcTemplate jdbcTemplate) {
private void ProcessProvinceExcellentQuestTypeDifficultyLevel(String province, String region, JdbcTemplate jdbcTemplate, String suffix) {
String sql = "SELECT\n" +
String sql = "SELECT\n" +
"\ta.region1 as region,\n" +
"\ta.sub_subject,\n" +
"\ta.subject_type,\n" +
......@@ -127,12 +126,12 @@ public class ClassIncrement {
"\tb.`ques_max_score`,\n" +
"\tb.`stu_id`\n" +
"\tFROM\n" +
"\tbase_area_question_tda20251023_mix a\n" +
"\tleft join base_student_question_tda20251023_mix b on a.ques_no = b.ques_no and a.sub_subject = b.`sub_subject` and a.region1 = b.region1 and a.subject_type = b.subject_type\n" +
"\twhere a.subject_type = '常规' and a.region1 = '"+region+"' and b.province = '"+province+"'";
"\tbase_area_question_tda" + suffix + "_mix a\n" +
"\tleft join base_student_question_tda" + suffix + "_mix b on a.ques_no = b.ques_no and a.sub_subject = b.`sub_subject` and a.region1 = b.region1 and a.subject_type = b.subject_type\n" +
"\twhere a.subject_type = '常规' and a.region1 = '" + region + "' and b.province = '" + province + "'";
NamedParameterJdbcTemplate namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(jdbcTemplate);
System.out.println("emoj--->"+sql);
System.out.println("emoj--->" + sql);
List<DeFenLu> list = namedParameterJdbcTemplate.query(sql, new BeanPropertyRowMapper<>(DeFenLu.class));
//化学 --》list 物理 ----》list
......@@ -140,16 +139,16 @@ public class ClassIncrement {
for (String subject : collect.keySet()) {
String sql2 = "select stu_id from base_student_subject_tda20251023_mix where sub_subject = '"+subject+"' and region1 = '"+region+"' and province = '"+province +"' and stu_subject_score_rate_province_pct_rank >= 0.73 and subject_type = '常规'";
String sql2 = "select stu_id from base_student_subject_tda" + suffix + "_mix where sub_subject = '" + subject + "' and region1 = '" + region + "' and province = '" + province + "' and stu_subject_score_rate_province_pct_rank >= 0.73 and subject_type = '常规'";
List<String> excellentIds = namedParameterJdbcTemplate.queryForList(sql2,new HashMap<>(),String.class);
List<String> excellentIds = namedParameterJdbcTemplate.queryForList(sql2, new HashMap<>(), String.class);
System.out.println("处理"+subject+"学科");
System.out.println("处理" + subject + "学科");
List<DeFenLu> deFenLus = collect.get(subject);
//本省优生的难度情况
deFenLus = deFenLus.stream().filter(x->excellentIds.contains(x.getStuId())).collect(Collectors.toList());
deFenLus = deFenLus.stream().filter(x -> excellentIds.contains(x.getStuId())).collect(Collectors.toList());
List<DeFenLu> yi = new ArrayList<>();
List<DeFenLu> jiaoyi = new ArrayList<>();
......@@ -159,15 +158,15 @@ public class ClassIncrement {
//单个科目答题记录:记录体型难度情况
for (DeFenLu fenLus : deFenLus) {
if(fenLus.getRegionQuesStandardDifficulty()>=0&&fenLus.getRegionQuesStandardDifficulty()<5){
if (fenLus.getRegionQuesStandardDifficulty() >= 0 && fenLus.getRegionQuesStandardDifficulty() < 5) {
yi.add(fenLus);
}else if(fenLus.getRegionQuesStandardDifficulty()>=5&&fenLus.getRegionQuesStandardDifficulty()<10){
} else if (fenLus.getRegionQuesStandardDifficulty() >= 5 && fenLus.getRegionQuesStandardDifficulty() < 10) {
jiaoyi.add(fenLus);
}else if(fenLus.getRegionQuesStandardDifficulty()>=10&&fenLus.getRegionQuesStandardDifficulty()<15){
} else if (fenLus.getRegionQuesStandardDifficulty() >= 10 && fenLus.getRegionQuesStandardDifficulty() < 15) {
zhong.add(fenLus);
}else if(fenLus.getRegionQuesStandardDifficulty()>=15&&fenLus.getRegionQuesStandardDifficulty()<20){
} else if (fenLus.getRegionQuesStandardDifficulty() >= 15 && fenLus.getRegionQuesStandardDifficulty() < 20) {
jiaonan.add(fenLus);
}else if(fenLus.getRegionQuesStandardDifficulty()>=20&&fenLus.getRegionQuesStandardDifficulty()<=25){
} else if (fenLus.getRegionQuesStandardDifficulty() >= 20 && fenLus.getRegionQuesStandardDifficulty() <= 25) {
nan.add(fenLus);
}
}
......@@ -187,63 +186,61 @@ public class ClassIncrement {
double nanStuSum = nan.stream().mapToDouble(DeFenLu::getStuQuesScore).sum();
double nanSum = nan.stream().mapToDouble(DeFenLu::getQuesMaxScore).sum();
System.out.println(yiStuSum/yiSum);
double yiResult = (Double.isNaN(yiStuSum/yiSum)||Double.isInfinite(yiStuSum/yiSum))?0.0:(yiStuSum/yiSum);
System.out.println(jiaoyiStuSum/jiaoyiyiSum);
double jiaoyiResult = (Double.isNaN(jiaoyiStuSum/jiaoyiyiSum)||Double.isInfinite(jiaoyiStuSum/jiaoyiyiSum))?0.0:(jiaoyiStuSum/jiaoyiyiSum);
System.out.println(zhongStuSum/zhongSum);
double zhongResult = (Double.isNaN(zhongStuSum/zhongSum)||Double.isInfinite(zhongStuSum/zhongSum))?0.0:(zhongStuSum/zhongSum);
System.out.println(jiaonanStuSum/jiaonanSum);
double jiaonanResult = (Double.isNaN(jiaonanStuSum/jiaonanSum)||Double.isInfinite(jiaonanStuSum/jiaonanSum))?0.0:(jiaonanStuSum/jiaonanSum);
System.out.println(nanStuSum/nanSum);
double nanResult = (Double.isNaN(nanStuSum/nanSum)||Double.isInfinite(nanStuSum/nanSum))?0.0:(nanStuSum/nanSum);
HashMap paramsYi = new HashMap(){{
put("province",province);
put("subSubject",subject);
put("difficult","易");
put("region",region);
System.out.println(yiStuSum / yiSum);
double yiResult = (Double.isNaN(yiStuSum / yiSum) || Double.isInfinite(yiStuSum / yiSum)) ? 0.0 : (yiStuSum / yiSum);
System.out.println(jiaoyiStuSum / jiaoyiyiSum);
double jiaoyiResult = (Double.isNaN(jiaoyiStuSum / jiaoyiyiSum) || Double.isInfinite(jiaoyiStuSum / jiaoyiyiSum)) ? 0.0 : (jiaoyiStuSum / jiaoyiyiSum);
System.out.println(zhongStuSum / zhongSum);
double zhongResult = (Double.isNaN(zhongStuSum / zhongSum) || Double.isInfinite(zhongStuSum / zhongSum)) ? 0.0 : (zhongStuSum / zhongSum);
System.out.println(jiaonanStuSum / jiaonanSum);
double jiaonanResult = (Double.isNaN(jiaonanStuSum / jiaonanSum) || Double.isInfinite(jiaonanStuSum / jiaonanSum)) ? 0.0 : (jiaonanStuSum / jiaonanSum);
System.out.println(nanStuSum / nanSum);
double nanResult = (Double.isNaN(nanStuSum / nanSum) || Double.isInfinite(nanStuSum / nanSum)) ? 0.0 : (nanStuSum / nanSum);
HashMap paramsYi = new HashMap() {{
put("province", province);
put("subSubject", subject);
put("difficult", "易");
put("region", region);
put("scoreMean", yiResult);
}};
HashMap paramsJiaoYi = new HashMap(){{
put("province",province);
put("subSubject",subject);
put("difficult","较易");
put("region",region);
HashMap paramsJiaoYi = new HashMap() {{
put("province", province);
put("subSubject", subject);
put("difficult", "较易");
put("region", region);
put("scoreMean", jiaoyiResult);
}};
HashMap paramsZhong = new HashMap(){{
put("province",province);
put("subSubject",subject);
put("difficult","中");
put("region",region);
HashMap paramsZhong = new HashMap() {{
put("province", province);
put("subSubject", subject);
put("difficult", "中");
put("region", region);
put("scoreMean", zhongResult);
}};
HashMap paramsJiaoNan = new HashMap(){{
put("province",province);
put("subSubject",subject);
put("difficult","较难");
put("region",region);
HashMap paramsJiaoNan = new HashMap() {{
put("province", province);
put("subSubject", subject);
put("difficult", "较难");
put("region", region);
put("scoreMean", jiaonanResult);
}};
HashMap paramsNan= new HashMap(){{
put("province",province);
put("subSubject",subject);
put("difficult","难");
put("region",region);
HashMap paramsNan = new HashMap() {{
put("province", province);
put("subSubject", subject);
put("difficult", "难");
put("region", region);
put("scoreMean", nanResult);
}};
namedParameterJdbcTemplate.update("insert into province_excellent_difficult20251023(sub_subject,difficult,region,province,score_mean) value(:subSubject,:difficult,:region,:province,:scoreMean)",new MapSqlParameterSource(paramsYi));
namedParameterJdbcTemplate.update("insert into province_excellent_difficult20251023(sub_subject,difficult,region,province,score_mean) value(:subSubject,:difficult,:region,:province,:scoreMean)",new MapSqlParameterSource(paramsJiaoYi));
namedParameterJdbcTemplate.update("insert into province_excellent_difficult20251023(sub_subject,difficult,region,province,score_mean) value(:subSubject,:difficult,:region,:province,:scoreMean)",new MapSqlParameterSource(paramsZhong));
namedParameterJdbcTemplate.update("insert into province_excellent_difficult20251023(sub_subject,difficult,region,province,score_mean) value(:subSubject,:difficult,:region,:province,:scoreMean)",new MapSqlParameterSource(paramsJiaoNan));
namedParameterJdbcTemplate.update("insert into province_excellent_difficult20251023(sub_subject,difficult,region,province,score_mean) value(:subSubject,:difficult,:region,:province,:scoreMean)",new MapSqlParameterSource(paramsNan));
namedParameterJdbcTemplate.update("insert into province_excellent_difficult" + suffix + "(sub_subject,difficult,region,province,score_mean) value(:subSubject,:difficult,:region,:province,:scoreMean)", new MapSqlParameterSource(paramsYi));
namedParameterJdbcTemplate.update("insert into province_excellent_difficult" + suffix + "(sub_subject,difficult,region,province,score_mean) value(:subSubject,:difficult,:region,:province,:scoreMean)", new MapSqlParameterSource(paramsJiaoYi));
namedParameterJdbcTemplate.update("insert into province_excellent_difficult" + suffix + "(sub_subject,difficult,region,province,score_mean) value(:subSubject,:difficult,:region,:province,:scoreMean)", new MapSqlParameterSource(paramsZhong));
namedParameterJdbcTemplate.update("insert into province_excellent_difficult" + suffix + "(sub_subject,difficult,region,province,score_mean) value(:subSubject,:difficult,:region,:province,:scoreMean)", new MapSqlParameterSource(paramsJiaoNan));
namedParameterJdbcTemplate.update("insert into province_excellent_difficult" + suffix + "(sub_subject,difficult,region,province,score_mean) value(:subSubject,:difficult,:region,:province,:scoreMean)", new MapSqlParameterSource(paramsNan));
}
}
}
......@@ -14,74 +14,75 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@SpringBootTest
public class Garbge {
// knowledge_region_excellent
@Test
public void meanRegion(){
public void meanRegion() {
String suffix = "202512";
JdbcTemplate jdbcTemplate = MyDataSourceConfig.getReportJdbcTemplate();
NamedParameterJdbcTemplate namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(jdbcTemplate);
String sql = "select region1 from base_school_subject_tda20251023 where subject_type = '常规' group by region1";
String sql = "select region1 from base_school_subject_tda"+suffix+" where subject_type = '常规' group by region1";
List<String> regions = jdbcTemplate.queryForList(sql, String.class);
for (String region : regions) {
meanRegionTest(region,namedParameterJdbcTemplate);
meanRegionTest(region, namedParameterJdbcTemplate,suffix);
}
}
public void meanRegionTest(String region, NamedParameterJdbcTemplate reportJdbcTemplate){
public void meanRegionTest(String region, NamedParameterJdbcTemplate reportJdbcTemplate,String suffix) {
String sql = "select \n" +
"knowledge,\n" +
"stu_kn_score_rate,\n" +
"sub_subject,\n" +
"stu_id\n" +
"from\n" +
"base_student_knowledge_tda20251023\n" +
"base_student_knowledge_tda"+suffix+"\n" +
"where\n" +
"region1 = '"+region+"' and subject_type = '常规'";
"region1 = '" + region + "' and subject_type = '常规'";
List<DtoKn> list = reportJdbcTemplate.query(sql,new BeanPropertyRowMapper<>(DtoKn.class));
List<DtoKn> list = reportJdbcTemplate.query(sql, new BeanPropertyRowMapper<>(DtoKn.class));
Map<String, List<DtoKn>> collect = list.stream().collect(Collectors.groupingBy(DtoKn::getSubSubject));
for (String subject : collect.keySet()) {
List<DtoKn> subjectLis =collect.get(subject);
List<DtoKn> subjectLis = collect.get(subject);
String sql2 = "select \n" +
"stu_id\n" +
"from \n" +
"base_student_subject_tda20251023\n" +
"base_student_subject_tda"+suffix+"\n" +
"where\n" +
"sub_subject = '"+subject+"'\n" +
"sub_subject = '" + subject + "'\n" +
"and\n" +
"subject_type = '常规'\n" +
"and\n" +
"region1= '"+region+"'\n" +
"region1= '" + region + "'\n" +
"and \n" +
"stu_subject_score_rate_region_pct_rank >= 0.73";
List<String> ids = reportJdbcTemplate.queryForList(sql2,new HashMap<>(),String.class);
List<String> ids = reportJdbcTemplate.queryForList(sql2, new HashMap<>(), String.class);
List<DtoKn> collect1 = subjectLis.stream().filter(x -> ids.contains(x.getStuId())).collect(Collectors.toList());
Map<String, List<DtoKn>> collect2 = collect1.stream().collect(Collectors.groupingBy(DtoKn::getKnowledge));
for (String knowledge : collect2.keySet()) {
//优生知识点层级
List<DtoKn> dataList = collect2.get(knowledge);
Double sumRate = dataList.stream().mapToDouble(DtoKn::getStuKnScoreRate).sum();
Double resultRate = sumRate/dataList.size();
if(Double.isNaN(resultRate)||Double.isInfinite(resultRate)){
Double resultRate = sumRate / dataList.size();
if (Double.isNaN(resultRate) || Double.isInfinite(resultRate)) {
resultRate = 0.0;
}
HashMap paramsYi = new HashMap(){{
put("subSubject",subject);
put("knowledge",knowledge);
put("region",region);
HashMap paramsYi = new HashMap() {{
put("subSubject", subject);
put("knowledge", knowledge);
put("region", region);
}};
paramsYi.put("rate",resultRate);
paramsYi.put("rate", resultRate);
reportJdbcTemplate.update("insert into knowledge_region_excellent20251023(sub_subject,knowledge,region,rate) value (:subSubject,:knowledge,:region,:rate)",new MapSqlParameterSource(paramsYi));
reportJdbcTemplate.update("insert into knowledge_region_excellent"+suffix+"(sub_subject,knowledge,region,rate) value (:subSubject,:knowledge,:region,:rate)", new MapSqlParameterSource(paramsYi));
}
......
......@@ -18,18 +18,20 @@ import java.util.stream.Collectors;
@SpringBootTest
public class NumberTwo {
// knowledge_province_excellent
@Test
public void ProvinceExKnow(){
public void ProvinceExKnow() {
String suffix = "202512";
JdbcTemplate jdbcTemplate = MyDataSourceConfig.getReportJdbcTemplate();
NamedParameterJdbcTemplate namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(jdbcTemplate);
String sql = "select region1 as region,province from base_school_subject_tda20251023_mix where subject_type = '常规' group by region1,province";
List<Params> paramsList = namedParameterJdbcTemplate.query(sql,new BeanPropertyRowMapper<>(Params.class));
String sql = "select region1 as region,province from base_school_subject_tda" + suffix + "_mix where subject_type = '常规' group by region1,province";
List<Params> paramsList = namedParameterJdbcTemplate.query(sql, new BeanPropertyRowMapper<>(Params.class));
for (Params param : paramsList) {
provinceExe(param.getRegion(),param.getProvince(),namedParameterJdbcTemplate);
provinceExe(param.getRegion(), param.getProvince(), namedParameterJdbcTemplate, suffix);
}
}
public void provinceExe(String region,String province,NamedParameterJdbcTemplate reportTemplate){
public void provinceExe(String region, String province, NamedParameterJdbcTemplate reportTemplate, String suffix) {
String sql = "select \n" +
"knowledge,\n" +
......@@ -37,28 +39,27 @@ public class NumberTwo {
"sub_subject,\n" +
"stu_id\n" +
"from\n" +
"base_student_knowledge_tda20251023_mix\n" +
"base_student_knowledge_tda" + suffix + "_mix\n" +
"where\n" +
"region1 = '"+region+"' and subject_type = '常规' and province = '"+province+"'";
"region1 = '" + region + "' and subject_type = '常规' and province = '" + province + "'";
List<DtoKn> list = reportTemplate.query(sql,new HashMap<>(),new BeanPropertyRowMapper<>(DtoKn.class));
List<DtoKn> list = reportTemplate.query(sql, new HashMap<>(), new BeanPropertyRowMapper<>(DtoKn.class));
Map<String, List<DtoKn>> collect = list.stream().collect(Collectors.groupingBy(DtoKn::getSubSubject));
for (String subject : collect.keySet()) {
//单个科目
List<DtoKn> data = collect.get(subject);
String sql3 = "\t\t\t\tSELECT\n" +
List<DtoKn> data = collect.get(subject);
String sql3 = "\t\t\t\tSELECT\n" +
"\t\t\tstu_id \n" +
"\t\tFROM\n" +
"\t\t\tbase_student_subject_tda20251023_mix \n" +
"\t\t\tbase_student_subject_tda" + suffix + "_mix \n" +
"\t\tWHERE\n" +
"\t\t\tprovince = '"+province+"' \n" +
"\t\t\tAND region1 = '"+region+"' \n" +
"\t\t\tprovince = '" + province + "' \n" +
"\t\t\tAND region1 = '" + region + "' \n" +
"\t\t\tAND subject_type = '常规' \n" +
"\t\t\tAND exam_id = 'TDA20251023G12' \n" +
"\t\t\tAND sub_subject = '"+subject+"' \n" +
"\t\t\tAND sub_subject = '" + subject + "' \n" +
"\t\t\tAND stu_subject_score_rate_province_pct_rank >= (1-0.27) ";
List<String> ids = reportTemplate.queryForList(sql3,new HashMap<>(),String.class);
List<String> ids = reportTemplate.queryForList(sql3, new HashMap<>(), String.class);
List<DtoKn> collect1 = data.stream().filter(x -> ids.contains(x.getStuId())).collect(Collectors.toList());
......@@ -67,25 +68,24 @@ public class NumberTwo {
for (String knowledge : collect2.keySet()) {
List<DtoKn> goods = collect2.get(knowledge);
Double sumRate = goods.stream().mapToDouble(DtoKn::getStuKnScoreRate).sum();
Double result = sumRate/goods.size();
if(Double.isNaN(result)||Double.isInfinite(result)){
Double result = sumRate / goods.size();
if (Double.isNaN(result) || Double.isInfinite(result)) {
result = 0.0;
}
HashMap paramsYi = new HashMap(){{
put("subSubject",subject);
put("knowledge",knowledge);
put("region",region);
put("province",province);
HashMap paramsYi = new HashMap() {{
put("subSubject", subject);
put("knowledge", knowledge);
put("region", region);
put("province", province);
}};
paramsYi.put("rate",result);
paramsYi.put("rate", result);
reportTemplate.update("insert into knowledge_province_excellent20251023(sub_subject,knowledge,region,rate,province) value (:subSubject,:knowledge,:region,:rate,:province)",new MapSqlParameterSource(paramsYi));
reportTemplate.update("insert into knowledge_province_excellent" + suffix + "(sub_subject,knowledge,region,rate,province) value (:subSubject,:knowledge,:region,:rate,:province)", new MapSqlParameterSource(paramsYi));
}
}
}
}
......@@ -24,18 +24,21 @@ class PdfGeneratorApplicationTests {
}
// class_diffficult
@Test
public void TestInsertSchoolClass(){
public void TestInsertSchoolClass() {
JdbcTemplate reportJdbcTemplate = MyDataSourceConfig.getReportJdbcTemplate();
String suffix = "202512";
JdbcTemplate reportJdbcTemplate = MyDataSourceConfig.getReportJdbcTemplate();
String sql = "SELECT\n" +
"\tregion1 as region,\n" +
"\tschool,\n" +
"\tclass as className\n" +
"FROM\n" +
"\tbase_class_subject_tda20251023 \n" +
"WHERE\n" +
"\tbase_class_subject_tda" + suffix +
" WHERE\n" +
"\tsubject_type = '常规' \n" +
"GROUP BY\n" +
"\tschool,\n" +
......@@ -43,15 +46,15 @@ class PdfGeneratorApplicationTests {
"\tclass\n" +
"order by region1,school,class";
List<ClassDtoArgs> paramsList = reportJdbcTemplate.query(sql,new Object[]{},new BeanPropertyRowMapper<>(ClassDtoArgs.class));
List<ClassDtoArgs> paramsList = reportJdbcTemplate.query(sql, new Object[]{}, new BeanPropertyRowMapper<>(ClassDtoArgs.class));
for(ClassDtoArgs param : paramsList){
System.out.println("运行"+param.getSchool()+param.getClassName()+"难度解析");
TestInsertClassName(param.getSchool(), param.getRegion(), param.getClassName(), reportJdbcTemplate);
for (ClassDtoArgs param : paramsList) {
System.out.println("运行" + param.getSchool() + param.getClassName() + "难度解析");
TestInsertClassName(param.getSchool(), param.getRegion(), param.getClassName(), reportJdbcTemplate, suffix);
}
}
public void TestInsertClassName(String school,String region,String className,JdbcTemplate jdbcTemplate){
public void TestInsertClassName(String school, String region, String className, JdbcTemplate jdbcTemplate, String suffix) {
//学校的
String sql = "SELECT\n" +
"\ta.region1 as region, \n" +
......@@ -63,9 +66,9 @@ class PdfGeneratorApplicationTests {
"\tb.stu_ques_score,\n" +
"\tb.`ques_max_score`,b.stu_ques_score\n" +
"\tFROM\n" +
"\tbase_area_question_tda20251023 a\n" +
"\tleft join base_student_question_tda20251023 b on a.ques_no = b.ques_no and a.sub_subject = b.`sub_subject`\n" +"and a.region1 = b.region1 "+
"\twhere b.school = '"+school+"' and b.subject_type = '常规' and a.region1 = '"+region+"'"+"and class = '"+className+"'";
"\tbase_area_question_tda" + suffix + " a\n" +
"\tleft join base_student_question_tda" + suffix + " b on a.ques_no = b.ques_no and a.sub_subject = b.`sub_subject`\n" + "and a.region1 = b.region1 " +
"\twhere b.school = '" + school + "' and b.subject_type = '常规' and a.region1 = '" + region + "'" + "and class = '" + className + "'";
NamedParameterJdbcTemplate namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(jdbcTemplate);
......@@ -75,11 +78,10 @@ class PdfGeneratorApplicationTests {
Map<String, List<DeFenLu>> collect = list.stream().collect(Collectors.groupingBy(DeFenLu::getSubSubject));
//学科粒度
for (String subject : collect.keySet()) {
System.out.println("处理"+subject+"学科");
System.out.println("处理" + subject + "学科");
List<DeFenLu> deFenLus = collect.get(subject);
List<DeFenLu> yi = new ArrayList<>();
......@@ -90,15 +92,15 @@ class PdfGeneratorApplicationTests {
//单个科目答题记录:记录体型难度情况
for (DeFenLu fenLus : deFenLus) {
if(fenLus.getRegionQuesStandardDifficulty()>=0&&fenLus.getRegionQuesStandardDifficulty()<5){
if (fenLus.getRegionQuesStandardDifficulty() >= 0 && fenLus.getRegionQuesStandardDifficulty() < 5) {
yi.add(fenLus);
}else if(fenLus.getRegionQuesStandardDifficulty()>=5&&fenLus.getRegionQuesStandardDifficulty()<10){
} else if (fenLus.getRegionQuesStandardDifficulty() >= 5 && fenLus.getRegionQuesStandardDifficulty() < 10) {
jiaoyi.add(fenLus);
}else if(fenLus.getRegionQuesStandardDifficulty()>=10&&fenLus.getRegionQuesStandardDifficulty()<15){
} else if (fenLus.getRegionQuesStandardDifficulty() >= 10 && fenLus.getRegionQuesStandardDifficulty() < 15) {
zhong.add(fenLus);
}else if(fenLus.getRegionQuesStandardDifficulty()>=15&&fenLus.getRegionQuesStandardDifficulty()<20){
} else if (fenLus.getRegionQuesStandardDifficulty() >= 15 && fenLus.getRegionQuesStandardDifficulty() < 20) {
jiaonan.add(fenLus);
}else if(fenLus.getRegionQuesStandardDifficulty()>=20&&fenLus.getRegionQuesStandardDifficulty()<=25){
} else if (fenLus.getRegionQuesStandardDifficulty() >= 20 && fenLus.getRegionQuesStandardDifficulty() <= 25) {
nan.add(fenLus);
}
}
......@@ -119,81 +121,82 @@ class PdfGeneratorApplicationTests {
double nanSum = nan.stream().mapToDouble(DeFenLu::getQuesMaxScore).sum();
// System.out.println(yiStuSum/yiSum);
double yiResult = (Double.isNaN(yiStuSum/yiSum)||Double.isInfinite(yiStuSum/yiSum))?0.0:(yiStuSum/yiSum);
double yiResult = (Double.isNaN(yiStuSum / yiSum) || Double.isInfinite(yiStuSum / yiSum)) ? 0.0 : (yiStuSum / yiSum);
// System.out.println(jiaoyiStuSum/jiaoyiyiSum);
double jiaoyiResult = (Double.isNaN(jiaoyiStuSum/jiaoyiyiSum)||Double.isInfinite(jiaoyiStuSum/jiaoyiyiSum))?0.0:(jiaoyiStuSum/jiaoyiyiSum);
double jiaoyiResult = (Double.isNaN(jiaoyiStuSum / jiaoyiyiSum) || Double.isInfinite(jiaoyiStuSum / jiaoyiyiSum)) ? 0.0 : (jiaoyiStuSum / jiaoyiyiSum);
// System.out.println(zhongStuSum/zhongSum);
double zhongResult = (Double.isNaN(zhongStuSum/zhongSum)||Double.isInfinite(zhongStuSum/zhongSum))?0.0:(zhongStuSum/zhongSum);
double zhongResult = (Double.isNaN(zhongStuSum / zhongSum) || Double.isInfinite(zhongStuSum / zhongSum)) ? 0.0 : (zhongStuSum / zhongSum);
// System.out.println(jiaonanStuSum/jiaonanSum);
double jiaonanResult = (Double.isNaN(jiaonanStuSum/jiaonanSum)||Double.isInfinite(jiaonanStuSum/jiaonanSum))?0.0:(jiaonanStuSum/jiaonanSum);
double jiaonanResult = (Double.isNaN(jiaonanStuSum / jiaonanSum) || Double.isInfinite(jiaonanStuSum / jiaonanSum)) ? 0.0 : (jiaonanStuSum / jiaonanSum);
// System.out.println(nanStuSum/nanSum);
double nanResult = (Double.isNaN(nanStuSum/nanSum)||Double.isInfinite(nanStuSum/nanSum))?0.0:(nanStuSum/nanSum);
HashMap paramsYi = new HashMap(){{
put("class",className);
put("school",school);
put("subSubject",subject);
put("difficult","易");
put("region",region);
double nanResult = (Double.isNaN(nanStuSum / nanSum) || Double.isInfinite(nanStuSum / nanSum)) ? 0.0 : (nanStuSum / nanSum);
HashMap paramsYi = new HashMap() {{
put("class", className);
put("school", school);
put("subSubject", subject);
put("difficult", "易");
put("region", region);
put("scoreMean", yiResult);
}};
HashMap paramsJiaoYi = new HashMap(){{
put("class",className);
put("school",school);
put("subSubject",subject);
put("difficult","较易");
put("region",region);
HashMap paramsJiaoYi = new HashMap() {{
put("class", className);
put("school", school);
put("subSubject", subject);
put("difficult", "较易");
put("region", region);
put("scoreMean", jiaoyiResult);
}};
HashMap paramsZhong = new HashMap(){{
put("class",className);
put("school",school);
put("subSubject",subject);
put("difficult","中");
put("region",region);
HashMap paramsZhong = new HashMap() {{
put("class", className);
put("school", school);
put("subSubject", subject);
put("difficult", "中");
put("region", region);
put("scoreMean", zhongResult);
}};
HashMap paramsJiaoNan = new HashMap(){{
put("class",className);
put("school",school);
put("subSubject",subject);
put("difficult","较难");
put("region",region);
HashMap paramsJiaoNan = new HashMap() {{
put("class", className);
put("school", school);
put("subSubject", subject);
put("difficult", "较难");
put("region", region);
put("scoreMean", jiaonanResult);
}};
HashMap paramsNan= new HashMap(){{
put("class",className);
put("school",school);
put("subSubject",subject);
put("difficult","难");
put("region",region);
HashMap paramsNan = new HashMap() {{
put("class", className);
put("school", school);
put("subSubject", subject);
put("difficult", "难");
put("region", region);
put("scoreMean", nanResult);
}};
namedParameterJdbcTemplate.update("insert into class_diffficult20251023(class,school,sub_subject,difficult,region,score_mean) value(:class,:school,:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsYi));
namedParameterJdbcTemplate.update("insert into class_diffficult20251023(class,school,sub_subject,difficult,region,score_mean) value(:class,:school,:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsJiaoYi));
namedParameterJdbcTemplate.update("insert into class_diffficult20251023(class,school,sub_subject,difficult,region,score_mean) value(:class,:school,:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsZhong));
namedParameterJdbcTemplate.update("insert into class_diffficult20251023(class,school,sub_subject,difficult,region,score_mean) value(:class,:school,:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsJiaoNan));
namedParameterJdbcTemplate.update("insert into class_diffficult20251023(class,school,sub_subject,difficult,region,score_mean) value(:class,:school,:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsNan));
namedParameterJdbcTemplate.update("insert into class_diffficult" + suffix + "(class,school,sub_subject,difficult,region,score_mean) value(:class,:school,:subSubject,:difficult,:region,:scoreMean)", new MapSqlParameterSource(paramsYi));
namedParameterJdbcTemplate.update("insert into class_diffficult" + suffix + "(class,school,sub_subject,difficult,region,score_mean) value(:class,:school,:subSubject,:difficult,:region,:scoreMean)", new MapSqlParameterSource(paramsJiaoYi));
namedParameterJdbcTemplate.update("insert into class_diffficult" + suffix + "(class,school,sub_subject,difficult,region,score_mean) value(:class,:school,:subSubject,:difficult,:region,:scoreMean)", new MapSqlParameterSource(paramsZhong));
namedParameterJdbcTemplate.update("insert into class_diffficult" + suffix + "(class,school,sub_subject,difficult,region,score_mean) value(:class,:school,:subSubject,:difficult,:region,:scoreMean)", new MapSqlParameterSource(paramsJiaoNan));
namedParameterJdbcTemplate.update("insert into class_diffficult" + suffix + "(class,school,sub_subject,difficult,region,score_mean) value(:class,:school,:subSubject,:difficult,:region,:scoreMean)", new MapSqlParameterSource(paramsNan));
}
}
// school_diffficult
@Test
public void TestInsertSchool(){
public void TestInsertSchool() {
String suffix = "202512";
JdbcTemplate reportJdbcTemplate = MyDataSourceConfig.getReportJdbcTemplate();
String sql = "select school,region1 as region from base_school_subject_tda20251023 where subject_type = '常规' group by school,region1";
String sql = "select school,region1 as region from base_school_subject_tda" + suffix + " where subject_type = '常规' group by school,region1";
List<Dto> listParams = reportJdbcTemplate.query(sql,new Object[]{},new BeanPropertyRowMapper<>(Dto.class));
List<Dto> listParams = reportJdbcTemplate.query(sql, new Object[]{}, new BeanPropertyRowMapper<>(Dto.class));
for (Dto listParam : listParams) {
System.out.println("运行"+listParam.getSchool()+listParam.getRegion());
test(listParam.getSchool(), listParam.getRegion(),reportJdbcTemplate);
System.out.println("运行" + listParam.getSchool() + listParam.getRegion());
test(listParam.getSchool(), listParam.getRegion(), reportJdbcTemplate, suffix);
}
}
public void test(String school,String region,JdbcTemplate jdbcTemplate) {
public void test(String school, String region, JdbcTemplate jdbcTemplate, String suffix) {
//学校的
String sql = "SELECT\n" +
......@@ -206,9 +209,9 @@ class PdfGeneratorApplicationTests {
"\tb.stu_ques_score,\n" +
"\tb.`ques_max_score`\n" +
"\tFROM\n" +
"\tbase_area_question_tda20251023 a\n" +
"\tleft join base_student_question_tda20251023 b on a.ques_no = b.ques_no and a.sub_subject = b.`sub_subject`\n" +"and a.region1 = b.region1 "+
"\twhere b.school = '"+school+"' and b.subject_type = '常规' and a.region1 = '"+region+"'";
"\tbase_area_question_tda" + suffix + " a\n" +
"\tleft join base_student_question_tda" + suffix + " b on a.ques_no = b.ques_no and a.sub_subject = b.`sub_subject`\n" + "and a.region1 = b.region1 " +
"\twhere b.school = '" + school + "' and b.subject_type = '常规' and a.region1 = '" + region + "'";
NamedParameterJdbcTemplate namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(jdbcTemplate);
......@@ -220,40 +223,40 @@ class PdfGeneratorApplicationTests {
//学科粒度
for (String subject : collect.keySet()) {
System.out.println("处理"+subject+"学科");
System.out.println("处理" + subject + "学科");
List<DeFenLu> deFenLus = collect.get(subject);
List<DeFenLu> yi = new ArrayList<>();
List<DeFenLu> yi = new ArrayList<>();
List<DeFenLu> jiaoyi = new ArrayList<>();
List<DeFenLu> jiaoyi = new ArrayList<>();
List<DeFenLu> zhong = new ArrayList<>();
List<DeFenLu> zhong = new ArrayList<>();
List<DeFenLu> jiaonan = new ArrayList<>();
List<DeFenLu> jiaonan = new ArrayList<>();
List<DeFenLu> nan = new ArrayList<>();
List<DeFenLu> nan = new ArrayList<>();
//单个科目答题记录:记录体型难度情况
for (DeFenLu fenLus : deFenLus) {
if(fenLus.getRegionQuesStandardDifficulty()>=0&&fenLus.getRegionQuesStandardDifficulty()<5){
if (fenLus.getRegionQuesStandardDifficulty() >= 0 && fenLus.getRegionQuesStandardDifficulty() < 5) {
yi.add(fenLus);
}else if(fenLus.getRegionQuesStandardDifficulty()>=5&&fenLus.getRegionQuesStandardDifficulty()<10){
} else if (fenLus.getRegionQuesStandardDifficulty() >= 5 && fenLus.getRegionQuesStandardDifficulty() < 10) {
jiaoyi.add(fenLus);
}else if(fenLus.getRegionQuesStandardDifficulty()>=10&&fenLus.getRegionQuesStandardDifficulty()<15){
} else if (fenLus.getRegionQuesStandardDifficulty() >= 10 && fenLus.getRegionQuesStandardDifficulty() < 15) {
zhong.add(fenLus);
}else if(fenLus.getRegionQuesStandardDifficulty()>=15&&fenLus.getRegionQuesStandardDifficulty()<20){
} else if (fenLus.getRegionQuesStandardDifficulty() >= 15 && fenLus.getRegionQuesStandardDifficulty() < 20) {
jiaonan.add(fenLus);
}else if(fenLus.getRegionQuesStandardDifficulty()>=20&&fenLus.getRegionQuesStandardDifficulty()<=25){
} else if (fenLus.getRegionQuesStandardDifficulty() >= 20 && fenLus.getRegionQuesStandardDifficulty() <= 25) {
nan.add(fenLus);
......@@ -278,84 +281,86 @@ class PdfGeneratorApplicationTests {
double nanSum = nan.stream().mapToDouble(DeFenLu::getQuesMaxScore).sum();
// System.out.println(yiStuSum/yiSum);
double yiResult = (Double.isNaN(yiStuSum/yiSum)||Double.isInfinite(yiStuSum/yiSum))?0.0:(yiStuSum/yiSum);
double yiResult = (Double.isNaN(yiStuSum / yiSum) || Double.isInfinite(yiStuSum / yiSum)) ? 0.0 : (yiStuSum / yiSum);
// System.out.println(jiaoyiStuSum/jiaoyiyiSum);
double jiaoyiResult = (Double.isNaN(jiaoyiStuSum/jiaoyiyiSum)||Double.isInfinite(jiaoyiStuSum/jiaoyiyiSum))?0.0:(jiaoyiStuSum/jiaoyiyiSum);
double jiaoyiResult = (Double.isNaN(jiaoyiStuSum / jiaoyiyiSum) || Double.isInfinite(jiaoyiStuSum / jiaoyiyiSum)) ? 0.0 : (jiaoyiStuSum / jiaoyiyiSum);
// System.out.println(zhongStuSum/zhongSum);
double zhongResult = (Double.isNaN(zhongStuSum/zhongSum)||Double.isInfinite(zhongStuSum/zhongSum))?0.0:(zhongStuSum/zhongSum);
double zhongResult = (Double.isNaN(zhongStuSum / zhongSum) || Double.isInfinite(zhongStuSum / zhongSum)) ? 0.0 : (zhongStuSum / zhongSum);
// System.out.println(jiaonanStuSum/jiaonanSum);
double jiaonanResult = (Double.isNaN(jiaonanStuSum/jiaonanSum)||Double.isInfinite(jiaonanStuSum/jiaonanSum))?0.0:(jiaonanStuSum/jiaonanSum);
double jiaonanResult = (Double.isNaN(jiaonanStuSum / jiaonanSum) || Double.isInfinite(jiaonanStuSum / jiaonanSum)) ? 0.0 : (jiaonanStuSum / jiaonanSum);
// System.out.println(nanStuSum/nanSum);
double nanResult = (Double.isNaN(nanStuSum/nanSum)||Double.isInfinite(nanStuSum/nanSum))?0.0:(nanStuSum/nanSum);
double nanResult = (Double.isNaN(nanStuSum / nanSum) || Double.isInfinite(nanStuSum / nanSum)) ? 0.0 : (nanStuSum / nanSum);
HashMap paramsYi = new HashMap(){{
put("school",school);
put("subSubject",subject);
put("difficult","易");
put("region",region);
HashMap paramsYi = new HashMap() {{
put("school", school);
put("subSubject", subject);
put("difficult", "易");
put("region", region);
put("scoreMean", yiResult);
}};
HashMap paramsJiaoYi = new HashMap(){{
put("school",school);
put("subSubject",subject);
put("difficult","较易");
put("region",region);
HashMap paramsJiaoYi = new HashMap() {{
put("school", school);
put("subSubject", subject);
put("difficult", "较易");
put("region", region);
put("scoreMean", jiaoyiResult);
}};
HashMap paramsZhong = new HashMap(){{
put("school",school);
put("subSubject",subject);
put("difficult","中");
put("region",region);
HashMap paramsZhong = new HashMap() {{
put("school", school);
put("subSubject", subject);
put("difficult", "中");
put("region", region);
put("scoreMean", zhongResult);
}};
HashMap paramsJiaoNan = new HashMap(){{
put("school",school);
put("subSubject",subject);
put("difficult","较难");
put("region",region);
HashMap paramsJiaoNan = new HashMap() {{
put("school", school);
put("subSubject", subject);
put("difficult", "较难");
put("region", region);
put("scoreMean", jiaonanResult);
}};
HashMap paramsNan= new HashMap(){{
put("school",school);
put("subSubject",subject);
put("difficult","难");
put("region",region);
HashMap paramsNan = new HashMap() {{
put("school", school);
put("subSubject", subject);
put("difficult", "难");
put("region", region);
put("scoreMean", nanResult);
}};
namedParameterJdbcTemplate.update("insert into school_diffficult20251023(school,sub_subject,difficult,region,score_mean) value(:school,:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsYi));
namedParameterJdbcTemplate.update("insert into school_diffficult20251023(school,sub_subject,difficult,region,score_mean) value(:school,:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsJiaoYi));
namedParameterJdbcTemplate.update("insert into school_diffficult20251023(school,sub_subject,difficult,region,score_mean) value(:school,:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsZhong));
namedParameterJdbcTemplate.update("insert into school_diffficult20251023(school,sub_subject,difficult,region,score_mean) value(:school,:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsJiaoNan));
namedParameterJdbcTemplate.update("insert into school_diffficult20251023(school,sub_subject,difficult,region,score_mean) value(:school,:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsNan));
namedParameterJdbcTemplate.update("insert into school_diffficult" + suffix + "(school,sub_subject,difficult,region,score_mean) value(:school,:subSubject,:difficult,:region,:scoreMean)", new MapSqlParameterSource(paramsYi));
namedParameterJdbcTemplate.update("insert into school_diffficult" + suffix + "(school,sub_subject,difficult,region,score_mean) value(:school,:subSubject,:difficult,:region,:scoreMean)", new MapSqlParameterSource(paramsJiaoYi));
namedParameterJdbcTemplate.update("insert into school_diffficult" + suffix + "(school,sub_subject,difficult,region,score_mean) value(:school,:subSubject,:difficult,:region,:scoreMean)", new MapSqlParameterSource(paramsZhong));
namedParameterJdbcTemplate.update("insert into school_diffficult" + suffix + "(school,sub_subject,difficult,region,score_mean) value(:school,:subSubject,:difficult,:region,:scoreMean)", new MapSqlParameterSource(paramsJiaoNan));
namedParameterJdbcTemplate.update("insert into school_diffficult" + suffix + "(school,sub_subject,difficult,region,score_mean) value(:school,:subSubject,:difficult,:region,:scoreMean)", new MapSqlParameterSource(paramsNan));
}
// DeFenLu deFenLu = yi.get(0);
}
// region
// region_difficult
@Test
public void TestInsertRegion(){
public void TestInsertRegion() {
String suffix = "202512";
JdbcTemplate reportJdbcTemplate = MyDataSourceConfig.getReportJdbcTemplate();
String sql = "select region1 from base_school_subject_tda20251023 where subject_type = '常规' group by region1";
String sql = "select region1 from base_school_subject_tda" + suffix + " where subject_type = '常规' group by region1";
List<String> listParams = reportJdbcTemplate.queryForList(sql,String.class);
List<String> listParams = reportJdbcTemplate.queryForList(sql, String.class);
for (String region : listParams) {
System.out.println("运行"+region);
TestRegion(region,reportJdbcTemplate);
System.out.println("运行" + region);
TestRegion(region, reportJdbcTemplate, suffix);
}
}
public void TestRegion(String region,JdbcTemplate jdbcTemplate){
public void TestRegion(String region, JdbcTemplate jdbcTemplate, String suffix) {
String sql = "SELECT\n" +
......@@ -368,9 +373,9 @@ class PdfGeneratorApplicationTests {
"\tb.stu_ques_score,\n" +
"\tb.`ques_max_score`\n" +
"\tFROM\n" +
"\tbase_area_question_tda20251023 a\n" +
"\tleft join base_student_question_tda20251023 b on a.ques_no = b.ques_no and a.sub_subject = b.`sub_subject` and a.region1 = b.region1 and a.subject_type = b.subject_type\n" +
"\twhere a.subject_type = '常规' and a.region1 = '"+region+"'\n";
"\tbase_area_question_tda" + suffix + " a\n" +
"\tleft join base_student_question_tda" + suffix + " b on a.ques_no = b.ques_no and a.sub_subject = b.`sub_subject` and a.region1 = b.region1 and a.subject_type = b.subject_type\n" +
"\twhere a.subject_type = '常规' and a.region1 = '" + region + "'\n";
NamedParameterJdbcTemplate namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(jdbcTemplate);
......@@ -380,12 +385,10 @@ class PdfGeneratorApplicationTests {
Map<String, List<DeFenLu>> collect = list.stream().collect(Collectors.groupingBy(DeFenLu::getSubSubject));
//学科粒度
for (String subject : collect.keySet()) {
System.out.println("处理"+subject+"学科");
System.out.println("处理" + subject + "学科");
List<DeFenLu> deFenLus = collect.get(subject);
List<DeFenLu> yi = new ArrayList<>();
......@@ -396,15 +399,15 @@ class PdfGeneratorApplicationTests {
//单个科目答题记录:记录体型难度情况
for (DeFenLu fenLus : deFenLus) {
if(fenLus.getRegionQuesStandardDifficulty()>=0&&fenLus.getRegionQuesStandardDifficulty()<5){
if (fenLus.getRegionQuesStandardDifficulty() >= 0 && fenLus.getRegionQuesStandardDifficulty() < 5) {
yi.add(fenLus);
}else if(fenLus.getRegionQuesStandardDifficulty()>=5&&fenLus.getRegionQuesStandardDifficulty()<10){
} else if (fenLus.getRegionQuesStandardDifficulty() >= 5 && fenLus.getRegionQuesStandardDifficulty() < 10) {
jiaoyi.add(fenLus);
}else if(fenLus.getRegionQuesStandardDifficulty()>=10&&fenLus.getRegionQuesStandardDifficulty()<15){
} else if (fenLus.getRegionQuesStandardDifficulty() >= 10 && fenLus.getRegionQuesStandardDifficulty() < 15) {
zhong.add(fenLus);
}else if(fenLus.getRegionQuesStandardDifficulty()>=15&&fenLus.getRegionQuesStandardDifficulty()<20){
} else if (fenLus.getRegionQuesStandardDifficulty() >= 15 && fenLus.getRegionQuesStandardDifficulty() < 20) {
jiaonan.add(fenLus);
}else if(fenLus.getRegionQuesStandardDifficulty()>=20&&fenLus.getRegionQuesStandardDifficulty()<=25){
} else if (fenLus.getRegionQuesStandardDifficulty() >= 20 && fenLus.getRegionQuesStandardDifficulty() <= 25) {
nan.add(fenLus);
}
}
......@@ -424,71 +427,73 @@ class PdfGeneratorApplicationTests {
double nanStuSum = nan.stream().mapToDouble(DeFenLu::getStuQuesScore).sum();
double nanSum = nan.stream().mapToDouble(DeFenLu::getQuesMaxScore).sum();
System.out.println(yiStuSum/yiSum);
double yiResult = (Double.isNaN(yiStuSum/yiSum)||Double.isInfinite(yiStuSum/yiSum))?0.0:(yiStuSum/yiSum);
System.out.println(jiaoyiStuSum/jiaoyiyiSum);
double jiaoyiResult = (Double.isNaN(jiaoyiStuSum/jiaoyiyiSum)||Double.isInfinite(jiaoyiStuSum/jiaoyiyiSum))?0.0:(jiaoyiStuSum/jiaoyiyiSum);
System.out.println(zhongStuSum/zhongSum);
double zhongResult = (Double.isNaN(zhongStuSum/zhongSum)||Double.isInfinite(zhongStuSum/zhongSum))?0.0:(zhongStuSum/zhongSum);
System.out.println(jiaonanStuSum/jiaonanSum);
double jiaonanResult = (Double.isNaN(jiaonanStuSum/jiaonanSum)||Double.isInfinite(jiaonanStuSum/jiaonanSum))?0.0:(jiaonanStuSum/jiaonanSum);
System.out.println(nanStuSum/nanSum);
double nanResult = (Double.isNaN(nanStuSum/nanSum)||Double.isInfinite(nanStuSum/nanSum))?0.0:(nanStuSum/nanSum);
HashMap paramsYi = new HashMap(){{
put("subSubject",subject);
put("difficult","易");
put("region",region);
System.out.println(yiStuSum / yiSum);
double yiResult = (Double.isNaN(yiStuSum / yiSum) || Double.isInfinite(yiStuSum / yiSum)) ? 0.0 : (yiStuSum / yiSum);
System.out.println(jiaoyiStuSum / jiaoyiyiSum);
double jiaoyiResult = (Double.isNaN(jiaoyiStuSum / jiaoyiyiSum) || Double.isInfinite(jiaoyiStuSum / jiaoyiyiSum)) ? 0.0 : (jiaoyiStuSum / jiaoyiyiSum);
System.out.println(zhongStuSum / zhongSum);
double zhongResult = (Double.isNaN(zhongStuSum / zhongSum) || Double.isInfinite(zhongStuSum / zhongSum)) ? 0.0 : (zhongStuSum / zhongSum);
System.out.println(jiaonanStuSum / jiaonanSum);
double jiaonanResult = (Double.isNaN(jiaonanStuSum / jiaonanSum) || Double.isInfinite(jiaonanStuSum / jiaonanSum)) ? 0.0 : (jiaonanStuSum / jiaonanSum);
System.out.println(nanStuSum / nanSum);
double nanResult = (Double.isNaN(nanStuSum / nanSum) || Double.isInfinite(nanStuSum / nanSum)) ? 0.0 : (nanStuSum / nanSum);
HashMap paramsYi = new HashMap() {{
put("subSubject", subject);
put("difficult", "易");
put("region", region);
put("scoreMean", yiResult);
}};
HashMap paramsJiaoYi = new HashMap(){{
put("subSubject",subject);
put("difficult","较易");
put("region",region);
HashMap paramsJiaoYi = new HashMap() {{
put("subSubject", subject);
put("difficult", "较易");
put("region", region);
put("scoreMean", jiaoyiResult);
}};
HashMap paramsZhong = new HashMap(){{
put("subSubject",subject);
put("difficult","中");
put("region",region);
HashMap paramsZhong = new HashMap() {{
put("subSubject", subject);
put("difficult", "中");
put("region", region);
put("scoreMean", zhongResult);
}};
HashMap paramsJiaoNan = new HashMap(){{
put("subSubject",subject);
put("difficult","较难");
put("region",region);
HashMap paramsJiaoNan = new HashMap() {{
put("subSubject", subject);
put("difficult", "较难");
put("region", region);
put("scoreMean", jiaonanResult);
}};
HashMap paramsNan= new HashMap(){{
put("subSubject",subject);
put("difficult","难");
put("region",region);
HashMap paramsNan = new HashMap() {{
put("subSubject", subject);
put("difficult", "难");
put("region", region);
put("scoreMean", nanResult);
}};
namedParameterJdbcTemplate.update("insert into region_difficult20251023(sub_subject,difficult,region,score_mean) value(:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsYi));
namedParameterJdbcTemplate.update("insert into region_difficult20251023(sub_subject,difficult,region,score_mean) value(:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsJiaoYi));
namedParameterJdbcTemplate.update("insert into region_difficult20251023(sub_subject,difficult,region,score_mean) value(:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsZhong));
namedParameterJdbcTemplate.update("insert into region_difficult20251023(sub_subject,difficult,region,score_mean) value(:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsJiaoNan));
namedParameterJdbcTemplate.update("insert into region_difficult20251023(sub_subject,difficult,region,score_mean) value(:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsNan));
namedParameterJdbcTemplate.update("insert into region_difficult" + suffix + "(sub_subject,difficult,region,score_mean) value(:subSubject,:difficult,:region,:scoreMean)", new MapSqlParameterSource(paramsYi));
namedParameterJdbcTemplate.update("insert into region_difficult" + suffix + "(sub_subject,difficult,region,score_mean) value(:subSubject,:difficult,:region,:scoreMean)", new MapSqlParameterSource(paramsJiaoYi));
namedParameterJdbcTemplate.update("insert into region_difficult" + suffix + "(sub_subject,difficult,region,score_mean) value(:subSubject,:difficult,:region,:scoreMean)", new MapSqlParameterSource(paramsZhong));
namedParameterJdbcTemplate.update("insert into region_difficult" + suffix + "(sub_subject,difficult,region,score_mean) value(:subSubject,:difficult,:region,:scoreMean)", new MapSqlParameterSource(paramsJiaoNan));
namedParameterJdbcTemplate.update("insert into region_difficult" + suffix + "(sub_subject,difficult,region,score_mean) value(:subSubject,:difficult,:region,:scoreMean)", new MapSqlParameterSource(paramsNan));
}
}
// province
// province_difficult
@Test
public void TestProvinceInsert(){
public void TestProvinceInsert() {
String suffix = "202512";
JdbcTemplate reportJdbcTemplate = MyDataSourceConfig.getReportJdbcTemplate();
String sql = "select region1 as region ,province from base_school_subject_tda20251023_mix where subject_type = '常规' group by region1,province";
String sql = "select region1 as region ,province from base_school_subject_tda" + suffix + "_mix where subject_type = '常规' group by region1,province";
List<Params> paramsList = reportJdbcTemplate.query(sql,new Object[]{},new BeanPropertyRowMapper<>(Params.class));
List<Params> paramsList = reportJdbcTemplate.query(sql, new Object[]{}, new BeanPropertyRowMapper<>(Params.class));
for (Params param : paramsList) {
System.out.println("运行"+param.getProvince()+param.getRegion());
TestProvince(param.getProvince(),param.getRegion(),reportJdbcTemplate);
System.out.println("运行" + param.getProvince() + param.getRegion());
TestProvince(param.getProvince(), param.getRegion(), reportJdbcTemplate, suffix);
}
// TestProvince("江西省","改革",reportJdbcTemplate);
......@@ -496,11 +501,9 @@ class PdfGeneratorApplicationTests {
}
public void TestProvince(String province, String region, JdbcTemplate jdbcTemplate, String suffix) {
public void TestProvince(String province,String region,JdbcTemplate jdbcTemplate){
String sql = "SELECT\n" +
String sql = "SELECT\n" +
"\ta.region1 as region,\n" +
"\ta.sub_subject,\n" +
"\ta.subject_type,\n" +
......@@ -510,9 +513,9 @@ class PdfGeneratorApplicationTests {
"\tb.stu_ques_score,\n" +
"\tb.`ques_max_score`\n" +
"\tFROM\n" +
"\tbase_area_question_tda20251023_mix a\n" +
"\tleft join base_student_question_tda20251023_mix b on a.ques_no = b.ques_no and a.sub_subject = b.`sub_subject` and a.region1 = b.region1 and a.subject_type = b.subject_type\n" +
"\twhere a.subject_type = '常规' and a.region1 = '"+region+"' and b.province = '"+province+"'";
"\tbase_area_question_tda" + suffix + "_mix a\n" +
"\tleft join base_student_question_tda" + suffix + "_mix b on a.ques_no = b.ques_no and a.sub_subject = b.`sub_subject` and a.region1 = b.region1 and a.subject_type = b.subject_type\n" +
"\twhere a.subject_type = '常规' and a.region1 = '" + region + "' and b.province = '" + province + "'";
NamedParameterJdbcTemplate namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(jdbcTemplate);
......@@ -524,7 +527,7 @@ class PdfGeneratorApplicationTests {
//学科粒度
for (String subject : collect.keySet()) {
System.out.println("处理"+subject+"学科");
System.out.println("处理" + subject + "学科");
List<DeFenLu> deFenLus = collect.get(subject);
List<DeFenLu> yi = new ArrayList<>();
......@@ -535,15 +538,15 @@ class PdfGeneratorApplicationTests {
//单个科目答题记录:记录体型难度情况
for (DeFenLu fenLus : deFenLus) {
if(fenLus.getRegionQuesStandardDifficulty()>=0&&fenLus.getRegionQuesStandardDifficulty()<5){
if (fenLus.getRegionQuesStandardDifficulty() >= 0 && fenLus.getRegionQuesStandardDifficulty() < 5) {
yi.add(fenLus);
}else if(fenLus.getRegionQuesStandardDifficulty()>=5&&fenLus.getRegionQuesStandardDifficulty()<10){
} else if (fenLus.getRegionQuesStandardDifficulty() >= 5 && fenLus.getRegionQuesStandardDifficulty() < 10) {
jiaoyi.add(fenLus);
}else if(fenLus.getRegionQuesStandardDifficulty()>=10&&fenLus.getRegionQuesStandardDifficulty()<15){
} else if (fenLus.getRegionQuesStandardDifficulty() >= 10 && fenLus.getRegionQuesStandardDifficulty() < 15) {
zhong.add(fenLus);
}else if(fenLus.getRegionQuesStandardDifficulty()>=15&&fenLus.getRegionQuesStandardDifficulty()<20){
} else if (fenLus.getRegionQuesStandardDifficulty() >= 15 && fenLus.getRegionQuesStandardDifficulty() < 20) {
jiaonan.add(fenLus);
}else if(fenLus.getRegionQuesStandardDifficulty()>=20&&fenLus.getRegionQuesStandardDifficulty()<=25){
} else if (fenLus.getRegionQuesStandardDifficulty() >= 20 && fenLus.getRegionQuesStandardDifficulty() <= 25) {
nan.add(fenLus);
}
}
......@@ -563,80 +566,80 @@ class PdfGeneratorApplicationTests {
double nanStuSum = nan.stream().mapToDouble(DeFenLu::getStuQuesScore).sum();
double nanSum = nan.stream().mapToDouble(DeFenLu::getQuesMaxScore).sum();
System.out.println(yiStuSum/yiSum);
double yiResult = (Double.isNaN(yiStuSum/yiSum)||Double.isInfinite(yiStuSum/yiSum))?0.0:(yiStuSum/yiSum);
System.out.println(jiaoyiStuSum/jiaoyiyiSum);
double jiaoyiResult = (Double.isNaN(jiaoyiStuSum/jiaoyiyiSum)||Double.isInfinite(jiaoyiStuSum/jiaoyiyiSum))?0.0:(jiaoyiStuSum/jiaoyiyiSum);
System.out.println(zhongStuSum/zhongSum);
double zhongResult = (Double.isNaN(zhongStuSum/zhongSum)||Double.isInfinite(zhongStuSum/zhongSum))?0.0:(zhongStuSum/zhongSum);
System.out.println(jiaonanStuSum/jiaonanSum);
double jiaonanResult = (Double.isNaN(jiaonanStuSum/jiaonanSum)||Double.isInfinite(jiaonanStuSum/jiaonanSum))?0.0:(jiaonanStuSum/jiaonanSum);
System.out.println(nanStuSum/nanSum);
double nanResult = (Double.isNaN(nanStuSum/nanSum)||Double.isInfinite(nanStuSum/nanSum))?0.0:(nanStuSum/nanSum);
HashMap paramsYi = new HashMap(){{
put("province",province);
put("subSubject",subject);
put("difficult","易");
put("region",region);
System.out.println(yiStuSum / yiSum);
double yiResult = (Double.isNaN(yiStuSum / yiSum) || Double.isInfinite(yiStuSum / yiSum)) ? 0.0 : (yiStuSum / yiSum);
System.out.println(jiaoyiStuSum / jiaoyiyiSum);
double jiaoyiResult = (Double.isNaN(jiaoyiStuSum / jiaoyiyiSum) || Double.isInfinite(jiaoyiStuSum / jiaoyiyiSum)) ? 0.0 : (jiaoyiStuSum / jiaoyiyiSum);
System.out.println(zhongStuSum / zhongSum);
double zhongResult = (Double.isNaN(zhongStuSum / zhongSum) || Double.isInfinite(zhongStuSum / zhongSum)) ? 0.0 : (zhongStuSum / zhongSum);
System.out.println(jiaonanStuSum / jiaonanSum);
double jiaonanResult = (Double.isNaN(jiaonanStuSum / jiaonanSum) || Double.isInfinite(jiaonanStuSum / jiaonanSum)) ? 0.0 : (jiaonanStuSum / jiaonanSum);
System.out.println(nanStuSum / nanSum);
double nanResult = (Double.isNaN(nanStuSum / nanSum) || Double.isInfinite(nanStuSum / nanSum)) ? 0.0 : (nanStuSum / nanSum);
HashMap paramsYi = new HashMap() {{
put("province", province);
put("subSubject", subject);
put("difficult", "易");
put("region", region);
put("scoreMean", yiResult);
}};
HashMap paramsJiaoYi = new HashMap(){{
put("province",province);
put("subSubject",subject);
put("difficult","较易");
put("region",region);
HashMap paramsJiaoYi = new HashMap() {{
put("province", province);
put("subSubject", subject);
put("difficult", "较易");
put("region", region);
put("scoreMean", jiaoyiResult);
}};
HashMap paramsZhong = new HashMap(){{
put("province",province);
put("subSubject",subject);
put("difficult","中");
put("region",region);
HashMap paramsZhong = new HashMap() {{
put("province", province);
put("subSubject", subject);
put("difficult", "中");
put("region", region);
put("scoreMean", zhongResult);
}};
HashMap paramsJiaoNan = new HashMap(){{
put("province",province);
put("subSubject",subject);
put("difficult","较难");
put("region",region);
HashMap paramsJiaoNan = new HashMap() {{
put("province", province);
put("subSubject", subject);
put("difficult", "较难");
put("region", region);
put("scoreMean", jiaonanResult);
}};
HashMap paramsNan= new HashMap(){{
put("province",province);
put("subSubject",subject);
put("difficult","难");
put("region",region);
HashMap paramsNan = new HashMap() {{
put("province", province);
put("subSubject", subject);
put("difficult", "难");
put("region", region);
put("scoreMean", nanResult);
}};
namedParameterJdbcTemplate.update("insert into province_difficult20251023(province,sub_subject,difficult,region,score_mean) value(:province,:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsYi));
namedParameterJdbcTemplate.update("insert into province_difficult20251023(province,sub_subject,difficult,region,score_mean) value(:province,:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsJiaoYi));
namedParameterJdbcTemplate.update("insert into province_difficult20251023(province,sub_subject,difficult,region,score_mean) value(:province,:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsZhong));
namedParameterJdbcTemplate.update("insert into province_difficult20251023(province,sub_subject,difficult,region,score_mean) value(:province,:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsJiaoNan));
namedParameterJdbcTemplate.update("insert into province_difficult20251023(province,sub_subject,difficult,region,score_mean) value(:province,:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsNan));
namedParameterJdbcTemplate.update("insert into province_difficult" + suffix + "(province,sub_subject,difficult,region,score_mean) value(:province,:subSubject,:difficult,:region,:scoreMean)", new MapSqlParameterSource(paramsYi));
namedParameterJdbcTemplate.update("insert into province_difficult" + suffix + "(province,sub_subject,difficult,region,score_mean) value(:province,:subSubject,:difficult,:region,:scoreMean)", new MapSqlParameterSource(paramsJiaoYi));
namedParameterJdbcTemplate.update("insert into province_difficult" + suffix + "(province,sub_subject,difficult,region,score_mean) value(:province,:subSubject,:difficult,:region,:scoreMean)", new MapSqlParameterSource(paramsZhong));
namedParameterJdbcTemplate.update("insert into province_difficult" + suffix + "(province,sub_subject,difficult,region,score_mean) value(:province,:subSubject,:difficult,:region,:scoreMean)", new MapSqlParameterSource(paramsJiaoNan));
namedParameterJdbcTemplate.update("insert into province_difficult" + suffix + "(province,sub_subject,difficult,region,score_mean) value(:province,:subSubject,:difficult,:region,:scoreMean)", new MapSqlParameterSource(paramsNan));
}
}
// region_excellent
// region_excellent_difficult
@Test
public void excellentRegion(){
public void excellentRegion() {
String suffix = "202512";
JdbcTemplate jdbcTemplate = MyDataSourceConfig.getReportJdbcTemplate();
String sql = "select region1 from base_school_subject_tda20251023 where subject_type ='常规' group by region1";
String sql = "select region1 from base_school_subject_tda" + suffix + " where subject_type ='常规' group by region1";
List<String> regions = jdbcTemplate.queryForList(sql,new Object[]{},String.class);
List<String> regions = jdbcTemplate.queryForList(sql, new Object[]{}, String.class);
for (String region : regions) {
testExcellent(region,jdbcTemplate);
testExcellent(region, jdbcTemplate, suffix);
}
}
public void testExcellent(String region,JdbcTemplate jdbcTemplate){
public void testExcellent(String region, JdbcTemplate jdbcTemplate, String suffix) {
String sql = "SELECT\n" +
" a.region1,\n" +
......@@ -649,9 +652,9 @@ class PdfGeneratorApplicationTests {
" b.`ques_max_score`,\n" +
" b.`stu_id`\n" +
" FROM\n" +
" base_area_question_tda20251023 a\n" +
" left join base_student_question_tda20251023 b on a.ques_no = b.ques_no and a.sub_subject = b.`sub_subject` and a.region1 = b.region1 and a.subject_type = b.subject_type\n" +
" where a.subject_type = '常规' and a.region1 = '"+region+"'";
" base_area_question_tda" + suffix + " a\n" +
" left join base_student_question_tda" + suffix + " b on a.ques_no = b.ques_no and a.sub_subject = b.`sub_subject` and a.region1 = b.region1 and a.subject_type = b.subject_type\n" +
" where a.subject_type = '常规' and a.region1 = '" + region + "'";
NamedParameterJdbcTemplate namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(jdbcTemplate);
......@@ -662,22 +665,20 @@ class PdfGeneratorApplicationTests {
Map<String, List<DeFenLu>> collect = list.stream().collect(Collectors.groupingBy(DeFenLu::getSubSubject));
//学科粒度
for (String subject : collect.keySet()) {
//这个级别开始晒数据
String sql2 = "select stu_id from base_student_subject_tda20251023 where sub_subject = '"+subject+"' and region1 = '"+region+"' and stu_subject_score_rate_region_pct_rank >= 0.73 and subject_type = '常规'";
String sql2 = "select stu_id from base_student_subject_tda" + suffix + " where sub_subject = '" + subject + "' and region1 = '" + region + "' and stu_subject_score_rate_region_pct_rank >= 0.73 and subject_type = '常规'";
List<String> excellent = namedParameterJdbcTemplate.queryForList(sql2,new HashMap<>(),String.class);
List<String> excellent = namedParameterJdbcTemplate.queryForList(sql2, new HashMap<>(), String.class);
System.out.println("处理"+subject+"学科");
System.out.println("处理" + subject + "学科");
List<DeFenLu> deFenLus = collect.get(subject);
deFenLus = deFenLus.stream().filter(x->excellent.contains(x.getStuId())).collect(Collectors.toList());
deFenLus = deFenLus.stream().filter(x -> excellent.contains(x.getStuId())).collect(Collectors.toList());
List<DeFenLu> yi = new ArrayList<>();
List<DeFenLu> jiaoyi = new ArrayList<>();
......@@ -687,15 +688,15 @@ class PdfGeneratorApplicationTests {
//单个科目答题记录:记录体型难度情况
for (DeFenLu fenLus : deFenLus) {
if(fenLus.getRegionQuesStandardDifficulty()>=0&&fenLus.getRegionQuesStandardDifficulty()<5){
if (fenLus.getRegionQuesStandardDifficulty() >= 0 && fenLus.getRegionQuesStandardDifficulty() < 5) {
yi.add(fenLus);
}else if(fenLus.getRegionQuesStandardDifficulty()>=5&&fenLus.getRegionQuesStandardDifficulty()<10){
} else if (fenLus.getRegionQuesStandardDifficulty() >= 5 && fenLus.getRegionQuesStandardDifficulty() < 10) {
jiaoyi.add(fenLus);
}else if(fenLus.getRegionQuesStandardDifficulty()>=10&&fenLus.getRegionQuesStandardDifficulty()<15){
} else if (fenLus.getRegionQuesStandardDifficulty() >= 10 && fenLus.getRegionQuesStandardDifficulty() < 15) {
zhong.add(fenLus);
}else if(fenLus.getRegionQuesStandardDifficulty()>=15&&fenLus.getRegionQuesStandardDifficulty()<20){
} else if (fenLus.getRegionQuesStandardDifficulty() >= 15 && fenLus.getRegionQuesStandardDifficulty() < 20) {
jiaonan.add(fenLus);
}else if(fenLus.getRegionQuesStandardDifficulty()>=20&&fenLus.getRegionQuesStandardDifficulty()<=25){
} else if (fenLus.getRegionQuesStandardDifficulty() >= 20 && fenLus.getRegionQuesStandardDifficulty() <= 25) {
nan.add(fenLus);
}
}
......@@ -715,71 +716,73 @@ class PdfGeneratorApplicationTests {
double nanStuSum = nan.stream().mapToDouble(DeFenLu::getStuQuesScore).sum();
double nanSum = nan.stream().mapToDouble(DeFenLu::getQuesMaxScore).sum();
System.out.println(yiStuSum/yiSum);
double yiResult = (Double.isNaN(yiStuSum/yiSum)||Double.isInfinite(yiStuSum/yiSum))?0.0:(yiStuSum/yiSum);
System.out.println(jiaoyiStuSum/jiaoyiyiSum);
double jiaoyiResult = (Double.isNaN(jiaoyiStuSum/jiaoyiyiSum)||Double.isInfinite(jiaoyiStuSum/jiaoyiyiSum))?0.0:(jiaoyiStuSum/jiaoyiyiSum);
System.out.println(zhongStuSum/zhongSum);
double zhongResult = (Double.isNaN(zhongStuSum/zhongSum)||Double.isInfinite(zhongStuSum/zhongSum))?0.0:(zhongStuSum/zhongSum);
System.out.println(jiaonanStuSum/jiaonanSum);
double jiaonanResult = (Double.isNaN(jiaonanStuSum/jiaonanSum)||Double.isInfinite(jiaonanStuSum/jiaonanSum))?0.0:(jiaonanStuSum/jiaonanSum);
System.out.println(nanStuSum/nanSum);
double nanResult = (Double.isNaN(nanStuSum/nanSum)||Double.isInfinite(nanStuSum/nanSum))?0.0:(nanStuSum/nanSum);
HashMap paramsYi = new HashMap(){{
put("subSubject",subject);
put("difficult","易");
put("region",region);
System.out.println(yiStuSum / yiSum);
double yiResult = (Double.isNaN(yiStuSum / yiSum) || Double.isInfinite(yiStuSum / yiSum)) ? 0.0 : (yiStuSum / yiSum);
System.out.println(jiaoyiStuSum / jiaoyiyiSum);
double jiaoyiResult = (Double.isNaN(jiaoyiStuSum / jiaoyiyiSum) || Double.isInfinite(jiaoyiStuSum / jiaoyiyiSum)) ? 0.0 : (jiaoyiStuSum / jiaoyiyiSum);
System.out.println(zhongStuSum / zhongSum);
double zhongResult = (Double.isNaN(zhongStuSum / zhongSum) || Double.isInfinite(zhongStuSum / zhongSum)) ? 0.0 : (zhongStuSum / zhongSum);
System.out.println(jiaonanStuSum / jiaonanSum);
double jiaonanResult = (Double.isNaN(jiaonanStuSum / jiaonanSum) || Double.isInfinite(jiaonanStuSum / jiaonanSum)) ? 0.0 : (jiaonanStuSum / jiaonanSum);
System.out.println(nanStuSum / nanSum);
double nanResult = (Double.isNaN(nanStuSum / nanSum) || Double.isInfinite(nanStuSum / nanSum)) ? 0.0 : (nanStuSum / nanSum);
HashMap paramsYi = new HashMap() {{
put("subSubject", subject);
put("difficult", "易");
put("region", region);
put("scoreMean", yiResult);
}};
HashMap paramsJiaoYi = new HashMap(){{
put("subSubject",subject);
put("difficult","较易");
put("region",region);
HashMap paramsJiaoYi = new HashMap() {{
put("subSubject", subject);
put("difficult", "较易");
put("region", region);
put("scoreMean", jiaoyiResult);
}};
HashMap paramsZhong = new HashMap(){{
put("subSubject",subject);
put("difficult","中");
put("region",region);
HashMap paramsZhong = new HashMap() {{
put("subSubject", subject);
put("difficult", "中");
put("region", region);
put("scoreMean", zhongResult);
}};
HashMap paramsJiaoNan = new HashMap(){{
put("subSubject",subject);
put("difficult","较难");
put("region",region);
HashMap paramsJiaoNan = new HashMap() {{
put("subSubject", subject);
put("difficult", "较难");
put("region", region);
put("scoreMean", jiaonanResult);
}};
HashMap paramsNan= new HashMap(){{
put("subSubject",subject);
put("difficult","难");
put("region",region);
HashMap paramsNan = new HashMap() {{
put("subSubject", subject);
put("difficult", "难");
put("region", region);
put("scoreMean", nanResult);
}};
namedParameterJdbcTemplate.update("insert into region_excellent_difficult20251023(sub_subject,difficult,region,score_mean) value(:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsYi));
namedParameterJdbcTemplate.update("insert into region_excellent_difficult20251023(sub_subject,difficult,region,score_mean) value(:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsJiaoYi));
namedParameterJdbcTemplate.update("insert into region_excellent_difficult20251023(sub_subject,difficult,region,score_mean) value(:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsZhong));
namedParameterJdbcTemplate.update("insert into region_excellent_difficult20251023(sub_subject,difficult,region,score_mean) value(:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsJiaoNan));
namedParameterJdbcTemplate.update("insert into region_excellent_difficult20251023(sub_subject,difficult,region,score_mean) value(:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsNan));
namedParameterJdbcTemplate.update("insert into region_excellent_difficult" + suffix + "(sub_subject,difficult,region,score_mean) value(:subSubject,:difficult,:region,:scoreMean)", new MapSqlParameterSource(paramsYi));
namedParameterJdbcTemplate.update("insert into region_excellent_difficult" + suffix + "(sub_subject,difficult,region,score_mean) value(:subSubject,:difficult,:region,:scoreMean)", new MapSqlParameterSource(paramsJiaoYi));
namedParameterJdbcTemplate.update("insert into region_excellent_difficult" + suffix + "(sub_subject,difficult,region,score_mean) value(:subSubject,:difficult,:region,:scoreMean)", new MapSqlParameterSource(paramsZhong));
namedParameterJdbcTemplate.update("insert into region_excellent_difficult" + suffix + "(sub_subject,difficult,region,score_mean) value(:subSubject,:difficult,:region,:scoreMean)", new MapSqlParameterSource(paramsJiaoNan));
namedParameterJdbcTemplate.update("insert into region_excellent_difficult" + suffix + "(sub_subject,difficult,region,score_mean) value(:subSubject,:difficult,:region,:scoreMean)", new MapSqlParameterSource(paramsNan));
}
}
// province_excellent_asw_time
@Test
public void ExcellentAswTimeProvince(){
public void ExcellentAswTimeProvince() {
String sql = "select region1 as region,province from base_province_subject_tda20251023_mix where subject_type = '常规' group by region1,province";
String suffix = "202512";
String sql = "select region1 as region,province from base_province_subject_tda" + suffix + "_mix where subject_type = '常规' group by region1,province";
JdbcTemplate jdbcTemplate = MyDataSourceConfig.getReportJdbcTemplate();
List<Params> params = jdbcTemplate.query(sql,new Object[]{},new BeanPropertyRowMapper<>(Params.class));
List<Params> params = jdbcTemplate.query(sql, new Object[]{}, new BeanPropertyRowMapper<>(Params.class));
for (Params param : params) {
ExcellentAswTime(param.getProvince(),param.getRegion(),jdbcTemplate);
ExcellentAswTime(param.getProvince(), param.getRegion(), jdbcTemplate, suffix);
}
}
public void ExcellentAswTime(String province,String region,JdbcTemplate jdbcTemplate){
public void ExcellentAswTime(String province, String region, JdbcTemplate jdbcTemplate, String suffix) {
String sql = "select\n" +
"ques_no,\n" +
......@@ -787,76 +790,73 @@ class PdfGeneratorApplicationTests {
"stu_ques_asw_time,\n" +
"sub_subject\n" +
"from \n" +
"base_student_question_log_time_tda20251023_mix\n" +
"base_student_question_log_time_tda" + suffix + "_mix\n" +
"where\n" +
"region1 = '"+region+"'\n" +
"and \n" +
"province = '"+province+"'\n" +
"region1 = '" + region + "'\n" +
"and \n" +
"subject_type='常规'\n" +
"province = '" + province + "'\n" +
"and \n" +
"exam_id = 'TDA20251023G12'\n" ;
"subject_type='常规'";
NamedParameterJdbcTemplate namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(jdbcTemplate);
List<DtoAsw> listDtoAsw = jdbcTemplate.query(sql,new Object[]{},new BeanPropertyRowMapper<>(DtoAsw.class));
List<DtoAsw> listDtoAsw = jdbcTemplate.query(sql, new Object[]{}, new BeanPropertyRowMapper<>(DtoAsw.class));
Map<String,List<DtoAsw>> collect = listDtoAsw.stream().collect(Collectors.groupingBy(DtoAsw::getSubSubject));
Map<String, List<DtoAsw>> collect = listDtoAsw.stream().collect(Collectors.groupingBy(DtoAsw::getSubSubject));
//科目粒度
for (String subject : collect.keySet()) {
System.out.println("operator"+subject+"科目");
String sql2 = "select stu_id from base_student_subject_tda20251023_mix where " +
"region1 = '"+region+"'\n" +
System.out.println("operator" + subject + "科目");
String sql2 = "select stu_id from base_student_subject_tda" + suffix + "_mix where " +
"region1 = '" + region + "'\n" +
"and \n" +
"sub_subject = '"+subject+"'\n" +
"sub_subject = '" + subject + "'\n" +
"and \n" +
"province = '"+province+"' \n" +
"province = '" + province + "' \n" +
"and \n" +
"subject_type= '常规'\n" +
"and \n" +
"exam_id = 'TDA20251023G12'\n" +
"and \n" +
"stu_subject_score_rate_province_pct_rank >= (1-0.27)";
List<String> excellent = jdbcTemplate.queryForList(sql2,String.class);
List<String> excellent = jdbcTemplate.queryForList(sql2, String.class);
List<DtoAsw> list = collect.get(subject);
List<DtoAsw> exCollect = list.stream().filter(x->excellent.contains(x.getStuId())).collect(Collectors.toList());
List<DtoAsw> exCollect = list.stream().filter(x -> excellent.contains(x.getStuId())).collect(Collectors.toList());
Map<String, List<DtoAsw>> collect1 = exCollect.stream().collect(Collectors.groupingBy(DtoAsw::getQuesNo));
for (String ques_no : collect1.keySet()) {
System.out.println("计算题目编号:"+ques_no);
List<DtoAsw> aswList = collect1.get(ques_no);
Double sumTime = aswList.stream().mapToDouble(DtoAsw::getStuQuesAswTime).sum();
Double avgTime = sumTime/aswList.size();
System.out.println("计算题目编号:" + ques_no);
List<DtoAsw> aswList = collect1.get(ques_no);
Double sumTime = aswList.stream().mapToDouble(DtoAsw::getStuQuesAswTime).sum();
Double avgTime = sumTime / aswList.size();
System.out.println(avgTime);
HashMap params = new HashMap(){{
put("subSubject",subject);
put("province",province);
put("region",region);
put("quesNo",ques_no);
put("time",avgTime);
HashMap params = new HashMap() {{
put("subSubject", subject);
put("province", province);
put("region", region);
put("quesNo", ques_no);
put("time", avgTime);
}};
namedParameterJdbcTemplate.update("insert into province_excellent_asw_time20251023(sub_subject,province,region,ques_no,time) value (:subSubject,:province,:region,:quesNo,:time)",new MapSqlParameterSource(params));
namedParameterJdbcTemplate.update("insert into province_excellent_asw_time" + suffix + "(sub_subject,province,region,ques_no,time) value (:subSubject,:province,:region,:quesNo,:time)", new MapSqlParameterSource(params));
}
}
}
// region_excellent_asw_time
// region_excellent_asw_time
@Test
public void ExcellentRegionAswTime(){
String sql = "select region1 from base_province_subject_tda20251023 where subject_type = '常规' group by region1\n";
JdbcTemplate reportJdbcTemplate = MyDataSourceConfig.getReportJdbcTemplate();
List<String> regions = reportJdbcTemplate.queryForList(sql,String.class);
public void ExcellentRegionAswTime() {
String suffix = "202512";
String sql = "select region1 from base_province_subject_tda"+suffix+" where subject_type = '常规' group by region1\n";
JdbcTemplate reportJdbcTemplate = MyDataSourceConfig.getReportJdbcTemplate();
List<String> regions = reportJdbcTemplate.queryForList(sql, String.class);
for (String region : regions) {
ExcellentRegionAsw(region,reportJdbcTemplate);
ExcellentRegionAsw(region, reportJdbcTemplate,suffix);
}
// ExcellentRegionAsw("",reportJdbcTemplate);
}
public void ExcellentRegionAsw(String region,JdbcTemplate jdbcTemplate){
public void ExcellentRegionAsw(String region, JdbcTemplate jdbcTemplate, String suffix) {
String sql = "select\n" +
"ques_no,\n" +
......@@ -864,46 +864,42 @@ class PdfGeneratorApplicationTests {
"stu_id,\n" +
"stu_ques_asw_time\n" +
"from \n" +
"base_student_question_log_time_tda20251023\n" +
"base_student_question_log_time_tda"+suffix+"\n" +
"where\n" +
"region1 = '"+region+"'\n" +
"and \n" +
"subject_type= '常规'\n" +
"region1 = '" + region + "'\n" +
"and \n" +
"exam_id = 'TDA20251023G12'\n";
"subject_type= '常规'\n";
NamedParameterJdbcTemplate namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(jdbcTemplate);
List<DtoAsw> list = jdbcTemplate.query(sql,new Object[]{},new BeanPropertyRowMapper<>(DtoAsw.class));
List<DtoAsw> list = jdbcTemplate.query(sql, new Object[]{}, new BeanPropertyRowMapper<>(DtoAsw.class));
Map<String, List<DtoAsw>> collect = list.stream().collect(Collectors.groupingBy(DtoAsw::getSubSubject));
for (String subject : collect.keySet()) {
String sql2 = "select stu_id from base_student_subject_tda20251023 where " +
"region1 = '"+region+"'\n" +
String sql2 = "select stu_id from base_student_subject_tda"+suffix+" where " +
"region1 = '" + region + "'\n" +
"and \n" +
"sub_subject = '"+subject+"'\n" +
"sub_subject = '" + subject + "'\n" +
"and \n" +
"subject_type= '常规'\n" +
"and \n" +
"exam_id = 'TDA20251023G12'\n" +
"and \n" +
"stu_subject_score_rate_region_pct_rank >= (1-0.27)";
List<String> yousheng = jdbcTemplate.queryForList(sql2,String.class);
List<String> yousheng = jdbcTemplate.queryForList(sql2, String.class);
List<DtoAsw> col = collect.get(subject);
List<DtoAsw> youshengList = col.stream().filter(x->yousheng.contains(x.getStuId())).collect(Collectors.toList());
List<DtoAsw> youshengList = col.stream().filter(x -> yousheng.contains(x.getStuId())).collect(Collectors.toList());
Map<String, List<DtoAsw>> collect1 = youshengList.stream().collect(Collectors.groupingBy(DtoAsw::getQuesNo));
for (String ques_no : collect1.keySet()) {
System.out.println("计算编号为:"+ques_no);
System.out.println("计算编号为:" + ques_no);
Double sumTime = collect1.get(ques_no).stream().mapToDouble(DtoAsw::getStuQuesAswTime).sum();
Double avgTime = sumTime/collect1.get(ques_no).size();
HashMap params = new HashMap(){{
put("subSubject",subject);
put("region",region);
put("quesNo",ques_no);
put("time",avgTime);
Double avgTime = sumTime / collect1.get(ques_no).size();
HashMap params = new HashMap() {{
put("subSubject", subject);
put("region", region);
put("quesNo", ques_no);
put("time", avgTime);
}};
namedParameterJdbcTemplate.update("insert into region_excellent_asw_time20251023(sub_subject,region,ques_no,time) value (:subSubject,:region,:quesNo,:time)",new MapSqlParameterSource(params));
namedParameterJdbcTemplate.update("insert into region_excellent_asw_time"+suffix+"(sub_subject,region,ques_no,time) value (:subSubject,:region,:quesNo,:time)", new MapSqlParameterSource(params));
}
}
......@@ -912,16 +908,17 @@ class PdfGeneratorApplicationTests {
// region_ques_type_excellent
@Test
public void testQuesType(){
String sql = "select region1 from base_province_subject_tda20251023 where subject_type = '常规' group by region1\n";
public void testQuesType() {
String suffix = "202512";
String sql = "select region1 from base_province_subject_tda"+suffix+" where subject_type = '常规' group by region1\n";
JdbcTemplate reportJdbcTemplate = MyDataSourceConfig.getReportJdbcTemplate();
List<String> regions = reportJdbcTemplate.queryForList(sql,String.class);
List<String> regions = reportJdbcTemplate.queryForList(sql, String.class);
for (String region : regions) {
testQuesTypeScoreMean(region,reportJdbcTemplate);
testQuesTypeScoreMean(region, reportJdbcTemplate,suffix);
}
}
public void testQuesTypeScoreMean(String region,JdbcTemplate jdbcTemplate){
public void testQuesTypeScoreMean(String region, JdbcTemplate jdbcTemplate, String suffix) {
String sql = "select\n" +
"ques_type,\n" +
......@@ -929,29 +926,27 @@ class PdfGeneratorApplicationTests {
"sub_subject,\n" +
"stu_id\n" +
"from\n" +
"base_student_ques_type_tda20251023\n" +
"base_student_ques_type_tda"+suffix+"\n" +
"where\n" +
"region1 = '"+region+"'\n" +
"\t\t\tAND subject_type = '常规' \n" +
"\t\t\tAND exam_id = 'TDA20251023G12'\n";
"region1 = '" + region + "'\n" +
"\t\t\tAND subject_type = '常规' \n";
List<DtoArgs> list = jdbcTemplate.query(sql,new Object[]{},new BeanPropertyRowMapper<>(DtoArgs.class));
List<DtoArgs> list = jdbcTemplate.query(sql, new Object[]{}, new BeanPropertyRowMapper<>(DtoArgs.class));
Map<String, List<DtoArgs>> collect = list.stream().collect(Collectors.groupingBy(DtoArgs::getSubSubject));
for (String subject : collect.keySet()) {
String sql2 = "SELECT\n" +
"\tstu_id \n" +
"FROM\n" +
"\tbase_student_subject_tda20251023 \n" +
"\tbase_student_subject_tda"+suffix+" \n" +
"WHERE\n" +
"\tstu_subject_score_rate_region_pct_rank >= ( 1-0.27 ) \n" +
"\tAND region1 = '"+region+"' \n" +
"\tAND region1 = '" + region + "' \n" +
"\tAND subject_type = '常规' \n" +
"\tAND exam_id = 'TDA20251023G12' \n" +
"\tAND sub_subject = '"+subject+"'";
"\tAND sub_subject = '" + subject + "'";
List<String> youshengIds = jdbcTemplate.queryForList(sql2, String.class);
//单科
List<DtoArgs> subejectList = collect.get(subject);
List<DtoArgs> subejectList = collect.get(subject);
List<DtoArgs> collect1 = subejectList.stream().filter(x -> youshengIds.contains(x.getStuId())).collect(Collectors.toList());
......@@ -962,21 +957,21 @@ class PdfGeneratorApplicationTests {
//进行插入数据
List<DtoArgs> finalList = collect2.get(ques_type);
Double typeRateMean = finalList.stream().mapToDouble(DtoArgs::getStuQtScoreRate).sum();
Double resultMean = typeRateMean/finalList.size();
if(Double.isNaN(resultMean)||Double.isInfinite(resultMean)){
Double resultMean = typeRateMean / finalList.size();
if (Double.isNaN(resultMean) || Double.isInfinite(resultMean)) {
resultMean = 0.0;
}
System.out.println(resultMean);
HashMap params = new HashMap(){{
put("subSubject",subject);
put("region",region);
put("quesType",ques_type);
HashMap params = new HashMap() {{
put("subSubject", subject);
put("region", region);
put("quesType", ques_type);
}};
params.put("Mean",resultMean);
params.put("Mean", resultMean);
NamedParameterJdbcTemplate namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(jdbcTemplate);
namedParameterJdbcTemplate.update("insert into region_ques_type_excellent20251023(region,sub_subject,mean,ques_type) value (:region,:subSubject,:Mean,:quesType)",new MapSqlParameterSource(params));
namedParameterJdbcTemplate.update("insert into region_ques_type_excellent"+suffix+"(region,sub_subject,mean,ques_type) value (:region,:subSubject,:Mean,:quesType)", new MapSqlParameterSource(params));
}
}
......
......@@ -14,7 +14,7 @@ public class GenerateSchool {
public void GenerateSchool() {
JdbcTemplate reportJdbcTemplate = MyDataSourceConfig.getReportJdbcTemplate();
String examId = "TDA20251023G12";
String examId = "TDA202512G12";
// String examId = "TDA20250918G11";
String suffix = examId.replace("TDA", "").replace("G2", "").replace("G3", "").replace("G11", "").replace("G12", "");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment