diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/nanrui/domain/NRStationStatusInfo.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/nanrui/domain/NRStationStatusInfo.java index 40c948a4b..0ff04a798 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/nanrui/domain/NRStationStatusInfo.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/nanrui/domain/NRStationStatusInfo.java @@ -1,7 +1,10 @@ package com.jsowell.thirdparty.nanrui.domain; import com.alibaba.fastjson2.annotation.JSONField; +import lombok.AllArgsConstructor; +import lombok.Builder; import lombok.Data; +import lombok.NoArgsConstructor; import java.util.List; @@ -12,6 +15,9 @@ import java.util.List; * @Date 2023/9/25 14:32 */ @Data +@AllArgsConstructor +@NoArgsConstructor +@Builder public class NRStationStatusInfo { @JSONField(name = "StationID") diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/nanrui/service/NRService.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/nanrui/service/NRService.java index 6aa27b0e7..8e03aeb1a 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/nanrui/service/NRService.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/nanrui/service/NRService.java @@ -2,8 +2,10 @@ package com.jsowell.thirdparty.nanrui.service; import com.jsowell.common.core.domain.ykc.RealTimeMonitorData; import com.jsowell.pile.dto.QueryStationInfoDTO; +import com.jsowell.thirdparty.nanrui.domain.NRStationStatusInfo; import java.text.ParseException; +import java.util.List; import java.util.Map; /** @@ -46,4 +48,12 @@ public interface NRService { * 充电过程中运营商平台应 每分钟 上报充电包含电流、电压在内的监测数据。 */ String notification_stationStatus(RealTimeMonitorData realTimeMonitorData); + + + /** + * 查询设备接口状态 + * @param stationIds + * @return + */ + String query_station_status(List stationIds); } \ No newline at end of file diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/nanrui/service/impl/NRServiceImpl.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/nanrui/service/impl/NRServiceImpl.java index c83b1367d..063f55dfd 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/nanrui/service/impl/NRServiceImpl.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/nanrui/service/impl/NRServiceImpl.java @@ -11,9 +11,12 @@ import com.jsowell.common.util.DateUtils; import com.jsowell.common.util.PageUtils; import com.jsowell.common.util.StringUtils; import com.jsowell.pile.domain.*; +import com.jsowell.pile.dto.QueryConnectorListDTO; import com.jsowell.pile.dto.QueryStationInfoDTO; import com.jsowell.pile.service.*; +import com.jsowell.pile.vo.base.ConnectorInfoVO; import com.jsowell.pile.vo.uniapp.CurrentTimePriceDetails; +import com.jsowell.pile.vo.web.PileConnectorInfoVO; import com.jsowell.pile.vo.web.PileModelInfoVO; import com.jsowell.pile.vo.web.PileStationVO; import com.jsowell.thirdparty.lianlian.domain.ConnectorInfo; @@ -26,6 +29,7 @@ import org.springframework.beans.factory.annotation.Autowired; import java.math.BigDecimal; import java.text.ParseException; import java.util.*; +import java.util.stream.Collectors; /** * TODO @@ -261,6 +265,80 @@ public class NRServiceImpl implements NRService { return null; } + @Override + public String query_station_status(List stationIds) { + List resultList = new ArrayList<>(); + + // 将 stationIdList 转换成 List + List stationLongList = stationIds.stream() + .map(Long::parseLong) + .collect(Collectors.toList()); + + QueryConnectorListDTO dto = QueryConnectorListDTO.builder() + .stationIdList(stationLongList) + .build(); + List connectorInfoVOS = pileConnectorInfoService.getConnectorInfoListByParams(dto); + if (CollectionUtils.isEmpty(connectorInfoVOS)) { + return null; + } + // 根据stationId分组 + Map> collect = connectorInfoVOS.stream() + .collect(Collectors.groupingBy(PileConnectorInfoVO::getStationId)); + // 遍历 map + for (Map.Entry> entry : collect.entrySet()) { + String stationId = entry.getKey(); + List connectorList = entry.getValue(); + List connectorStatusInfoList = new ArrayList<>(); + + for (PileConnectorInfoVO connectorInfoVO : connectorList) { + NRConnectorStatusInfo nrConnectorStatusInfo = NRConnectorStatusInfo.builder() + .connectorID(connectorInfoVO.getPileConnectorCode()) + .status(connectorInfoVO.getStatus()) + .currentA(0) + .voltageA(0) + .soc(BigDecimal.ZERO) + .beginTime(null) + .currentKwh(BigDecimal.ZERO) + .timeStamp((int) (System.currentTimeMillis() / 1000)) + + .build(); + if (StringUtils.equals(String.valueOf(connectorInfoVO.getStatus()), "3")) { + // 充电中 + nrConnectorStatusInfo.setCurrentA(connectorInfoVO.getCurrent().intValue()); + nrConnectorStatusInfo.setVoltageA(connectorInfoVO.getVoltage().intValue()); + nrConnectorStatusInfo.setSoc(new BigDecimal(connectorInfoVO.getSOC())); + String chargingTime = connectorInfoVO.getChargingTime(); + Date beginTime = DateUtils.addMinute(new Date(), -Integer.parseInt(chargingTime)); + nrConnectorStatusInfo.setBeginTime(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, beginTime)); + } + if (StringUtils.equals(String.valueOf(connectorInfoVO.getStatus()), "255")) { + // 故障 + nrConnectorStatusInfo.setStatus(255); + } + connectorStatusInfoList.add(nrConnectorStatusInfo); + } + // 封装参数 + NRStationStatusInfo stationStatusInfo = NRStationStatusInfo.builder() + .stationId(stationId) + .connectorStatusInfos(connectorStatusInfoList) + .build(); + resultList.add(stationStatusInfo); + } + Map map = new LinkedHashMap<>(); + map.put("StationStatusInfos", resultList); + + // TODO 发送请求 + + return null; + } + + public static void main(String[] args) { + String chargingTime = "30"; + Date beginTime = DateUtils.addMinute(new Date(), -Integer.parseInt(chargingTime)); + String s = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, beginTime); + System.out.println(s); + } + /** * 获取设备信息 * @param stationId