Commit 613bd30a by liulianglang

合成作战工作室

parents
# http://editorconfig.org
root = true
# 空格替代Tab缩进在各种编辑工具下效果一致
[*]
indent_style = space
indent_size = 4
charset = utf-8
end_of_line = lf
trim_trailing_whitespace = true
insert_final_newline = true
[*.java]
indent_style = tab
[*.{json,yml}]
indent_size = 2
[*.md]
insert_final_newline = false
trim_trailing_whitespace = false
/target/
.idea/
.mvn/
.classpath
.project
.settings
##filter databfile、sln file##*.mdb
*.ldb
*.sln
##class file##*.com
*.class
*.dll
*.exe
*.o
*.so
# compression file
*.7z
*.dmg
*.gz
*.iso
*.jar
*.rar
*.iml
*.ipr
*.iws
# Compiled class file
# Log file
*.log
# BlueJ files
*.ctxt
# Mobile Tools for Java (J2ME)
.mtj.tmp/
# Package Files #
*.war
*.ear
*.zip
*.tar.gz
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
*.bak
### Maven templatepom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
pom.xml.next
release.properties
dependency-reduced-pom.xml
buildNumber.properties
.mvn/timing.properties
# Avoid ignoring Maven wrapper jar file (.jar files are usually ignored)
!/.mvn/wrapper/maven-wrapper.jar
/.idea/
/.idea/
FROM anapsix/alpine-java:8_server-jre_unlimited
MAINTAINER smallchill@163.com
RUN mkdir -p /blade
WORKDIR /blade
EXPOSE 8800
ADD ./target/SpringBlade.jar ./app.jar
ENTRYPOINT ["java", "-Djava.security.egd=file:/dev/./urandom", "-jar", "app.jar"]
CMD ["--spring.profiles.active=test"]
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
/**
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springblade;
import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure;
import org.springblade.common.constant.LauncherConstant;
import org.springblade.core.launch.BladeApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
/**
* 启动器
*
* @author Chill
*/
@EnableScheduling
@SpringBootApplication(exclude = DruidDataSourceAutoConfigure.class)
@EnableAsync
@EnableAspectJAutoProxy(exposeProxy = true)
public class Application {
public static void main(String[] args) {
BladeApplication.run(LauncherConstant.APPLICATION_NAME, Application.class, args);
}
}
/**
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springblade.common.cache;
/**
* 缓存名
*
* @author Chill
*/
public interface CacheNames {
String NOTICE_ONE = "notice:one";
String DICT_VALUE = "dict:value";
String DICT_LIST = "dict:list";
String CAPTCHA_KEY = "blade:auth::captcha:";
}
package org.springblade.common.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import java.util.concurrent.Executor;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
/**
* @author zzj
* async注解默认线程池无最大限制,可能导致oom
*/
@Configuration
public class AsyncPoolConfig {
/**
* 核心线程数
*/
private static final Integer corePoolSize = Runtime.getRuntime().availableProcessors() + 1;
/**
* 最大线程数
*/
private static final Integer maxPoolSize = corePoolSize * 2;
/**
* 线程池维护线程所允许的空闲时间
*/
private static final Integer keepAliveTime = 60;
/**
* 线程阻塞队列,核心线程数满之后提交的任务先放入该队列,该队列满之后创建最大线程
*/
private static int queueSize = 100;
@Bean("async-executor")
public Executor asyncExecutor() {
ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();
taskExecutor.setCorePoolSize(corePoolSize);
taskExecutor.setMaxPoolSize(maxPoolSize);
taskExecutor.setQueueCapacity(queueSize);
taskExecutor.setKeepAliveSeconds(keepAliveTime);
taskExecutor.setThreadNamePrefix("async-executor-");
//线程拒绝策略-主线程执行
taskExecutor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
taskExecutor.initialize();
return taskExecutor;
}
}
/**
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springblade.common.config;
import org.springblade.core.secure.registry.SecureRegistry;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
/**
* Blade配置
*
* @author Chill
*/
@Configuration
public class BladeConfiguration implements WebMvcConfigurer {
@Autowired
private UserHandlerConfig userHandlerConfig;
@Bean
public SecureRegistry secureRegistry() {
SecureRegistry secureRegistry = new SecureRegistry();
secureRegistry.setEnabled(true);
secureRegistry.excludePathPatterns("/dddl/**");
secureRegistry.excludePathPatterns("/selectXsByAsjbh");
secureRegistry.excludePathPatterns("/selectThtjByAsjbh");
secureRegistry.excludePathPatterns("/blade-auth/**");
secureRegistry.excludePathPatterns("/api/sys/**");
secureRegistry.excludePathPatterns("/blade-log/**");
secureRegistry.excludePathPatterns("/blade-system/menu/auth-routes");
secureRegistry.excludePathPatterns("/doc.html");
secureRegistry.excludePathPatterns("/js/**");
secureRegistry.excludePathPatterns("/webjars/**");
secureRegistry.excludePathPatterns("/swagger-resources/**");
secureRegistry.excludePathPatterns("/ajzljc/**");
secureRegistry.excludePathPatterns("/refreshCodeCache");
secureRegistry.excludePathPatterns("/reloadSysDict");
secureRegistry.excludePathPatterns("/refreCaCheCode");
secureRegistry.excludePathPatterns("/xsbk/executeBkTask");
secureRegistry.excludePathPatterns("/ajQuery/initTh");
secureRegistry.excludePathPatterns("/hcyprw/getFkfjByXxzjbh");
secureRegistry.excludePathPatterns("/tjpg/*");
secureRegistry.excludePathPatterns("/bbkwp/*");
secureRegistry.excludePathPatterns("/queryCodeByType");
secureRegistry.excludePathPatterns("/whitelist/check");
secureRegistry.excludePathPatterns("/qqzc/flow/getDzqqByAsjbhAndSjh");
secureRegistry.excludePathPatterns("/qqzc/flow/getDzqqByAsjbhAndSjhCount");
secureRegistry.excludePathPatterns("/qqzc/flow/exportDzqqByAsjbhAndSjh");
secureRegistry.excludePathPatterns("/qqzc/flow/getDzqqListByAsjbh");
secureRegistry.excludePathPatterns("/qqzc/flow/getDzqqListByAsjbhCount");
secureRegistry.excludePathPatterns("/qqzc/unitAndPeople/createLogsForRxbd");
secureRegistry.excludePathPatterns("/qqzc/unitAndPeople/createLogsForDzgl");
// secureRegistry.excludePathPatterns("/**");
// secureRegistry.excludePathPatterns("/detail/**");
// secureRegistry.excludePathPatterns("/cbxsz/**");
/*secureRegistry.excludePathPatterns("/**");
secureRegistry.excludePathPatterns("/ajDetail/**");
secureRegistry.excludePathPatterns("/tbstAsj/stasj*");
secureRegistry.excludePathPatterns("/matj*");
secureRegistry.excludePathPatterns("/tbstAsj/stasjCj*");
secureRegistry.excludePathPatterns("/tbStRyZp/**");
secureRegistry.excludePathPatterns("/flwsFj*");
secureRegistry.excludePathPatterns("/maMaptj*");
secureRegistry.excludePathPatterns("/getFlwsCountForAutoCheck");
secureRegistry.excludePathPatterns("/getFlwsForAutoSwCheck");
secureRegistry.excludePathPatterns("/ajxq*");
secureRegistry.excludePathPatterns("/ajsp*");*/
return secureRegistry;
}
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/js/**").addResourceLocations("classpath:/js/");
registry.addResourceHandler("doc.html")
.addResourceLocations("classpath:/META-INF/resources/");
registry.addResourceHandler("/webjars/**")
.addResourceLocations("classpath:/META-INF/resources/webjars/");
}
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(userHandlerConfig)
.excludePathPatterns(secureRegistry().getExcludePatterns());
// 参数记录
registry.addInterceptor(new WebInvokeTimeInterceptor());
}
}
package org.springblade.common.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.validation.MessageCodesResolver;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
/**
* Created by admin on 2021/5/13.
*/
@Configuration
public class CorsConfig implements WebMvcConfigurer {
@Override
public void addCorsMappings(CorsRegistry registry){
registry.addMapping("/**")
.allowedOriginPatterns("*")
.allowCredentials(true)
.allowedMethods("*")
.maxAge(3600)
;
}
}
package org.springblade.common.config;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.net.InetAddress;
/**
* 允许跨域请求
*
* @author Administrator
*/
@Component
public class FilterConfig implements HandlerInterceptor {
@Override
public void afterCompletion(HttpServletRequest arg0, HttpServletResponse arg1, Object arg2, Exception arg3)
throws Exception {
}
public void postHandle(HttpServletRequest arg0, HttpServletResponse arg1, Object arg2)
throws Exception {
}
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object arg2) throws Exception {
//支持跨域请求
response.setHeader("Access-Control-Allow-Origin", request.getHeader("Origin"));
response.setHeader("Access-Control-Allow-Methods", "*");
//是否支持cookie跨域
response.setHeader("Access-Control-Allow-Credentials", "true");
//Origin, X-Requested-With, Content-Type, Accept,Access-Token
response.setHeader("Access-Control-Allow-Headers",
"Authorization,Origin, X-Requested-With, Content-Type, Accept,Access-Token,blade-auth");
String ip = request.getHeader("x-forwarded-for");
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("Proxy-Client-IP");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("WL-Proxy-Client-IP");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("HTTP_CLIENT_IP");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("HTTP_X_FORWARDED_FOR");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getRemoteAddr();
}
if ("127.0.0.1".equals(ip) || "0:0:0:0:0:0:0:1".equals(ip)) {
ip = InetAddress.getLocalHost().getHostAddress();
}
String url = "http://" + ip + ":" +
request.getServerPort() +
request.getRequestURI();
System.out.println(url);
return true;
}
}
package org.springblade.common.config;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springblade.core.secure.utils.SecureUtil;
import org.springblade.core.tool.jackson.JsonUtil;
import org.springblade.core.tool.utils.WebUtil;
import org.springblade.founder.utils.R;
import org.springblade.modules.system.entity.XzxtUser;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Objects;
import java.util.concurrent.TimeUnit;
/**
* 重写用户登录拦截
*
* @auther: Lilei
* @date: 2023/3/7 10:40
*/
@Component
public class UserHandlerConfig implements HandlerInterceptor {
@Resource(name = "userredisTemplate")
private RedisTemplate<String, String> redisTemplate;
@Value("${userIdleTime}")
private Integer userIdleTime;
private static final Logger log = LoggerFactory.getLogger(UserHandlerConfig.class);
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) {
XzxtUser user = SecureUtil.getUserXzxt();
if (null != user) {
ValueOperations<String, String> ops = redisTemplate.opsForValue();
String key = "userIdleTime:" + user.getIdentitycard();
if (!"1".equals(ops.get(key))) {
log.warn("用户" + userIdleTime + "分钟未操作,请求接口:{},请求IP:{},请求参数:{}", new Object[]{request.getRequestURI(), WebUtil.getIP(request), JsonUtil.toJson(request.getParameterMap())});
//R result = R.fail(ResultCode.REQ_REJECT,"用户二十分钟未操作");
R result = R.overtime("用户" + userIdleTime + "分钟未操作");
errorResult(response, JsonUtil.toJson(result));
return false;
}
ops.set(key, "1", userIdleTime, TimeUnit.MINUTES);//存入redis并设置过期时间
return true;
} else {
log.warn("签名认证失败,请求接口:{},请求IP:{},请求参数:{}", new Object[]{request.getRequestURI(), WebUtil.getIP(request), JsonUtil.toJson(request.getParameterMap())});
//R result = R.fail(ResultCode.UN_AUTHORIZED);
R result = R.overtime("操作未授权");
errorResult(response, JsonUtil.toJson(result));
return false;
}
}
private void errorResult(HttpServletResponse response, String message) {
response.setCharacterEncoding("UTF-8");
response.setHeader("Content-type", "application/json");
response.setStatus(200);
try {
response.getWriter().write(Objects.requireNonNull(message));
} catch (IOException var6) {
log.error(var6.getMessage());
}
}
public UserHandlerConfig() {
}
}
package org.springblade.common.config;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.PropertyAccessor;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.data.redis.RedisProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.connection.RedisPassword;
import org.springframework.data.redis.connection.RedisStandaloneConfiguration;
import org.springframework.data.redis.connection.jedis.JedisConnection;
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
import org.springframework.data.redis.core.RedisOperations;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
import org.springframework.data.redis.serializer.StringRedisSerializer;
/**
* 多个redis配置类
* @auther: Lilei
* @date: 2023/3/8 20:06
*/
@Configuration
@ConditionalOnClass({JedisConnection.class, RedisOperations.class, RedisProperties.Jedis.class})
public class UserRedisConfigure {
@Bean(name = "userredisTemplate")
public RedisTemplate redisTemplate(
//与properties一一对应
@Value("${spring.redis.userredis.host}") String hostName,
@Value("${spring.redis.userredis.port}") int port,
@Value("${spring.redis.userredis.password}") String password,
@Value("${spring.redis.userredis.database}") int index
) {
RedisTemplate temple = new RedisTemplate();
temple.setConnectionFactory(
connectionFactory2(hostName, port, password,index));
//使用Jackson2JsonRedisSerializer来序列化和反序列化redis的value值(默认使用JDK的序列化方式)
Jackson2JsonRedisSerializer<Object> jacksonSeial = new Jackson2JsonRedisSerializer<>(Object.class);
ObjectMapper om = new ObjectMapper();
// 指定要序列化的域,field,get和set,以及修饰符范围,ANY是都有包括private和public
om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
// 指定序列化输入的类型,类必须是非final修饰的,final修饰的类,比如String,Integer等会跑出异常
om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
jacksonSeial.setObjectMapper(om);
// 值采用json序列化
temple.setValueSerializer(jacksonSeial);
//使用StringRedisSerializer来序列化和反序列化redis的key值
temple.setKeySerializer(new StringRedisSerializer());
// 设置hash key 和value序列化模式
temple.setHashKeySerializer(new StringRedisSerializer());
temple.setHashValueSerializer(jacksonSeial);
temple.afterPropertiesSet();
return temple;
}
/**
* springboot2.x默认使用lettuce取代jedis
* @Date: 2023/3/8 20:17
*/
public RedisConnectionFactory connectionFactory2(String hostName, int port, String password, int index){
RedisStandaloneConfiguration configuration = new RedisStandaloneConfiguration();
configuration.setHostName(hostName);
configuration.setPort(port);
configuration.setPassword(RedisPassword.of(password));
configuration.setDatabase(index);
LettuceConnectionFactory factory = new LettuceConnectionFactory(configuration);
factory.afterPropertiesSet();
return factory;
}
}
package org.springblade.common.config;
import cn.hutool.core.io.IoUtil;
import cn.hutool.core.map.MapUtil;
import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.util.StopWatch;
import org.springframework.util.StringUtils;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.BufferedReader;
import java.util.Map;
/**
* @author zzj
* 参数记录拦截器
*/
@Slf4j
public class WebInvokeTimeInterceptor implements HandlerInterceptor {
private final ThreadLocal<StopWatch> invokeTimeTL = new ThreadLocal<>();
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
String url = request.getMethod() + " " + request.getRequestURI();
// 打印请求参数
if (isJsonRequest(request)) {
String jsonParam = "";
BufferedReader reader = request.getReader();
jsonParam = IoUtil.read(reader);
log.info("开始请求 => URL[{}],参数类型[json],参数:[{}]", url, jsonParam);
} else {
Map<String, String[]> parameterMap = request.getParameterMap();
if (MapUtil.isNotEmpty(parameterMap)) {
String parameters = JSON.toJSONString(parameterMap);
log.info("开始请求 => URL[{}],参数类型[param],参数:[{}]", url, parameters);
} else {
log.info("开始请求 => URL[{}],无参数", url);
}
}
StopWatch stopWatch = new StopWatch();
invokeTimeTL.set(stopWatch);
stopWatch.start();
return true;
}
@Override
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
}
@Override
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
StopWatch stopWatch = invokeTimeTL.get();
stopWatch.stop();
log.info("结束请求 => URL[{}],耗时:[{}]毫秒", request.getMethod() + " " + request.getRequestURI(), stopWatch.getTotalTimeMillis());
invokeTimeTL.remove();
}
/**
* 判断本次请求的数据类型是否为json
*
* @param request request
* @return boolean
*/
private boolean isJsonRequest(HttpServletRequest request) {
String contentType = request.getContentType();
if (contentType != null) {
return StringUtils.startsWithIgnoreCase(contentType, MediaType.APPLICATION_JSON_VALUE);
}
return false;
}
}
//package org.springblade.common.config.mongo;
//
//import com.mongodb.MongoClientSettings;
//import com.mongodb.MongoCredential;
//import com.mongodb.ServerAddress;
//import com.mongodb.client.MongoClient;
//import com.mongodb.client.MongoClients;
//import com.mongodb.connection.ConnectionPoolSettings;
//import lombok.Getter;
//import lombok.Setter;
//import org.apache.commons.lang.StringUtils;
//import org.springframework.data.mongodb.core.MongoTemplate;
//import org.springframework.data.mongodb.core.SimpleMongoClientDatabaseFactory;
//
//import java.util.ArrayList;
//import java.util.List;
//
///**
// * @author szLi
// * @date 2021/11/11 9:54
// */
//@Getter
//@Setter
//public abstract class AbstractMongoConfigure {
// private String database;
//
// private String host;
//
// private int port;
//
// private String authenticationDatabase;
//
// private String username;
//
// private String password;
//
// public SimpleMongoClientDatabaseFactory mongoDbFactory() {
// MongoClientSettings settings = null;
// ConnectionPoolSettings poolSetting=ConnectionPoolSettings.builder().build();
// List<ServerAddress> serverAddressList=new ArrayList<>();
// serverAddressList.add(new ServerAddress(host, port));
// if(StringUtils.isNotBlank(username)) {
// MongoCredential credential = MongoCredential.createScramSha1Credential(username,
// authenticationDatabase, password.toCharArray());
// settings = MongoClientSettings.builder()
// .credential(credential)
// .applyToConnectionPoolSettings(builder->builder.applySettings(poolSetting))
// .applyToClusterSettings(builder -> builder.hosts(serverAddressList)).build();
// }else {
// settings = MongoClientSettings.builder().applyToConnectionPoolSettings(builder->builder.applySettings(poolSetting))
// .applyToClusterSettings(builder -> builder.hosts(serverAddressList)).build();
// }
//
// MongoClient mongoClient= MongoClients.create(settings);
// SimpleMongoClientDatabaseFactory factory = new SimpleMongoClientDatabaseFactory(mongoClient,
// database);
//
// return factory;
// }
//
// public abstract MongoTemplate getMongoTemplate();
//}
//package org.springblade.common.config.mongo;
//
//import org.springframework.boot.context.properties.ConfigurationProperties;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Primary;
//import org.springframework.data.mongodb.core.MongoTemplate;
//import org.springframework.data.mongodb.repository.config.EnableMongoRepositories;
//import org.springframework.stereotype.Component;
//
///**
// * 主数据源
// *
// * @author szLi
// * @date 2021/11/11 9:56
// */
//@Component
//@ConfigurationProperties(prefix = "spring.data.mongodb.primary")
//@EnableMongoRepositories(basePackages = "org.springblade.founder.*.mongo.primary", mongoTemplateRef = "primaryMongoTemplate")
//public class PrimaryMongoConfigure extends AbstractMongoConfigure{
//
// @Override
// @Primary
// @Bean(name = "primaryMongoTemplate")
// public MongoTemplate getMongoTemplate() {
// return new MongoTemplate(mongoDbFactory());
// }
//
//}
//package org.springblade.common.config.mongo;
//
//import org.springframework.boot.context.properties.ConfigurationProperties;
//import org.springframework.context.annotation.Bean;
//import org.springframework.data.mongodb.core.MongoTemplate;
//import org.springframework.data.mongodb.repository.config.EnableMongoRepositories;
//import org.springframework.stereotype.Component;
//
///**
// * 二号数据源配置
// *
// * @author szLi
// * @date 2021/11/11 10:00
// */
//@Component
//@ConfigurationProperties(prefix = "spring.data.mongodb.secondary")
//@EnableMongoRepositories(basePackages = "org.springblade.founder.*.mongo.secondary", mongoTemplateRef = "secondaryMongoTemplate")
//public class SecondaryMongoConfigure extends AbstractMongoConfigure {
//
// @Override
// @Bean(name = "secondaryMongoTemplate")
// public MongoTemplate getMongoTemplate() {
// return new MongoTemplate(mongoDbFactory());
// }
//}
/**
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springblade.common.constant;
/**
* 通用常量
*
* @author Chill
*/
public interface CommonConstant {
/**
* sword 系统名
*/
String SWORD_NAME = "sword";
/**
* saber 系统名
*/
String SABER_NAME = "saber";
/**
* 顶级父节点id
*/
Long TOP_PARENT_ID = 0L;
/**
* 顶级父节点名称
*/
String TOP_PARENT_NAME = "顶级";
/**
* 默认密码
*/
String DEFAULT_PASSWORD = "123456";
}
/**
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springblade.common.constant;
import org.springblade.core.launch.constant.AppConstant;
/**
* 通用常量
*
* @author Chill
*/
public interface LauncherConstant {
/**
* app name
*/
String APPLICATION_NAME = AppConstant.APPLICATION_NAME_PREFIX + "api";
/**
* sentinel dev 地址
*/
String SENTINEL_DEV_ADDR = "127.0.0.1:8858";
/**
* sentinel prod 地址
*/
String SENTINEL_PROD_ADDR = "192.168.186.129:8858";
/**
* sentinel test 地址
*/
String SENTINEL_TEST_ADDR = "192.168.186.129:8858";
/**
* 动态获取sentinel地址
*
* @param profile 环境变量
* @return addr
*/
static String sentinelAddr(String profile) {
switch (profile) {
case (AppConstant.PROD_CODE):
return SENTINEL_PROD_ADDR;
case (AppConstant.TEST_CODE):
return SENTINEL_TEST_ADDR;
default:
return SENTINEL_DEV_ADDR;
}
}
}
package org.springblade.common.core;
import org.apdplat.word.WordSegmenter;
import org.apdplat.word.segmentation.Word;
import org.lionsoul.jcseg.core.*;
import java.io.IOException;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class ClipWords{
ISegment seg = null;
static List<String> lists = new ArrayList<String>();
public ClipWords() throws JcsegException, IOException{
JcsegTaskConfig localJcsegTaskConfig = new JcsegTaskConfig();
ADictionary localADictionary = DictionaryFactory.createDefaultDictionary(localJcsegTaskConfig);
//用第二种分词法好,姓名等都能分出来
this.seg = SegmentFactory.createJcseg(2, new Object[] { localJcsegTaskConfig, localADictionary });
}
/**
* 分词后直接进行归类的函数
* @param WordsString:待分的字符串
* @return 返回类型
*/
public SortResult ClipWordSort(String WordsString) throws IOException
{
SortResult SResult=new SortResult();
IWord localIWord = null;
IWord localIWord1 = null;
IWord localIWord2 = null;
IWord QQlocalIWord = null;
String curstr="";
String curstr1="";
String curstr2="";
String cphStr="";
String macStr="";
int i=0;
int j=0;
boolean reswx = false;
//车牌号提取
List<Word> words = WordSegmenter.segWithStopWords(WordsString);//晋A90904
for (int k = 0;k < words.size(); k++) {
if(WordsTpye.isProname(words.get(k).toString())){
if(k+1<words.size()){
String nextWord = words.get(k + 1).toString().trim();if((nextWord.length() == 6|| nextWord.length() == 5)&& WordsTpye.isLetter(nextWord.charAt(0)) && isOnlyNumAndChar(nextWord)){
if(nextWord.length() == 5){
String nextWord2 = words.get(k + 2).toString().trim();
if("挂".equals(nextWord2)||"学".equals(nextWord2)||"警".equals(nextWord2)||"港".equals(nextWord2)||"澳".equals(nextWord2)){
SResult.carid+= words.get(k).toString() + nextWord +nextWord2+ "#";
}
}else{
SResult.carid+= words.get(k).toString() + nextWord + "#";
}
}
}
}
}
isMac(WordsString);//mac网卡
if(lists!=null&&!"".equals(lists)){
for(String mac : lists){
macStr+= mac;
}
if(macStr!=null&&!"".equals(macStr)){
SResult.mac+=macStr;
}
}
lists=new ArrayList<String>();
this.seg.reset(new StringReader(WordsString));
WordsTpye wt=new WordsTpye();
List<IWord> backSpaceWordList = new ArrayList<IWord>(6);//用于查询回退
try
{
while ((localIWord = getNextWord(backSpaceWordList)) != null){
curstr=localIWord.getValue().trim();
i++;
// 长度20以上的都是些垃圾数据
if(curstr.length()>20){
continue;
}
if(WordsTpye.isProname(curstr)){
j=i;
cphStr=curstr;
String str = "";
}else{
if(i==j+1&&!"".equals(cphStr)){
}
else{
// 小于3位的数字直接忽略
if(WordsTpye.isNumeric(curstr)){
if(curstr.length()>=5){
if(WordsTpye.isMobile(curstr)){
SResult.mobile+=curstr;
}
else if(WordsTpye.isYhk(curstr)){
SResult.yhkh+=curstr;
}
else if(WordsTpye.isImsi(curstr)){
SResult.imsi+=curstr;
}
else if(WordsTpye.isIMEI(curstr)){
SResult.imei+=curstr;
}
else if(WordsTpye.isPsnid(curstr)){
SResult.psnid+=curstr;
}
else if(isOnlyNumAndChar(curstr)){
SResult.otherid+=curstr;
}
else{
//针对身份证中包含X情况作判断,otherid不要重复保存分词器读到的17位(少一位X)身份证号
String psnid=curstr+"X";
if(WordsTpye.isPsnid(psnid)==false){
SResult.otherid+=curstr;
}
}
}
}
else{
if(!WordsTpye.isPunctPoint(curstr)){
if(WordsTpye.isPsnid(curstr))
{
SResult.psnid+=curstr.toUpperCase();
}
else if(WordsTpye.isEmail(curstr))
{
SResult.email+=curstr;
}
else if(WordsTpye.isIP(curstr))
{
SResult.ip+=curstr;
}else if(WordsTpye.isVIN(curstr))
{
SResult.vin+=curstr;
}
else if(WordsTpye.isUrl(curstr)|| curstr.indexOf("com")>0||curstr.indexOf("cn")>0|| curstr.indexOf("http")>0|| curstr.indexOf("html")>0||curstr.indexOf("https")>0||curstr.indexOf("HTTP")>0||curstr.indexOf("HTTPS")>0)
{
SResult.url+=curstr;
}else if(WordsTpye.isWxid(curstr))
{
if((localIWord1 = getNextWord(backSpaceWordList) )!= null &&(localIWord1.getValue().trim().startsWith("_")||localIWord1.getValue().trim().startsWith("-"))){
curstr1=localIWord1.getValue().trim();
curstr=curstr+curstr1;
while((localIWord2=getNextWord(backSpaceWordList))!= null&& WordsTpye.isWxhmybf(localIWord2.getValue().trim())&& !WordsTpye.isPunctPoint(localIWord2.getValue().trim())){
curstr2 =localIWord2.getValue().trim();
reswx = WordsTpye.isWxhmybf(curstr2);
if(reswx==true){
curstr=curstr+curstr2;
}
}
//如果wxid_ 后面是纯数字直接保存,如果是加字母加数字需要/2+3
if(WordsTpye.isNumeric(curstr.substring(5))){
SResult.wx+=curstr;
}else{
int ws= (int)Math.ceil((curstr.length()/2)+3);
curstr=curstr.substring(0, ws);
SResult.wx+=curstr;
}
}
}
else if(WordsTpye.isQQZFC(curstr))
{
int cs =0;
while((QQlocalIWord=getNextWord(backSpaceWordList))!= null) {
cs=cs+1;
if(cs>3){
break;
}
if(WordsTpye.isEmail(QQlocalIWord.getValue().trim()))
{
SResult.email += QQlocalIWord.getValue().trim();
break;
}else if(!WordsTpye.isMobile(QQlocalIWord.getValue().trim())&&WordsTpye.isNumeric(QQlocalIWord.getValue().trim())) {
if (WordsTpye.isQQ(QQlocalIWord.getValue().trim())) {
SResult.qq += QQlocalIWord.getValue().trim();
}
break;
}
}
}
else
{
//数字大于5个以上才有可能是号码吧
//没有http的情况下,也有可能有网址
if(getCharCount(curstr,".")>=2){
if(WordsTpye.isUrl("http://"+curstr)||curstr.indexOf("com")>0||curstr.indexOf("cn")>0|| curstr.indexOf("http")>0|| curstr.indexOf("html")>0||curstr.indexOf("https")>0||curstr.indexOf("HTTP")>0||curstr.indexOf("HTTPS")>0){
SResult.url+=curstr;
}
}
}
}
}
}
}
//end while
localIWord = null;
}
}
catch(Exception e)
{
e.printStackTrace();
}
//wt.FreeAndNull();
return SResult;
}
/**
* @TODO 判断是否仅包含字母和数字
* @param trim
* @return
*/
private boolean isOnlyNumAndChar(String trim) {
// TODO Auto-generated method stub
String regex = "^[A-Za-z0-9]+$";
Pattern pattern = Pattern.compile(regex);
Matcher mat = pattern.matcher(trim);
return mat.find();
}
/**
* @TODO 获取下一个字符,当且仅当回退list中不存在word时会从分词器中取下一个word
* @param
* @return
* @throws IOException
*/
private IWord getNextWord(List<IWord> backSpaceWordList) throws IOException{
if(0 == backSpaceWordList.size()){
return this.seg.next();
}else{
return backSpaceWordList.remove(0);
}
}
private int getCharCount(String srcs,String mats){
String ts=srcs;
int ri=0;
int p=srcs.indexOf(mats);
while(p>0){
ri++;
ts=ts.substring(p+1);
p=ts.indexOf(mats);
}
return ri;
}
public static void isMac(String title){
String pattern = "(.*)([0-9A-F]{2}-[0-9A-F]{2}-[0-9A-F]{2}-[0-9A-F]{2}-[0-9A-F]{2}-[0-9A-F]{2})(.*)";
// 创建 Pattern 对象
Pattern r = Pattern.compile(pattern);
if (title != null && title != "") {
// 创建 matcher 对象
Matcher m = r.matcher(title);
if (m.matches()) {
lists.add(m.group(2));
if(m.group(1) != null && !"".equals(m.group(1))){
isMac(m.group(1));
}
}
}
}
/**
* 分词测试
*/
public static void main(String[] paramArrayOfString) throws JcsegException, IOException{
String str1="简要案情:姓名:李思文 性别:男 手机号: 18219235955 QQ:617191077 身份证号:36082919870314455X";
ClipWords localJcsegTest = new ClipWords();
SortResult SResult=localJcsegTest.ClipWordSort(str1);
System.out.println("carid="+SResult.carid);
System.out.println("qq="+SResult.qq);
System.out.println("mobie="+SResult.mobile);
System.out.println("psnname="+SResult.psnname);
System.out.println("psnid="+SResult.psnid);
System.out.println("ip="+SResult.ip);
System.out.println("email="+SResult.email);
System.out.println("url="+SResult.url);
System.out.println("otherid="+SResult.otherid);
System.out.println("yhkh="+SResult.yhkh);
System.out.println("imsi="+SResult.imsi);
}
}
package org.springblade.common.core;
/**
* <p>Title: SortResult.java</p>
* <p>Description: 归类结果结构</p> /
* <p>Copyright: HIGHLAND'S Copyright (c) 2014</p>
* <p>Company: HIGHLAND</p>
* @author admin
* @date 2021-12-4
* @version 1.0
*/
public class SortResult{
public String psnname="";
public String psnid="";
public String carid="";
public String mobile="";
public String otherid="";
public String email="";
public String ip="";
public String url="";
public String imsi="";
public String yhkh="";
public String imei="";
public String vin="";
public String mac="";
public String wx="";
public String qq="";
}
/**
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springblade.common.launch;
import org.springblade.common.constant.LauncherConstant;
import org.springblade.core.launch.service.LauncherService;
import org.springframework.boot.builder.SpringApplicationBuilder;
import java.util.Properties;
/**
* 启动参数拓展
*
* @author smallchil
*/
public class LauncherServiceImpl implements LauncherService {
@Override
public void launcher(SpringApplicationBuilder builder, String appName, String profile) {
Properties props = System.getProperties();
props.setProperty("spring.cloud.sentinel.transport.dashboard", LauncherConstant.sentinelAddr(profile));
}
}
/**
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springblade.common.tool;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springblade.common.core.ClipWords;
import org.springblade.common.core.SortResult;
import java.util.*;
/**
* 通用工具类
*
* @author Chill
*/
@Api(value = "工具类", tags = "工具类")
public class CommonUtil {
public static String getStrByLenth(String str){
return str.substring(0,str.length() - 1);
}
@ApiOperation(value = "提取标识号", notes = "提取标识号")
public static List<Map<String,Object>> doBshProcess(String info){
List<Map<String,Object>> listResult = new ArrayList<>();
String dostr="";
if(info!=null){
dostr=info.trim();
}
if(dostr.equals("")){
return listResult;
}
dostr=dostr.replaceAll (" ", "");
try{
ClipWords localJcsegTest = new ClipWords();
SortResult SResult=localJcsegTest.ClipWordSort(dostr);
if(SResult.carid!=null&&!SResult.carid.equals("")){
Map map = new HashMap();
map.put("bshlx","carid");
map.put("bsh",SResult.carid);
map.put("bshlxMc","车牌号");
listResult.add(map);
}
if(SResult.mobile!=null&&!SResult.mobile.equals("")){
Map map = new HashMap();
map.put("bshlx","mobile");
map.put("bsh",SResult.mobile);
map.put("bshlxMc","手机号");
listResult.add(map);
}
if(SResult.psnid!=null&&!SResult.psnid.equals("")){
Map map = new HashMap();
map.put("bshlx","personid");
map.put("bsh",SResult.psnid);
map.put("bshlxMc","身份证号码");
listResult.add(map);
}
if(SResult.ip!=null&&!SResult.ip.equals("")) {
Map map = new HashMap();
map.put("bshlx","ip");
map.put("bsh",SResult.ip);
map.put("bshlxMc","ip地址");
listResult.add(map);
}
if(SResult.imei!=null&&!SResult.imei.equals("")) {
Map map = new HashMap();
map.put("bshlx","imei");
map.put("bsh",SResult.imei);
map.put("bshlxMc","imei");
listResult.add(map);
}
if(SResult.vin!=null&&!SResult.vin.equals("")) {//车辆识别号码,简称VIN,是一组由十七个英数组成,用于汽车上的一组独一无二的号码,可以识别汽车的生产商、引擎、底盘序号及其他性能等资料。
Map map = new HashMap();
map.put("bshlx","vin");
map.put("bsh",SResult.vin);
map.put("bshlxMc","车辆识别号码");
listResult.add(map);
}
if(SResult.mac!=null&&!SResult.mac.equals("")) {
Map map = new HashMap();
map.put("bshlx","mac");
map.put("bsh",SResult.mac);
map.put("bshlxMc","mac");
listResult.add(map);
}
if(SResult.email!=null&&!SResult.email.equals("")) {
Map map = new HashMap();
map.put("bshlx","email");
map.put("bsh",SResult.email);
map.put("bshlxMc","email");
listResult.add(map);
}
if(SResult.url!=null&&!SResult.url.equals("")) {
Map map = new HashMap();
map.put("bshlx","url");
map.put("bsh",SResult.url);
map.put("bshlxMc","url");
listResult.add(map);
}
if(SResult.yhkh!=null&&!SResult.yhkh.equals("")) {//银行卡号
Map map = new HashMap();
map.put("bshlx","yhkh");
map.put("bsh",SResult.yhkh);
map.put("bshlxMc","yhkh");
listResult.add(map);
}
if(SResult.imsi!=null&&!SResult.imsi.equals("")) {
Map map = new HashMap();
map.put("bshlx","imsi");
map.put("bsh",SResult.imsi);
map.put("bshlxMc","imsi");
listResult.add(map);
}
if(SResult.qq!=null&&!SResult.qq.equals("")){
Map map = new HashMap();
map.put("bshlx","qq");
map.put("bsh",SResult.qq);
map.put("bshlxMc","qq");
listResult.add(map);
}
if(SResult.wx!=null&&!SResult.wx.equals("")){
Map map = new HashMap();
map.put("bshlx","wx");
map.put("bsh",SResult.wx);
map.put("bshlxMc","微信号");
listResult.add(map);
}
}
catch(Exception e){
System.out.println("doProcess异常:" + e.getMessage());
System.out.println(e.getStackTrace().toString());
}
return removeMapRepeat(listResult,"bsh");
}
/**
* 根据指定key去除重复Map
*
* @param list 传入的list集合
* @param keyName 指定的key
*/
public static List<Map<String, Object>> removeMapRepeat(List<Map<String, Object>> list, String keyName) {
if (list == null || list.isEmpty()) {
return null;
}
//根据属性值进行去重
Set<Map<String, Object>> sets = new TreeSet<>((m1, m2) -> {
Object obj1 = m1.get(keyName);
Object obj2 = m2.get(keyName);
//根据指定的key进行去重
return obj1.toString().compareTo(obj2.toString());
});
sets.addAll(list);
return new ArrayList(sets);
}
public static void main(String[] args) {
String ddd ="我的qq号1213254318,我的手机号18335155543";
// 提取标识号,并且保存
// List<Map<String, Object>> maps = doBshProcess(ddd);
// for (Map<String, Object> item: maps){
// System.out.println(item);
//
//
// }
}
}
package org.springblade.common.tool;
import org.apache.commons.lang.StringUtils;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.DayOfWeek;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoField;
import java.time.temporal.ChronoUnit;
import java.time.temporal.TemporalAdjuster;
import java.time.temporal.TemporalAdjusters;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
import java.util.regex.Pattern;
/**
* 日期相关工具类
*
* @author jing
*/
public class DateUtilXX {
public static String getDateStr(Date date){
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
return sdf.format(date);
}
public static String getSysDateStr(){
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
return sdf.format(new Date());
}
public static String getFirstDayOfYear() {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Calendar c = Calendar.getInstance();
c.set(c.get(Calendar.YEAR),0,1);
return sdf.format(c.getTime());
}
public static String getSysDateCnStr(){
SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日");
return sdf.format(new Date());
}
public static String getDiffDateStr(int num){
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Calendar c = Calendar.getInstance();
c.add(Calendar.DATE, num);
return sdf.format(c.getTime());
}
public static String getNextWorkDay(Date date) {
TemporalAdjuster nextWorkingDay = TemporalAdjusters.ofDateAdjuster(
temporal -> {
DayOfWeek dow = DayOfWeek.of(temporal.get(ChronoField.DAY_OF_WEEK));
int dayToAdd = 1;
if (dow == DayOfWeek.FRIDAY) {
dayToAdd = 3;
}
if (dow == DayOfWeek.SATURDAY) {
dayToAdd = 2;
}
return temporal.plus(dayToAdd, ChronoUnit.DAYS);
});
LocalDate localDate = LocalDate.now().with(nextWorkingDay);
DateTimeFormatter fmt = DateTimeFormatter.ofPattern("yyyy-MM-dd");
return localDate.format(fmt);
}
/**
* checkDateFormat 验证日期格式,若日期格式为标准日期则转换成所指定的日期格式
* @param dateStr: 日期字符串
* @param formatPattern: 日期格式
* @return String: 结果日期
* @author lystar
* 2021/9/13 10:53
*/
public static String checkDateFormat(String dateStr, String formatPattern) {
if (StringUtils.isNotBlank(dateStr)) {
SimpleDateFormat dateFormat = new SimpleDateFormat(formatPattern);
try {
dateFormat.parse(dateStr);
} catch (ParseException e) {
String[] REPLACE_STRING = new String[]{"GMT+0800", "GMT+08:00"};
String SPLIT_STRING = "(中国标准时间)";
dateStr = dateStr.split(Pattern.quote(SPLIT_STRING))[0].replace(REPLACE_STRING[0], REPLACE_STRING[1]);
SimpleDateFormat sdf = new SimpleDateFormat("E MMM dd yyyy HH:mm:ss z", Locale.US);
try {
Date date = sdf.parse(dateStr);
return dateFormat.format(date);
} catch (ParseException e1) {
e1.printStackTrace();
return null;
}
}
}
return dateStr;
}
}
package org.springblade.common.tool;
import io.swagger.annotations.Api;
import org.apache.commons.lang.StringUtils;
import java.util.HashMap;
import java.util.Map;
/**
* @author jing
* @date 2021/12/10 -- 17:43
*/
@Api(value = "获取分类单位工具类", tags = "获取分类单位工具类")
public class HqXjDwCommon {
public static Map<String, String> getMapDwLevCode(String dwUnitCode, String userGrade) {
Map<String, String> map = new HashMap<>();
String firstlev = "";
String lev="";
String codeLevCol="";
String dscodeLevCol="";
String unitcode=dwUnitCode;
if ("1".equals(userGrade)) {
firstlev = "1";
lev = "2";
codeLevCol = "CODE_LEV1";
dscodeLevCol = "CODE_LEV2";
}else if ("2".equals(userGrade)) {
firstlev = "2";
lev = "3";
codeLevCol = "CODE_LEV2";
dscodeLevCol = "CODE_LEV3";
} else if ("3".equals(userGrade)) {
firstlev = "3";
lev = "4";
codeLevCol = "CODE_LEV3";
dscodeLevCol = "CODE_LEV4";
} else if ("4".equals(userGrade)) {
firstlev = "4";
lev = "5";
codeLevCol = "CODE_LEV4";
dscodeLevCol = "CODE_LEV5";
}
//userGarde传入数字,是根据单位查询出其所在lev,传入unitcode时应该查哪一级别
map.put("firstlev",firstlev);
map.put("lev",lev);
map.put("codeLevCol",codeLevCol);
map.put("dscodeLevCol",dscodeLevCol);
map.put("unitcode",unitcode);
return map;
}
}
package org.springblade.common.tool;
import lombok.Data;
@Data
public class QgckryBean {
//姓名
private String xm;
//籍贯代码
private String jgssx;
//文化程度
private String whcd;
//曾用名
private String cym;
//人员照片
private String xp;
//婚姻状况
private String hyzk;
//毕业情况?
private String byqk;
//身份证号
private String sfzh;
//民族代码
private String mz;
//性别代码
private String xb;
//户籍地址行政区划代码
private String hkszd;
//出生地详址
private String csdxz;
//服务场所?
private String fwcs;
//出生日期
private String csrq;
//现住址
private String zzxz;
//身高
private String sg;
//证件类型代码
private String cyzjCyzjdm;
}
/**
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springblade.core.log.config;
import lombok.AllArgsConstructor;
import org.springblade.core.launch.props.BladeProperties;
import org.springblade.core.launch.server.ServerInfo;
import org.springblade.core.log.aspect.ApiLogAspect;
import org.springblade.core.log.event.ApiLogListener;
import org.springblade.core.log.event.ErrorLogListener;
import org.springblade.core.log.event.UsualLogListener;
import org.springblade.core.log.logger.BladeLogger;
import org.springblade.modules.system.service.ILogService;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* 日志工具自动配置
*
* @author Chill
*/
@Configuration
@AllArgsConstructor
@ConditionalOnWebApplication
public class BladeLogToolAutoConfiguration {
private final ILogService logService;
private final ServerInfo serverInfo;
private final BladeProperties bladeProperties;
@Bean
public ApiLogAspect apiLogAspect() {
return new ApiLogAspect();
}
@Bean
public BladeLogger bladeLogger() {
return new BladeLogger();
}
@Bean
public ApiLogListener apiLogListener() {
return new ApiLogListener(logService, serverInfo, bladeProperties);
}
@Bean
public ErrorLogListener errorEventListener() {
return new ErrorLogListener(logService, serverInfo, bladeProperties);
}
@Bean
public UsualLogListener bladeEventListener() {
return new UsualLogListener(logService, serverInfo, bladeProperties);
}
}
/**
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springblade.core.log.event;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.launch.props.BladeProperties;
import org.springblade.core.launch.server.ServerInfo;
import org.springblade.core.log.constant.EventConstant;
import org.springblade.core.log.model.LogApi;
import org.springblade.core.log.utils.LogAbstractUtil;
import org.springblade.modules.system.service.ILogService;
import org.springframework.context.event.EventListener;
import org.springframework.core.annotation.Order;
import org.springframework.scheduling.annotation.Async;
import java.util.Map;
/**
* 异步监听日志事件
*
* @author Chill
*/
@Slf4j
@AllArgsConstructor
public class ApiLogListener {
private final ILogService logService;
private final ServerInfo serverInfo;
private final BladeProperties bladeProperties;
@Async("async-executor")
@Order
@EventListener(ApiLogEvent.class)
public void saveApiLog(ApiLogEvent event) {
Map<String, Object> source = (Map<String, Object>) event.getSource();
LogApi logApi = (LogApi) source.get(EventConstant.EVENT_LOG);
LogAbstractUtil.addOtherInfoToLog(logApi, bladeProperties, serverInfo);
logService.saveApiLog(logApi);
}
}
/**
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springblade.core.log.event;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.launch.props.BladeProperties;
import org.springblade.core.launch.server.ServerInfo;
import org.springblade.modules.system.service.ILogService;
import org.springframework.context.event.EventListener;
import org.springframework.core.annotation.Order;
import org.springframework.scheduling.annotation.Async;
/**
* 异步监听错误日志事件
*
* @author Chill
*/
@Slf4j
@AllArgsConstructor
public class ErrorLogListener {
private final ILogService logService;
private final ServerInfo serverInfo;
private final BladeProperties bladeProperties;
@Async("async-executor")
@Order
@EventListener(ErrorLogEvent.class)
public void saveErrorLog(ErrorLogEvent event) {
/* Map<String, Object> source = (Map<String, Object>) event.getSource();
LogError logError = (LogError) source.get(EventConstant.EVENT_LOG);
LogAbstractUtil.addOtherInfoToLog(logError, bladeProperties, serverInfo);
logService.saveErrorLog(logError);*/
}
}
/**
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springblade.core.log.event;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.launch.props.BladeProperties;
import org.springblade.core.launch.server.ServerInfo;
import org.springblade.core.log.constant.EventConstant;
import org.springblade.core.log.model.LogUsual;
import org.springblade.core.log.utils.LogAbstractUtil;
import org.springblade.modules.system.service.ILogService;
import org.springframework.context.event.EventListener;
import org.springframework.core.annotation.Order;
import org.springframework.scheduling.annotation.Async;
import java.util.Map;
/**
* 异步监听日志事件
*
* @author Chill
*/
@Slf4j
@AllArgsConstructor
public class UsualLogListener {
private final ILogService logService;
private final ServerInfo serverInfo;
private final BladeProperties bladeProperties;
@Async("async-executor")
@Order
@EventListener(UsualLogEvent.class)
public void saveUsualLog(UsualLogEvent event) {
Map<String, Object> source = (Map<String, Object>) event.getSource();
LogUsual logUsual = (LogUsual) source.get(EventConstant.EVENT_LOG);
LogAbstractUtil.addOtherInfoToLog(logUsual, bladeProperties, serverInfo);
logService.saveUsualLog(logUsual);
}
}
/**
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
* <p>
* Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.gnu.org/licenses/lgpl.html
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springblade.core.secure;
import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* AuthInfo
*
* @author Chill
*/
@Data
@ApiModel(description = "认证信息")
public class AuthInfo {
@ApiModelProperty(value = "令牌")
private String accessToken;
@ApiModelProperty(value = "令牌类型")
private String tokenType;
@ApiModelProperty(value = "刷新令牌")
private String refreshToken;
@ApiModelProperty(value = "头像")
private String avatar = "https://gw.alipayobjects.com/zos/rmsportal/BiazfanxmamNRoxxVxka.png";
@ApiModelProperty(value = "角色名")
private String authority;
@ApiModelProperty(value = "用户名")
private String userName;
@ApiModelProperty(value = "账号名")
private String account;
@ApiModelProperty(value = "过期时间")
private long expiresIn;
@ApiModelProperty(value = "许可证")
private String license = "powered by blade";
@ApiModelProperty(value = "用户等级")
private String grade ;
@ApiModelProperty(value = "身份证号")
private String identitycard ;
@ApiModelProperty(value = "单位代码")
private String unitcode ;
@ApiModelProperty(value = "单位名称")
private String unitname ;
@ApiModelProperty(value = "电话")
private String phone ;
@ApiModelProperty(value = "真实姓名")
private String realname ;
@ApiModelProperty(value = "ip")
@TableField(exist = false)
private String ip ;
private String permission;
private String userId;
}
package org.springblade.founder.gnsyrzlog;
import java.lang.annotation.*;
/**
* @Descrption该注解描述方法的操作类型和菜单内容
*/
@Target(value = ElementType.METHOD)
@Retention(value = RetentionPolicy.RUNTIME)
@Documented
public @interface LogOper {
/**
* @Description操作类型 为必填项,01:查询, 02:新建, 03:修改,04:删除, 05:登录 ,06:退出,07:文件下载
*/
String czxxLbdm();
/**
* @Description应用名称
*/
String yymcJyqk() default "";
/**
* @Description操作信息简要描述
*/
String czxxJyqk() default "";
}
package org.springblade.founder.gnsyrzlog.mapper;
import org.apache.ibatis.annotations.Mapper;
import org.springblade.founder.gnsyrzlog.pojo.SysGnsyrz;
import org.springframework.stereotype.Component;
@Component
@Mapper
public interface LogDao {
void addGnsyrz(SysGnsyrz sysGnsyrz);
}
<?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="org.springblade.founder.gnsyrzlog.mapper.LogDao">
<insert id="addGnsyrz" parameterType="org.springblade.founder.gnsyrzlog.pojo.SysGnsyrz">
INSERT INTO sys_gnsyrz (
rzlsh
,fwsj
,yymc_jyqk
,yh_gmsfhm
,yh_ip
,yhdw_gajgjgdm
,yhdw_gajgmc
,czlxdm
,czxx_jyqk
,czxx_param
,xxsc_pdbz
,xxdjdw_gajgjgdm
,xxdjdw_gajgmc
,xxdjry_xm
,xxdjry_gmsfhm
,xxdjry_lxdh
,djsj
,xxczdw_gajgjgdm
,xxczdw_gajgmc
,xxczry_xm
,xxczry_gmsfhm
,gxsj
,xxlyms
,yymcdm
,ywbhlxdm
,ywbh
,yh_xm
,cxnrlbdm
,cxnrbh
,cxxxjg
)
VALUES(
#{ rzlsh , jdbcType=VARCHAR }
,now()
,#{ yymcJyqk , jdbcType=VARCHAR }
,#{ yhGmsfhm , jdbcType=VARCHAR }
,#{ yhIp , jdbcType=VARCHAR }
,#{ yhdwGajgjgdm , jdbcType=VARCHAR }
,#{ yhdwGajgmc , jdbcType=VARCHAR }
,#{ czlxdm , jdbcType=VARCHAR }
,#{ czxxJyqk , jdbcType=VARCHAR }
,#{ czxxParam , jdbcType=VARCHAR }
,#{ xxscPdbz , jdbcType=VARCHAR }
,#{ xxdjdwGajgjgdm , jdbcType=VARCHAR }
,#{ xxdjdwGajgmc , jdbcType=VARCHAR }
,#{ xxdjryXm , jdbcType=VARCHAR }
,#{ xxdjryGmsfhm , jdbcType=VARCHAR }
,#{ xxdjryLxdh , jdbcType=VARCHAR }
,now()
,#{ xxczdwGajgjgdm , jdbcType=VARCHAR }
,#{ xxczdwGajgmc , jdbcType=VARCHAR }
,#{ xxczryXm , jdbcType=VARCHAR }
,#{ xxczryGmsfhm , jdbcType=VARCHAR }
,now()
,#{ xxlyms , jdbcType=VARCHAR }
,#{ yymcdm , jdbcType=VARCHAR }
,#{ ywbhlxdm , jdbcType=VARCHAR }
,#{ ywbh , jdbcType=VARCHAR }
,#{ yhXm , jdbcType=VARCHAR }
,#{ cxnrlbdm , jdbcType=VARCHAR }
,#{ cxnrbh , jdbcType=VARCHAR }
,#{ cxxxjg , jdbcType=VARCHAR }
)
</insert>
</mapper>
package org.springblade.founder.gnsyrzlog.pojo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @author jing
* @date 2021/9/26 -- 16:57
*/
@Data
@ApiModel(value = "SysGnsyrz", description = "功能使用日志")
public class SysGnsyrz {
//日志流水号
@ApiModelProperty(value = "日志流水号")
private String rzlsh;
//访问时间
@ApiModelProperty(value = "访问时间")
private String fwsj;
private String fwsjkssj;
private String fwsjjssj;
//应用名称
@ApiModelProperty(value = "应用名称")
private String yymcJyqk;
//用户_公民身份号码
@ApiModelProperty(value = "用户_公民身份号码")
private String yhGmsfhm;
//用户IP
@ApiModelProperty(value = "用户IP")
private String yhIp;
//用户单位公安机关机构代码
@ApiModelProperty(value = "用户单位公安机关机构代码")
private String yhdwGajgjgdm;
//用户单位名称
@ApiModelProperty(value = "用户单位名称")
private String yhdwGajgmc;
//操作类型代码
@ApiModelProperty(value = "操作类型代码")
private String czlxdm;
//操作信息
@ApiModelProperty(value = "操作信息")
private String czxxJyqk;
private String czxxParam;
//应用名称代码
@ApiModelProperty(value = "应用名称代码")
private String yymcdm;
//业务编号类型代码
@ApiModelProperty(value = "业务编号类型代码")
private String ywbhlxdm;
//业务编号
@ApiModelProperty(value = "业务编号")
private String ywbh;
//用户_姓名
@ApiModelProperty(value = "用户_姓名")
private String yhXm;
//查询内容类别代码
@ApiModelProperty(value = "查询内容类别代码")
private String cxnrlbdm;
//查询内容编号
@ApiModelProperty(value = "查询内容编号")
private String cxnrbh;
//操作(查询)信息结果
@ApiModelProperty(value = "操作(查询)信息结果")
private String cxxxjg;
/**
* 信息删除_判断标识/1-是,0-否/CODE_IF
*/
@ApiModelProperty(value = "信息删除_判断标识")
private String xxscPdbz;
/**
* 信息登记单位_公安机关机构代码/采用GA 380《全国公安机关机构代码编码规则》统一编制的代码/CODE_GXS
*/
@ApiModelProperty(value = "信息登记单位_公安机关机构代码")
private String xxdjdwGajgjgdm;
/**
* 信息登记单位_公安机关名称
*/
@ApiModelProperty(value = "信息登记单位_公安机关名称")
private String xxdjdwGajgmc;
/**
* 信息登记人员_公民身份号码/符合GB 11643《公民身份号码》
*/
@ApiModelProperty(value = "信息登记人员_公民身份号码")
private String xxdjryGmsfhm;
/**
* 信息登记人员_联系电话
*/
@ApiModelProperty(value = "信息登记人员_联系电话")
private String xxdjryLxdh;
/**
* 信息登记人员_姓名
*/
@ApiModelProperty(value = "信息登记人员_姓名")
private String xxdjryXm;
/**
* 信息操作单位_公安机关机构代码/采用GA 380《全国公安机关机构代码编码规则》统一编制的代码/CODE_GXS
*/
@ApiModelProperty(value = "信息操作单位_公安机关机构代码")
private String xxczdwGajgjgdm;
/**
* 信息操作单位_公安机关名称
*/
@ApiModelProperty(value = "信息操作单位_公安机关名称")
private String xxczdwGajgmc;
/**
* 信息操作人员_公民身份号码/符合GB 11643《公民身份号码》
*/
@ApiModelProperty(value = "信息操作人员_公民身份号码")
private String xxczryGmsfhm;
/**
* 信息操作人员_联系电话
*/
@ApiModelProperty(value = "信息操作人员_联系电话")
private String xxczryLxdh;
/**
* 信息操作人员_姓名
*/
@ApiModelProperty(value = "信息操作人员_姓名")
private String xxczryXm;
/**
* 信息入部库时间
*/
@ApiModelProperty(value = "信息入部库时间")
private String xxrbksj;
/**
* 信息入省库时间
*/
@ApiModelProperty(value = "信息入省库时间")
private String xxrsksj;
/**
* 信息来源描述
*/
@ApiModelProperty(value = "信息来源描述")
private String xxlyms;
/**
* 信息入部库_判断标识/1-是,0-否/CODE_IF
*/
@ApiModelProperty(value = "信息入部库_判断标识")
private String xxrbkPdbz;
/**
* 信息入省库_判断标识/1-是,0-否/CODE_IF
*/
@ApiModelProperty(value = "信息入省库_判断标识")
private String xxrskPdbz;
}
package org.springblade.founder.shzy.controller;
import com.alibaba.excel.EasyExcel;
import com.alibaba.fastjson.JSON;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.codec.Charsets;
import org.springblade.founder.gnsyrzlog.LogOper;
import org.springblade.founder.shzy.entity.KuaishouGjXx;
import org.springblade.founder.shzy.entity.KuaishouZcXx;
import org.springblade.founder.shzy.entity.SysYhczrz;
import org.springblade.founder.shzy.entity.TbShzysjDdxx;
import org.springblade.founder.shzy.service.KuaiShouService;
import org.springblade.founder.shzy.util.YhczRzUtil;
import org.springblade.founder.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.net.URLEncoder;
import java.util.List;
import java.util.Map;
@RestController
@RequestMapping(value = "/ks")
public class KuaiShouController {
@Autowired
private KuaiShouService kuaiShouService;
@PostMapping("zcxxList")
@ApiOperation(value = "注册信息", notes = "注册信息")
@LogOper(czxxLbdm = "01", yymcJyqk = "快手注册信息查询", czxxJyqk = "快手注册信息查询列表")
public R zcxxList(KuaishouZcXx zc) {
try{
SysYhczrz sysYhczrz=new SysYhczrz();
sysYhczrz.setCzlx("查询");
sysYhczrz.setCzlxdm("04");
Map<String, Object> map = JSON.parseObject(JSON.toJSONString(zc));
sysYhczrz.setYymcdm("B0703");
sysYhczrz.setYymcJyqk("快手注册信息查询");
YhczRzUtil.doCzrz(sysYhczrz,map);
return R.ok().data(kuaiShouService.queryZcxxBySjh(zc));
}catch (Exception e){
e.printStackTrace();
return R.error(e.getMessage());
}
}
@RequestMapping("/exportZcxxList")
@ResponseBody
public void exportZcxxList(KuaishouZcXx zc, HttpServletResponse response, HttpServletRequest request) throws IOException {
SysYhczrz sysYhczrz=new SysYhczrz();
sysYhczrz.setCzlx("导出");
sysYhczrz.setCzlxdm("06");
Map<String, Object> map = JSON.parseObject(JSON.toJSONString(zc));
sysYhczrz.setYymcdm("B070301");
sysYhczrz.setYymcJyqk("导出快手注册信息");
YhczRzUtil.doCzrz(sysYhczrz,map);
zc.setLimit(10000);
zc.setPage(1);
Map<String, Object> result = kuaiShouService.queryZcxxBySjh(zc);
List<KuaishouZcXx> dzqqXxList = (List<KuaishouZcXx>) result.get("rows");
response.setContentType("application/vnd.ms-excel");
response.setCharacterEncoding(Charsets.UTF_8.name());
String fileName = URLEncoder.encode("注册信息", Charsets.UTF_8.name());
response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx");
EasyExcel.write(response.getOutputStream(), KuaishouZcXx.class).sheet("注册信息").doWrite(dzqqXxList);
}
@PostMapping("gjxxList")
@ApiOperation(value = "快手轨迹信息", notes = "快手轨迹信息")
@LogOper(czxxLbdm = "01", yymcJyqk = "快手轨迹信息查询", czxxJyqk = "快手轨迹信息查询列表")
public R gjxxList(KuaishouGjXx gjXx) {
try{
SysYhczrz sysYhczrz=new SysYhczrz();
sysYhczrz.setCzlx("查询");
sysYhczrz.setCzlxdm("04");
Map<String, Object> map = JSON.parseObject(JSON.toJSONString(gjXx));
sysYhczrz.setYymcdm("B070302");
sysYhczrz.setYymcJyqk("快手账号轨迹信息查询");
YhczRzUtil.doCzrz(sysYhczrz,map);
return R.ok().data(kuaiShouService.gjxxList(gjXx));
}catch (Exception e){
e.printStackTrace();
return R.error(e.getMessage());
}
}
@RequestMapping("/exportGjxxList")
@ResponseBody
public void exportGjxxList(KuaishouGjXx gjXx, HttpServletResponse response, HttpServletRequest request) throws IOException {
SysYhczrz sysYhczrz=new SysYhczrz();
sysYhczrz.setCzlx("导出");
sysYhczrz.setCzlxdm("06");
Map<String, Object> map = JSON.parseObject(JSON.toJSONString(gjXx));
sysYhczrz.setYymcdm("B070303");
sysYhczrz.setYymcJyqk("导出快手账号轨迹信息");
YhczRzUtil.doCzrz(sysYhczrz,map);
gjXx.setLimit(10000);
gjXx.setPage(1);
Map<String, Object> result = kuaiShouService.gjxxList(gjXx);
List<KuaishouGjXx> dzqqXxList = (List<KuaishouGjXx>) result.get("rows");
response.setContentType("application/vnd.ms-excel");
response.setCharacterEncoding(Charsets.UTF_8.name());
String fileName = URLEncoder.encode("轨迹信息", Charsets.UTF_8.name());
response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx");
EasyExcel.write(response.getOutputStream(), KuaishouGjXx.class).sheet("轨迹信息").doWrite(dzqqXxList);
}
}
package org.springblade.founder.shzy.controller;
import io.swagger.annotations.ApiOperation;
import org.springblade.founder.shzy.entity.TbSfDrsj;
import org.springblade.founder.shzy.entity.TbShzysjDdxx;
import org.springblade.founder.shzy.service.MtxxService;
import org.springblade.founder.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping(value = "/xhmt")
public class XhMtController {
@Autowired
private MtxxService mtxxService;
@PostMapping("mtQmdtjMclb")
@ApiOperation(value = "美团亲密度统计列表", notes = "美团亲密度统计列表")
public R mtQmdtjMclb(TbShzysjDdxx tbShzysjDdxx) {
try{
return R.ok().data(mtxxService.mtQmdtjMclb(tbShzysjDdxx));
}catch (Exception e){
e.printStackTrace();
return R.error(e.getMessage());
}
}
@PostMapping("mtdztjMclb")
@ApiOperation(value = "美团亲密度统计列表", notes = "美团亲密度统计列表")
public R mtdztjMclb(TbShzysjDdxx tbShzysjDdxx) {
try{
return R.ok().data(mtxxService.mtdztjMclb(tbShzysjDdxx));
}catch (Exception e){
e.printStackTrace();
return R.error(e.getMessage());
}
}
@PostMapping("wlQmdtjMclb")
@ApiOperation(value = "物流亲密度统计列表", notes = "物流亲密度统计列表")
public R wlQmdtjMclb(TbShzysjDdxx tbShzysjDdxx) {
try{
return R.ok().data(mtxxService.wlQmdtjMclb(tbShzysjDdxx));
}catch (Exception e){
e.printStackTrace();
return R.error(e.getMessage());
}
}
@PostMapping("wldztjMclb")
@ApiOperation(value = "物流dz统计列表", notes = "物流dz统计列表")
public R wldztjMclb(TbShzysjDdxx tbShzysjDdxx) {
try{
return R.ok().data(mtxxService.wldztjMclb(tbShzysjDdxx));
}catch (Exception e){
e.printStackTrace();
return R.error(e.getMessage());
}
}
@PostMapping("queryWlxxBySjh")
@ApiOperation(value = "物流信息", notes = "物流信息")
public R queryWlxxBySjh(TbSfDrsj wlxx) {
try{
return R.ok().data(mtxxService.queryWlxxBySjhtest(wlxx));
}catch (Exception e){
e.printStackTrace();
return R.error(e.getMessage());
}
}
}
package org.springblade.founder.shzy.entity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class CountNameVo {
/**
* 百分比
*/
private String bfb;
private String maxsj;
/**
* 总数
*/
private Long count;
public Long getCount() {
return count;
}
public void setCount(Long count) {
this.count = count;
}
public String getBfb() {
return bfb;
}
public void setBfb(String bfb) {
this.bfb = bfb;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
/**
* 名称
*/
private String name;
/**
* 代码
*/
private String code;
}
package org.springblade.founder.shzy.entity;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import lombok.Data;
@Data
@ExcelIgnoreUnannotated
@ColumnWidth(25)
public class KuaishouGjXx {
/**
* 信息主键编号
*/
private String xxzjbh;
/**
* 用户ID
*/
private String userId;
/**
* 活动时间
*/
@ExcelProperty(value = "活动时间")
private String activeTime;
/**
* 活动类型
*/
@ExcelProperty(value = "活动类型")
private String activeType;
/**
* 活动IP
*/
@ExcelProperty(value = "活动IP")
private String activeIp;
/**
* 端口号
*/
@ExcelProperty(value = "端口号")
private String activePort;
/**
* 活动地点
*/
@ExcelProperty(value = "活动地点")
private String activeLocation;
/**
* 活动经纬度
*/
@ExcelProperty(value = "活动经纬度")
private String longitudeLatitude;
private int page;
private int limit;
private String paramSjh;
}
package org.springblade.founder.shzy.entity;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
@Data
@ExcelIgnoreUnannotated
@ColumnWidth(25)
public class KuaishouZcXx {
/**
* 信息主键编号
*/
private String xxzjbh;
/**
* 用户ID
*/
@ExcelProperty(value = "用户ID")
private String userId;
/**
* 快手号
*/
@ExcelProperty(value = "快手号")
private String kwaiNumber;
/**
* 用户名
*/
@ExcelProperty(value = "用户名")
private String userName;
/**
* 真实姓名
*/
@ExcelProperty(value = "真实姓名")
private String realName;
/**
* 身份证号
*/
@ExcelProperty(value = "身份证号")
private String identitycard;
/**
* OPENID
*/
@ExcelProperty(value = "OPENID")
private String openId;
/**
* 注册时间
*/
@ExcelProperty(value = "注册时间")
private String registrationTime;
/**
* 注册IP
*/
@ExcelProperty(value = "注册IP")
private String registrationIp;
/**
* 注册地
*/
@ExcelProperty(value = "注册地")
private String registrationLocation;
/**
* 注册方式
*/
@ExcelProperty(value = "注册方式")
private String registrationMethod;
/**
* 手机号码
*/
@ExcelProperty(value = "手机号码")
private String phoneNumber;
private int page;
private int limit;
private String paramSjh;
}
package org.springblade.founder.shzy.entity;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
@Data
@TableName("sys_yhczrz")
@ApiModel(value = "SysYhczrz", description = "用户操作日志对象")
@ColumnWidth(30)
public class SysYhczrz {
@ApiModelProperty(value = "日志流水号")
@TableField("rzlsh")
private String rzlsh;
@ApiModelProperty(value = "访问时间")
@TableField("fwsj")
private Date fwsj;
@ApiModelProperty(value = "应用名称")
@TableField("yymc_jyqk")
private String yymcJyqk;
@ApiModelProperty(value = "应用名称代码")
@TableField("yymcdm")
private String yymcdm;
@ApiModelProperty(value = "用户_姓名")
@TableField("yh_xm")
private String yhXm;
@ApiModelProperty(value = "用户_公民身份号码")
@TableField("yh_gmsfhm")
private String yhGmsfhm;
@ApiModelProperty(value = "用户IP")
@TableField("yh_ip")
private String yhIp;
@ApiModelProperty(value = "用户单位公安机关机构代码")
@TableField("yhdw_gajgjgdm")
private String yhdwGajgjgdm;
@ApiModelProperty(value = "用户单位名称")
@TableField("yhdw_gajgmc")
private String yhdwGajgmc;
@ApiModelProperty(value = "操作类型代码")
@TableField("czlxdm")
private String czlxdm;
@ApiModelProperty(value = "操作类型")
@TableField("czlx")
private String czlx;
@ApiModelProperty(value = "操作信息参数")
@TableField("czxx_param")
private String czxxParam;
@ApiModelProperty(value = "信息删除_判断标识")
@TableField("xxsc_pdbz")
private String xxscPdbz;
@ApiModelProperty(value = "信息登记单位_公安机关机构代码")
@TableField("xxdjdw_gajgjgdm")
private String xxdjdwGajgjgdm;
@ApiModelProperty(value = "信息登记单位_公安机关名称")
@TableField("xxdjdw_gajgmc")
private String xxdjdwGajgmc;
@ApiModelProperty(value = "信息登记人员_姓名")
@TableField("xxdjry_xm")
private String xxdjryXm;
@ApiModelProperty(value = "信息登记人员_公民身份号码")
@TableField("xxdjry_gmsfhm")
private String xxdjryGmsfhm;
@ApiModelProperty(value = "信息登记人员_联系电话")
@TableField("xxdjry_lxdh")
private String xxdjryLxdh;
@ApiModelProperty(value = "登记时间")
@TableField("djsj")
private Date djsj;
@ApiModelProperty(value = "信息操作单位_公安机关机构代码")
@TableField("xxczdw_gajgjgdm")
private String xxczdwGajgjgdm;
@ApiModelProperty(value = "信息操作单位_公安机关名称")
@TableField("xxczdw_gajgmc")
private String xxczdwGajgmc;
@ApiModelProperty(value = "信息操作人员_姓名")
@TableField("xxczry_xm")
private String xxczryXm;
@ApiModelProperty(value = "信息操作人员_公民身份号码")
@TableField("xxczry_gmsfhm")
private String xxczryGmsfhm;
@ApiModelProperty(value = "改写时间")
@TableField("gxsj")
private Date gxsj;
@ApiModelProperty(value = "信息来源描述")
@TableField("xxlyms")
private String xxlyms;
@ApiModelProperty(value = "比对原因")
@ExcelIgnore
@TableField(exist = false)
private String zpms;
@ApiModelProperty(value = "信息主键编号")
@ExcelIgnore
@TableField(exist = false)
private String xxzjbh;
@ApiModelProperty(value = "任务id")
@ExcelIgnore
@TableField(exist = false)
private String taskId;
}
package org.springblade.founder.shzy.entity;
import lombok.Data;
@Data
public class TbDbKdxx {
/**
* 自增主键
*/
private Integer id;
/**
* 运单号
*/
private String ydh;
/**
* 收货日期
*/
private String shrq;
/**
* 发货人
*/
private String fhr;
/**
* 发货人-手机号码
*/
private String fhrSjhm;
/**
* 发货人-电话号码
*/
private String fhrDhhm;
/**
* 发货人-地址
*/
private String fhrDz;
/**
* 商品名称
*/
private String spmc;
/**
* 数量
*/
private String sl;
/**
* 重量
*/
private String zl;
/**
* 体积
*/
private String tj;
/**
* 出发城市
*/
private String cfcs;
/**
* 到大城市
*/
private String ddcs;
/**
* 发货部门
*/
private String fhbm;
/**
* 收货人
*/
private String shr;
/**
* 收货人-手机号码
*/
private String shrSjhm;
/**
* 收货人-电话号码
*/
private String shrDhhm;
/**
* 收货人-地址
*/
private String shrDz;
}
package org.springblade.founder.shzy.entity;
import lombok.Data;
import java.util.Date;
//物流信息(顺丰)
@Data
public class TbSfDrsj {
private String paramSjh;
private String paramSjh2;
private String paramdz2;
private String id;
/**
* 运单号
*/
private String ydh;
/**
* 寄件时间
*/
private String jjsj;
private String jjsjStart;
private String jjsjEnd;
/**
* 寄件地址
*/
private String jjdz;
/**
* 寄件公司
*/
private String jjgs;
/**
* 寄件联系人
*/
private String jjlxr;
/**
* 寄件电话
*/
private String jjdh;
/**
* 寄件手机号
*/
private String jjsjh;
/**
* 收件地址
*/
private String sjdz;
/**
* 收件公司
*/
private String sjgs;
/**
* 收件联系人
*/
private String sjlxr;
/**
* 收件电话
*/
private String sjdh;
/**
* 收件手机号
*/
private String sjsjh;
/**
* 收件员
*/
private String sjy;
/**
* 原寄地
*/
private String yjd;
/**
* 目的地
*/
private String mdd;
/**
* 寄方客户编号
*/
private String jfkhbm;
/**
* 付款方式
*/
private String fkfs;
/**
*
*/
private String dshkje;
private String tjnr;
private String jfzl;
private String js;
private String yf;
private String pfkhbm;
private String pjy;
private Date lrsj;
private String filename;
private Date rksj;
private Integer qxbj;
private String yjdpd;
private String yjdpm;
private String yjdcd;
private String yjdcm;
private String mddpd;
private String mddpm;
private String mddcd;
private String mddcm;
private int page;
private int limit;
private String yuefrqparam; //月份日期时间
private String rqparam;
private String sfparam; //省份字段查询
private String dzcs;
private String sfbr;
private String qmcs;
private String xdsjStart;
private String xdsjEnd;
private String cxlx="1";
}
package org.springblade.founder.shzy.entity;
import lombok.Data;
import java.util.Date;
//美团信息
@Data
public class TbShzysjDdxx {
/**
* 自增主键
*/
private Integer id;
/**
* 订单ID
*/
private String ddid;
/**
* 收单手机号码
*/
private String xdsjhm;
/**
* 下单时间
*/
private Date xdsj;
private String xdsjStart;
private String xdsjEnd;
/**
* 商品名称
*/
private String spmc;
/**
* 订单行政区划名称
*/
private String ddXzqhmc;
/**
* 收货人
*/
private String shr;
/**
* 收货人手机号码
*/
private String sdrsjhm;
/**
* 收货地址
*/
private String shdz;
/**
* 事件类型
*/
private String sjlx;
/**
* 线索类型
*/
private String xslx;
/**
* 线索数据
*/
private String xssj;
/**
* 数据入库时间
*/
private Date rksj;
/**
* 导入文件名称
*/
private String wjmc;
/**
* 删除标志: 0:有效;1;删除
*/
private String scbz;
private int page;
private int limit;
private String paramSjh;
private String rqparam; //日期时间
private String yuefrqparam; //月份日期时间
private String dzcs;
private String sfbr; //1:是本人 ,2非本人
private String qmcs;
private String sjhone;
private String sjhtwo;
private String shdzone;
private String shdzsjh;
}
package org.springblade.founder.shzy.mapper;
import org.apache.ibatis.annotations.Mapper;
import org.springblade.founder.shzy.entity.KuaishouGjXx;
import org.springblade.founder.shzy.entity.KuaishouZcXx;
import org.springframework.stereotype.Component;
import java.util.List;
@Component
@Mapper
public interface KuaiShouMapper {
List<KuaishouZcXx> queryZcxxBySjh(KuaishouZcXx kuaishouZcXx);
int queryZcxxBySjhCount(KuaishouZcXx kuaishouZcXx);
List<KuaishouGjXx> queryGjxxBySjh(KuaishouGjXx kuaishouGjXx);
int queryGjxxBySjhCount(KuaishouGjXx kuaishouGjXx);
}
<?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="org.springblade.founder.shzy.mapper.KuaiShouMapper">
<select id="queryZcxxBySjh" resultType="org.springblade.founder.shzy.entity.KuaishouZcXx">
select * from tb_yw_dzqq_kuaishou_info where
phone_number like concat(concat('%',#{paramSjh}),'%')
or user_name like concat(concat('%',#{paramSjh}),'%')
order by registration_time desc
limit #{page} ,#{limit}
</select>
<select id="queryZcxxBySjhCount" resultType="java.lang.Integer">
select count(*) from tb_yw_dzqq_kuaishou_info where
phone_number like concat(concat('%',#{paramSjh}),'%')
or user_name like concat(concat('%',#{paramSjh}),'%')
</select>
<select id="queryGjxxBySjh" resultType="org.springblade.founder.shzy.entity.KuaishouGjXx">
select * from tb_yw_dzqq_kuaishou_active_info where user_id=#{userId}
and SUBSTRING_INDEX(longitude_latitude,',',1)>=72 and SUBSTRING_INDEX(longitude_latitude,',',1) <![CDATA[<=]]> 136
and SUBSTRING_INDEX(longitude_latitude,',',-1)>=1 and SUBSTRING_INDEX(longitude_latitude,',',-1) <![CDATA[<=]]> 56
order by active_time desc
limit #{page} ,#{limit}
</select>
<select id="queryGjxxBySjhCount" resultType="java.lang.Integer">
select count(1) from tb_yw_dzqq_kuaishou_active_info where user_id=#{userId}
and SUBSTRING_INDEX(longitude_latitude,',',1)>=72 and SUBSTRING_INDEX(longitude_latitude,',',1) <![CDATA[<=]]> 136
and SUBSTRING_INDEX(longitude_latitude,',',-1)>=1 and SUBSTRING_INDEX(longitude_latitude,',',-1) <![CDATA[<=]]> 56
</select>
</mapper>
package org.springblade.founder.shzy.mapper;
import org.apache.ibatis.annotations.Mapper;
import org.springblade.founder.shzy.entity.CountNameVo;
import org.springblade.founder.shzy.entity.TbSfDrsj;
import org.springblade.founder.shzy.entity.TbShzysjDdxx;
import org.springframework.stereotype.Component;
import java.util.List;
@Component
@Mapper
public interface MtxxMapper {
List<TbShzysjDdxx> queryMtxxBySjh(TbShzysjDdxx tbShzysjDdxx);
int queryMtxxBySjhCount(TbShzysjDdxx tbShzysjDdxx);
List<TbShzysjDdxx> queryMtxxBySjhTj(TbShzysjDdxx tbShzysjDdxx);
List<TbShzysjDdxx> queryMtxxBySjhTj2(TbShzysjDdxx tbShzysjDdxx);
List<TbSfDrsj> queryWlxxBySjh(TbSfDrsj tbSfDrsj);
List<TbSfDrsj> queryWlxxBySjhtest(TbSfDrsj tbSfDrsj);
int queryWlxxBySjhCountTest(TbSfDrsj tbSfDrsj);
int queryWlxxBySjhCount(TbSfDrsj tbSfDrsj);
List<TbSfDrsj> queryWlxxBySjhTj(TbSfDrsj tbSfDrsj);
List<TbSfDrsj> queryWlxxBySjhTj2(TbSfDrsj tbSfDrsj);
//美团日期统计
List<CountNameVo> mtRqsjBySjh(TbShzysjDdxx tbShzysjDdxx);
//美团月份日期统计
List<CountNameVo> mtYuefRqsjBySjh(TbShzysjDdxx tbShzysjDdxx);
//美团本人下单统计
int mtBrxdCountBySjh(TbShzysjDdxx tbShzysjDdxx);
//美团收货地址统计
List<CountNameVo> mtShdztjBySjh(TbShzysjDdxx tbShzysjDdxx);
//美团亲密度统计
List<CountNameVo> mtQmdtjBySjh(TbShzysjDdxx tbShzysjDdxx);
//细化美团亲密度列表
List<CountNameVo> mtQmdtjMclb(TbShzysjDdxx tbShzysjDdxx);
List<CountNameVo> mtdztjMclb(TbShzysjDdxx tbShzysjDdxx);
//end
//细化物流亲密度列表
List<CountNameVo> wlQmdtjMclb(TbShzysjDdxx tbShzysjDdxx);
List<CountNameVo> wldztjMclb(TbShzysjDdxx tbShzysjDdxx);
//end
//物流日期统计
List<CountNameVo> wlRqsjBySjh(TbSfDrsj tbSfDrsj);
//物流月份日期统计
List<CountNameVo> wlYuefRqsjBySjh(TbSfDrsj tbSfDrsj);
//物流本人寄件统计
int wlBrjjBySjh(TbSfDrsj tbSfDrsj);
//物流地址统计
List<CountNameVo> wlShdztjBySjh(TbSfDrsj tbSfDrsj);
//物流省份统计
List<CountNameVo> wlSftjBySjh(TbSfDrsj tbSfDrsj);
//物流亲密度统计
List<CountNameVo> wlQmdtjBySjh(TbSfDrsj tbSfDrsj);
}
This source diff could not be displayed because it is too large. You can view the blob instead.
package org.springblade.founder.shzy.mapper;
import org.apache.ibatis.annotations.Mapper;
import org.springblade.founder.shzy.entity.CountNameVo;
import org.springblade.founder.shzy.entity.TbDbKdxx;
import org.springblade.founder.shzy.entity.TbSfDrsj;
import org.springframework.stereotype.Component;
import java.util.List;
@Component
@Mapper
public interface WlxxMapper {
//德邦
List<TbDbKdxx> queryWlxxBySjh(TbDbKdxx tbDbKdxx);
//德邦
List<TbSfDrsj> queryWlxxBySjh2(TbSfDrsj tbDbKdxx);
int queryWlxxBySjhCount(TbDbKdxx tbDbKdxx);
//物流日期统计
List<CountNameVo> wlRqsjBySjh(TbSfDrsj mtxx);
//物流月份日期统计
List<CountNameVo> wlYuefRqsjBySjh(TbSfDrsj mtxx);
//物流本人寄件统计
int wlBrjjBySjh(TbSfDrsj mtxx);
//物流地址统计
List<CountNameVo> wlShdztjBySjh(TbSfDrsj mtxx);
//物流省份统计
List<CountNameVo> wlSftjBySjh(TbSfDrsj mtxx);
//物流亲密度统计
List<CountNameVo> wlQmdtjBySjh(TbSfDrsj mtxx);
}
package org.springblade.founder.shzy.service;
import org.springblade.founder.shzy.entity.KuaishouGjXx;
import org.springblade.founder.shzy.entity.KuaishouZcXx;
import java.util.Map;
public interface KuaiShouService {
Map<String, Object> queryZcxxBySjh(KuaishouZcXx zc);
Map<String, Object> gjxxList(KuaishouGjXx zc);
}
package org.springblade.founder.shzy.service;
import org.springblade.founder.shzy.entity.TbSfDrsj;
import org.springblade.founder.shzy.entity.TbShzysjDdxx;
import java.util.List;
import java.util.Map;
public interface MtxxService {
Map<String, Object> queryMtxxBySjh(TbShzysjDdxx mtxx);
Map<String, Object> queryWlxxBySjh(TbSfDrsj mtxx);
Map<String, Object> queryWlxxBySjhtest(TbSfDrsj mtxx);
Map<String, Object> doAnalyseWlxxBySjh(TbSfDrsj mtxx);
Map<String, Object> mtRqsjBySjh(TbShzysjDdxx mtxx);
Map<String, Object> mtYuefRqsjBySjh(TbShzysjDdxx mtxx);
Map<String, Object> mtBrxdCountBySjh(TbShzysjDdxx mtxx);
Map<String, Object> mtShdztjBySjh(TbShzysjDdxx mtxx);
Map<String, Object> mtQmdtjBySjh(TbShzysjDdxx mtxx);
//细化
Map<String, Object> mtQmdtjMclb(TbShzysjDdxx mtxx);
Map<String, Object> mtdztjMclb(TbShzysjDdxx mtxx);
//细化物流
Map<String, Object> wlQmdtjMclb(TbShzysjDdxx mtxx);
Map<String, Object> wldztjMclb(TbShzysjDdxx mtxx);
Map<String, Object> queryXhMtxxBySjh(TbShzysjDdxx mtxx);
//end
Map<String, Object> mtDzListTjBySjh(TbShzysjDdxx mtxx);
Map<String, Object> mtQmdListTjBySjh(TbShzysjDdxx mtxx);
Map<String, Object> wlRqsjBySjh(TbSfDrsj mtxx);
Map<String, Object> wlYuefRqsjBySjh(TbSfDrsj mtxx);
Map<String, Object> wlBrjjBySjh(TbSfDrsj mtxx);
Map<String, Object> wlShdztjBySjh(TbSfDrsj mtxx);
Map<String, Object> wlSftjBySjh(TbSfDrsj mtxx);
Map<String, Object> wlQmdtjBySjh(TbSfDrsj mtxx);
Map<String, Object> wlDzListTjBySjh(TbSfDrsj mtxx);
Map<String, Object> wlQmdListTjBySjh(TbSfDrsj mtxx);
Map<String, Object> wlSfListTjBySjh(TbSfDrsj mtxx);
}
package org.springblade.founder.shzy.service.impl;
import com.baomidou.dynamic.datasource.annotation.DS;
import org.springblade.founder.shzy.entity.KuaishouGjXx;
import org.springblade.founder.shzy.entity.KuaishouZcXx;
import org.springblade.founder.shzy.entity.TbSfDrsj;
import org.springblade.founder.shzy.mapper.KuaiShouMapper;
import org.springblade.founder.shzy.service.KuaiShouService;
import org.springblade.founder.utils.EasyUIPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service
@DS("hunan_shzy")
public class KuaiShouServiceImpl implements KuaiShouService {
@Autowired
private KuaiShouMapper kuaiShouMapper;
@Override
public Map<String, Object> queryZcxxBySjh(KuaishouZcXx zc) {
Map<String, Object> rtMap = new HashMap<>();
List<KuaishouZcXx> listResult=new ArrayList<>();
long total=0;
rtMap.put("rows",new ArrayList<>());
rtMap.put("total",0);
EasyUIPage easyUIPage = new EasyUIPage();
easyUIPage.setPage(zc.getPage());
easyUIPage.setPagePara(zc.getLimit());
int begin = easyUIPage.getBegin();
int end = easyUIPage.getEnd();
zc.setPage(begin);
zc.setLimit(end);
listResult= kuaiShouMapper.queryZcxxBySjh(zc);
total= kuaiShouMapper.queryZcxxBySjhCount(zc);
rtMap.put("total",total);
rtMap.put("rows",listResult);
return rtMap;
}
@Override
public Map<String, Object> gjxxList(KuaishouGjXx gjXx) {
Map<String, Object> rtMap = new HashMap<>();
List<KuaishouGjXx> listResult=new ArrayList<>();
long total=0;
rtMap.put("rows",new ArrayList<>());
rtMap.put("total",0);
EasyUIPage easyUIPage = new EasyUIPage();
easyUIPage.setPage(gjXx.getPage());
easyUIPage.setPagePara(gjXx.getLimit());
int begin = easyUIPage.getBegin();
int end = easyUIPage.getEnd();
gjXx.setPage(begin);
gjXx.setLimit(end);
listResult= kuaiShouMapper.queryGjxxBySjh(gjXx);
total= kuaiShouMapper.queryGjxxBySjhCount(gjXx);
rtMap.put("total",total);
rtMap.put("rows",listResult);
return rtMap;
}
}
package org.springblade.founder.shzy.util;
import com.alibaba.fastjson.JSON;
import org.apache.http.HttpStatus;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import org.springblade.core.secure.utils.SecureUtil;
import org.springblade.founder.shzy.entity.SysYhczrz;
import org.springblade.modules.system.entity.XzxtUser;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.http.HttpServletRequest;
import java.net.InetAddress;
import java.util.*;
@Component
public class YhczRzUtil {
private static String url;
private static String authorization;
private static final HashMap<String, String> headers = new HashMap<>();
@Value("${yhczrz.url}")
private void setUrl(String url) {
YhczRzUtil.url = url;
}
@Value("${yhczrz.authorization}")
private void setAuthorization(String authorization) {
YhczRzUtil.authorization = authorization;
if (!headers.containsKey("founder.authorization")) {
headers.put("founder.authorization", YhczRzUtil.authorization);
}
}
public static void doCzrz(SysYhczrz sysYhczrz,Map<String, Object> map) {
try {
XzxtUser xzxtUser = SecureUtil.getUserXzxt();
if (xzxtUser != null) {
String dw = xzxtUser.getUnitcode().substring(0, 2);
if ("43".equals(dw)) {
} else {
return;
}
} else {
return;
}
Set<String> set = map.keySet();
Iterator<String> it = set.iterator();
while (it.hasNext()) {
String key = (String) it.next();
Object values = map.get(key);
if (values instanceof String) {
values = ((String) values).trim();
if (values.equals("")) {
values = null;
}
}
map.put(key, values);
}
sysYhczrz.setCzxxParam(JSON.toJSONString(map));
sysYhczrz.setYhIp(getIp());
sysYhczrz.setYhdwGajgjgdm(xzxtUser.getUnitcode());
sysYhczrz.setYhdwGajgmc(xzxtUser.getUnitname());
sysYhczrz.setYhGmsfhm(xzxtUser.getIdentitycard());
sysYhczrz.setYhXm(xzxtUser.getRealname());
sysYhczrz.setFwsj(new Date());
sysYhczrz.setXxdjdwGajgjgdm(xzxtUser.getUnitcode());
sysYhczrz.setXxdjdwGajgmc(xzxtUser.getUnitname());
sysYhczrz.setXxdjryXm(xzxtUser.getRealname());
sysYhczrz.setXxdjryGmsfhm(xzxtUser.getIdentitycard());
sysYhczrz.setXxdjryLxdh(xzxtUser.getPhone());
sysYhczrz.setXxczdwGajgjgdm(xzxtUser.getUnitcode());
sysYhczrz.setXxczdwGajgmc(xzxtUser.getUnitname());
sysYhczrz.setXxczryXm(xzxtUser.getRealname());
sysYhczrz.setXxczryGmsfhm(xzxtUser.getIdentitycard());
String param = JSON.toJSONString(sysYhczrz);
String resultToken = doPostJson(url, headers, param);
} catch (Exception e) {
e.printStackTrace();
}
}
public static String doPostJson(String url, Map<String, String> headers, String json) throws Exception {
// post请求返回结果
CloseableHttpClient httpClient = HttpClients.createDefault();
String jsonResult = null;
HttpPost httpPost = new HttpPost(url);
// 设置请求和传输超时时间
httpPost.setConfig(RequestConfig.custom().setSocketTimeout(4000).setConnectTimeout(4000).build());
if (headers != null) {
for (String key : headers.keySet()) {
httpPost.setHeader(key, headers.get(key));
}
}
try {
//设置参数解决中文乱码
if (null != json) {
StringEntity entity = new StringEntity(json, "utf-8");
entity.setContentEncoding("UTF-8");
entity.setContentType("application/json");
httpPost.setEntity(entity);
}
//发送请求
CloseableHttpResponse result = httpClient.execute(httpPost);
if (result.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
// 读取服务器返回的json数据(然后解析)
jsonResult = EntityUtils.toString(result.getEntity(), "utf-8");
} else {
throw new Exception();
}
} catch (Exception e) {
e.printStackTrace();
throw new Exception();
} finally {
httpPost.releaseConnection();
}
return jsonResult;
}
public static String getIp() throws Exception {
HttpServletRequest request = ((ServletRequestAttributes)
RequestContextHolder.getRequestAttributes()).getRequest();
String ip = request.getHeader("X-Forwarded-For");
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("Proxy-Client-IP");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("WL-Proxy-Client-IP");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("HTTP_CLIENT_IP");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("HTTP_X_FORWARDED_FOR");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("X-Real-IP");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getRemoteAddr();
}
//有些网络通过多层代理,那么获取到的ip就会有多个,一般都是通过逗号(,)分割开来,并且第一个ip为客户端的真实IP
if (ip != null && ip.length() != 0) {
ip = ip.split(",")[0];
}
if ("127.0.0.1".equals(ip) || ip == "127.0.0.1" || "0:0:0:0:0:0:0:1".equals(ip)
|| ip == "0:0:0:0:0:0:0:1") {
ip = InetAddress.getLocalHost().getHostAddress();
}
return ip;
}
}
package org.springblade.founder.utils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "全局自定义异常")
public class ApiException extends RuntimeException {
@ApiModelProperty(value = "状态码")
private Integer code;
@ApiModelProperty(value = "异常消息")
private String message;
@Override
public String toString() {
return "AsjxxzbException{" +
"message=" + this.getMessage() +
", code=" + code +
'}';
}
}
package org.springblade.founder.utils;
/**
* 自定义异常类
* @author wsy
* 2018/7/3
*/
public class BaseException extends RuntimeException{
private Throwable exception;
private String message;
/**
* 无参构造函数<br>
*/
public BaseException() {
}
/**
* 带参构造函数,传入String参数
*
* @param msg String
*/
public BaseException(String msg) {
super(msg);
this.message = msg;
}
/**
* 带参构造函数,传入Throwable参数
*
* @param thrown Throwable
*/
public BaseException(Throwable thrown) {
super(thrown);
exception = thrown;
}
/**
* 带参构造函数,传入String和Throwable参数
*
* @param msg String
* @param thrown Throwable
*/
public BaseException(String msg, Throwable thrown) {
super(msg, thrown);
this.message = msg;
this.exception = thrown;
}
public Throwable getException() {
return exception;
}
public void setException(Throwable exception) {
this.exception = exception;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
}
package org.springblade.founder.utils;
import lombok.Data;
import org.springblade.modules.system.entity.XzxtUser;
/**
* @author szLi
* @date 2021/8/25 15:39
*/
@Data
public class BaseModel {
protected String xxscPdbz;
protected String xxdjdwGajgjgdm;
protected String xxdjdwGajgmc;
protected String xxdjryXm;
protected String xxdjryGmsfhm;
protected String xxdjryLxdh;
protected String djsj;
protected String gxsj;
protected String xxczdwGajgjgdm;
protected String xxczdwGajgmc;
protected String xxczryXm;
protected String xxczryGmsfhm;
protected String xxczryLxdh;
protected String xxlyms = "刑侦信息专业应用系统";
protected String xxrsksj;
protected String xxrbksj;
protected String xxrskPdbz;
protected String xxrbkPdbz;
protected String gabxf;
protected int begin;
protected int end;
protected int page;//当前第几页
protected int limit;//每页多少行
//登录人员
public void setDjUser(XzxtUser user){
this.xxdjryXm=user.getRealname();
this.xxdjdwGajgjgdm=user.getUnitcode();
this.xxdjdwGajgmc=user.getUnitname();
this.xxdjryGmsfhm=user.getIdentitycard();
this.xxdjryLxdh=user.getPhone();
this.xxczryXm=user.getRealname();
this.xxczdwGajgjgdm=user.getUnitcode();
this.xxczdwGajgmc=user.getUnitname();
this.xxczryGmsfhm=user.getIdentitycard();
}
// 更新人员
public void setUpUser(XzxtUser user){
this.xxczryXm=user.getRealname();
this.xxczdwGajgjgdm=user.getUnitcode();
this.xxczdwGajgmc=user.getUnitname();
this.xxczryGmsfhm=user.getIdentitycard();
}
}
package org.springblade.founder.utils;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
public class DateUtil {
public static Date parse(String strDate) throws ParseException {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
return sdf.parse(strDate);
}
public static String getAge(String date) {
try {
Date birthDay = parse(date);
Calendar cal = Calendar.getInstance();
if (cal.before(birthDay)) {
//出生日期晚于当前时间,无法计算
throw new IllegalArgumentException(
"The birthDay is before Now.It's unbelievable!");
}
//当前年份
int yearNow = cal.get(Calendar.YEAR);
//当前月份
int monthNow = cal.get(Calendar.MONTH);
//当前日期
int dayOfMonthNow = cal.get(Calendar.DAY_OF_MONTH);
cal.setTime(birthDay);
int yearBirth = cal.get(Calendar.YEAR);
int monthBirth = cal.get(Calendar.MONTH);
int dayOfMonthBirth = cal.get(Calendar.DAY_OF_MONTH);
//计算整岁数
int age = yearNow - yearBirth;
if (monthNow <= monthBirth) {
if (monthNow == monthBirth) {
if (dayOfMonthNow < dayOfMonthBirth){
//当前日期在生日之前,年龄减一
age--;
}
} else {
age--;//当前月份在生日之前,年龄减一
}
} return age+"";
}catch (Exception e){
}
return "未知";
}
public static String getDateStr(Date date){
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
return sdf.format(date);
}
public static String getDateStr(Date date,String datePattern){
SimpleDateFormat sdf = new SimpleDateFormat(datePattern);
return sdf.format(date);
}
public static String getSysDateStr(){
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
return sdf.format(new Date());
}
public static String getSysDateCnStr(){
SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日");
return sdf.format(new Date());
}
/**
* isodate时间格式转换
* @param datetime Thu Jul 29 22:31:27 CST 2010
* @return
*/
public static String getISODateStr(String datetime){
SimpleDateFormat sdf = new SimpleDateFormat("EEE MMM dd HH:mm:ss z yyyy", java.util.Locale.US);
Date date = null;
try {
date = sdf.parse(datetime);
} catch (ParseException e) {
e.printStackTrace();
}
String newDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(date);
return newDate;
}
public static Date diffDate(Date date, int days){
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.add(Calendar.DATE, days);
return calendar.getTime();
}
/**
* 获取环比开始时间
* @param kssj
* @param jssj
* @return
*/
public static String getHbKssj(String kssj, String jssj) {
String hbkssj = "";
try {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Date date1 = sdf.parse(kssj);
Date date2 = sdf.parse(jssj);
long mis = date2.getTime() - date1.getTime();
Date date3 = new Date(date1.getTime()-mis);
hbkssj = sdf.format(date3);
} catch (ParseException e) {
e.printStackTrace();
}
return hbkssj;
}
//获取指定格式的时间
public static String format(Date date, String pattern) throws ParseException {
SimpleDateFormat sdf = new SimpleDateFormat(pattern);
return sdf.format(date);
}
//转换时间格式
public static String patternDateToNewPatternDate(String dateStr, String pattern, String newPattern) throws ParseException {
SimpleDateFormat sdf = new SimpleDateFormat(pattern);
Date parse = sdf.parse(dateStr);
sdf.applyPattern(newPattern);
return sdf.format(parse);
}
public static String getSj(String dateStr) throws ParseException {
String sj = null;
switch (dateStr.length()){
case 8:
sj = DateUtil.patternDateToNewPatternDate(dateStr, "yyyyMMdd", "yyyy-MM-dd");
break;
case 12:
sj = DateUtil.patternDateToNewPatternDate(dateStr, "yyyyMMddHHmm", "yyyy-MM-dd HH:mm");
break;
case 14:
sj = DateUtil.patternDateToNewPatternDate(dateStr, "yyyyMMddHHmmss", "yyyy-MM-dd HH:mm:ss");
break;
case 18:
sj = dateStr;
break;
}
return sj;
}
public static Date getSjDate(String dateStr) throws ParseException {
Date sj = null;
switch (dateStr.length()){
case 8:
sj = new SimpleDateFormat("yyyyMMdd").parse(dateStr);
break;
case 10:
sj = new SimpleDateFormat("yyyy-MM-dd").parse(dateStr);
break;
case 12:
sj = new SimpleDateFormat("yyyyMMddHHmm").parse(dateStr);
break;
case 14:
sj = new SimpleDateFormat("yyyyMMddHHmmss").parse(dateStr);
break;
case 19:
sj = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(dateStr);
break;
}
return sj;
}
}
package org.springblade.founder.utils;
import java.util.HashMap;
import java.util.Map;
/**
* 单位工具类
*
* @author szLi
* @date 2021/12/14
*/
public class DwUtil {
/**
* 当前用户级别(codeLevCol记录的是当前用户单位的级别)的下一级别各个辖区的总数,通过dscodeLevCol进行分组
*
* @param unitcode
* @param userGrade
* @return
*/
public static Map<String, Object> getDwLevCode(String unitcode, String userGrade) {
Map<String, Object> map = new HashMap<>();
String lev;
String codeLevCol;
String dscodeLevCol;
if ("S".equals(userGrade) || "T".equals(userGrade)
|| "1".equals(userGrade)) {
lev = "2";
codeLevCol = "CODE_LEV1";
dscodeLevCol = "CODE_LEV2";
} else if ("D".equals(userGrade) || "2".equals(userGrade)) {
lev = "3";
codeLevCol = "CODE_LEV2";
dscodeLevCol = "CODE_LEV3";
} else if ("X".equals(userGrade) || "3".equals(userGrade)) {
lev = "4";
codeLevCol = "CODE_LEV3";
dscodeLevCol = "CODE_LEV4";
} else {
lev = "5";
codeLevCol = "CODE_LEV4";
dscodeLevCol = "CODE_LEV5";
}
map.put("lev", lev);
map.put("codeLevCol", codeLevCol);
map.put("dscodeLevCol", dscodeLevCol);
map.put("unitcode", unitcode);
return map;
}
}
package org.springblade.founder.utils;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
public class EasyUIPage implements Serializable {
private static final long serialVersionUID = 1L;
public EasyUIPage() {
}
private int page = 1;
private int begin;
private int end;
private int total = 0;
private String sort;
private String order;
private int rownum = 20;
private List<?> rows = new ArrayList();
private String flag;
private String pagePara;
public String getFlag() {
return flag;
}
public void setFlag(String flag) {
this.flag = flag;
}
public int getTotal() {
return total;
}
public void setTotal(int total) {
this.total = total;
}
public void setRows(List<?> rows) {
this.rows = rows;
}
public int getPage() {
return page;
}
public void setPage(int page) {
this.page = page;
}
public int getBegin() {
return begin;
}
public int getEnd() {
return end;
}
public List<?> getRows() {
return rows;
}
public String getSort() {
return sort;
}
public void setSort(String sort) {
this.sort = sort;
}
public String getOrder() {
return order;
}
public void setOrder(String order) {
this.order = order;
}
public void setPagePara(Integer rows) {
if (rows != null) {
this.begin = (this.page - 1) * rows;
this.end = rows;
} else {
this.begin = (this.page - 1) * rownum;
this.end = rownum;
}
}
public void setPageParaOracle(Integer rows) {
if (rows != null) {
this.begin = (this.page - 1) * rows;
this.end = this.page * rows;
} else {
this.begin = (this.page - 1) * rownum;
this.end = this.page * rownum;
}
}
public int getRownum() {
return rownum;
}
public void setRownum(int rownum) {
this.rownum = rownum;
}
/**
* @return the pagePara
*/
public String getPagePara() {
return pagePara;
}
/**
* @param pagePara the pagePara to set
*/
public void setPagePara(String pagePara) {
this.pagePara = pagePara;
}
}
package org.springblade.founder.utils;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
/**
* @Description 全局异常类,省去一堆try catch
* @author zzj
*/
@ControllerAdvice
public class GlobalException extends Exception {
@ExceptionHandler(Exception.class)
@ResponseBody
public R defultExceptionHandler(HttpServletRequest request,Exception e){
e.printStackTrace();
return R.error(e.getMessage());
}
}
package org.springblade.founder.utils;
import org.springblade.founder.shzy.entity.CountNameVo;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
public class HMacUtil {
public static void main(String[] args) {
try {
String secret = HMACSHA256("app_id=XZ15000000&app_key=pSFRNTQQXDJKSjzL&xz_token=2d69c3e2da6e8ecc8e977603&timestamp=1591152151950", "zdejRKFNCUSSAIjbvijEdRFxjnzKAI");
System.out.println(secret);
List<CountNameVo> list = new ArrayList<>();
list.add(new CountNameVo("","",70L,"张三","" ));
list.add(new CountNameVo("","",70L,"张三","" ));
list.add(new CountNameVo("","",70L,"张三","" ));
list.add(new CountNameVo("","",70L,"张三","" ));
List<CountNameVo> studentList = new ArrayList<>();
list.parallelStream().collect(Collectors.groupingBy(o -> (o.getName() ), Collectors.toList())).forEach((id, transfer) -> {
transfer.stream().reduce((a, b) -> new CountNameVo("","",a.getCount() + b.getCount(),a.getName(),"" )).ifPresent(studentList::add);
});
for (CountNameVo student : studentList) {
System.out.println(student.toString());
}
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* HMac-SHA256算法加密
*
* @param data
* @param key
* @return
* @throws Exception
*/
public static String HMACSHA256(String data, String key) throws Exception {
Mac sha256_HMAC = Mac.getInstance("HmacSHA256");
SecretKeySpec secret_key = new SecretKeySpec(key.getBytes("UTF-8"), "HmacSHA256");
sha256_HMAC.init(secret_key);
byte[] array = sha256_HMAC.doFinal(data.getBytes("UTF-8"));
StringBuilder sb = new StringBuilder();
for (byte item : array) {
sb.append(Integer.toHexString((item & 0xFF) | 0x100).substring(1, 3));
}
return sb.toString();
}
}
package org.springblade.founder.utils;
import com.alibaba.fastjson.JSON;
import org.apache.http.HttpEntity;
import org.apache.http.HttpStatus;
import org.apache.http.NameValuePair;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.BasicCookieStore;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.protocol.HTTP;
import org.apache.http.util.EntityUtils;
import java.io.*;
import java.net.HttpURLConnection;
import java.net.URI;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public class HttpClientUtil {
private static RequestConfig requestConfig = null;
static{
// 设置请求和传输超时时间
//setConnectTimeout:设置连接超时时间,单位毫秒。
//setSocketTimeout:请求获取数据的超时时间,单位毫秒。 如果访问一个接口,多少时间内无法返回数据,就直接放弃此次调用。
//setConnectionRequestTimeout:设置从connect Manager获取Connection 超时时间,单位毫秒
requestConfig = RequestConfig.custom().setSocketTimeout(60000).setConnectTimeout(60000).build();
}
public static String doGet(String url, Map<String, String> param) {
// 创建Httpclient对象
CloseableHttpClient httpclient = HttpClients.createDefault();
String resultString = "";
CloseableHttpResponse response = null;
try {
// 创建uri
URIBuilder builder = new URIBuilder(url);
if (param != null) {
for (String key : param.keySet()) {
builder.addParameter(key, param.get(key));
}
}
URI uri = builder.build();
// 创建http GET请求
HttpGet httpGet = new HttpGet(uri);
// 执行请求
response = httpclient.execute(httpGet);
// 判断返回状态是否为200
if (response.getStatusLine().getStatusCode() == 200) {
resultString = EntityUtils.toString(response.getEntity(), "UTF-8");
}else{
return resultString;
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (response != null) {
response.close();
}
httpclient.close();
} catch (IOException e) {
e.printStackTrace();
} catch (Exception e){
System.out.println("访问思悦质量检查数据发生异常。"+e.getMessage());
e.printStackTrace();
}
}
return resultString;
}
public static String doGet(String url) {
return doGet(url, null);
}
public static String doPost(String url, Map<String, String> param) {
// 创建Httpclient对象
CloseableHttpClient httpClient = HttpClients.createDefault();
CloseableHttpResponse response = null;
String resultString = "";
try {
// 创建Http Post请求
HttpPost httpPost = new HttpPost(url);
// 创建参数列表
if (param != null) {
List<NameValuePair> paramList = new ArrayList<>();
for (String key : param.keySet()) {
paramList.add(new BasicNameValuePair(key, param.get(key)));
}
// 模拟表单
UrlEncodedFormEntity entity = new UrlEncodedFormEntity(paramList);
httpPost.setEntity(entity);
}
// 执行http请求
response = httpClient.execute(httpPost);
resultString = EntityUtils.toString(response.getEntity(), "utf-8");
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
response.close();
} catch (IOException e) {
e.printStackTrace();
} catch (Exception e){
e.printStackTrace();
}
}
return resultString;
}
public static String doPost(String url) {
return doPost(url, null);
}
//请求美亚数据监测接口的的post请求
public static String doPostJson(String url, String json,String token) {
// 创建Httpclient对象
CloseableHttpClient httpClient = HttpClients.createDefault();
CloseableHttpResponse response = null;
String resultString = "";
try {
// 创建Http Post请求
HttpPost httpPost = new HttpPost(url);
httpPost.setHeader("Content-Type","application/json");
httpPost.setHeader("token",token);
// 创建请求内容
StringEntity entity = new StringEntity(json, ContentType.APPLICATION_JSON);
httpPost.setEntity(entity);
// 执行http请求
response = httpClient.execute(httpPost);
resultString = EntityUtils.toString(response.getEntity(), "utf-8");
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
response.close();
} catch (IOException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
}
return resultString;
}
public static String doRequest(CloseableHttpClient httpclient, HttpUriRequest httpUriRequest, BasicCookieStore cookieStore) throws IOException {
//返回相应
CloseableHttpResponse response = httpclient.execute(httpUriRequest);
//获取response返回的相应实体
HttpEntity entity = response.getEntity();
entity.getContent();
//转码
String res= EntityUtils.toString(response.getEntity(), HTTP.UTF_8);
return res;
}
public static void main(String []args){
HttpClientUtil hu = new HttpClientUtil();
String imgstrs = null;
try {
imgstrs = hu.getJsonString("http://172.18.116.158:8081/data/getPSNRollByRybh?rybh=1506020149992010042416");
} catch (Exception e) {
e.printStackTrace();
}
//System.out.println(imgstrs);
//Map<String,Object> rstmap = new HashMap<String,Object>();
//JSONObject jsonObject = (JSONObject) JSONObject.parse(imgstrs);
//JSONArray jsa = jsonObject.getJSONArray("ret");
//for (int i = 0; i < jsa.size(); i++) {
// JSONObject obj = jsa.getJSONObject(i);
// String position= obj.getString("position");
// String image= obj.getString("image");
// rstmap.put("rfpimg"+i,image);
//}
}
public String getJsonString(String urlPath) throws Exception {
// 设置请求和传输超时时间
URL url = new URL(urlPath);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setConnectTimeout(5000);
connection.setReadTimeout(5000);
connection.connect();
InputStream inputStream = connection.getInputStream();
// 对应的字符编码转换
Reader reader = new InputStreamReader(inputStream, "UTF-8");
BufferedReader bufferedReader = new BufferedReader(reader);
String str = null;
StringBuffer sb = new StringBuffer();
while ((str = bufferedReader.readLine()) != null) {
sb.append(str);
}
reader.close();
connection.disconnect();
return sb.toString();
}
/**
* 将参数拼接为?key1=a&key2=b形式提交
* @param url
* @param headers
* @param jsonParam
* @return
*/
public static String doPostUrlEncodedFormEntity(String url, Map<String, String> headers, String jsonParam) throws Exception{
String resultString = "";
HttpPost httpPost = new HttpPost(url);
/*try{*/
//给httpPost请求设置header
if(null!=headers&&headers.size()>0){
for(String key:headers.keySet()){
httpPost.addHeader(key,headers.get(key));
}
}
// 设置参数解决中文乱码
if (null != jsonParam){
List<NameValuePair> paramList=new ArrayList<>();
Map<String, String> paramMap=(Map<String, String>) JSON.parse(jsonParam);
for(String key:paramMap.keySet()){
paramList.add(new BasicNameValuePair(key,paramMap.get(key)));
}
//模拟表单
UrlEncodedFormEntity entity=new UrlEncodedFormEntity(paramList);
httpPost.setEntity(entity);
}
// 设置请求和传输超时时间
httpPost.setConfig(requestConfig);
//创建客户端连接请求
CloseableHttpClient httpClient = HttpClients.createDefault();
// 发送请求
CloseableHttpResponse result = httpClient.execute(httpPost);
if (result.getStatusLine().getStatusCode() == HttpStatus.SC_OK){
// 读取服务器返回的json数据(然后解析)
resultString = EntityUtils.toString(result.getEntity(), "utf-8");
}
/*}catch (Exception e){
e.printStackTrace();
}finally{
httpPost.releaseConnection();
}*/
return resultString;
}
}
package org.springblade.founder.utils;
import cn.hutool.core.exceptions.ExceptionUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.http.HttpEntity;
import org.apache.http.HttpStatus;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.apache.http.util.EntityUtils;
import org.springframework.beans.factory.annotation.Value;
import java.io.IOException;
import java.util.Map;
@Slf4j
public class HttpUtils {
private static RequestConfig requestConfig = null;
private static String tokenPath="";
static{
// 设置请求和传输超时时间
//setConnectTimeout:设置连接超时时间,单位毫秒。
//setSocketTimeout:请求获取数据的超时时间,单位毫秒。 如果访问一个接口,多少时间内无法返回数据,就直接放弃此次调用。
//setConnectionRequestTimeout:设置从connect Manager获取Connection 超时时间,单位毫秒
requestConfig = RequestConfig.custom().setSocketTimeout(120000).setConnectTimeout(120000).build();
}
/**
* 静态属性注册配置文件中的值
* @param tokenPath
*/
@Value("${tokenPath}")
void setTokenPath(String tokenPath){
HttpUtils.tokenPath=tokenPath;
}
private static PoolingHttpClientConnectionManager cm =
new PoolingHttpClientConnectionManager();
public static String ytkdUrl;
@Value("${ytkdUrl}")
public void setYtkdUrl(String ytkdUrl) {
HttpUtils.ytkdUrl = ytkdUrl;
}
public static String doGet(String url) {
// 不是每次创建新的HttpClient对象,而是从连接池中获取HttpClient对象
CloseableHttpClient httpClient = HttpClients.custom()
.setConnectionManager(cm).build();
HttpGet httpget = new HttpGet(url);
String entityStr = "";
CloseableHttpResponse response = null;
try {
response = httpClient.execute(httpget);
HttpEntity entity = response.getEntity();
if (entity != null) {
entityStr = EntityUtils.toString(entity,"UTF-8");
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (response != null) {
response.close();
}
} catch (IOException e) {
e.printStackTrace();
log.error(ExceptionUtil.getMessage(e));
}
}
return entityStr;
}
public static String doPost(String url){
// 不是每次创建新的HttpClient对象,而是从连接池中获取HttpClient对象
CloseableHttpClient httpClient = HttpClients.custom()
.setConnectionManager(cm).build();
HttpPost httpPost = new HttpPost(url);
String entityStr = "";
CloseableHttpResponse response = null;
try {
response = httpClient.execute(httpPost);
HttpEntity entity = response.getEntity();
if (entity != null) {
entityStr = EntityUtils.toString(entity,"UTF-8");
}
} catch (Exception e) {
e.printStackTrace();
log.error(ExceptionUtil.getMessage(e));
} finally {
try {
if (response != null) {
response.close();
}
} catch (IOException e) {
e.printStackTrace();
log.error(ExceptionUtil.getMessage(e));
}
}
return entityStr;
}
/**
* 请求的参数类型为json
* @param url
* @param json
* @return {username:"",pass:""}
*/
public static String doPostJson(String url, Map<String, String> headers, String json) {
// post请求返回结果
CloseableHttpClient httpClient = HttpClients.custom()
.setConnectionManager(cm).build();
String jsonResult = null;
HttpPost httpPost = new HttpPost(url);
// 设置请求和传输超时时间
httpPost.setConfig(requestConfig);
if(headers != null) {
for (String key : headers.keySet()) {
httpPost.setHeader(key, headers.get(key));
}
}
try{
//设置参数解决中文乱码
if (null != json){
StringEntity entity = new StringEntity(json,"utf-8");
entity.setContentEncoding("UTF-8");
entity.setContentType("application/json");
httpPost.setEntity(entity);
}
//发送请求
CloseableHttpResponse result = httpClient.execute(httpPost);
if (result.getStatusLine().getStatusCode() == HttpStatus.SC_OK){
// 读取服务器返回的json数据(然后解析)
jsonResult = EntityUtils.toString(result.getEntity(), "utf-8");
}else{
throw new Exception();
}
}catch (Exception e){
e.printStackTrace();
log.error(ExceptionUtil.getMessage(e));
}finally{
httpPost.releaseConnection();
}
return jsonResult;
}
public static String doGetAddHeader(String url, String headerName, String headerValue) {
// 不是每次创建新的HttpClient对象,而是从连接池中获取HttpClient对象
CloseableHttpClient httpClient = HttpClients.custom()
.setConnectionManager(cm).build();
HttpGet httpget = new HttpGet(url);
String entityStr = "";
CloseableHttpResponse response = null;
try {
httpget.setHeader(headerName, headerValue);
response = httpClient.execute(httpget);
HttpEntity entity = response.getEntity();
if (entity != null) {
entityStr = EntityUtils.toString(entity,"UTF-8");
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (response != null) {
response.close();
}
} catch (IOException e) {
e.printStackTrace();
log.error(ExceptionUtil.getMessage(e));
}
}
return entityStr;
}
}
package org.springblade.founder.utils;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.http.HttpServletRequest;
import java.net.InetAddress;
public class IPUtil {
public static String getIp() throws Exception {
HttpServletRequest request = ((ServletRequestAttributes)
RequestContextHolder.getRequestAttributes()).getRequest();
String ip = request.getHeader("X-Forwarded-For");
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("Proxy-Client-IP");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("WL-Proxy-Client-IP");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("HTTP_CLIENT_IP");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("HTTP_X_FORWARDED_FOR");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("X-Real-IP");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getRemoteAddr();
}
//有些网络通过多层代理,那么获取到的ip就会有多个,一般都是通过逗号(,)分割开来,并且第一个ip为客户端的真实IP
if (ip != null && ip.length() != 0) {
ip = ip.split(",")[0];
}
if ("127.0.0.1".equals(ip) || ip == "127.0.0.1" || "0:0:0:0:0:0:0:1".equals(ip)
|| ip == "0:0:0:0:0:0:0:1") {
ip = InetAddress.getLocalHost().getHostAddress();
}
return ip;
}
}
package org.springblade.founder.utils;
import org.apache.commons.httpclient.HttpStatus;
import org.apache.commons.httpclient.NameValuePair;
import org.apache.commons.httpclient.methods.PostMethod;
import org.springframework.util.StringUtils;
/**
* 警信通相关接口
* @auther: Lilei
* @date: 2022/8/22 10:12
*/
public class JxtUtil {
private static final String url = "http://10.142.46.128:9080/sms/SMSSendService";
private static final String user_id = "4536";
private static final String user_pwd = "123456";
private static final String sub_code = "0213";
public static R sendService(String phone ,String message) {
if (StringUtils.isEmpty(phone)){
return R.error("用户手机号码为空");
}
if (StringUtils.isEmpty(message)){
return R.error("用户发送消息内容为空");
}
String result = send(phone,message);
if (result.startsWith("0#")){
result = "提交成功," + result;
return R.ok().data("result",result);
}else {
switch (result) {
case "100":
result = "余额不足";
break;
case "101":
result = "账号关闭";
break;
case "102":
result = "短信内容超过195字或为空或内容编码格式不正确";
break;
case "103":
result = "手机号码超过50个或合法的手机号码为空";
break;
case "104":
result = "用户访问时间间隔低于50毫秒";
break;
case "105":
result = "用户访问方式不是post方式";
break;
case "106":
result = "用户名不存在";
break;
case "107":
result = "密码错误";
break;
case "108":
result = "指定访问ip错误";
break;
case "110":
result = "小号不合法";
break;
case "111":
result = "短信内容内有敏感词";
break;
case "-100":
result = "其他未知错误";
break;
}
return R.error(result);
}
}
/* 接口返回代码说明
0#数字#唯一ID 提交成功#提交成功的手机数量#发送唯一标示(状态报告接口将通过此唯一标示提交给个账号)
100 余额不足
101 账号关闭
102 短信内容超过195字或为空或内容编码格式不正确
103 手机号码超过50个或合法的手机号码为空
104 用户访问时间间隔低于50毫秒
105 用户访问方式不是post方式
106 用户名不存在
107 密码错误
108 指定访问ip错误
110 小号不合法
111 短信内容内有敏感词
-100 其他未知错误*/
private static String send(String phone ,String message){
org.apache.commons.httpclient.HttpClient httpClient = new org.apache.commons.httpclient.HttpClient();
PostMethod postMethod = new PostMethod(url);
postMethod.addRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=GBK");
NameValuePair userId = new NameValuePair("user_id", user_id);
NameValuePair userPwd = new NameValuePair("user_pwd", user_pwd);
NameValuePair mobile = new NameValuePair("mobile", phone);
NameValuePair msg_content = new NameValuePair("msg_content", message);
NameValuePair subCode = new NameValuePair("sub_code", sub_code);
NameValuePair[] data ={userId, userPwd, mobile, msg_content,subCode};
postMethod.setRequestBody(data);
int statusCode = 0;
String result = "";
try{
statusCode = httpClient.executeMethod(postMethod);
System.out.println("statusCode:"+statusCode);
if (statusCode == HttpStatus.SC_OK) {
result = postMethod.getResponseBodyAsString();
//根据返回状态可判断是否发送成功
System.out.println("result:"+result);
}
}catch (Exception e){
e.printStackTrace();
return "警信通接口调用失败";
}
return result;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment