Commit bf72068b authored by ryzeycy's avatar ryzeycy

xx

parent 29d4f66b
......@@ -26,15 +26,38 @@ public class MyDataSourceConfig {
private static JdbcTemplate basicTemplate;
private static JdbcTemplate testTemplate;
@PostConstruct
private void init() {
initReport();
initMkReport();
// initCampCenter();
initBasic();
// initBasic();
initTest();
}
public static JdbcTemplate getTestJdbcTemplate(){
return testTemplate;
}
public DataSource initTest(){
System.err.println("print init reportSource...");
//外网
String url = "jdbc:mysql://192.168.0.14:3306/tda_20250918?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT%2B8";
DruidDataSource dataSource = getDataSource(url);
dataSource.setUsername("root");
dataSource.setPassword("Thussat@2023");
testTemplate = new JdbcTemplate(dataSource);
return dataSource;
}
public static JdbcTemplate getReportJdbcTemplate(){
return reportJdbcTemplate;
}
......
......@@ -23,7 +23,7 @@ import java.util.stream.Collectors;
@RestController
@RequestMapping("/")
@RequestMapping("/pdf")
public class GeneratorAllTypePdfByProvinceController {
private static final Logger logger = LoggerFactory.getLogger(GeneratorAllTypePdfByProvinceController.class);
......@@ -42,7 +42,7 @@ public class GeneratorAllTypePdfByProvinceController {
@RequestMapping("/GeneratorByProvinceName")
public ResponseEntity generatorName(@RequestParam("examId")String examId, @RequestParam(value = "provinceName",required = false)String provinceName,@RequestParam(value = "schoolName",required = false)String schoolName) throws IOException, InterruptedException {
String suffix = examId.trim().replace("TDA","").replace("G3","").replace("G2","").trim();
String suffix = examId.trim().replace("TDA","").replace("G3","").replace("G2","").replace("G11","").replace("G12","").trim();
String synthesisSchoolSubjectReportSql = "select \n" +
"school,exam_id,province,region1 as region,sub_subject\n" +
......@@ -272,7 +272,7 @@ public class GeneratorAllTypePdfByProvinceController {
logger.info("basicReport:loading");
logger.info("exitCode:"+schoolLevel.getSchool());
ProcessBuilder processBuilder = new ProcessBuilder();
processBuilder.command("bash", "-c", schoolLevel.getCommand());
processBuilder.command("cmd.exe", "-c", schoolLevel.getCommand());
processBuilder.redirectErrorStream(true); // 合并标准输出和错误输出
Process process = null;
try {
......@@ -326,7 +326,7 @@ public class GeneratorAllTypePdfByProvinceController {
logger.info("subjectReport:loading");
logger.info("exitCode:"+parameters.getSubSubject());
ProcessBuilder processBuilderSubject = new ProcessBuilder();
processBuilderSubject.command("bash", "-c", parameters.getCommand());
processBuilderSubject.command("cmd.exe", "-c", parameters.getCommand());
processBuilderSubject.redirectErrorStream(true); // 合并标准输出和错误输出
Process processSubject = null;
try {
......@@ -382,7 +382,7 @@ public class GeneratorAllTypePdfByProvinceController {
logger.info("classBasic:loading");
logger.info("exitCode:"+arg.getClassName());
ProcessBuilder processBuilderClass = new ProcessBuilder();
processBuilderClass.command("bash", "-c", arg.getCommand());
processBuilderClass.command("cmd.exe", "-c", arg.getCommand());
processBuilderClass.redirectErrorStream(true); // 合并标准输出和错误输出
Process processClass = null;
try {
......@@ -437,7 +437,7 @@ public class GeneratorAllTypePdfByProvinceController {
logger.info("classSubject:loading");
logger.info("exitCode:"+classBasicReportParameters.getSubSubject());
ProcessBuilder processBuilderClassSubject = new ProcessBuilder();
processBuilderClassSubject.command("bash", "-c", classBasicReportParameters.getCommand());
processBuilderClassSubject.command("cmd.exe", "-c", classBasicReportParameters.getCommand());
processBuilderClassSubject.redirectErrorStream(true); // 合并标准输出和错误输出
Process processClassSubject = null;
try {
......@@ -507,7 +507,7 @@ public class GeneratorAllTypePdfByProvinceController {
logger.info("RetryCommand:ls");
ProcessBuilder processBuilderClassSubject = new ProcessBuilder();
processBuilderClassSubject.command("bash", "-c", command);
processBuilderClassSubject.command("cmd.exe", "-c", command);
processBuilderClassSubject.redirectErrorStream(true); // 合并标准输出和错误输出
Process processClassSubject = null;
try {
......
......@@ -3,7 +3,7 @@ server:
spring:
datasource:
url: jdbc:mysql://192.168.0.46:3306/temp_test?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT%2B8
url: jdbc:mysql://192.168.0.46:3306/tempnew?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT%2B8
username: jiru
password: Jiru@20231026
druid:
......@@ -12,7 +12,7 @@ spring:
min-idle: 5
max-wait: 6000
redis:
host: 192.168.0.4
host: 192.168.0.13
port: 6379
password: Thussat@2023
database: 101
......
......@@ -27,7 +27,7 @@ public class ClassIncrement {
public void GeProvinceQuesTypeSituation(){
String sql = "select region1" +
" as region,province from base_province_subject_tda20250227 where subject_type = '常规' group by region1,province";
" as region,province from base_province_subject_tda20250918 where subject_type = '常规' group by region1,province";
JdbcTemplate jdbcTemplate = MyDataSourceConfig.getReportJdbcTemplate();
List<Params> params = jdbcTemplate.query(sql,new Object[]{},new BeanPropertyRowMapper<>(Params.class));
for (Params param : params) {
......@@ -44,25 +44,25 @@ public class ClassIncrement {
"sub_subject,\n" +
"stu_id\n" +
"from\n" +
"base_student_ques_type_tda20250227\n" +
"base_student_ques_type_tda20250918\n" +
"where\n" +
"region1 = '"+region+"'\n" +
"AND province = '"+province+"'\n" +
"\t\t\tAND subject_type = '常规' \n" +
"\t\t\tAND exam_id = 'TDA20250227G3'\n";
"\t\t\tAND exam_id = 'TDA20250918G11'\n";
List<DtoArgs> list = jdbcTemplate.query(sql,new Object[]{},new BeanPropertyRowMapper<>(DtoArgs.class));
Map<String, List<DtoArgs>> collect = list.stream().collect(Collectors.groupingBy(DtoArgs::getSubSubject));
for(String subject : collect.keySet()){
String sql2 = "SELECT\n" +
"\tstu_id \n" +
"FROM\n" +
"\tbase_student_subject_tda20250227 \n" +
"\tbase_student_subject_tda20250918 \n" +
"WHERE\n" +
"\tstu_subject_score_rate_province_pct_rank >= ( 1-0.27 ) \n" +
"\tAND region1 = '"+region+"' \n" +
"\tAND province = '"+province+"' \n" +
"\tAND subject_type = '常规' \n" +
"\tAND exam_id = 'TDA20250227G3' \n" +
"\tAND exam_id = 'TDA20250918G11' \n" +
"\tAND sub_subject = '"+subject+"'";
List<String> excellentIds = jdbcTemplate.queryForList(sql2,String.class);
......@@ -94,7 +94,7 @@ public class ClassIncrement {
params.put("Mean",resultMean);
NamedParameterJdbcTemplate namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(jdbcTemplate);
namedParameterJdbcTemplate.update("insert into province_ques_type_excellent20250227(region,province,sub_subject,mean,ques_type) value (:region,:province,:subSubject,:Mean,:quesType)",new MapSqlParameterSource(params));
namedParameterJdbcTemplate.update("insert into province_ques_type_excellent20250918(region,province,sub_subject,mean,ques_type) value (:region,:province,:subSubject,:Mean,:quesType)",new MapSqlParameterSource(params));
}
}
......@@ -105,7 +105,7 @@ public class ClassIncrement {
@Test
public void GeProvinceExcellentDifficultySituations(){
String sql = "select region1 as region,province from base_province_subject_tda20250227 where subject_type = '常规' group by region1,province";
String sql = "select region1 as region,province from base_province_subject_tda20250918 where subject_type = '常规' group by region1,province";
JdbcTemplate jdbcTemplate = MyDataSourceConfig.getReportJdbcTemplate();
List<Params> params = jdbcTemplate.query(sql,new Object[]{},new BeanPropertyRowMapper<>(Params.class));
for (Params param : params) {
......@@ -127,8 +127,8 @@ public class ClassIncrement {
"\tb.`ques_max_score`,\n" +
"\tb.`stu_id`\n" +
"\tFROM\n" +
"\tbase_area_question_tda20250227 a\n" +
"\tleft join base_student_question_tda20250227 b on a.ques_no = b.ques_no and a.sub_subject = b.`sub_subject` and a.region1 = b.region1 and a.subject_type = b.subject_type\n" +
"\tbase_area_question_tda20250918 a\n" +
"\tleft join base_student_question_tda20250918 b on a.ques_no = b.ques_no and a.sub_subject = b.`sub_subject` and a.region1 = b.region1 and a.subject_type = b.subject_type\n" +
"\twhere a.subject_type = '常规' and a.region1 = '"+region+"' and b.province = '"+province+"'";
NamedParameterJdbcTemplate namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(jdbcTemplate);
......@@ -140,7 +140,7 @@ public class ClassIncrement {
for (String subject : collect.keySet()) {
String sql2 = "select stu_id from base_student_subject_tda20250227 where sub_subject = '"+subject+"' and region1 = '"+region+"' and province = '"+province +"' and stu_subject_score_rate_province_pct_rank >= 0.73 and subject_type = '常规'";
String sql2 = "select stu_id from base_student_subject_tda20250918 where sub_subject = '"+subject+"' and region1 = '"+region+"' and province = '"+province +"' and stu_subject_score_rate_province_pct_rank >= 0.73 and subject_type = '常规'";
List<String> excellentIds = namedParameterJdbcTemplate.queryForList(sql2,new HashMap<>(),String.class);
......@@ -233,11 +233,11 @@ public class ClassIncrement {
put("scoreMean", nanResult);
}};
namedParameterJdbcTemplate.update("insert into province_excellent_difficult20250227(sub_subject,difficult,region,province,score_mean) value(:subSubject,:difficult,:region,:province,:scoreMean)",new MapSqlParameterSource(paramsYi));
namedParameterJdbcTemplate.update("insert into province_excellent_difficult20250227(sub_subject,difficult,region,province,score_mean) value(:subSubject,:difficult,:region,:province,:scoreMean)",new MapSqlParameterSource(paramsJiaoYi));
namedParameterJdbcTemplate.update("insert into province_excellent_difficult20250227(sub_subject,difficult,region,province,score_mean) value(:subSubject,:difficult,:region,:province,:scoreMean)",new MapSqlParameterSource(paramsZhong));
namedParameterJdbcTemplate.update("insert into province_excellent_difficult20250227(sub_subject,difficult,region,province,score_mean) value(:subSubject,:difficult,:region,:province,:scoreMean)",new MapSqlParameterSource(paramsJiaoNan));
namedParameterJdbcTemplate.update("insert into province_excellent_difficult20250227(sub_subject,difficult,region,province,score_mean) value(:subSubject,:difficult,:region,:province,:scoreMean)",new MapSqlParameterSource(paramsNan));
namedParameterJdbcTemplate.update("insert into province_excellent_difficult20250918(sub_subject,difficult,region,province,score_mean) value(:subSubject,:difficult,:region,:province,:scoreMean)",new MapSqlParameterSource(paramsYi));
namedParameterJdbcTemplate.update("insert into province_excellent_difficult20250918(sub_subject,difficult,region,province,score_mean) value(:subSubject,:difficult,:region,:province,:scoreMean)",new MapSqlParameterSource(paramsJiaoYi));
namedParameterJdbcTemplate.update("insert into province_excellent_difficult20250918(sub_subject,difficult,region,province,score_mean) value(:subSubject,:difficult,:region,:province,:scoreMean)",new MapSqlParameterSource(paramsZhong));
namedParameterJdbcTemplate.update("insert into province_excellent_difficult20250918(sub_subject,difficult,region,province,score_mean) value(:subSubject,:difficult,:region,:province,:scoreMean)",new MapSqlParameterSource(paramsJiaoNan));
namedParameterJdbcTemplate.update("insert into province_excellent_difficult20250918(sub_subject,difficult,region,province,score_mean) value(:subSubject,:difficult,:region,:province,:scoreMean)",new MapSqlParameterSource(paramsNan));
}
......
......@@ -25,7 +25,7 @@ public class Garbge {
NamedParameterJdbcTemplate namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(jdbcTemplate);
String sql = "select region1 from base_school_subject_tda20250227 where subject_type = '常规' group by region1";
String sql = "select region1 from base_school_subject_tda20250918 where subject_type = '常规' group by region1";
List<String> regions = jdbcTemplate.queryForList(sql, String.class);
for (String region : regions) {
......@@ -41,7 +41,7 @@ public class Garbge {
"sub_subject,\n" +
"stu_id\n" +
"from\n" +
"base_student_knowledge_tda20250227\n" +
"base_student_knowledge_tda20250918\n" +
"where\n" +
"region1 = '"+region+"' and subject_type = '常规'";
......@@ -52,7 +52,7 @@ public class Garbge {
String sql2 = "select \n" +
"stu_id\n" +
"from \n" +
"base_student_subject_tda20250227\n" +
"base_student_subject_tda20250918\n" +
"where\n" +
"sub_subject = '"+subject+"'\n" +
"and\n" +
......@@ -81,7 +81,7 @@ public class Garbge {
paramsYi.put("rate",resultRate);
reportJdbcTemplate.update("insert into knowledge_region_excellent20250227(sub_subject,knowledge,region,rate) value (:subSubject,:knowledge,:region,:rate)",new MapSqlParameterSource(paramsYi));
reportJdbcTemplate.update("insert into knowledge_region_excellent20250918(sub_subject,knowledge,region,rate) value (:subSubject,:knowledge,:region,:rate)",new MapSqlParameterSource(paramsYi));
}
......
......@@ -15,7 +15,7 @@ import java.util.List;
@SpringBootTest
public class GenerateTaskPool {
@Test
public void GenerateTaskPoolUnit(){
......@@ -28,13 +28,13 @@ public class GenerateTaskPool {
"\tschool,\n" +
"\t0 as status\n" +
"FROM\n" +
"\tbase_school_subject_tda20250227 \n" +
"\tbase_school_subject_tda20250918 \n" +
"GROUP BY\n" +
"\tregion1,\n" +
"\tprovince,\n" +
"\tschool,\n" +
"\texam_id";
List<TaskPoolDto> taskPoolDtoList = reportJdbcTemplate.query(sql,new Object[]{},new BeanPropertyRowMapper<>(TaskPoolDto.class));
batchInsert(taskPoolDtoList,reportJdbcTemplate);
......
......@@ -22,7 +22,7 @@ public class NumberTwo {
public void ProvinceExKnow(){
JdbcTemplate jdbcTemplate = MyDataSourceConfig.getReportJdbcTemplate();
NamedParameterJdbcTemplate namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(jdbcTemplate);
String sql = "select region1 as region,province from base_school_subject_tda20250227 where subject_type = '常规' group by region1,province";
String sql = "select region1 as region,province from base_school_subject_tda20250918 where subject_type = '常规' group by region1,province";
List<Params> paramsList = namedParameterJdbcTemplate.query(sql,new BeanPropertyRowMapper<>(Params.class));
for (Params param : paramsList) {
provinceExe(param.getRegion(),param.getProvince(),namedParameterJdbcTemplate);
......@@ -37,7 +37,7 @@ public class NumberTwo {
"sub_subject,\n" +
"stu_id\n" +
"from\n" +
"base_student_knowledge_tda20250227\n" +
"base_student_knowledge_tda20250918\n" +
"where\n" +
"region1 = '"+region+"' and subject_type = '常规' and province = '"+province+"'";
......@@ -49,12 +49,12 @@ public class NumberTwo {
String sql3 = "\t\t\t\tSELECT\n" +
"\t\t\tstu_id \n" +
"\t\tFROM\n" +
"\t\t\tbase_student_subject_tda20250227 \n" +
"\t\t\tbase_student_subject_tda20250918 \n" +
"\t\tWHERE\n" +
"\t\t\tprovince = '"+province+"' \n" +
"\t\t\tAND region1 = '"+region+"' \n" +
"\t\t\tAND subject_type = '常规' \n" +
"\t\t\tAND exam_id = 'TDA20250227G3' \n" +
"\t\t\tAND exam_id = 'TDA20250918G11' \n" +
"\t\t\tAND sub_subject = '"+subject+"' \n" +
"\t\t\tAND stu_subject_score_rate_province_pct_rank >= (1-0.27) ";
......@@ -80,7 +80,7 @@ public class NumberTwo {
}};
paramsYi.put("rate",result);
reportTemplate.update("insert into knowledge_province_excellent20250227(sub_subject,knowledge,region,rate,province) value (:subSubject,:knowledge,:region,:rate,:province)",new MapSqlParameterSource(paramsYi));
reportTemplate.update("insert into knowledge_province_excellent20250918(sub_subject,knowledge,region,rate,province) value (:subSubject,:knowledge,:region,:rate,:province)",new MapSqlParameterSource(paramsYi));
}
}
......
......@@ -11,14 +11,15 @@ public class GenerateSchool {
@Test
public void GenerateSchool(){
public void GenerateSchool() {
JdbcTemplate reportJdbcTemplate = MyDataSourceConfig.getReportJdbcTemplate();
String examId = "TDA20250227G3";
String examId = "TDA20251023G12";
// String examId = "TDA20250918G11";
String suffix = examId.replace("TDA","").replace("G2","").replace("G3","");
String suffix = examId.replace("TDA", "").replace("G2", "").replace("G3", "").replace("G11", "").replace("G12", "");
String createTableClassDifficult = "CREATE TABLE IF NOT EXISTS `class_diffficult"+suffix+"` (\n" +
String createTableClassDifficult = "CREATE TABLE IF NOT EXISTS `class_diffficult" + suffix + "` (\n" +
" `id` int NOT NULL AUTO_INCREMENT,\n" +
" `class` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,\n" +
" `school` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,\n" +
......@@ -29,7 +30,7 @@ public class GenerateSchool {
" PRIMARY KEY (`id`) USING BTREE\n" +
") ENGINE=InnoDB AUTO_INCREMENT=17401 DEFAULT CHARSET=utf8mb3";
String createTableProvinceDifficult = "CREATE TABLE IF NOT EXISTS `province_difficult"+suffix+"` (\n" +
String createTableProvinceDifficult = "CREATE TABLE IF NOT EXISTS `province_difficult" + suffix + "` (\n" +
" `id` int NOT NULL AUTO_INCREMENT,\n" +
" `province` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,\n" +
" `region` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,\n" +
......@@ -39,7 +40,7 @@ public class GenerateSchool {
" PRIMARY KEY (`id`) USING BTREE\n" +
") ENGINE=InnoDB AUTO_INCREMENT=371 DEFAULT CHARSET=utf8mb3";
String createTableProvinceExcellentDifficult = "CREATE TABLE IF NOT EXISTS `province_excellent_difficult"+suffix+"` (\n" +
String createTableProvinceExcellentDifficult = "CREATE TABLE IF NOT EXISTS `province_excellent_difficult" + suffix + "` (\n" +
" `id` int NOT NULL AUTO_INCREMENT,\n" +
" `region` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,\n" +
" `province` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,\n" +
......@@ -49,7 +50,7 @@ public class GenerateSchool {
" PRIMARY KEY (`id`) USING BTREE\n" +
") ENGINE=InnoDB AUTO_INCREMENT=916 DEFAULT CHARSET=utf8mb3";
String createTableRegionDifficult = "CREATE TABLE `region_difficult"+suffix+"` (\n" +
String createTableRegionDifficult = "CREATE TABLE `region_difficult" + suffix + "` (\n" +
" `id` int NOT NULL AUTO_INCREMENT,\n" +
" `region` varchar(255) DEFAULT NULL,\n" +
" `sub_subject` varchar(255) DEFAULT NULL,\n" +
......@@ -58,7 +59,7 @@ public class GenerateSchool {
" PRIMARY KEY (`id`)\n" +
") ENGINE=InnoDB AUTO_INCREMENT=101 DEFAULT CHARSET=utf8mb3";
String createTableRegionExcellentDifficult = "CREATE TABLE IF NOT EXISTS `region_excellent_difficult"+suffix+"` (\n" +
String createTableRegionExcellentDifficult = "CREATE TABLE IF NOT EXISTS `region_excellent_difficult" + suffix + "` (\n" +
" `id` int NOT NULL AUTO_INCREMENT,\n" +
" `region` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,\n" +
" `sub_subject` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,\n" +
......@@ -67,7 +68,7 @@ public class GenerateSchool {
" PRIMARY KEY (`id`) USING BTREE\n" +
") ENGINE=InnoDB AUTO_INCREMENT=101 DEFAULT CHARSET=utf8mb3";
String createTableSchoolDifficult = "CREATE TABLE IF NOT EXISTS `school_diffficult"+suffix+"` (\n" +
String createTableSchoolDifficult = "CREATE TABLE IF NOT EXISTS `school_diffficult" + suffix + "` (\n" +
" `id` int NOT NULL AUTO_INCREMENT,\n" +
" `school` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,\n" +
" `sub_subject` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,\n" +
......@@ -77,7 +78,7 @@ public class GenerateSchool {
" PRIMARY KEY (`id`) USING BTREE\n" +
") ENGINE=InnoDB AUTO_INCREMENT=7176 DEFAULT CHARSET=utf8mb3";
String createTableKnowledgeProvinceExcellent = "CREATE TABLE IF NOT EXISTS `knowledge_province_excellent"+suffix+"` (\n" +
String createTableKnowledgeProvinceExcellent = "CREATE TABLE IF NOT EXISTS `knowledge_province_excellent" + suffix + "` (\n" +
" `id` int NOT NULL AUTO_INCREMENT,\n" +
" `region` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,\n" +
" `province` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,\n" +
......@@ -87,7 +88,7 @@ public class GenerateSchool {
" PRIMARY KEY (`id`) USING BTREE\n" +
") ENGINE=InnoDB AUTO_INCREMENT=811 DEFAULT CHARSET=utf8mb3";
String createTableKnowledgeRegionExcellent = "CREATE TABLE IF NOT EXISTS `knowledge_region_excellent"+suffix+"` (\n" +
String createTableKnowledgeRegionExcellent = "CREATE TABLE IF NOT EXISTS `knowledge_region_excellent" + suffix + "` (\n" +
" `id` int NOT NULL AUTO_INCREMENT,\n" +
" `region` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,\n" +
" `sub_subject` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,\n" +
......@@ -96,7 +97,7 @@ public class GenerateSchool {
" PRIMARY KEY (`id`) USING BTREE\n" +
") ENGINE=InnoDB AUTO_INCREMENT=218 DEFAULT CHARSET=utf8mb3";
String createTableProvinceExcellentAswTime = "CREATE TABLE IF NOT EXISTS `province_excellent_asw_time"+suffix+"` (\n" +
String createTableProvinceExcellentAswTime = "CREATE TABLE IF NOT EXISTS `province_excellent_asw_time" + suffix + "` (\n" +
" `id` int NOT NULL AUTO_INCREMENT,\n" +
" `region` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,\n" +
" `province` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,\n" +
......@@ -107,7 +108,7 @@ public class GenerateSchool {
") ENGINE=InnoDB AUTO_INCREMENT=916 DEFAULT CHARSET=utf8mb3";
String createTableProvinceQuesTypeExcellent = "CREATE TABLE \n" +
"IF NOT EXISTS `province_ques_type_excellent"+suffix+"` (\n" +
"IF NOT EXISTS `province_ques_type_excellent" + suffix + "` (\n" +
" `id` int NOT NULL AUTO_INCREMENT,\n" +
" `region` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,\n" +
" `province` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,\n" +
......@@ -118,7 +119,7 @@ public class GenerateSchool {
") ENGINE=InnoDB AUTO_INCREMENT=526 DEFAULT CHARSET=utf8mb3\n";
String createTableRegionExcellentAswTime = "CREATE TABLE \n" +
"IF NOT EXISTS `region_excellent_asw_time"+suffix+"` (\n" +
"IF NOT EXISTS `region_excellent_asw_time" + suffix + "` (\n" +
" `id` int NOT NULL AUTO_INCREMENT,\n" +
" `region` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,\n" +
" `ques_no` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,\n" +
......@@ -127,7 +128,7 @@ public class GenerateSchool {
" PRIMARY KEY (`id`) USING BTREE\n" +
") ENGINE=InnoDB AUTO_INCREMENT=273 DEFAULT CHARSET=utf8mb3";
String createTableRegionQuesTypeExcellent = "CREATE TABLE IF NOT EXISTS `region_ques_type_excellent"+suffix+"` (\n" +
String createTableRegionQuesTypeExcellent = "CREATE TABLE IF NOT EXISTS `region_ques_type_excellent" + suffix + "` (\n" +
" `id` int NOT NULL AUTO_INCREMENT,\n" +
" `region` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,\n" +
" `sub_subject` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,\n" +
......
package com.example.pdfgenerator;
import com.example.pdfgenerator.Dto.RetryCommand;
import com.example.pdfgenerator.config.MyDataSourceConfig;
import com.qcloud.cos.COSClient;
import com.qcloud.cos.exception.CosClientException;
import com.qcloud.cos.exception.CosServiceException;
import com.qcloud.cos.model.PutObjectRequest;
import com.qcloud.cos.model.PutObjectResult;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.jdbc.core.JdbcTemplate;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* @Author ryze
* @Date 2025/9/26
*/
@SpringBootTest
@Slf4j
public class UploadPdfToCosTest {
String bucketName = "schoolreportpdf-1317275686";
@Autowired
private COSClient cosClient;
@Test
public void test1() {
// 1.上传学校报告
JdbcTemplate reportJdbcTemplate = MyDataSourceConfig.getTestJdbcTemplate();
reportJdbcTemplate.queryForList("select * from dp_total_score");
File basicFile = new File("F:\\myworkSpace\\basic\\");
File[] basicFiles = basicFile.listFiles();
assert basicFiles != null;
for (File file : basicFiles) {
String prefix = "PdfDir/" + file.getName();
PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, prefix, file);
try {
PutObjectResult putObjectResult = cosClient.putObject(putObjectRequest);
log.info(putObjectResult.getRequestId());
//file.delete();
} catch (CosServiceException e) {
log.info("cos服务出现问题");
e.printStackTrace();
} catch (CosClientException e) {
log.info("cos客户端出现问题" + file.getName() + "文件上传有误,重新上传");
e.printStackTrace();
}
}
//3.上传班级综合报告
//3.上传班级科目分析报告
}
// 2.测试上传学校科目报告
@Test
public void test2Test() {
JdbcTemplate reportJdbcTemplate = MyDataSourceConfig.getTestJdbcTemplate();
List<Map<String, Object>> mapList = reportJdbcTemplate.queryForList("SELECT DISTINCT\n" +
"\ta.school_id,\n" +
"\tc.name,\n" +
"\ta.subject_id,\n" +
"\tb.desc\n" +
"FROM\n" +
"\tdp_subject_score a\n" +
"\tLEFT JOIN \n" +
"\tsparta_subject b \n" +
"\ton a.subject_id =b.id\n" +
"\tLEFT JOIN \n" +
"\tsparta_school c on a.school_id = c.id");
File basicFile = new File("F:\\myworkSpace\\subject\\");
File[] basicFiles = basicFile.listFiles();
assert basicFiles != null;
List<String> list = new ArrayList<>();
for (File file : basicFiles) {
list.add(file.getName());
}
for (Map<String, Object> map : mapList) {
String schoolName = map.get("name").toString();
String subjectName = map.get("desc").toString();
if (list.contains(subjectName) && list.contains(schoolName)) {
System.out.println("包含");
} else {
System.out.println("schoolName = " + schoolName + " subjectName = " + subjectName + "不包含");
}
}
//3.上传班级综合报告
//4.上传班级科目分析报告
}
@Test
public void test2() {
// 1.上传学校报告
JdbcTemplate reportJdbcTemplate = MyDataSourceConfig.getTestJdbcTemplate();
reportJdbcTemplate.queryForList("select * from dp_total_score");
File basicFile = new File("F:\\myworkSpace\\subject\\");
File[] basicFiles = basicFile.listFiles();
assert basicFiles != null;
for (File file : basicFiles) {
String prefix = "PdfSubject/" + file.getName();
PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, prefix, file);
try {
PutObjectResult putObjectResult = cosClient.putObject(putObjectRequest);
log.info(putObjectResult.getRequestId());
//file.delete();
} catch (CosServiceException e) {
log.info("cos服务出现问题");
e.printStackTrace();
} catch (CosClientException e) {
log.info("cos客户端出现问题" + file.getName() + "文件上传有误,重新上传");
e.printStackTrace();
}
}
}
//3.上传班级综合报告
@Test
public void testZh() {
String examUuid = "TDA20250918G11";
String typeName = "班级综合报告";
JdbcTemplate reportJdbcTemplate = MyDataSourceConfig.getTestJdbcTemplate();
List<Map<String, Object>> mapList = reportJdbcTemplate.queryForList("\tSELECT DISTINCT\n" +
"\t c.province_name,\n" +
"\t IF(c.province_name = '山东省','改革3+3','改革3+1+2') as type,\n" +
" a.school_id,\n" +
"\tc.name,\n" +
"\ta.banji_name,\n" +
"\tCONCAT(IF(c.province_name = '山东省','改革3+3','改革3+1+2'),c.province_name,c.name,a.banji_name,'TDA20250918G11','.pdf') as xx\n" +
"FROM\n" +
"\tdp_ques_score a\n" +
"\tLEFT JOIN \n" +
"\tsparta_school c on a.school_id = c.id\n" +
"\t\n" +
"\tORDER BY a.school_id,a.banji_name ");
File basicFile = new File("F:\\myworkSpace\\Class\\Basic");
for (Map<String, Object> map : mapList) {
String provinceName = map.get("province_name").toString();
String schoolName = map.get("name").toString();
String banjiName = map.get("banji_name").toString();
String path = map.get("xx").toString();
File file2 = new File(basicFile, path);
if (!file2.exists()) {
System.out.println(path + " 不存在");
} else {
System.out.println("存在");
String prefix = "class/" + examUuid + "/" + provinceName + "/" + schoolName + "/" + typeName + "/" + banjiName + "/" + path;
PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, prefix, file2);
try {
PutObjectResult putObjectResult = cosClient.putObject(putObjectRequest);
log.info(putObjectResult.getRequestId());
//file.delete();
} catch (CosServiceException e) {
log.info("cos服务出现问题");
e.printStackTrace();
} catch (CosClientException e) {
log.info("cos客户端出现问题" + file2.getName() + "文件上传有误,重新上传");
e.printStackTrace();
}
}
}
}
//4.上传班级科目分析报告
@Test
public void testFx() {
String examUuid = "TDA20250918G11";
String typeName = "班级学科报告";
JdbcTemplate reportJdbcTemplate = MyDataSourceConfig.getTestJdbcTemplate();
List<Map<String, Object>> mapList = reportJdbcTemplate.queryForList("\t\tSELECT DISTINCT\n" +
"\tc.province_name,\n" +
" a.school_id,\n" +
"\tc.name,\n" +
"\ta.banji_name,\n" +
"\td.desc,\n" +
"\ta.subject_id,\n" +
"\tCONCAT(IF(c.province_name = '山东省','改革3+3','改革3+1+2'),c.province_name,c.name,d.desc,'TDA20250918G11',d.desc,a.banji_name,'.pdf') as xx\n" +
"FROM\n" +
"\tdp_subject_score a\n" +
"\tLEFT JOIN \n" +
"\tsparta_school c on a.school_id = c.id\n" +
"\tLEFT JOIN sparta_subject d on a.subject_id = d.id\n" +
"\tGROUP BY a.school_id,a.banji_name,a.subject_id");
File basicFile = new File("F:\\myworkSpace\\Class\\Subject");
for (Map<String, Object> map : mapList) {
String provinceName = map.get("province_name").toString();
String schoolName = map.get("name").toString();
String banjiName = map.get("banji_name").toString();
String subjectName = map.get("desc").toString();
String path = map.get("xx").toString();
File file2 = new File(basicFile, path);
if (!file2.exists()) {
System.out.println(path + " 不存在");
} else {
System.out.println("存在");
String prefix = "class/" + examUuid + "/" + provinceName + "/" + schoolName + "/" + typeName + "/" + banjiName + "/" +subjectName+"/"+ path;
PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, prefix, file2);
try {
PutObjectResult putObjectResult = cosClient.putObject(putObjectRequest);
log.info(putObjectResult.getRequestId());
//file.delete();
} catch (CosServiceException e) {
log.info("cos服务出现问题");
e.printStackTrace();
} catch (CosClientException e) {
log.info("cos客户端出现问题" + file2.getName() + "文件上传有误,重新上传");
e.printStackTrace();
}
}
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment