|
@@ -17,6 +17,7 @@ import com.ebei.screen.common.util.EbaUtils;
|
|
|
import com.ebei.screen.common.util.Levi;
|
|
|
import com.ebei.screen.common.util.LeviUtils;
|
|
|
import com.ebei.screen.common.util.ScheduledUtils;
|
|
|
+import com.ebei.screen.modules.req.RealTimeReq;
|
|
|
import com.ebei.screen.service.EbaSystemService;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
@@ -569,5 +570,77 @@ public class EbaSystemServiceImpl implements EbaSystemService {
|
|
|
return ResponseBuilder.ok("删除成功");
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+ /**
|
|
|
+ * 分页查询火警和故障信息
|
|
|
+ *
|
|
|
+ * @param params
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public ResponseBean getRealTimeListByPage(RealTimeReq params) {
|
|
|
+ String projectId = params.getProjectId();
|
|
|
+ boolean flag = StringUtils.isNotBlank(projectId);
|
|
|
+ Integer pageNum = params.getPageNum();
|
|
|
+ Integer pageSize = params.getPageSize();
|
|
|
+ Integer dateType = params.getDateType();
|
|
|
+ Integer type = params.getType();
|
|
|
+ LocalDateTime now = LocalDateTime.now();
|
|
|
+ int year = now.getYear();
|
|
|
+ int month = now.getMonthValue();
|
|
|
+ int day = now.getDayOfMonth();
|
|
|
+ Map monthMap = mongoTemplate.findById(EbaMessageCode.D.getCode() + "_" + year + "_" + month, Map.class, "realTimeList");
|
|
|
+ if (MapUtil.isEmpty(monthMap)) {
|
|
|
+ return ResponseBuilder.ok("暂无实时火警和预警信息");
|
|
|
+ }
|
|
|
+ List<Map> dayList = (List<Map>) monthMap.get("data");
|
|
|
+ // 抽取AlarmType:1火警、2故障
|
|
|
+ List<Map> huojing = new ArrayList<>();
|
|
|
+ List<Map> guzhang = new ArrayList<>();
|
|
|
+ // 查询一天 则替换集合元素为当日
|
|
|
+ if (dateType == 0) {
|
|
|
+ dayList = Arrays.asList(dayList.get(day - 1));
|
|
|
+ }
|
|
|
+ dayList.forEach(dayMap -> {
|
|
|
+ List<Map> hourList = (List<Map>) dayMap.get("data");
|
|
|
+ List<Map> filterList = hourList.stream().filter(x -> {
|
|
|
+ List<Map> dataList = (List<Map>) x.get("data");
|
|
|
+ return dataList.size() > 0;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ filterList.forEach(x -> {
|
|
|
+ List<Map> dataList = (List<Map>) x.get("data");
|
|
|
+ dataList.forEach(y -> {
|
|
|
+ Integer alarmType = (Integer) y.get("AlarmType");
|
|
|
+ Integer pid = (Integer) y.get("ProjectId");
|
|
|
+ y.put("AlarmTimeStr", LeviUtils.convertTime(y.get("AlarmTime")));
|
|
|
+ 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) {
|
|
|
+ guzhang.add(y);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+ });
|
|
|
+ // 过滤多余字段 返回结果集
|
|
|
+ if (type == 0) {
|
|
|
+ List<Levi> hjList = huojing.stream().map(x -> Levi.by("ProjectName", x.get("ProjectName").toString()).set("ProjectId", x.get("ProjectId").toString()).set("AlarmContent", x.get("AlarmContent").toString()).set("AlarmTimeStr", x.get("AlarmTimeStr").toString())).collect(Collectors.toList());
|
|
|
+ Supplier<Stream<Levi>> hjStream = () -> hjList.stream();
|
|
|
+ List<Map> hjResult = hjStream.get().skip((pageNum - 1) * pageSize).limit(pageSize).collect(Collectors.toList());
|
|
|
+ return ResponseBuilder.ok(PageBean.<Map>builder().total(hjStream.get().count()).row(hjResult).build());
|
|
|
+ } else {
|
|
|
+ List<Levi> gzList = guzhang.stream().map(x -> Levi.by("ProjectName", x.get("ProjectName").toString()).set("ProjectId", x.get("ProjectId").toString()).set("AlarmContent", x.get("AlarmContent").toString()).set("AlarmTimeStr", x.get("AlarmTimeStr").toString())).collect(Collectors.toList());
|
|
|
+ Supplier<Stream<Levi>> gzStream = () -> gzList.stream();
|
|
|
+ List<Map> gzResult = gzStream.get().skip((pageNum - 1) * pageSize).limit(pageSize).collect(Collectors.toList());
|
|
|
+ return ResponseBuilder.ok(PageBean.<Map>builder().total(gzStream.get().count()).row(gzResult).build());
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|