|
|
|
|
@ -82,7 +82,7 @@ public class IotDeviceServiceImpl implements IIotDeviceService {
|
|
|
|
|
private LambdaQueryWrapper<IotDevice> buildQueryWrapper(IotDeviceBo bo) {
|
|
|
|
|
Map<String, Object> params = bo.getParams();
|
|
|
|
|
LambdaQueryWrapper<IotDevice> lqw = Wrappers.lambdaQuery();
|
|
|
|
|
lqw.orderByAsc(IotDevice::getId);
|
|
|
|
|
lqw.orderByAsc(IotDevice::getCreateTime);
|
|
|
|
|
lqw.like(StringUtils.isNotBlank(bo.getName()), IotDevice::getName, bo.getName());
|
|
|
|
|
lqw.eq(StringUtils.isNotBlank(bo.getSensorCode()), IotDevice::getSensorCode, bo.getSensorCode());
|
|
|
|
|
lqw.eq(StringUtils.isNotBlank(bo.getStatus()), IotDevice::getStatus, bo.getStatus());
|
|
|
|
|
@ -92,6 +92,7 @@ public class IotDeviceServiceImpl implements IIotDeviceService {
|
|
|
|
|
lqw.eq(StringUtils.isNotBlank(bo.getTxt1()), IotDevice::getTxt1, bo.getTxt1());
|
|
|
|
|
lqw.eq(StringUtils.isNotBlank(bo.getTxt2()), IotDevice::getTxt2, bo.getTxt2());
|
|
|
|
|
lqw.eq(StringUtils.isNotBlank(bo.getTxt3()), IotDevice::getTxt3, bo.getTxt3());
|
|
|
|
|
|
|
|
|
|
return lqw;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -106,23 +107,29 @@ public class IotDeviceServiceImpl implements IIotDeviceService {
|
|
|
|
|
public Boolean insertByBo(IotDeviceBo bo) {
|
|
|
|
|
IotDevice add = MapstructUtils.convert(bo, IotDevice.class);
|
|
|
|
|
validEntityBeforeSave(add);
|
|
|
|
|
String join = String.join(",", bo.getSensorCodes());
|
|
|
|
|
if (add != null) {
|
|
|
|
|
add.setStatus("0");
|
|
|
|
|
add.setSensorCode(join);
|
|
|
|
|
if (bo.getSensorCodes()!=null && bo.getSensorCodes().length>0){
|
|
|
|
|
String join = String.join(",", bo.getSensorCodes());
|
|
|
|
|
if (add != null) {
|
|
|
|
|
add.setStatus("0");
|
|
|
|
|
add.setSensorCode(join);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
boolean flag = baseMapper.insert(add) > 0;
|
|
|
|
|
if (flag) {
|
|
|
|
|
bo.setId(add.getId());
|
|
|
|
|
//将设备id保存到传感器的绑定设备字段中去device_bound
|
|
|
|
|
List<String> list = Arrays.stream(bo.getSensorCodes()).toList();
|
|
|
|
|
for (String s : list) {
|
|
|
|
|
IotSensorVo iotSensorVo = iotSensorService.queryById(Long.valueOf(s));
|
|
|
|
|
IotSensorBo iotSensorBo = new IotSensorBo();
|
|
|
|
|
BeanUtils.copyProperties(iotSensorVo,iotSensorBo);
|
|
|
|
|
iotSensorBo.setDeviceBound(String.valueOf(bo.getId()));
|
|
|
|
|
iotSensorService.updateByBo(iotSensorBo);
|
|
|
|
|
if (bo.getSensorCodes()!=null && bo.getSensorCodes().length>0){
|
|
|
|
|
List<String> list = Arrays.stream(bo.getSensorCodes()).toList();
|
|
|
|
|
for (String s : list) {
|
|
|
|
|
IotSensorVo iotSensorVo = iotSensorService.queryById(Long.valueOf(s));
|
|
|
|
|
IotSensorBo iotSensorBo = new IotSensorBo();
|
|
|
|
|
BeanUtils.copyProperties(iotSensorVo,iotSensorBo);
|
|
|
|
|
iotSensorBo.setDeviceBound(String.valueOf(bo.getId()));
|
|
|
|
|
iotSensorService.updateByBo(iotSensorBo);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
return flag;
|
|
|
|
|
}
|
|
|
|
|
|