若依微服务1.3.3

修复bug:
1、标准场景传scenceid值不对的问题
2、定位场景告警信息没有传sceneid的问题
3、设备监测页面监控单元信息显示的问题
4、设备监测页面查看设备信息传参传反的问题
dev 1.3.3
xins 1 year ago
parent deb1044dd4
commit 76a99b2d02

@ -36,6 +36,28 @@ cp ../ruoyi-modules/ruoyi-file/target/ruoyi-modules-file.jar ./ruoyi/modules/fil
echo "begin copy ruoyi-modules-job "
cp ../ruoyi-modules/ruoyi-job/target/ruoyi-modules-job.jar ./ruoyi/modules/job/jar
echo "begin copy ruoyi-modules-gen "
cp ../ruoyi-modules/ruoyi-gen/target/ruoyi-modules-gen.jar ./ruoyi/modules/gen/jar
echo "begin copy ruoyi-modules-basic "
cp ../ruoyi-modules/hw-basic/target/ruoyi-modules-basic.jar ./ruoyi/modules/basic/jar
echo "begin copy ruoyi-modules-business "
cp ../ruoyi-modules/hw-business/target/ruoyi-modules-business.jar ./ruoyi/modules/business/jar
echo "begin copy ruoyi-modules-dataprocess "
cp ../ruoyi-modules/hw-data-process/target/ruoyi-modules-dataprocess.jar ./ruoyi/modules/dataprocess/jar
echo "begin copy ruoyi-modules-mqttbroker"
cp ../ruoyi-modules/hw-mqtt-broker/target/ruoyi-modules-mqttbroker.jar ./ruoyi/modules/mqttbroker/jar
echo "begin copy ruoyi-modules-tdengine"
cp ../ruoyi-modules/hw-tdengine/target/ruoyi-modules-tdengine.jar ./ruoyi/modules/tdengine/jar

