|
@@ -1,12 +1,16 @@
|
|
|
package org.jeecg.modules.devicePoint.service.impl;
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
|
|
|
+import org.apache.poi.ss.formula.functions.T;
|
|
|
import org.jeecg.common.util.oConvertUtils;
|
|
|
import org.jeecg.modules.device.entity.DeviceGatherService;
|
|
|
import org.jeecg.modules.device.service.IDeviceGatherServiceService;
|
|
|
import org.jeecg.modules.devicePoint.entity.DevicePoint;
|
|
|
+import org.jeecg.modules.devicePoint.entity.DevicePointInfos;
|
|
|
import org.jeecg.modules.devicePoint.entity.EditBatchParam;
|
|
|
import org.jeecg.modules.devicePoint.entity.EditDevicePointBatchParam;
|
|
|
import org.jeecg.modules.devicePoint.mapper.DevicePointMapper;
|
|
@@ -31,12 +35,9 @@ import java.util.stream.Collectors;
|
|
|
@Service
|
|
|
public class DevicePointServiceImpl extends ServiceImpl<DevicePointMapper, DevicePoint> implements IDevicePointService {
|
|
|
|
|
|
-
|
|
|
@Autowired
|
|
|
private IDeviceGatherServiceService deviceGatherServiceService;
|
|
|
|
|
|
-
|
|
|
-
|
|
|
@Override
|
|
|
public void editBatch(EditBatchParam editBatchParam) {
|
|
|
baseMapper.delete(new LambdaQueryWrapper<DevicePoint>().eq(DevicePoint::getDeviceId,editBatchParam.getDeviceId()));
|
|
@@ -59,23 +60,29 @@ public class DevicePointServiceImpl extends ServiceImpl<DevicePointMapper, Devic
|
|
|
}
|
|
|
List<String> ids = deviceGatherServiceList.stream().map(DeviceGatherService::getId).collect(Collectors.toList());
|
|
|
LambdaQueryWrapper<DevicePoint> query = new LambdaQueryWrapper<>();
|
|
|
- query.in(DevicePoint::getGatherServiceId, ids);
|
|
|
+ query.in(DevicePoint::getGatherServiceId, ids).isNull(DevicePoint::getDeviceId);
|
|
|
devicePointList = baseMapper.selectList(query);
|
|
|
return devicePointList;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void editDevicePointBatch(EditDevicePointBatchParam editDevicePointBatchParam) {
|
|
|
- if (oConvertUtils.listIsNotEmpty(editDevicePointBatchParam.getDeleteDevicePoints())){
|
|
|
- List<DevicePoint> deleteDevicePointList = new ArrayList<>();
|
|
|
- deleteDevicePointList.forEach(x ->{
|
|
|
- x.setDeviceId(null);
|
|
|
- baseMapper.updateById(x);
|
|
|
- });
|
|
|
+ List<String> deleteDevicePointIds = editDevicePointBatchParam.getDeleteDevicePoints();
|
|
|
+ if (oConvertUtils.listIsNotEmpty(deleteDevicePointIds)){
|
|
|
+ LambdaQueryWrapper<DevicePoint> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.in(DevicePoint::getId, deleteDevicePointIds);
|
|
|
+ List<DevicePoint> listDevicePoint = baseMapper.selectList(queryWrapper);
|
|
|
+ if (oConvertUtils.listIsNotEmpty(listDevicePoint)){
|
|
|
+ listDevicePoint.forEach(x ->{
|
|
|
+ UpdateWrapper<DevicePoint> updateWrapper = new UpdateWrapper<>();
|
|
|
+ updateWrapper.set("device_id", null); // 显式设置device_id为null
|
|
|
+ updateWrapper.eq("id", x.getId());
|
|
|
+ baseMapper.update(x, updateWrapper);
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
- List<DevicePoint> saveOrUpdateDevicePointList = editDevicePointBatchParam.getDevicePoints();
|
|
|
- if (oConvertUtils.listIsNotEmpty(saveOrUpdateDevicePointList)){
|
|
|
- List<String> ids = saveOrUpdateDevicePointList.stream().map(DevicePoint::getId).collect(Collectors.toList());
|
|
|
+ List<String> ids = editDevicePointBatchParam.getDevicePoints();
|
|
|
+ if (oConvertUtils.listIsNotEmpty(ids)){
|
|
|
LambdaQueryWrapper<DevicePoint> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
queryWrapper.in(DevicePoint::getId, ids);
|
|
|
List<DevicePoint> listDevicePoint = baseMapper.selectList(queryWrapper);
|
|
@@ -87,4 +94,32 @@ public class DevicePointServiceImpl extends ServiceImpl<DevicePointMapper, Devic
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public DevicePointInfos getByDeviceId(String deviceId) {
|
|
|
+
|
|
|
+ DevicePointInfos devicePointInfos = new DevicePointInfos();
|
|
|
+ LambdaQueryWrapper<DevicePoint> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.eq(DevicePoint::getDeviceId,deviceId);
|
|
|
+ List<DevicePoint> devicePointList = baseMapper.selectList(queryWrapper);
|
|
|
+ if (!oConvertUtils.listIsNotEmpty(devicePointList)){
|
|
|
+ return devicePointInfos;
|
|
|
+ }
|
|
|
+ List<String> gatherServiceIds = devicePointList.stream().map(DevicePoint::getGatherServiceId).distinct().collect(Collectors.toList());
|
|
|
+ if (!oConvertUtils.listIsNotEmpty(gatherServiceIds)){
|
|
|
+ // 采集点信息存在,对应的采集点服务为空,返回采集点信息即可
|
|
|
+ devicePointInfos.setDevicePoints(devicePointList);
|
|
|
+ return devicePointInfos;
|
|
|
+ }
|
|
|
+ LambdaQueryWrapper<DeviceGatherService> queryWrapper1 = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper1.in(DeviceGatherService::getId, gatherServiceIds);
|
|
|
+ List<DeviceGatherService> deviceGatherServiceList = deviceGatherServiceService.list(queryWrapper1);
|
|
|
+ if (!oConvertUtils.listIsNotEmpty(deviceGatherServiceList)){
|
|
|
+ devicePointInfos.setDevicePoints(devicePointList);
|
|
|
+ return devicePointInfos;
|
|
|
+ }
|
|
|
+ devicePointInfos.setDevicePoints(devicePointList);
|
|
|
+ devicePointInfos.setDeviceGatherServices(deviceGatherServiceList);
|
|
|
+ return devicePointInfos;
|
|
|
+ }
|
|
|
}
|