feat: 物联平台分支创建及代码整合。
This commit is contained in:
2
intc-modules/intc-tdengine/README.md
Normal file
2
intc-modules/intc-tdengine/README.md
Normal file
@@ -0,0 +1,2 @@
|
||||
基础信息模块
|
||||
包含位置信息(building)、设施信息(facility)、设备信息(device)、报警信息(alarm)
|
||||
131
intc-modules/intc-tdengine/pom.xml
Normal file
131
intc-modules/intc-tdengine/pom.xml
Normal file
@@ -0,0 +1,131 @@
|
||||
<?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.intc</groupId>
|
||||
<artifactId>intc-modules</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>intc-tdengine</artifactId>
|
||||
|
||||
<description>
|
||||
intc-tdengine模块
|
||||
</description>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<!-- SpringCloud Alibaba Nacos -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringCloud Alibaba Nacos Config -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringCloud Alibaba Sentinel -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringBoot Actuator -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-security</artifactId>
|
||||
</dependency>
|
||||
<!-- Swagger UI -->
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger-ui</artifactId>
|
||||
<version>${swagger.fox.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Mysql Connector -->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>mysql</groupId>-->
|
||||
<!-- <artifactId>mysql-connector-java</artifactId>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
<!-- RuoYi Common DataSource -->
|
||||
<dependency>
|
||||
<groupId>com.intc</groupId>
|
||||
<artifactId>intc-common-datasource</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- RuoYi Common DataScope -->
|
||||
<dependency>
|
||||
<groupId>com.intc</groupId>
|
||||
<artifactId>intc-common-datascope</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- RuoYi Common Log -->
|
||||
<dependency>
|
||||
<groupId>com.intc</groupId>
|
||||
<artifactId>intc-common-log</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- RuoYi Common Swagger -->
|
||||
<dependency>
|
||||
<groupId>com.intc</groupId>
|
||||
<artifactId>intc-common-swagger</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!--mysql脚本版本管理-->
|
||||
<dependency>
|
||||
<groupId>org.flywaydb</groupId>
|
||||
<artifactId>flyway-core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.taosdata.jdbc</groupId>
|
||||
<artifactId>taos-jdbcdriver</artifactId>
|
||||
<version>3.0.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.intc</groupId>
|
||||
<artifactId>intc-api-tdengine</artifactId>
|
||||
<version>3.6.3</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.intc</groupId>
|
||||
<artifactId>intc-api-iot-basics</artifactId>
|
||||
<version>3.6.3</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<finalName>${project.artifactId}</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.intc;
|
||||
|
||||
import com.intc.common.security.annotation.EnableCustomConfig;
|
||||
import com.intc.common.security.annotation.EnableRyFeignClients;
|
||||
import com.intc.common.swagger.annotation.EnableCustomSwagger2;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
/**
|
||||
* 系统模块
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@EnableCustomConfig
|
||||
@EnableCustomSwagger2
|
||||
@EnableRyFeignClients
|
||||
@SpringBootApplication
|
||||
public class IntcTdEngineApplication
|
||||
{
|
||||
public static void main(String[] args)
|
||||
{
|
||||
SpringApplication.run(com.intc.IntcTdEngineApplication.class, args);
|
||||
System.out.println("(♥◠‿◠)ノ゙ TdEngine服务启动成功 ლ(´ڡ`ლ)゙");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.intc.config;
|
||||
|
||||
import com.intc.common.core.utils.StringUtils;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
|
||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
||||
import org.springframework.security.web.SecurityFilterChain;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* @ClassName ActuatorSecurityConfig
|
||||
* @Author YaphetS
|
||||
* @Date 2023/3/14 9:18
|
||||
* @Version 1.0
|
||||
* @Description TODO
|
||||
*/
|
||||
@Configuration
|
||||
@EnableWebSecurity
|
||||
@EnableGlobalMethodSecurity(prePostEnabled = true)
|
||||
public class ActuatorSecurityConfig {
|
||||
|
||||
@Resource
|
||||
Environment env;
|
||||
|
||||
@Bean
|
||||
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
|
||||
String contextPath = env.getProperty("management.endpoints.web.base-path");
|
||||
if(StringUtils.isEmpty(contextPath)) {
|
||||
contextPath = "/actuator";
|
||||
}
|
||||
http.csrf().disable();
|
||||
http.authorizeRequests()
|
||||
.antMatchers("/**"+contextPath+"/**")
|
||||
.authenticated()
|
||||
.anyRequest()
|
||||
.permitAll()
|
||||
.and()
|
||||
.httpBasic();
|
||||
return http.build();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.intc.tdengine.controller;
|
||||
|
||||
|
||||
import com.intc.common.core.web.controller.BaseController;
|
||||
import com.intc.tdengine.service.DataDemoService;
|
||||
import io.swagger.annotations.Api;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* TDEngine监控数据信息Controller
|
||||
*
|
||||
* @author YaphetS
|
||||
* @date 2023-03-13
|
||||
*/
|
||||
@Api(tags="TDEngine监控数据")
|
||||
@RestController
|
||||
@RequestMapping("/data/demo")
|
||||
public class DataDemoController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private DataDemoService dataService;
|
||||
|
||||
@GetMapping("/send")
|
||||
public String send(){
|
||||
dataService.dataDemo();
|
||||
return "SUCESS";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package com.intc.tdengine.controller;
|
||||
|
||||
import com.intc.api.tdengine.domain.DataAvdVo;
|
||||
import com.intc.api.tdengine.domain.DataDto;
|
||||
import com.intc.api.tdengine.domain.RealDataVo;
|
||||
import com.intc.common.core.web.controller.BaseController;
|
||||
import com.intc.tdengine.service.TdEngineService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* TDEngine监控数据信息Controller
|
||||
*
|
||||
* @author YaphetS
|
||||
* @date 2023-03-13
|
||||
*/
|
||||
@Api(tags="TDEngine监控数据")
|
||||
@RestController
|
||||
@RequestMapping("/td")
|
||||
public class TdEngineController extends BaseController
|
||||
{
|
||||
@Resource
|
||||
private TdEngineService tdEngineService;
|
||||
|
||||
/**
|
||||
* 查询TDEngine监控数据列表
|
||||
*/
|
||||
@ApiOperation(value="按类型查询对应点最新数据的平均值和最大最小值")
|
||||
@PostMapping("/selectMaxMinAvgData")
|
||||
public DataAvdVo selectMaxMinAvgData(@RequestParam(value = "tagTypeId") String tagTypeId)
|
||||
{
|
||||
return tdEngineService.selectMaxMinAvgData(tagTypeId);
|
||||
}
|
||||
@ApiOperation(value="按类型查询对应点最新数据的平均值和最大最小值")
|
||||
@PostMapping("/selectDataListToMap")
|
||||
public Map<String, String> selectDataListToMap(DataDto dataDto)
|
||||
{
|
||||
return tdEngineService.selectDataListToMap(dataDto);
|
||||
}
|
||||
@ApiOperation(value="查询最新数据")
|
||||
@PostMapping("/getLastData")
|
||||
public RealDataVo getLastData(@RequestParam(value = "tagId") String tagId)
|
||||
{
|
||||
return tdEngineService.getLastData(tagId);
|
||||
}
|
||||
@ApiOperation(value="查询历史数据")
|
||||
@PostMapping("/getHistoryData")
|
||||
public List<RealDataVo> getHistoryData(@RequestParam(value = "tagId") String tagId, @RequestParam(value = "startTime") String startTime, @RequestParam(value = "endTime") String endTime)
|
||||
{
|
||||
return tdEngineService.getHistoryData(tagId,startTime,endTime);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.intc.tdengine.domain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author 22024089
|
||||
*/
|
||||
@Data
|
||||
public class RealTimeDataT implements Serializable {
|
||||
|
||||
private String tagId;
|
||||
private String buildingId;
|
||||
private String valueType;
|
||||
private String tagShowType;
|
||||
private String deviceId;
|
||||
private String tagTypeId;
|
||||
private Date dataTime;
|
||||
private String val;
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.intc.tdengine.mapper;
|
||||
|
||||
|
||||
import com.intc.tdengine.domain.RealTimeDataT;
|
||||
|
||||
/**
|
||||
* @author 22024089
|
||||
*/
|
||||
public interface DataDemoMapper {
|
||||
/**
|
||||
* 新增实时数据
|
||||
*
|
||||
* @param realTimeData 实时数据信息
|
||||
* @return 结果
|
||||
*/
|
||||
|
||||
public int insertRealTimeDataT(RealTimeDataT realTimeData);
|
||||
|
||||
public int createTableT(RealTimeDataT realTimeData);
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.intc.tdengine.mapper;
|
||||
|
||||
import com.intc.api.tdengine.domain.DataAvdVo;
|
||||
import com.intc.api.tdengine.domain.DataDto;
|
||||
import com.intc.api.tdengine.domain.RealDataVo;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* TDEngine监控数据Mapper接口
|
||||
*
|
||||
* @author YaphetS
|
||||
* @date 2023-03-13
|
||||
*/
|
||||
public interface TdEngineMapper
|
||||
{
|
||||
/**
|
||||
* 点类型统计信息
|
||||
*
|
||||
* @param tagTypeId 点类型ID
|
||||
* @return 点类型统计信息
|
||||
*/
|
||||
public DataAvdVo selectMaxMinAvgData(String tagTypeId);
|
||||
|
||||
RealDataVo getLastData(String tagId);
|
||||
|
||||
List<RealDataVo> selectDataList(DataDto dataDto);
|
||||
|
||||
List<RealDataVo> getHistoryDataList(@Param("tagId") String tagId,@Param("startTime") String startTime,@Param("endTime") String endTime);
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
package com.intc.tdengine.service;
|
||||
|
||||
|
||||
import com.intc.api.basics.RemoteDeviceService;
|
||||
import com.intc.api.basics.domain.TagBasicInfoApiDto;
|
||||
import com.intc.api.basics.domain.TagBasicInfoApiVo;
|
||||
import com.intc.common.core.utils.DateUtils;
|
||||
import com.intc.common.core.utils.LocalDateUtils;
|
||||
import com.intc.tdengine.domain.RealTimeDataT;
|
||||
import com.intc.tdengine.mapper.DataDemoMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* 设备实时状态Service业务层处理
|
||||
*
|
||||
* @author tianyongbao
|
||||
* @date 2023-03-10
|
||||
*/
|
||||
@Service
|
||||
public class DataDemoService
|
||||
{
|
||||
@Resource
|
||||
private RemoteDeviceService remoteDeviceService;
|
||||
@Resource
|
||||
private DataDemoMapper dataDemoMapper;
|
||||
public void dataDemo(){
|
||||
TagBasicInfoApiDto tagBasicInfoApiDto = new TagBasicInfoApiDto();
|
||||
tagBasicInfoApiDto.setIsShow("1");
|
||||
long time = DateUtils.parseDate(DateUtils.dateTimeNow("yyyy-MM-dd HH:00:00")).getTime();
|
||||
List<TagBasicInfoApiVo> tagBasicInfoVos = remoteDeviceService.tagListAll(tagBasicInfoApiDto).getData();
|
||||
for (TagBasicInfoApiVo tagBasicInfoVo : tagBasicInfoVos) {
|
||||
for (int i = 0; i < 48; i++) {
|
||||
String data="20";
|
||||
Double num=20.0;
|
||||
if("1".equals(tagBasicInfoVo.getValueType())){
|
||||
data=String.valueOf((int) (Math.random()*99)/50);
|
||||
|
||||
}else if("2".equals(tagBasicInfoVo.getValueType())){
|
||||
/**氧气浓度*/
|
||||
if(14==tagBasicInfoVo.getTagTypeId()){
|
||||
num=num+new Random().nextDouble()*2;
|
||||
num=num-new Random().nextDouble()*2;
|
||||
} /**温度*/
|
||||
else if(16==tagBasicInfoVo.getTagTypeId()){
|
||||
num=num+new Random().nextDouble()*2;
|
||||
}/**湿度*/
|
||||
else if(15==tagBasicInfoVo.getTagTypeId()){
|
||||
num=45.0;
|
||||
num=num-new Random().nextDouble()*2;
|
||||
}/**甲烷*/
|
||||
else if(23==tagBasicInfoVo.getTagTypeId()){
|
||||
num=0.0;
|
||||
}/**硫化氢*/
|
||||
else if(22==tagBasicInfoVo.getTagTypeId()){
|
||||
num=0.0;
|
||||
}
|
||||
/**位移*/
|
||||
else if(4==tagBasicInfoVo.getTagTypeId()){
|
||||
num=9.0;
|
||||
}
|
||||
/**沉降*/
|
||||
else if(5==tagBasicInfoVo.getTagTypeId()){
|
||||
num=9.0;
|
||||
}
|
||||
/**压力*/
|
||||
else if(7==tagBasicInfoVo.getTagTypeId()){
|
||||
num=50.0;
|
||||
}
|
||||
/**流量*/
|
||||
else if(8==tagBasicInfoVo.getTagTypeId()){
|
||||
num=50.0;
|
||||
}else{
|
||||
num=25.0;
|
||||
num=num-new Random().nextDouble()*2;
|
||||
}
|
||||
num=(double) Math.round(num * 100) / 100;
|
||||
data= String.valueOf(num);
|
||||
}
|
||||
|
||||
// num=num+new Random().nextDouble()*5;
|
||||
|
||||
RealTimeDataT realTimeData = new RealTimeDataT();
|
||||
realTimeData.setTagId(String.valueOf(tagBasicInfoVo.getId()));
|
||||
|
||||
realTimeData.setDeviceId(tagBasicInfoVo.getDeviceId());
|
||||
realTimeData.setBuildingId(tagBasicInfoVo.getBuildingId());
|
||||
realTimeData.setTagTypeId(String.valueOf(tagBasicInfoVo.getTagTypeId()));
|
||||
realTimeData.setValueType(tagBasicInfoVo.getValueType());
|
||||
realTimeData.setTagShowType(tagBasicInfoVo.getIsShow());
|
||||
realTimeData.setDataTime(LocalDateUtils.LocalDateTimetoDate(LocalDateTime.now().minusMinutes(i*30),null));
|
||||
realTimeData.setVal(data);
|
||||
if(i==0){
|
||||
dataDemoMapper.createTableT(realTimeData);
|
||||
}
|
||||
dataDemoMapper.insertRealTimeDataT(realTimeData);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
for (int i = 0; i < 100; i++) {
|
||||
System.out.println(String.valueOf((int) (Math.random()*99)/50));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package com.intc.tdengine.service;
|
||||
|
||||
import com.intc.api.tdengine.domain.DataAvdVo;
|
||||
import com.intc.api.tdengine.domain.DataDto;
|
||||
import com.intc.api.tdengine.domain.RealDataVo;
|
||||
import com.intc.tdengine.mapper.TdEngineMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @ClassName TdEngineService
|
||||
* @Author YaphetS
|
||||
* @Date 2023/4/17 17:17
|
||||
* @Version 1.0
|
||||
* @Description TODO
|
||||
*/
|
||||
@Service
|
||||
public class TdEngineService {
|
||||
@Resource
|
||||
private TdEngineMapper tdEngineMapper;
|
||||
public DataAvdVo selectMaxMinAvgData(String tagTypeId){
|
||||
DataAvdVo dataAvdVo=new DataAvdVo();
|
||||
try {
|
||||
dataAvdVo= tdEngineMapper.selectMaxMinAvgData(tagTypeId);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
return dataAvdVo;
|
||||
}
|
||||
|
||||
public RealDataVo getLastData(String tagId) {
|
||||
RealDataVo lastData=null;
|
||||
try {
|
||||
lastData = tdEngineMapper.getLastData(tagId);
|
||||
}catch (Exception e){
|
||||
lastData=new RealDataVo();
|
||||
|
||||
}
|
||||
return lastData;
|
||||
}
|
||||
|
||||
public Map<String, String> selectDataListToMap(DataDto dataDto) {
|
||||
Map<String,String> map=new HashMap<>();
|
||||
List<RealDataVo> dataVoList=tdEngineMapper.selectDataList(dataDto);
|
||||
if(dataVoList!=null&&dataVoList.size()>0){
|
||||
for (RealDataVo realDataVo : dataVoList) {
|
||||
map.put(realDataVo.getTagId(),realDataVo.getVal());
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
public List<RealDataVo> getHistoryData(String tagId, String startTime, String endTime) {
|
||||
List<RealDataVo> list=new ArrayList<>();
|
||||
try {
|
||||
list=tdEngineMapper.getHistoryDataList(tagId,startTime,endTime);
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
||||
11
intc-modules/intc-tdengine/src/main/resources/banner.txt
Normal file
11
intc-modules/intc-tdengine/src/main/resources/banner.txt
Normal file
@@ -0,0 +1,11 @@
|
||||
Spring Boot Version: ${spring-boot.version}
|
||||
Spring Application Name: ${spring.application.name}
|
||||
|
||||
_ _ _
|
||||
| | | | (_)
|
||||
| |__ _ __ _ _ ______| |__ __ _ ___ _ ___ ___
|
||||
| '_ \| '_ \| | | |______| '_ \ / _` / __| |/ __/ __|
|
||||
| | | | | | | |_| | | |_) | (_| \__ \ | (__\__ \
|
||||
|_| |_|_| |_|\__, | |_.__/ \__,_|___/_|\___|___/
|
||||
__/ |
|
||||
|___/
|
||||
32
intc-modules/intc-tdengine/src/main/resources/bootstrap.yml
Normal file
32
intc-modules/intc-tdengine/src/main/resources/bootstrap.yml
Normal file
@@ -0,0 +1,32 @@
|
||||
# Tomcat
|
||||
server:
|
||||
port: 9220
|
||||
|
||||
# Spring
|
||||
spring:
|
||||
application:
|
||||
# 应用名称
|
||||
name: intc-tdengine
|
||||
profiles:
|
||||
# 环境配置
|
||||
active: dev
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
namespace: intc
|
||||
# 服务注册地址
|
||||
server-addr: 101.126.95.100:8858
|
||||
group: dev
|
||||
config:
|
||||
namespace: intc
|
||||
# 配置中心地址
|
||||
server-addr: 101.126.95.100:8858
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
shared-configs:
|
||||
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||
# 用于服务监控可在线查看日志,该配置用于生产环境
|
||||
logging:
|
||||
file:
|
||||
name: logs/${spring.application.name}/info.log
|
||||
74
intc-modules/intc-tdengine/src/main/resources/logback.xml
Normal file
74
intc-modules/intc-tdengine/src/main/resources/logback.xml
Normal file
@@ -0,0 +1,74 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration scan="true" scanPeriod="60 seconds" debug="false">
|
||||
<!-- 日志存放路径 -->
|
||||
<property name="log.path" value="logs/hny-tdengine" />
|
||||
<!-- 日志输出格式 -->
|
||||
<property name="log.pattern" value="%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n" />
|
||||
|
||||
<!-- 控制台输出 -->
|
||||
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>${log.pattern}</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<!-- 系统日志输出 -->
|
||||
<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${log.path}/info.log</file>
|
||||
<!-- 循环政策:基于时间创建日志文件 -->
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<!-- 日志文件名格式 -->
|
||||
<fileNamePattern>${log.path}/info.%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||
<!-- 日志最大的历史 60天 -->
|
||||
<maxHistory>60</maxHistory>
|
||||
</rollingPolicy>
|
||||
<encoder>
|
||||
<pattern>${log.pattern}</pattern>
|
||||
</encoder>
|
||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||
<!-- 过滤的级别 -->
|
||||
<level>INFO</level>
|
||||
<!-- 匹配时的操作:接收(记录) -->
|
||||
<onMatch>ACCEPT</onMatch>
|
||||
<!-- 不匹配时的操作:拒绝(不记录) -->
|
||||
<onMismatch>DENY</onMismatch>
|
||||
</filter>
|
||||
</appender>
|
||||
|
||||
<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${log.path}/error.log</file>
|
||||
<!-- 循环政策:基于时间创建日志文件 -->
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<!-- 日志文件名格式 -->
|
||||
<fileNamePattern>${log.path}/error.%d{yyyy-MM}.log</fileNamePattern>
|
||||
<!-- 日志最大的历史 60天 -->
|
||||
<maxHistory>60</maxHistory>
|
||||
</rollingPolicy>
|
||||
<encoder>
|
||||
<pattern>${log.pattern}</pattern>
|
||||
</encoder>
|
||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||
<!-- 过滤的级别 -->
|
||||
<level>ERROR</level>
|
||||
<!-- 匹配时的操作:接收(记录) -->
|
||||
<onMatch>ACCEPT</onMatch>
|
||||
<!-- 不匹配时的操作:拒绝(不记录) -->
|
||||
<onMismatch>DENY</onMismatch>
|
||||
</filter>
|
||||
</appender>
|
||||
|
||||
<!-- 系统模块日志级别控制 -->
|
||||
<logger name="com.intc" level="debug" />
|
||||
<!-- Spring日志级别控制 -->
|
||||
<logger name="org.springframework" level="warn" />
|
||||
|
||||
<root level="info">
|
||||
<appender-ref ref="console" />
|
||||
</root>
|
||||
|
||||
<!--系统操作日志-->
|
||||
<root level="info">
|
||||
<appender-ref ref="file_info" />
|
||||
<appender-ref ref="file_error" />
|
||||
</root>
|
||||
</configuration>
|
||||
@@ -0,0 +1,21 @@
|
||||
<?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.intc.tdengine.mapper.DataDemoMapper">
|
||||
|
||||
<insert id="createTableT" parameterType="RealTimeDataT">
|
||||
create table if not exists
|
||||
pg_d.t${tagId}
|
||||
USING pg_d.pg_monitor_data(buildingId,valueType,tagId,deviceId,tagShowType,tagTypeId)
|
||||
TAGS (#{buildingId}, #{valueType}, #{tagId}, #{deviceId}, #{tagShowType}, #{tagTypeId})
|
||||
</insert>
|
||||
<insert id="insertRealTimeDataT" parameterType="RealTimeDataT">
|
||||
insert into pg_d.t${tagId} VALUES (#{dataTime},NOW, #{val});
|
||||
</insert>
|
||||
<update id="createSuperTable">
|
||||
create table if not exists
|
||||
pg_d.pg_monitor_data(time timestamp,createTime timestamp, val nchar(100))
|
||||
tags(buildingId nchar(100),valueType nchar(10), tagId nchar(100),deviceId nchar(100),tagShowType nchar(50),tagTypeId nchar(100))
|
||||
</update>
|
||||
</mapper>
|
||||
@@ -0,0 +1,57 @@
|
||||
<?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.intc.tdengine.mapper.TdEngineMapper">
|
||||
<!-- <update id="createSuperTable">-->
|
||||
<!-- create table if not exists-->
|
||||
<!-- pg_d.pg_monitor_data(time timestamp,createTime timestamp, val nchar(20))-->
|
||||
<!-- tags(buildingId nchar(100),valueType nchar(10), tagId nchar(100),deviceId nchar(100),tagShowType nchar(50),tagTypeId nchar(100))-->
|
||||
<!-- </update>-->
|
||||
<!-- <insert id="createTable" parameterType="RealTimeData">-->
|
||||
<!-- create table if not exists-->
|
||||
<!-- pg_d.t${tagId}-->
|
||||
<!-- USING pg_d.pg_monitor_data(buildingId,valueType,tagId,deviceId,tagShowType,tagTypeId)-->
|
||||
<!-- TAGS (#{buildingId}, #{valueType}, #{tagId}, #{deviceId}, #{tagshowType}, #{tagTypeId})-->
|
||||
<!-- </insert>-->
|
||||
<!-- <insert id="insertRealTimeData" parameterType="RealTimeData">-->
|
||||
<!-- insert into pg_d.t${tagId} VALUES (#{dataTime},NOW, #{val});-->
|
||||
<!-- </insert>-->
|
||||
<select id="selectMaxMinAvgData" parameterType="String" resultType="DataAvdVo">
|
||||
select avg(cast(val as double)) as avg,max(cast(val as double)) as max,min(cast(val as double)) as min
|
||||
from ( select last_row(*)
|
||||
from pg_d.pg_monitor_data
|
||||
<where>
|
||||
tagtypeid=#{tagTypeId} and valueType!='3'
|
||||
</where>
|
||||
group by tagid
|
||||
)
|
||||
|
||||
</select>
|
||||
<select id="getLastData" parameterType="String" resultType="RealDataVo">
|
||||
select last_row(*)
|
||||
from pg_d.t${tagId}
|
||||
</select>
|
||||
<resultMap type="RealDataVo" id="RealDataVoResult">
|
||||
<result property="time" column="last_row(time)" />
|
||||
<result property="createTime" column="last_row(createtime)" />
|
||||
<result property="val" column="last_row(val)" />
|
||||
</resultMap>
|
||||
<select id="selectDataList" parameterType="DataDto" resultType="RealDataVo" >
|
||||
select last_row(time,createTime,val),tagid from pg_d.pg_monitor_data
|
||||
<where>
|
||||
time>=now-1d
|
||||
<if test="tagId != null and tagId != ''"> AND tagid=#{tagId}</if>
|
||||
<if test="deviceId != null and deviceId != ''"> AND deviceid=#{deviceId}</if>
|
||||
<if test="buildingId != null and buildingId != ''"> AND buildingId=#{buildingId}</if>
|
||||
<if test="tagTypeId != null and tagTypeId != ''"> AND tagTypeId=#{tagTypeId}</if>
|
||||
</where>
|
||||
group by tagid
|
||||
</select>
|
||||
<select id="getHistoryDataList" parameterType="String" resultType="RealDataVo">
|
||||
select time,createTime,val,tagId from pg_d.t${tagId}
|
||||
<where>
|
||||
time >= #{startTime} and time <= #{endTime}
|
||||
</where>
|
||||
</select>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user