update 查询枪口列表接口、add 查询各状态枪口汇总数据接口

This commit is contained in:
Lemon
2026-01-07 10:14:59 +08:00
parent 96725e53e5
commit 22865eae82
12 changed files with 157 additions and 87 deletions

View File

@@ -456,5 +456,5 @@ public interface OrderBasicInfoMapper {
* @param chargingConnectorCodeList
* @return
*/
List<BusinessOrderDetailInfoVO> batchQueryChargingConnectorInfo(@Param("pileConnectorCodes") List<String> chargingConnectorCodeList);
List<PileConnectorInfoVO> batchQueryChargingConnectorInfo(@Param("pileConnectorCodes") List<String> chargingConnectorCodeList);
}

View File

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

View File

@@ -658,7 +658,7 @@ public interface OrderBasicInfoService{
* @param chargingConnectorCodeList
* @return
*/
List<BusinessOrderDetailInfoVO> batchQueryChargingConnectorInfo(List<String> chargingConnectorCodeList);
List<PileConnectorInfoVO> batchQueryChargingConnectorInfo(List<String> chargingConnectorCodeList);
/**
* 批量查询充电枪实时数据

View File

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

View File

@@ -216,5 +216,10 @@ public interface PileStationInfoService {
*/
PageResponse queryUserFrequentedStation(QueryStationDTO dto);
/**
* 通过运营商ids查询站点ids
* @param merchantIdList
* @return
*/
List<String> getStationIdsByMerchantIds(List<String> merchantIdList);
}

View File

