lenos增加可配置化定时任务,可实现前端定时增删改查,个性化配置,定时可对数据库进行操作,新增定时表sys_job。

This commit is contained in:
zxm 2018-01-07 17:44:42 +08:00
parent c03d9982a5
commit 6f101b03a8
58 changed files with 2204 additions and 131 deletions

View File

@ -7,6 +7,7 @@
<element id="module-output" name="len-web" /> <element id="module-output" name="len-web" />
</element> </element>
<element id="directory" name="lib"> <element id="directory" name="lib">
<element id="library" level="project" name="Maven: org.mybatis.generator:mybatis-generator-core:1.3.5" />
<element id="library" level="project" name="Maven: org.springframework.boot:spring-boot-starter-web:1.5.9.RELEASE" /> <element id="library" level="project" name="Maven: org.springframework.boot:spring-boot-starter-web:1.5.9.RELEASE" />
<element id="library" level="project" name="Maven: org.springframework.boot:spring-boot-starter:1.5.9.RELEASE" /> <element id="library" level="project" name="Maven: org.springframework.boot:spring-boot-starter:1.5.9.RELEASE" />
<element id="library" level="project" name="Maven: org.springframework.boot:spring-boot:1.5.9.RELEASE" /> <element id="library" level="project" name="Maven: org.springframework.boot:spring-boot:1.5.9.RELEASE" />
@ -34,7 +35,23 @@
<element id="archive" name="len-sys-1.0-SNAPSHOT.jar"> <element id="archive" name="len-sys-1.0-SNAPSHOT.jar">
<element id="module-output" name="len-sys" /> <element id="module-output" name="len-sys" />
</element> </element>
<element id="library" level="project" name="Maven: org.springframework.boot:spring-boot-starter-test:1.5.9.RELEASE" />
<element id="library" level="project" name="Maven: org.springframework.boot:spring-boot-test:1.5.9.RELEASE" />
<element id="library" level="project" name="Maven: org.springframework.boot:spring-boot-test-autoconfigure:1.5.9.RELEASE" />
<element id="library" level="project" name="Maven: com.jayway.jsonpath:json-path:2.2.0" />
<element id="library" level="project" name="Maven: net.minidev:json-smart:2.2.1" />
<element id="library" level="project" name="Maven: net.minidev:accessors-smart:1.1" />
<element id="library" level="project" name="Maven: org.ow2.asm:asm:5.0.3" />
<element id="library" level="project" name="Maven: org.assertj:assertj-core:2.6.0" />
<element id="library" level="project" name="Maven: org.mockito:mockito-core:1.10.19" />
<element id="library" level="project" name="Maven: org.objenesis:objenesis:2.1" />
<element id="library" level="project" name="Maven: org.hamcrest:hamcrest-core:1.3" />
<element id="library" level="project" name="Maven: org.hamcrest:hamcrest-library:1.3" />
<element id="library" level="project" name="Maven: org.skyscreamer:jsonassert:1.4.0" />
<element id="library" level="project" name="Maven: com.vaadin.external.google:android-json:0.0.20131108.vaadin1" />
<element id="library" level="project" name="Maven: org.springframework:spring-core:4.3.13.RELEASE" /> <element id="library" level="project" name="Maven: org.springframework:spring-core:4.3.13.RELEASE" />
<element id="library" level="project" name="Maven: org.springframework:spring-test:4.3.13.RELEASE" />
<element id="library" level="project" name="Maven: junit:junit:4.12" />
<element id="library" level="project" name="Maven: org.mybatis.spring.boot:mybatis-spring-boot-starter:1.3.1" /> <element id="library" level="project" name="Maven: org.mybatis.spring.boot:mybatis-spring-boot-starter:1.3.1" />
<element id="library" level="project" name="Maven: org.mybatis.spring.boot:mybatis-spring-boot-autoconfigure:1.3.1" /> <element id="library" level="project" name="Maven: org.mybatis.spring.boot:mybatis-spring-boot-autoconfigure:1.3.1" />
<element id="library" level="project" name="Maven: org.springframework.boot:spring-boot-starter-cache:1.5.9.RELEASE" /> <element id="library" level="project" name="Maven: org.springframework.boot:spring-boot-starter-cache:1.5.9.RELEASE" />
@ -72,8 +89,6 @@
<element id="library" level="project" name="Maven: log4j:log4j:1.2.17" /> <element id="library" level="project" name="Maven: log4j:log4j:1.2.17" />
<element id="library" level="project" name="Maven: com.google.zxing:javase:3.1.0" /> <element id="library" level="project" name="Maven: com.google.zxing:javase:3.1.0" />
<element id="library" level="project" name="Maven: com.google.zxing:core:3.1.0" /> <element id="library" level="project" name="Maven: com.google.zxing:core:3.1.0" />
<element id="library" level="project" name="Maven: org.quartz-scheduler:quartz:2.2.1" />
<element id="library" level="project" name="Maven: c3p0:c3p0:0.9.1.1" />
<element id="library" level="project" name="Maven: org.springframework.integration:spring-integration-mail:4.3.12.RELEASE" /> <element id="library" level="project" name="Maven: org.springframework.integration:spring-integration-mail:4.3.12.RELEASE" />
<element id="library" level="project" name="Maven: org.springframework.integration:spring-integration-core:4.3.12.RELEASE" /> <element id="library" level="project" name="Maven: org.springframework.integration:spring-integration-core:4.3.12.RELEASE" />
<element id="library" level="project" name="Maven: org.springframework:spring-messaging:4.3.13.RELEASE" /> <element id="library" level="project" name="Maven: org.springframework:spring-messaging:4.3.13.RELEASE" />
@ -120,6 +135,11 @@
<element id="library" level="project" name="Maven: io.springfox:springfox-swagger-ui:2.7.0" /> <element id="library" level="project" name="Maven: io.springfox:springfox-swagger-ui:2.7.0" />
<element id="library" level="project" name="Maven: org.springframework:spring-context-support:4.3.13.RELEASE" /> <element id="library" level="project" name="Maven: org.springframework:spring-context-support:4.3.13.RELEASE" />
<element id="library" level="project" name="Maven: org.springframework:spring-beans:4.3.13.RELEASE" /> <element id="library" level="project" name="Maven: org.springframework:spring-beans:4.3.13.RELEASE" />
<element id="library" level="project" name="Maven: org.quartz-scheduler:quartz:2.3.0" />
<element id="library" level="project" name="Maven: com.mchange:c3p0:0.9.5.2" />
<element id="library" level="project" name="Maven: com.mchange:mchange-commons-java:0.2.11" />
<element id="library" level="project" name="Maven: com.zaxxer:HikariCP-java6:2.3.13" />
<element id="library" level="project" name="Maven: org.apache.shiro:shiro-quartz:1.2.3" />
</element> </element>
</element> </element>
<element id="directory" name="META-INF"> <element id="directory" name="META-INF">

View File

@ -1,13 +0,0 @@
<component name="libraryTable">
<library name="Maven: c3p0:c3p0:0.9.1.1">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/c3p0/c3p0/0.9.1.1/c3p0-0.9.1.1.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/c3p0/c3p0/0.9.1.1/c3p0-0.9.1.1-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/c3p0/c3p0/0.9.1.1/c3p0-0.9.1.1-sources.jar!/" />
</SOURCES>
</library>
</component>

View File

@ -0,0 +1,13 @@
<component name="libraryTable">
<library name="Maven: com.mchange:c3p0:0.9.5.2">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/com/mchange/c3p0/0.9.5.2/c3p0-0.9.5.2.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/com/mchange/c3p0/0.9.5.2/c3p0-0.9.5.2-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/com/mchange/c3p0/0.9.5.2/c3p0-0.9.5.2-sources.jar!/" />
</SOURCES>
</library>
</component>

View File

@ -0,0 +1,13 @@
<component name="libraryTable">
<library name="Maven: com.mchange:mchange-commons-java:0.2.11">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/com/mchange/mchange-commons-java/0.2.11/mchange-commons-java-0.2.11.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/com/mchange/mchange-commons-java/0.2.11/mchange-commons-java-0.2.11-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/com/mchange/mchange-commons-java/0.2.11/mchange-commons-java-0.2.11-sources.jar!/" />
</SOURCES>
</library>
</component>

View File

@ -0,0 +1,13 @@
<component name="libraryTable">
<library name="Maven: com.zaxxer:HikariCP-java6:2.3.13">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/com/zaxxer/HikariCP-java6/2.3.13/HikariCP-java6-2.3.13.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/com/zaxxer/HikariCP-java6/2.3.13/HikariCP-java6-2.3.13-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/com/zaxxer/HikariCP-java6/2.3.13/HikariCP-java6-2.3.13-sources.jar!/" />
</SOURCES>
</library>
</component>

View File

@ -1,13 +0,0 @@
<component name="libraryTable">
<library name="Maven: junit:junit:3.8.1">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/junit/junit/3.8.1/junit-3.8.1.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/junit/junit/3.8.1/junit-3.8.1-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/junit/junit/3.8.1/junit-3.8.1-sources.jar!/" />
</SOURCES>
</library>
</component>

View File

@ -0,0 +1,13 @@
<component name="libraryTable">
<library name="Maven: org.apache.shiro:shiro-quartz:1.2.3">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/apache/shiro/shiro-quartz/1.2.3/shiro-quartz-1.2.3.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/org/apache/shiro/shiro-quartz/1.2.3/shiro-quartz-1.2.3-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/apache/shiro/shiro-quartz/1.2.3/shiro-quartz-1.2.3-sources.jar!/" />
</SOURCES>
</library>
</component>

View File

@ -0,0 +1,13 @@
<component name="libraryTable">
<library name="Maven: org.mybatis.generator:mybatis-generator-core:1.3.5">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/mybatis/generator/mybatis-generator-core/1.3.5/mybatis-generator-core-1.3.5.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/org/mybatis/generator/mybatis-generator-core/1.3.5/mybatis-generator-core-1.3.5-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/mybatis/generator/mybatis-generator-core/1.3.5/mybatis-generator-core-1.3.5-sources.jar!/" />
</SOURCES>
</library>
</component>

View File

@ -1,13 +1,13 @@
<component name="libraryTable"> <component name="libraryTable">
<library name="Maven: org.quartz-scheduler:quartz:2.2.1"> <library name="Maven: org.quartz-scheduler:quartz:2.3.0">
<CLASSES> <CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/quartz-scheduler/quartz/2.2.1/quartz-2.2.1.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/org/quartz-scheduler/quartz/2.3.0/quartz-2.3.0.jar!/" />
</CLASSES> </CLASSES>
<JAVADOC> <JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/org/quartz-scheduler/quartz/2.2.1/quartz-2.2.1-javadoc.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/org/quartz-scheduler/quartz/2.3.0/quartz-2.3.0-javadoc.jar!/" />
</JAVADOC> </JAVADOC>
<SOURCES> <SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/quartz-scheduler/quartz/2.2.1/quartz-2.2.1-sources.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/org/quartz-scheduler/quartz/2.3.0/quartz-2.3.0-sources.jar!/" />
</SOURCES> </SOURCES>
</library> </library>
</component> </component>

File diff suppressed because one or more lines are too long

View File

