| | |
| | | package com.sandu.ximon.admin.service; |
| | | |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.sandu.common.execption.BusinessException; |
| | | import com.sandu.common.service.impl.BaseServiceImpl; |
| | | import com.sandu.ximon.admin.param.PoleBindingParam; |
| | | import com.sandu.ximon.dao.domain.LightReportData; |
| | | import com.sandu.ximon.dao.domain.PoleBinding; |
| | | import com.sandu.ximon.dao.enums.PoleBindingEnums; |
| | | import com.sandu.ximon.dao.mapper.PoleBindingMapper; |
| | |
| | | |
| | | private final LightReportDataService lightReportDataService; |
| | | |
| | | /** |
| | | * 灯杆绑定设备 |
| | | * |
| | | * @param poleId |
| | | * @param param |
| | | * @return |
| | | */ |
| | | public boolean bindPole(Long poleId, PoleBindingParam param) { |
| | | Integer deviceType = param.getDeviceType(); |
| | | if (PoleBindingEnums.LIGHT.getCode().equals(deviceType)) { |
| | | // if (PoleBindingEnums.LIGHT.getCode().equals(deviceType)) { |
| | | // } |
| | | |
| | | PoleBinding one = getOne(Wrappers.lambdaQuery(PoleBinding.class).eq(PoleBinding::getDeviceCode, param.getDeviceCode())); |
| | | if (one == null) { |
| | | PoleBinding poleBinding = new PoleBinding(); |
| | | poleBinding.setPoleId(poleId); |
| | | poleBinding.setDeviceType(deviceType); |
| | | poleBinding.setDeviceName(param.getDeviceName()); |
| | | poleBinding.setDeviceMac(param.getDeviceMac()); |
| | | poleBinding.setDeviceCode(param.getDeviceCode()); |
| | | return save(poleBinding); |
| | | } else { |
| | | throw new BusinessException("该设备已绑定过"); |
| | | } |
| | | } |
| | | |
| | | return false; |
| | | /** |
| | | * 灯杆解绑设备,删除设备前需要解绑 |
| | | * |
| | | * @param deviceCode |
| | | */ |
| | | public void unBindPole(String deviceCode) { |
| | | if (deviceCode == null) |
| | | throw new BusinessException("设备编号不能为空"); |
| | | |
| | | PoleBinding one = getOne(Wrappers.lambdaQuery(PoleBinding.class).eq(PoleBinding::getDeviceCode, deviceCode)); |
| | | if (one != null) { |
| | | removeById(one.getId()); |
| | | } |
| | | } |
| | | } |