优化辅控设备逻辑
This commit is contained in:
parent
347c33bd95
commit
1442a9e113
@ -4,6 +4,7 @@ import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.yfd.platform.modules.auxcontrol.domain.GatewayDevice;
|
||||
import com.yfd.platform.modules.auxcontrol.domain.MeterDevice;
|
||||
import com.yfd.platform.modules.auxcontrol.mapper.MeterDeviceMapper;
|
||||
import com.yfd.platform.modules.auxcontrol.service.IMeterDeviceService;
|
||||
@ -30,7 +31,12 @@ public class MeterDeviceServiceImpl extends ServiceImpl<MeterDeviceMapper, Meter
|
||||
@Override
|
||||
public Page<MeterDevice> getDevicePage(String deviceName, String deviceModel, String deviceType, String status,
|
||||
String systemcode, Page<MeterDevice> page) {
|
||||
return null;
|
||||
LambdaQueryWrapper<MeterDevice> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.like(StrUtil.isNotBlank(deviceName), MeterDevice::getDeviceName, deviceName);
|
||||
queryWrapper.like(StrUtil.isNotBlank(deviceModel), MeterDevice::getDeviceModel, deviceModel);
|
||||
queryWrapper.eq(StrUtil.isNotBlank(deviceType), MeterDevice::getDeviceType, deviceType);
|
||||
queryWrapper.eq(StrUtil.isNotBlank(systemcode), MeterDevice::getSystemcode, systemcode).orderByAsc(MeterDevice::getDeviceCode);
|
||||
return this.page(page, queryWrapper);
|
||||
}
|
||||
|
||||
/**********************************
|
||||
@ -40,6 +46,14 @@ public class MeterDeviceServiceImpl extends ServiceImpl<MeterDeviceMapper, Meter
|
||||
***********************************/
|
||||
@Override
|
||||
public boolean addMeterDevice(MeterDevice meterDevice) {
|
||||
if (StrUtil.isNotBlank(meterDevice.getIpAddr())) {
|
||||
LambdaQueryWrapper<MeterDevice> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(MeterDevice::getIpAddr, meterDevice.getIpAddr());
|
||||
int count = this.count(queryWrapper);
|
||||
if (count > 0) {
|
||||
throw new RuntimeException("当前ip已经有设备绑定");
|
||||
}
|
||||
}
|
||||
meterDevice.setLastmodifier(SecurityUtils.getCurrentUsername());
|
||||
//当前操作时间 最近修改时间
|
||||
meterDevice.setLastmodifydate(new Timestamp(System.currentTimeMillis()));
|
||||
@ -53,6 +67,15 @@ public class MeterDeviceServiceImpl extends ServiceImpl<MeterDeviceMapper, Meter
|
||||
***********************************/
|
||||
@Override
|
||||
public boolean updateMeterDevice(MeterDevice meterDevice) {
|
||||
if (StrUtil.isNotBlank(meterDevice.getIpAddr())) {
|
||||
LambdaQueryWrapper<MeterDevice> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.ne(MeterDevice::getDeviceId, meterDevice.getDeviceId()).eq(MeterDevice::getIpAddr,
|
||||
meterDevice.getIpAddr());
|
||||
int count = this.count(queryWrapper);
|
||||
if (count > 0) {
|
||||
throw new RuntimeException("当前ip已经有设备绑定");
|
||||
}
|
||||
}
|
||||
meterDevice.setLastmodifier(SecurityUtils.getCurrentUsername());
|
||||
//当前操作时间 最近修改时间
|
||||
meterDevice.setLastmodifydate(new Timestamp(System.currentTimeMillis()));
|
||||
@ -82,7 +105,7 @@ public class MeterDeviceServiceImpl extends ServiceImpl<MeterDeviceMapper, Meter
|
||||
@Override
|
||||
public List<Map<String, Object>> getMeterDeviceByCode(String stationId, String systemCode) {
|
||||
LambdaQueryWrapper<MeterDevice> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(StrUtil.isNotBlank(stationId), MeterDevice::getStationId, stationId).eq(StrUtil.isNotBlank(systemCode), MeterDevice::getSystemcode, systemCode).select(MeterDevice::getDeviceId, MeterDevice::getDeviceName);
|
||||
queryWrapper.eq(StrUtil.isNotBlank(stationId), MeterDevice::getStationId, stationId).eq(StrUtil.isNotBlank(systemCode), MeterDevice::getSystemcode, systemCode).select(MeterDevice::getDeviceId, MeterDevice::getDeviceName).orderByAsc(MeterDevice::getDeviceCode);
|
||||
return this.listMaps(queryWrapper);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user