mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-19 18:45:03 +08:00
Merge branch 'feature-business-minigram' into dev
# Conflicts: # jsowell-pile/src/main/java/com/jsowell/pile/service/impl/OrderBasicInfoServiceImpl.java
This commit is contained in:
@@ -459,4 +459,11 @@ public interface OrderBasicInfoMapper {
|
||||
* @return
|
||||
*/
|
||||
List<IndexPlatformProfitVO> getInsuranceAmount(@Param("dto") IndexQueryDTO dto);
|
||||
|
||||
/**
|
||||
* 批量查询充电枪信息
|
||||
* @param chargingConnectorCodeList
|
||||
* @return
|
||||
*/
|
||||
List<PileConnectorInfoVO> batchQueryChargingConnectorInfo(@Param("pileConnectorCodes") List<String> chargingConnectorCodeList);
|
||||
}
|
||||
|
||||
@@ -136,6 +136,14 @@ public interface PileConnectorInfoMapper {
|
||||
*/
|
||||
List<ConnectorInfoVO> batchSelectConnectorList(@Param("stationIds") List<String> stationIds);
|
||||
|
||||
/**
|
||||
* 此方法与上面方法一样,只是多加了status字段
|
||||
* @param stationIds
|
||||
* @param status
|
||||
* @return
|
||||
*/
|
||||
List<ConnectorInfoVO> batchSelectConnectorListByStatus(@Param("stationIds") List<String> stationIds, @Param("status") String status);
|
||||
|
||||
/**
|
||||
* 查询异常设备数量
|
||||
* @param stationId
|
||||
|
||||
@@ -133,4 +133,11 @@ public interface PileStationInfoMapper {
|
||||
* @return
|
||||
*/
|
||||
List<UserFrequentedStationInfo> queryUserFrequentedStation(@Param("memberId") String memberId ,@Param("startTime") String startTime ,@Param("endTime") String endTime);
|
||||
|
||||
/**
|
||||
* 通过运营商ids查询站点ids
|
||||
* @param merchantIdList
|
||||
* @return
|
||||
*/
|
||||
List<String> getStationIdsByMerchantIds(@Param("merchantIds") List<String> merchantIdList);
|
||||
}
|
||||
|
||||
@@ -661,4 +661,18 @@ public interface OrderBasicInfoService{
|
||||
* @return
|
||||
*/
|
||||
List<IndexPlatformProfitVO> getInsuranceAmount(IndexQueryDTO dto);
|
||||
|
||||
/**
|
||||
* 批量查询充电枪信息
|
||||
* @param chargingConnectorCodeList
|
||||
* @return
|
||||
*/
|
||||
List<PileConnectorInfoVO> batchQueryChargingConnectorInfo(List<String> chargingConnectorCodeList);
|
||||
|
||||
/**
|
||||
* 批量查询充电枪实时数据
|
||||
* @param transactionCodeList
|
||||
* @return
|
||||
*/
|
||||
List<RealTimeMonitorData> getRealTimeMonitorDataList(List<String> transactionCodeList);
|
||||
}
|
||||
|
||||
@@ -153,7 +153,7 @@ public interface PileConnectorInfoService {
|
||||
/**
|
||||
* 通过站点id和枪口状态查询枪口列表
|
||||
*/
|
||||
BusinessConnectorInfoVO getConnectorListByStationAndStatus(QueryConnectorInfoDTO dto);
|
||||
PageResponse getConnectorListByStationAndStatus(QueryConnectorInfoDTO dto);
|
||||
|
||||
/**
|
||||
* 通过查询参数查询枪口信息
|
||||
@@ -183,4 +183,12 @@ public interface PileConnectorInfoService {
|
||||
* @return
|
||||
*/
|
||||
int queryAbnormalDeviceCount(String id);
|
||||
|
||||
/**
|
||||
* 查询充电桩枪口状态数量
|
||||
* @param stationIds
|
||||
* @param connectorStatus
|
||||
* @return
|
||||
*/
|
||||
public Map<String, Object> getConnectorStatusNum(List<String> stationIds, String connectorStatus);
|
||||
}
|
||||
|
||||
@@ -216,5 +216,10 @@ public interface PileStationInfoService {
|
||||
*/
|
||||
PageResponse queryUserFrequentedStation(QueryStationDTO dto);
|
||||
|
||||
|
||||
/**
|
||||
* 通过运营商ids查询站点ids
|
||||
* @param merchantIdList
|
||||
* @return
|
||||
*/
|
||||
List<String> getStationIdsByMerchantIds(List<String> merchantIdList);
|
||||
}
|
||||
|
||||
@@ -6255,6 +6255,7 @@ public class OrderBasicInfoServiceImpl implements OrderBasicInfoService {
|
||||
}
|
||||
|
||||
/**
|
||||
<<<<<<< HEAD
|
||||
* 运营端小程序查询订单
|
||||
* @param dto 查询条件
|
||||
* @return 订单查询结果
|
||||
@@ -6360,6 +6361,63 @@ public class OrderBasicInfoServiceImpl implements OrderBasicInfoService {
|
||||
.build();
|
||||
}
|
||||
|
||||
/*
|
||||
* 批量查询充电枪口信息
|
||||
* @param chargingConnectorCodeList
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<PileConnectorInfoVO> batchQueryChargingConnectorInfo(List<String> chargingConnectorCodeList) {
|
||||
// 这个infoVOs只有简单数据,没有充电中数据
|
||||
List<PileConnectorInfoVO> infoVOS = orderBasicInfoMapper.batchQueryChargingConnectorInfo(chargingConnectorCodeList);
|
||||
|
||||
List<String> transactionCodes = infoVOS.stream()
|
||||
.map(PileConnectorInfoVO::getTransactionCode)
|
||||
.collect(Collectors.toList());
|
||||
List<RealTimeMonitorData> list = getRealTimeMonitorDataList(transactionCodes);
|
||||
|
||||
Map<String, RealTimeMonitorData> bMap = list.stream()
|
||||
.collect(Collectors.toMap(
|
||||
RealTimeMonitorData::getPileConnectorCode,
|
||||
x -> x,
|
||||
(existing, replacement) -> existing // 如果有重复key,保留第一个
|
||||
));
|
||||
for (PileConnectorInfoVO infoVO : infoVOS) {
|
||||
String pileConnectorCode = infoVO.getPileConnectorCode();
|
||||
if (pileConnectorCode != null && bMap.containsKey(pileConnectorCode)) {
|
||||
RealTimeMonitorData realTimeMonitorData = bMap.get(pileConnectorCode);
|
||||
|
||||
infoVO.setChargingDegree(new BigDecimal(realTimeMonitorData.getChargingDegree()));
|
||||
infoVO.setChargingTime(realTimeMonitorData.getSumChargingTime());
|
||||
infoVO.setSOC(realTimeMonitorData.getSOC());
|
||||
infoVO.setTimeRemaining(realTimeMonitorData.getTimeRemaining());
|
||||
}
|
||||
}
|
||||
return infoVOS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 批量查询实时监控数据
|
||||
* @param transactionCodeList
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<RealTimeMonitorData> getRealTimeMonitorDataList(List<String> transactionCodeList) {
|
||||
List<RealTimeMonitorData> resultList = new ArrayList<>();
|
||||
List<String> redisKeys = new ArrayList<>();
|
||||
for (String transactionCode : transactionCodeList) {
|
||||
// 截取枪口编号
|
||||
String pileConnectorCode = transactionCode.substring(0, 16);
|
||||
redisKeys.add(CacheConstants.PILE_REAL_TIME_MONITOR_DATA + pileConnectorCode + "_" + transactionCode);
|
||||
}
|
||||
// 批量查询多个key值的数据 key: redisKey, value: 最后一条实时数据
|
||||
Map<String, RealTimeMonitorData> map = redisCache.multiGetLastListValue(redisKeys);
|
||||
// 循环该map
|
||||
for (Map.Entry<String, RealTimeMonitorData> entry : map.entrySet()) {
|
||||
resultList.add(entry.getValue());
|
||||
}
|
||||
return resultList;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.jsowell.common.enums.ykc.PileStatusEnum;
|
||||
import com.jsowell.common.enums.ykc.ReturnCodeEnum;
|
||||
import com.jsowell.common.exception.BusinessException;
|
||||
import com.jsowell.common.util.DateUtils;
|
||||
import com.jsowell.common.util.PageUtils;
|
||||
import com.jsowell.common.util.SecurityUtils;
|
||||
import com.jsowell.common.util.StringUtils;
|
||||
import com.jsowell.common.util.spring.SpringUtils;
|
||||
@@ -34,9 +35,13 @@ import com.jsowell.pile.dto.business.QueryConnectorInfoDTO;
|
||||
import com.jsowell.pile.mapper.PileBasicInfoMapper;
|
||||
import com.jsowell.pile.mapper.PileConnectorInfoMapper;
|
||||
import com.jsowell.pile.service.*;
|
||||
import com.jsowell.pile.util.UserUtils;
|
||||
import com.jsowell.pile.vo.base.ConnectorInfoVO;
|
||||
import com.jsowell.pile.vo.base.LoginUserDetailVO;
|
||||
import com.jsowell.pile.vo.uniapp.business.BusinessConnectorDetailVO;
|
||||
import com.jsowell.pile.vo.uniapp.business.BusinessConnectorInfoVO;
|
||||
import com.jsowell.pile.vo.uniapp.business.BusinessOrderDetailInfoVO;
|
||||
import com.jsowell.pile.vo.uniapp.customer.OrderVO;
|
||||
import com.jsowell.pile.vo.web.PileConnectorInfoVO;
|
||||
import com.jsowell.pile.vo.web.PileDetailVO;
|
||||
import com.jsowell.pile.vo.web.PileModelInfoVO;
|
||||
@@ -1053,58 +1058,102 @@ public class PileConnectorInfoServiceImpl implements PileConnectorInfoService {
|
||||
|
||||
/**
|
||||
* 查询站点枪口列表
|
||||
*
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public BusinessConnectorInfoVO getConnectorListByStationAndStatus(QueryConnectorInfoDTO dto) {
|
||||
// 获取登录账号信息
|
||||
Long deptId = SecurityUtils.getDeptId();
|
||||
List<String> stationIds = pileMerchantInfoService.queryByMerchantDeptIds(Lists.newArrayList(String.valueOf(deptId)));
|
||||
String connectorStatus = dto.getConnectorStatus();
|
||||
int pageNum = dto.getPageNum();
|
||||
int pageSize = dto.getPageSize();
|
||||
BusinessConnectorInfoVO vo = new BusinessConnectorInfoVO();
|
||||
// 根据站点ids查询枪口列表(有缓存)
|
||||
List<ConnectorInfoVO> connectorInfoVOS = batchSelectConnectorList(stationIds);
|
||||
// 筛选出枪口编号
|
||||
List<String> pileConnectorCodeList = connectorInfoVOS.stream()
|
||||
public PageResponse getConnectorListByStationAndStatus(QueryConnectorInfoDTO dto) {
|
||||
List<PileConnectorInfoVO> list = new ArrayList<>();
|
||||
List<String> stationIds = dto.getStationIds();
|
||||
|
||||
int pageNum = dto.getPageNum() == 0 ? 1 : dto.getPageNum();
|
||||
int pageSize = dto.getPageSize() == 0 ? 10 : dto.getPageSize();
|
||||
|
||||
// 分页查询符合条件站点的枪口列表
|
||||
PageUtils.startPage(pageNum, pageSize);
|
||||
List<ConnectorInfoVO> connectorInfoVOS = pileConnectorInfoMapper.batchSelectConnectorListByStatus(stationIds, null);
|
||||
|
||||
PageInfo<ConnectorInfoVO> pageInfo = new PageInfo<>(connectorInfoVOS);
|
||||
// 将分页列表中充电中的枪编码筛选出来
|
||||
List<String> chargingPileConnectorCodeList = connectorInfoVOS.stream()
|
||||
.filter(connectorInfoVO -> StringUtils.equals(connectorInfoVO.getConnectorStatus()
|
||||
, PileConnectorDataBaseStatusEnum.OCCUPIED_CHARGING.getValue()))
|
||||
.map(ConnectorInfoVO::getPileConnectorCode)
|
||||
.collect(Collectors.toList());
|
||||
// 批量获取某状态的枪口数量
|
||||
Map<String, Integer> connectorStatusNumMap = getConnectorStatus(pileConnectorCodeList);
|
||||
Integer offlineNum = connectorStatusNumMap.get("offlineNum");
|
||||
Integer freeNum = connectorStatusNumMap.get("freeNum");
|
||||
Integer occupiedNum = connectorStatusNumMap.get("occupiedNum");
|
||||
Integer chargingNum = connectorStatusNumMap.get("chargingNum");
|
||||
Integer faultNum = connectorStatusNumMap.get("faultNum");
|
||||
|
||||
vo.setConnectorNum(pileConnectorCodeList.size());
|
||||
vo.setOfflineConnectorNum(offlineNum);
|
||||
vo.setFreeConnectorNum(freeNum);
|
||||
vo.setOccupiedConnectorNum(occupiedNum);
|
||||
vo.setChargingConnectorNum(chargingNum);
|
||||
vo.setFaultConnectorNum(faultNum);
|
||||
|
||||
List<Long> longStationIds = stationIds.stream()
|
||||
.map(Long::parseLong) // 或 s -> Long.parseLong(s)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 根据站点id和枪口状态查询枪口列表
|
||||
QueryConnectorListDTO queryConnectorListDTO = QueryConnectorListDTO.builder()
|
||||
.pageNum(pageNum)
|
||||
.pageSize(pageSize)
|
||||
.stationIdList(longStationIds)
|
||||
.build();
|
||||
List<PileConnectorInfoVO> pileConnectorInfoVOList = getConnectorInfoListByParams(queryConnectorListDTO);
|
||||
if (connectorStatus != null) {
|
||||
// 筛选出符合状态的数据
|
||||
pileConnectorInfoVOList = pileConnectorInfoVOList.stream()
|
||||
.filter(x -> x.getStatus() == Integer.parseInt(connectorStatus))
|
||||
.collect(Collectors.toList());
|
||||
if (CollectionUtils.isNotEmpty(chargingPileConnectorCodeList)) {
|
||||
// 批量查询充电中的各项信息
|
||||
List<PileConnectorInfoVO> pileConnectorInfoVOS = orderBasicInfoService.batchQueryChargingConnectorInfo(chargingPileConnectorCodeList);
|
||||
// 将获取到的充电信息详情根据枪口编码将信息set进对应的pageInfo.list中对应的值
|
||||
for (PileConnectorInfoVO pileConnectorInfoVO : pileConnectorInfoVOS) {
|
||||
for (ConnectorInfoVO connectorInfoVO : connectorInfoVOS) {
|
||||
if (StringUtils.equals(pileConnectorInfoVO.getPileConnectorCode(), connectorInfoVO.getPileConnectorCode())) {
|
||||
connectorInfoVO.setOrderCode(pileConnectorInfoVO.getOrderCode());
|
||||
connectorInfoVO.setChargeTime(pileConnectorInfoVO.getChargingTime());
|
||||
connectorInfoVO.setChargeDegree(String.valueOf(pileConnectorInfoVO.getChargingDegree()));
|
||||
connectorInfoVO.setTimeRemaining(pileConnectorInfoVO.getTimeRemaining());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
vo.setPileConnectorInfoVOList(pileConnectorInfoVOList);
|
||||
return vo;
|
||||
|
||||
return PageResponse.builder()
|
||||
.pageNum(pageInfo.getPageNum())
|
||||
.pageSize(pageInfo.getPageSize())
|
||||
.total(pageInfo.getTotal())
|
||||
.pages(pageInfo.getPages())
|
||||
.list(connectorInfoVOS)
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取站点各状态的枪口数量
|
||||
* @param stationIds
|
||||
* @param connectorStatus
|
||||
* @return
|
||||
*/
|
||||
public Map<String, Object> getConnectorStatusNum(List<String> stationIds, String connectorStatus) {
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
List<ConnectorInfoVO> connectorInfoVOS = pileConnectorInfoMapper.batchSelectConnectorListByStatus(stationIds, connectorStatus);
|
||||
// 初始化对象
|
||||
int offlineNum = 0;
|
||||
int freeNum = 0;
|
||||
int occupiedNum = 0;
|
||||
int chargingNum = 0;
|
||||
int faultNum = 0;
|
||||
|
||||
for (ConnectorInfoVO connectorInfoVO : connectorInfoVOS) {
|
||||
String status = connectorInfoVO.getConnectorStatus();
|
||||
|
||||
if (StringUtils.equals(status, PileConnectorDataBaseStatusEnum.OFF_NETWORK.getValue())) {
|
||||
// 离网
|
||||
offlineNum += 1;
|
||||
}
|
||||
if (StringUtils.equals(status, PileConnectorDataBaseStatusEnum.FREE.getValue())) {
|
||||
// 空闲
|
||||
freeNum += 1;
|
||||
}
|
||||
if (StringUtils.equals(status, PileConnectorDataBaseStatusEnum.OCCUPIED_NOT_CHARGED.getValue())) {
|
||||
// 占用未充电
|
||||
occupiedNum += 1;
|
||||
}
|
||||
if (StringUtils.equals(status, PileConnectorDataBaseStatusEnum.OCCUPIED_CHARGING.getValue())) {
|
||||
// 充电中
|
||||
chargingNum += 1;
|
||||
}
|
||||
if (StringUtils.equals(status, PileConnectorDataBaseStatusEnum.FAULT.getValue())) {
|
||||
// 故障
|
||||
faultNum += 1;
|
||||
}
|
||||
}
|
||||
map.put("offlineNum", offlineNum);
|
||||
map.put("freeNum", freeNum);
|
||||
map.put("occupiedNum", occupiedNum);
|
||||
map.put("chargingNum", chargingNum);
|
||||
map.put("faultNum", faultNum);
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1623,4 +1623,14 @@ public class PileStationInfoServiceImpl implements PileStationInfoService {
|
||||
return uniAppQueryStationInfoListV2(dto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据商户ids查询站点ids
|
||||
* @param merchantIdList
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<String> getStationIdsByMerchantIds(List<String> merchantIdList) {
|
||||
return pileStationInfoMapper.getStationIdsByMerchantIds(merchantIdList);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -66,4 +66,11 @@ public class ConnectorInfoVO {
|
||||
*/
|
||||
private String ratedVoltage;
|
||||
|
||||
private String orderCode;
|
||||
|
||||
private String chargeDegree;
|
||||
|
||||
private String chargeTime;
|
||||
|
||||
private String timeRemaining;
|
||||
}
|
||||
|
||||
@@ -25,6 +25,11 @@ public class BusinessOrderDetailInfoVO {
|
||||
|
||||
private String pileConnectorCode;
|
||||
|
||||
/**
|
||||
* 交易流水号
|
||||
*/
|
||||
private String transactionCode;
|
||||
|
||||
/**
|
||||
* 充电次数
|
||||
*/
|
||||
@@ -185,4 +190,9 @@ public class BusinessOrderDetailInfoVO {
|
||||
*/
|
||||
private String memberId;
|
||||
|
||||
/**
|
||||
* 剩余时间
|
||||
*/
|
||||
private String timeRemaining;
|
||||
|
||||
}
|
||||
|
||||
@@ -3592,4 +3592,17 @@
|
||||
and `settlement_time` BETWEEN #{dto.startTime,jdbcType=VARCHAR} and #{dto.endTime,jdbcType=VARCHAR}
|
||||
group by DATE_FORMAT(settlement_time, '%Y-%m-%d');
|
||||
</select>
|
||||
|
||||
<select id="batchQueryChargingConnectorInfo"
|
||||
resultType="com.jsowell.pile.vo.web.PileConnectorInfoVO">
|
||||
select
|
||||
order_code as orderCode,
|
||||
transaction_code as transactionCode,
|
||||
pile_connector_code as pileConnectorCode
|
||||
from order_basic_info where pile_connector_code in
|
||||
<foreach item="pileConnectorCode" collection="pileConnectorCodes" separator="," open="(" close=")">
|
||||
#{pileConnectorCode}
|
||||
</foreach>
|
||||
and order_status = '1'
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
@@ -319,4 +319,27 @@
|
||||
AND
|
||||
t1.del_flag = '0'
|
||||
</select>
|
||||
|
||||
<select id="batchSelectConnectorListByStatus" resultType="com.jsowell.pile.vo.base.ConnectorInfoVO">
|
||||
SELECT
|
||||
t1.pile_connector_code as pileConnectorCode,
|
||||
t2.station_id as stationId,
|
||||
t1.STATUS as connectorStatus,
|
||||
t1.pile_sn as pileSn,
|
||||
t2.model_id as modelId,
|
||||
t3.speed_type as chargingType,
|
||||
t3.rated_power as ratedPower
|
||||
FROM
|
||||
pile_connector_info t1
|
||||
JOIN pile_basic_info t2 ON (t1.pile_sn = t2.sn AND t2.del_flag = '0')
|
||||
JOIN pile_model_info t3 ON (t2.model_id = t3.id AND t3.del_flag = '0')
|
||||
WHERE t1.del_flag = '0'
|
||||
AND t2.station_id in
|
||||
<foreach collection="stationIds" item="stationId" open="(" separator="," close=")">
|
||||
#{stationId, jdbcType=VARCHAR}
|
||||
</foreach>
|
||||
<if test="status != null and status != ''">
|
||||
AND t1.status = #{status,jdbcType=VARCHAR}
|
||||
</if>
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -743,4 +743,15 @@
|
||||
ORDER BY
|
||||
chargeNum DESC;
|
||||
</select>
|
||||
|
||||
<select id="getStationIdsByMerchantIds" resultType="java.lang.String">
|
||||
select
|
||||
id
|
||||
from
|
||||
pile_station_info
|
||||
where merchant_id in
|
||||
<foreach collection="merchantIds" item="merchantId" open="(" separator="," close=")">
|
||||
#{merchantId,jdbcType=VARCHAR}
|
||||
</foreach>
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
Reference in New Issue
Block a user