From 261173783d820d20b301965cce4e1001d695a6c7 Mon Sep 17 00:00:00 2001
From: yuyang <2265829957@qq.com>
Date: Wed, 18 Aug 2021 15:35:11 +0800
Subject: [PATCH] =?UTF-8?q?=E6=A1=A9=E5=9B=9E=E8=B0=83=E6=8E=A5=E5=8F=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../mapper/XhpcChargingStationMapper.xml | 4 +-
.../order/api/HxpcPileOrderController.java | 135 ++++++++++++------
.../xhpc/order/domain/XhpcRealTimeOrder.java | 18 +--
.../order/mapper/HxpcChargeOrderMapper.java | 11 --
.../order/mapper/XhpcRealTimeOrderMapper.java | 13 +-
.../service/IHxpcChargeOrderService.java | 4 -
.../service/IXhpcRealTimeOrderService.java | 45 +++++-
.../impl/HxpcChargeOrderServiceImpl.java | 8 +-
.../impl/XhpcRealTimeOrderServiceImpl.java | 53 ++++---
.../mapper/XhpcChargeOrderMapper.xml | 14 --
.../mapper/XhpcRealTimeOrderMapper.xml | 16 +++
11 files changed, 201 insertions(+), 120 deletions(-)
diff --git a/xhpc-modules/xhpc-charging-station/src/main/resources/mapper/XhpcChargingStationMapper.xml b/xhpc-modules/xhpc-charging-station/src/main/resources/mapper/XhpcChargingStationMapper.xml
index a085c76e..857d5f56 100644
--- a/xhpc-modules/xhpc-charging-station/src/main/resources/mapper/XhpcChargingStationMapper.xml
+++ b/xhpc-modules/xhpc-charging-station/src/main/resources/mapper/XhpcChargingStationMapper.xml
@@ -286,9 +286,7 @@
- and (cs.area_code in (select
- cscode
- from xhpc_area where pcode=#{code}) or area_code=#{code})
+ and cs.area_code in (select code from xhpc_area where pcode=#{code}) or cs.area_code=#{code}
ORDER BY distance asc
diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/api/HxpcPileOrderController.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/api/HxpcPileOrderController.java
index a7b442ce..b0aabb3e 100644
--- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/api/HxpcPileOrderController.java
+++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/api/HxpcPileOrderController.java
@@ -13,11 +13,10 @@ import com.xhpc.common.data.redis.CacheRealtimeData;
import com.xhpc.common.dto.PileEndOrder;
import com.xhpc.common.redis.service.RedisService;
import com.xhpc.common.util.ConnectionRabbitMQUtil;
-import com.xhpc.order.domain.HxpcChargeOrder;
-import com.xhpc.order.domain.XhpcHistoryOrder;
-import com.xhpc.order.domain.XhpcRealTimeOrder;
+import com.xhpc.order.domain.*;
import com.xhpc.order.service.IHxpcChargeOrderService;
import com.xhpc.order.service.IXhpcHistoryOrderService;
+import com.xhpc.order.service.IXhpcRealTimeOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
@@ -40,12 +39,15 @@ public class HxpcPileOrderController extends BaseController {
@Autowired
private IXhpcHistoryOrderService xhpcHistoryOrderService;
+ @Autowired
+ private IXhpcRealTimeOrderService xhpcRealTimeOrderService;
@Autowired
private PileOrderService pileOrderService;
+
/**
* 测试
*/
@@ -124,53 +126,104 @@ public class HxpcPileOrderController extends BaseController {
* @return
*/
@GetMapping("/chargeOrder/pileRimeOrder")
- public R pileRealtime(String orderNo) {
+ public R pileRealtime(@RequestParam(value = "orderNo")String orderNo) {
Date date = new Date();
//获取实时订单
- Map cacheMap = redisService.getCacheMap("order:"+orderNo);
- JSONArray st = (JSONArray)cacheMap.get("realtimeDataList");
- System.out.println(st.toString());
+ Map cacheMap = redisService.getCacheMap("order:"+orderNo+".lord");
+ JSONObject jsonObject = (JSONObject)cacheMap.get("realtimeDataList");
+ System.out.println(jsonObject.toString());
HxpcChargeOrder hxpcChargeOrder = hxpcChargeOrderService.getSerialNumberMessage(orderNo);
- if(st!=null && st.size()>0){
- for (int i = 0; i 60){
+ int mins = cacheRealtimeData.getChargingTime() % 60;
+ int hours = cacheRealtimeData.getChargingTime() / 60;
+ xhpcRealTimeOrder.setChargingTime(mins+"时"+hours+"分");
+ }else{
+ xhpcRealTimeOrder.setChargingTime(cacheRealtimeData.getChargingTime()+"分");
+ }
+ if(cacheRealtimeData.getRemainingTime()>60){
+ int mins = cacheRealtimeData.getChargingTime() % 60;
+ int hours = cacheRealtimeData.getChargingTime() / 60;
+ xhpcRealTimeOrder.setRemainingTime(mins+"时"+hours+"分");
+ }else{
+ xhpcRealTimeOrder.setRemainingTime(cacheRealtimeData.getChargingTime()+"分");
+ }
+ BigDecimal decimal = new BigDecimal(100);
+ xhpcRealTimeOrder.setChargingDegree(new BigDecimal(cacheRealtimeData.getChargingDegree()).divide(decimal));
+ xhpcRealTimeOrder.setLossChargingDegree(new BigDecimal(cacheRealtimeData.getLossChargingDegree()).divide(decimal));
+ xhpcRealTimeOrder.setAmountCharged(new BigDecimal(cacheRealtimeData.getLossChargingDegree()).divide(decimal));
+ xhpcRealTimeOrder.setHardwareFault(cacheRealtimeData.getHardwareFault());
+ if("00".equals(cacheRealtimeData.getStatus())){
+ xhpcRealTimeOrder.setStatus(0);
+ }else if("01".equals(cacheRealtimeData.getStatus())){
+ xhpcRealTimeOrder.setStatus(1);
+ }else if("02".equals(cacheRealtimeData.getStatus())){
+ xhpcRealTimeOrder.setStatus(2);
+ }else{
+ xhpcRealTimeOrder.setStatus(3);
+ }
+ xhpcRealTimeOrder.setCreateTime(date);
+ xhpcRealTimeOrder.setUserId(hxpcChargeOrder.getUserId());
+ Long chargingStationId = hxpcChargeOrder.getChargingStationId();
+ Long chargeOrderId = hxpcChargeOrder.getChargeOrderId();
+ xhpcRealTimeOrder.setChargingStationId(chargingStationId);
+
+ xhpcRealTimeOrderService.addXhpcRealTimeOrder(xhpcRealTimeOrder);
+ //实时数据存入MYsql、soc、电流、电压
+
+ XhpcChargeOrderSoc xhpcChargeOrderSoc =new XhpcChargeOrderSoc();
+ xhpcChargeOrderSoc.setChargeOrderId(chargeOrderId);
+ xhpcChargeOrderSoc.setSoc(soc.toString());
+ xhpcChargeOrderSoc.setCreateTime(date);
+ xhpcRealTimeOrderService.addSOC(xhpcChargeOrderSoc);
+
+ XhpcChargeOrderCurrent xhpcChargeOrderCurrent =new XhpcChargeOrderCurrent();
+ xhpcChargeOrderCurrent.setChargeOrderId(chargeOrderId);
+ xhpcChargeOrderCurrent.setCurrent(c.toString());
+ xhpcChargeOrderCurrent.setCreateTime(date);
+ xhpcRealTimeOrderService.addCurrent(xhpcChargeOrderCurrent);
+
+ XhpcChargeOrderVoltage xhpcChargeOrderVoltage =new XhpcChargeOrderVoltage();
+ xhpcChargeOrderVoltage.setChargeOrderId(chargeOrderId);
+ xhpcChargeOrderVoltage.setVoltage(v.toString());
+ xhpcChargeOrderVoltage.setCreateTime(date);
+ xhpcRealTimeOrderService.addVoltage(xhpcChargeOrderVoltage);
+ }catch (Exception e){
return R.fail(500,"无实时数据");
}
+
+
return R.ok();
}
diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/domain/XhpcRealTimeOrder.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/domain/XhpcRealTimeOrder.java
index d41b3106..c800c023 100644
--- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/domain/XhpcRealTimeOrder.java
+++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/domain/XhpcRealTimeOrder.java
@@ -73,15 +73,15 @@ public class XhpcRealTimeOrder extends BaseEntity {
/**
* 充电度数
*/
- private Double chargingDegree;
+ private BigDecimal chargingDegree;
/**
* 计损充电度数
*/
- private Double lossChargingDegree;
+ private BigDecimal lossChargingDegree;
/**
* 已充金额
*/
- private Double amountCharged;
+ private BigDecimal amountCharged;
/**
* 硬件故障
*/
@@ -234,32 +234,32 @@ public class XhpcRealTimeOrder extends BaseEntity {
this.remainingTime = remainingTime;
}
- public Double getChargingDegree() {
+ public BigDecimal getChargingDegree() {
return chargingDegree;
}
- public void setChargingDegree(Double chargingDegree) {
+ public void setChargingDegree(BigDecimal chargingDegree) {
this.chargingDegree = chargingDegree;
}
- public Double getLossChargingDegree() {
+ public BigDecimal getLossChargingDegree() {
return lossChargingDegree;
}
- public void setLossChargingDegree(Double lossChargingDegree) {
+ public void setLossChargingDegree(BigDecimal lossChargingDegree) {
this.lossChargingDegree = lossChargingDegree;
}
- public Double getAmountCharged() {
+ public BigDecimal getAmountCharged() {
return amountCharged;
}
- public void setAmountCharged(Double amountCharged) {
+ public void setAmountCharged(BigDecimal amountCharged) {
this.amountCharged = amountCharged;
}
diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/mapper/HxpcChargeOrderMapper.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/mapper/HxpcChargeOrderMapper.java
index b0aac282..340012f7 100644
--- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/mapper/HxpcChargeOrderMapper.java
+++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/mapper/HxpcChargeOrderMapper.java
@@ -101,15 +101,4 @@ public interface HxpcChargeOrderMapper {
*/
Map getOperatorMessage(@Param("chargingStationId") Long chargingStationId);
-
- /**
- * 删除之前的实时订单数据
- */
- void deleteRealTimeOrder(@Param("chargingStationId")Long chargingOrderId);
-
- void deleteChargeVoltage(@Param("chargingStationId")Long chargingOrderId);
-
- void deleteChargeOrderSoc(@Param("chargingStationId")Long chargingOrderId);
-
- void deleteChargeOrderCurrent(@Param("chargingStationId")Long chargingOrderId);
}
diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/mapper/XhpcRealTimeOrderMapper.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/mapper/XhpcRealTimeOrderMapper.java
index 62e4d1f3..58b6c325 100644
--- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/mapper/XhpcRealTimeOrderMapper.java
+++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/mapper/XhpcRealTimeOrderMapper.java
@@ -39,7 +39,7 @@ public interface XhpcRealTimeOrderMapper {
int addCurrent(XhpcChargeOrderCurrent XhpcChargeOrderCurrent);
/**
- * 添加订单实时电流
+ * 添加订单实时电压
* @param xhpcChargeOrderVoltage
* @return
*/
@@ -96,4 +96,15 @@ public interface XhpcRealTimeOrderMapper {
* @return
*/
Map timeChartCurrentList(Long chargingOrderId);
+
+ /**
+ * 删除之前的实时订单数据
+ */
+ void deleteRealTimeOrder(@Param("chargingStationId")Long chargingOrderId);
+
+ void deleteChargeVoltage(@Param("chargingStationId")Long chargingOrderId);
+
+ void deleteChargeOrderSoc(@Param("chargingStationId")Long chargingOrderId);
+
+ void deleteChargeOrderCurrent(@Param("chargingStationId")Long chargingOrderId);
}
diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/IHxpcChargeOrderService.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/IHxpcChargeOrderService.java
index d687a662..4d33d4dd 100644
--- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/IHxpcChargeOrderService.java
+++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/IHxpcChargeOrderService.java
@@ -87,8 +87,4 @@ public interface IHxpcChargeOrderService {
*/
Map getOperatorMessage( Long chargingStationId);
- /**
- * 删除之前的实时订单数据
- */
- void deleteRealTimeOrder(Long chargingOrderId);
}
diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/IXhpcRealTimeOrderService.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/IXhpcRealTimeOrderService.java
index b0c093d4..f0339230 100644
--- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/IXhpcRealTimeOrderService.java
+++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/IXhpcRealTimeOrderService.java
@@ -1,6 +1,10 @@
package com.xhpc.order.service;
import com.xhpc.common.core.web.domain.AjaxResult;
+import com.xhpc.order.domain.XhpcChargeOrderCurrent;
+import com.xhpc.order.domain.XhpcChargeOrderSoc;
+import com.xhpc.order.domain.XhpcChargeOrderVoltage;
+import com.xhpc.order.domain.XhpcRealTimeOrder;
import java.util.ArrayList;
import java.util.List;
@@ -12,13 +16,6 @@ import java.util.Map;
*/
public interface IXhpcRealTimeOrderService {
- /**
- * 添加实时订单数据
- * @param orderNo 交易流水号
- * @param status
- */
- public void addXhpcRealTimeOrder(String orderNo,Integer status);
-
/**
* 实时订单接口(PC端)
@@ -55,4 +52,38 @@ public interface IXhpcRealTimeOrderService {
* @return
*/
AjaxResult timeChartList(Long chargingOrderId);
+
+ /**
+ * 删除之前的实时订单数据
+ */
+ void deleteRealTimeOrder(Long chargingOrderId);
+
+ /**
+ * 添加实时充电订单
+ * @param xhpcRealTimeOrder
+ * @return
+ */
+ int addXhpcRealTimeOrder(XhpcRealTimeOrder xhpcRealTimeOrder);
+
+
+ /**
+ * 添加订单实时SOC
+ * @param xhpcChargeOrderSoc
+ * @return
+ */
+ int addSOC(XhpcChargeOrderSoc xhpcChargeOrderSoc);
+
+ /**
+ * 添加订单实时电流
+ * @param XhpcChargeOrderCurrent
+ * @return
+ */
+ int addCurrent(XhpcChargeOrderCurrent XhpcChargeOrderCurrent);
+
+ /**
+ * 添加订单实时电流
+ * @param xhpcChargeOrderVoltage
+ * @return
+ */
+ int addVoltage(XhpcChargeOrderVoltage xhpcChargeOrderVoltage);
}
diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/HxpcChargeOrderServiceImpl.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/HxpcChargeOrderServiceImpl.java
index 700d26eb..b4e245d0 100644
--- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/HxpcChargeOrderServiceImpl.java
+++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/HxpcChargeOrderServiceImpl.java
@@ -212,12 +212,6 @@ public class HxpcChargeOrderServiceImpl implements IHxpcChargeOrderService {
return hxpcChargeOrderMapper.getOperatorMessage(chargingStationId);
}
- @Override
- public void deleteRealTimeOrder(Long chargingOrderId) {
- hxpcChargeOrderMapper.deleteRealTimeOrder(chargingOrderId);
- hxpcChargeOrderMapper.deleteChargeOrderCurrent(chargingOrderId);
- hxpcChargeOrderMapper.deleteChargeOrderSoc(chargingOrderId);
- hxpcChargeOrderMapper.deleteChargeVoltage(chargingOrderId);
- }
+
}
diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcRealTimeOrderServiceImpl.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcRealTimeOrderServiceImpl.java
index e061bacd..4db95188 100644
--- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcRealTimeOrderServiceImpl.java
+++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcRealTimeOrderServiceImpl.java
@@ -2,6 +2,10 @@ package com.xhpc.order.service.impl;
import com.xhpc.common.core.web.domain.AjaxResult;
import com.xhpc.common.redis.service.RedisService;
+import com.xhpc.order.domain.XhpcChargeOrderCurrent;
+import com.xhpc.order.domain.XhpcChargeOrderSoc;
+import com.xhpc.order.domain.XhpcChargeOrderVoltage;
+import com.xhpc.order.domain.XhpcRealTimeOrder;
import com.xhpc.order.mapper.XhpcRealTimeOrderMapper;
import com.xhpc.order.service.IXhpcRealTimeOrderService;
import org.springframework.beans.factory.annotation.Autowired;
@@ -25,29 +29,6 @@ public class XhpcRealTimeOrderServiceImpl implements IXhpcRealTimeOrderService {
private XhpcRealTimeOrderMapper xhpcRealTimeOrderMapper;
- /**
- * 添加实时数据
- * @param orderNo 交易流水号
- * @param status
- */
- @Override
- public void addXhpcRealTimeOrder(String orderNo, Integer status) {
-
-
- //获取redis 数据
-
-
- //记录电流、电压、soc实时记录
-
- //当状态为status =1 时,订单结束
- //用户是否第一单,享受折扣
- //获取运营商 平台抽成、运维抽成
- //结算订单
- //添加历史订单
-
-
- }
-
@Override
public List