Merge remote-tracking branch 'origin/master'
commit
dbfeb97eec
@ -0,0 +1,137 @@
|
||||
<?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>org.dromara</groupId>
|
||||
<artifactId>ruoyi-modules</artifactId>
|
||||
<version>${revision}</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>hwmom-dms</artifactId>
|
||||
|
||||
<description>
|
||||
hwmom-dms设备模块
|
||||
</description>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.dromara</groupId>
|
||||
<artifactId>ruoyi-common-nacos</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.dromara</groupId>
|
||||
<artifactId>ruoyi-common-sentinel</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- RuoYi Common Log -->
|
||||
<dependency>
|
||||
<groupId>org.dromara</groupId>
|
||||
<artifactId>ruoyi-common-log</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.dromara</groupId>
|
||||
<artifactId>ruoyi-common-dict</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.dromara</groupId>
|
||||
<artifactId>ruoyi-common-doc</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.dromara</groupId>
|
||||
<artifactId>ruoyi-common-web</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.dromara</groupId>
|
||||
<artifactId>ruoyi-common-mybatis</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.dromara</groupId>
|
||||
<artifactId>ruoyi-common-dubbo</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.dromara</groupId>
|
||||
<artifactId>ruoyi-common-seata</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.dromara</groupId>
|
||||
<artifactId>ruoyi-common-idempotent</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.dromara</groupId>
|
||||
<artifactId>ruoyi-common-tenant</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.dromara</groupId>
|
||||
<artifactId>ruoyi-common-security</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.dromara</groupId>
|
||||
<artifactId>ruoyi-common-translation</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.dromara</groupId>
|
||||
<artifactId>ruoyi-common-sensitive</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.dromara</groupId>
|
||||
<artifactId>ruoyi-common-encrypt</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- RuoYi Api System -->
|
||||
<dependency>
|
||||
<groupId>org.dromara</groupId>
|
||||
<artifactId>ruoyi-api-system</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.dromara</groupId>
|
||||
<artifactId>ruoyi-api-resource</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>com.mysql</groupId>-->
|
||||
<!-- <artifactId>mysql-connector-j</artifactId>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
<dependency>
|
||||
<groupId>com.microsoft.sqlserver</groupId>
|
||||
<artifactId>mssql-jdbc</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<finalName>${project.artifactId}</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<version>${spring-boot.version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
@ -0,0 +1,22 @@
|
||||
package org.dromara.dms;
|
||||
|
||||
import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.context.metrics.buffering.BufferingApplicationStartup;
|
||||
|
||||
/**
|
||||
* DMS设备模块
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@EnableDubbo
|
||||
@SpringBootApplication
|
||||
public class HwMomDmsApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication application = new SpringApplication(HwMomDmsApplication.class);
|
||||
application.setApplicationStartup(new BufferingApplicationStartup(2048));
|
||||
application.run(args);
|
||||
System.out.println("(♥◠‿◠)ノ゙ HwDms启动成功 ლ(´ڡ`ლ)゙ ");
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,117 @@
|
||||
package org.dromara.dms.controller;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.constraints.*;
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.dromara.common.idempotent.annotation.RepeatSubmit;
|
||||
import org.dromara.common.log.annotation.Log;
|
||||
import org.dromara.common.web.core.BaseController;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.core.domain.R;
|
||||
import org.dromara.common.core.validate.AddGroup;
|
||||
import org.dromara.common.core.validate.EditGroup;
|
||||
import org.dromara.common.log.enums.BusinessType;
|
||||
import org.dromara.common.excel.utils.ExcelUtil;
|
||||
import org.dromara.dms.domain.vo.DmsDeviceModeVo;
|
||||
import org.dromara.dms.domain.bo.DmsDeviceModeBo;
|
||||
import org.dromara.dms.service.IDmsDeviceModeService;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 设备模型
|
||||
* 前端访问路由地址为:/dms/deviceMode
|
||||
*
|
||||
* @author Yinq
|
||||
* @date 2025-03-11
|
||||
*/
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/deviceMode")
|
||||
public class DmsDeviceModeController extends BaseController {
|
||||
|
||||
private final IDmsDeviceModeService dmsDeviceModeService;
|
||||
|
||||
/**
|
||||
* 查询设备模型列表
|
||||
*/
|
||||
@SaCheckPermission("dms:deviceMode:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<DmsDeviceModeVo> list(DmsDeviceModeBo bo, PageQuery pageQuery) {
|
||||
return dmsDeviceModeService.queryPageList(bo, pageQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出设备模型列表
|
||||
*/
|
||||
@SaCheckPermission("dms:deviceMode:export")
|
||||
@Log(title = "设备模型", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(DmsDeviceModeBo bo, HttpServletResponse response) {
|
||||
List<DmsDeviceModeVo> list = dmsDeviceModeService.queryList(bo);
|
||||
ExcelUtil.exportExcel(list, "设备模型", DmsDeviceModeVo.class, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取设备模型详细信息
|
||||
*
|
||||
* @param deviceModeId 主键
|
||||
*/
|
||||
@SaCheckPermission("dms:deviceMode:query")
|
||||
@GetMapping("/{deviceModeId}")
|
||||
public R<DmsDeviceModeVo> getInfo(@NotNull(message = "主键不能为空")
|
||||
@PathVariable Long deviceModeId) {
|
||||
return R.ok(dmsDeviceModeService.queryById(deviceModeId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增设备模型
|
||||
*/
|
||||
@SaCheckPermission("dms:deviceMode:add")
|
||||
@Log(title = "设备模型", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit()
|
||||
@PostMapping()
|
||||
public R<Void> add(@Validated(AddGroup.class) @RequestBody DmsDeviceModeBo bo) {
|
||||
return toAjax(dmsDeviceModeService.insertByBo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改设备模型
|
||||
*/
|
||||
@SaCheckPermission("dms:deviceMode:edit")
|
||||
@Log(title = "设备模型", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit()
|
||||
@PutMapping()
|
||||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody DmsDeviceModeBo bo) {
|
||||
return toAjax(dmsDeviceModeService.updateByBo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除设备模型
|
||||
*
|
||||
* @param deviceModeIds 主键串
|
||||
*/
|
||||
@SaCheckPermission("dms:deviceMode:remove")
|
||||
@Log(title = "设备模型", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{deviceModeIds}")
|
||||
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
||||
@PathVariable Long[] deviceModeIds) {
|
||||
return toAjax(dmsDeviceModeService.deleteWithValidByIds(List.of(deviceModeIds), true));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 下拉框查询设备模型列表
|
||||
*/
|
||||
|
||||
@GetMapping("/getDmsDeviceModeList")
|
||||
public R<List<DmsDeviceModeVo>> getDmsDeviceModeList(DmsDeviceModeBo bo) {
|
||||
List<DmsDeviceModeVo> list = dmsDeviceModeService.queryList(bo);
|
||||
return R.ok(list);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,116 @@
|
||||
package org.dromara.dms.controller;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.constraints.*;
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.dromara.common.idempotent.annotation.RepeatSubmit;
|
||||
import org.dromara.common.log.annotation.Log;
|
||||
import org.dromara.common.web.core.BaseController;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.core.domain.R;
|
||||
import org.dromara.common.core.validate.AddGroup;
|
||||
import org.dromara.common.core.validate.EditGroup;
|
||||
import org.dromara.common.log.enums.BusinessType;
|
||||
import org.dromara.common.excel.utils.ExcelUtil;
|
||||
import org.dromara.dms.domain.vo.DmsDeviceModeFunctionVo;
|
||||
import org.dromara.dms.domain.bo.DmsDeviceModeFunctionBo;
|
||||
import org.dromara.dms.service.IDmsDeviceModeFunctionService;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 设备模型功能
|
||||
* 前端访问路由地址为:/dms/deviceModeFunction
|
||||
*
|
||||
* @author Yinq
|
||||
* @date 2025-03-12
|
||||
*/
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/deviceModeFunction")
|
||||
public class DmsDeviceModeFunctionController extends BaseController {
|
||||
|
||||
private final IDmsDeviceModeFunctionService dmsDeviceModeFunctionService;
|
||||
|
||||
/**
|
||||
* 查询设备模型功能列表
|
||||
*/
|
||||
@SaCheckPermission("dms:deviceModeFunction:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<DmsDeviceModeFunctionVo> list(DmsDeviceModeFunctionBo bo, PageQuery pageQuery) {
|
||||
return dmsDeviceModeFunctionService.queryPageList(bo, pageQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出设备模型功能列表
|
||||
*/
|
||||
@SaCheckPermission("dms:deviceModeFunction:export")
|
||||
@Log(title = "设备模型功能", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(DmsDeviceModeFunctionBo bo, HttpServletResponse response) {
|
||||
List<DmsDeviceModeFunctionVo> list = dmsDeviceModeFunctionService.queryList(bo);
|
||||
ExcelUtil.exportExcel(list, "设备模型功能", DmsDeviceModeFunctionVo.class, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取设备模型功能详细信息
|
||||
*
|
||||
* @param modeFunctionId 主键
|
||||
*/
|
||||
@SaCheckPermission("dms:deviceModeFunction:query")
|
||||
@GetMapping("/{modeFunctionId}")
|
||||
public R<DmsDeviceModeFunctionVo> getInfo(@NotNull(message = "主键不能为空")
|
||||
@PathVariable Long modeFunctionId) {
|
||||
return R.ok(dmsDeviceModeFunctionService.queryById(modeFunctionId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增设备模型功能
|
||||
*/
|
||||
@SaCheckPermission("dms:deviceModeFunction:add")
|
||||
@Log(title = "设备模型功能", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit()
|
||||
@PostMapping()
|
||||
public R<Void> add(@Validated(AddGroup.class) @RequestBody DmsDeviceModeFunctionBo bo) {
|
||||
return toAjax(dmsDeviceModeFunctionService.insertByBo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改设备模型功能
|
||||
*/
|
||||
@SaCheckPermission("dms:deviceModeFunction:edit")
|
||||
@Log(title = "设备模型功能", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit()
|
||||
@PutMapping()
|
||||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody DmsDeviceModeFunctionBo bo) {
|
||||
return toAjax(dmsDeviceModeFunctionService.updateByBo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除设备模型功能
|
||||
*
|
||||
* @param modeFunctionIds 主键串
|
||||
*/
|
||||
@SaCheckPermission("dms:deviceModeFunction:remove")
|
||||
@Log(title = "设备模型功能", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{modeFunctionIds}")
|
||||
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
||||
@PathVariable Long[] modeFunctionIds) {
|
||||
return toAjax(dmsDeviceModeFunctionService.deleteWithValidByIds(List.of(modeFunctionIds), true));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 下拉框查询设备模型功能列表
|
||||
*/
|
||||
@GetMapping("/getDmsDeviceModeFunctionList")
|
||||
public R<List<DmsDeviceModeFunctionVo>> getDmsDeviceModeFunctionList(DmsDeviceModeFunctionBo bo) {
|
||||
List<DmsDeviceModeFunctionVo> list = dmsDeviceModeFunctionService.queryList(bo);
|
||||
return R.ok(list);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,116 @@
|
||||
package org.dromara.dms.controller;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.constraints.*;
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.dromara.common.idempotent.annotation.RepeatSubmit;
|
||||
import org.dromara.common.log.annotation.Log;
|
||||
import org.dromara.common.web.core.BaseController;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.core.domain.R;
|
||||
import org.dromara.common.core.validate.AddGroup;
|
||||
import org.dromara.common.core.validate.EditGroup;
|
||||
import org.dromara.common.log.enums.BusinessType;
|
||||
import org.dromara.common.excel.utils.ExcelUtil;
|
||||
import org.dromara.dms.domain.vo.DmsDeviceModeParameterVo;
|
||||
import org.dromara.dms.domain.bo.DmsDeviceModeParameterBo;
|
||||
import org.dromara.dms.service.IDmsDeviceModeParameterService;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 设备参数
|
||||
* 前端访问路由地址为:/dms/deviceModeParameter
|
||||
*
|
||||
* @author Yinq
|
||||
* @date 2025-03-12
|
||||
*/
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/deviceModeParameter")
|
||||
public class DmsDeviceModeParameterController extends BaseController {
|
||||
|
||||
private final IDmsDeviceModeParameterService dmsDeviceModeParameterService;
|
||||
|
||||
/**
|
||||
* 查询设备参数列表
|
||||
*/
|
||||
@SaCheckPermission("dms:deviceModeParameter:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<DmsDeviceModeParameterVo> list(DmsDeviceModeParameterBo bo, PageQuery pageQuery) {
|
||||
return dmsDeviceModeParameterService.queryPageList(bo, pageQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出设备参数列表
|
||||
*/
|
||||
@SaCheckPermission("dms:deviceModeParameter:export")
|
||||
@Log(title = "设备参数", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(DmsDeviceModeParameterBo bo, HttpServletResponse response) {
|
||||
List<DmsDeviceModeParameterVo> list = dmsDeviceModeParameterService.queryList(bo);
|
||||
ExcelUtil.exportExcel(list, "设备参数", DmsDeviceModeParameterVo.class, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取设备参数详细信息
|
||||
*
|
||||
* @param modeParameterId 主键
|
||||
*/
|
||||
@SaCheckPermission("dms:deviceModeParameter:query")
|
||||
@GetMapping("/{modeParameterId}")
|
||||
public R<DmsDeviceModeParameterVo> getInfo(@NotNull(message = "主键不能为空")
|
||||
@PathVariable Long modeParameterId) {
|
||||
return R.ok(dmsDeviceModeParameterService.queryById(modeParameterId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增设备参数
|
||||
*/
|
||||
@SaCheckPermission("dms:deviceModeParameter:add")
|
||||
@Log(title = "设备参数", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit()
|
||||
@PostMapping()
|
||||
public R<Void> add(@Validated(AddGroup.class) @RequestBody DmsDeviceModeParameterBo bo) {
|
||||
return toAjax(dmsDeviceModeParameterService.insertByBo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改设备参数
|
||||
*/
|
||||
@SaCheckPermission("dms:deviceModeParameter:edit")
|
||||
@Log(title = "设备参数", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit()
|
||||
@PutMapping()
|
||||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody DmsDeviceModeParameterBo bo) {
|
||||
return toAjax(dmsDeviceModeParameterService.updateByBo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除设备参数
|
||||
*
|
||||
* @param modeParameterIds 主键串
|
||||
*/
|
||||
@SaCheckPermission("dms:deviceModeParameter:remove")
|
||||
@Log(title = "设备参数", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{modeParameterIds}")
|
||||
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
||||
@PathVariable Long[] modeParameterIds) {
|
||||
return toAjax(dmsDeviceModeParameterService.deleteWithValidByIds(List.of(modeParameterIds), true));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 下拉框查询设备参数列表
|
||||
*/
|
||||
@GetMapping("/getDmsDeviceModeParameterList")
|
||||
public R<List<DmsDeviceModeParameterVo>> getDmsDeviceModeParameterList(DmsDeviceModeParameterBo bo) {
|
||||
List<DmsDeviceModeParameterVo> list = dmsDeviceModeParameterService.queryList(bo);
|
||||
return R.ok(list);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,15 @@
|
||||
package org.dromara.dms.mapper;
|
||||
|
||||
import org.dromara.dms.domain.DmsDeviceModeFunction;
|
||||
import org.dromara.dms.domain.vo.DmsDeviceModeFunctionVo;
|
||||
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
|
||||
|
||||
/**
|
||||
* 设备模型功能Mapper接口
|
||||
*
|
||||
* @author Yinq
|
||||
* @date 2025-03-12
|
||||
*/
|
||||
public interface DmsDeviceModeFunctionMapper extends BaseMapperPlus<DmsDeviceModeFunction, DmsDeviceModeFunctionVo> {
|
||||
|
||||
}
|
||||
@ -0,0 +1,15 @@
|
||||
package org.dromara.dms.mapper;
|
||||
|
||||
import org.dromara.dms.domain.DmsDeviceMode;
|
||||
import org.dromara.dms.domain.vo.DmsDeviceModeVo;
|
||||
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
|
||||
|
||||
/**
|
||||
* 设备模型Mapper接口
|
||||
*
|
||||
* @author Yinq
|
||||
* @date 2025-03-11
|
||||
*/
|
||||
public interface DmsDeviceModeMapper extends BaseMapperPlus<DmsDeviceMode, DmsDeviceModeVo> {
|
||||
|
||||
}
|
||||
@ -0,0 +1,15 @@
|
||||
package org.dromara.dms.mapper;
|
||||
|
||||
import org.dromara.dms.domain.DmsDeviceModeParameter;
|
||||
import org.dromara.dms.domain.vo.DmsDeviceModeParameterVo;
|
||||
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
|
||||
|
||||
/**
|
||||
* 设备参数Mapper接口
|
||||
*
|
||||
* @author Yinq
|
||||
* @date 2025-03-12
|
||||
*/
|
||||
public interface DmsDeviceModeParameterMapper extends BaseMapperPlus<DmsDeviceModeParameter, DmsDeviceModeParameterVo> {
|
||||
|
||||
}
|
||||
@ -0,0 +1,69 @@
|
||||
package org.dromara.dms.service;
|
||||
|
||||
import org.dromara.dms.domain.DmsDeviceModeFunction;
|
||||
import org.dromara.dms.domain.vo.DmsDeviceModeFunctionVo;
|
||||
import org.dromara.dms.domain.bo.DmsDeviceModeFunctionBo;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 设备模型功能Service接口
|
||||
*
|
||||
* @author Yinq
|
||||
* @date 2025-03-12
|
||||
*/
|
||||
public interface IDmsDeviceModeFunctionService {
|
||||
|
||||
/**
|
||||
* 查询设备模型功能
|
||||
*
|
||||
* @param modeFunctionId 主键
|
||||
* @return 设备模型功能
|
||||
*/
|
||||
DmsDeviceModeFunctionVo queryById(Long modeFunctionId);
|
||||
|
||||
/**
|
||||
* 分页查询设备模型功能列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @param pageQuery 分页参数
|
||||
* @return 设备模型功能分页列表
|
||||
*/
|
||||
TableDataInfo<DmsDeviceModeFunctionVo> queryPageList(DmsDeviceModeFunctionBo bo, PageQuery pageQuery);
|
||||
|
||||
/**
|
||||
* 查询符合条件的设备模型功能列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @return 设备模型功能列表
|
||||
*/
|
||||
List<DmsDeviceModeFunctionVo> queryList(DmsDeviceModeFunctionBo bo);
|
||||
|
||||
/**
|
||||
* 新增设备模型功能
|
||||
*
|
||||
* @param bo 设备模型功能
|
||||
* @return 是否新增成功
|
||||
*/
|
||||
Boolean insertByBo(DmsDeviceModeFunctionBo bo);
|
||||
|
||||
/**
|
||||
* 修改设备模型功能
|
||||
*
|
||||
* @param bo 设备模型功能
|
||||
* @return 是否修改成功
|
||||
*/
|
||||
Boolean updateByBo(DmsDeviceModeFunctionBo bo);
|
||||
|
||||
/**
|
||||
* 校验并批量删除设备模型功能信息
|
||||
*
|
||||
* @param ids 待删除的主键集合
|
||||
* @param isValid 是否进行有效性校验
|
||||
* @return 是否删除成功
|
||||
*/
|
||||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||
}
|
||||
@ -0,0 +1,69 @@
|
||||
package org.dromara.dms.service;
|
||||
|
||||
import org.dromara.dms.domain.DmsDeviceModeParameter;
|
||||
import org.dromara.dms.domain.vo.DmsDeviceModeParameterVo;
|
||||
import org.dromara.dms.domain.bo.DmsDeviceModeParameterBo;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 设备参数Service接口
|
||||
*
|
||||
* @author Yinq
|
||||
* @date 2025-03-12
|
||||
*/
|
||||
public interface IDmsDeviceModeParameterService {
|
||||
|
||||
/**
|
||||
* 查询设备参数
|
||||
*
|
||||
* @param modeParameterId 主键
|
||||
* @return 设备参数
|
||||
*/
|
||||
DmsDeviceModeParameterVo queryById(Long modeParameterId);
|
||||
|
||||
/**
|
||||
* 分页查询设备参数列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @param pageQuery 分页参数
|
||||
* @return 设备参数分页列表
|
||||
*/
|
||||
TableDataInfo<DmsDeviceModeParameterVo> queryPageList(DmsDeviceModeParameterBo bo, PageQuery pageQuery);
|
||||
|
||||
/**
|
||||
* 查询符合条件的设备参数列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @return 设备参数列表
|
||||
*/
|
||||
List<DmsDeviceModeParameterVo> queryList(DmsDeviceModeParameterBo bo);
|
||||
|
||||
/**
|
||||
* 新增设备参数
|
||||
*
|
||||
* @param bo 设备参数
|
||||
* @return 是否新增成功
|
||||
*/
|
||||
Boolean insertByBo(DmsDeviceModeParameterBo bo);
|
||||
|
||||
/**
|
||||
* 修改设备参数
|
||||
*
|
||||
* @param bo 设备参数
|
||||
* @return 是否修改成功
|
||||
*/
|
||||
Boolean updateByBo(DmsDeviceModeParameterBo bo);
|
||||
|
||||
/**
|
||||
* 校验并批量删除设备参数信息
|
||||
*
|
||||
* @param ids 待删除的主键集合
|
||||
* @param isValid 是否进行有效性校验
|
||||
* @return 是否删除成功
|
||||
*/
|
||||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||
}
|
||||
@ -0,0 +1,69 @@
|
||||
package org.dromara.dms.service;
|
||||
|
||||
import org.dromara.dms.domain.DmsDeviceMode;
|
||||
import org.dromara.dms.domain.vo.DmsDeviceModeVo;
|
||||
import org.dromara.dms.domain.bo.DmsDeviceModeBo;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 设备模型Service接口
|
||||
*
|
||||
* @author Yinq
|
||||
* @date 2025-03-11
|
||||
*/
|
||||
public interface IDmsDeviceModeService {
|
||||
|
||||
/**
|
||||
* 查询设备模型
|
||||
*
|
||||
* @param deviceModeId 主键
|
||||
* @return 设备模型
|
||||
*/
|
||||
DmsDeviceModeVo queryById(Long deviceModeId);
|
||||
|
||||
/**
|
||||
* 分页查询设备模型列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @param pageQuery 分页参数
|
||||
* @return 设备模型分页列表
|
||||
*/
|
||||
TableDataInfo<DmsDeviceModeVo> queryPageList(DmsDeviceModeBo bo, PageQuery pageQuery);
|
||||
|
||||
/**
|
||||
* 查询符合条件的设备模型列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @return 设备模型列表
|
||||
*/
|
||||
List<DmsDeviceModeVo> queryList(DmsDeviceModeBo bo);
|
||||
|
||||
/**
|
||||
* 新增设备模型
|
||||
*
|
||||
* @param bo 设备模型
|
||||
* @return 是否新增成功
|
||||
*/
|
||||
Boolean insertByBo(DmsDeviceModeBo bo);
|
||||
|
||||
/**
|
||||
* 修改设备模型
|
||||
*
|
||||
* @param bo 设备模型
|
||||
* @return 是否修改成功
|
||||
*/
|
||||
Boolean updateByBo(DmsDeviceModeBo bo);
|
||||
|
||||
/**
|
||||
* 校验并批量删除设备模型信息
|
||||
*
|
||||
* @param ids 待删除的主键集合
|
||||
* @param isValid 是否进行有效性校验
|
||||
* @return 是否删除成功
|
||||
*/
|
||||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||
}
|
||||
@ -0,0 +1,151 @@
|
||||
package org.dromara.dms.service.impl;
|
||||
|
||||
import org.dromara.common.core.utils.MapstructUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.github.yulichang.toolkit.JoinWrappers;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.dromara.dms.domain.bo.DmsDeviceModeFunctionBo;
|
||||
import org.dromara.dms.domain.vo.DmsDeviceModeFunctionVo;
|
||||
import org.dromara.dms.domain.DmsDeviceModeFunction;
|
||||
import org.dromara.dms.mapper.DmsDeviceModeFunctionMapper;
|
||||
import org.dromara.dms.service.IDmsDeviceModeFunctionService;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* 设备模型功能Service业务层处理
|
||||
*
|
||||
* @author Yinq
|
||||
* @date 2025-03-12
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class DmsDeviceModeFunctionServiceImpl implements IDmsDeviceModeFunctionService {
|
||||
|
||||
private final DmsDeviceModeFunctionMapper baseMapper;
|
||||
|
||||
/**
|
||||
* 查询设备模型功能
|
||||
*
|
||||
* @param modeFunctionId 主键
|
||||
* @return 设备模型功能
|
||||
*/
|
||||
@Override
|
||||
public DmsDeviceModeFunctionVo queryById(Long modeFunctionId) {
|
||||
return baseMapper.selectVoById(modeFunctionId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询设备模型功能列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @param pageQuery 分页参数
|
||||
* @return 设备模型功能分页列表
|
||||
*/
|
||||
@Override
|
||||
public TableDataInfo<DmsDeviceModeFunctionVo> queryPageList(DmsDeviceModeFunctionBo bo, PageQuery pageQuery) {
|
||||
MPJLambdaWrapper<DmsDeviceModeFunction> lqw = buildQueryWrapper(bo);
|
||||
Page<DmsDeviceModeFunctionVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
||||
return TableDataInfo.build(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询符合条件的设备模型功能列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @return 设备模型功能列表
|
||||
*/
|
||||
@Override
|
||||
public List<DmsDeviceModeFunctionVo> queryList(DmsDeviceModeFunctionBo bo) {
|
||||
MPJLambdaWrapper<DmsDeviceModeFunction> lqw = buildQueryWrapper(bo);
|
||||
return baseMapper.selectVoList(lqw);
|
||||
}
|
||||
|
||||
private MPJLambdaWrapper<DmsDeviceModeFunction> buildQueryWrapper(DmsDeviceModeFunctionBo bo) {
|
||||
Map<String, Object> params = bo.getParams();
|
||||
MPJLambdaWrapper<DmsDeviceModeFunction> lqw = JoinWrappers.lambda(DmsDeviceModeFunction.class)
|
||||
.selectAll(DmsDeviceModeFunction.class)
|
||||
.eq(bo.getModeFunctionId() != null, DmsDeviceModeFunction::getModeFunctionId, bo.getModeFunctionId())
|
||||
.eq(bo.getDeviceModeId() != null, DmsDeviceModeFunction::getDeviceModeId, bo.getDeviceModeId())
|
||||
.eq(StringUtils.isNotBlank(bo.getFunctionMode()), DmsDeviceModeFunction::getFunctionMode, bo.getFunctionMode())
|
||||
.eq(StringUtils.isNotBlank(bo.getCoordinate()), DmsDeviceModeFunction::getCoordinate, bo.getCoordinate())
|
||||
.like(StringUtils.isNotBlank(bo.getFunctionName()), DmsDeviceModeFunction::getFunctionName, bo.getFunctionName())
|
||||
.eq(StringUtils.isNotBlank(bo.getFunctionIdentifier()), DmsDeviceModeFunction::getFunctionIdentifier, bo.getFunctionIdentifier())
|
||||
.eq(StringUtils.isNotBlank(bo.getFunctionType()), DmsDeviceModeFunction::getFunctionType, bo.getFunctionType())
|
||||
.eq(bo.getDataType() != null, DmsDeviceModeFunction::getDataType, bo.getDataType())
|
||||
.eq(StringUtils.isNotBlank(bo.getDataDefinition()), DmsDeviceModeFunction::getDataDefinition, bo.getDataDefinition())
|
||||
.eq(StringUtils.isNotBlank(bo.getFunctionFormula()), DmsDeviceModeFunction::getFunctionFormula, bo.getFunctionFormula())
|
||||
.eq(StringUtils.isNotBlank(bo.getPropertyUnit()), DmsDeviceModeFunction::getPropertyUnit, bo.getPropertyUnit())
|
||||
.eq(StringUtils.isNotBlank(bo.getDisplayFlag()), DmsDeviceModeFunction::getDisplayFlag, bo.getDisplayFlag())
|
||||
.eq(StringUtils.isNotBlank(bo.getRwFlag()), DmsDeviceModeFunction::getRwFlag, bo.getRwFlag())
|
||||
.eq(StringUtils.isNotBlank(bo.getInvokeMethod()), DmsDeviceModeFunction::getInvokeMethod, bo.getInvokeMethod())
|
||||
.eq(StringUtils.isNotBlank(bo.getEventType()), DmsDeviceModeFunction::getEventType, bo.getEventType())
|
||||
.eq(StringUtils.isNotBlank(bo.getAcquisitionFormula()), DmsDeviceModeFunction::getAcquisitionFormula, bo.getAcquisitionFormula())
|
||||
.eq(bo.getOrderFlag() != null, DmsDeviceModeFunction::getOrderFlag, bo.getOrderFlag())
|
||||
.eq(StringUtils.isNotBlank(bo.getDeviceRegister()), DmsDeviceModeFunction::getDeviceRegister, bo.getDeviceRegister())
|
||||
.eq(bo.getPropertyStep() != null, DmsDeviceModeFunction::getPropertyStep, bo.getPropertyStep())
|
||||
.eq(StringUtils.isNotBlank(bo.getPropertyField()), DmsDeviceModeFunction::getPropertyField, bo.getPropertyField())
|
||||
.orderByAsc(DmsDeviceModeFunction::getModeFunctionId);
|
||||
return lqw;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增设备模型功能
|
||||
*
|
||||
* @param bo 设备模型功能
|
||||
* @return 是否新增成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean insertByBo(DmsDeviceModeFunctionBo bo) {
|
||||
DmsDeviceModeFunction add = MapstructUtils.convert(bo, DmsDeviceModeFunction.class);
|
||||
validEntityBeforeSave(add);
|
||||
boolean flag = baseMapper.insert(add) > 0;
|
||||
if (flag) {
|
||||
bo.setModeFunctionId(add.getModeFunctionId());
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改设备模型功能
|
||||
*
|
||||
* @param bo 设备模型功能
|
||||
* @return 是否修改成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean updateByBo(DmsDeviceModeFunctionBo bo) {
|
||||
DmsDeviceModeFunction update = MapstructUtils.convert(bo, DmsDeviceModeFunction.class);
|
||||
validEntityBeforeSave(update);
|
||||
return baseMapper.updateById(update) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存前的数据校验
|
||||
*/
|
||||
private void validEntityBeforeSave(DmsDeviceModeFunction entity) {
|
||||
//TODO 做一些数据校验,如唯一约束
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验并批量删除设备模型功能信息
|
||||
*
|
||||
* @param ids 待删除的主键集合
|
||||
* @param isValid 是否进行有效性校验
|
||||
* @return 是否删除成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||
if (isValid) {
|
||||
//TODO 做一些业务上的校验,判断是否需要校验
|
||||
}
|
||||
return baseMapper.deleteByIds(ids) > 0;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,141 @@
|
||||
package org.dromara.dms.service.impl;
|
||||
|
||||
import org.dromara.common.core.utils.MapstructUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.github.yulichang.toolkit.JoinWrappers;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.dromara.dms.domain.bo.DmsDeviceModeParameterBo;
|
||||
import org.dromara.dms.domain.vo.DmsDeviceModeParameterVo;
|
||||
import org.dromara.dms.domain.DmsDeviceModeParameter;
|
||||
import org.dromara.dms.mapper.DmsDeviceModeParameterMapper;
|
||||
import org.dromara.dms.service.IDmsDeviceModeParameterService;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* 设备参数Service业务层处理
|
||||
*
|
||||
* @author Yinq
|
||||
* @date 2025-03-12
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class DmsDeviceModeParameterServiceImpl implements IDmsDeviceModeParameterService {
|
||||
|
||||
private final DmsDeviceModeParameterMapper baseMapper;
|
||||
|
||||
/**
|
||||
* 查询设备参数
|
||||
*
|
||||
* @param modeParameterId 主键
|
||||
* @return 设备参数
|
||||
*/
|
||||
@Override
|
||||
public DmsDeviceModeParameterVo queryById(Long modeParameterId) {
|
||||
return baseMapper.selectVoById(modeParameterId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询设备参数列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @param pageQuery 分页参数
|
||||
* @return 设备参数分页列表
|
||||
*/
|
||||
@Override
|
||||
public TableDataInfo<DmsDeviceModeParameterVo> queryPageList(DmsDeviceModeParameterBo bo, PageQuery pageQuery) {
|
||||
MPJLambdaWrapper<DmsDeviceModeParameter> lqw = buildQueryWrapper(bo);
|
||||
Page<DmsDeviceModeParameterVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
||||
return TableDataInfo.build(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询符合条件的设备参数列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @return 设备参数列表
|
||||
*/
|
||||
@Override
|
||||
public List<DmsDeviceModeParameterVo> queryList(DmsDeviceModeParameterBo bo) {
|
||||
MPJLambdaWrapper<DmsDeviceModeParameter> lqw = buildQueryWrapper(bo);
|
||||
return baseMapper.selectVoList(lqw);
|
||||
}
|
||||
|
||||
private MPJLambdaWrapper<DmsDeviceModeParameter> buildQueryWrapper(DmsDeviceModeParameterBo bo) {
|
||||
Map<String, Object> params = bo.getParams();
|
||||
MPJLambdaWrapper<DmsDeviceModeParameter> lqw = JoinWrappers.lambda(DmsDeviceModeParameter.class)
|
||||
.selectAll(DmsDeviceModeParameter.class)
|
||||
.eq(bo.getModeParameterId() != null, DmsDeviceModeParameter::getModeParameterId, bo.getModeParameterId())
|
||||
.eq(bo.getModeFunctionId() != null, DmsDeviceModeParameter::getModeFunctionId, bo.getModeFunctionId())
|
||||
.eq(bo.getReleatedParameterId() != null, DmsDeviceModeParameter::getReleatedParameterId, bo.getReleatedParameterId())
|
||||
.eq(StringUtils.isNotBlank(bo.getParameterType()), DmsDeviceModeParameter::getParameterType, bo.getParameterType())
|
||||
.like(StringUtils.isNotBlank(bo.getParameterName()), DmsDeviceModeParameter::getParameterName, bo.getParameterName())
|
||||
.eq(StringUtils.isNotBlank(bo.getParameterIdentifier()), DmsDeviceModeParameter::getParameterIdentifier, bo.getParameterIdentifier())
|
||||
.eq(bo.getDataType() != null, DmsDeviceModeParameter::getDataType, bo.getDataType())
|
||||
.eq(StringUtils.isNotBlank(bo.getDataDefinition()), DmsDeviceModeParameter::getDataDefinition, bo.getDataDefinition())
|
||||
.eq(StringUtils.isNotBlank(bo.getPropertyUnit()), DmsDeviceModeParameter::getPropertyUnit, bo.getPropertyUnit())
|
||||
.eq(bo.getPropertyStep() != null, DmsDeviceModeParameter::getPropertyStep, bo.getPropertyStep())
|
||||
.orderByDesc(DmsDeviceModeParameter::getModeParameterId);
|
||||
return lqw;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增设备参数
|
||||
*
|
||||
* @param bo 设备参数
|
||||
* @return 是否新增成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean insertByBo(DmsDeviceModeParameterBo bo) {
|
||||
DmsDeviceModeParameter add = MapstructUtils.convert(bo, DmsDeviceModeParameter.class);
|
||||
validEntityBeforeSave(add);
|
||||
boolean flag = baseMapper.insert(add) > 0;
|
||||
if (flag) {
|
||||
bo.setModeParameterId(add.getModeParameterId());
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改设备参数
|
||||
*
|
||||
* @param bo 设备参数
|
||||
* @return 是否修改成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean updateByBo(DmsDeviceModeParameterBo bo) {
|
||||
DmsDeviceModeParameter update = MapstructUtils.convert(bo, DmsDeviceModeParameter.class);
|
||||
validEntityBeforeSave(update);
|
||||
return baseMapper.updateById(update) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存前的数据校验
|
||||
*/
|
||||
private void validEntityBeforeSave(DmsDeviceModeParameter entity) {
|
||||
//TODO 做一些数据校验,如唯一约束
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验并批量删除设备参数信息
|
||||
*
|
||||
* @param ids 待删除的主键集合
|
||||
* @param isValid 是否进行有效性校验
|
||||
* @return 是否删除成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||
if (isValid) {
|
||||
//TODO 做一些业务上的校验,判断是否需要校验
|
||||
}
|
||||
return baseMapper.deleteByIds(ids) > 0;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,135 @@
|
||||
package org.dromara.dms.service.impl;
|
||||
|
||||
import org.dromara.common.core.utils.MapstructUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.github.yulichang.toolkit.JoinWrappers;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.dromara.dms.domain.bo.DmsDeviceModeBo;
|
||||
import org.dromara.dms.domain.vo.DmsDeviceModeVo;
|
||||
import org.dromara.dms.domain.DmsDeviceMode;
|
||||
import org.dromara.dms.mapper.DmsDeviceModeMapper;
|
||||
import org.dromara.dms.service.IDmsDeviceModeService;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* 设备模型Service业务层处理
|
||||
*
|
||||
* @author Yinq
|
||||
* @date 2025-03-11
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class DmsDeviceModeServiceImpl implements IDmsDeviceModeService {
|
||||
|
||||
private final DmsDeviceModeMapper baseMapper;
|
||||
|
||||
/**
|
||||
* 查询设备模型
|
||||
*
|
||||
* @param deviceModeId 主键
|
||||
* @return 设备模型
|
||||
*/
|
||||
@Override
|
||||
public DmsDeviceModeVo queryById(Long deviceModeId){
|
||||
return baseMapper.selectVoById(deviceModeId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询设备模型列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @param pageQuery 分页参数
|
||||
* @return 设备模型分页列表
|
||||
*/
|
||||
@Override
|
||||
public TableDataInfo<DmsDeviceModeVo> queryPageList(DmsDeviceModeBo bo, PageQuery pageQuery) {
|
||||
MPJLambdaWrapper<DmsDeviceMode> lqw = buildQueryWrapper(bo);
|
||||
Page<DmsDeviceModeVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
||||
return TableDataInfo.build(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询符合条件的设备模型列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @return 设备模型列表
|
||||
*/
|
||||
@Override
|
||||
public List<DmsDeviceModeVo> queryList(DmsDeviceModeBo bo) {
|
||||
MPJLambdaWrapper<DmsDeviceMode> lqw = buildQueryWrapper(bo);
|
||||
return baseMapper.selectVoList(lqw);
|
||||
}
|
||||
|
||||
private MPJLambdaWrapper<DmsDeviceMode> buildQueryWrapper(DmsDeviceModeBo bo) {
|
||||
Map<String, Object> params = bo.getParams();
|
||||
MPJLambdaWrapper<DmsDeviceMode> lqw = JoinWrappers.lambda(DmsDeviceMode.class)
|
||||
.selectAll(DmsDeviceMode.class)
|
||||
.eq(bo.getDeviceModeId() != null, DmsDeviceMode::getDeviceModeId, bo.getDeviceModeId())
|
||||
.like(StringUtils.isNotBlank(bo.getDeviceModeName()), DmsDeviceMode::getDeviceModeName, bo.getDeviceModeName())
|
||||
.eq(StringUtils.isNotBlank(bo.getDeviceModeStatus()), DmsDeviceMode::getDeviceModeStatus, bo.getDeviceModeStatus())
|
||||
.eq(StringUtils.isNotBlank(bo.getDeviceModePic()), DmsDeviceMode::getDeviceModePic, bo.getDeviceModePic())
|
||||
.orderByAsc(DmsDeviceMode::getCreateTime);
|
||||
return lqw;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增设备模型
|
||||
*
|
||||
* @param bo 设备模型
|
||||
* @return 是否新增成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean insertByBo(DmsDeviceModeBo bo) {
|
||||
DmsDeviceMode add = MapstructUtils.convert(bo, DmsDeviceMode.class);
|
||||
validEntityBeforeSave(add);
|
||||
boolean flag = baseMapper.insert(add) > 0;
|
||||
if (flag) {
|
||||
bo.setDeviceModeId(add.getDeviceModeId());
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改设备模型
|
||||
*
|
||||
* @param bo 设备模型
|
||||
* @return 是否修改成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean updateByBo(DmsDeviceModeBo bo) {
|
||||
DmsDeviceMode update = MapstructUtils.convert(bo, DmsDeviceMode.class);
|
||||
validEntityBeforeSave(update);
|
||||
return baseMapper.updateById(update) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存前的数据校验
|
||||
*/
|
||||
private void validEntityBeforeSave(DmsDeviceMode entity){
|
||||
//TODO 做一些数据校验,如唯一约束
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验并批量删除设备模型信息
|
||||
*
|
||||
* @param ids 待删除的主键集合
|
||||
* @param isValid 是否进行有效性校验
|
||||
* @return 是否删除成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||
if(isValid){
|
||||
//TODO 做一些业务上的校验,判断是否需要校验
|
||||
}
|
||||
return baseMapper.deleteByIds(ids) > 0;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,34 @@
|
||||
# Tomcat
|
||||
server:
|
||||
port: 6017
|
||||
|
||||
# Spring
|
||||
spring:
|
||||
application:
|
||||
# 应用名称
|
||||
name: hwmom-dms
|
||||
profiles:
|
||||
# 环境配置
|
||||
active: @profiles.active@
|
||||
|
||||
--- # nacos 配置
|
||||
spring:
|
||||
cloud:
|
||||
nacos:
|
||||
# nacos 服务地址
|
||||
server-addr: @nacos.server@
|
||||
username: @nacos.username@
|
||||
password: @nacos.password@
|
||||
discovery:
|
||||
# 注册组
|
||||
group: @nacos.discovery.group@
|
||||
namespace: ${spring.profiles.active}
|
||||
config:
|
||||
# 配置组
|
||||
group: @nacos.config.group@
|
||||
namespace: ${spring.profiles.active}
|
||||
config:
|
||||
import:
|
||||
- optional:nacos:application-common.yml
|
||||
- optional:nacos:datasource.yml
|
||||
- optional:nacos:${spring.application.name}.yml
|
||||
@ -0,0 +1,8 @@
|
||||
Spring Boot Version: ${spring-boot.version}
|
||||
Spring Application Name: ${spring.application.name}
|
||||
_ _
|
||||
| |____ ___ __ ___ ___ _ __ ___ __| |_ __ ___ ___
|
||||
| '_ \ \ /\ / / '_ ` _ \ / _ \| '_ ` _ \ _____ / _` | '_ ` _ \/ __|
|
||||
| | | \ V V /| | | | | | (_) | | | | | |_____| (_| | | | | | \__ \
|
||||
|_| |_|\_/\_/ |_| |_| |_|\___/|_| |_| |_| \__,_|_| |_| |_|___/
|
||||
|
||||
@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration scan="true" scanPeriod="60 seconds" debug="false">
|
||||
<!-- 日志存放路径 -->
|
||||
<property name="log.path" value="logs/${project.artifactId}" />
|
||||
<!-- 日志输出格式 -->
|
||||
<property name="console.log.pattern"
|
||||
value="%red(%d{yyyy-MM-dd HH:mm:ss}) %green([%thread]) %highlight(%-5level) %boldMagenta(%logger{36}%n) - %msg%n"/>
|
||||
|
||||
<!-- 控制台输出 -->
|
||||
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>${console.log.pattern}</pattern>
|
||||
<charset>utf-8</charset>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<include resource="logback-common.xml" />
|
||||
|
||||
<include resource="logback-logstash.xml" />
|
||||
|
||||
<!-- 开启 skywalking 日志收集 -->
|
||||
<include resource="logback-skylog.xml" />
|
||||
|
||||
<!--系统操作日志-->
|
||||
<root level="info">
|
||||
<appender-ref ref="console" />
|
||||
</root>
|
||||
</configuration>
|
||||
@ -0,0 +1,7 @@
|
||||
<?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="org.dromara.dms.mapper.DmsDeviceModeFunctionMapper">
|
||||
|
||||
</mapper>
|
||||
@ -0,0 +1,7 @@
|
||||
<?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="org.dromara.dms.mapper.DmsDeviceModeMapper">
|
||||
|
||||
</mapper>
|
||||
@ -0,0 +1,7 @@
|
||||
<?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="org.dromara.dms.mapper.DmsDeviceModeParameterMapper">
|
||||
|
||||
</mapper>
|
||||
@ -0,0 +1,3 @@
|
||||
java包使用 `.` 分割 resource 目录使用 `/` 分割
|
||||
<br>
|
||||
此文件目的 防止文件夹粘连找不到 `xml` 文件
|
||||
@ -0,0 +1,93 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.dromara</groupId>
|
||||
<artifactId>ruoyi-modules</artifactId>
|
||||
<version>${revision}</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>hwmom-dp</artifactId>
|
||||
|
||||
<description>
|
||||
hwmom-dp data process数据处理模块
|
||||
</description>
|
||||
|
||||
<dependencies>
|
||||
<!-- Kafka -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.kafka</groupId>
|
||||
<artifactId>spring-kafka</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.dromara</groupId>
|
||||
<artifactId>ruoyi-common-nacos</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>org.dromara</groupId>
|
||||
<artifactId>ruoyi-common-security</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>org.dromara</groupId>
|
||||
<artifactId>ruoyi-api-resource</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba.fastjson2</groupId>
|
||||
<artifactId>fastjson2</artifactId>
|
||||
<version>2.0.51</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>com.mysql</groupId>-->
|
||||
<!-- <artifactId>mysql-connector-j</artifactId>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>com.microsoft.sqlserver</groupId>-->
|
||||
<!-- <artifactId>mssql-jdbc</artifactId>-->
|
||||
<!-- </dependency>-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>com.github.jsqlparser</groupId>-->
|
||||
<!-- <artifactId>jsqlparser</artifactId>-->
|
||||
<!-- <version>1.4</version>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<finalName>${project.artifactId}</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.1</version> <!-- 确保使用兼容的插件版本 -->
|
||||
<configuration>
|
||||
<source>17</source>
|
||||
<target>17</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<version>${spring-boot.version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
||||
</project>
|
||||
@ -0,0 +1,20 @@
|
||||
package org.dromara.dp;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||
import org.springframework.boot.context.metrics.buffering.BufferingApplicationStartup;
|
||||
|
||||
@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)
|
||||
public class HwDataProcessApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication application = new SpringApplication(HwDataProcessApplication.class);
|
||||
application.setApplicationStartup(new BufferingApplicationStartup(2048));
|
||||
application.run(args);
|
||||
System.out.println("(♥◠‿◠)ノ゙ data process数据处理模块启动成功 ლ(´ڡ`ლ)゙ ");
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,13 @@
|
||||
package org.dromara.dp.kafka.service;
|
||||
|
||||
import org.springframework.kafka.annotation.KafkaListener;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class KafkaConsumerService {
|
||||
|
||||
@KafkaListener(topics = "test", groupId = "my-consumer-group")
|
||||
public void listen(String message) {
|
||||
System.out.println("Received message: " + message);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,178 @@
|
||||
//package org.dromara.service;
|
||||
//
|
||||
//import com.alibaba.fastjson.JSON;
|
||||
//import com.alibaba.fastjson.JSONObject;
|
||||
//import com.ruoyi.common.core.constant.HwDictConstants;
|
||||
//import com.ruoyi.common.core.constant.SecurityConstants;
|
||||
//import com.ruoyi.common.core.constant.TdEngineConstants;
|
||||
//import com.ruoyi.common.core.domain.R;
|
||||
//import com.ruoyi.common.core.utils.StringUtils;
|
||||
//import com.ruoyi.dataprocess.domain.*;
|
||||
//import com.ruoyi.dataprocess.mapper.HwAlarmInfoMapper;
|
||||
//import com.ruoyi.dataprocess.mapper.HwDeviceMapper;
|
||||
//import com.ruoyi.dataprocess.mapper.HwOfflineRuleMapper;
|
||||
//import com.ruoyi.dataprocess.service.CommanHandleService;
|
||||
//import com.ruoyi.dataprocess.service.IDeviceStatusService;
|
||||
//import com.ruoyi.tdengine.api.RemoteTdEngineService;
|
||||
//import com.ruoyi.tdengine.api.domain.DeviceStatus;
|
||||
//import com.ruoyi.tdengine.api.domain.TdField;
|
||||
//import com.ruoyi.tdengine.api.domain.TdTableVo;
|
||||
//import org.springframework.beans.factory.annotation.Autowired;
|
||||
//import org.springframework.stereotype.Service;
|
||||
//
|
||||
//import javax.annotation.Resource;
|
||||
//import java.util.ArrayList;
|
||||
//import java.util.Date;
|
||||
//import java.util.List;
|
||||
//import java.util.Map;
|
||||
//
|
||||
///**
|
||||
// * @Description: 设备状态处理服务
|
||||
// * @ClassName: DeviceStatusServiceImpl
|
||||
// * @Author : xins
|
||||
// * @Date :2023-09-12 15:31
|
||||
// * @Version :1.0
|
||||
// */
|
||||
//@Service
|
||||
//public class DeviceStatusServiceImpl extends CommanHandleService implements IDeviceStatusService {
|
||||
//
|
||||
// @Autowired
|
||||
// private HwDeviceMapper hwDeviceMapper;
|
||||
// @Autowired
|
||||
// private HwOfflineRuleMapper hwOfflineRuleMapper;
|
||||
// @Autowired
|
||||
// private HwAlarmInfoMapper hwAlarmInfoMapper;
|
||||
// @Resource
|
||||
// private RemoteTdEngineService remoteTdEngineService;
|
||||
//
|
||||
// @Override
|
||||
// public void handleDeviceStatus(String payloadString, String clientId) {
|
||||
//// ddd:{"msg":"设备设备连接状态信息","deviceType":"edge","connectStatus":1,
|
||||
//// "statusTime":1694506127199,"deviceCode":"hw-data-process-1"}
|
||||
// JSONObject json = JSON.parseObject(payloadString);
|
||||
// String deviceCode = json.getString("deviceCode").toLowerCase();
|
||||
// if (clientId.equals(deviceCode)) { //校验是不是自己,如果是自己则不记录状态,返回即可。
|
||||
// return;
|
||||
// }
|
||||
// HwDevice hwDevice = hwDeviceMapper.selectHwDeviceByDeviceCode(deviceCode);
|
||||
// if (hwDevice != null) {
|
||||
// Long deviceId = hwDevice.getDeviceId();
|
||||
// TdTableVo tdTableVo = new TdTableVo();
|
||||
// tdTableVo.setDatabaseName(TdEngineConstants.PLATFORM_DB_NAME);
|
||||
// tdTableVo.setTableName(TdEngineConstants.DEFAULT_DEVICE_STATUS_TABLE_NAME_PREFIX + deviceId);
|
||||
//
|
||||
// List<TdField> schemaFields = new ArrayList<>();
|
||||
// TdField onlineStatusField = new TdField();
|
||||
// onlineStatusField.setFieldName(TdEngineConstants.ST_TAG_ONLINESTATUS);
|
||||
// onlineStatusField.setFieldValue(json.getInteger("connectStatus"));
|
||||
// schemaFields.add(onlineStatusField);
|
||||
//
|
||||
// TdField deviceTypeField = new TdField();
|
||||
// deviceTypeField.setFieldName(TdEngineConstants.ST_TAG_DEVICETYPE);
|
||||
// deviceTypeField.setFieldValue(json.getString("deviceType"));
|
||||
// schemaFields.add(deviceTypeField);
|
||||
//
|
||||
// TdField tsField = new TdField();
|
||||
// tsField.setFieldName(TdEngineConstants.DEFAULT_FIRST_FIELD_NAME);
|
||||
// tsField.setFieldValue(json.getLong("statusTime"));
|
||||
// schemaFields.add(tsField);
|
||||
//
|
||||
// tdTableVo.setSchemaFields(schemaFields);
|
||||
//
|
||||
// this.remoteTdEngineService.insertTable(tdTableVo, SecurityConstants.INNER);
|
||||
//
|
||||
// //更新设备当前状态信息
|
||||
// String connectStatus = String.valueOf(json.getInteger("connectStatus"));
|
||||
// hwDevice.setOnlineStatus(connectStatus);
|
||||
// //判断如果是否是第一次连接,更新激活状态和激活时间。
|
||||
// if (hwDevice.getActiveStatus().equals(HwDictConstants.DEVICE_ACTIVE_STATUS_INACTIVE)) {
|
||||
// hwDevice.setActiveStatus(HwDictConstants.DEVICE_ACTIVE_STATUS_ACTIVE);
|
||||
// hwDevice.setActiveTime(new Date());
|
||||
// }
|
||||
//
|
||||
// hwDeviceMapper.updateHwDevice(hwDevice);
|
||||
//
|
||||
// if (connectStatus.equals(HwDictConstants.DEVICE_ONLINE_STATUS_OFFLINE)) {
|
||||
// this.checkOfflineAlarm(hwDevice);
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * @param: device
|
||||
// * @description 离线报警处理
|
||||
// * @author xins
|
||||
// * @date 2023-11-14 16:01
|
||||
// */
|
||||
// private void checkOfflineAlarm(HwDevice device) {
|
||||
// Long deviceId = device.getDeviceId();
|
||||
// Long sceneId = device.getSceneId();
|
||||
//
|
||||
// HwOfflineRule offlineRule = hwOfflineRuleMapper.selectHwOfflineRuleByDeviceId(deviceId);
|
||||
// if (offlineRule == null) {
|
||||
// offlineRule = hwOfflineRuleMapper.selectHwOfflineRuleBySceneId(sceneId);
|
||||
// }
|
||||
//
|
||||
// if (offlineRule != null) {
|
||||
// Long offlineNumberTime = offlineRule.getOfflineNumberTime();//分钟
|
||||
// Long offlineNumber = offlineRule.getOfflineNumber();
|
||||
//
|
||||
// if (offlineNumber > 1) {
|
||||
// Long currentTime = System.currentTimeMillis();
|
||||
// Long startTime = currentTime - offlineNumberTime * 60 * 1000;
|
||||
// DeviceStatus queryDeviceStatus = new DeviceStatus();
|
||||
// queryDeviceStatus.setDeviceId(deviceId);
|
||||
// queryDeviceStatus.setStartTime(startTime);
|
||||
// queryDeviceStatus.setEndTime(currentTime);
|
||||
// queryDeviceStatus.setOnlineStatus(0);
|
||||
//
|
||||
// R<List<Map<String, Object>>> deviceStatusListR = this.remoteTdEngineService.getDeviceStatusList(queryDeviceStatus, SecurityConstants.INNER);
|
||||
// List<Map<String, Object>> deviceStatusList = deviceStatusListR.getData();
|
||||
// //在几分钟时间内离线几次的报警信息保存
|
||||
// if (deviceStatusList != null && deviceStatusList.size() > offlineNumber) {
|
||||
// insertHwAlarmInfo(device, offlineRule, deviceId);
|
||||
// }
|
||||
// } else {//只要离线就报警
|
||||
// insertHwAlarmInfo(device, offlineRule, deviceId);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private void insertHwAlarmInfo(HwDevice device, HwOfflineRule offlineRule, Long deviceId) {
|
||||
// Date currentDate = new Date();
|
||||
//
|
||||
// HwAlarmInfo alarmInfo = new HwAlarmInfo();
|
||||
// alarmInfo.setAlarmInfoType(HwDictConstants.ALARM_INFO_TYPE_OFFLINE);
|
||||
// alarmInfo.setAlarmReleatedId(offlineRule.getOfflineRuleId());
|
||||
// alarmInfo.setDeviceId(deviceId);
|
||||
// alarmInfo.setTenantId(device.getTenantId());
|
||||
// alarmInfo.setSceneId(device.getSceneId());
|
||||
// alarmInfo.setMonitorUnitId(device.getMonitorUnitId());
|
||||
// alarmInfo.setAlarmLevelId(offlineRule.getAlarmLevelId());
|
||||
// alarmInfo.setHandleStatus(HwDictConstants.ALARM_HANDLE_STATUS_NO);
|
||||
// alarmInfo.setAlarmTime(currentDate);
|
||||
// alarmInfo.setCreateTime(currentDate);
|
||||
// hwAlarmInfoMapper.insertHwAlarmInfo(alarmInfo);
|
||||
// this.handleAlarmLink(offlineRule, device.getDeviceCode());
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * @param: offlineRule
|
||||
// * @param: deviceCode
|
||||
// * @description 处理报警规则联动设备
|
||||
// * @author xins
|
||||
// * @date 2023-11-07 16:39
|
||||
// */
|
||||
// private void handleAlarmLink(HwOfflineRule offlineRule, String deviceCode) {
|
||||
// String controlCommandTopic = StringUtils
|
||||
// .format(HwDictConstants.CONTROL_COMMAND_TOPIC_VALUE, deviceCode);
|
||||
// if (offlineRule.getLinkFlag().equals(HwDictConstants.ALARM_RULE_LINK_FLAG_YES)) {
|
||||
// List<HwAlarmRuleLink> offlineRuleLinks = offlineRule.getHwAlarmRuleLinkList();
|
||||
// offlineRuleLinks.forEach(offlineRuleLink -> {
|
||||
// this.publishControlCommand(controlCommandTopic, deviceCode, offlineRuleLink.getLinkDeviceFunctionIdentifier());
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
@ -0,0 +1,99 @@
|
||||
<?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>org.dromara</groupId>
|
||||
<artifactId>ruoyi-modules</artifactId>
|
||||
<version>${revision}</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>hwmom-mqtt</artifactId>
|
||||
|
||||
<description>
|
||||
hwmom-mqtt broker模块
|
||||
</description>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>net.dreamlu</groupId>
|
||||
<artifactId>mica-mqtt-server-spring-boot-starter</artifactId>
|
||||
<version>2.3.5</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Kafka -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.kafka</groupId>
|
||||
<artifactId>spring-kafka</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.dromara</groupId>
|
||||
<artifactId>ruoyi-common-nacos</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>org.dromara</groupId>
|
||||
<artifactId>ruoyi-common-security</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>org.dromara</groupId>
|
||||
<artifactId>ruoyi-api-resource</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba.fastjson2</groupId>
|
||||
<artifactId>fastjson2</artifactId>
|
||||
<version>2.0.51</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>com.mysql</groupId>-->
|
||||
<!-- <artifactId>mysql-connector-j</artifactId>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>com.microsoft.sqlserver</groupId>-->
|
||||
<!-- <artifactId>mssql-jdbc</artifactId>-->
|
||||
<!-- </dependency>-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>com.github.jsqlparser</groupId>-->
|
||||
<!-- <artifactId>jsqlparser</artifactId>-->
|
||||
<!-- <version>1.4</version>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<finalName>${project.artifactId}</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.1</version> <!-- 确保使用兼容的插件版本 -->
|
||||
<configuration>
|
||||
<source>17</source>
|
||||
<target>17</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<version>${spring-boot.version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
@ -0,0 +1,20 @@
|
||||
package com.hw.mqtt;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||
import org.springframework.boot.context.metrics.buffering.BufferingApplicationStartup;
|
||||
|
||||
@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)
|
||||
public class HwMqttBrokerApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication application = new SpringApplication(HwMqttBrokerApplication.class);
|
||||
application.setApplicationStartup(new BufferingApplicationStartup(2048));
|
||||
application.run(args);
|
||||
System.out.println("(♥◠‿◠)ノ゙ mqtt模块启动成功 ლ(´ڡ`ლ)゙ ");
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,37 @@
|
||||
package com.hw.mqtt.auth;
|
||||
|
||||
import net.dreamlu.iot.mqtt.core.server.http.api.code.ResultCode;
|
||||
import net.dreamlu.iot.mqtt.core.server.http.api.result.Result;
|
||||
import net.dreamlu.iot.mqtt.core.server.http.handler.HttpFilter;
|
||||
import net.dreamlu.iot.mqtt.core.server.http.handler.MqttHttpRoutes;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.tio.http.common.HttpRequest;
|
||||
import org.tio.http.common.HttpResponse;
|
||||
|
||||
/**
|
||||
* mqtt http 接口认证
|
||||
* @author WenJY
|
||||
* @date 2023-03-14 12:20
|
||||
* @return null
|
||||
*/
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
public class MqttHttpAuthFilter implements HttpFilter, InitializingBean {
|
||||
|
||||
@Override
|
||||
public boolean filter(HttpRequest request) throws Exception {
|
||||
// 自行实现逻辑
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResponse response(HttpRequest request) {
|
||||
// 认证不通过时的响应
|
||||
return Result.fail(request, ResultCode.E103);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
MqttHttpRoutes.addFilter(this);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,32 @@
|
||||
package com.hw.mqtt.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
/**
|
||||
* 设备连接状态枚举
|
||||
* @author Wen JY
|
||||
* @description: TODO
|
||||
* @date 2023-09-13 13:42:37
|
||||
* @version: 1.0
|
||||
*/
|
||||
@Getter
|
||||
@RequiredArgsConstructor
|
||||
public enum ConnectStatus {
|
||||
|
||||
/**
|
||||
* 设备连接
|
||||
*/
|
||||
connct(1),
|
||||
|
||||
/**
|
||||
* 设备断开
|
||||
*/
|
||||
disconnect(0);
|
||||
|
||||
private final int key;
|
||||
|
||||
public int getKey(){
|
||||
return this.key;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,37 @@
|
||||
package com.hw.mqtt.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
/**
|
||||
* 设备类型枚举
|
||||
* @author Wen JY
|
||||
* @description: TODO
|
||||
* @date 2023-09-13 13:30:38
|
||||
* @version: 1.0
|
||||
*/
|
||||
@Getter
|
||||
@RequiredArgsConstructor
|
||||
public enum DeviceType {
|
||||
|
||||
/**
|
||||
* 网关/基站
|
||||
*/
|
||||
edge(1),
|
||||
|
||||
/**
|
||||
* 网关子设备/传感器
|
||||
*/
|
||||
sensor(2),
|
||||
|
||||
/**
|
||||
* 直连设备
|
||||
*/
|
||||
device(3);
|
||||
|
||||
private final int key;
|
||||
|
||||
public int getKey(){
|
||||
return this.key;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,49 @@
|
||||
package com.hw.mqtt.listener;
|
||||
|
||||
//import net.dreamlu.iot.mqtt.codec.ByteBufferUtil;
|
||||
|
||||
import net.dreamlu.iot.mqtt.codec.MqttPublishMessage;
|
||||
import net.dreamlu.iot.mqtt.codec.MqttQoS;
|
||||
import net.dreamlu.iot.mqtt.core.server.event.IMqttMessageListener;
|
||||
import net.dreamlu.iot.mqtt.spring.server.MqttServerTemplate;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.SmartInitializingSingleton;
|
||||
import com.hw.mqtt.service.KafkaProducerService;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.tio.core.ChannelContext;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
/**
|
||||
* 消息监听器
|
||||
*
|
||||
* @author WenJY
|
||||
* @date 2023-03-14 12:18
|
||||
* @return null
|
||||
*/
|
||||
@Service
|
||||
public class MqttServerMessageListener implements IMqttMessageListener, SmartInitializingSingleton {
|
||||
private static final Logger logger = LoggerFactory.getLogger(MqttServerMessageListener.class);
|
||||
private final ApplicationContext applicationContext;
|
||||
private MqttServerTemplate mqttServerTemplate;
|
||||
private final KafkaProducerService kafkaProducerService;
|
||||
|
||||
public MqttServerMessageListener(ApplicationContext applicationContext, KafkaProducerService kafkaProducerService) {
|
||||
this.applicationContext = applicationContext;
|
||||
this.kafkaProducerService = kafkaProducerService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMessage(ChannelContext context, String clientId, String topic, MqttQoS qos, MqttPublishMessage message) {
|
||||
logger.info("context:{} clientId:{} message:{} payload:{}", context, clientId, message, new String(message.getPayload(), StandardCharsets.UTF_8));
|
||||
kafkaProducerService.sendMessage("test", new String(message.getPayload(), StandardCharsets.UTF_8));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterSingletonsInstantiated() {
|
||||
// 单利 bean 初始化完成之后从 ApplicationContext 中获取 bean
|
||||
mqttServerTemplate = applicationContext.getBean(MqttServerTemplate.class);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,19 @@
|
||||
package com.hw.mqtt.service;
|
||||
|
||||
import org.springframework.kafka.core.KafkaTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class KafkaProducerService {
|
||||
|
||||
private final KafkaTemplate<String, String> kafkaTemplate;
|
||||
|
||||
public KafkaProducerService(KafkaTemplate<String, String> kafkaTemplate) {
|
||||
this.kafkaTemplate = kafkaTemplate;
|
||||
}
|
||||
|
||||
public void sendMessage(String topic, String message) {
|
||||
kafkaTemplate.send(topic, message);
|
||||
System.out.println("Forwarded message to Kafka: " + message);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,17 @@
|
||||
package org.dromara;
|
||||
|
||||
//TIP To <b>Run</b> code, press <shortcut actionId="Run"/> or
|
||||
// click the <icon src="AllIcons.Actions.Execute"/> icon in the gutter.
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
//TIP Press <shortcut actionId="ShowIntentionActions"/> with your caret at the highlighted text
|
||||
// to see how IntelliJ IDEA suggests fixing it.
|
||||
System.out.printf("Hello and welcome!");
|
||||
|
||||
for (int i = 1; i <= 5; i++) {
|
||||
//TIP Press <shortcut actionId="Debug"/> to start debugging your code. We have set one <icon src="AllIcons.Debugger.Db_set_breakpoint"/> breakpoint
|
||||
// for you, but you can always add more by pressing <shortcut actionId="ToggleLineBreakpoint"/>.
|
||||
System.out.println("i = " + i);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,10 @@
|
||||
|
||||
${AnsiColor.RED} ## ## ####### ######## ########
|
||||
${AnsiColor.RED} ### ### ## ## ## ##
|
||||
${AnsiColor.RED} #### #### ## ## ## ##
|
||||
${AnsiColor.RED} ## ### ## ## ## ## ##
|
||||
${AnsiColor.RED} ## ## ## ## ## ## ##
|
||||
${AnsiColor.RED} ## ## ## ## ## ##
|
||||
${AnsiColor.RED} ## ## ##### ## ## ##
|
||||
|
||||
${AnsiColor.BRIGHT_BLUE}:: ${spring.application.name} :: Running Spring Boot ${spring-boot.version} 🏃🏃🏃 ${AnsiColor.DEFAULT}
|
||||
@ -0,0 +1,100 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.dromara</groupId>
|
||||
<artifactId>ruoyi-modules</artifactId>
|
||||
<version>${revision}</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>hwmom-tsdb</artifactId>
|
||||
|
||||
<description>
|
||||
hwmom-tsdb 时序数据库处理模块
|
||||
</description>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.dromara</groupId>
|
||||
<artifactId>ruoyi-common-nacos</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.dromara</groupId>
|
||||
<artifactId>ruoyi-common-security</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.dromara</groupId>
|
||||
<artifactId>ruoyi-common-sentinel</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- InfluxDB Java Client -->
|
||||
<dependency>
|
||||
<groupId>org.influxdb</groupId>
|
||||
<artifactId>influxdb-java</artifactId>
|
||||
<version>2.23</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- RuoYi Common Log -->
|
||||
<dependency>
|
||||
<groupId>org.dromara</groupId>
|
||||
<artifactId>ruoyi-common-log</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.dromara</groupId>
|
||||
<artifactId>ruoyi-common-doc</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.dromara</groupId>
|
||||
<artifactId>ruoyi-common-web</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.dromara</groupId>
|
||||
<artifactId>ruoyi-common-dubbo</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.dromara</groupId>
|
||||
<artifactId>ruoyi-common-tenant</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<finalName>${project.artifactId}</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.1</version> <!-- 确保使用兼容的插件版本 -->
|
||||
<configuration>
|
||||
<source>17</source>
|
||||
<target>17</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<version>${spring-boot.version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
||||
</project>
|
||||
@ -0,0 +1,20 @@
|
||||
package org.dromara.tsdb;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||
import org.springframework.boot.context.metrics.buffering.BufferingApplicationStartup;
|
||||
|
||||
@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)
|
||||
public class HwTsDbApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication application = new SpringApplication(HwTsDbApplication.class);
|
||||
application.setApplicationStartup(new BufferingApplicationStartup(2048));
|
||||
application.run(args);
|
||||
System.out.println("(♥◠‿◠)ノ゙ TSDB 时序数据库处理模块启动成功 ლ(´ڡ`ლ)゙ ");
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,30 @@
|
||||
package org.dromara.tsdb.config;
|
||||
|
||||
import org.influxdb.InfluxDB;
|
||||
import org.influxdb.InfluxDBFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
public class InfluxDbConfig {
|
||||
|
||||
@Value("${influxdb.url}")
|
||||
private String influxDBUrl;
|
||||
|
||||
@Value("${influxdb.username}")
|
||||
private String username;
|
||||
|
||||
@Value("${influxdb.password}")
|
||||
private String password;
|
||||
|
||||
@Value("${influxdb.database}")
|
||||
private String database;
|
||||
|
||||
@Bean
|
||||
public InfluxDB influxDB() {
|
||||
InfluxDB influxDB = InfluxDBFactory.connect(influxDBUrl, username, password);
|
||||
influxDB.setDatabase(database);
|
||||
return influxDB;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,32 @@
|
||||
package org.dromara.tsdb.controller;
|
||||
|
||||
import org.dromara.tsdb.domain.bo.InfluxMeasurementBo;
|
||||
import org.dromara.tsdb.service.IInfluxDbService;
|
||||
import org.influxdb.dto.QueryResult;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/influx")
|
||||
public class InfluxDbController {
|
||||
|
||||
@Autowired
|
||||
private IInfluxDbService influxDbService;
|
||||
|
||||
/**
|
||||
* 写入数据到InfluxDB
|
||||
*/
|
||||
@PostMapping("/write")
|
||||
public String writeData(@RequestBody InfluxMeasurementBo influxMeasurementBo) {
|
||||
influxDbService.writeData(influxMeasurementBo);
|
||||
return "Data written to InfluxDB successfully!";
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询数据
|
||||
*/
|
||||
@GetMapping("/query")
|
||||
public QueryResult queryData(@RequestParam String query) {
|
||||
return influxDbService.queryData(query);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,23 @@
|
||||
package org.dromara.tsdb.domain.bo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class InfluxMeasurementBo {
|
||||
|
||||
/** @param measurement 表名
|
||||
* @param tagKey 标签键
|
||||
* @param tagValue 标签值
|
||||
* @param fieldKey 字段键
|
||||
* @param fieldValue 字段值*/
|
||||
private String measurement;
|
||||
|
||||
private String tagKey;
|
||||
|
||||
private String tagValue;
|
||||
|
||||
private String fieldKey;
|
||||
|
||||
private String fieldValue;
|
||||
|
||||
}
|
||||
@ -0,0 +1,21 @@
|
||||
package org.dromara.tsdb.service;
|
||||
|
||||
import org.dromara.tsdb.domain.bo.InfluxMeasurementBo;
|
||||
import org.influxdb.dto.QueryResult;
|
||||
|
||||
public interface IInfluxDbService {
|
||||
/**
|
||||
* 写入数据到InfluxDB
|
||||
* @param influxMeasurementBo
|
||||
*/
|
||||
public void writeData(InfluxMeasurementBo influxMeasurementBo);
|
||||
|
||||
/**
|
||||
* 查询数据
|
||||
*
|
||||
* @param query 查询语句
|
||||
* @return 查询结果
|
||||
*/
|
||||
public QueryResult queryData(String query);
|
||||
|
||||
}
|
||||
@ -0,0 +1,46 @@
|
||||
package org.dromara.tsdb.service.impl;
|
||||
|
||||
import org.dromara.tsdb.domain.bo.InfluxMeasurementBo;
|
||||
import org.dromara.tsdb.service.IInfluxDbService;
|
||||
import org.influxdb.InfluxDB;
|
||||
import org.influxdb.dto.Point;
|
||||
import org.influxdb.dto.Query;
|
||||
import org.influxdb.dto.QueryResult;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Service
|
||||
public class InfluxDbServiceImpl implements IInfluxDbService {
|
||||
|
||||
@Autowired
|
||||
private InfluxDB influxDB;
|
||||
|
||||
/**
|
||||
* 写入数据到InfluxDB
|
||||
* @param influxMeasurementBo
|
||||
*/
|
||||
@Override
|
||||
public void writeData(InfluxMeasurementBo influxMeasurementBo) {
|
||||
Point point = Point.measurement(influxMeasurementBo.getMeasurement())
|
||||
.tag(influxMeasurementBo.getTagKey(), influxMeasurementBo.getTagValue())
|
||||
.addField(influxMeasurementBo.getFieldKey(), influxMeasurementBo.getFieldValue())
|
||||
.time(System.currentTimeMillis(), TimeUnit.MILLISECONDS)
|
||||
.build();
|
||||
influxDB.write(point);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询数据
|
||||
*
|
||||
* @param query 查询语句
|
||||
* @return 查询结果
|
||||
*/
|
||||
@Override
|
||||
public QueryResult queryData(String query) {
|
||||
QueryResult queryResult = influxDB.query(new Query(query));
|
||||
System.out.println(queryResult.getResults());
|
||||
return queryResult;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,37 @@
|
||||
# Tomcat
|
||||
server:
|
||||
port: 9608
|
||||
|
||||
# Spring
|
||||
spring:
|
||||
application:
|
||||
# 应用名称
|
||||
name: hwmom-tsdb
|
||||
profiles:
|
||||
# 环境配置
|
||||
active: @profiles.active@
|
||||
|
||||
--- # nacos 配置
|
||||
spring:
|
||||
application:
|
||||
# 应用名称
|
||||
name: hwmom-tsdb
|
||||
cloud:
|
||||
nacos:
|
||||
# nacos 服务地址
|
||||
server-addr: @nacos.server@
|
||||
username: @nacos.username@
|
||||
password: @nacos.password@
|
||||
discovery:
|
||||
# 注册组
|
||||
group: @nacos.discovery.group@
|
||||
namespace: ${spring.profiles.active}
|
||||
config:
|
||||
# 配置组
|
||||
group: @nacos.config.group@
|
||||
namespace: ${spring.profiles.active}
|
||||
config:
|
||||
import:
|
||||
- optional:nacos:application-common.yml
|
||||
- optional:nacos:datasource.yml
|
||||
- optional:nacos:${spring.application.name}.yml
|
||||
Loading…
Reference in New Issue