2021与蓝度共同重构项目,服务端
liuhaonan
2022-04-13 3f65fcaa359cadeffa9cec2c757ab879d0aad739
ximon-admin/src/main/java/com/sandu/ximon/admin/service/PoleBindingService.java
@@ -5,7 +5,6 @@
import com.sandu.common.service.impl.BaseServiceImpl;
import com.sandu.ximon.admin.param.PoleBindingParam;
import com.sandu.ximon.dao.domain.PoleBinding;
import com.sandu.ximon.dao.enums.PoleBindingEnums;
import com.sandu.ximon.dao.mapper.PoleBindingMapper;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
@@ -50,16 +49,44 @@
     *
     * @param deviceCode
     */
    public boolean unBindPole(Long poleId, String deviceCode) {
        if (deviceCode == null) {
            throw new BusinessException("设备编号不能为空");
        }
        PoleBinding one;
        //直接删除设备不需要灯杆ID
        if (poleId == null) {
            one = getOne(Wrappers.lambdaQuery(PoleBinding.class).eq(PoleBinding::getDeviceCode, deviceCode));
        } else {
            one = getOne(Wrappers.lambdaQuery(PoleBinding.class).eq(PoleBinding::getDeviceCode, deviceCode).eq(PoleBinding::getPoleId, poleId));
        }
        if (one != null) {
            return removeById(one.getId());
        } else {
            throw new BusinessException("设备不存在绑定情况或灯杆ID不正确");
        }
    }
    /**
     * 设备删除,直接解绑设备相关绑定数据
     *
     * @param deviceCode
     */
    public boolean unBindPole(String deviceCode) {
        if (deviceCode == null) {
            throw new BusinessException("设备编号不能为空");
        }
        //直接删除设备不需要灯杆ID
        PoleBinding one = getOne(Wrappers.lambdaQuery(PoleBinding.class).eq(PoleBinding::getDeviceCode, deviceCode));
        if (one != null) {
            return removeById(one.getId());
        } else {
            throw new BusinessException("设备不存在绑定情况");
            return false;
        }
    }
    public PoleBinding getPoleIdByMac(String deviceCode){
       return getOne(Wrappers.lambdaQuery(PoleBinding.class).eq(PoleBinding::getDeviceCode, deviceCode));
    }
}