2021与蓝度共同重构项目,服务端
liuhaonan
2022-11-04 2611d27616bdbea6331f75a0147bd67c95f2eb0e
ximon-admin/src/main/java/com/sandu/ximon/admin/service/PoleBindingService.java
@@ -103,7 +103,7 @@
        }
        LambdaQueryWrapper<PoleBinding> eq = Wrappers.lambdaQuery(PoleBinding.class).eq(PoleBinding::getPoleId, poleId);
        LambdaQueryWrapper<PoleBinding> eq = Wrappers.lambdaQuery(PoleBinding.class).eq(PoleBinding::getDeviceType, param.getDeviceType()).eq(PoleBinding::getPoleId, poleId);
        List<PoleBinding> list = list(eq);
        if (list.size() != 0) {
            for (PoleBinding poleBinding : list) {
@@ -114,7 +114,8 @@
            }
        }
        PoleBinding one = getOne(Wrappers.lambdaQuery(PoleBinding.class).eq(PoleBinding::getDeviceCode, param.getDeviceCode()));
        PoleBinding one = getOne(Wrappers.lambdaQuery(PoleBinding.class).eq(PoleBinding::getDeviceCode, param.getDeviceCode())
                .eq(PoleBinding::getDeviceType, param.getDeviceType()));
        if (one == null) {
            //充电桩保存绑定关系需要先判断是不是正确的灯杆
            if (deviceType == 2) {
@@ -190,6 +191,31 @@
        }
    }
    /**
     * 灯杆解绑设备,删除设备前需要解绑
     *
     * @param deviceCode
     */
    public boolean unBindPole(Long poleId, String deviceCode, Integer deviceType) {
        if (deviceCode == null) {
            throw new BusinessException("设备编号不能为空");
        }
        PoleBinding one;
        //直接删除设备不需要灯杆ID
        if (poleId == null) {
            one = getOne(Wrappers.lambdaQuery(PoleBinding.class).eq(PoleBinding::getDeviceCode, deviceCode).eq(PoleBinding::getDeviceType, deviceType));
        } else {
            one = getOne(Wrappers.lambdaQuery(PoleBinding.class).eq(PoleBinding::getDeviceCode, deviceCode)
                    .eq(PoleBinding::getDeviceType, deviceType).eq(PoleBinding::getPoleId, poleId));
        }
        if (one != null) {
            return removeById(one.getId());
        } else {
            throw new BusinessException("设备不存在绑定情况或灯杆ID不正确");
        }
    }
    /**
     * 设备删除,直接解绑设备相关绑定数据
     *
@@ -217,7 +243,7 @@
    }
    public PoleBinding getPoleIdByMac(String deviceCode) {
        return getOne(Wrappers.lambdaQuery(PoleBinding.class).eq(PoleBinding::getDeviceCode, deviceCode));
        return getOne(Wrappers.lambdaQuery(PoleBinding.class).eq(PoleBinding::getDeviceCode, deviceCode).eq(PoleBinding::getDeviceType, 0));
    }