update 订单相关修改

This commit is contained in:
Lemon
2023-03-14 09:19:47 +08:00
parent db31e0679b
commit 1b3fa33bb8
9 changed files with 78 additions and 15 deletions

View File

@@ -626,7 +626,7 @@ public class OrderService {
String pileConnectorCode = orderBasicInfo.getPileSn() + orderBasicInfo.getConnectorCode(); String pileConnectorCode = orderBasicInfo.getPileSn() + orderBasicInfo.getConnectorCode();
QueryConnectorListDTO dto = new QueryConnectorListDTO(); QueryConnectorListDTO dto = new QueryConnectorListDTO();
dto.setConnectorCodeList(Lists.newArrayList(pileConnectorCode)); dto.setConnectorCodeList(Lists.newArrayList(pileConnectorCode));
List<RealTimeMonitorData> chargingRealTimeDataList = orderBasicInfoService.getChargingRealTimeData(orderCode); List<RealTimeMonitorData> chargingRealTimeDataList = orderBasicInfoService.getChargingRealTimeData(orderBasicInfo.getTransactionCode());
if (CollectionUtils.isNotEmpty(chargingRealTimeDataList)) { if (CollectionUtils.isNotEmpty(chargingRealTimeDataList)) {
List<OrderDetailInfoVO.RealTimeMonitorData> infoList = Lists.newArrayList(); List<OrderDetailInfoVO.RealTimeMonitorData> infoList = Lists.newArrayList();
for (RealTimeMonitorData realTimeMonitorData : chargingRealTimeDataList) { for (RealTimeMonitorData realTimeMonitorData : chargingRealTimeDataList) {
@@ -733,7 +733,9 @@ public class OrderService {
vo.setPileConnectorCode(orderBasicInfo.getPileSn() + orderBasicInfo.getConnectorCode()); vo.setPileConnectorCode(orderBasicInfo.getPileSn() + orderBasicInfo.getConnectorCode());
String orderStatus = orderBasicInfo.getOrderStatus(); String orderStatus = orderBasicInfo.getOrderStatus();
vo.setOrderStatus(orderStatus); vo.setOrderStatus(orderStatus);
if (Objects.nonNull(orderBasicInfo.getChargeStartTime())) {
vo.setStartChargingTime(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, orderBasicInfo.getChargeStartTime())); vo.setStartChargingTime(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, orderBasicInfo.getChargeStartTime()));
}
Date chargeEndTime = orderBasicInfo.getChargeEndTime(); Date chargeEndTime = orderBasicInfo.getChargeEndTime();
if (Objects.nonNull(chargeEndTime)) { if (Objects.nonNull(chargeEndTime)) {
vo.setEndChargingTime(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, chargeEndTime)); vo.setEndChargingTime(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, chargeEndTime));
@@ -768,7 +770,7 @@ public class OrderService {
} }
// 获取订单充电数据 // 获取订单充电数据
List<RealTimeMonitorData> monitorDataList = orderBasicInfoService.getChargingRealTimeData(orderCode); List<RealTimeMonitorData> monitorDataList = orderBasicInfoService.getChargingRealTimeData(orderBasicInfo.getTransactionCode());
if (CollectionUtils.isNotEmpty(monitorDataList)) { if (CollectionUtils.isNotEmpty(monitorDataList)) {
List<UniAppOrderVO.ChargingData> chargingDataList = Lists.newArrayList(); List<UniAppOrderVO.ChargingData> chargingDataList = Lists.newArrayList();
UniAppOrderVO.ChargingData data = null; UniAppOrderVO.ChargingData data = null;
@@ -821,7 +823,11 @@ public class OrderService {
* @return * @return
*/ */
public String selectPileStarterStatus(String orderCode) { public String selectPileStarterStatus(String orderCode) {
List<RealTimeMonitorData> chargingRealTimeData = orderBasicInfoService.getChargingRealTimeData(orderCode); OrderBasicInfo orderInfoByOrderCode = orderBasicInfoService.getOrderInfoByOrderCode(orderCode);
if (orderInfoByOrderCode == null) {
return Constants.ZERO;
}
List<RealTimeMonitorData> chargingRealTimeData = orderBasicInfoService.getChargingRealTimeData(orderInfoByOrderCode.getTransactionCode());
// 只有充电桩上传的实时数据中的状态为充电,才能查到实时数据列表 // 只有充电桩上传的实时数据中的状态为充电,才能查到实时数据列表
return CollectionUtils.isNotEmpty(chargingRealTimeData) ? Constants.ONE : Constants.ZERO; return CollectionUtils.isNotEmpty(chargingRealTimeData) ? Constants.ONE : Constants.ZERO;
} }

View File

@@ -337,7 +337,7 @@ public class PileService {
} }
String orderCode = basicInfo.getOrderCode(); String orderCode = basicInfo.getOrderCode();
// 根据订单号从redis中获取实时数据信息(默认时间倒叙排列,所以取第一条) // 根据订单号从redis中获取实时数据信息(默认时间倒叙排列,所以取第一条)
List<RealTimeMonitorData> chargingRealTimeData = orderBasicInfoService.getChargingRealTimeData(orderCode); List<RealTimeMonitorData> chargingRealTimeData = orderBasicInfoService.getChargingRealTimeData(basicInfo.getTransactionCode());
if (CollectionUtils.isEmpty(chargingRealTimeData)) { if (CollectionUtils.isEmpty(chargingRealTimeData)) {
throw new BusinessException(ReturnCodeEnum.CODE_NO_REAL_TIME_INFO); throw new BusinessException(ReturnCodeEnum.CODE_NO_REAL_TIME_INFO);
} }

View File

@@ -105,6 +105,14 @@ public interface PileBillingTemplateMapper {
List<BillingTemplateVO> queryStationBillingTemplateList(@Param("stationId") String stationId, List<BillingTemplateVO> queryStationBillingTemplateList(@Param("stationId") String stationId,
@Param("stationDeptIds") List<String> stationDeptIds); @Param("stationDeptIds") List<String> stationDeptIds);
/**
* 根据站点id查询站点计费模板列表
* 根据发布时间倒序,最新一条就是目前正在使用的计费模板
* @param stationId 站点id
* @return
*/
List<BillingTemplateVO> queryStationBillingTemplateListForUniApp(@Param("stationId") String stationId);
/** /**
* 通过桩sn号查询计费模板 * 通过桩sn号查询计费模板
* *

View File

@@ -89,6 +89,14 @@ public interface IPileBillingTemplateService {
*/ */
List<BillingTemplateVO> queryStationBillingTemplateList(String stationId); List<BillingTemplateVO> queryStationBillingTemplateList(String stationId);
/**
* 查询站点计费模板
*
* @param stationId 站点id
* @return
*/
List<BillingTemplateVO> queryStationBillingTemplateListForUniApp(String stationId);
/** /**
* 查询正在使用中的计费模板 * 查询正在使用中的计费模板
* @param stationId 站点id * @param stationId 站点id

View File

@@ -314,7 +314,7 @@ public class OrderBasicInfoServiceImpl implements IOrderBasicInfoService {
continue; continue;
} }
// 获取订单的实时检测数据,有实时数据说明充电了,没有实时数据说明桩确实没有充电 // 获取订单的实时检测数据,有实时数据说明充电了,没有实时数据说明桩确实没有充电
List<RealTimeMonitorData> chargingRealTimeData = getChargingRealTimeData(orderCode); List<RealTimeMonitorData> chargingRealTimeData = getChargingRealTimeData(orderBasicInfo.getTransactionCode());
if (CollectionUtils.isEmpty(chargingRealTimeData)) { if (CollectionUtils.isEmpty(chargingRealTimeData)) {
// 充电桩在线并且没有0x13实时数据则执行结算退款操作 // 充电桩在线并且没有0x13实时数据则执行结算退款操作
chargingPileFailedToStart(orderCode, "充电桩启动失败,执行退款处理"); chargingPileFailedToStart(orderCode, "充电桩启动失败,执行退款处理");
@@ -690,17 +690,18 @@ public class OrderBasicInfoServiceImpl implements IOrderBasicInfoService {
* 根据订单编号获取充电实时数据 时间倒序 * 根据订单编号获取充电实时数据 时间倒序
* 订单只有在充电中才会把实时数据保存到redis * 订单只有在充电中才会把实时数据保存到redis
* *
* @param orderCode 订单编号 * @param transactionCode 订单编号
* @return * @return
*/ */
@Override @Override
public List<RealTimeMonitorData> getChargingRealTimeData(String orderCode) { public List<RealTimeMonitorData> getChargingRealTimeData(String transactionCode) {
List<RealTimeMonitorData> resultList = Lists.newArrayList(); List<RealTimeMonitorData> resultList = Lists.newArrayList();
if (StringUtils.isBlank(orderCode)) { if (StringUtils.isBlank(transactionCode)) {
return resultList; return resultList;
} }
String pileConnectorCode = orderCode.substring(0, 16); logger.info("transactionCode:{}", transactionCode);
String redisKey = CacheConstants.PILE_REAL_TIME_MONITOR_DATA + pileConnectorCode + "_" + orderCode; String pileConnectorCode = transactionCode.substring(0, 16);
String redisKey = CacheConstants.PILE_REAL_TIME_MONITOR_DATA + pileConnectorCode + "_" + transactionCode;
// 拿到所有数据 // 拿到所有数据
Map<Object, Object> map = redisCache.hmget(redisKey); Map<Object, Object> map = redisCache.hmget(redisKey);
if (map != null && !map.isEmpty()) { if (map != null && !map.isEmpty()) {

View File

@@ -457,7 +457,7 @@ public class PileBasicInfoServiceImpl implements IPileBasicInfoService {
@Override @Override
public void saveRealTimeMonitorData2Redis(RealTimeMonitorData realTimeMonitorData) { public void saveRealTimeMonitorData2Redis(RealTimeMonitorData realTimeMonitorData) {
// 保存到redis // 保存到redis
String redisKey = CacheConstants.PILE_REAL_TIME_MONITOR_DATA + realTimeMonitorData.getPileConnectorCode() + "_" + realTimeMonitorData.getConnectorCode(); String redisKey = CacheConstants.PILE_REAL_TIME_MONITOR_DATA + realTimeMonitorData.getPileConnectorCode() + "_" + realTimeMonitorData.getTransactionCode();
// 设置接收到实时数据的时间 // 设置接收到实时数据的时间
Date now = new Date(); Date now = new Date();

View File

@@ -359,6 +359,11 @@ public class PileBillingTemplateServiceImpl implements IPileBillingTemplateServi
return pileBillingTemplateMapper.queryStationBillingTemplateList(stationId, authorizedMap.getStationDeptIds()); return pileBillingTemplateMapper.queryStationBillingTemplateList(stationId, authorizedMap.getStationDeptIds());
} }
@Override
public List<BillingTemplateVO> queryStationBillingTemplateListForUniApp(String stationId) {
return pileBillingTemplateMapper.queryStationBillingTemplateListForUniApp(stationId);
}
/** /**
* 查询正在使用中的计费模板 * 查询正在使用中的计费模板
* 1 发布时间不为null * 1 发布时间不为null
@@ -368,7 +373,7 @@ public class PileBillingTemplateServiceImpl implements IPileBillingTemplateServi
*/ */
@Override @Override
public BillingTemplateVO queryUsedBillingTemplate(String stationId) { public BillingTemplateVO queryUsedBillingTemplate(String stationId) {
List<BillingTemplateVO> list = queryStationBillingTemplateList(stationId); List<BillingTemplateVO> list = queryStationBillingTemplateListForUniApp(stationId);
Optional<BillingTemplateVO> max = list.stream() Optional<BillingTemplateVO> max = list.stream()
.filter(x -> StringUtils.isNotBlank(x.getPublishTime())) .filter(x -> StringUtils.isNotBlank(x.getPublishTime()))
.max(Comparator.comparing(BillingTemplateVO::getPublishTime)); .max(Comparator.comparing(BillingTemplateVO::getPublishTime));

View File

@@ -412,8 +412,10 @@ public class PileConnectorInfoServiceImpl implements IPileConnectorInfoService {
// 获取枪口的日志记录 // 获取枪口的日志记录
for (PileConnectorInfoVO pileConnectorInfoVO : pileConnectorInfoList) { for (PileConnectorInfoVO pileConnectorInfoVO : pileConnectorInfoList) {
// 从redis中获取实时数据信息 // 从redis中获取实时数据信息
if (StringUtils.isNotBlank(pileConnectorInfoVO.getOrderCode())) { String orderCode = pileConnectorInfoVO.getOrderCode();
List<RealTimeMonitorData> chargingRealTimeDataList = orderBasicInfoService.getChargingRealTimeData(pileConnectorInfoVO.getOrderCode()); if (StringUtils.isNotBlank(orderCode)) {
OrderBasicInfo orderBasicInfo = orderBasicInfoService.getOrderInfoByOrderCode(orderCode);
List<RealTimeMonitorData> chargingRealTimeDataList = orderBasicInfoService.getChargingRealTimeData(orderBasicInfo.getTransactionCode());
RealTimeMonitorData realTimeMonitorData = chargingRealTimeDataList.get(0); RealTimeMonitorData realTimeMonitorData = chargingRealTimeDataList.get(0);
BigDecimal outputVoltage = new BigDecimal(realTimeMonitorData.getOutputVoltage()); BigDecimal outputVoltage = new BigDecimal(realTimeMonitorData.getOutputVoltage());
pileConnectorInfoVO.setVoltage(outputVoltage); pileConnectorInfoVO.setVoltage(outputVoltage);

View File

@@ -438,4 +438,37 @@
order by t2.publish_time DESC order by t2.publish_time DESC
limit 1 limit 1
</select> </select>
<select id="queryStationBillingTemplateListForUniApp" resultType="com.jsowell.pile.vo.web.BillingTemplateVO">
select
t2.id as templateId,
t2.template_code as templateCode,
t2.name as templateName,
t2.remark as remark,
t2.type as deviceType,
t2.publish_time as publishTime,
t3.electricity_price AS sharpElectricityPrice,
t3.service_price AS sharpServicePrice,
t3.apply_time AS sharpApplyDate,
t4.electricity_price AS peakElectricityPrice,
t4.service_price AS peakServicePrice,
t4.apply_time AS peakApplyDate,
t5.electricity_price AS flatElectricityPrice,
t5.service_price AS flatServicePrice,
t5.apply_time AS flatApplyDate,
t6.electricity_price AS valleyElectricityPrice,
t6.service_price AS valleyServicePrice,
t6.apply_time AS valleyApplyDate
from
pile_billing_template t2
left join pile_station_info t1 on t1.id = t2.station_id
left JOIN pile_billing_detail t3 ON t3.template_code = t2.template_code AND t3.time_type = '1'
left JOIN pile_billing_detail t4 ON t4.template_code = t2.template_code AND t4.time_type = '2'
left JOIN pile_billing_detail t5 ON t5.template_code = t2.template_code AND t5.time_type = '3'
left JOIN pile_billing_detail t6 ON t6.template_code = t2.template_code AND t6.time_type = '4'
where
t2.del_flag = '0'
and t2.station_id = #{stationId,jdbcType=VARCHAR}
order by t2.publish_time desc
</select>
</mapper> </mapper>