From ea82f635e918891f1f1fe3b7e2f62d34d19db542 Mon Sep 17 00:00:00 2001 From: xins Date: Fri, 27 Oct 2023 16:05:02 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8B=A5=E4=BE=9D=E5=BE=AE=E6=9C=8D=E5=8A=A11.?= =?UTF-8?q?6.4=201=E3=80=81=E8=8E=B7=E5=8F=96=E8=AE=BE=E5=A4=87=E5=9C=A8?= =?UTF-8?q?=E7=BA=BF=E6=95=B0=E9=87=8F=E6=97=B6=EF=BC=8C=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E7=9B=B4=E8=BF=9E=E8=AE=BE=E5=A4=87=E6=95=B0=E9=87=8F=202?= =?UTF-8?q?=E3=80=81=E6=A0=B9=E6=8D=AE=E7=9B=91=E6=8E=A7=E5=8D=95=E5=85=83?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E8=AE=BE=E5=A4=87=E6=97=B6=EF=BC=8C=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E8=8E=B7=E5=8F=96=E7=9B=B4=E8=BF=9E=E8=AE=BE=E5=A4=87?= =?UTF-8?q?=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/HwDeviceController.java | 44 +++++++------------ .../ruoyi/business/mapper/HwDeviceMapper.java | 2 + .../service/impl/HwDeviceServiceImpl.java | 7 ++- .../impl/HwMonitorUnitServiceImpl.java | 2 +- .../mapper/business/HwDeviceMapper.xml | 18 +++++++- 5 files changed, 40 insertions(+), 33 deletions(-) diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/controller/HwDeviceController.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/controller/HwDeviceController.java index 7c110a6..22454c0 100644 --- a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/controller/HwDeviceController.java +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/controller/HwDeviceController.java @@ -1,41 +1,29 @@ package com.ruoyi.business.controller; -import java.util.Date; -import java.util.List; -import java.util.Map; -import javax.servlet.http.HttpServletResponse; - -import com.ruoyi.business.domain.*; +import com.ruoyi.business.domain.HwDevice; +import com.ruoyi.business.domain.HwDeviceMode; +import com.ruoyi.business.domain.HwMonitorUnit; +import com.ruoyi.business.domain.HwScene; import com.ruoyi.business.domain.VO.DeviceControlVo; -import com.ruoyi.business.domain.VO.DeviceModeVo; -import com.ruoyi.business.domain.VO.HwMonitorUnitVo; import com.ruoyi.business.service.IHwDeviceModeService; +import com.ruoyi.business.service.IHwDeviceService; import com.ruoyi.business.service.IHwMonitorUnitService; import com.ruoyi.business.service.IHwSceneService; import com.ruoyi.common.core.constant.HwDictConstants; -import com.ruoyi.common.security.annotation.InnerAuth; -import com.ruoyi.common.security.utils.SecurityUtils; -import com.ruoyi.system.api.domain.SysDept; -import com.ruoyi.system.api.domain.SysRole; -import com.ruoyi.system.api.domain.SysUser; -import com.ruoyi.system.api.model.LoginUser; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; -import com.ruoyi.common.log.annotation.Log; -import com.ruoyi.common.log.enums.BusinessType; -import com.ruoyi.common.security.annotation.RequiresPermissions; -import com.ruoyi.business.service.IHwDeviceService; +import com.ruoyi.common.core.utils.poi.ExcelUtil; import com.ruoyi.common.core.web.controller.BaseController; import com.ruoyi.common.core.web.domain.AjaxResult; -import com.ruoyi.common.core.utils.poi.ExcelUtil; import com.ruoyi.common.core.web.page.TableDataInfo; +import com.ruoyi.common.log.annotation.Log; +import com.ruoyi.common.log.enums.BusinessType; +import com.ruoyi.common.security.annotation.InnerAuth; +import com.ruoyi.common.security.annotation.RequiresPermissions; +import com.ruoyi.common.security.utils.SecurityUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletResponse; +import java.util.List; /** * 设备信息Controller diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/mapper/HwDeviceMapper.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/mapper/HwDeviceMapper.java index 8b7c436..359950d 100644 --- a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/mapper/HwDeviceMapper.java +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/mapper/HwDeviceMapper.java @@ -113,4 +113,6 @@ public interface HwDeviceMapper public int selectAbnormalDeviceNumCount(HwDevice hwDevice); + + public List selectHwDeviceListByMonitor(HwDevice hwDevice); } diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwDeviceServiceImpl.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwDeviceServiceImpl.java index 44e7a29..ba88544 100644 --- a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwDeviceServiceImpl.java +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwDeviceServiceImpl.java @@ -123,6 +123,10 @@ public class HwDeviceServiceImpl implements IHwDeviceService { @Transactional @Override public int insertHwDevice(HwDevice hwDevice) { + HwDevice duplicateDevice = hwDeviceMapper.selectHwDeviceByDeviceCode(hwDevice.getDeviceCode()); + if(duplicateDevice != null){ + throw new ServiceException("设备编号已经存在,请修改"); + } hwDevice.setCreateTime(DateUtils.getNowDate()); String deviceType = hwDevice.getDeviceType(); int deviceId = hwDeviceMapper.insertHwDevice(hwDevice); @@ -393,8 +397,7 @@ public class HwDeviceServiceImpl implements IHwDeviceService { List acquisitionDeviceVos = new ArrayList(); String databaseName = TdEngineConstants.getDatabaseName(); - queryHwDevice.setDeviceType(HwDictConstants.DEVICE_TYPE_GATEWAY_SUB_EQUIPMENT); - List hwDevices = hwDeviceMapper.selectHwDeviceList(queryHwDevice); + List hwDevices = hwDeviceMapper.selectHwDeviceListByMonitor(queryHwDevice); hwDevices.forEach(hwDevice -> { Long deviceId = hwDevice.getDeviceId(); HwDeviceModeFunction queryDeviceModeFunction = new HwDeviceModeFunction(); diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwMonitorUnitServiceImpl.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwMonitorUnitServiceImpl.java index 62ad7fb..d21c002 100644 --- a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwMonitorUnitServiceImpl.java +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwMonitorUnitServiceImpl.java @@ -180,7 +180,7 @@ public class HwMonitorUnitServiceImpl implements IHwMonitorUnitService { @Override public SubDeviceSumVo selectSubDeviceSum(Long sceneId) { AllNumsVo numsVo = selectAllNums(sceneId); - //获取在线设备数量,获取已发布状态子设备并且关联网关为在线的数量 + //获取在线设备数量,获取已发布状态子设备并且关联网关为在线的数量以及在线状态发布状态的直连设备数量之和 int onlineDeviceNum = hwDeviceMapper.getOnlineDeviceNum(sceneId); SubDeviceSumVo subDeviceSumVo = new SubDeviceSumVo(); diff --git a/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwDeviceMapper.xml b/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwDeviceMapper.xml index 1e9b538..bac5d95 100644 --- a/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwDeviceMapper.xml +++ b/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwDeviceMapper.xml @@ -232,8 +232,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" @@ -309,4 +309,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + + \ No newline at end of file