时间工具类新增 将分钟转成 x时x分钟方法,小程序订单列表页充电时长从缓存中取

This commit is contained in:
Lemon
2023-10-11 11:04:14 +08:00
parent fbf2f03058
commit dd77f63f07
5 changed files with 54 additions and 11 deletions

View File

@@ -236,18 +236,31 @@ public class OrderService {
for (OrderVO orderVO : pageInfo.getList()) { for (OrderVO orderVO : pageInfo.getList()) {
orderVO.setPileConnectorCode(orderVO.getPileSn() + orderVO.getConnectorCode()); orderVO.setPileConnectorCode(orderVO.getPileSn() + orderVO.getConnectorCode());
String chargingTime = "0分钟"; // 从缓存中获取充电时长
if (orderVO.getStartTime() != null) { List<RealTimeMonitorData> chargingRealTimeData = orderBasicInfoService.getChargingRealTimeData(orderVO.getTransactionCode());
Date startTimeDate = DateUtils.parseDate(orderVO.getStartTime()); // 默认时间倒序排列,因此只取第一条就可以
Date endTimeDate; if (CollectionUtils.isEmpty(chargingRealTimeData)) {
if (orderVO.getEndTime() != null) { orderVO.setChargingTime("-");
endTimeDate = DateUtils.parseDate(orderVO.getEndTime()); continue;
} else {
endTimeDate = new Date();
}
// 计算出两个时间差
chargingTime = DateUtils.getDatePoor(endTimeDate, startTimeDate);
} }
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); orderVO.setChargingTime(chargingTime);
} }

View File

@@ -153,6 +153,11 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
} }
public static void main(String[] args) throws ParseException { public static void main(String[] args) throws ParseException {
String s = convertMinutesToTime(75);
System.out.println(s);
String startDate = "2023-07-01"; String startDate = "2023-07-01";
String endDate = "2023-07-20"; String endDate = "2023-07-20";
LocalDate of = LocalDate.of(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; 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);
}
}
/** /**
* 当前时间是否在时间指定范围内<br> * 当前时间是否在时间指定范围内<br>
* *

View File

@@ -19,6 +19,11 @@ public class OrderVO {
*/ */
private String orderCode; private String orderCode;
/**
* 交易流水号
*/
private String transactionCode;
/** /**
* 桩编号 * 桩编号
*/ */

View File

@@ -803,6 +803,7 @@
<select id="getListByMemberIdAndOrderStatus" resultType="com.jsowell.pile.vo.uniapp.OrderVO"> <select id="getListByMemberIdAndOrderStatus" resultType="com.jsowell.pile.vo.uniapp.OrderVO">
SELECT t1.id, SELECT t1.id,
t1.order_code as orderCode, t1.order_code as orderCode,
t1.transaction_code as transactionCode,
t1.order_status as orderStatus, t1.order_status as orderStatus,
t1.reason, t1.reason,
t1.station_id as stationId, t1.station_id as stationId,

View File

@@ -72,6 +72,7 @@ public interface NRService {
String notification_orderInfo(String orderCode); String notification_orderInfo(String orderCode);
/** /**
* 查询充电电量信息
* 此接口用于批量查询时间区段内交易记录 * 此接口用于批量查询时间区段内交易记录
* @param dto * @param dto
* @return * @return