| | |
| | | |
| | | PoleBinding one = getOne(Wrappers.lambdaQuery(PoleBinding.class).eq(PoleBinding::getDeviceCode, param.getDeviceCode())); |
| | | if (one == null) { |
| | | //充电桩保存绑定关系需要先判断是不是正确的灯杆 |
| | | if (deviceType == 2) { |
| | | C3mCharging mCharging = SpringContextHolder.getBean(C3ChargingService.class). |
| | | getOne(Wrappers.lambdaQuery(C3mCharging.class).eq(C3mCharging::getMcuUdid, param.getDeviceCode())); |
| | | Pole poleInfo = SpringContextHolder.getBean(PoleService.class).getById(poleId); |
| | | |
| | | if (!mCharging.getPoleDevicesCode().equals(poleInfo.getDeviceCode())) { |
| | | throw new BusinessException("绑定出错!该充电桩硬件绑定的灯杆mac为:" + mCharging.getPoleDevicesCode()); |
| | | } |
| | | |
| | | } |
| | | PoleBinding poleBinding = new PoleBinding(); |
| | | poleBinding.setPoleId(poleId); |
| | | poleBinding.setDeviceType(deviceType); |
| | | poleBinding.setDeviceName(param.getDeviceName()); |
| | | poleBinding.setDeviceCode(param.getDeviceCode()); |
| | | return save(poleBinding); |
| | | |
| | | } else { |
| | | //修改单灯的绑定关系的时候要额外处理的事务 |
| | | // 删除灯杆的devicescode |
| | |
| | | pole.setDeviceCode(null); |
| | | poleService.updateById(pole); |
| | | } |
| | | } |
| | | |
| | | //充电桩保存绑定关系需要先判断是不是正确的灯杆 |
| | | if (deviceType == 2) { |
| | | C3mCharging mCharging = SpringContextHolder.getBean(C3ChargingService.class). |
| | | getOne(Wrappers.lambdaQuery(C3mCharging.class).eq(C3mCharging::getMcuUdid, param.getDeviceCode())); |
| | | Pole poleInfo = SpringContextHolder.getBean(PoleService.class).getById(poleId); |
| | | |
| | | if (!mCharging.getPoleDevicesCode().equals(poleInfo.getDeviceCode())) { |
| | | throw new BusinessException("绑定出错!该充电桩硬件绑定的灯杆mac为:" + mCharging.getPoleDevicesCode()); |
| | | } |
| | | |
| | | } |
| | | |
| | | one.setPoleId(poleId); |
| | |
| | | if (deviceCode == null) { |
| | | throw new BusinessException("设备编号不能为空"); |
| | | } |
| | | //查灯杆归属关系 |
| | | boolean belong = isBelong(deviceCode, null); |
| | | if(!belong){ |
| | | throw new BusinessException("该灯杆不属于您,无法解绑!"); |
| | | if (SecurityUtils.getClientId() != null) { |
| | | //查灯杆归属关系 |
| | | boolean belong = isBelong(deviceCode, null); |
| | | if (!belong) { |
| | | throw new BusinessException("该灯杆不属于您,无法解绑!"); |
| | | } |
| | | } |
| | | //直接删除设备不需要灯杆ID |
| | | PoleBinding one = getOne(Wrappers.lambdaQuery(PoleBinding.class).eq(PoleBinding::getDeviceCode, deviceCode)); |