@@ -6252,12 +6252,12 @@ public class OrderBasicInfoServiceImpl implements OrderBasicInfoService {
* @return
*/
@Override
public List<BusinessOrderDetailInfoVO> batchQueryChargingConnectorInfo(List<String> chargingConnectorCodeList) {
public List<PileConnectorInfoVO> batchQueryChargingConnectorInfo(List<String> chargingConnectorCodeList) {
// 这个infoVOs只有简单数据没有充电中数据
List<BusinessOrderDetailInfoVO> infoVOS = orderBasicInfoMapper.batchQueryChargingConnectorInfo(chargingConnectorCodeList);
List<PileConnectorInfoVO> infoVOS = orderBasicInfoMapper.batchQueryChargingConnectorInfo(chargingConnectorCodeList);
List<String> transactionCodes = infoVOS.stream()
.map(BusinessOrderDetailInfoVO::getTransactionCode)
.map(PileConnectorInfoVO::getTransactionCode)
.collect(Collectors.toList());
List<RealTimeMonitorData> list = getRealTimeMonitorDataList(transactionCodes);
@@ -6267,14 +6267,14 @@ public class OrderBasicInfoServiceImpl implements OrderBasicInfoService {
x -> x,
(existing, replacement) -> existing // 如果有重复key保留第一个
));
for (BusinessOrderDetailInfoVO infoVO : infoVOS) {
for (PileConnectorInfoVO infoVO : infoVOS) {
String pileConnectorCode = infoVO.getPileConnectorCode();
if (pileConnectorCode != null && bMap.containsKey(pileConnectorCode)) {
RealTimeMonitorData realTimeMonitorData = bMap.get(pileConnectorCode);
infoVO.setChargeDegree(realTimeMonitorData.getChargingDegree());
infoVO.setChargeTime(realTimeMonitorData.getSumChargingTime());
infoVO.setEndSOC(realTimeMonitorData.getSOC());
infoVO.setChargingDegree(new BigDecimal(realTimeMonitorData.getChargingDegree()));
infoVO.setChargingTime(realTimeMonitorData.getSumChargingTime());
infoVO.setSOC(realTimeMonitorData.getSOC());
infoVO.setTimeRemaining(realTimeMonitorData.getTimeRemaining());
}
}

View File

@@ -41,6 +41,7 @@ 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;
@@ -1062,33 +1063,60 @@ public class PileConnectorInfoServiceImpl implements PileConnectorInfoService {
* @return
*/
@Override
public BusinessConnectorInfoVO getConnectorListByStationAndStatus(QueryConnectorInfoDTO dto) {
public PageResponse getConnectorListByStationAndStatus(QueryConnectorInfoDTO dto) {
List<PileConnectorInfoVO> list = new ArrayList<>();
PileConnectorInfoVO info = null;
List<String> stationIds = dto.getStationIds();
int pageNum = dto.getPageNum() == 0 ? 1 : dto.getPageNum();
int pageSize = dto.getPageSize() == 0 ? 10 : dto.getPageSize();
// 获取登录账号信息
LoginUserDetailVO loginUserDetail = UserUtils.getLoginUserDetail();
List<String> merchantIdList = loginUserDetail.getFirstMerchantIdList();
List<PileStationInfo> stationInfos = pileStationInfoService.getStationInfosByMerchantIds(merchantIdList);
// 获取站点ids
List<Long> longStationIds = stationInfos.stream()
.map(PileStationInfo::getId)
.collect(Collectors.toList());
List<String> stationIds = longStationIds.stream()
.map(String::valueOf) // 或 s -> Long.parseLong(s)
.collect(Collectors.toList());
String connectorStatus = dto.getConnectorStatus();
BusinessConnectorInfoVO vo = new BusinessConnectorInfoVO();
// 根据站点ids、枪口状态查询枪口列表(有缓存)
// 分页查询符合条件站点的枪口列表
PageUtils.startPage(pageNum, pageSize);
// List<ConnectorInfoVO> connectorInfoVOS = batchSelectConnectorList(stationIds);
List<ConnectorInfoVO> connectorInfoVOS = pileConnectorInfoMapper.batchSelectConnectorListByStatus(stationIds, connectorStatus);
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());
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());
}
}
}
}
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);
// 初始化对象
List<String> chargingConnectorCodeList = new ArrayList<>(); // 充电中枪口 pileConnectorCodeList
int offlineNum = 0;
int freeNum = 0;
int occupiedNum = 0;
@@ -1096,82 +1124,36 @@ public class PileConnectorInfoServiceImpl implements PileConnectorInfoService {
int faultNum = 0;
for (ConnectorInfoVO connectorInfoVO : connectorInfoVOS) {
String pileConnectorCode = connectorInfoVO.getPileConnectorCode();
String status = connectorInfoVO.getConnectorStatus();
info = new PileConnectorInfoVO();
if (StringUtils.equals(status, PileConnectorDataBaseStatusEnum.OFF_NETWORK.getValue())) {
// 离网
offlineNum += 1;
info.setPileConnectorCode(pileConnectorCode);
info.setStatus(Integer.parseInt(PileConnectorDataBaseStatusEnum.OFF_NETWORK.getValue()));
list.add(info);
}
if (StringUtils.equals(status, PileConnectorDataBaseStatusEnum.FREE.getValue())) {
// 空闲
freeNum += 1;
info.setPileConnectorCode(pileConnectorCode);
info.setStatus(Integer.parseInt(PileConnectorDataBaseStatusEnum.FREE.getValue()));
list.add(info);
}
if (StringUtils.equals(status, PileConnectorDataBaseStatusEnum.OCCUPIED_NOT_CHARGED.getValue())) {
// 占用未充电
occupiedNum += 1;
info.setPileConnectorCode(pileConnectorCode);
info.setStatus(Integer.parseInt(PileConnectorDataBaseStatusEnum.OCCUPIED_NOT_CHARGED.getValue()));
list.add(info);
}
if (StringUtils.equals(status, PileConnectorDataBaseStatusEnum.OCCUPIED_CHARGING.getValue())) {
// 充电中
chargingNum += 1;
chargingConnectorCodeList.add(pileConnectorCode);
}
if (StringUtils.equals(status, PileConnectorDataBaseStatusEnum.FAULT.getValue())) {
// 故障
faultNum += 1;
info.setPileConnectorCode(pileConnectorCode);
info.setStatus(Integer.parseInt(PileConnectorDataBaseStatusEnum.FAULT.getValue()));
list.add(info);
}
vo.setConnectorNum(connectorInfoVOS.size());
vo.setOfflineConnectorNum(offlineNum);
vo.setFreeConnectorNum(freeNum);
vo.setOccupiedConnectorNum(occupiedNum);
vo.setChargingConnectorNum(chargingNum);
vo.setFaultConnectorNum(faultNum);
}
// 如果充电中的枪列表不为空
if (CollectionUtils.isNotEmpty(chargingConnectorCodeList)) {
// 根据充电中的枪口List批量获取充电中的枪口信息
List<BusinessOrderDetailInfoVO> infoVOS = orderBasicInfoService.batchQueryChargingConnectorInfo(chargingConnectorCodeList);
Map<String, BusinessOrderDetailInfoVO> bMap = infoVOS.stream()
.collect(Collectors.toMap(
BusinessOrderDetailInfoVO::getPileConnectorCode,
x -> x,
(existing, replacement) -> existing // 如果有重复key保留第一个
));
for (PileConnectorInfoVO pileConnectorInfoVO : list) {
String pileConnectorCode = pileConnectorInfoVO.getPileConnectorCode();
if (pileConnectorCode != null && bMap.containsKey(pileConnectorCode)) {
BusinessOrderDetailInfoVO businessOrderDetailInfoVO = bMap.get(pileConnectorCode);
pileConnectorInfoVO.setStatus(Integer.parseInt(PileConnectorDataBaseStatusEnum.OCCUPIED_CHARGING.getValue()));
pileConnectorInfoVO.setChargingDegree(new BigDecimal(businessOrderDetailInfoVO.getChargeDegree()));
pileConnectorInfoVO.setChargingTime(businessOrderDetailInfoVO.getChargeTime());
pileConnectorInfoVO.setSOC(businessOrderDetailInfoVO.getEndSOC());
pileConnectorInfoVO.setTimeRemaining(businessOrderDetailInfoVO.getTimeRemaining());
}
}
}
vo.setPileConnectorInfoVOList(list);
return vo;
map.put("offlineNum", offlineNum);
map.put("freeNum", freeNum);
map.put("occupiedNum", occupiedNum);
map.put("chargingNum", chargingNum);
map.put("faultNum", faultNum);
return map;
}
/**

View File

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

View File

@@ -66,4 +66,11 @@ public class ConnectorInfoVO {
*/
private String ratedVoltage;
private String orderCode;
private String chargeDegree;
private String chargeTime;
private String timeRemaining;
}

View File

@@ -3523,7 +3523,7 @@
</select>
<select id="batchQueryChargingConnectorInfo"
resultType="com.jsowell.pile.vo.uniapp.business.BusinessOrderDetailInfoVO">
resultType="com.jsowell.pile.vo.web.PileConnectorInfoVO">
select
order_code as orderCode,
transaction_code as transactionCode,

View File

@@ -740,4 +740,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>