Browse Source

采集点配置和编辑02

qiangxuan 7 months ago
parent
commit
fccc096396

+ 18 - 0
jeecg-module-gather/src/main/java/org/jeecg/modules/devicePoint/controller/DevicePointController.java

@@ -374,4 +374,22 @@ public class DevicePointController extends JeecgController<DevicePoint, IDeviceP
 			opcUaClient.disconnect();
 		}
 	}
+
+
+	@ApiOperation(value="设备采集点-根据采集点信息查询", notes="设备采集点-根据采集点信息查询")
+	@GetMapping(value = "/queryListByDeviceGather")
+	public Result<List<DevicePoint>> queryListByType(@RequestParam(name="deviceGather") String deviceGather) {
+		List<DevicePoint> list = devicePointService.queryListByType(deviceGather);
+		return Result.OK(list);
+	}
+
+
+	@AutoLog(value = "设备采集点配置")
+	@ApiOperation(value="设备采集点配置", notes="设备采集点配置")
+	@RequestMapping(value = "/editDevicePointBatch", method = {RequestMethod.PUT,RequestMethod.POST})
+	public Result<String> editDevicePointBatch(@RequestBody EditDevicePointBatchParam editDevicePointBatchParam) {
+		devicePointService.editDevicePointBatch(editDevicePointBatchParam);
+		return Result.OK("编辑成功!");
+	}
+
 }

+ 25 - 0
jeecg-module-gather/src/main/java/org/jeecg/modules/devicePoint/entity/EditDevicePointBatchParam.java

@@ -0,0 +1,25 @@
+package org.jeecg.modules.devicePoint.entity;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+import java.util.List;
+
+@Data
+@Accessors(chain = true)
+@EqualsAndHashCode(callSuper = false)
+@ApiModel(value="设备采集点配置批量编辑参数", description="设备采集点配置批量编辑参数")
+public class EditDevicePointBatchParam {
+
+    @ApiModelProperty(value = "设备id")
+    private String deviceId;
+
+    @ApiModelProperty(value = "设备采集点集合")
+    private List<DevicePoint> devicePoints;
+
+    @ApiModelProperty(value = "已删除的设备采集点集合")
+    private List<DevicePoint> deleteDevicePoints;
+}

+ 7 - 0
jeecg-module-gather/src/main/java/org/jeecg/modules/devicePoint/service/IDevicePointService.java

@@ -3,6 +3,9 @@ package org.jeecg.modules.devicePoint.service;
 import org.jeecg.modules.devicePoint.entity.DevicePoint;
 import com.baomidou.mybatisplus.extension.service.IService;
 import org.jeecg.modules.devicePoint.entity.EditBatchParam;
+import org.jeecg.modules.devicePoint.entity.EditDevicePointBatchParam;
+
+import java.util.List;
 
 /**
  * @Description: 设备采集点
@@ -13,4 +16,8 @@ import org.jeecg.modules.devicePoint.entity.EditBatchParam;
 public interface IDevicePointService extends IService<DevicePoint> {
 
     void editBatch(EditBatchParam editBatchParam);
+
+    List<DevicePoint> queryListByType(String deviceGather);
+
+    void editDevicePointBatch(EditDevicePointBatchParam editDevicePointBatchParam);
 }

+ 57 - 0
jeecg-module-gather/src/main/java/org/jeecg/modules/devicePoint/service/impl/DevicePointServiceImpl.java

@@ -1,16 +1,27 @@
 package org.jeecg.modules.devicePoint.service.impl;
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
 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.EditBatchParam;
+import org.jeecg.modules.devicePoint.entity.EditDevicePointBatchParam;
 import org.jeecg.modules.devicePoint.mapper.DevicePointMapper;
 import org.jeecg.modules.devicePoint.service.IDevicePointService;
+import org.jeecg.modules.gatherData.entity.FpgGatherData;
+import org.jeecg.modules.gatherData.service.IFpgGatherDataService;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Collectors;
+
 /**
  * @Description: 设备采集点
  * @Author: jeecg-boot
@@ -20,6 +31,12 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 @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()));
@@ -30,4 +47,44 @@ public class DevicePointServiceImpl extends ServiceImpl<DevicePointMapper, Devic
             });
         }
     }
+
+    @Override
+    public List<DevicePoint> queryListByType(String deviceGather) {
+        List<DevicePoint> devicePointList = new ArrayList<>();
+        LambdaQueryWrapper<DeviceGatherService> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.eq(DeviceGatherService::getDeviceGather, deviceGather);
+        List<DeviceGatherService> deviceGatherServiceList = deviceGatherServiceService.list(queryWrapper);
+        if (!oConvertUtils.listIsNotEmpty(deviceGatherServiceList)){
+            return devicePointList;
+        }
+        List<String> ids = deviceGatherServiceList.stream().map(DeviceGatherService::getId).collect(Collectors.toList());
+        LambdaQueryWrapper<DevicePoint> query = new LambdaQueryWrapper<>();
+        query.in(DevicePoint::getGatherServiceId, ids);
+        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<DevicePoint> saveOrUpdateDevicePointList = editDevicePointBatchParam.getDevicePoints();
+        if (oConvertUtils.listIsNotEmpty(saveOrUpdateDevicePointList)){
+            List<String> ids = saveOrUpdateDevicePointList.stream().map(DevicePoint::getId).collect(Collectors.toList());
+            LambdaQueryWrapper<DevicePoint> queryWrapper = new LambdaQueryWrapper<>();
+            queryWrapper.in(DevicePoint::getId, ids);
+            List<DevicePoint> listDevicePoint = baseMapper.selectList(queryWrapper);
+            if (oConvertUtils.listIsNotEmpty(listDevicePoint)){
+                listDevicePoint.forEach(y ->{
+                    y.setDeviceId(editDevicePointBatchParam.getDeviceId());
+                    baseMapper.updateById(y);
+                });
+            }
+        }
+    }
 }