mirror of
https://github.com/luoye663/e5.git
synced 2024-12-25 19:28:49 +00:00
backup
This commit is contained in:
parent
affb7b3de4
commit
9e3aeaac3c
35
pom.xml
35
pom.xml
@ -103,6 +103,12 @@
|
||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||
<version>3.4.1</version>
|
||||
</dependency>
|
||||
<!--多数据源-->
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>dynamic-datasource-spring-boot-starter</artifactId>
|
||||
<version>3.4.1</version>
|
||||
</dependency>
|
||||
<!--Mybatis plus代码生成器-->
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
@ -124,7 +130,7 @@
|
||||
<dependency>
|
||||
<groupId>com.squareup.okhttp3</groupId>
|
||||
<artifactId>okhttp</artifactId>
|
||||
<version>3.10.0</version>
|
||||
<version>3.14.9</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
@ -151,6 +157,32 @@
|
||||
<version>RELEASE</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/com.alibaba/fastjson -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<version>1.2.76</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.h2database</groupId>
|
||||
<artifactId>h2</artifactId>
|
||||
<version>1.4.200</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
||||
<!--<dependency>
|
||||
<groupId>com.taosdata.jdbc</groupId>
|
||||
<artifactId>taos-jdbcdriver</artifactId>
|
||||
<version>2.0.33</version>
|
||||
</dependency>-->
|
||||
|
||||
<dependency>
|
||||
<groupId>com.influxdb</groupId>
|
||||
<artifactId>influxdb-client-java</artifactId>
|
||||
<version>2.0.0</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!--webflux依赖-->
|
||||
<!--<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
@ -171,6 +203,7 @@
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<version>2.5.2</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
|
24
src/main/java/io/qyi/e5/bean/influx2/InfluxdbConfig.java
Normal file
24
src/main/java/io/qyi/e5/bean/influx2/InfluxdbConfig.java
Normal file
@ -0,0 +1,24 @@
|
||||
package io.qyi.e5.bean.influx2;
|
||||
|
||||
import com.influxdb.LogLevel;
|
||||
import com.influxdb.client.InfluxDBClient;
|
||||
import com.influxdb.client.InfluxDBClientFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
public class InfluxdbConfig {
|
||||
@Value("${spring.influx.url:''}")
|
||||
private String influxDBUrl;
|
||||
@Value("${spring.influx.token:''}")
|
||||
private String token;
|
||||
|
||||
@Bean
|
||||
public InfluxDBClient influxDBClient() {
|
||||
InfluxDBClient influxDBClient = InfluxDBClientFactory.create(influxDBUrl, token.toCharArray());
|
||||
influxDBClient.setLogLevel(LogLevel.BASIC);
|
||||
return influxDBClient;
|
||||
}
|
||||
|
||||
}
|
@ -64,7 +64,7 @@ public class Start {
|
||||
|
||||
}
|
||||
|
||||
@Scheduled(cron = "0 0/1 * * * ? ")
|
||||
// @Scheduled(cron = "0 0/1 * * * ? ")
|
||||
private void distributeTask() {
|
||||
List<Outlook> runOutlookList = outlookService.findRunOutlookList();
|
||||
CountDownLatch cdl = new CountDownLatch(runOutlookList.size());
|
||||
|
@ -2,6 +2,11 @@ package io.qyi.e5.outlook_log.controller;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.influxdb.client.InfluxDBClient;
|
||||
import com.influxdb.client.WriteApi;
|
||||
import com.influxdb.client.WriteOptions;
|
||||
import com.influxdb.client.domain.WritePrecision;
|
||||
import com.influxdb.client.write.Point;
|
||||
import io.qyi.e5.bean.result.Result;
|
||||
import io.qyi.e5.config.security.UsernamePasswordAuthenticationToken;
|
||||
import io.qyi.e5.outlook.service.IOutlookService;
|
||||
@ -21,6 +26,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
@ -45,6 +51,15 @@ public class OutlookLogController {
|
||||
@Autowired
|
||||
IOutlookService outlookService;
|
||||
|
||||
@Autowired
|
||||
InfluxDBClient influxDBClient;
|
||||
@Value("${spring.influx.org:''}")
|
||||
private String org;
|
||||
|
||||
@Value("${spring.influx.bucket:''}")
|
||||
private String bucket;
|
||||
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
@Value("${page.size}")
|
||||
@ -58,7 +73,8 @@ public class OutlookLogController {
|
||||
|
||||
QueryWrapper<OutlookLog> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("github_id", github_id).eq("outlook_id", outlookId).orderByAsc("call_time");
|
||||
List<OutlookLog> list = outlookLogService.list(queryWrapper);
|
||||
|
||||
List<OutlookLog> list = outlookLogService.findAllList(github_id, outlookId);
|
||||
Iterator<OutlookLog> iterator = list.iterator();
|
||||
List<LogVo> logVo = new LinkedList<>();
|
||||
while (iterator.hasNext()) {
|
||||
@ -70,4 +86,20 @@ public class OutlookLogController {
|
||||
return ResultUtil.success(logVo);
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/save")
|
||||
public String save(){
|
||||
Point point = Point.measurement("e5s")
|
||||
.addTag("githubud", "22121")
|
||||
.addField("call_time", "11111")
|
||||
.addField("call_time2", "222222")
|
||||
.addField("call_time3", "3333333")
|
||||
.time(Instant.now().toEpochMilli(), WritePrecision.MS);
|
||||
|
||||
try (WriteApi writeApi = influxDBClient.getWriteApi()) {
|
||||
writeApi.writePoint(bucket, org, point);
|
||||
}
|
||||
return "ok";
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
package io.qyi.e5.outlook_log.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.sql.Timestamp;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
@ -38,7 +40,7 @@ public class OutlookLog implements Serializable {
|
||||
/**
|
||||
* 调用时间
|
||||
*/
|
||||
private Integer callTime;
|
||||
private Timestamp callTime;
|
||||
|
||||
/**
|
||||
* 调用结果
|
||||
|
@ -2,6 +2,10 @@ package io.qyi.e5.outlook_log.mapper;
|
||||
|
||||
import io.qyi.e5.outlook_log.entity.OutlookLog;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@ -13,4 +17,8 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
*/
|
||||
public interface OutlookLogMapper extends BaseMapper<OutlookLog> {
|
||||
|
||||
@Select("select * from e5.d_#{githubId}_#{outlookId}")
|
||||
List<OutlookLog> findAllList(@Param("githubId") int githubId,@Param("outlookId") int outlookId);
|
||||
|
||||
|
||||
}
|
||||
|
@ -3,6 +3,8 @@ package io.qyi.e5.outlook_log.service;
|
||||
import io.qyi.e5.outlook_log.entity.OutlookLog;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
@ -14,4 +16,6 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
||||
public interface IOutlookLogService extends IService<OutlookLog> {
|
||||
void addLog(int githubId,int outlookId, String msg,int result,String original_msg);
|
||||
int deleteInfo(int github_id);
|
||||
|
||||
List<OutlookLog> findAllList(int githubId, int outlookId);
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package io.qyi.e5.outlook_log.service.impl;
|
||||
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import io.qyi.e5.outlook_log.entity.OutlookLog;
|
||||
import io.qyi.e5.outlook_log.mapper.OutlookLogMapper;
|
||||
@ -7,6 +8,8 @@ import io.qyi.e5.outlook_log.service.IOutlookLogService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
@ -16,6 +19,7 @@ import org.springframework.stereotype.Service;
|
||||
* @since 2020-03-03
|
||||
*/
|
||||
@Service
|
||||
@DS("td")
|
||||
public class OutlookLogServiceImpl extends ServiceImpl<OutlookLogMapper, OutlookLog> implements IOutlookLogService {
|
||||
@Override
|
||||
public void addLog(int githubId,int outlookId, String msg, int result,String original_msg) {
|
||||
@ -23,7 +27,7 @@ public class OutlookLogServiceImpl extends ServiceImpl<OutlookLogMapper, Outlook
|
||||
outlookLog.setGithubId(githubId)
|
||||
.setOutlookId(outlookId)
|
||||
.setResult(result)
|
||||
.setCallTime((int) (System.currentTimeMillis() / 1000))
|
||||
// .setCallTime((int) (System.currentTimeMillis() / 1000))
|
||||
.setMsg(msg)
|
||||
.setOriginalMsg(original_msg);
|
||||
|
||||
@ -36,4 +40,9 @@ public class OutlookLogServiceImpl extends ServiceImpl<OutlookLogMapper, Outlook
|
||||
outlookLogQueryWrapper.eq("github_id", github_id);
|
||||
return baseMapper.delete(outlookLogQueryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OutlookLog> findAllList(int githubId, int outlookId) {
|
||||
return baseMapper.findAllList(githubId, outlookId);
|
||||
}
|
||||
}
|
||||
|
22
src/test/java/influxdb2Test.java
Normal file
22
src/test/java/influxdb2Test.java
Normal file
@ -0,0 +1,22 @@
|
||||
import io.qyi.e5.bean.influx2.InfluxdbConfig;
|
||||
import io.qyi.e5.outlook_log.service.IOutlookLogService;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
|
||||
public class influxdb2Test {
|
||||
|
||||
@InjectMocks
|
||||
InfluxdbConfig influxdbConfig;
|
||||
|
||||
@Mock
|
||||
IOutlookLogService outlookLogService;
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void test1(){
|
||||
// outlookLogService.findAllList(1000, 2000);
|
||||
influxdbConfig.influxDBClient();
|
||||
}
|
||||
}
|
13
src/test/java/io/qyi/e5/E5ApplicationTest.java
Normal file
13
src/test/java/io/qyi/e5/E5ApplicationTest.java
Normal file
@ -0,0 +1,13 @@
|
||||
package io.qyi.e5;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class E5ApplicationTest {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(E5ApplicationTest.class, args);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user