|
@@ -17,6 +17,7 @@ import com.ebei.screen.common.util.LeviUtils;
|
|
|
import com.ebei.screen.common.util.ScheduledUtils;
|
|
|
import com.ebei.screen.service.EbaSystemService;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.data.mongodb.core.MongoTemplate;
|
|
@@ -370,7 +371,20 @@ public class EbaSystemServiceImpl implements EbaSystemService {
|
|
|
@Override
|
|
|
public ResponseBean getDeviceList(String projectId) {
|
|
|
JSONObject obj = mongoTemplate.findById("mobjectList", JSONObject.class, "ebaAuth");
|
|
|
- JSONArray array = obj.getJSONObject("data").getJSONArray(projectId);
|
|
|
+ JSONArray array = new JSONArray();
|
|
|
+ if (StringUtils.isNotBlank(projectId)) {
|
|
|
+ projectId = EbaUtils.getProjectId(projectId);
|
|
|
+ array = obj.getJSONObject("data").getJSONArray(projectId);
|
|
|
+ } else {
|
|
|
+ JSONObject obj2 = mongoTemplate.findById("relevanceProject", JSONObject.class, "relevanceProject");
|
|
|
+ JSONObject data = obj2 != null ? obj2.getJSONObject("data") : new JSONObject();
|
|
|
+ List<String> collect = data.values().stream().map(x -> (String) x).distinct().collect(Collectors.toList());
|
|
|
+ if (data != null) {
|
|
|
+ for (String p : collect) {
|
|
|
+ array.addAll(obj.getJSONObject("data").getJSONArray(p));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
if (array == null || array.size() <= 0) {
|
|
|
return ResponseBuilder.ok(Levi.by("electricity", new JSONArray()).set("water", new JSONArray()));
|
|
|
}
|
|
@@ -393,6 +407,7 @@ public class EbaSystemServiceImpl implements EbaSystemService {
|
|
|
*/
|
|
|
@Override
|
|
|
public ResponseBean getRealTimeList(String projectId) {
|
|
|
+ boolean flag = StringUtils.isNotBlank(projectId);
|
|
|
LocalDateTime now = LocalDateTime.now();
|
|
|
int year = now.getYear();
|
|
|
int month = now.getMonthValue();
|
|
@@ -417,7 +432,15 @@ public class EbaSystemServiceImpl implements EbaSystemService {
|
|
|
Integer alarmType = (Integer) y.get("AlarmType");
|
|
|
Integer pid = (Integer) y.get("ProjectId");
|
|
|
y.put("AlarmTimeStr", LeviUtils.convertTime(y.get("AlarmTime")));
|
|
|
- if ((pid.toString()).equals(projectId)) {
|
|
|
+ if (flag) {
|
|
|
+ if ((pid.toString()).equals(projectId)) {
|
|
|
+ if (alarmType == 1) {
|
|
|
+ huojing.add(y);
|
|
|
+ } else if (alarmType == 2) {
|
|
|
+ guzhang.add(y);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
if (alarmType == 1) {
|
|
|
huojing.add(y);
|
|
|
} else if (alarmType == 2) {
|