瀏覽代碼

设备采集点配置接口优化联调01

qiangxuan 7 月之前
父節點
當前提交
0d0e631e5c

+ 0 - 85
jeecg-module-gather/src/main/java/org/jeecg/modules/device/entity/DeviceInformation.java

@@ -69,89 +69,4 @@ public class DeviceInformation implements Serializable {
     @Excel(name = "备注", width = 15)
     @ApiModelProperty(value = "备注")
     private String deviceRemark;
-    //	/**设备类型*/
-//	@Excel(name = "设备类型", width = 15, dicCode = "equipment_model")
-//    @ApiModelProperty(value = "设备类型")
-//    @Dict(dicCode = "equipment_model")
-//    private String s7Model;
-//	/**ip*/
-//	@Excel(name = "ip", width = 15)
-//    @ApiModelProperty(value = "ip")
-//    private String deviceIp;
-//	/**端口*/
-//	@Excel(name = "端口", width = 15)
-//    @ApiModelProperty(value = "端口")
-//    private String devicePort;
-//	/**机架号*/
-//	@Excel(name = "机架号", width = 15)
-//    @ApiModelProperty(value = "机架号")
-//    private Integer s7Rack;
-//	/**槽号*/
-//	@Excel(name = "槽号", width = 15)
-//    @ApiModelProperty(value = "槽号")
-//    private String s7Slot;
-//	/**安装地址*/
-//	@Excel(name = "安装地址", width = 15)
-//    @ApiModelProperty(value = "安装地址")
-//    private String deviceAddress;
-//	/**最长位宽*/
-//	@Excel(name = "最长位宽", width = 15)
-//    @ApiModelProperty(value = "最长位宽")
-//    private String s7LongestWidth;
-//	/**备注*/
-//	@Excel(name = "备注", width = 15)
-//    @ApiModelProperty(value = "备注")
-//    private String deviceRemark;
-//	/**采集通道*/
-//	@Excel(name = "采集通道", width = 15, dicCode = "device_information_gather")
-//    @ApiModelProperty(value = "采集通道")
-//    @Dict(dicCode = "device_information_gather")
-//    private String deviceGather;
-//	/**从站号*/
-//	@Excel(name = "从站号", width = 15)
-//    @ApiModelProperty(value = "从站号")
-//    private Integer modbusDeviceNum;
-//	/**运行状态*/
-//	@Excel(name = "运行状态", width = 15, dicCode = "sfqy")
-//    @ApiModelProperty(value = "运行状态")
-//    @Dict(dicCode = "sfqy")
-//    private String status;
-//	/**clsid*/
-//	@Excel(name = "clsid", width = 15)
-//    @ApiModelProperty(value = "clsid")
-//    private String opcClsid;
-//	/**用户名*/
-//	@Excel(name = "用户名", width = 15)
-//    @ApiModelProperty(value = "用户名")
-//    private String opcUsername;
-//	/**密码*/
-//	@Excel(name = "密码", width = 15)
-//    @ApiModelProperty(value = "密码")
-//    private String opcPassword;
-//	/**注册表中的名称*/
-//	@Excel(name = "注册表中的名称", width = 15)
-//    @ApiModelProperty(value = "注册表中的名称")
-//    private String opcRegname;
-//	/**opc版本号*/
-//	@Excel(name = "opc版本号", width = 15)
-//    @ApiModelProperty(value = "opc版本号")
-//    private String opcVersion;
-//	/**opc中文名称*/
-//	@Excel(name = "opc中文名称", width = 15)
-//    @ApiModelProperty(value = "opc中文名称")
-//    private String opcZhName;
-//	/**opc英文名称*/
-//	@Excel(name = "opc英文名称", width = 15)
-//    @ApiModelProperty(value = "opc英文名称")
-//    private String opcEnName;
-//    /**opc域*/
-//    @Excel(name = "opc域", width = 15)
-//    @ApiModelProperty(value = "opc域")
-//    private String opcDomain;
-//    /**采集频率*/
-//    @Excel(name = "采集频率", width = 15)
-//    @ApiModelProperty(value = "采集频率")
-//    @Dict(dicCode = "device_freq")
-//    @TableField(updateStrategy = FieldStrategy.IGNORED)
-//    private String freq;
 }

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

@@ -392,4 +392,13 @@ public class DevicePointController extends JeecgController<DevicePoint, IDeviceP
 		return Result.OK("编辑成功!");
 	}
 
+	@ApiOperation(value="设备采集点信息-通过deviceId查询", notes="设备采集点-通过id查询")
+	@GetMapping(value = "/queryByDeviceId")
+	public Result<DevicePointInfos> queryByDeviceId(@RequestParam(name="deviceId",required=true) String deviceId) {
+		DevicePointInfos devicePointInfos = devicePointService.getByDeviceId(deviceId);
+		if(devicePointInfos==null) {
+			return Result.error("未找到对应数据");
+		}
+		return Result.OK(devicePointInfos);
+	}
 }

+ 20 - 0
jeecg-module-gather/src/main/java/org/jeecg/modules/devicePoint/entity/DevicePointInfos.java

@@ -0,0 +1,20 @@
+package org.jeecg.modules.devicePoint.entity;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import org.jeecg.modules.device.entity.DeviceGatherService;
+
+import java.util.List;
+
+@Data
+@ApiModel(value="device_point对象", description="设备采集点和通道信息")
+public class DevicePointInfos {
+
+    @ApiModelProperty(value = "设备采集点集合")
+    private List<DevicePoint> devicePoints;
+
+    @ApiModelProperty(value = "设备采集点服务集合")
+    private List<DeviceGatherService> deviceGatherServices;
+
+}

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

@@ -18,8 +18,8 @@ public class EditDevicePointBatchParam {
     private String deviceId;
 
     @ApiModelProperty(value = "设备采集点集合")
-    private List<DevicePoint> devicePoints;
+    private List<String> devicePoints;
 
     @ApiModelProperty(value = "已删除的设备采集点集合")
-    private List<DevicePoint> deleteDevicePoints;
+    private List<String> deleteDevicePoints;
 }

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

@@ -2,6 +2,7 @@ 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.DevicePointInfos;
 import org.jeecg.modules.devicePoint.entity.EditBatchParam;
 import org.jeecg.modules.devicePoint.entity.EditDevicePointBatchParam;
 
@@ -20,4 +21,6 @@ public interface IDevicePointService extends IService<DevicePoint> {
     List<DevicePoint> queryListByType(String deviceGather);
 
     void editDevicePointBatch(EditDevicePointBatchParam editDevicePointBatchParam);
+
+    DevicePointInfos getByDeviceId(String deviceId);
 }

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

@@ -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;
+    }
 }