| | |
| | | poleBinding.setDeviceCode(param.getDeviceCode()); |
| | | return save(poleBinding); |
| | | } else { |
| | | //删除灯杆的devicescode |
| | | PoleService poleService = SpringContextHolder.getBean(PoleService.class); |
| | | Pole pole = poleService.getOne(Wrappers.lambdaQuery(Pole.class).eq(Pole::getId, one.getPoleId())); |
| | | if (pole != null) { |
| | | pole.setDeviceCode(null); |
| | | poleService.updateById(pole); |
| | | //修改单灯的绑定关系的时候要额外处理的事务 |
| | | // 删除灯杆的devicescode |
| | | if(param.getDeviceType() == 0){ |
| | | PoleService poleService = SpringContextHolder.getBean(PoleService.class); |
| | | Pole pole = poleService.getOne(Wrappers.lambdaQuery(Pole.class).eq(Pole::getId, one.getPoleId())); |
| | | if (pole != null) { |
| | | pole.setDeviceCode(null); |
| | | poleService.updateById(pole); |
| | | } |
| | | } |
| | | |
| | | one.setPoleId(poleId); |
| | |
| | | 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)); |
| | | |
| | | //删除灯杆的devicescode |
| | | PoleService poleService = SpringContextHolder.getBean(PoleService.class); |
| | | Pole pole = poleService.getOne(Wrappers.lambdaQuery(Pole.class).eq(Pole::getId, poleId)); |
| | | if (pole != null) { |
| | | pole.setDeviceCode(null); |
| | | poleService.updateById(pole); |
| | | } |
| | | |
| | | |
| | | } |
| | | if (one != null) { |
| | | return removeById(one.getId()); |