Commit ed47312e authored by 霍传世's avatar 霍传世

具体到学校生成PDF报告数据

parent 4e8e7d1e
......@@ -48,7 +48,7 @@ public class MyDataSourceConfig {
System.err.println("print init reportSource...");
//外网
String url = "jdbc:mysql://192.168.0.46:3306/temp_test?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT%2B8";
String url = "jdbc:mysql://192.168.0.46:3306/tempnew?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT%2B8";
DruidDataSource dataSource = getDataSource(url);
dataSource.setUsername("jiru");
dataSource.setPassword("Jiru@20231026");
......
......@@ -5,10 +5,6 @@ import com.example.pdfgenerator.Dto.ClassBasicReportParameters;
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 org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -21,7 +17,6 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
......@@ -37,11 +32,13 @@ public class GeneratorAllTypePdfByProvinceController {
@Autowired
private COSClient cosClient;
private static final String bucketName = "schoolreportpdf-1317275686";
private static Map<String,String> fileToUrl = new HashMap<>();
JdbcTemplate reportJdbcTemplate = MyDataSourceConfig.getReportJdbcTemplate();
private static final String bucketName = "schoolreportpdf-1317275686";
@GetMapping("/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 {
......@@ -128,12 +125,23 @@ public class GeneratorAllTypePdfByProvinceController {
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 \"https://schoolreport.cssatest.com/pdf/subject?province=condition5&school=condition1&examId=condition4&region=conditionC&subSubject=condition6&subjectType=常规\" pdf";
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);
......@@ -142,7 +150,7 @@ public class GeneratorAllTypePdfByProvinceController {
fileToUrl.put(fileName.replace("/myworkSpace/subject/",""),"PdfSubject/"+fileName.replace("/myworkSpace/subject/",""));
}else{
String command = "node /myworkSpace/puppeteer2.js \"https://schoolreport.cssatest.com/pdf/subject?province=condition5&school=condition1&examId=condition4&region=非改革&branch=condition3&subSubject=condition6&subjectType=常规\" pdf";
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);
......@@ -156,7 +164,7 @@ public class GeneratorAllTypePdfByProvinceController {
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 \"https://schoolreport.cssatest.com/pdf/basic?province=condition5&school=condition1&examId=condition4&region=conditionC&subjectType=常规\" pdf ";
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);
......@@ -164,7 +172,7 @@ public class GeneratorAllTypePdfByProvinceController {
synthesisSchoolReportParameter.setPrefix("/myworkSpace/basic/");
fileToUrl.put(fileName.replace("/myworkSpace/basic/",""),"PdfDir/"+fileName.replace("/myworkSpace/basic/",""));
}else{
String command = "node /myworkSpace/puppeteer.js \"https://schoolreport.cssatest.com/pdf/basic?province=condition5&school=condition1&examId=condition4&region=非改革&branch=condition3&subjectType=常规\" pdf ";
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);
......@@ -180,7 +188,7 @@ public class GeneratorAllTypePdfByProvinceController {
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 \"https://schoolreport.cssatest.com/pdf/classSubject?province=condition5&school=condition1&examId=condition4&region=conditionC&subSubject=condition6&subjectType=常规&className=conditionA\" pdf";
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);
......@@ -188,7 +196,7 @@ public class GeneratorAllTypePdfByProvinceController {
synthesisClassSubjectReportParameter.setCommand(command);
synthesisClassSubjectReportParameter.setPrefix("/myworkSpace/Class/subject/");
} else {
String command = "node /myworkSpace/pdfOfClassSubjectGen.js \"https://schoolreport.cssatest.com/pdf/classSubject?province=condition5&school=condition1&examId=condition4&region=非改革&branch=condition3&subSubject=condition6&subjectType=常规&className=conditionA\" pdf";
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())
......@@ -205,7 +213,7 @@ public class GeneratorAllTypePdfByProvinceController {
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 \"https://schoolreport.cssatest.com/pdf/classBasic?province=condition5&school=condition1&examId=condition4&region=conditionC&subjectType=常规&className=conditionA\" pdf ";
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";
......@@ -220,7 +228,7 @@ public class GeneratorAllTypePdfByProvinceController {
} else {
String command = "node/myworkSpace/pdfOfClassBasicGen.js \"https://schoolreport.cssatest.com/pdf/classBasic?province=condition5&school=condition1&examId=condition4&region=非改革&branch=condition3&subjectType=常规&className=conditionA\" pdf ";
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";
......@@ -236,6 +244,10 @@ public class GeneratorAllTypePdfByProvinceController {
}
}
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));
......@@ -252,7 +264,6 @@ public class GeneratorAllTypePdfByProvinceController {
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));
......@@ -272,12 +283,18 @@ public class GeneratorAllTypePdfByProvinceController {
}
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 (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();
......@@ -285,27 +302,27 @@ public class GeneratorAllTypePdfByProvinceController {
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();
}
}
// 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());
......@@ -320,11 +337,17 @@ public class GeneratorAllTypePdfByProvinceController {
}
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 (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 {
......@@ -332,27 +355,27 @@ public class GeneratorAllTypePdfByProvinceController {
} 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 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());
......@@ -370,11 +393,17 @@ public class GeneratorAllTypePdfByProvinceController {
}
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 (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 {
......@@ -382,27 +411,27 @@ public class GeneratorAllTypePdfByProvinceController {
} 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) {
......@@ -419,11 +448,17 @@ public class GeneratorAllTypePdfByProvinceController {
}
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 (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 {
......@@ -431,28 +466,28 @@ 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();
}
}
// 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();
// }
// }
}
}
......@@ -483,11 +518,17 @@ public class GeneratorAllTypePdfByProvinceController {
}
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 (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 {
......@@ -495,23 +536,23 @@ public class GeneratorAllTypePdfByProvinceController {
} 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()+"文件上传有误,重新上传");
}
}
// 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()+"文件上传有误,重新上传");
// }
// }
}
......
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;
@RequestMapping("/local")
@RestController
public class LocalHostControllerGen {
private static final Logger logger = LoggerFactory.getLogger(LocalHostControllerGen.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("/test")
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 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 D:/myworkSpace/puppeteer2.js \"http://schoolreport.cssat.cn/pdf/subject?province=condition5&school=condition1&examId=condition4&region=conditionC&subSubject=condition6&subjectType=常规\" pdf";
String fileName = "D:/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("D:/myworkSpace/subject/");
fileToUrl.put(fileName.replace("D:/myworkSpace/subject/",""),"PdfSubject/"+fileName.replace("D:/myworkSpace/subject/",""));
}else{
String command = "node D:/myworkSpace/puppeteer2.js \"http://schoolreport.cssat.cn/pdf/subject?province=condition5&school=condition1&examId=condition4&region=非改革&branch=condition3&subSubject=condition6&subjectType=常规\" pdf";
String fileName = "D:/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("D:/myworkSpace/subject/");
fileToUrl.put(fileName.replace("D:/myworkSpace/subject/",""),"PdfSubject/"+fileName.replace("D:/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 D:/myworkSpace/puppeteer.js \"http://schoolreport.cssat.cn/pdf/basic?province=condition5&school=condition1&examId=condition4&region=conditionC&subjectType=常规\" pdf ";
String fileName = "D:/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("D:/myworkSpace/basic/");
fileToUrl.put(fileName.replace("D:/myworkSpace/basic/",""),"PdfDir/"+fileName.replace("D:/myworkSpace/basic/",""));
}else{
String command = "node D:/myworkSpace/puppeteer.js \"http://schoolreport.cssat.cn/pdf/basic?province=condition5&school=condition1&examId=condition4&region=非改革&branch=condition3&subjectType=常规\" pdf ";
String fileName = "D:/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("D:/myworkSpace/basic/");
fileToUrl.put(fileName.replace("D:/myworkSpace/basic/",""),"PdfDir/"+fileName.replace("D:/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 D:/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 = "D:/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("D:/myworkSpace/Class/subject/",""),"/class/"+synthesisClassSubjectReportParameter.getExamId()+"/"+synthesisClassSubjectReportParameter.getProvince()+"/"+synthesisClassSubjectReportParameter.getSchool()+"/班级学科报告/"+synthesisClassSubjectReportParameter.getClassName()+"/"+synthesisClassSubjectReportParameter.getSubSubject()+"/"+fileName.replace("D:/myworkSpace/Class/subject/",""));
synthesisClassSubjectReportParameter.setCommand(command);
synthesisClassSubjectReportParameter.setPrefix("D:/myworkSpace/Class/subject/");
} else {
String command = "node D:/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 = "D:/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("D:/myworkSpace/Class/subject/",""),"/class/"+synthesisClassSubjectReportParameter.getExamId()+"/"+synthesisClassSubjectReportParameter.getProvince()+"/"+synthesisClassSubjectReportParameter.getSchool()+"/班级学科报告/"+synthesisClassSubjectReportParameter.getClassName()+"/"+synthesisClassSubjectReportParameter.getSubSubject()+"/"+fileName.replace("D:/myworkSpace/Class/subject/",""));
synthesisClassSubjectReportParameter.setCommand(command);
synthesisClassSubjectReportParameter.setPrefix("D:/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 D:/myworkSpace/pdfOfClassBasicGen.js \"http://schoolreport.cssat.cn/pdf/classBasic?province=condition5&school=condition1&examId=condition4&region=conditionC&subjectType=常规&className=conditionA\" pdf ";
String fileName = "D:/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("D:/myworkSpace/Class/Basic/",""),"/class/"+synthesisClassReportParameter.getExamId()+"/"+synthesisClassReportParameter.getProvince()+"/"+synthesisClassReportParameter.getSchool()+"/班级综合报告/"+synthesisClassReportParameter.getClassName()+"/"+fileName.replace("D:/myworkSpace/Class/Basic/",""));
synthesisClassReportParameter.setCommand(command);
synthesisClassReportParameter.setPrefix("D:/myworkSpace/Class/Basic/");
} else {
String command = "nodeD:/myworkSpace/pdfOfClassBasicGen.js \"http://schoolreport.cssat.cn/pdf/classBasic?province=condition5&school=condition1&examId=condition4&region=非改革&branch=condition3&subjectType=常规&className=conditionA\" pdf ";
String fileName = "D:/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("D:/myworkSpace/Class/Basic/",""),"/class/"+synthesisClassReportParameter.getExamId()+"/"+synthesisClassReportParameter.getProvince()+"/"+synthesisClassReportParameter.getSchool()+"/班级综合报告/"+synthesisClassReportParameter.getClassName()+"/"+fileName.replace("D:/myworkSpace/Class/Basic/",""));
synthesisClassReportParameter.setCommand(command);
synthesisClassReportParameter.setPrefix("D:/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 {
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);
}
}
try {
int exitCode = process.waitFor();
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
//上传文件
// File basicFile = new File("D:/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 {
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);
}
}
try {
int exitCodeSubject = processSubject.waitFor();
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
// File subjectFile = new File("D:/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 {
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);
}
}
try {
int exitCodeSubject = processClass.waitFor();
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
// File classBasicFile = new File("D:/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 {
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);
}
}
try {
int exitCodeSubjectClass = processClassSubject.waitFor();
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
// File classSubjectFile = new File("D:/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);
}
}
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("操作成功");
}
}
......@@ -26,7 +26,7 @@ public class ClassIncrement {
public void GeProvinceQuesTypeSituation(){
String sql = "select region1" +
" as region,province from base_province_subject_tda20241031 where subject_type = '常规' group by region1,province";
" as region,province from base_province_subject_tda20241215 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) {
......@@ -43,25 +43,25 @@ public class ClassIncrement {
"sub_subject,\n" +
"stu_id\n" +
"from\n" +
"base_student_ques_type_tda20241031\n" +
"base_student_ques_type_tda20241215\n" +
"where\n" +
"region1 = '"+region+"'\n" +
"AND province = '"+province+"'\n" +
"\t\t\tAND subject_type = '常规' \n" +
"\t\t\tAND exam_id = 'TDA20241031G3'\n";
"\t\t\tAND exam_id = 'TDA20241215G3'\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_tda20241031 \n" +
"\tbase_student_subject_tda20241215 \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 = 'TDA20241031G3' \n" +
"\tAND exam_id = 'TDA20241215G3' \n" +
"\tAND sub_subject = '"+subject+"'";
List<String> excellentIds = jdbcTemplate.queryForList(sql2,String.class);
......@@ -93,7 +93,7 @@ public class ClassIncrement {
params.put("Mean",resultMean);
NamedParameterJdbcTemplate namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(jdbcTemplate);
namedParameterJdbcTemplate.update("insert into province_ques_type_excellent20241031(region,province,sub_subject,mean,ques_type) value (:region,:province,:subSubject,:Mean,:quesType)",new MapSqlParameterSource(params));
namedParameterJdbcTemplate.update("insert into province_ques_type_excellent20241215(region,province,sub_subject,mean,ques_type) value (:region,:province,:subSubject,:Mean,:quesType)",new MapSqlParameterSource(params));
}
}
......@@ -104,7 +104,7 @@ public class ClassIncrement {
@Test
public void GeProvinceExcellentDifficultySituations(){
String sql = "select region1 as region,province from base_province_subject_tda20241031 where subject_type = '常规' group by region1,province";
String sql = "select region1 as region,province from base_province_subject_tda20241215 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) {
......@@ -126,8 +126,8 @@ public class ClassIncrement {
"\tb.`ques_max_score`,\n" +
"\tb.`stu_id`\n" +
"\tFROM\n" +
"\tbase_area_question_tda20241031 a\n" +
"\tleft join base_student_question_tda20241031 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_tda20241215 a\n" +
"\tleft join base_student_question_tda20241215 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);
......@@ -139,7 +139,7 @@ public class ClassIncrement {
for (String subject : collect.keySet()) {
String sql2 = "select stu_id from base_student_subject_tda20241031 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_tda20241215 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);
......@@ -232,11 +232,11 @@ public class ClassIncrement {
put("scoreMean", nanResult);
}};
namedParameterJdbcTemplate.update("insert into province_excellent_difficult20241031(sub_subject,difficult,region,province,score_mean) value(:subSubject,:difficult,:region,:province,:scoreMean)",new MapSqlParameterSource(paramsYi));
namedParameterJdbcTemplate.update("insert into province_excellent_difficult20241031(sub_subject,difficult,region,province,score_mean) value(:subSubject,:difficult,:region,:province,:scoreMean)",new MapSqlParameterSource(paramsJiaoYi));
namedParameterJdbcTemplate.update("insert into province_excellent_difficult20241031(sub_subject,difficult,region,province,score_mean) value(:subSubject,:difficult,:region,:province,:scoreMean)",new MapSqlParameterSource(paramsZhong));
namedParameterJdbcTemplate.update("insert into province_excellent_difficult20241031(sub_subject,difficult,region,province,score_mean) value(:subSubject,:difficult,:region,:province,:scoreMean)",new MapSqlParameterSource(paramsJiaoNan));
namedParameterJdbcTemplate.update("insert into province_excellent_difficult20241031(sub_subject,difficult,region,province,score_mean) value(:subSubject,:difficult,:region,:province,:scoreMean)",new MapSqlParameterSource(paramsNan));
namedParameterJdbcTemplate.update("insert into province_excellent_difficult20241215(sub_subject,difficult,region,province,score_mean) value(:subSubject,:difficult,:region,:province,:scoreMean)",new MapSqlParameterSource(paramsYi));
namedParameterJdbcTemplate.update("insert into province_excellent_difficult20241215(sub_subject,difficult,region,province,score_mean) value(:subSubject,:difficult,:region,:province,:scoreMean)",new MapSqlParameterSource(paramsJiaoYi));
namedParameterJdbcTemplate.update("insert into province_excellent_difficult20241215(sub_subject,difficult,region,province,score_mean) value(:subSubject,:difficult,:region,:province,:scoreMean)",new MapSqlParameterSource(paramsZhong));
namedParameterJdbcTemplate.update("insert into province_excellent_difficult20241215(sub_subject,difficult,region,province,score_mean) value(:subSubject,:difficult,:region,:province,:scoreMean)",new MapSqlParameterSource(paramsJiaoNan));
namedParameterJdbcTemplate.update("insert into province_excellent_difficult20241215(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_tda20241031 where subject_type = '常规' group by region1";
String sql = "select region1 from base_school_subject_tda20241215 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_tda20241031\n" +
"base_student_knowledge_tda20241215\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_tda20241031\n" +
"base_student_subject_tda20241215\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_excellent20241031(sub_subject,knowledge,region,rate) value (:subSubject,:knowledge,:region,:rate)",new MapSqlParameterSource(paramsYi));
reportJdbcTemplate.update("insert into knowledge_region_excellent20241215(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_tda20241031 \n" +
"\tbase_school_subject_tda20241215 \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_tda20241031 where subject_type = '常规' group by region1,province";
String sql = "select region1 as region,province from base_school_subject_tda20241215 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_tda20241031\n" +
"base_student_knowledge_tda20241215\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_tda20241031 \n" +
"\t\t\tbase_student_subject_tda20241215 \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 = 'TDA20241031G3' \n" +
"\t\t\tAND exam_id = 'TDA20241215G3' \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_excellent20241031(sub_subject,knowledge,region,rate,province) value (:subSubject,:knowledge,:region,:rate,:province)",new MapSqlParameterSource(paramsYi));
reportTemplate.update("insert into knowledge_province_excellent20241215(sub_subject,knowledge,region,rate,province) value (:subSubject,:knowledge,:region,:rate,:province)",new MapSqlParameterSource(paramsYi));
}
}
......
......@@ -9,7 +9,11 @@ import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
import java.util.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@SpringBootTest
......@@ -30,7 +34,7 @@ class PdfGeneratorApplicationTests {
"\tschool,\n" +
"\tclass as className\n" +
"FROM\n" +
"\tbase_class_subject_tda20241031 \n" +
"\tbase_class_subject_tda20241215 \n" +
"WHERE\n" +
"\tsubject_type = '常规' \n" +
"GROUP BY\n" +
......@@ -59,8 +63,8 @@ class PdfGeneratorApplicationTests {
"\tb.stu_ques_score,\n" +
"\tb.`ques_max_score`,b.stu_ques_score\n" +
"\tFROM\n" +
"\tbase_area_question_tda20241031 a\n" +
"\tleft join base_student_question_tda20241031 b on a.ques_no = b.ques_no and a.sub_subject = b.`sub_subject`\n" +"and a.region1 = b.region1 "+
"\tbase_area_question_tda20241215 a\n" +
"\tleft join base_student_question_tda20241215 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);
......@@ -164,20 +168,20 @@ class PdfGeneratorApplicationTests {
put("region",region);
put("scoreMean", nanResult);
}};
namedParameterJdbcTemplate.update("insert into class_diffficult20241031(class,school,sub_subject,difficult,region,score_mean) value(:class,:school,:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsYi));
namedParameterJdbcTemplate.update("insert into class_diffficult20241031(class,school,sub_subject,difficult,region,score_mean) value(:class,:school,:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsJiaoYi));
namedParameterJdbcTemplate.update("insert into class_diffficult20241031(class,school,sub_subject,difficult,region,score_mean) value(:class,:school,:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsZhong));
namedParameterJdbcTemplate.update("insert into class_diffficult20241031(class,school,sub_subject,difficult,region,score_mean) value(:class,:school,:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsJiaoNan));
namedParameterJdbcTemplate.update("insert into class_diffficult20241031(class,school,sub_subject,difficult,region,score_mean) value(:class,:school,:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsNan));
namedParameterJdbcTemplate.update("insert into class_diffficult20241215(class,school,sub_subject,difficult,region,score_mean) value(:class,:school,:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsYi));
namedParameterJdbcTemplate.update("insert into class_diffficult20241215(class,school,sub_subject,difficult,region,score_mean) value(:class,:school,:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsJiaoYi));
namedParameterJdbcTemplate.update("insert into class_diffficult20241215(class,school,sub_subject,difficult,region,score_mean) value(:class,:school,:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsZhong));
namedParameterJdbcTemplate.update("insert into class_diffficult20241215(class,school,sub_subject,difficult,region,score_mean) value(:class,:school,:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsJiaoNan));
namedParameterJdbcTemplate.update("insert into class_diffficult20241215(class,school,sub_subject,difficult,region,score_mean) value(:class,:school,:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsNan));
}
}
// @Test
@Test
public void TestInsertSchool(){
JdbcTemplate reportJdbcTemplate = MyDataSourceConfig.getReportJdbcTemplate();
String sql = "select school,region1 as region from base_school_subject_tda20241031 where subject_type = '常规' group by school,region1";
String sql = "select school,region1 as region from base_school_subject_tda20241215 where subject_type = '常规' group by school,region1";
List<Dto> listParams = reportJdbcTemplate.query(sql,new Object[]{},new BeanPropertyRowMapper<>(Dto.class));
......@@ -201,8 +205,8 @@ class PdfGeneratorApplicationTests {
"\tb.stu_ques_score,\n" +
"\tb.`ques_max_score`\n" +
"\tFROM\n" +
"\tbase_area_question_tda20241031 a\n" +
"\tleft join base_student_question_tda20241031 b on a.ques_no = b.ques_no and a.sub_subject = b.`sub_subject`\n" +"and a.region1 = b.region1 "+
"\tbase_area_question_tda20241215 a\n" +
"\tleft join base_student_question_tda20241215 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);
......@@ -323,11 +327,11 @@ class PdfGeneratorApplicationTests {
put("scoreMean", nanResult);
}};
namedParameterJdbcTemplate.update("insert into school_diffficult20241031(school,sub_subject,difficult,region,score_mean) value(:school,:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsYi));
namedParameterJdbcTemplate.update("insert into school_diffficult20241031(school,sub_subject,difficult,region,score_mean) value(:school,:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsJiaoYi));
namedParameterJdbcTemplate.update("insert into school_diffficult20241031(school,sub_subject,difficult,region,score_mean) value(:school,:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsZhong));
namedParameterJdbcTemplate.update("insert into school_diffficult20241031(school,sub_subject,difficult,region,score_mean) value(:school,:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsJiaoNan));
namedParameterJdbcTemplate.update("insert into school_diffficult20241031(school,sub_subject,difficult,region,score_mean) value(:school,:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsNan));
namedParameterJdbcTemplate.update("insert into school_diffficult20241215(school,sub_subject,difficult,region,score_mean) value(:school,:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsYi));
namedParameterJdbcTemplate.update("insert into school_diffficult20241215(school,sub_subject,difficult,region,score_mean) value(:school,:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsJiaoYi));
namedParameterJdbcTemplate.update("insert into school_diffficult20241215(school,sub_subject,difficult,region,score_mean) value(:school,:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsZhong));
namedParameterJdbcTemplate.update("insert into school_diffficult20241215(school,sub_subject,difficult,region,score_mean) value(:school,:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsJiaoNan));
namedParameterJdbcTemplate.update("insert into school_diffficult20241215(school,sub_subject,difficult,region,score_mean) value(:school,:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsNan));
}
// DeFenLu deFenLu = yi.get(0);
}
......@@ -338,7 +342,7 @@ class PdfGeneratorApplicationTests {
public void TestInsertRegion(){
JdbcTemplate reportJdbcTemplate = MyDataSourceConfig.getReportJdbcTemplate();
String sql = "select region1 from base_school_subject_tda20241031 where subject_type = '常规' group by region1";
String sql = "select region1 from base_school_subject_tda20241215 where subject_type = '常规' group by region1";
List<String> listParams = reportJdbcTemplate.queryForList(sql,String.class);
......@@ -362,8 +366,8 @@ class PdfGeneratorApplicationTests {
"\tb.stu_ques_score,\n" +
"\tb.`ques_max_score`\n" +
"\tFROM\n" +
"\tbase_area_question_tda20241031 a\n" +
"\tleft join base_student_question_tda20241031 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_tda20241215 a\n" +
"\tleft join base_student_question_tda20241215 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);
......@@ -459,11 +463,11 @@ class PdfGeneratorApplicationTests {
put("scoreMean", nanResult);
}};
namedParameterJdbcTemplate.update("insert into region_difficult20241031(sub_subject,difficult,region,score_mean) value(:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsYi));
namedParameterJdbcTemplate.update("insert into region_difficult20241031(sub_subject,difficult,region,score_mean) value(:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsJiaoYi));
namedParameterJdbcTemplate.update("insert into region_difficult20241031(sub_subject,difficult,region,score_mean) value(:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsZhong));
namedParameterJdbcTemplate.update("insert into region_difficult20241031(sub_subject,difficult,region,score_mean) value(:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsJiaoNan));
namedParameterJdbcTemplate.update("insert into region_difficult20241031(sub_subject,difficult,region,score_mean) value(:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsNan));
namedParameterJdbcTemplate.update("insert into region_difficult20241215(sub_subject,difficult,region,score_mean) value(:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsYi));
namedParameterJdbcTemplate.update("insert into region_difficult20241215(sub_subject,difficult,region,score_mean) value(:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsJiaoYi));
namedParameterJdbcTemplate.update("insert into region_difficult20241215(sub_subject,difficult,region,score_mean) value(:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsZhong));
namedParameterJdbcTemplate.update("insert into region_difficult20241215(sub_subject,difficult,region,score_mean) value(:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsJiaoNan));
namedParameterJdbcTemplate.update("insert into region_difficult20241215(sub_subject,difficult,region,score_mean) value(:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsNan));
}
......@@ -475,7 +479,7 @@ class PdfGeneratorApplicationTests {
JdbcTemplate reportJdbcTemplate = MyDataSourceConfig.getReportJdbcTemplate();
String sql = "select region1 as region ,province from base_school_subject_tda20241031 where subject_type = '常规' group by region1,province";
String sql = "select region1 as region ,province from base_school_subject_tda20241215 where subject_type = '常规' group by region1,province";
List<Params> paramsList = reportJdbcTemplate.query(sql,new Object[]{},new BeanPropertyRowMapper<>(Params.class));
......@@ -503,8 +507,8 @@ class PdfGeneratorApplicationTests {
"\tb.stu_ques_score,\n" +
"\tb.`ques_max_score`\n" +
"\tFROM\n" +
"\tbase_area_question_tda20241031 a\n" +
"\tleft join base_student_question_tda20241031 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_tda20241215 a\n" +
"\tleft join base_student_question_tda20241215 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);
......@@ -601,11 +605,11 @@ class PdfGeneratorApplicationTests {
put("region",region);
put("scoreMean", nanResult);
}};
namedParameterJdbcTemplate.update("insert into province_difficult20241031(province,sub_subject,difficult,region,score_mean) value(:province,:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsYi));
namedParameterJdbcTemplate.update("insert into province_difficult20241031(province,sub_subject,difficult,region,score_mean) value(:province,:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsJiaoYi));
namedParameterJdbcTemplate.update("insert into province_difficult20241031(province,sub_subject,difficult,region,score_mean) value(:province,:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsZhong));
namedParameterJdbcTemplate.update("insert into province_difficult20241031(province,sub_subject,difficult,region,score_mean) value(:province,:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsJiaoNan));
namedParameterJdbcTemplate.update("insert into province_difficult20241031(province,sub_subject,difficult,region,score_mean) value(:province,:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsNan));
namedParameterJdbcTemplate.update("insert into province_difficult20241215(province,sub_subject,difficult,region,score_mean) value(:province,:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsYi));
namedParameterJdbcTemplate.update("insert into province_difficult20241215(province,sub_subject,difficult,region,score_mean) value(:province,:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsJiaoYi));
namedParameterJdbcTemplate.update("insert into province_difficult20241215(province,sub_subject,difficult,region,score_mean) value(:province,:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsZhong));
namedParameterJdbcTemplate.update("insert into province_difficult20241215(province,sub_subject,difficult,region,score_mean) value(:province,:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsJiaoNan));
namedParameterJdbcTemplate.update("insert into province_difficult20241215(province,sub_subject,difficult,region,score_mean) value(:province,:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsNan));
}
......@@ -618,7 +622,7 @@ class PdfGeneratorApplicationTests {
JdbcTemplate jdbcTemplate = MyDataSourceConfig.getReportJdbcTemplate();
String sql = "select region1 from base_school_subject_tda20241031 where subject_type ='常规' group by region1";
String sql = "select region1 from base_school_subject_tda20241215 where subject_type ='常规' group by region1";
List<String> regions = jdbcTemplate.queryForList(sql,new Object[]{},String.class);
for (String region : regions) {
......@@ -641,8 +645,8 @@ class PdfGeneratorApplicationTests {
" b.`ques_max_score`,\n" +
" b.`stu_id`\n" +
" FROM\n" +
" base_area_question_tda20241031 a\n" +
" left join base_student_question_tda20241031 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_tda20241215 a\n" +
" left join base_student_question_tda20241215 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+"'";
......@@ -662,7 +666,7 @@ class PdfGeneratorApplicationTests {
//这个级别开始晒数据
String sql2 = "select stu_id from base_student_subject_tda20241031 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_tda20241215 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);
......@@ -748,11 +752,11 @@ class PdfGeneratorApplicationTests {
put("scoreMean", nanResult);
}};
namedParameterJdbcTemplate.update("insert into region_excellent_difficult20241031(sub_subject,difficult,region,score_mean) value(:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsYi));
namedParameterJdbcTemplate.update("insert into region_excellent_difficult20241031(sub_subject,difficult,region,score_mean) value(:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsJiaoYi));
namedParameterJdbcTemplate.update("insert into region_excellent_difficult20241031(sub_subject,difficult,region,score_mean) value(:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsZhong));
namedParameterJdbcTemplate.update("insert into region_excellent_difficult20241031(sub_subject,difficult,region,score_mean) value(:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsJiaoNan));
namedParameterJdbcTemplate.update("insert into region_excellent_difficult20241031(sub_subject,difficult,region,score_mean) value(:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsNan));
namedParameterJdbcTemplate.update("insert into region_excellent_difficult20241215(sub_subject,difficult,region,score_mean) value(:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsYi));
namedParameterJdbcTemplate.update("insert into region_excellent_difficult20241215(sub_subject,difficult,region,score_mean) value(:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsJiaoYi));
namedParameterJdbcTemplate.update("insert into region_excellent_difficult20241215(sub_subject,difficult,region,score_mean) value(:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsZhong));
namedParameterJdbcTemplate.update("insert into region_excellent_difficult20241215(sub_subject,difficult,region,score_mean) value(:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsJiaoNan));
namedParameterJdbcTemplate.update("insert into region_excellent_difficult20241215(sub_subject,difficult,region,score_mean) value(:subSubject,:difficult,:region,:scoreMean)",new MapSqlParameterSource(paramsNan));
}
......@@ -761,7 +765,7 @@ class PdfGeneratorApplicationTests {
@Test
public void ExcellentAswTimeProvince(){
String sql = "select region1 as region,province from base_province_subject_tda20241031 where subject_type = '常规' group by region1,province";
String sql = "select region1 as region,province from base_province_subject_tda20241215 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) {
......@@ -779,7 +783,7 @@ class PdfGeneratorApplicationTests {
"stu_ques_asw_time,\n" +
"sub_subject\n" +
"from \n" +
"base_student_question_log_time_tda20241031\n" +
"base_student_question_log_time_tda20241215\n" +
"where\n" +
"region1 = '"+region+"'\n" +
"and \n" +
......@@ -787,7 +791,7 @@ class PdfGeneratorApplicationTests {
"and \n" +
"subject_type='常规'\n" +
"and \n" +
"exam_id = 'TDA20241031G3'\n" ;
"exam_id = 'TDA20241215G3'\n" ;
NamedParameterJdbcTemplate namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(jdbcTemplate);
List<DtoAsw> listDtoAsw = jdbcTemplate.query(sql,new Object[]{},new BeanPropertyRowMapper<>(DtoAsw.class));
......@@ -797,7 +801,7 @@ class PdfGeneratorApplicationTests {
//科目粒度
for (String subject : collect.keySet()) {
System.out.println("operator"+subject+"科目");
String sql2 = "select stu_id from base_student_subject_tda20241031 where " +
String sql2 = "select stu_id from base_student_subject_tda20241215 where " +
"region1 = '"+region+"'\n" +
"and \n" +
"sub_subject = '"+subject+"'\n" +
......@@ -806,7 +810,7 @@ class PdfGeneratorApplicationTests {
"and \n" +
"subject_type= '常规'\n" +
"and \n" +
"exam_id = 'TDA20241031G3'\n" +
"exam_id = 'TDA20241215G3'\n" +
"and \n" +
"stu_subject_score_rate_province_pct_rank >= (1-0.27)";
......@@ -830,7 +834,7 @@ class PdfGeneratorApplicationTests {
put("quesNo",ques_no);
put("time",avgTime);
}};
namedParameterJdbcTemplate.update("insert into province_excellent_asw_time20241031(sub_subject,province,region,ques_no,time) value (:subSubject,:province,:region,:quesNo,:time)",new MapSqlParameterSource(params));
namedParameterJdbcTemplate.update("insert into province_excellent_asw_time20241215(sub_subject,province,region,ques_no,time) value (:subSubject,:province,:region,:quesNo,:time)",new MapSqlParameterSource(params));
}
}
......@@ -839,7 +843,7 @@ class PdfGeneratorApplicationTests {
@Test
public void ExcellentRegionAswTime(){
String sql = "select region1 from base_province_subject_tda20241031 where subject_type = '常规' group by region1\n";
String sql = "select region1 from base_province_subject_tda20241215 where subject_type = '常规' group by region1\n";
JdbcTemplate reportJdbcTemplate = MyDataSourceConfig.getReportJdbcTemplate();
List<String> regions = reportJdbcTemplate.queryForList(sql,String.class);
for (String region : regions) {
......@@ -856,13 +860,13 @@ class PdfGeneratorApplicationTests {
"stu_id,\n" +
"stu_ques_asw_time\n" +
"from \n" +
"base_student_question_log_time_tda20241031\n" +
"base_student_question_log_time_tda20241215\n" +
"where\n" +
"region1 = '"+region+"'\n" +
"and \n" +
"subject_type= '常规'\n" +
"and \n" +
"exam_id = 'TDA20241031G3'\n";
"exam_id = 'TDA20241215G3'\n";
NamedParameterJdbcTemplate namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(jdbcTemplate);
List<DtoAsw> list = jdbcTemplate.query(sql,new Object[]{},new BeanPropertyRowMapper<>(DtoAsw.class));
......@@ -870,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_tda20241031 where " +
String sql2 = "select stu_id from base_student_subject_tda20241215 where " +
"region1 = '"+region+"'\n" +
"and \n" +
"sub_subject = '"+subject+"'\n" +
"and \n" +
"subject_type= '常规'\n" +
"and \n" +
"exam_id = 'TDA20241031G3'\n" +
"exam_id = 'TDA20241215G3'\n" +
"and \n" +
"stu_subject_score_rate_region_pct_rank >= (1-0.27)";
List<String> yousheng = jdbcTemplate.queryForList(sql2,String.class);
......@@ -895,7 +899,7 @@ class PdfGeneratorApplicationTests {
put("time",avgTime);
}};
namedParameterJdbcTemplate.update("insert into region_excellent_asw_time20241031(sub_subject,region,ques_no,time) value (:subSubject,:region,:quesNo,:time)",new MapSqlParameterSource(params));
namedParameterJdbcTemplate.update("insert into region_excellent_asw_time20241215(sub_subject,region,ques_no,time) value (:subSubject,:region,:quesNo,:time)",new MapSqlParameterSource(params));
}
}
......@@ -904,7 +908,7 @@ class PdfGeneratorApplicationTests {
@Test
public void testQuesType(){
String sql = "select region1 from base_province_subject_tda20241031 where subject_type = '常规' group by region1\n";
String sql = "select region1 from base_province_subject_tda20241215 where subject_type = '常规' group by region1\n";
JdbcTemplate reportJdbcTemplate = MyDataSourceConfig.getReportJdbcTemplate();
List<String> regions = reportJdbcTemplate.queryForList(sql,String.class);
for (String region : regions) {
......@@ -920,11 +924,11 @@ class PdfGeneratorApplicationTests {
"sub_subject,\n" +
"stu_id\n" +
"from\n" +
"base_student_ques_type_tda20241031\n" +
"base_student_ques_type_tda20241215\n" +
"where\n" +
"region1 = '"+region+"'\n" +
"\t\t\tAND subject_type = '常规' \n" +
"\t\t\tAND exam_id = 'TDA20241031G3'\n";
"\t\t\tAND exam_id = 'TDA20241215G3'\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));
......@@ -932,12 +936,12 @@ class PdfGeneratorApplicationTests {
String sql2 = "SELECT\n" +
"\tstu_id \n" +
"FROM\n" +
"\tbase_student_subject_tda20241031 \n" +
"\tbase_student_subject_tda20241215 \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 = 'TDA20241031G3' \n" +
"\tAND exam_id = 'TDA20241215G3' \n" +
"\tAND sub_subject = '"+subject+"'";
List<String> youshengIds = jdbcTemplate.queryForList(sql2, String.class);
......@@ -967,7 +971,7 @@ class PdfGeneratorApplicationTests {
params.put("Mean",resultMean);
NamedParameterJdbcTemplate namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(jdbcTemplate);
namedParameterJdbcTemplate.update("insert into region_ques_type_excellent20241031(region,sub_subject,mean,ques_type) value (:region,:subSubject,:Mean,:quesType)",new MapSqlParameterSource(params));
namedParameterJdbcTemplate.update("insert into region_ques_type_excellent20241215(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 = "TDA20241031G3";
String examId = "TDA20241215G3";
String suffix = examId.replace("TDA","").replace("G2","").replace("G3","");
......
package com.example.pdfgenerator.LocalFileMule;
import lombok.Data;
@Data
public class Args {
private String examId;
private String region;
private String province;
private String school;
private String subject;
}
package com.example.pdfgenerator.LocalFileMule;
import com.example.pdfgenerator.config.MyDataSourceConfig;
import com.qcloud.cos.COSClient;
import com.qcloud.cos.model.COSObject;
import com.qcloud.cos.model.COSObjectInputStream;
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.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@SpringBootTest
public class FIleTogether {
@Autowired
private COSClient cosClient;
private static final String bucketName = "schoolreportpdf-1317275686";
@Test
public void fileAllToOne(){
JdbcTemplate reportTemplate = MyDataSourceConfig.getReportJdbcTemplate();
String sql = "SELECT\n" +
"\texam_id,\n" +
"\tregion1 as region,\n" +
"\tprovince,\n" +
"\tschool,\n" +
"\tsub_subject AS subject \n" +
"FROM\n" +
"\tbase_school_subject_tda20241031 \n" +
"WHERE\n" +
"\tsubject_type = '常规' \n" +
"\tAND province = '山东省' \n" +
"ORDER BY\n" +
"\tschool,school_subject_score_mean DESC ";
List<Args> argsList = reportTemplate.query(sql,new Object[]{},new BeanPropertyRowMapper<>(Args.class));
Map<String, List<Args>> argsDecideBySchool = argsList.stream().collect(Collectors.groupingBy(Args::getSchool));
for (String key : argsDecideBySchool.keySet()) {
List<Args> args = argsDecideBySchool.get(key);
//下载学科报告
for (Args arg : args) {
String bucketKey = "PdfSubject/"+arg.getRegion()+arg.getProvince()+arg.getSchool()+arg.getSubject()+arg.getExamId()+".pdf";
String localFilePath = "D:/"+"schoolReport/"+arg.getProvince()+"/"+arg.getSchool();
File file = new File(localFilePath);
if(!file.exists()){
file.mkdirs();
}
downloadFile(cosClient,bucketName,bucketKey,localFilePath);
}
//下载综合报告
String oneKey = "PdfDir/"+args.get(0).getRegion()+args.get(0).getProvince()+args.get(0).getSchool()+"xxxx"+args.get(0).getExamId()+".pdf";
String filePath = "D:/"+"schoolReport/"+args.get(0).getProvince()+"/"+args.get(0).getSchool();
downloadFile(cosClient,bucketName,oneKey,filePath);
}
}
// 5. 下载文件的具体方法
public static void downloadFile(COSClient cosClient, String bucketName, String fileKey, String localFolder) {
try {
// 获取文件对象
COSObject cosObject = cosClient.getObject(bucketName,fileKey.replace("xxxx",""));
COSObjectInputStream inputStream = cosObject.getObjectContent();
// 设置本地文件路径
File localFile = new File(localFolder + "/" + fileKey.replace("PdfSubject/","").replace("PdfDir/","").replace("xxxx","综合"));
// 创建本地文件夹
if (!localFile.getParentFile().exists()) {
localFile.getParentFile().mkdirs(); // 如果文件夹不存在,则创建
}
// 保存文件到本地
Files.copy(inputStream, Paths.get(localFile.toURI()));
System.out.println("File downloaded successfully: " + fileKey + " to " + localFile.getAbsolutePath());
} catch (IOException e) {
System.err.println("Error downloading file " + fileKey);
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