Browse Source

岸电开发调试和BUG修复

sbj 1 month ago
parent
commit
f3d3f3995d

+ 5 - 0
src/README.md

@@ -0,0 +1,5 @@
+该项目分支用于港口岸电对接
+1、岸电数据定时同步;
+端口:9098
+2、岸电报表定期生成;
+端口:9096

+ 6 - 4
src/main/java/com/shcd/controller/ShorePowerController.java

@@ -394,6 +394,7 @@ public class ShorePowerController {
   @PostMapping("/query_connRecord_info")
   public String getConnRecordInfo(@RequestBody Map<String, Object> map) {
     try {
+      log.info("==============> 手动获取连船记录信息查询接口调用开始");
       String portId = (String) map.get("portId");
       String deviceId = (String) map.get("deviceId");
       String berthId = (String) map.get("berthId");
@@ -641,7 +642,7 @@ public class ShorePowerController {
     JSONObject berthInfo = new JSONObject();
     LocalDateTime now = LocalDateTime.now();
     LocalDateTime oneHourAgo = now.minusHours(12);
-    DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd hh:mm:ss");
+    DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
     berthInfo.put("realName", realName);
     berthInfo.put("page", page);
     berthInfo.put("limit", limit);
@@ -728,8 +729,9 @@ public class ShorePowerController {
     JSONObject data = new JSONObject();
     JSONObject berthInfo = new JSONObject();
     LocalDateTime now = LocalDateTime.now();
-    LocalDateTime oneHourAgo = now.minusMonths(3);
-    DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd hh:mm:ss");
+//    LocalDateTime oneHourAgo = now.minusMonths(3);
+    LocalDateTime oneHourAgo = now.minusHours(6);
+    DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
     berthInfo.put("portId", portId);
     berthInfo.put("deviceId", deviceId);
     berthInfo.put("berthId", berthId);
@@ -988,7 +990,7 @@ public class ShorePowerController {
     berthInfo.put("limit", limit);
 //    LocalDateTime now = LocalDateTime.now();
 //    LocalDateTime oneHourAgo = now.minusHours(24);
-//    DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd hh:mm:ss");
+//    DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
 //    berthInfo.put("updateDate", formatter.format(oneHourAgo));
     data.put("portInfo", berthInfo);
     JSONObject portRequest = new JSONObject();

+ 136 - 136
src/main/java/com/shcd/scheduling/ShorePowerReportGenerateScheduler.java

@@ -1,136 +1,136 @@
-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
-@Slf4j
-public class ShorePowerReportGenerateScheduler {
-
-  @Resource
-  SpStatementShipUsageMonthService spStatementShipUsageMonthService;
-
-  @Resource
-  SpStatementInlandLowService spStatementInlandLowService;
-
-  @Autowired
-  private SpStatementQuarterReportService spStatementQuarterReportService;
-
-  @Resource
-  private ShorePowerDeviceUsageService shorePowerDeviceUsageService;
-
-  //  @PostConstruct
-  @Scheduled(cron = "0 0 0 25 * ?")
-  public void generateSpInlandLowStatement() {
-    try {
-      // 生成各区上报数据   内河低压分析表
-      log.warn("开始生成 内河低压分析表-各区上报数据  ========");
-      generateReport1();
-      log.warn("内河低压分析表-各区上报数据  ======== 生成结束");
-      log.warn("生成下个月的内河非标岸电使用情况表  ======");
-      generateDeviceUsage();
-      log.warn("生成下个月的内河非标岸电使用情况表  ====== 生成结束");
-////       生成市级平台自动上传数据   内河低压分析表
-      log.warn("开始生成 内河低压分析表-市级平台自动上传数据  ========");
-      generateReport2();
-      log.warn("内河低压分析表-市级平台自动上传数据  ========生成结束");
-      //生成上海市长江经济带船舶使用岸电情况报表
-      log.warn(
-          "开始生成 上海市长江经济带船舶使用岸电情况报表   以及  上海港船舶使用岸电情况分年度对比分析表  以及  靠泊上港集团码头的集装箱船舶(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 {
-      spStatementQuarterReportService.generateReportSpQuarterReport(getShorePowerDate());
-    } catch (Exception e) {
-      log.error("季度表出错....原因:{}", e.getMessage());
-    }
-  }
-
-  private void generateReport3() {
-    try {
-      spStatementShipUsageMonthService.makeShangHaiShorePowerUsageRecord(getShorePowerDate());
-    } catch (Exception e) {
-      log.error("上海市长江经济带船舶使用岸电情况报表出错....原因:{}", e.getMessage());
-    }
-  }
-
-  private void generateReport1() {
-    try {
-      spStatementInlandLowService.makeReport1(getShorePowerDate(), getShorePowerLastMonthDate());
-    } catch (Exception e) {
-      log.error("内河低压分析表-市级平台自动上传数据出错....原因:{}", e.getMessage());
-    }
-  }
-
-  private void generateReport2() {
-    try {
-      spStatementInlandLowService.makeReport2(getShorePowerDate(), getShorePowerLastMonthDate(),
-          getShorePowerLast2MonthDate(), getShorePowerLast3MonthDate());
-    } catch (Exception e) {
-      log.error("内河低压分析表-各区上报出错....原因:{}", e.getMessage());
-    }
-  }
-
-  private static String getShorePowerDate() {
-    String date = null;
-    LocalDate now = LocalDate.now();
-    date = DateTimeFormatter.ofPattern("yyyy-MM").format(now);
-    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));
-    return date;
-  }
-
-
-  private static String getShorePowerLast2MonthDate() {
-    String date = null;
-    date = DateTimeFormatter.ofPattern("yyyy-MM").format(LocalDate.now().plusMonths(-2));
-    return date;
-  }
-
-  private static String getShorePowerLast3MonthDate() {
-    String date = null;
-    date = DateTimeFormatter.ofPattern("yyyy-MM").format(LocalDate.now().plusMonths(-3));
-    return date;
-  }
-}
+//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
+//@Slf4j
+//public class ShorePowerReportGenerateScheduler {
+//
+//  @Resource
+//  SpStatementShipUsageMonthService spStatementShipUsageMonthService;
+//
+//  @Resource
+//  SpStatementInlandLowService spStatementInlandLowService;
+//
+//  @Autowired
+//  private SpStatementQuarterReportService spStatementQuarterReportService;
+//
+//  @Resource
+//  private ShorePowerDeviceUsageService shorePowerDeviceUsageService;
+//
+//  //  @PostConstruct
+//  @Scheduled(cron = "0 0 0 25 * ?")
+//  public void generateSpInlandLowStatement() {
+//    try {
+//      // 生成各区上报数据   内河低压分析表
+//      log.warn("开始生成 内河低压分析表-各区上报数据  ========");
+//      generateReport1();
+//      log.warn("内河低压分析表-各区上报数据  ======== 生成结束");
+//      log.warn("生成下个月的内河非标岸电使用情况表  ======");
+//      generateDeviceUsage();
+//      log.warn("生成下个月的内河非标岸电使用情况表  ====== 生成结束");
+//////       生成市级平台自动上传数据   内河低压分析表
+//      log.warn("开始生成 内河低压分析表-市级平台自动上传数据  ========");
+//      generateReport2();
+//      log.warn("内河低压分析表-市级平台自动上传数据  ========生成结束");
+//      //生成上海市长江经济带船舶使用岸电情况报表
+//      log.warn(
+//          "开始生成 上海市长江经济带船舶使用岸电情况报表   以及  上海港船舶使用岸电情况分年度对比分析表  以及  靠泊上港集团码头的集装箱船舶(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 {
+//      spStatementQuarterReportService.generateReportSpQuarterReport(getShorePowerDate());
+//    } catch (Exception e) {
+//      log.error("季度表出错....原因:{}", e.getMessage());
+//    }
+//  }
+//
+//  private void generateReport3() {
+//    try {
+//      spStatementShipUsageMonthService.makeShangHaiShorePowerUsageRecord(getShorePowerDate());
+//    } catch (Exception e) {
+//      log.error("上海市长江经济带船舶使用岸电情况报表出错....原因:{}", e.getMessage());
+//    }
+//  }
+//
+//  private void generateReport1() {
+//    try {
+//      spStatementInlandLowService.makeReport1(getShorePowerDate(), getShorePowerLastMonthDate());
+//    } catch (Exception e) {
+//      log.error("内河低压分析表-市级平台自动上传数据出错....原因:{}", e.getMessage());
+//    }
+//  }
+//
+//  private void generateReport2() {
+//    try {
+//      spStatementInlandLowService.makeReport2(getShorePowerDate(), getShorePowerLastMonthDate(),
+//          getShorePowerLast2MonthDate(), getShorePowerLast3MonthDate());
+//    } catch (Exception e) {
+//      log.error("内河低压分析表-各区上报出错....原因:{}", e.getMessage());
+//    }
+//  }
+//
+//  private static String getShorePowerDate() {
+//    String date = null;
+//    LocalDate now = LocalDate.now();
+//    date = DateTimeFormatter.ofPattern("yyyy-MM").format(now);
+//    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));
+//    return date;
+//  }
+//
+//
+//  private static String getShorePowerLast2MonthDate() {
+//    String date = null;
+//    date = DateTimeFormatter.ofPattern("yyyy-MM").format(LocalDate.now().plusMonths(-2));
+//    return date;
+//  }
+//
+//  private static String getShorePowerLast3MonthDate() {
+//    String date = null;
+//    date = DateTimeFormatter.ofPattern("yyyy-MM").format(LocalDate.now().plusMonths(-3));
+//    return date;
+//  }
+//}

+ 1 - 1
src/main/java/com/shcd/service/impl/SpStatementShipUsageMonthServiceImpl.java

@@ -272,7 +272,7 @@ public class SpStatementShipUsageMonthServiceImpl extends
       sum.setShorePowerTimeYear(origin.getShorePowerTimeYear().add(gh.getShorePowerTimeYear())
           .add(underLine.getShorePowerTimeYear()).setScale(2, RoundingMode.HALF_UP));
       spStatementShipUsageMonths.add(sum);
-      //傻逼一样的要多算一部分数据,外电1,2,3
+      //zoro备注:要多算一部分数据,外电1,2,3
       List<SpStatementShipUsageDetail> sbWgq = spStatementShipUsageMonthMapper.selectWgqMonth(
           thisDate, lastDate, lastCycleStart, lastCycleEnd);
       SpStatementShipUsageMonthVo wgqMonth = makeOriginMonthData(sbWgq);