@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" output="target/classes" path="src/main/java">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
|
||||
<attributes>
|
||||
<attribute name="test" value="true"/>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
|
||||
<attributes>
|
||||
<attribute name="module" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/OpenCV-4.4.0"/>
|
||||
<classpathentry kind="lib" path="lib/opencv-4.0.1-1.4.4-windows-x86_64.jar"/>
|
||||
<classpathentry kind="output" path="target/classes"/>
|
||||
</classpath>
|
@ -0,0 +1,13 @@
|
||||
### 该问题是怎么引起的?
|
||||
|
||||
|
||||
|
||||
### 重现步骤
|
||||
|
||||
|
||||
|
||||
### 报错信息
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,15 @@
|
||||
### 相关的Issue
|
||||
|
||||
|
||||
### 原因(目的、解决的问题等)
|
||||
|
||||
|
||||
### 描述(做了什么,变更了什么)
|
||||
|
||||
|
||||
### 测试用例(新增、改动、可能影响的功能)
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,23 @@
|
||||
# Compiled class file
|
||||
*.class
|
||||
|
||||
# Log file
|
||||
*.log
|
||||
|
||||
# BlueJ files
|
||||
*.ctxt
|
||||
|
||||
# Mobile Tools for Java (J2ME)
|
||||
.mtj.tmp/
|
||||
|
||||
# Package Files #
|
||||
*.jar
|
||||
*.war
|
||||
*.nar
|
||||
*.ear
|
||||
*.zip
|
||||
*.tar.gz
|
||||
*.rar
|
||||
|
||||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||
hs_err_pid*
|
@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>yx-image-recognition</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
@ -0,0 +1,5 @@
|
||||
eclipse.preferences.version=1
|
||||
encoding//src/main/java=UTF-8
|
||||
encoding//src/main/resources=UTF-8
|
||||
encoding//src/test/java=UTF-8
|
||||
encoding/<project>=UTF-8
|
@ -0,0 +1,9 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.methodParameters=generate
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
||||
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
|
||||
org.eclipse.jdt.core.compiler.release=disabled
|
||||
org.eclipse.jdt.core.compiler.source=1.8
|
@ -0,0 +1,29 @@
|
||||
BSD 3-Clause License
|
||||
|
||||
Copyright (c) 2020, yuxue
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the name of the copyright holder nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
After Width: | Height: | Size: 427 KiB |
After Width: | Height: | Size: 44 KiB |
After Width: | Height: | Size: 47 KiB |
After Width: | Height: | Size: 34 KiB |
After Width: | Height: | Size: 49 KiB |
After Width: | Height: | Size: 782 B |
After Width: | Height: | Size: 684 B |
After Width: | Height: | Size: 761 B |
After Width: | Height: | Size: 762 B |
After Width: | Height: | Size: 611 B |
After Width: | Height: | Size: 770 B |
After Width: | Height: | Size: 435 B |
After Width: | Height: | Size: 4.4 KiB |
After Width: | Height: | Size: 4.7 KiB |
After Width: | Height: | Size: 770 B |
After Width: | Height: | Size: 3.2 KiB |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 29 KiB |
After Width: | Height: | Size: 35 KiB |
After Width: | Height: | Size: 10 KiB |
After Width: | Height: | Size: 3.9 KiB |
After Width: | Height: | Size: 2.7 KiB |
After Width: | Height: | Size: 7.2 KiB |
After Width: | Height: | Size: 727 B |
After Width: | Height: | Size: 42 KiB |
After Width: | Height: | Size: 12 KiB |
After Width: | Height: | Size: 661 B |
After Width: | Height: | Size: 3.1 KiB |
After Width: | Height: | Size: 3.7 KiB |
After Width: | Height: | Size: 3.2 KiB |
After Width: | Height: | Size: 3.1 KiB |
After Width: | Height: | Size: 3.3 KiB |
After Width: | Height: | Size: 4.0 KiB |
After Width: | Height: | Size: 40 KiB |
After Width: | Height: | Size: 120 KiB |
After Width: | Height: | Size: 200 KiB |
After Width: | Height: | Size: 200 KiB |
After Width: | Height: | Size: 11 KiB |
After Width: | Height: | Size: 212 KiB |
@ -0,0 +1,36 @@
|
||||
package com.yuxue;
|
||||
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* spring boot 启动类
|
||||
* @author yuxue
|
||||
* @date 2019-12-06
|
||||
*/
|
||||
@SpringBootApplication
|
||||
@MapperScan("mapper")
|
||||
@EnableScheduling //开启对定时任务的支持
|
||||
@Slf4j
|
||||
public class Application {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(Application.class, args);
|
||||
String version = System.getProperty("java.version");
|
||||
if (Integer.parseInt(
|
||||
version.substring(0,1)) == 1
|
||||
&& Integer.parseInt(version.substring(2, 3)) >= 8
|
||||
&& Integer.parseInt(version.substring(6)) >= 60
|
||||
|| Integer.parseInt(version.substring(0,1))>=9) {
|
||||
SpringApplication.run(Application.class, args);
|
||||
} else {
|
||||
log.error("java version need greater than 1.8.60, and do not use open jdk !!!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package com.yuxue.aop;
|
||||
|
||||
import org.springframework.aop.support.DefaultPointcutAdvisor;
|
||||
import org.springframework.aop.support.JdkRegexpMethodPointcut;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
|
||||
/**
|
||||
* 返回值封装aop
|
||||
* @author yuxue
|
||||
* @date 2019-08-20
|
||||
*/
|
||||
@Configuration
|
||||
@ConditionalOnMissingBean(DefaultPointcutAdvisor.class)
|
||||
public class DefaultAopConfig {
|
||||
|
||||
// @Value("${test.aop.pointcut:com.yuxue..*.controller..*.*(..)}")
|
||||
@Value("${test.aop.pointcut:com.yuxue.controller..*.*(..)}")
|
||||
private String pattern;
|
||||
|
||||
@Bean("resultAop")
|
||||
public DefaultPointcutAdvisor resultAop() {
|
||||
DefaultPointcutAdvisor pfb = new DefaultPointcutAdvisor();
|
||||
JdkRegexpMethodPointcut j = new JdkRegexpMethodPointcut();
|
||||
j.setPattern(pattern);
|
||||
AroundMethod method = new AroundMethod();
|
||||
pfb.setAdvice(method);
|
||||
pfb.setPointcut(j);
|
||||
return pfb;
|
||||
}
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
package com.yuxue.aop;
|
||||
|
||||
import org.aspectj.lang.JoinPoint;
|
||||
import org.aspectj.lang.annotation.AfterReturning;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.aspectj.lang.annotation.Before;
|
||||
import org.aspectj.lang.annotation.Pointcut;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* controller 层日志aop
|
||||
* @author yuxue
|
||||
* @date 2018-09-07
|
||||
*/
|
||||
@Aspect
|
||||
@Slf4j
|
||||
@Component
|
||||
public class WebAop {
|
||||
|
||||
@Pointcut("execution(* com.yuxue.controller..*.*(..))")
|
||||
public void webLog() {}
|
||||
|
||||
@Before("webLog()")
|
||||
public void doBefore(JoinPoint joinPoint) throws Throwable {
|
||||
// 接收到请求,记录请求内容
|
||||
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
|
||||
HttpServletRequest request = attributes.getRequest();
|
||||
|
||||
log.info("====================");
|
||||
log.info("Cookie: " + request.getHeader("Cookie"));
|
||||
log.info(request.getMethod() + "=>" + request.getRequestURL().toString());
|
||||
log.info("IP: " + request.getRemoteAddr());
|
||||
log.info("CLASS_METHOD: "
|
||||
+ joinPoint.getSignature().getDeclaringTypeName()
|
||||
+ "."
|
||||
+ joinPoint.getSignature().getName());
|
||||
log.info("ARGS: " + Arrays.toString(joinPoint.getArgs()));
|
||||
log.info("====================\n");
|
||||
}
|
||||
|
||||
|
||||
@AfterReturning(returning = "ret", pointcut = "webLog()")
|
||||
public void doAfterReturning(Object ret) throws Throwable {
|
||||
// 关闭: 返回前进行内容结果日志输出
|
||||
log.info("RESPONSE: " + ret);
|
||||
log.info("====================\n");
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
package com.yuxue.config;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.CommandLineRunner;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
|
||||
/**
|
||||
* 配置自动启动浏览器
|
||||
*
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class CommandRunner implements CommandLineRunner {
|
||||
|
||||
@Value("${server.port}")
|
||||
private String port;
|
||||
|
||||
@Override
|
||||
public void run(String... args) {
|
||||
try {
|
||||
String os = System.getProperty("os.name").toLowerCase();
|
||||
if(os.contains("windows")) {
|
||||
// 默认浏览器打开
|
||||
// Runtime.getRuntime().exec("cmd /c start http://localhost:" + port + "/index");
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
log.error("打开默认浏览器异常", ex);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
package com.yuxue.config;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
/**
|
||||
* 跨域通配
|
||||
* 支持 @CrossOrigin 注解局部声明
|
||||
* @author yuxue
|
||||
* @date 2018-09-07
|
||||
*/
|
||||
@Configuration
|
||||
public class CorsConfig {
|
||||
|
||||
@Bean
|
||||
public WebMvcConfigurer corsConfigurer() {
|
||||
return new WebMvcConfigurer() {
|
||||
@Override
|
||||
public void addCorsMappings(CorsRegistry registry) {
|
||||
/** * 至少需要addMapping *** */
|
||||
registry
|
||||
.addMapping("/**")
|
||||
.allowedOrigins("*")
|
||||
.allowedMethods("PUT", "DELETE", "GET", "POST", "OPTIONS", "HEAD")
|
||||
.allowedHeaders("Content-Type", "X-Requested-With", "accept", "Authorization", "Origin", "Access-Control-Request-Method", "Access-Control-Request-Headers")
|
||||
.allowCredentials(true)//是否带上cookie
|
||||
.maxAge(3600)
|
||||
.exposedHeaders(
|
||||
"access-control-allow-headers",
|
||||
"access-control-allow-methods",
|
||||
"access-control-allow-origin",
|
||||
"access-Control-allow-credentials",
|
||||
"access-control-max-age",
|
||||
"X-Frame-Options");
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package com.yuxue.config;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.LocaleResolver;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 自定义配置
|
||||
* @author yuxue
|
||||
* @date 2019-06-13
|
||||
*/
|
||||
@Configuration
|
||||
public class DefaultMvcConfig {
|
||||
|
||||
/**
|
||||
* 国际化配置
|
||||
* 设置区域信息
|
||||
* @return
|
||||
*/
|
||||
@Bean
|
||||
public LocaleResolver localeResolver(){
|
||||
return new MyLocaleResolver();
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package com.yuxue.config;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
|
||||
|
||||
@Configuration
|
||||
public class LocalDateTimeSerializerConfig {
|
||||
|
||||
@Value("${spring.jackson.date-format:yyyy-MM-dd HH:mm:ss}")
|
||||
private String pattern;
|
||||
|
||||
@Bean
|
||||
public LocalDateTimeSerializer localDateTimeDeserializer() {
|
||||
return new LocalDateTimeSerializer(DateTimeFormatter.ofPattern(pattern));
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Jackson2ObjectMapperBuilderCustomizer jackson2ObjectMapperBuilderCustomizer() {
|
||||
return builder -> builder.serializerByType(LocalDateTime.class, localDateTimeDeserializer());
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package com.yuxue.config;
|
||||
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.servlet.LocaleResolver;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* 配置多语言
|
||||
* @author yuxue
|
||||
* @date 2019-06-13
|
||||
*/
|
||||
public class MyLocaleResolver implements LocaleResolver {
|
||||
|
||||
@Override
|
||||
public Locale resolveLocale(HttpServletRequest request) {
|
||||
String l = request.getParameter("i18n");
|
||||
Locale locale = Locale.getDefault();
|
||||
if(!StringUtils.isEmpty(l)){
|
||||
String[] split = l.split("_");
|
||||
locale = new Locale(split[0],split[1]);
|
||||
}
|
||||
return locale;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLocale(HttpServletRequest request, HttpServletResponse response, Locale locale) {
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package com.yuxue.config;
|
||||
|
||||
import com.github.pagehelper.PageInterceptor;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
|
||||
/**
|
||||
* 分页查询控制
|
||||
* @author yuxue
|
||||
* @date 2018-09-07
|
||||
*/
|
||||
@Configuration
|
||||
public class PageHelperConfig {
|
||||
|
||||
@Value("${pagehelper.helperDialect}")
|
||||
private String helperDialect;
|
||||
|
||||
@Bean
|
||||
public PageInterceptor pageInterceptor() {
|
||||
PageInterceptor pageInterceptor = new PageInterceptor();
|
||||
Properties properties = new Properties();
|
||||
properties.setProperty("helperDialect", helperDialect);
|
||||
pageInterceptor.setProperties(properties);
|
||||
return pageInterceptor;
|
||||
}
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
package com.yuxue.config;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
|
||||
import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.task.TaskExecutor;
|
||||
import org.springframework.scheduling.annotation.AsyncConfigurer;
|
||||
import org.springframework.scheduling.annotation.EnableAsync;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||
|
||||
@Configuration
|
||||
@ComponentScan("com.yuxue.auth.service.impl")
|
||||
@EnableAsync
|
||||
public class ThreadPoolConfig implements AsyncConfigurer {
|
||||
|
||||
@Bean(name = "taskExecutor")
|
||||
public TaskExecutor taskExecutor() {
|
||||
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
|
||||
|
||||
// 设置核心线程数
|
||||
executor.setCorePoolSize(4);
|
||||
// 设置最大线程数
|
||||
executor.setMaxPoolSize(8);
|
||||
// 设置队列容量
|
||||
executor.setQueueCapacity(100);
|
||||
// 设置线程活跃时间(秒)
|
||||
executor.setKeepAliveSeconds(60);
|
||||
// 设置默认线程名称
|
||||
executor.setThreadNamePrefix("localThread:");
|
||||
// 设置拒绝策略
|
||||
executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
|
||||
// 等待所有任务结束后再关闭线程池
|
||||
executor.setWaitForTasksToCompleteOnShutdown(true);
|
||||
return executor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Executor getAsyncExecutor() {
|
||||
return taskExecutor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
package com.yuxue.controller;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
|
||||
import com.yuxue.annotation.RetExclude;
|
||||
|
||||
import springfox.documentation.annotations.ApiIgnore;
|
||||
|
||||
|
||||
|
||||
@ApiIgnore
|
||||
@Controller
|
||||
public class CommonController {
|
||||
|
||||
@RetExclude
|
||||
@RequestMapping(value = "", method = { RequestMethod.GET })
|
||||
public String doc() {
|
||||
return "redirect:swagger-ui.html";
|
||||
}
|
||||
|
||||
@RetExclude
|
||||
@RequestMapping(value = "login", method = { RequestMethod.GET })
|
||||
public String loginPage() {
|
||||
return "home/login";
|
||||
}
|
||||
|
||||
@RetExclude
|
||||
@RequestMapping(value = "index", method = { RequestMethod.GET })
|
||||
public String indexPage() {
|
||||
return "home/index";
|
||||
}
|
||||
|
||||
@RetExclude
|
||||
@RequestMapping(value = "unauthorized", method = { RequestMethod.GET })
|
||||
public String unauthorizedPage() {
|
||||
return "unauthorized";
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
package com.yuxue.controller;
|
||||
|
||||
import org.opencv.core.Core;
|
||||
import org.opencv.core.Mat;
|
||||
import org.opencv.core.MatOfRect;
|
||||
import org.opencv.core.Rect;
|
||||
import org.opencv.imgcodecs.Imgcodecs;
|
||||
import org.opencv.imgproc.Imgproc;
|
||||
import org.opencv.objdetect.CascadeClassifier;
|
||||
|
||||
/**
|
||||
* 识别人脸
|
||||
* Detects faces in an image, draws boxes around them,
|
||||
* and writes the results to "faceDetection.png".
|
||||
*/
|
||||
public class FaceController {
|
||||
|
||||
static {
|
||||
System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
// Create a face detector from the cascade file in the resources directory.
|
||||
// 创建识别器
|
||||
CascadeClassifier faceDetector = new CascadeClassifier("/src/main/resources/haarcascades/lbpcascade_frontalface.xml");
|
||||
|
||||
String imgPath = "/src/main/resources/DetectFace/AverageMaleFace.jpg";
|
||||
Mat image = Imgcodecs.imread(imgPath);
|
||||
|
||||
Mat dst = new Mat();
|
||||
Imgproc.Canny(image, dst, 130, 250);
|
||||
|
||||
// Detect faces in the image. MatOfRect is a special container class for Rect.
|
||||
MatOfRect faceDetections = new MatOfRect();
|
||||
faceDetector.detectMultiScale(dst, faceDetections);
|
||||
|
||||
System.out.println(String.format("识别出 %s 张人脸", faceDetections.toArray().length));
|
||||
|
||||
// Draw a bounding box around each face.
|
||||
for (Rect rect : faceDetections.toArray()) {
|
||||
// Core.rectangle(image, new Point(rect.x, rect.y), new Point(rect.x + rect.width, rect.y + rect.height), new Scalar(0, 255, 0));
|
||||
}
|
||||
|
||||
// Save the visualized detection.
|
||||
// System.out.println(String.format("Writing %s", filename));
|
||||
//Highgui.imwrite(filename, image);
|
||||
}
|
||||
}
|
@ -0,0 +1,83 @@
|
||||
package com.yuxue.easypr.core;
|
||||
|
||||
import org.bytedeco.javacpp.opencv_core;
|
||||
import org.bytedeco.javacpp.opencv_core.Mat;
|
||||
import org.bytedeco.javacpp.opencv_ml.ANN_MLP;
|
||||
|
||||
import com.yuxue.constant.Constant;
|
||||
import com.yuxue.util.Convert;
|
||||
|
||||
|
||||
/**
|
||||
* 字符检测
|
||||
* @author yuxue
|
||||
* @date 2020-04-24 15:31
|
||||
*/
|
||||
public class CharsIdentify {
|
||||
|
||||
private ANN_MLP ann=ANN_MLP.create();
|
||||
|
||||
public CharsIdentify() {
|
||||
loadModel(Constant.DEFAULT_ANN_PATH);
|
||||
}
|
||||
|
||||
public void loadModel(String path) {
|
||||
this.ann.clear();
|
||||
// 加载ann配置文件 图像转文字的训练库文件
|
||||
//ann=ANN_MLP.loadANN_MLP(path, "ann");
|
||||
ann = ANN_MLP.load(path);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param input
|
||||
* @param isChinese
|
||||
* @return
|
||||
*/
|
||||
public String charsIdentify(final Mat input, final Boolean isChinese, final Boolean isSpeci) {
|
||||
String result = "";
|
||||
|
||||
/*String name = "D:/PlateDetect/train/chars_recognise_ann/" + System.currentTimeMillis() + ".jpg";
|
||||
opencv_imgcodecs.imwrite(name, input);
|
||||
Mat img = opencv_imgcodecs.imread(name);
|
||||
Mat f = CoreFunc.features(img, Constant.predictSize);*/
|
||||
|
||||
Mat f = CoreFunc.features(input, Constant.predictSize);
|
||||
|
||||
int index = this.classify(f, isChinese, isSpeci);
|
||||
|
||||
System.err.print(index);
|
||||
if (index < Constant.numCharacter) {
|
||||
result = String.valueOf(Constant.strCharacters[index]);
|
||||
} else {
|
||||
String s = Constant.strChinese[index - Constant.numCharacter];
|
||||
result = Constant.KEY_CHINESE_MAP.get(s); // 编码转中文
|
||||
}
|
||||
System.err.println(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
private int classify(final Mat f, final Boolean isChinses, final Boolean isSpeci) {
|
||||
int result = -1;
|
||||
|
||||
Mat output = new Mat(1, 140, opencv_core.CV_32F);
|
||||
|
||||
ann.predict(f, output, 0); // 预测结果
|
||||
|
||||
int ann_min = (!isChinses) ? ((isSpeci) ? 10 : 0) : Constant.numCharacter;
|
||||
int ann_max = (!isChinses) ? Constant.numCharacter : Constant.numAll;
|
||||
|
||||
float maxVal = -2;
|
||||
|
||||
for (int j = ann_min; j < ann_max; j++) {
|
||||
float val = Convert.toFloat(output.ptr(0, j));
|
||||
if (val > maxVal) {
|
||||
maxVal = val;
|
||||
result = j;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,90 @@
|
||||
package com.yuxue.easypr.core;
|
||||
|
||||
import static com.yuxue.easypr.core.CoreFunc.features;
|
||||
import static org.bytedeco.javacpp.opencv_core.merge;
|
||||
import static org.bytedeco.javacpp.opencv_core.split;
|
||||
|
||||
import org.bytedeco.javacpp.opencv_core.Mat;
|
||||
import org.bytedeco.javacpp.opencv_core.MatVector;
|
||||
import org.bytedeco.javacpp.opencv_imgproc;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author yuxue
|
||||
* @date 2020-05-05 08:26
|
||||
*/
|
||||
public class Features implements SVMCallback {
|
||||
|
||||
/***
|
||||
* EasyPR的getFeatures回调函数
|
||||
* 本函数是生成直方图均衡特征的回调函数
|
||||
* @param image
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Mat getHisteqFeatures(final Mat image) {
|
||||
return histeq(image);
|
||||
}
|
||||
|
||||
private Mat histeq(Mat in) {
|
||||
Mat out = new Mat(in.size(), in.type());
|
||||
if (in.channels() == 3) {
|
||||
Mat hsv = new Mat();
|
||||
MatVector hsvSplit = new MatVector();
|
||||
opencv_imgproc.cvtColor(in, hsv, opencv_imgproc.CV_BGR2HSV);
|
||||
split(hsv, hsvSplit);
|
||||
opencv_imgproc.equalizeHist(hsvSplit.get(2), hsvSplit.get(2));
|
||||
merge(hsvSplit, hsv);
|
||||
opencv_imgproc.cvtColor(hsv, out, opencv_imgproc.CV_HSV2BGR);
|
||||
hsv = null;
|
||||
hsvSplit = null;
|
||||
System.gc();
|
||||
} else if (in.channels() == 1) {
|
||||
opencv_imgproc.equalizeHist(in, out);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
/**
|
||||
* EasyPR的getFeatures回调函数
|
||||
* 本函数是获取垂直和水平的直方图图值
|
||||
* @param image
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Mat getHistogramFeatures(Mat image) {
|
||||
Mat grayImage = new Mat();
|
||||
opencv_imgproc.cvtColor(image, grayImage, opencv_imgproc.CV_RGB2GRAY);
|
||||
|
||||
Mat img_threshold = new Mat();
|
||||
opencv_imgproc.threshold(grayImage, img_threshold, 0, 255, opencv_imgproc.CV_THRESH_OTSU + opencv_imgproc.CV_THRESH_BINARY);
|
||||
|
||||
return features(img_threshold, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* 本函数是获取SITF特征子的回调函数
|
||||
*
|
||||
* @param image
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Mat getSIFTFeatures(final Mat image) {
|
||||
// TODO: 待完善
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 本函数是获取HOG特征子的回调函数
|
||||
*
|
||||
* @param image
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Mat getHOGFeatures(final Mat image) {
|
||||
// TODO: 待完善
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,107 @@
|
||||
package com.yuxue.easypr.core;
|
||||
|
||||
import org.bytedeco.javacpp.opencv_core;
|
||||
import org.bytedeco.javacpp.opencv_imgproc;
|
||||
|
||||
import java.util.Vector;
|
||||
|
||||
import org.bytedeco.javacpp.opencv_core.Mat;
|
||||
import org.bytedeco.javacpp.opencv_core.Rect;
|
||||
import org.bytedeco.javacpp.opencv_core.Size;
|
||||
import org.bytedeco.javacpp.opencv_ml.SVM;
|
||||
|
||||
import com.yuxue.constant.Constant;
|
||||
|
||||
|
||||
/**
|
||||
* 车牌判断
|
||||
* @author yuxue
|
||||
* @date 2020-04-26 15:21
|
||||
*/
|
||||
public class PlateJudge {
|
||||
|
||||
private SVM svm = SVM.create();
|
||||
|
||||
public PlateJudge() {
|
||||
loadSVM(Constant.DEFAULT_SVM_PATH);
|
||||
}
|
||||
|
||||
public void loadSVM(String path) {
|
||||
svm.clear();
|
||||
// svm=SVM.loadSVM(path, "svm");
|
||||
svm=SVM.load(path);
|
||||
}
|
||||
|
||||
/**
|
||||
* EasyPR的getFeatures回调函数, 用于从车牌的image生成svm的训练特征features
|
||||
*/
|
||||
private SVMCallback features = new Features();
|
||||
|
||||
|
||||
/**
|
||||
* 对单幅图像进行SVM判断
|
||||
* @param inMat
|
||||
* @return
|
||||
*/
|
||||
public int plateJudge(final Mat inMat) {
|
||||
int ret = 1;
|
||||
// 使用com.yuxue.train.SVMTrain 生成的训练库文件
|
||||
Mat features = this.features.getHistogramFeatures(inMat);
|
||||
/*Mat samples = features.reshape(1, 1);
|
||||
samples.convertTo(samples, opencv_core.CV_32F);*/
|
||||
|
||||
Mat p = features.reshape(1, 1);
|
||||
p.convertTo(p, opencv_core.CV_32FC1);
|
||||
ret = (int) svm.predict(features);
|
||||
return ret;
|
||||
|
||||
// 使用com.yuxue.train.PlateRecoTrain 生成的训练库文件
|
||||
// 在使用的过程中,传入的样本切图要跟训练的时候处理切图的方法一致
|
||||
/*Mat grayImage = new Mat();
|
||||
opencv_imgproc.cvtColor(inMat, grayImage, opencv_imgproc.CV_RGB2GRAY);
|
||||
Mat dst = new Mat();
|
||||
opencv_imgproc.Canny(grayImage, dst, 130, 250);
|
||||
Mat samples = dst.reshape(1, 1);
|
||||
samples.convertTo(samples, opencv_core.CV_32F);*/
|
||||
|
||||
// 正样本为0 负样本为1
|
||||
/*if(svm.predict(samples) <= 0) {
|
||||
ret = 1;
|
||||
}*/
|
||||
/*ret = (int)svm.predict(samples);
|
||||
System.err.println(ret);
|
||||
return ret ;*/
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 对多幅图像进行SVM判断
|
||||
* @param inVec
|
||||
* @param resultVec
|
||||
* @return
|
||||
*/
|
||||
public int plateJudge(Vector<Mat> inVec, Vector<Mat> resultVec) {
|
||||
|
||||
for (int j = 0; j < inVec.size(); j++) {
|
||||
Mat inMat = inVec.get(j);
|
||||
|
||||
if (1 == plateJudge(inMat)) {
|
||||
resultVec.add(inMat);
|
||||
} else { // 再取中间部分判断一次
|
||||
int w = inMat.cols();
|
||||
int h = inMat.rows();
|
||||
|
||||
Mat tmpDes = inMat.clone();
|
||||
Mat tmpMat = new Mat(inMat, new Rect((int) (w * 0.05), (int) (h * 0.1), (int) (w * 0.9), (int) (h * 0.8)));
|
||||
opencv_imgproc.resize(tmpMat, tmpDes, new Size(inMat.size()));
|
||||
|
||||
if (plateJudge(tmpDes) == 1) {
|
||||
resultVec.add(inMat);
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
package com.yuxue.easypr.core;
|
||||
|
||||
import org.bytedeco.javacpp.opencv_core.Mat;
|
||||
|
||||
|
||||
/**
|
||||
* @author Created by fanwenjie
|
||||
* @author lin.yao
|
||||
*
|
||||
*/
|
||||
public interface SVMCallback {
|
||||
|
||||
/***
|
||||
* EasyPR的getFeatures回调函数,本函数是生成直方图均衡特征的回调函数
|
||||
*
|
||||
* @param image
|
||||
* @return
|
||||
*/
|
||||
public abstract Mat getHisteqFeatures(final Mat image);
|
||||
|
||||
/**
|
||||
* EasyPR的getFeatures回调函数, 本函数是获取垂直和水平的直方图图值
|
||||
*
|
||||
* @param image
|
||||
* @return
|
||||
*/
|
||||
public abstract Mat getHistogramFeatures(final Mat image);
|
||||
|
||||
/**
|
||||
* 本函数是获取SITF特征子的回调函数
|
||||
*
|
||||
* @param image
|
||||
* @return
|
||||
*/
|
||||
public abstract Mat getSIFTFeatures(final Mat image);
|
||||
|
||||
/**
|
||||
* 本函数是获取HOG特征子的回调函数
|
||||
*
|
||||
* @param image
|
||||
* @return
|
||||
*/
|
||||
public abstract Mat getHOGFeatures(final Mat image);
|
||||
}
|
@ -0,0 +1,81 @@
|
||||
package com.yuxue.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* t_plate_file
|
||||
* @author yuxue
|
||||
* 2020-04-30 11:04:47.169
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class PlateFileEntity implements Serializable {
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* fileName
|
||||
*/
|
||||
private String fileName;
|
||||
|
||||
/**
|
||||
* filePath
|
||||
*/
|
||||
private String filePath;
|
||||
|
||||
/**
|
||||
* fileType
|
||||
*/
|
||||
private String fileType;
|
||||
|
||||
/**
|
||||
* fileLength
|
||||
*/
|
||||
private Integer fileLength;
|
||||
|
||||
/**
|
||||
* plate
|
||||
*/
|
||||
private String plate;
|
||||
|
||||
/**
|
||||
* plateColor
|
||||
*/
|
||||
private String plateColor;
|
||||
|
||||
/**
|
||||
* lastRecoTime
|
||||
*/
|
||||
private String lastRecoTime;
|
||||
|
||||
/**
|
||||
* tempPath
|
||||
*/
|
||||
private String tempPath;
|
||||
|
||||
/**
|
||||
* recoPlate
|
||||
*/
|
||||
private String recoPlate;
|
||||
|
||||
/**
|
||||
* recoColor
|
||||
*/
|
||||
private String recoColor;
|
||||
|
||||
/**
|
||||
* recoCorrect
|
||||
* 0未识别 1正确 2错误 3未检测到车牌
|
||||
*/
|
||||
private Integer recoCorrect;
|
||||
|
||||
private List<PlateRecoDebugEntity> debug;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
@ -0,0 +1,66 @@
|
||||
package com.yuxue.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* t_plate_reco_debug
|
||||
* @author yuxue
|
||||
* 2020-04-30 16:17:58.795
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class PlateRecoDebugEntity implements Serializable {
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* parentId
|
||||
*/
|
||||
private Integer parentId;
|
||||
|
||||
/**
|
||||
* fileName
|
||||
*/
|
||||
private String fileName;
|
||||
|
||||
/**
|
||||
* filePath
|
||||
*/
|
||||
private String filePath;
|
||||
|
||||
/**
|
||||
* debugType
|
||||
*/
|
||||
private String debugType;
|
||||
|
||||
/**
|
||||
* fileLength
|
||||
*/
|
||||
private Integer fileLength;
|
||||
|
||||
/**
|
||||
* lastRecoTime
|
||||
*/
|
||||
private String lastRecoTime;
|
||||
|
||||
/**
|
||||
* recoPlate
|
||||
*/
|
||||
private String recoPlate;
|
||||
|
||||
/**
|
||||
* plateColor
|
||||
*/
|
||||
private String plateColor;
|
||||
|
||||
/**
|
||||
* sort
|
||||
*/
|
||||
private Integer sort;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
@ -0,0 +1,93 @@
|
||||
package com.yuxue.entity;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import com.yuxue.exception.ErrorEnum;
|
||||
|
||||
|
||||
/**
|
||||
* 返回值封装模型类
|
||||
* @author yuxue
|
||||
* @date 2018-09-07
|
||||
*/
|
||||
public class Result extends HashMap<String, Object> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private static final Integer SUCCESS_CODE = 200;
|
||||
private static final String SUCCESS_INFO = "Success!";
|
||||
|
||||
public Result() {
|
||||
put("code", SUCCESS_CODE);
|
||||
put("msg", SUCCESS_INFO);
|
||||
put("success", true);
|
||||
}
|
||||
|
||||
public Result(Object obj) {
|
||||
put("code", SUCCESS_CODE);
|
||||
put("msg", SUCCESS_INFO);
|
||||
put("obj", obj);
|
||||
put("success", true);
|
||||
}
|
||||
|
||||
public static Result ok() {
|
||||
return new Result();
|
||||
}
|
||||
|
||||
public static Result ok(Object obj) {
|
||||
return new Result(obj);
|
||||
}
|
||||
|
||||
/**
|
||||
* 待办任务切面需要返回的数据
|
||||
* 与前端业务逻辑无关
|
||||
*
|
||||
* @param todo
|
||||
* @return
|
||||
*/
|
||||
public static Result ok(Object obj, Object todo) {
|
||||
Result result = new Result(obj);
|
||||
result.put("todo", todo);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static Result error() {
|
||||
return error(ErrorEnum.COMMON_ERROR);
|
||||
}
|
||||
|
||||
public static Result error(String msg) {
|
||||
Result result = error(ErrorEnum.COMMON_ERROR);
|
||||
result.put("msg", msg);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static Result error(String msg, int code) {
|
||||
Result result = error(ErrorEnum.COMMON_ERROR);
|
||||
result.put("msg", msg);
|
||||
result.put("code", code);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static Result error(ErrorEnum fwWebError) {
|
||||
Result result = new Result();
|
||||
result.put("code", fwWebError.code);
|
||||
result.put("msg", fwWebError.msg);
|
||||
result.put("success", false);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static Result error(int code, String msg) {
|
||||
Result result = new Result();
|
||||
result.put("code", code);
|
||||
result.put("msg", msg);
|
||||
result.put("success", false);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Result put(String key, Object value) {
|
||||
super.put(key, value);
|
||||
return this;
|
||||
}
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
package com.yuxue.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* t_system_menu
|
||||
* @author
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class SystemMenuEntity implements Serializable {
|
||||
private Integer id;
|
||||
|
||||
private String menuName;
|
||||
|
||||
private String menuUrl;
|
||||
|
||||
private Integer parentId;
|
||||
|
||||
private Integer sort;
|
||||
|
||||
private Integer menuLevel;
|
||||
|
||||
private String menuIcon;
|
||||
|
||||
private Integer showFlag;
|
||||
|
||||
private Integer platform;
|
||||
|
||||
private Integer menuType;
|
||||
|
||||
private String permission;
|
||||
|
||||
private Date updateTime;
|
||||
|
||||
private Integer editorId;
|
||||
|
||||
private String createTime;
|
||||
|
||||
private Integer creatorId;
|
||||
|
||||
private Integer version;
|
||||
|
||||
private Integer delFlag;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
package com.yuxue.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* temp_plate_file
|
||||
* @author yuxue
|
||||
* 2020-04-30 09:39:59.928
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class TempPlateFileEntity implements Serializable {
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* fileName
|
||||
*/
|
||||
private String fileName;
|
||||
|
||||
/**
|
||||
* filePath
|
||||
*/
|
||||
private String filePath;
|
||||
|
||||
/**
|
||||
* fileType
|
||||
*/
|
||||
private String fileType;
|
||||
|
||||
/**
|
||||
* fileLength
|
||||
*/
|
||||
private Long fileLength;
|
||||
|
||||
/**
|
||||
* parentId
|
||||
*/
|
||||
private Integer parentId;
|
||||
|
||||
/**
|
||||
* level
|
||||
*/
|
||||
private Integer level;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
package com.yuxue.enumtype;
|
||||
|
||||
public enum Direction {
|
||||
|
||||
VERTICAL("VERTICAL","垂直"),
|
||||
HORIZONTAL("HORIZONTAL","水平"),
|
||||
UNKNOWN("UNKNOWN","未知");
|
||||
|
||||
public final String code;
|
||||
public final String desc;
|
||||
|
||||
Direction(String code, String desc) {
|
||||
this.code = code;
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
public static String getDesc(String code) {
|
||||
Direction[] enums = values();
|
||||
for (Direction type : enums) {
|
||||
if (type.code().equals(code)) {
|
||||
return type.desc();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String getCode(String desc) {
|
||||
Direction[] enums = values();
|
||||
for (Direction type : enums) {
|
||||
if (type.desc().equals(desc)) {
|
||||
return type.code();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public String code() {
|
||||
return this.code;
|
||||
}
|
||||
|
||||
public String desc() {
|
||||
return this.desc;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
package com.yuxue.exception;
|
||||
|
||||
|
||||
/**
|
||||
* 自定义runtime异常
|
||||
* @author yuxue
|
||||
* @date 2018-09-07
|
||||
*/
|
||||
public class ResultReturnException extends RuntimeException {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String msg = ErrorEnum.COMMON_ERROR.msg;
|
||||
private int code = ErrorEnum.COMMON_ERROR.code;
|
||||
|
||||
public ResultReturnException(ErrorEnum error) {
|
||||
super(error.msg);
|
||||
this.msg = error.msg;
|
||||
this.code = error.code;
|
||||
}
|
||||
|
||||
public ResultReturnException(String msg) {
|
||||
super(msg);
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public ResultReturnException(String msg, Throwable e) {
|
||||
super(msg, e);
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public ResultReturnException(String msg, int code) {
|
||||
super(msg);
|
||||
this.msg = msg;
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public ResultReturnException(String msg, int code, Throwable e) {
|
||||
super(msg, e);
|
||||
this.msg = msg;
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,84 @@
|
||||
package com.yuxue.exception;
|
||||
|
||||
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.converter.HttpMessageNotReadableException;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
import org.springframework.web.multipart.MultipartException;
|
||||
|
||||
import com.yuxue.entity.Result;
|
||||
|
||||
|
||||
/**
|
||||
* 捕获RestController抛出的异常
|
||||
* @author yuxue
|
||||
* @date 2018-09-06
|
||||
*/
|
||||
@RestControllerAdvice
|
||||
public class ResultReturnExceptionHandler {
|
||||
|
||||
protected static Logger log=LoggerFactory.getLogger(ResultReturnExceptionHandler.class);
|
||||
|
||||
/** 捕捉shiro的异常 *//*
|
||||
@ResponseStatus(HttpStatus.UNAUTHORIZED)
|
||||
@ExceptionHandler(ShiroException.class)
|
||||
public Result handle401(ShiroException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Result.error(ErrorEnum.UNAUTHORIZED);
|
||||
}
|
||||
|
||||
*//** 捕捉UnauthorizedException *//*
|
||||
@ResponseStatus(HttpStatus.UNAUTHORIZED)
|
||||
@ExceptionHandler(UnauthorizedException.class)
|
||||
public Result handle401() {
|
||||
return Result.error(ErrorEnum.UNAUTHORIZED);
|
||||
}*/
|
||||
|
||||
/** 文件上传大小异常 */
|
||||
@ExceptionHandler(MultipartException.class)
|
||||
public Result handleMultipart(Throwable t) {
|
||||
log.error(t.getMessage(), t);
|
||||
return Result.error(ErrorEnum.UPLOAD_FILE_SIZE_MAX);
|
||||
}
|
||||
|
||||
/** jackson转换Bean * */
|
||||
@ExceptionHandler(HttpMessageNotReadableException.class)
|
||||
public Result handleJsonConv(Throwable t) {
|
||||
log.error(t.getMessage(), t);
|
||||
return Result.error(ErrorEnum.COMMON_PARAMS_NOT_EXIST);
|
||||
}
|
||||
|
||||
/** 异常参数处理器 */
|
||||
@ExceptionHandler(IllegalArgumentException.class)
|
||||
public Result handleRRException(Throwable e) {
|
||||
//log.error(e.getMessage(), e);
|
||||
return Result.error(ErrorEnum.COMMON_PARAMS_ERR.code, e.getMessage());
|
||||
}
|
||||
|
||||
/** 自定义异常 */
|
||||
@ExceptionHandler(ResultReturnException.class)
|
||||
public Result handleRRException(ResultReturnException e) {
|
||||
log.error(exTraceBack(e), e);
|
||||
return Result.error(e.getCode(), e.getMsg());
|
||||
}
|
||||
|
||||
@ExceptionHandler(Exception.class)
|
||||
public Result handleException(Exception e) {
|
||||
log.error(exTraceBack(e), e);
|
||||
return Result.error("系统发生错误,请联系管理员");
|
||||
}
|
||||
|
||||
public static String exTraceBack(Exception e) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
StackTraceElement[] stackTrace = e.getStackTrace();
|
||||
for (int i = 0; i < stackTrace.length; i++) {
|
||||
sb.append("<---");
|
||||
sb.append(String.format("[%s * %s] ", stackTrace[i].getClassName(), stackTrace[i].getMethodName()));
|
||||
}
|
||||
sb.append(e.getMessage());
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package com.yuxue.mapper;
|
||||
|
||||
import com.yuxue.entity.PlateFileEntity;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface PlateFileMapper {
|
||||
int deleteByPrimaryKey(Integer id);
|
||||
|
||||
int insert(PlateFileEntity record);
|
||||
|
||||
int insertSelective(PlateFileEntity record);
|
||||
|
||||
PlateFileEntity selectByPrimaryKey(Integer id);
|
||||
|
||||
List<PlateFileEntity> selectByCondition(Map map);
|
||||
|
||||
int updateByPrimaryKeySelective(PlateFileEntity record);
|
||||
|
||||
int updateByPrimaryKey(PlateFileEntity record);
|
||||
|
||||
List<PlateFileEntity> getUnRecogniseList();
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package com.yuxue.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import com.yuxue.entity.PlateRecoDebugEntity;
|
||||
|
||||
@Mapper
|
||||
public interface PlateRecoDebugMapper {
|
||||
int deleteByPrimaryKey(Integer id);
|
||||
|
||||
int insert(PlateRecoDebugEntity record);
|
||||
|
||||
int insertSelective(PlateRecoDebugEntity record);
|
||||
|
||||
PlateRecoDebugEntity selectByPrimaryKey(Integer id);
|
||||
|
||||
List<PlateRecoDebugEntity> selectByCondition(Map map);
|
||||
|
||||
int updateByPrimaryKeySelective(PlateRecoDebugEntity record);
|
||||
|
||||
int updateByPrimaryKey(PlateRecoDebugEntity record);
|
||||
|
||||
int deleteByParentId(@Param("parentId")Integer parentId);
|
||||
|
||||
int batchInsert(@Param("list")List<PlateRecoDebugEntity> list);
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package com.yuxue.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import com.yuxue.entity.SystemMenuEntity;
|
||||
|
||||
@Mapper
|
||||
public interface SystemMenuMapper {
|
||||
int deleteByPrimaryKey(Integer id);
|
||||
|
||||
int insert(SystemMenuEntity record);
|
||||
|
||||
int insertSelective(SystemMenuEntity record);
|
||||
|
||||
SystemMenuEntity selectByPrimaryKey(Integer id);
|
||||
|
||||
List<SystemMenuEntity> selectByCondition(Map map);
|
||||
|
||||
int updateByPrimaryKeySelective(SystemMenuEntity record);
|
||||
|
||||
int updateByPrimaryKey(SystemMenuEntity record);
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package com.yuxue.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import com.yuxue.entity.TempPlateFileEntity;
|
||||
|
||||
@Mapper
|
||||
public interface TempPlateFileMapper {
|
||||
int deleteByPrimaryKey(Integer id);
|
||||
|
||||
int insert(TempPlateFileEntity record);
|
||||
|
||||
int insertSelective(TempPlateFileEntity record);
|
||||
|
||||
TempPlateFileEntity selectByPrimaryKey(Integer id);
|
||||
|
||||
List<TempPlateFileEntity> selectByCondition(Map map);
|
||||
|
||||
int updateByPrimaryKeySelective(TempPlateFileEntity record);
|
||||
|
||||
int updateByPrimaryKey(TempPlateFileEntity record);
|
||||
|
||||
int turncateTable();
|
||||
|
||||
int batchInsert(@Param("list")List<TempPlateFileEntity> list);
|
||||
|
||||
int updateFileInfo();
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package com.yuxue.service;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
|
||||
public interface FileService {
|
||||
|
||||
List<JSONObject> getFileTreeByDir(String dir, String typeFilter);
|
||||
|
||||
File readFile(String filePath);
|
||||
|
||||
|
||||
}
|