Commit bf72068b authored by ryzeycy's avatar ryzeycy

xx

parent 29d4f66b
......@@ -26,15 +26,38 @@ public class MyDataSourceConfig {
private static JdbcTemplate basicTemplate;
private static JdbcTemplate testTemplate;
@PostConstruct
private void init() {
initReport();
initMkReport();
// initCampCenter();
initBasic();
// initBasic();
initTest();
}
public static JdbcTemplate getTestJdbcTemplate(){
return testTemplate;
}
public DataSource initTest(){
System.err.println("print init reportSource...");
//外网
String url = "jdbc:mysql://192.168.0.14:3306/tda_20250918?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT%2B8";
DruidDataSource dataSource = getDataSource(url);
dataSource.setUsername("root");
dataSource.setPassword("Thussat@2023");
testTemplate = new JdbcTemplate(dataSource);
return dataSource;
}
public static JdbcTemplate getReportJdbcTemplate(){
return reportJdbcTemplate;
}
......
......@@ -23,7 +23,7 @@ import java.util.stream.Collectors;
@RestController
@RequestMapping("/")
@RequestMapping("/pdf")
public class GeneratorAllTypePdfByProvinceController {
private static final Logger logger = LoggerFactory.getLogger(GeneratorAllTypePdfByProvinceController.class);
......@@ -42,7 +42,7 @@ public class GeneratorAllTypePdfByProvinceController {
@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","").trim();
String suffix = examId.trim().replace("TDA","").replace("G3","").replace("G2","").replace("G11","").replace("G12","").trim();
String synthesisSchoolSubjectReportSql = "select \n" +
"school,exam_id,province,region1 as region,sub_subject\n" +
......@@ -272,7 +272,7 @@ public class GeneratorAllTypePdfByProvinceController {
logger.info("basicReport:loading");
logger.info("exitCode:"+schoolLevel.getSchool());
ProcessBuilder processBuilder = new ProcessBuilder();
processBuilder.command("bash", "-c", schoolLevel.getCommand());
processBuilder.command("cmd.exe", "-c", schoolLevel.getCommand());
processBuilder.redirectErrorStream(true); // 合并标准输出和错误输出
Process process = null;
try {
......@@ -326,7 +326,7 @@ public class GeneratorAllTypePdfByProvinceController {
logger.info("subjectReport:loading");
logger.info("exitCode:"+parameters.getSubSubject());
ProcessBuilder processBuilderSubject = new ProcessBuilder();
processBuilderSubject.command("bash", "-c", parameters.getCommand());
processBuilderSubject.command("cmd.exe", "-c", parameters.getCommand());
processBuilderSubject.redirectErrorStream(true); // 合并标准输出和错误输出
Process processSubject = null;
try {
......@@ -382,7 +382,7 @@ public class GeneratorAllTypePdfByProvinceController {
logger.info("classBasic:loading");
logger.info("exitCode:"+arg.getClassName());
ProcessBuilder processBuilderClass = new ProcessBuilder();
processBuilderClass.command("bash", "-c", arg.getCommand());
processBuilderClass.command("cmd.exe", "-c", arg.getCommand());
processBuilderClass.redirectErrorStream(true); // 合并标准输出和错误输出
Process processClass = null;
try {
......@@ -437,7 +437,7 @@ public class GeneratorAllTypePdfByProvinceController {
logger.info("classSubject:loading");
logger.info("exitCode:"+classBasicReportParameters.getSubSubject());
ProcessBuilder processBuilderClassSubject = new ProcessBuilder();
processBuilderClassSubject.command("bash", "-c", classBasicReportParameters.getCommand());
processBuilderClassSubject.command("cmd.exe", "-c", classBasicReportParameters.getCommand());
processBuilderClassSubject.redirectErrorStream(true); // 合并标准输出和错误输出
Process processClassSubject = null;
try {
......@@ -507,7 +507,7 @@ public class GeneratorAllTypePdfByProvinceController {
logger.info("RetryCommand:ls");
ProcessBuilder processBuilderClassSubject = new ProcessBuilder();
processBuilderClassSubject.command("bash", "-c", command);
processBuilderClassSubject.command("cmd.exe", "-c", command);
processBuilderClassSubject.redirectErrorStream(true); // 合并标准输出和错误输出
Process processClassSubject = null;
try {
......
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("/ycy")
public class GeneratorAllTypePdfByProvinceYcyController {
private static final Logger logger = LoggerFactory.getLogger(GeneratorAllTypePdfByProvinceYcyController.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("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));
// }
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("cmd.exe ", "/c", schoolLevel.getCommand());
processBuilder.redirectErrorStream(true); // 合并标准输出和错误输出
Process process = null;
try {
logger.info("command = {}", schoolLevel.getCommand());
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");
logger.info("exitCode:"+parameters.getSubSubject());
ProcessBuilder processBuilderSubject = new ProcessBuilder();
processBuilderSubject.command("cmd.exe ", "/c", parameters.getCommand());
processBuilderSubject.redirectErrorStream(true); // 合并标准输出和错误输出
Process processSubject = null;
try {
logger.info("command = {}", parameters.getCommand());
processSubject = processBuilderSubject.start();
} catch (IOException 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();
// }
// }
}
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("cmd.exe ", "/c", arg.getCommand());
processBuilderClass.redirectErrorStream(true); // 合并标准输出和错误输出
Process processClass = null;
try {
logger.info("command = {}", arg.getCommand());
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();
// }
// }
// final Map<String, List<ClassBasicReportParameters>> collect = params.stream().collect(Collectors.groupingBy(ClassBasicReportParameters::getClassName));
// List<ClassBasicReportParameters> list = collect.get(arg.getClassName());
// for (ClassBasicReportParameters classBasicReportParameters : list) {
// logger.info("classSubject:loading");
// logger.info("exitCode:"+classBasicReportParameters.getSubSubject());
// ProcessBuilder processBuilderClassSubject = new ProcessBuilder();
// processBuilderClassSubject.command("cmd.exe ", "/c", classBasicReportParameters.getCommand());
// processBuilderClassSubject.redirectErrorStream(true); // 合并标准输出和错误输出
// Process processClassSubject = null;
// try {
// logger.info("command = {}", classBasicReportParameters.getCommand());
// 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();
}
if (arguments instanceof ClassBasicReportParameters) {
ClassBasicReportParameters parametersTwo = (ClassBasicReportParameters) arguments;
filePrefix = parametersTwo.getPrefix();
}
logger.info("RetryCommand:ls");
ProcessBuilder processBuilderClassSubject = new ProcessBuilder();
processBuilderClassSubject.command("cmd.exe ", "/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("操作成功");
}
}
......@@ -3,7 +3,7 @@ server:
spring:
datasource:
url: jdbc:mysql://192.168.0.46:3306/temp_test?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT%2B8
url: jdbc:mysql://192.168.0.46:3306/tempnew?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT%2B8
username: jiru
password: Jiru@20231026
druid:
......@@ -12,7 +12,7 @@ spring:
min-idle: 5
max-wait: 6000
redis:
host: 192.168.0.4
host: 192.168.0.13
port: 6379
password: Thussat@2023
database: 101
......
......@@ -27,7 +27,7 @@ public class ClassIncrement {
public void GeProvinceQuesTypeSituation(){
String sql = "select region1" +
" as region,province from base_province_subject_tda20250227 where subject_type = '常规' group by region1,province";
" as region,province from base_province_subject_tda20250918 where subject_type = '常规' group by region1,province";
JdbcTemplate jdbcTemplate = MyDataSourceConfig.getReportJdbcTemplate();
List<Params> params = jdbcTemplate.query(sql,new Object[]{},new BeanPropertyRowMapper<>(Params.class));
for (Params param : params) {
......@@ -44,25 +44,25 @@ public class ClassIncrement {
"sub_subject,\n" +
"stu_id\n" +
"from\n" +
"base_student_ques_type_tda20250227\n" +
"base_student_ques_type_tda20250918\n" +
"where\n" +
"region1 = '"+region+"'\n" +
"AND province = '"+province+"'\n" +
"\t\t\tAND subject_type = '常规' \n" +
"\t\t\tAND exam_id = 'TDA20250227G3'\n";
"\t\t\tAND exam_id = 'TDA20250918G11'\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()){
String sql2 = "SELECT\n" +
"\tstu_id \n" +
"FROM\n" +
"\tbase_student_subject_tda20250227 \n" +
"\tbase_student_subject_tda20250918 \n" +
"WHERE\n" +
"\tstu_subject_score_rate_province_pct_rank >= ( 1-0.27 ) \n" +
"\tAND region1 = '"+region+"' \n" +
"\tAND province = '"+province+"' \n" +
"\tAND subject_type = '常规' \n" +
"\tAND exam_id = 'TDA20250227G3' \n" +
"\tAND exam_id = 'TDA20250918G11' \n" +
"\tAND sub_subject = '"+subject+"'";
List<String> excellentIds = jdbcTemplate.queryForList(sql2,String.class);
......@@ -94,7 +94,7 @@ public class ClassIncrement {
params.put("Mean",resultMean);
NamedParameterJdbcTemplate namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(jdbcTemplate);
namedParameterJdbcTemplate.update("insert into province_ques_type_excellent20250227(region,province,sub_subject,mean,ques_type) value (:region,:province,:subSubject,:Mean,:quesType)",new MapSqlParameterSource(params));
namedParameterJdbcTemplate.update("insert into province_ques_type_excellent20250918(region,province,sub_subject,mean,ques_type) value (:region,:province,:subSubject,:Mean,:quesType)",new MapSqlParameterSource(params));
}
}
......@@ -105,7 +105,7 @@ public class ClassIncrement {
@Test
public void GeProvinceExcellentDifficultySituations(){
String sql = "select region1 as region,province from base_province_subject_tda20250227 where subject_type = '常规' group by region1,province";
String sql = "select region1 as region,province from base_province_subject_tda20250918 where subject_type = '常规' group by region1,province";
JdbcTemplate jdbcTemplate = MyDataSourceConfig.getReportJdbcTemplate();
List<Params> params = jdbcTemplate.query(sql,new Object[]{},new BeanPropertyRowMapper<>(Params.class));
for (Params param : params) {
......@@ -127,8 +127,8 @@ public class ClassIncrement {
"\tb.`ques_max_score`,\n" +
"\tb.`stu_id`\n" +
"\tFROM\n" +
"\tbase_area_question_tda20250227 a\n" +
"\tleft join base_student_question_tda20250227 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" +
"\tbase_area_question_tda20250918 a\n" +
"\tleft join base_student_question_tda20250918 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);
......@@ -140,7 +140,7 @@ public class ClassIncrement {
for (String subject : collect.keySet()) {
String sql2 = "select stu_id from base_student_subject_tda20250227 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_tda20250918 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);
......@@ -233,11 +233,11 @@ public class ClassIncrement {
put("scoreMean", nanResult);
}};
namedParameterJdbcTemplate.update("insert into province_excellent_difficult20250227(sub_subject,difficult,region,province,score_mean) value(:subSubject,:difficult,:region,:province,:scoreMean)",new MapSqlParameterSource(paramsYi));
namedParameterJdbcTemplate.update("insert into province_excellent_difficult20250227(sub_subject,difficult,region,province,score_mean) value(:subSubject,:difficult,:region,:province,:scoreMean)",new MapSqlParameterSource(paramsJiaoYi));
namedParameterJdbcTemplate.update("insert into province_excellent_difficult20250227(sub_subject,difficult,region,province,score_mean) value(:subSubject,:difficult,:region,:province,:scoreMean)",new MapSqlParameterSource(paramsZhong));
namedParameterJdbcTemplate.update("insert into province_excellent_difficult20250227(sub_subject,difficult,region,province,score_mean) value(:subSubject,:difficult,:region,:province,:scoreMean)",new MapSqlParameterSource(paramsJiaoNan));
namedParameterJdbcTemplate.update("insert into province_excellent_difficult20250227(sub_subject,difficult,region,province,score_mean) value(:subSubject,:difficult,:region,:province,:scoreMean)",new MapSqlParameterSource(paramsNan));
namedParameterJdbcTemplate.update("insert into province_excellent_difficult20250918(sub_subject,difficult,region,province,score_mean) value(:subSubject,:difficult,:region,:province,:scoreMean)",new MapSqlParameterSource(paramsYi));
namedParameterJdbcTemplate.update("insert into province_excellent_difficult20250918(sub_subject,difficult,region,province,score_mean) value(:subSubject,:difficult,:region,:province,:scoreMean)",new MapSqlParameterSource(paramsJiaoYi));
namedParameterJdbcTemplate.update("insert into province_excellent_difficult20250918(sub_subject,difficult,region,province,score_mean) value(:subSubject,:difficult,:region,:province,:scoreMean)",new MapSqlParameterSource(paramsZhong));
namedParameterJdbcTemplate.update("insert into province_excellent_difficult20250918(sub_subject,difficult,region,province,score_mean) value(:subSubject,:difficult,:region,:province,:scoreMean)",new MapSqlParameterSource(paramsJiaoNan));
namedParameterJdbcTemplate.update("insert into province_excellent_difficult20250918(sub_subject,difficult,region,province,score_mean) value(:subSubject,:difficult,:region,:province,:scoreMean)",new MapSqlParameterSource(paramsNan));
}
......
......@@ -25,7 +25,7 @@ public class Garbge {
NamedParameterJdbcTemplate namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(jdbcTemplate);
String sql = "select region1 from base_school_subject_tda20250227 where subject_type = '常规' group by region1";
String sql = "select region1 from base_school_subject_tda20250918 where subject_type = '常规' group by region1";
List<String> regions = jdbcTemplate.queryForList(sql, String.class);
for (String region : regions) {
......@@ -41,7 +41,7 @@ public class Garbge {
"sub_subject,\n" +
"stu_id\n" +
"from\n" +
"base_student_knowledge_tda20250227\n" +
"base_student_knowledge_tda20250918\n" +
"where\n" +
"region1 = '"+region+"' and subject_type = '常规'";
......@@ -52,7 +52,7 @@ public class Garbge {
String sql2 = "select \n" +
"stu_id\n" +
"from \n" +
"base_student_subject_tda20250227\n" +
"base_student_subject_tda20250918\n" +
"where\n" +
"sub_subject = '"+subject+"'\n" +
"and\n" +
......@@ -81,7 +81,7 @@ public class Garbge {
paramsYi.put("rate",resultRate);
reportJdbcTemplate.update("insert into knowledge_region_excellent20250227(sub_subject,knowledge,region,rate) value (:subSubject,:knowledge,:region,:rate)",new MapSqlParameterSource(paramsYi));
reportJdbcTemplate.update("insert into knowledge_region_excellent20250918(sub_subject,knowledge,region,rate) value (:subSubject,:knowledge,:region,:rate)",new MapSqlParameterSource(paramsYi));
}
......
......@@ -28,7 +28,7 @@ public class GenerateTaskPool {
"\tschool,\n" +
"\t0 as status\n" +
"FROM\n" +
"\tbase_school_subject_tda20250227 \n" +
"\tbase_school_subject_tda20250918 \n" +
"GROUP BY\n" +
"\tregion1,\n" +
"\tprovince,\n" +
......
......@@ -22,7 +22,7 @@ public class NumberTwo {
public void ProvinceExKnow(){
JdbcTemplate jdbcTemplate = MyDataSourceConfig.getReportJdbcTemplate();
NamedParameterJdbcTemplate namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(jdbcTemplate);
String sql = "select region1 as region,province from base_school_subject_tda20250227 where subject_type = '常规' group by region1,province";
String sql = "select region1 as region,province from base_school_subject_tda20250918 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);
......@@ -37,7 +37,7 @@ public class NumberTwo {
"sub_subject,\n" +
"stu_id\n" +
"from\n" +
"base_student_knowledge_tda20250227\n" +
"base_student_knowledge_tda20250918\n" +
"where\n" +
"region1 = '"+region+"' and subject_type = '常规' and province = '"+province+"'";
......@@ -49,12 +49,12 @@ public class NumberTwo {
String sql3 = "\t\t\t\tSELECT\n" +
"\t\t\tstu_id \n" +
"\t\tFROM\n" +
"\t\t\tbase_student_subject_tda20250227 \n" +
"\t\t\tbase_student_subject_tda20250918 \n" +
"\t\tWHERE\n" +
"\t\t\tprovince = '"+province+"' \n" +
"\t\t\tAND region1 = '"+region+"' \n" +
"\t\t\tAND subject_type = '常规' \n" +
"\t\t\tAND exam_id = 'TDA20250227G3' \n" +
"\t\t\tAND exam_id = 'TDA20250918G11' \n" +
"\t\t\tAND sub_subject = '"+subject+"' \n" +
"\t\t\tAND stu_subject_score_rate_province_pct_rank >= (1-0.27) ";
......@@ -80,7 +80,7 @@ public class NumberTwo {
}};
paramsYi.put("rate",result);
reportTemplate.update("insert into knowledge_province_excellent20250227(sub_subject,knowledge,region,rate,province) value (:subSubject,:knowledge,:region,:rate,:province)",new MapSqlParameterSource(paramsYi));
reportTemplate.update("insert into knowledge_province_excellent20250918(sub_subject,knowledge,region,rate,province) value (:subSubject,:knowledge,:region,:rate,:province)",new MapSqlParameterSource(paramsYi));
}
}
......
......@@ -34,7 +34,7 @@ class PdfGeneratorApplicationTests {
"\tschool,\n" +
"\tclass as className\n" +
"FROM\n" +
"\tbase_class_subject_tda20250227 \n" +
"\tbase_class_subject_tda20250918 \n" +
"WHERE\n" +
"\tsubject_type = '常规' \n" +
"GROUP BY\n" +
......@@ -63,8 +63,8 @@ class PdfGeneratorApplicationTests {
"\tb.stu_ques_score,\n" +
"\tb.`ques_max_score`,b.stu_ques_score\n" +
"\tFROM\n" +
"\tbase_area_question_tda20250227 a\n" +
"\tleft join base_student_question_tda20250227 b on a.ques_no = b.ques_no and a.sub_subject = b.`sub_subject`\n" +"and a.region1 = b.region1 "+
"\tbase_area_question_tda20250918 a\n" +
"\tleft join base_student_question_tda20250918 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);
......@@ -168,11 +168,11 @@ class PdfGeneratorApplicationTests {
put("region",region);
put("scoreMean", nanResult);
}};
namedParameterJdbcTemplate.update("insert into class_diffficult20250227(class,school,sub_subject,difficult,region,score_mean) value(:class,:school,:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsYi));
namedParameterJdbcTemplate.update("insert into class_diffficult20250227(class,school,sub_subject,difficult,region,score_mean) value(:class,:school,:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsJiaoYi));
namedParameterJdbcTemplate.update("insert into class_diffficult20250227(class,school,sub_subject,difficult,region,score_mean) value(:class,:school,:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsZhong));
namedParameterJdbcTemplate.update("insert into class_diffficult20250227(class,school,sub_subject,difficult,region,score_mean) value(:class,:school,:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsJiaoNan));
namedParameterJdbcTemplate.update("insert into class_diffficult20250227(class,school,sub_subject,difficult,region,score_mean) value(:class,:school,:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsNan));
namedParameterJdbcTemplate.update("insert into class_diffficult20250918(class,school,sub_subject,difficult,region,score_mean) value(:class,:school,:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsYi));
namedParameterJdbcTemplate.update("insert into class_diffficult20250918(class,school,sub_subject,difficult,region,score_mean) value(:class,:school,:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsJiaoYi));
namedParameterJdbcTemplate.update("insert into class_diffficult20250918(class,school,sub_subject,difficult,region,score_mean) value(:class,:school,:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsZhong));
namedParameterJdbcTemplate.update("insert into class_diffficult20250918(class,school,sub_subject,difficult,region,score_mean) value(:class,:school,:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsJiaoNan));
namedParameterJdbcTemplate.update("insert into class_diffficult20250918(class,school,sub_subject,difficult,region,score_mean) value(:class,:school,:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsNan));
}
}
......@@ -181,7 +181,7 @@ class PdfGeneratorApplicationTests {
JdbcTemplate reportJdbcTemplate = MyDataSourceConfig.getReportJdbcTemplate();
String sql = "select school,region1 as region from base_school_subject_tda20250227 where subject_type = '常规' group by school,region1";
String sql = "select school,region1 as region from base_school_subject_tda20250918 where subject_type = '常规' group by school,region1";
List<Dto> listParams = reportJdbcTemplate.query(sql,new Object[]{},new BeanPropertyRowMapper<>(Dto.class));
......@@ -205,8 +205,8 @@ class PdfGeneratorApplicationTests {
"\tb.stu_ques_score,\n" +
"\tb.`ques_max_score`\n" +
"\tFROM\n" +
"\tbase_area_question_tda20250227 a\n" +
"\tleft join base_student_question_tda20250227 b on a.ques_no = b.ques_no and a.sub_subject = b.`sub_subject`\n" +"and a.region1 = b.region1 "+
"\tbase_area_question_tda20250918 a\n" +
"\tleft join base_student_question_tda20250918 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);
......@@ -327,11 +327,11 @@ class PdfGeneratorApplicationTests {
put("scoreMean", nanResult);
}};
namedParameterJdbcTemplate.update("insert into school_diffficult20250227(school,sub_subject,difficult,region,score_mean) value(:school,:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsYi));
namedParameterJdbcTemplate.update("insert into school_diffficult20250227(school,sub_subject,difficult,region,score_mean) value(:school,:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsJiaoYi));
namedParameterJdbcTemplate.update("insert into school_diffficult20250227(school,sub_subject,difficult,region,score_mean) value(:school,:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsZhong));
namedParameterJdbcTemplate.update("insert into school_diffficult20250227(school,sub_subject,difficult,region,score_mean) value(:school,:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsJiaoNan));
namedParameterJdbcTemplate.update("insert into school_diffficult20250227(school,sub_subject,difficult,region,score_mean) value(:school,:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsNan));
namedParameterJdbcTemplate.update("insert into school_diffficult20250918(school,sub_subject,difficult,region,score_mean) value(:school,:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsYi));
namedParameterJdbcTemplate.update("insert into school_diffficult20250918(school,sub_subject,difficult,region,score_mean) value(:school,:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsJiaoYi));
namedParameterJdbcTemplate.update("insert into school_diffficult20250918(school,sub_subject,difficult,region,score_mean) value(:school,:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsZhong));
namedParameterJdbcTemplate.update("insert into school_diffficult20250918(school,sub_subject,difficult,region,score_mean) value(:school,:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsJiaoNan));
namedParameterJdbcTemplate.update("insert into school_diffficult20250918(school,sub_subject,difficult,region,score_mean) value(:school,:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsNan));
}
// DeFenLu deFenLu = yi.get(0);
}
......@@ -342,7 +342,7 @@ class PdfGeneratorApplicationTests {
public void TestInsertRegion(){
JdbcTemplate reportJdbcTemplate = MyDataSourceConfig.getReportJdbcTemplate();
String sql = "select region1 from base_school_subject_tda20250227 where subject_type = '常规' group by region1";
String sql = "select region1 from base_school_subject_tda20250918 where subject_type = '常规' group by region1";
List<String> listParams = reportJdbcTemplate.queryForList(sql,String.class);
......@@ -366,8 +366,8 @@ class PdfGeneratorApplicationTests {
"\tb.stu_ques_score,\n" +
"\tb.`ques_max_score`\n" +
"\tFROM\n" +
"\tbase_area_question_tda20250227 a\n" +
"\tleft join base_student_question_tda20250227 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" +
"\tbase_area_question_tda20250918 a\n" +
"\tleft join base_student_question_tda20250918 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);
......@@ -463,11 +463,11 @@ class PdfGeneratorApplicationTests {
put("scoreMean", nanResult);
}};
namedParameterJdbcTemplate.update("insert into region_difficult20250227(sub_subject,difficult,region,score_mean) value(:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsYi));
namedParameterJdbcTemplate.update("insert into region_difficult20250227(sub_subject,difficult,region,score_mean) value(:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsJiaoYi));
namedParameterJdbcTemplate.update("insert into region_difficult20250227(sub_subject,difficult,region,score_mean) value(:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsZhong));
namedParameterJdbcTemplate.update("insert into region_difficult20250227(sub_subject,difficult,region,score_mean) value(:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsJiaoNan));
namedParameterJdbcTemplate.update("insert into region_difficult20250227(sub_subject,difficult,region,score_mean) value(:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsNan));
namedParameterJdbcTemplate.update("insert into region_difficult20250918(sub_subject,difficult,region,score_mean) value(:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsYi));
namedParameterJdbcTemplate.update("insert into region_difficult20250918(sub_subject,difficult,region,score_mean) value(:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsJiaoYi));
namedParameterJdbcTemplate.update("insert into region_difficult20250918(sub_subject,difficult,region,score_mean) value(:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsZhong));
namedParameterJdbcTemplate.update("insert into region_difficult20250918(sub_subject,difficult,region,score_mean) value(:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsJiaoNan));
namedParameterJdbcTemplate.update("insert into region_difficult20250918(sub_subject,difficult,region,score_mean) value(:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsNan));
}
......@@ -479,7 +479,7 @@ class PdfGeneratorApplicationTests {
JdbcTemplate reportJdbcTemplate = MyDataSourceConfig.getReportJdbcTemplate();
String sql = "select region1 as region ,province from base_school_subject_tda20250227 where subject_type = '常规' group by region1,province";
String sql = "select region1 as region ,province from base_school_subject_tda20250918 where subject_type = '常规' group by region1,province";
List<Params> paramsList = reportJdbcTemplate.query(sql,new Object[]{},new BeanPropertyRowMapper<>(Params.class));
......@@ -507,8 +507,8 @@ class PdfGeneratorApplicationTests {
"\tb.stu_ques_score,\n" +
"\tb.`ques_max_score`\n" +
"\tFROM\n" +
"\tbase_area_question_tda20250227 a\n" +
"\tleft join base_student_question_tda20250227 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" +
"\tbase_area_question_tda20250918 a\n" +
"\tleft join base_student_question_tda20250918 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);
......@@ -605,11 +605,11 @@ class PdfGeneratorApplicationTests {
put("region",region);
put("scoreMean", nanResult);
}};
namedParameterJdbcTemplate.update("insert into province_difficult20250227(province,sub_subject,difficult,region,score_mean) value(:province,:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsYi));
namedParameterJdbcTemplate.update("insert into province_difficult20250227(province,sub_subject,difficult,region,score_mean) value(:province,:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsJiaoYi));
namedParameterJdbcTemplate.update("insert into province_difficult20250227(province,sub_subject,difficult,region,score_mean) value(:province,:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsZhong));
namedParameterJdbcTemplate.update("insert into province_difficult20250227(province,sub_subject,difficult,region,score_mean) value(:province,:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsJiaoNan));
namedParameterJdbcTemplate.update("insert into province_difficult20250227(province,sub_subject,difficult,region,score_mean) value(:province,:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsNan));
namedParameterJdbcTemplate.update("insert into province_difficult20250918(province,sub_subject,difficult,region,score_mean) value(:province,:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsYi));
namedParameterJdbcTemplate.update("insert into province_difficult20250918(province,sub_subject,difficult,region,score_mean) value(:province,:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsJiaoYi));
namedParameterJdbcTemplate.update("insert into province_difficult20250918(province,sub_subject,difficult,region,score_mean) value(:province,:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsZhong));
namedParameterJdbcTemplate.update("insert into province_difficult20250918(province,sub_subject,difficult,region,score_mean) value(:province,:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsJiaoNan));
namedParameterJdbcTemplate.update("insert into province_difficult20250918(province,sub_subject,difficult,region,score_mean) value(:province,:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsNan));
}
......@@ -622,7 +622,7 @@ class PdfGeneratorApplicationTests {
JdbcTemplate jdbcTemplate = MyDataSourceConfig.getReportJdbcTemplate();
String sql = "select region1 from base_school_subject_tda20250227 where subject_type ='常规' group by region1";
String sql = "select region1 from base_school_subject_tda20250918 where subject_type ='常规' group by region1";
List<String> regions = jdbcTemplate.queryForList(sql,new Object[]{},String.class);
for (String region : regions) {
......@@ -645,8 +645,8 @@ class PdfGeneratorApplicationTests {
" b.`ques_max_score`,\n" +
" b.`stu_id`\n" +
" FROM\n" +
" base_area_question_tda20250227 a\n" +
" left join base_student_question_tda20250227 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" +
" base_area_question_tda20250918 a\n" +
" left join base_student_question_tda20250918 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+"'";
......@@ -666,7 +666,7 @@ class PdfGeneratorApplicationTests {
//这个级别开始晒数据
String sql2 = "select stu_id from base_student_subject_tda20250227 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_tda20250918 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);
......@@ -752,11 +752,11 @@ class PdfGeneratorApplicationTests {
put("scoreMean", nanResult);
}};
namedParameterJdbcTemplate.update("insert into region_excellent_difficult20250227(sub_subject,difficult,region,score_mean) value(:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsYi));
namedParameterJdbcTemplate.update("insert into region_excellent_difficult20250227(sub_subject,difficult,region,score_mean) value(:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsJiaoYi));
namedParameterJdbcTemplate.update("insert into region_excellent_difficult20250227(sub_subject,difficult,region,score_mean) value(:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsZhong));
namedParameterJdbcTemplate.update("insert into region_excellent_difficult20250227(sub_subject,difficult,region,score_mean) value(:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsJiaoNan));
namedParameterJdbcTemplate.update("insert into region_excellent_difficult20250227(sub_subject,difficult,region,score_mean) value(:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsNan));
namedParameterJdbcTemplate.update("insert into region_excellent_difficult20250918(sub_subject,difficult,region,score_mean) value(:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsYi));
namedParameterJdbcTemplate.update("insert into region_excellent_difficult20250918(sub_subject,difficult,region,score_mean) value(:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsJiaoYi));
namedParameterJdbcTemplate.update("insert into region_excellent_difficult20250918(sub_subject,difficult,region,score_mean) value(:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsZhong));
namedParameterJdbcTemplate.update("insert into region_excellent_difficult20250918(sub_subject,difficult,region,score_mean) value(:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsJiaoNan));
namedParameterJdbcTemplate.update("insert into region_excellent_difficult20250918(sub_subject,difficult,region,score_mean) value(:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsNan));
}
......@@ -765,7 +765,7 @@ class PdfGeneratorApplicationTests {
@Test
public void ExcellentAswTimeProvince(){
String sql = "select region1 as region,province from base_province_subject_tda20250227 where subject_type = '常规' group by region1,province";
String sql = "select region1 as region,province from base_province_subject_tda20250918 where subject_type = '常规' group by region1,province";
JdbcTemplate jdbcTemplate = MyDataSourceConfig.getReportJdbcTemplate();
List<Params> params = jdbcTemplate.query(sql,new Object[]{},new BeanPropertyRowMapper<>(Params.class));
for (Params param : params) {
......@@ -783,7 +783,7 @@ class PdfGeneratorApplicationTests {
"stu_ques_asw_time,\n" +
"sub_subject\n" +
"from \n" +
"base_student_question_log_time_tda20250227\n" +
"base_student_question_log_time_tda20250918\n" +
"where\n" +
"region1 = '"+region+"'\n" +
"and \n" +
......@@ -791,7 +791,7 @@ class PdfGeneratorApplicationTests {
"and \n" +
"subject_type='常规'\n" +
"and \n" +
"exam_id = 'TDA20250227G3'\n" ;
"exam_id = 'TDA20250918G11'\n" ;
NamedParameterJdbcTemplate namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(jdbcTemplate);
List<DtoAsw> listDtoAsw = jdbcTemplate.query(sql,new Object[]{},new BeanPropertyRowMapper<>(DtoAsw.class));
......@@ -801,7 +801,7 @@ class PdfGeneratorApplicationTests {
//科目粒度
for (String subject : collect.keySet()) {
System.out.println("operator"+subject+"科目");
String sql2 = "select stu_id from base_student_subject_tda20250227 where " +
String sql2 = "select stu_id from base_student_subject_tda20250918 where " +
"region1 = '"+region+"'\n" +
"and \n" +
"sub_subject = '"+subject+"'\n" +
......@@ -810,7 +810,7 @@ class PdfGeneratorApplicationTests {
"and \n" +
"subject_type= '常规'\n" +
"and \n" +
"exam_id = 'TDA20250227G3'\n" +
"exam_id = 'TDA20250918G11'\n" +
"and \n" +
"stu_subject_score_rate_province_pct_rank >= (1-0.27)";
......@@ -834,7 +834,7 @@ class PdfGeneratorApplicationTests {
put("quesNo",ques_no);
put("time",avgTime);
}};
namedParameterJdbcTemplate.update("insert into province_excellent_asw_time20250227(sub_subject,province,region,ques_no,time) value (:subSubject,:province,:region,:quesNo,:time)",new MapSqlParameterSource(params));
namedParameterJdbcTemplate.update("insert into province_excellent_asw_time20250918(sub_subject,province,region,ques_no,time) value (:subSubject,:province,:region,:quesNo,:time)",new MapSqlParameterSource(params));
}
}
......@@ -843,7 +843,7 @@ class PdfGeneratorApplicationTests {
@Test
public void ExcellentRegionAswTime(){
String sql = "select region1 from base_province_subject_tda20250227 where subject_type = '常规' group by region1\n";
String sql = "select region1 from base_province_subject_tda20250918 where subject_type = '常规' group by region1\n";
JdbcTemplate reportJdbcTemplate = MyDataSourceConfig.getReportJdbcTemplate();
List<String> regions = reportJdbcTemplate.queryForList(sql,String.class);
for (String region : regions) {
......@@ -860,13 +860,13 @@ class PdfGeneratorApplicationTests {
"stu_id,\n" +
"stu_ques_asw_time\n" +
"from \n" +
"base_student_question_log_time_tda20250227\n" +
"base_student_question_log_time_tda20250918\n" +
"where\n" +
"region1 = '"+region+"'\n" +
"and \n" +
"subject_type= '常规'\n" +
"and \n" +
"exam_id = 'TDA20250227G3'\n";
"exam_id = 'TDA20250918G11'\n";
NamedParameterJdbcTemplate namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(jdbcTemplate);
List<DtoAsw> list = jdbcTemplate.query(sql,new Object[]{},new BeanPropertyRowMapper<>(DtoAsw.class));
......@@ -874,14 +874,14 @@ class PdfGeneratorApplicationTests {
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_tda20250227 where " +
String sql2 = "select stu_id from base_student_subject_tda20250918 where " +
"region1 = '"+region+"'\n" +
"and \n" +
"sub_subject = '"+subject+"'\n" +
"and \n" +
"subject_type= '常规'\n" +
"and \n" +
"exam_id = 'TDA20250227G3'\n" +
"exam_id = 'TDA20250918G11'\n" +
"and \n" +
"stu_subject_score_rate_region_pct_rank >= (1-0.27)";
List<String> yousheng = jdbcTemplate.queryForList(sql2,String.class);
......@@ -899,7 +899,7 @@ class PdfGeneratorApplicationTests {
put("time",avgTime);
}};
namedParameterJdbcTemplate.update("insert into region_excellent_asw_time20250227(sub_subject,region,ques_no,time) value (:subSubject,:region,:quesNo,:time)",new MapSqlParameterSource(params));
namedParameterJdbcTemplate.update("insert into region_excellent_asw_time20250918(sub_subject,region,ques_no,time) value (:subSubject,:region,:quesNo,:time)",new MapSqlParameterSource(params));
}
}
......@@ -908,7 +908,7 @@ class PdfGeneratorApplicationTests {
@Test
public void testQuesType(){
String sql = "select region1 from base_province_subject_tda20250227 where subject_type = '常规' group by region1\n";
String sql = "select region1 from base_province_subject_tda20250918 where subject_type = '常规' group by region1\n";
JdbcTemplate reportJdbcTemplate = MyDataSourceConfig.getReportJdbcTemplate();
List<String> regions = reportJdbcTemplate.queryForList(sql,String.class);
for (String region : regions) {
......@@ -924,11 +924,11 @@ class PdfGeneratorApplicationTests {
"sub_subject,\n" +
"stu_id\n" +
"from\n" +
"base_student_ques_type_tda20250227\n" +
"base_student_ques_type_tda20250918\n" +
"where\n" +
"region1 = '"+region+"'\n" +
"\t\t\tAND subject_type = '常规' \n" +
"\t\t\tAND exam_id = 'TDA20250227G3'\n";
"\t\t\tAND exam_id = 'TDA20250918G11'\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));
......@@ -936,12 +936,12 @@ class PdfGeneratorApplicationTests {
String sql2 = "SELECT\n" +
"\tstu_id \n" +
"FROM\n" +
"\tbase_student_subject_tda20250227 \n" +
"\tbase_student_subject_tda20250918 \n" +
"WHERE\n" +
"\tstu_subject_score_rate_region_pct_rank >= ( 1-0.27 ) \n" +
"\tAND region1 = '"+region+"' \n" +
"\tAND subject_type = '常规' \n" +
"\tAND exam_id = 'TDA20250227G3' \n" +
"\tAND exam_id = 'TDA20250918G11' \n" +
"\tAND sub_subject = '"+subject+"'";
List<String> youshengIds = jdbcTemplate.queryForList(sql2, String.class);
......@@ -971,7 +971,7 @@ class PdfGeneratorApplicationTests {
params.put("Mean",resultMean);
NamedParameterJdbcTemplate namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(jdbcTemplate);
namedParameterJdbcTemplate.update("insert into region_ques_type_excellent20250227(region,sub_subject,mean,ques_type) value (:region,:subSubject,:Mean,:quesType)",new MapSqlParameterSource(params));
namedParameterJdbcTemplate.update("insert into region_ques_type_excellent20250918(region,sub_subject,mean,ques_type) value (:region,:subSubject,:Mean,:quesType)",new MapSqlParameterSource(params));
}
}
......
......@@ -11,14 +11,15 @@ public class GenerateSchool {
@Test
public void GenerateSchool(){
public void GenerateSchool() {
JdbcTemplate reportJdbcTemplate = MyDataSourceConfig.getReportJdbcTemplate();
String examId = "TDA20250227G3";
String examId = "TDA20251023G12";
// String examId = "TDA20250918G11";
String suffix = examId.replace("TDA","").replace("G2","").replace("G3","");
String suffix = examId.replace("TDA", "").replace("G2", "").replace("G3", "").replace("G11", "").replace("G12", "");
String createTableClassDifficult = "CREATE TABLE IF NOT EXISTS `class_diffficult"+suffix+"` (\n" +
String createTableClassDifficult = "CREATE TABLE IF NOT EXISTS `class_diffficult" + suffix + "` (\n" +
" `id` int NOT NULL AUTO_INCREMENT,\n" +
" `class` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,\n" +
" `school` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,\n" +
......@@ -29,7 +30,7 @@ public class GenerateSchool {
" PRIMARY KEY (`id`) USING BTREE\n" +
") ENGINE=InnoDB AUTO_INCREMENT=17401 DEFAULT CHARSET=utf8mb3";
String createTableProvinceDifficult = "CREATE TABLE IF NOT EXISTS `province_difficult"+suffix+"` (\n" +
String createTableProvinceDifficult = "CREATE TABLE IF NOT EXISTS `province_difficult" + suffix + "` (\n" +
" `id` int NOT NULL AUTO_INCREMENT,\n" +
" `province` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,\n" +
" `region` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,\n" +
......@@ -39,7 +40,7 @@ public class GenerateSchool {
" PRIMARY KEY (`id`) USING BTREE\n" +
") ENGINE=InnoDB AUTO_INCREMENT=371 DEFAULT CHARSET=utf8mb3";
String createTableProvinceExcellentDifficult = "CREATE TABLE IF NOT EXISTS `province_excellent_difficult"+suffix+"` (\n" +
String createTableProvinceExcellentDifficult = "CREATE TABLE IF NOT EXISTS `province_excellent_difficult" + suffix + "` (\n" +
" `id` int NOT NULL AUTO_INCREMENT,\n" +
" `region` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,\n" +
" `province` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,\n" +
......@@ -49,7 +50,7 @@ public class GenerateSchool {
" PRIMARY KEY (`id`) USING BTREE\n" +
") ENGINE=InnoDB AUTO_INCREMENT=916 DEFAULT CHARSET=utf8mb3";
String createTableRegionDifficult = "CREATE TABLE `region_difficult"+suffix+"` (\n" +
String createTableRegionDifficult = "CREATE TABLE `region_difficult" + suffix + "` (\n" +
" `id` int NOT NULL AUTO_INCREMENT,\n" +
" `region` varchar(255) DEFAULT NULL,\n" +
" `sub_subject` varchar(255) DEFAULT NULL,\n" +
......@@ -58,7 +59,7 @@ public class GenerateSchool {
" PRIMARY KEY (`id`)\n" +
") ENGINE=InnoDB AUTO_INCREMENT=101 DEFAULT CHARSET=utf8mb3";
String createTableRegionExcellentDifficult = "CREATE TABLE IF NOT EXISTS `region_excellent_difficult"+suffix+"` (\n" +
String createTableRegionExcellentDifficult = "CREATE TABLE IF NOT EXISTS `region_excellent_difficult" + suffix + "` (\n" +
" `id` int NOT NULL AUTO_INCREMENT,\n" +
" `region` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,\n" +
" `sub_subject` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,\n" +
......@@ -67,7 +68,7 @@ public class GenerateSchool {
" PRIMARY KEY (`id`) USING BTREE\n" +
") ENGINE=InnoDB AUTO_INCREMENT=101 DEFAULT CHARSET=utf8mb3";
String createTableSchoolDifficult = "CREATE TABLE IF NOT EXISTS `school_diffficult"+suffix+"` (\n" +
String createTableSchoolDifficult = "CREATE TABLE IF NOT EXISTS `school_diffficult" + suffix + "` (\n" +
" `id` int NOT NULL AUTO_INCREMENT,\n" +
" `school` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,\n" +
" `sub_subject` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,\n" +
......@@ -77,7 +78,7 @@ public class GenerateSchool {
" PRIMARY KEY (`id`) USING BTREE\n" +
") ENGINE=InnoDB AUTO_INCREMENT=7176 DEFAULT CHARSET=utf8mb3";
String createTableKnowledgeProvinceExcellent = "CREATE TABLE IF NOT EXISTS `knowledge_province_excellent"+suffix+"` (\n" +
String createTableKnowledgeProvinceExcellent = "CREATE TABLE IF NOT EXISTS `knowledge_province_excellent" + suffix + "` (\n" +
" `id` int NOT NULL AUTO_INCREMENT,\n" +
" `region` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,\n" +
" `province` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,\n" +
......@@ -87,7 +88,7 @@ public class GenerateSchool {
" PRIMARY KEY (`id`) USING BTREE\n" +
") ENGINE=InnoDB AUTO_INCREMENT=811 DEFAULT CHARSET=utf8mb3";
String createTableKnowledgeRegionExcellent = "CREATE TABLE IF NOT EXISTS `knowledge_region_excellent"+suffix+"` (\n" +
String createTableKnowledgeRegionExcellent = "CREATE TABLE IF NOT EXISTS `knowledge_region_excellent" + suffix + "` (\n" +
" `id` int NOT NULL AUTO_INCREMENT,\n" +
" `region` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,\n" +
" `sub_subject` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,\n" +
......@@ -96,7 +97,7 @@ public class GenerateSchool {
" PRIMARY KEY (`id`) USING BTREE\n" +
") ENGINE=InnoDB AUTO_INCREMENT=218 DEFAULT CHARSET=utf8mb3";
String createTableProvinceExcellentAswTime = "CREATE TABLE IF NOT EXISTS `province_excellent_asw_time"+suffix+"` (\n" +
String createTableProvinceExcellentAswTime = "CREATE TABLE IF NOT EXISTS `province_excellent_asw_time" + suffix + "` (\n" +
" `id` int NOT NULL AUTO_INCREMENT,\n" +
" `region` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,\n" +
" `province` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,\n" +
......@@ -107,7 +108,7 @@ public class GenerateSchool {
") ENGINE=InnoDB AUTO_INCREMENT=916 DEFAULT CHARSET=utf8mb3";
String createTableProvinceQuesTypeExcellent = "CREATE TABLE \n" +
"IF NOT EXISTS `province_ques_type_excellent"+suffix+"` (\n" +
"IF NOT EXISTS `province_ques_type_excellent" + suffix + "` (\n" +
" `id` int NOT NULL AUTO_INCREMENT,\n" +
" `region` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,\n" +
" `province` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,\n" +
......@@ -118,7 +119,7 @@ public class GenerateSchool {
") ENGINE=InnoDB AUTO_INCREMENT=526 DEFAULT CHARSET=utf8mb3\n";
String createTableRegionExcellentAswTime = "CREATE TABLE \n" +
"IF NOT EXISTS `region_excellent_asw_time"+suffix+"` (\n" +
"IF NOT EXISTS `region_excellent_asw_time" + suffix + "` (\n" +
" `id` int NOT NULL AUTO_INCREMENT,\n" +
" `region` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,\n" +
" `ques_no` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,\n" +
......@@ -127,7 +128,7 @@ public class GenerateSchool {
" PRIMARY KEY (`id`) USING BTREE\n" +
") ENGINE=InnoDB AUTO_INCREMENT=273 DEFAULT CHARSET=utf8mb3";
String createTableRegionQuesTypeExcellent = "CREATE TABLE IF NOT EXISTS `region_ques_type_excellent"+suffix+"` (\n" +
String createTableRegionQuesTypeExcellent = "CREATE TABLE IF NOT EXISTS `region_ques_type_excellent" + suffix + "` (\n" +
" `id` int NOT NULL AUTO_INCREMENT,\n" +
" `region` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,\n" +
" `sub_subject` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,\n" +
......
package com.example.pdfgenerator;
import com.example.pdfgenerator.Dto.RetryCommand;
import com.example.pdfgenerator.config.MyDataSourceConfig;
import com.qcloud.cos.COSClient;
import com.qcloud.cos.exception.CosClientException;
import com.qcloud.cos.exception.CosServiceException;
import com.qcloud.cos.model.PutObjectRequest;
import com.qcloud.cos.model.PutObjectResult;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.jdbc.core.JdbcTemplate;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* @Author ryze
* @Date 2025/9/26
*/
@SpringBootTest
@Slf4j
public class UploadPdfToCosTest {
String bucketName = "schoolreportpdf-1317275686";
@Autowired
private COSClient cosClient;
@Test
public void test1() {
// 1.上传学校报告
JdbcTemplate reportJdbcTemplate = MyDataSourceConfig.getTestJdbcTemplate();
reportJdbcTemplate.queryForList("select * from dp_total_score");
File basicFile = new File("F:\\myworkSpace\\basic\\");
File[] basicFiles = basicFile.listFiles();
assert basicFiles != null;
for (File file : basicFiles) {
String prefix = "PdfDir/" + file.getName();
PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, prefix, file);
try {
PutObjectResult putObjectResult = cosClient.putObject(putObjectRequest);
log.info(putObjectResult.getRequestId());
//file.delete();
} catch (CosServiceException e) {
log.info("cos服务出现问题");
e.printStackTrace();
} catch (CosClientException e) {
log.info("cos客户端出现问题" + file.getName() + "文件上传有误,重新上传");
e.printStackTrace();
}
}
//3.上传班级综合报告
//3.上传班级科目分析报告
}
// 2.测试上传学校科目报告
@Test
public void test2Test() {
JdbcTemplate reportJdbcTemplate = MyDataSourceConfig.getTestJdbcTemplate();
List<Map<String, Object>> mapList = reportJdbcTemplate.queryForList("SELECT DISTINCT\n" +
"\ta.school_id,\n" +
"\tc.name,\n" +
"\ta.subject_id,\n" +
"\tb.desc\n" +
"FROM\n" +
"\tdp_subject_score a\n" +
"\tLEFT JOIN \n" +
"\tsparta_subject b \n" +
"\ton a.subject_id =b.id\n" +
"\tLEFT JOIN \n" +
"\tsparta_school c on a.school_id = c.id");
File basicFile = new File("F:\\myworkSpace\\subject\\");
File[] basicFiles = basicFile.listFiles();
assert basicFiles != null;
List<String> list = new ArrayList<>();
for (File file : basicFiles) {
list.add(file.getName());
}
for (Map<String, Object> map : mapList) {
String schoolName = map.get("name").toString();
String subjectName = map.get("desc").toString();
if (list.contains(subjectName) && list.contains(schoolName)) {
System.out.println("包含");
} else {
System.out.println("schoolName = " + schoolName + " subjectName = " + subjectName + "不包含");
}
}
//3.上传班级综合报告
//4.上传班级科目分析报告
}
@Test
public void test2() {
// 1.上传学校报告
JdbcTemplate reportJdbcTemplate = MyDataSourceConfig.getTestJdbcTemplate();
reportJdbcTemplate.queryForList("select * from dp_total_score");
File basicFile = new File("F:\\myworkSpace\\subject\\");
File[] basicFiles = basicFile.listFiles();
assert basicFiles != null;
for (File file : basicFiles) {
String prefix = "PdfSubject/" + file.getName();
PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, prefix, file);
try {
PutObjectResult putObjectResult = cosClient.putObject(putObjectRequest);
log.info(putObjectResult.getRequestId());
//file.delete();
} catch (CosServiceException e) {
log.info("cos服务出现问题");
e.printStackTrace();
} catch (CosClientException e) {
log.info("cos客户端出现问题" + file.getName() + "文件上传有误,重新上传");
e.printStackTrace();
}
}
}
//3.上传班级综合报告
@Test
public void testZh() {
String examUuid = "TDA20250918G11";
String typeName = "班级综合报告";
JdbcTemplate reportJdbcTemplate = MyDataSourceConfig.getTestJdbcTemplate();
List<Map<String, Object>> mapList = reportJdbcTemplate.queryForList("\tSELECT DISTINCT\n" +
"\t c.province_name,\n" +
"\t IF(c.province_name = '山东省','改革3+3','改革3+1+2') as type,\n" +
" a.school_id,\n" +
"\tc.name,\n" +
"\ta.banji_name,\n" +
"\tCONCAT(IF(c.province_name = '山东省','改革3+3','改革3+1+2'),c.province_name,c.name,a.banji_name,'TDA20250918G11','.pdf') as xx\n" +
"FROM\n" +
"\tdp_ques_score a\n" +
"\tLEFT JOIN \n" +
"\tsparta_school c on a.school_id = c.id\n" +
"\t\n" +
"\tORDER BY a.school_id,a.banji_name ");
File basicFile = new File("F:\\myworkSpace\\Class\\Basic");
for (Map<String, Object> map : mapList) {
String provinceName = map.get("province_name").toString();
String schoolName = map.get("name").toString();
String banjiName = map.get("banji_name").toString();
String path = map.get("xx").toString();
File file2 = new File(basicFile, path);
if (!file2.exists()) {
System.out.println(path + " 不存在");
} else {
System.out.println("存在");
String prefix = "class/" + examUuid + "/" + provinceName + "/" + schoolName + "/" + typeName + "/" + banjiName + "/" + path;
PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, prefix, file2);
try {
PutObjectResult putObjectResult = cosClient.putObject(putObjectRequest);
log.info(putObjectResult.getRequestId());
//file.delete();
} catch (CosServiceException e) {
log.info("cos服务出现问题");
e.printStackTrace();
} catch (CosClientException e) {
log.info("cos客户端出现问题" + file2.getName() + "文件上传有误,重新上传");
e.printStackTrace();
}
}
}
}
//4.上传班级科目分析报告
@Test
public void testFx() {
String examUuid = "TDA20250918G11";
String typeName = "班级学科报告";
JdbcTemplate reportJdbcTemplate = MyDataSourceConfig.getTestJdbcTemplate();
List<Map<String, Object>> mapList = reportJdbcTemplate.queryForList("\t\tSELECT DISTINCT\n" +
"\tc.province_name,\n" +
" a.school_id,\n" +
"\tc.name,\n" +
"\ta.banji_name,\n" +
"\td.desc,\n" +
"\ta.subject_id,\n" +
"\tCONCAT(IF(c.province_name = '山东省','改革3+3','改革3+1+2'),c.province_name,c.name,d.desc,'TDA20250918G11',d.desc,a.banji_name,'.pdf') as xx\n" +
"FROM\n" +
"\tdp_subject_score a\n" +
"\tLEFT JOIN \n" +
"\tsparta_school c on a.school_id = c.id\n" +
"\tLEFT JOIN sparta_subject d on a.subject_id = d.id\n" +
"\tGROUP BY a.school_id,a.banji_name,a.subject_id");
File basicFile = new File("F:\\myworkSpace\\Class\\Subject");
for (Map<String, Object> map : mapList) {
String provinceName = map.get("province_name").toString();
String schoolName = map.get("name").toString();
String banjiName = map.get("banji_name").toString();
String subjectName = map.get("desc").toString();
String path = map.get("xx").toString();
File file2 = new File(basicFile, path);
if (!file2.exists()) {
System.out.println(path + " 不存在");
} else {
System.out.println("存在");
String prefix = "class/" + examUuid + "/" + provinceName + "/" + schoolName + "/" + typeName + "/" + banjiName + "/" +subjectName+"/"+ path;
PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, prefix, file2);
try {
PutObjectResult putObjectResult = cosClient.putObject(putObjectRequest);
log.info(putObjectResult.getRequestId());
//file.delete();
} catch (CosServiceException e) {
log.info("cos服务出现问题");
e.printStackTrace();
} catch (CosClientException e) {
log.info("cos客户端出现问题" + file2.getName() + "文件上传有误,重新上传");
e.printStackTrace();
}
}
}
}
}
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