|
@@ -13,10 +13,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.*;
|
|
|
|
|
|
@Service
|
|
|
public class PlatBuildingServiceImpl implements IPlatBuildingService {
|
|
@@ -303,10 +300,16 @@ public class PlatBuildingServiceImpl implements IPlatBuildingService {
|
|
|
}
|
|
|
|
|
|
public Map<String, Object> getThisWeekElectricity(){
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
LargeBuildingControl largeBuildingControl = platBuildingMapper.getThisWeekElectricity();
|
|
|
+ if (Objects.isNull(largeBuildingControl)) {
|
|
|
+ JSONArray array = new JSONArray();
|
|
|
+ map.put("total", array);
|
|
|
+ map.put("room", array);
|
|
|
+ return map;
|
|
|
+ }
|
|
|
JSONArray weekElectricity = JSONArray.parseArray(largeBuildingControl.getWeekElectricity());
|
|
|
JSONArray roomElectricity = JSONArray.parseArray(largeBuildingControl.getRoomElectricity());
|
|
|
- Map<String, Object> map = new HashMap<>();
|
|
|
map.put("total", weekElectricity);
|
|
|
map.put("room", roomElectricity);
|
|
|
return map;
|
|
@@ -327,19 +330,30 @@ public class PlatBuildingServiceImpl implements IPlatBuildingService {
|
|
|
|
|
|
public List<Map<String, Object>> getTodayElectricity(){
|
|
|
String json = platBuildingMapper.getTodayElectricity();
|
|
|
+ if (StringUtils.isBlank(json)) {
|
|
|
+ return new ArrayList<>();
|
|
|
+ }
|
|
|
JSONArray jsonArray = JSONArray.parseArray(json);
|
|
|
return repeatElectricity(jsonArray);
|
|
|
}
|
|
|
|
|
|
public Map<String, Object> getMonthElectricity(){
|
|
|
LargeBuildingControl largeBuildingControl = platBuildingMapper.getMonthElectricity();
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ if (Objects.isNull(largeBuildingControl)) {
|
|
|
+ List<Map<String, Object>> list = new ArrayList<>();
|
|
|
+ map.put("first", list);
|
|
|
+ map.put("second", list);
|
|
|
+ map.put("third", list);
|
|
|
+ return map;
|
|
|
+ }
|
|
|
JSONArray x = JSONArray.parseArray(largeBuildingControl.getMonthElectricityOne());
|
|
|
JSONArray y = JSONArray.parseArray(largeBuildingControl.getMonthElectricityTwo());
|
|
|
JSONArray z = JSONArray.parseArray(largeBuildingControl.getMonthElectricityThree());
|
|
|
List<Map<String, Object>> a = repeatElectricity(x);
|
|
|
List<Map<String, Object>> b = repeatElectricity(y);
|
|
|
List<Map<String, Object>> c = repeatElectricity(z);
|
|
|
- Map<String, Object> map = new HashMap<>();
|
|
|
+
|
|
|
map.put("first", a);
|
|
|
map.put("second", b);
|
|
|
map.put("third", c);
|
|
@@ -348,6 +362,14 @@ public class PlatBuildingServiceImpl implements IPlatBuildingService {
|
|
|
|
|
|
public Map<String, Object> getRoomLoad(){
|
|
|
LargeBuildingControl largeBuildingControl = platBuildingMapper.getRoomLoad();
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ if (Objects.isNull(largeBuildingControl)) {
|
|
|
+ List<Integer> list = new ArrayList<>();
|
|
|
+ map.put("first", list);
|
|
|
+ map.put("second", list);
|
|
|
+ map.put("third", list);
|
|
|
+ return map;
|
|
|
+ }
|
|
|
JSONArray x = JSONArray.parseArray(largeBuildingControl.getRoomLoadOne());
|
|
|
JSONArray y = JSONArray.parseArray(largeBuildingControl.getRoomLoadTwo());
|
|
|
JSONArray z = JSONArray.parseArray(largeBuildingControl.getRoomLoadThree());
|
|
@@ -369,7 +391,6 @@ public class PlatBuildingServiceImpl implements IPlatBuildingService {
|
|
|
Integer value = (Integer) jsonObject.values().iterator().next(); // 获取第一个值(每个 JSON 对象只有一个键值对)
|
|
|
c.add(value);
|
|
|
}
|
|
|
- Map<String, Object> map = new HashMap<>();
|
|
|
map.put("first", a);
|
|
|
map.put("second", b);
|
|
|
map.put("third", c);
|
|
@@ -378,8 +399,17 @@ public class PlatBuildingServiceImpl implements IPlatBuildingService {
|
|
|
|
|
|
public Map<String, Object> getWarnDevice(){
|
|
|
LargeBuildingControl largeBuildingControl = platBuildingMapper.getWarnDevice();
|
|
|
- JSONObject jsonObject = JSONObject.parseObject(largeBuildingControl.getWarnDevice());
|
|
|
+
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
+ if (Objects.isNull(largeBuildingControl)) {
|
|
|
+ JSONObject db = new JSONObject();
|
|
|
+ map.put("db", db);
|
|
|
+ map.put("ywj", db);
|
|
|
+ map.put("sj", db);
|
|
|
+ map.put("yw", db);
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(largeBuildingControl.getWarnDevice());
|
|
|
JSONObject water = jsonObject.getJSONObject("sj");
|
|
|
water.put("zcdw", largeBuildingControl.getWaterControlNormalNum() + largeBuildingControl.getWaterDeviceAirNum());
|
|
|
water.put("air", largeBuildingControl.getWaterDeviceAirNum());
|
|
@@ -393,6 +423,9 @@ public class PlatBuildingServiceImpl implements IPlatBuildingService {
|
|
|
|
|
|
public JSONArray getAbnormalPoint(String type){
|
|
|
LargeBuildingControl largeBuildingControl = platBuildingMapper.getAbnormalPoint();
|
|
|
+ if (Objects.isNull(largeBuildingControl)) {
|
|
|
+ return new JSONArray();
|
|
|
+ }
|
|
|
switch (type){
|
|
|
case "1":
|
|
|
return JSONArray.parseArray(largeBuildingControl.getAbnormalPointOne());
|
|
@@ -415,6 +448,12 @@ public class PlatBuildingServiceImpl implements IPlatBuildingService {
|
|
|
public Map<String, Object> getWarnState(){
|
|
|
LargeBuildingControl largeBuildingControl = platBuildingMapper.getWarnState();
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
+ if (Objects.isNull(largeBuildingControl)) {
|
|
|
+ List<Map<String, Object>> list = new ArrayList<>();
|
|
|
+ map.put("twentyThree", list);
|
|
|
+ map.put("minusTwo", list);
|
|
|
+ return map;
|
|
|
+ }
|
|
|
map.put("twentyThree", JSONObject.parseObject(largeBuildingControl.getWaterStateOne()));
|
|
|
map.put("minusTwo", JSONObject.parseObject(largeBuildingControl.getWaterStateTwo()));
|
|
|
return map;
|
|
@@ -422,6 +461,9 @@ public class PlatBuildingServiceImpl implements IPlatBuildingService {
|
|
|
|
|
|
|
|
|
private JSONObject repeatWarnDevice(JSONObject jsonObject){
|
|
|
+ if (Objects.isNull(jsonObject)) {
|
|
|
+ return new JSONObject();
|
|
|
+ }
|
|
|
Long x = Long.parseLong(jsonObject.getString("zcdw")) + Long.parseLong(jsonObject.getString("ycdw"));
|
|
|
jsonObject.put("total", x);
|
|
|
return jsonObject;
|