@ -23,24 +23,24 @@
</content> </content>
<orderEntry type="inheritedJdk" /> <orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:3.8.1" level="project" /> <orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.12" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-starter-test:1.5.9.RELEASE" level="project" /> <orderEntry type="library" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-test:1.5.9.RELEASE" level="project" /> <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-test:1.5.9.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-test:1.5.9.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot:1.5.9.RELEASE" level="project" /> <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot:1.5.9.RELEASE" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-test-autoconfigure:1.5.9.RELEASE" level="project" /> <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-test-autoconfigure:1.5.9.RELEASE" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: com.jayway.jsonpath:json-path:2.2.0" level="project" /> <orderEntry type="library" name="Maven: com.jayway.jsonpath:json-path:2.2.0" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: net.minidev:json-smart:2.2.1" level="project" /> <orderEntry type="library" name="Maven: net.minidev:json-smart:2.2.1" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: net.minidev:accessors-smart:1.1" level="project" /> <orderEntry type="library" name="Maven: net.minidev:accessors-smart:1.1" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.ow2.asm:asm:5.0.3" level="project" /> <orderEntry type="library" name="Maven: org.ow2.asm:asm:5.0.3" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.assertj:assertj-core:2.6.0" level="project" /> <orderEntry type="library" name="Maven: org.assertj:assertj-core:2.6.0" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.mockito:mockito-core:1.10.19" level="project" /> <orderEntry type="library" name="Maven: org.mockito:mockito-core:1.10.19" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.objenesis:objenesis:2.1" level="project" /> <orderEntry type="library" scope="RUNTIME" name="Maven: org.objenesis:objenesis:2.1" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" /> <orderEntry type="library" name="Maven: org.hamcrest:hamcrest-library:1.3" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-library:1.3" level="project" /> <orderEntry type="library" name="Maven: org.skyscreamer:jsonassert:1.4.0" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.skyscreamer:jsonassert:1.4.0" level="project" /> <orderEntry type="library" name="Maven: com.vaadin.external.google:android-json:0.0.20131108.vaadin1" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: com.vaadin.external.google:android-json:0.0.20131108.vaadin1" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-core:4.3.13.RELEASE" level="project" /> <orderEntry type="library" name="Maven: org.springframework:spring-core:4.3.13.RELEASE" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.springframework:spring-test:4.3.13.RELEASE" level="project" /> <orderEntry type="library" name="Maven: org.springframework:spring-test:4.3.13.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.mybatis.spring.boot:mybatis-spring-boot-starter:1.3.1" level="project" /> <orderEntry type="library" name="Maven: org.mybatis.spring.boot:mybatis-spring-boot-starter:1.3.1" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter:1.5.9.RELEASE" level="project" /> <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter:1.5.9.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-logging:1.5.9.RELEASE" level="project" /> <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-logging:1.5.9.RELEASE" level="project" />
@ -108,8 +108,6 @@
<orderEntry type="library" name="Maven: log4j:log4j:1.2.17" level="project" /> <orderEntry type="library" name="Maven: log4j:log4j:1.2.17" level="project" />
<orderEntry type="library" name="Maven: com.google.zxing:javase:3.1.0" level="project" /> <orderEntry type="library" name="Maven: com.google.zxing:javase:3.1.0" level="project" />
<orderEntry type="library" name="Maven: com.google.zxing:core:3.1.0" level="project" /> <orderEntry type="library" name="Maven: com.google.zxing:core:3.1.0" level="project" />
<orderEntry type="library" name="Maven: org.quartz-scheduler:quartz:2.2.1" level="project" />
<orderEntry type="library" name="Maven: c3p0:c3p0:0.9.1.1" level="project" />
<orderEntry type="library" name="Maven: org.springframework.integration:spring-integration-mail:4.3.12.RELEASE" level="project" /> <orderEntry type="library" name="Maven: org.springframework.integration:spring-integration-mail:4.3.12.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.integration:spring-integration-core:4.3.12.RELEASE" level="project" /> <orderEntry type="library" name="Maven: org.springframework.integration:spring-integration-core:4.3.12.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-messaging:4.3.13.RELEASE" level="project" /> <orderEntry type="library" name="Maven: org.springframework:spring-messaging:4.3.13.RELEASE" level="project" />
@ -156,5 +154,10 @@
<orderEntry type="library" name="Maven: io.springfox:springfox-swagger-ui:2.7.0" level="project" /> <orderEntry type="library" name="Maven: io.springfox:springfox-swagger-ui:2.7.0" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-context-support:4.3.13.RELEASE" level="project" /> <orderEntry type="library" name="Maven: org.springframework:spring-context-support:4.3.13.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-beans:4.3.13.RELEASE" level="project" /> <orderEntry type="library" name="Maven: org.springframework:spring-beans:4.3.13.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.quartz-scheduler:quartz:2.3.0" level="project" />
<orderEntry type="library" name="Maven: com.mchange:c3p0:0.9.5.2" level="project" />
<orderEntry type="library" name="Maven: com.mchange:mchange-commons-java:0.2.11" level="project" />
<orderEntry type="library" name="Maven: com.zaxxer:HikariCP-java6:2.3.13" level="project" />
<orderEntry type="library" name="Maven: org.apache.shiro:shiro-quartz:1.2.3" level="project" />
</component> </component>
</module> </module>

View File

@ -25,5 +25,10 @@
<version>3.8.1</version> <version>3.8.1</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies> </dependencies>
</project> </project>

View File

@ -0,0 +1,27 @@
package com.len.util;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
/**
* @author zhuxiaomeng
* @date 2018/1/5.
* @email 154040976@qq.com
*/
public class ApplicationContextUtil implements ApplicationContextAware {
private static ApplicationContext applicationContext;
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
ApplicationContextUtil.applicationContext=applicationContext;
}
public static ApplicationContext getContext(){
return applicationContext;
}
public static Object getBean(String arg){
return applicationContext.getBean(arg);
}
}

View File

@ -0,0 +1,52 @@
package com.len.util;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;
/**
* @author zhuxiaomeng
* @date 2018/1/5.
* @email 154040976@qq.com
* 参照一些案例在此对 在此对网上分享者说声感谢 byzxm
* 通过封装applicationContext上线文
* 获取 spring bean对象 bean启动时候 已经被打印出可直接根据nameclassname class获取
*
* 很多地方能用得到
*/
@Component
public class SpringUtil implements ApplicationContextAware {
private static ApplicationContext applicationContext;
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
if (SpringUtil.applicationContext == null) {
SpringUtil.applicationContext = applicationContext;
}
}
public static ApplicationContext getApplicationContext() {
return applicationContext;
}
/***
* 根据name获取bean
* @param name
* @param <T>
* @return
*/
@SuppressWarnings("unchecked")
public static <T> T getBean(String name) {
return (T) getApplicationContext().getBean(name);
}
public static <T> T getBean(Class<T> clazz) {
return getApplicationContext().getBean(clazz);
}
public static <T> T getBean(String name, Class<T> clazz) {
return getApplicationContext().getBean(name, clazz);
}
}

View File

@ -26,24 +26,24 @@
<orderEntry type="inheritedJdk" /> <orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module" module-name="len-core" /> <orderEntry type="module" module-name="len-core" />
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:3.8.1" level="project" /> <orderEntry type="library" name="Maven: junit:junit:4.12" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-starter-test:1.5.9.RELEASE" level="project" /> <orderEntry type="library" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-test:1.5.9.RELEASE" level="project" /> <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-test:1.5.9.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-test:1.5.9.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot:1.5.9.RELEASE" level="project" /> <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot:1.5.9.RELEASE" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-test-autoconfigure:1.5.9.RELEASE" level="project" /> <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-test-autoconfigure:1.5.9.RELEASE" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: com.jayway.jsonpath:json-path:2.2.0" level="project" /> <orderEntry type="library" name="Maven: com.jayway.jsonpath:json-path:2.2.0" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: net.minidev:json-smart:2.2.1" level="project" /> <orderEntry type="library" name="Maven: net.minidev:json-smart:2.2.1" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: net.minidev:accessors-smart:1.1" level="project" /> <orderEntry type="library" name="Maven: net.minidev:accessors-smart:1.1" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.ow2.asm:asm:5.0.3" level="project" /> <orderEntry type="library" name="Maven: org.ow2.asm:asm:5.0.3" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.assertj:assertj-core:2.6.0" level="project" /> <orderEntry type="library" name="Maven: org.assertj:assertj-core:2.6.0" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.mockito:mockito-core:1.10.19" level="project" /> <orderEntry type="library" name="Maven: org.mockito:mockito-core:1.10.19" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.objenesis:objenesis:2.1" level="project" /> <orderEntry type="library" scope="RUNTIME" name="Maven: org.objenesis:objenesis:2.1" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" /> <orderEntry type="library" name="Maven: org.hamcrest:hamcrest-library:1.3" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-library:1.3" level="project" /> <orderEntry type="library" name="Maven: org.skyscreamer:jsonassert:1.4.0" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.skyscreamer:jsonassert:1.4.0" level="project" /> <orderEntry type="library" name="Maven: com.vaadin.external.google:android-json:0.0.20131108.vaadin1" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: com.vaadin.external.google:android-json:0.0.20131108.vaadin1" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-core:4.3.13.RELEASE" level="project" /> <orderEntry type="library" name="Maven: org.springframework:spring-core:4.3.13.RELEASE" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.springframework:spring-test:4.3.13.RELEASE" level="project" /> <orderEntry type="library" name="Maven: org.springframework:spring-test:4.3.13.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.mybatis.spring.boot:mybatis-spring-boot-starter:1.3.1" level="project" /> <orderEntry type="library" name="Maven: org.mybatis.spring.boot:mybatis-spring-boot-starter:1.3.1" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter:1.5.9.RELEASE" level="project" /> <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter:1.5.9.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-logging:1.5.9.RELEASE" level="project" /> <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-logging:1.5.9.RELEASE" level="project" />
@ -111,8 +111,6 @@
<orderEntry type="library" name="Maven: log4j:log4j:1.2.17" level="project" /> <orderEntry type="library" name="Maven: log4j:log4j:1.2.17" level="project" />
<orderEntry type="library" name="Maven: com.google.zxing:javase:3.1.0" level="project" /> <orderEntry type="library" name="Maven: com.google.zxing:javase:3.1.0" level="project" />
<orderEntry type="library" name="Maven: com.google.zxing:core:3.1.0" level="project" /> <orderEntry type="library" name="Maven: com.google.zxing:core:3.1.0" level="project" />
<orderEntry type="library" name="Maven: org.quartz-scheduler:quartz:2.2.1" level="project" />
<orderEntry type="library" name="Maven: c3p0:c3p0:0.9.1.1" level="project" />
<orderEntry type="library" name="Maven: org.springframework.integration:spring-integration-mail:4.3.12.RELEASE" level="project" /> <orderEntry type="library" name="Maven: org.springframework.integration:spring-integration-mail:4.3.12.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.integration:spring-integration-core:4.3.12.RELEASE" level="project" /> <orderEntry type="library" name="Maven: org.springframework.integration:spring-integration-core:4.3.12.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-messaging:4.3.13.RELEASE" level="project" /> <orderEntry type="library" name="Maven: org.springframework:spring-messaging:4.3.13.RELEASE" level="project" />
@ -159,5 +157,10 @@
<orderEntry type="library" name="Maven: io.springfox:springfox-swagger-ui:2.7.0" level="project" /> <orderEntry type="library" name="Maven: io.springfox:springfox-swagger-ui:2.7.0" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-context-support:4.3.13.RELEASE" level="project" /> <orderEntry type="library" name="Maven: org.springframework:spring-context-support:4.3.13.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-beans:4.3.13.RELEASE" level="project" /> <orderEntry type="library" name="Maven: org.springframework:spring-beans:4.3.13.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.quartz-scheduler:quartz:2.3.0" level="project" />
<orderEntry type="library" name="Maven: com.mchange:c3p0:0.9.5.2" level="project" />
<orderEntry type="library" name="Maven: com.mchange:mchange-commons-java:0.2.11" level="project" />
<orderEntry type="library" name="Maven: com.zaxxer:HikariCP-java6:2.3.13" level="project" />
<orderEntry type="library" name="Maven: org.apache.shiro:shiro-quartz:1.2.3" level="project" />
</component> </component>
</module> </module>

View File

@ -27,8 +27,7 @@
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
<artifactId>junit</artifactId> <artifactId>junit</artifactId>
<version>3.8.1</version> <version>4.12</version>
<scope>test</scope>
</dependency> </dependency>
</dependencies> </dependencies>
</project> </project>

View File

