防止错误数据导致返回格式错误

This commit is contained in:
ZZ 2021-11-18 13:55:21 +08:00
parent 92d04c76f9
commit dd2cf17eb2
2 changed files with 5 additions and 1 deletions

View File

@ -118,7 +118,7 @@ public class QueryEquipChargeStatusController {
equipChargeStatus.setTotalMoney(lord.getAmountCharged() == null ? 0 : lord.getAmountCharged() / 10000.0); equipChargeStatus.setTotalMoney(lord.getAmountCharged() == null ? 0 : lord.getAmountCharged() / 10000.0);
final Long rateModelId = REDIS.getCacheMapValue("pile:".concat(connectorId.substring(0, 14)), "rateModelId"); final Long rateModelId = REDIS.getCacheMapValue("pile:".concat(connectorId.substring(0, 14)), "rateModelId");
final CacheRateModel cacheRateModel = REDIS.getCacheObject("rateModel:" + rateModelId); final CacheRateModel cacheRateModel = REDIS.getCacheObject("rateModel:" + rateModelId);
if (cacheRateModel != null) calculateEm(equipChargeStatus, cacheRateModel); calculateEm(equipChargeStatus, cacheRateModel);
CommonResponse response = new CommonResponse(); CommonResponse response = new CommonResponse();
response.setRet(EvcsConst.RET_SUCC); response.setRet(EvcsConst.RET_SUCC);
response.setData(JSONUtil.toJSONString(equipChargeStatus)); response.setData(JSONUtil.toJSONString(equipChargeStatus));

View File

@ -95,6 +95,10 @@ public class NotificationEquipChargeStatusTask extends CoreDispatcher {
public static void calculateEm(EquipChargeStatus equipChargeStatus, CacheRateModel cacheRateModel) { public static void calculateEm(EquipChargeStatus equipChargeStatus, CacheRateModel cacheRateModel) {
if (cacheRateModel != null) {
equipChargeStatus.setChargeDetails(new ChargeDetails[0]);
return;
}
final Date endTime = DateUtil.string2Date(equipChargeStatus.getEndTime()); final Date endTime = DateUtil.string2Date(equipChargeStatus.getEndTime());
final Date startTime = DateUtil.string2Date(equipChargeStatus.getStartTime()); final Date startTime = DateUtil.string2Date(equipChargeStatus.getStartTime());
long totalMilSec = endTime.getTime() - startTime.getTime(); long totalMilSec = endTime.getTime() - startTime.getTime();