|
|
@@ -1,18 +1,12 @@
|
|
|
package com.zsElectric.boot.charging.service.impl;
|
|
|
|
|
|
-import cn.hutool.core.util.StrUtil;
|
|
|
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
-import com.zsElectric.boot.charging.entity.ThirdPartyConnectorInfo;
|
|
|
-import com.zsElectric.boot.charging.entity.ThirdPartyEquipmentInfo;
|
|
|
-import com.zsElectric.boot.charging.mapper.ThirdPartyConnectorInfoMapper;
|
|
|
import com.zsElectric.boot.charging.mapper.ThirdPartyEquipmentInfoMapper;
|
|
|
import com.zsElectric.boot.charging.model.query.ThirdPartyEquipmentInfoQuery;
|
|
|
import com.zsElectric.boot.charging.model.vo.ThirdPartyEquipmentInfoVO;
|
|
|
import com.zsElectric.boot.charging.service.ThirdPartyEquipmentInfoService;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
-import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
/**
|
|
|
@@ -26,56 +20,13 @@ import org.springframework.stereotype.Service;
|
|
|
public class ThirdPartyEquipmentInfoServiceImpl implements ThirdPartyEquipmentInfoService {
|
|
|
|
|
|
private final ThirdPartyEquipmentInfoMapper equipmentInfoMapper;
|
|
|
- private final ThirdPartyConnectorInfoMapper connectorInfoMapper;
|
|
|
|
|
|
@Override
|
|
|
public IPage<ThirdPartyEquipmentInfoVO> getEquipmentInfoPage(ThirdPartyEquipmentInfoQuery queryParams) {
|
|
|
// 构建分页
|
|
|
- Page<ThirdPartyEquipmentInfo> page = new Page<>(queryParams.getPageNum(), queryParams.getPageSize());
|
|
|
+ Page<ThirdPartyEquipmentInfoVO> page = new Page<>(queryParams.getPageNum(), queryParams.getPageSize());
|
|
|
|
|
|
- // 构建查询条件
|
|
|
- LambdaQueryWrapper<ThirdPartyEquipmentInfo> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
- queryWrapper.eq(StrUtil.isNotBlank(queryParams.getEquipmentId()), ThirdPartyEquipmentInfo::getEquipmentId, queryParams.getEquipmentId())
|
|
|
- .like(StrUtil.isNotBlank(queryParams.getEquipmentName()), ThirdPartyEquipmentInfo::getEquipmentName, queryParams.getEquipmentName())
|
|
|
- .eq(StrUtil.isNotBlank(queryParams.getStationId()), ThirdPartyEquipmentInfo::getStationId, queryParams.getStationId())
|
|
|
- .like(StrUtil.isNotBlank(queryParams.getStationName()), ThirdPartyEquipmentInfo::getStationName, queryParams.getStationName())
|
|
|
- .eq(queryParams.getEquipmentType() != null, ThirdPartyEquipmentInfo::getEquipmentType, queryParams.getEquipmentType())
|
|
|
- .eq(StrUtil.isNotBlank(queryParams.getDeviceStatus()), ThirdPartyEquipmentInfo::getDeviceStatus, queryParams.getDeviceStatus())
|
|
|
- .eq(StrUtil.isNotBlank(queryParams.getParkNo()), ThirdPartyEquipmentInfo::getParkNo, queryParams.getParkNo())
|
|
|
- .eq(queryParams.getNationalStandard() != null, ThirdPartyEquipmentInfo::getNationalStandard, queryParams.getNationalStandard())
|
|
|
- .orderByDesc(ThirdPartyEquipmentInfo::getUpdateTime);
|
|
|
-
|
|
|
- // 查询设备信息
|
|
|
- Page<ThirdPartyEquipmentInfo> equipmentPage = equipmentInfoMapper.selectPage(page, queryWrapper);
|
|
|
-
|
|
|
- // 实体转换并填充接口信息
|
|
|
- Page<ThirdPartyEquipmentInfoVO> voPage = new Page<>(equipmentPage.getCurrent(), equipmentPage.getSize(), equipmentPage.getTotal());
|
|
|
- voPage.setRecords(equipmentPage.getRecords().stream().map(entity -> {
|
|
|
- ThirdPartyEquipmentInfoVO vo = new ThirdPartyEquipmentInfoVO();
|
|
|
- BeanUtils.copyProperties(entity, vo);
|
|
|
-
|
|
|
- // 根据接口类型查询参数,查询接口信息
|
|
|
- LambdaQueryWrapper<ThirdPartyConnectorInfo> connectorWrapper = new LambdaQueryWrapper<>();
|
|
|
- connectorWrapper.eq(ThirdPartyConnectorInfo::getEquipmentId, entity.getEquipmentId())
|
|
|
- .eq(ThirdPartyConnectorInfo::getStationId, entity.getStationId());
|
|
|
- if (queryParams.getConnectorType() != null) {
|
|
|
- connectorWrapper.eq(ThirdPartyConnectorInfo::getConnectorType, queryParams.getConnectorType());
|
|
|
- }
|
|
|
- connectorWrapper.last("LIMIT 1");
|
|
|
-
|
|
|
- ThirdPartyConnectorInfo connectorInfo = connectorInfoMapper.selectOne(connectorWrapper);
|
|
|
- if (connectorInfo != null) {
|
|
|
- vo.setConnectorId(connectorInfo.getConnectorId());
|
|
|
- vo.setConnectorName(connectorInfo.getConnectorName());
|
|
|
- vo.setConnectorType(connectorInfo.getConnectorType());
|
|
|
- vo.setVoltageUpperLimits(connectorInfo.getVoltageUpperLimits());
|
|
|
- vo.setVoltageLowerLimits(connectorInfo.getVoltageLowerLimits());
|
|
|
- vo.setCurrent(connectorInfo.getCurrent());
|
|
|
- }
|
|
|
-
|
|
|
- return vo;
|
|
|
- }).toList());
|
|
|
-
|
|
|
- return voPage;
|
|
|
+ // 调用Mapper联表查询
|
|
|
+ return equipmentInfoMapper.selectEquipmentInfoPage(page, queryParams);
|
|
|
}
|
|
|
}
|