@ -0,0 +1,197 @@
package com.len.controller;
import com.len.base.BaseController;
import com.len.core.annotation.Log;
import com.len.core.annotation.Log.LOG_TYPE;
import com.len.core.quartz.JobTask;
import com.len.entity.SysJob;
import com.len.entity.SysUser;
import com.len.exception.MyException;
import com.len.service.JobService;
import com.len.util.BeanUtil;
import com.len.util.Checkbox;
import com.len.util.JsonUtil;
import io.swagger.annotations.ApiOperation;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
/**
* @author zhuxiaomeng
* @date 2018/1/6.
* @email 154040976@qq.com
*
* 定时任务 controller
*/
@Controller
@RequestMapping("/job")
public class JobController extends BaseController<SysJob> {
@Autowired
JobService jobService;
@Autowired
JobTask jobTask;
@GetMapping(value = "showJob")
public String showUser(Model model) {
return "/system/job/jobList";
}
@GetMapping(value = "showJobList")
@ResponseBody
public String showUser(Model model, SysJob job, String page, String limit) {
return jobService.show(job,Integer.valueOf(page),Integer.valueOf(limit));
}
@GetMapping(value = "showAddJob")
public String addJob(Model model) {
return "/system/job/add-job";
}
@ApiOperation(value = "/addJob", httpMethod = "POST", notes = "添加任务类")
@Log(desc = "添加任务")
@PostMapping(value = "addJob")
@ResponseBody
public JsonUtil addJob(SysJob job) {
JsonUtil j=new JsonUtil();
String msg="保存成功";
job.setStatus(false);
try {
jobService.insertSelective(job);
}catch (MyException e){
msg="保存失败";
j.setFlag(false);
e.printStackTrace();
}
j.setMsg(msg);
return j;
}
@GetMapping(value = "updateJob")
public String updateJob(String id, Model model, boolean detail) {
if (StringUtils.isNotEmpty(id)) {
SysJob job = jobService.selectByPrimaryKey(id);
model.addAttribute("job", job);
}
model.addAttribute("detail", detail);
return "system/job/update-job";
}
@ApiOperation(value = "/updateJob", httpMethod = "POST", notes = "更新任务")
@Log(desc = "更新任务",type = LOG_TYPE.UPDATE)
@PostMapping(value = "updateJob")
@ResponseBody
public JsonUtil updateJob(SysJob job){
JsonUtil j=new JsonUtil();
j.setFlag(false);
if (job == null) {
j.setMsg("获取数据失败");
return j;
}
if(jobTask.checkJob(job)){
j.setMsg("已经启动任务无法更新,请停止后更新");
return j;
}
try{
SysJob oldJob=jobService.selectByPrimaryKey(job.getId());
BeanUtil.copyNotNullBean(job, oldJob);
jobService.updateByPrimaryKey(oldJob);
j.setFlag(true);
j.setMsg("修改成功");
}catch (MyException e){
j.setMsg("更新失败");
e.printStackTrace();
}
return j;
}
@Log(desc = "删除任务",type = LOG_TYPE.DEL)
@ApiOperation(value = "/del", httpMethod = "POST", notes = "删除任务")
@PostMapping(value = "del")
@ResponseBody
public JsonUtil del(String id){
JsonUtil j=new JsonUtil();
j.setFlag(false);
if (StringUtils.isEmpty(id)) {
j.setMsg("获取数据失败");
return j;
}
try{
SysJob job=jobService.selectByPrimaryKey(id);
boolean flag=jobTask.checkJob(job);
if((flag&&!job.getStatus())||!flag&&job.getStatus()){
j.setMsg("您任务表状态和web任务状态不一致,无法删除");
return j;
}
if(flag){
j.setMsg("该任务处于启动中,无法删除");
return j;
}
jobService.deleteByPrimaryKey(id);
j.setFlag(true);
j.setMsg("任务删除成功");
}catch (MyException e){
j.setMsg("任务删除异常");
e.printStackTrace();
}
return j;
}
@Log(desc = "启动任务")
@PostMapping(value = "startJob")
@ResponseBody
public JsonUtil startJob(String id){
JsonUtil j=new JsonUtil();
String msg=null;
if(StringUtils.isEmpty(id)){
j.setMsg("获取数据失败");
j.setFlag(false);
return j;
}
try {
SysJob job = jobService.selectByPrimaryKey(id);
jobTask.startJob(job);
job.setStatus(true);
jobService.updateByPrimaryKey(job);
msg="启动成功";
}catch (MyException e){
e.printStackTrace();
}
j.setMsg(msg);
return j;
}
@Log(desc = "停止任务")
@PostMapping(value = "endJob")
@ResponseBody
public JsonUtil endJob(String id){
JsonUtil j=new JsonUtil();
String msg=null;
if(StringUtils.isEmpty(id)){
j.setMsg("获取数据失败");
j.setFlag(false);
return j;
}
try {
SysJob job = jobService.selectByPrimaryKey(id);
jobTask.remove(job);
job.setStatus(false);
jobService.updateByPrimaryKey(job);
msg="停止成功";
}catch (MyException e){
e.printStackTrace();
}
j.setMsg(msg);
return j;
}
}

View File

