提交 ebf4eed6 作者: 刘伟刚

第一次提交项目

上级
# Default ignored files
/shelf/
/workspace.xml
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml
# Editor-based HTTP Client requests
/httpRequests/
# Zeppelin ignored files
/ZeppelinRemoteNotebooks/
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<annotationProcessing>
<profile default="true" name="Default" enabled="true" />
<profile name="Maven default annotation processors profile" enabled="true">
<sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" />
<module name="kgjDataSyncNoImage" />
</profile>
</annotationProcessing>
</component>
<component name="JavacSettings">
<option name="ADDITIONAL_OPTIONS_OVERRIDE">
<module name="kgjDataSyncNoImage" options="-parameters" />
</option>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding">
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RemoteRepositoriesConfiguration">
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Central Repository" />
<option name="url" value="http://maven.aliyun.com/nexus/content/groups/public/" />
</remote-repository>
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Maven Central repository" />
<option name="url" value="https://repo1.maven.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="jboss.community" />
<option name="name" value="JBoss Community repository" />
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
</remote-repository>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="MavenProjectsManager">
<option name="originalFiles">
<list>
<option value="$PROJECT_DIR$/pom.xml" />
</list>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
<component name="ProjectType">
<option name="id" value="jpab" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RunConfigurationProducerService">
<option name="ignoredProducers">
<set>
<option value="com.android.tools.idea.compose.preview.runconfiguration.ComposePreviewRunConfigurationProducer" />
</set>
</option>
</component>
</project>
\ No newline at end of file
maxId=23042000000124
自治区
自治州
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.4.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.zzsn</groupId>
<artifactId>kgjDataSyncNoImage</artifactId>
<version>2.0</version>
<name>dataSync</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
<xxl-core.version>2.2.0</xxl-core.version>
<mybatis-plus.version>3.3.2</mybatis-plus.version>
<druid.version>1.1.17</druid.version>
<commons.version>2.6</commons.version>
<lombok.version>1.18.6</lombok.version>
<fastjson.version>1.2.69</fastjson.version>
<oracle-database.version>11.2.0.3</oracle-database.version>
<jackson.version>2.11.2</jackson.version>
<pagehelper.boot.version>1.2.5</pagehelper.boot.version>
<hanlp.version>portable-1.7.7</hanlp.version>
</properties>
<dependencies>
<!--mysql-->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.47</version>
<!--<scope>system</scope>-->
</dependency>
<dependency>
<groupId>ojdbc6</groupId>
<artifactId>ojdbc6</artifactId>
<version>0.1</version>
<scope>system</scope>
<systemPath>${pom.basedir}/lib/ojdbc6-0.1.jar</systemPath>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- <dependency>-->
<!-- <groupId>org.springframework.boot</groupId>-->
<!-- <artifactId>spring-boot-starter</artifactId>-->
<!-- </dependency>-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>${mybatis-plus.version}</version>
</dependency>
<!-- druid -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>${druid.version}</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>${commons.version}</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>${commons.version}</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</dependency>
<!-- json -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>${fastjson.version}</version>
</dependency>
<!-- oracle驱动 -->
<!--<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc6</artifactId>
<version>${oracle-database.version}</version>
<scope>runtime</scope>
</dependency>-->
<!--<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc6</artifactId>
<version>11.2.0.3</version>
</dependency>-->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>${jackson.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-annotations -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>${pagehelper.boot.version}</version>
<exclusions>
<exclusion>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
</exclusion>
<exclusion>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>dynamic-datasource-spring-boot-starter</artifactId>
<version>2.5.4</version>
</dependency>
<dependency>
<!-- jsoup HTML parser library @ https://jsoup.org/ -->
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.11.3</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-elasticsearch</artifactId>
</dependency>
<!-- 图片压缩-->
<dependency>
<groupId>net.coobird</groupId>
<artifactId>thumbnailator</artifactId>
<version>0.4.8</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<!--hanlp-->
<dependency>
<groupId>com.hankcs</groupId>
<artifactId>hanlp</artifactId>
<version>${hanlp.version}</version>
</dependency>
<!-- Redis -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-pool2</artifactId>
<version>2.6.2</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<mainClass>com.zzsn.DataSyncApplication</mainClass>
<includeSystemScope>true</includeSystemScope><!--外部进行打包-->
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- 指定JDK编译版本-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<!-- 打包跳过测试 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<includes>
<include>**/*.xml</include>
<include>**/*.yml</include>
<include>**/*.txt</include>
</includes>
</resource>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.xml</include>
<include>**/*.yml</include>
</includes>
</resource>
</resources>
</build>
</project>
package com.zzsn;
import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
@SpringBootApplication(exclude = DruidDataSourceAutoConfigure.class)
@MapperScan("com.zzsn.mapper")
@EnableAspectJAutoProxy(exposeProxy = true)
public class DataSyncApplication {
public static void main(String[] args) {
ConfigurableApplicationContext application=SpringApplication.run(DataSyncApplication.class, args);
}
}
package com.zzsn.config;
import lombok.extern.slf4j.Slf4j;
import org.apache.http.HttpHost;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.CredentialsProvider;
import org.apache.http.impl.client.BasicCredentialsProvider;
import org.apache.http.impl.nio.reactor.IOReactorConfig;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestClientBuilder;
import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.util.StringUtils;
import java.io.IOException;
/**
* @author kongliufeng
* @create 2020-07-31 17:40onfi
*/
@Slf4j
@Configuration
public class ElasticsearchClientConfig implements DisposableBean {
@Value("${zzsn.es.host}")
private String host;
@Value("${zzsn.es.port}")
private int port;
@Value("${zzsn.es.url}")
private String url;
@Value("${zzsn.es.userName}")
private String userName;
@Value("${zzsn.es.passWord}")
private String passWord;
@Value("${zzsn.es.clusterIsStart}")
private Boolean clusterIsStart;
private final String scheme = "http";
private final int connectTimeOut = 5000;
private final int socketTimeOut = 60000;
private final int connectionRequestTimeOut = 1500;
private final int maxConnectPerRoute = 10;
//es 集群node系欸但数量
private final int nodesNum = 3;
//最大连接数量
private final int maxConnectNum = maxConnectPerRoute * nodesNum;
private final boolean uniqueConnectTimeConfig = true;
private final boolean uniqueConnectNumConfig = true;
private RestClientBuilder builder;
private RestHighLevelClient client;
public ElasticsearchClientConfig() {
}
/*
* 创建 RestHigLevelClient,@Scope("prototype")
* */
@Bean()
public RestHighLevelClient restHighLevelClient(){
//HttpHost httpHost = new HttpHost(host, port, scheme);
if(clusterIsStart){
HttpHost[] httpHosts = null;
if(url!=null){
String[] urls = url.split(",");
httpHosts = new HttpHost[urls.length];
for (int i = 0; i < urls.length; i++) {
String[] ipAndPort = urls[i].split(":");
httpHosts[i] = new HttpHost(ipAndPort[0],Integer.valueOf(ipAndPort[1]),scheme);
}
}
builder = RestClient.builder(httpHosts);
}else{
HttpHost httpHost = new HttpHost(host, port, scheme);
builder = RestClient.builder(httpHost);
}
if(uniqueConnectNumConfig){
setConnectTimeOutConfig();
}if (uniqueConnectNumConfig) {
setMutiConnectConfig();
}
/*RestHighLevelClient restHighLevelClient = new RestHighLevelClient(
RestClient.builder(httpHost)
);*/
client = new RestHighLevelClient(builder);
return client;
}
private void setMutiConnectConfig() {
builder.setHttpClientConfigCallback(HttpClientBuilder ->{
//if(!("zzsn".equals(userName) && (Objects.isNull(passWord) || "zzsn9988".equals(passWord)))){
if(!StringUtils.isEmpty(userName) && !StringUtils.isEmpty(passWord)){
log.info("es集群服务器账号[{}],密码[{}]",userName,passWord);
CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
credentialsProvider.setCredentials(AuthScope.ANY,
new UsernamePasswordCredentials(userName,passWord));
HttpClientBuilder.setDefaultCredentialsProvider(credentialsProvider);
};
return HttpClientBuilder.setMaxConnTotal(maxConnectNum)
.setMaxConnPerRoute(maxConnectPerRoute)
.setDefaultIOReactorConfig(IOReactorConfig.custom().setIoThreadCount(
Runtime.getRuntime().availableProcessors() << 1
).build());
});
}
/**
* lambda表达式创建
* 异步httpclient 的连接延时配置
*/
private void setConnectTimeOutConfig() {
builder.setRequestConfigCallback(requestConfigBuilder ->
requestConfigBuilder
.setConnectTimeout(connectTimeOut)
.setSocketTimeout(socketTimeOut)
.setConnectionRequestTimeout(connectionRequestTimeOut)
);
}
/**
* 销毁方法
* @throws Exception
*/
@Override
public void destroy() throws Exception {
close();
}
public void close() {
if (client != null) {
try {
client.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
package com.zzsn.config;
import com.zzsn.constant.FileConstant;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
/**
* @ClassName: FileConfig
* @Description: 图片读取
* @Auth: Sunty
* @Date: 2020/4/6 12:29
* @Version: 1.0.0
**/
@Configuration
public class FileConfig extends WebMvcConfigurationSupport {
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
//图片文件
registry.addResourceHandler(FileConstant.IMG_VIR_PATH + FileConstant.ACCESS_SUFFIX).
addResourceLocations(FileConstant.FILE_PREFIX + Global.getProfile());
super.addResourceHandlers(registry);
}
}
package com.zzsn.config;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
/**
* 全局配置类
*/
@Component
@ConfigurationProperties(prefix = "file")
public class Global {
//图片文件真实地址所在文件夹
private static String profile;
//图片访问前缀
private static String accessAddress;
public static String getProfile() {
return profile;
}
public void setProfile(String profile) {
Global.profile = profile;
}
public static String getAccessAddress() {
return accessAddress;
}
public void setAccessAddress(String accessAddress) {
Global.accessAddress = accessAddress;
}
}
package com.zzsn.config;
import com.baomidou.mybatisplus.extension.incrementer.OracleKeyGenerator;
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement;
/**
* @author
* @description: mybatis-plus配置
* @date
*/
@EnableTransactionManagement
@Configuration
//@MapperScan("com.zzsn.mapper")
public class MybatisPlusConfig {
/**
* mybatis-plus分页配置
*/
@Bean
public PaginationInterceptor paginationInterceptor() {
return new PaginationInterceptor();
}
/**
* Sequence主键自增
*
* @return 返回oracle自增类
* @author zhenggc
*/
@Bean
public OracleKeyGenerator oracleKeyGenerator(){
return new OracleKeyGenerator();
}
}
package com.zzsn.config;
import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility;
import com.fasterxml.jackson.annotation.PropertyAccessor;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectMapper.DefaultTyping;
import com.zzsn.constant.CacheConstant;
import org.springframework.cache.CacheManager;
import org.springframework.cache.annotation.CachingConfigurerSupport;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.cache.RedisCacheConfiguration;
import org.springframework.data.redis.cache.RedisCacheManager;
import org.springframework.data.redis.cache.RedisCacheWriter;
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.*;
import javax.annotation.Resource;
import java.time.Duration;
import static java.util.Collections.singletonMap;
@Configuration
@EnableCaching // 开启缓存支持
public class RedisConfig extends CachingConfigurerSupport {
@Resource
private LettuceConnectionFactory lettuceConnectionFactory;
// /**
// * @description 自定义的缓存key的生成策略 若想使用这个key
// * 只需要讲注解上keyGenerator的值设置为keyGenerator即可</br>
// * @return 自定义策略生成的key
// */
// @Override
// @Bean
// public KeyGenerator keyGenerator() {
// return new KeyGenerator() {
// @Override
// public Object generate(Object target, Method method, Object... params) {
// StringBuilder sb = new StringBuilder();
// sb.append(target.getClass().getName());
// sb.append(method.getDeclaringClass().getName());
// Arrays.stream(params).map(Object::toString).forEach(sb::append);
// return sb.toString();
// }
// };
// }
/**
* RedisTemplate配置
*
* @param lettuceConnectionFactory
* @return
*/
@Bean
public RedisTemplate<String, Object> redisTemplate(LettuceConnectionFactory lettuceConnectionFactory) {
// 设置序列化
Jackson2JsonRedisSerializer<Object> jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer<Object>(Object.class);
ObjectMapper om = new ObjectMapper();
om.setVisibility(PropertyAccessor.ALL, Visibility.ANY);
om.enableDefaultTyping(DefaultTyping.NON_FINAL);
jackson2JsonRedisSerializer.setObjectMapper(om);
// 配置redisTemplate
RedisTemplate<String, Object> redisTemplate = new RedisTemplate<String, Object>();
redisTemplate.setConnectionFactory(lettuceConnectionFactory);
RedisSerializer<?> stringSerializer = new StringRedisSerializer();
redisTemplate.setKeySerializer(stringSerializer);// key序列化
redisTemplate.setValueSerializer(jackson2JsonRedisSerializer);// value序列化
redisTemplate.setHashKeySerializer(stringSerializer);// Hash key序列化
redisTemplate.setHashValueSerializer(jackson2JsonRedisSerializer);// Hash value序列化
redisTemplate.afterPropertiesSet();
return redisTemplate;
}
/**
* 缓存配置管理器
*
* @param factory
* @return
*/
@Bean
public CacheManager cacheManager(LettuceConnectionFactory factory) {
// 配置序列化(缓存默认有效期 6小时)
RedisCacheConfiguration config = RedisCacheConfiguration.defaultCacheConfig().entryTtl(Duration.ofHours(6));
RedisCacheConfiguration redisCacheConfiguration = config.serializeKeysWith(RedisSerializationContext.SerializationPair.fromSerializer(new StringRedisSerializer()))
.serializeValuesWith(RedisSerializationContext.SerializationPair.fromSerializer(new GenericJackson2JsonRedisSerializer()));
// 以锁写入的方式创建RedisCacheWriter对象
//RedisCacheWriter writer = RedisCacheWriter.lockingRedisCacheWriter(factory);
// 创建默认缓存配置对象
/* 默认配置,设置缓存有效期 1小时*/
//RedisCacheConfiguration defaultCacheConfig = RedisCacheConfiguration.defaultCacheConfig().entryTtl(Duration.ofHours(1));
/* 自定义配置test:demo 的超时时间为 5分钟*/
RedisCacheManager cacheManager = RedisCacheManager.builder(RedisCacheWriter.lockingRedisCacheWriter(factory)).cacheDefaults(redisCacheConfiguration)
.withInitialCacheConfigurations(singletonMap(CacheConstant.TEST_DEMO_CACHE, RedisCacheConfiguration.defaultCacheConfig().entryTtl(Duration.ofMinutes(5)).disableCachingNullValues()))
.transactionAware().build();
return cacheManager;
}
}
package com.zzsn.config;
import com.hankcs.hanlp.corpus.io.IIOAdapter;
import org.springframework.core.io.ClassPathResource;
import org.springframework.stereotype.Component;
import java.io.*;
import java.util.Properties;
@Component
public class ResourceIOAdapter implements IIOAdapter {
@Override
public InputStream open(String path) throws IOException {
Properties properties = System.getProperties();
String s = properties.getProperty("user.dir");
if (properties.getProperty("os.name").toLowerCase().contains("win")) {
s += "\\";
}else {
s += "/";
}
// 将符号“\\”和“\”替换成“/”,有时候便于统一的处理路径的分隔符,避免同一个路径出现两个或三种不同的分隔符
path = (s+path).replace("\\", "/").replace("\\\\", "/");
ClassPathResource resource = new ClassPathResource(path);
InputStream is = new FileInputStream(resource.getFile());
return is;
}
@Override
public OutputStream create(String path) throws IOException {
Properties properties = System.getProperties();
String s = properties.getProperty("user.dir");
if (properties.getProperty("os.name").toLowerCase().contains("win")) {
s += "\\";
}else {
s += "/";
}
// 将符号“\\”和“\”替换成“/”,有时候便于统一的处理路径的分隔符,避免同一个路径出现两个或三种不同的分隔符
path = (s+path).replace("\\", "/").replace("\\\\", "/");
ClassPathResource resource = new ClassPathResource(path);
OutputStream os = new FileOutputStream(resource.getFile());
return os;
}
}
\ No newline at end of file
package com.zzsn.config;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;
@Configuration
public class RestTemplateConfig {
@Bean
public RestTemplate restTemplate(RestTemplateBuilder restTemplateBuilder){
return restTemplateBuilder.build();
}
}
package com.zzsn.constant;
/**
* @author:
* @date:
* @description: 缓存常量
*/
public class CacheConstant {
/**
* 测试缓存key
*/
public static final String TEST_DEMO_CACHE = "test:demo";
/**
* 代理缓存key
*/
public static final String PROXY_KEY = "proxyIp";
/**
* 调用百度加上官方名称
*/
public static final String BAIDU_NAME = "政府网站";
/**
* 百度搜索的url
*/
public static final String BAIDU_URL = "http://www.baidu.com/s?wd=";
}
package com.zzsn.constant;
/**
* 文件位置相关
*/
public class FileConstant {
//访问后缀
public final static String ACCESS_SUFFIX = "**";
//图片文件虚拟地址
public final static String IMG_VIR_PATH = "/image/";
/** 文件前缀 */
public final static String FILE_PREFIX = "file:";
}
package com.zzsn.constant;
public class PageConstant {
public static final int page =0;
// public static final int pageSize =1000;
public static final int pageSize =10;
public static final String path = "config/config.txt";
public static final String LOCATION_PATH = "config/local.txt";
}
package com.zzsn.constant;
public class SecretColorConstant {
public static final String SPAN_COLOR_START = "<span style=\"color: #f1c40f;\">";
public static final String SPAN_COLOR_END = "</span>";
}
package com.zzsn.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
/**
* base64图片实体类
*/
@TableName(value = "CIS_ANS_BASEDATA_IMAGE")
public class BaseDataImage {
private String id;
@TableField("DATAIMAGE")
private String dataImage;
@TableField("BID")
private String bid;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getDataImage() {
return dataImage;
}
public void setDataImage(String dataImage) {
this.dataImage = dataImage;
}
public String getBid() {
return bid;
}
public void setBid(String bid) {
this.bid = bid;
}
}
package com.zzsn.entity;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.io.Serializable;
/**
* @Description: 文章网站中间表
* @Author: zzsn-boot
* @Date: 2021-01-05
* @Version: V1.0
*/
@Data
@TableName("cis_basedata_web_mid")
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@KeySequence("seq_cis_basedata_web_mid")
public class BaseDataWebMid implements Serializable {
private static final long serialVersionUID = 1L;
/**主键*/
@TableId(value = "ID",type = IdType.INPUT)
private Long id;
/**文章ID*/
@TableField("BID")
private Long bId;
/**网站ID*/
@TableField("WEB_ID")
private String webId;
/**密点等级*/
@TableField("SECRET_LEVEL")
private Long secretLevel;
}
package com.zzsn.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import java.io.Serializable;
/**
* 情报分类Model
* @author 刘小鹏
* @date 2015-10-25 14:13
* @company 郑州数能软件科技有限公司
*/
@TableName("CIS_ANS_BASEDATA_TYPE")
@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
public class BasedataType implements Serializable {
public static final Long ISNOTWARNINFO = 0L;//机器判断不是重大舆情
public static final Long ISWARNINFO = 1L;//机器判断是重大舆情
public static final Long ISNOTWARNINFOBYPERSON = 2L;//人工审核 判断不是重大舆情
public static final Long ISWARNINFOBYPERSON = 3L;//人工审核 判断是重大舆情
public static final Long ISNOWARNINFOPUSH = 0L;//未推送
public static final Long ISWARNINFOPUSHED = 1L;//已推送
//columns START
/**
* bid db_column: ID
*/
private Long id;
/**
* bid db_column: BID
*/
private Long bid;
/**
* tid db_column: TID
*/
private Long tid;
/**
* orgId db_column: ORG_ID
*/
private Long orgId;
private Long mark;
private Long delflag;
private Long repeat;
private Long briefmark;
private String checkDate;
private String checkName;
private Long relevance;
private String infotype;
private String tids;
private String createDate;
private String publishDate;
private String orientation;
//0:机器判断非重大舆情;1:机器判断是重大舆情;2:人工审核不是重大舆情;3:人工审核是重大舆情; 其他也表示非重大舆情
private Long warnInfo;
//0:未推送;1:已推送;其他也表示未推送
private Long warnInfoPush;
//关联关键词
private String matchKeywords;
private Long hotvalue;
//IS_FIRST_PUBLISH 是否是首发信息; 0:不是首发信息;1:是首发信息
private Long isFirstPublish;
//FIRST_PUBLISH_BID 首发信息ID; 当当前信息是首发信息时,该字段为空;当当前信息不是首发时,此信息为当前信息的首发信息ID
private Long firstPublishBid;
private Long repeatFilter;
public Long getRepeatFilter() {
return repeatFilter;
}
public void setRepeatFilter(Long repeatFilter) {
this.repeatFilter = repeatFilter;
}
public Long getHotvalue() {
return hotvalue;
}
public void setHotvalue(Long hotvalue) {
this.hotvalue = hotvalue;
}
public Long getRepeatcount() {
return repeatcount;
}
public void setRepeatcount(Long repeatcount) {
this.repeatcount = repeatcount;
}
private Long repeatcount;
//columns END
public Long getBid() {
return bid;
}
public void setBid(Long bid) {
this.bid = bid;
}
public Long getTid() {
return tid;
}
public void setTid(Long tid) {
this.tid = tid;
}
public Long getOrgId() {
return orgId;
}
public void setOrgId(Long orgId) {
this.orgId = orgId;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Long getMark() {
return mark;
}
public void setMark(Long mark) {
this.mark = mark;
}
public Long getDelflag() {
return delflag;
}
public void setDelflag(Long delflag) {
this.delflag = delflag;
}
public Long getRepeat() {
return repeat;
}
public void setRepeat(Long repeat) {
this.repeat = repeat;
}
public Long getBriefmark() {
return briefmark;
}
public void setBriefmark(Long briefmark) {
this.briefmark = briefmark;
}
public String getCheckDate() {
return checkDate;
}
public void setCheckDate(String checkDate) {
this.checkDate = checkDate;
}
public String getCheckName() {
return checkName;
}
public void setCheckName(String checkName) {
this.checkName = checkName;
}
public Long getRelevance() {
return relevance;
}
public void setRelevance(Long relevance) {
this.relevance = relevance;
}
public String getInfotype() {
return infotype;
}
public void setInfotype(String infotype) {
this.infotype = infotype;
}
public String getTids() {
return tids;
}
public void setTids(String tids) {
this.tids = tids;
}
public String getCreateDate() {
return createDate;
}
public void setCreateDate(String createDate) {
this.createDate = createDate;
}
public String getPublishDate() {
return publishDate;
}
public void setPublishDate(String publishDate) {
this.publishDate = publishDate;
}
public String getOrientation() {
return orientation;
}
public void setOrientation(String orientation) {
this.orientation = orientation;
}
public Long getWarnInfo() {
return warnInfo;
}
public void setWarnInfo(Long warnInfo) {
this.warnInfo = warnInfo;
}
public Long getWarnInfoPush() {
return warnInfoPush;
}
public void setWarnInfoPush(Long warnInfoPush) {
this.warnInfoPush = warnInfoPush;
}
public String getMatchKeywords() {
return matchKeywords;
}
public void setMatchKeywords(String matchKeywords) {
this.matchKeywords = matchKeywords;
}
public Long getIsFirstPublish() {
return isFirstPublish;
}
public void setIsFirstPublish(Long isFirstPublish) {
this.isFirstPublish = isFirstPublish;
}
public Long getFirstPublishBid() {
return firstPublishBid;
}
public void setFirstPublishBid(Long firstPublishBid) {
this.firstPublishBid = firstPublishBid;
}
}
package com.zzsn.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.util.Date;
/**
* @Description: 密点表
* @Author: zzsn-boot
* @Date: 2020-10-22
* @Version: V1.0
*/
@Data
@TableName("ces_sys_secret")
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
public class CesSysSecret implements Serializable {
private static final long serialVersionUID = 1L;
/**主键*/
@TableId(type = IdType.ID_WORKER_STR)
private String id;
/**创建人*/
private String createBy;
/**创建日期*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
private Date createTime;
/**更新人*/
private String updateBy;
/**更新日期*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
private Date updateTime;
/**内容*/
private String content;
/**密点类型*/
private Integer type;
/**密点等级*/
private Long secretLevel;
}
package com.zzsn.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.util.Date;
/**
* @Description: 网站信息源
* @Author: zzsn-boot
* @Date: 2020-10-21
* @Version: V1.0
*/
@Data
@TableName("ces_sys_web")
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
public class CesSysWeb implements Serializable {
private static final long serialVersionUID = 1L;
/**主键*/
@TableId(type = IdType.ID_WORKER_STR)
private String id;
/**创建人*/
private String createBy;
/**创建日期*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
private Date createTime;
/**更新人*/
private String updateBy;
/**更新日期*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
private Date updateTime;
/**网站*/
private String url;
/**网站名*/
private String name;
/**地点*/
private String local;
/**网址类型:1:科工局子机构网址,2:文章关联政府机构网址*/
private Long urlType;
/**开始时间*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
private Date startTime;
/**结束时间*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
private Date endTime;
}
package com.zzsn.entity;
import lombok.Data;
import org.springframework.data.elasticsearch.annotations.Document;
import java.io.Serializable;
import java.util.List;
@Data
public class EsBaseData implements Serializable {
private String id;
private String title;
private String keywords;
private String summary;
private String author;
private String sourceSite;
private String sourceAddress;
private String type;
private String withTagFile;
private String publishDate;
private String createBy;
private String createDate;
private String content;
private Long sid;
private String lang;
private Integer isDelete;
private Long orgId;
private String words;
private Long hits;
private String origin;
private String contentNoTag;
private String reliability;
private String influence;
private String orientation;
private String sourceType;
private String featureWords;
private String fileDownLoadPath;
private String contentImgCvtTag;
private Integer reprintCount;
private String fromWhere;
//RELATE_PLACES 相关国家城市地点信息
private String relatePlaces;
//LOCALE 信息所属国别(国别,不是城市)
private String locale;
@Override
public String toString() {
return "EsBaseData{" +
"id=" + id +
", title='" + title + '\'' +
", keywords='" + keywords + '\'' +
", summary='" + summary + '\'' +
", author='" + author + '\'' +
", sourceSite='" + sourceSite + '\'' +
", sourceAddress='" + sourceAddress + '\'' +
", type='" + type + '\'' +
", withTagFile='" + withTagFile + '\'' +
", publishDate='" + publishDate + '\'' +
", createBy='" + createBy + '\'' +
", createDate='" + createDate + '\'' +
", content='" + content + '\'' +
", sid=" + sid +
", lang='" + lang + '\'' +
", isDelete=" + isDelete +
", orgId=" + orgId +
", words='" + words + '\'' +
", hits=" + hits +
", origin='" + origin + '\'' +
", contentNoTag='" + contentNoTag + '\'' +
", reliability='" + reliability + '\'' +
", influence='" + influence + '\'' +
", orientation='" + orientation + '\'' +
", sourceType='" + sourceType + '\'' +
", featureWords='" + featureWords + '\'' +
", fileDownLoadPath='" + fileDownLoadPath + '\'' +
", contentImgCvtTag='" + contentImgCvtTag + '\'' +
", reprintCount=" + reprintCount +
", fromWhere='" + fromWhere + '\'' +
", relatePlaces='" + relatePlaces + '\'' +
", locale='" + locale + '\'' +
'}';
}
}
package com.zzsn.entity;
import lombok.Data;
import java.io.Serializable;
/**
* http请求响应体
*/
@Data
public class ResultModel<T> implements Serializable {
private boolean result;
/**
* 返回码
*/
private int code;
/**
* 返回结果描述
*/
private String msg;
/**
* 返回内容
*/
private T data;
public ResultModel() {
}
public T getData() {
return data;
}
private ResultModel(boolean result, int code, String msg) {
this.result = result;
this.code = code;
this.msg = msg;
}
private ResultModel(boolean result, int code, String msg, T data) {
this.result = result;
this.code = code;
this.msg = msg;
this.data = data;
}
public static ResultModel<Object> OK(Object data) {
return new ResultModel<>(true, 200, "成功", data);
}
public static ResultModel OK() {
return new ResultModel(true, 200, "成功");
}
public static ResultModel FAIL(String msg) {
return new ResultModel(false, -200, msg);
}
}
package com.zzsn.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import lombok.Data;
import java.io.Serializable;
@Data
@TableName(value = "CIS_SUBJECT")
@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
public class Subject implements Serializable {
/*
id
*/
String id;
/*
专题名称
*/
String title;
/*
专题动态
*/
@TableField(value="suject_dy",exist = false,typeHandler = org.apache.ibatis.type.BlobTypeHandler.class)
String sujectDy;
/*
观点分析
*/
@TableField(value="point_analysis",exist = false,typeHandler = org.apache.ibatis.type.BlobTypeHandler.class)
String pointAnalysis;
/*
事件脉络
*/
@TableField(value="event_context",exist = false,typeHandler = org.apache.ibatis.type.BlobTypeHandler.class)
String eventContext;
/*
传播路径
*/
@TableField(value="propagation_path",exist = false,typeHandler = org.apache.ibatis.type.BlobTypeHandler.class)
String propagationPath;
/*
统计分析
*/
@TableField(value="statistic_analysis",exist = false,typeHandler = org.apache.ibatis.type.BlobTypeHandler.class)
String statisticAnalysis;
/*
热词动态
*/
@TableField(value="hot_words",exist = false,typeHandler = org.apache.ibatis.type.BlobTypeHandler.class)
String hotWords;
}
package com.zzsn.entity.VO;
import lombok.Data;
@Data
public class WebTypeVo {
//网站ID
private String webId;
//网站分类ID
private Long webTypeId;
}
package com.zzsn.mapper;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zzsn.entity.BaseDataImage;
import com.zzsn.entity.Basedata;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
*
*/
@DS("master")
public interface BaseDataImageMapper extends BaseMapper<BaseDataImage> {
/**
* 插入单条数据
* @return
*/
int save(BaseDataImage baseDataImage);
/**
* 通过ID查询数据
* @param id
* @return
*/
BaseDataImage queryById(@Param("id") String id);
/**
* 批量插入要求
*/
int insertList(@Param("list") List<BaseDataImage> list);
/**
* 通过ID批量查询
*/
List<BaseDataImage> selectByIds(@Param("list") List<String> ids);
}
package com.zzsn.mapper;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zzsn.entity.Basedata;
import java.util.List;
import java.util.Map;
import org.apache.ibatis.annotations.Param;
public abstract interface BaseDataMapper extends BaseMapper<Basedata> {
@DS("slave")
public abstract List<Basedata> queryByCondition(Long paramLong);
@DS("master")
public abstract int insertList(@Param("list") List<Basedata> paramList);
@DS("master")
public abstract int queryByAddress(@Param("source") String paramString);
public abstract int save(@Param("item") Basedata paramBasedata);
public abstract Basedata getContent();
@DS("master")
public abstract void getserialno(Map<String, String> paramMap);
}
package com.zzsn.mapper;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zzsn.entity.Basedata;
import com.zzsn.entity.BasedataType;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* @author 陈如意
* @description: TODO
* @date 2020/9/28 9:26
*/
public interface BaseDataTypeMapper extends BaseMapper<BasedataType> {
/**
* 查询大于最大值后的数据
* @param maxId
* @param data
* @return
*/
@DS("slave")
List<BasedataType> queryByCondition(@Param("maxId") Long maxId, @Param("bids") List<String> data);
/**
* 批量插入数据
* @param list
* @return
*/
@DS("master")
int insertList(List<BasedataType> list);
}
package com.zzsn.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zzsn.entity.BaseDataWebMid;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* @Description: 网址分类中间表
* @Author: zzsn-boot
* @Date: 2021-01-05
* @Version: V1.0
*/
public interface BaseDataWebMidMapper extends BaseMapper<BaseDataWebMid> {
/**
* 批量插入
* @param baseDataWebList
* @return
*/
int insertBatch(@Param("list") List<BaseDataWebMid> baseDataWebList);
}
package com.zzsn.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zzsn.entity.CesSysSecret;
import java.util.List;
/**
* @Description: 密点表
* @Author: zzsn-boot
* @Date: 2020-10-22
* @Version: V1.0
*/
public interface CesSysSecretMapper extends BaseMapper<CesSysSecret> {
}
package com.zzsn.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zzsn.entity.CesSysWeb;
import com.zzsn.entity.VO.WebTypeVo;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* @Description: 网站信息源
* @Author: zzsn-boot
* @Date: 2020-10-21
* @Version: V1.0
*/
public interface CesSysWebMapper extends BaseMapper<CesSysWeb> {
/**
* 批量插入
* @param newWebList
* @return
*/
int insertBatch(@Param("list") List<CesSysWeb> newWebList);
/**
* 判断是否是科工局下边的子机构
* @param url
* @return
*/
WebTypeVo isKgj(@Param("url") String url);
}
package com.zzsn.mapper;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zzsn.entity.Subject;
import org.apache.ibatis.annotations.Param;
@DS("master")
public abstract interface SubjectMapper extends BaseMapper<Subject> {
@DS("master")
public abstract int insertMsg(@Param("item") Subject paramBasedata);
//
// @DS("master")
// public abstract int update(@Param("item") Subject paramBasedata);
}
<?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.zzsn.mapper.BaseDataImageMapper">
<resultMap id="baseDataMap" type="com.zzsn.entity.BaseDataImage" >
<result property="id" column="ID" />
<result property="dataImage" column="DATAIMAGE" typeHandler="com.zzsn.utils.BlobTypeHandler" />
<result property="bid" column="BID" />
</resultMap>
<insert id="save" parameterType="com.zzsn.entity.BaseDataImage" >
<!-- <insert id="save" parameterType="com.zzsn.entity.BaseDataImage" useGeneratedKeys="false">-->
insert into CIS_ANS_BASEDATA_IMAGE (
ID, DATAIMAGE
)values(#{id},
#{dataImage,jdbcType=BLOB,javaType=String,typeHandler=com.zzsn.utils.BlobTypeHandler}
)
</insert>
<select id="queryById" resultMap="baseDataMap">
select * from CIS_ANS_BASEDATA_IMAGE where id =#{id}
</select>
<select id="selectByIds" parameterType="java.util.List" resultMap="baseDataMap">
select * from CIS_ANS_BASEDATA_IMAGE
where 1=1 and
id in
<foreach collection="list" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</select>
<insert id="insertList" parameterType="java.util.List" useGeneratedKeys="false">
insert into CIS_ANS_BASEDATA_IMAGE (
ID, DATAIMAGE,BID
)
<foreach collection="list" item="item" index="index" separator="union all">
(select #{item.id},
#{item.dataImage,jdbcType=BLOB,javaType=String,typeHandler=com.zzsn.utils.BlobTypeHandler},
#{item.bid}
from dual)
</foreach>
</insert>
</mapper>
\ No newline at end of file
<?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.zzsn.mapper.BaseDataTypeMapper">
<resultMap id="basedataTypeMap" type="com.zzsn.entity.BasedataType" >
<result property="id" column="ID"/>
<result property="bid" column="BID"/>
<result property="tid" column="TID"/>
<result property="orgId" column="ORG_ID"/>
<result property="mark" column="MARK"/>
<result property="delflag" column="DELFLAG"/>
<result property="repeat" column="REPEAT"/>
<result property="briefmark" column="BRIEFMARK"/>
<result property="checkDate" column="CHECK_DATE"/>
<result property="checkName" column="CHECK_NAME"/>
<result property="relevance" column="RELEVANCE"/>
<result property="infotype" column="INFOTYPE"/>
<result property="createDate" column="CREATE_DATE"/>
<result property="publishDate" column="PUBLISH_DATE"/>
<result property="orientation" column="ORIENTATION"/>
<result property="warnInfo" column="WARN_INFO" />
<result property="warnInfoPush" column="WARN_INFO_PUSH" />
<result property="matchKeywords" column="MATCH_KEYWORDS" />
<result property="hotvalue" column="HOT_VALUE" />
<result property="repeatcount" column="REPEAT_COUNT" />
<result property="isFirstPublish" column="IS_FIRST_PUBLISH" />
<result property="firstPublishBid" column="FIRST_PUBLISH_BID" />
<result property="repeatFilter" column="REPEAT_FILTER" />
</resultMap>
<!-- select * from CIS_ANS_BASEDATA_TYPE where BID <![CDATA[>]]> #{maxId} order by id desc-->
<select id="queryByCondition" resultMap="basedataTypeMap">
select b.* from
CIS_ANS_BASEDATA_TYPE b
where
b.org_id = 3942
and b.bid in
<foreach collection="bids" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</select>
<insert id="insertList" parameterType="java.util.List">
insert into CIS_ANS_BASEDATA_TYPE (
BID, TID, ORG_ID, ID, MARK, DELFLAG,
REPEAT, BRIEFMARK, CHECK_DATE, RELEVANCE,
INFOTYPE, CHECK_NAME, PUBLISH_DATE, CREATE_DATE,
ORIENTATION, WARN_INFO, WARN_INFO_PUSH,
REPEAT_COUNT, HOT_VALUE, MATCH_KEYWORDS,
REPEAT_FILTER,IS_FIRST_PUBLISH,
FIRST_PUBLISH_BID
)
<foreach collection="list" item="item" index="index" separator="union all">
(select #{item.bid,jdbcType=NUMERIC},#{item.tid,jdbcType=NUMERIC},#{item.orgId,jdbcType=NUMERIC},
#{item.id,jdbcType=NUMERIC},#{item.mark,jdbcType=NUMERIC},#{item.delflag,jdbcType=NUMERIC},
#{item.repeat,jdbcType=NUMERIC},#{item.briefmark,jdbcType=NUMERIC},#{item.checkDate,jdbcType=VARCHAR},
#{item.relevance,jdbcType=NUMERIC},#{item.infotype,jdbcType=VARCHAR},#{item.checkName,jdbcType=VARCHAR},
#{item.publishDate,jdbcType=VARCHAR},#{item.createDate,jdbcType=VARCHAR},#{item.orientation,jdbcType=VARCHAR},
#{item.warnInfo,jdbcType=NUMERIC},#{item.warnInfoPush,jdbcType=NUMERIC},#{item.repeatcount,jdbcType=NUMERIC},
#{item.hotvalue,jdbcType=NUMERIC},#{item.matchKeywords,jdbcType=VARCHAR},#{item.repeatFilter,jdbcType=NUMERIC},
#{item.isFirstPublish,jdbcType=NUMERIC},#{item.firstPublishBid,jdbcType=NUMERIC}
from dual)
</foreach>
</insert>
</mapper>
\ No newline at end of file
<?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.zzsn.mapper.BaseDataWebMidMapper">
<insert id="insertBatch" parameterType="java.util.List" useGeneratedKeys="false">
insert into CIS_BASEDATA_WEB_MID
(ID,BID,WEB_ID)
<foreach collection="list" item="item" separator="union all" index="index">
(select
#{item.id,jdbcType=NUMERIC},
#{item.bId,jdbcType=NUMERIC},
#{item.webId,jdbcType=VARCHAR} from dual)
</foreach>
</insert>
</mapper>
\ No newline at end of file
<?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.zzsn.mapper.CesSysSecretMapper">
</mapper>
\ No newline at end of file
<?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.zzsn.mapper.CesSysWebMapper">
<insert id="insertBatch" parameterType="java.util.List" >
insert into CES_SYS_WEB
( id,create_by, create_time, url, name, local, url_type, start_time, end_time)
<foreach collection="list" item="item" index="index" separator="union all">
(select #{item.id,jdbcType=VARCHAR},#{item.createBy,jdbcType=VARCHAR}, #{item.createTime,jdbcType=TIMESTAMP},
#{item.url,jdbcType=VARCHAR}, #{item.name,jdbcType=VARCHAR},
#{item.local,jdbcType=VARCHAR}, #{item.urlType,jdbcType=NUMERIC},
#{item.startTime,jdbcType=TIMESTAMP}, #{item.endTime,jdbcType=TIMESTAMP} from dual)
</foreach>
</insert>
<select id="isKgj" resultType="com.zzsn.entity.VO.WebTypeVo">
select w.id as webId,s.ID as webTypeId from CIS_COL_SITE_TYPE s
inner join CIS_COL_SITE_TYPE_MID m on s.ID=m.TYPEID
inner join CES_SYS_WEB w on m.SITEID=w.ID
<where>
<if test="url!=null and url!=''">
w.url=#{url}
</if>
</where>
</select>
</mapper>
\ No newline at end of file
<?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.zzsn.mapper.SubjectMapper">
<resultMap id="basedataMap" type="com.zzsn.entity.Subject" >
<result property="id" column="ID" />
<result property="title" column="title" />
<result property="sujectDy" column="suject_dy" typeHandler="com.zzsn.utils.BlobTypeHandler"/>
<result property="pointAnalysis" column="point_analysis" typeHandler="com.zzsn.utils.BlobTypeHandler" />
<result property="eventContext" column="event_context" typeHandler="com.zzsn.utils.BlobTypeHandler" />
<result property="propagationPath" column="propagation_path" typeHandler="com.zzsn.utils.BlobTypeHandler" />
<result property="statisticAnalysis" column="statistic_analysis" typeHandler="com.zzsn.utils.BlobTypeHandler" />
<result property="hotWords" column="hot_words" typeHandler="com.zzsn.utils.BlobTypeHandler" />
</resultMap>
<insert id="insertMsg" parameterType="com.zzsn.entity.Subject" useGeneratedKeys="false">
insert into CIS_SUBJECT (
ID, TITLE, suject_dy, point_analysis, event_context,
propagation_path, statistic_analysis,hot_words
)values(#{item.id,jdbcType=NUMERIC},
#{item.title,jdbcType=VARCHAR},
#{item.sujectDy,jdbcType=BLOB,javaType=String,typeHandler=com.zzsn.utils.BlobTypeHandler},
#{item.pointAnalysis,jdbcType=BLOB,javaType=String,typeHandler=com.zzsn.utils.BlobTypeHandler},
#{item.eventContext,jdbcType=BLOB,javaType=String,typeHandler=com.zzsn.utils.BlobTypeHandler},
#{item.propagationPath,jdbcType=BLOB,javaType=String,typeHandler=com.zzsn.utils.BlobTypeHandler},
#{item.statisticAnalysis,jdbcType=BLOB,javaType=String,typeHandler=com.zzsn.utils.BlobTypeHandler},
#{item.hotWords,jdbcType=BLOB,javaType=String,typeHandler=com.zzsn.utils.BlobTypeHandler})
</insert>
</mapper>
package com.zzsn.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.zzsn.entity.Basedata;
public interface BaseDataService extends IService<Basedata> {
public abstract Long getserialno();
}
package com.zzsn.service;
public interface DataSyncService {
}
package com.zzsn.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.zzsn.entity.BaseDataWebMid;
/**
* @Description: 网址分类中间表
* @Author: zzsn-boot
* @Date: 2021-01-05
* @Version: V1.0
*/
public interface IBaseDataWebMidService extends IService<BaseDataWebMid> {
}
package com.zzsn.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.zzsn.entity.CesSysSecret;
/**
* @Description: 密点表
* @Author: zzsn-boot
* @Date: 2020-10-22
* @Version: V1.0
*/
public interface ICesSysSecretService extends IService<CesSysSecret> {
}
package com.zzsn.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.zzsn.entity.CesSysWeb;
/**
* @Description: 网站信息源
* @Author: zzsn-boot
* @Date: 2020-10-21
* @Version: V1.0
*/
public interface ICesSysWebService extends IService<CesSysWeb> {
boolean isExist(CesSysWeb cesSysWeb);
}
package com.zzsn.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.zzsn.entity.Subject;
public interface SubjectService extends IService<Subject> {
}
package com.zzsn.service;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang.StringUtils;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.parser.Tag;
import org.jsoup.select.Elements;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.http.client.SimpleClientHttpRequestFactory;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.util.SocketUtils;
import org.springframework.web.client.RestTemplate;
import java.net.InetSocketAddress;
import java.net.Proxy;
import java.util.*;
public class Test {
public static void main(String[] args) {
// Set<String> set = new HashSet<>();
// set.add("哈喽");
// set.add("哈喽");
// set.forEach(s -> System.out.println(s));
// set.remove("哈喽");
// set.forEach(s -> System.out.println("移除后"+s));
// SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory();
// requestFactory.setProxy(
// new Proxy(
// Proxy.Type.HTTP,
// new InetSocketAddress("123.73.147.183", 32223) //设置代理服务
// )
// );
// RestTemplate restTemplate = new RestTemplate(requestFactory);
RestTemplate restTemplate = new RestTemplate();
// HttpHeaders headers = new HttpHeaders();
// headers.setContentType(MediaType.MULTIPART_FORM_DATA);
//
// MultiValueMap<String, String> map= new LinkedMultiValueMap<String, String>();
// map.add("text", null);
//
// HttpEntity<MultiValueMap<String, String>> request = new HttpEntity<MultiValueMap<String, String>>(map, headers);
//
// ResponseEntity<String> response = restTemplate.postForEntity( "http://localhost:8018/extract/", request , String.class );
// String body = response.getBody();
// System.out.println("---->"+body);
// ResponseEntity<String> forEntity = restTemplate.getForEntity("http://www.baidu.com/s?wd=郑州市人民政府", String.class);
// String body = forEntity.getBody();
// System.out.println("---------->" + body);
Map<String, String> map = new HashMap<>();
map.put("name", "海南藏族自治州人民政府");
ResponseEntity response = restTemplate.getForEntity("http://www.baidu.com/s?wd={name}", String.class, map);
System.out.println("------->" + response.getStatusCode());
System.out.println("------->" + response.getStatusCodeValue());
String body = (String) response.getBody();
Document parse = Jsoup.parse(body);
Elements elementsByClass = parse.getElementsByClass("OP_LOG_LINK c-text c-text-public c-text-mult c-gap-left-small");
if(!(elementsByClass.size()>0)){
//带官方的元素为空,说明没有
System.out.println("没有带官方的网站");;
}
//获取第一个带官方的元素
Element element = elementsByClass.get(0);
Element element2 = element.previousElementSibling();
// Element parent = element.parent().firstElementSibling();
// Element element1 = element.parent().nextElementSibling();
// Elements elementsByClass1 = element1.getElementsByClass("c-showurl c-color-gray");
// Element element2 = elementsByClass1.get(0);
String text = element2.text();
// if(text.contains(".gov.cn")){
// System.out.println("---网址内容"+text);
// }else{
//如果不是,而是文本
String href = element2.attr("href");
System.out.println("href"+href);
String href1 = href.replace("http","https")+"&wd=&eqid=";
System.out.println("href1"+href1);
ResponseEntity response1 = restTemplate.getForEntity(href1, String.class);
// HttpHeaders headers = response1.getHeaders();
// List<String> location = headers.get("Location");
// System.out.println(location.get(0));
String body1 = (String) response1.getBody();
Document parse1 = Jsoup.parse(body1);
Elements noscript = parse1.getElementsByTag("noscript");
Element element3 = noscript.get(0);
Elements meta = element3.getElementsByTag("meta");
String url = meta.attr("content");
String s = "";
if(StringUtils.isNotBlank(url)){
int i = url.indexOf("'");
if(i!=-1 && i+1<url.length()-1){
s = url.substring(i + 1, url.length() - 1);
}
}
System.out.println("文字的政府地址为:"+s);
// }
}
}
package com.zzsn.service;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.SimpleFormatter;
public class Test1 {
public static void main(String[] args) {
// String s1 = "0;URL='https://www.henan.gov.cn/'";
// String s ="hehee'h";
// int i = s.indexOf("'");
// System.out.println(i);
// if(i+1<s.length()){
// System.out.println("---->"+s.substring(i+1,s.length()-1));
// }
// SimpleDateFormat simpleFormat= new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
// Date date = new Date();
// System.out.println("今天的日期是:"+simpleFormat.format(date));
// Calendar instance = Calendar.getInstance();
// instance.setTime(date);
// instance.set(Calendar.DATE,instance.get(Calendar.DATE)+2);
// System.out.println(simpleFormat.format(instance.getTime()));
Map map = new HashMap();
for (Object o : map.entrySet()) {
System.out.println("/////////");
}
}
}
package com.zzsn.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zzsn.entity.Basedata;
import com.zzsn.mapper.BaseDataMapper;
import com.zzsn.service.BaseDataService;
import java.util.HashMap;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@Service
public class BaseDataServiceImpl extends ServiceImpl<BaseDataMapper, Basedata>
implements BaseDataService
{
private static final Logger log = LoggerFactory.getLogger(BaseDataServiceImpl.class);
@Autowired
private BaseDataMapper baseDataMapper;
@Transactional
public Long getserialno() {
log.info("生成bid");
Map map = new HashMap();
map.put("serialNo", null);
map.put("e", null);
this.baseDataMapper.getserialno(map);
String error = (String)map.get("e");
if (error == null) {
return Long.valueOf((String)map.get("serialNo"));
}
return null;
// this.baseDataMapper.autoIncrement();
// String orderId= this.baseDataMapper.getorderId();
// return Long.valueOf(orderId);
}
}
\ No newline at end of file
package com.zzsn.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zzsn.entity.BaseDataWebMid;
import com.zzsn.mapper.BaseDataWebMidMapper;
import com.zzsn.service.IBaseDataWebMidService;
import org.springframework.stereotype.Service;
@Service
public class BaseDataWebMidServiceImpl extends ServiceImpl<BaseDataWebMidMapper, BaseDataWebMid> implements IBaseDataWebMidService {
}
package com.zzsn.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zzsn.entity.CesSysSecret;
import com.zzsn.mapper.CesSysSecretMapper;
import com.zzsn.service.ICesSysSecretService;
import org.springframework.stereotype.Service;
/**
* @Description: 密点表
* @Author: zzsn-boot
* @Date: 2020-10-22
* @Version: V1.0
*/
@Service
public class CesSysSecretServiceImpl extends ServiceImpl<CesSysSecretMapper, CesSysSecret> implements ICesSysSecretService {
}
package com.zzsn.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zzsn.entity.CesSysWeb;
import com.zzsn.mapper.CesSysWebMapper;
import com.zzsn.service.ICesSysWebService;
import org.springframework.stereotype.Service;
/**
* @Description: 网站信息源
* @Author: zzsn-boot
* @Date: 2020-10-21
* @Version: V1.0
*/
@Service
public class CesSysWebServiceImpl extends ServiceImpl<CesSysWebMapper, CesSysWeb> implements ICesSysWebService {
@Override
public boolean isExist(CesSysWeb cesSysWeb) {
QueryWrapper<CesSysWeb> wrapper = new QueryWrapper<>();
wrapper.eq("URL",cesSysWeb.getUrl());
if (cesSysWeb.getId() != null) {
wrapper.ne("id", cesSysWeb.getId());
}
int count = count(wrapper);
return count(wrapper) > 0;
}
}
package com.zzsn.service.impl;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.zzsn.constant.PageConstant;
import com.zzsn.entity.Basedata;
import com.zzsn.entity.BasedataType;
import com.zzsn.mapper.BaseDataTypeMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Service
public class DataTypeSyncServiceImpl extends ServiceImpl<BaseDataTypeMapper, BasedataType> {
private Logger logger = LoggerFactory.getLogger(DataTypeSyncServiceImpl.class);
@Autowired
private BaseDataTypeMapper dataTypeMapper;
/**
* 同步数据
*/
public List<BasedataType> processSync(Long maxId, List<String> repeatIDList, List<Basedata> data){
logger.info("开始同步basedataType:maxId:[{}],重复数据:[{}]",maxId,repeatIDList);
//2.查询数据库basedataType表新增的数据
List<BasedataType> basedataList = query(maxId,data);
if(!(basedataList.size()>0)){
//如果新增加的数据为0,不处理,直接返回。
return new ArrayList<>();
}
//3.先处理重复数据
List<BasedataType> resultList = new ArrayList<>();
if(repeatIDList !=null && repeatIDList.size()>0){
Map<Long, BasedataType> map = basedataList.stream()
.collect(Collectors.toMap(BasedataType::getBid, BasedataType -> BasedataType));
for (String s : repeatIDList) {
map.remove(new Long(s));
}
resultList = new ArrayList<>(map.values());
}else{
resultList = basedataList;
}
//去重ID
return resultList;
}
/**
* 插入数据到科工局数据库中
* @param list
*/
// @DS("slave")
// @Transactional()
// public int insertBatch(List<BasedataType> list ){
// logger.info("批量插入新的数据到科工局数据库中",list);
// //批量插入新的数据到科工局数据库中
// int i = dataTypeMapper.insertList(list);
// return i;
// }
/**
* 查询公司数据库中新增的数据
* @param maxId
* @param data
* @return
*/
// @DS("slave")
public List<BasedataType> query(Long maxId, List<Basedata> data){
logger.info("查询公司数据库basedataType新增数据{}",maxId);
// PageHelper.startPage(PageConstant.page, PageConstant.pageSize);
if(CollectionUtils.isEmpty(data)){
return new ArrayList<BasedataType>();
}
//bid列表
List<String> bidList = data.stream().map(basedata -> {
return basedata.getId();
}).collect(Collectors.toList());
List<BasedataType> basedataList = dataTypeMapper.queryByCondition(maxId,bidList);
return basedataList;
}
}
package com.zzsn.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zzsn.entity.Subject;
import com.zzsn.mapper.SubjectMapper;
import com.zzsn.service.SubjectService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class SubjectServiceImpl extends ServiceImpl<SubjectMapper, Subject>
implements SubjectService
{
private static final Logger log = LoggerFactory.getLogger(SubjectServiceImpl.class);
@Autowired
private SubjectMapper subjectMapper;
// @Override
// public boolean save(Subject entity) {
// return super.save(entity);
// }
}
\ No newline at end of file
//package com.example.chen.demo.test;
//
//import java.sql.Connection;
// import java.sql.PreparedStatement;
// import java.sql.ResultSet;
// import java.sql.Statement;
// import java.util.List;
// import java.util.concurrent.atomic.AtomicLong;
//
// import org.apache.log4j.Logger;
//
// /**
// * <p>
// * title: 数据同步类
// * </p>
// * <p>
// * Description: 该类用于将生产核心库数据同步到开发库
// * </p>
// *
// * @author Tank Zhang
// */
// public class CoreDataSyncImpl {
//
// private List<String> coreTBNames; // 要同步的核心库表名
// private ConnectionFactory connectionFactory;
// private Logger log = Logger.getLogger(getClass());
//
// private AtomicLong currentSynCount = new AtomicLong(0L); // 当前已同步的条数
//
// private int syncThreadNum; // 同步的线程数
//
// public void syncData(int businessType) throws Exception {
//
// for (String tmpTBName : coreTBNames) {
// log.info("开始同步核心库" + tmpTBName + "表数据");
// // 获得核心库连接
// Connection coreConnection = connectionFactory.getDMSConnection(4);
// Statement coreStmt = coreConnection.createStatement();
// // 为每个线程分配结果集
// ResultSet coreRs = coreStmt.executeQuery("SELECT count(*) FROM "+tmpTBName);
// coreRs.next();
// // 总共处理的数量
// long totalNum = coreRs.getLong(1);
// // 每个线程处理的数量
// long ownerRecordNum =(long) Math.ceil((totalNum / syncThreadNum));
// log.info("共需要同步的数据量:"+totalNum);
// log.info("同步线程数量:"+syncThreadNum);
// log.info("每个线程可处理的数量:"+ownerRecordNum);
// // 开启五个线程向目标库同步数据
// for(int i=0; i < syncThreadNum; i ++){
// StringBuilder sqlBuilder = new StringBuilder();
// // 拼装后SQL示例
// // Select * From dms_core_ds Where id between 1 And 657398
// // Select * From dms_core_ds Where id between 657399 And
// // 1314796
// // Select * From dms_core_ds Where id between 1314797 And
// // 1972194
// // Select * From dms_core_ds Where id between 1972195 And
// // 2629592
// // Select * From dms_core_ds Where id between 2629593 And
// // 3286990
// // ..
// sqlBuilder.append("Select * From ").append(tmpTBName)
// .append(" Where id between " ).append(i * ownerRecordNum +1)
// .append( " And ")
// .append((i * ownerRecordNum + ownerRecordNum));
// Thread workThread = new Thread(
// new WorkerHandler(sqlBuilder.toString(),businessType,tmpTBName));
// workThread.setName("SyncThread-"+i);
// workThread.start();
// }
// while (currentSynCount.get() < totalNum);
// // 休眠一会儿让数据库有机会commit剩余的批处理(只针对JUnit单元测试,因为单元测试完成后会关闭虚拟器,使线程里的代码没有机会作提交操作);
// // Thread.sleep(1000 * 3);
// log.info( "核心库"+tmpTBName+"表数据同步完成,共同步了" + currentSynCount.get() + "条数据");
// }
// }// end for loop
//
// public void setCoreTBNames(List<String> coreTBNames) {
// this.coreTBNames = coreTBNames;
// }
//
// public void setConnectionFactory(ConnectionFactory connectionFactory) {
// this.connectionFactory = connectionFactory;
// }
//
// public void setSyncThreadNum(int syncThreadNum) {
// this.syncThreadNum = syncThreadNum;
// }
//
// // 数据同步线程
// final class WorkerHandler implements Runnable {
// ResultSet coreRs;
// String queryStr;
// int businessType;
// String targetTBName;
// public WorkerHandler(String queryStr,int businessType,String targetTBName) {
// this.queryStr = queryStr;
// this.businessType = businessType;
// this.targetTBName = targetTBName;
// }
// @Override
// public void run() {
// try {
// // 开始同步
// launchSyncData();
// } catch(Exception e){
// log.error(e);
// e.printStackTrace();
// }
// }
// // 同步数据方法
// void launchSyncData() throws Exception{
// // 获得核心库连接
// Connection coreConnection = connectionFactory.getDMSConnection(4);
// Statement coreStmt = coreConnection.createStatement();
// // 获得目标库连接
// Connection targetConn = connectionFactory.getDMSConnection(businessType);
// targetConn.setAutoCommit(false);// 设置手动提交
// PreparedStatement targetPstmt = targetConn.prepareStatement("INSERT INTO " + targetTBName+" VALUES (?,?,?,?,?)");
// ResultSet coreRs = coreStmt.executeQuery(queryStr);
// log.info(Thread.currentThread().getName()+"'s Query SQL::"+queryStr);
// int batchCounter = 0; // 累加的批处理数量
// while (coreRs.next()) {
// targetPstmt.setString(1, coreRs.getString(2));
// targetPstmt.setString(2, coreRs.getString(3));
// targetPstmt.setString(3, coreRs.getString(4));
// targetPstmt.setString(4, coreRs.getString(5));
// targetPstmt.setString(5, coreRs.getString(6));
// targetPstmt.addBatch();
// batchCounter++;
// currentSynCount.incrementAndGet();// 递增
// if (batchCounter % 10000 == 0) { // 1万条数据一提交
// targetPstmt.executeBatch();
// targetPstmt.clearBatch();
// targetConn.commit();
// }
// }
// // 提交剩余的批处理
// targetPstmt.executeBatch();
// targetPstmt.clearBatch();
// targetConn.commit();
// // 释放连接
// connectionFactory.release(targetConn, targetPstmt,coreRs);
// }
// }
// }
\ No newline at end of file
package com.zzsn.test;
import com.zzsn.constant.PageConstant;
import com.zzsn.entity.*;
import com.zzsn.mapper.BaseDataImageMapper;
import com.zzsn.mapper.CesSysSecretMapper;
import com.zzsn.service.ICesSysWebService;
import com.zzsn.service.impl.DataSyncServiceImpl;
import com.zzsn.service.impl.DataTypeSyncServiceImpl;
import com.zzsn.utils.FileUtil;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.ClassPathResource;
import org.springframework.util.ResourceUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@RestController
public class Test {
private Logger logger = LoggerFactory.getLogger(Test.class);
@Autowired
private DataSyncServiceImpl dataSyncService;
@Autowired
private DataTypeSyncServiceImpl dataTypeSyncService;
@Autowired
private BaseDataImageMapper imageMapper;
@Autowired
private CesSysSecretMapper cesSysSecretMapper;
@Autowired
private ICesSysWebService webService;
@GetMapping("/test")
public void test() throws IOException {
String jar_parent = new File(ResourceUtils.getURL("classpath:").getPath()).getParentFile().getParentFile().getParent();
System.out.println(jar_parent);
//1.获取上一次的ID最大值
String s = FileUtil.getMaxId(PageConstant.path);
String str = s.substring(s.lastIndexOf("=")+1);
Long maxId = new Long(str);
if(maxId == null){
logger.info("txt文件中最大值ID错误");
throw new RuntimeException("配置文件中的最大值ID错误");
}
//2.获取basedata表重复的数据和表中要插入的数据
Map<String, Object> map = dataSyncService.repeat(maxId);
//重复数据
List<String> repeatList = (List<String>) map.get("repeat");
//3.获取basedataType要同步到数据库的数据
List<BasedataType> typeList = dataTypeSyncService.processSync(maxId, repeatList, null);
//4.通过密点库对要插入到basedata的信息进行过滤
Map<String, Object> secretMap = dataSyncService.secret((List<Basedata>) map.get("data"),typeList);
//5.插入之前对basedata中的内容包涵图片的进行base64转码
// List<Basedata> baseData = dataSyncService.imgHandler((List<Basedata>) secretMap.get("data"));
//6.插入到科工局数据库
dataSyncService.insertBatch((List<Basedata>) secretMap.get("data"), (List<BasedataType>) secretMap.get("typeData"),null,null,null,null);
//7.同步到es库中
// dataSyncService.syncEsData((List<Basedata>) secretMap.get("data"));
//8.更改txt文件中maxId的值
if(!StringUtils.isBlank((String) map.get("newMaxId"))){
String content = "maxId="+map.get("newMaxId");
logger.info("更新txt文件{}",content);
FileUtil.updateId(PageConstant.path,content);
}
}
@GetMapping("/content")
public String getContent(){
Basedata basedata = dataSyncService.getContent();
return basedata.getContent();
}
@GetMapping("/test2")
public void test2() throws FileNotFoundException {
String jar_parent = new File(ResourceUtils.getURL("classpath:").getPath()).getParentFile().getParent();
System.out.println(jar_parent);
String path1 = ResourceUtils.getURL("classpath:").getPath();
System.out.println(path1);
ClassPathResource classPathResource = new ClassPathResource("application.yml");
String path = classPathResource.getPath();
File file = new File(ResourceUtils.getURL("classpath:").getPath());
String absolutePath = file.getAbsolutePath();
System.out.println(absolutePath);
System.out.println(path);
}
@GetMapping("/test3")
public ResultModel get(){
List<CesSysSecret> secretList = cesSysSecretMapper.selectByMap(new HashMap<>());
return ResultModel.OK(secretList);
}
@GetMapping("/image")
public ResultModel getImage(@RequestParam("id") String id){
return ResultModel.OK(imageMapper.queryById(id));
}
public static void main(String[] args) throws IOException {
// DataSyncServiceImpl dataSyncService = new DataSyncServiceImpl();
// DataTypeSyncServiceImpl dataTypeSyncService = new DataTypeSyncServiceImpl();
// String path ="config.txt";
// //1.获取上一次的最大值
// String s = FileUtil.getMaxId(path);
// String maxId = s.substring(s.lastIndexOf("="));
// if(StringUtils.isBlank(maxId)){
//// logger.info("最大值ID错误");
// throw new RuntimeException("配置文件中的最大值ID错误");
// }
// //获取重复的数据和basedata表中要插入的数据
// Map<String, Object> map = dataSyncService.repeat(maxId);
// //重复数据
// List<String> repeatList = (List<String>) map.get("repeat");
// //basedata表中的数据
// List<Basedata> data = (List<Basedata>) map.get("data");
// //获取basedataType要同步到数据库的数据
// List<BasedataType> typeList = dataTypeSyncService.processSync(maxId, repeatList);
// //插入到科工局数据库
//// dataSyncService.insertBatch(data, typeList);
// //更改txt文件中maxId的值
// if(!StringUtils.isBlank((String) map.get("newMaxId"))){
// String content = "maxId="+map.get("newMaxId");
// FileUtil.updateId(path,content);
// }
}
}
package com.zzsn.test;
import com.zzsn.utils.ContentFileFinder;
import com.zzsn.utils.FileTag;
import org.jsoup.Jsoup;
import org.jsoup.safety.Whitelist;
import org.springframework.core.io.ClassPathResource;
import org.springframework.jdbc.datasource.DataSourceUtils;
import java.io.*;
import java.sql.Blob;
import java.util.Map;
import java.util.Set;
public class Test2 {
public static void main (String[] args) throws IOException {
String s =content();
Map<String, FileTag> contentFileTag = ContentFileFinder.getContentFileTag(s, "http://www.csicl.com.cn/n332/n334/c24531/content.html");
for (Map.Entry<String, FileTag> mapentry :
contentFileTag.entrySet()) {
System.out.println(mapentry.getKey()+":"+mapentry.getValue().getAbsolutePath());
}
}
public static String content(){
String content="<div class=\"article_text\" id=\"zoom\">\n" +
" <p style=\"TEXT-ALIGN: center\">\n" +
" <video controls=\"controls\" loop=\"loop\" width=\"640\" height=\"338\" src=\"../../../n332/n336/c23793/part/28631.mp4\">\n" +
" <object classid=\"clsid:6bf52a52-394a-11d3-b153-00c04f79faa6\" width=\"640\" height=\"338\"> <param name=\"url\" value=\"../../../n332/n336/c23793/part/28631.mp4\"> <param name=\"autostart\" value=\"false\"> <param name=\"uimode\" value=\"full\"><embed type=\"application/x-mplayer2\" src=\"../../../n332/n336/c23793/part/28631.mp4\" width=\"640\" height=\"338\" autostart=\"false\" uimode=\"full\" pluginspage=\"http://microsoft.com/windows/mediaplayer/en/download/\"></object>\n" +
" </video></p> \n" +
"<p>  7月17日,央视《新闻联播》对我国造船国际市场份额继续位居世界第一进行了报道。数据显示,一至六月份,我国造船完工量、新接订单量、手持订单量,以载重吨计分别占世界总量的45.2%、50.8%和47.8%,国际市场份额继续位居世界第一。 <br> <br> 来源:央视《新闻联播》</p>\n" +
" </div>";
return content;
}
}
package com.zzsn.utils;
import org.apache.commons.lang.StringUtils;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* @author zhan
* @date 2020/04/08 17:19:14
* @description 地址解析工具类
*/
public class AddressUtil {
/**
* 解析地址
* @param address
* @return
*/
public static Map<String,String> getAddressInfo(String address) {
//1级 省 自治区 2级 市 自治州 地区 3级:区县市旗(镇?)
String province = null, city = null, provinceAndCity = null, town = null ;
Map<String, String> row = new LinkedHashMap<>();
List<Map<String, String>> table = new ArrayList<>();
Map<String,String> resultMap = new HashMap<>(4);
if (address.startsWith("香港特别行政区")) {
resultMap.put("province","香港");
return resultMap;
} else if (address.contains("澳门特别行政区")) {
resultMap.put("province","澳门");
return resultMap;
} else if (address.contains("台湾")) {
resultMap.put("province","台湾");
return resultMap;
} else {
//普通地址
String regex = "((?<provinceAndCity>[^市]+市|.*?自治州|.*?区|.*县)(?<town>[^区]+区|.*?市|.*?县|.*?路|.*?街|.*?道|.*?镇|.*?旗)(?<detailAddress>.*))";
Matcher m = Pattern.compile(regex).matcher(address);
while (m.find()) {
provinceAndCity = m.group("provinceAndCity");
String regex2 = "((?<province>[^省]+省|.+自治区|上海市|北京市|天津市|重庆市|上海|北京|天津|重庆)(?<city>.*))";
Matcher m2 = Pattern.compile(regex2).matcher(provinceAndCity);
while (m2.find()) {
province = m2.group("province");
row.put("province", province == null ? "" : province.trim());
city = m2.group("city");
row.put("city", city == null ? "" : city.trim());
}
town = m.group("town");
row.put("town", town == null ? "" : town.trim());
table.add(row);
}
}
if (table != null && table.size() > 0) {
if (StringUtils.isNotBlank(table.get(0).get("province"))) {
province = table.get(0).get("province");
//对自治区进行处理
if (province.contains("自治区")) {
if (province.contains("内蒙古")) {
province = province.substring(0,4);
} else {
province = province.substring(0,3);
}
}
}
if (StringUtils.isNotBlank(province)) {
if (StringUtils.isNotBlank(table.get(0).get("city"))) {
city = table.get(0).get("city");
if (city.equals("上海市") || city.equals("重庆市") || city.equals("北京市") || city.equals("天津市")) {
province = table.get(0).get("city");
}
}
else if (province.equals("上海市") || province.equals("重庆市") || province.equals("北京市") || province.equals("天津市")) {
city = province;
}
if (StringUtils.isNotBlank(table.get(0).get("town"))) {
town = table.get(0).get("town");
}
province = province.substring(0,province.length() - 1);
}
} else {
return resultMap;
}
resultMap.put("province",province);
resultMap.put("city",city);
resultMap.put("district",town);
return resultMap;
}
public static void main(String[] args) {
// Map<String, String> map = getAddressInfo("广东省深圳市南山区东滨路205号");
// Map<String, String > map = getAddressInfo("上海市虹口区飞虹路518号");
// Map<String, String > map = getAddressInfo("河北省廊坊市三河市燕顺路1140号");
// Map<String, String> map = getAddressInfo("香港特别行政区油尖旺区广华街58号");
// Map<String, String> map = getAddressInfo("黑龙江省大兴安岭地区呼玛县合兴街");
// Map<String, String> map = getAddressInfo("江苏省南京市江宁区202县道");
// Map<String, String> map = getAddressInfo("海南省陵水黎族自治县陵水黎族自治县提蒙大道215号");
// Map<String, String> map = getAddressInfo("山东省烟台市龙口市062县道");
// Map<String, String> map = getAddressInfo("新疆维吾尔自治区乌鲁木齐市沙依巴克区阿里山街");
// Map<String, String> map = getAddressInfo("内蒙古自治区呼伦贝尔市鄂温克族自治旗");
// Map<String, String> map = getAddressInfo("日本滋贺县甲賀市県道507号線");
// Map<String, String> map = getAddressInfo("广东省东莞市仍然市振华路290号");
Map<String, String > map = getAddressInfo("海南藏族自治州");
map.entrySet().stream().forEach(item -> {
System.out.println(item.getKey()+":"+item.getValue());
});
}
}
package com.zzsn.utils;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.sql.Blob;
import java.sql.CallableStatement;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import org.apache.ibatis.type.BaseTypeHandler;
import org.apache.ibatis.type.JdbcType;
import org.apache.ibatis.type.MappedJdbcTypes;
import org.apache.ibatis.type.MappedTypes;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* BLOB类型转换器
* 创建人:李东亮
* 创建时间:2015-5-30 下午2:28:19
* 公司 :郑州数能软件科技有限公司
* @version 1.0
*
*/
//@MappedJdbcTypes(JdbcType.BLOB) // 声明数据库中对应数据类型
//@MappedTypes(value = String.class)
public class BlobTypeHandler extends BaseTypeHandler<String> {
@Override
public String getNullableResult(ResultSet rs, String columnName)
throws SQLException {
// TODO Auto-generated method stub
Blob blob = rs.getBlob(columnName);
if(blob==null){
return null;
}
return this.readBlob(blob, "UTF-8" );
}
@Override
public String getNullableResult(ResultSet rs, int columnIndex)
throws SQLException {
// TODO Auto-generated method stub
Blob blob = rs.getBlob(columnIndex);
String charset = rs.getString("charset");
if(charset==null){
charset = "UTF-8";
}
return this.readBlob(blob,charset);
}
@Override
public String getNullableResult(CallableStatement cs, int columnIndex)
throws SQLException {
// TODO Auto-generated method stub
Blob blob = cs.getBlob(columnIndex);
if(blob==null){
return null;
}
return this.readBlob(blob, cs.getString("charset"));
}
@Override
public void setNonNullParameter(PreparedStatement ps, int columnIndex,
String content, JdbcType jdbcType) throws SQLException {
// TODO Auto-generated method stub
try {
ps.setBlob(columnIndex, new ByteArrayInputStream(content.getBytes("UTF-8")));
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
/**
* 获取blob字段值
* 创建人: 李东亮
* 创建时间: 2015-5-28 上午9:40:21
* @version 1.0
* @param blob
* @return
*/
private String readBlob(Blob blob,String charset){
StringBuffer result = new StringBuffer();
if (blob != null) {
try {
InputStream input = blob.getBinaryStream();
BufferedReader br = new BufferedReader(new InputStreamReader(
input,"UTF-8"));
char[] buffer = new char[256];
int length = -1;
while ((length = br.read(buffer)) != -1) {
result.append(new String(buffer,0,length));
}
/* byte[] buffer = new byte[512];
int length = -1;
while((length=input.read(buffer))!=-1){
result.append();
}*/
} catch (SQLException | IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
return result.toString();
}
public static void main(String[] args) {
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论