@ -21,6 +21,18 @@ port(){
firewall-cmd --add-port=9202/tcp --permanent
firewall-cmd --add-port=9203/tcp --permanent
firewall-cmd --add-port=9300/tcp --permanent
firewall-cmd --add-port=9600/tcp --permanent
firewall-cmd --add-port=9601/tcp --permanent
firewall-cmd --add-port=9603/tcp --permanent
firewall-cmd --add-port=9605/tcp --permanent
firewall-cmd --add-port=9602/tcp --permanent
firewall-cmd --add-port=9080/tcp --permanent
firewall-cmd --add-port=9660/tcp --permanent
firewall-cmd --add-port=9661/tcp --permanent
firewall-cmd --add-port=9663/tcp --permanent
firewall-cmd --add-port=9665/tcp --permanent
firewall-cmd --add-port=9666/tcp --permanent
firewall-cmd --add-port=9080/tcp --permanent
service firewalld restart
}
@ -31,9 +43,10 @@ base(){
# 启动程序模块(必须)
modules(){
docker-compose up -d ruoyi-nginx ruoyi-gateway ruoyi-auth ruoyi-modules-system
docker-compose up -d ruoyi-nginx ruoyi-gateway ruoyi-auth ruoyi-modules-system ruoyi-modules-business ruoyi-modules-basic ruoyi-modules-mqttbroker ruoyi-modules-tdengine ruoyi-modules-dataprocess
}
# 关闭所有环境/模块
stop(){
docker-compose stop

@ -1,56 +1,7 @@
version : '3.8'
services:
ruoyi-nacos:
container_name: ruoyi-nacos
image: nacos/nacos-server
build:
context: ./nacos
environment:
- MODE=standalone
volumes:
- ./nacos/logs/:/home/nacos/logs
- ./nacos/conf/application.properties:/home/nacos/conf/application.properties
ports:
- "8848:8848"
- "9848:9848"
- "9849:9849"
depends_on:
- ruoyi-mysql
ruoyi-mysql:
container_name: ruoyi-mysql
image: mysql:5.7
build:
context: ./mysql
ports:
- "3306:3306"
volumes:
- ./mysql/conf:/etc/mysql/conf.d
- ./mysql/logs:/logs
- ./mysql/data:/var/lib/mysql
command: [
'mysqld',
'--innodb-buffer-pool-size=80M',
'--character-set-server=utf8mb4',
'--collation-server=utf8mb4_unicode_ci',
'--default-time-zone=+8:00',
'--lower-case-table-names=1'
]
environment:
MYSQL_DATABASE: 'ry-cloud'
MYSQL_ROOT_PASSWORD: 123456
ruoyi-redis:
container_name: ruoyi-redis
image: redis
build:
context: ./redis
ports:
- "6379:6379"
volumes:
- ./redis/conf/redis.conf:/home/ruoyi/redis/redis.conf
- ./redis/data:/data
command: redis-server /home/ruoyi/redis/redis.conf
ruoyi-nginx:
container_name: ruoyi-nginx
container_name: hwsaas-nginx
image: nginx
build:
context: ./nginx
@ -71,70 +22,74 @@ services:
context: ./ruoyi/gateway
dockerfile: dockerfile
ports:
- "8080:8080"
depends_on:
- ruoyi-redis
links:
- ruoyi-redis
- "9080:9080"
ruoyi-auth:
container_name: ruoyi-auth
build:
context: ./ruoyi/auth
dockerfile: dockerfile
ports:
- "9200:9200"
depends_on:
- ruoyi-redis
links:
- ruoyi-redis
- "9660:9660"
ruoyi-modules-system:
container_name: ruoyi-modules-system
build:
context: ./ruoyi/modules/system
dockerfile: dockerfile
ports:
- "9201:9201"
depends_on:
- ruoyi-redis
- ruoyi-mysql
links:
- ruoyi-redis
- ruoyi-mysql
ruoyi-modules-gen:
container_name: ruoyi-modules-gen
build:
context: ./ruoyi/modules/gen
dockerfile: dockerfile
ports:
- "9202:9202"
depends_on:
- ruoyi-mysql
links:
- ruoyi-mysql
- "9661:9661"
ruoyi-modules-job:
container_name: ruoyi-modules-job
build:
context: ./ruoyi/modules/job
dockerfile: dockerfile
ports:
- "9203:9203"
depends_on:
- ruoyi-mysql
links:
- ruoyi-mysql
- "9663:9663"
ruoyi-modules-file:
container_name: ruoyi-modules-file
build:
context: ./ruoyi/modules/file
dockerfile: dockerfile
ports:
- "9300:9300"
- "9665:9665"
volumes:
- ./ruoyi/uploadPath:/home/ruoyi/uploadPath
ruoyi-visual-monitor:
container_name: ruoyi-visual-monitor
ruoyi-modules-basic:
container_name: ruoyi-modules-basic
build:
context: ./ruoyi/modules/basic
dockerfile: dockerfile
ports:
- "9600:9600"
ruoyi-modules-business:
container_name: ruoyi-modules-business
build:
context: ./ruoyi/modules/business
dockerfile: dockerfile
ports:
- "9601:9601"
ruoyi-modules-mqttbroker:
container_name: ruoyi-modules-mqttbroker
build:
context: ./ruoyi/modules/mqttbroker
dockerfile: dockerfile
ports:
- "9605:9605"
ruoyi-modules-dataprocess:
container_name: ruoyi-modules-dataprocess
build:
context: ./ruoyi/modules/dataprocess
dockerfile: dockerfile
ports:
- "9603:9603"
depends_on:
- ruoyi-modules-mqttbroker
links:
- ruoyi-modules-mqttbroker
ruoyi-modules-tdengine:
container_name: ruoyi-modules-tdengine
build:
context: ./ruoyi/visual/monitor
context: ./ruoyi/modules/tdengine
dockerfile: dockerfile
ports:
- "9100:9100"
- "9602:9602"

@ -11,8 +11,8 @@ http {
keepalive_timeout 65;
server {
listen 80;
server_name localhost;
listen 8018;
server_name 175.27.215.92;
location / {
root /home/ruoyi/projects/ruoyi-ui;

@ -227,6 +227,14 @@
<version>${ruoyi.version}</version>
</dependency>
<!-- 基本模块接口 -->
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>hw-api-business</artifactId>
<version>${ruoyi.version}</version>
</dependency>
</dependencies>
</dependencyManagement>

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-api</artifactId>
<version>3.6.3</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>hw-api-business</artifactId>
<description>
hw-api-business平台业务模块
</description>
<dependencies>
<!-- RuoYi Common Core-->
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-common-core</artifactId>
</dependency>
</dependencies>
</project>

@ -0,0 +1,21 @@
package com.ruoyi.business.api;
import com.ruoyi.business.api.factory.RemoteBusinessFallbackFactory;
import com.ruoyi.common.core.constant.ServiceNameConstants;
import com.ruoyi.common.core.domain.R;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
@FeignClient(contextId = "remoteBusinessService", value = ServiceNameConstants.BUSINESS_SERVICE, fallbackFactory = RemoteBusinessFallbackFactory.class)
public interface RemoteBusinessService {
/**
*
*
* @param days
* @return
*/
@GetMapping("/device/computeOnlineDevicecCount/{days}")
public R<?> computeOnlineDevicecCount(@PathVariable("days") int days);
}

@ -0,0 +1,26 @@
package com.ruoyi.business.api.factory;
import com.ruoyi.business.api.RemoteBusinessService;
import com.ruoyi.common.core.domain.R;
import org.springframework.cloud.openfeign.FallbackFactory;
import java.util.List;
/**
* @Description:
* @ClassName: RemoteBusinessFallbackFactory
* @Author : xins
* @Date :2023-09-20 20:25
* @Version :1.0
*/
public class RemoteBusinessFallbackFactory implements FallbackFactory<RemoteBusinessService> {
@Override
public RemoteBusinessService create(Throwable throwable) {
return new RemoteBusinessService() {
@Override
public R<?> computeOnlineDevicecCount(int days) {
return R.fail("获取租户信息失败:" + throwable.getMessage());
}
};
}
}

@ -20,7 +20,7 @@ import java.util.Map;
public interface RemoteTdEngineService {
@PostMapping("/tdengine/createDatabase")
R<?> createDataBase(@RequestParam("databaseName") String databaseName);
R<?> createDataBase(@RequestBody String databaseName);
@PostMapping("/tdengine/createSuperTable")
R<?> createSuperTable(@Validated @RequestBody TdSuperTableVo tdSuperTableVo);
@ -54,4 +54,7 @@ public interface RemoteTdEngineService {
@PostMapping("/tdengine/getOnlineDevicesGroupByDay")
R<?> getOnlineDevicesGroupByDay(@Validated @RequestBody DeviceStatus queryDeviceStatus);
@PostMapping("/tdengine/getLastOnlineDevices")
R<?> getLastOnlineDevices(@Validated @RequestBody DeviceStatus queryDeviceStatus);
}

@ -23,6 +23,9 @@ public class DeviceStatus extends BaseEntity {
private Long sceneId;
private Long startTime;
private Long endTime;
public Long getTs() {
return ts;
}
@ -70,4 +73,20 @@ public class DeviceStatus extends BaseEntity {
public void setSceneId(Long sceneId) {
this.sceneId = sceneId;
}
public Long getStartTime() {
return startTime;
}
public void setStartTime(Long startTime) {
this.startTime = startTime;
}
public Long getEndTime() {
return endTime;
}
public void setEndTime(Long endTime) {
this.endTime = endTime;
}
}

@ -86,6 +86,11 @@ public class RemoteTdEngineFallbackFactory implements FallbackFactory<RemoteTdEn
return R.fail("获取设备状态失败:" + throwable.getMessage());
}
@Override
public R<?> getLastOnlineDevices(DeviceStatus queryDeviceStatus) {
return R.fail("获取最近设备状态失败:" + throwable.getMessage());
}
};
}
}

@ -12,6 +12,7 @@
<module>ruoyi-api-system</module>
<module>hw-api-tdengine</module>
<module>hw-api-basic</module>
<module>hw-api-business</module>
</modules>
<artifactId>ruoyi-api</artifactId>

@ -1,6 +1,6 @@
# Tomcat
server:
port: 9200
port: 9660
# Spring
spring:

@ -58,6 +58,8 @@ public class HwDictConstants {
public static final String REDIS_KEY_DEVICE_INFO = "hw_device_info";//保存设备用户名和密码等信息的redis的key
public static final String REDIS_KEY_ONLINE_DEVICE_COUNT_INFO = "online_device_count";//按照天存放每天设备在线数量
public static final String DEVICE_MODE_STATUS_NORMAL = "1";//设备模型正常状态
public static final String SCENE_DEFAULT_FLAG_YES = "1";//场景是否默认标识:是
@ -77,4 +79,9 @@ public class HwDictConstants {
SCENE_MODE_ROUTER_MAP.put(SCENE_MODE_GPS, ROUTER_GPS);
}
public static final String DEVICE_ONLINE_STATUS_ONLINE="1";//在线状态
public static final String DEVICE_ONLINE_STATUS_OFFLINE="0"; //离线状态
public static final String ALARM_HANDLE_STATUS_YES = "1";//已处理
public static final String ALARM_HANDLE_STATUS_NO = "0";//未处理
}

@ -31,4 +31,9 @@ public class ServiceNameConstants
* basicserviceid
*/
public static final String BASIC_SERVICE = "hw-basic";
/**
* businessserviceid
*/
public static final String BUSINESS_SERVICE = "hw-business";
}

@ -39,6 +39,9 @@ public class TdEngineConstants {
public static final int ST_TAG_DEVICECODE_SIZE=50;
public static final String ST_TAG_DEVICENAME = "devicename";
public static final String ST_TAG_DEVICETYPE = "devicetype";
public static final String ST_TAG_ONLINESTATUS = "onlinestatus";
public static final int ST_TAG_DEVICENAME_TYPE = 10;
public static final int ST_TAG_DEVICENAME_SIZE=200;

@ -28,6 +28,8 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
public static String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss";
public static final String MM_DD = "MM-dd";
private static String[] parsePatterns = {
"yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm", "yyyy-MM",
"yyyy/MM/dd", "yyyy/MM/dd HH:mm:ss", "yyyy/MM/dd HH:mm", "yyyy/MM",

@ -1,6 +1,6 @@
# Tomcat
server:
port: 8080
port: 9080
# Spring
spring:

@ -9,7 +9,7 @@
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>rouyi-modules-business</artifactId>
<artifactId>ruoyi-modules-business</artifactId>
<description>
海威物联网平台业务模块
@ -104,6 +104,12 @@
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.json</artifactId>
<version>1.0.4</version>
<scope>compile</scope>
</dependency>
</dependencies>

@ -196,4 +196,8 @@ public class HwDeviceController extends BaseController
return toAjax(hwDeviceService.updateHwDevice(device));
}
@GetMapping("/computeOnlineDevicecCount/{days}")
public void computeOnlineDevicecCount(@PathVariable("days") int days){
hwDeviceService.computeOnlineDevicecCount(days);
}
}

@ -4,15 +4,19 @@ import com.alibaba.fastjson.JSONObject;
import com.ruoyi.business.domain.*;
import com.ruoyi.business.domain.VO.*;
import com.ruoyi.business.service.*;
import com.ruoyi.common.core.constant.HwDictConstants;
import com.ruoyi.common.core.constant.TdEngineConstants;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.common.security.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
@ -39,6 +43,7 @@ public class HwMonitorPlatformController extends BaseController {
/**
* 3.
*/
@RequiresPermissions("business:monitor:index")
@GetMapping("/monitorUnitPercentage")
public TableDataInfo monitorUnitPercentage() {
List<DeviceModeVo> maps = hwDeviceService.selectDeviceModeNameVo();
@ -48,6 +53,7 @@ public class HwMonitorPlatformController extends BaseController {
/**
* ()
*/
@RequiresPermissions("business:monitor:index")
@GetMapping("/monitorPercentage")
public TableDataInfo monitorPercentage() {
List<HwMonitorUnitVo> maps = hwMonitorUnitService.selectMonitorPercentage();
@ -57,6 +63,7 @@ public class HwMonitorPlatformController extends BaseController {
/**
*
*/
@RequiresPermissions("business:monitor:index")
@GetMapping("/allNums")
public AllNumsVo allNums() {
AllNumsVo allNumsVos = hwMonitorUnitService.selectAllNums(null);
@ -72,33 +79,37 @@ public class HwMonitorPlatformController extends BaseController {
* @date 2023-09-15 11:03
*/
@GetMapping("/getAlarmInfos")
@RequiresPermissions("business:monitor:alarm")
public TableDataInfo getAlarmInfos(HwAlarmInfo hwAlarmInfo) {
startPage();
//startPage();
hwAlarmInfo.setHandleStatus(HwDictConstants.ALARM_HANDLE_STATUS_NO);
List<HwAlarmInfo> alarmInfos = hwAlarmInfoService.selectHwAlarmInfoList(hwAlarmInfo);
return getDataTable(alarmInfos);
}
@PutMapping("/handleAlarmInfo")
@RequiresPermissions("business:monitor:alarm")
public AjaxResult handleAlarmInfo(@RequestBody HwAlarmInfo hwAlarmInfo){
hwAlarmInfo.setUpdateBy(SecurityUtils.getUsername());
return toAjax(hwAlarmInfoService.updateHwAlarmInfo(hwAlarmInfo));
}
/**
* 2. 线()
*
* @param sceneId id
*/
@RequiresPermissions("business:monitor:index")
@GetMapping("/getDeviceOperations/{sceneId}")
public AjaxResult selectDeviceStatus(@PathVariable("sceneId") Long sceneId) {
JSONObject data = new JSONObject();
data.put("10-01", 10);
data.put("10-02", 20);
data.put("10-03", 30);
data.put("10-04", 40);
data.put("10-05", 16);
return AjaxResult.success(data);
return AjaxResult.success(hwDeviceService.getOnlineDevicesCount(sceneId));
}
/**
*
*
*/
@RequiresPermissions("business:monitor:standard")
@GetMapping("/sceneAllNums/{sceneId}")
public AllNumsVo sceneAllNums(@PathVariable("sceneId") Long sceneId) {
AllNumsVo allNumsVos = hwMonitorUnitService.selectAllNums(sceneId);
@ -108,14 +119,24 @@ public class HwMonitorPlatformController extends BaseController {
/**
* ()
*/
@RequiresPermissions("business:monitor:standard")
@GetMapping("/limitSubMonitorUnit/{sceneId}")
public TableDataInfo limitSubMonitorUnit(@PathVariable("sceneId") Long sceneId) {
//todo sceneid should be
HwMonitorUnit hwMonitorUnit = new HwMonitorUnit();
hwMonitorUnit.setSceneId(sceneId);
startPage();
List<HwMonitorUnit> hwMonitorUnits = hwMonitorUnitService.selectLimitSubMonitorUnit();
List<HwMonitorUnit> hwMonitorUnits = hwMonitorUnitService.selectLimitSubMonitorUnit(hwMonitorUnit);
return getDataTable(hwMonitorUnits);
}
/**
* @return AjaxResult
* @param: sceneId
* @description
* @author xins
* @date 2023-09-21 11:35
*/
@RequiresPermissions("business:monitor:standard")
@GetMapping("/getAlarmCountGroupAlarmType/{sceneId}")
public AjaxResult getAlarmCountGroupAlarmType(@PathVariable("sceneId") Long sceneId) {
return success(hwAlarmInfoService.selectAlarmsByAlarmType(sceneId));
@ -126,25 +147,10 @@ public class HwMonitorPlatformController extends BaseController {
*
* @param sceneId
*/
@RequiresPermissions("business:monitor:gps")
@GetMapping("/ElectronicNumVo/{sceneId}")
public AjaxResult ElectronicNumVo(@PathVariable("sceneId") Long sceneId) {
// {
// type:'多边形',
// children:[{
// latitude:'',
// longtitude:''
// }]
// }
// {
// type:'圆形',
// centerpoint:{
// 'lantitude':,
// 'longtitude':,
// }
// }
// }
return success(hwElectronicFenceService.selectEleTypeNums(sceneId));
}
@ -159,10 +165,11 @@ public class HwMonitorPlatformController extends BaseController {
}
/**
* 线
* 线
*
* @param sceneId id
*/
@RequiresPermissions("business:monitor:gps")
@GetMapping("/subDevice/{sceneId}")
public SubDeviceSumVo subDevice(@PathVariable("sceneId") Long sceneId) {
@ -179,9 +186,9 @@ public class HwMonitorPlatformController extends BaseController {
* @return list
* @throws
*/
@RequiresPermissions("business:monitor:deviceMonitor")
@GetMapping("/treeList/{sceneId}")
public AjaxResult monitorUnitTree(@PathVariable("sceneId") Long sceneId)
{
public AjaxResult monitorUnitTree(@PathVariable("sceneId") Long sceneId) {
HwMonitorUnit queryMonitorUnit = new HwMonitorUnit();
queryMonitorUnit.setSceneId(sceneId);
return success(hwMonitorUnitService.selectMonitorTreeList(queryMonitorUnit));
@ -207,9 +214,10 @@ public class HwMonitorPlatformController extends BaseController {
*
*/
// @RequiresPermissions("business:monitorUnit:query")
@RequiresPermissions("business:monitor:deviceMonitor")
@GetMapping(value = "/getMonitorById/{monitorUnitId}")
public AjaxResult getMonitorById(@PathVariable("monitorUnitId") Long monitorUnitId) {
return success(hwMonitorUnitService.selectHwMonitorUnitByMonitorUnitId(monitorUnitId));
return success(hwMonitorUnitService.selectHwMonitorUnitJoinByMonitorUnitId(monitorUnitId));
}
/**
@ -217,6 +225,7 @@ public class HwMonitorPlatformController extends BaseController {
*
* @param monitorUnitId id
*/
@RequiresPermissions("business:monitor:deviceMonitor")
@GetMapping("/selectDevicesByMonitorUnitId/{monitorUnitId}/{sceneId}")
public AjaxResult selectDeviceByDeviceModeByMonitorUnitId(@PathVariable("monitorUnitId") Long monitorUnitId,
@PathVariable("sceneId") Long sceneId) {
@ -229,10 +238,11 @@ public class HwMonitorPlatformController extends BaseController {
/**
* @description ID
* @description ID()
* @author xins
* @date 2023-09-16 12:44
*/
@RequiresPermissions("business:monitor:deviceList")
@PostMapping("/getDeviceModesBySceneId")
public AjaxResult getDeviceModesBySceneId(@RequestBody HwDeviceMode queryHwDeviceMode) {
return success(hwDeviceModeService.selectHwDeviceModeList(queryHwDeviceMode));
@ -241,10 +251,11 @@ public class HwMonitorPlatformController extends BaseController {
/**
* @return AjaxResult
* @param: monitorUnitId
* @description
* @description
* @author xins
* @date 2023-09-16 12:45
*/
@RequiresPermissions("business:monitor:deviceList")
@PostMapping("/selectLatestDataByDeviceMode")
public AjaxResult selectLatestDataByDeviceMode(@Validated @RequestBody DeviceLatestDataVo deviceLatestData) {
JSONObject returnObj = new JSONObject();
@ -255,16 +266,16 @@ public class HwMonitorPlatformController extends BaseController {
returnObj.put("latestData", latestDataMaps);
return success(returnObj);
}
@RequiresPermissions("business:monitor:deviceInfo")
@GetMapping("/getDeviceInfo/{deviceId}")
public AjaxResult getDeviceInfo(@PathVariable("deviceId") Long deviceId){
public AjaxResult getDeviceInfo(@PathVariable("deviceId") Long deviceId) {
HwDevice device = hwDeviceService.selectHwDeviceJoinByDeviceId(deviceId);
return success(device);
}
@RequiresPermissions("business:monitor:deviceInfo")
@GetMapping("/getLinkDevices/{deviceId}")
public AjaxResult getLinkDevices(@PathVariable("deviceId")Long deviceId){
public AjaxResult getLinkDevices(@PathVariable("deviceId") Long deviceId) {
return success(hwDeviceService.selectLinkDeviceList(deviceId));
}
@ -275,6 +286,7 @@ public class HwMonitorPlatformController extends BaseController {
* @author xins
* @date 2023-09-16 15:15
*/
@RequiresPermissions("business:monitor:deviceInfo")
@PostMapping("/getHistoryData")
public AjaxResult getHistoryData(@Validated @RequestBody DeviceHistoryDataVo deviceHistoryData) {
// startPage();
@ -288,7 +300,7 @@ public class HwMonitorPlatformController extends BaseController {
}
private List<DeviceDataColumnVo> getDeviceDataColumns(List<Map<String, Object>> latestDataMaps){
private List<DeviceDataColumnVo> getDeviceDataColumns(List<Map<String, Object>> latestDataMaps) {
List<DeviceDataColumnVo> deviceDataColumnVos = new ArrayList<DeviceDataColumnVo>();
if (latestDataMaps != null && latestDataMaps.size() > 0) {
Map<String, Object> latestDataMap = latestDataMaps.get(0);

@ -68,7 +68,7 @@ public class HwMonitorUnit extends BaseEntity
private String sceneName;
private String monitorUnitTypeName;
private String tenantName;
private boolean normalFlag;//是否正常(如果有报警未处理的则为异常)
private List<HwMonitorUnit> child = new ArrayList<HwMonitorUnit>();
@ -224,6 +224,14 @@ public class HwMonitorUnit extends BaseEntity
this.tenantName = tenantName;
}
public boolean isNormalFlag() {
return normalFlag;
}
public void setNormalFlag(boolean normalFlag) {
this.normalFlag = normalFlag;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)

@ -0,0 +1,11 @@
package com.ruoyi.business.domain.VO;
import lombok.Data;
@Data
public class AlarmInfoVo {
private Integer alarmCount;
}

@ -2,6 +2,7 @@ package com.ruoyi.business.mapper;
import java.util.List;
import com.ruoyi.business.domain.HwAlarmInfo;
import com.ruoyi.business.domain.VO.AlarmInfoVo;
import com.ruoyi.business.domain.VO.AlarmTypeVo;
/**
@ -62,4 +63,7 @@ public interface HwAlarmInfoMapper
public List<AlarmTypeVo> selectAlarmsByAlarmType(Long sceneId);
public AlarmInfoVo selectAlarmCountByFenceArea(Long fenceAreaId);
}

@ -38,7 +38,7 @@ public interface HwMonitorUnitMapper
/**
*
* */
public List<HwMonitorUnit> selectLimitSubMonitorUnit();
public List<HwMonitorUnit> selectLimitSubMonitorUnit(HwMonitorUnit hwMonitorUnit);
Integer selectReleatedDeviceIdNums(Long deviceCode);
Integer selectDeviceNums(Long sceneId);
Integer selectSubDeviceSum(Long sceneId);
@ -130,4 +130,12 @@ public interface HwMonitorUnitMapper
*/
public List<HwMonitorUnit> selectHwMonitorUnitJoinList(HwMonitorUnit hwMonitorUnit);
/**
* Join monitorunittypename
*
* @param monitorUnitId
* @return
*/
public HwMonitorUnit selectHwMonitorUnitJoinByMonitorUnitId(Long monitorUnitId);
}

@ -3,6 +3,7 @@ package com.ruoyi.business.service;
import java.util.List;
import java.util.Map;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.business.domain.HwDevice;
import com.ruoyi.business.domain.VO.DeviceModeVo;
import com.ruoyi.business.domain.VO.HwDeviceVo;
@ -104,4 +105,21 @@ public interface IHwDeviceService
*/
public List<HwDevice> selectHwDeviceJoinList(HwDevice hwDevice);
/**
* @param: days
* @description 线
* @author xins
* @date 2023-09-20 19:28
*/
public void computeOnlineDevicecCount(int days);
/**
* @param: sceneId
* @description 线
* @author xins
* @date 2023-09-21 9:09
* @return JSONObject
*/
public JSONObject getOnlineDevicesCount(Long sceneId);
}

@ -38,7 +38,7 @@ public interface IHwMonitorUnitService
/**
*
* */
public List<HwMonitorUnit> selectLimitSubMonitorUnit();
public List<HwMonitorUnit> selectLimitSubMonitorUnit(HwMonitorUnit hwMonitorUnit);
/**
*
@ -139,4 +139,11 @@ public interface IHwMonitorUnitService
*/
public List<HwMonitorUnit> selectHwMonitorUnitJoinList(HwMonitorUnit hwMonitorUnit);
/**
* ,Join monitorunittype
*
* @param monitorUnitId
* @return
*/
public HwMonitorUnit selectHwMonitorUnitJoinByMonitorUnitId(Long monitorUnitId);
}

@ -8,7 +8,9 @@ import java.util.stream.Collectors;
import com.ruoyi.business.domain.HwAlarmType;
import com.ruoyi.business.domain.VO.AlarmTypeVo;
import com.ruoyi.business.mapper.HwAlarmTypeMapper;
import com.ruoyi.common.core.constant.HwDictConstants;
import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.common.datascope.annotation.DataScope;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.business.mapper.HwAlarmInfoMapper;
@ -47,6 +49,7 @@ public class HwAlarmInfoServiceImpl implements IHwAlarmInfoService {
* @return
*/
@Override
@DataScope(tenantAlias = "hai")
public List<HwAlarmInfo> selectHwAlarmInfoList(HwAlarmInfo hwAlarmInfo) {
return hwAlarmInfoMapper.selectHwAlarmInfoList(hwAlarmInfo);
}
@ -72,6 +75,7 @@ public class HwAlarmInfoServiceImpl implements IHwAlarmInfoService {
@Override
public int updateHwAlarmInfo(HwAlarmInfo hwAlarmInfo) {
hwAlarmInfo.setUpdateTime(DateUtils.getNowDate());
hwAlarmInfo.setHandleStatus(HwDictConstants.ALARM_HANDLE_STATUS_YES);
return hwAlarmInfoMapper.updateHwAlarmInfo(hwAlarmInfo);
}

@ -3,6 +3,7 @@ package com.ruoyi.business.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.nacos.shaded.com.google.gson.JsonObject;
import com.ruoyi.business.domain.HwDevice;
import com.ruoyi.business.domain.HwDeviceModeFunction;
import com.ruoyi.business.domain.HwScene;
@ -23,20 +24,14 @@ import com.ruoyi.common.core.utils.NumberUtils;
import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.common.datascope.annotation.DataScope;
import com.ruoyi.tdengine.api.RemoteTdEngineService;
import com.ruoyi.tdengine.api.domain.AlterTagVo;
import com.ruoyi.tdengine.api.domain.TdField;
import com.ruoyi.tdengine.api.domain.TdSelectDto;
import com.ruoyi.tdengine.api.domain.TdTableVo;
import com.ruoyi.tdengine.api.domain.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
/**
@ -156,7 +151,7 @@ public class HwDeviceServiceImpl implements IHwDeviceService {
for (Object deviceInfoObj : deviceInfoJsonArr) {
JSONObject deviceInfoJson = (JSONObject) deviceInfoObj;
if (deviceInfoJson.getString("deviceCode").equals(hwDevice.getDeviceCode())) {
deviceInfoJson.put("username", modeAccount);
deviceInfoJson.put("userName", modeAccount);
deviceInfoJson.put("password", modeKey);
redisUpdated = true;
}
@ -468,4 +463,131 @@ public class HwDeviceServiceImpl implements IHwDeviceService {
public List<HwDevice> selectHwDeviceJoinList(HwDevice hwDevice) {
return hwDeviceMapper.selectHwDeviceJoinList(hwDevice);
}
/**
* @param: days
* @description 线
* @author xins
* @date 2023-09-20 19:28
*/
@Override
public void computeOnlineDevicecCount(int days) {
JSONObject jsonObject = new JSONObject();
for (int i = 1; i <= days; i++) {
Date currentDate = new Date();
Calendar calendar = Calendar.getInstance();
calendar.setTime(currentDate);
calendar.add(Calendar.DAY_OF_MONTH, -i);
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
Long startTime = calendar.getTimeInMillis();//先是昨天 00:00
calendar.set(Calendar.HOUR_OF_DAY, 23);
calendar.set(Calendar.MINUTE, 59);
calendar.set(Calendar.SECOND, 59);
Long endTime = calendar.getTimeInMillis();//23:59.59
Map<Long, Integer> onlineDeviceCountPerDay = computeDeviceCountPerDay(startTime, endTime);
Set<Long> times = onlineDeviceCountPerDay.keySet();
for (Long key : times) {
jsonObject.put(String.valueOf(key), onlineDeviceCountPerDay.get(key));
}
}
redisTemplate.opsForValue().set(HwDictConstants.REDIS_KEY_ONLINE_DEVICE_COUNT_INFO,jsonObject.toString());
}
private Map<Long, Integer> computeDeviceCountPerDay(Long startTime, Long endTime) {
DeviceStatus queryGroupStatus = new DeviceStatus();
queryGroupStatus.setStartTime(startTime);
queryGroupStatus.setEndTime(endTime);
DeviceStatus queryLastStatus = new DeviceStatus();
queryLastStatus.setEndTime(startTime);
Map<Long, Integer> onlineDeviceCountByDay = new HashMap<Long, Integer>();
Map<Long, List<DeviceStatus>> groupDeviceStatuMapList =
(Map<Long, List<DeviceStatus>>) this.remoteTdEngineService.getOnlineDevicesGroupByDay(queryGroupStatus).getData();
if (groupDeviceStatuMapList == null) {
groupDeviceStatuMapList = new HashMap<>();
}
List<Map<String, Object>> lastDeviceStatuMapList =
(List<Map<String, Object>>) this.remoteTdEngineService.getLastOnlineDevices(queryLastStatus).getData();
for (Map<String, Object> groupDeviceStatuMap : lastDeviceStatuMapList) {
DeviceStatus ds = new DeviceStatus();
for (Map.Entry<String, Object> entry : groupDeviceStatuMap.entrySet()) {
if (entry.getKey().equals(TdEngineConstants.ST_TAG_DEVICEID)) {
ds.setDeviceId((long) (Integer) entry.getValue());
} else if (entry.getKey().equals(TdEngineConstants.ST_TAG_DEVICETYPE)) {
ds.setDeviceType((Integer) entry.getValue());
} else if (entry.getKey().equals(TdEngineConstants.ST_TAG_ONLINESTATUS)) {
ds.setOnlineStatus((Integer) entry.getValue());
}
}
List<DeviceStatus> dss = groupDeviceStatuMapList.get(ds.getDeviceId());
int count = 0;
if (dss == null) {
if (String.valueOf(ds.getOnlineStatus())
.equals(HwDictConstants.DEVICE_ONLINE_STATUS_ONLINE)) {
count = this.getDeviceCount(ds);
}
} else {
count = this.getDeviceCount(dss.get(0));
}
if (onlineDeviceCountByDay.get(startTime) == null) {
onlineDeviceCountByDay.put(startTime, count);
} else {
onlineDeviceCountByDay.put(startTime, onlineDeviceCountByDay.get(startTime) + count);
}
}
return onlineDeviceCountByDay;
}
private int getDeviceCount(DeviceStatus ds) {
String deviceType = String.valueOf(ds.getDeviceType());
if (deviceType.equals(HwDictConstants.DEVICE_TYPE_GATEWAY_DEVICE)) {
HwDevice queryDevice = new HwDevice();
queryDevice.setReleatedDeviceId(ds.getDeviceId());
List<HwDevice> deviceList = hwDeviceMapper.selectHwDeviceList(queryDevice);
return deviceList == null ? 0 : deviceList.size();
} else {
return 1;
}
}
/**
* @param: sceneId
* @description 线
* @author xins
* @date 2023-09-21 9:09
* @return String
*/
@Override
public JSONObject getOnlineDevicesCount(Long sceneId){
JSONObject returnObj = new JSONObject();
int onlineDevicesCount = hwDeviceMapper.getOnlineDeviceNum(sceneId);
String onlineDeviceCountJsonStr = redisTemplate.opsForValue().get(HwDictConstants.REDIS_KEY_ONLINE_DEVICE_COUNT_INFO);
JSONObject jsonObject = JSONObject.parseObject(onlineDeviceCountJsonStr);
JSONObject sortedJsonObject = new JSONObject();
jsonObject.forEach((key,value) ->{
String dateStrKey = DateUtils.parseDateToStr(DateUtils.MM_DD,new Date(Long.parseLong(key)));
sortedJsonObject.put(dateStrKey,value);
});
returnObj.put("onlineDevicesTrend",sortedJsonObject);
returnObj.put("onlineDevicesCount",onlineDevicesCount);
return returnObj;
}
public void publishContrlCommand(String channel,String message){
redisTemplate.convertAndSend(channel,message);
}
}

@ -11,8 +11,10 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.business.domain.HwFenceArea;
import com.ruoyi.business.domain.HwFenceTarget;
import com.ruoyi.business.domain.VO.AlarmInfoVo;
import com.ruoyi.business.domain.VO.EleMonitorDeviceSumVo;
import com.ruoyi.business.domain.VO.ElectronicFenceVo;
import com.ruoyi.business.mapper.HwAlarmInfoMapper;
import com.ruoyi.business.mapper.HwFenceAreaMapper;
import com.ruoyi.business.mapper.HwFenceTargetMapper;
import com.ruoyi.common.core.constant.HwDictConstants;
@ -42,6 +44,9 @@ public class HwElectronicFenceServiceImpl implements IHwElectronicFenceService {
@Autowired
private HwFenceAreaMapper hwFenceAreaMapper;
@Autowired
private HwAlarmInfoMapper hwAlarmInfoMapper;
/**
*
*
@ -101,7 +106,7 @@ public class HwElectronicFenceServiceImpl implements IHwElectronicFenceService {
@Override
public List<ElectronicFenceVo> selectEleTypeNums(Long sceneId) {
List<ElectronicFenceVo> electronicFenceVos = new ArrayList<ElectronicFenceVo>();
List<ElectronicFenceVo> electronicFenceVos = new ArrayList<>();
HwElectronicFence queryElectronicFence = new HwElectronicFence();
queryElectronicFence.setSceneId(sceneId);
List<HwElectronicFence> electronicFenceList = hwElectronicFenceMapper.selectHwElectronicFenceList(queryElectronicFence);
@ -149,7 +154,8 @@ public class HwElectronicFenceServiceImpl implements IHwElectronicFenceService {
e.setRadius(Double.valueOf(areaRangeArr[2]));
}
e.setAbnormalCount(2);//todo 异常数量获取
AlarmInfoVo alarmInfoVo = hwAlarmInfoMapper.selectAlarmCountByFenceArea(fenceArea.getFenceAreaId());
e.setAbnormalCount(alarmInfoVo.getAlarmCount());
e.setAreaShapeFlag(areaShapeFlag);
e.setDeviceCount(deviceCount);
electronicFenceVos.add(e);

@ -9,26 +9,18 @@ import com.ruoyi.business.mapper.HwDeviceMapper;
import com.ruoyi.business.mapper.HwElectronicFenceMapper;
import com.ruoyi.business.mapper.HwMonitorUnitMapper;
import com.ruoyi.business.service.IHwMonitorUnitService;
import com.ruoyi.common.core.constant.TdEngineConstants;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.exception.ServiceException;
import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.common.core.utils.NumberUtils;
import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.common.datascope.annotation.DataScope;
import com.ruoyi.tdengine.api.RemoteTdEngineService;
import com.ruoyi.tdengine.api.domain.DeviceStatus;
import com.ruoyi.tdengine.api.domain.TdSelectDto;
import com.ruoyi.tdengine.api.domain.TdSuperTableSelectVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.stream.Collectors;
/**
@ -129,10 +121,11 @@ public class HwMonitorUnitServiceImpl implements IHwMonitorUnitService {
return list;
}
//获取总的设备数量与监控单元数量
//获取总的设备数量与监控单元数量(标准场景使用)
@Override
public AllNumsVo selectAllNums(Long sceneId) {
//监控单元
//查询设备数量包括网关
Integer monitor = hwMonitorUnitMapper.selectSubSetNums(sceneId) == null ? 0
: hwMonitorUnitMapper.selectSubSetNums(sceneId);
Integer integer = hwMonitorUnitMapper.selectDeviceNums(sceneId) == null ? 0
@ -159,9 +152,9 @@ public class HwMonitorUnitServiceImpl implements IHwMonitorUnitService {
// }
@Override
public List<HwMonitorUnit> selectLimitSubMonitorUnit() {
public List<HwMonitorUnit> selectLimitSubMonitorUnit(HwMonitorUnit hwMonitorUnit) {
List<HwMonitorUnit> hwMonitorUnits = hwMonitorUnitMapper.selectLimitSubMonitorUnit();
List<HwMonitorUnit> hwMonitorUnits = hwMonitorUnitMapper.selectLimitSubMonitorUnit(hwMonitorUnit);
return hwMonitorUnits;
}
@ -405,4 +398,15 @@ public class HwMonitorUnitServiceImpl implements IHwMonitorUnitService {
}
}
/**
* ,Join monitorunittype
*
* @param monitorUnitId
* @return
*/
@Override
public HwMonitorUnit selectHwMonitorUnitJoinByMonitorUnitId(Long monitorUnitId) {
return hwMonitorUnitMapper.selectHwMonitorUnitJoinByMonitorUnitId(monitorUnitId);
}
}

@ -190,7 +190,7 @@ public class HwSceneServiceImpl implements IHwSceneService {
for (Object deviceInfoObj : deviceInfoJsonArr) {
JSONObject deviceInfoJson = (JSONObject) deviceInfoObj;
if (deviceInfoJson.getString("deviceCode").equals(device.getDeviceCode())) {
deviceInfoJson.put("username", modeAccount);
deviceInfoJson.put("userName", modeAccount);
deviceInfoJson.put("password", modeKey);
redisUpdated = true;
}
@ -199,7 +199,7 @@ public class HwSceneServiceImpl implements IHwSceneService {
if (!redisUpdated) {
JSONObject deviceInfoJson = new JSONObject();
deviceInfoJson.put("deviceCode", device.getDeviceCode());
deviceInfoJson.put("username", modeAccount);
deviceInfoJson.put("userName", modeAccount);
deviceInfoJson.put("password", modeKey);
deviceInfoJsonArr.add(deviceInfoJson);
}

@ -8,6 +8,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="alarmInfoId" column="alarm_info_id" />
<result property="alarmInfoType" column="alarm_info_type" />
<result property="alarmReleatedId" column="alarm_releated_id" />
<result property="fenceAreaId" column="fence_area_id" />
<result property="deviceId" column="device_id" />
<result property="monitorUnitId" column="monitor_unit_id" />
<result property="tenantId" column="tenant_id" />
@ -36,6 +37,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="alarmTypeName" column="alarm_type_name" />
</resultMap>
<resultMap type="AlarmInfoVo" id="AlarmInfoVoResult">
<result property="alarmCount" column="alarm_count" />
</resultMap>
<sql id="selectHwAlarmInfoVo">
select hai.alarm_info_id, hai.alarm_info_type, hai.alarm_releated_id, hai.device_id,
@ -68,7 +73,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="handleStatus != null and handleStatus != ''"> and handle_status = #{handleStatus}</if>
<if test="alarmTime != null "> and alarm_time = #{alarmTime}</if>
<if test="alarmInfoField != null and alarmInfoField != ''"> and alarm_info_field = #{alarmInfoField}</if>
<!-- 租户数据范围过滤 -->
${params.tenantDataScope}
</where>
order by alarm_info_id desc
</select>
<select id="selectHwAlarmInfoByAlarmInfoId" parameterType="Long" resultMap="HwAlarmInfoResult">
@ -165,4 +173,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where scene_id = #{sceneId} group by alarm_type_id;
</select>
<select id="selectAlarmCountByFenceArea" parameterType="Long" resultMap="AlarmInfoVoResult">
SELECT count(distinct(device_id)) as alarm_count from hw_alarm_info hai
where hai.fence_area_id = #{fenceAreaId}
</select>
</mapper>

@ -22,7 +22,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
<sql id="selectHwAlarmTypeVo">
select alarm_type_id, alarm_type_name, tenant_id, scene_id, language_code, common_flag, handle_mode, type_status, remark, create_by, create_time, update_by, update_time, alarm_type_field from hw_alarm_type
select alarm_type_id, alarm_type_name, tenant_id, scene_id, language_code, common_flag, handle_mode, type_status, remark, create_by, create_time, update_by, update_time, alarm_type_field from hw_alarm_type hat
</sql>
<select id="selectHwAlarmTypeList" parameterType="HwAlarmType" resultMap="HwAlarmTypeResult">

@ -50,6 +50,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
SELECT b.device_mode_name ,a.sum FROM hw_device_mode b
LEFT JOIN (SELECT device_mode_id,count(*) as sum FROM hw_device GROUP BY device_mode_id order by sum desc
) a on a.device_mode_id = b.device_mode_id
</select>
<select id="selectDeviceByDeviceModeByDeviceModeFunction" parameterType="Long" resultType="String">
select count(*) from hw_device_mode_function where device_mode_id =
@ -227,8 +228,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</delete>
<select id="getOnlineDeviceNum" parameterType="Long">
select count(*) as count from hw_device where
scene_id = #{sceneId} and device_status=1 and online_status=1
SELECT count(1) as count FROM hw_device hd where hd.scene_id=#{sceneId} and hd.device_type=2 and hd.device_status=1
and exists (select 1 from hw_device hdd where hd.releated_device_id=hdd.device_id and hdd.online_status=1)
</select>
<sql id="selectHwDeviceJoinVo">

@ -150,39 +150,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</foreach>
</delete>
<delete id="deleteHwFenceTargetByElectronicFenceId" parameterType="Long">
delete from hw_fence_target where electronic_fence_id = #{electronicFenceId}
</delete>
<insert id="batchHwFenceTarget">
insert into hw_fence_target( electronic_fence_id, target_type, target_id) values
<foreach item="item" index="index" collection="list" separator=",">
( #{item.electronicFenceId}, #{item.targetType}, #{item.targetId})
</foreach>
</insert>
<select id="selectDeviceCount" parameterType="Long">
select count(*) as count
from hw_fence_target a where a.electronic_fence_id = #{electronicFenceId}
</select>
<select id="selectDeviceCountByMonitorUnit" parameterType="Long">
select count(*) as count
from hw_device hd where hd.device_status=1 and (hd.device_type=2 or hd.device_type=3) and exists (select 1 from hw_fence_target a
where hd.monitor_unit_id = a.target_id
and a.electronic_fence_id = #{electronicFenceId})
</select>
<select id="selectHwElectronicFenceJoinList" parameterType="HwElectronicFence" resultMap="HwElectronicFenceResult">
select hef.electronic_fence_id,hef.electronic_fence_name,hef.fence_type,hef.trigger_status,
hs.scene_name
from hw_electronic_fence hef
left join hw_scene hs on hef.scene_id = hs.scene_id
<where>
<if test="electronicFenceName != null and electronicFenceName != ''"> and hef.electronic_fence_name like concat('%', #{electronicFenceName}, '%')</if>
<if test="tenantId != null "> and hef.tenant_id = #{tenantId}</if>
<if test="sceneId != null "> and hef.scene_id = #{sceneId}</if>
<if test="fenceType != null and fenceType != ''"> and hef.fence_type = #{fenceType}</if>
<if test="effectiveTimeFlag != null and effectiveTimeFlag != ''"> and hef.effective_time_flag = #{effectiveTimeFlag}</if>
<if test="timeZone != null and timeZone != ''"> and hef.time_zone = #{timeZone}</if>
<if test="effectiveTime != null and effectiveTime != ''"> and hef.effective_time = #{effectiveTime}</if>
<if test="triggerStatus != null and triggerStatus != ''"> and hef.trigger_status = #{triggerStatus}</if>
<if test="fencePushFlag != null and fencePushFlag != ''"> and hef.fence_push_flag = #{fencePushFlag}</if>
<if test="fencePushContent != null and fencePushContent != ''"> and hef.fence_push_content = #{fencePushContent}</if>
<if test="fenceRecoverContent != null and fenceRecoverContent != ''"> and hef.fence_recover_content = #{fenceRecoverContent}</if>
<if test="fenceField != null and fenceField != ''"> and hef.fence_field = #{fenceField}</if>
<!-- 租户数据范围过滤 -->
${params.tenantDataScope}
</where>
<select id="selectDeviceCountByScene" parameterType="Long">
select count(*) as count
from hw_device hd where hd.device_status=1 and (hd.device_type=2 or hd.device_type=3) and hd.scene_id = #{sceneId}
</select>
</mapper>

@ -109,6 +109,7 @@
<include refid="selectHwMonitorUnitVo"/>
where monitor_unit_id = #{monitorUnitId}
</select>
<!--查询最子集监控单元以场景进行分组-->
<select id="selectAllNums" resultMap="AllNumsVoResult">
select scene_id,count(*) as sub_sum from
@ -125,7 +126,7 @@
<select id="selectDeviceNums" resultType="Integer">
select count(*) as sum from hw_device
where device_status = '1'
<if test="sceneId != null "> and scene_id = #{sceneId}</if>
<if test="sceneId != null and sceneId!=0"> and scene_id = #{sceneId}</if>
</select>
<!-- 通过场景分组,查询设备数量 todo 已解决 -->
<select id="selectsum" resultMap="AllNumsVoResult">
@ -158,6 +159,8 @@
<select id="selectLimitSubMonitorUnit" resultMap="HwMonitorUnitResult">
select * from hw_monitor_unit where monitor_unit_id
not in (select parent_id from hw_monitor_unit where parent_id is not null)
<if test="tenantId != null "> and tenant_id = #{tenantId}</if>
<if test="sceneId != null "> and scene_id = #{sceneId}</if>
</select>
<!-- 查询最子集监控单元使用sceneid进行分组-->
<select id="selectMonitorPercentage" resultMap="HwMonitorUnitVoResult">
@ -310,4 +313,14 @@
</where>
</select>
<select id="selectHwMonitorUnitJoinByMonitorUnitId" parameterType="Long" resultMap="HwMonitorUnitResult">
select hmu.monitor_unit_id,hmu.monitor_unit_name,hmu.monitor_unit_status,hmut.monitor_unit_type_name
from hw_monitor_unit hmu left join hw_monitor_unit_type hmut on hmu.monitor_unit_type_id=hmut.monitor_unit_type_id
where monitor_unit_id = #{monitorUnitId}
</select>
</mapper>

@ -192,7 +192,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</delete>
<delete id="deleteHwSceneBySceneIds" parameterType="String">
update hw_scene set scene_status = '9' where scene_id = in
update hw_scene set scene_status = '9' where scene_id in
<foreach item="sceneId" collection="array" open="(" separator="," close=")">
#{sceneId}
</foreach>

@ -1,105 +0,0 @@
package com.ruoyi.business.controller;
import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
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.domain.HwAlarmRule;
import com.ruoyi.business.service.IHwAlarmRuleService;
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;
/**
* Controller
*
* @author xins
* @date 2023-09-16
*/
@RestController
@RequestMapping("/alarmRule")
public class HwAlarmRuleController extends BaseController
{
@Autowired
private IHwAlarmRuleService hwAlarmRuleService;
/**
*
*/
@RequiresPermissions("business:alarmRule:list")
@GetMapping("/list")
public TableDataInfo list(HwAlarmRule hwAlarmRule)
{
startPage();
List<HwAlarmRule> list = hwAlarmRuleService.selectHwAlarmRuleList(hwAlarmRule);
return getDataTable(list);
}
/**
*
*/
@RequiresPermissions("business:alarmRule:export")
@Log(title = "报警规则", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, HwAlarmRule hwAlarmRule)
{
List<HwAlarmRule> list = hwAlarmRuleService.selectHwAlarmRuleList(hwAlarmRule);
ExcelUtil<HwAlarmRule> util = new ExcelUtil<HwAlarmRule>(HwAlarmRule.class);
util.exportExcel(response, list, "报警规则数据");
}
/**
*
*/
@RequiresPermissions("business:alarmRule:query")
@GetMapping(value = "/{alarmRuleId}")
public AjaxResult getInfo(@PathVariable("alarmRuleId") Long alarmRuleId)
{
return success(hwAlarmRuleService.selectHwAlarmRuleByAlarmRuleId(alarmRuleId));
}
/**
*
*/
@RequiresPermissions("business:alarmRule:add")
@Log(title = "报警规则", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody HwAlarmRule hwAlarmRule)
{
return toAjax(hwAlarmRuleService.insertHwAlarmRule(hwAlarmRule));
}
/**
*
*/
@RequiresPermissions("business:alarmRule:edit")
@Log(title = "报警规则", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody HwAlarmRule hwAlarmRule)
{
return toAjax(hwAlarmRuleService.updateHwAlarmRule(hwAlarmRule));
}
/**
*
*/
@RequiresPermissions("business:alarmRule:remove")
@Log(title = "报警规则", businessType = BusinessType.DELETE)
@DeleteMapping("/{alarmRuleIds}")
public AjaxResult remove(@PathVariable Long[] alarmRuleIds)
{
return toAjax(hwAlarmRuleService.deleteHwAlarmRuleByAlarmRuleIds(alarmRuleIds));
}
}

@ -1,392 +0,0 @@
package com.ruoyi.business.domain;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.core.annotation.Excel;
import com.ruoyi.common.core.web.domain.BaseEntity;
/**
* hw_alarm_rule
*
* @author xins
* @date 2023-09-16
*/
public class HwAlarmRule extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 报警规则ID */
private Long alarmRuleId;
/** 规则名称 */
@Excel(name = "规则名称")
private String alarmRuleName;
/** 租户ID关联hw_tenant的tenant_id */
@Excel(name = "租户ID关联hw_tenant的tenant_id")
private Long tenantId;
/** 所属场景关联hw_scene表的scene_id字段 */
@Excel(name = "所属场景关联hw_scene表的scene_id字段")
private Long sceneId;
/** 报警级别关联表hw_alarm_level字段alarm_level_id */
@Excel(name = "报警级别关联表hw_alarm_level字段alarm_level_id")
private Long alarmLevelId;
/** 报警类型关联表hw_alarm_type字段alarm_type_id */
@Excel(name = "报警类型关联表hw_alarm_type字段alarm_type_id")
private Long alarmTypeId;
/** 规则类型1、设备模型2、设备 */
@Excel(name = "规则类型", readConverterExp = "1=、设备模型2、设备")
private String ruleType;
/** 设备关联表hw_device字段device_id */
@Excel(name = "设备关联表hw_device字段device_id")
private Long deviceId;
/** 设备模型关联表hw_device_mode字段device_mode_id */
@Excel(name = "设备模型关联表hw_device_mode字段device_mode_id")
private Long deviceModeId;
/** 设备属性关联表hw_device_mode_function字段mode_function_id */
@Excel(name = "设备属性关联表hw_device_mode_function字段mode_function_id")
private Long modeFunctionId;
/** 触发条件1、数值大于A2、数值小于B3、数值大于A且小于B4、数值小于A或大于B5、数值等于A */
@Excel(name = "触发条件", readConverterExp = "1=、数值大于A2、数值小于B3、数值大于A且小于B4、数值小于A或大于B5、数值等于A")
private String triggerCondition;
/** 触发定义A值 */
@Excel(name = "触发定义A值")
private String triggerDataA;
/** 触发定义B值 */
@Excel(name = "触发定义B值")
private String triggerDataB;
/** 触发死区 */
@Excel(name = "触发死区")
private String triggerDeadzone;
/** 触发阈值次数 */
@Excel(name = "触发阈值次数")
private Long triggerNumber;
/** 时间范围(单位:分钟) */
@Excel(name = "时间范围", readConverterExp = "单=位:分钟")
private Long triggerTimeFrame;
/** 联动标识1、是0、否 */
@Excel(name = "联动标识", readConverterExp = "1=、是0、否")
private String linkFlag;
/** 联动类型1、控制2、采集 */
@Excel(name = "联动类型", readConverterExp = "1=、控制2、采集")
private String linkType;
/** 联动设备关联表hw_device字段device_id */
@Excel(name = "联动设备关联表hw_device字段device_id")
private Long linkDeviceId;
/** 联动设备功能关联表hw_device_mode_function字段mode_function_id */
@Excel(name = "联动设备功能关联表hw_device_mode_function字段mode_function_id")
private Long linkDeviceFunctionId;
/** 联动设备属性值 */
@Excel(name = "联动设备属性值")
private String linkDeviceFunctionData;
/** 报警启用状态(1、是2、否 */
@Excel(name = "报警启用状态(1、是2、否")
private String alarmRuleStatus;
/** 报警推送标识(1、是2、否 */
@Excel(name = "报警推送标识(1、是2、否")
private String alarmPushFlag;
/** 报警推送内容 */
@Excel(name = "报警推送内容")
private String alarmPushContent;
/** 恢复正常推送内容 */
@Excel(name = "恢复正常推送内容")
private String alarmRecoverContent;
/** 预留字段 */
@Excel(name = "预留字段")
private String alarmRuleField;
public void setAlarmRuleId(Long alarmRuleId)
{
this.alarmRuleId = alarmRuleId;
}
public Long getAlarmRuleId()
{
return alarmRuleId;
}
public void setAlarmRuleName(String alarmRuleName)
{
this.alarmRuleName = alarmRuleName;
}
public String getAlarmRuleName()
{
return alarmRuleName;
}
public void setTenantId(Long tenantId)
{
this.tenantId = tenantId;
}
public Long getTenantId()
{
return tenantId;
}
public void setSceneId(Long sceneId)
{
this.sceneId = sceneId;
}
public Long getSceneId()
{
return sceneId;
}
public void setAlarmLevelId(Long alarmLevelId)
{
this.alarmLevelId = alarmLevelId;
}
public Long getAlarmLevelId()
{
return alarmLevelId;
}
public void setAlarmTypeId(Long alarmTypeId)
{
this.alarmTypeId = alarmTypeId;
}
public Long getAlarmTypeId()
{
return alarmTypeId;
}
public void setRuleType(String ruleType)
{
this.ruleType = ruleType;
}
public String getRuleType()
{
return ruleType;
}
public void setDeviceId(Long deviceId)
{
this.deviceId = deviceId;
}
public Long getDeviceId()
{
return deviceId;
}
public void setDeviceModeId(Long deviceModeId)
{
this.deviceModeId = deviceModeId;
}
public Long getDeviceModeId()
{
return deviceModeId;
}
public void setModeFunctionId(Long modeFunctionId)
{
this.modeFunctionId = modeFunctionId;
}
public Long getModeFunctionId()
{
return modeFunctionId;
}
public void setTriggerCondition(String triggerCondition)
{
this.triggerCondition = triggerCondition;
}
public String getTriggerCondition()
{
return triggerCondition;
}
public void setTriggerDataA(String triggerDataA)
{
this.triggerDataA = triggerDataA;
}
public String getTriggerDataA()
{
return triggerDataA;
}
public void setTriggerDataB(String triggerDataB)
{
this.triggerDataB = triggerDataB;
}
public String getTriggerDataB()
{
return triggerDataB;
}
public void setTriggerDeadzone(String triggerDeadzone)
{
this.triggerDeadzone = triggerDeadzone;
}
public String getTriggerDeadzone()
{
return triggerDeadzone;
}
public void setTriggerNumber(Long triggerNumber)
{
this.triggerNumber = triggerNumber;
}
public Long getTriggerNumber()
{
return triggerNumber;
}
public void setTriggerTimeFrame(Long triggerTimeFrame)
{
this.triggerTimeFrame = triggerTimeFrame;
}
public Long getTriggerTimeFrame()
{
return triggerTimeFrame;
}
public void setLinkFlag(String linkFlag)
{
this.linkFlag = linkFlag;
}
public String getLinkFlag()
{
return linkFlag;
}
public void setLinkType(String linkType)
{
this.linkType = linkType;
}
public String getLinkType()
{
return linkType;
}
public void setLinkDeviceId(Long linkDeviceId)
{
this.linkDeviceId = linkDeviceId;
}
public Long getLinkDeviceId()
{
return linkDeviceId;
}
public void setLinkDeviceFunctionId(Long linkDeviceFunctionId)
{
this.linkDeviceFunctionId = linkDeviceFunctionId;
}
public Long getLinkDeviceFunctionId()
{
return linkDeviceFunctionId;
}
public void setLinkDeviceFunctionData(String linkDeviceFunctionData)
{
this.linkDeviceFunctionData = linkDeviceFunctionData;
}
public String getLinkDeviceFunctionData()
{
return linkDeviceFunctionData;
}
public void setAlarmRuleStatus(String alarmRuleStatus)
{
this.alarmRuleStatus = alarmRuleStatus;
}
public String getAlarmRuleStatus()
{
return alarmRuleStatus;
}
public void setAlarmPushFlag(String alarmPushFlag)
{
this.alarmPushFlag = alarmPushFlag;
}
public String getAlarmPushFlag()
{
return alarmPushFlag;
}
public void setAlarmPushContent(String alarmPushContent)
{
this.alarmPushContent = alarmPushContent;
}
public String getAlarmPushContent()
{
return alarmPushContent;
}
public void setAlarmRecoverContent(String alarmRecoverContent)
{
this.alarmRecoverContent = alarmRecoverContent;
}
public String getAlarmRecoverContent()
{
return alarmRecoverContent;
}
public void setAlarmRuleField(String alarmRuleField)
{
this.alarmRuleField = alarmRuleField;
}
public String getAlarmRuleField()
{
return alarmRuleField;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("alarmRuleId", getAlarmRuleId())
.append("alarmRuleName", getAlarmRuleName())
.append("tenantId", getTenantId())
.append("sceneId", getSceneId())
.append("alarmLevelId", getAlarmLevelId())
.append("alarmTypeId", getAlarmTypeId())
.append("ruleType", getRuleType())
.append("deviceId", getDeviceId())
.append("deviceModeId", getDeviceModeId())
.append("modeFunctionId", getModeFunctionId())
.append("triggerCondition", getTriggerCondition())
.append("triggerDataA", getTriggerDataA())
.append("triggerDataB", getTriggerDataB())
.append("triggerDeadzone", getTriggerDeadzone())
.append("triggerNumber", getTriggerNumber())
.append("triggerTimeFrame", getTriggerTimeFrame())
.append("linkFlag", getLinkFlag())
.append("linkType", getLinkType())
.append("linkDeviceId", getLinkDeviceId())
.append("linkDeviceFunctionId", getLinkDeviceFunctionId())
.append("linkDeviceFunctionData", getLinkDeviceFunctionData())
.append("alarmRuleStatus", getAlarmRuleStatus())
.append("alarmPushFlag", getAlarmPushFlag())
.append("alarmPushContent", getAlarmPushContent())
.append("alarmRecoverContent", getAlarmRecoverContent())
.append("remark", getRemark())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.append("alarmRuleField", getAlarmRuleField())
.toString();
}
}

@ -1,61 +0,0 @@
package com.ruoyi.business.mapper;
import java.util.List;
import com.ruoyi.business.domain.HwAlarmRule;
/**
* Mapper
*
* @author xins
* @date 2023-09-16
*/
public interface HwAlarmRuleMapper
{
/**
*
*
* @param alarmRuleId
* @return
*/
public HwAlarmRule selectHwAlarmRuleByAlarmRuleId(Long alarmRuleId);
/**
*
*
* @param hwAlarmRule
* @return
*/
public List<HwAlarmRule> selectHwAlarmRuleList(HwAlarmRule hwAlarmRule);
/**
*
*
* @param hwAlarmRule
* @return
*/
public int insertHwAlarmRule(HwAlarmRule hwAlarmRule);
/**
*
*
* @param hwAlarmRule
* @return
*/
public int updateHwAlarmRule(HwAlarmRule hwAlarmRule);
/**
*
*
* @param alarmRuleId
* @return
*/
public int deleteHwAlarmRuleByAlarmRuleId(Long alarmRuleId);
/**
*
*
* @param alarmRuleIds
* @return
*/
public int deleteHwAlarmRuleByAlarmRuleIds(Long[] alarmRuleIds);
}

@ -1,61 +0,0 @@
package com.ruoyi.business.service;
import java.util.List;
import com.ruoyi.business.domain.HwAlarmRule;
/**
* Service
*
* @author xins
* @date 2023-09-16
*/
public interface IHwAlarmRuleService
{
/**
*
*
* @param alarmRuleId
* @return
*/
public HwAlarmRule selectHwAlarmRuleByAlarmRuleId(Long alarmRuleId);
/**
*
*
* @param hwAlarmRule
* @return
*/
public List<HwAlarmRule> selectHwAlarmRuleList(HwAlarmRule hwAlarmRule);
/**
*
*
* @param hwAlarmRule
* @return
*/
public int insertHwAlarmRule(HwAlarmRule hwAlarmRule);
/**
*
*
* @param hwAlarmRule
* @return
*/
public int updateHwAlarmRule(HwAlarmRule hwAlarmRule);
/**
*
*
* @param alarmRuleIds
* @return
*/
public int deleteHwAlarmRuleByAlarmRuleIds(Long[] alarmRuleIds);
/**
*
*
* @param alarmRuleId
* @return
*/
public int deleteHwAlarmRuleByAlarmRuleId(Long alarmRuleId);
}

@ -1,96 +0,0 @@
package com.ruoyi.business.service.impl;
import java.util.List;
import com.ruoyi.common.core.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.business.mapper.HwAlarmRuleMapper;
import com.ruoyi.business.domain.HwAlarmRule;
import com.ruoyi.business.service.IHwAlarmRuleService;
/**
* Service
*
* @author xins
* @date 2023-09-16
*/
@Service
public class HwAlarmRuleServiceImpl implements IHwAlarmRuleService
{
@Autowired
private HwAlarmRuleMapper hwAlarmRuleMapper;
/**
*
*
* @param alarmRuleId
* @return
*/
@Override
public HwAlarmRule selectHwAlarmRuleByAlarmRuleId(Long alarmRuleId)
{
return hwAlarmRuleMapper.selectHwAlarmRuleByAlarmRuleId(alarmRuleId);
}
/**
*
*
* @param hwAlarmRule
* @return
*/
@Override
public List<HwAlarmRule> selectHwAlarmRuleList(HwAlarmRule hwAlarmRule)
{
return hwAlarmRuleMapper.selectHwAlarmRuleList(hwAlarmRule);
}
/**
*
*
* @param hwAlarmRule
* @return
*/
@Override
public int insertHwAlarmRule(HwAlarmRule hwAlarmRule)
{
hwAlarmRule.setCreateTime(DateUtils.getNowDate());
return hwAlarmRuleMapper.insertHwAlarmRule(hwAlarmRule);
}
/**
*
*
* @param hwAlarmRule
* @return
*/
@Override
public int updateHwAlarmRule(HwAlarmRule hwAlarmRule)
{
hwAlarmRule.setUpdateTime(DateUtils.getNowDate());
return hwAlarmRuleMapper.updateHwAlarmRule(hwAlarmRule);
}
/**
*
*
* @param alarmRuleIds
* @return
*/
@Override
public int deleteHwAlarmRuleByAlarmRuleIds(Long[] alarmRuleIds)
{
return hwAlarmRuleMapper.deleteHwAlarmRuleByAlarmRuleIds(alarmRuleIds);
}
/**
*
*
* @param alarmRuleId
* @return
*/
@Override
public int deleteHwAlarmRuleByAlarmRuleId(Long alarmRuleId)
{
return hwAlarmRuleMapper.deleteHwAlarmRuleByAlarmRuleId(alarmRuleId);
}
}

@ -30,6 +30,8 @@ public class HwAlarmInfo extends BaseEntity
@Excel(name = "报警信息类型")
private Long alarmReleatedId;
private Long fenceAreaId;
/** 报警设备ID关联hw_device表的device_id字段 */
@Excel(name = "报警设备ID关联hw_device表的device_id字段")
private Long deviceId;
@ -114,6 +116,15 @@ public class HwAlarmInfo extends BaseEntity
{
return alarmReleatedId;
}
public Long getFenceAreaId() {
return fenceAreaId;
}
public void setFenceAreaId(Long fenceAreaId) {
this.fenceAreaId = fenceAreaId;
}
public void setDeviceId(Long deviceId)
{
this.deviceId = deviceId;

@ -36,14 +36,6 @@ public class HwElectronicFence extends BaseEntity
@Excel(name = "触发状态", readConverterExp = "0=、关闭1、出界2、入界3、双向")
private String triggerStatus;
/** 区域形状1、多边形2、圆形 */
@Excel(name = "区域形状", readConverterExp = "1=、多边形2、圆形")
private String areaShapeFlag;
/** 区域范围为多边形时保存格式经度_纬度多个以|隔开;为圆形时的中心点和半径,下划线隔开 */
@Excel(name = "区域范围", readConverterExp = "为多边形时保存格式为经度_纬度多个以|隔开;为圆形时的中心点和半径,下划线")
private String areaRange;
/** 报警推送标识(1、是0、否 */
@Excel(name = "报警推送标识(1、是0、否")
private Long fencePushFlag;
@ -123,24 +115,6 @@ public class HwElectronicFence extends BaseEntity
{
return triggerStatus;
}
public void setAreaShapeFlag(String areaShapeFlag)
{
this.areaShapeFlag = areaShapeFlag;
}
public String getAreaShapeFlag()
{
return areaShapeFlag;
}
public void setAreaRange(String areaRange)
{
this.areaRange = areaRange;
}
public String getAreaRange()
{
return areaRange;
}
public void setFencePushFlag(Long fencePushFlag)
{
@ -189,8 +163,6 @@ public class HwElectronicFence extends BaseEntity
.append("effectiveTimeFlag", getEffectiveTimeFlag())
.append("effectiveTime", getEffectiveTime())
.append("triggerStatus", getTriggerStatus())
.append("areaShapeFlag", getAreaShapeFlag())
.append("areaRange", getAreaRange())
.append("fencePushFlag", getFencePushFlag())
.append("fencePushContent", getFencePushContent())
.append("fenceRecoverContent", getFenceRecoverContent())

@ -0,0 +1,79 @@
package com.ruoyi.dataprocess.domain;
import com.ruoyi.common.core.annotation.Excel;
import com.ruoyi.common.core.web.domain.BaseEntity;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
/**
* hw_fence_area
*
* @author xins
* @date 2023-09-19
*/
public class HwFenceArea extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 电子围栏区域ID */
private Long fenceAreaId;
/** 电子围栏ID */
@Excel(name = "电子围栏ID")
private Long electronicFenceId;
/** 区域形状1、多边形2、圆形 */
@Excel(name = "区域形状", readConverterExp = "1=、多边形2、圆形")
private String areaShapeFlag;
/** 区域范围:为多边形时保存格式,经度,纬度多个以_隔开为圆形时的中心点和半径,隔开 */
@Excel(name = "区域范围:为多边形时保存格式,经度,纬度多个以_隔开为圆形时的中心点和半径,隔开")
private String areaRange;
public void setFenceAreaId(Long fenceAreaId)
{
this.fenceAreaId = fenceAreaId;
}
public Long getFenceAreaId()
{
return fenceAreaId;
}
public void setElectronicFenceId(Long electronicFenceId)
{
this.electronicFenceId = electronicFenceId;
}
public Long getElectronicFenceId()
{
return electronicFenceId;
}
public void setAreaShapeFlag(String areaShapeFlag)
{
this.areaShapeFlag = areaShapeFlag;
}
public String getAreaShapeFlag()
{
return areaShapeFlag;
}
public void setAreaRange(String areaRange)
{
this.areaRange = areaRange;
}
public String getAreaRange()
{
return areaRange;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("fenceAreaId", getFenceAreaId())
.append("electronicFenceId", getElectronicFenceId())
.append("areaShapeFlag", getAreaShapeFlag())
.append("areaRange", getAreaRange())
.toString();
}
}

@ -0,0 +1,62 @@
package com.ruoyi.dataprocess.mapper;
import com.ruoyi.dataprocess.domain.HwFenceArea;
import java.util.List;
/**
* Mapper
*
* @author xins
* @date 2023-09-19
*/
public interface HwFenceAreaMapper
{
/**
*
*
* @param fenceAreaId
* @return
*/
public HwFenceArea selectHwFenceAreaByFenceAreaId(Long fenceAreaId);
/**
*
*
* @param hwFenceArea
* @return
*/
public List<HwFenceArea> selectHwFenceAreaList(HwFenceArea hwFenceArea);
/**
*
*
* @param hwFenceArea
* @return
*/
public int insertHwFenceArea(HwFenceArea hwFenceArea);
/**
*
*
* @param hwFenceArea
* @return
*/
public int updateHwFenceArea(HwFenceArea hwFenceArea);
/**
*
*
* @param fenceAreaId
* @return
*/
public int deleteHwFenceAreaByFenceAreaId(Long fenceAreaId);
/**
*
*
* @param fenceAreaIds
* @return
*/
public int deleteHwFenceAreaByFenceAreaIds(Long[] fenceAreaIds);
}

@ -46,6 +46,10 @@ import java.nio.charset.StandardCharsets;
public class MqttConfiguration {
private static final Logger logger = LoggerFactory.getLogger(MqttConfiguration.class);
public static final String TOPIC_TYPE_DATA_POSTFIX = "data";
public static final String TOPIC_TYPE_COMMAND_POSTFIX = "command";
public static final String TOPIC_TYPE_REPLY_POSTFIX = "reply";
@Value("${mqtt.client.ip}")
String ip;
@Value("${mqtt.client.port}")
@ -120,17 +124,21 @@ public class MqttConfiguration {
@Override
public void onMessage(ChannelContext channelContext, String topic, MqttPublishMessage mqttPublishMessage, ByteBuffer payload) {
System.out.println("dataprocessservice:" + dataProcessService);
String payloadString = new String(payload.array(), StandardCharsets.UTF_8);
System.out.println("paa:" + topic);
logger.info("topic:{} payload:{}", topic, payloadString);
System.out.println(topic+"----"+dataTopicFilter);
System.out.println(topic.startsWith(dataTopicFilter));
if (topic.startsWith(dataTopicFilter.replace("#",""))) {
try{
if (topic.startsWith(dataTopicFilter.replace("#","")) && topic.endsWith(TOPIC_TYPE_DATA_POSTFIX)) {
System.out.println("rrrrrr");
dataProcessService.processBusinessData(payloadString, imagePath, imagePatterns);
} else if (topic.equals(deviceStatusTopic)) {
deviceStatusService.handleDeviceStatus(payloadString,clientId);
}
}catch(Exception e){
e.printStackTrace();
logger.error("Error processing business data:"+e.getMessage());
}
}
});

@ -43,6 +43,8 @@ public class MqttClientConnectListener implements IMqttClientConnectListener {
@Override
public void onDisconnect(ChannelContext channelContext, Throwable throwable, String remark, boolean isRemove) {
logger.error("mqtt 链接断开 remark:{} isRemove:{}", remark, isRemove, throwable);
}
}

@ -15,9 +15,11 @@ import com.ruoyi.dataprocess.common.ImageUtils;
import com.ruoyi.dataprocess.domain.HwAlarmInfo;
import com.ruoyi.dataprocess.domain.HwDevice;
import com.ruoyi.dataprocess.domain.HwElectronicFence;
import com.ruoyi.dataprocess.domain.HwFenceArea;
import com.ruoyi.dataprocess.mapper.HwAlarmInfoMapper;
import com.ruoyi.dataprocess.mapper.HwDeviceMapper;
import com.ruoyi.dataprocess.mapper.HwElectronicFenceMapper;
import com.ruoyi.dataprocess.mapper.HwFenceAreaMapper;
import com.ruoyi.dataprocess.service.IDataProcessService;
import com.ruoyi.tdengine.api.RemoteTdEngineService;
import com.ruoyi.tdengine.api.domain.TdField;
@ -55,6 +57,10 @@ public class DataProcessServiceImpl implements IDataProcessService {
@Autowired
private HwElectronicFenceMapper hwElectronicFenceMapper;
@Autowired
private HwFenceAreaMapper hwFenceAreaMapper;
@Autowired
private HwAlarmInfoMapper hwAlarmInfoMapper;
@ -194,13 +200,18 @@ public class DataProcessServiceImpl implements IDataProcessService {
}
if (StringUtils.isNotEmpty(hwElectronicFences)) {
hwElectronicFences.forEach(hwElectronicFence -> {
for (HwElectronicFence hwElectronicFence : hwElectronicFences) {
HwFenceArea queryFenceArea = new HwFenceArea();
queryFenceArea.setElectronicFenceId(hwElectronicFence.getElectronicFenceId());
List<HwFenceArea> fenceAreas = hwFenceAreaMapper.selectHwFenceAreaList(queryFenceArea);
String effectiveTimeFlag = hwElectronicFence.getEffectiveTimeFlag();
String triggerStatus = hwElectronicFence.getTriggerStatus();
if (fenceAreas != null && !fenceAreas.isEmpty()) {
fenceAreas.forEach(fenceArea -> {
boolean isAlarmed = false;//是否报警
if (effectiveTimeFlag.equals(HwDictConstants.EFFECTIVE_TIME_FLAG_LONG)) {
String areaShapeFlag = hwElectronicFence.getAreaShapeFlag();
String areaRange = hwElectronicFence.getAreaRange();
String areaShapeFlag = fenceArea.getAreaShapeFlag();
String areaRange = fenceArea.getAreaRange();
if (areaShapeFlag.equals(HwDictConstants.AREA_SHAPE_FLAG_POLYGN)) {
LocationVo polygonVo = new LocationVo();
polygonVo.setMarkerType(LocationVo.MARKER_TYPE_POLYGON);
@ -260,10 +271,16 @@ public class DataProcessServiceImpl implements IDataProcessService {
hwAralmInfo.setTriggerStatus(triggerStatus);
hwAralmInfo.setAlarmTime(new Date(ts));
hwAralmInfo.setCreateTime(new Date());
hwAralmInfo.setFenceAreaId(fenceArea.getFenceAreaId());
hwAlarmInfoMapper.insertHwAlarmInfo(hwAralmInfo);
}
});
}
}
}
}
public static void main(String[] args) {

@ -2,6 +2,21 @@
server:
port: 9603
mqtt:
client:
ip: 127.0.0.1 # mqtt server ip地址
port: 1883 # mqtt server 端口
clientId: hw-data-process-1 # 客户端ID保证唯一
username: mica # mqtt server 认证用户名
password: mica # mqtt server 认证密码
timeout: 10
keepalive: 20
qos : 1 # qos服务质量等级0最多交付一次1至少交付一次2只交付一次
dataTopicFilter: /v1/# # 订阅的处理设备上报数据的topic
deviceStatusTopic: /device/status/v1 # 订阅的处理设备状态的topic
imagePath: images # base64图片转换保存的路径
imagePatterns: jpg,jpeg,png #支持的图片格式
# Spring
spring:
application:

@ -2,12 +2,13 @@
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.business.mapper.HwAlarmInfoMapper">
<mapper namespace="com.ruoyi.dataprocess.mapper.HwAlarmInfoMapper">
<resultMap type="HwAlarmInfo" id="HwAlarmInfoResult">
<result property="alarmInfoId" column="alarm_info_id" />
<result property="alarmInfoType" column="alarm_info_type" />
<result property="alarmReleatedId" column="alarm_releated_id" />
<result property="fenceAreaId" column="fence_area_id" />
<result property="deviceId" column="device_id" />
<result property="monitorUnitId" column="monitor_unit_id" />
<result property="tenantId" column="tenant_id" />
@ -33,6 +34,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="alarmInfoType != null and alarmInfoType != ''">alarm_info_type,</if>
<if test="alarmReleatedId != null">alarm_releated_id,</if>
<if test="fenceAreaId != null">fence_area_id,</if>
<if test="deviceId != null">device_id,</if>
<if test="monitorUnitId != null">monitor_unit_id,</if>
<if test="tenantId != null">tenant_id,</if>
@ -54,6 +56,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="alarmInfoType != null and alarmInfoType != ''">#{alarmInfoType},</if>
<if test="alarmReleatedId != null">#{alarmReleatedId},</if>
<if test="fenceAreaId != null">#{fenceAreaId},</if>
<if test="deviceId != null">#{deviceId},</if>
<if test="monitorUnitId != null">#{monitorUnitId},</if>
<if test="tenantId != null">#{tenantId},</if>

@ -1,196 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.business.mapper.HwAlarmRuleMapper">
<resultMap type="HwAlarmRule" id="HwAlarmRuleResult">
<result property="alarmRuleId" column="alarm_rule_id" />
<result property="alarmRuleName" column="alarm_rule_name" />
<result property="tenantId" column="tenant_id" />
<result property="sceneId" column="scene_id" />
<result property="alarmLevelId" column="alarm_level_id" />
<result property="alarmTypeId" column="alarm_type_id" />
<result property="ruleType" column="rule_type" />
<result property="deviceId" column="device_id" />
<result property="deviceModeId" column="device_mode_id" />
<result property="modeFunctionId" column="mode_function_id" />
<result property="triggerCondition" column="trigger_condition" />
<result property="triggerDataA" column="trigger_data_a" />
<result property="triggerDataB" column="trigger_data_b" />
<result property="triggerDeadzone" column="trigger_deadzone" />
<result property="triggerNumber" column="trigger_number" />
<result property="triggerTimeFrame" column="trigger_time_frame" />
<result property="linkFlag" column="link_flag" />
<result property="linkType" column="link_type" />
<result property="linkDeviceId" column="link_device_id" />
<result property="linkDeviceFunctionId" column="link_device_function_id" />
<result property="linkDeviceFunctionData" column="link_device_function_data" />
<result property="alarmRuleStatus" column="alarm_rule_status" />
<result property="alarmPushFlag" column="alarm_push_flag" />
<result property="alarmPushContent" column="alarm_push_content" />
<result property="alarmRecoverContent" column="alarm_recover_content" />
<result property="remark" column="remark" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="alarmRuleField" column="alarm_rule_field" />
</resultMap>
<sql id="selectHwAlarmRuleVo">
select alarm_rule_id, alarm_rule_name, tenant_id, scene_id, alarm_level_id, alarm_type_id, rule_type, device_id, device_mode_id, mode_function_id, trigger_condition, trigger_data_a, trigger_data_b, trigger_deadzone, trigger_number, trigger_time_frame, link_flag, link_type, link_device_id, link_device_function_id, link_device_function_data, alarm_rule_status, alarm_push_flag, alarm_push_content, alarm_recover_content, remark, create_by, create_time, update_by, update_time, alarm_rule_field from hw_alarm_rule
</sql>
<select id="selectHwAlarmRuleList" parameterType="HwAlarmRule" resultMap="HwAlarmRuleResult">
<include refid="selectHwAlarmRuleVo"/>
<where>
<if test="alarmRuleName != null and alarmRuleName != ''"> and alarm_rule_name like concat('%', #{alarmRuleName}, '%')</if>
<if test="tenantId != null "> and tenant_id = #{tenantId}</if>
<if test="sceneId != null "> and scene_id = #{sceneId}</if>
<if test="alarmLevelId != null "> and alarm_level_id = #{alarmLevelId}</if>
<if test="alarmTypeId != null "> and alarm_type_id = #{alarmTypeId}</if>
<if test="ruleType != null and ruleType != ''"> and rule_type = #{ruleType}</if>
<if test="deviceId != null "> and device_id = #{deviceId}</if>
<if test="deviceModeId != null "> and device_mode_id = #{deviceModeId}</if>
<if test="modeFunctionId != null "> and mode_function_id = #{modeFunctionId}</if>
<if test="triggerCondition != null and triggerCondition != ''"> and trigger_condition = #{triggerCondition}</if>
<if test="triggerDataA != null and triggerDataA != ''"> and trigger_data_a = #{triggerDataA}</if>
<if test="triggerDataB != null and triggerDataB != ''"> and trigger_data_b = #{triggerDataB}</if>
<if test="triggerDeadzone != null and triggerDeadzone != ''"> and trigger_deadzone = #{triggerDeadzone}</if>
<if test="triggerNumber != null "> and trigger_number = #{triggerNumber}</if>
<if test="triggerTimeFrame != null "> and trigger_time_frame = #{triggerTimeFrame}</if>
<if test="linkFlag != null and linkFlag != ''"> and link_flag = #{linkFlag}</if>
<if test="linkType != null and linkType != ''"> and link_type = #{linkType}</if>
<if test="linkDeviceId != null "> and link_device_id = #{linkDeviceId}</if>
<if test="linkDeviceFunctionId != null "> and link_device_function_id = #{linkDeviceFunctionId}</if>
<if test="linkDeviceFunctionData != null and linkDeviceFunctionData != ''"> and link_device_function_data = #{linkDeviceFunctionData}</if>
<if test="alarmRuleStatus != null and alarmRuleStatus != ''"> and alarm_rule_status = #{alarmRuleStatus}</if>
<if test="alarmPushFlag != null and alarmPushFlag != ''"> and alarm_push_flag = #{alarmPushFlag}</if>
<if test="alarmPushContent != null and alarmPushContent != ''"> and alarm_push_content = #{alarmPushContent}</if>
<if test="alarmRecoverContent != null and alarmRecoverContent != ''"> and alarm_recover_content = #{alarmRecoverContent}</if>
<if test="alarmRuleField != null and alarmRuleField != ''"> and alarm_rule_field = #{alarmRuleField}</if>
</where>
</select>
<select id="selectHwAlarmRuleByAlarmRuleId" parameterType="Long" resultMap="HwAlarmRuleResult">
<include refid="selectHwAlarmRuleVo"/>
where alarm_rule_id = #{alarmRuleId}
</select>
<insert id="insertHwAlarmRule" parameterType="HwAlarmRule" useGeneratedKeys="true" keyProperty="alarmRuleId">
insert into hw_alarm_rule
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="alarmRuleName != null and alarmRuleName != ''">alarm_rule_name,</if>
<if test="tenantId != null">tenant_id,</if>
<if test="sceneId != null">scene_id,</if>
<if test="alarmLevelId != null">alarm_level_id,</if>
<if test="alarmTypeId != null">alarm_type_id,</if>
<if test="ruleType != null and ruleType != ''">rule_type,</if>
<if test="deviceId != null">device_id,</if>
<if test="deviceModeId != null">device_mode_id,</if>
<if test="modeFunctionId != null">mode_function_id,</if>
<if test="triggerCondition != null and triggerCondition != ''">trigger_condition,</if>
<if test="triggerDataA != null and triggerDataA != ''">trigger_data_a,</if>
<if test="triggerDataB != null">trigger_data_b,</if>
<if test="triggerDeadzone != null">trigger_deadzone,</if>
<if test="triggerNumber != null">trigger_number,</if>
<if test="triggerTimeFrame != null">trigger_time_frame,</if>
<if test="linkFlag != null and linkFlag != ''">link_flag,</if>
<if test="linkType != null">link_type,</if>
<if test="linkDeviceId != null">link_device_id,</if>
<if test="linkDeviceFunctionId != null">link_device_function_id,</if>
<if test="linkDeviceFunctionData != null">link_device_function_data,</if>
<if test="alarmRuleStatus != null and alarmRuleStatus != ''">alarm_rule_status,</if>
<if test="alarmPushFlag != null and alarmPushFlag != ''">alarm_push_flag,</if>
<if test="alarmPushContent != null">alarm_push_content,</if>
<if test="alarmRecoverContent != null">alarm_recover_content,</if>
<if test="remark != null">remark,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="alarmRuleField != null">alarm_rule_field,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="alarmRuleName != null and alarmRuleName != ''">#{alarmRuleName},</if>
<if test="tenantId != null">#{tenantId},</if>
<if test="sceneId != null">#{sceneId},</if>
<if test="alarmLevelId != null">#{alarmLevelId},</if>
<if test="alarmTypeId != null">#{alarmTypeId},</if>
<if test="ruleType != null and ruleType != ''">#{ruleType},</if>
<if test="deviceId != null">#{deviceId},</if>
<if test="deviceModeId != null">#{deviceModeId},</if>
<if test="modeFunctionId != null">#{modeFunctionId},</if>
<if test="triggerCondition != null and triggerCondition != ''">#{triggerCondition},</if>
<if test="triggerDataA != null and triggerDataA != ''">#{triggerDataA},</if>
<if test="triggerDataB != null">#{triggerDataB},</if>
<if test="triggerDeadzone != null">#{triggerDeadzone},</if>
<if test="triggerNumber != null">#{triggerNumber},</if>
<if test="triggerTimeFrame != null">#{triggerTimeFrame},</if>
<if test="linkFlag != null and linkFlag != ''">#{linkFlag},</if>
<if test="linkType != null">#{linkType},</if>
<if test="linkDeviceId != null">#{linkDeviceId},</if>
<if test="linkDeviceFunctionId != null">#{linkDeviceFunctionId},</if>
<if test="linkDeviceFunctionData != null">#{linkDeviceFunctionData},</if>
<if test="alarmRuleStatus != null and alarmRuleStatus != ''">#{alarmRuleStatus},</if>
<if test="alarmPushFlag != null and alarmPushFlag != ''">#{alarmPushFlag},</if>
<if test="alarmPushContent != null">#{alarmPushContent},</if>
<if test="alarmRecoverContent != null">#{alarmRecoverContent},</if>
<if test="remark != null">#{remark},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="alarmRuleField != null">#{alarmRuleField},</if>
</trim>
</insert>
<update id="updateHwAlarmRule" parameterType="HwAlarmRule">
update hw_alarm_rule
<trim prefix="SET" suffixOverrides=",">
<if test="alarmRuleName != null and alarmRuleName != ''">alarm_rule_name = #{alarmRuleName},</if>
<if test="tenantId != null">tenant_id = #{tenantId},</if>
<if test="sceneId != null">scene_id = #{sceneId},</if>
<if test="alarmLevelId != null">alarm_level_id = #{alarmLevelId},</if>
<if test="alarmTypeId != null">alarm_type_id = #{alarmTypeId},</if>
<if test="ruleType != null and ruleType != ''">rule_type = #{ruleType},</if>
<if test="deviceId != null">device_id = #{deviceId},</if>
<if test="deviceModeId != null">device_mode_id = #{deviceModeId},</if>
<if test="modeFunctionId != null">mode_function_id = #{modeFunctionId},</if>
<if test="triggerCondition != null and triggerCondition != ''">trigger_condition = #{triggerCondition},</if>
<if test="triggerDataA != null and triggerDataA != ''">trigger_data_a = #{triggerDataA},</if>
<if test="triggerDataB != null">trigger_data_b = #{triggerDataB},</if>
<if test="triggerDeadzone != null">trigger_deadzone = #{triggerDeadzone},</if>
<if test="triggerNumber != null">trigger_number = #{triggerNumber},</if>
<if test="triggerTimeFrame != null">trigger_time_frame = #{triggerTimeFrame},</if>
<if test="linkFlag != null and linkFlag != ''">link_flag = #{linkFlag},</if>
<if test="linkType != null">link_type = #{linkType},</if>
<if test="linkDeviceId != null">link_device_id = #{linkDeviceId},</if>
<if test="linkDeviceFunctionId != null">link_device_function_id = #{linkDeviceFunctionId},</if>
<if test="linkDeviceFunctionData != null">link_device_function_data = #{linkDeviceFunctionData},</if>
<if test="alarmRuleStatus != null and alarmRuleStatus != ''">alarm_rule_status = #{alarmRuleStatus},</if>
<if test="alarmPushFlag != null and alarmPushFlag != ''">alarm_push_flag = #{alarmPushFlag},</if>
<if test="alarmPushContent != null">alarm_push_content = #{alarmPushContent},</if>
<if test="alarmRecoverContent != null">alarm_recover_content = #{alarmRecoverContent},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="alarmRuleField != null">alarm_rule_field = #{alarmRuleField},</if>
</trim>
where alarm_rule_id = #{alarmRuleId}
</update>
<delete id="deleteHwAlarmRuleByAlarmRuleId" parameterType="Long">
delete from hw_alarm_rule where alarm_rule_id = #{alarmRuleId}
</delete>
<delete id="deleteHwAlarmRuleByAlarmRuleIds" parameterType="String">
delete from hw_alarm_rule where alarm_rule_id in
<foreach item="alarmRuleId" collection="array" open="(" separator="," close=")">
#{alarmRuleId}
</foreach>
</delete>
</mapper>

@ -12,16 +12,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="effectiveTimeFlag" column="effective_time_flag" />
<result property="effectiveTime" column="effective_time" />
<result property="triggerStatus" column="trigger_status" />
<result property="areaShapeFlag" column="area_shape_flag" />
<result property="areaRange" column="area_range" />
<result property="fencePushFlag" column="fence_push_flag" />
<result property="fencePushContent" column="fence_push_content" />
<result property="fenceRecoverContent" column="fence_recover_content" />
</resultMap>
<sql id="selectElectronicFenceVo">
select electronic_fence_id, electronic_fence_name, scene_id, fence_type, effective_time_flag, effective_time, trigger_status, area_shape_flag,
area_range, fence_push_flag, fence_push_content, fence_recover_content
select electronic_fence_id, electronic_fence_name, scene_id, fence_type, effective_time_flag, effective_time, trigger_status,
fence_push_flag, fence_push_content, fence_recover_content
from hw_electronic_fence hef
</sql>

@ -0,0 +1,66 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.dataprocess.mapper.HwFenceAreaMapper">
<resultMap type="HwFenceArea" id="HwFenceAreaResult">
<result property="fenceAreaId" column="fence_area_id" />
<result property="electronicFenceId" column="electronic_fence_id" />
<result property="areaShapeFlag" column="area_shape_flag" />
<result property="areaRange" column="area_range" />
</resultMap>
<sql id="selectHwFenceAreaVo">
select fence_area_id, electronic_fence_id, area_shape_flag, area_range from hw_fence_area
</sql>
<select id="selectHwFenceAreaList" parameterType="HwFenceArea" resultMap="HwFenceAreaResult">
<include refid="selectHwFenceAreaVo"/>
<where>
<if test="electronicFenceId != null "> and electronic_fence_id = #{electronicFenceId}</if>
<if test="areaShapeFlag != null and areaShapeFlag != ''"> and area_shape_flag = #{areaShapeFlag}</if>
<if test="areaRange != null and areaRange != ''"> and area_range = #{areaRange}</if>
</where>
</select>
<select id="selectHwFenceAreaByFenceAreaId" parameterType="Long" resultMap="HwFenceAreaResult">
<include refid="selectHwFenceAreaVo"/>
where fence_area_id = #{fenceAreaId}
</select>
<insert id="insertHwFenceArea" parameterType="HwFenceArea" useGeneratedKeys="true" keyProperty="fenceAreaId">
insert into hw_fence_area
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="electronicFenceId != null">electronic_fence_id,</if>
<if test="areaShapeFlag != null and areaShapeFlag != ''">area_shape_flag,</if>
<if test="areaRange != null">area_range,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="electronicFenceId != null">#{electronicFenceId},</if>
<if test="areaShapeFlag != null and areaShapeFlag != ''">#{areaShapeFlag},</if>
<if test="areaRange != null">#{areaRange},</if>
</trim>
</insert>
<update id="updateHwFenceArea" parameterType="HwFenceArea">
update hw_fence_area
<trim prefix="SET" suffixOverrides=",">
<if test="electronicFenceId != null">electronic_fence_id = #{electronicFenceId},</if>
<if test="areaShapeFlag != null and areaShapeFlag != ''">area_shape_flag = #{areaShapeFlag},</if>
<if test="areaRange != null">area_range = #{areaRange},</if>
</trim>
where fence_area_id = #{fenceAreaId}
</update>
<delete id="deleteHwFenceAreaByFenceAreaId" parameterType="Long">
delete from hw_fence_area where fence_area_id = #{fenceAreaId}
</delete>
<delete id="deleteHwFenceAreaByFenceAreaIds" parameterType="String">
delete from hw_fence_area where fence_area_id in
<foreach item="fenceAreaId" collection="array" open="(" separator="," close=")">
#{fenceAreaId}
</foreach>
</delete>
</mapper>

@ -11,7 +11,7 @@ mqtt:
#broker相关配置
broker:
#客户端ClientId白名单不进行接入校验,多个ClientId用逗号隔开
whitelist: Test123,Test234,Test256
whitelist: hw-data-process-1
#设备接入状态推送
connectStatus:
enable: true #是否启用设备连接状态推送
@ -29,7 +29,7 @@ spring:
nacos:
config:
# 配置中心地址
server-addr: localhost:8848
server-addr: 127.0.0.1:8848
# 配置文件格式
file-extension: yml
# 共享配置

@ -385,7 +385,7 @@ public class TdEngineController {
try {
List<DeviceStatus> deviceStatuses = this.deviceStatusService.getOnlineDevicesGroupByDay(queryDeviceStatus);
Map<Long, List<DeviceStatus>> deviceStatusMap = deviceStatuses.stream()
.collect(Collectors.groupingBy(DeviceStatus::getTs));
.collect(Collectors.groupingBy(DeviceStatus::getDeviceId));
return R.ok(deviceStatusMap);
} catch (UncategorizedSQLException e) {
String message = e.getCause().getMessage();
@ -401,4 +401,31 @@ public class TdEngineController {
}
}
/**
* @return R<?>
* @param: tdSelectDto
* @description 线
* @author xins
* @date 2023-08-29 11:26
*/
@PostMapping("/getLastOnlineDevices")
public R<?> getLastOnlineDevices(@RequestBody DeviceStatus queryDeviceStatus) {
try {
List<Map<String,Object>> deviceStatusMapList = this.deviceStatusService.getLastOnlineDevices(queryDeviceStatus);
return R.ok(deviceStatusMapList);
} catch (UncategorizedSQLException e) {
String message = e.getCause().getMessage();
try {
message = message.substring(message.lastIndexOf("invalid operation"));
} catch (Exception ex) {
}
log.error(message);
return R.fail(message);
} catch (Exception e) {
log.error(e.getMessage());
return R.fail(e.getMessage());
}
}
}

@ -3,6 +3,7 @@ package com.ruoyi.tdengine.mapper;
import com.ruoyi.tdengine.api.domain.DeviceStatus;
import java.util.List;
import java.util.Map;
/**
* @Description:TDengine
@ -21,4 +22,14 @@ public interface DeviceStatusMapper {
* @return List<DeviceStatus>
*/
List<DeviceStatus> getOnlineDevicesGroupByDay(DeviceStatus deviceStatus);
/**
* @param: deviceStatus
* @description 线
* @author xins
* @date 2023-09-05 11:43
* @return List<DeviceStatus>
*/
List<Map<String, Object>> getLastOnlineDevices(DeviceStatus deviceStatus);
}

@ -3,6 +3,7 @@ package com.ruoyi.tdengine.service;
import com.ruoyi.tdengine.api.domain.DeviceStatus;
import java.util.List;
import java.util.Map;
public interface IDeviceStatusService {
@ -14,4 +15,13 @@ public interface IDeviceStatusService {
* @return List<DeviceStatus>
*/
public List<DeviceStatus> getOnlineDevicesGroupByDay(DeviceStatus queryDeviceStatus);
/**
* @return List<Map<String, Object>>
* @param: DeviceStatus
* @description 线
* @author xins
* @date 2023-09-05 13:23
*/
public List<Map<String, Object>> getLastOnlineDevices(DeviceStatus queryDeviceStatus);
}

@ -7,9 +7,11 @@ import com.ruoyi.tdengine.service.IDeviceStatusService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* @Description:
@ -49,4 +51,36 @@ public class DeviceStatusServiceImpl implements IDeviceStatusService {
return deviceStatuses;
}
/**
* @return List<Map<String, Object>>
* @param: DeviceStatus
* @description 线
* @author xins
* @date 2023-09-05 13:23
*/
@Override
public List<Map<String, Object>> getLastOnlineDevices(DeviceStatus queryDeviceStatus) {
Map<String, Object> params = queryDeviceStatus.getParams();
params.put("databaseName", TdEngineConstants.PLATFORM_DB_NAME);
params.put("superTableName", TdEngineConstants.DEFAULT_DEVICE_STATUS_SUPER_TABLE_NAME);
List<Map<String, Object>> deviceStatusMap = deviceStatusMapper.getLastOnlineDevices(queryDeviceStatus);
List<Map<String, Object>> filterMaps = new ArrayList<>();
String i18nKey = "";//todo国际化看在哪处理
for (Map<String, Object> latestMap : deviceStatusMap) {
Map<String, Object> filterMap = latestMap.entrySet()
.stream()
.filter(entry -> entry.getValue() != null)
.collect(HashMap::new, (m, v) ->
m.put(i18nKey + v.getKey().substring(v.getKey().indexOf("(") + 1,
v.getKey().indexOf(")")), v.getValue()), HashMap::putAll);
filterMaps.add(filterMap);
}
return filterMaps;
}
}

@ -303,4 +303,5 @@ public class TdEngineServiceImpl implements ITdEngineService {
// return maps;
// }
}

@ -6,13 +6,24 @@
<select id="getOnlineDevicesGroupByDay" parameterType="com.ruoyi.tdengine.api.domain.DeviceStatus" resultType="com.ruoyi.tdengine.api.domain.DeviceStatus" >
select timetruncate(ts,1d) ts,devicetype,onlinestatus,deviceid from #{params.databaseName}.#{params.superTableName}
where onlinestatus=1
<if test="{params.beginTime}!= null and {params.endTime} != null">
and ts BETWEEN #{params.beginTime} AND #{params.endTime}
<if test="startTime!= null and endTime != null and startTime!= 0 and endTime != 0">
and ts BETWEEN #{startTime} AND #{endTime}
</if>
<if test="sceneId != null "> and scene_id = #{sceneId}</if>
group by timetruncate(ts,1d),devicetype,onlinestatus,deviceid
order by ts
</select>
<select id="getLastOnlineDevices" parameterType="com.ruoyi.tdengine.api.domain.DeviceStatus" resultType="java.util.Map" >
select last_row(*),last_row(deviceid) from #{params.databaseName}.#{params.superTableName}
<where>
<if test="endTime!= null and endTime != 0">
and ts &lt;= #{endTime}
</if>
</where>
group by deviceid
</select>
</mapper>

@ -1,6 +1,6 @@
# Tomcat
server:
port: 9300
port: 9665
# Spring
spring:

@ -81,6 +81,12 @@
<groupId>com.ruoyi</groupId>
<artifactId>hw-api-tdengine</artifactId>
</dependency>
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>hw-api-business</artifactId>
<version>3.6.3</version>
<scope>compile</scope>
</dependency>
</dependencies>

@ -1,16 +1,10 @@
package com.ruoyi.job.task;
import com.ruoyi.common.core.constant.TdEngineConstants;
import com.ruoyi.tdengine.api.RemoteTdEngineService;
import com.ruoyi.tdengine.api.domain.DeviceStatus;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;
import com.ruoyi.business.api.RemoteBusinessService;
import com.ruoyi.common.core.utils.StringUtils;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
/**
*
@ -20,11 +14,7 @@ import java.util.Map;
@Component("ryTask")
public class RyTask {
@Resource
private RemoteTdEngineService remoteTdEngineService;
@Autowired
private StringRedisTemplate redisTemplate;
private RemoteBusinessService remoteBusinessService;
public void ryMultipleParams(String s, Boolean b, Long l, Double d, Integer i) {
System.out.println(StringUtils.format("执行多参方法: 字符串类型{},布尔类型{},长整型{},浮点型{},整形{}", s, b, l, d, i));
@ -39,38 +29,7 @@ public class RyTask {
}
public void updateDeviceStatusData(Long days) {
Long startTime = 0L;//先是昨天
Long endTime = 1L;
DeviceStatus queryGroupStatus = new DeviceStatus();
queryGroupStatus.setStartTime(startTime);
queryGroupStatus.setEndTime(endTime);
DeviceStatus queryLastStatus = new DeviceStatus();
queryLastStatus.setEndTime(startTime);
Map<Long, List<DeviceStatus>> groupDeviceStatuMapList =
(Map<Long, List<DeviceStatus>>) this.remoteTdEngineService.getOnlineDevicesGroupByDay(queryGroupStatus).getData();
List<Map<String, Object>> lastDeviceStatuMapList =
(List<Map<String, Object>>) this.remoteTdEngineService.getLastOnlineDevices(queryLastStatus).getData();
for (Map<String, Object> groupDeviceStatuMap : lastDeviceStatuMapList) {
DeviceStatus ds = new DeviceStatus();
for (Map.Entry<String, Object> entry : groupDeviceStatuMap.entrySet()) {
if (entry.getKey().equals(TdEngineConstants.ST_TAG_DEVICEID)) {
ds.setDeviceId((Long) entry.getValue());
} else if (entry.getKey().equals(TdEngineConstants.ST_TAG_DEVICETYPE)) {
ds.setDeviceType((Integer) entry.getValue());
} else if (entry.getKey().equals(TdEngineConstants.ST_TAG_ONLINESTATUS)) {
ds.setOnlineStatus((Integer) entry.getValue());
}
}
if(groupDeviceStatuMapList.get(ds.getDeviceId())==null){
// groupDeviceStatuMapList.put(ds.getDeviceId(), Lists.newArrayList());
}
}
public void computeOnlineDevicecCount(int days) {
this.remoteBusinessService.computeOnlineDevicecCount(days);
}
}

@ -1,6 +1,6 @@
# Tomcat
server:
port: 9203
port: 9663
# Spring
spring:

@ -1,5 +1,6 @@
package com.ruoyi.system;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import com.ruoyi.common.security.annotation.EnableCustomConfig;
@ -17,9 +18,14 @@ import com.ruoyi.common.swagger.annotation.EnableCustomSwagger2;
@SpringBootApplication
public class RuoYiSystemApplication
{
@Value("${spring.nacos.config.server-addr}")
public static String dd;
public static void main(String[] args)
{
System.out.println("---"+dd);
SpringApplication.run(RuoYiSystemApplication.class, args);
System.out.println("-----"+dd);
System.out.println("(♥◠‿◠)ノ゙ 系统模块启动成功 ლ(´ڡ`ლ)゙ \n" +
" .-------. ____ __ \n" +
" | _ _ \\ \\ \\ / / \n" +

@ -1,6 +1,6 @@
# Tomcat
server:
port: 9201
port: 9661
# Spring
spring:

@ -22,6 +22,7 @@ export function getAlarmInfos(query) {
// baseURL:'/monitoring-api',
url: '/business/monitorPlatform/getAlarmInfos',
method: 'get',
params: query
})
}
// 右下

@ -33,5 +33,6 @@ export function getAlarmInfos(query) {
// baseURL:'/monitoring-api',
url: '/business/monitorPlatform/getAlarmInfos',
method: 'get',
params: query
})
}

@ -12,7 +12,7 @@
告警类型
</div>
<div class="scrollTable" style="font-weight: bold;">
告警位置
告警单元
</div>
<div class="scrollTable" style="font-weight: bold;">
操作
@ -274,12 +274,12 @@ export default {
this.num3 = data.onlineDeviceNum
},
async setAlarmInfos() {
const {rows: data} = await getAlarmInfos()
const {rows: data} = await getAlarmInfos({"sceneId": this.sceneId})
console.log(data)
this.table1Data = data.map((e, i) => {
return {
value1: i,
value2: '高温预警',
value1: e.alarmInfoId,
value2: e.alarmTypeName,
value3: e.monitorUnitName,
status: e.handleStatus
}

@ -3,7 +3,7 @@
<div class="title1">监控单元</div>
<div class="centerImg"></div>
<BoardTopNav ref="boardTopNav" nowMenu="3" @sceneIdChange="sceneIdChange"></BoardTopNav>
<div class="title">物联网平台</div>
<div class="title">监控单元</div>
<div class="tree">
<el-tree
@ -18,29 +18,29 @@
</div>
<div v-if="show" class="equipmentInfo">
<p>
<span>设备名称</span>
<span>名称</span>
<span style="color: #d9dee3">{{ MonitorInfo.monitorUnitName }}</span>
</p>
<p>
<span>设备id</span>
<span>ID</span>
<span style="color: #d9dee3">{{ MonitorInfo.monitorUnitId }}</span>
</p>
<p>
<span>设备状态</span>
<span>状态</span>
<span style="color: #d9dee3">{{ MonitorInfo.monitorUnitStatus === 1 ? '正常' : '异常' }}</span>
</p>
<p>
<span>设备类型</span>
<span style="color: #d9dee3">{{ MonitorInfo.monitorUnitTypeId }}</span>
<span>类型</span>
<span style="color: #d9dee3">{{ MonitorInfo.monitorUnitTypeName }}</span>
</p>
</div>
<div v-if="show" class="img"></div>
<div class="terminal">
<el-form :model="form" class="demo-form-inline">
<!--el-form :model="form" class="demo-form-inline">
<el-form-item label="传感器名称:">
<el-input v-model="form.data1" placeholder="传感器名称" style="width:calc(100% - 100px)"></el-input>
</el-form-item>
</el-form>
</el-form-->
<div class="terminalList">
<div v-for="(i,k) in controlList" class="item">
<div class="icon"></div>
@ -63,7 +63,7 @@
<div class="rightBg">
<div class="title">{{ i.deviceName }}</div>
<div style="position: absolute;left: 24%;top: 0px;width: 75%;height: 100%;">
<div v-for="val in Object.keys(i.deviceDataMaps[0]).slice(0,3)" class="infoItem">
<div v-for="val in Object.keys(i.deviceDataMaps[0])" class="infoItem">
<div class="span">{{ val }}:</div>
<div class="spanBg"></div>
<div class="num">{{ i.deviceDataMaps[0][val] }}</div>
@ -162,7 +162,7 @@ export default {
}
},
async getDevice(e) {
const {data} = await selectDevicesByMonitorUnitId(this.$store.getters.sceneId, e)
const {data} = await selectDevicesByMonitorUnitId(e, this.$store.getters.sceneId)
console.log(data)
this.deviceId = e
this.controlList = data.control
@ -190,7 +190,7 @@ export default {
};
</script>
<style lang="less" scoped>
.title1{
.title1 {
position: absolute;
top: 12%;
left: 73%;
@ -198,6 +198,7 @@ export default {
color: #00f8ff;
transform: translateX(-50%);
}
.container {
background-image: url("~@/assets/board/equipment/bg.jpg");
background-repeat: no-repeat;

@ -355,8 +355,8 @@ export default {
const {rows: data} = await getAlarmInfos()
this.table1Data = data.map((e, i) => {
return {
no: i+1,
type: '高温警告',
no: e.alarmInfoId,
type: e.alarmTypeName,
location: e.monitorUnitName,
status:e.handleStatus
}
@ -364,18 +364,20 @@ export default {
},
async setDeviceOperations() {
let {data: data} = await getDeviceOperations()
let sortArr = Object.keys(data)
let onlineDevicesTrend = data["onlineDevicesTrend"];
let sortArr = Object.keys(onlineDevicesTrend)
sortArr = sortArr.sort((a,b)=>{
return new Date(a).getTime() - new Date(b).getTime()
})
console.log(sortArr)
let x = sortArr
let y = sortArr.map(e=>{
return data[e]
return onlineDevicesTrend[e]
})
this.inTransitNum = y.reduce((a, b) => {
return a + b
}, 0)
// this.inTransitNum = y.reduce((a, b) => {
// return a + b
// }, 0)
this.inTransitNum = data["onlineDevicesCount"];
let option3 = {
...this.chart3Option,

@ -21,13 +21,10 @@
告警类型
</div>
<div class="scrollTable" style="font-weight: bold;width: 15%">
告警单元
</div>
<div class="scrollTable" style="font-weight: bold;width: 30%">
告警信息
告警级别
</div>
<div class="scrollTable" style="font-weight: bold;width: 11%">
告警位置
<div class="scrollTable" style="font-weight: bold;width: 21%">
告警单元
</div>
<div class="scrollTable" style="font-weight: bold;width: 20%">
告警时间
@ -49,14 +46,11 @@
<div class="scrollTable" style="width: 15%">
{{ item.data3 }}
</div>
<div class="scrollTable" style="width: 20%">
{{ item.data4 }}
</div>
<div class="scrollTable" style="width: 21%">
{{ item.data5 }}
{{ item.data4 }}
</div>
<div class="scrollTable" style="width: 20%">
{{ item.data6 }}
{{ item.data5 }}
</div>
<div class="scrollTable" style="width: 8%">
<span style="color: #67C23A;">已处理</span>
@ -161,15 +155,14 @@ export default {
this.alarmCountGroupAlarmType = data
},
async setAlarmInfos() {
const {rows: data} = await getAlarmInfos()
const {rows: data} = await getAlarmInfos({"sceneId":this.sceneId})
this.table1Data = data.map((e,i)=>{
return {
data1: i+1,
data2: e.alarmLevelName,
data3: e.alarmTypeName,
data4:e.remark,
data5: e.monitorUnitName,
data6: e.alarmTime,
data1: e.alarmInfoId,
data2: e.alarmTypeName,
data3: e.alarmLevelName,
data4: e.monitorUnitName,
data5: e.alarmTime,
}
})
}

@ -138,16 +138,16 @@
<el-table-column label="所属场景" align="center" prop="sceneName"/>
<el-table-column label="监控单元" align="center" prop="monitorUnitName"/>
<el-table-column label="设备模型" align="center" prop="deviceModeName"/>
<el-table-column label="激活状态" align="center" prop="activeStatus">
<!--el-table-column label="激活状态" align="center" prop="activeStatus">
<template slot-scope="scope">
<dict-tag :options="dict.type.hw_device_active_status" :value="scope.row.activeStatus"/>
</template>
</el-table-column>
<el-table-column label="设备激活时间" align="center" prop="activeTime" width="180">
</el-table-column-->
<!--el-table-column label="设备激活时间" align="center" prop="activeTime" width="180">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.activeTime, '{y}-{m}-{d}') }}</span>
</template>
</el-table-column>
</el-table-column-->
<el-table-column label="设备状态" align="center" prop="deviceStatus">
<template slot-scope="scope">
<el-switch
@ -874,11 +874,11 @@ export default {
//
handleDeviceStatusChange(row) {
if(row.deviceStatus==='1' && row.activeStatus === '0'){
this.$modal.msgSuccess("激活后才能修改为发布状态");
row.deviceStatus = row.deviceStatus === "0" ? "1" : "0";
return;
}
// if(row.deviceStatus==='1' && row.activeStatus === '0'){
// this.$modal.msgSuccess("");
// row.deviceStatus = row.deviceStatus === "0" ? "1" : "0";
// return;
// }
let text = row.deviceStatus === "0" ? "测试" : "发布";
this.$modal.confirm('确认要改为'+text+'状态吗?').then(function () {
return changeDeviceStatus(row.deviceId, row.deviceStatus);

@ -1,6 +1,25 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<!-- <el-form-item label="行业类型关联sys_dict_data的dict_type是hw_tenant_industry的dict_value" prop="tenantIndustry">-->
<!-- <el-input-->
<!-- v-model="queryParams.tenantIndustry"-->
<!-- placeholder="请输入行业类型关联sys_dict_data的dict_type是hw_tenant_industry的dict_value"-->
<!-- clearable-->
<!-- @keyup.enter.native="handleQuery"-->
<!-- />-->
<!-- </el-form-item>-->
<el-form-item label="租户类型" prop="tenantType">
<el-select v-model="queryParams.tenantType" placeholder="租户类型">
<el-option
v-for="dict in dict.type.hw_tenant_type"
:key ="dict.value"
:label="dict.label"
:value="dict.value">
</el-option>
</el-select>
</el-form-item>
<el-form-item label="租户名称" prop="tenantName">
<el-input
v-model="queryParams.tenantName"
@ -9,14 +28,6 @@
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="行业类型关联sys_dict_data的dict_type是hw_tenant_industry的dict_value" prop="tenantIndustry">
<el-input
v-model="queryParams.tenantIndustry"
placeholder="请输入行业类型关联sys_dict_data的dict_type是hw_tenant_industry的dict_value"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="联系人姓名" prop="contactName">
<el-input
v-model="queryParams.contactName"
@ -33,54 +44,54 @@
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="邮箱地址" prop="email">
<el-input
v-model="queryParams.email"
placeholder="请输入邮箱地址"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="区域ID管理区域hw_area" prop="areaId">
<el-input
v-model="queryParams.areaId"
placeholder="请输入区域ID管理区域hw_area"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="联系人地址" prop="contactAddress">
<el-input
v-model="queryParams.contactAddress"
placeholder="请输入联系人地址"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="是否外部注册" prop="isRegister">
<el-input
v-model="queryParams.isRegister"
placeholder="请输入是否外部注册"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="租户等级,预留字段" prop="tenantGrade">
<el-input
v-model="queryParams.tenantGrade"
placeholder="请输入租户等级,预留字段"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="预留字段" prop="tenantField">
<el-input
v-model="queryParams.tenantField"
placeholder="请输入预留字段"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<!-- <el-form-item label="邮箱地址" prop="email">-->
<!-- <el-input-->
<!-- v-model="queryParams.email"-->
<!-- placeholder="请输入邮箱地址"-->
<!-- clearable-->
<!-- @keyup.enter.native="handleQuery"-->
<!-- />-->
<!-- </el-form-item>-->
<!-- <el-form-item label="区域ID管理区域hw_area" prop="areaId">-->
<!-- <el-input-->
<!-- v-model="queryParams.areaId"-->
<!-- placeholder="请输入区域ID管理区域hw_area"-->
<!-- clearable-->
<!-- @keyup.enter.native="handleQuery"-->
<!-- />-->
<!-- </el-form-item>-->
<!-- <el-form-item label="联系人地址" prop="contactAddress">-->
<!-- <el-input-->
<!-- v-model="queryParams.contactAddress"-->
<!-- placeholder="请输入联系人地址"-->
<!-- clearable-->
<!-- @keyup.enter.native="handleQuery"-->
<!-- />-->
<!-- </el-form-item>-->
<!-- <el-form-item label="是否外部注册" prop="isRegister">-->
<!-- <el-input-->
<!-- v-model="queryParams.isRegister"-->
<!-- placeholder="请输入是否外部注册"-->
<!-- clearable-->
<!-- @keyup.enter.native="handleQuery"-->
<!-- />-->
<!-- </el-form-item>-->
<!-- <el-form-item label="租户等级,预留字段" prop="tenantGrade">-->
<!-- <el-input-->
<!-- v-model="queryParams.tenantGrade"-->
<!-- placeholder="请输入租户等级,预留字段"-->
<!-- clearable-->
<!-- @keyup.enter.native="handleQuery"-->
<!-- />-->
<!-- </el-form-item>-->
<!-- <el-form-item label="预留字段" prop="tenantField">-->
<!-- <el-input-->
<!-- v-model="queryParams.tenantField"-->
<!-- placeholder="请输入预留字段"-->
<!-- clearable-->
<!-- @keyup.enter.native="handleQuery"-->
<!-- />-->
<!-- </el-form-item>-->
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery"></el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery"></el-button>
@ -135,20 +146,39 @@
<el-table v-loading="loading" :data="tenantList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="租户ID" align="center" prop="tenantId" />
<el-table-column label="租户类型,(1、企业2、个人)" align="center" prop="tenantType" />
<!-- <el-table-column label="租户ID" align="center" prop="tenantId" />-->
<el-table-column label="租户名称" align="center" prop="tenantName" />
<el-table-column label="行业类型关联sys_dict_data的dict_type是hw_tenant_industry的dict_value" align="center" prop="tenantIndustry" />
<el-table-column label="租户类型" align="center" prop="tenantType">
<template slot-scope="scope">
<dict-tag
:options="dict.type.hw_tenant_type"
:value="scope.row.tenantType"
>
</dict-tag>
</template>
</el-table-column>
<el-table-column label="行业类型" align="center" prop="tenantIndustry">
<template slot-scope="scope">
<dict-tag
:options="dict.type.hw_tenant_industry"
:value="scope.row.tenantIndustry"
>
</dict-tag>
</template>
</el-table-column>
<el-table-column label="联系人姓名" align="center" prop="contactName" />
<el-table-column label="联系人电话" align="center" prop="contactPhone" />
<el-table-column label="邮箱地址" align="center" prop="email" />
<el-table-column label="区域ID管理区域hw_area" align="center" prop="areaId" />
<!-- <el-table-column label="区域ID管理区域hw_area" align="center" prop="areaId" />-->
<el-table-column label="联系人地址" align="center" prop="contactAddress" />
<el-table-column label="描述" align="center" prop="remark" />
<el-table-column label="状态" align="center" prop="tenantStatus" />
<el-table-column label="是否外部注册" align="center" prop="isRegister" />
<el-table-column label="租户等级,预留字段" align="center" prop="tenantGrade" />
<el-table-column label="预留字段" align="center" prop="tenantField" />
<!-- <el-table-column label="描述" align="center" prop="remark" />-->
<!-- <el-table-column label="状态" align="center" prop="tenantStatus" />-->
<!-- <el-table-column label="是否外部注册" align="center" prop="isRegister" />-->
<!-- <el-table-column label="租户等级,预留字段" align="center" prop="tenantGrade" />-->
<!-- <el-table-column label="预留字段" align="center" prop="tenantField" />-->
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
@ -178,41 +208,82 @@
/>
<!-- 添加或修改租户信息对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-dialog :title="title" :visible.sync="open" width="65%" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="100px">
<el-row>
<el-col span="12">
<el-form-item label="租户类型">
<el-radio-group v-model="form.tenantType">
<el-radio
v-for="dict in dict.type.hw_tenant_type"
:key="dict.value"
:label="dict.value"
>{{dict.label}}</el-radio>
</el-radio-group>
</el-form-item>
</el-col>
<el-col span="12">
<el-form-item label="租户名称" prop="tenantName">
<el-input v-model="form.tenantName" placeholder="请输入租户名称" />
</el-form-item>
<el-form-item label="行业类型关联sys_dict_data的dict_type是hw_tenant_industry的dict_value" prop="tenantIndustry">
<el-input v-model="form.tenantIndustry" placeholder="请输入行业类型关联sys_dict_data的dict_type是hw_tenant_industry的dict_value" />
</el-col>
<el-col span="12">
<el-form-item label="租户行业">
<el-select v-model="form.tenantIndustry" placeholder="请选择租户行业">
<el-option
v-for="dict in dict.type.hw_tenant_industry"
:key ="dict.value"
:label="dict.label"
:value="parseInt(dict.value)">
</el-option>
</el-select>
</el-form-item>
</el-col>
<el-col span="12">
<el-form-item label="联系人姓名" prop="contactName">
<el-input v-model="form.contactName" placeholder="请输入联系人姓名" />
</el-form-item>
</el-col>
<el-col span="12">
<el-form-item label="联系人电话" prop="contactPhone">
<el-input v-model="form.contactPhone" placeholder="请输入联系人电话" />
</el-form-item>
</el-col>
<el-col span="12">
<el-form-item label="邮箱地址" prop="email">
<el-input v-model="form.email" placeholder="请输入邮箱地址" />
</el-form-item>
<el-form-item label="区域ID管理区域hw_area" prop="areaId">
<el-input v-model="form.areaId" placeholder="请输入区域ID管理区域hw_area" />
</el-form-item>
</el-col>
<el-col span="12">
<el-form-item label="联系人地址" prop="contactAddress">
<el-input v-model="form.contactAddress" placeholder="请输入联系人地址" />
</el-form-item>
</el-col>
</el-row>
<!-- <el-form-item label="行业类型关联sys_dict_data的dict_type是hw_tenant_industry的dict_value" prop="tenantIndustry">-->
<!-- <el-input v-model="form.tenantIndustry" placeholder="请输入行业类型关联sys_dict_data的dict_type是hw_tenant_industry的dict_value" />-->
<!-- </el-form-item>-->
<!-- 区域ID管理区域hw_area-->
<el-form-item label="描述" prop="remark">
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
</el-form-item>
<el-form-item label="是否外部注册" prop="isRegister">
<el-input v-model="form.isRegister" placeholder="请输入是否外部注册" />
</el-form-item>
<el-form-item label="租户等级,预留字段" prop="tenantGrade">
<el-input v-model="form.tenantGrade" placeholder="请输入租户等级,预留字段" />
</el-form-item>
<el-form-item label="预留字段" prop="tenantField">
<el-input v-model="form.tenantField" placeholder="请输入预留字段" />
</el-form-item>
<!-- <el-form-item label="是否外部注册" prop="isRegister">-->
<!-- <el-input v-model="form.isRegister" placeholder="请输入是否外部注册" />-->
<!-- </el-form-item>-->
<!-- <el-form-item label="租户等级,预留字段" prop="tenantGrade">-->
<!-- <el-input v-model="form.tenantGrade" placeholder="请输入租户等级,预留字段" />-->
<!-- </el-form-item>-->
<!-- <el-form-item label="预留字段" prop="tenantField">-->
<!-- <el-input v-model="form.tenantField" placeholder="请输入预留字段" />-->
<!-- </el-form-item>-->
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
@ -224,9 +295,11 @@
<script>
import { listTenant, getTenant, delTenant, addTenant, updateTenant } from "@/api/business/tenant";
import {delUser} from "@/api/system/user";
export default {
name: "Tenant",
dicts:['hw_tenant_industry','hw_tenant_type'],
data() {
return {
//
@ -253,7 +326,7 @@ export default {
pageSize: 10,
tenantType: null,
tenantName: null,
tenantIndustry: null,
// tenantIndustry: null,
contactName: null,
contactPhone: null,
email: null,
@ -269,7 +342,7 @@ export default {
//
rules: {
tenantType: [
{ required: true, message: "租户类型(1、企业2、个人)不能为空", trigger: "change" }
{ required: true, message: "租户类型不能为空", trigger: "change" }
],
tenantName: [
{ required: true, message: "租户名称不能为空", trigger: "blur" }
@ -280,12 +353,12 @@ export default {
contactPhone: [
{ required: true, message: "联系人电话不能为空", trigger: "blur" }
],
tenantStatus: [
{ required: true, message: "状态不能为空", trigger: "change" }
],
isRegister: [
{ required: true, message: "是否外部注册不能为空", trigger: "blur" }
],
// tenantStatus: [
// { required: true, message: "", trigger: "change" }
// ],
// isRegister: [
// { required: true, message: "", trigger: "blur" }
// ],
}
};
},
@ -293,6 +366,8 @@ export default {
this.getList();
},
methods: {
/** 查询租户信息列表 */
getList() {
this.loading = true;
@ -310,24 +385,24 @@ export default {
//
reset() {
this.form = {
tenantId: null,
tenantType: null,
tenantName: null,
tenantIndustry: null,
contactName: null,
contactPhone: null,
email: null,
areaId: null,
contactAddress: null,
remark: null,
tenantStatus: null,
isRegister: null,
createBy: null,
createTime: null,
updateBy: null,
updateTime: null,
tenantGrade: null,
tenantField: null
tenantId: undefined,
tenantType: "1",
tenantName: undefined,
tenantIndustry: undefined,
contactName: undefined,
contactPhone: undefined,
email: undefined,
areaId: undefined,
contactAddress: undefined,
remark: undefined,
tenantStatus: undefined,
isRegister: undefined,
createBy: undefined,
createTime: undefined,
updateBy: undefined,
updateTime: undefined,
tenantGrade: undefined,
tenantField: undefined
};
this.resetForm("form");
},
@ -358,6 +433,7 @@ export default {
this.reset();
const tenantId = row.tenantId || this.ids
getTenant(tenantId).then(response => {
//int
this.form = response.data;
this.open = true;
this.title = "修改租户信息";
@ -383,10 +459,10 @@ export default {
}
});
},
/** 删除按钮操作 */
// /** */
handleDelete(row) {
const tenantIds = row.tenantId || this.ids;
this.$modal.confirm('是否确认删除租户信息编号为"' + tenantIds + '"的数据项?').then(function() {
this.$modal.confirm('是否确认删除租户名称为"' + row.tenantName + '"的数据项?').then(function() {
return delTenant(tenantIds);
}).then(() => {
this.getList();
@ -402,3 +478,27 @@ export default {
}
};
</script>
<a-form-item label="测站类型">
<a-select
allowClear
v-decorator="[
'typeId',
{ rules: [{ required: true, message: '请选择测站类型' }] },
]"
placeholder="请选择测站类型"
>
<a-select-option
v-for="(item, index) in $attrs.testList"
:value="String(item.id)"
:key="index"
>
{{ item.name }}
</a-select-option>
</a-select>
</a-form-item>

@ -9,7 +9,7 @@ const CompressionPlugin = require('compression-webpack-plugin')
const name = process.env.VUE_APP_TITLE || '若依管理系统' // 网页标题
const port = process.env.port || process.env.npm_config_port || 80 // 端口
const port = process.env.port || process.env.npm_config_port || 8018 // 端口
// vue.config.js 配置说明
//官方vue.config.js 参考文档 https://cli.vuejs.org/zh/config/#css-loaderoptions
@ -35,7 +35,7 @@ module.exports = {
proxy: {
// detail: https://cli.vuejs.org/config/#devserver-proxy
[process.env.VUE_APP_BASE_API]: {
target: `http://10.11.40.120:8080`,
target: `http://127.0.0.1:9080`,
// target: `http://10.11.43.111:8080`,
changeOrigin: true,
pathRewrite: {

@ -9,7 +9,7 @@ spring:
name: ruoyi-monitor
profiles:
# 环境配置
active: dev
active: druid
cloud:
nacos:
discovery:

Loading…
Cancel
Save