parent
2538677c9b
commit
2a1b06aedf
Binary file not shown.
Binary file not shown.
@ -0,0 +1,28 @@
|
||||
package com.renchao;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* Created on: 2024-09-13
|
||||
*
|
||||
* @author ren_chao
|
||||
*/
|
||||
@SpringBootApplication
|
||||
public class MyApp {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(MyApp.class, args);
|
||||
}
|
||||
|
||||
@RestController
|
||||
static class MyController {
|
||||
|
||||
@GetMapping("/test")
|
||||
public String test() {
|
||||
return "OK.......";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,38 +0,0 @@
|
||||
package com.jiuyv.business.app.config;
|
||||
|
||||
/**
|
||||
* @author he_jiebing@jiuyv.com
|
||||
* @create 2023-08-25 16:39
|
||||
*/
|
||||
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import org.springframework.cache.CacheManager;
|
||||
import org.springframework.cache.annotation.EnableCaching;
|
||||
import org.springframework.cache.concurrent.ConcurrentMapCache;
|
||||
import org.springframework.cache.concurrent.ConcurrentMapCacheManager;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Configuration
|
||||
@EnableCaching
|
||||
public class CacheConfig {
|
||||
|
||||
@Bean
|
||||
public CacheManager cacheManager() {
|
||||
ConcurrentMapCacheManager cacheManager = new ConcurrentMapCacheManager() {
|
||||
@Override
|
||||
protected org.springframework.cache.Cache createConcurrentMapCache(String name) {
|
||||
return new ConcurrentMapCache(name,
|
||||
CacheBuilder.newBuilder()
|
||||
.expireAfterWrite(1, TimeUnit.DAYS) // Set cache expiration time
|
||||
.build().asMap(),
|
||||
false);
|
||||
}
|
||||
};
|
||||
|
||||
return cacheManager;
|
||||
}
|
||||
}
|
||||
|
@ -1,82 +0,0 @@
|
||||
package com.jiuyv.framework.aspectj;
|
||||
|
||||
import com.jiuyv.common.annotation.RateLimiter;
|
||||
import com.jiuyv.common.enums.LimitType;
|
||||
import com.jiuyv.common.exception.ServiceException;
|
||||
import com.jiuyv.common.utils.ServletUtils;
|
||||
import com.jiuyv.common.utils.ip.IpUtils;
|
||||
import org.aspectj.lang.JoinPoint;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.aspectj.lang.annotation.Before;
|
||||
import org.aspectj.lang.reflect.MethodSignature;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.core.script.RedisScript;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 限流处理
|
||||
*
|
||||
* @author admin
|
||||
*/
|
||||
@Aspect
|
||||
@Component
|
||||
public class RateLimiterAspect
|
||||
{
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(RateLimiterAspect.class);
|
||||
|
||||
private final RedisTemplate<Object, Object> redisTemplate;
|
||||
|
||||
private final RedisScript<Long> limitScript;
|
||||
|
||||
@Autowired
|
||||
public RateLimiterAspect(RedisTemplate<Object, Object> redisTemplate, RedisScript<Long> limitScript) {
|
||||
this.redisTemplate = redisTemplate;
|
||||
this.limitScript = limitScript;
|
||||
}
|
||||
|
||||
@Before("@annotation(rateLimiter)")
|
||||
public void doBefore(JoinPoint point, RateLimiter rateLimiter)
|
||||
{
|
||||
String key = rateLimiter.key();
|
||||
int time = rateLimiter.time();
|
||||
int count = rateLimiter.count();
|
||||
|
||||
String combineKey = getCombineKey(rateLimiter, point);
|
||||
List<Object> keys = Collections.singletonList(combineKey);
|
||||
try
|
||||
{
|
||||
Long number = redisTemplate.execute(limitScript, keys, count, time);
|
||||
if (number == null || number.intValue() > count)
|
||||
{
|
||||
throw new ServiceException("访问过于频繁,请稍候再试");
|
||||
}
|
||||
LOGGER.info("限制请求'{}',当前请求'{}',缓存key'{}'", count, number.intValue(), key);
|
||||
}
|
||||
catch (ServiceException e)
|
||||
{
|
||||
LOGGER.error(e.getMessage(), e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
public String getCombineKey(RateLimiter rateLimiter, JoinPoint point)
|
||||
{
|
||||
StringBuilder stringBuffer = new StringBuilder(rateLimiter.key());
|
||||
if (rateLimiter.limitType() == LimitType.IP)
|
||||
{
|
||||
stringBuffer.append(IpUtils.getIpAddr(ServletUtils.getRequest())).append("-");
|
||||
}
|
||||
MethodSignature signature = (MethodSignature) point.getSignature();
|
||||
Method method = signature.getMethod();
|
||||
Class<?> targetClass = method.getDeclaringClass();
|
||||
stringBuffer.append(targetClass.getName()).append("-").append(method.getName());
|
||||
return stringBuffer.toString();
|
||||
}
|
||||
}
|
@ -1,49 +0,0 @@
|
||||
package com.jiuyv.framework.config;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONReader;
|
||||
import com.alibaba.fastjson2.JSONWriter;
|
||||
import org.springframework.data.redis.serializer.RedisSerializer;
|
||||
import org.springframework.data.redis.serializer.SerializationException;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
/**
|
||||
* Redis使用FastJson序列化
|
||||
*
|
||||
* @author admin
|
||||
*/
|
||||
public class FastJson2JsonRedisSerializer<T> implements RedisSerializer<T>
|
||||
{
|
||||
public static final Charset DEFAULT_CHARSET = Charset.forName("UTF-8");
|
||||
|
||||
private Class<T> clazz;
|
||||
|
||||
public FastJson2JsonRedisSerializer(Class<T> clazz)
|
||||
{
|
||||
super();
|
||||
this.clazz = clazz;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] serialize(T t) throws SerializationException
|
||||
{
|
||||
if (t == null)
|
||||
{
|
||||
return new byte[0];
|
||||
}
|
||||
return JSON.toJSONString(t, JSONWriter.Feature.WriteClassName).getBytes(DEFAULT_CHARSET);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T deserialize(byte[] bytes) throws SerializationException
|
||||
{
|
||||
if (bytes == null || bytes.length <= 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
String str = new String(bytes, DEFAULT_CHARSET);
|
||||
|
||||
return JSON.parseObject(str, clazz, JSONReader.Feature.SupportAutoType);
|
||||
}
|
||||
}
|
@ -1,98 +0,0 @@
|
||||
package com.jiuyv.framework.config;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.cache.annotation.CachingConfigurerSupport;
|
||||
import org.springframework.cache.annotation.EnableCaching;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.core.script.DefaultRedisScript;
|
||||
import org.springframework.data.redis.serializer.StringRedisSerializer;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
/**
|
||||
* redis配置
|
||||
*
|
||||
* @author admin
|
||||
*/
|
||||
@Configuration
|
||||
@EnableCaching
|
||||
public class RedisConfig extends CachingConfigurerSupport {
|
||||
@Value("${carcheck.redisPrefix}")
|
||||
private String redisPrefix;
|
||||
|
||||
class RedisKeySerializer extends StringRedisSerializer {
|
||||
@Override
|
||||
public byte[] serialize(String s) {
|
||||
if (s == null) {
|
||||
return null;
|
||||
}
|
||||
// 这里加上你需要加上的key前缀
|
||||
String realKey = redisPrefix + s;
|
||||
return super.serialize(realKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String deserialize(byte[] bytes) {
|
||||
if (bytes == null) {
|
||||
return null;
|
||||
}
|
||||
String s = new String(bytes, StandardCharsets.UTF_8);
|
||||
int index = s.indexOf(redisPrefix);
|
||||
if (index != -1) {
|
||||
return s.substring(index + 2);
|
||||
}
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
@Bean
|
||||
@SuppressWarnings(value = {"unchecked", "rawtypes"})
|
||||
public RedisTemplate<Object, Object> redisTemplate(RedisConnectionFactory connectionFactory) {
|
||||
RedisTemplate<Object, Object> template = new RedisTemplate<>();
|
||||
template.setConnectionFactory(connectionFactory);
|
||||
|
||||
FastJson2JsonRedisSerializer serializer = new FastJson2JsonRedisSerializer(Object.class);
|
||||
|
||||
// 使用StringRedisSerializer来序列化和反序列化redis的key值
|
||||
template.setKeySerializer(new StringRedisSerializer());
|
||||
template.setValueSerializer(serializer);
|
||||
|
||||
// Hash的key也采用StringRedisSerializer的序列化方式
|
||||
template.setHashKeySerializer(new StringRedisSerializer());
|
||||
template.setHashValueSerializer(serializer);
|
||||
|
||||
template.afterPropertiesSet();
|
||||
return template;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public DefaultRedisScript<Long> limitScript()
|
||||
{
|
||||
DefaultRedisScript<Long> redisScript = new DefaultRedisScript<>();
|
||||
redisScript.setScriptText(limitScriptText());
|
||||
redisScript.setResultType(Long.class);
|
||||
return redisScript;
|
||||
}
|
||||
|
||||
/**
|
||||
* 限流脚本
|
||||
*/
|
||||
private String limitScriptText()
|
||||
{
|
||||
return "local key = KEYS[1]\n" +
|
||||
"local count = tonumber(ARGV[1])\n" +
|
||||
"local time = tonumber(ARGV[2])\n" +
|
||||
"local current = redis.call('get', key);\n" +
|
||||
"if current and tonumber(current) > count then\n" +
|
||||
" return tonumber(current);\n" +
|
||||
"end\n" +
|
||||
"current = redis.call('incr', key)\n" +
|
||||
"if tonumber(current) == 1 then\n" +
|
||||
" redis.call('expire', key, time)\n" +
|
||||
"end\n" +
|
||||
"return tonumber(current);";
|
||||
}
|
||||
}
|
@ -1,48 +0,0 @@
|
||||
package com.jiuyv.system.service;
|
||||
|
||||
import com.jiuyv.common.core.domain.model.LoginUser;
|
||||
import com.jiuyv.system.domain.SysUserOnline;
|
||||
|
||||
/**
|
||||
* 在线用户 服务层
|
||||
*
|
||||
* @author admin
|
||||
*/
|
||||
public interface ISysUserOnlineService
|
||||
{
|
||||
/**
|
||||
* 通过登录地址查询信息
|
||||
*
|
||||
* @param ipaddr 登录地址
|
||||
* @param user 用户信息
|
||||
* @return 在线用户信息
|
||||
*/
|
||||
public SysUserOnline selectOnlineByIpaddr(String ipaddr, LoginUser user);
|
||||
|
||||
/**
|
||||
* 通过用户名称查询信息
|
||||
*
|
||||
* @param userName 用户名称
|
||||
* @param user 用户信息
|
||||
* @return 在线用户信息
|
||||
*/
|
||||
public SysUserOnline selectOnlineByUserName(String userName, LoginUser user);
|
||||
|
||||
/**
|
||||
* 通过登录地址/用户名称查询信息
|
||||
*
|
||||
* @param ipaddr 登录地址
|
||||
* @param userName 用户名称
|
||||
* @param user 用户信息
|
||||
* @return 在线用户信息
|
||||
*/
|
||||
public SysUserOnline selectOnlineByInfo(String ipaddr, String userName, LoginUser user);
|
||||
|
||||
/**
|
||||
* 设置在线用户信息
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 在线用户
|
||||
*/
|
||||
public SysUserOnline loginUserToUserOnline(LoginUser user);
|
||||
}
|
@ -1,96 +0,0 @@
|
||||
package com.jiuyv.system.service.impl;
|
||||
|
||||
import com.jiuyv.common.core.domain.model.LoginUser;
|
||||
import com.jiuyv.common.utils.CarcheckStringUtils;
|
||||
import com.jiuyv.system.domain.SysUserOnline;
|
||||
import com.jiuyv.system.service.ISysUserOnlineService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 在线用户 服务层处理
|
||||
*
|
||||
* @author admin
|
||||
*/
|
||||
@Service
|
||||
public class SysUserOnlineServiceImpl implements ISysUserOnlineService
|
||||
{
|
||||
/**
|
||||
* 通过登录地址查询信息
|
||||
*
|
||||
* @param ipaddr 登录地址
|
||||
* @param user 用户信息
|
||||
* @return 在线用户信息
|
||||
*/
|
||||
@Override
|
||||
public SysUserOnline selectOnlineByIpaddr(String ipaddr, LoginUser user)
|
||||
{
|
||||
if (CarcheckStringUtils.equals(ipaddr, user.getIpaddr()))
|
||||
{
|
||||
return loginUserToUserOnline(user);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过用户名称查询信息
|
||||
*
|
||||
* @param userName 用户名称
|
||||
* @param user 用户信息
|
||||
* @return 在线用户信息
|
||||
*/
|
||||
@Override
|
||||
public SysUserOnline selectOnlineByUserName(String userName, LoginUser user)
|
||||
{
|
||||
if (CarcheckStringUtils.equals(userName, user.getUsername()))
|
||||
{
|
||||
return loginUserToUserOnline(user);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过登录地址/用户名称查询信息
|
||||
*
|
||||
* @param ipaddr 登录地址
|
||||
* @param userName 用户名称
|
||||
* @param user 用户信息
|
||||
* @return 在线用户信息
|
||||
*/
|
||||
@Override
|
||||
public SysUserOnline selectOnlineByInfo(String ipaddr, String userName, LoginUser user)
|
||||
{
|
||||
if (CarcheckStringUtils.equals(ipaddr, user.getIpaddr()) && CarcheckStringUtils.equals(userName, user.getUsername()))
|
||||
{
|
||||
return loginUserToUserOnline(user);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置在线用户信息
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 在线用户
|
||||
*/
|
||||
@Override
|
||||
public SysUserOnline loginUserToUserOnline(LoginUser user)
|
||||
{
|
||||
if (CarcheckStringUtils.isNull(user) || CarcheckStringUtils.isNull(user.getUser()))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
SysUserOnline sysUserOnline = new SysUserOnline();
|
||||
sysUserOnline.setTokenId(user.getToken());
|
||||
sysUserOnline.setUserName(user.getUsername());
|
||||
sysUserOnline.setIpaddr(user.getIpaddr());
|
||||
sysUserOnline.setLoginLocation(user.getLoginLocation());
|
||||
sysUserOnline.setBrowser(user.getBrowser());
|
||||
sysUserOnline.setOs(user.getOs());
|
||||
sysUserOnline.setLoginTime(user.getLoginTime());
|
||||
if (CarcheckStringUtils.isNotNull(user.getUser().getDept()))
|
||||
{
|
||||
sysUserOnline.setDeptName(user.getUser().getDept().getDeptName());
|
||||
}
|
||||
return sysUserOnline;
|
||||
}
|
||||
}
|
@ -1,130 +0,0 @@
|
||||
package com.jiuyv.web.controller.monitor;
|
||||
|
||||
import com.jiuyv.common.constant.CacheConstants;
|
||||
import com.jiuyv.common.core.domain.AjaxResult;
|
||||
import com.jiuyv.common.exception.ServiceException;
|
||||
import com.jiuyv.common.utils.CarcheckStringUtils;
|
||||
import com.jiuyv.system.domain.SysCache;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.RedisCallback;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 缓存监控
|
||||
*
|
||||
* @author admin
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/monitor/cache")
|
||||
public class CacheController
|
||||
{
|
||||
private final RedisTemplate<String, String> redisTemplate;
|
||||
|
||||
@Autowired
|
||||
public CacheController(RedisTemplate<String, String> redisTemplate) {
|
||||
this.redisTemplate = redisTemplate;
|
||||
}
|
||||
|
||||
private final static List<SysCache> caches = new ArrayList<SysCache>();
|
||||
{
|
||||
caches.add(new SysCache(CacheConstants.LOGIN_TOKEN_KEY, "用户信息"));
|
||||
caches.add(new SysCache(CacheConstants.SYS_CONFIG_KEY, "配置信息"));
|
||||
caches.add(new SysCache(CacheConstants.SYS_DICT_KEY, "数据字典"));
|
||||
caches.add(new SysCache(CacheConstants.CAPTCHA_CODE_KEY, "验证码"));
|
||||
caches.add(new SysCache(CacheConstants.REPEAT_SUBMIT_KEY, "防重提交"));
|
||||
caches.add(new SysCache(CacheConstants.RATE_LIMIT_KEY, "限流处理"));
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('monitor:cache:list')")
|
||||
@GetMapping()
|
||||
public AjaxResult getInfo() throws Exception
|
||||
{
|
||||
Properties info = (Properties) redisTemplate.execute((RedisCallback<Object>) connection -> connection.info());
|
||||
Properties commandStats = (Properties) redisTemplate.execute((RedisCallback<Object>) connection -> connection.info("commandstats"));
|
||||
if (commandStats == null) {
|
||||
throw new ServiceException("系统异常");
|
||||
}
|
||||
Object dbSize = redisTemplate.execute((RedisCallback<Object>) connection -> connection.dbSize());
|
||||
|
||||
Map<String, Object> result = new HashMap<>(3);
|
||||
result.put("info", info);
|
||||
result.put("dbSize", dbSize);
|
||||
|
||||
List<Map<String, String>> pieList = new ArrayList<>();
|
||||
commandStats.stringPropertyNames().forEach((String key) -> {
|
||||
Map<String, String> data = new HashMap<>(2);
|
||||
String property = commandStats.getProperty(key);
|
||||
data.put("name", CarcheckStringUtils.removeStart(key, "cmdstat_"));
|
||||
data.put("value", CarcheckStringUtils.substringBetween(property, "calls=", ",usec"));
|
||||
pieList.add(data);
|
||||
});
|
||||
result.put("commandStats", pieList);
|
||||
return AjaxResult.success(result);
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('monitor:cache:list')")
|
||||
@GetMapping("/getNames")
|
||||
public AjaxResult cache()
|
||||
{
|
||||
return AjaxResult.success(caches);
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('monitor:cache:list')")
|
||||
@GetMapping("/getKeys/{cacheName}")
|
||||
public AjaxResult getCacheKeys(@PathVariable String cacheName)
|
||||
{
|
||||
Set<String> cacheKyes = redisTemplate.keys(cacheName + "*");
|
||||
return AjaxResult.success(cacheKyes);
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('monitor:cache:list')")
|
||||
@GetMapping("/getValue/{cacheName}/{cacheKey}")
|
||||
public AjaxResult getCacheValue(@PathVariable String cacheName, @PathVariable String cacheKey)
|
||||
{
|
||||
String cacheValue = redisTemplate.opsForValue().get(cacheKey);
|
||||
SysCache sysCache = new SysCache(cacheName, cacheKey, cacheValue);
|
||||
return AjaxResult.success(sysCache);
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('monitor:cache:list')")
|
||||
@DeleteMapping("/clearCacheName/{cacheName}")
|
||||
public AjaxResult clearCacheName(@PathVariable String cacheName)
|
||||
{
|
||||
Collection<String> cacheKeys = redisTemplate.keys(cacheName + "*");
|
||||
assert cacheKeys != null;
|
||||
redisTemplate.delete(cacheKeys);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('monitor:cache:list')")
|
||||
@DeleteMapping("/clearCacheKey/{cacheKey}")
|
||||
public AjaxResult clearCacheKey(@PathVariable String cacheKey)
|
||||
{
|
||||
redisTemplate.delete(cacheKey);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('monitor:cache:list')")
|
||||
@DeleteMapping("/clearCacheAll")
|
||||
public AjaxResult clearCacheAll()
|
||||
{
|
||||
Collection<String> cacheKeys = redisTemplate.keys("*");
|
||||
assert cacheKeys != null;
|
||||
redisTemplate.delete(cacheKeys);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
}
|
@ -1,93 +0,0 @@
|
||||
package com.jiuyv.web.controller.monitor;
|
||||
|
||||
import com.jiuyv.common.annotation.Log;
|
||||
import com.jiuyv.common.constant.CacheConstants;
|
||||
import com.jiuyv.common.core.controller.BaseController;
|
||||
import com.jiuyv.common.core.domain.AjaxResult;
|
||||
import com.jiuyv.common.core.domain.model.LoginUser;
|
||||
import com.jiuyv.common.core.page.TableDataInfo;
|
||||
import com.jiuyv.common.core.redis.RedisCache;
|
||||
import com.jiuyv.common.enums.BusinessType;
|
||||
import com.jiuyv.common.utils.CarcheckStringUtils;
|
||||
import com.jiuyv.system.domain.SysUserOnline;
|
||||
import com.jiuyv.system.service.ISysUserOnlineService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 在线用户监控
|
||||
*
|
||||
* @author admin
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/monitor/online")
|
||||
public class SysUserOnlineController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private ISysUserOnlineService userOnlineService;
|
||||
|
||||
@Autowired
|
||||
private RedisCache redisCache;
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('monitor:online:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(String ipaddr, String userName)
|
||||
{
|
||||
Collection<String> keys = redisCache.keys(CacheConstants.LOGIN_TOKEN_KEY + "*");
|
||||
List<SysUserOnline> userOnlineList = new ArrayList<SysUserOnline>();
|
||||
for (String key : keys)
|
||||
{
|
||||
LoginUser user = redisCache.getCacheObject(key);
|
||||
if (CarcheckStringUtils.isNotEmpty(ipaddr) && CarcheckStringUtils.isNotEmpty(userName))
|
||||
{
|
||||
if (CarcheckStringUtils.equals(ipaddr, user.getIpaddr()) && CarcheckStringUtils.equals(userName, user.getUsername()))
|
||||
{
|
||||
userOnlineList.add(userOnlineService.selectOnlineByInfo(ipaddr, userName, user));
|
||||
}
|
||||
}
|
||||
else if (CarcheckStringUtils.isNotEmpty(ipaddr))
|
||||
{
|
||||
if (CarcheckStringUtils.equals(ipaddr, user.getIpaddr()))
|
||||
{
|
||||
userOnlineList.add(userOnlineService.selectOnlineByIpaddr(ipaddr, user));
|
||||
}
|
||||
}
|
||||
else if (CarcheckStringUtils.isNotEmpty(userName) && CarcheckStringUtils.isNotNull(user.getUser()))
|
||||
{
|
||||
if (CarcheckStringUtils.equals(userName, user.getUsername()))
|
||||
{
|
||||
userOnlineList.add(userOnlineService.selectOnlineByUserName(userName, user));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
userOnlineList.add(userOnlineService.loginUserToUserOnline(user));
|
||||
}
|
||||
}
|
||||
Collections.reverse(userOnlineList);
|
||||
userOnlineList.removeAll(Collections.singleton(null));
|
||||
return getDataTable(userOnlineList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 强退用户
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('monitor:online:forceLogout')")
|
||||
@Log(title = "在线用户", businessType = BusinessType.FORCE)
|
||||
@DeleteMapping("/{tokenId}")
|
||||
public AjaxResult forceLogout(@PathVariable String tokenId)
|
||||
{
|
||||
redisCache.deleteObject(CacheConstants.LOGIN_TOKEN_KEY + tokenId);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
}
|
File diff suppressed because one or more lines are too long
Binary file not shown.
@ -0,0 +1 @@
|
||||
.el-descriptions-item__label:not(.is-bordered-label){text-align:right;width:110px;display:inline-block}.imglist[data-v-2cb805f7]{overflow:hidden;padding:0;margin:0}.imglist li[data-v-2cb805f7]{float:left;margin:5px;width:100px;height:100px;overflow:hidden}.imglist li img[data-v-2cb805f7]{width:100%;display:block}
|
Binary file not shown.
@ -1 +0,0 @@
|
||||
.el-descriptions-item__label:not(.is-bordered-label){text-align:right;width:110px;display:inline-block}.imglist[data-v-5d6437b8]{overflow:hidden;padding:0;margin:0}.imglist li[data-v-5d6437b8]{float:left;margin:5px;width:100px;height:100px;overflow:hidden}.imglist li img[data-v-5d6437b8]{width:100%;display:block}
|
Binary file not shown.
File diff suppressed because one or more lines are too long
Binary file not shown.
File diff suppressed because one or more lines are too long
Binary file not shown.
File diff suppressed because one or more lines are too long
Binary file not shown.
File diff suppressed because one or more lines are too long
Binary file not shown.
File diff suppressed because one or more lines are too long
Binary file not shown.
File diff suppressed because one or more lines are too long
Binary file not shown.
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,25 @@
|
||||
package com.jiuyv.sptcc.carbon.dataprocess.controller;
|
||||
|
||||
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
/**
|
||||
* @author ren_chao
|
||||
* @since 2024-09-05
|
||||
*/
|
||||
@ControllerAdvice
|
||||
public class Test02Controller {
|
||||
@ExceptionHandler(TestException.class)
|
||||
@ResponseBody
|
||||
public String handleException(TestException ex) {
|
||||
System.out.println("捕获到TestException。。。。。。");
|
||||
// 处理异常并返回视图名
|
||||
return "error";
|
||||
}
|
||||
|
||||
|
||||
static class TestException extends RuntimeException {
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,26 @@
|
||||
package com.jiuyv.sptcc.carbon.dataprocess.enums;
|
||||
|
||||
/**
|
||||
* 数据状态枚举
|
||||
*
|
||||
* @author ren_chao
|
||||
*/
|
||||
public enum TransTypeEnum {
|
||||
BAR_CODE("BC_CODE", "乘车码"),
|
||||
NFC_CARD("NFC_CARD", "NFC");
|
||||
private final String code;
|
||||
private final String info;
|
||||
|
||||
TransTypeEnum(String code, String info) {
|
||||
this.code = code;
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getInfo() {
|
||||
return info;
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package com.jiuyv.sptcc.carbon.dataprocess.enums;
|
||||
|
||||
public enum WarnTypeEnum {
|
||||
|
||||
PUSH("PUSH", "碳减排量报送"),
|
||||
CHAIN("CHAIN", "碳行为上链");
|
||||
|
||||
private final String code;
|
||||
private final String info;
|
||||
|
||||
WarnTypeEnum(String code, String info) {
|
||||
this.code = code;
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getInfo() {
|
||||
return info;
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package com.jiuyv.sptcc.carbon.dataprocess.feign;
|
||||
|
||||
import com.jiuyv.sptcc.carbon.auth.fegin.IAccountApi;
|
||||
import com.jiuyv.sptcc.carbon.auth.fegin.ICardApi;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
|
||||
/**
|
||||
* 内部授权查询接口
|
||||
*
|
||||
* @author ren_chao
|
||||
*/
|
||||
@FeignClient(value = "${carbon-data-process.auth-serve}", contextId = "carbonAuthNFCFeign")
|
||||
public interface CarbonAuthNFCFeign extends ICardApi {
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package com.jiuyv.sptcc.carbon.dataprocess.service;
|
||||
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 缓存service
|
||||
*/
|
||||
public interface ICacheService {
|
||||
|
||||
/**
|
||||
* 获取所有得里程信息
|
||||
* @return 里程信息Map key为进站id_出站id
|
||||
*/
|
||||
Map<String, String> getAllMileage();
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package com.jiuyv.sptcc.carbon.dataprocess.service;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* 下载文件
|
||||
*/
|
||||
public interface IFileService {
|
||||
|
||||
/**
|
||||
* 获取二维码行程文件
|
||||
* @param dateStr 目标日期
|
||||
* @param currentTime 当前时间
|
||||
* @return 文件
|
||||
*/
|
||||
File getBcTravelFile(String dateStr, String currentTime);
|
||||
|
||||
/**
|
||||
* 获取NFC行程文件
|
||||
* @param dateStr 目标日期
|
||||
* @param currentTime 当前时间
|
||||
* @return 文件
|
||||
*/
|
||||
File getNfcTravelFile(String dateStr, String currentTime);
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package com.jiuyv.sptcc.carbon.dataprocess.service;
|
||||
|
||||
import com.jiuyv.sptcc.carbon.dataprocess.enums.WarnTypeEnum;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface IWarnService {
|
||||
|
||||
/**
|
||||
* 查询需要告警的数量
|
||||
* @param stlmDate 清算日期
|
||||
* @return 数量
|
||||
*/
|
||||
Map<WarnTypeEnum, Map<String, Long>> countForWarn(String stlmDate);
|
||||
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
package com.jiuyv.sptcc.carbon.dataprocess.service.impl;
|
||||
|
||||
import com.jiuyv.sptcc.carbon.dataprocess.domain.BcSubwayMileage;
|
||||
import com.jiuyv.sptcc.carbon.dataprocess.mapper.BcSubwayMileageMapper;
|
||||
import com.jiuyv.sptcc.carbon.dataprocess.service.ICacheService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 缓存service
|
||||
*/
|
||||
@Service
|
||||
public class CacheServiceImpl implements ICacheService {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(CacheServiceImpl.class);
|
||||
|
||||
@Autowired
|
||||
private BcSubwayMileageMapper mileageDao;
|
||||
|
||||
/**
|
||||
* 获取所有得里程信息
|
||||
* @return 里程信息Map key为进站id_出站id
|
||||
*/
|
||||
@Cacheable(value = "mileageCache", key = "'allMileage'", sync = true)
|
||||
public Map<String, String> getAllMileage() {
|
||||
LOGGER.info("get all mileage...");
|
||||
Map<String, String> result = new HashMap<>();
|
||||
String minId = "0";
|
||||
List<BcSubwayMileage> list = mileageDao.selectAllMileageRange(minId);
|
||||
while (!list.isEmpty()) {
|
||||
result.putAll(list.stream().collect(Collectors.toMap(x -> x.getInStationId() + "_" + x.getOutStationId(), BcSubwayMileage::getMileage)));
|
||||
minId = list.get(list.size() - 1).getId();
|
||||
list = mileageDao.selectAllMileageRange(minId);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
@ -0,0 +1,110 @@
|
||||
package com.jiuyv.sptcc.carbon.dataprocess.service.impl;
|
||||
|
||||
import com.jcraft.jsch.ChannelSftp;
|
||||
import com.jcraft.jsch.SftpException;
|
||||
import com.jiuyv.sptcc.carbon.dataprocess.config.sftp.SftpChannelPool;
|
||||
import com.jiuyv.sptcc.carbon.dataprocess.config.sftp.SftpProperties;
|
||||
import com.jiuyv.sptcc.carbon.dataprocess.exception.ServiceException;
|
||||
import com.jiuyv.sptcc.carbon.dataprocess.service.IFileService;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipInputStream;
|
||||
|
||||
/**
|
||||
* 下载文件
|
||||
*/
|
||||
@Service
|
||||
public class FileService implements IFileService {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(FileService.class);
|
||||
|
||||
private static final DateTimeFormatter SDF = DateTimeFormatter.ofPattern("yyyyMMdd");
|
||||
|
||||
private final SftpChannelPool sftpChannelPool;
|
||||
private final String remoteDir;
|
||||
private final String fileSuffix;
|
||||
private final String tempDir;
|
||||
private final String nfcFileSuffix;
|
||||
|
||||
public FileService(SftpChannelPool sftpChannelPool,
|
||||
SftpProperties sftpProperties) {
|
||||
this.sftpChannelPool = sftpChannelPool;
|
||||
this.remoteDir = sftpProperties.getRemoteDir();
|
||||
this.fileSuffix = sftpProperties.getFileSuffix();
|
||||
this.tempDir = sftpProperties.getTempDir();
|
||||
this.nfcFileSuffix = sftpProperties.getNfcFileSuffix();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取二维码行程文件
|
||||
* @param dateStr 目标日期
|
||||
* @param currentTime 当前时间
|
||||
* @return 文件
|
||||
*/
|
||||
@Override
|
||||
public File getBcTravelFile(String dateStr, String currentTime) {
|
||||
if (StringUtils.isBlank(dateStr)) {
|
||||
dateStr = LocalDate.parse(currentTime.substring(0, 8), SDF).minusDays(1).format(SDF);
|
||||
}
|
||||
String fileName = dateStr + fileSuffix;
|
||||
return getFile(fileName);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取NFC行程文件
|
||||
* @param dateStr 目标日期
|
||||
* @param currentTime 当前时间
|
||||
* @return 文件
|
||||
*/
|
||||
@Override
|
||||
public File getNfcTravelFile(String dateStr, String currentTime) {
|
||||
if (StringUtils.isBlank(dateStr)) {
|
||||
dateStr = LocalDate.parse(currentTime.substring(0, 8), SDF).minusDays(1).format(SDF);
|
||||
}
|
||||
String fileName = dateStr + nfcFileSuffix;
|
||||
return getFile(fileName);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据文件名获取文件
|
||||
* @param fileName 文件名
|
||||
* @return 文件
|
||||
*/
|
||||
private File getFile(String fileName) {
|
||||
ChannelSftp sftpChannel = sftpChannelPool.getSftpChannel();
|
||||
LOGGER.info(">>>> 获取sftpChannel成功");
|
||||
try (InputStream inputStream = sftpChannel.get(remoteDir + fileName);
|
||||
ZipInputStream zipInputStream = new ZipInputStream(inputStream)) {
|
||||
ZipEntry nextEntry;
|
||||
while ((nextEntry = zipInputStream.getNextEntry()) != null && !nextEntry.isDirectory()) {
|
||||
String filePath = tempDir + nextEntry.getName();
|
||||
LOGGER.info(">>>> 下载并解压:{}", filePath);
|
||||
try (FileOutputStream fileOutputStream = new FileOutputStream(filePath)) {
|
||||
IOUtils.copy(zipInputStream, fileOutputStream);
|
||||
}
|
||||
}
|
||||
LOGGER.info(">>>> 文件下载成功");
|
||||
} catch (IOException | SftpException e) {
|
||||
LOGGER.error("获取文件出错", e);
|
||||
throw new ServiceException("获取文件出错");
|
||||
} finally {
|
||||
sftpChannelPool.closeChannel(sftpChannel);
|
||||
}
|
||||
|
||||
final File file = new File(tempDir, fileName.replace("zip", "csv"));
|
||||
LOGGER.info(">>>> 开始读取文件:{}", file.getAbsolutePath());
|
||||
return file;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,65 @@
|
||||
package com.jiuyv.sptcc.carbon.dataprocess.service.impl;
|
||||
|
||||
import com.jiuyv.sptcc.carbon.dataprocess.domain.BcTravelNotice;
|
||||
import com.jiuyv.sptcc.carbon.dataprocess.enums.WarnTypeEnum;
|
||||
import com.jiuyv.sptcc.carbon.dataprocess.mapper.BcTravelNoticeMapper;
|
||||
import com.jiuyv.sptcc.carbon.dataprocess.service.IWarnService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 告警Service
|
||||
*/
|
||||
@Service
|
||||
public class WarnServiceImpl implements IWarnService {
|
||||
|
||||
@Autowired
|
||||
private BcTravelNoticeMapper travelNoticeMapper;
|
||||
|
||||
/**
|
||||
* 查询需要告警的碳减排量上报数量
|
||||
* @param stlmDate 清算日期
|
||||
* @return 数量
|
||||
*/
|
||||
public Map<WarnTypeEnum, Map<String, Long>> countForWarn(String stlmDate) {
|
||||
Map<WarnTypeEnum, Map<String, Long>> result = new HashMap<>();
|
||||
String startTime = stlmDate + "000000";
|
||||
String endTime = stlmDate + "235959";
|
||||
String minOrderNo = "0";
|
||||
List<BcTravelNotice> list = travelNoticeMapper.range(startTime, endTime, minOrderNo);
|
||||
while(!list.isEmpty()) {
|
||||
for (BcTravelNotice notice : list) {
|
||||
String status = notice.getStatus();
|
||||
processMap(WarnTypeEnum.PUSH, status, result);
|
||||
String chainStatus = notice.getChainStatus();
|
||||
processMap(WarnTypeEnum.CHAIN, chainStatus, result);
|
||||
minOrderNo = notice.getSeqNo();
|
||||
}
|
||||
list = travelNoticeMapper.range(startTime, endTime, minOrderNo);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 合并统计结果集
|
||||
* @param warnTypeEnum 告警类型
|
||||
* @param status 目标状态
|
||||
* @param result 结果集
|
||||
* @return 结果集
|
||||
*/
|
||||
private Map<WarnTypeEnum, Map<String, Long>> processMap(WarnTypeEnum warnTypeEnum, String status, Map<WarnTypeEnum, Map<String, Long>> result) {
|
||||
if (!result.containsKey(warnTypeEnum)) {
|
||||
result.put(warnTypeEnum, new HashMap<>());
|
||||
}
|
||||
if (!result.get(warnTypeEnum).containsKey(status)) {
|
||||
result.get(warnTypeEnum).put(status, 0L);
|
||||
}
|
||||
result.get(warnTypeEnum).put(status, result.get(warnTypeEnum).get(status) +1);
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
package com.jiuyv.sptcc.carbon.dataprocess.api;
|
||||
|
||||
import com.jiuyv.sptcc.carbon.auth.entity.CardBindStatusCheck;
|
||||
import com.jiuyv.sptcc.carbon.auth.web.request.CardBindOperationRequest;
|
||||
import com.jiuyv.sptcc.carbon.auth.web.request.CardBindStatusCheckRequest;
|
||||
import com.jiuyv.sptcc.carbon.auth.web.request.CardWhiteListCheckRequest;
|
||||
import com.jiuyv.sptcc.carbon.auth.web.request.GetUserBatchRequest;
|
||||
import com.jiuyv.sptcc.carbon.auth.web.response.CardBindOperationResponse;
|
||||
import com.jiuyv.sptcc.carbon.auth.web.response.CardBindStatusCheckResponse;
|
||||
import com.jiuyv.sptcc.carbon.auth.web.response.R;
|
||||
import com.jiuyv.sptcc.carbon.auth.web.response.UserHistoryBatchResponse;
|
||||
import com.jiuyv.sptcc.carbon.dataprocess.feign.CarbonAuthNFCFeign;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class CarbonAuthCardFeignMock implements CarbonAuthNFCFeign {
|
||||
@Override
|
||||
public R<CardBindOperationResponse> cardBind(CardBindOperationRequest cardBindOperationRequest) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public R<CardBindOperationResponse> cardUnbind(CardBindOperationRequest cardBindOperationRequest) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public R<CardBindOperationResponse> cardBindStatus(CardBindOperationRequest cardBindStatusRequest) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public R<Boolean> cardWhiteListCheck(CardWhiteListCheckRequest cardWhiteListCheckRequest) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public R<CardBindStatusCheckResponse> cardBindStatusCheck(CardBindStatusCheckRequest request) {
|
||||
List<CardBindStatusCheck> list = new ArrayList<>();
|
||||
for (CardBindStatusCheck auth : request.getList()) {
|
||||
auth.setCcid("did:unitrust:7TYSznS7TFAPskJb3XDxbCDqZpaG");
|
||||
auth.setUserId("0000670723");
|
||||
auth.setBindStatus("BIND");
|
||||
list.add(auth);
|
||||
}
|
||||
CardBindStatusCheckResponse response = new CardBindStatusCheckResponse();
|
||||
response.setList(list);
|
||||
return R.ok(response);
|
||||
}
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
package com.jiuyv.sptcc.carbon.dataprocess.api;
|
||||
|
||||
import com.jiuyv.sptcc.carbon.auth.web.request.AccoutRequest;
|
||||
import com.jiuyv.sptcc.carbon.auth.web.request.AuthApplyRequest;
|
||||
import com.jiuyv.sptcc.carbon.auth.web.request.AuthRequest;
|
||||
import com.jiuyv.sptcc.carbon.auth.web.request.BoundRequest;
|
||||
import com.jiuyv.sptcc.carbon.auth.web.request.GetUserBatchRequest;
|
||||
import com.jiuyv.sptcc.carbon.auth.web.request.GetUserRequest;
|
||||
import com.jiuyv.sptcc.carbon.auth.web.response.AccountResponse;
|
||||
import com.jiuyv.sptcc.carbon.auth.web.response.AuthApplyResponse;
|
||||
import com.jiuyv.sptcc.carbon.auth.web.response.R;
|
||||
import com.jiuyv.sptcc.carbon.auth.web.response.UserHistoryBatchResponse;
|
||||
import com.jiuyv.sptcc.carbon.auth.web.response.UserHistoryResponse;
|
||||
import com.jiuyv.sptcc.carbon.dataprocess.feign.CarbonAuthFeign;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class CarbonAuthFeignMock implements CarbonAuthFeign {
|
||||
@Override
|
||||
public R<AccountResponse> getInfo(AccoutRequest request) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public R<AuthApplyResponse> apply(AuthApplyRequest request) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public R<Void> boundCcId(BoundRequest request) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public R<UserHistoryResponse> getUserByCid(GetUserRequest request) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public R<UserHistoryBatchResponse> getUserByCidBatch(GetUserBatchRequest request) {
|
||||
List<UserHistoryBatchResponse.AuthRecord> list = new ArrayList<>();
|
||||
for (GetUserBatchRequest.AuthRequest auth : request.getList()) {
|
||||
UserHistoryBatchResponse.AuthRecord r = new UserHistoryBatchResponse.AuthRecord();
|
||||
r.setTravelNo(auth.getTravelNo());
|
||||
r.setAuthFlag(Boolean.TRUE);
|
||||
list.add(r);
|
||||
}
|
||||
UserHistoryBatchResponse response = new UserHistoryBatchResponse();
|
||||
response.setList(list);
|
||||
return R.ok(response);
|
||||
}
|
||||
}
|
@ -0,0 +1,67 @@
|
||||
package com.jiuyv.sptcc.carbon.dataprocess.api;
|
||||
|
||||
import com.jcraft.jsch.SftpException;
|
||||
import com.jiuyv.sptcc.carbon.dataprocess.controller.DataProcessControllerTest;
|
||||
import com.jiuyv.sptcc.carbon.dataprocess.exception.ServiceException;
|
||||
import com.jiuyv.sptcc.carbon.dataprocess.service.IFileService;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipInputStream;
|
||||
|
||||
public class FileServiceMock implements IFileService {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory
|
||||
.getLogger(DataProcessControllerTest.class);
|
||||
|
||||
@Override
|
||||
public File getBcTravelFile(String dateStr, String currentTime) {
|
||||
try (InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream("20231023_QrTravel.zip");
|
||||
ZipInputStream zipInputStream = new ZipInputStream(inputStream)) {
|
||||
ZipEntry nextEntry;
|
||||
while ((nextEntry = zipInputStream.getNextEntry()) != null && !nextEntry.isDirectory()) {
|
||||
String filePath = System.getProperty("java.io.tmpdir") + "/" + nextEntry.getName();
|
||||
LOGGER.info(">>>> 下载并解压:{}", filePath);
|
||||
try (FileOutputStream fileOutputStream = new FileOutputStream(filePath)) {
|
||||
IOUtils.copy(zipInputStream, fileOutputStream);
|
||||
}
|
||||
}
|
||||
LOGGER.info(">>>> 文件下载成功");
|
||||
} catch (IOException e) {
|
||||
LOGGER.error("获取文件出错", e);
|
||||
throw new ServiceException("获取文件出错");
|
||||
}
|
||||
final File file = new File(System.getProperty("java.io.tmpdir"), "20231023_QrTravel.csv");
|
||||
LOGGER.info(">>>> 开始读取文件:{}", file.getAbsolutePath());
|
||||
return file;
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getNfcTravelFile(String dateStr, String currentTime) {
|
||||
try (InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream("20231024_NFCTravel.zip");
|
||||
ZipInputStream zipInputStream = new ZipInputStream(inputStream)) {
|
||||
ZipEntry nextEntry;
|
||||
while ((nextEntry = zipInputStream.getNextEntry()) != null && !nextEntry.isDirectory()) {
|
||||
String filePath = System.getProperty("java.io.tmpdir") + "/" + nextEntry.getName();
|
||||
LOGGER.info(">>>> 下载并解压:{}", filePath);
|
||||
try (FileOutputStream fileOutputStream = new FileOutputStream(filePath)) {
|
||||
IOUtils.copy(zipInputStream, fileOutputStream);
|
||||
}
|
||||
}
|
||||
LOGGER.info(">>>> 文件下载成功");
|
||||
} catch (IOException e) {
|
||||
LOGGER.error("获取文件出错", e);
|
||||
throw new ServiceException("获取文件出错");
|
||||
}
|
||||
final File file = new File(System.getProperty("java.io.tmpdir"), "20231024_NFCTravel.csv");
|
||||
LOGGER.info(">>>> 开始读取文件:{}", file.getAbsolutePath());
|
||||
return file;
|
||||
}
|
||||
}
|
@ -0,0 +1,95 @@
|
||||
package com.jiuyv.sptcc.carbon.dataprocess.controller;
|
||||
|
||||
import com.jiuyv.sptcc.carbon.dataprocess.DataProcessApplication;
|
||||
import com.jiuyv.sptcc.carbon.dataprocess.api.CarbonAuthCardFeignMock;
|
||||
import com.jiuyv.sptcc.carbon.dataprocess.api.CarbonAuthFeignMock;
|
||||
import com.jiuyv.sptcc.carbon.dataprocess.api.FileServiceMock;
|
||||
import com.jiuyv.sptcc.carbon.dataprocess.quartz.CarbonDataTask;
|
||||
import com.jiuyv.sptcc.carbon.dataprocess.service.impl.ReadFileServiceImpl;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.MethodOrderer;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestMethodOrder;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.mockito.Spy;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 核心test
|
||||
* @author jiuyv
|
||||
*
|
||||
*/
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@SpringBootTest(classes = DataProcessApplication.class)
|
||||
@ActiveProfiles("junit")//测试配置
|
||||
public class DataProcessControllerTest {
|
||||
|
||||
/** The Constant LOGGER. */
|
||||
private static final Logger LOGGER = LoggerFactory
|
||||
.getLogger(DataProcessControllerTest.class);
|
||||
|
||||
@Resource
|
||||
@InjectMocks
|
||||
private ReadFileServiceImpl readFileService;
|
||||
|
||||
@Resource
|
||||
private CarbonDataTask task;
|
||||
@Spy
|
||||
private FileServiceMock fileServiceMock = new FileServiceMock();
|
||||
|
||||
@Spy
|
||||
private CarbonAuthFeignMock carbonAuthFeignMock = new CarbonAuthFeignMock();
|
||||
|
||||
@Spy
|
||||
private CarbonAuthCardFeignMock carbonAuthCardFeignMock = new CarbonAuthCardFeignMock();
|
||||
|
||||
@BeforeEach
|
||||
public void initMocks() {
|
||||
MockitoAnnotations.openMocks(this);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test1() {
|
||||
LOGGER.info("---------------- 二维码行程读取 开始 ----------------");
|
||||
Boolean isException = false;
|
||||
try {
|
||||
readFileService.readFileAndInsertDatabase("20231023");
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("二维码行程读取运行失败",e);
|
||||
isException = true;
|
||||
}
|
||||
Assertions.assertEquals(Boolean.FALSE, isException);
|
||||
LOGGER.info("---------------- 二维码行程读取 结束 ----------------");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test2() {
|
||||
LOGGER.info("---------------- NFC行程读取 开始 ----------------");
|
||||
Boolean isException = false;
|
||||
try {
|
||||
readFileService.readNFCFileAndInsertDatabase("20231024");
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("NFC行程读取运行失败",e);
|
||||
isException = true;
|
||||
}
|
||||
Assertions.assertEquals(Boolean.FALSE, isException);
|
||||
LOGGER.info("----------------NFC行程读取 结束 ----------------");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test3() {
|
||||
LOGGER.info("---------------- 碳普惠日终统计 开始 ----------------");
|
||||
task.dailyWarning();
|
||||
LOGGER.info("---------------- 碳普惠日终统计 结束 ----------------");
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,111 @@
|
||||
spring:
|
||||
datasource:
|
||||
type: com.zaxxer.hikari.HikariDataSource
|
||||
url: jdbc:h2:mem:testdb;DB_CLOSE_DELAY=FALSE;MODE=Oracle
|
||||
driver-class-name: org.h2.Driver
|
||||
username: root
|
||||
password: 123456
|
||||
hikari:
|
||||
auto-commit: false
|
||||
connection-init-sql: select 1 from dual
|
||||
connection-test-query: select 1 from dual
|
||||
minimum-idle: 5
|
||||
idle-timeout: 180000
|
||||
maximum-pool-size: 10
|
||||
connection-timeout: 30000
|
||||
max-lifetime: 1800000
|
||||
jpa:
|
||||
hibernate:
|
||||
ddl-auto: create
|
||||
sql:
|
||||
init:
|
||||
schema-locations: classpath:db/schema.sql
|
||||
data-locations: classpath:db/data.sql
|
||||
mode: always
|
||||
separator: ;
|
||||
platform: h2
|
||||
encoding: utf-8
|
||||
cache:
|
||||
type: caffeine
|
||||
cache-names:
|
||||
- mileageCache
|
||||
caffeine:
|
||||
spec: initialCapacity=10,maximumSize=500,expireAfterWrite=60s
|
||||
server:
|
||||
compression :
|
||||
enabled : true
|
||||
min-response-size: 1024
|
||||
tomcat:
|
||||
uri-encoding: UTF-8
|
||||
connection-timeout: 60000
|
||||
threads:
|
||||
max: 200
|
||||
cache:
|
||||
type: caffeine
|
||||
cache-names:
|
||||
- changeStationCache
|
||||
- mileageCache
|
||||
- calcFactorCache
|
||||
caffeine:
|
||||
spec: initialCapacity=10,maximumSize=500,expireAfterWrite=60s
|
||||
security:
|
||||
user:
|
||||
password: markettest
|
||||
name: markettest
|
||||
jackson:
|
||||
default-property-inclusion: non_null
|
||||
|
||||
eureka:
|
||||
instance:
|
||||
appname: ${spring.application.name}
|
||||
lease-expiration-duration-in-seconds: 90
|
||||
lease-renewal-interval-in-seconds: 10
|
||||
prefer-ip-address: true
|
||||
instance-id: ${spring.cloud.client.ip-address}:${server.port}
|
||||
metadata-map:
|
||||
user.name: ${spring.security.user.name}
|
||||
user.password: ${spring.security.user.password}
|
||||
client:
|
||||
register-with-eureka: false
|
||||
fetch-registry: false
|
||||
serviceUrl:
|
||||
defaultZone: http://192.168.10.165:18888/eureka/
|
||||
|
||||
feign:
|
||||
httpclient:
|
||||
enabled: false
|
||||
#替换默认的http连接
|
||||
okhttp:
|
||||
enabled: true
|
||||
compression:
|
||||
request:
|
||||
enabled: false
|
||||
response:
|
||||
enabled: false
|
||||
|
||||
mybatis:
|
||||
mapper-locations: classpath:mapper/**/*.xml
|
||||
|
||||
carbon-data-process:
|
||||
sftp:
|
||||
host: 192.168.10.165
|
||||
port: 22
|
||||
username: tomcat
|
||||
password: tomcat123
|
||||
# 远端目录
|
||||
remoteDir: /home/tomcat/transData/
|
||||
# 本地临时目录
|
||||
tempDir: /home/tomcat/carbon/dataprocess/temp/
|
||||
# 连接池最大实例数
|
||||
maxTotal: 5
|
||||
# 连接池最大空闲数
|
||||
maxIdle: 3
|
||||
# 连接池最小空闲数
|
||||
minIdle: 2
|
||||
gateway-serve: FADEOUT
|
||||
auth-serve: CARBON-AUTH
|
||||
sms:
|
||||
enable: false
|
||||
sendUrl: http://168.10.35.161:18878/smsBridge/wl/SmsServlet
|
||||
phone-list:
|
||||
- 13862851173
|
@ -0,0 +1,247 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>2.3.3.RELEASE</version>
|
||||
<relativePath />
|
||||
</parent>
|
||||
<groupId>com.jiuyv</groupId>
|
||||
<artifactId>carcheck-appgate</artifactId>
|
||||
<version>1.0.1-SNAPSHOT</version>
|
||||
<name>carcheck-appgate</name>
|
||||
<description>carcheck-appgate</description>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<java.version>1.8</java.version>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
<maven-jar-plugin.version>3.1.1</maven-jar-plugin.version>
|
||||
<mybatis-spring-boot.version>2.2.2</mybatis-spring-boot.version>
|
||||
<pagehelper.boot.version>1.4.1</pagehelper.boot.version>
|
||||
<commons.io.version>2.11.0</commons.io.version>
|
||||
<commons.fileupload.version>1.4</commons.fileupload.version>
|
||||
<commons.collections.version>3.2.2</commons.collections.version>
|
||||
<druid.version>1.2.11</druid.version>
|
||||
</properties>
|
||||
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
<id>nexus-releases</id>
|
||||
<name>Internal Releases</name>
|
||||
<url>http://172.16.12.11:8082/repository/maven-releases/</url>
|
||||
</repository>
|
||||
|
||||
<snapshotRepository>
|
||||
<id>nexus-snapshots</id>
|
||||
<name>Internal Snapshots</name>
|
||||
<url>http://172.16.12.11:8082/repository/maven-snapshots/</url>
|
||||
</snapshotRepository>
|
||||
</distributionManagement>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<!-- SpringBoot的依赖配置 -->
|
||||
<!--<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-dependencies</artifactId>
|
||||
<version>2.5.14</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>-->
|
||||
|
||||
|
||||
<!-- redis 缓存操作 -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-aop</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- pool 对象池 -->
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-pool2</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 阿里数据库连接池 -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>druid-spring-boot-starter</artifactId>
|
||||
<version>${druid.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<!-- SpringBoot集成mybatis框架 -->
|
||||
<dependency>
|
||||
<groupId>org.mybatis.spring.boot</groupId>
|
||||
<artifactId>mybatis-spring-boot-starter</artifactId>
|
||||
<version>${mybatis-spring-boot.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- pagehelper 分页插件 -->
|
||||
<dependency>
|
||||
<groupId>com.github.pagehelper</groupId>
|
||||
<artifactId>pagehelper-spring-boot-starter</artifactId>
|
||||
<version>${pagehelper.boot.version}</version>
|
||||
</dependency>
|
||||
<!-- 自定义验证注解 -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-validation</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.bouncycastle</groupId>
|
||||
<artifactId>bcprov-jdk15on</artifactId>
|
||||
<version>1.69</version>
|
||||
</dependency>
|
||||
|
||||
<!-- io常用工具类 -->
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>${commons.io.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 文件上传工具类 -->
|
||||
<dependency>
|
||||
<groupId>commons-fileupload</groupId>
|
||||
<artifactId>commons-fileupload</artifactId>
|
||||
<version>${commons.fileupload.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- collections工具类 -->
|
||||
<dependency>
|
||||
<groupId>commons-collections</groupId>
|
||||
<artifactId>commons-collections</artifactId>
|
||||
<version>${commons.collections.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!--常用工具类 -->
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-codec</groupId>
|
||||
<artifactId>commons-codec</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- JSON工具类 -->
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- json logstash encoder -->
|
||||
<dependency>
|
||||
<groupId>net.logstash.logback</groupId>
|
||||
<artifactId>logstash-logback-encoder</artifactId>
|
||||
<version>6.4</version>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/cn.hutool/hutool-all -->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>cn.hutool</groupId>-->
|
||||
<!-- <artifactId>hutool-all</artifactId>-->
|
||||
<!-- <version>5.8.20</version>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
<version>28.1-jre</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.jiuyv</groupId>
|
||||
<artifactId>smtools</artifactId>
|
||||
<version>1.1.3</version>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/com.squareup.okhttp3/okhttp -->
|
||||
<dependency>
|
||||
<groupId>com.squareup.okhttp3</groupId>
|
||||
<artifactId>okhttp</artifactId>
|
||||
<version>4.10.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>eu.bitwalker</groupId>
|
||||
<artifactId>UserAgentUtils</artifactId>
|
||||
<version>1.21</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.alibaba.fastjson2</groupId>
|
||||
<artifactId>fastjson2</artifactId>
|
||||
<version>2.0.8</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<scm>
|
||||
<connection>scm:svn:http://172.16.12.10/svn/carcheck/code/carcheck-appgate/trunk/</connection>
|
||||
<developerConnection>scm:svn:http://172.16.12.10/svn/carcheck/code/carcheck-appgate/trunk/
|
||||
</developerConnection>
|
||||
</scm>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>jiuyv</id>
|
||||
<name>jiuyv</name>
|
||||
<url>http://172.16.12.11:8082/repository/maven-public/</url>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
<updatePolicy>always</updatePolicy>
|
||||
</snapshots>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>jiuyv</id>
|
||||
<name>jiuyv Plugin Repository</name>
|
||||
<url>http://172.16.12.11:8082/repository/maven-public/</url>
|
||||
</pluginRepository>
|
||||
<pluginRepository>
|
||||
<id>central</id>
|
||||
<name>Maven Plugin Repository</name>
|
||||
<url>http://repo1.maven.org/maven2/</url>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
|
||||
</project>
|
@ -0,0 +1,15 @@
|
||||
package com.jiuyv.appgate;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
|
||||
@EnableScheduling
|
||||
@SpringBootApplication
|
||||
public class CarcheckAppgateApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(CarcheckAppgateApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
package com.jiuyv.appgate.api;
|
||||
|
||||
import com.jiuyv.appgate.common.AjaxResult;
|
||||
import com.jiuyv.appgate.service.IFileService;
|
||||
import com.jiuyv.appgate.vo.file.ReqFileDeleteVO;
|
||||
import com.jiuyv.appgate.vo.file.ResFileUploadVO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/app/img")
|
||||
public class FileController {
|
||||
|
||||
@Autowired
|
||||
private IFileService fileService;
|
||||
|
||||
/**
|
||||
* 拍照上传
|
||||
*
|
||||
* @param file
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/upload")
|
||||
public AjaxResult fileUpload(@RequestParam("file") MultipartFile file,
|
||||
@RequestParam("orderId") String orderId,
|
||||
@RequestParam("carVin") String carVin) {
|
||||
ResFileUploadVO result = fileService.fileUpload(file, orderId, carVin);
|
||||
return AjaxResult.success(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 照片删除
|
||||
*
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/delete")
|
||||
public AjaxResult fileDelete(@RequestBody ReqFileDeleteVO req) {
|
||||
fileService.fileDelete(req);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue