避免第三方查询未启动的订单报错
This commit is contained in:
parent
0cb71ab537
commit
338ebbaebb
@ -53,83 +53,88 @@ public class QueryEquipChargeStatusController {
|
|||||||
}
|
}
|
||||||
String internalOrderNum = etOrderMapping.getXhOrderNo();
|
String internalOrderNum = etOrderMapping.getXhOrderNo();
|
||||||
Map<String, Object> cacheOrder = REDIS.getCacheMap("order:" + internalOrderNum);
|
Map<String, Object> cacheOrder = REDIS.getCacheMap("order:" + internalOrderNum);
|
||||||
String orderStatus = (String) cacheOrder.get("status");
|
if (cacheOrder == null) {
|
||||||
int startChargeSeqStat = 0;
|
response.setRet(EvcsConst.RET_FAIL);
|
||||||
if (orderStatus == null) {
|
response.setMsg("Order cache data not found");
|
||||||
startChargeSeqStat = 5;
|
|
||||||
} else switch (orderStatus) {
|
|
||||||
case "启动中":
|
|
||||||
startChargeSeqStat = 1;
|
|
||||||
break;
|
|
||||||
case "充电中":
|
|
||||||
startChargeSeqStat = 2;
|
|
||||||
break;
|
|
||||||
case "停止中":
|
|
||||||
startChargeSeqStat = 3;
|
|
||||||
break;
|
|
||||||
case "已结束":
|
|
||||||
startChargeSeqStat = 4;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
startChargeSeqStat = 5;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
equipChargeStatus.setStartChargeSeqStat(startChargeSeqStat);
|
|
||||||
//充电设备接口编码
|
|
||||||
String connectorId = internalOrderNum.substring(0, 16);
|
|
||||||
equipChargeStatus.setConnectorID(connectorId);
|
|
||||||
//充电设备接口状态
|
|
||||||
Map<String, Object> cacheGunData = REDIS.getCacheMap("gun:" + connectorId);
|
|
||||||
String gunStatus = (String) cacheGunData.get("status");
|
|
||||||
int connectorStatus = 0;
|
|
||||||
switch (gunStatus) {
|
|
||||||
case "空闲":
|
|
||||||
connectorStatus = 1;
|
|
||||||
break;
|
|
||||||
case "离线":
|
|
||||||
connectorStatus = 2;
|
|
||||||
break;
|
|
||||||
case "故障":
|
|
||||||
connectorStatus = 255;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
connectorStatus = 3;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
equipChargeStatus.setConnectorStatus(connectorStatus);
|
|
||||||
//A相电流
|
|
||||||
Double current = (Double) cacheGunData.get("current");
|
|
||||||
equipChargeStatus.setCurrentA(current);
|
|
||||||
//A相电压
|
|
||||||
Double voltage = (Double) cacheGunData.get("voltage");
|
|
||||||
equipChargeStatus.setVoltageA(voltage);
|
|
||||||
//电池剩余电量
|
|
||||||
Integer endSoc = (Integer) cacheOrder.get("endSoc");
|
|
||||||
Double soc = Double.valueOf(endSoc == null ? 0 : endSoc);
|
|
||||||
equipChargeStatus.setSoc(soc);
|
|
||||||
//开始充电时间
|
|
||||||
String startTime = (String) cacheOrder.get("startTime");
|
|
||||||
if (startTime == null) startTime = orderNo2DateStr(internalOrderNum);
|
|
||||||
equipChargeStatus.setStartTime(startTime);
|
|
||||||
//本次采样时间 直接new一个当前时间的Date就可以了
|
|
||||||
CacheRealtimeData lord = REDIS.getCacheObject("order:" + internalOrderNum + ".lord");
|
|
||||||
if (lord != null) {
|
|
||||||
equipChargeStatus.setEndTime(lord.getCreateTime());
|
|
||||||
equipChargeStatus.setTotalMoney(lord.getAmountCharged() / 10000.0);
|
|
||||||
equipChargeStatus.setTotalPower(lord.getChargingDegree() / 10000.0);
|
|
||||||
} else {
|
} else {
|
||||||
equipChargeStatus.setEndTime(equipChargeStatus.getStartTime());
|
String orderStatus = (String) cacheOrder.get("status");
|
||||||
equipChargeStatus.setTotalMoney(0.0);
|
int startChargeSeqStat;
|
||||||
equipChargeStatus.setTotalPower(0.0);
|
if (orderStatus == null) {
|
||||||
|
startChargeSeqStat = 5;
|
||||||
|
} else switch (orderStatus) {
|
||||||
|
case "启动中":
|
||||||
|
startChargeSeqStat = 1;
|
||||||
|
break;
|
||||||
|
case "充电中":
|
||||||
|
startChargeSeqStat = 2;
|
||||||
|
break;
|
||||||
|
case "停止中":
|
||||||
|
startChargeSeqStat = 3;
|
||||||
|
break;
|
||||||
|
case "已结束":
|
||||||
|
startChargeSeqStat = 4;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
startChargeSeqStat = 5;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
equipChargeStatus.setStartChargeSeqStat(startChargeSeqStat);
|
||||||
|
//充电设备接口编码
|
||||||
|
String connectorId = internalOrderNum.substring(0, 16);
|
||||||
|
equipChargeStatus.setConnectorID(connectorId);
|
||||||
|
//充电设备接口状态
|
||||||
|
Map<String, Object> cacheGunData = REDIS.getCacheMap("gun:" + connectorId);
|
||||||
|
String gunStatus = (String) cacheGunData.get("status");
|
||||||
|
int connectorStatus = 0;
|
||||||
|
switch (gunStatus) {
|
||||||
|
case "空闲":
|
||||||
|
connectorStatus = 1;
|
||||||
|
break;
|
||||||
|
case "离线":
|
||||||
|
connectorStatus = 2;
|
||||||
|
break;
|
||||||
|
case "故障":
|
||||||
|
connectorStatus = 255;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
connectorStatus = 3;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
equipChargeStatus.setConnectorStatus(connectorStatus);
|
||||||
|
//A相电流
|
||||||
|
Double current = (Double) cacheGunData.get("current");
|
||||||
|
equipChargeStatus.setCurrentA(current);
|
||||||
|
//A相电压
|
||||||
|
Double voltage = (Double) cacheGunData.get("voltage");
|
||||||
|
equipChargeStatus.setVoltageA(voltage);
|
||||||
|
//电池剩余电量
|
||||||
|
Integer endSoc = (Integer) cacheOrder.get("endSoc");
|
||||||
|
Double soc = Double.valueOf(endSoc == null ? 0 : endSoc);
|
||||||
|
equipChargeStatus.setSoc(soc);
|
||||||
|
//开始充电时间
|
||||||
|
String startTime = (String) cacheOrder.get("startTime");
|
||||||
|
if (startTime == null) startTime = orderNo2DateStr(internalOrderNum);
|
||||||
|
equipChargeStatus.setStartTime(startTime);
|
||||||
|
//本次采样时间 直接new一个当前时间的Date就可以了
|
||||||
|
CacheRealtimeData lord = REDIS.getCacheObject("order:" + internalOrderNum + ".lord");
|
||||||
|
if (lord != null) {
|
||||||
|
equipChargeStatus.setEndTime(lord.getCreateTime());
|
||||||
|
equipChargeStatus.setTotalMoney(lord.getAmountCharged() / 10000.0);
|
||||||
|
equipChargeStatus.setTotalPower(lord.getChargingDegree() / 10000.0);
|
||||||
|
} else {
|
||||||
|
equipChargeStatus.setEndTime(equipChargeStatus.getStartTime());
|
||||||
|
equipChargeStatus.setTotalMoney(0.0);
|
||||||
|
equipChargeStatus.setTotalPower(0.0);
|
||||||
|
}
|
||||||
|
Integer chargeModel = (Integer) cacheOrder.get("chargeModel");
|
||||||
|
equipChargeStatus.setChargeModel(chargeModel == null ? 0 : chargeModel);
|
||||||
|
final Long rateModelId = REDIS.getCacheMapValue("pile:".concat(connectorId.substring(0, 14)), "rateModelId");
|
||||||
|
final CacheRateModel cacheRateModel = REDIS.getCacheObject("rateModel:" + rateModelId);
|
||||||
|
calculateEm(equipChargeStatus, cacheRateModel);
|
||||||
|
response.setRet(EvcsConst.RET_SUCC);
|
||||||
|
response.setData(JSONUtil.toJSONString(equipChargeStatus));
|
||||||
|
response.setMsg("success");
|
||||||
}
|
}
|
||||||
Integer chargeModel = (Integer) cacheOrder.get("chargeModel");
|
|
||||||
equipChargeStatus.setChargeModel(chargeModel == null ? 0 : chargeModel);
|
|
||||||
final Long rateModelId = REDIS.getCacheMapValue("pile:".concat(connectorId.substring(0, 14)), "rateModelId");
|
|
||||||
final CacheRateModel cacheRateModel = REDIS.getCacheObject("rateModel:" + rateModelId);
|
|
||||||
calculateEm(equipChargeStatus, cacheRateModel);
|
|
||||||
response.setRet(EvcsConst.RET_SUCC);
|
|
||||||
response.setData(JSONUtil.toJSONString(equipChargeStatus));
|
|
||||||
response.setMsg("success");
|
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user