优化数据大屏实时数据接口相应速度
This commit is contained in:
parent
603edc89e2
commit
91192d83cd
@ -0,0 +1,44 @@
|
||||
package com.xhpc.card.domain;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author yuyang
|
||||
* @date 2022/9/20 15:20
|
||||
*/
|
||||
@Data
|
||||
public class RealtimeOrder {
|
||||
/**
|
||||
* 用户类型
|
||||
*/
|
||||
private String userType;
|
||||
/**
|
||||
* 开始充电时间
|
||||
*/
|
||||
private String startChargingTime;
|
||||
/**
|
||||
* 充电时长
|
||||
*/
|
||||
private String chargingTime;
|
||||
/**
|
||||
* 已充电量(度)
|
||||
*/
|
||||
private Double chargedElectric;
|
||||
/**
|
||||
* 充电金额
|
||||
*/
|
||||
private Double chargingSum;
|
||||
/**
|
||||
* 电流
|
||||
*/
|
||||
private Double electricCurrent;
|
||||
/**
|
||||
* 电压
|
||||
*/
|
||||
private Double voltage;
|
||||
/**
|
||||
* SOC
|
||||
*/
|
||||
private String soc;
|
||||
}
|
||||
@ -25,54 +25,4 @@ public class RealtimeOrders {
|
||||
@JsonProperty("data")
|
||||
private List<RealtimeOrder> data;
|
||||
|
||||
/**
|
||||
* RealtimeOrder
|
||||
*/
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public static class RealtimeOrder {
|
||||
|
||||
/**
|
||||
* 用户类型
|
||||
*/
|
||||
@JsonProperty("userType")
|
||||
private String userType;
|
||||
/**
|
||||
* 开始充电时间
|
||||
*/
|
||||
@JsonProperty("startChargingTime")
|
||||
private String startChargingTime;
|
||||
/**
|
||||
* 充电时长
|
||||
*/
|
||||
@JsonProperty("chargingTime")
|
||||
private String chargingTime;
|
||||
/**
|
||||
* 已充电量(度)
|
||||
*/
|
||||
@JsonProperty("chargedElectric")
|
||||
private Double chargedElectric;
|
||||
/**
|
||||
* 充电金额
|
||||
*/
|
||||
@JsonProperty("chargingSum")
|
||||
private Double chargingSum;
|
||||
/**
|
||||
* 电流
|
||||
*/
|
||||
@JsonProperty("electricCurrent")
|
||||
private Double electricCurrent;
|
||||
/**
|
||||
* 电压
|
||||
*/
|
||||
@JsonProperty("voltage")
|
||||
private Double voltage;
|
||||
/**
|
||||
* SOC
|
||||
*/
|
||||
@JsonProperty("soc")
|
||||
private String soc;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package com.xhpc.card.mapper;
|
||||
|
||||
import com.xhpc.card.domain.RealtimeOrder;
|
||||
import com.xhpc.card.pojo.XhpcRateTime;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
@ -28,6 +29,6 @@ public interface XhpcRateTimeMapper {
|
||||
* @date 2022/3/17 14:46
|
||||
* @since version-1.0
|
||||
*/
|
||||
List<Map<String, Object>> selectByTenantIdsAndCharingStationIds(@Param("tenantIdsStr") String tenantIdsStr, @Param("xhpcChargingStationList") ArrayList<Long> xhpcChargingStationList);
|
||||
List<RealtimeOrder> selectByTenantIdsAndCharingStationIds(@Param("tenantIdsStr") String tenantIdsStr, @Param("xhpcChargingStationList") ArrayList<Long> xhpcChargingStationList, @Param("chargingStationId") Long chargingStationId);
|
||||
|
||||
}
|
||||
@ -1,14 +1,11 @@
|
||||
package com.xhpc.card.service.impl;
|
||||
|
||||
import com.xhpc.card.domain.*;
|
||||
import com.xhpc.common.constant.ConstantClass;
|
||||
import com.xhpc.common.core.domain.R;
|
||||
import com.xhpc.common.redis.service.RedisService;
|
||||
import com.xhpc.common.util.MyDateUtil;
|
||||
import com.xhpc.common.util.UserTypeUtil;
|
||||
import com.xhpc.card.domain.CoreParam;
|
||||
import com.xhpc.card.domain.OrderRatio;
|
||||
import com.xhpc.card.domain.OrderTrend;
|
||||
import com.xhpc.card.domain.RealtimeOrders;
|
||||
import com.xhpc.card.mapper.XhpcAppUserMapper;
|
||||
import com.xhpc.card.mapper.XhpcChargingStationMapper;
|
||||
import com.xhpc.card.mapper.XhpcHistoryOrderMapper;
|
||||
@ -524,18 +521,25 @@ public class XhpcDataBigScreenServiceImpl implements XhpcDataBigScreenService {
|
||||
|
||||
String tenantIdsStr = null;
|
||||
List<Map<String, Object>> xhpcChargingStationList = null;
|
||||
List<RealtimeOrder> realtimeOrderList =new ArrayList<>();
|
||||
RealtimeOrders realtimeOrders = new RealtimeOrders();
|
||||
//judge care param function
|
||||
switch (coreParam.getParamType()) {
|
||||
case 0:
|
||||
tenantIdsStr = coreParam.getTenantIds();
|
||||
if (!"".equals(tenantIdsStr) && tenantIdsStr != null) {
|
||||
List<Map<String, Object>> realtimeOrderList = xhpcRateTimeMapper.selectByTenantIdsAndCharingStationIds(tenantIdsStr, null);
|
||||
return getRealtimeOrders(realtimeOrderList);
|
||||
realtimeOrderList = xhpcRateTimeMapper.selectByTenantIdsAndCharingStationIds(tenantIdsStr, null,null);
|
||||
} else {
|
||||
List<Map<String, Object>> realtimeOrderList = xhpcRateTimeMapper.selectByTenantIdsAndCharingStationIds(tenantIdsStr, null);
|
||||
return getRealtimeOrders(realtimeOrderList);
|
||||
realtimeOrderList = xhpcRateTimeMapper.selectByTenantIdsAndCharingStationIds(tenantIdsStr, null,null);
|
||||
}
|
||||
//query charging station infos of whole area
|
||||
realtimeOrders.setTotalItems(0L);
|
||||
if (realtimeOrderList.size()==0) {
|
||||
realtimeOrders.setData(new ArrayList<>());
|
||||
return R.ok(realtimeOrders);
|
||||
}
|
||||
realtimeOrders.setData(realtimeOrderList);
|
||||
realtimeOrders.setTotalItems((long) realtimeOrderList.size());
|
||||
return R.ok(realtimeOrders);
|
||||
case 1:
|
||||
Integer areaCode = coreParam.getAreaCode();
|
||||
tenantIdsStr = coreParam.getTenantIds();
|
||||
@ -549,30 +553,38 @@ public class XhpcDataBigScreenServiceImpl implements XhpcDataBigScreenService {
|
||||
for (Map<String, Object> chargingStation : xhpcChargingStationList) {
|
||||
chargingStationIdList.add((Long) chargingStation.get(ConstantClass.CHARGING_STATION_ID));
|
||||
}
|
||||
List<Map<String, Object>> realtimeOrderList = xhpcRateTimeMapper.selectByTenantIdsAndCharingStationIds(tenantIdsStr, chargingStationIdList);
|
||||
return getRealtimeOrders(realtimeOrderList);
|
||||
realtimeOrderList = xhpcRateTimeMapper.selectByTenantIdsAndCharingStationIds(tenantIdsStr, chargingStationIdList,null);
|
||||
} else {
|
||||
xhpcChargingStationList = xhpcChargingStationMapper.selectByTenantIdAndAreaCode(tenantIdsStr, areaCode,number);
|
||||
ArrayList<Long> chargingStationIdList = new ArrayList<>();
|
||||
for (Map<String, Object> chargingStation : xhpcChargingStationList) {
|
||||
chargingStationIdList.add((Long) chargingStation.get(ConstantClass.CHARGING_STATION_ID));
|
||||
}
|
||||
List<Map<String, Object>> realtimeOrderList = xhpcRateTimeMapper.selectByTenantIdsAndCharingStationIds(tenantIdsStr, chargingStationIdList);
|
||||
return getRealtimeOrders(realtimeOrderList);
|
||||
realtimeOrderList = xhpcRateTimeMapper.selectByTenantIdsAndCharingStationIds(tenantIdsStr, chargingStationIdList,null);
|
||||
}
|
||||
realtimeOrders.setTotalItems(0L);
|
||||
if (realtimeOrderList.size()==0) {
|
||||
realtimeOrders.setData(new ArrayList<>());
|
||||
return R.ok(realtimeOrders);
|
||||
}
|
||||
realtimeOrders.setData(realtimeOrderList);
|
||||
realtimeOrders.setTotalItems((long) realtimeOrderList.size());
|
||||
return R.ok(realtimeOrders);
|
||||
case 2:
|
||||
//query location info of special charging station of special tenant
|
||||
tenantIdsStr = coreParam.getTenantIds();
|
||||
|
||||
if (!"".equals(tenantIdsStr) && tenantIdsStr != null) {
|
||||
String chargingStationIdStr = coreParam.getChargingStationIds();
|
||||
long chargingStationId = Long.parseLong(chargingStationIdStr);
|
||||
xhpcChargingStationList = xhpcChargingStationMapper.selectByTenantIdAndChargingStationId(tenantIdsStr, chargingStationId);
|
||||
ArrayList<Long> chargingStationIdList = new ArrayList<>();
|
||||
for (Map<String, Object> chargingStation : xhpcChargingStationList) {
|
||||
chargingStationIdList.add((Long) chargingStation.get(ConstantClass.CHARGING_STATION_ID));
|
||||
long chargingStationId = Long.parseLong(coreParam.getChargingStationIds());
|
||||
realtimeOrderList = xhpcRateTimeMapper.selectByTenantIdsAndCharingStationIds(tenantIdsStr,null,chargingStationId);
|
||||
realtimeOrders.setTotalItems(0L);
|
||||
if (realtimeOrderList.size()==0) {
|
||||
realtimeOrders.setData(new ArrayList<>());
|
||||
return R.ok(realtimeOrders);
|
||||
}
|
||||
List<Map<String, Object>> realtimeOrderList = xhpcRateTimeMapper.selectByTenantIdsAndCharingStationIds(tenantIdsStr, chargingStationIdList);
|
||||
return getRealtimeOrders(realtimeOrderList);
|
||||
realtimeOrders.setData(realtimeOrderList);
|
||||
realtimeOrders.setTotalItems((long) realtimeOrderList.size());
|
||||
return R.ok(realtimeOrders);
|
||||
} else {
|
||||
return R.fail("传入的参数有误");
|
||||
}
|
||||
@ -716,25 +728,25 @@ public class XhpcDataBigScreenServiceImpl implements XhpcDataBigScreenService {
|
||||
private R<RealtimeOrders> getRealtimeOrders(List<Map<String, Object>> realtimeOrderList) {
|
||||
//init wrapper class object,set default value
|
||||
RealtimeOrders realtimeOrders = new RealtimeOrders();
|
||||
ArrayList<RealtimeOrders.RealtimeOrder> realtimeOrderWrapperList = new ArrayList<>();
|
||||
realtimeOrders.setData(realtimeOrderWrapperList);
|
||||
realtimeOrders.setTotalItems(0L);
|
||||
if (realtimeOrderList.isEmpty()) {
|
||||
return R.ok(realtimeOrders);
|
||||
}
|
||||
realtimeOrders.setTotalItems((long) realtimeOrderList.size());
|
||||
for (Map<String, Object> realtimeOrderMap : realtimeOrderList) {
|
||||
RealtimeOrders.RealtimeOrder realtimeOrder = new RealtimeOrders.RealtimeOrder();
|
||||
realtimeOrder.setUserType((String) realtimeOrderMap.get("chargingMode"));
|
||||
realtimeOrder.setStartChargingTime((String) realtimeOrderMap.get("startTime"));
|
||||
realtimeOrder.setChargingTime((String) realtimeOrderMap.get("chargingTime"));
|
||||
realtimeOrder.setChargedElectric((Double) realtimeOrderMap.get("chargingDegree"));
|
||||
realtimeOrder.setChargingSum((Double) realtimeOrderMap.get("amountCharged"));
|
||||
realtimeOrder.setElectricCurrent((Double) realtimeOrderMap.get("electricCurrent"));
|
||||
realtimeOrder.setVoltage((Double) realtimeOrderMap.get("voltage"));
|
||||
realtimeOrder.setSoc((String) realtimeOrderMap.get("soc"));
|
||||
realtimeOrderWrapperList.add(realtimeOrder);
|
||||
}
|
||||
// ArrayList<RealtimeOrders.RealtimeOrder> realtimeOrderWrapperList = new ArrayList<>();
|
||||
// realtimeOrders.setData(realtimeOrderWrapperList);
|
||||
// realtimeOrders.setTotalItems(0L);
|
||||
// if (realtimeOrderList.isEmpty()) {
|
||||
// return R.ok(realtimeOrders);
|
||||
// }
|
||||
// realtimeOrders.setTotalItems((long) realtimeOrderList.size());
|
||||
// for (Map<String, Object> realtimeOrderMap : realtimeOrderList) {
|
||||
// RealtimeOrders.RealtimeOrder realtimeOrder = new RealtimeOrders.RealtimeOrder();
|
||||
// realtimeOrder.setUserType((String) realtimeOrderMap.get("chargingMode"));
|
||||
// realtimeOrder.setStartChargingTime((String) realtimeOrderMap.get("startTime"));
|
||||
// realtimeOrder.setChargingTime((String) realtimeOrderMap.get("chargingTime"));
|
||||
// realtimeOrder.setChargedElectric((Double) realtimeOrderMap.get("chargingDegree"));
|
||||
// realtimeOrder.setChargingSum((Double) realtimeOrderMap.get("amountCharged"));
|
||||
// realtimeOrder.setElectricCurrent((Double) realtimeOrderMap.get("electricCurrent"));
|
||||
// realtimeOrder.setVoltage((Double) realtimeOrderMap.get("voltage"));
|
||||
// realtimeOrder.setSoc((String) realtimeOrderMap.get("soc"));
|
||||
// realtimeOrderWrapperList.add(realtimeOrder);
|
||||
// }
|
||||
return R.ok(realtimeOrders);
|
||||
}
|
||||
|
||||
|
||||
@ -33,11 +33,11 @@
|
||||
from xhpc_rate_time
|
||||
where rate_time_id = #{rateTimeId,jdbcType=BIGINT}
|
||||
</select>
|
||||
<select id="selectByTenantIdsAndCharingStationIds" resultType="Map">
|
||||
<select id="selectByTenantIdsAndCharingStationIds" resultType="com.xhpc.card.domain.RealtimeOrder">
|
||||
select
|
||||
ifnull(ROUND(ro.charging_degree,2),0) as chargingDegree,
|
||||
DATE_FORMAT(co.start_time,"%H:%i") as startTime,
|
||||
ifnull(ro.amount_charged,0) amountCharged,
|
||||
ifnull(ROUND(ro.charging_degree,2),0) as chargedElectric,
|
||||
DATE_FORMAT(co.start_time,"%H:%i") as startChargingTime,
|
||||
ifnull(ro.amount_charged,0) chargingSum,
|
||||
ifnull(ro.electric_current,0) electricCurrent,
|
||||
ro.real_time_order_id as realTimeOrderId,
|
||||
ifnull(ro.voltage,0) as voltage,
|
||||
@ -54,8 +54,7 @@
|
||||
"小桔用户"
|
||||
ELSE
|
||||
"C端用户"
|
||||
END chargingMode
|
||||
from xhpc_charge_order co
|
||||
END userType
|
||||
left join xhpc_internet_user as inu on inu.internet_user_id = co.user_id and co.source =1
|
||||
left join xhpc_app_user as apu on apu.app_user_id = co.user_id and co.source =0
|
||||
left join xhpc_community_personnel as cop on cop.community_personnel_id = co.user_id and co.source =2
|
||||
@ -74,8 +73,12 @@
|
||||
#{chargingStationId}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="chargingStationId !=null">
|
||||
and co.charging_station_id =#{chargingStationId}
|
||||
</if>
|
||||
order by co.create_time desc
|
||||
</select>
|
||||
|
||||
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
|
||||
delete
|
||||
from xhpc_rate_time
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
package com.xhpc.order.service.impl;
|
||||
|
||||
import com.xhpc.common.api.WorkOrderYuService;
|
||||
import com.xhpc.common.core.web.domain.AjaxResult;
|
||||
import com.xhpc.common.core.web.service.BaseService;
|
||||
import com.xhpc.common.redis.service.RedisService;
|
||||
import com.xhpc.common.security.service.TokenService;
|
||||
import com.xhpc.order.domain.XhpcPileRegularInspect;
|
||||
import com.xhpc.order.mapper.XhpcPileRegularInspectMapper;
|
||||
@ -10,8 +12,6 @@ import com.xhpc.system.api.model.LoginUser;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@ -20,6 +20,11 @@ public class XhpcPileRegularInspectServiceImpl extends BaseService implements IX
|
||||
|
||||
@Resource
|
||||
private TokenService tokenService;
|
||||
@Resource
|
||||
private RedisService redisService;
|
||||
@Resource
|
||||
private WorkOrderYuService workOrderService;
|
||||
|
||||
@Resource
|
||||
private XhpcPileRegularInspectMapper xhpcPileRegularInspectMapper;
|
||||
|
||||
@ -131,6 +136,22 @@ public class XhpcPileRegularInspectServiceImpl extends BaseService implements IX
|
||||
List<Map<String, Object>> list = xhpcPileRegularInspectMapper.verificationPileRepeat();
|
||||
for (int i = 0; i <list.size() ; i++) {
|
||||
Map<String, Object> map=list.get(i);
|
||||
String serialNumber = map.get("serialNumber").toString();
|
||||
String directNumber = map.get("directNumber").toString();
|
||||
String communicationNumber = map.get("communicationNumber").toString();
|
||||
Integer type =Integer.parseInt(map.get("type").toString());
|
||||
Map<String, Object> cachePile = redisService.getCacheMap("pile:" + serialNumber);
|
||||
//Long rateModelId = (Long) cachePile.get("rateModelId");
|
||||
String firmwareVersion = cachePile.get("firmwareVersion").toString();
|
||||
if(type==1){
|
||||
if(!directNumber.equals(firmwareVersion)){
|
||||
//添加一条工单
|
||||
}
|
||||
}else{
|
||||
if(!communicationNumber.equals(firmwareVersion)){
|
||||
//添加一条工单
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -130,7 +130,8 @@
|
||||
xcp.charging_pile_id,
|
||||
xcp.serial_number serialNumber,
|
||||
xpe.direct_number directNumber,
|
||||
xpe.communication_number communicationNumber
|
||||
xpe.communication_number communicationNumber,
|
||||
xcp.type as type
|
||||
FROM
|
||||
xhpc_charging_pile xcp
|
||||
LEFT JOIN xhpc_pile_edition xpe on xpe.charging_station_id = xcp.charging_station_id
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user