2021与蓝度共同重构项目,服务端
liuhaonan
2022-08-10 ada0b243f16f12b5025253663eacfe53055f8310
ximon-admin/src/main/java/com/sandu/ximon/admin/service/LightService.java
@@ -73,7 +73,7 @@
        Boolean hasKey = redisService.hasKey(LightKey.REPORT_MAC.key(deviceName));
        if (!hasKey) {
            int count = count(Wrappers.lambdaQuery(Light.class).eq(Light::getDeviceCode, deviceName));
            log.info("redis查不到路灯数据{}={}", count, deviceName);
            log.info("redis查不到路灯数据 数量:{}={}", count, deviceName);
            // 当前路灯表没有录入设备吗
            if (count == 0) {
                Light light = new Light();
@@ -992,6 +992,21 @@
    }
    /**
     * 用户拥有的路灯(用于首页数据统计)
     *
     * @return
     */
    public List<LightBo> listLightOnHome() {
        List<LightBo> listLight;
        if (SecurityUtils.getClientId() != null) {
            listLight = baseMapper.listLight(SecurityUtils.getUserId(), null);
        } else {
            listLight = baseMapper.listLight(null, null);
        }
        return listLight;
    }
    /**
     * 获取用户所有的设备码
     */
    public CommonPage<String> listDeviceCode(int pageNo, int pageSize, String keyword, String deviceCode) {
@@ -1016,6 +1031,16 @@
        lights.forEach(light -> {
            light.setPower1(lightPowerSettingParam.getPower1());
            light.setPower2(lightPowerSettingParam.getPower2());
            if (lightPowerSettingParam.getPower1() != null) {
                light.setLight1(1);
            } else {
                light.setLight1(0);
            }
            if (lightPowerSettingParam.getPower2() != null) {
                light.setLight2(1);
            } else {
                light.setLight2(0);
            }
            light.setLightCount(lightPowerSettingParam.getLightCount());
        });
        return updateBatchById(lights);