修改异常订单列表显示

This commit is contained in:
yuyang 2022-01-13 19:07:34 +08:00
parent 6919cff922
commit 3b9fbc5cc4
5 changed files with 45 additions and 8 deletions

View File

@ -69,7 +69,7 @@ public interface XhpcHistoryOrderMapper {
* @param historyOrderId
* @return
*/
Map<String, Object> gethistotyOrderMessage(@Param("userId") Long userId, @Param("historyOrderId") Long historyOrderId, @Param("type") Integer type, @Param("chargingOrderId") Long chargingOrderId, @Param("tenantId") String tenantId);
Map<String, Object> 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<String, Object> getchargingOrderById(@Param("chargingOrderId")Long chargingOrderId);
Map<String, Object> getchargingOrderById(@Param("chargingOrderId")Long chargingOrderId,@Param("userId")Long userId,@Param("source")Integer source,@Param("tenantId")String tenantId);
}

View File

@ -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<Map<String, Object>> getHistotyChargeOrderStatusList(HttpServletRequest request) {
LoginUser loginUser = tokenService.getLoginUser(request);
startPage();
return xhpcChargeOrderMapper.getHistotyChargeOrderStatusList(loginUser.getUserid(),loginUser.getTenantId(),loginUser.getUserType());
List<Map<String, Object>> list = xhpcChargeOrderMapper.getHistotyChargeOrderStatusList(loginUser.getUserid(), loginUser.getTenantId(), loginUser.getUserType());
if(list !=null && list.size()>0){
for (int i = 0; i <list.size() ; i++) {
Map<String, Object> map = list.get(i);
//获取该订单最后一条实时数据
Map<String, Object> cacheMap = redisService.getCacheMap("order:" + map.get("serialNumber").toString());
if(cacheMap !=null && cacheMap.size()>0){
List<CacheRealtimeData> CacheRealtimeDataList = (List<CacheRealtimeData>) 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

View File

@ -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<String, Object> map = xhpcHistoryOrderMapper.gethistotyOrderMessage(loginUser.getUserid(), historyOrderId, type, chargingOrderId, loginUser.getTenantId());
Map<String, Object> map = xhpcHistoryOrderMapper.gethistotyOrderMessage(loginUser.getUserid(), historyOrderId, loginUser.getUserType(), chargingOrderId, loginUser.getTenantId());
if(map !=null){
return AjaxResult.success(map);
}
//查询最后一帧数据
if(chargingOrderId !=null){
Map<String, Object> stringObjectMap = xhpcHistoryOrderMapper.getchargingOrderById(chargingOrderId);
Map<String, Object> stringObjectMap = xhpcHistoryOrderMapper.getchargingOrderById(chargingOrderId,loginUser.getUserid(),loginUser.getUserType(),loginUser.getTenantId());
if(stringObjectMap !=null){
//获取该订单最后一条实时数据
Map<String, Object> cacheMap = redisService.getCacheMap("order:" + stringObjectMap.get("serialNumber").toString());

View File

@ -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}

View File

@ -609,6 +609,9 @@
<if test="tenantId !=null and tenantId !=''">
and ho.tenant_id =#{tenantId}
</if>
<if test="source !=null ">
and ho.source =#{source}
</if>
order by ho.create_time desc
</select>
@ -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}
<if test="userId !=null">
and co.user_id = #{userId}
</if>
<if test="source !=null">
and co.source = #{source}
</if>
<if test="tenantId !=null and tenantId !=''">
and co.tenant_id = #{tenantId}
</if>
</select>
</mapper>