diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/mapper/XhpcHistoryOrderMapper.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/mapper/XhpcHistoryOrderMapper.java index 334dff6b..ed09318c 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/mapper/XhpcHistoryOrderMapper.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/mapper/XhpcHistoryOrderMapper.java @@ -69,7 +69,7 @@ public interface XhpcHistoryOrderMapper { * @param historyOrderId * @return */ - Map gethistotyOrderMessage(@Param("userId") Long userId, @Param("historyOrderId") Long historyOrderId, @Param("type") Integer type, @Param("chargingOrderId") Long chargingOrderId, @Param("tenantId") String tenantId); + Map gethistotyOrderMessage(@Param("userId") Long userId, @Param("historyOrderId") Long historyOrderId, @Param("source") Integer source, @Param("chargingOrderId") Long chargingOrderId, @Param("tenantId") String tenantId); /** * 历史订单记录(PC) @@ -117,5 +117,5 @@ public interface XhpcHistoryOrderMapper { /** * 查询启动订单表 */ - Map getchargingOrderById(@Param("chargingOrderId")Long chargingOrderId); + Map getchargingOrderById(@Param("chargingOrderId")Long chargingOrderId,@Param("userId")Long userId,@Param("source")Integer source,@Param("tenantId")String tenantId); } diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcChargeOrderServiceImpl.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcChargeOrderServiceImpl.java index 76be4198..b83c85ce 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcChargeOrderServiceImpl.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcChargeOrderServiceImpl.java @@ -1,5 +1,7 @@ package com.xhpc.order.service.impl; +import cn.hutool.core.date.DateTime; +import cn.hutool.core.date.DateUnit; import cn.hutool.core.date.DateUtil; import com.xhpc.common.api.PowerPileService; import com.xhpc.common.api.UserTypeService; @@ -17,9 +19,11 @@ import com.xhpc.common.security.service.TokenService; import com.xhpc.common.util.UserTypeUtil; import com.xhpc.order.domain.XhpcChargeOrder; import com.xhpc.order.domain.XhpcOrderRedisRecord; +import com.xhpc.order.domain.XhpcRealTimeOrder; import com.xhpc.order.mapper.XhpcChargeOrderMapper; import com.xhpc.order.mapper.XhpcInternetUserMapper; import com.xhpc.order.service.IXhpcChargeOrderService; +import com.xhpc.order.service.IXhpcRealTimeOrderService; import com.xhpc.system.api.model.LoginUser; import org.bouncycastle.jcajce.provider.asymmetric.util.BaseAgreementSpi; import org.slf4j.Logger; @@ -58,6 +62,8 @@ public class XhpcChargeOrderServiceImpl extends BaseService implements IXhpcChar private TokenService tokenService; @Autowired private UserTypeService userTypeService; + @Autowired + private IXhpcRealTimeOrderService xhpcRealTimeOrderService; private static final Logger logger = LoggerFactory.getLogger(XhpcChargeOrderServiceImpl.class); //队列名称 @@ -90,7 +96,29 @@ public class XhpcChargeOrderServiceImpl extends BaseService implements IXhpcChar public List> getHistotyChargeOrderStatusList(HttpServletRequest request) { LoginUser loginUser = tokenService.getLoginUser(request); startPage(); - return xhpcChargeOrderMapper.getHistotyChargeOrderStatusList(loginUser.getUserid(),loginUser.getTenantId(),loginUser.getUserType()); + List> list = xhpcChargeOrderMapper.getHistotyChargeOrderStatusList(loginUser.getUserid(), loginUser.getTenantId(), loginUser.getUserType()); + if(list !=null && list.size()>0){ + for (int i = 0; i map = list.get(i); + //获取该订单最后一条实时数据 + Map cacheMap = redisService.getCacheMap("order:" + map.get("serialNumber").toString()); + if(cacheMap !=null && cacheMap.size()>0){ + List CacheRealtimeDataList = (List) cacheMap.get("realtimeDataList"); + if(CacheRealtimeDataList !=null && CacheRealtimeDataList.size()>0){ + CacheRealtimeData endData = CacheRealtimeDataList.get(list.size() - 1); + if (endData != null) { + map.put("actPrice", new BigDecimal(endData.getAmountCharged()).divide(new BigDecimal(10000), 2, BigDecimal.ROUND_DOWN)); + } + } + }else{ + XhpcRealTimeOrder endRealTimeOrder = xhpcRealTimeOrderService.getChargingOrderId(Long.valueOf(map.get("chargeOrderId").toString()), 2); + if (endRealTimeOrder != null) { + map.put("actPrice", endRealTimeOrder.getAmountCharged()); + } + } + } + } + return list; } @Override diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcHistoryOrderServiceImpl.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcHistoryOrderServiceImpl.java index e32078a3..84e52108 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcHistoryOrderServiceImpl.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcHistoryOrderServiceImpl.java @@ -106,13 +106,13 @@ public class XhpcHistoryOrderServiceImpl extends BaseService implements IXhpcHis public AjaxResult gethistotyOrderMessage(HttpServletRequest request, Long userId, Long historyOrderId, Integer type, Long chargingOrderId) { LoginUser loginUser = tokenService.getLoginUser(request); - Map map = xhpcHistoryOrderMapper.gethistotyOrderMessage(loginUser.getUserid(), historyOrderId, type, chargingOrderId, loginUser.getTenantId()); + Map map = xhpcHistoryOrderMapper.gethistotyOrderMessage(loginUser.getUserid(), historyOrderId, loginUser.getUserType(), chargingOrderId, loginUser.getTenantId()); if(map !=null){ return AjaxResult.success(map); } //查询最后一帧数据 if(chargingOrderId !=null){ - Map stringObjectMap = xhpcHistoryOrderMapper.getchargingOrderById(chargingOrderId); + Map stringObjectMap = xhpcHistoryOrderMapper.getchargingOrderById(chargingOrderId,loginUser.getUserid(),loginUser.getUserType(),loginUser.getTenantId()); if(stringObjectMap !=null){ //获取该订单最后一条实时数据 Map cacheMap = redisService.getCacheMap("order:" + stringObjectMap.get("serialNumber").toString()); diff --git a/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcChargeOrderMapper.xml b/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcChargeOrderMapper.xml index ece34bd9..1e7e293f 100644 --- a/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcChargeOrderMapper.xml +++ b/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcChargeOrderMapper.xml @@ -327,15 +327,12 @@ cor.serial_number as serialNumber, cs.name as chargingStationName, ter.name as terminalName, - ho.history_order_id as historyOrderId, - ho.act_price as actPrice, cor.charging_time as chargingTime, cor.charging_degree as chargingDegree, cor.status as status from xhpc_charge_order as cor left join xhpc_charging_station as cs on cs.charging_station_id = cor.charging_station_id left join xhpc_terminal as ter on ter.terminal_id=cor.terminal_id - left join xhpc_history_order as ho on ho.charge_order_id = cor.charge_order_id where cor.status =2 and cor.del_flag =0 and cor.user_id=#{userId} diff --git a/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcHistoryOrderMapper.xml b/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcHistoryOrderMapper.xml index 863127c7..0b24dafd 100644 --- a/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcHistoryOrderMapper.xml +++ b/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcHistoryOrderMapper.xml @@ -609,6 +609,9 @@ and ho.tenant_id =#{tenantId} + + and ho.source =#{source} + order by ho.create_time desc @@ -954,5 +957,14 @@ LEFT JOIN xhpc_terminal AS te ON te.terminal_id = co.terminal_id LEFT JOIN xhpc_charging_station AS cs ON cs.charging_station_id = co.charging_station_id where charge_order_id=#{chargingOrderId} + + and co.user_id = #{userId} + + + and co.source = #{source} + + + and co.tenant_id = #{tenantId} +