多了一个NPE空指针异常判断,少了几行代码

This commit is contained in:
ZZ 2021-10-29 11:23:14 +08:00
parent 8d0f60bfbc
commit 38174984b1

View File

@ -31,26 +31,18 @@ public class QueryEquipBusinessPolicyController {
EquipBizRequest equipBizRequest = JSONUtil.readParams(commonRequest.getData(), EquipBizRequest.class);
String connectorId = equipBizRequest.getConnectorId();
//获取枪所对应的桩编码
String bySerialNumber = xhpcTerminalRepository.selectBySql(connectorId);
String pileSerialNumber = bySerialNumber;
//找不到对应的桩编码说明充电设备接口编码有误
if (pileSerialNumber == null) {
String pileSerialNumber = xhpcTerminalRepository.selectBySql(connectorId);
Map<String, Object> cachePile = REDIS.getCacheMap("pile:" + pileSerialNumber);
if (pileSerialNumber == null || cachePile == null) {
CommonResponse commonResponse = new CommonResponse();
commonResponse.setMsg("error connectorId");
commonResponse.setMsg("ConnectorID not found");
commonResponse.setRet("1");
commonResponse.setData(null);
return commonResponse;
}
//通过桩编码进入redis找到其所用的费率模型id
Map<String, Object> cacheMap = REDIS.getCacheMap("pile:" + pileSerialNumber);
Long rateModelId = (Long) cacheMap.get("rateModelId");
//通过指定费率模型id找到其对应的费率模型
Long rateModelId = (Long) cachePile.get("rateModelId");
CacheRateModel rateModel = REDIS.getCacheObject("rateModel:" + rateModelId);
String[] tfPricesSeq = rateModel.getTfPricesSeq();
//遍历获取每一个时段
//存储时段
ArrayList<String> modelTypes = new ArrayList<>();
//存储时段个数
@ -61,6 +53,7 @@ public class QueryEquipBusinessPolicyController {
int count = 0;
//最后一个时段的前一个时段的下标索引
int index = 0;
//遍历获取每一个时段
for (int i = 0; i < tfPricesSeq.length - 1; i++) {
count++;
//如果当前时段与后面的时段不相同则表示当前时段已经结束添加当前时段到list中,并将其坐标存放到另一个集合中