From dd77f63f07a21faa57fc6a27fc5dec9f198e0764 Mon Sep 17 00:00:00 2001 From: Lemon Date: Wed, 11 Oct 2023 11:04:14 +0800 Subject: [PATCH] =?UTF-8?q?=E6=97=B6=E9=97=B4=E5=B7=A5=E5=85=B7=E7=B1=BB?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=20=E5=B0=86=E5=88=86=E9=92=9F=E8=BD=AC?= =?UTF-8?q?=E6=88=90=20x=E6=97=B6x=E5=88=86=E9=92=9F=E6=96=B9=E6=B3=95?= =?UTF-8?q?=EF=BC=8C=E5=B0=8F=E7=A8=8B=E5=BA=8F=E8=AE=A2=E5=8D=95=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E9=A1=B5=E5=85=85=E7=94=B5=E6=97=B6=E9=95=BF=E4=BB=8E?= =?UTF-8?q?=E7=BC=93=E5=AD=98=E4=B8=AD=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/jsowell/service/OrderService.java | 35 +++++++++++++------ .../com/jsowell/common/util/DateUtils.java | 23 ++++++++++++ .../com/jsowell/pile/vo/uniapp/OrderVO.java | 5 +++ .../mapper/pile/OrderBasicInfoMapper.xml | 1 + .../thirdparty/nanrui/service/NRService.java | 1 + 5 files changed, 54 insertions(+), 11 deletions(-) diff --git a/jsowell-admin/src/main/java/com/jsowell/service/OrderService.java b/jsowell-admin/src/main/java/com/jsowell/service/OrderService.java index 05e6f986d..cd2d75221 100644 --- a/jsowell-admin/src/main/java/com/jsowell/service/OrderService.java +++ b/jsowell-admin/src/main/java/com/jsowell/service/OrderService.java @@ -236,18 +236,31 @@ public class OrderService { for (OrderVO orderVO : pageInfo.getList()) { orderVO.setPileConnectorCode(orderVO.getPileSn() + orderVO.getConnectorCode()); - String chargingTime = "0分钟"; - if (orderVO.getStartTime() != null) { - Date startTimeDate = DateUtils.parseDate(orderVO.getStartTime()); - Date endTimeDate; - if (orderVO.getEndTime() != null) { - endTimeDate = DateUtils.parseDate(orderVO.getEndTime()); - } else { - endTimeDate = new Date(); - } - // 计算出两个时间差 - chargingTime = DateUtils.getDatePoor(endTimeDate, startTimeDate); + // 从缓存中获取充电时长 + List chargingRealTimeData = orderBasicInfoService.getChargingRealTimeData(orderVO.getTransactionCode()); + // 默认时间倒序排列,因此只取第一条就可以 + if (CollectionUtils.isEmpty(chargingRealTimeData)) { + orderVO.setChargingTime("-"); + continue; } + RealTimeMonitorData realTimeMonitorData = chargingRealTimeData.get(0); + String sumChargingTime = realTimeMonitorData.getSumChargingTime(); // xx分钟 + // 分钟转成 x时x分 + String chargingTime = DateUtils.convertMinutesToTime(Integer.parseInt(sumChargingTime)); + + // String chargingTime = "0分钟"; + // if (orderVO.getStartTime() != null) { + // Date startTimeDate = DateUtils.parseDate(orderVO.getStartTime()); + // Date endTimeDate; + // if (orderVO.getEndTime() != null) { + // endTimeDate = DateUtils.parseDate(orderVO.getEndTime()); + // // 计算出两个时间差 + // chargingTime = DateUtils.getDatePoor(endTimeDate, startTimeDate); + // } else { + // endTimeDate = new Date(); + // } + // + // } orderVO.setChargingTime(chargingTime); } diff --git a/jsowell-common/src/main/java/com/jsowell/common/util/DateUtils.java b/jsowell-common/src/main/java/com/jsowell/common/util/DateUtils.java index 109b715c3..7466b849f 100644 --- a/jsowell-common/src/main/java/com/jsowell/common/util/DateUtils.java +++ b/jsowell-common/src/main/java/com/jsowell/common/util/DateUtils.java @@ -153,6 +153,11 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils { } public static void main(String[] args) throws ParseException { + + String s = convertMinutesToTime(75); + System.out.println(s); + + String startDate = "2023-07-01"; String endDate = "2023-07-20"; LocalDate of = LocalDate.of(2023, 07, 20); @@ -855,6 +860,24 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils { return DateTimes; } + /** + * 分钟转 x时x分 + * @param minutes + * @return + */ + public static String convertMinutesToTime(int minutes) { + if (minutes < 0) { + return null; + } + int hours = minutes / 60; + int remainingMinutes = minutes % 60; + if (hours < 1) { + return String.format("%d分钟", remainingMinutes); + }else { + return String.format("%d小时%d分钟", hours, remainingMinutes); + } + } + /** * 当前时间是否在时间指定范围内
* diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/vo/uniapp/OrderVO.java b/jsowell-pile/src/main/java/com/jsowell/pile/vo/uniapp/OrderVO.java index dccd758a0..5fa947720 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/vo/uniapp/OrderVO.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/vo/uniapp/OrderVO.java @@ -19,6 +19,11 @@ public class OrderVO { */ private String orderCode; + /** + * 交易流水号 + */ + private String transactionCode; + /** * 桩编号 */ diff --git a/jsowell-pile/src/main/resources/mapper/pile/OrderBasicInfoMapper.xml b/jsowell-pile/src/main/resources/mapper/pile/OrderBasicInfoMapper.xml index c6529ef5a..64fb104f6 100644 --- a/jsowell-pile/src/main/resources/mapper/pile/OrderBasicInfoMapper.xml +++ b/jsowell-pile/src/main/resources/mapper/pile/OrderBasicInfoMapper.xml @@ -803,6 +803,7 @@