@ -3,6 +3,7 @@ package com.len.controller;
import com.len.base.BaseController; import com.len.base.BaseController;
import com.len.core.annotation.Log; import com.len.core.annotation.Log;
import com.len.core.annotation.Log.LOG_TYPE; import com.len.core.annotation.Log.LOG_TYPE;
import com.len.core.quartz.JobTask;
import com.len.entity.SysRoleUser; import com.len.entity.SysRoleUser;
import com.len.entity.SysUser; import com.len.entity.SysUser;
import com.len.exception.MyException; import com.len.exception.MyException;
@ -19,8 +20,6 @@ import java.util.Date;
import java.util.List; import java.util.List;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.ui.Model; import org.springframework.ui.Model;
@ -50,6 +49,10 @@ public class UserController extends BaseController{
@Autowired @Autowired
RoleUserService roleUserService; RoleUserService roleUserService;
@Autowired
JobTask task;
@GetMapping(value = "mainTest") @GetMapping(value = "mainTest")
public String showTest() { public String showTest() {
return "system/user/mainTest"; return "system/user/mainTest";
@ -63,7 +66,6 @@ public class UserController extends BaseController{
@GetMapping(value = "showUserList") @GetMapping(value = "showUserList")
@ResponseBody @ResponseBody
public String showUser(Model model, SysUser user, String page, String limit) { public String showUser(Model model, SysUser user, String page, String limit) {
// logger.error("show userList");
return userService.show(user,Integer.valueOf(page),Integer.valueOf(limit)); return userService.show(user,Integer.valueOf(page),Integer.valueOf(limit));
} }
@ -165,7 +167,6 @@ public class UserController extends BaseController{
@ResponseBody @ResponseBody
public String del(String id, boolean flag) { public String del(String id, boolean flag) {
if (StringUtils.isEmpty(id)) { if (StringUtils.isEmpty(id)) {
return "获取数据失败"; return "获取数据失败";
} }
@ -174,6 +175,12 @@ public class UserController extends BaseController{
if("admin".equals(sysUser.getUsername())){ if("admin".equals(sysUser.getUsername())){
return "超管无法删除"; return "超管无法删除";
} }
SysRoleUser roleUser=new SysRoleUser();
roleUser.setUserId(id);
int count=roleUserService.selectCountByCondition(roleUser);
if(count>0){
return "账户已经绑定角色,无法删除";
}
if (flag) { if (flag) {
//逻辑 //逻辑
sysUser.setDelFlag(Byte.parseByte("1")); sysUser.setDelFlag(Byte.parseByte("1"));

View File

@ -0,0 +1,54 @@
package com.len.core.BootListener;
import com.len.core.quartz.JobTask;
import com.len.entity.SysJob;
import com.len.service.JobService;
import com.len.util.SpringUtil;
import com.len.service.RoleService;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
/**
* @author zhuxiaomeng
* @date 2018/1/6.
* @email 154040976@qq.com
*
* 启动数据库中已经设定为 启动状态(status:1)的任务 项目启动时init
*/
@Configuration
public class DataSourceJobThread extends Thread {
private static final Logger log = LoggerFactory.getLogger(DataSourceJobThread.class);
@Autowired
RoleService roleService;
@Autowired
JobService jobService;
@Override
public void run() {
try {
Thread.sleep(1000);
log.info("---------线程启动---------");
JobTask jobTask = SpringUtil.getBean("jobTask");
SysJob job = new SysJob();
job.setStatus(true);
List<SysJob> jobList = jobService.selectListByPage(job);
//开启任务
jobList.forEach(jobs -> {
log.info("---任务["+jobs.getId()+"]系统 init--开始启动---------");
jobTask.startJob(jobs);
}
);
if(jobList.size()==0){
log.info("---数据库暂无启动的任务---------");
}else
System.out.println("---任务启动完毕---------");
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}

View File

@ -0,0 +1,35 @@
package com.len.core.BootListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.stereotype.Component;
/**
* @author zhuxiaomeng
* @date 2018/1/6.
* @email 154040976@qq.com
*
* 通过监听开辟线程执行定时任务 当然 也可以执行其他
*/
@Component
public class MyApplicationListener implements ApplicationListener<ContextRefreshedEvent> {
Logger logger= LoggerFactory.getLogger(MyApplicationListener.class);
@Override
public void onApplicationEvent(ContextRefreshedEvent event) {
logger.info("-------------bean初始化完毕-------------");
/**
* 通过线程开启数据库中已经开启的定时任务 灵感来自spring
* spring boot继续执行 mythread开辟线程延迟后执行
*/
DataSourceJobThread myThread= (DataSourceJobThread) event.getApplicationContext().getBean(
"dataSourceJobThread");
myThread.start();
}
}

View File

@ -0,0 +1,24 @@
package com.len.core.BootListener;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import org.springframework.stereotype.Component;
/**
* @author zhuxiaomeng
* @date 2018/1/6.
* @email 154040976@qq.com
*/
@Component
public class MyServletContextListener implements ServletContextListener {
@Override
public void contextInitialized(ServletContextEvent sce) {
System.out.println("-------contextInitialized-----------");
}
@Override
public void contextDestroyed(ServletContextEvent sce) {
System.out.println("------------contextDestroyed-------------");
}
}

View File

@ -78,8 +78,8 @@ public class LogAspect {
*/ */
@AfterThrowing(value="pointcut()",throwing="e") @AfterThrowing(value="pointcut()",throwing="e")
public void afterException(JoinPoint joinPoint,Exception e){ public void afterException(JoinPoint joinPoint,Exception e){
System.out.print(e.getMessage()); System.out.print("-----------afterException:"+e.getMessage());
addLog(joinPoint,getDesc(joinPoint)+e.getMessage()); // addLog(joinPoint,getDesc(joinPoint)+e.getMessage());
} }

View File

@ -0,0 +1,41 @@
package com.len.core.quartz.CustomQuartz;
import com.len.util.SpringUtil;
import com.len.entity.SysUser;
import com.len.service.SysUserService;
import com.len.service.impl.SysUserServiceImpl;
import java.text.SimpleDateFormat;
import java.util.List;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.context.ApplicationContext;
/**
* @author zhuxiaomeng
* @date 2018/1/7.
* @email 154040976@qq.com
*
* 定时
*/
public class JobDemo1 implements Job{
@Override
public void execute(JobExecutionContext context) throws JobExecutionException {
System.out.println("JobDemo1启动任务=======================");
run();
System.out.println("JobDemo1下次执行时间====="+
new SimpleDateFormat("yyyy-MM-dd hh:mm:ss")
.format(context.getNextFireTime())+"==============");
}
public void run(){
ApplicationContext applicationContext=SpringUtil.getApplicationContext();
SysUserService sys=SpringUtil.getBean(SysUserServiceImpl.class);
List<SysUser> userList=sys.selectListByPage(new SysUser());
System.out.println(userList.get(0).getUsername());;
System.out.println("JobDemo1执行完毕=======================");
}
}

View File

@ -0,0 +1,42 @@
package com.len.core.quartz.CustomQuartz;
import com.len.entity.SysUser;
import com.len.service.SysUserService;
import com.len.service.impl.SysUserServiceImpl;
import com.len.util.SpringUtil;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.context.ApplicationContext;
/**
* @author zhuxiaomeng
* @date 2018/1/7.
* @email 154040976@qq.com
*
* 定时测试类
*/
public class JobDemo2 implements Job{
@Override
public void execute(JobExecutionContext context) throws JobExecutionException {
System.out.println("JobDemo2启动任务=======================");
run();
System.out.println("JobDemo2下次执行时间====="+
new SimpleDateFormat("yyyy-MM-dd hh:mm:ss")
.format(context.getNextFireTime())+"==============");
}
public void run(){
ApplicationContext applicationContext=SpringUtil.getApplicationContext();
SysUserService sys=SpringUtil.getBean(SysUserServiceImpl.class);
List<SysUser> userList=sys.selectListByPage(new SysUser());
System.out.println(userList.get(0).getUsername());;
System.out.println("JobDemo2执行完毕=======================");
}
}

View File

@ -0,0 +1,41 @@
package com.len.core.quartz.CustomQuartz;
import com.len.entity.SysUser;
import com.len.service.SysUserService;
import com.len.service.impl.SysUserServiceImpl;
import com.len.util.SpringUtil;
import java.text.SimpleDateFormat;
import java.util.List;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.context.ApplicationContext;
/**
* @author zhuxiaomeng
* @date 2018/1/7.
* @email 154040976@qq.com
*
* 定时测试类
*/
public class JobDemo3 implements Job{
@Override
public void execute(JobExecutionContext context) throws JobExecutionException {
System.out.println("JobDemo3启动任务=======================");
run();
System.out.println("JobDemo3下次执行时间====="+
new SimpleDateFormat("yyyy-MM-dd hh:mm:ss")
.format(context.getNextFireTime())+"==============");
}
public void run(){
ApplicationContext applicationContext=SpringUtil.getApplicationContext();
SysUserService sys=SpringUtil.getBean(SysUserServiceImpl.class);
List<SysUser> userList=sys.selectListByPage(new SysUser());
System.out.println(userList.get(0).getUsername());;
System.out.println("JobDemo3执行完毕=======================");
}
}

View File

@ -0,0 +1,41 @@
package com.len.core.quartz.CustomQuartz;
import com.len.entity.SysUser;
import com.len.service.SysUserService;
import com.len.service.impl.SysUserServiceImpl;
import com.len.util.SpringUtil;
import java.text.SimpleDateFormat;
import java.util.List;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.context.ApplicationContext;
/**
* @author zhuxiaomeng
* @date 2018/1/7.
* @email 154040976@qq.com
*
* 定时测试类
*/
public class JobDemo4 implements Job{
@Override
public void execute(JobExecutionContext context) throws JobExecutionException {
System.out.println("JobDemo4启动任务=======================");
run();
System.out.println("JobDemo4下次执行时间====="+
new SimpleDateFormat("yyyy-MM-dd hh:mm:ss")
.format(context.getNextFireTime())+"==============");
}
public void run(){
ApplicationContext applicationContext=SpringUtil.getApplicationContext();
SysUserService sys=SpringUtil.getBean(SysUserServiceImpl.class);
List<SysUser> userList=sys.selectListByPage(new SysUser());
System.out.println(userList.get(0).getUsername());;
System.out.println("JobDemo4执行完毕=======================");
}
}

View File

@ -0,0 +1,41 @@
package com.len.core.quartz.CustomQuartz;
import com.len.entity.SysUser;
import com.len.service.SysUserService;
import com.len.service.impl.SysUserServiceImpl;
import com.len.util.SpringUtil;
import java.text.SimpleDateFormat;
import java.util.List;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.context.ApplicationContext;
/**
* @author zhuxiaomeng
* @date 2018/1/7.
* @email 154040976@qq.com
*
* 定时测试类
*/
public class JobDemo5 implements Job{
@Override
public void execute(JobExecutionContext context) throws JobExecutionException {
System.out.println("JobDemo5启动任务=======================");
run();
System.out.println("JobDemo5下次执行时间====="+
new SimpleDateFormat("yyyy-MM-dd hh:mm:ss")
.format(context.getNextFireTime())+"==============");
}
public void run(){
ApplicationContext applicationContext=SpringUtil.getApplicationContext();
SysUserService sys=SpringUtil.getBean(SysUserServiceImpl.class);
List<SysUser> userList=sys.selectListByPage(new SysUser());
System.out.println(userList.get(0).getUsername());;
System.out.println("JobDemo5执行完毕=======================");
}
}

View File

@ -0,0 +1,149 @@
package com.len.core.quartz;
import com.len.core.annotation.Log;
import com.len.core.annotation.Log.LOG_TYPE;
import com.len.entity.SysJob;
import java.text.ParseException;
import java.util.Date;
import java.util.HashSet;
import javax.annotation.PostConstruct;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.quartz.CronScheduleBuilder;
import org.quartz.CronTrigger;
import org.quartz.JobBuilder;
import org.quartz.JobDetail;
import org.quartz.JobKey;
import org.quartz.Scheduler;
import org.quartz.SchedulerException;
import org.quartz.Trigger;
import org.quartz.TriggerBuilder;
import org.quartz.TriggerKey;
import org.quartz.impl.StdSchedulerFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Lazy;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.quartz.SchedulerFactoryBean;
import org.springframework.stereotype.Service;
/**
* @author zhuxiaomeng
* @date 2018/1/5.
* @email 154040976@qq.com
*
* 定时任务类 增删改 可参考apihttp://www.quartz-scheduler.org/api/2.2.1/
*
* 任务名称 默认为 SysJob id
*/
@Service
public class JobTask {
private static final Logger log = LoggerFactory.getLogger(JobTask.class);
@Autowired
SchedulerFactoryBean schedulerFactoryBean;
/**
* true 存在 false 不存在
* @param
* @return
*/
public boolean checkJob(SysJob job){
Scheduler scheduler = schedulerFactoryBean.getScheduler();
TriggerKey triggerKey = TriggerKey.triggerKey(job.getId(), Scheduler.DEFAULT_GROUP);
try {
if(scheduler.checkExists(triggerKey)){
return true;
}
} catch (SchedulerException e) {
e.printStackTrace();
}
return false;
}
/**
* 开启
*/
//@Log(desc = "开启定时任务")
public boolean startJob(SysJob job) {
Scheduler scheduler = schedulerFactoryBean.getScheduler();
try {
Class clazz = Class.forName(job.getClazzPath());
JobDetail jobDetail = JobBuilder.newJob(clazz).build();
// 触发器
TriggerKey triggerKey = TriggerKey.triggerKey(job.getId(), Scheduler.DEFAULT_GROUP);
CronTrigger trigger = TriggerBuilder.newTrigger()
.withIdentity(triggerKey)
.withSchedule(CronScheduleBuilder.cronSchedule(job.getCron())).build();
scheduler.scheduleJob(jobDetail, trigger);
// 启动
if (!scheduler.isShutdown()) {
scheduler.start();
log.info("---任务[" + triggerKey.getName() + "]启动成功-------");
return true;
}else{
log.info("---任务[" + triggerKey.getName() + "]已经运行,请勿再次启动-------");
}
} catch (Exception e) {
throw new RuntimeException(e);
}
return false;
}
/**
* 更新
*/
@Log(desc = "更新定时任务", type = LOG_TYPE.UPDATE)
public boolean updateJob(SysJob job) {
Scheduler scheduler = schedulerFactoryBean.getScheduler();
String createTime = DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss");
TriggerKey triggerKey = TriggerKey.triggerKey(job.getId(), Scheduler.DEFAULT_GROUP);
try {
if (scheduler.checkExists(triggerKey)) {
return false;
}
JobKey jobKey = JobKey.jobKey(job.getId(), Scheduler.DEFAULT_GROUP);
CronScheduleBuilder schedBuilder = CronScheduleBuilder.cronSchedule(job.getCron())
.withMisfireHandlingInstructionDoNothing();
CronTrigger trigger = TriggerBuilder.newTrigger().withIdentity(triggerKey)
.withDescription(createTime).withSchedule(schedBuilder).build();
Class clazz = null;
JobDetail jobDetail = scheduler.getJobDetail(jobKey);
HashSet<Trigger> triggerSet = new HashSet<>();
triggerSet.add(trigger);
scheduler.scheduleJob(jobDetail, triggerSet, true);
log.info("---任务["+triggerKey.getName()+"]更新成功-------");
return true;
} catch (SchedulerException e) {
e.printStackTrace();
}
return false;
}
/**
* 删除
*/
@Log(desc = "删除定时任务", type = LOG_TYPE.DEL)
public boolean remove(SysJob job) {
Scheduler scheduler = schedulerFactoryBean.getScheduler();
TriggerKey triggerKey = TriggerKey.triggerKey(job.getId(), Scheduler.DEFAULT_GROUP);
try {
if (checkJob(job)) {
scheduler.pauseTrigger(triggerKey);
scheduler.unscheduleJob(triggerKey);
scheduler.deleteJob(JobKey.jobKey(job.getId(), Scheduler.DEFAULT_GROUP));
log.info("---任务[" + triggerKey.getName() + "]删除成功-------");
return true;
}
} catch (SchedulerException e) {
e.printStackTrace();
}
return false;
}
}

View File

@ -0,0 +1,23 @@
package com.len.core.quartz;
import org.quartz.spi.TriggerFiredBundle;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
import org.springframework.scheduling.quartz.AdaptableJobFactory;
import org.springframework.stereotype.Component;
@Component
public class MyJobFactory extends AdaptableJobFactory {
@Autowired
private AutowireCapableBeanFactory capableBeanFactory;
@Override
protected Object createJobInstance(TriggerFiredBundle bundle) throws Exception {
// 调用父类的方法
Object jobInstance = super.createJobInstance(bundle);
// 进行注入
capableBeanFactory.autowireBean(jobInstance);
return jobInstance;
}
}

View File

@ -0,0 +1,24 @@
package com.len.core.quartz;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.quartz.SchedulerFactoryBean;
@Configuration
public class MySchedulerListener {
@Autowired
MyJobFactory myJobFactory;
@Bean(name ="mySchedulerFactoryBean")
public SchedulerFactoryBean mySchedulerFactory() {
SchedulerFactoryBean bean = new SchedulerFactoryBean();
bean.setOverwriteExistingJobs(true);
bean.setStartupDelay(1);
bean.setJobFactory(myJobFactory);
return bean;
}
}

View File

@ -0,0 +1,34 @@
package com.len.entity;
import java.io.Serializable;
import java.util.Date;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
@Getter
@Setter
@ToString
public class SysJob implements Serializable {
private String id;
private String jobName;
private String cron;
private Boolean status;
private String clazzPath;
private String jobDesc;
private String createBy;
private Date createDate;
private String updateBy;
private Date updateDate;
private static final long serialVersionUID = 1L;
}

View File

@ -0,0 +1,18 @@
package com.len.mapper;
import com.len.base.BaseMapper;
import com.len.entity.SysJob;
public interface SysJobMapper extends BaseMapper<SysJob,String> {
int deleteByPrimaryKey(String id);
int insert(SysJob record);
int insertSelective(SysJob record);
SysJob selectByPrimaryKey(String id);
int updateByPrimaryKeySelective(SysJob record);
int updateByPrimaryKey(SysJob record);
}

View File

@ -0,0 +1,14 @@
package com.len.service;
import com.len.base.BaseService;
import com.len.entity.SysJob;
import com.len.entity.SysMenu;
/**
* @author zhuxiaomeng
* @date 2018/1/6.
* @email 154040976@qq.com
*/
public interface JobService extends BaseService<SysJob,String> {
}

View File

@ -0,0 +1,25 @@
package com.len.service.impl;
import com.len.base.BaseMapper;
import com.len.base.impl.BaseServiceImpl;
import com.len.entity.SysJob;
import com.len.mapper.SysJobMapper;
import com.len.service.JobService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* @author zhuxiaomeng
* @date 2018/1/6.
* @email 154040976@qq.com
*/
@Service
public class JobServiceImpl extends BaseServiceImpl<SysJob,String> implements JobService {
@Autowired
SysJobMapper jobMapper;
@Override
public BaseMapper<SysJob, String> getMappser() {
return jobMapper;
}
}

View File

@ -0,0 +1,155 @@
<#--Created by IntelliJ IDEA.
User: zxm
Date: 2017/12/20
Time: 10:00
To change this template use File | Settings | File Templates.-->
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>添加任务</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
<link rel="stylesheet" href="${re.contextPath}/plugin/layui/css/layui.css">
<link rel="stylesheet" href="${re.contextPath}/plugin/ztree/css/metroStyle/metroStyle.css">
<script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
<script type="text/javascript" src="${re.contextPath}/plugin/layui/layui.all.js" charset="utf-8"></script>
</head>
<body>
<div class="x-body">
<form class="layui-form layui-form-pane" style="margin-left: 20px;">
<div style="width:100%;height:400px;overflow: auto;">
<div class="layui-form-item">
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 10px;">
<legend style="font-size:16px;">任务信息</legend>
</fieldset>
</div>
<div class="layui-form-item">
<label for="jobName" class="layui-form-label">
<span class="x-red">*</span>任务名称
</label>
<div class="layui-input-inline">
<input type="text" id="jobName" name="jobName" lay-verify="jobName"
autocomplete="off" class="layui-input">
</div>
<div id="ms" class="layui-form-mid layui-word-aux">
<span class="x-red">*</span><span id="ums">名称必填</span>
</div>
</div>
<div class="layui-form-item">
<div class="layui-inline">
<label for="cron" class="layui-form-label">
<span class="x-red">*</span>表达式
</label>
<div class="layui-input-inline">
<input type="text" id="cron" name="cron" lay-verify="cron" autocomplete="off" class="layui-input">
</div>
<div id="ms" class="layui-form-mid layui-word-aux">
<span class="x-red">*</span><a href="http://cron.qqe2.com/" target="_blank">获取表达式</a>
</div>
</div>
</div>
<div class="layui-form-item">
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 10px;">
<legend style="font-size:16px;">执行类要实现Job</legend>
</fieldset>
</div>
<div class="layui-form-item">
<div class="layui-inline">
<label for="clazzPath" class="layui-form-label">
<span class="x-red">*</span>任务执行类
</label>
<div class="layui-input-inline">
<input type="text" id="clazzPath" style="width: 300px;" name="clazzPath" lay-verify="clazzPath" autocomplete="off" class="layui-input">
</div>
</div>
</div>
<div class="layui-form-item">
<div class="layui-inline">
<label for="jobDesc" class="layui-form-label">
<span class="x-red">*</span>任务描述
</label>
<div class="layui-input-inline">
<input type="text" id="jobDesc" name="jobDesc" lay-verify="jobDesc" autocomplete="off" class="layui-input">
</div>
</div>
</div>
<div style="height: 60px"></div>
</div>
<div style="width: 100%;height: 55px;background-color: white;border-top:1px solid #e6e6e6;
position: fixed;bottom: 1px;margin-left:-20px;">
<div class="layui-form-item" style=" float: right;margin-right: 30px;margin-top: 8px">
<button class="layui-btn layui-btn-normal" lay-filter="add" lay-submit>
增加
</button>
<button class="layui-btn layui-btn-primary" id="close">
取消
</button>
</div>
</div>
</form>
</div>
<script>
layui.use(['form','layer'], function(){
$ = layui.jquery;
var form = layui.form
,layer = layui.layer;
//自定义验证规则
form.verify({
jobName: function(value){
if(value.trim()==""){
return "任务名称不能为空";
}
},
cron:function(value) {
if (value.trim() == "") {
return "表达式不能为空";
}
},
clazzPath:function(value){
if(value.trim()==""){
return "执行类不能为空";
}
}
});
$('#close').click(function(){
var index = parent.layer.getFrameIndex(window.name);
parent.layer.close(index);
});
//监听提交
form.on('submit(add)', function(data){
$.ajax({
url:'addJob',
type:'post',
data:data.field,
async:false, traditional: true,
success:function(d){
var index = parent.layer.getFrameIndex(window.name);
if(d.flag){
parent.layer.close(index);
window.parent.layui.table.reload('jobList');
window.top.layer.msg(d.msg,{icon:6,offset: 'rb',area:['120px','80px'],anim:2});
}else{
layer.msg(d.msg,{icon:5});
}
},error:function(){
layer.alert("请求失败", {icon: 6},function () {
var index = parent.layer.getFrameIndex(window.name);
parent.layer.close(index);
});
}
});
return false;
});
});
</script>
</body>
</html>

View File

@ -0,0 +1,387 @@
<#-- Created by IntelliJ IDEA.
User: zxm
Date: 2017/1/7
Time: 11:06
To change this template use File | Settings | File Templates.-->
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>任务管理</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi"/>
<link rel="stylesheet" href="${re.contextPath}/plugin/layui/css/layui.css">
<script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
<script type="text/javascript" src="${re.contextPath}/plugin/layui/layui.all.js"
charset="utf-8"></script>
<style>
.layui-input {
height: 30px;
width: 120px;
}
.x-nav {
padding: 0 20px;
position: relative;
z-index: 99;
border-bottom: 1px solid #e5e5e5;
height: 32px;
overflow: hidden;
}
</style>
</head>
<body>
<br/>
<div class="x-nav">
<div class="select">
任务名称:
<div class="layui-inline">
<input class="layui-input" height="20px" id="rolename" autocomplete="off">
</div>
描述:
<div class="layui-inline">
<input class="layui-input" height="20px" id="remark" autocomplete="off">
</div>
<button class="select-on layui-btn layui-btn-sm" data-type="select"><i class="layui-icon"></i>
</button>
<button class="layui-btn layui-btn-sm" id="refresh" style="float: right;"
data-type="reload">
<i class="layui-icon">ဂ</i>
</button>
</div>
</div>
<div class="layui-col-md12" style="height:40px;margin-top:3px;">
<div class="layui-btn-group">
<@shiro.hasPermission name="job:add">
<button class="layui-btn layui-btn-normal" data-type="add">
<i class="layui-icon">&#xe608;</i>新增
</button>
</@shiro.hasPermission>
<@shiro.hasPermission name="job:update">
<button class="layui-btn layui-btn-normal" data-type="update">
<i class="layui-icon">&#xe642;</i>编辑
</button>
</@shiro.hasPermission>
<@shiro.hasPermission name="job:select">
<button class="layui-btn layui-btn-normal" data-type="detail">
<i class="layui-icon">&#xe605;</i>查看
</button>
</@shiro.hasPermission>
</div>
</div>
<table id="jobList" class="layui-hide" lay-filter="job"></table>
<script type="text/html" id="toolBar">
<@shiro.hasPermission name="job:add">
<a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail">查看</a>
</@shiro.hasPermission>
<@shiro.hasPermission name="job:update">
<a class="layui-btn layui-btn-xs layui-btn-normal" lay-event="edit">编辑</a>
</@shiro.hasPermission>
{{# if(!d.status){ }}
<@shiro.hasPermission name="job:start">
<a class="layui-btn layui-btn-xs layui-btn-normal" lay-event="start">启动</a>
</@shiro.hasPermission>
{{# } }}
{{# if(d.status){ }}
<@shiro.hasPermission name="job:end">
<a class="layui-btn layui-btn-xs layui-btn-normal" lay-event="end">停止</a>
</@shiro.hasPermission>
{{# } }}
<@shiro.hasPermission name="role:del">
<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</@shiro.hasPermission>
</script>
<script>
/**前端后期完美后 会进行封装 目前先不处理 精力在后端。。。*/
layui.laytpl.toDateString = function(d, format){
var date = new Date(d || new Date())
,ymd = [
this.digit(date.getFullYear(), 4)
,this.digit(date.getMonth() + 1)
,this.digit(date.getDate())
]
,hms = [
this.digit(date.getHours())
,this.digit(date.getMinutes())
,this.digit(date.getSeconds())
];
format = format || 'yyyy-MM-dd HH:mm:ss';
return format.replace(/yyyy/g, ymd[0])
.replace(/MM/g, ymd[1])
.replace(/dd/g, ymd[2])
.replace(/HH/g, hms[0])
.replace(/mm/g, hms[1])
.replace(/ss/g, hms[2]);
};
//数字前置补零
layui.laytpl.digit = function(num, length, end){
var str = '';
num = String(num);
length = length || 2;
for(var i = num.length; i < length; i++){
str += '0';
}
return num < Math.pow(10, length) ? str + (num|0) : num;
};
document.onkeydown = function (e) { // 回车提交表单
var theEvent = window.event || e;
var code = theEvent.keyCode || theEvent.which;
if (code == 13) {
$(".select .select-on").click();
}
}
layui.use('table', function () {
var table = layui.table;
//方法级渲染
table.render({
id: 'jobList',
elem: '#jobList'
, url: 'showJobList'
, cols: [[
{checkbox: true, fixed: true, width: '5%'}
, {field: 'jobName', title: '任务名称', width: '10%', sort: true}
, {field: 'cron', title: '表达式', width: '10%'}
, {field: 'clazzPath', title: '任务类', width: '20%', sort: true}
, {field: 'status', title: '状态', width: '10%', sort: true}
, {field: 'jobDesc', title: '任务描述', width: '10%'}
, {field: 'createDate', title: '创建时间', width: '10%',templet: '<div>{{ layui.laytpl.toDateString(d.createDate,"yyyy-MM-dd hh:mm:ss") }}</div>'}
, {field: 'remark', title: '操作', width: '20%', toolbar: "#toolBar"}
]]
, page: true
, height: 'full-105'
});
var $ = layui.$, active = {
select: function () {
var rolename = $('#rolename').val();
var remark = $('#remark').val();
table.reload('jobList', {
where: {
roleName: rolename,
remark: remark
}
});
},
reload:function(){
$('#rolename').val('');
$('#remark').val('');
table.reload('jobList', {
where: {
roleName: null,
remark: null
}
});
},
add: function () {
add('添加任务', 'showAddJob', 700, 450);
},
update: function () {
var checkStatus = table.checkStatus('jobList')
, data = checkStatus.data;
if (data.length != 1) {
layer.msg('请选择一行编辑', {icon: 5});
return false;
}
if(data[0].status){
layer.msg('已经启动任务无法更新,请停止后更新',{icon:5,offset: 'rb',area:['200px','100px'],anim:2});
return false;
}
update('编辑任务', 'updateJob?id=' + data[0].id, 700, 450);
},
detail: function () {
var checkStatus = table.checkStatus('jobList')
, data = checkStatus.data;
if (data.length != 1) {
layer.msg('请选择一行查看', {icon: 5});
return false;
}
detail('查看任务信息', 'updateJob?id=' + data[0].id, 700, 450);
}
};
//监听表格复选框选择
table.on('checkbox(job)', function (obj) {
console.log(obj)
});
//监听工具条
table.on('tool(job)', function (obj) {
var data = obj.data;
if (obj.event === 'detail') {
detail('编辑角色', 'updateRole?id=' + data.id, 700, 450);
} else if (obj.event === 'del') {
if(!data.status) {
layer.confirm('确定删除任务[<label style="color: #00AA91;">' + data.jobName + '</label>]?',
function () {
del(data.id);
});
}else{
layer.msg('已经启动任务无法更新,请停止后删除',{icon:5,offset: 'rb',area:['200px','100px'],anim:2});
}
} else if (obj.event === 'edit') {
if(!data.status){
update('编辑任务', 'updateJob?id=' + data.id, 700, 450);
}else{
layer.msg('已经启动任务无法更新,请停止后更新',{icon:5,offset: 'rb',area:['200px','100px'],anim:2});
}
} else if(obj.event === 'start'){
layer.confirm('确定开启任务[<label style="color: #00AA91;">' + data.jobName + '</label>]?', function(){
reqByAjax(data.id,'startJob','jobList');
});
} else if(obj.event === 'end'){
layer.confirm('确定停止任务[<label style="color: #00AA91;">' + data.jobName + '</label>]?', function(){
reqByAjax(data.id,'endJob','jobList');
});
}
});
$('.layui-col-md12 .layui-btn').on('click', function () {
var type = $(this).data('type');
active[type] ? active[type].call(this) : '';
});
$('.select .layui-btn').on('click', function () {
var type = $(this).data('type');
active[type] ? active[type].call(this) : '';
});
});
function reqByAjax(id,url,tableId){
$.ajax({
url: url,
type: "post",
data: {id: id},
success: function (d) {
if(d.flag){
layer.msg(d.msg,{icon:6,offset: 'rb',area:['120px','80px'],anim:2});
layui.table.reload(tableId);
}else{
layer.msg(d.msg,{icon:5,offset: 'rb',area:['120px','80px'],anim:2});
}
}
});
}
function del(id) {
$.ajax({
url: "del",
type: "post",
data: {id: id},
success: function (d) {
if(d.flag){
layer.msg(d.msg,{icon:6,offset: 'rb',area:['120px','80px'],anim:2});
layui.table.reload('jobList');
}else{
layer.msg(d.msg,{icon:5,offset: 'rb',area:['120px','80px'],anim:2});
}
}
});
}
function detail(title, url, w, h) {
var number = 1;
if (title == null || title == '') {
title = false;
}
;
if (url == null || url == '') {
url = "404.html";
}
;
if (w == null || w == '') {
w = ($(window).width() * 0.9);
}
;
if (h == null || h == '') {
h = ($(window).height() - 50);
}
;
layer.open({
id: 'user-detail',
type: 2,
area: [w + 'px', h + 'px'],
fix: false,
maxmin: true,
shadeClose: true,
shade: 0.4,
title: title,
content: url + '&detail=true',
// btn:['关闭']
});
}
/**
* 更新用户
*/
function update(title, url, w, h) {
if (title == null || title == '') {
title = false;
}
if (url == null || url == '') {
url = "404.html";
}
if (w == null || w == '') {
w = ($(window).width() * 0.9);
}
if (h == null || h == '') {
h = ($(window).height() - 50);
}
layer.open({
id: 'user-update',
type: 2,
area: [w + 'px', h + 'px'],
fix: false,
maxmin: true,
shadeClose: false,
shade: 0.4,
title: title,
content: url + '&detail=false'
});
}
/*弹出层*/
/*
参数解释:
title 标题
url 请求的url
id 需要操作的数据id
w 弹出层宽度(缺省调默认值)
h 弹出层高度(缺省调默认值)
*/
function add(title, url, w, h) {
if (title == null || title == '') {
title = false;
}
;
if (url == null || url == '') {
url = "404.html";
}
;
if (w == null || w == '') {
w = ($(window).width() * 0.9);
}
;
if (h == null || h == '') {
h = ($(window).height() - 50);
}
;
layer.open({
id: 'job-add',
type: 2,
area: [w + 'px', h + 'px'],
fix: false,
maxmin: true,
shadeClose: false,
shade: 0.4,
title: title,
content: url
});
}
</script>
</body>
</html>

View File

@ -0,0 +1,173 @@
<#--Created by IntelliJ IDEA.
User: zxm
Date: 2017/12/20
Time: 10:00
To change this template use File | Settings | File Templates.-->
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>更新任务</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
<link rel="stylesheet" href="${re.contextPath}/plugin/layui/css/layui.css">
<link rel="stylesheet" href="${re.contextPath}/plugin/ztree/css/metroStyle/metroStyle.css">
<script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
<script type="text/javascript" src="${re.contextPath}/plugin/layui/layui.all.js" charset="utf-8"></script>
</head>
<script type="text/javascript">
(function($) {
$.fn.disable = function () {
return $(this).find("*").each(function () {
$(this).attr("disabled", "disabled");
});
}
})(jQuery);
</script>
<script type="text/javascript">
$(document).ready(function() {
var flag='${detail}';
if(flag){
$("form").disable();
}
});
</script>
<body>
<div class="x-body">
<form class="layui-form layui-form-pane" style="margin-left: 20px;">
<div style="width:100%;height:400px;overflow: auto;">
<div class="layui-form-item">
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 10px;">
<legend style="font-size:16px;">任务信息</legend>
</fieldset>
</div>
<div class="layui-form-item">
<label for="jobName" class="layui-form-label">
<span class="x-red">*</span>任务名称
</label>
<div class="layui-input-inline">
<input type="hidden" value="${job.id}" name="id">
<input type="text" value="${job.jobName}" id="jobName" name="jobName" lay-verify="jobName"
autocomplete="off" class="layui-input">
</div>
<div id="ms" class="layui-form-mid layui-word-aux">
<span class="x-red">*</span><span id="ums">名称必填</span>
</div>
</div>
<div class="layui-form-item">
<div class="layui-inline">
<label for="cron" class="layui-form-label">
<span class="x-red">*</span>表达式
</label>
<div class="layui-input-inline">
<input type="text" id="cron" name="cron" lay-verify="cron" value="${job.cron}" autocomplete="off" class="layui-input">
</div>
<div id="ms" class="layui-form-mid layui-word-aux">
<span class="x-red">*</span><a href="http://cron.qqe2.com/" target="_blank">获取表达式</a>
</div>
</div>
</div>
<div class="layui-form-item">
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 10px;">
<legend style="font-size:16px;">执行类要实现Job</legend>
</fieldset>
</div>
<div class="layui-form-item">
<div class="layui-inline">
<label for="clazzPath" class="layui-form-label">
<span class="x-red">*</span>任务执行类
</label>
<div class="layui-input-inline">
<input type="text" id="clazzPath" style="width: 300px;" value="${job.clazzPath}" name="clazzPath" lay-verify="clazzPath" autocomplete="off" class="layui-input">
</div>
</div>
</div>
<div class="layui-form-item">
<div class="layui-inline">
<label for="jobDesc" class="layui-form-label">
<span class="x-red">*</span>任务描述
</label>
<div class="layui-input-inline">
<input type="text" id="jobDesc" name="jobDesc" value="${job.jobDesc}" lay-verify="jobDesc" autocomplete="off" class="layui-input">
</div>
</div>
</div>
<div style="height: 60px"></div>
</div>
<#if !detail>
<div style="width: 100%;height: 55px;background-color: white;border-top:1px solid #e6e6e6;
position: fixed;bottom: 1px;margin-left:-20px;">
<div class="layui-form-item" style=" float: right;margin-right: 30px;margin-top: 8px">
<button class="layui-btn layui-btn-normal" lay-filter="add" lay-submit>
确认
</button>
<button class="layui-btn layui-btn-primary" id="close">
取消
</button>
</div>
</div>
</#if>
</form>
</div>
<script>
layui.use(['form','layer'], function(){
$ = layui.jquery;
var form = layui.form
,layer = layui.layer;
//自定义验证规则
form.verify({
jobName: function(value){
if(value.trim()==""){
return "任务名称不能为空";
}
},
cron:function(value) {
if (value.trim() == "") {
return "表达式不能为空";
}
},
clazzPath:function(value){
if(value.trim()==""){
return "执行类不能为空";
}
}
});
$('#close').click(function(){
var index = parent.layer.getFrameIndex(window.name);
parent.layer.close(index);
});
//监听提交
form.on('submit(add)', function(data){
$.ajax({
url:'updateJob',
type:'post',
data:data.field,
async:false, traditional: true,
success:function(d){
var index = parent.layer.getFrameIndex(window.name);
if(d.flag){
parent.layer.close(index);
window.parent.layui.table.reload('jobList');
window.top.layer.msg(d.msg,{icon:6,offset: 'rb',area:['120px','80px'],anim:2});
}else{
layer.msg(d.msg,{icon:5});
}
},error:function(){
layer.alert("请求失败", {icon: 6},function () {
var index = parent.layer.getFrameIndex(window.name);
parent.layer.close(index);
});
}
});
return false;
});
});
</script>
</body>
</html>

View File

@ -123,15 +123,15 @@
, cols: [[ , cols: [[
{checkbox: true, fixed: true, width: '5%'} {checkbox: true, fixed: true, width: '5%'}
, {field: 'userName', title: '操作人', width: '10%', sort: true} , {field: 'userName', title: '操作人', width: '10%', sort: true}
, {field: 'type', title: '操作类型', width: '5%', sort: true} , {field: 'type', title: '操作类型', width: '10%', sort: true}
, {field: 'text', title: '描述内容', width: '10%', sort: true} , {field: 'text', title: '描述内容', width: '10%', sort: true}
, {field: 'param', title: '参数', width: '45%', sort: true} , {field: 'param', title: '参数', width: '45%', sort: true}
, {field: 'createTime', title: '操作时间', width: '10%',templet: '<div>{{ layui.laytpl.toDateString(d.createTime,"yyyy-MM-dd HH:mm:ss") }}</div>'} , {field: 'createTime', title: '操作时间', width: '10%',templet: '<div>{{ layui.laytpl.toDateString(d.createTime,"yyyy-MM-dd HH:mm:ss") }}</div>'}
, {field: 'text', title: '操作', width: '20%', toolbar:'#toolBar'} , {field: 'text', title: '操作', width: '10%', toolbar:'#toolBar'}
]] ]]
, page: true , page: true
, height: 400 , height: 'full-105'
}); });
var $ = layui.$, active = { var $ = layui.$, active = {

View File

@ -143,7 +143,7 @@
, {field: 'remark', title: '操作', width: '20%', toolbar: "#toolBar"} , {field: 'remark', title: '操作', width: '20%', toolbar: "#toolBar"}
]] ]]
, page: true , page: true
, height: 400 , height: 'full-105'
}); });
var $ = layui.$, active = { var $ = layui.$, active = {

View File

@ -19,6 +19,23 @@ To change this template use File | Settings | File Templates.-->
<script type="text/javascript" src="${re.contextPath}/plugin/layui/layui.all.js" charset="utf-8"></script> <script type="text/javascript" src="${re.contextPath}/plugin/layui/layui.all.js" charset="utf-8"></script>
<script type="text/javascript" src="${re.contextPath}/plugin/ztree/js/jquery.ztree.core.js"></script> <script type="text/javascript" src="${re.contextPath}/plugin/ztree/js/jquery.ztree.core.js"></script>
<script type="text/javascript" src="${re.contextPath}/plugin/ztree/js/jquery.ztree.excheck.js" charset="utf-8"></script> <script type="text/javascript" src="${re.contextPath}/plugin/ztree/js/jquery.ztree.excheck.js" charset="utf-8"></script>
<script type="text/javascript">
(function($) {
$.fn.disable = function () {
return $(this).find("*").each(function () {
$(this).attr("disabled", "disabled");
});
}
})(jQuery);
</script>
<script type="text/javascript">
$(document).ready(function() {
var flag='${detail}';
if(flag){
$("form").disable();
}
});
</script>
<script type="text/javascript"> <script type="text/javascript">
var setting = { var setting = {
check: { check: {

View File

@ -125,9 +125,10 @@ To change this template use File | Settings | File Templates.-->
<button class="layui-btn layui-btn-primary" id="close"> <button class="layui-btn layui-btn-primary" id="close">
取消 取消
</button> </button>
</#if>
</div> </div>
</div> </div>
</#if>
</form> </form>
</div> </div>
<script> <script>

View File

@ -74,7 +74,7 @@
</@shiro.hasPermission> </@shiro.hasPermission>
<@shiro.hasPermission name="user:repass"> <@shiro.hasPermission name="user:repass">
<button class="layui-btn layui-btn-normal" data-type="changePwd"> <button class="layui-btn layui-btn-normal" data-type="changePwd">
<i class="layui-icon">&#xe605;</i>修改密 <i class="layui-icon">&#xe605;</i>修改密
</button> </button>
</@shiro.hasPermission> </@shiro.hasPermission>
</div> </div>

View File

@ -0,0 +1,170 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.len.mapper.SysJobMapper">
<resultMap id="BaseResultMap" type="com.len.entity.SysJob">
<id column="id" jdbcType="VARCHAR" property="id" />
<result column="job_name" jdbcType="VARCHAR" property="jobName" />
<result column="cron" jdbcType="VARCHAR" property="cron" />
<result column="status" jdbcType="BIT" property="status" />
<result column="clazz_path" jdbcType="VARCHAR" property="clazzPath" />
<result column="job_desc" jdbcType="VARCHAR" property="jobDesc" />
<result column="create_by" jdbcType="VARCHAR" property="createBy" />
<result column="create_date" jdbcType="TIMESTAMP" property="createDate" />
<result column="update_by" jdbcType="VARCHAR" property="updateBy" />
<result column="update_date" jdbcType="TIMESTAMP" property="updateDate" />
</resultMap>
<sql id="Base_Column_List">
id, job_name, cron, status, clazz_path, job_desc, create_by, create_date, update_by,
update_date
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from sys_job
where id = #{id,jdbcType=VARCHAR}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
delete from sys_job
where id = #{id,jdbcType=VARCHAR}
</delete>
<insert id="insert" parameterType="com.len.entity.SysJob">
<selectKey resultType="String" keyProperty="id" order="BEFORE">
select replace(uuid(),'-','') from dual
</selectKey>
insert into sys_job (id, job_name, cron,
status, clazz_path, job_desc,
create_by, create_date, update_by,
update_date)
values (#{id,jdbcType=VARCHAR}, #{jobName,jdbcType=VARCHAR}, #{cron,jdbcType=VARCHAR},
#{status,jdbcType=BIT}, #{clazzPath,jdbcType=VARCHAR}, #{jobDesc,jdbcType=VARCHAR},
#{createBy,jdbcType=VARCHAR}, #{createDate,jdbcType=TIMESTAMP}, #{updateBy,jdbcType=VARCHAR},
#{updateDate,jdbcType=TIMESTAMP})
</insert>
<insert id="insertSelective" parameterType="com.len.entity.SysJob">
<selectKey resultType="String" keyProperty="id" order="BEFORE">
select replace(uuid(),'-','') from dual
</selectKey>
insert into sys_job
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="jobName != null">
job_name,
</if>
<if test="cron != null">
cron,
</if>
<if test="status != null">
status,
</if>
<if test="clazzPath != null">
clazz_path,
</if>
<if test="jobDesc != null">
job_desc,
</if>
<if test="createBy != null">
create_by,
</if>
<if test="createDate != null">
create_date,
</if>
<if test="updateBy != null">
update_by,
</if>
<if test="updateDate != null">
update_date,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=VARCHAR},
</if>
<if test="jobName != null">
#{jobName,jdbcType=VARCHAR},
</if>
<if test="cron != null">
#{cron,jdbcType=VARCHAR},
</if>
<if test="status != null">
#{status,jdbcType=BIT},
</if>
<if test="clazzPath != null">
#{clazzPath,jdbcType=VARCHAR},
</if>
<if test="jobDesc != null">
#{jobDesc,jdbcType=VARCHAR},
</if>
<if test="createBy != null">
#{createBy,jdbcType=VARCHAR},
</if>
<if test="createDate != null">
#{createDate,jdbcType=TIMESTAMP},
</if>
<if test="updateBy != null">
#{updateBy,jdbcType=VARCHAR},
</if>
<if test="updateDate != null">
#{updateDate,jdbcType=TIMESTAMP},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.len.entity.SysJob">
update sys_job
<set>
<if test="jobName != null">
job_name = #{jobName,jdbcType=VARCHAR},
</if>
<if test="cron != null">
cron = #{cron,jdbcType=VARCHAR},
</if>
<if test="status != null">
status = #{status,jdbcType=BIT},
</if>
<if test="clazzPath != null">
clazz_path = #{clazzPath,jdbcType=VARCHAR},
</if>
<if test="jobDesc != null">
job_desc = #{jobDesc,jdbcType=VARCHAR},
</if>
<if test="createBy != null">
create_by = #{createBy,jdbcType=VARCHAR},
</if>
<if test="createDate != null">
create_date = #{createDate,jdbcType=TIMESTAMP},
</if>
<if test="updateBy != null">
update_by = #{updateBy,jdbcType=VARCHAR},
</if>
<if test="updateDate != null">
update_date = #{updateDate,jdbcType=TIMESTAMP},
</if>
</set>
where id = #{id,jdbcType=VARCHAR}
</update>
<update id="updateByPrimaryKey" parameterType="com.len.entity.SysJob">
update sys_job
set job_name = #{jobName,jdbcType=VARCHAR},
cron = #{cron,jdbcType=VARCHAR},
status = #{status,jdbcType=BIT},
clazz_path = #{clazzPath,jdbcType=VARCHAR},
job_desc = #{jobDesc,jdbcType=VARCHAR},
create_by = #{createBy,jdbcType=VARCHAR},
create_date = #{createDate,jdbcType=TIMESTAMP},
update_by = #{updateBy,jdbcType=VARCHAR},
update_date = #{updateDate,jdbcType=TIMESTAMP}
where id = #{id,jdbcType=VARCHAR}
</update>
<select id="selectListByPage" parameterType="com.len.entity.SysJob" resultMap="BaseResultMap">
SELECT <include refid="Base_Column_List"/>
from sys_job
<where>
<if test="jobName!=null and jobName!=''"> and job_name like "%" #{job_name} "%"</if>
<if test="clazzPath!=null and clazzPath!=''"> and clazz_path like "%" #{clazz_path} "%"</if>
<if test="jobDesc!=null and jobDesc!=''"> and job_desc like "%" #{job_desc} "%"</if>
<if test="status!=null and status!=''"> and status =#{status}</if>
</where>
</select>
</mapper>

View File

@ -22,7 +22,7 @@
</content> </content>
<orderEntry type="inheritedJdk" /> <orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:3.8.1" level="project" /> <orderEntry type="library" name="Maven: org.mybatis.generator:mybatis-generator-core:1.3.5" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-web:1.5.9.RELEASE" level="project" /> <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-web:1.5.9.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter:1.5.9.RELEASE" level="project" /> <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter:1.5.9.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot:1.5.9.RELEASE" level="project" /> <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot:1.5.9.RELEASE" level="project" />
@ -46,22 +46,23 @@
<orderEntry type="library" name="Maven: org.springframework:spring-expression:4.3.13.RELEASE" level="project" /> <orderEntry type="library" name="Maven: org.springframework:spring-expression:4.3.13.RELEASE" level="project" />
<orderEntry type="module" module-name="len-core" /> <orderEntry type="module" module-name="len-core" />
<orderEntry type="module" module-name="len-sys" /> <orderEntry type="module" module-name="len-sys" />
<orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-starter-test:1.5.9.RELEASE" level="project" /> <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-test:1.5.9.RELEASE" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-test:1.5.9.RELEASE" level="project" /> <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-test:1.5.9.RELEASE" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-test-autoconfigure:1.5.9.RELEASE" level="project" /> <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-test-autoconfigure:1.5.9.RELEASE" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: com.jayway.jsonpath:json-path:2.2.0" level="project" /> <orderEntry type="library" name="Maven: com.jayway.jsonpath:json-path:2.2.0" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: net.minidev:json-smart:2.2.1" level="project" /> <orderEntry type="library" name="Maven: net.minidev:json-smart:2.2.1" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: net.minidev:accessors-smart:1.1" level="project" /> <orderEntry type="library" name="Maven: net.minidev:accessors-smart:1.1" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.ow2.asm:asm:5.0.3" level="project" /> <orderEntry type="library" name="Maven: org.ow2.asm:asm:5.0.3" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.assertj:assertj-core:2.6.0" level="project" /> <orderEntry type="library" name="Maven: org.assertj:assertj-core:2.6.0" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.mockito:mockito-core:1.10.19" level="project" /> <orderEntry type="library" name="Maven: org.mockito:mockito-core:1.10.19" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.objenesis:objenesis:2.1" level="project" /> <orderEntry type="library" scope="RUNTIME" name="Maven: org.objenesis:objenesis:2.1" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" /> <orderEntry type="library" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-library:1.3" level="project" /> <orderEntry type="library" name="Maven: org.hamcrest:hamcrest-library:1.3" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.skyscreamer:jsonassert:1.4.0" level="project" /> <orderEntry type="library" name="Maven: org.skyscreamer:jsonassert:1.4.0" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: com.vaadin.external.google:android-json:0.0.20131108.vaadin1" level="project" /> <orderEntry type="library" name="Maven: com.vaadin.external.google:android-json:0.0.20131108.vaadin1" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-core:4.3.13.RELEASE" level="project" /> <orderEntry type="library" name="Maven: org.springframework:spring-core:4.3.13.RELEASE" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.springframework:spring-test:4.3.13.RELEASE" level="project" /> <orderEntry type="library" name="Maven: org.springframework:spring-test:4.3.13.RELEASE" level="project" />
<orderEntry type="library" name="Maven: junit:junit:4.12" level="project" />
<orderEntry type="library" name="Maven: org.mybatis.spring.boot:mybatis-spring-boot-starter:1.3.1" level="project" /> <orderEntry type="library" name="Maven: org.mybatis.spring.boot:mybatis-spring-boot-starter:1.3.1" level="project" />
<orderEntry type="library" name="Maven: org.mybatis.spring.boot:mybatis-spring-boot-autoconfigure:1.3.1" level="project" /> <orderEntry type="library" name="Maven: org.mybatis.spring.boot:mybatis-spring-boot-autoconfigure:1.3.1" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-cache:1.5.9.RELEASE" level="project" /> <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-cache:1.5.9.RELEASE" level="project" />
@ -109,8 +110,6 @@
<orderEntry type="library" name="Maven: log4j:log4j:1.2.17" level="project" /> <orderEntry type="library" name="Maven: log4j:log4j:1.2.17" level="project" />
<orderEntry type="library" name="Maven: com.google.zxing:javase:3.1.0" level="project" /> <orderEntry type="library" name="Maven: com.google.zxing:javase:3.1.0" level="project" />
<orderEntry type="library" name="Maven: com.google.zxing:core:3.1.0" level="project" /> <orderEntry type="library" name="Maven: com.google.zxing:core:3.1.0" level="project" />
<orderEntry type="library" name="Maven: org.quartz-scheduler:quartz:2.2.1" level="project" />
<orderEntry type="library" name="Maven: c3p0:c3p0:0.9.1.1" level="project" />
<orderEntry type="library" name="Maven: org.springframework.integration:spring-integration-mail:4.3.12.RELEASE" level="project" /> <orderEntry type="library" name="Maven: org.springframework.integration:spring-integration-mail:4.3.12.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.integration:spring-integration-core:4.3.12.RELEASE" level="project" /> <orderEntry type="library" name="Maven: org.springframework.integration:spring-integration-core:4.3.12.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-messaging:4.3.13.RELEASE" level="project" /> <orderEntry type="library" name="Maven: org.springframework:spring-messaging:4.3.13.RELEASE" level="project" />
@ -157,5 +156,10 @@
<orderEntry type="library" name="Maven: io.springfox:springfox-swagger-ui:2.7.0" level="project" /> <orderEntry type="library" name="Maven: io.springfox:springfox-swagger-ui:2.7.0" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-context-support:4.3.13.RELEASE" level="project" /> <orderEntry type="library" name="Maven: org.springframework:spring-context-support:4.3.13.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-beans:4.3.13.RELEASE" level="project" /> <orderEntry type="library" name="Maven: org.springframework:spring-beans:4.3.13.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.quartz-scheduler:quartz:2.3.0" level="project" />
<orderEntry type="library" name="Maven: com.mchange:c3p0:0.9.5.2" level="project" />
<orderEntry type="library" name="Maven: com.mchange:mchange-commons-java:0.2.11" level="project" />
<orderEntry type="library" name="Maven: com.zaxxer:HikariCP-java6:2.3.13" level="project" />
<orderEntry type="library" name="Maven: org.apache.shiro:shiro-quartz:1.2.3" level="project" />
</component> </component>
</module> </module>

View File

@ -12,13 +12,13 @@
<name>len-web Maven Webapp</name> <name>len-web Maven Webapp</name>
<url>http://maven.apache.org</url> <url>http://maven.apache.org</url>
<dependencies> <dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<!--生成代码插件-->
<dependency>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-core</artifactId>
<version>1.3.5</version>
</dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId> <artifactId>spring-boot-starter-web</artifactId>

View File

@ -1,8 +1,11 @@
package com.len; package com.len;
import java.util.Arrays;
import org.mybatis.spring.annotation.MapperScan; import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.web.servlet.config.annotation.EnableWebMvc; import org.springframework.web.servlet.config.annotation.EnableWebMvc;
/** /**
@ -17,7 +20,16 @@ import org.springframework.web.servlet.config.annotation.EnableWebMvc;
public class Application { public class Application {
public static void main(String[] args) { public static void main(String[] args) {
SpringApplication.run(Application.class,args); ApplicationContext applicationContext=SpringApplication.run(Application.class,args);
String[] names = applicationContext.getBeanDefinitionNames();
Arrays.asList(names).forEach(name -> System.out.println(name));//打印bean
/* SchedulerFactory schedulerFactory = new StdSchedulerFactory();
Scheduler scheduler = schedulerFactory.getScheduler();
JobDetail jobDetail = JobBuilder.newJob(ScheduledTasks.class).withIdentity("testkey", "testvalue").withDescription("一个测试的类").build();
jobDetail.getJobDataMap().put("ConfigurableApplicationContext",applicationContext);//重点是这句话
Trigger trigger = TriggerBuilder.newTrigger().startNow().withSchedule(CronScheduleBuilder.cronSchedule("0/1 * * * * ?")).startNow().build();
scheduler.scheduleJob(jobDetail,trigger);
scheduler.start();*/
} }
} }

View File

@ -0,0 +1,31 @@
package test;
import com.len.Application;
import com.len.entity.SysUser;
import com.len.service.SysUserService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;
/**
* @author zhuxiaomeng
* @date 2018/1/5.
* @email 154040976@qq.com
*/
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes = Application.class)
@WebAppConfiguration
public class BootTest {
@Autowired
SysUserService userService;
@Test
public void testStartJob() throws Exception {
SysUser user=userService.selectByPrimaryKey("2211fec3e17c11e795ed201a068c6482");
}
}

View File

@ -0,0 +1,17 @@
package test;
import org.mybatis.generator.api.ShellRunner;
/**
* @author zhuxiaomeng
* @date 2017/12/4.
* @email 154040976@qq.com
*/
public class MybatisApp {
public static void main(String[] args) {
args = new String[] { "-configfile", "len-web\\src\\main\\resources\\auto-config\\mybatis-config.xml", "-overwrite" };
ShellRunner.main(args);
}
}

View File

@ -0,0 +1,48 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE generatorConfiguration PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
"http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd" >
<generatorConfiguration>
<context id="prod">
<!-- RowBounds pagination -->
<plugin type="org.mybatis.generator.plugins.RowBoundsPlugin" />
<plugin type="org.mybatis.generator.plugins.CaseInsensitiveLikePlugin" />
<plugin type="org.mybatis.generator.plugins.SerializablePlugin" />
<commentGenerator>
<property name="suppressDate" value="true" />
<property name="suppressAllComments" value="true" />
</commentGenerator>
<!-- jdbc连接 -->
<jdbcConnection driverClass="com.mysql.jdbc.Driver"
connectionURL="jdbc:mysql://localhost:3306/lenos" userId="root"
password="" />
<!--mode-->
<javaModelGenerator targetPackage="com.len.entity"
targetProject="len-sys/src/main/java">
<property name="enableSubPackages" value="true"/>
<property name="trimStrings" value="true" />
</javaModelGenerator>
<!--生成映射文件存放位置-->
<sqlMapGenerator targetPackage="com.len.mapper" targetProject="len-sys/src/main/java" >
<property name="enableSubPackages" value="true"/>
</sqlMapGenerator>
<!--生成Dao类存放位置-->
<javaClientGenerator targetPackage="com.len.mapper"
targetProject="len-sys/src/main/java" type="XMLMAPPER" >
<property name="enableSubPackages" value="true"/>
</javaClientGenerator>
<!--生成table 先建表 后生成 勿随意覆盖本身table 避免功能缺失 测试 自己找其他表测试 by zxm-->
<!--<table tableName="sys_user" domainObjectName="SysUser"/>-->
<!-- <table tableName="sys_job" domainObjectName="SysJob"
enableCountByExample="false"
enableUpdateByExample="false"
enableDeleteByExample="false"
enableSelectByExample="false"
selectByExampleQueryId="false"
/>-->
</context>
</generatorConfiguration>

View File

@ -0,0 +1,40 @@
# 固定前缀org.quartz
# 主要分为scheduler、threadPool、jobStore、plugin等部分
#
#
org.quartz.scheduler.instanceName = DefaultQuartzScheduler
org.quartz.scheduler.rmi.export = false
org.quartz.scheduler.rmi.proxy = false
org.quartz.scheduler.wrapJobExecutionInUserTransaction = false
# 实例化ThreadPool时使用的线程类为SimpleThreadPool
org.quartz.threadPool.class = org.quartz.simpl.SimpleThreadPool
# threadCount和threadPriority将以setter的形式注入ThreadPool实例
# 并发个数
org.quartz.threadPool.threadCount = 5
# 优先级
org.quartz.threadPool.threadPriority = 5
org.quartz.threadPool.threadsInheritContextClassLoaderOfInitializingThread = true
org.quartz.jobStore.misfireThreshold = 5000
# 默认存储在内存中
#org.quartz.jobStore.class = org.quartz.simpl.RAMJobStore
#持久化
org.quartz.jobStore.class = org.quartz.impl.jdbcjobstore.JobStoreTX
org.quartz.jobStore.tablePrefix = QRTZ_
org.quartz.jobStore.dataSource = qzDS
org.quartz.dataSource.qzDS.driver = com.mysql.jdbc.Driver
org.quartz.dataSource.qzDS.URL = jdbc:mysql://190.0.1.88:3306/hello_test?useUnicode=true&characterEncoding=UTF-8
org.quartz.dataSource.qzDS.user = root
org.quartz.dataSource.qzDS.password = root
org.quartz.dataSource.qzDS.maxConnections = 10

View File

@ -13,24 +13,24 @@
</content> </content>
<orderEntry type="inheritedJdk" /> <orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-starter-test:1.5.9.RELEASE" level="project" /> <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-test:1.5.9.RELEASE" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-test:1.5.9.RELEASE" level="project" /> <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-test:1.5.9.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot:1.5.9.RELEASE" level="project" /> <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot:1.5.9.RELEASE" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-test-autoconfigure:1.5.9.RELEASE" level="project" /> <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-test-autoconfigure:1.5.9.RELEASE" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: com.jayway.jsonpath:json-path:2.2.0" level="project" /> <orderEntry type="library" name="Maven: com.jayway.jsonpath:json-path:2.2.0" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: net.minidev:json-smart:2.2.1" level="project" /> <orderEntry type="library" name="Maven: net.minidev:json-smart:2.2.1" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: net.minidev:accessors-smart:1.1" level="project" /> <orderEntry type="library" name="Maven: net.minidev:accessors-smart:1.1" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.ow2.asm:asm:5.0.3" level="project" /> <orderEntry type="library" name="Maven: org.ow2.asm:asm:5.0.3" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.12" level="project" /> <orderEntry type="library" name="Maven: org.assertj:assertj-core:2.6.0" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.assertj:assertj-core:2.6.0" level="project" /> <orderEntry type="library" name="Maven: org.mockito:mockito-core:1.10.19" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.mockito:mockito-core:1.10.19" level="project" /> <orderEntry type="library" scope="RUNTIME" name="Maven: org.objenesis:objenesis:2.1" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.objenesis:objenesis:2.1" level="project" /> <orderEntry type="library" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" /> <orderEntry type="library" name="Maven: org.hamcrest:hamcrest-library:1.3" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-library:1.3" level="project" /> <orderEntry type="library" name="Maven: org.skyscreamer:jsonassert:1.4.0" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.skyscreamer:jsonassert:1.4.0" level="project" /> <orderEntry type="library" name="Maven: com.vaadin.external.google:android-json:0.0.20131108.vaadin1" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: com.vaadin.external.google:android-json:0.0.20131108.vaadin1" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-core:4.3.13.RELEASE" level="project" /> <orderEntry type="library" name="Maven: org.springframework:spring-core:4.3.13.RELEASE" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.springframework:spring-test:4.3.13.RELEASE" level="project" /> <orderEntry type="library" name="Maven: org.springframework:spring-test:4.3.13.RELEASE" level="project" />
<orderEntry type="library" name="Maven: junit:junit:4.12" level="project" />
<orderEntry type="library" name="Maven: org.mybatis.spring.boot:mybatis-spring-boot-starter:1.3.1" level="project" /> <orderEntry type="library" name="Maven: org.mybatis.spring.boot:mybatis-spring-boot-starter:1.3.1" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter:1.5.9.RELEASE" level="project" /> <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter:1.5.9.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-logging:1.5.9.RELEASE" level="project" /> <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-logging:1.5.9.RELEASE" level="project" />
@ -98,8 +98,6 @@
<orderEntry type="library" name="Maven: log4j:log4j:1.2.17" level="project" /> <orderEntry type="library" name="Maven: log4j:log4j:1.2.17" level="project" />
<orderEntry type="library" name="Maven: com.google.zxing:javase:3.1.0" level="project" /> <orderEntry type="library" name="Maven: com.google.zxing:javase:3.1.0" level="project" />
<orderEntry type="library" name="Maven: com.google.zxing:core:3.1.0" level="project" /> <orderEntry type="library" name="Maven: com.google.zxing:core:3.1.0" level="project" />
<orderEntry type="library" name="Maven: org.quartz-scheduler:quartz:2.2.1" level="project" />
<orderEntry type="library" name="Maven: c3p0:c3p0:0.9.1.1" level="project" />
<orderEntry type="library" name="Maven: org.springframework.integration:spring-integration-mail:4.3.12.RELEASE" level="project" /> <orderEntry type="library" name="Maven: org.springframework.integration:spring-integration-mail:4.3.12.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.integration:spring-integration-core:4.3.12.RELEASE" level="project" /> <orderEntry type="library" name="Maven: org.springframework.integration:spring-integration-core:4.3.12.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-messaging:4.3.13.RELEASE" level="project" /> <orderEntry type="library" name="Maven: org.springframework:spring-messaging:4.3.13.RELEASE" level="project" />
@ -146,5 +144,10 @@
<orderEntry type="library" name="Maven: io.springfox:springfox-swagger-ui:2.7.0" level="project" /> <orderEntry type="library" name="Maven: io.springfox:springfox-swagger-ui:2.7.0" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-context-support:4.3.13.RELEASE" level="project" /> <orderEntry type="library" name="Maven: org.springframework:spring-context-support:4.3.13.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-beans:4.3.13.RELEASE" level="project" /> <orderEntry type="library" name="Maven: org.springframework:spring-beans:4.3.13.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.quartz-scheduler:quartz:2.3.0" level="project" />
<orderEntry type="library" name="Maven: com.mchange:c3p0:0.9.5.2" level="project" />
<orderEntry type="library" name="Maven: com.mchange:mchange-commons-java:0.2.11" level="project" />
<orderEntry type="library" name="Maven: com.zaxxer:HikariCP-java6:2.3.13" level="project" />
<orderEntry type="library" name="Maven: org.apache.shiro:shiro-quartz:1.2.3" level="project" />
</component> </component>
</module> </module>

39
pom.xml
View File

@ -30,8 +30,11 @@
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId> <artifactId>spring-boot-starter-test</artifactId>
<!-- 只在test测试里面运行 --> </dependency>
<scope>test</scope> <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency> </dependency>
<dependency> <dependency>
@ -225,6 +228,38 @@
<artifactId>spring-context-support</artifactId> <artifactId>spring-context-support</artifactId>
</dependency> </dependency>
<!-- &lt;!&ndash; https://mvnrepository.com/artifact/org.quartz-scheduler/quartz &ndash;&gt;
<dependency>
<groupId>org.quartz-scheduler</groupId>
<artifactId>quartz</artifactId>
<version>1.8.6</version>
</dependency>-->
<!-- https://mvnrepository.com/artifact/org.quartz-scheduler/quartz -->
<dependency>
<groupId>org.quartz-scheduler</groupId>
<artifactId>quartz</artifactId>
<version>2.3.0</version>
</dependency>
<!--
<dependency>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-core</artifactId>
</dependency>-->
<dependency>
<groupId>org.apache.shiro</groupId>
<artifactId>shiro-quartz</artifactId>
<version>1.2.3</version>
<!-- 解决 shiro和quartz 冲突-->
<exclusions>
<exclusion>
<groupId>org.opensymphony.quartz</groupId>
<artifactId>quartz</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies> </dependencies>
<dependencyManagement> <dependencyManagement>