|
@@ -1,13 +1,18 @@
|
|
|
package com.shcd.scheduling;
|
|
|
|
|
|
+import com.shcd.entity.ShorePowerDeviceUsage;
|
|
|
+import com.shcd.enums.AreaSortEnum;
|
|
|
+import com.shcd.service.ShorePowerDeviceUsageService;
|
|
|
import com.shcd.service.SpStatementInlandLowService;
|
|
|
import com.shcd.service.SpStatementQuarterReportService;
|
|
|
import com.shcd.service.SpStatementShipUsageMonthService;
|
|
|
+import java.text.ParseException;
|
|
|
import java.time.LocalDate;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
import javax.annotation.Resource;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.scheduling.annotation.Scheduled;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
@Component
|
|
@@ -23,15 +28,21 @@ public class ShorePowerReportGenerateScheduler {
|
|
|
@Autowired
|
|
|
private SpStatementQuarterReportService spStatementQuarterReportService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private ShorePowerDeviceUsageService shorePowerDeviceUsageService;
|
|
|
+
|
|
|
// @PostConstruct
|
|
|
-// @Scheduled(cron = "0 0/1 * * * ?")
|
|
|
+ @Scheduled(cron = "0 0/1 * * * ?")
|
|
|
public void generateSpInlandLowStatement() {
|
|
|
try {
|
|
|
// 生成各区上报数据 内河低压分析表
|
|
|
log.warn("开始生成 内河低压分析表-各区上报数据 ========");
|
|
|
generateReport1();
|
|
|
log.warn("内河低压分析表-各区上报数据 ======== 生成结束");
|
|
|
-// 生成市级平台自动上传数据 内河低压分析表
|
|
|
+ log.warn("生成下个月的内河非标岸电使用情况表 ======");
|
|
|
+ generateDeviceUsage();
|
|
|
+ log.warn("生成下个月的内河非标岸电使用情况表 ====== 生成结束");
|
|
|
+//// 生成市级平台自动上传数据 内河低压分析表
|
|
|
log.warn("开始生成 内河低压分析表-市级平台自动上传数据 ========");
|
|
|
generateReport2();
|
|
|
log.warn("内河低压分析表-市级平台自动上传数据 ========生成结束");
|
|
@@ -40,35 +51,55 @@ public class ShorePowerReportGenerateScheduler {
|
|
|
"开始生成 上海市长江经济带船舶使用岸电情况报表 以及 上海港船舶使用岸电情况分年度对比分析表 以及 靠泊上港集团码头的集装箱船舶(2024年上海市岸电使用指标Part2) ========");
|
|
|
generateReport3();
|
|
|
log.warn("上海市长江经济带船舶使用岸电情况报表 ========生成结束");
|
|
|
+ log.warn("开始生成 岸电季度报表 ================");
|
|
|
+ generateSpQuarterReport();
|
|
|
+ log.warn("岸电季度报表 ========生成结束");
|
|
|
} catch (Exception e) {
|
|
|
log.error("中间表生成逻辑出错....原因:{}", e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private void generateDeviceUsage() throws ParseException {
|
|
|
+ try {
|
|
|
+ shorePowerDeviceUsageService.generateDeviceUsageNextMonth(getShorePowerNextMonthDate());
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("生成下个月的内河非标岸电使用情况表出错....原因:{}", e.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
//@PostConstruct
|
|
|
public void generateSpQuarterReport() {
|
|
|
try {
|
|
|
- generateReportSpQuarterReport();
|
|
|
+ spStatementQuarterReportService.generateReportSpQuarterReport(getShorePowerDate());
|
|
|
} catch (Exception e) {
|
|
|
log.error("季度表出错....原因:{}", e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void generateReportSpQuarterReport() {
|
|
|
- spStatementQuarterReportService.generateReportSpQuarterReport(null);
|
|
|
- }
|
|
|
-
|
|
|
private void generateReport3() {
|
|
|
- spStatementShipUsageMonthService.makeShangHaiShorePowerUsageRecord(null);
|
|
|
+ try {
|
|
|
+ spStatementShipUsageMonthService.makeShangHaiShorePowerUsageRecord(getShorePowerDate());
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("上海市长江经济带船舶使用岸电情况报表出错....原因:{}", e.getMessage());
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private void generateReport1() {
|
|
|
- spStatementInlandLowService.makeReport1(getShorePowerDate(), getShorePowerLastMonthDate());
|
|
|
+ try {
|
|
|
+ spStatementInlandLowService.makeReport1(getShorePowerDate(), getShorePowerLastMonthDate());
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("内河低压分析表-市级平台自动上传数据出错....原因:{}", e.getMessage());
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private void generateReport2() {
|
|
|
- spStatementInlandLowService.makeReport2(getShorePowerDate(), getShorePowerLastMonthDate(),
|
|
|
- getShorePowerLast2MonthDate(), getShorePowerLast3MonthDate());
|
|
|
+ try {
|
|
|
+ spStatementInlandLowService.makeReport2(getShorePowerDate(), getShorePowerLastMonthDate(),
|
|
|
+ getShorePowerLast2MonthDate(), getShorePowerLast3MonthDate());
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("内河低压分析表-各区上报出错....原因:{}", e.getMessage());
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private static String getShorePowerDate() {
|
|
@@ -78,6 +109,12 @@ public class ShorePowerReportGenerateScheduler {
|
|
|
return date;
|
|
|
}
|
|
|
|
|
|
+ private static String getShorePowerNextMonthDate() {
|
|
|
+ String date = null;
|
|
|
+ date = DateTimeFormatter.ofPattern("yyyy-MM").format(LocalDate.now().plusMonths(1));
|
|
|
+ return date;
|
|
|
+ }
|
|
|
+
|
|
|
private static String getShorePowerLastMonthDate() {
|
|
|
String date = null;
|
|
|
date = DateTimeFormatter.ofPattern("yyyy-MM").format(LocalDate.now().plusMonths(-1));
|