快电ing

This commit is contained in:
ZZ 2021-10-25 18:50:51 +08:00
parent fab6246b02
commit 98fc694b9e
5 changed files with 38 additions and 32 deletions

View File

@ -5,8 +5,6 @@ import lombok.Getter;
import lombok.Setter;
import org.apache.commons.lang3.builder.ToStringBuilder;
import javax.persistence.Id;
import javax.persistence.Transient;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
@ -29,14 +27,13 @@ public class ConnectorStatusInfo {
public final static int BOOKED = 4;//占用预约锁定)
public final static int ERROR = 255;//故障
@Id
@JsonProperty("ConnectorID")
private String connectorID;
@JsonProperty("OperatorID")
@JsonIgnore()
private String operatorID;
@JsonProperty("Status")
private Integer status;
@Transient
@JsonIgnore
private Map<String, Object> additionalProperties = new HashMap<String, Object>();

View File

@ -32,7 +32,7 @@ public class EquipmentInfo {
@JsonProperty("Power")
public Double power;
@JsonProperty("ConnectorInfos")
public List<ConnectorInfo> connectorInfos = null;
public List<ConnectorStatusInfo> connectorStatusInfos;
@JsonProperty("EquipmentLng")
public Double equipmentLng;
@JsonProperty("EquipmentLat")
@ -56,8 +56,8 @@ public class EquipmentInfo {
public String toString() {
return new ToStringBuilder(this).append("equipmentID", equipmentID).append("manufacturerID", manufacturerID).append(
"equipmentType", equipmentType).append("power", power).append("connectorInfos", connectorInfos).append(
"equipmentLng", equipmentLng).append("equipmentLat", equipmentLat).append("additionalProperties",
"equipmentType", equipmentType).append("power", power).append("connectorInfos", connectorStatusInfos).append(
"equipmentLng", equipmentLng).append("equipmentLat", equipmentLat).append("additionalProperties",
additionalProperties).toString();
}

View File

@ -46,9 +46,16 @@ public class StationsInfoController extends CoreDispatcher {
xhpcStationInternetBlacklistRepo.findByInternetUserId(operatorId);
List<String> stationKeys = new ArrayList<>(REDIS.keys("station:*"));
List<String> validStationKeys = new ArrayList<>();
for (XhpcStationInternetBlacklist xhpcStationInternetBlack : xhpcStationInternetBlacklist) {
for (String stationKey : stationKeys) {
if (!stationKey.substring(8).equals(xhpcStationInternetBlack.getChargingStationId().toString())) {
for (String stationKey : stationKeys) {
boolean isValid = true;
for (XhpcStationInternetBlacklist xhpcStationInternetBlack : xhpcStationInternetBlacklist) {
if (stationKey.substring(8).equals(xhpcStationInternetBlack.getChargingStationId().toString())) {
isValid = false;
}
}
ChargingStationDto chargingStationDto = REDIS.getCacheObject(stationKey);
if (chargingStationDto.getPiles() != null) {
if (isValid) {
validStationKeys.add(stationKey);
}
}
@ -65,7 +72,7 @@ public class StationsInfoController extends CoreDispatcher {
for (int i = ((pageNo - 1) * pageSize); i < lastOne; i++) {
final String stationKey = validStationKeys.get(i);
ChargingStationDto chargingStationDto = REDIS.getCacheObject(stationKey);
if (chargingStationDto.getPiles() != null) {
if (chargingStationDto.getPiles() != null) { //todo rm dup or-else?
StationInfo station = new StationInfo();
station.setStationStatus(50L);
final String stationId = stationKey.replace("station:", "");
@ -119,13 +126,14 @@ public class StationsInfoController extends CoreDispatcher {
for (String pileNo : pileNoSet) {
final Map<String, Object> cachePile = REDIS.getCacheMap("pile:".concat(pileNo));
Integer connectorType = (Integer) cachePile.get("connectorType");
if (connectorType == null) {
if (connectorType == null) { //未缓存
XhpcChargingPile pileExample = new XhpcChargingPile();
pileExample.setSerialNumber(pileNo);
Example<XhpcChargingPile> example = Example.of(pileExample);
XhpcChargingPile xhpcChargingPile = xhpcChargingPileRepository.findOne(example).orElse(null);
if (xhpcChargingPile != null) {
cachePile.put("connectorType", xhpcChargingPile.getType() == 1 ? Integer.valueOf(4) : Integer.valueOf(3));
cachePile.put("connectorType", xhpcChargingPile.getType() == null ? Integer.valueOf(4) :
Integer.valueOf(xhpcChargingPile.getType()));
cachePile.put("voltageUpperLimits", xhpcChargingPile.getMaxVoltage().intValue());
cachePile.put("voltageLowerLimits", xhpcChargingPile.getMinVoltage().intValue());
cachePile.put("current", xhpcChargingPile.getCurrent());
@ -140,31 +148,32 @@ public class StationsInfoController extends CoreDispatcher {
equipmentInfo.setEquipmentID(pileNo);
equipmentInfo.setEquipmentType((Integer) cachePile.get("equipmentType"));
equipmentInfo.setPower((Double) cachePile.get("power"));
equipmentInfo.setConnectorInfos(getConnectorInfos(pileNo, cachePile));
equipmentInfo.setConnectorStatusInfos(getConnectorInfos(pileNo, cachePile));
equipmentInfos.add(equipmentInfo);
}
return equipmentInfos;
}
private List<ConnectorInfo> getConnectorInfos(String pileNo, Map<String, Object> cachePile) {
private List<ConnectorStatusInfo> getConnectorInfos(String pileNo, Map<String, Object> cachePile) {
List<ConnectorInfo> connectorInfos = new ArrayList<>();
final Object gunNumCache = cachePile.get("gunNum");
if (gunNumCache == null) return connectorInfos;
int gunNum = (int) gunNumCache;
for (int i = 1; i <= gunNum; i++) {
List<ConnectorStatusInfo> connectorStatusInfoList = new ArrayList<>();
Integer gunNumCache = (Integer) cachePile.get("gunNum");
gunNumCache = gunNumCache == null ? 1 : gunNumCache;
for (int i = 1; i <= gunNumCache; i++) {
String gunId = pileNo.concat(String.format("%02d", i));
ConnectorInfo connectorInfo = new ConnectorInfo();
ConnectorStatusInfo connectorInfo = new ConnectorStatusInfo();
connectorInfo.setConnectorID(gunId);
connectorInfo.setConnectorType((Integer) cachePile.get("connectorType"));
connectorInfo.setVoltageUpperLimits((Integer) cachePile.get("voltageUpperLimits"));
connectorInfo.setVoltageLowerLimits((Integer) cachePile.get("voltageLowerLimits"));
connectorInfo.setCurrent((Integer) cachePile.get("current"));
connectorInfo.setPower((Double) cachePile.get("power"));
connectorInfo.setNationalStandard((Integer) cachePile.get("nationalStandard"));
connectorInfos.add(connectorInfo);
Integer statusInt = REDIS.getCacheMapValue("gun:".concat(gunId), "statusInt");
connectorInfo.setStatus(statusInt == null ? 0 : statusInt);
// connectorInfo.setConnectorType((Integer) cachePile.get("connectorType"));
// connectorInfo.setVoltageUpperLimits((Integer) cachePile.get("voltageUpperLimits"));
// connectorInfo.setVoltageLowerLimits((Integer) cachePile.get("voltageLowerLimits"));
// connectorInfo.setCurrent((Integer) cachePile.get("current"));
// connectorInfo.setPower((Double) cachePile.get("power"));
// connectorInfo.setNationalStandard((Integer) cachePile.get("nationalStandard"));
connectorStatusInfoList.add(connectorInfo);
}
return connectorInfos;
return connectorStatusInfoList;
}
}

View File

@ -180,7 +180,7 @@ public class HexUtils {
public static void main(String[] args) {
// System.out.println(Integer.parseInt("FF00", 16));
System.out.println(Long.valueOf(10L).toString());
// System.out.println(reverseHexInt("FF00"));
// byte[] data1 = toBytes(reverseHex("10270000"));
// System.out.println(toInteger(data1, 0, 4));

View File

@ -21,7 +21,7 @@ public class TestController {
@GetMapping("test/{pno}/{ono}/{b}/{gid}")
public R test(@PathVariable String pno, @PathVariable String ono, @PathVariable int b, @PathVariable String gid) throws NacosException {
// String serverIp = "172.31.183.135";
// String serverIp = "127.0.0.1";
// int serverPort = 8848;
// String serverAddr = serverIp + ":" + serverPort;
// NamingService namingService = NacosFactory.createNamingService(serverAddr);