Commit 6bf8e4aa authored by ryzeycy's avatar ryzeycy

xx

parent 45095df1
...@@ -32,10 +32,10 @@ public class MyDataSourceConfig { ...@@ -32,10 +32,10 @@ public class MyDataSourceConfig {
@PostConstruct @PostConstruct
private void init() { private void init() {
initReport(); initReport();
initMkReport(); // initMkReport();
// initCampCenter(); // initCampCenter();
// initBasic(); // initBasic();
initTest(); // initTest();
} }
...@@ -86,10 +86,10 @@ public class MyDataSourceConfig { ...@@ -86,10 +86,10 @@ public class MyDataSourceConfig {
System.err.println("print init reportSource..."); System.err.println("print init reportSource...");
//外网 //外网
String url = "jdbc:mysql://192.168.0.46:3306/tempnew?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT%2B8"; String url = "jdbc:mysql://192.168.0.11:3306/tempnew?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT%2B8";
DruidDataSource dataSource = getDataSource(url); DruidDataSource dataSource = getDataSource(url);
dataSource.setUsername("jiru"); dataSource.setUsername("root");
dataSource.setPassword("Jiru@20231026"); dataSource.setPassword("Thu#DSS#0419");
reportJdbcTemplate = new JdbcTemplate(dataSource); reportJdbcTemplate = new JdbcTemplate(dataSource);
return dataSource; return dataSource;
......
//package com.example.pdfgenerator.controller; package com.example.pdfgenerator.controller;
//
//import com.example.pdfgenerator.Dto.BasicReportParameters; import com.example.pdfgenerator.Dto.BasicReportParameters;
//import com.example.pdfgenerator.Dto.ClassBasicReportParameters; import com.example.pdfgenerator.Dto.ClassBasicReportParameters;
//import com.example.pdfgenerator.Dto.RetryCommand; import com.example.pdfgenerator.Dto.RetryCommand;
//import com.example.pdfgenerator.config.MyDataSourceConfig; import com.example.pdfgenerator.config.MyDataSourceConfig;
//import com.qcloud.cos.COSClient; import com.qcloud.cos.COSClient;
//import org.slf4j.Logger; import org.slf4j.Logger;
//import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
//import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
//import org.springframework.jdbc.core.BeanPropertyRowMapper; import org.springframework.jdbc.core.BeanPropertyRowMapper;
//import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.JdbcTemplate;
//import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
//import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
//
//import java.io.BufferedReader; import java.io.BufferedReader;
//import java.io.IOException; import java.io.IOException;
//import java.io.InputStreamReader; import java.io.InputStreamReader;
//import java.util.*; import java.util.*;
//import java.util.stream.Collectors; import java.util.stream.Collectors;
//
//
//@RestController @RestController
//@RequestMapping("/pdf") @RequestMapping("/pdf")
//public class GeneratorAllTypePdfByProvinceController { public class GeneratorAllTypePdfByProvinceController {
//
// private static final Logger logger = LoggerFactory.getLogger(GeneratorAllTypePdfByProvinceController.class); private static final Logger logger = LoggerFactory.getLogger(GeneratorAllTypePdfByProvinceController.class);
//
// @Autowired @Autowired
// private COSClient cosClient; private COSClient cosClient;
//
// private static final String bucketName = "schoolreportpdf-1317275686"; private static final String bucketName = "schoolreportpdf-1317275686";
//
//
// private static Map<String, String> fileToUrl = new HashMap<>(); private static Map<String, String> fileToUrl = new HashMap<>();
//
// JdbcTemplate reportJdbcTemplate = MyDataSourceConfig.getReportJdbcTemplate(); JdbcTemplate reportJdbcTemplate = MyDataSourceConfig.getReportJdbcTemplate();
//
//
// @RequestMapping("/GeneratorByProvinceName") @RequestMapping("/GeneratorByProvinceName")
// public ResponseEntity generatorName(@RequestParam("examId") String examId, @RequestParam(value = "provinceName", required = false) String provinceName, @RequestParam(value = "schoolName", required = false) String schoolName) throws IOException, InterruptedException { public ResponseEntity generatorName(@RequestParam("examId") String examId, @RequestParam(value = "provinceName", required = false) String provinceName, @RequestParam(value = "schoolName", required = false) String schoolName) throws IOException, InterruptedException {
//
// String suffix = examId.trim().replace("TDA", "").replace("G3", "").replace("G2", "").replace("G10", "").replace("G11", "").replace("G12", "").trim(); String suffix = examId.trim().replace("TDA", "").replace("G3", "").replace("G2", "").replace("G10", "").replace("G11", "").replace("G12", "").trim();
//
// String synthesisSchoolSubjectReportSql = "select \n" + // 学校的单科的pdf
// "school,exam_id,province,region1 as region,sub_subject\n" + String synthesisSchoolSubjectReportSql = "select \n" +
// "from \n" + "school,exam_id,province,region1 as region,sub_subject\n" +
// "base_school_subject_tda" + suffix + " \n" + "from \n" +
// " where subject_type = '常规' \n"; "base_school_subject_tda" + suffix + " \n" +
// " where subject_type = '常规' \n";
// String synthesisSchoolReportSql = "select \n" +
// "school,exam_id,province,region1 as region\n" + // 学校的综合的pdf
// "from \n" + String synthesisSchoolReportSql = "select \n" +
// "base_school_subject_tda" + suffix + " where subject_type = '常规' \n"; "school,exam_id,province,region1 as region\n" +
// "from \n" +
// String synthesisClassSubjectReportSql = "SELECT\n" + "base_school_subject_tda" + suffix + " where subject_type = '常规' \n";
// "\tclass as class_name,\n" +
// "\tsub_subject,\n" + // 班级的单科的pdf
// "\tschool,\n" + String synthesisClassSubjectReportSql = "SELECT\n" +
// "\tprovince,\n" + "\tclass as class_name,\n" +
// "\tregion1 as region,\n" + "\tsub_subject,\n" +
// "\texam_id\n" + "\tschool,\n" +
// "FROM\n" + "\tprovince,\n" +
// "\tbase_student_subject_tda" + suffix + "\n" + "\tregion1 as region,\n" +
// "where\n" + "\texam_id\n" +
// "subject_type = '常规' \n "; "FROM\n" +
// "\tbase_student_subject_tda" + suffix + "\n" +
// String synthesisClassReportSql = "SELECT\n" + "where\n" +
// "\tclass AS class_name,\n" + "subject_type = '常规' \n ";
// "\tschool,\n" +
// "\texam_id,\n" + // 班级的综合的pdf
// "\tprovince,\n" + String synthesisClassReportSql = "SELECT\n" +
// "\tregion1 as region \n" + "\tclass AS class_name,\n" +
// "FROM\n" + "\tschool,\n" +
// "\tbase_class_subject_tda" + suffix + "\n" + "\texam_id,\n" +
// "WHERE\n" + "\tprovince,\n" +
// "\tsubject_type = '常规'\n"; "\tregion1 as region \n" +
// "FROM\n" +
// if (provinceName != null) { "\tbase_class_subject_tda" + suffix + "\n" +
// "WHERE\n" +
// List<String> provinceList = Arrays.asList(provinceName.split("#")); "\tsubject_type = '常规'\n";
//
// String appendStatement = " and province in ("; // 根据特定的省份生成
// if (provinceName != null) {
// for (String s : provinceList) {
// appendStatement = appendStatement + "'" + s + "',"; List<String> provinceList = Arrays.asList(provinceName.split("#"));
// }
// String appendStatement = " and province in (";
// appendStatement = appendStatement.substring(0, appendStatement.length() - 1) + ") ";
// for (String s : provinceList) {
// synthesisSchoolSubjectReportSql = synthesisSchoolSubjectReportSql + " " + appendStatement; appendStatement = appendStatement + "'" + s + "',";
// synthesisSchoolReportSql = synthesisSchoolReportSql + " " + appendStatement; }
// synthesisClassSubjectReportSql = synthesisClassSubjectReportSql + " " + appendStatement;
// synthesisClassReportSql = synthesisClassReportSql + " " + appendStatement; appendStatement = appendStatement.substring(0, appendStatement.length() - 1) + ") ";
//
// synthesisSchoolSubjectReportSql = synthesisSchoolSubjectReportSql + " " + appendStatement;
// } synthesisSchoolReportSql = synthesisSchoolReportSql + " " + appendStatement;
// synthesisClassSubjectReportSql = synthesisClassSubjectReportSql + " " + appendStatement;
// if (schoolName != null) { synthesisClassReportSql = synthesisClassReportSql + " " + appendStatement;
// List<String> schoolList = Arrays.asList(schoolName.split("#"));
//
// String appendStatement = " and school in ("; }
//
// for (String s : schoolList) { // 根据特定的学校生成
// appendStatement = appendStatement + "'" + s + "',"; if (schoolName != null) {
// } List<String> schoolList = Arrays.asList(schoolName.split("#"));
//
// appendStatement = appendStatement.substring(0, appendStatement.length() - 1) + ") "; String appendStatement = " and school in (";
//
// synthesisSchoolSubjectReportSql = synthesisSchoolSubjectReportSql + " " + appendStatement; for (String s : schoolList) {
// synthesisSchoolReportSql = synthesisSchoolReportSql + " " + appendStatement; appendStatement = appendStatement + "'" + s + "',";
// synthesisClassSubjectReportSql = synthesisClassSubjectReportSql + " " + appendStatement; }
// synthesisClassReportSql = synthesisClassReportSql + " " + appendStatement;
// appendStatement = appendStatement.substring(0, appendStatement.length() - 1) + ") ";
// }
// synthesisSchoolSubjectReportSql = synthesisSchoolSubjectReportSql + " " + appendStatement;
// synthesisSchoolSubjectReportSql = synthesisSchoolSubjectReportSql + " group by school,exam_id,province,region1,sub_subject"; synthesisSchoolReportSql = synthesisSchoolReportSql + " " + appendStatement;
// synthesisClassSubjectReportSql = synthesisClassSubjectReportSql + " " + appendStatement;
// synthesisSchoolReportSql = synthesisSchoolReportSql + " " + " group by school,exam_id,province,region1"; synthesisClassReportSql = synthesisClassReportSql + " " + appendStatement;
//
// 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"; synthesisSchoolSubjectReportSql = synthesisSchoolSubjectReportSql + " group by school,exam_id,province,region1,sub_subject";
//
//// System.out.println(1); synthesisSchoolReportSql = synthesisSchoolReportSql + " " + " group by school,exam_id,province,region1";
//// System.out.println(synthesisSchoolSubjectReportSql);
//// synthesisClassSubjectReportSql = synthesisClassSubjectReportSql + " " + "\tGROUP BY\n" + "\tclass,\n" + "\tsub_subject,\n" + "\tschool,\n" + "\tprovince,\n" + "\tregion1,\n" + "\texam_id";
//// System.out.println(2);
//// System.out.println(synthesisSchoolReportSql); synthesisClassReportSql = synthesisClassReportSql + " " + " GROUP BY\n" + "\tclass,\n" + "\tschool,\n" + "\texam_id,\n" + "\tprovince,\n" + "\tregion1\n";
////
//// System.out.println(3); List<BasicReportParameters> synthesisSchoolSubjectReportParameters = this.reportJdbcTemplate.query(synthesisSchoolSubjectReportSql, new Object[]{}, new BeanPropertyRowMapper<>(BasicReportParameters.class));
//// System.out.println(synthesisClassSubjectReportSql);
//// for (BasicReportParameters parameter : synthesisSchoolSubjectReportParameters) {
//// System.out.println(4); if (parameter.getRegion().equals("改革") || parameter.getRegion().equals("改革A") || parameter.getRegion().equals("改革3+3") || parameter.getRegion().equals("改革3+1+2")) {
//// System.out.println(synthesisClassReportSql); 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";
// List<BasicReportParameters> synthesisSchoolSubjectReportParameters = this.reportJdbcTemplate.query(synthesisSchoolSubjectReportSql, new Object[]{}, new BeanPropertyRowMapper<>(BasicReportParameters.class)); 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);
// for (BasicReportParameters parameter : synthesisSchoolSubjectReportParameters) { parameter.setCommand(command);
// if (parameter.getRegion().equals("改革") || parameter.getRegion().equals("改革A") || parameter.getRegion().equals("改革3+3") || parameter.getRegion().equals("改革3+1+2")) { parameter.setPrefix("/myworkSpace/subject/");
// String command = "node /myworkSpace/puppeteer2.js \"http://schoolreport.cssat.cn/pdf/subject?province=condition5&school=condition1&examId=condition4&region=conditionC&subSubject=condition6&subjectType=常规\" pdf"; fileToUrl.put(fileName.replace("/myworkSpace/subject/", ""), "PdfSubject/" + fileName.replace("/myworkSpace/subject/", ""));
// 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()) } else {
// .concat(" ").concat(fileName); 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";
// parameter.setCommand(command); String fileName = "/myworkSpace/subject/" + parameter.getRegion() + parameter.getProvince() + parameter.getSchool() + parameter.getSubSubject() + parameter.getExamId() + ".pdf";
// parameter.setPrefix("/myworkSpace/subject/"); command = command.replace("condition1", parameter.getSchool()).replace("condition5", parameter.getProvince()).replace("condition3", parameter.getRegion()).replace("condition4", parameter.getExamId()).replace("condition6", parameter.getSubSubject())
// fileToUrl.put(fileName.replace("/myworkSpace/subject/", ""), "PdfSubject/" + fileName.replace("/myworkSpace/subject/", "")); .concat(" ").concat(fileName);
// parameter.setCommand(command);
// } else { parameter.setPrefix("/myworkSpace/subject/");
// 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"; fileToUrl.put(fileName.replace("/myworkSpace/subject/", ""), "PdfSubject/" + fileName.replace("/myworkSpace/subject/", ""));
// String fileName = "/myworkSpace/subject/" + parameter.getRegion() + parameter.getProvince() + parameter.getSchool() + parameter.getSubSubject() + parameter.getExamId() + ".pdf"; }
// command = command.replace("condition1", parameter.getSchool()).replace("condition5", parameter.getProvince()).replace("condition3", parameter.getRegion()).replace("condition4", parameter.getExamId()).replace("condition6", parameter.getSubSubject()) }
// .concat(" ").concat(fileName);
// parameter.setCommand(command); List<BasicReportParameters> synthesisSchoolReportParameters = this.reportJdbcTemplate.query(synthesisSchoolReportSql, new Object[]{}, new BeanPropertyRowMapper<>(BasicReportParameters.class));
// parameter.setPrefix("/myworkSpace/subject/");
// fileToUrl.put(fileName.replace("/myworkSpace/subject/", ""), "PdfSubject/" + fileName.replace("/myworkSpace/subject/", "")); for (BasicReportParameters synthesisSchoolReportParameter : synthesisSchoolReportParameters) {
// } if (synthesisSchoolReportParameter.getRegion().equals("改革") || synthesisSchoolReportParameter.getRegion().equals("改革A") || synthesisSchoolReportParameter.getRegion().equals("改革3+3") || synthesisSchoolReportParameter.getRegion().equals("改革3+1+2")) {
// } String command = "node /myworkSpace/puppeteer.js \"http://schoolreport.cssat.cn/pdf/basic?province=condition5&school=condition1&examId=condition4&region=conditionC&subjectType=常规\" pdf ";
// String fileName = "/myworkSpace/basic/" + synthesisSchoolReportParameter.getRegion() + synthesisSchoolReportParameter.getProvince() + synthesisSchoolReportParameter.getSchool() + synthesisSchoolReportParameter.getExamId() + ".pdf";
// List<BasicReportParameters> synthesisSchoolReportParameters = this.reportJdbcTemplate.query(synthesisSchoolReportSql, new Object[]{}, new BeanPropertyRowMapper<>(BasicReportParameters.class)); command = command.replace("condition1", synthesisSchoolReportParameter.getSchool()).replace("condition5", synthesisSchoolReportParameter.getProvince()).replace("conditionC", synthesisSchoolReportParameter.getRegion()).replace("condition4", synthesisSchoolReportParameter.getExamId())
// .concat(" ").concat(fileName);
// for (BasicReportParameters synthesisSchoolReportParameter : synthesisSchoolReportParameters) { synthesisSchoolReportParameter.setCommand(command);
// if (synthesisSchoolReportParameter.getRegion().equals("改革") || synthesisSchoolReportParameter.getRegion().equals("改革A") || synthesisSchoolReportParameter.getRegion().equals("改革3+3") || synthesisSchoolReportParameter.getRegion().equals("改革3+1+2")) { synthesisSchoolReportParameter.setPrefix("/myworkSpace/basic/");
// String command = "node /myworkSpace/puppeteer.js \"http://schoolreport.cssat.cn/pdf/basic?province=condition5&school=condition1&examId=condition4&region=conditionC&subjectType=常规\" pdf "; fileToUrl.put(fileName.replace("/myworkSpace/basic/", ""), "PdfDir/" + fileName.replace("/myworkSpace/basic/", ""));
// String fileName = "/myworkSpace/basic/" + synthesisSchoolReportParameter.getRegion() + synthesisSchoolReportParameter.getProvince() + synthesisSchoolReportParameter.getSchool() + synthesisSchoolReportParameter.getExamId() + ".pdf"; } else {
// command = command.replace("condition1", synthesisSchoolReportParameter.getSchool()).replace("condition5", synthesisSchoolReportParameter.getProvince()).replace("conditionC", synthesisSchoolReportParameter.getRegion()).replace("condition4", synthesisSchoolReportParameter.getExamId()) String command = "node /myworkSpace/puppeteer.js \"http://schoolreport.cssat.cn/pdf/basic?province=condition5&school=condition1&examId=condition4&region=非改革&branch=condition3&subjectType=常规\" pdf ";
// .concat(" ").concat(fileName); String fileName = "/myworkSpace/basic/" + synthesisSchoolReportParameter.getRegion() + synthesisSchoolReportParameter.getProvince() + synthesisSchoolReportParameter.getSchool() + synthesisSchoolReportParameter.getExamId() + ".pdf";
// synthesisSchoolReportParameter.setCommand(command); command = command.replace("condition1", synthesisSchoolReportParameter.getSchool()).replace("condition5", synthesisSchoolReportParameter.getProvince()).replace("condition3", synthesisSchoolReportParameter.getRegion()).replace("condition4", synthesisSchoolReportParameter.getExamId())
// synthesisSchoolReportParameter.setPrefix("/myworkSpace/basic/"); .concat(" ").concat(fileName);
// fileToUrl.put(fileName.replace("/myworkSpace/basic/", ""), "PdfDir/" + fileName.replace("/myworkSpace/basic/", "")); synthesisSchoolReportParameter.setCommand(command);
// } else { synthesisSchoolReportParameter.setPrefix("/myworkSpace/basic/");
// String command = "node /myworkSpace/puppeteer.js \"http://schoolreport.cssat.cn/pdf/basic?province=condition5&school=condition1&examId=condition4&region=非改革&branch=condition3&subjectType=常规\" pdf "; fileToUrl.put(fileName.replace("/myworkSpace/basic/", ""), "PdfDir/" + fileName.replace("/myworkSpace/basic/", ""));
// String fileName = "/myworkSpace/basic/" + synthesisSchoolReportParameter.getRegion() + synthesisSchoolReportParameter.getProvince() + synthesisSchoolReportParameter.getSchool() + synthesisSchoolReportParameter.getExamId() + ".pdf";
// command = command.replace("condition1", synthesisSchoolReportParameter.getSchool()).replace("condition5", synthesisSchoolReportParameter.getProvince()).replace("condition3", synthesisSchoolReportParameter.getRegion()).replace("condition4", synthesisSchoolReportParameter.getExamId()) }
// .concat(" ").concat(fileName); }
// synthesisSchoolReportParameter.setCommand(command);
// synthesisSchoolReportParameter.setPrefix("/myworkSpace/basic/"); List<ClassBasicReportParameters> synthesisClassSubjectReportParameters = this.reportJdbcTemplate.query(synthesisClassSubjectReportSql, new Object[]{}, new BeanPropertyRowMapper<>(ClassBasicReportParameters.class));
// fileToUrl.put(fileName.replace("/myworkSpace/basic/", ""), "PdfDir/" + fileName.replace("/myworkSpace/basic/", ""));
// for (ClassBasicReportParameters synthesisClassSubjectReportParameter : synthesisClassSubjectReportParameters) {
// }
// } if (synthesisClassSubjectReportParameter.getRegion().equals("改革") || synthesisClassSubjectReportParameter.getRegion().equals("改革A") || synthesisClassSubjectReportParameter.getRegion().equals("改革3+3") || synthesisClassSubjectReportParameter.getRegion().equals("改革3+1+2")) {
// String command = "node /myworkSpace/pdfOfClassSubjectGen.js \"http://schoolreport.cssat.cn/pdf/classSubject?province=condition5&school=condition1&examId=condition4&region=conditionC&subSubject=condition6&subjectType=常规&className=conditionA\" pdf";
// List<ClassBasicReportParameters> synthesisClassSubjectReportParameters = this.reportJdbcTemplate.query(synthesisClassSubjectReportSql, new Object[]{}, new BeanPropertyRowMapper<>(ClassBasicReportParameters.class)); 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())
// for (ClassBasicReportParameters synthesisClassSubjectReportParameter : synthesisClassSubjectReportParameters) { .concat(" ").concat(fileName);
// fileToUrl.put(fileName.replace("/myworkSpace/Class/subject/", ""), "/class/" + synthesisClassSubjectReportParameter.getExamId() + "/" + synthesisClassSubjectReportParameter.getProvince() + "/" + synthesisClassSubjectReportParameter.getSchool() + "/班级学科报告/" + synthesisClassSubjectReportParameter.getClassName() + "/" + synthesisClassSubjectReportParameter.getSubSubject() + "/" + fileName.replace("/myworkSpace/Class/subject/", ""));
// if (synthesisClassSubjectReportParameter.getRegion().equals("改革") || synthesisClassSubjectReportParameter.getRegion().equals("改革A") || synthesisClassSubjectReportParameter.getRegion().equals("改革3+3") || synthesisClassSubjectReportParameter.getRegion().equals("改革3+1+2")) { synthesisClassSubjectReportParameter.setCommand(command);
// 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"; synthesisClassSubjectReportParameter.setPrefix("/myworkSpace/Class/subject/");
// String fileName = "/myworkSpace/Class/subject/" + synthesisClassSubjectReportParameter.getRegion() + synthesisClassSubjectReportParameter.getProvince() + synthesisClassSubjectReportParameter.getSchool() + synthesisClassSubjectReportParameter.getSubSubject() + synthesisClassSubjectReportParameter.getExamId() + synthesisClassSubjectReportParameter.getSubSubject() + synthesisClassSubjectReportParameter.getClassName().replace(" ", "") + ".pdf"; } else {
// 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()) 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";
// .concat(" ").concat(fileName);
// fileToUrl.put(fileName.replace("/myworkSpace/Class/subject/", ""), "/class/" + synthesisClassSubjectReportParameter.getExamId() + "/" + synthesisClassSubjectReportParameter.getProvince() + "/" + synthesisClassSubjectReportParameter.getSchool() + "/班级学科报告/" + synthesisClassSubjectReportParameter.getClassName() + "/" + synthesisClassSubjectReportParameter.getSubSubject() + "/" + fileName.replace("/myworkSpace/Class/subject/", "")); String fileName = "/myworkSpace/Class/subject/" + synthesisClassSubjectReportParameter.getRegion() + synthesisClassSubjectReportParameter.getProvince() + synthesisClassSubjectReportParameter.getSchool() + synthesisClassSubjectReportParameter.getSubSubject() + synthesisClassSubjectReportParameter.getExamId() + synthesisClassSubjectReportParameter.getSubSubject() + synthesisClassSubjectReportParameter.getClassName().replace(" ", "") + ".pdf";
// synthesisClassSubjectReportParameter.setCommand(command); 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())
// synthesisClassSubjectReportParameter.setPrefix("/myworkSpace/Class/subject/"); .concat(" ").concat(fileName);
// } else { fileToUrl.put(fileName.replace("/myworkSpace/Class/subject/", ""), "/class/" + synthesisClassSubjectReportParameter.getExamId() + "/" + synthesisClassSubjectReportParameter.getProvince() + "/" + synthesisClassSubjectReportParameter.getSchool() + "/班级学科报告/" + synthesisClassSubjectReportParameter.getClassName() + "/" + synthesisClassSubjectReportParameter.getSubSubject() + "/" + fileName.replace("/myworkSpace/Class/subject/", ""));
// 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"; synthesisClassSubjectReportParameter.setCommand(command);
// synthesisClassSubjectReportParameter.setPrefix("/myworkSpace/Class/subject/");
// String fileName = "/myworkSpace/Class/subject/" + synthesisClassSubjectReportParameter.getRegion() + synthesisClassSubjectReportParameter.getProvince() + synthesisClassSubjectReportParameter.getSchool() + synthesisClassSubjectReportParameter.getSubSubject() + synthesisClassSubjectReportParameter.getExamId() + synthesisClassSubjectReportParameter.getSubSubject() + synthesisClassSubjectReportParameter.getClassName().replace(" ", "") + ".pdf"; }
// command = command.replace("condition1", synthesisClassSubjectReportParameter.getSchool()).replace("condition5", synthesisClassSubjectReportParameter.getProvince()).replace("condition3", synthesisClassSubjectReportParameter.getRegion()).replace("condition4", synthesisClassSubjectReportParameter.getExamId()).replace("condition6", synthesisClassSubjectReportParameter.getSubSubject()).replace("conditionA", synthesisClassSubjectReportParameter.getClassName()) }
// .concat(" ").concat(fileName);
// fileToUrl.put(fileName.replace("/myworkSpace/Class/subject/", ""), "/class/" + synthesisClassSubjectReportParameter.getExamId() + "/" + synthesisClassSubjectReportParameter.getProvince() + "/" + synthesisClassSubjectReportParameter.getSchool() + "/班级学科报告/" + synthesisClassSubjectReportParameter.getClassName() + "/" + synthesisClassSubjectReportParameter.getSubSubject() + "/" + fileName.replace("/myworkSpace/Class/subject/", "")); List<ClassBasicReportParameters> synthesisClassReportParameters = this.reportJdbcTemplate.query(synthesisClassReportSql, new Object[]{}, new BeanPropertyRowMapper<>(ClassBasicReportParameters.class));
// synthesisClassSubjectReportParameter.setCommand(command);
// synthesisClassSubjectReportParameter.setPrefix("/myworkSpace/Class/subject/"); for (ClassBasicReportParameters synthesisClassReportParameter : synthesisClassReportParameters) {
// }
// } if (synthesisClassReportParameter.getRegion().equals("改革") || synthesisClassReportParameter.getRegion().equals("改革A") || synthesisClassReportParameter.getRegion().equals("改革3+3") || synthesisClassReportParameter.getRegion().equals("改革3+1+2")) {
//
// List<ClassBasicReportParameters> synthesisClassReportParameters = this.reportJdbcTemplate.query(synthesisClassReportSql, new Object[]{}, new BeanPropertyRowMapper<>(ClassBasicReportParameters.class)); String command = "node /myworkSpace/pdfOfClassBasicGen.js \"http://schoolreport.cssat.cn/pdf/classBasic?province=condition5&school=condition1&examId=condition4&region=conditionC&subjectType=常规&className=conditionA\" pdf ";
//
// for (ClassBasicReportParameters synthesisClassReportParameter : synthesisClassReportParameters) { String fileName = "/myworkSpace/Class/Basic/" + synthesisClassReportParameter.getRegion() + synthesisClassReportParameter.getProvince() + synthesisClassReportParameter.getSchool() + synthesisClassReportParameter.getClassName() + synthesisClassReportParameter.getExamId() + ".pdf";
//
// if (synthesisClassReportParameter.getRegion().equals("改革") || synthesisClassReportParameter.getRegion().equals("改革A") || synthesisClassReportParameter.getRegion().equals("改革3+3") || synthesisClassReportParameter.getRegion().equals("改革3+1+2")) { 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);
// String command = "node /myworkSpace/pdfOfClassBasicGen.js \"http://schoolreport.cssat.cn/pdf/classBasic?province=condition5&school=condition1&examId=condition4&region=conditionC&subjectType=常规&className=conditionA\" pdf ";
// fileToUrl.put(fileName.replace("/myworkSpace/Class/Basic/", ""), "/class/" + synthesisClassReportParameter.getExamId() + "/" + synthesisClassReportParameter.getProvince() + "/" + synthesisClassReportParameter.getSchool() + "/班级综合报告/" + synthesisClassReportParameter.getClassName() + "/" + fileName.replace("/myworkSpace/Class/Basic/", ""));
// String fileName = "/myworkSpace/Class/Basic/" + synthesisClassReportParameter.getRegion() + synthesisClassReportParameter.getProvince() + synthesisClassReportParameter.getSchool() + synthesisClassReportParameter.getClassName() + synthesisClassReportParameter.getExamId() + ".pdf";
// synthesisClassReportParameter.setCommand(command);
// 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); synthesisClassReportParameter.setPrefix("/myworkSpace/Class/Basic/");
//
// fileToUrl.put(fileName.replace("/myworkSpace/Class/Basic/", ""), "/class/" + synthesisClassReportParameter.getExamId() + "/" + synthesisClassReportParameter.getProvince() + "/" + synthesisClassReportParameter.getSchool() + "/班级综合报告/" + synthesisClassReportParameter.getClassName() + "/" + fileName.replace("/myworkSpace/Class/Basic/", "")); } else {
//
// synthesisClassReportParameter.setCommand(command); 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 ";
//
// synthesisClassReportParameter.setPrefix("/myworkSpace/Class/Basic/"); String fileName = "/myworkSpace/Class/Basic/" + synthesisClassReportParameter.getRegion() + synthesisClassReportParameter.getProvince() + synthesisClassReportParameter.getSchool() + synthesisClassReportParameter.getClassName() + synthesisClassReportParameter.getExamId() + ".pdf";
//
// } else { 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);
// 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 ";
// fileToUrl.put(fileName.replace("/myworkSpace/Class/Basic/", ""), "/class/" + synthesisClassReportParameter.getExamId() + "/" + synthesisClassReportParameter.getProvince() + "/" + synthesisClassReportParameter.getSchool() + "/班级综合报告/" + synthesisClassReportParameter.getClassName() + "/" + fileName.replace("/myworkSpace/Class/Basic/", ""));
// String fileName = "/myworkSpace/Class/Basic/" + synthesisClassReportParameter.getRegion() + synthesisClassReportParameter.getProvince() + synthesisClassReportParameter.getSchool() + synthesisClassReportParameter.getClassName() + synthesisClassReportParameter.getExamId() + ".pdf";
// synthesisClassReportParameter.setCommand(command);
// 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); synthesisClassReportParameter.setPrefix("/myworkSpace/Class/Basic/");
//
// fileToUrl.put(fileName.replace("/myworkSpace/Class/Basic/", ""), "/class/" + synthesisClassReportParameter.getExamId() + "/" + synthesisClassReportParameter.getProvince() + "/" + synthesisClassReportParameter.getSchool() + "/班级综合报告/" + synthesisClassReportParameter.getClassName() + "/" + fileName.replace("/myworkSpace/Class/Basic/", "")); }
// }
// synthesisClassReportParameter.setCommand(command);
// for (String s : fileToUrl.keySet()) {
// synthesisClassReportParameter.setPrefix("/myworkSpace/Class/Basic/"); System.out.println("file="+s+"==mapto=="+"key="+fileToUrl.get(s));
// }
// }
// } Map<String, List<BasicReportParameters>> schoolReport = synthesisSchoolReportParameters.stream().collect(Collectors.groupingBy(BasicReportParameters::getProvince));
//
//// for (String s : fileToUrl.keySet()) { Map<String, List<BasicReportParameters>> schoolSubjectReport = synthesisSchoolSubjectReportParameters.stream().collect(Collectors.groupingBy(BasicReportParameters::getProvince));
//// System.out.println("file="+s+"==mapto=="+"key="+fileToUrl.get(s));
//// } Map<String, List<ClassBasicReportParameters>> classReport = synthesisClassReportParameters.stream().collect(Collectors.groupingBy(ClassBasicReportParameters::getProvince));
//
// Map<String, List<BasicReportParameters>> schoolReport = synthesisSchoolReportParameters.stream().collect(Collectors.groupingBy(BasicReportParameters::getProvince)); Map<String, List<ClassBasicReportParameters>> classSubjectReport = synthesisClassSubjectReportParameters.stream().collect(Collectors.groupingBy(ClassBasicReportParameters::getProvince));
//
// Map<String, List<BasicReportParameters>> schoolSubjectReport = synthesisSchoolSubjectReportParameters.stream().collect(Collectors.groupingBy(BasicReportParameters::getProvince)); // 分组开始执行记录
// for (String key : schoolReport.keySet()) {
// Map<String, List<ClassBasicReportParameters>> classReport = synthesisClassReportParameters.stream().collect(Collectors.groupingBy(ClassBasicReportParameters::getProvince)); logger.info("province:" + key + "Gen");
// List<BasicReportParameters> schoolBasicReport = schoolReport.get(key);
// Map<String, List<ClassBasicReportParameters>> classSubjectReport = synthesisClassSubjectReportParameters.stream().collect(Collectors.groupingBy(ClassBasicReportParameters::getProvince)); List<BasicReportParameters> schoolSubject = schoolSubjectReport.get(key);
// List<ClassBasicReportParameters> classBasicReport = classReport.get(key);
//// 分组开始执行记录 List<ClassBasicReportParameters> classSubject = classSubjectReport.get(key);
// for (String key : schoolReport.keySet()) { for (BasicReportParameters schoolLevel : schoolBasicReport) {
// logger.info("province:" + key + "Gen"); List<RetryCommand> retryCommands = new ArrayList<>();
// List<BasicReportParameters> schoolBasicReport = schoolReport.get(key); logger.info("school:" + schoolLevel.getSchool() + "loading");
// List<BasicReportParameters> schoolSubject = schoolSubjectReport.get(key); Map<String, List<BasicReportParameters>> schoolMap = schoolSubject.stream().collect(Collectors.groupingBy(BasicReportParameters::getSchool));
// List<ClassBasicReportParameters> classBasicReport = classReport.get(key); Map<String, List<ClassBasicReportParameters>> classBasic = classBasicReport.stream().collect(Collectors.groupingBy(ClassBasicReportParameters::getSchool));
// List<ClassBasicReportParameters> classSubject = classSubjectReport.get(key); final Map<String, List<ClassBasicReportParameters>> subjectClass = classSubject.stream().collect(Collectors.groupingBy(ClassBasicReportParameters::getSchool));
// for (BasicReportParameters schoolLevel : schoolBasicReport) { List<BasicReportParameters> schoolSelf = schoolMap.get(schoolLevel.getSchool());
// List<RetryCommand> retryCommands = new ArrayList<>(); logger.info("basicReport:loading");
// logger.info("school:" + schoolLevel.getSchool() + "loading"); logger.info("exitCode:" + schoolLevel.getSchool());
// Map<String, List<BasicReportParameters>> schoolMap = schoolSubject.stream().collect(Collectors.groupingBy(BasicReportParameters::getSchool)); ProcessBuilder processBuilder = new ProcessBuilder();
// Map<String, List<ClassBasicReportParameters>> classBasic = classBasicReport.stream().collect(Collectors.groupingBy(ClassBasicReportParameters::getSchool)); processBuilder.command("bash", "-c", schoolLevel.getCommand());
// final Map<String, List<ClassBasicReportParameters>> subjectClass = classSubject.stream().collect(Collectors.groupingBy(ClassBasicReportParameters::getSchool)); processBuilder.redirectErrorStream(true); // 合并标准输出和错误输出
// List<BasicReportParameters> schoolSelf = schoolMap.get(schoolLevel.getSchool()); Process process = null;
// logger.info("basicReport:loading"); try {
// logger.info("exitCode:" + schoolLevel.getSchool()); process = processBuilder.start();
//// ProcessBuilder processBuilder = new ProcessBuilder(); } catch (IOException e) {
//// processBuilder.command("bash", "-c", schoolLevel.getCommand()); throw new RuntimeException(e);
//// processBuilder.redirectErrorStream(true); // 合并标准输出和错误输出 }
//// Process process = null; BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
//// try { String line;
//// process = processBuilder.start(); while (true) {
//// } catch (IOException e) { try {
//// throw new RuntimeException(e); if (!((line = reader.readLine()) != null)) break;
//// } } catch (IOException e) {
//// BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream())); throw new RuntimeException(e);
//// String line; }
//// while (true) { }
//// try { // while ((line = reader.readLine()) != null) {
//// if (!((line = reader.readLine()) != null)) break; // // 如果输出了 "DONE",表示生成完毕
//// } catch (IOException e) { // if ("DONE".equals(line)) {
//// throw new RuntimeException(e); // break; // 跳出循环
//// } // }
//// }
////// while ((line = reader.readLine()) != null) {
////// // 如果输出了 "DONE",表示生成完毕
////// if ("DONE".equals(line)) {
////// break; // 跳出循环
////// }
////// }
//// try {
//// int exitCode = process.waitFor();
//// } catch (InterruptedException e) {
//// throw new RuntimeException(e);
//// }
// //上传文件
//// File basicFile = new File("/myworkSpace/basic/");
//// File[] basicFiles = basicFile.listFiles();
//// assert basicFiles != null;
//// for (File file : basicFiles) {
//// PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, fileToUrl.get(file.getName()), file);
//// try {
//// PutObjectResult putObjectResult = cosClient.putObject(putObjectRequest);
//// logger.info(putObjectResult.getRequestId());
//// file.delete();
//// } catch (CosServiceException e) {
//// logger.info("cos服务出现问题");
//// e.printStackTrace();
//// } catch (CosClientException e) {
//// logger.info("cos客户端出现问题"+file.getName()+"文件上传有误,重新上传");
//// RetryCommand retryCommand = new RetryCommand();
//// retryCommand.setRetryCommand(schoolLevel.getCommand());
//// retryCommand.setParams(schoolLevel);
//// retryCommands.add(retryCommand);
//// e.printStackTrace();
//// }
//// }
// for (BasicReportParameters parameters : schoolSelf) {
// logger.info("subjectReport:loading");
//
//// String subSubject = parameters.getSubSubject();
//// if (!subSubject.equals("生物") && !subSubject.equals("历史")) {
//// continue;
//// }
// logger.info("exitCode:" + parameters.getSubSubject());
//// ProcessBuilder processBuilderSubject = new ProcessBuilder();
//// processBuilderSubject.command("bash", "-c", parameters.getCommand());
//// processBuilderSubject.redirectErrorStream(true); // 合并标准输出和错误输出
//// Process processSubject = null;
//// try {
//// processSubject = processBuilderSubject.start();
//// } catch (IOException e) {
//// throw new RuntimeException(e);
//// }
//// BufferedReader readerSubject = new BufferedReader(new InputStreamReader(processSubject.getInputStream()));
//// String lineSubject;
//// while (true) {
//// try {
//// if (!((lineSubject = readerSubject.readLine()) != null)) break;
//// } catch (IOException e) {
//// throw new RuntimeException(e);
//// }
//// }
////// while ((lineSubject = readerSubject.readLine()) != null) {
////// // 如果输出了 "DONE",表示生成完毕
////// if ("DONE".equals(lineSubject)) {
////// break; // 跳出循环
////// }
////// }
//// try {
//// int exitCodeSubject = processSubject.waitFor();
//// } catch (InterruptedException e) {
//// throw new RuntimeException(e);
//// }
//// File subjectFile = new File("/myworkSpace/subject/");
//// File[] subjectFiles = subjectFile.listFiles();
//// assert subjectFiles != null;
//// for (File file : subjectFiles) {
//// PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, fileToUrl.get(file.getName()), file);
//// try {
//// PutObjectResult putObjectResult = cosClient.putObject(putObjectRequest);
//// logger.info(putObjectResult.getRequestId());
//// file.delete();
//// } catch (CosServiceException e) {
//// logger.info("cos服务出现问题");
//// e.printStackTrace();
//// } catch (CosClientException e) {
//// logger.info("cos客户端出现问题"+file.getName()+"文件上传有误,重新上传");
//// RetryCommand retryCommand = new RetryCommand();
//// retryCommand.setParams(parameters);
//// retryCommand.setRetryCommand(parameters.getCommand());
//// retryCommands.add(retryCommand);
//// e.printStackTrace();
//// }
//// }
// }
// List<ClassBasicReportParameters> args = classBasic.get(schoolLevel.getSchool());
// List<ClassBasicReportParameters> params = subjectClass.get(schoolLevel.getSchool());
// for (ClassBasicReportParameters arg : args) {
// logger.info("classBasic:loading");
// logger.info("exitCode:" + arg.getClassName());
// ProcessBuilder processBuilderClass = new ProcessBuilder();
// processBuilderClass.command("bash", "-c", arg.getCommand());
// processBuilderClass.redirectErrorStream(true); // 合并标准输出和错误输出
// Process processClass = null;
// try {
// processClass = processBuilderClass.start();
// } catch (IOException e) {
// throw new RuntimeException(e);
// }
// BufferedReader readerClass = new BufferedReader(new InputStreamReader(processClass.getInputStream()));
// String lineClass;
// while (true) {
// try {
// if (!((lineClass = readerClass.readLine()) != null)) break;
// } catch (IOException e) {
// throw new RuntimeException(e);
// }
// }
//// while ((lineClass = readerClass.readLine()) != null) {
//// // 如果输出了 "DONE",表示生成完毕
//// if ("DONE".equals(lineClass)) {
//// break; // 跳出循环
//// }
//// }
// try {
// int exitCodeSubject = processClass.waitFor();
// } catch (InterruptedException e) {
// throw new RuntimeException(e);
// } // }
//// File classBasicFile = new File("/myworkSpace/Class/Basic/"); try {
//// File[] classBasicFiles = classBasicFile.listFiles(); int exitCode = process.waitFor();
//// assert classBasicFiles != null; } catch (InterruptedException e) {
//// for (File file : classBasicFiles) { throw new RuntimeException(e);
//// PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, fileToUrl.get(file.getName()), file); }
//// try { for (BasicReportParameters parameters : schoolSelf) {
//// PutObjectResult putObjectResult = cosClient.putObject(putObjectRequest); logger.info("subjectReport:loading");
//// logger.info(putObjectResult.getRequestId());
//// file.delete(); // String subSubject = parameters.getSubSubject();
//// } catch (CosServiceException e) { // if (!subSubject.equals("生物") && !subSubject.equals("历史")) {
//// logger.info("cos服务出现问题"); // continue;
//// e.printStackTrace();
//// } catch (CosClientException e) {
//// logger.info("cos客户端出现问题"+file.getName()+"文件上传有误,重新上传");
//// RetryCommand retryCommand = new RetryCommand();
//// retryCommand.setParams(arg);
//// retryCommand.setRetryCommand(arg.getCommand());
//// retryCommands.add(retryCommand);
//// e.printStackTrace();
//// }
//// }
// final Map<String, List<ClassBasicReportParameters>> collect = params.stream().collect(Collectors.groupingBy(ClassBasicReportParameters::getClassName));
// List<ClassBasicReportParameters> list = collect.get(arg.getClassName());
// for (ClassBasicReportParameters classBasicReportParameters : list) {
//// String subSubject = classBasicReportParameters.getSubSubject();
//// if (!subSubject.equals("历史")) {
//// continue;
//// }
////
//// logger.info("classSubject:loading");
//// logger.info("exitCode:" + classBasicReportParameters.getSubSubject());
//// ProcessBuilder processBuilderClassSubject = new ProcessBuilder();
//// processBuilderClassSubject.command("bash", "-c", classBasicReportParameters.getCommand());
//// processBuilderClassSubject.redirectErrorStream(true); // 合并标准输出和错误输出
//// Process processClassSubject = null;
//// try {
//// processClassSubject = processBuilderClassSubject.start();
//// } catch (IOException e) {
//// throw new RuntimeException(e);
//// }
//// BufferedReader readerClassSubject = new BufferedReader(new InputStreamReader(processClassSubject.getInputStream()));
//// String lineClassSubject;
//// while (true) {
//// try {
//// if (!((lineClassSubject = readerClassSubject.readLine()) != null)) break;
//// } catch (IOException e) {
//// throw new RuntimeException(e);
//// }
//// }
////// while ((lineClassSubject = readerClassSubject.readLine()) != null) {
////// // 如果输出了 "DONE",表示生成完毕
////// if ("DONE".equals(lineClassSubject)) {
////// break; // 跳出循环
////// }
////// }
//// try {
//// int exitCodeSubjectClass = processClassSubject.waitFor();
//// } catch (InterruptedException e) {
//// throw new RuntimeException(e);
//// }
//// File classSubjectFile = new File("/myworkSpace/Class/subject/");
//// File[] classSubjectFiles = classSubjectFile.listFiles();
//// assert classSubjectFiles != null;
//// for (File file : classSubjectFiles) {
//// logger.info(file.getName()+"=file—>key="+fileToUrl.get(file.getName()));
//// PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, fileToUrl.get(file.getName()), file);
//// try {
//// PutObjectResult putObjectResult = cosClient.putObject(putObjectRequest);
//// logger.info(putObjectResult.getRequestId());
//// file.delete();
//// } catch (CosServiceException e) {
//// logger.info("cos服务出现问题");
//// e.printStackTrace();
//// } catch (CosClientException e) {
//// logger.info("cos客户端出现问题"+file.getName()+"文件上传有误,重新上传");
//// RetryCommand retryCommand = new RetryCommand();
//// retryCommand.setParams(classBasicReportParameters);
//// retryCommand.setRetryCommand(classBasicReportParameters.getCommand());
//// retryCommands.add(retryCommand);
//// e.printStackTrace();
//// }
//// }
// } // }
// } logger.info("exitCode:" + parameters.getSubSubject());
// ProcessBuilder processBuilderSubject = new ProcessBuilder();
// if (retryCommands.size() != 0) { processBuilderSubject.command("bash", "-c", parameters.getCommand());
// logger.info("size" + retryCommands.size()); processBuilderSubject.redirectErrorStream(true); // 合并标准输出和错误输出
// for (RetryCommand retryCommand : retryCommands) { Process processSubject = null;
// String command = retryCommand.getRetryCommand(); try {
// Object arguments = retryCommand.getParams(); processSubject = processBuilderSubject.start();
// String filePrefix = ""; } catch (IOException e) {
// if (arguments instanceof BasicReportParameters) { throw new RuntimeException(e);
// BasicReportParameters parametersOne = (BasicReportParameters) arguments; }
// filePrefix = parametersOne.getPrefix(); BufferedReader readerSubject = new BufferedReader(new InputStreamReader(processSubject.getInputStream()));
// } String lineSubject;
// if (arguments instanceof ClassBasicReportParameters) { while (true) {
// ClassBasicReportParameters parametersTwo = (ClassBasicReportParameters) arguments; try {
// filePrefix = parametersTwo.getPrefix(); if (!((lineSubject = readerSubject.readLine()) != null)) break;
// } } catch (IOException e) {
// throw new RuntimeException(e);
// logger.info("RetryCommand:ls"); }
// ProcessBuilder processBuilderClassSubject = new ProcessBuilder(); }
// processBuilderClassSubject.command("bash", "-c", command); // while ((lineSubject = readerSubject.readLine()) != null) {
// processBuilderClassSubject.redirectErrorStream(true); // 合并标准输出和错误输出 // // 如果输出了 "DONE",表示生成完毕
// Process processClassSubject = null; // if ("DONE".equals(lineSubject)) {
// try { // break; // 跳出循环
// processClassSubject = processBuilderClassSubject.start(); // }
// } catch (IOException e) {
// throw new RuntimeException(e);
// } // }
// BufferedReader readerClassSubject = new BufferedReader(new InputStreamReader(processClassSubject.getInputStream())); try {
// String lineClassSubject; int exitCodeSubject = processSubject.waitFor();
// while (true) { } catch (InterruptedException e) {
// try { throw new RuntimeException(e);
// if (!((lineClassSubject = readerClassSubject.readLine()) != null)) break; }
// } catch (IOException e) { }
// throw new RuntimeException(e); List<ClassBasicReportParameters> args = classBasic.get(schoolLevel.getSchool());
List<ClassBasicReportParameters> params = subjectClass.get(schoolLevel.getSchool());
for (ClassBasicReportParameters arg : args) {
logger.info("classBasic:loading");
logger.info("exitCode:" + arg.getClassName());
ProcessBuilder processBuilderClass = new ProcessBuilder();
processBuilderClass.command("bash", "-c", arg.getCommand());
processBuilderClass.redirectErrorStream(true); // 合并标准输出和错误输出
Process processClass = null;
try {
processClass = processBuilderClass.start();
} catch (IOException e) {
throw new RuntimeException(e);
}
BufferedReader readerClass = new BufferedReader(new InputStreamReader(processClass.getInputStream()));
String lineClass;
while (true) {
try {
if (!((lineClass = readerClass.readLine()) != null)) break;
} catch (IOException e) {
throw new RuntimeException(e);
}
}
// while ((lineClass = readerClass.readLine()) != null) {
// // 如果输出了 "DONE",表示生成完毕
// if ("DONE".equals(lineClass)) {
// break; // 跳出循环
// } // }
// } // }
//// while ((lineClassSubject = readerClassSubject.readLine()) != null) { try {
//// // 如果输出了 "DONE",表示生成完毕 int exitCodeSubject = processClass.waitFor();
//// if ("DONE".equals(lineClassSubject)) { } catch (InterruptedException e) {
//// break; // 跳出循环 throw new RuntimeException(e);
//// } }
//// }
// try { final Map<String, List<ClassBasicReportParameters>> collect = params.stream().collect(Collectors.groupingBy(ClassBasicReportParameters::getClassName));
// int exitCodeSubjectClass = processClassSubject.waitFor(); List<ClassBasicReportParameters> list = collect.get(arg.getClassName());
// } catch (InterruptedException e) { for (ClassBasicReportParameters classBasicReportParameters : list) {
// throw new RuntimeException(e); // String subSubject = classBasicReportParameters.getSubSubject();
// if (!subSubject.equals("历史")) {
// continue;
// } // }
//// 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()+"文件上传有误,重新上传");
//// }
//// }
// //
// } logger.info("classSubject:loading");
// logger.info("exitCode:" + classBasicReportParameters.getSubSubject());
// } ProcessBuilder processBuilderClassSubject = new ProcessBuilder();
// processBuilderClassSubject.command("bash", "-c", classBasicReportParameters.getCommand());
// //插入数据 processBuilderClassSubject.redirectErrorStream(true); // 合并标准输出和错误输出
// 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()); Process processClassSubject = null;
// try {
// logger.info("Rows affected:" + rowsAffected); processClassSubject = processBuilderClassSubject.start();
// } } catch (IOException e) {
// } throw new RuntimeException(e);
// }
// BufferedReader readerClassSubject = new BufferedReader(new InputStreamReader(processClassSubject.getInputStream()));
// return ResponseEntity.ok("操作成功"); String lineClassSubject;
// while (true) {
// } try {
// if (!((lineClassSubject = readerClassSubject.readLine()) != null)) break;
//} } catch (IOException e) {
throw new RuntimeException(e);
}
}
// while ((lineClassSubject = readerClassSubject.readLine()) != null) {
// // 如果输出了 "DONE",表示生成完毕
// if ("DONE".equals(lineClassSubject)) {
// break; // 跳出循环
// }
// }
try {
int exitCodeSubjectClass = processClassSubject.waitFor();
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
}
if (retryCommands.size() != 0) {
logger.info("size" + retryCommands.size());
for (RetryCommand retryCommand : retryCommands) {
String command = retryCommand.getRetryCommand();
Object arguments = retryCommand.getParams();
String filePrefix = "";
if (arguments instanceof BasicReportParameters) {
BasicReportParameters parametersOne = (BasicReportParameters) arguments;
filePrefix = parametersOne.getPrefix();
}
if (arguments instanceof ClassBasicReportParameters) {
ClassBasicReportParameters parametersTwo = (ClassBasicReportParameters) arguments;
filePrefix = parametersTwo.getPrefix();
}
logger.info("RetryCommand:ls");
ProcessBuilder processBuilderClassSubject = new ProcessBuilder();
processBuilderClassSubject.command("bash", "-c", command);
processBuilderClassSubject.redirectErrorStream(true); // 合并标准输出和错误输出
Process processClassSubject = null;
try {
processClassSubject = processBuilderClassSubject.start();
} catch (IOException e) {
throw new RuntimeException(e);
}
BufferedReader readerClassSubject = new BufferedReader(new InputStreamReader(processClassSubject.getInputStream()));
String lineClassSubject;
while (true) {
try {
if (!((lineClassSubject = readerClassSubject.readLine()) != null)) break;
} catch (IOException e) {
throw new RuntimeException(e);
}
}
// while ((lineClassSubject = readerClassSubject.readLine()) != null) {
// // 如果输出了 "DONE",表示生成完毕
// if ("DONE".equals(lineClassSubject)) {
// break; // 跳出循环
// }
// }
try {
int exitCodeSubjectClass = processClassSubject.waitFor();
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
// File classSubjectFile = new File(filePrefix);
// File[] classSubjectFiles = classSubjectFile.listFiles();
// assert classSubjectFiles != null;
// for (File file : classSubjectFiles) {
// logger.info(file.getName()+"=file—>key="+fileToUrl.get(file.getName()));
// PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, fileToUrl.get(file.getName()), file);
// try {
// PutObjectResult putObjectResult = cosClient.putObject(putObjectRequest);
// logger.info(putObjectResult.getRequestId());
// file.delete();
// } catch (CosServiceException e) {
// logger.info("cos服务出现问题");
// e.printStackTrace();
// } catch (CosClientException e) {
// logger.info("cos客户端出现问题"+file.getName()+"文件上传有误,重新上传");
// }
// }
}
}
//插入数据
int rowsAffected = reportJdbcTemplate.update("UPDATE school_report_task_generate SET status = ? WHERE exam_id = ? AND region = ? AND province = ? AND school = ?", 1, schoolLevel.getExamId(), schoolLevel.getRegion(), schoolLevel.getProvince(), schoolLevel.getSchool());
logger.info("Rows affected:" + rowsAffected);
}
}
return ResponseEntity.ok("操作成功");
}
}
package com.example.pdfgenerator.controller; //package com.example.pdfgenerator.controller;
//
import com.example.pdfgenerator.Dto.BasicReportParameters; //import com.example.pdfgenerator.Dto.BasicReportParameters;
import com.example.pdfgenerator.Dto.ClassBasicReportParameters; //import com.example.pdfgenerator.Dto.ClassBasicReportParameters;
import com.example.pdfgenerator.Dto.RetryCommand; //import com.example.pdfgenerator.Dto.RetryCommand;
import com.example.pdfgenerator.config.MyDataSourceConfig; //import com.example.pdfgenerator.config.MyDataSourceConfig;
import com.qcloud.cos.COSClient; //import com.qcloud.cos.COSClient;
import org.slf4j.Logger; //import org.slf4j.Logger;
import org.slf4j.LoggerFactory; //import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; //import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity; //import org.springframework.http.ResponseEntity;
import org.springframework.jdbc.core.BeanPropertyRowMapper; //import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate; //import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.RequestMapping; //import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; //import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; //import org.springframework.web.bind.annotation.RestController;
//
import java.io.BufferedReader; //import java.io.BufferedReader;
import java.io.IOException; //import java.io.IOException;
import java.io.InputStreamReader; //import java.io.InputStreamReader;
import java.util.*; //import java.util.*;
import java.util.stream.Collectors; //import java.util.stream.Collectors;
//
//
@RestController //@RestController
@RequestMapping("/pdf") //@RequestMapping("/pdf")
public class GeneratorAllTypePdfByProvinceXxController { //public class GeneratorAllTypePdfByProvinceXxController {
//
private static final Logger logger = LoggerFactory.getLogger(GeneratorAllTypePdfByProvinceXxController.class); // private static final Logger logger = LoggerFactory.getLogger(GeneratorAllTypePdfByProvinceXxController.class);
//
@Autowired // @Autowired
private COSClient cosClient; // private COSClient cosClient;
//
private static final String bucketName = "schoolreportpdf-1317275686"; // private static final String bucketName = "schoolreportpdf-1317275686";
//
//
private static Map<String,String> fileToUrl = new HashMap<>(); // private static Map<String,String> fileToUrl = new HashMap<>();
//
JdbcTemplate reportJdbcTemplate = MyDataSourceConfig.getReportJdbcTemplate(); // JdbcTemplate reportJdbcTemplate = MyDataSourceConfig.getReportJdbcTemplate();
//
//
@RequestMapping("/GeneratorByProvinceName") // @RequestMapping("/GeneratorByProvinceName")
public ResponseEntity generatorName(@RequestParam("examId")String examId, @RequestParam(value = "provinceName",required = false)String provinceName,@RequestParam(value = "schoolName",required = false)String schoolName) throws IOException, InterruptedException { // public ResponseEntity generatorName(@RequestParam("examId")String examId, @RequestParam(value = "provinceName",required = false)String provinceName,@RequestParam(value = "schoolName",required = false)String schoolName) throws IOException, InterruptedException {
//
String suffix = examId.trim().replace("TDA","").replace("G3","").replace("G2","").replace("G10","").replace("G11","").replace("G12","").trim(); // String suffix = examId.trim().replace("TDA","").replace("G3","").replace("G2","").replace("G10","").replace("G11","").replace("G12","").trim();
//
String synthesisSchoolSubjectReportSql = "select \n" + // String synthesisSchoolSubjectReportSql = "select \n" +
"school,exam_id,province,region1 as region,sub_subject\n" + // "school,exam_id,province,region1 as region,sub_subject\n" +
"from \n" + // "from \n" +
"base_school_subject_tda"+suffix+" \n" + // "base_school_subject_tda"+suffix+" \n" +
" where subject_type = '常规' \n"; // " where subject_type = '常规' \n";
//
String synthesisSchoolReportSql = "select \n" + // String synthesisSchoolReportSql = "select \n" +
"school,exam_id,province,region1 as region\n" + // "school,exam_id,province,region1 as region\n" +
"from \n" + // "from \n" +
"base_school_subject_tda"+suffix+" where subject_type = '常规' \n"; // "base_school_subject_tda"+suffix+" where subject_type = '常规' \n";
//
String synthesisClassSubjectReportSql = "SELECT\n" + // String synthesisClassSubjectReportSql = "SELECT\n" +
"\tclass as class_name,\n" + // "\tclass as class_name,\n" +
"\tsub_subject,\n" + // "\tsub_subject,\n" +
"\tschool,\n" + // "\tschool,\n" +
"\tprovince,\n" + // "\tprovince,\n" +
"\tregion1 as region,\n" + // "\tregion1 as region,\n" +
"\texam_id\n" + // "\texam_id\n" +
"FROM\n" + // "FROM\n" +
"\tbase_student_subject_tda"+suffix+"\n" + // "\tbase_student_subject_tda"+suffix+"\n" +
"where\n" + // "where\n" +
"subject_type = '常规' \n " ; // "subject_type = '常规' \n " ;
//
String synthesisClassReportSql = "SELECT\n" + // String synthesisClassReportSql = "SELECT\n" +
"\tclass AS class_name,\n" + // "\tclass AS class_name,\n" +
"\tschool,\n" + // "\tschool,\n" +
"\texam_id,\n" + // "\texam_id,\n" +
"\tprovince,\n" + // "\tprovince,\n" +
"\tregion1 as region \n" + // "\tregion1 as region \n" +
"FROM\n" + // "FROM\n" +
"\tbase_class_subject_tda"+suffix+"\n" + // "\tbase_class_subject_tda"+suffix+"\n" +
"WHERE\n" + // "WHERE\n" +
"\tsubject_type = '常规'\n" ; // "\tsubject_type = '常规'\n" ;
//
if(provinceName!=null){ // if(provinceName!=null){
//
List<String> provinceList = Arrays.asList(provinceName.split("#")); // List<String> provinceList = Arrays.asList(provinceName.split("#"));
//
String appendStatement = " and province in (" ; // String appendStatement = " and province in (" ;
//
for (String s : provinceList) { // for (String s : provinceList) {
appendStatement = appendStatement +"'"+s+"',"; // appendStatement = appendStatement +"'"+s+"',";
} // }
//
appendStatement = appendStatement.substring(0,appendStatement.length()-1)+") "; // appendStatement = appendStatement.substring(0,appendStatement.length()-1)+") ";
//
synthesisSchoolSubjectReportSql = synthesisSchoolSubjectReportSql + " " + appendStatement; // synthesisSchoolSubjectReportSql = synthesisSchoolSubjectReportSql + " " + appendStatement;
synthesisSchoolReportSql = synthesisSchoolReportSql + " " + appendStatement ; // synthesisSchoolReportSql = synthesisSchoolReportSql + " " + appendStatement ;
synthesisClassSubjectReportSql = synthesisClassSubjectReportSql + " " + appendStatement; // synthesisClassSubjectReportSql = synthesisClassSubjectReportSql + " " + appendStatement;
synthesisClassReportSql = synthesisClassReportSql + " " + appendStatement; // synthesisClassReportSql = synthesisClassReportSql + " " + appendStatement;
//
//
} // }
//
if(schoolName!=null){ // if(schoolName!=null){
List<String> schoolList = Arrays.asList(schoolName.split("#")); // List<String> schoolList = Arrays.asList(schoolName.split("#"));
//
String appendStatement = " and school in (" ; // String appendStatement = " and school in (" ;
//
for (String s : schoolList) { // for (String s : schoolList) {
appendStatement = appendStatement +"'"+s+"',"; // appendStatement = appendStatement +"'"+s+"',";
} // }
//
appendStatement = appendStatement.substring(0,appendStatement.length()-1)+") "; // appendStatement = appendStatement.substring(0,appendStatement.length()-1)+") ";
//
synthesisSchoolSubjectReportSql = synthesisSchoolSubjectReportSql + " " + appendStatement; // synthesisSchoolSubjectReportSql = synthesisSchoolSubjectReportSql + " " + appendStatement;
synthesisSchoolReportSql = synthesisSchoolReportSql + " " + appendStatement ; // synthesisSchoolReportSql = synthesisSchoolReportSql + " " + appendStatement ;
synthesisClassSubjectReportSql = synthesisClassSubjectReportSql + " " + appendStatement; // synthesisClassSubjectReportSql = synthesisClassSubjectReportSql + " " + appendStatement;
synthesisClassReportSql = synthesisClassReportSql + " " + appendStatement; // synthesisClassReportSql = synthesisClassReportSql + " " + appendStatement;
//
} // }
//
synthesisSchoolSubjectReportSql = synthesisSchoolSubjectReportSql + " group by school,exam_id,province,region1,sub_subject"; // synthesisSchoolSubjectReportSql = synthesisSchoolSubjectReportSql + " group by school,exam_id,province,region1,sub_subject";
//
synthesisSchoolReportSql = synthesisSchoolReportSql + " " + " group by school,exam_id,province,region1"; // 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"; // 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"; // synthesisClassReportSql = synthesisClassReportSql + " " + " GROUP BY\n" + "\tclass,\n" + "\tschool,\n" + "\texam_id,\n" + "\tprovince,\n" + "\tregion1\n";
//
// System.out.println(1); //// System.out.println(1);
// System.out.println(synthesisSchoolSubjectReportSql); //// System.out.println(synthesisSchoolSubjectReportSql);
// ////
// System.out.println(2); //// System.out.println(2);
// System.out.println(synthesisSchoolReportSql); //// System.out.println(synthesisSchoolReportSql);
// ////
// System.out.println(3); //// System.out.println(3);
// System.out.println(synthesisClassSubjectReportSql); //// System.out.println(synthesisClassSubjectReportSql);
// ////
// System.out.println(4); //// System.out.println(4);
// System.out.println(synthesisClassReportSql); //// System.out.println(synthesisClassReportSql);
//
List<BasicReportParameters> synthesisSchoolSubjectReportParameters = this.reportJdbcTemplate.query(synthesisSchoolSubjectReportSql, new Object[]{}, new BeanPropertyRowMapper<>(BasicReportParameters.class)); // List<BasicReportParameters> synthesisSchoolSubjectReportParameters = this.reportJdbcTemplate.query(synthesisSchoolSubjectReportSql, new Object[]{}, new BeanPropertyRowMapper<>(BasicReportParameters.class));
//
for (BasicReportParameters parameter : synthesisSchoolSubjectReportParameters) { // for (BasicReportParameters parameter : synthesisSchoolSubjectReportParameters) {
if(parameter.getRegion().equals("改革")||parameter.getRegion().equals("改革A")||parameter.getRegion().equals("改革3+3")||parameter.getRegion().equals("改革3+1+2")){ // if(parameter.getRegion().equals("改革")||parameter.getRegion().equals("改革A")||parameter.getRegion().equals("改革3+3")||parameter.getRegion().equals("改革3+1+2")){
String command = "node /myworkSpace/puppeteer2.js \"http://schoolreport.cssat.cn/pdf/subject?province=condition5&school=condition1&examId=condition4&region=conditionC&subSubject=condition6&subjectType=常规\" pdf"; // String 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"; // 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()) // 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); // .concat(" ").concat(fileName);
parameter.setCommand(command); // parameter.setCommand(command);
parameter.setPrefix("/myworkSpace/subject/"); // parameter.setPrefix("/myworkSpace/subject/");
fileToUrl.put(fileName.replace("/myworkSpace/subject/",""),"PdfSubject/"+fileName.replace("/myworkSpace/subject/","")); // fileToUrl.put(fileName.replace("/myworkSpace/subject/",""),"PdfSubject/"+fileName.replace("/myworkSpace/subject/",""));
//
}else{ // }else{
String command = "node /myworkSpace/puppeteer2.js \"http://schoolreport.cssat.cn/pdf/subject?province=condition5&school=condition1&examId=condition4&region=非改革&branch=condition3&subSubject=condition6&subjectType=常规\" pdf"; // String 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"; // 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()) // 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); // .concat(" ").concat(fileName);
parameter.setCommand(command); // parameter.setCommand(command);
parameter.setPrefix("/myworkSpace/subject/"); // parameter.setPrefix("/myworkSpace/subject/");
fileToUrl.put(fileName.replace("/myworkSpace/subject/",""),"PdfSubject/"+fileName.replace("/myworkSpace/subject/","")); // fileToUrl.put(fileName.replace("/myworkSpace/subject/",""),"PdfSubject/"+fileName.replace("/myworkSpace/subject/",""));
} // }
} // }
//
List<BasicReportParameters> synthesisSchoolReportParameters = this.reportJdbcTemplate.query(synthesisSchoolReportSql, new Object[]{}, new BeanPropertyRowMapper<>(BasicReportParameters.class)); // List<BasicReportParameters> synthesisSchoolReportParameters = this.reportJdbcTemplate.query(synthesisSchoolReportSql, new Object[]{}, new BeanPropertyRowMapper<>(BasicReportParameters.class));
//
for (BasicReportParameters synthesisSchoolReportParameter : synthesisSchoolReportParameters) { // for (BasicReportParameters synthesisSchoolReportParameter : synthesisSchoolReportParameters) {
if(synthesisSchoolReportParameter.getRegion().equals("改革")||synthesisSchoolReportParameter.getRegion().equals("改革A")||synthesisSchoolReportParameter.getRegion().equals("改革3+3")||synthesisSchoolReportParameter.getRegion().equals("改革3+1+2")){ // if(synthesisSchoolReportParameter.getRegion().equals("改革")||synthesisSchoolReportParameter.getRegion().equals("改革A")||synthesisSchoolReportParameter.getRegion().equals("改革3+3")||synthesisSchoolReportParameter.getRegion().equals("改革3+1+2")){
String command = "node /myworkSpace/puppeteer.js \"http://schoolreport.cssat.cn/pdf/basic?province=condition5&school=condition1&examId=condition4&region=conditionC&subjectType=常规\" pdf "; // String 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"; // 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()) // command = command.replace("condition1", synthesisSchoolReportParameter.getSchool()).replace("condition5", synthesisSchoolReportParameter.getProvince()).replace("conditionC",synthesisSchoolReportParameter.getRegion()).replace("condition4", synthesisSchoolReportParameter.getExamId())
.concat(" ").concat(fileName); // .concat(" ").concat(fileName);
synthesisSchoolReportParameter.setCommand(command); // synthesisSchoolReportParameter.setCommand(command);
synthesisSchoolReportParameter.setPrefix("/myworkSpace/basic/"); // synthesisSchoolReportParameter.setPrefix("/myworkSpace/basic/");
fileToUrl.put(fileName.replace("/myworkSpace/basic/",""),"PdfDir/"+fileName.replace("/myworkSpace/basic/","")); // fileToUrl.put(fileName.replace("/myworkSpace/basic/",""),"PdfDir/"+fileName.replace("/myworkSpace/basic/",""));
}else{ // }else{
String command = "node /myworkSpace/puppeteer.js \"http://schoolreport.cssat.cn/pdf/basic?province=condition5&school=condition1&examId=condition4&region=非改革&branch=condition3&subjectType=常规\" pdf "; // String 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"; // 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()) // command = command.replace("condition1", synthesisSchoolReportParameter.getSchool()).replace("condition5", synthesisSchoolReportParameter.getProvince()).replace("condition3",synthesisSchoolReportParameter.getRegion()).replace("condition4", synthesisSchoolReportParameter.getExamId())
.concat(" ").concat(fileName); // .concat(" ").concat(fileName);
synthesisSchoolReportParameter.setCommand(command); // synthesisSchoolReportParameter.setCommand(command);
synthesisSchoolReportParameter.setPrefix("/myworkSpace/basic/"); // synthesisSchoolReportParameter.setPrefix("/myworkSpace/basic/");
fileToUrl.put(fileName.replace("/myworkSpace/basic/",""),"PdfDir/"+fileName.replace("/myworkSpace/basic/","")); // fileToUrl.put(fileName.replace("/myworkSpace/basic/",""),"PdfDir/"+fileName.replace("/myworkSpace/basic/",""));
//
} // }
} // }
//
List<ClassBasicReportParameters> synthesisClassSubjectReportParameters = this.reportJdbcTemplate.query(synthesisClassSubjectReportSql,new Object[]{},new BeanPropertyRowMapper<>(ClassBasicReportParameters.class)); // List<ClassBasicReportParameters> synthesisClassSubjectReportParameters = this.reportJdbcTemplate.query(synthesisClassSubjectReportSql,new Object[]{},new BeanPropertyRowMapper<>(ClassBasicReportParameters.class));
//
for (ClassBasicReportParameters synthesisClassSubjectReportParameter : synthesisClassSubjectReportParameters) { // for (ClassBasicReportParameters synthesisClassSubjectReportParameter : synthesisClassSubjectReportParameters) {
//
if (synthesisClassSubjectReportParameter.getRegion().equals("改革")||synthesisClassSubjectReportParameter.getRegion().equals("改革A")||synthesisClassSubjectReportParameter.getRegion().equals("改革3+3")||synthesisClassSubjectReportParameter.getRegion().equals("改革3+1+2")) { // if (synthesisClassSubjectReportParameter.getRegion().equals("改革")||synthesisClassSubjectReportParameter.getRegion().equals("改革A")||synthesisClassSubjectReportParameter.getRegion().equals("改革3+3")||synthesisClassSubjectReportParameter.getRegion().equals("改革3+1+2")) {
String command = "node /myworkSpace/pdfOfClassSubjectGen.js \"http://schoolreport.cssat.cn/pdf/classSubject?province=condition5&school=condition1&examId=condition4&region=conditionC&subSubject=condition6&subjectType=常规&className=conditionA\" pdf"; // String 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"; // 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()) // 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); // .concat(" ").concat(fileName);
fileToUrl.put(fileName.replace("/myworkSpace/Class/subject/",""),"/class/"+synthesisClassSubjectReportParameter.getExamId()+"/"+synthesisClassSubjectReportParameter.getProvince()+"/"+synthesisClassSubjectReportParameter.getSchool()+"/班级学科报告/"+synthesisClassSubjectReportParameter.getClassName()+"/"+synthesisClassSubjectReportParameter.getSubSubject()+"/"+fileName.replace("/myworkSpace/Class/subject/","")); // fileToUrl.put(fileName.replace("/myworkSpace/Class/subject/",""),"/class/"+synthesisClassSubjectReportParameter.getExamId()+"/"+synthesisClassSubjectReportParameter.getProvince()+"/"+synthesisClassSubjectReportParameter.getSchool()+"/班级学科报告/"+synthesisClassSubjectReportParameter.getClassName()+"/"+synthesisClassSubjectReportParameter.getSubSubject()+"/"+fileName.replace("/myworkSpace/Class/subject/",""));
synthesisClassSubjectReportParameter.setCommand(command); // synthesisClassSubjectReportParameter.setCommand(command);
synthesisClassSubjectReportParameter.setPrefix("/myworkSpace/Class/subject/"); // synthesisClassSubjectReportParameter.setPrefix("/myworkSpace/Class/subject/");
} else { // } else {
String command = "node /myworkSpace/pdfOfClassSubjectGen.js \"http://schoolreport.cssat.cn/pdf/classSubject?province=condition5&school=condition1&examId=condition4&region=非改革&branch=condition3&subSubject=condition6&subjectType=常规&className=conditionA\" pdf"; // String 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"; // 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()) // 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); // .concat(" ").concat(fileName);
fileToUrl.put(fileName.replace("/myworkSpace/Class/subject/",""),"/class/"+synthesisClassSubjectReportParameter.getExamId()+"/"+synthesisClassSubjectReportParameter.getProvince()+"/"+synthesisClassSubjectReportParameter.getSchool()+"/班级学科报告/"+synthesisClassSubjectReportParameter.getClassName()+"/"+synthesisClassSubjectReportParameter.getSubSubject()+"/"+fileName.replace("/myworkSpace/Class/subject/","")); // fileToUrl.put(fileName.replace("/myworkSpace/Class/subject/",""),"/class/"+synthesisClassSubjectReportParameter.getExamId()+"/"+synthesisClassSubjectReportParameter.getProvince()+"/"+synthesisClassSubjectReportParameter.getSchool()+"/班级学科报告/"+synthesisClassSubjectReportParameter.getClassName()+"/"+synthesisClassSubjectReportParameter.getSubSubject()+"/"+fileName.replace("/myworkSpace/Class/subject/",""));
synthesisClassSubjectReportParameter.setCommand(command); // synthesisClassSubjectReportParameter.setCommand(command);
synthesisClassSubjectReportParameter.setPrefix("/myworkSpace/Class/subject/"); // synthesisClassSubjectReportParameter.setPrefix("/myworkSpace/Class/subject/");
} // }
} // }
//
List<ClassBasicReportParameters> synthesisClassReportParameters = this.reportJdbcTemplate.query(synthesisClassReportSql,new Object[]{},new BeanPropertyRowMapper<>(ClassBasicReportParameters.class)); // List<ClassBasicReportParameters> synthesisClassReportParameters = this.reportJdbcTemplate.query(synthesisClassReportSql,new Object[]{},new BeanPropertyRowMapper<>(ClassBasicReportParameters.class));
//
for (ClassBasicReportParameters synthesisClassReportParameter : synthesisClassReportParameters) { // for (ClassBasicReportParameters synthesisClassReportParameter : synthesisClassReportParameters) {
//
if(synthesisClassReportParameter.getRegion().equals("改革")||synthesisClassReportParameter.getRegion().equals("改革A")||synthesisClassReportParameter.getRegion().equals("改革3+3")||synthesisClassReportParameter.getRegion().equals("改革3+1+2")){ // if(synthesisClassReportParameter.getRegion().equals("改革")||synthesisClassReportParameter.getRegion().equals("改革A")||synthesisClassReportParameter.getRegion().equals("改革3+3")||synthesisClassReportParameter.getRegion().equals("改革3+1+2")){
//
String command = "node /myworkSpace/pdfOfClassBasicGen.js \"http://schoolreport.cssat.cn/pdf/classBasic?province=condition5&school=condition1&examId=condition4&region=conditionC&subjectType=常规&className=conditionA\" pdf "; // String 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"; // String fileName = "/myworkSpace/Class/Basic/"+synthesisClassReportParameter.getRegion()+synthesisClassReportParameter.getProvince()+synthesisClassReportParameter.getSchool()+ synthesisClassReportParameter.getClassName()+synthesisClassReportParameter.getExamId()+".pdf";
//
command = command.replace("condition1", synthesisClassReportParameter.getSchool()).replace("condition5", synthesisClassReportParameter.getProvince()).replace("conditionC",synthesisClassReportParameter.getRegion()).replace("condition4", synthesisClassReportParameter.getExamId()).replace("conditionA",synthesisClassReportParameter.getClassName()) // 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); // .concat(" ").concat(fileName);
//
fileToUrl.put(fileName.replace("/myworkSpace/Class/Basic/",""),"/class/"+synthesisClassReportParameter.getExamId()+"/"+synthesisClassReportParameter.getProvince()+"/"+synthesisClassReportParameter.getSchool()+"/班级综合报告/"+synthesisClassReportParameter.getClassName()+"/"+fileName.replace("/myworkSpace/Class/Basic/","")); // fileToUrl.put(fileName.replace("/myworkSpace/Class/Basic/",""),"/class/"+synthesisClassReportParameter.getExamId()+"/"+synthesisClassReportParameter.getProvince()+"/"+synthesisClassReportParameter.getSchool()+"/班级综合报告/"+synthesisClassReportParameter.getClassName()+"/"+fileName.replace("/myworkSpace/Class/Basic/",""));
//
synthesisClassReportParameter.setCommand(command); // synthesisClassReportParameter.setCommand(command);
//
synthesisClassReportParameter.setPrefix("/myworkSpace/Class/Basic/"); // synthesisClassReportParameter.setPrefix("/myworkSpace/Class/Basic/");
//
} else { // } else {
//
String command = "node/myworkSpace/pdfOfClassBasicGen.js \"http://schoolreport.cssat.cn/pdf/classBasic?province=condition5&school=condition1&examId=condition4&region=非改革&branch=condition3&subjectType=常规&className=conditionA\" pdf "; // String 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"; // String fileName = "/myworkSpace/Class/Basic/"+synthesisClassReportParameter.getRegion()+synthesisClassReportParameter.getProvince()+synthesisClassReportParameter.getSchool()+synthesisClassReportParameter.getClassName()+synthesisClassReportParameter.getExamId()+".pdf";
//
command = command.replace("condition1", synthesisClassReportParameter.getSchool()).replace("condition5", synthesisClassReportParameter.getProvince()).replace("condition3",synthesisClassReportParameter.getRegion()).replace("condition4", synthesisClassReportParameter.getExamId()).replace("conditionA",synthesisClassReportParameter.getClassName()) // 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); // .concat(" ").concat(fileName);
//
fileToUrl.put(fileName.replace("/myworkSpace/Class/Basic/",""),"/class/"+synthesisClassReportParameter.getExamId()+"/"+synthesisClassReportParameter.getProvince()+"/"+synthesisClassReportParameter.getSchool()+"/班级综合报告/"+synthesisClassReportParameter.getClassName()+"/"+fileName.replace("/myworkSpace/Class/Basic/","")); // fileToUrl.put(fileName.replace("/myworkSpace/Class/Basic/",""),"/class/"+synthesisClassReportParameter.getExamId()+"/"+synthesisClassReportParameter.getProvince()+"/"+synthesisClassReportParameter.getSchool()+"/班级综合报告/"+synthesisClassReportParameter.getClassName()+"/"+fileName.replace("/myworkSpace/Class/Basic/",""));
//
synthesisClassReportParameter.setCommand(command); // synthesisClassReportParameter.setCommand(command);
//
synthesisClassReportParameter.setPrefix("/myworkSpace/Class/Basic/"); // synthesisClassReportParameter.setPrefix("/myworkSpace/Class/Basic/");
//
} // }
}
// for (String s : fileToUrl.keySet()) {
// System.out.println("file="+s+"==mapto=="+"key="+fileToUrl.get(s));
// } // }
//
Map<String, List<BasicReportParameters>> schoolReport = synthesisSchoolReportParameters.stream().collect(Collectors.groupingBy(BasicReportParameters::getProvince)); //// for (String s : fileToUrl.keySet()) {
//// System.out.println("file="+s+"==mapto=="+"key="+fileToUrl.get(s));
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<BasicReportParameters>> schoolReport = synthesisSchoolReportParameters.stream().collect(Collectors.groupingBy(BasicReportParameters::getProvince));
//
Map<String, List<ClassBasicReportParameters>> classSubjectReport = synthesisClassSubjectReportParameters.stream().collect(Collectors.groupingBy(ClassBasicReportParameters::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));
for (String key : schoolReport.keySet()) { //
logger.info("province:"+key+ "Gen"); // Map<String, List<ClassBasicReportParameters>> classSubjectReport = synthesisClassSubjectReportParameters.stream().collect(Collectors.groupingBy(ClassBasicReportParameters::getProvince));
List<BasicReportParameters> schoolBasicReport = schoolReport.get(key); //
List<BasicReportParameters> schoolSubject = schoolSubjectReport.get(key); //// 分组开始执行记录
List<ClassBasicReportParameters> classBasicReport = classReport.get(key); // for (String key : schoolReport.keySet()) {
List<ClassBasicReportParameters> classSubject = classSubjectReport.get(key); // logger.info("province:"+key+ "Gen");
for (BasicReportParameters schoolLevel : schoolBasicReport) { // List<BasicReportParameters> schoolBasicReport = schoolReport.get(key);
List<RetryCommand> retryCommands = new ArrayList<>(); // List<BasicReportParameters> schoolSubject = schoolSubjectReport.get(key);
logger.info("school:"+schoolLevel.getSchool()+"loading"); // List<ClassBasicReportParameters> classBasicReport = classReport.get(key);
Map<String, List<BasicReportParameters>> schoolMap= schoolSubject.stream().collect(Collectors.groupingBy(BasicReportParameters::getSchool)); // List<ClassBasicReportParameters> classSubject = classSubjectReport.get(key);
Map<String, List<ClassBasicReportParameters>> classBasic = classBasicReport.stream().collect(Collectors.groupingBy(ClassBasicReportParameters::getSchool)); // for (BasicReportParameters schoolLevel : schoolBasicReport) {
final Map<String, List<ClassBasicReportParameters>> subjectClass = classSubject.stream().collect(Collectors.groupingBy(ClassBasicReportParameters::getSchool)); // List<RetryCommand> retryCommands = new ArrayList<>();
List<BasicReportParameters> schoolSelf = schoolMap.get(schoolLevel.getSchool()); // logger.info("school:"+schoolLevel.getSchool()+"loading");
logger.info("basicReport:loading"); // Map<String, List<BasicReportParameters>> schoolMap= schoolSubject.stream().collect(Collectors.groupingBy(BasicReportParameters::getSchool));
logger.info("exitCode:"+schoolLevel.getSchool()); // Map<String, List<ClassBasicReportParameters>> classBasic = classBasicReport.stream().collect(Collectors.groupingBy(ClassBasicReportParameters::getSchool));
ProcessBuilder processBuilder = new ProcessBuilder(); // final Map<String, List<ClassBasicReportParameters>> subjectClass = classSubject.stream().collect(Collectors.groupingBy(ClassBasicReportParameters::getSchool));
processBuilder.command("bash", "-c", schoolLevel.getCommand()); // List<BasicReportParameters> schoolSelf = schoolMap.get(schoolLevel.getSchool());
processBuilder.redirectErrorStream(true); // 合并标准输出和错误输出 // logger.info("basicReport:loading");
Process process = null; // logger.info("exitCode:"+schoolLevel.getSchool());
try { // ProcessBuilder processBuilder = new ProcessBuilder();
process = processBuilder.start(); // processBuilder.command("bash", "-c", schoolLevel.getCommand());
} catch (IOException e) { // processBuilder.redirectErrorStream(true); // 合并标准输出和错误输出
throw new RuntimeException(e); // Process process = null;
} // try {
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream())); // process = processBuilder.start();
String line; // } catch (IOException e) {
while (true) { // throw new RuntimeException(e);
try { // }
if (!((line = reader.readLine()) != null)) break; // BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
} catch (IOException e) { // String line;
throw new RuntimeException(e); // while (true) {
} // try {
} // if (!((line = reader.readLine()) != null)) break;
// while ((line = reader.readLine()) != null) { // } catch (IOException e) {
// // 如果输出了 "DONE",表示生成完毕 // throw new RuntimeException(e);
// if ("DONE".equals(line)) { // }
// break; // 跳出循环 // }
// } //// while ((line = reader.readLine()) != null) {
//// // 如果输出了 "DONE",表示生成完毕
//// if ("DONE".equals(line)) {
//// break; // 跳出循环
//// }
//// }
// try {
// int exitCode = process.waitFor();
// } catch (InterruptedException e) {
// throw new RuntimeException(e);
// }
// //上传文件
//// File basicFile = new File("/myworkSpace/basic/");
//// File[] basicFiles = basicFile.listFiles();
//// assert basicFiles != null;
//// for (File file : basicFiles) {
//// PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, fileToUrl.get(file.getName()), file);
//// try {
//// PutObjectResult putObjectResult = cosClient.putObject(putObjectRequest);
//// logger.info(putObjectResult.getRequestId());
//// file.delete();
//// } catch (CosServiceException e) {
//// logger.info("cos服务出现问题");
//// e.printStackTrace();
//// } catch (CosClientException e) {
//// logger.info("cos客户端出现问题"+file.getName()+"文件上传有误,重新上传");
//// RetryCommand retryCommand = new RetryCommand();
//// retryCommand.setRetryCommand(schoolLevel.getCommand());
//// retryCommand.setParams(schoolLevel);
//// retryCommands.add(retryCommand);
//// e.printStackTrace();
//// }
//// }
// for (BasicReportParameters parameters : schoolSelf) {
// logger.info("subjectReport:loading");
// logger.info("exitCode:"+parameters.getSubSubject());
// ProcessBuilder processBuilderSubject = new ProcessBuilder();
// processBuilderSubject.command("bash", "-c", parameters.getCommand());
// processBuilderSubject.redirectErrorStream(true); // 合并标准输出和错误输出
// Process processSubject = null;
// try {
// processSubject = processBuilderSubject.start();
// } catch (IOException e) {
// throw new RuntimeException(e);
// } // }
try { // BufferedReader readerSubject = new BufferedReader(new InputStreamReader(processSubject.getInputStream()));
int exitCode = process.waitFor(); // String lineSubject;
} catch (InterruptedException e) { // while (true) {
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 { // try {
// PutObjectResult putObjectResult = cosClient.putObject(putObjectRequest); // if (!((lineSubject = readerSubject.readLine()) != null)) break;
// logger.info(putObjectResult.getRequestId()); // } catch (IOException e) {
// file.delete(); // throw new RuntimeException(e);
// } 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) { //// while ((lineSubject = readerSubject.readLine()) != null) {
logger.info("subjectReport:loading"); //// // 如果输出了 "DONE",表示生成完毕
logger.info("exitCode:"+parameters.getSubSubject()); //// if ("DONE".equals(lineSubject)) {
ProcessBuilder processBuilderSubject = new ProcessBuilder(); //// break; // 跳出循环
processBuilderSubject.command("bash", "-c", parameters.getCommand()); //// }
processBuilderSubject.redirectErrorStream(true); // 合并标准输出和错误输出 //// }
Process processSubject = null; // try {
try { // int exitCodeSubject = processSubject.waitFor();
processSubject = processBuilderSubject.start(); // } catch (InterruptedException e) {
} catch (IOException e) { // throw new RuntimeException(e);
throw new RuntimeException(e); // }
} //// File subjectFile = new File("/myworkSpace/subject/");
BufferedReader readerSubject = new BufferedReader(new InputStreamReader(processSubject.getInputStream())); //// File[] subjectFiles = subjectFile.listFiles();
String lineSubject; //// assert subjectFiles != null;
while (true) { //// for (File file : subjectFiles) {
try { //// PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, fileToUrl.get(file.getName()), file);
if (!((lineSubject = readerSubject.readLine()) != null)) break; //// try {
} catch (IOException e) { //// PutObjectResult putObjectResult = cosClient.putObject(putObjectRequest);
throw new RuntimeException(e); //// logger.info(putObjectResult.getRequestId());
} //// file.delete();
} //// } catch (CosServiceException e) {
// while ((lineSubject = readerSubject.readLine()) != null) { //// logger.info("cos服务出现问题");
// // 如果输出了 "DONE",表示生成完毕 //// e.printStackTrace();
// if ("DONE".equals(lineSubject)) { //// } catch (CosClientException e) {
// break; // 跳出循环 //// logger.info("cos客户端出现问题"+file.getName()+"文件上传有误,重新上传");
// } //// RetryCommand retryCommand = new RetryCommand();
//// retryCommand.setParams(parameters);
//// retryCommand.setRetryCommand(parameters.getCommand());
//// retryCommands.add(retryCommand);
//// e.printStackTrace();
//// }
//// }
// }
// List<ClassBasicReportParameters> args = classBasic.get(schoolLevel.getSchool());
// List<ClassBasicReportParameters> params = subjectClass.get(schoolLevel.getSchool());
// for (ClassBasicReportParameters arg : args) {
// logger.info("classBasic:loading");
// logger.info("exitCode:"+arg.getClassName());
// ProcessBuilder processBuilderClass = new ProcessBuilder();
// processBuilderClass.command("bash", "-c", arg.getCommand());
// processBuilderClass.redirectErrorStream(true); // 合并标准输出和错误输出
// Process processClass = null;
// try {
// processClass = processBuilderClass.start();
// } catch (IOException e) {
// throw new RuntimeException(e);
// }
// BufferedReader readerClass = new BufferedReader(new InputStreamReader(processClass.getInputStream()));
// String lineClass;
// while (true) {
// try {
// if (!((lineClass = readerClass.readLine()) != null)) break;
// } catch (IOException e) {
// throw new RuntimeException(e);
// }
// }
//// while ((lineClass = readerClass.readLine()) != null) {
//// // 如果输出了 "DONE",表示生成完毕
//// if ("DONE".equals(lineClass)) {
//// break; // 跳出循环
//// }
//// }
// try {
// int exitCodeSubject = processClass.waitFor();
// } catch (InterruptedException e) {
// throw new RuntimeException(e);
// }
//// File classBasicFile = new File("/myworkSpace/Class/Basic/");
//// File[] classBasicFiles = classBasicFile.listFiles();
//// assert classBasicFiles != null;
//// for (File file : classBasicFiles) {
//// PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, fileToUrl.get(file.getName()), file);
//// try {
//// PutObjectResult putObjectResult = cosClient.putObject(putObjectRequest);
//// logger.info(putObjectResult.getRequestId());
//// file.delete();
//// } catch (CosServiceException e) {
//// logger.info("cos服务出现问题");
//// e.printStackTrace();
//// } catch (CosClientException e) {
//// logger.info("cos客户端出现问题"+file.getName()+"文件上传有误,重新上传");
//// RetryCommand retryCommand = new RetryCommand();
//// retryCommand.setParams(arg);
//// retryCommand.setRetryCommand(arg.getCommand());
//// retryCommands.add(retryCommand);
//// e.printStackTrace();
//// }
//// }
// 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("bash", "-c", classBasicReportParameters.getCommand());
// processBuilderClassSubject.redirectErrorStream(true); // 合并标准输出和错误输出
// Process processClassSubject = null;
// try {
// processClassSubject = processBuilderClassSubject.start();
// } catch (IOException e) {
// throw new RuntimeException(e);
// } // }
try { // BufferedReader readerClassSubject = new BufferedReader(new InputStreamReader(processClassSubject.getInputStream()));
int exitCodeSubject = processSubject.waitFor(); // String lineClassSubject;
} catch (InterruptedException e) { // while (true) {
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 { // try {
// PutObjectResult putObjectResult = cosClient.putObject(putObjectRequest); // if (!((lineClassSubject = readerClassSubject.readLine()) != null)) break;
// logger.info(putObjectResult.getRequestId()); // } catch (IOException e) {
// file.delete(); // throw new RuntimeException(e);
// } 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();
// } // }
// } // }
} //// while ((lineClassSubject = readerClassSubject.readLine()) != null) {
List<ClassBasicReportParameters> args = classBasic.get(schoolLevel.getSchool()); //// // 如果输出了 "DONE",表示生成完毕
List<ClassBasicReportParameters> params = subjectClass.get(schoolLevel.getSchool()); //// if ("DONE".equals(lineClassSubject)) {
for (ClassBasicReportParameters arg : args) { //// break; // 跳出循环
logger.info("classBasic:loading"); //// }
logger.info("exitCode:"+arg.getClassName()); //// }
ProcessBuilder processBuilderClass = new ProcessBuilder(); // try {
processBuilderClass.command("bash", "-c", arg.getCommand()); // int exitCodeSubjectClass = processClassSubject.waitFor();
processBuilderClass.redirectErrorStream(true); // 合并标准输出和错误输出 // } catch (InterruptedException e) {
Process processClass = null; // throw new RuntimeException(e);
try { // }
processClass = processBuilderClass.start(); //// File classSubjectFile = new File("/myworkSpace/Class/subject/");
} catch (IOException e) { //// File[] classSubjectFiles = classSubjectFile.listFiles();
throw new RuntimeException(e); //// assert classSubjectFiles != null;
} //// for (File file : classSubjectFiles) {
BufferedReader readerClass = new BufferedReader(new InputStreamReader(processClass.getInputStream())); //// logger.info(file.getName()+"=file—>key="+fileToUrl.get(file.getName()));
String lineClass; //// PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, fileToUrl.get(file.getName()), file);
while (true) { //// try {
try { //// PutObjectResult putObjectResult = cosClient.putObject(putObjectRequest);
if (!((lineClass = readerClass.readLine()) != null)) break; //// logger.info(putObjectResult.getRequestId());
} catch (IOException e) { //// file.delete();
throw new RuntimeException(e); //// } catch (CosServiceException e) {
} //// logger.info("cos服务出现问题");
} //// e.printStackTrace();
// while ((lineClass = readerClass.readLine()) != null) { //// } catch (CosClientException e) {
// // 如果输出了 "DONE",表示生成完毕 //// logger.info("cos客户端出现问题"+file.getName()+"文件上传有误,重新上传");
// if ("DONE".equals(lineClass)) { //// RetryCommand retryCommand = new RetryCommand();
// break; // 跳出循环 //// 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();
// } // }
try { // if (arguments instanceof ClassBasicReportParameters) {
int exitCodeSubject = processClass.waitFor(); // ClassBasicReportParameters parametersTwo = (ClassBasicReportParameters) arguments;
} catch (InterruptedException e) { // filePrefix = parametersTwo.getPrefix();
throw new RuntimeException(e); // }
} //
// File classBasicFile = new File("/myworkSpace/Class/Basic/"); // logger.info("RetryCommand:ls");
// File[] classBasicFiles = classBasicFile.listFiles(); // ProcessBuilder processBuilderClassSubject = new ProcessBuilder();
// assert classBasicFiles != null; // processBuilderClassSubject.command("bash", "-c", command);
// for (File file : classBasicFiles) { // processBuilderClassSubject.redirectErrorStream(true); // 合并标准输出和错误输出
// PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, fileToUrl.get(file.getName()), file); // 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 { // try {
// PutObjectResult putObjectResult = cosClient.putObject(putObjectRequest); // if (!((lineClassSubject = readerClassSubject.readLine()) != null)) break;
// logger.info(putObjectResult.getRequestId()); // } catch (IOException e) {
// file.delete(); // throw new RuntimeException(e);
// } 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)); //// while ((lineClassSubject = readerClassSubject.readLine()) != null) {
List<ClassBasicReportParameters> list = collect.get(arg.getClassName()); //// // 如果输出了 "DONE",表示生成完毕
for (ClassBasicReportParameters classBasicReportParameters : list) { //// if ("DONE".equals(lineClassSubject)) {
logger.info("classSubject:loading"); //// break; // 跳出循环
logger.info("exitCode:"+classBasicReportParameters.getSubSubject()); //// }
ProcessBuilder processBuilderClassSubject = new ProcessBuilder(); //// }
processBuilderClassSubject.command("bash", "-c", classBasicReportParameters.getCommand()); // try {
processBuilderClassSubject.redirectErrorStream(true); // 合并标准输出和错误输出 // int exitCodeSubjectClass = processClassSubject.waitFor();
Process processClassSubject = null; // } catch (InterruptedException e) {
try { // throw new RuntimeException(e);
processClassSubject = processBuilderClassSubject.start(); // }
} catch (IOException e) { //// File classSubjectFile = new File(filePrefix);
throw new RuntimeException(e); //// File[] classSubjectFiles = classSubjectFile.listFiles();
} //// assert classSubjectFiles != null;
BufferedReader readerClassSubject = new BufferedReader(new InputStreamReader(processClassSubject.getInputStream())); //// for (File file : classSubjectFiles) {
String lineClassSubject; //// logger.info(file.getName()+"=file—>key="+fileToUrl.get(file.getName()));
while (true) { //// PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, fileToUrl.get(file.getName()), file);
try { //// try {
if (!((lineClassSubject = readerClassSubject.readLine()) != null)) break; //// PutObjectResult putObjectResult = cosClient.putObject(putObjectRequest);
} catch (IOException e) { //// logger.info(putObjectResult.getRequestId());
throw new RuntimeException(e); //// file.delete();
} //// } catch (CosServiceException e) {
} //// logger.info("cos服务出现问题");
// while ((lineClassSubject = readerClassSubject.readLine()) != null) { //// e.printStackTrace();
// // 如果输出了 "DONE",表示生成完毕 //// } catch (CosClientException e) {
// if ("DONE".equals(lineClassSubject)) { //// logger.info("cos客户端出现问题"+file.getName()+"文件上传有误,重新上传");
// break; // 跳出循环 //// }
// } //// }
// } //
try { // }
int exitCodeSubjectClass = processClassSubject.waitFor(); //
} catch (InterruptedException e) { // }
throw new RuntimeException(e); //
} // //插入数据
// File classSubjectFile = new File("/myworkSpace/Class/subject/"); // 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());
// File[] classSubjectFiles = classSubjectFile.listFiles(); //
// assert classSubjectFiles != null; // logger.info("Rows affected:" + rowsAffected);
// 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); // return ResponseEntity.ok("操作成功");
// logger.info(putObjectResult.getRequestId()); //
// file.delete(); // }
// } catch (CosServiceException e) { //
// logger.info("cos服务出现问题"); //}
// e.printStackTrace();
// } catch (CosClientException e) {
// logger.info("cos客户端出现问题"+file.getName()+"文件上传有误,重新上传");
// RetryCommand retryCommand = new RetryCommand();
// retryCommand.setParams(classBasicReportParameters);
// retryCommand.setRetryCommand(classBasicReportParameters.getCommand());
// retryCommands.add(retryCommand);
// e.printStackTrace();
// }
// }
}
}
if(retryCommands.size()!=0){
logger.info("size"+retryCommands.size());
for (RetryCommand retryCommand : retryCommands) {
String command = retryCommand.getRetryCommand();
Object arguments = retryCommand.getParams();
String filePrefix = "";
if ( arguments instanceof BasicReportParameters){
BasicReportParameters parametersOne = (BasicReportParameters) arguments;
filePrefix = parametersOne.getPrefix();
}
if (arguments instanceof ClassBasicReportParameters) {
ClassBasicReportParameters parametersTwo = (ClassBasicReportParameters) arguments;
filePrefix = parametersTwo.getPrefix();
}
logger.info("RetryCommand:ls");
ProcessBuilder processBuilderClassSubject = new ProcessBuilder();
processBuilderClassSubject.command("bash", "-c", command);
processBuilderClassSubject.redirectErrorStream(true); // 合并标准输出和错误输出
Process processClassSubject = null;
try {
processClassSubject = processBuilderClassSubject.start();
} catch (IOException e) {
throw new RuntimeException(e);
}
BufferedReader readerClassSubject = new BufferedReader(new InputStreamReader(processClassSubject.getInputStream()));
String lineClassSubject;
while (true) {
try {
if (!((lineClassSubject = readerClassSubject.readLine()) != null)) break;
} catch (IOException e) {
throw new RuntimeException(e);
}
}
// while ((lineClassSubject = readerClassSubject.readLine()) != null) {
// // 如果输出了 "DONE",表示生成完毕
// if ("DONE".equals(lineClassSubject)) {
// break; // 跳出循环
// }
// }
try {
int exitCodeSubjectClass = processClassSubject.waitFor();
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
// File classSubjectFile = new File(filePrefix);
// File[] classSubjectFiles = classSubjectFile.listFiles();
// assert classSubjectFiles != null;
// for (File file : classSubjectFiles) {
// logger.info(file.getName()+"=file—>key="+fileToUrl.get(file.getName()));
// PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, fileToUrl.get(file.getName()), file);
// try {
// PutObjectResult putObjectResult = cosClient.putObject(putObjectRequest);
// logger.info(putObjectResult.getRequestId());
// file.delete();
// } catch (CosServiceException e) {
// logger.info("cos服务出现问题");
// e.printStackTrace();
// } catch (CosClientException e) {
// logger.info("cos客户端出现问题"+file.getName()+"文件上传有误,重新上传");
// }
// }
}
}
//插入数据
int rowsAffected = reportJdbcTemplate.update("UPDATE school_report_task_generate SET status = ? WHERE exam_id = ? AND region = ? AND province = ? AND school = ?",1,schoolLevel.getExamId(),schoolLevel.getRegion(),schoolLevel.getProvince(),schoolLevel.getSchool());
logger.info("Rows affected:" + rowsAffected);
}
}
return ResponseEntity.ok("操作成功");
}
}
...@@ -3,9 +3,9 @@ server: ...@@ -3,9 +3,9 @@ server:
spring: spring:
datasource: datasource:
url: jdbc:mysql://192.168.0.46:3306/tempnew?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT%2B8 url: jdbc:mysql://192.168.0.11:3306/tempnew?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT%2B8
username: jiru username: root
password: Jiru@20231026 password: Thu#DSS#0419
druid: druid:
initial-size: 5 initial-size: 5
max-active: 200 max-active: 200
......
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