master
commit
07759933e0
@ -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) {
|
||||
|
||||
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);
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package com.yuxue.service;
|
||||
|
||||
|
||||
public interface PlateService {
|
||||
|
||||
public Object getProcessStep();
|
||||
|
||||
Object recognise(String filePath, boolean reRecognise);
|
||||
|
||||
Object refreshFileInfo();
|
||||
|
||||
Object recogniseAll();
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package com.yuxue.service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.yuxue.entity.SystemMenuEntity;
|
||||
|
||||
|
||||
/**
|
||||
* 服务实现层接口
|
||||
* @author yuxue
|
||||
* @date 2019-06-20 16:15:23
|
||||
*/
|
||||
public interface SystemMenuService {
|
||||
|
||||
public SystemMenuEntity getByPrimaryKey(Integer id);
|
||||
|
||||
public PageInfo<SystemMenuEntity> queryByPage(Integer pageNo, Integer pageSize, Map<String, Object> map);
|
||||
|
||||
public List<SystemMenuEntity> queryByCondition(Map<String, Object> map);
|
||||
|
||||
public Map<String, Object> save(SystemMenuEntity systemMenuEntity);
|
||||
|
||||
public Integer deleteById(Integer id);
|
||||
|
||||
public Integer updateById(SystemMenuEntity systemMenuEntity);
|
||||
|
||||
public Object getUserMenu();
|
||||
}
|
@ -0,0 +1,101 @@
|
||||
package com.yuxue.service.impl;
|
||||
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.yuxue.entity.SystemMenuEntity;
|
||||
import com.yuxue.mapper.SystemMenuMapper;
|
||||
import com.yuxue.service.SystemMenuService;
|
||||
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 服务实现层
|
||||
* @author yuxue
|
||||
* @date 2019-06-20 16:15:23
|
||||
*/
|
||||
@Service
|
||||
public class SystemMenuServiceImpl implements SystemMenuService {
|
||||
|
||||
@Autowired
|
||||
private SystemMenuMapper systemMenuMapper;
|
||||
|
||||
|
||||
@Override
|
||||
public SystemMenuEntity getByPrimaryKey(Integer id) {
|
||||
SystemMenuEntity entity = systemMenuMapper.selectByPrimaryKey(id);
|
||||
return entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageInfo<SystemMenuEntity> queryByPage(Integer pageNo, Integer pageSize, Map<String, Object> map) {
|
||||
PageHelper.startPage(pageNo, pageSize);
|
||||
PageInfo<SystemMenuEntity> page = new PageInfo(systemMenuMapper.selectByCondition(map));
|
||||
return page;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SystemMenuEntity> queryByCondition(Map<String, Object> map) {
|
||||
return systemMenuMapper.selectByCondition(map);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(propagation = Propagation.REQUIRED)
|
||||
public Map<String, Object> save(SystemMenuEntity entity) {
|
||||
entity.setId(0);
|
||||
systemMenuMapper.insertSelective(entity);
|
||||
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
result.put("id" , entity.getId());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(propagation = Propagation.REQUIRED)
|
||||
public Integer deleteById(Integer id){
|
||||
return systemMenuMapper.deleteByPrimaryKey(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(propagation = Propagation.REQUIRED)
|
||||
public Integer updateById(SystemMenuEntity systemMenuEntity) {
|
||||
if(null == systemMenuEntity || systemMenuEntity.getId() <= 0){
|
||||
return 0;
|
||||
}
|
||||
return systemMenuMapper.updateByPrimaryKeySelective(systemMenuEntity);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Object getUserMenu() {
|
||||
Map<String, Object> map = Maps.newHashMap();
|
||||
//根据角色查询菜单--未完成 //根据层级 sort排序
|
||||
map.put("showFlag", 1);
|
||||
List<SystemMenuEntity> menus = systemMenuMapper.selectByCondition(map);
|
||||
|
||||
//按层级封装,最多三级
|
||||
Map<String, Object> result = Maps.newHashMap();
|
||||
|
||||
result.put("first", menus.stream().filter(n -> {
|
||||
return n.getMenuLevel() == 1;
|
||||
}));
|
||||
result.put("second", menus.stream().filter(n -> {
|
||||
return n.getMenuLevel() == 2;
|
||||
}));
|
||||
result.put("third", menus.stream().filter(n -> {
|
||||
return n.getMenuLevel() == 3;
|
||||
}));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,87 @@
|
||||
package com.yuxue.util;
|
||||
|
||||
import org.bytedeco.javacpp.BytePointer;
|
||||
|
||||
/**
|
||||
* There are 3 kinds of convert functions:
|
||||
* 1. [float|double|int|long] to[Float|Double|Int|Long](BytePointer pointer)
|
||||
* 2. byte[] getBytes([float|double|int|long] value)
|
||||
* 3. [float|double|int|long] to[Float|Double|Int|Long](byte[] value)
|
||||
*
|
||||
* @author lin.yao
|
||||
*
|
||||
*/
|
||||
public class Convert {
|
||||
|
||||
public static float toFloat(BytePointer pointer) {
|
||||
byte[] buffer = new byte[4];
|
||||
pointer.get(buffer);
|
||||
return toFloat(buffer);
|
||||
}
|
||||
|
||||
public static double toDouble(BytePointer pointer) {
|
||||
byte[] buffer = new byte[8];
|
||||
pointer.get(buffer);
|
||||
return toDouble(buffer);
|
||||
}
|
||||
|
||||
public static int toInt(BytePointer pointer) {
|
||||
byte[] buffer = new byte[4];
|
||||
pointer.get(buffer);
|
||||
return toInt(buffer);
|
||||
}
|
||||
|
||||
public static long toLong(BytePointer pointer) {
|
||||
byte[] buffer = new byte[8];
|
||||
pointer.get(buffer);
|
||||
return toLong(buffer);
|
||||
}
|
||||
|
||||
public static byte[] getBytes(float value) {
|
||||
return getBytes(Float.floatToIntBits(value));
|
||||
}
|
||||
|
||||
public static byte[] getBytes(double value) {
|
||||
return getBytes(Double.doubleToLongBits(value));
|
||||
}
|
||||
|
||||
public static byte[] getBytes(int value) {
|
||||
final int length = 4;
|
||||
byte[] buffer = new byte[length];
|
||||
for (int i = 0; i < length; ++i)
|
||||
buffer[i] = (byte) ((value >> (i * 8)) & 0xFF);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
public static byte[] getBytes(long value) {
|
||||
final int length = 8;
|
||||
byte[] buffer = new byte[length];
|
||||
for (int i = 0; i < length; ++i)
|
||||
buffer[i] = (byte) ((value >> (i * 8)) & 0xFF);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
public static int toInt(byte[] value) {
|
||||
final int length = 4;
|
||||
int n = 0;
|
||||
for (int i = 0; i < length; ++i)
|
||||
n += (value[i] & 0xFF) << (i * 8);
|
||||
return n;
|
||||
}
|
||||
|
||||
public static long toLong(byte[] value) {
|
||||
final int length = 8;
|
||||
long n = 0;
|
||||
for (int i = 0; i < length; ++i)
|
||||
n += ((long) (value[i] & 0xFF)) << (i * 8);
|
||||
return n;
|
||||
}
|
||||
|
||||
public static double toDouble(byte[] value) {
|
||||
return Double.longBitsToDouble(toLong(value));
|
||||
}
|
||||
|
||||
public static float toFloat(byte[] value) {
|
||||
return Float.intBitsToFloat(toInt(value));
|
||||
}
|
||||
}
|
Loading…
Reference in new issue