| | |
| | | import com.sandu.ximon.dao.mapper.PoleBindingMapper; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.List; |
| | | |
| | |
| | | * @param param |
| | | * @return |
| | | */ |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean bindPole(Long poleId, PoleBindingParam param) { |
| | | Integer deviceType = param.getDeviceType(); |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | 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) { |
| | |
| | | } |
| | | } |
| | | |
| | | 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) { |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 灯杆解绑设备,删除设备前需要解绑 |
| | | * |
| | | * @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不正确"); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 设备删除,直接解绑设备相关绑定数据 |
| | | * |
| | |
| | | } |
| | | |
| | | 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)); |
| | | } |
| | | |
| | | |