2021与蓝度共同重构项目,服务端
liuhaonan
2022-04-18 652bbc43722b3eed164609d10dc6967989b253d5
ximon-admin/src/main/java/com/sandu/ximon/admin/service/PoleService.java
@@ -34,6 +34,7 @@
import com.sandu.ximon.admin.redis.LightKey;
import com.sandu.ximon.admin.security.SecurityUtils;
import com.sandu.ximon.admin.vo.PoleBindVO;
import com.sandu.ximon.dao.domain.LedPlayerEntity;
import com.sandu.ximon.dao.domain.Pole;
import com.sandu.ximon.dao.domain.PoleBinding;
import com.sandu.ximon.dao.domain.PoleGroupRelation;
@@ -44,10 +45,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;
/**
@@ -91,6 +89,8 @@
        if (pole == null) {
            throw new BusinessException("未找到该灯杆");
        }
        // 删除灯杆绑定关系
        poleBindingService.remove(Wrappers.<PoleBinding>lambdaQuery().eq(PoleBinding::getPoleId, poleId));
        return removeById(poleId);
    }
@@ -114,13 +114,56 @@
    }
    /**
     * 统计在线灯杆数量
     *
     * @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("poleOnlineCount", poles.size());
        result.put("poleTotalCount", list.size());
        //诺瓦
        // SpringContextHolder.getBean(LightService.class).listLight(SecurityUtils.getUserId(), SecurityUtils.getClientId());
        List<LedPlayerEntity> ledPlayerEntities = SpringContextHolder.getBean(LedPlayerEntityService.class).ledPlayerEntityList(null, null);
        int munber = 0;
        for (LedPlayerEntity bean : ledPlayerEntities) {
            if (bean.getOnlineStatus() == 1) {
                munber++;
            }
        }
        result.put("novaOnlineCount", munber);
        result.put("novaTotalCount", ledPlayerEntities.size());
        SpringContextHolder.getBean(C3ChargingService.class).list();
        return result;
    }
    public List<Pole> queryAllStatesAndList(Integer pageNo, Integer pageSize, PoleStatesParam param) {
        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());
            wrapper = Wrappers.lambdaQuery(Pole.class).eq(Pole::getClientId, SecurityUtils.getUserId()).or(
                    w -> {
                        w.eq(Pole::getUserId, SecurityUtils.getUserId());
                    });
        }
        if (!param.getKeyword().isEmpty()) {
            wrapper.like(Pole::getPoleCode, param.getKeyword()).or(
@@ -130,6 +173,7 @@
            );
        }
        PageHelper.startPage(pageNo, pageSize);
        list = list(wrapper);
        if (param.getGroupid() != null) {
            //  List<Long> poleIds = new ArrayList<>();
@@ -215,6 +259,26 @@
            return offline;
        }
        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;
    }
    /**
@@ -646,7 +710,7 @@
            } else if (poleBinding.getDeviceType() == 3) {//大气
                bindVO.setAirMonitoring(SpringContextHolder.getBean(AirEquipmentService.class).getAirEquipment(poleBinding.getDeviceCode()));
            } else if (poleBinding.getDeviceType() == 4) {//水质
                 bindVO.setWaterMonitoring(SpringContextHolder.getBean(WaterQualityDataService.class).getWaterQualityDataInfo(poleBinding.getDeviceCode()));
                bindVO.setWaterMonitoring(SpringContextHolder.getBean(WaterQualityDataService.class).getWaterQualityDataInfo(poleBinding.getDeviceCode()));
            } else if (poleBinding.getDeviceType() == 5) {//音柱
                bindVO.setIpVolume(SpringContextHolder.getBean(IpVolumeService.class).getIpTerminalDetail(Integer.valueOf(poleBinding.getDeviceCode())));
            } else if (poleBinding.getDeviceType() == 6) {//LCD