diff --git a/zc-business/src/main/java/com/zc/business/controller/DcSwitchController.java b/zc-business/src/main/java/com/zc/business/controller/DcSwitchController.java index 4f201cff..71a23dd2 100644 --- a/zc-business/src/main/java/com/zc/business/controller/DcSwitchController.java +++ b/zc-business/src/main/java/com/zc/business/controller/DcSwitchController.java @@ -2,6 +2,8 @@ package com.zc.business.controller; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; +import com.zc.business.domain.DcDevice; +import com.zc.business.domain.DcDeviceOfflineRecord; import com.zc.business.domain.DcSwitch; import com.zc.business.domain.Device; import com.zc.business.enums.UniversalEnum; @@ -111,8 +113,8 @@ public class DcSwitchController extends BaseController { } //设备处理建议 @PostMapping("/deviceDiagnostics") - public AjaxResult deviceDiagnostics(@RequestBody Device device) throws Exception { - if (device==null||device.getDeviceIp()==null){ + public AjaxResult deviceDiagnostics(@RequestBody DcDeviceOfflineRecord device) throws Exception { + if (device==null||device.getDeviceIp()==null||device.getDeviceType()==null){ return AjaxResult.error("参数错误"); } return dcSwitchService.deviceDiagnostics(device); diff --git a/zc-business/src/main/java/com/zc/business/mapper/DcSwitchMapper.java b/zc-business/src/main/java/com/zc/business/mapper/DcSwitchMapper.java index de5b45b5..1fa09aed 100644 --- a/zc-business/src/main/java/com/zc/business/mapper/DcSwitchMapper.java +++ b/zc-business/src/main/java/com/zc/business/mapper/DcSwitchMapper.java @@ -2,6 +2,7 @@ package com.zc.business.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.zc.business.domain.DcDevice; +import com.zc.business.domain.DcDeviceOfflineRecord; import com.zc.business.domain.DcSwitch; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -22,7 +23,7 @@ public interface DcSwitchMapper extends BaseMapper { //查询交换机ip存在的设备id List getSwitchIPDeviceId(); //根据设备ip查询设备id - List getDcDeviceId(String deviceIp); + List getDcDeviceId(@Param("deviceIp") String deviceIp,@Param("deviceType") String deviceType); //依据交换机ip查询交换机名称 List getSwitchName(String switchIp); //根据交换机ip查询对应的桩号 diff --git a/zc-business/src/main/java/com/zc/business/service/DcSwitchService.java b/zc-business/src/main/java/com/zc/business/service/DcSwitchService.java index 31c653fe..db7ad178 100644 --- a/zc-business/src/main/java/com/zc/business/service/DcSwitchService.java +++ b/zc-business/src/main/java/com/zc/business/service/DcSwitchService.java @@ -2,6 +2,7 @@ package com.zc.business.service; import com.ruoyi.common.core.domain.AjaxResult; import com.zc.business.domain.DcDevice; +import com.zc.business.domain.DcDeviceOfflineRecord; import com.zc.business.domain.DcSwitch; import com.zc.business.domain.Device; @@ -41,5 +42,5 @@ public interface DcSwitchService { //设备诊断 - AjaxResult deviceDiagnostics(Device device) throws Exception; + AjaxResult deviceDiagnostics(DcDeviceOfflineRecord device) throws Exception; } diff --git a/zc-business/src/main/java/com/zc/business/service/impl/DcSwitchServiceImpl.java b/zc-business/src/main/java/com/zc/business/service/impl/DcSwitchServiceImpl.java index 35e05223..48ca0ab4 100644 --- a/zc-business/src/main/java/com/zc/business/service/impl/DcSwitchServiceImpl.java +++ b/zc-business/src/main/java/com/zc/business/service/impl/DcSwitchServiceImpl.java @@ -9,6 +9,7 @@ import com.ruoyi.common.utils.spring.SpringUtils; import com.zc.business.constant.RedisKeyConstants; import com.zc.business.controller.DcDeviceController; import com.zc.business.domain.DcDevice; +import com.zc.business.domain.DcDeviceOfflineRecord; import com.zc.business.domain.DcSwitch; import com.zc.business.domain.Device; import com.zc.business.enums.UniversalEnum; @@ -176,8 +177,9 @@ public class DcSwitchServiceImpl extends ServiceImpl i @Override - public AjaxResult deviceDiagnostics(Device device) throws Exception { + public AjaxResult deviceDiagnostics(DcDeviceOfflineRecord device) throws Exception { String deviceIp = device.getDeviceIp(); + String deviceType = device.getDeviceType(); RedisCache redisCache = SpringUtils.getBean(RedisCache.class); String cacheObject = redisCache.getCacheObject(DEVICEDIAGNOSTICS+deviceIp);//获取缓存是否存在诊断结果 if (StringUtils.isNotBlank(cacheObject)){ //存在即返回 @@ -191,13 +193,13 @@ public class DcSwitchServiceImpl extends ServiceImpl i redisCache.setCacheObject(DEVICEDIAGNOSTICS+deviceIp,"设备网关网络异常",2, TimeUnit.MINUTES); return AjaxResult.success("设备网关网络异常"); } - List dcDeviceId = dcSwitchMapper.getDcDeviceId(deviceIp);//查询设备id + List dcDeviceId = dcSwitchMapper.getDcDeviceId(deviceIp,deviceType);//查询设备id DcDevice dcDevice = new DcDevice();//存放设备id if (dcDeviceId.size()>1){ redisCache.setCacheObject(DEVICEDIAGNOSTICS+deviceIp,"设备IP存在冲突",2, TimeUnit.MINUTES); return AjaxResult.success("设备IP存在冲突"); }else { - for (DcDevice dcDeviceValue:dcDeviceId){ + for (DcDeviceOfflineRecord dcDeviceValue:dcDeviceId){ dcDevice.setId(dcDeviceValue.getId());//存入设备id } } diff --git a/zc-business/src/main/resources/mapper/business/DcSwitchMapper.xml b/zc-business/src/main/resources/mapper/business/DcSwitchMapper.xml index 897b37bc..6cf9721a 100644 --- a/zc-business/src/main/resources/mapper/business/DcSwitchMapper.xml +++ b/zc-business/src/main/resources/mapper/business/DcSwitchMapper.xml @@ -70,8 +70,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - + select id from dc_device where device_ip=#{deviceIp} and device_type=#{deviceType}