2021与蓝度共同重构项目,服务端
liuhaonan
2022-04-18 a015509816d8799b0f0f8eb945984067ba305dc5
ximon-admin/src/main/java/com/sandu/ximon/admin/service/PoleService.java
@@ -44,10 +44,7 @@
import org.springframework.stereotype.Service;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import java.util.*;
import java.util.stream.Collectors;
/**
@@ -115,6 +112,29 @@
        return Long.parseLong(sb.toString());
    }
    /**
     * 统计在线灯杆数量
     * @return
     */
    public Map<String,Integer> poleCount() {
        Map<String,Integer> result = new HashMap<>();
        List<Pole> list = new ArrayList<>();
        LambdaQueryWrapper<Pole> wrapper = new LambdaQueryWrapper<>();
        if (SecurityUtils.getClientId() == null) {
            wrapper = Wrappers.lambdaQuery(Pole.class);
        } else {
            wrapper = Wrappers.lambdaQuery(Pole.class).eq(Pole::getClientId, SecurityUtils.getUserId()).or(
                    w -> {
                        w.eq(Pole::getUserId, SecurityUtils.getUserId());
                    });
        }
        list = list(wrapper);
        List<Pole> poles = isOnLine(list);
        result.put("onlineCount",poles.size());
        result.put("totalCount",list.size());
        return result;
    }
    public List<Pole> queryAllStatesAndList(Integer pageNo, Integer pageSize, PoleStatesParam param) {
        List<Pole> list = new ArrayList<>();
@@ -222,6 +242,26 @@
        return list;
    }
    /**
     * 在线灯杆
     *
     * @param list
     * @param
     * @return
     */
    public List<Pole> isOnLine(List<Pole> list) {
        setOnline(list);
        List<Pole> online = new ArrayList<>();//在线
        list.forEach(onLinePole -> {
            if (("ONLINE").equals(onLinePole.getOnLineState())) {
                online.add(onLinePole);
            }
        });
        return online;
    }
    /**
     * 查询绑定状态
     *