dev.data.processing.dataTreating
parent
1e668ce238
commit
0c0d9fca3c
|
@ -67,35 +67,49 @@
|
|||
<artifactId>mysql-connector-j</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- MuYu Common DataSource -->
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>cloud-common-datasource</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- MuYu Common DataScope -->
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>cloud-common-datascope</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- MuYu Common Log -->
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>cloud-common-log</artifactId>
|
||||
<groupId>org.apache.iotdb</groupId>
|
||||
<artifactId>iotdb-jdbc</artifactId>
|
||||
<version>0.12.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>druid-spring-boot-starter</artifactId>
|
||||
<version>1.1.9</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 接口模块 -->
|
||||
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>cloud-common-api-doc</artifactId>
|
||||
<groupId>org.mybatis</groupId>
|
||||
<artifactId>mybatis-spring</artifactId>
|
||||
<version>3.0.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||
<version>3.5.5</version>
|
||||
</dependency>
|
||||
|
||||
<!-- XllJob定时任务 -->
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>cloud-common-xxl</artifactId>
|
||||
</dependency>
|
||||
<!-- <!– Druid –>-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>com.alibaba</groupId>-->
|
||||
<!-- <artifactId>druid-spring-boot-3-starter</artifactId>-->
|
||||
<!-- <version>${druid.version}</version>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
<!-- <!– Dynamic DataSource –>-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>com.baomidou</groupId>-->
|
||||
<!-- <artifactId>dynamic-datasource-spring-boot3-starter</artifactId>-->
|
||||
<!-- <version>${dynamic-ds.version}</version>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
|
|
@ -16,10 +16,8 @@ import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
|||
* @FilePath: com.muyu.data.processing
|
||||
*/
|
||||
|
||||
@EnableCustomConfig
|
||||
//@EnableCustomSwagger2
|
||||
@EnableMyFeignClients
|
||||
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
|
||||
|
||||
@SpringBootApplication
|
||||
public class MyDataApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(MyDataApplication.class, args);
|
||||
|
|
|
@ -0,0 +1,160 @@
|
|||
package com.muyu.data.processing.controller;
|
||||
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.data.processing.domain.IotDbData;
|
||||
import com.muyu.data.processing.service.DataProcessingService;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 数据处理控制层
|
||||
*
|
||||
* @Author: 胡杨
|
||||
* @Name: DataProcessing
|
||||
* @Description: 数据处理控制层
|
||||
* @CreatedDate: 2024/9/28 下午3:53
|
||||
* @FilePath: com.muyu.data.processing.controller
|
||||
*/
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/DataProcessing")
|
||||
public class DataProcessingController {
|
||||
@Resource
|
||||
private DataProcessingService service;
|
||||
|
||||
|
||||
|
||||
@RequestMapping(value = "/createCarData", method = RequestMethod.POST)
|
||||
// @Transactional(rollbackFor = Exception.class)
|
||||
public Result createCarData(@RequestBody IotDbData data) {
|
||||
try {
|
||||
data.setTimestamp(System.currentTimeMillis());
|
||||
data.setCreateTime(new Date());
|
||||
Integer v = service.createCarData(data);
|
||||
if (v == -1) {
|
||||
return Result.success(v);
|
||||
} else {
|
||||
return Result.error(false);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.info("创建车辆报文记录失败!" + e);
|
||||
return Result.error(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 更新操作 其实也是插入操作 时间戳相同 只和时间戳相关
|
||||
* @param data
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/updateCarData", method = RequestMethod.POST)
|
||||
public Result updateCarData(@RequestBody IotDbData data) {
|
||||
try {
|
||||
data.setTimestamp(System.currentTimeMillis());
|
||||
data.setCreateTime(new Date());
|
||||
Integer v = service.updateCarData(data);
|
||||
if (v == -1) {
|
||||
return Result.success(v);
|
||||
} else {
|
||||
return Result.error(false);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.info("更新车辆报文记录失败!" + e);
|
||||
return Result.error(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 删除操作 要将时间戳的加号变成%2B
|
||||
* @param timestamp
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/deleteCarData", method = RequestMethod.GET)
|
||||
public Result deleteCarData(String timestamp) {
|
||||
try {
|
||||
Integer v = service.deleteCarData(timestamp);
|
||||
if (v == -1) {
|
||||
return Result.success(v);
|
||||
} else {
|
||||
return Result.error(false);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.info("删除车辆报文记录失败!" + e);
|
||||
return Result.error(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 创建组 也就是相当于数据库
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/createCarDataGroup", method = RequestMethod.POST)
|
||||
public Result createCarDataGroup() {
|
||||
try {
|
||||
Integer v = service.createCarDataGroup();
|
||||
if (v > 0) {
|
||||
return Result.success(v);
|
||||
} else {
|
||||
return Result.error(false);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.info("创建车辆报文记录组失败!" + e);
|
||||
return Result.error(false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询所有车辆报文记录数据
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/queryCarData", method = RequestMethod.GET)
|
||||
public Result queryCarData() {
|
||||
try {
|
||||
List<IotDbData> v = service.queryCarData();
|
||||
if (v.size() > 0) {
|
||||
v.forEach(x -> {
|
||||
System.out.println(x.toString());
|
||||
});
|
||||
return Result.success(v);
|
||||
} else {
|
||||
return Result.error(false);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.info("查询车辆报文记录组失败!" + e);
|
||||
return Result.error(false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看数据库有多少组
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/selectStorageGroup", method = RequestMethod.GET)
|
||||
public Result selectStorageGroup() {
|
||||
try {
|
||||
List<String> v = service.selectStorageGroup();
|
||||
if (v.size() > 0) {
|
||||
v.forEach(x -> {
|
||||
System.out.println("group------------------" + x.toString());
|
||||
});
|
||||
return Result.success(v);
|
||||
} else {
|
||||
return Result.error(false);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.info("查询组失败!" + e);
|
||||
return Result.error(false);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
package com.muyu.data.processing.domain;
|
||||
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import lombok.*;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 报文信息 时序实体类
|
||||
*
|
||||
* @Author: 胡杨
|
||||
* @Name: DataProcessing
|
||||
* @Description: 报文信息 时序实体类
|
||||
* @CreatedDate: 2024/9/28 下午3:48
|
||||
* @FilePath: com.muyu.data.processing.domain
|
||||
*/
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@ToString
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class IotDbData extends BaseEntity {
|
||||
private long timestamp;
|
||||
|
||||
private String vin;
|
||||
|
||||
private String key;
|
||||
private String label;
|
||||
private String value;
|
||||
private String type;
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -2,7 +2,6 @@ package com.muyu.data.processing.kafka;
|
|||
|
||||
|
||||
import com.muyu.common.kafka.constants.KafkaConstants;
|
||||
import io.swagger.v3.oas.annotations.servers.Server;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.kafka.annotation.KafkaListener;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
package com.muyu.data.processing.mapper;
|
||||
|
||||
import com.muyu.data.processing.domain.IotDbData;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 数据处理持久层
|
||||
*
|
||||
* @Author: 胡杨
|
||||
* @Name: DataPeocessingMapper
|
||||
* @Description: 数据处理持久层
|
||||
* @CreatedDate: 2024/9/28 下午3:47
|
||||
* @FilePath: com.muyu.data.processing.mapper
|
||||
*/
|
||||
|
||||
@Repository
|
||||
@Mapper
|
||||
public interface DataProcessingMapper{
|
||||
|
||||
Integer createCarData(IotDbData data);
|
||||
|
||||
Integer updateCarData(IotDbData data);
|
||||
|
||||
Integer deleteCarData(String timestamp);
|
||||
|
||||
Integer createCarDataGroup();
|
||||
|
||||
Integer createCarDataGroupElement();
|
||||
|
||||
// List<DataProcessing> queryCarData();
|
||||
|
||||
List<String> selectStorageGroup();
|
||||
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
package com.muyu.data.processing.service;
|
||||
|
||||
|
||||
import com.muyu.data.processing.domain.IotDbData;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 数据处理业务层
|
||||
*
|
||||
* @Author: 胡杨
|
||||
* @Name: DataProcessing
|
||||
* @Description: 数据处理业务层
|
||||
* @CreatedDate: 2024/9/28 下午3:52
|
||||
* @FilePath: com.muyu.data.processing.server
|
||||
*/
|
||||
|
||||
public interface DataProcessingService{
|
||||
/**
|
||||
* 创建车辆报文记录
|
||||
*
|
||||
* @param data 数据
|
||||
* @return {@link Integer }
|
||||
*/
|
||||
Integer createCarData(IotDbData data);
|
||||
|
||||
/**
|
||||
* 更新车辆报文记录
|
||||
*
|
||||
* @param data 数据
|
||||
* @return {@link Integer }
|
||||
*/
|
||||
Integer updateCarData(IotDbData data);
|
||||
|
||||
/**
|
||||
* 删除车辆报文记录
|
||||
*
|
||||
* @param timestamp 时间戳
|
||||
* @return {@link Integer }
|
||||
*/
|
||||
Integer deleteCarData(String timestamp);
|
||||
|
||||
/**
|
||||
* 创建车辆报文记录组
|
||||
*
|
||||
* @return {@link Integer }
|
||||
*/
|
||||
Integer createCarDataGroup();
|
||||
|
||||
/**
|
||||
* 查询顺序
|
||||
*
|
||||
* @return {@link List }<{@link IotDbData }>
|
||||
*/
|
||||
List<IotDbData> queryCarData();
|
||||
/**
|
||||
* 选择存储组
|
||||
*
|
||||
* @return {@link List }<{@link String }>
|
||||
*/
|
||||
List<String> selectStorageGroup();
|
||||
|
||||
}
|
|
@ -0,0 +1,70 @@
|
|||
package com.muyu.data.processing.service.impl;
|
||||
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import com.muyu.data.processing.domain.IotDbData;
|
||||
import org.springframework.stereotype.Service;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import com.muyu.data.processing.mapper.DataProcessingMapper;
|
||||
import com.muyu.data.processing.service.DataProcessingService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 数据处理实现层
|
||||
*
|
||||
* @Author: 胡杨
|
||||
* @Name: DataProcessing
|
||||
* @Description: 数据处理实现层
|
||||
* @CreatedDate: 2024/9/28 下午3:52
|
||||
* @FilePath: com.muyu.data.processing.server.impl
|
||||
*/
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class DataProcessingServiceImpl implements DataProcessingService {
|
||||
@Resource
|
||||
private DataProcessingMapper mapper;
|
||||
|
||||
@Override
|
||||
public Integer createCarData(IotDbData data) {
|
||||
return mapper.createCarData(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer updateCarData(IotDbData data) {
|
||||
return mapper.updateCarData(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer deleteCarData(String timestamp) {
|
||||
return mapper.deleteCarData(timestamp);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer createCarDataGroup() {
|
||||
try {
|
||||
Integer flag = mapper.createCarDataGroup();
|
||||
Integer flagEle = mapper.createCarDataGroupElement();
|
||||
System.out.println("\n\t执行sql数量为{}" + flagEle);
|
||||
return flagEle;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IotDbData> queryCarData() {
|
||||
// return mapper.queryCarData();
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> selectStorageGroup() {
|
||||
return mapper.selectStorageGroup();
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -11,6 +11,22 @@ nacos:
|
|||
# SPRING_AMQP_DESERIALIZATION_TRUST_ALL=true spring.amqp.deserialization.trust.all
|
||||
# Spring
|
||||
spring:
|
||||
datasource:
|
||||
username: root
|
||||
password: root
|
||||
driver-class-name: org.apache.iotdb.jdbc.IoTDBDriver
|
||||
url: jdbc:iotdb://47.116.173.119:6667/
|
||||
initial-size: 5
|
||||
min-idle: 10
|
||||
max-active: 20
|
||||
max-wait: 60000
|
||||
remove-abandoned: true
|
||||
remove-abandoned-timeout: 30
|
||||
time-between-eviction-runs-millis: 60000
|
||||
min-evictable-idle-time-millis: 300000
|
||||
test-while-idle: false
|
||||
test-on-borrow: false
|
||||
test-on-return: false
|
||||
amqp:
|
||||
deserialization:
|
||||
trust:
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
<?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.muyu.data.processing.mapper.DataProcessingMapper">
|
||||
|
||||
<insert id="createCarData" parameterType="com.muyu.data.processing.domain.IotDbData">
|
||||
insert into root.one.data(timestamp, CarData_id, CarData_num, CarData_name,create_time) values(#{timestamp},#{CarDataId},#{CarDataNum},#{CarDataName},#{createTime});
|
||||
</insert>
|
||||
<select id="selectStorageGroup" resultType="java.lang.String">
|
||||
show storage group
|
||||
</select>
|
||||
<delete id="deleteCarData" parameterType="java.lang.String">
|
||||
delete from root.one.data where timestamp = ${timestamp};
|
||||
</delete>
|
||||
|
||||
<insert id="updateCarData">
|
||||
insert into root.one.data(timestamp, CarData_id, CarData_num, CarData_name,create_time) values(2021-11-24T18:28:20.689+08:00,#{CarDataId},#{CarDataNum},#{CarDataName},#{createTime});
|
||||
</insert>
|
||||
|
||||
<update id="createCarDataGroup">
|
||||
SET STORAGE GROUP TO root.one.data
|
||||
</update>
|
||||
<update id="createCarDataGroupElement">
|
||||
CREATE TIMESERIES root.one.data.CarData_num WITH DATATYPE=INT32, ENCODING=PLAIN, COMPRESSOR=SNAPPY;
|
||||
</update>
|
||||
|
||||
</mapper>
|
Loading…
Reference in New Issue