Commit 9518bd36 authored by chenzhao's avatar chenzhao

ziliaoxiazai youhua

parent 37c6daf5
...@@ -39,6 +39,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -39,6 +39,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource; import org.springframework.core.io.Resource;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -82,6 +83,7 @@ public class CommonServiceImpl { ...@@ -82,6 +83,7 @@ public class CommonServiceImpl {
private Resource urlInfo; private Resource urlInfo;
@Autowired @Autowired
SurveyInformationServiceImpl surveyInformationServiceImpl; SurveyInformationServiceImpl surveyInformationServiceImpl;
private static final String regionRedis = "app_region_redis"; private static final String regionRedis = "app_region_redis";
@Autowired @Autowired
RedisUtils redisUtil; RedisUtils redisUtil;
...@@ -524,14 +526,13 @@ public class CommonServiceImpl { ...@@ -524,14 +526,13 @@ public class CommonServiceImpl {
redisUtils.set(redisKey, MapBuilder.<String, Object>create() redisUtils.set(redisKey, MapBuilder.<String, Object>create()
.put("value", current).build()); .put("value", current).build());
String powerStationInstanceId = powerStationMapper.getInstanceIdByhouseId(peasantHouseholdId); String powerStationInstanceId = powerStationMapper.getInstanceIdByhouseId(peasantHouseholdId);
String basicGridInstanceId = basicGridAuditingMapper.getInstanceIdByhouseId(peasantHouseholdId);
String financingInstanceId = financingAuditingMapper.getInstanceIdByhouseId(peasantHouseholdId); String financingInstanceId = financingAuditingMapper.getInstanceIdByhouseId(peasantHouseholdId);
List<LinkedHashMap> powerStationWorkLog = new ArrayList<>(); List<LinkedHashMap> powerStationWorkLog = new ArrayList<>();
List<ConstructionRecords> workOrderStationWorkLog = new ArrayList<>(); List<ConstructionRecords> workOrderStationWorkLog = new ArrayList<>();
List<ConstructionGirdRecords> basicGridWorkLog = new ArrayList<>(); List<ConstructionGirdRecords> basicGridWorkLog = new ArrayList<>();
List<LinkedHashMap> financingWorkLog = new ArrayList<>(); List<LinkedHashMap> financingWorkLog = new ArrayList<>();
List<ConstructionAcceptanceRecords> accptWorkLog = new ArrayList<>(); List<ConstructionAcceptanceRecords> accptWorkLog = new ArrayList<>();
workOrderStationWorkLog = this.getConstructionRecords(peasantHouseholdId); workOrderStationWorkLog = this.getConstructionRecords(returnDto.getPowerStationEngineeringInfo().getWorkOrderPowerStationId(),returnDto.getPowerStationEngineeringInfo().getWorkOrderId());
accptWorkLog = this.getConstructionRecordsAcc(peasantHouseholdId); accptWorkLog = this.getConstructionRecordsAcc(peasantHouseholdId);
basicGridWorkLog = this.getConstructionRecordsBasic(peasantHouseholdId); basicGridWorkLog = this.getConstructionRecordsBasic(peasantHouseholdId);
...@@ -643,10 +644,13 @@ public class CommonServiceImpl { ...@@ -643,10 +644,13 @@ public class CommonServiceImpl {
futures.add(executorService.submit(() -> { futures.add(executorService.submit(() -> {
try { try {
downloadAndZipImages(returnDto.getSurveyInformation(),"基本信息附件",tempDir,urlPath); downloadAndZipImages(returnDto.getSurveyInformation(),"基本信息附件",tempDir,urlPath);
if (!finalRedisKey.contains(",")){
Map<String, Object> map = (Map<String, Object>) redisUtils.get(finalRedisKey); Map<String, Object> map = (Map<String, Object>) redisUtils.get(finalRedisKey);
Integer currentNum = (Integer) map.get("value")+7; Integer currentNum = (Integer) map.get("value")+7;
redisUtils.set(finalRedisKey, MapBuilder.<String, Object>create() redisUtils.set(finalRedisKey, MapBuilder.<String, Object>create()
.put("value", currentNum).build()); .put("value", currentNum).build());
}
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
...@@ -654,10 +658,13 @@ public class CommonServiceImpl { ...@@ -654,10 +658,13 @@ public class CommonServiceImpl {
futures.add(executorService.submit(() -> { futures.add(executorService.submit(() -> {
try { try {
downloadAndZipImages(returnDto.getSurveyDetails(),"勘察信息附件",tempDir,urlPath); downloadAndZipImages(returnDto.getSurveyDetails(),"勘察信息附件",tempDir,urlPath);
if (!finalRedisKey.contains(",")){
Map<String, Object> map = (Map<String, Object>) redisUtils.get(finalRedisKey); Map<String, Object> map = (Map<String, Object>) redisUtils.get(finalRedisKey);
Integer currentNum = (Integer) map.get("value")+7; Integer currentNum = (Integer) map.get("value")+7;
redisUtils.set(finalRedisKey, MapBuilder.<String, Object>create() redisUtils.set(finalRedisKey, MapBuilder.<String, Object>create()
.put("value", currentNum).build()); .put("value", currentNum).build());
}
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
...@@ -665,10 +672,13 @@ public class CommonServiceImpl { ...@@ -665,10 +672,13 @@ public class CommonServiceImpl {
futures.add(executorService.submit(() -> { futures.add(executorService.submit(() -> {
try { try {
downloadAndZipImages(returnDto.getDesignInformation(),"设计信息附件",tempDir,urlPath); downloadAndZipImages(returnDto.getDesignInformation(),"设计信息附件",tempDir,urlPath);
if (!finalRedisKey.contains(",")){
Map<String, Object> map = (Map<String, Object>) redisUtils.get(finalRedisKey); Map<String, Object> map = (Map<String, Object>) redisUtils.get(finalRedisKey);
Integer currentNum = (Integer) map.get("value")+7; Integer currentNum = (Integer) map.get("value")+7;
redisUtils.set(finalRedisKey, MapBuilder.<String, Object>create() redisUtils.set(finalRedisKey, MapBuilder.<String, Object>create()
.put("value", currentNum).build()); .put("value", currentNum).build());
}
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
...@@ -676,10 +686,13 @@ public class CommonServiceImpl { ...@@ -676,10 +686,13 @@ public class CommonServiceImpl {
futures.add(executorService.submit(() -> { futures.add(executorService.submit(() -> {
try { try {
downloadAndZipImages(returnDto.getCommercial(),"商务信息附件",tempDir,urlPath); downloadAndZipImages(returnDto.getCommercial(),"商务信息附件",tempDir,urlPath);
if (!finalRedisKey.contains(",")){
Map<String, Object> map = (Map<String, Object>) redisUtils.get(finalRedisKey); Map<String, Object> map = (Map<String, Object>) redisUtils.get(finalRedisKey);
Integer currentNum = (Integer) map.get("value")+7; Integer currentNum = (Integer) map.get("value")+7;
redisUtils.set(finalRedisKey, MapBuilder.<String, Object>create() redisUtils.set(finalRedisKey, MapBuilder.<String, Object>create()
.put("value", currentNum).build()); .put("value", currentNum).build());
}
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
...@@ -687,10 +700,12 @@ public class CommonServiceImpl { ...@@ -687,10 +700,12 @@ public class CommonServiceImpl {
futures.add(executorService.submit(() -> { futures.add(executorService.submit(() -> {
try { try {
downloadAndZipImages(returnDto.getInformation(),"资料归档附件",tempDir,urlPath); downloadAndZipImages(returnDto.getInformation(),"资料归档附件",tempDir,urlPath);
if (!finalRedisKey.contains(",")){
Map<String, Object> map = (Map<String, Object>) redisUtils.get(finalRedisKey); Map<String, Object> map = (Map<String, Object>) redisUtils.get(finalRedisKey);
Integer currentNum = (Integer) map.get("value")+7; Integer currentNum = (Integer) map.get("value")+7;
redisUtils.set(finalRedisKey, MapBuilder.<String, Object>create() redisUtils.set(finalRedisKey, MapBuilder.<String, Object>create()
.put("value", currentNum).build()); .put("value", currentNum).build());
}
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
...@@ -698,10 +713,13 @@ public class CommonServiceImpl { ...@@ -698,10 +713,13 @@ public class CommonServiceImpl {
futures.add(executorService.submit(() -> { futures.add(executorService.submit(() -> {
try { try {
downloadAndZipImages(returnDto.getPowerStationConstructionData(),"施工信息附件",tempDir,urlPath); downloadAndZipImages(returnDto.getPowerStationConstructionData(),"施工信息附件",tempDir,urlPath);
if (!finalRedisKey.contains(",")){
Map<String, Object> map = (Map<String, Object>) redisUtils.get(finalRedisKey); Map<String, Object> map = (Map<String, Object>) redisUtils.get(finalRedisKey);
Integer currentNum = (Integer) map.get("value")+7; Integer currentNum = (Integer) map.get("value")+7;
redisUtils.set(finalRedisKey, MapBuilder.<String, Object>create() redisUtils.set(finalRedisKey, MapBuilder.<String, Object>create()
.put("value", currentNum).build()); .put("value", currentNum).build());
}
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
...@@ -709,10 +727,13 @@ public class CommonServiceImpl { ...@@ -709,10 +727,13 @@ public class CommonServiceImpl {
futures.add(executorService.submit(() -> { futures.add(executorService.submit(() -> {
try { try {
downloadAndZipImages(areaOrdersCon,"施工信息整改单附件",tempDir,urlPath); downloadAndZipImages(areaOrdersCon,"施工信息整改单附件",tempDir,urlPath);
if (!finalRedisKey.contains(",")){
Map<String, Object> map = (Map<String, Object>) redisUtils.get(finalRedisKey); Map<String, Object> map = (Map<String, Object>) redisUtils.get(finalRedisKey);
Integer currentNum = (Integer) map.get("value")+7; Integer currentNum = (Integer) map.get("value")+7;
redisUtils.set(finalRedisKey, MapBuilder.<String, Object>create() redisUtils.set(finalRedisKey, MapBuilder.<String, Object>create()
.put("value", currentNum).build()); .put("value", currentNum).build());
}
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
...@@ -720,10 +741,13 @@ public class CommonServiceImpl { ...@@ -720,10 +741,13 @@ public class CommonServiceImpl {
futures.add(executorService.submit(() -> { futures.add(executorService.submit(() -> {
try { try {
downloadAndZipImages(returnDto.getHygfOnGrid(),"并网信息附件",tempDir,urlPath); downloadAndZipImages(returnDto.getHygfOnGrid(),"并网信息附件",tempDir,urlPath);
if (!finalRedisKey.contains(",")){
Map<String, Object> map = (Map<String, Object>) redisUtils.get(finalRedisKey); Map<String, Object> map = (Map<String, Object>) redisUtils.get(finalRedisKey);
Integer currentNum = (Integer) map.get("value")+7; Integer currentNum = (Integer) map.get("value")+7;
redisUtils.set(finalRedisKey, MapBuilder.<String, Object>create() redisUtils.set(finalRedisKey, MapBuilder.<String, Object>create()
.put("value", currentNum).build()); .put("value", currentNum).build());
}
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
...@@ -731,10 +755,13 @@ public class CommonServiceImpl { ...@@ -731,10 +755,13 @@ public class CommonServiceImpl {
futures.add(executorService.submit(() -> { futures.add(executorService.submit(() -> {
try { try {
downloadAndZipImages(areaOrders,"并网信息整改单附件",tempDir,urlPath); downloadAndZipImages(areaOrders,"并网信息整改单附件",tempDir,urlPath);
if (!finalRedisKey.contains(",")){
Map<String, Object> map = (Map<String, Object>) redisUtils.get(finalRedisKey); Map<String, Object> map = (Map<String, Object>) redisUtils.get(finalRedisKey);
Integer currentNum = (Integer) map.get("value")+7; Integer currentNum = (Integer) map.get("value")+7;
redisUtils.set(finalRedisKey, MapBuilder.<String, Object>create() redisUtils.set(finalRedisKey, MapBuilder.<String, Object>create()
.put("value", currentNum).build()); .put("value", currentNum).build());
}
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
...@@ -742,10 +769,13 @@ public class CommonServiceImpl { ...@@ -742,10 +769,13 @@ public class CommonServiceImpl {
futures.add(executorService.submit(() -> { futures.add(executorService.submit(() -> {
try { try {
downloadAndZipImages(returnDto.getWorkOrder(),"派工单信息附件",tempDir,urlPath); downloadAndZipImages(returnDto.getWorkOrder(),"派工单信息附件",tempDir,urlPath);
if (!finalRedisKey.contains(",")){
Map<String, Object> map = (Map<String, Object>) redisUtils.get(finalRedisKey); Map<String, Object> map = (Map<String, Object>) redisUtils.get(finalRedisKey);
Integer currentNum = (Integer) map.get("value")+7; Integer currentNum = (Integer) map.get("value")+7;
redisUtils.set(finalRedisKey, MapBuilder.<String, Object>create() redisUtils.set(finalRedisKey, MapBuilder.<String, Object>create()
.put("value", currentNum).build()); .put("value", currentNum).build());
}
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
...@@ -753,10 +783,13 @@ public class CommonServiceImpl { ...@@ -753,10 +783,13 @@ public class CommonServiceImpl {
futures.add(executorService.submit(() -> { futures.add(executorService.submit(() -> {
try { try {
downloadAndZipImages(areaOrdersAcc,"验收信息整改单附件",tempDir,urlPath); downloadAndZipImages(areaOrdersAcc,"验收信息整改单附件",tempDir,urlPath);
if (!finalRedisKey.contains(",")){
Map<String, Object> map = (Map<String, Object>) redisUtils.get(finalRedisKey); Map<String, Object> map = (Map<String, Object>) redisUtils.get(finalRedisKey);
Integer currentNum = (Integer) map.get("value")+7; Integer currentNum = (Integer) map.get("value")+7;
redisUtils.set(finalRedisKey, MapBuilder.<String, Object>create() redisUtils.set(finalRedisKey, MapBuilder.<String, Object>create()
.put("value", currentNum).build()); .put("value", currentNum).build());
}
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
...@@ -1296,8 +1329,10 @@ public class CommonServiceImpl { ...@@ -1296,8 +1329,10 @@ public class CommonServiceImpl {
private static void createZipFile(Path folderPath, String zipFilePath, HttpServletResponse response) { private static void createZipFile(Path folderPath, String zipFilePath, HttpServletResponse response) {
try (ServletOutputStream out = response.getOutputStream(); try (ServletOutputStream out = response.getOutputStream();
ZipOutputStream zos = new ZipOutputStream(out)) { ZipOutputStream zos = new ZipOutputStream(out)) {
// 计算ZIP文件的总大小
addFolderToZip(zipFilePath, folderPath, zos); long totalSize = getTotalFileSize(folderPath);
response.setContentLengthLong((int) totalSize);
addFolderToZip(zipFilePath, folderPath, zos,response);
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
...@@ -1325,14 +1360,26 @@ public class CommonServiceImpl { ...@@ -1325,14 +1360,26 @@ public class CommonServiceImpl {
} }
} }
private static long getTotalFileSize(Path folderPath) throws IOException {
private static void addFolderToZip(String relativePath, Path folderPath, ZipOutputStream zos) throws IOException { // 获取文件夹内所有文件的总大小
if (!Files.exists(folderPath)) { return Files.walk(folderPath)
return; .filter(Files::isRegularFile)
.mapToLong(path -> {
try {
return Files.size(path);
} catch (IOException e) {
e.printStackTrace();
return 0;
} }
})
.sum();
}
private static void addFolderToZip(String relativePath, Path folderPath, ZipOutputStream zos, HttpServletResponse response) throws IOException {
try { try {
// FileOutputStream fout = new FileOutputStream(relativePath); // FileOutputStream fout = new FileOutputStream(relativePath);
File folder = new File(relativePath); File folder = new File(relativePath);
addFilesToZip(folder, zos, folder.getName()); addFilesToZip(folder, zos, folder.getName());
zos.close(); zos.close();
...@@ -1360,8 +1407,8 @@ public class CommonServiceImpl { ...@@ -1360,8 +1407,8 @@ public class CommonServiceImpl {
// }); // });
} }
@Async
private static void cleanup(Path tempDir) { void cleanup(Path tempDir) {
try { try {
Files.walk(tempDir).sorted(Comparator.reverseOrder()).forEach(path -> { Files.walk(tempDir).sorted(Comparator.reverseOrder()).forEach(path -> {
try { try {
...@@ -1471,7 +1518,7 @@ public class CommonServiceImpl { ...@@ -1471,7 +1518,7 @@ public class CommonServiceImpl {
headerFont.setBold(true); // 加粗字体 headerFont.setBold(true); // 加粗字体
headerFont.setFontHeightInPoints((short) 12); // 字体大小 headerFont.setFontHeightInPoints((short) 12); // 字体大小
headerStyle.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex()); headerStyle.setFillForegroundColor(IndexedColors.PALE_BLUE.getIndex());
headerStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND); headerStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
headerStyle.setAlignment(HorizontalAlignment.CENTER); // 居中对齐 headerStyle.setAlignment(HorizontalAlignment.CENTER); // 居中对齐
headerStyle.setFont(headerFont); // 设置字体样式 headerStyle.setFont(headerFont); // 设置字体样式
...@@ -1722,10 +1769,11 @@ public class CommonServiceImpl { ...@@ -1722,10 +1769,11 @@ public class CommonServiceImpl {
} }
List<ConstructionRecords> getConstructionRecords (String peasantHouseholdId) { List<ConstructionRecords> getConstructionRecords (Long workOrderPowerStationId,Long workOrderId) {
// 施工自审操作记录 // 施工自审操作记录
LambdaQueryWrapper<ConstructionRecords> up5 = new LambdaQueryWrapper<ConstructionRecords>(); LambdaQueryWrapper<ConstructionRecords> up5 = new LambdaQueryWrapper<ConstructionRecords>();
up5.eq(ConstructionRecords::getPeasantHouseholdId, peasantHouseholdId); up5.eq(ConstructionRecords::getWorkOrderPowerStationId,workOrderPowerStationId);
up5.eq(ConstructionRecords::getWorkOrderId,workOrderId);
up5.orderByAsc(ConstructionRecords::getRecDate); up5.orderByAsc(ConstructionRecords::getRecDate);
return constructionRecordsMapper.selectList(up5); return constructionRecordsMapper.selectList(up5);
} }
...@@ -1733,7 +1781,7 @@ public class CommonServiceImpl { ...@@ -1733,7 +1781,7 @@ public class CommonServiceImpl {
List<ConstructionGirdRecords> getConstructionRecordsBasic (String peasantHouseholdId) { List<ConstructionGirdRecords> getConstructionRecordsBasic (String peasantHouseholdId) {
// 施工自审操作记录 // 施工自审操作记录
LambdaQueryWrapper<ConstructionGirdRecords> up5 = new LambdaQueryWrapper<ConstructionGirdRecords>(); LambdaQueryWrapper<ConstructionGirdRecords> up5 = new LambdaQueryWrapper<ConstructionGirdRecords>();
up5.eq(ConstructionGirdRecords::getPeasantHouseholdId, peasantHouseholdId); up5.eq(ConstructionGirdRecords::getWorkOrderPowerStationId, peasantHouseholdId);
up5.orderByAsc(ConstructionGirdRecords::getRecDate); up5.orderByAsc(ConstructionGirdRecords::getRecDate);
return constructionGirdRecordsMapper.selectList(up5); return constructionGirdRecordsMapper.selectList(up5);
} }
......
...@@ -88,4 +88,4 @@ feign.okhttp.enabled= true ...@@ -88,4 +88,4 @@ feign.okhttp.enabled= true
workflow.feign.name=AMOS-API-WORKFLOW-CZ workflow.feign.name=AMOS-API-WORKFLOW-CZ
repaymentCron=0 0 1 * * ? repaymentCron=0 0 1 * * ?
urlHttp=http://47.92.234.253:8088 urlHttp=http://47.92.234.253:9000
\ No newline at end of file \ No newline at end of file
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