opt:优化空指针提示和判断

This commit is contained in:
DESKTOP-5DIJMF9\admin
2025-03-07 10:14:41 +08:00
parent 565a612f6d
commit 67711c0be9

View File

@@ -142,8 +142,12 @@ public class BakingServiceImpl implements BakingService {
for (int i = 0; i < hot_rows.size(); i++) {
JSONObject hot_row = hot_rows.getJSONObject(i);
String point_code = hot_row.getString("point_code");
String point_temperature = (String) redisUtils.hget(point_code, "temperature");
if (!ObjectUtil.isEmpty(point_temperature)) {
boolean exists = redisUtils.hHasKey(point_code, "temperature");
String point_temperature = "";
if(exists){
point_temperature = (String) redisUtils.hget(point_code, "temperature");
}
if (ObjectUtil.isNotEmpty(point_temperature)) {
if (point_temperature.equals(temperature)) {
jsonHotIvt = hot_row;
break;
@@ -159,8 +163,12 @@ public class BakingServiceImpl implements BakingService {
for (int i = 0; i < hot_rows.size(); i++) {
JSONObject hot_row = hot_rows.getJSONObject(i);
String point_code = hot_row.getString("point_code");
String point_temperature = (String) redisUtils.hget(point_code, "temperature");
if (!ObjectUtil.isEmpty(point_temperature)) {
boolean exists = redisUtils.hHasKey(point_code, "temperature");
String point_temperature = "";
if(exists){
point_temperature = (String) redisUtils.hget(point_code, "temperature");
}
if (ObjectUtil.isNotEmpty(point_temperature)) {
if (point_temperature.equals(temperature)) {
jsonHotIvt = hot_row;
break;
@@ -427,8 +435,15 @@ public class BakingServiceImpl implements BakingService {
hotParam.put("task_id", task_id);
hotParam.put("start_point_code", point_code1);
hotParam.put("end_point_code", cache_jo.getString("point_code"));
String point_temperature = (String) redisUtils.hget(point_code1, "temperature");
boolean exists = redisUtils.hHasKey(point_code1, "temperature");
String point_temperature = "";
if(exists){
point_temperature = (String) redisUtils.hget(point_code1, "temperature");
}else{
throw new BadRequestException("当前操作点位设备:"+point_code1+",无法获取温度,请稍后再试!");
}
hotParam.put("temperature", point_temperature);
if (ObjectUtil.isEmpty(last_hot_mst)) {
hotParam.put("oven_time", "480");
} else {
@@ -544,6 +559,9 @@ public class BakingServiceImpl implements BakingService {
}
public JSONObject getJsonObject(String product_area, JSONObject point_code2_jo, String temperature) {
if (ObjectUtil.isEmpty(point_code2_jo)) {
throw new BadRequestException("暂无可用烘箱对接位!");
}
JSONObject jsonMap = new JSONObject();
jsonMap.put("flag", "1");
jsonMap.put("product_area", product_area);
@@ -553,8 +571,12 @@ public class BakingServiceImpl implements BakingService {
for (int i = 0; i < hot_rows.size(); i++) {
JSONObject hot_row = hot_rows.getJSONObject(i);
String point_code = hot_row.getString("point_code");
String point_temperature = (String) redisUtils.hget(point_code, "temperature");
if (!ObjectUtil.isEmpty(point_temperature)) {
boolean exists = redisUtils.hHasKey(point_code, "temperature");
String point_temperature = "";
if(exists){
point_temperature = (String) redisUtils.hget(point_code, "temperature");
}
if (ObjectUtil.isNotEmpty(point_temperature)) {
if (point_temperature.equals(temperature)) {
jsonHotIvt = hot_row;
break;