|
@@ -3,6 +3,7 @@ package com.project.zcustom.service.smart.impl;
|
|
|
import com.alibaba.fastjson2.JSONArray;
|
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
|
import com.project.common.utils.StringUtils;
|
|
|
+import com.project.zcustom.domain.addional.LargeBuildingControl;
|
|
|
import com.project.zcustom.mapper.unit.PlatBuildingMapper;
|
|
|
import com.project.zcustom.service.smart.IPlatBuildingService;
|
|
|
import com.project.zcustom.service.smart.IPlatGreenFoodsService;
|
|
@@ -284,4 +285,129 @@ public class PlatBuildingServiceImpl implements IPlatBuildingService {
|
|
|
}
|
|
|
return resultList;
|
|
|
}
|
|
|
+
|
|
|
+ public int updateAirNum(Long num){
|
|
|
+ if (platBuildingMapper.getExist() > 0){
|
|
|
+ platBuildingMapper.updateAirNum(num);
|
|
|
+ }
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ public Map<String, Object> getThisWeekElectricity(){
|
|
|
+ LargeBuildingControl largeBuildingControl = platBuildingMapper.getThisWeekElectricity();
|
|
|
+ JSONArray weekElectricity = JSONArray.parseArray(largeBuildingControl.getWeekElectricity());
|
|
|
+ JSONArray roomElectricity = JSONArray.parseArray(largeBuildingControl.getRoomElectricity());
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ List<String> weeklist = new ArrayList<>();
|
|
|
+ List<String> roomlist = new ArrayList<>();
|
|
|
+ for (int i = 0; i < weekElectricity.size(); i++) {
|
|
|
+ JSONObject item = weekElectricity.getJSONObject(i);
|
|
|
+ weeklist.add(item.getString("num"));
|
|
|
+ }
|
|
|
+ for (int i = 0; i < roomElectricity.size(); i++) {
|
|
|
+ JSONObject item = roomElectricity.getJSONObject(i);
|
|
|
+ roomlist.add(item.getString("num"));
|
|
|
+ }
|
|
|
+ map.put("total", weeklist);
|
|
|
+ map.put("room", roomlist);
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ public List<Map<String, Object>> getTodayElectricity(){
|
|
|
+ String json = platBuildingMapper.getTodayElectricity();
|
|
|
+ JSONArray jsonArray = JSONArray.parseArray(json);
|
|
|
+ return repeatElectricity(jsonArray);
|
|
|
+ }
|
|
|
+
|
|
|
+ public Map<String, Object> getMonthElectricity(){
|
|
|
+ LargeBuildingControl largeBuildingControl = platBuildingMapper.getMonthElectricity();
|
|
|
+ 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("一号配电室", a);
|
|
|
+ map.put("二号配电室", b);
|
|
|
+ map.put("三号配电室", c);
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ public Map<String, Object> getRoomLoad(){
|
|
|
+ LargeBuildingControl largeBuildingControl = platBuildingMapper.getRoomLoad();
|
|
|
+ JSONArray x = JSONArray.parseArray(largeBuildingControl.getRoomLoadOne());
|
|
|
+ JSONArray y = JSONArray.parseArray(largeBuildingControl.getRoomLoadTwo());
|
|
|
+ JSONArray z = JSONArray.parseArray(largeBuildingControl.getRoomLoadThree());
|
|
|
+ List<Map<String, Object>> a = repeatLoad(x);
|
|
|
+ List<Map<String, Object>> b = repeatLoad(y);
|
|
|
+ List<Map<String, Object>> c = repeatLoad(z);
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ map.put("一号配电室", a);
|
|
|
+ map.put("二号配电室", b);
|
|
|
+ map.put("三号配电室", c);
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ public Map<String, Object> getWarnDevice(){
|
|
|
+ LargeBuildingControl largeBuildingControl = platBuildingMapper.getWarnDevice();
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(largeBuildingControl.getWarnDevice());
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ JSONObject water = jsonObject.getJSONObject("水浸");
|
|
|
+ water.put("正常点位", largeBuildingControl.getWaterControlNormalNum() + largeBuildingControl.getWaterDeviceAirNum());
|
|
|
+ water.put("air", largeBuildingControl.getWaterDeviceAirNum());
|
|
|
+ water.put("control", largeBuildingControl.getWaterControlNormalNum() + largeBuildingControl.getWaterControlAbnormalNum());
|
|
|
+ map.put("电表", repeatWarnDevice(jsonObject.getJSONObject("电表")));
|
|
|
+ map.put("液位计", repeatWarnDevice(jsonObject.getJSONObject("液位计")));
|
|
|
+ map.put("水浸", repeatWarnDevice(water));
|
|
|
+ map.put("烟雾", repeatWarnDevice(jsonObject.getJSONObject("烟雾")));
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ public Map<String, Object> getWarnEvent(){
|
|
|
+ String json = platBuildingMapper.getWarnEvent();
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(json);
|
|
|
+ return jsonObject;
|
|
|
+ }
|
|
|
+
|
|
|
+ public Map<String, Object> getWarnState(){
|
|
|
+ LargeBuildingControl largeBuildingControl = platBuildingMapper.getWarnState();
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ map.put("23F", largeBuildingControl.getWaterStateOne());
|
|
|
+ map.put("-2F", largeBuildingControl.getWaterStateTwo());
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private JSONObject repeatWarnDevice(JSONObject jsonObject){
|
|
|
+ jsonObject.put("total", Long.valueOf(jsonObject.getString("正常点位")) + Long.valueOf(jsonObject.getString("异常点位")));
|
|
|
+ return jsonObject;
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<Map<String, Object>> repeatLoad(JSONArray jsonArray){
|
|
|
+ List<Map<String, Object>> list = new ArrayList<>();
|
|
|
+ for (int i = 0; i < jsonArray.size(); i++) {
|
|
|
+ JSONObject item = jsonArray.getJSONObject(i);
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ map.put("空载", item.getString("空载"));
|
|
|
+ map.put("轻载", item.getString("轻载"));
|
|
|
+ map.put("正常", item.getString("正常"));
|
|
|
+ map.put("重载", item.getString("重载"));
|
|
|
+ map.put("过载", item.getString("过载"));
|
|
|
+ list.add(map);
|
|
|
+ }
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<Map<String, Object>> repeatElectricity(JSONArray jsonArray){
|
|
|
+ List<Map<String, Object>> list = new ArrayList<>();
|
|
|
+ for (int i = 0; i < jsonArray.size(); i++) {
|
|
|
+ JSONObject item = jsonArray.getJSONObject(i);
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ map.put("time", item.getString("time"));
|
|
|
+ map.put("Kwh", item.getString("Kwh"));
|
|
|
+ list.add(map);
|
|
|
+ }
|
|
|
+ return list;
|
|
|
+ }
|
|
|
}
|