31 changed files with 1394 additions and 0 deletions
@ -0,0 +1,51 @@
|
||||
HELP.md |
||||
target/ |
||||
!.mvn/wrapper/maven-wrapper.jar |
||||
!.mvn/wrapper/maven-wrapper.properties |
||||
!**/src/main/**/target/ |
||||
!**/src/test/**/target/ |
||||
|
||||
### STS ### |
||||
.apt_generated |
||||
.classpath |
||||
.factorypath |
||||
.project |
||||
.settings |
||||
.springBeans |
||||
.sts4-cache |
||||
.log |
||||
*.class |
||||
|
||||
### IntelliJ IDEA ### |
||||
.idea |
||||
*.iws |
||||
*.iml |
||||
*.ipr |
||||
|
||||
### NetBeans ### |
||||
/nbproject/private/ |
||||
/nbbuild/ |
||||
/dist/ |
||||
/nbdist/ |
||||
/.nb-gradle/ |
||||
build/ |
||||
!**/src/main/**/build/ |
||||
!**/src/test/**/build/ |
||||
|
||||
### VS Code ### |
||||
.vscode/ |
||||
|
||||
# windows # |
||||
Thumbs.db |
||||
|
||||
# Mac # |
||||
.DS_Store |
||||
|
||||
# Package Files # |
||||
*.jar |
||||
*.war |
||||
*.ear |
||||
|
||||
logs |
||||
|
||||
rebel.xml |
@ -0,0 +1,27 @@
|
||||
FROM adoptopenjdk/openjdk8-openj9:alpine-slim |
||||
|
||||
MAINTAINER dev@qingniaoiiot.com |
||||
|
||||
RUN echo "#aliyun" > /etc/apk/repositories |
||||
RUN echo "https://mirrors.aliyun.com/alpine/v3.12/main/" >> /etc/apk/repositories |
||||
RUN echo "https://mirrors.aliyun.com/alpine/v3.12/community/" >> /etc/apk/repositories |
||||
RUN apk update |
||||
|
||||
RUN apk add --no-cache tzdata |
||||
|
||||
ENV TIME_ZONE="Asia/Shanghai" |
||||
|
||||
RUN set -xe \ |
||||
&& apk --no-cache add ttf-dejavu fontconfig |
||||
|
||||
RUN mkdir -p /snhub |
||||
|
||||
WORKDIR /snhub |
||||
|
||||
RUN ln -snf /usr/share/zoneinfo/$TIME_ZONE /etc/localtime && echo '$TIME_ZONE' > /etc/timezone |
||||
|
||||
EXPOSE 9093 |
||||
|
||||
ADD ./target/qn-sn-hub.jar ./app.jar |
||||
|
||||
ENTRYPOINT ["java", "-Djava.security.egd=file:/dev/./urandom", "-jar", "app.jar"] |
@ -0,0 +1,179 @@
|
||||
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd"> |
||||
<modelVersion>4.0.0</modelVersion> |
||||
<parent> |
||||
<groupId>org.springframework.boot</groupId> |
||||
<artifactId>spring-boot-starter-parent</artifactId> |
||||
<version>2.7.1</version> |
||||
<relativePath/> <!-- lookup parent from repository --> |
||||
</parent> |
||||
|
||||
<groupId>com.sinenux</groupId> |
||||
<artifactId>qn-ys-hub</artifactId> |
||||
<version>1.0.0</version> |
||||
<name>SNHub</name> |
||||
<description>qn-ys-hub</description> |
||||
|
||||
<properties> |
||||
<hub.project.name>qn-ys-hub</hub.project.name> |
||||
|
||||
<java.version>8</java.version> |
||||
<maven.plugin.version>3.8.1</maven.plugin.version> |
||||
|
||||
<!-- 推荐使用Harbor --> |
||||
<harbor.library>qn-ys-hub</harbor.library> |
||||
<harbor.tag>1.0.0</harbor.tag> |
||||
|
||||
<docker.serverId>harbor</docker.serverId> |
||||
<docker.registry.url>192.168.1.251</docker.registry.url> |
||||
<!-- <docker.registry.url>192.168.40.203:8089</docker.registry.url>--> |
||||
<docker.registry.host>http://${docker.registry.url}:2375</docker.registry.host> |
||||
<docker.username>admin</docker.username> |
||||
<docker.plugin.version>1.4.13</docker.plugin.version> |
||||
<docker.username>admin</docker.username> |
||||
<docker.password>Qingniao13542</docker.password> |
||||
</properties> |
||||
|
||||
<dependencies> |
||||
<dependency> |
||||
<groupId>org.springframework.boot</groupId> |
||||
<artifactId>spring-boot-starter-web</artifactId> |
||||
</dependency> |
||||
|
||||
<dependency> |
||||
<groupId>org.springframework.boot</groupId> |
||||
<artifactId>spring-boot-starter-test</artifactId> |
||||
<scope>test</scope> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>org.projectlombok</groupId> |
||||
<artifactId>lombok</artifactId> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>mysql</groupId> |
||||
<artifactId>mysql-connector-java</artifactId> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>com.dream-orm</groupId> |
||||
<artifactId>dream-orm-spring-boot-starter</artifactId> |
||||
<version>1.2.6</version> |
||||
</dependency> |
||||
|
||||
<!-- fastjson --> |
||||
<dependency> |
||||
<groupId>com.alibaba</groupId> |
||||
<artifactId>fastjson</artifactId> |
||||
<version>2.0.25</version> |
||||
</dependency> |
||||
<!-- <dependency>--> |
||||
<!-- <groupId>com.bluebird</groupId>--> |
||||
<!-- <artifactId>hulk-starter-http</artifactId>--> |
||||
<!-- <version>1.2.2.RELEASE</version>--> |
||||
<!-- </dependency>--> |
||||
<!-- mongo --> |
||||
<dependency> |
||||
<groupId>com.bluebird</groupId> |
||||
<artifactId>hulk-starter-mongo</artifactId> |
||||
<version>1.2.2.RELEASE</version> |
||||
<exclusions> |
||||
<exclusion> |
||||
<groupId>com.bluebird</groupId> |
||||
<artifactId>hulk-core-launch</artifactId> |
||||
</exclusion> |
||||
</exclusions> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>com.baomidou</groupId> |
||||
<artifactId>mybatis-plus-boot-starter</artifactId> |
||||
<version>3.5.3.2</version> |
||||
</dependency> |
||||
<!-- <dependency>--> |
||||
<!-- <groupId>com.bluebird</groupId>--> |
||||
<!-- <artifactId>hulk-starter-mybatis</artifactId>--> |
||||
<!-- <version>1.2.2.RELEASE</version>--> |
||||
<!-- </dependency>--> |
||||
</dependencies> |
||||
|
||||
<build> |
||||
<finalName>${hub.project.name}</finalName> |
||||
<plugins> |
||||
<plugin> |
||||
<groupId>org.springframework.boot</groupId> |
||||
<artifactId>spring-boot-maven-plugin</artifactId> |
||||
</plugin> |
||||
<plugin> |
||||
<groupId>com.spotify</groupId> |
||||
<artifactId>dockerfile-maven-plugin</artifactId> |
||||
<version>${docker.plugin.version}</version> |
||||
<configuration> |
||||
<username>${docker.username}</username> |
||||
<password>${docker.password}</password> |
||||
<repository>${docker.registry.url}/${harbor.library}/${project.artifactId}</repository> |
||||
<tag>${harbor.tag}</tag> |
||||
<useMavenSettingsForAuth>true</useMavenSettingsForAuth> |
||||
<buildArgs> |
||||
<JAR_FILE>target/${project.build.finalName}.jar</JAR_FILE> |
||||
</buildArgs> |
||||
<skip>false</skip> |
||||
</configuration> |
||||
</plugin> |
||||
<plugin> |
||||
<groupId>org.apache.maven.plugins</groupId> |
||||
<artifactId>maven-compiler-plugin</artifactId> |
||||
<version>${maven.plugin.version}</version> |
||||
<executions> |
||||
<execution> |
||||
<id>compile</id> |
||||
<phase>compile</phase> |
||||
<goals> |
||||
<goal>compile</goal> |
||||
</goals> |
||||
</execution> |
||||
<execution> |
||||
<id>testCompile</id> |
||||
<phase>test-compile</phase> |
||||
<goals> |
||||
<goal>testCompile</goal> |
||||
</goals> |
||||
</execution> |
||||
</executions> |
||||
</plugin> |
||||
</plugins> |
||||
|
||||
<resources> |
||||
<!-- 扫描src/main/java下所有xx.xml文件 --> |
||||
<resource> |
||||
<directory>src/main/java</directory> |
||||
<includes> |
||||
<include>**/*.xml</include> |
||||
</includes> |
||||
</resource> |
||||
<!-- 扫描resources下所有资源 --> |
||||
<resource> |
||||
<directory>src/main/resources</directory> |
||||
</resource> |
||||
</resources> |
||||
</build> |
||||
|
||||
<repositories> |
||||
<repository> |
||||
<id>aliyun-repos</id> |
||||
<url>https://maven.aliyun.com/nexus/content/groups/public/</url> |
||||
<snapshots> |
||||
<enabled>false</enabled> |
||||
</snapshots> |
||||
</repository> |
||||
</repositories> |
||||
|
||||
<pluginRepositories> |
||||
<pluginRepository> |
||||
<id>aliyun-plugin</id> |
||||
<url>https://maven.aliyun.com/nexus/content/groups/public/</url> |
||||
<snapshots> |
||||
<enabled>false</enabled> |
||||
</snapshots> |
||||
</pluginRepository> |
||||
</pluginRepositories> |
||||
|
||||
</project> |
@ -0,0 +1,39 @@
|
||||
package com.sinenux.yshub; |
||||
|
||||
import com.dream.boot.bean.ConfigurationBean; |
||||
import com.dream.drive.listener.DebugListener; |
||||
import com.dream.flex.annotation.FlexAPT; |
||||
import com.dream.system.core.listener.Listener; |
||||
import org.mybatis.spring.annotation.MapperScan; |
||||
import org.springframework.boot.SpringApplication; |
||||
import org.springframework.boot.autoconfigure.SpringBootApplication; |
||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; |
||||
import org.springframework.context.annotation.Bean; |
||||
import org.springframework.core.env.ConfigurableEnvironment; |
||||
import org.springframework.core.env.StandardEnvironment; |
||||
|
||||
import java.util.Arrays; |
||||
import java.util.Collections; |
||||
import java.util.List; |
||||
|
||||
@MapperScan("com.sinenux.yshub.mapper") |
||||
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class}) |
||||
public class HubApplication { |
||||
|
||||
public static void main(String[] args) { |
||||
// 创建一个SpringApplication实例
|
||||
SpringApplication app = new SpringApplication(HubApplication.class); |
||||
|
||||
// 读取环境变量,使用spring boot的规则
|
||||
ConfigurableEnvironment environment = new StandardEnvironment(); |
||||
|
||||
// 检查是否存在名为 "spring.profiles.active" 的环境属性,如果不存在,则设置为 "dev"
|
||||
if (environment.getProperty("spring.profiles.active") == null) { |
||||
app.setDefaultProperties(Collections.singletonMap("spring.profiles.active", "dev")); |
||||
} |
||||
|
||||
// 启动应用程序
|
||||
app.run(args); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,43 @@
|
||||
package com.sinenux.yshub.config; |
||||
|
||||
import com.bluebird.core.tool.utils.Func; |
||||
import com.bluebird.core.tool.utils.WebUtil; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.jetbrains.annotations.NotNull; |
||||
import org.springframework.web.servlet.HandlerInterceptor; |
||||
|
||||
import javax.servlet.http.HttpServletRequest; |
||||
import javax.servlet.http.HttpServletResponse; |
||||
import java.util.Arrays; |
||||
import java.util.List; |
||||
|
||||
@Slf4j |
||||
public class IpWhitelistInterceptor implements HandlerInterceptor { |
||||
|
||||
// private final List<String> allowedIpList = Arrays.asList("127.0.0.1", "192.168.1.100", "192.168.1.101");
|
||||
private final String ips; |
||||
|
||||
public IpWhitelistInterceptor(String ips) { |
||||
this.ips = ips; |
||||
} |
||||
|
||||
@Override |
||||
public boolean preHandle(HttpServletRequest request, @NotNull HttpServletResponse response, @NotNull Object handler) { |
||||
if (Func.isBlank(ips) || Func.equals("0.0.0.0", ips)) { |
||||
return true; |
||||
} |
||||
log.info("SN-HUB ===================== IP白名单 为 {}", ips); |
||||
|
||||
String[] ipArray = Func.split(ips, ","); |
||||
List<String> allowedIpList = Arrays.asList(ipArray); |
||||
|
||||
String requestIp = WebUtil.getIP(request); |
||||
log.info("SN-HUB ===================== 请求IP 为 {}", requestIp); |
||||
if (!allowedIpList.contains(requestIp)) { |
||||
response.setStatus(HttpServletResponse.SC_FORBIDDEN); |
||||
return false; // 不允许访问
|
||||
} |
||||
return true; // 允许访问
|
||||
} |
||||
|
||||
} |
@ -0,0 +1,29 @@
|
||||
package com.sinenux.yshub.config; |
||||
|
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.springframework.beans.factory.annotation.Value; |
||||
import org.springframework.context.annotation.Bean; |
||||
import org.springframework.context.annotation.Configuration; |
||||
import org.springframework.data.mongodb.core.MongoTemplate; |
||||
import org.springframework.data.mongodb.core.SimpleMongoClientDatabaseFactory; |
||||
|
||||
@Slf4j |
||||
@Configuration |
||||
public class MongoConfig { |
||||
|
||||
@Value("${MONGODB_URI}") |
||||
private String mongodbUri; |
||||
|
||||
@Bean |
||||
public SimpleMongoClientDatabaseFactory mongoDbFactory() { |
||||
log.info("SN-HUB ===================== 获取到的 mongodbUri 为 {}", mongodbUri); |
||||
return new SimpleMongoClientDatabaseFactory(mongodbUri); |
||||
|
||||
} |
||||
|
||||
@Bean |
||||
public MongoTemplate mongoTemplate() { |
||||
return new MongoTemplate(mongoDbFactory()); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,61 @@
|
||||
package com.sinenux.yshub.config; |
||||
|
||||
import com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean; |
||||
import com.bluebird.core.tool.utils.Func; |
||||
import com.dream.drive.factory.DriveDataSourceFactory; |
||||
import com.dream.system.datasource.DataSourceFactory; |
||||
import com.zaxxer.hikari.HikariDataSource; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.apache.ibatis.session.SqlSessionFactory; |
||||
import org.mybatis.spring.annotation.MapperScan; |
||||
import org.mybatis.spring.transaction.SpringManagedTransactionFactory; |
||||
import org.springframework.beans.factory.annotation.Value; |
||||
import org.springframework.context.annotation.Bean; |
||||
import org.springframework.context.annotation.Configuration; |
||||
|
||||
import javax.sql.DataSource; |
||||
import java.sql.SQLException; |
||||
|
||||
@Configuration |
||||
@Slf4j |
||||
@MapperScan("com.sinenux.yshub.mapper") |
||||
public class MysqlConfig { |
||||
@Value("${MYSQL_URL}") |
||||
private String url; |
||||
@Value("${MYSQL_USERNAME}") |
||||
private String username; |
||||
@Value("${MYSQL_PASSWORD}") |
||||
private String password; |
||||
|
||||
@Bean |
||||
public DataSource mySqlDataSource() throws SQLException { |
||||
HikariDataSource dataSource = new HikariDataSource(); |
||||
dataSource.setJdbcUrl(url); |
||||
dataSource.setUsername(username); |
||||
dataSource.setPassword(password); |
||||
dataSource.setDriverClassName("com.mysql.cj.jdbc.Driver"); |
||||
if (Func.isNotEmpty(url)) { |
||||
dataSource.getConnection().close(); |
||||
} |
||||
|
||||
return dataSource; |
||||
} |
||||
|
||||
@Bean |
||||
public SqlSessionFactory sqlSessionFactory(DataSource dataSource) throws Exception { |
||||
MybatisSqlSessionFactoryBean sqlSessionFactory = new MybatisSqlSessionFactoryBean(); |
||||
sqlSessionFactory.setDataSource(dataSource); |
||||
sqlSessionFactory.setTypeAliasesPackage("com.sinenux.snhub.entity"); |
||||
|
||||
sqlSessionFactory.setTransactionFactory(new SpringManagedTransactionFactory()); |
||||
|
||||
return sqlSessionFactory.getObject(); |
||||
} |
||||
|
||||
@Bean |
||||
public DataSourceFactory dataSourceFactory(DataSource dataSource) { |
||||
return new DriveDataSourceFactory(dataSource); |
||||
} |
||||
|
||||
|
||||
} |
@ -0,0 +1,18 @@
|
||||
package com.sinenux.yshub.config; |
||||
|
||||
import org.springframework.beans.factory.annotation.Value; |
||||
import org.springframework.context.annotation.Configuration; |
||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry; |
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; |
||||
|
||||
@Configuration |
||||
public class WebMvcConfig implements WebMvcConfigurer { |
||||
|
||||
@Value("${REQUEST_IPS:0.0.0.0}") |
||||
private String requestIps; |
||||
|
||||
@Override |
||||
public void addInterceptors(InterceptorRegistry registry) { |
||||
registry.addInterceptor(new IpWhitelistInterceptor(requestIps)); |
||||
} |
||||
} |
@ -0,0 +1,13 @@
|
||||
package com.sinenux.yshub.controller; |
||||
|
||||
import lombok.AllArgsConstructor; |
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
import org.springframework.web.bind.annotation.RestController; |
||||
|
||||
@RestController |
||||
@AllArgsConstructor |
||||
@RequestMapping("/demo") |
||||
public class DemoController { |
||||
|
||||
|
||||
} |
@ -0,0 +1,66 @@
|
||||
package com.sinenux.yshub.controller; |
||||
|
||||
import com.bluebird.core.tool.api.R; |
||||
import com.sinenux.yshub.entity.EnterprisePrefix; |
||||
import com.sinenux.yshub.service.IEnterprisePrefixService; |
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import lombok.AllArgsConstructor; |
||||
import org.springframework.web.bind.annotation.GetMapping; |
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
import org.springframework.web.bind.annotation.RestController; |
||||
|
||||
import java.util.List; |
||||
import java.util.Map; |
||||
import java.util.stream.Collectors; |
||||
|
||||
/** |
||||
* 告警记录 控制器 |
||||
* |
||||
* @author wtc |
||||
* @since 2023-05-24 |
||||
*/ |
||||
@RestController |
||||
@AllArgsConstructor |
||||
@RequestMapping("/enterprise/prefix") |
||||
@Api(value = "企业前缀", tags = "企业前缀接口") |
||||
public class EnterprisePrefixController { |
||||
|
||||
private final IEnterprisePrefixService enterprisePrefixService; |
||||
|
||||
/** |
||||
* 企业前缀top10 |
||||
*/ |
||||
@GetMapping("/top") |
||||
@ApiOperation(value = "企业前缀top10", notes = "企业前缀top10") |
||||
public R<List<EnterprisePrefix>> prefixTop() { |
||||
List<EnterprisePrefix> list = enterprisePrefixService.getTop10(); |
||||
return R.data(list); |
||||
} |
||||
|
||||
/** |
||||
* 获取所有企业名称 |
||||
*/ |
||||
@GetMapping("/allName") |
||||
@ApiOperation(value = "所有企业名称", notes = "所有企业名称") |
||||
public R<List<String>> list() { |
||||
List<String> list = enterprisePrefixService.lambdaQuery() |
||||
.select(EnterprisePrefix::getEntName) |
||||
.eq(EnterprisePrefix::getState, 1) |
||||
.list() |
||||
.stream() |
||||
.map(EnterprisePrefix::getEntName) |
||||
.collect(Collectors.toList()); |
||||
return R.data(list); |
||||
} |
||||
|
||||
/** |
||||
* 获取当前注册量,以及昨日注册量,增长量 |
||||
*/ |
||||
@GetMapping("/statistics") |
||||
@ApiOperation(value = "前缀注册量统计", notes = "前缀注册量统计") |
||||
public R<Map<String, Object>> statistics() { |
||||
Map<String, Object> map = enterprisePrefixService.prefixStatistics(); |
||||
return R.data(map); |
||||
} |
||||
} |
@ -0,0 +1,36 @@
|
||||
package com.sinenux.yshub.controller; |
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
||||
import com.bluebird.core.tool.api.R; |
||||
import com.sinenux.yshub.dto.HandleQuery; |
||||
import com.sinenux.yshub.entity.MHandleInfo; |
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import lombok.AllArgsConstructor; |
||||
import org.springframework.web.bind.annotation.GetMapping; |
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
import org.springframework.web.bind.annotation.RestController; |
||||
|
||||
/** |
||||
* 标识 控制器 |
||||
*/ |
||||
@RestController |
||||
@AllArgsConstructor |
||||
@RequestMapping("/handle") |
||||
@Api(value = "标识表", tags = "标识接口") |
||||
public class HandleInfoController { |
||||
|
||||
private final IHandleInfoService handleInfoRepository; |
||||
|
||||
/** |
||||
* 标识列表分页 |
||||
*/ |
||||
@GetMapping("/page") |
||||
@ApiOperation(value = "分页", notes = "传入handleInput") |
||||
public R<Page<MHandleInfo>> page(HandleQuery handleQuery) { |
||||
|
||||
Page<MHandleInfo> page = handleInfoRepository.selectPage(handleQuery); |
||||
return R.data(page); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,45 @@
|
||||
package com.sinenux.yshub.controller; |
||||
|
||||
import com.alibaba.fastjson.JSONArray; |
||||
import com.alibaba.fastjson.JSONObject; |
||||
import com.bluebird.core.tool.api.R; |
||||
import com.dream.jdbc.mapper.JdbcMapper; |
||||
import lombok.AllArgsConstructor; |
||||
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; |
||||
|
||||
/** |
||||
* 超级接口 |
||||
*/ |
||||
@RestController |
||||
@RequestMapping("/super") |
||||
@AllArgsConstructor |
||||
public class MainController { |
||||
private final JdbcMapper jdbcMapper; |
||||
|
||||
@PostMapping("/selectList") |
||||
public R test(@RequestParam String sql) { |
||||
try { |
||||
sql = AESUtil.AESDncode(sql); |
||||
JSONArray jsonArray = new JSONArray(jdbcMapper.queryForList(sql, JSONObject.class)); |
||||
return R.data(jsonArray); |
||||
} catch (Exception e) { |
||||
return R.fail("sql语句错误"); |
||||
} |
||||
} |
||||
|
||||
@PostMapping("/selectOne") |
||||
public R test2(@RequestParam String sql) { |
||||
try { |
||||
sql = AESUtil.AESDncode(sql); |
||||
JSONObject jsonObject = jdbcMapper.queryForObject(sql, JSONObject.class); |
||||
return R.data(jsonObject); |
||||
} catch (Exception e) { |
||||
return R.fail("sql语句错误"); |
||||
|
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,47 @@
|
||||
package com.sinenux.yshub.controller; |
||||
|
||||
import com.bluebird.core.tool.api.R; |
||||
import com.bluebird.core.tool.utils.Func; |
||||
import com.sinenux.yshub.dto.IdentityTemplateQuery; |
||||
import com.sinenux.yshub.entity.IdentityTemplate; |
||||
import com.sinenux.yshub.entity.IdentityTemplateItem; |
||||
import lombok.AllArgsConstructor; |
||||
import org.springframework.web.bind.annotation.GetMapping; |
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
import org.springframework.web.bind.annotation.RestController; |
||||
|
||||
import java.util.Date; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 标识模板 控制器 |
||||
*/ |
||||
@RestController |
||||
@RequestMapping("/template") |
||||
@AllArgsConstructor |
||||
public class TemplateController { |
||||
private final IIdentityTemplateService identityTemplateService; |
||||
private final IIdentityTemplateItemService identityTemplateItemService; |
||||
|
||||
@GetMapping("/list") |
||||
public R test(IdentityTemplateQuery identityTemplate) { |
||||
List<IdentityTemplate> identityTemplates = identityTemplateService.queryContent(identityTemplate); |
||||
return R.data(identityTemplates); |
||||
} |
||||
|
||||
@GetMapping("/list/item") |
||||
public R test2(IdentityTemplateItem identityTemplateItem) { |
||||
List<IdentityTemplateItem> list = identityTemplateService.queryContentItem(identityTemplateItem); |
||||
return R.data(list); |
||||
} |
||||
|
||||
@GetMapping("/list/item/date") |
||||
public R test3(Date startDate, Date endDate) { |
||||
List<IdentityTemplateItem> list = identityTemplateItemService.lambdaQuery() |
||||
.ge(Func.isNotEmpty(startDate), IdentityTemplateItem::getUpdateDate, startDate) |
||||
.le(Func.isNotEmpty(endDate), IdentityTemplateItem::getUpdateDate, endDate) |
||||
.list(); |
||||
return R.data(list); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,34 @@
|
||||
package com.sinenux.yshub.dto; |
||||
|
||||
import io.swagger.annotations.ApiModelProperty; |
||||
import lombok.Data; |
||||
|
||||
import java.io.Serializable; |
||||
|
||||
/** |
||||
* @author laifeng |
||||
* @since 2023/3/24 |
||||
*/ |
||||
@Data |
||||
public class HandleQuery implements Serializable { |
||||
private static final long serialVersionUID = 1L; |
||||
@ApiModelProperty("页码") |
||||
String pageNo; |
||||
@ApiModelProperty("页面数量") |
||||
String pageSize; |
||||
|
||||
@ApiModelProperty("企业前缀") |
||||
private String prefix; |
||||
|
||||
@ApiModelProperty("标识名称") |
||||
private String handleName; |
||||
|
||||
|
||||
@ApiModelProperty("开始时间") |
||||
private String startTime; |
||||
|
||||
|
||||
@ApiModelProperty("结束时间") |
||||
private String endTime; |
||||
|
||||
} |
@ -0,0 +1,90 @@
|
||||
package com.sinenux.yshub.dto; |
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat; |
||||
import lombok.Data; |
||||
import org.springframework.format.annotation.DateTimeFormat; |
||||
|
||||
/** |
||||
* 标识模板 查询类 |
||||
* |
||||
* @author laifeng |
||||
* @since 2023-11-27 |
||||
*/ |
||||
@Data |
||||
public class IdentityTemplateQuery { |
||||
|
||||
/** |
||||
* 主键id |
||||
*/ |
||||
private Long id; |
||||
/** |
||||
* 描述 |
||||
*/ |
||||
private String description; |
||||
|
||||
/** |
||||
* 企业前缀 |
||||
*/ |
||||
private String prefix; |
||||
|
||||
/** |
||||
* 版本型号 |
||||
*/ |
||||
private String version; |
||||
|
||||
/** |
||||
* 标识模板 |
||||
*/ |
||||
private String handle; |
||||
|
||||
/** |
||||
* 行业门类 |
||||
*/ |
||||
private String industryCategory; |
||||
/** |
||||
* 行业大类 |
||||
*/ |
||||
private String industrySpecific; |
||||
|
||||
/** |
||||
* 行业中类 |
||||
*/ |
||||
private String industryTrade; |
||||
|
||||
/** |
||||
* 行业小类 |
||||
*/ |
||||
private String industrySubclass; |
||||
|
||||
/** |
||||
* 模板类型 |
||||
*/ |
||||
private Integer type; |
||||
|
||||
/** |
||||
* 是否删除 |
||||
*/ |
||||
private Integer isDeleted; |
||||
|
||||
/** |
||||
* 开始时间 |
||||
*/ |
||||
@DateTimeFormat( |
||||
pattern = "yyyy-MM-dd HH:mm:ss" |
||||
) |
||||
@JsonFormat( |
||||
pattern = "yyyy-MM-dd HH:mm:ss" |
||||
) |
||||
private String startDate; |
||||
|
||||
/** |
||||
* 结束时间 |
||||
*/ |
||||
@DateTimeFormat( |
||||
pattern = "yyyy-MM-dd HH:mm:ss" |
||||
) |
||||
@JsonFormat( |
||||
pattern = "yyyy-MM-dd HH:mm:ss" |
||||
) |
||||
private String endDate; |
||||
} |
@ -0,0 +1,80 @@
|
||||
package com.sinenux.yshub.entity; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId; |
||||
import com.baomidou.mybatisplus.annotation.TableName; |
||||
import com.fasterxml.jackson.annotation.JsonFormat; |
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize; |
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; |
||||
import io.swagger.annotations.ApiModel; |
||||
import io.swagger.annotations.ApiModelProperty; |
||||
import lombok.Data; |
||||
import org.springframework.format.annotation.DateTimeFormat; |
||||
|
||||
import java.util.Date; |
||||
|
||||
/** |
||||
* 企业前缀 实体类(只写了部分字段) |
||||
* |
||||
* @author cgm |
||||
* @since 2021-09-01 |
||||
*/ |
||||
@Data |
||||
@TableName("nbms_ent_prefix") |
||||
@ApiModel(value = "AliIotConfig对象", description = "云对接-阿里云物联网配置表") |
||||
public class EnterprisePrefix { |
||||
|
||||
/** |
||||
* 主键Id |
||||
*/ |
||||
@JsonSerialize( |
||||
using = ToStringSerializer.class |
||||
) |
||||
@ApiModelProperty("主键Id") |
||||
@TableId( |
||||
value = "id" |
||||
) |
||||
private Long id; |
||||
|
||||
|
||||
/** |
||||
* 创建时间 |
||||
*/ |
||||
@DateTimeFormat( |
||||
pattern = "yyyy-MM-dd HH:mm:ss" |
||||
) |
||||
@JsonFormat( |
||||
pattern = "yyyy-MM-dd HH:mm:ss" |
||||
) |
||||
@ApiModelProperty(value = "创建时间", hidden = true) |
||||
private Date createDate; |
||||
|
||||
|
||||
/** |
||||
* 更新时间 |
||||
*/ |
||||
@DateTimeFormat( |
||||
pattern = "yyyy-MM-dd HH:mm:ss" |
||||
) |
||||
@JsonFormat( |
||||
pattern = "yyyy-MM-dd HH:mm:ss" |
||||
) |
||||
@ApiModelProperty(value = "更新时间", hidden = true) |
||||
private Date updateDate; |
||||
|
||||
/** |
||||
* 业务状态 |
||||
*/ |
||||
@ApiModelProperty(value = "状态是否有效 1启用2停用") |
||||
private Integer state; |
||||
/** |
||||
* 标识前缀 |
||||
*/ |
||||
@ApiModelProperty(value = "标识前缀") |
||||
private String entPrefix; |
||||
|
||||
/** |
||||
* 企业名称 |
||||
*/ |
||||
@ApiModelProperty(value = "企业名称") |
||||
private String entName; |
||||
} |
@ -0,0 +1,100 @@
|
||||
package com.sinenux.yshub.entity; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId; |
||||
import com.baomidou.mybatisplus.annotation.TableName; |
||||
import com.fasterxml.jackson.annotation.JsonFormat; |
||||
import io.swagger.annotations.ApiModel; |
||||
import lombok.Data; |
||||
import org.springframework.format.annotation.DateTimeFormat; |
||||
|
||||
import java.util.Date; |
||||
|
||||
/** |
||||
* 标识模板 实体类 |
||||
* |
||||
* @author laifeng |
||||
* @since 2023-11-27 |
||||
*/ |
||||
@Data |
||||
@TableName("nbms_identity_template") |
||||
@ApiModel(value = "nbms_identity_template对象", description = "标识模板") |
||||
public class IdentityTemplate { |
||||
|
||||
/** |
||||
* 主键id |
||||
*/ |
||||
@TableId( |
||||
value = "id" |
||||
) |
||||
private Long id; |
||||
/** |
||||
* 描述 |
||||
*/ |
||||
private String description; |
||||
|
||||
/** |
||||
* 企业前缀 |
||||
*/ |
||||
private String prefix; |
||||
|
||||
/** |
||||
* 版本型号 |
||||
*/ |
||||
private String version; |
||||
|
||||
/** |
||||
* 标识模板 |
||||
*/ |
||||
private String handle; |
||||
|
||||
/** |
||||
* 行业门类 |
||||
*/ |
||||
private String industryCategory; |
||||
/** |
||||
* 行业大类 |
||||
*/ |
||||
private String industrySpecific; |
||||
|
||||
/** |
||||
* 行业中类 |
||||
*/ |
||||
private String industryTrade; |
||||
|
||||
/** |
||||
* 行业小类 |
||||
*/ |
||||
private String industrySubclass; |
||||
|
||||
/** |
||||
* 模板类型 |
||||
*/ |
||||
private Integer type; |
||||
|
||||
/** |
||||
* 是否删除 |
||||
*/ |
||||
private Integer isDeleted; |
||||
|
||||
/** |
||||
* 创建时间 |
||||
*/ |
||||
@DateTimeFormat( |
||||
pattern = "yyyy-MM-dd HH:mm:ss" |
||||
) |
||||
@JsonFormat( |
||||
pattern = "yyyy-MM-dd HH:mm:ss" |
||||
) |
||||
private Date createDate; |
||||
|
||||
/** |
||||
* 更新时间 |
||||
*/ |
||||
@DateTimeFormat( |
||||
pattern = "yyyy-MM-dd HH:mm:ss" |
||||
) |
||||
@JsonFormat( |
||||
pattern = "yyyy-MM-dd HH:mm:ss" |
||||
) |
||||
private Date updateDate; |
||||
} |
@ -0,0 +1,78 @@
|
||||
package com.sinenux.yshub.entity; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId; |
||||
import com.baomidou.mybatisplus.annotation.TableName; |
||||
import com.fasterxml.jackson.annotation.JsonFormat; |
||||
import io.swagger.annotations.ApiModel; |
||||
import lombok.Data; |
||||
import org.springframework.format.annotation.DateTimeFormat; |
||||
|
||||
import java.util.Date; |
||||
|
||||
/** |
||||
* 标识模板内容 实体类 |
||||
* |
||||
* @author laifeng |
||||
* @since 2023-11-27 |
||||
*/ |
||||
@Data |
||||
@TableName("nbms_identity_template_item") |
||||
@ApiModel(value = "nbms_identity_template对象", description = "标识模板内容") |
||||
public class IdentityTemplateItem { |
||||
|
||||
/** |
||||
* 主键id |
||||
*/ |
||||
@TableId( |
||||
value = "id" |
||||
) |
||||
private Long id; |
||||
/** |
||||
* 权限码 |
||||
*/ |
||||
private String authorizationKey; |
||||
/** |
||||
* 下标 |
||||
*/ |
||||
private Integer idIndex; |
||||
/** |
||||
* 英文名称 |
||||
*/ |
||||
private String idType; |
||||
/** |
||||
* 中文名称 |
||||
*/ |
||||
private String name; |
||||
|
||||
/** |
||||
* 模板id |
||||
*/ |
||||
private Long tid; |
||||
|
||||
/** |
||||
* 禁用状态(0:禁用 1:启用) |
||||
*/ |
||||
private Integer state; |
||||
|
||||
/** |
||||
* 创建时间 |
||||
*/ |
||||
@DateTimeFormat( |
||||
pattern = "yyyy-MM-dd HH:mm:ss" |
||||
) |
||||
@JsonFormat( |
||||
pattern = "yyyy-MM-dd HH:mm:ss" |
||||
) |
||||
private Date createDate; |
||||
|
||||
/** |
||||
* 更新时间 |
||||
*/ |
||||
@DateTimeFormat( |
||||
pattern = "yyyy-MM-dd HH:mm:ss" |
||||
) |
||||
@JsonFormat( |
||||
pattern = "yyyy-MM-dd HH:mm:ss" |
||||
) |
||||
private Date updateDate; |
||||
} |
@ -0,0 +1,62 @@
|
||||
package com.sinenux.yshub.entity; |
||||
|
||||
import io.swagger.annotations.ApiModel; |
||||
import io.swagger.annotations.ApiModelProperty; |
||||
import lombok.Data; |
||||
import org.springframework.data.annotation.Id; |
||||
import org.springframework.data.mongodb.core.mapping.Document; |
||||
import org.springframework.data.mongodb.core.mapping.Field; |
||||
|
||||
import java.io.Serializable; |
||||
import java.util.Date; |
||||
|
||||
/** |
||||
* 标识Mongo实体类(只写了部份字段) |
||||
* |
||||
* @author laifeng |
||||
* @date 2023-3-24 |
||||
*/ |
||||
@Data |
||||
@Document("handle_info") |
||||
@ApiModel(value = "handle_info对象", description = "标识统计表") |
||||
public class MHandleInfo implements Serializable { |
||||
|
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
@Id |
||||
@ApiModelProperty("主键id") |
||||
private String id; |
||||
|
||||
/** |
||||
* 企业前缀 |
||||
*/ |
||||
@ApiModelProperty("企业前缀") |
||||
private String prefix; |
||||
|
||||
/** |
||||
* 二级前缀 |
||||
*/ |
||||
@ApiModelProperty("二级前缀") |
||||
private String subPrefix; |
||||
|
||||
/** |
||||
* 标识名称 |
||||
*/ |
||||
@ApiModelProperty("标识名称") |
||||
@Field("handle_name") |
||||
private String handleName; |
||||
|
||||
/** |
||||
* 创建时间 |
||||
*/ |
||||
@ApiModelProperty(value = "创建时间", hidden = true) |
||||
@Field("create_time") |
||||
private Date createTime; |
||||
|
||||
/** |
||||
* 更新时间 |
||||
*/ |
||||
@ApiModelProperty(value = "更新时间", hidden = true) |
||||
@Field("update_time") |
||||
private Date updateTime; |
||||
} |
@ -0,0 +1,17 @@
|
||||
package com.sinenux.yshub.mapper; |
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import com.sinenux.yshub.entity.EnterprisePrefix; |
||||
import org.apache.ibatis.annotations.Mapper; |
||||
|
||||
/** |
||||
* 告警规则表 Mapper 接口 |
||||
* |
||||
* @author acX |
||||
* @since 2023-04-24 |
||||
*/ |
||||
@Mapper |
||||
public interface EnterprisePrefixMapper extends BaseMapper<EnterprisePrefix> { |
||||
|
||||
|
||||
} |
@ -0,0 +1,16 @@
|
||||
<?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.sinenux.snhub.mapper.EnterprisePrefixMapper"> |
||||
|
||||
<!-- 通用查询映射结果 --> |
||||
<resultMap id="alarmRuleResultMap" type="com.sinenux.yshub.entity.EnterprisePrefix"> |
||||
<result column="id" property="id"/> |
||||
<result column="state" property="state"/> |
||||
<result column="ent_prefix" property="entPrefix"/> |
||||
<result column="ent_name" property="entName"/> |
||||
<result column="create_Date" property="createDate"/> |
||||
<result column="update_Date" property="updateDate"/> |
||||
</resultMap> |
||||
|
||||
|
||||
</mapper> |
@ -0,0 +1,17 @@
|
||||
package com.sinenux.yshub.mapper; |
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import com.sinenux.yshub.entity.IdentityTemplateItem; |
||||
import org.apache.ibatis.annotations.Mapper; |
||||
|
||||
/** |
||||
* 模板内容表 Mapper 接口 |
||||
* |
||||
* @author laifeng |
||||
* @since 2023-11-27 |
||||
*/ |
||||
@Mapper |
||||
public interface IdentityTemplateItemMapper extends BaseMapper<IdentityTemplateItem> { |
||||
|
||||
|
||||
} |
@ -0,0 +1,8 @@
|
||||
<?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.sinenux.snhub.mapper.IdentityTemplateItemMapper"> |
||||
|
||||
|
||||
|
||||
|
||||
</mapper> |
@ -0,0 +1,17 @@
|
||||
package com.sinenux.yshub.mapper; |
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import com.sinenux.yshub.entity.IdentityTemplate; |
||||
import org.apache.ibatis.annotations.Mapper; |
||||
|
||||
/** |
||||
* 模板表 Mapper 接口 |
||||
* |
||||
* @author laifeng |
||||
* @since 2023-11-27 |
||||
*/ |
||||
@Mapper |
||||
public interface IdentityTemplateMapper extends BaseMapper<IdentityTemplate> { |
||||
|
||||
|
||||
} |
@ -0,0 +1,8 @@
|
||||
<?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.sinenux.snhub.mapper.IdentityTemplateMapper"> |
||||
|
||||
|
||||
|
||||
|
||||
</mapper> |
@ -0,0 +1,25 @@
|
||||
package com.sinenux.yshub.service; |
||||
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService; |
||||
import com.sinenux.yshub.entity.EnterprisePrefix; |
||||
|
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* 企业前缀 服务类 |
||||
* |
||||
* @author laifeng |
||||
* @since 2023-11-08 |
||||
*/ |
||||
|
||||
public interface IEnterprisePrefixService extends IService<EnterprisePrefix> { |
||||
|
||||
/** |
||||
* 获取企业前缀Top10 |
||||
*/ |
||||
List<EnterprisePrefix> getTop10(); |
||||
|
||||
Map<String,Object> prefixStatistics(); |
||||
} |
@ -0,0 +1,48 @@
|
||||
package com.sinenux.yshub.service.impl; |
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||
import com.bluebird.core.tool.utils.DateUtil; |
||||
import com.sinenux.yshub.entity.EnterprisePrefix; |
||||
import com.sinenux.yshub.mapper.EnterprisePrefixMapper; |
||||
import com.sinenux.yshub.service.IEnterprisePrefixService; |
||||
import com.sinenux.yshub.utils.MyDateUtil; |
||||
import lombok.AllArgsConstructor; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
import java.util.Date; |
||||
import java.util.HashMap; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
@Service |
||||
@AllArgsConstructor |
||||
public class EnterprisePrefixServiceImpl extends ServiceImpl<EnterprisePrefixMapper, EnterprisePrefix> implements IEnterprisePrefixService { |
||||
private final EnterprisePrefixMapper enterprisePrefixMapper; |
||||
|
||||
@Override |
||||
public List<EnterprisePrefix> getTop10() { |
||||
List<EnterprisePrefix> list = this.lambdaQuery().eq(EnterprisePrefix::getState, 1) |
||||
.orderByDesc(EnterprisePrefix::getCreateDate) |
||||
.last("limit 10") |
||||
.list(); |
||||
return list; |
||||
} |
||||
|
||||
@Override |
||||
public Map<String, Object> prefixStatistics() { |
||||
Date date = MyDateUtil.getDateOfHour(DateUtil.now()); |
||||
|
||||
Long totalCount = this.lambdaQuery() |
||||
.eq(EnterprisePrefix::getState, 1) |
||||
.count(); |
||||
Long yesterdayCount = this.lambdaQuery() |
||||
.eq(EnterprisePrefix::getState, 1) |
||||
.lt(EnterprisePrefix::getCreateDate, date) |
||||
.count(); |
||||
HashMap<String, Object> map = new HashMap<>(); |
||||
map.put("totalCount", totalCount); |
||||
map.put("yesterdayCount", yesterdayCount); |
||||
map.put("increaseCount", totalCount - yesterdayCount); |
||||
return map; |
||||
} |
||||
} |
@ -0,0 +1,102 @@
|
||||
package com.sinenux.yshub.utils; |
||||
|
||||
import com.bluebird.core.tool.utils.ConcurrentDateFormat; |
||||
import com.bluebird.core.tool.utils.DateUtil; |
||||
|
||||
import java.text.ParseException; |
||||
import java.text.SimpleDateFormat; |
||||
import java.util.ArrayList; |
||||
import java.util.Calendar; |
||||
import java.util.Date; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 日期工具类(补充) |
||||
* |
||||
* @author cgm |
||||
* @date 2022/2/15 17:17 |
||||
*/ |
||||
public class MyDateUtil { |
||||
public static final ConcurrentDateFormat YEAR_FORMAT = ConcurrentDateFormat.of("yyyy"); |
||||
public static final ConcurrentDateFormat MONTH_FORMAT = ConcurrentDateFormat.of("yyyyMM"); |
||||
|
||||
public static String formatYear(Date date) { |
||||
return YEAR_FORMAT.format(date); |
||||
} |
||||
|
||||
public static String formatMonth(Date date) { |
||||
return MONTH_FORMAT.format(date); |
||||
} |
||||
|
||||
/** |
||||
* 获取当月所有日期 |
||||
*/ |
||||
public static List<Date> getAllDateOfTheMonth(Date date) { |
||||
List<Date> list = new ArrayList<>(); |
||||
|
||||
Calendar calendar = Calendar.getInstance(); |
||||
calendar.setTime(date); |
||||
calendar.set(Calendar.DATE, 1); |
||||
|
||||
int month = calendar.get(Calendar.MONTH); |
||||
while (calendar.get(Calendar.MONTH) == month) { |
||||
list.add(calendar.getTime()); |
||||
calendar.add(Calendar.DATE, 1); |
||||
} |
||||
|
||||
return list; |
||||
} |
||||
|
||||
/** |
||||
* 将当前时间 分秒归零 |
||||
*/ |
||||
public static Date getDateOfMinute(Date date) { |
||||
Calendar calendar = Calendar.getInstance(); |
||||
calendar.setTime(date); |
||||
calendar.set(Calendar.MINUTE, 0); |
||||
calendar.set(Calendar.SECOND, 0); |
||||
calendar.set(Calendar.MILLISECOND, 0); |
||||
String time = DateUtil.formatDateTime(calendar.getTime()); |
||||
return DateUtil.parse(time, DateUtil.DATETIME_FORMAT); |
||||
} |
||||
|
||||
/** |
||||
* 将当前时间 时分秒归零 |
||||
*/ |
||||
public static Date getDateOfHour(Date date) { |
||||
Calendar calendar = Calendar.getInstance(); |
||||
calendar.setTime(date); |
||||
calendar.set(Calendar.HOUR_OF_DAY, 0); |
||||
calendar.set(Calendar.MINUTE, 0); |
||||
calendar.set(Calendar.SECOND, 0); |
||||
calendar.set(Calendar.MILLISECOND, 0); |
||||
String time = DateUtil.formatDateTime(calendar.getTime()); |
||||
return DateUtil.parse(time, DateUtil.DATETIME_FORMAT); |
||||
} |
||||
|
||||
/** |
||||
* 将yyyy-mm-dd格式 或者 yyyy-MM 格式 转换成 yyyy-MM-dd HH:mm:ss |
||||
* |
||||
* @param |
||||
* @return |
||||
*/ |
||||
public static String formatShortTimeToLong(String shortTimeStr) { |
||||
if (shortTimeStr == null) { |
||||
return null; |
||||
} |
||||
// 定义SimpleDateFormat的格式
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); |
||||
|
||||
// 解析日期字符串
|
||||
Date date = null; |
||||
try { |
||||
date = sdf.parse(shortTimeStr); |
||||
} catch (ParseException e) { |
||||
return null; |
||||
} |
||||
|
||||
// 将Date转换为带时间的字符串格式并返回
|
||||
SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
||||
return sdf2.format(date); |
||||
} |
||||
} |
@ -0,0 +1,13 @@
|
||||
#本地测试使用 |
||||
MONGODB_URI: mongodb://idis_user:Teleinfo-88@223.99.228.240:27017/idis_lhs?authSource=admin |
||||
REQUEST_IPS: 0.0.0.0 |
||||
MYSQL_URL: jdbc:mysql://223.99.228.240:3306/snms?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&tinyInt1isBit=false&serverTimezone=Asia/Shanghai |
||||
MYSQL_USERNAME: idis_user |
||||
MYSQL_PASSWORD: Teleinfo-88 |
||||
#MYSQL_URL: jdbc:mysql://47.97.5.58:3306/cat_app?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&tinyInt1isBit=false&serverTimezone=Asia/Shanghai |
||||
#MYSQL_USERNAME: root |
||||
#MYSQL_PASSWORD: 157242 |
||||
logging: |
||||
level: |
||||
org.springframework.data.mongodb.core: debug |
||||
|
@ -0,0 +1,22 @@
|
||||
package com.sinenux.yshub; |
||||
|
||||
import org.junit.jupiter.api.Test; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.boot.test.context.SpringBootTest; |
||||
import org.springframework.data.mongodb.core.MongoTemplate; |
||||
import org.springframework.data.mongodb.core.mapping.Document; |
||||
import org.springframework.data.mongodb.core.query.Query; |
||||
|
||||
@SpringBootTest |
||||
class HubApplicationTests { |
||||
@Autowired |
||||
private MongoTemplate mongoTemplate; |
||||
|
||||
@Test |
||||
void contextLoads() { |
||||
Query query = new Query(); |
||||
Document one = mongoTemplate.findOne(query, Document.class); |
||||
System.out.println(one); |
||||
} |
||||
|
||||
} |
Loading…
Reference in new issue