Commit 461b0342 authored by 霍传世's avatar 霍传世

测试生成上传

parent 01e5d750
Pipeline #233 canceled with stages
...@@ -4,6 +4,10 @@ import com.example.pdfgenerator.Dto.BasicReportParameters; ...@@ -4,6 +4,10 @@ import com.example.pdfgenerator.Dto.BasicReportParameters;
import com.example.pdfgenerator.Dto.ClassBasicReportParameters; import com.example.pdfgenerator.Dto.ClassBasicReportParameters;
import com.example.pdfgenerator.config.MyDataSourceConfig; import com.example.pdfgenerator.config.MyDataSourceConfig;
import com.qcloud.cos.COSClient; import com.qcloud.cos.COSClient;
import com.qcloud.cos.exception.CosClientException;
import com.qcloud.cos.exception.CosServiceException;
import com.qcloud.cos.model.PutObjectRequest;
import com.qcloud.cos.model.PutObjectResult;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -15,6 +19,7 @@ import org.springframework.web.bind.annotation.RequestParam; ...@@ -15,6 +19,7 @@ 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.File;
import java.io.IOException; import java.io.IOException;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.util.Arrays; import java.util.Arrays;
...@@ -33,7 +38,7 @@ public class PDFGeByProvinceBatchController { ...@@ -33,7 +38,7 @@ public class PDFGeByProvinceBatchController {
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;
JdbcTemplate reportJdbcTemplate = MyDataSourceConfig.getReportJdbcTemplate(); JdbcTemplate reportJdbcTemplate = MyDataSourceConfig.getReportJdbcTemplate();
...@@ -204,10 +209,8 @@ public class PDFGeByProvinceBatchController { ...@@ -204,10 +209,8 @@ public class PDFGeByProvinceBatchController {
for (String key : schoolReport.keySet()) { for (String key : schoolReport.keySet()) {
logger.info("province:"+key+ "Gen..............................................................."); logger.info("province:"+key+ "Gen...............................................................");
List<BasicReportParameters> schoolBasicReport = schoolReport.get(key); List<BasicReportParameters> schoolBasicReport = schoolReport.get(key);
List<BasicReportParameters> schoolSubject = schoolSubjectReport.get(key);
for (BasicReportParameters schoolLevel : schoolBasicReport) { for (BasicReportParameters schoolLevel : schoolBasicReport) {
logger.info("school:"+schoolLevel.getSchool()+"loading---------------------------------------------------------------"); logger.info("school:"+schoolLevel.getSchool()+"loading---------------------------------------------------------------");
Map<String, List<BasicReportParameters>> schoolMap= schoolSubject.stream().collect(Collectors.groupingBy(BasicReportParameters::getSchool));
logger.info("basicReport:loading******************************************"); logger.info("basicReport:loading******************************************");
ProcessBuilder processBuilder = new ProcessBuilder(); ProcessBuilder processBuilder = new ProcessBuilder();
processBuilder.command("bash", "-c", schoolLevel.getCommand()); processBuilder.command("bash", "-c", schoolLevel.getCommand());
...@@ -217,9 +220,25 @@ public class PDFGeByProvinceBatchController { ...@@ -217,9 +220,25 @@ public class PDFGeByProvinceBatchController {
String line; String line;
while ((line = reader.readLine()) != null) { while ((line = reader.readLine()) != null) {
} }
Thread.sleep(1000);
int exitCode = process.waitFor(); int exitCode = process.waitFor();
logger.info("exitCode:"+schoolLevel.getSchool()); logger.info("exitCode:"+schoolLevel.getSchool());
File file = new File("/myworkSpace/basic/");
File[] files1 = file.listFiles();
assert files1 != null;
for (File file1 : files1) {
PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, "PdfTest/"+file1.getName(), file1);
try {
PutObjectResult putObjectResult = cosClient.putObject(putObjectRequest);
logger.info(putObjectResult.getRequestId());
file1.delete();
} catch (CosServiceException e) {
logger.info("cos服务出现问题");
e.printStackTrace();
} catch (CosClientException e) {
logger.info("cos客户端出现问题"+file.getName()+"文件上传有误,重新上传");
e.printStackTrace();
}
}
} }
} }
return null; return null;
......
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