Kaynağa Gözat

init project
已完成一键刷单页面开发

xiaoyuzhang 3 hafta önce
işleme
bb04a7ecb6

+ 42 - 0
.gitignore

@@ -0,0 +1,42 @@
1
+.DS_Store
2
+*/.DS_Store
3
+HELP.md
4
+target/
5
+logs/
6
+!.mvn/wrapper/maven-wrapper.jar
7
+!**/src/main/**/target/
8
+!**/src/test/**/target/
9
+log/
10
+/db/*.sql
11
+
12
+### STS ###
13
+.apt_generated
14
+.classpath
15
+.factorypath
16
+.project
17
+.settings
18
+.springBeans
19
+.sts4-cache
20
+
21
+### IntelliJ IDEA ###
22
+.idea
23
+*.iws
24
+*.iml
25
+*.ipr
26
+
27
+### NetBeans ###
28
+/nbproject/private/
29
+/nbbuild/
30
+/dist/
31
+/nbdist/
32
+/.nb-gradle/
33
+build/
34
+!**/src/main/**/build/
35
+!**/src/test/**/build/
36
+
37
+### VS Code ###
38
+.vscode/
39
+/src/main/java/com/semsx/common/config/InterceptorConfig.java
40
+/src/main/java/com/semsx/common/interceptor/PermsMethodInterceptor.java
41
+/src/main/resources/banner.txt
42
+/src/test/java/com/semsx/JavaTest.java

+ 127 - 0
pom.xml

@@ -0,0 +1,127 @@
1
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3
+  <modelVersion>4.0.0</modelVersion>
4
+
5
+  <groupId>cn.mrdear</groupId>
6
+  <artifactId>mrdear</artifactId>
7
+  <version>1.0-SNAPSHOT</version>
8
+  <packaging>jar</packaging>
9
+
10
+  <name>fakeMes</name>
11
+  <url>http://maven.apache.org</url>
12
+
13
+  <properties>
14
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
15
+    <java.version>1.8</java.version>
16
+  </properties>
17
+
18
+  <parent>
19
+    <groupId>org.springframework.boot</groupId>
20
+    <artifactId>spring-boot-starter-parent</artifactId>
21
+    <version>1.4.0.RELEASE</version>
22
+  </parent>
23
+
24
+
25
+  <dependencies>
26
+
27
+    <!--spring boot start-->
28
+    <dependency>
29
+      <groupId>org.springframework.boot</groupId>
30
+      <artifactId>spring-boot-starter-thymeleaf</artifactId>
31
+    </dependency>
32
+    <!--mybatis start-->
33
+    <dependency>
34
+      <groupId>org.mybatis.spring.boot</groupId>
35
+      <artifactId>mybatis-spring-boot-starter</artifactId>
36
+      <version>1.1.1</version>
37
+    </dependency>
38
+    <dependency>
39
+      <groupId>com.github.pagehelper</groupId>
40
+      <artifactId>pagehelper</artifactId>
41
+      <version>4.1.3</version>
42
+    </dependency>
43
+    <dependency>
44
+      <groupId>org.mybatis.caches</groupId>
45
+      <artifactId>mybatis-ehcache</artifactId>
46
+      <version>1.0.3</version>
47
+    </dependency>
48
+    <!--mybatis end-->
49
+
50
+    <!--spring boot end-->
51
+
52
+    <!--ehcache start-->
53
+    <dependency>
54
+      <groupId>net.sf.ehcache</groupId>
55
+      <artifactId>ehcache</artifactId>
56
+    </dependency>
57
+    <dependency>
58
+      <groupId>net.sf.ehcache</groupId>
59
+      <artifactId>ehcache-web</artifactId>
60
+      <version>2.0.4</version>
61
+    </dependency>
62
+    <!--ehcache end-->
63
+
64
+    <!--druid start-->
65
+    <dependency>
66
+      <groupId>com.alibaba</groupId>
67
+      <artifactId>druid</artifactId>
68
+      <version>1.0.19</version>
69
+    </dependency>
70
+    <!--druid end-->
71
+
72
+    <!--mysql start-->
73
+    <dependency>
74
+      <groupId>mysql</groupId>
75
+      <artifactId>mysql-connector-java</artifactId>
76
+      <version>5.1.34</version>
77
+    </dependency>
78
+    <!--mysql end-->
79
+    <dependency>
80
+      <groupId>org.postgresql</groupId>
81
+      <artifactId>postgresql</artifactId>
82
+      <version>42.3.1</version> <!-- 使用最新版本或适合你的 PostgreSQL 数据库服务器的版本 -->
83
+    </dependency>
84
+
85
+    <!--fast json start-->
86
+    <dependency>
87
+      <groupId>com.alibaba</groupId>
88
+      <artifactId>fastjson</artifactId>
89
+      <version>1.2.14</version>
90
+    </dependency>
91
+    <!--fast json end-->
92
+
93
+    <!--junit start-->
94
+    <dependency>
95
+      <groupId>junit</groupId>
96
+      <artifactId>junit</artifactId>
97
+      <version>4.10</version>
98
+      <scope>test</scope>
99
+    </dependency>
100
+    <!--junit end-->
101
+    <dependency>
102
+      <groupId>ch.qos.logback</groupId>
103
+      <artifactId>logback-classic</artifactId>
104
+    </dependency>
105
+
106
+  </dependencies>
107
+  <build>
108
+    <finalName>fakeMes</finalName>
109
+    <!--spring boot plugin start-->
110
+    <plugins>
111
+      <plugin>
112
+        <groupId>org.springframework.boot</groupId>
113
+        <artifactId>spring-boot-maven-plugin</artifactId>
114
+        <!--配置热部署-->
115
+        <dependencies>
116
+          <dependency>
117
+            <groupId>org.springframework</groupId>
118
+            <artifactId>springloaded</artifactId>
119
+            <version>1.2.0.RELEASE</version>
120
+          </dependency>
121
+        </dependencies>
122
+      </plugin>
123
+    </plugins>
124
+    <!--spring boot plugin end-->
125
+
126
+  </build>
127
+</project>

+ 18 - 0
src/main/java/cn/mrdear/Application.java

@@ -0,0 +1,18 @@
1
+package cn.mrdear;
2
+
3
+import org.springframework.boot.SpringApplication;
4
+import org.springframework.boot.autoconfigure.SpringBootApplication;
5
+
6
+/**
7
+ * 默认启动类
8
+ */
9
+@SpringBootApplication
10
+public class Application
11
+{
12
+    public static void main( String[] args )
13
+    {
14
+        System.setProperty("net.sf.ehcache.skipUpdateCheck", "true");
15
+        SpringApplication.run(Application.class, args);
16
+    }
17
+
18
+}

+ 92 - 0
src/main/java/cn/mrdear/conf/DataSourcesConfig.java

@@ -0,0 +1,92 @@
1
+package cn.mrdear.conf;
2
+
3
+import com.alibaba.druid.pool.DruidDataSource;
4
+import com.alibaba.druid.support.http.StatViewServlet;
5
+import com.alibaba.druid.support.http.WebStatFilter;
6
+import org.springframework.boot.web.servlet.FilterRegistrationBean;
7
+import org.springframework.boot.web.servlet.ServletRegistrationBean;
8
+import org.springframework.context.annotation.Bean;
9
+import org.springframework.context.annotation.Configuration;
10
+import org.springframework.context.annotation.Primary;
11
+
12
+import java.sql.SQLException;
13
+
14
+/**
15
+ * @author Niu Li
16
+ * @date 2016/8/12
17
+ */
18
+@Configuration
19
+public class DataSourcesConfig {
20
+    /**
21
+     * druid初始化
22
+     * @return
23
+     * @throws SQLException
24
+     */
25
+    @Primary //默认数据源
26
+    @Bean(name = "dataSource",destroyMethod = "close")
27
+    public DruidDataSource Construction() throws SQLException {
28
+        DruidDataSource dataSource = new DruidDataSource();
29
+        dataSource.setUrl("jdbc:postgresql://192.168.40.101:5432/mes");
30
+        dataSource.setUsername("postgres");
31
+        dataSource.setPassword("123456");
32
+        dataSource.setDriverClassName("org.postgresql.Driver");
33
+        //配置最大连接
34
+        dataSource.setMaxActive(20);
35
+        //配置初始连接
36
+        dataSource.setInitialSize(1);
37
+        //配置最小连接
38
+        dataSource.setMinIdle(1);
39
+        //连接等待超时时间
40
+        dataSource.setMaxWait(60000);
41
+        //间隔多久进行检测,关闭空闲连接
42
+        dataSource.setTimeBetweenEvictionRunsMillis(60000);
43
+        //一个连接最小生存时间
44
+        dataSource.setMinEvictableIdleTimeMillis(300000);
45
+        //用来检测是否有效的sql
46
+//        dataSource.setValidationQuery("select 'x'");
47
+        dataSource.setTestWhileIdle(true);
48
+        dataSource.setTestOnBorrow(false);
49
+        dataSource.setTestOnReturn(false);
50
+        //打开PSCache,并指定每个连接的PSCache大小
51
+        dataSource.setPoolPreparedStatements(true);
52
+        dataSource.setMaxOpenPreparedStatements(20);
53
+        //配置sql监控的filter
54
+        dataSource.setFilters("stat,wall,log4j");
55
+        try {
56
+            dataSource.init();
57
+        } catch (SQLException e) {
58
+            throw new RuntimeException("druid datasource init fail");
59
+        }
60
+        return dataSource;
61
+    }
62
+
63
+    /**
64
+     * druid监控
65
+     * @return
66
+     */
67
+    @Bean
68
+    public ServletRegistrationBean druidServlet() {
69
+        ServletRegistrationBean reg = new ServletRegistrationBean();
70
+        reg.setServlet(new StatViewServlet());
71
+        reg.addUrlMappings("/druid/*");
72
+        //reg.addInitParameter("allow", "127.0.0.1");
73
+        //reg.addInitParameter("deny","");
74
+        reg.addInitParameter("loginUsername", "niuli");
75
+        reg.addInitParameter("loginPassword", "123456");
76
+        return reg;
77
+    }
78
+
79
+    /**
80
+     * druid监控过滤
81
+     * @return
82
+     */
83
+    @Bean
84
+    public FilterRegistrationBean filterRegistrationBean() {
85
+        FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean();
86
+        filterRegistrationBean.setFilter(new WebStatFilter());
87
+        filterRegistrationBean.addUrlPatterns("/*");
88
+        filterRegistrationBean.addInitParameter("exclusions", "*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*");
89
+        return filterRegistrationBean;
90
+    }
91
+
92
+}

+ 48 - 0
src/main/java/cn/mrdear/conf/FilterConfig.java

@@ -0,0 +1,48 @@
1
+package cn.mrdear.conf;
2
+
3
+import net.sf.ehcache.constructs.web.filter.GzipFilter;
4
+import net.sf.ehcache.constructs.web.filter.SimplePageCachingFilter;
5
+
6
+import org.springframework.boot.web.servlet.FilterRegistrationBean;
7
+import org.springframework.context.annotation.Bean;
8
+import org.springframework.context.annotation.Configuration;
9
+
10
+import java.util.Arrays;
11
+import java.util.HashMap;
12
+import java.util.Map;
13
+
14
+/**
15
+ * 定义一些Filter使用
16
+ * @author Niu Li
17
+ * @date 2016/8/13
18
+ */
19
+@Configuration
20
+public class FilterConfig {
21
+    /**
22
+     * 配置ehcache的Gzip压缩
23
+     * @return
24
+     */
25
+    @Bean
26
+    public FilterRegistrationBean gzipFilter(){
27
+        FilterRegistrationBean gzipFilter = new FilterRegistrationBean(new GzipFilter());
28
+        String[] arrs = {"*.js","*.css","*.json","*.html"};
29
+        gzipFilter.setUrlPatterns(Arrays.asList(arrs));
30
+        return gzipFilter;
31
+    }
32
+    /**
33
+     * 配置页面缓存,页面缓存会自动开启GZIP压缩
34
+     */
35
+    @Bean
36
+    public FilterRegistrationBean helloFilter(){
37
+        FilterRegistrationBean helloFilter = new FilterRegistrationBean(new SimplePageCachingFilter());
38
+        Map<String,String> maps = new HashMap<>();
39
+        //设置参数
40
+        maps.put("cacheName","hello");
41
+        helloFilter.setInitParameters(maps);
42
+        //设置路径
43
+        String[] arrs = {"/hello"};
44
+        helloFilter.setUrlPatterns(Arrays.asList(arrs));
45
+        return helloFilter;
46
+    }
47
+
48
+}

+ 90 - 0
src/main/java/cn/mrdear/conf/MybatisConfig.java

@@ -0,0 +1,90 @@
1
+package cn.mrdear.conf;
2
+
3
+import com.github.pagehelper.PageHelper;
4
+
5
+import org.apache.ibatis.plugin.Interceptor;
6
+import org.apache.ibatis.session.SqlSessionFactory;
7
+import org.mybatis.spring.SqlSessionFactoryBean;
8
+import org.mybatis.spring.SqlSessionTemplate;
9
+import org.springframework.context.annotation.Bean;
10
+import org.springframework.context.annotation.Configuration;
11
+import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
12
+import org.springframework.core.io.support.ResourcePatternResolver;
13
+import org.springframework.jdbc.datasource.DataSourceTransactionManager;
14
+import org.springframework.transaction.PlatformTransactionManager;
15
+import org.springframework.transaction.annotation.EnableTransactionManagement;
16
+import org.springframework.transaction.annotation.TransactionManagementConfigurer;
17
+
18
+import java.util.Properties;
19
+
20
+import javax.annotation.Resource;
21
+import javax.sql.DataSource;
22
+
23
+/**
24
+ * mybatis配置类
25
+ * @author Niu Li
26
+ * @date 2016/8/12
27
+ */
28
+@Configuration
29
+@EnableTransactionManagement
30
+public class MybatisConfig implements TransactionManagementConfigurer{
31
+    @Resource(name = "dataSource")
32
+    DataSource dataSource;
33
+
34
+    /**
35
+     * 可以通过这个类,详细配置mybatis
36
+     * @return
37
+     */
38
+//    @Bean
39
+//    public org.apache.ibatis.session.Configuration mybatisSetting(){
40
+//        org.apache.ibatis.session.Configuration configuration = new org.apache.ibatis.session.Configuration();
41
+//        return configuration;
42
+//    }
43
+
44
+    @Bean(name = "sqlSessionFactory")
45
+    public SqlSessionFactory sqlSessionFactoryBean() {
46
+
47
+        SqlSessionFactoryBean bean = new SqlSessionFactoryBean();
48
+        bean.setDataSource(dataSource);
49
+        bean.setTypeAliasesPackage("cn.mrdear.entity");
50
+
51
+        //分页插件,插件无非是设置mybatis的拦截器
52
+        PageHelper pageHelper = new PageHelper();
53
+        Properties properties = new Properties();
54
+        properties.setProperty("reasonable", "true");
55
+        properties.setProperty("supportMethodsArguments", "true");
56
+        properties.setProperty("returnPageInfo", "check");
57
+        properties.setProperty("params", "count=countSql");
58
+        pageHelper.setProperties(properties);
59
+
60
+        //添加插件
61
+        bean.setPlugins(new Interceptor[]{pageHelper});
62
+
63
+        //添加XML目录
64
+        ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
65
+        try {
66
+            bean.setMapperLocations(resolver.getResources("classpath:mapper/*.xml"));
67
+            return bean.getObject();
68
+        } catch (Exception e) {
69
+            throw new RuntimeException("sqlSessionFactory init fail",e);
70
+        }
71
+    }
72
+
73
+    /**
74
+     * 用于实际查询的sql工具,传统dao开发形式可以使用这个,基于mapper代理则不需要注入
75
+     * @param sqlSessionFactory
76
+     * @return
77
+     */
78
+    @Bean(name = "sqlSessionTemplate")
79
+    public SqlSessionTemplate sqlSessionTemplate(SqlSessionFactory sqlSessionFactory) {
80
+        return new SqlSessionTemplate(sqlSessionFactory);
81
+    }
82
+    /**
83
+     * 事务管理,具体使用在service层加入@Transactional注解
84
+     */
85
+    @Bean(name = "transactionManager")
86
+    @Override
87
+    public PlatformTransactionManager annotationDrivenTransactionManager() {
88
+        return new DataSourceTransactionManager(dataSource);
89
+    }
90
+}

+ 13 - 0
src/main/java/cn/mrdear/conf/ServletConfig.java

@@ -0,0 +1,13 @@
1
+package cn.mrdear.conf;
2
+
3
+import org.springframework.context.annotation.Configuration;
4
+
5
+/**
6
+ * 定义一些servlet使用
7
+ * @author Niu Li
8
+ * @date 2016/8/13
9
+ */
10
+@Configuration
11
+public class ServletConfig {
12
+
13
+}

+ 31 - 0
src/main/java/cn/mrdear/conf/WEBMessageConvert.java

@@ -0,0 +1,31 @@
1
+package cn.mrdear.conf;
2
+
3
+import com.alibaba.fastjson.serializer.SerializerFeature;
4
+import com.alibaba.fastjson.support.config.FastJsonConfig;
5
+import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter;
6
+import org.springframework.boot.autoconfigure.web.HttpMessageConverters;
7
+import org.springframework.context.annotation.Bean;
8
+import org.springframework.context.annotation.Configuration;
9
+import org.springframework.http.converter.HttpMessageConverter;
10
+
11
+/**
12
+ * 使用fastjson作为消息转换器
13
+ * @author Niu Li
14
+ * @date 2016/8/9
15
+ */
16
+@Configuration
17
+public class WEBMessageConvert {
18
+    /**
19
+     * 使用bean注入,才能使其有效果,验证的话就在Entity字段中使用fastjson的
20
+     * 注解@JSONField(serialize = false),转换出来的信息不含该字段,则成功
21
+     * @return
22
+     */
23
+    @Bean
24
+    public HttpMessageConverters customConverters() {
25
+        FastJsonHttpMessageConverter fastConverter = new FastJsonHttpMessageConverter();
26
+        FastJsonConfig fastJsonConfig = new FastJsonConfig();
27
+        fastJsonConfig.setSerializerFeatures(SerializerFeature.PrettyFormat);
28
+        fastConverter.setFastJsonConfig(fastJsonConfig);
29
+        return new HttpMessageConverters((HttpMessageConverter<?>) fastConverter);
30
+    }
31
+}

+ 48 - 0
src/main/java/cn/mrdear/controller/ExeOrderController.java

@@ -0,0 +1,48 @@
1
+package cn.mrdear.controller;
2
+
3
+import cn.mrdear.mapper.JobOrderMapper;
4
+import org.slf4j.Logger;
5
+import org.slf4j.LoggerFactory;
6
+import org.springframework.beans.factory.annotation.Autowired;
7
+import org.springframework.stereotype.Controller;
8
+import org.springframework.transaction.annotation.Transactional;
9
+import org.springframework.web.bind.annotation.RequestMapping;
10
+import org.springframework.web.bind.annotation.RequestMethod;
11
+import org.springframework.web.bind.annotation.ResponseBody;
12
+
13
+import java.util.Calendar;
14
+import java.util.HashMap;
15
+import java.util.Map;
16
+
17
+/**
18
+ * @Author: zxy
19
+ * @Date: create in 2025/4/2 10:10
20
+ */
21
+@Controller
22
+public class ExeOrderController {
23
+    private Logger logger = LoggerFactory.getLogger(ExeOrderController.class);
24
+
25
+    @Autowired
26
+    JobOrderMapper jobOrderMapper;
27
+
28
+    @RequestMapping(value = "/execOrder",method = RequestMethod.GET)
29
+    public String execOrder() {
30
+        return "execOrder";
31
+    }
32
+
33
+
34
+    @RequestMapping(value = "/runJobOrder",method = RequestMethod.POST)
35
+    @ResponseBody
36
+    @Transactional(rollbackFor = Exception.class)
37
+    public Map<String,Object> runJobOrder(){
38
+        int currentYear = Calendar.getInstance().get(Calendar.YEAR);
39
+        String jobOrderExeTableName = "emeso_job_order_exe_" + currentYear;
40
+        String jobOrderTableName = "emeso_job_order_" + currentYear;
41
+        jobOrderMapper.updateJobOrderExe(jobOrderExeTableName);
42
+        int orderCount = jobOrderMapper.updateJobOrder(jobOrderTableName);
43
+        Map<String, Object> resultMap = new HashMap<>();
44
+        resultMap.put("order_count",orderCount);
45
+        logger.warn("刷单条数:----》" + orderCount);
46
+        return resultMap;
47
+    }
48
+}

+ 16 - 0
src/main/java/cn/mrdear/controller/FirstController.java

@@ -0,0 +1,16 @@
1
+package cn.mrdear.controller;
2
+
3
+import org.springframework.stereotype.Controller;
4
+import org.springframework.web.bind.annotation.RequestMapping;
5
+
6
+/**
7
+ * @Author: zxy
8
+ * @Date: create in 2025/4/2 9:04
9
+ */
10
+@Controller
11
+public class FirstController {
12
+    @RequestMapping("/index")
13
+    public String toFirstHtml(){
14
+        return "index";
15
+    }
16
+}

+ 42 - 0
src/main/java/cn/mrdear/controller/HelloController.java

@@ -0,0 +1,42 @@
1
+package cn.mrdear.controller;
2
+
3
+import cn.mrdear.entity.User;
4
+import cn.mrdear.mapper.UserMapper;
5
+import org.slf4j.Logger;
6
+import org.slf4j.LoggerFactory;
7
+import org.springframework.stereotype.Controller;
8
+import org.springframework.ui.Model;
9
+import org.springframework.web.bind.annotation.RequestMapping;
10
+import org.springframework.web.bind.annotation.RequestMethod;
11
+import org.springframework.web.bind.annotation.ResponseBody;
12
+
13
+import javax.annotation.Resource;
14
+
15
+/**
16
+ * @author Niu Li
17
+ * @date 2016/8/9
18
+ */
19
+@Controller
20
+public class HelloController {
21
+
22
+    private Logger logger = LoggerFactory.getLogger(HelloController.class);
23
+    @Resource
24
+    private UserMapper userMapper;
25
+    /**
26
+     * 测试hello
27
+     * @return
28
+     */
29
+    @RequestMapping(value = "/hello",method = RequestMethod.GET)
30
+    public String hello(Model model) {
31
+        model.addAttribute("name", "Dear");
32
+        logger.warn("12313");
33
+        return "hello";
34
+    }
35
+
36
+    @RequestMapping(value = "/users",method = RequestMethod.GET)
37
+    public @ResponseBody User testUserDao(){
38
+        User user = userMapper.findById("B408A43C5A1C405DA4E909A78266F187");
39
+        return user;
40
+    }
41
+
42
+}

+ 29 - 0
src/main/java/cn/mrdear/entity/User.java

@@ -0,0 +1,29 @@
1
+package cn.mrdear.entity;
2
+
3
+import java.io.Serializable;
4
+
5
+/**
6
+ * 用户实体类
7
+ * @author Niu Li
8
+ * @date 2016/8/12
9
+ */
10
+public class User implements Serializable{
11
+    private String ad_alert_id;
12
+    private String description;
13
+
14
+    public String getAd_alert_id() {
15
+        return ad_alert_id;
16
+    }
17
+
18
+    public void setAd_alert_id(String ad_alert_id) {
19
+        this.ad_alert_id = ad_alert_id;
20
+    }
21
+
22
+    public String getDescription() {
23
+        return description;
24
+    }
25
+
26
+    public void setDescription(String description) {
27
+        this.description = description;
28
+    }
29
+}

+ 32 - 0
src/main/java/cn/mrdear/exception/PageException.java

@@ -0,0 +1,32 @@
1
+package cn.mrdear.exception;
2
+
3
+import org.slf4j.Logger;
4
+import org.slf4j.LoggerFactory;
5
+import org.springframework.web.bind.annotation.ControllerAdvice;
6
+import org.springframework.web.servlet.HandlerExceptionResolver;
7
+import org.springframework.web.servlet.ModelAndView;
8
+
9
+import javax.servlet.http.HttpServletRequest;
10
+import javax.servlet.http.HttpServletResponse;
11
+
12
+/**
13
+ * 自定义异常类
14
+ * @author Niu Li
15
+ * @date 2016/8/10
16
+ */
17
+@ControllerAdvice//配置文件没了,所以使用注解让spring管理
18
+public class PageException implements HandlerExceptionResolver {
19
+
20
+    private Logger logger = LoggerFactory.getLogger(PageException.class);
21
+
22
+    @Override
23
+    public ModelAndView resolveException(HttpServletRequest Request, HttpServletResponse Response, Object o, Exception ex) {
24
+        logger.warn("==============异常开始=============");
25
+        logger.error("异常:",ex);
26
+        logger.warn("==============异常结束=============");
27
+        ModelAndView mv = new ModelAndView();
28
+        mv.addObject("error", ex.getMessage());
29
+        mv.setViewName("error");
30
+        return mv;
31
+    }
32
+}

+ 16 - 0
src/main/java/cn/mrdear/mapper/JobOrderMapper.java

@@ -0,0 +1,16 @@
1
+package cn.mrdear.mapper;
2
+
3
+import org.apache.ibatis.annotations.Mapper;
4
+import org.apache.ibatis.annotations.Param;
5
+
6
+import java.util.Map;
7
+
8
+/**
9
+ * @Author: zxy
10
+ * @Date: create in 2025/4/2 14:08
11
+ */
12
+@Mapper
13
+public interface JobOrderMapper {
14
+    int updateJobOrderExe(@Param("tableName") String tableName);
15
+    int updateJobOrder(@Param("tableName") String tableName);
16
+}

+ 19 - 0
src/main/java/cn/mrdear/mapper/UserMapper.java

@@ -0,0 +1,19 @@
1
+package cn.mrdear.mapper;
2
+
3
+import cn.mrdear.entity.User;
4
+import org.apache.ibatis.annotations.Mapper;
5
+
6
+/**
7
+ * UserMapper.xml代理
8
+ * @author Niu Li
9
+ * @date 2016/8/13
10
+ */
11
+@Mapper
12
+public interface UserMapper {
13
+    /**
14
+     * 根据id查询用户
15
+     * @param id
16
+     * @return
17
+     */
18
+    User findById(String id);
19
+}

+ 24 - 0
src/main/resources/application.properties

@@ -0,0 +1,24 @@
1
+#logger start
2
+logging.path = logs/loging.log
3
+logging.level.org.springframework.web = info
4
+logging.level.cn.mrdear = debug
5
+logging.level.net.sf.ehcache = debug
6
+logging.level.org.mybatis.caches = debug
7
+#logger end
8
+
9
+#thymeleaf start
10
+spring.thymeleaf.mode=HTML5
11
+spring.thymeleaf.encoding=UTF-8
12
+spring.thymeleaf.prefix=classpath:/templates/
13
+spring.thymeleaf.suffix=.html
14
+spring.thymeleaf.content-type=text/html
15
+spring.thymeleaf.cache=false
16
+
17
+
18
+#thymeleaf end
19
+server.port=8077
20
+spring.mvc.view.prefix=/templates/
21
+spring.mvc.view.suffix=.html
22
+logging.config=classpath:logback-spring.xml
23
+spring.jpa.show-sql=true
24
+logging.level.org.apache.ibatis=debug

+ 19 - 0
src/main/resources/ehcache.xml

@@ -0,0 +1,19 @@
1
+<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://ehcache.org/ehcache.xsd">
2
+    <diskStore path="E:\test" />
3
+    <!--
4
+    name:Cache的唯一标识
5
+    maxElementsInMemory:内存中最大缓存对象数
6
+    maxElementsOnDisk:磁盘中最大缓存对象数,若是0表示无穷大
7
+    eternal:Element是否永久有效,一但设置了,timeout将不起作用
8
+    overflowToDisk:配置此属性,当内存中Element数量达到maxElementsInMemory时,Ehcache将会Element写到磁盘中
9
+    timeToIdleSeconds:设置Element在失效前的允许闲置时间。仅当element不是永久有效时使用,可选属性,默认值是0,也就是可闲置时间无穷大
10
+    timeToLiveSeconds:设置Element在失效前允许存活时间。最大时间介于创建时间和失效时间之间。仅当element不是永久有效时使用,默认是0.,也就是element存活时间无穷大
11
+    diskPersistent:是否缓存虚拟机重启期数据
12
+    diskExpiryThreadIntervalSeconds:磁盘失效线程运行时间间隔,默认是120秒
13
+    diskSpoolBufferSizeMB:这个参数设置DiskStore(磁盘缓存)的缓存区大小。默认是30MB。每个Cache都应该有自己的一个缓冲区
14
+    memoryStoreEvictionPolicy:当达到maxElementsInMemory限制时,Ehcache将会根据指定的策略去清理内存。默认策略是LRU(最近最少使用)。你可以设置为FIFO(先进先出)或是LFU(较少使用)
15
+    -->
16
+    <defaultCache maxElementsInMemory="1000" maxElementsOnDisk="3600" eternal="false" overflowToDisk="true" timeToIdleSeconds="3600" timeToLiveSeconds="86400" diskExpiryThreadIntervalSeconds="120" memoryStoreEvictionPolicy="LRU"/>
17
+
18
+    <cache name="hello" maxElementsInMemory="1000" timeToIdleSeconds="3600" timeToLiveSeconds="86400" eternal="false" overflowToDisk="true" />
19
+</ehcache>  

+ 131 - 0
src/main/resources/logback-spring.xml

@@ -0,0 +1,131 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<configuration>
3
+    <property name="LOG_CONTEXT_NAME" value="log"/>
4
+    <!--定义日志文件的存储地址 勿在 LogBack 的配置中使用相对路径-->
5
+    <property name="LOG_HOME" value="logs/${LOG_CONTEXT_NAME}" />
6
+    <!-- 定义日志上下文的名称 -->
7
+    <contextName>${LOG_CONTEXT_NAME}</contextName>
8
+    <!-- 控制台输出 -->
9
+    <!--<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
10
+      <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
11
+        &lt;!&ndash;格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符&ndash;&gt;
12
+        <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %highlight(%-5level) %cyan(%logger{50}:%L) - %msg%n</pattern>
13
+        <charset>utf-8</charset>
14
+      </encoder>
15
+      <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
16
+        <level>INFO</level>
17
+      </filter>
18
+    </appender>-->
19
+
20
+
21
+    <!-- 彩色日志依赖的渲染类 -->
22
+    <conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter" />
23
+    <conversionRule conversionWord="wex" converterClass="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter" />
24
+    <conversionRule conversionWord="wEx" converterClass="org.springframework.boot.logging.logback.ExtendedWhitespaceThrowableProxyConverter" />
25
+    <!-- 彩色日志格式 -->
26
+    <property name="CONSOLE_LOG_PATTERN" value="${CONSOLE_LOG_PATTERN:-%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}"/>
27
+
28
+    <!--1. 输出到控制台-->
29
+    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
30
+        <!--此日志appender是为开发使用,只配置最底级别,控制台输出的日志级别是大于或等于此级别的日志信息-->
31
+        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
32
+            <level>INFO</level>
33
+        </filter>
34
+        <encoder>
35
+            <Pattern>${CONSOLE_LOG_PATTERN}</Pattern>
36
+            <!-- 设置字符集 -->
37
+            <charset>UTF-8</charset>
38
+        </encoder>
39
+    </appender>
40
+
41
+    <!--info日志统一输出到这里-->
42
+    <appender name="file.info" class="ch.qos.logback.core.rolling.RollingFileAppender">
43
+        <Prudent>true</Prudent>
44
+        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
45
+            <!--日志文件输出的文件名,按小时生成-->
46
+            <FileNamePattern>${LOG_HOME}/%d{yyyy-MM-dd}/info/info.%d{yyyy-MM-dd-HH}.%i.log</FileNamePattern>
47
+            <!--日志文件保留天数-->
48
+            <MaxHistory>30</MaxHistory>
49
+            <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
50
+                <!-- 除按日志记录之外,还配置了日志文件不能超过10M(默认),若超过10M,日志文件会以索引0开始, -->
51
+                <maxFileSize>10MB</maxFileSize>
52
+            </timeBasedFileNamingAndTriggeringPolicy>
53
+        </rollingPolicy>
54
+        <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
55
+            <!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度 %method 方法名  %L 行数 %msg:日志消息,%n是换行符-->
56
+            <pattern> %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{56}.%method:%L - %msg%n</pattern>
57
+            <charset>utf-8</charset>
58
+        </encoder>
59
+        <!-- 此日志文件只记录info级别的 -->
60
+        <filter class="ch.qos.logback.classic.filter.LevelFilter">
61
+            <level>INFO</level>
62
+            <onMatch>ACCEPT</onMatch>
63
+            <onMismatch>DENY</onMismatch>
64
+        </filter>
65
+    </appender>
66
+
67
+
68
+    <!--错误日志统一输出到这里-->
69
+    <appender name="file.error" class="ch.qos.logback.core.rolling.RollingFileAppender">
70
+        <Prudent>true</Prudent>
71
+        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
72
+            <!--日志文件输出的文件名,按天生成-->
73
+            <FileNamePattern>${LOG_HOME}/%d{yyyy-MM-dd}/error/error.%d{yyyy-MM-dd}.%i.log</FileNamePattern>
74
+            <!--日志文件保留天数-->
75
+            <MaxHistory>30</MaxHistory>
76
+            <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
77
+                <!-- 除按日志记录之外,还配置了日志文件不能超过10M(默认),若超过10M,日志文件会以索引0开始, -->
78
+                <maxFileSize>10MB</maxFileSize>
79
+            </timeBasedFileNamingAndTriggeringPolicy>
80
+        </rollingPolicy>
81
+        <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
82
+            <!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度 %method 方法名  %L 行数 %msg:日志消息,%n是换行符-->
83
+            <pattern> %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{56}.%method:%L - %msg%n</pattern>
84
+            <charset>utf-8</charset>
85
+        </encoder>
86
+        <!-- 此日志文件只记录error级别的 -->
87
+        <filter class="ch.qos.logback.classic.filter.LevelFilter">
88
+            <level>ERROR</level>
89
+            <onMatch>ACCEPT</onMatch>
90
+            <onMismatch>DENY</onMismatch>
91
+        </filter>
92
+    </appender>
93
+
94
+    <!--warn日志统一输出到这里-->
95
+    <appender name="file.warn" class="ch.qos.logback.core.rolling.RollingFileAppender">
96
+        <Prudent>true</Prudent>
97
+        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
98
+            <FileNamePattern>${LOG_HOME}/%d{yyyy-MM-dd}/warn/warn.%d{yyyy-MM-dd}.%i.log</FileNamePattern>
99
+            <!--日志文件保留天数-->
100
+            <MaxHistory>30</MaxHistory>
101
+            <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
102
+                <!-- 除按日志记录之外,还配置了日志文件不能超过10M(默认),若超过10M,日志文件会以索引0开始, -->
103
+                <maxFileSize>10MB</maxFileSize>
104
+            </timeBasedFileNamingAndTriggeringPolicy>
105
+        </rollingPolicy>
106
+        <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
107
+            <!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度 %method 方法名  %L 行数 %msg:日志消息,%n是换行符-->
108
+            <pattern> %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{56}.%method:%L - %msg%n</pattern>
109
+            <charset>utf-8</charset>
110
+        </encoder>
111
+        <!-- 此日志文件只记录warn级别的 -->
112
+        <filter class="ch.qos.logback.classic.filter.LevelFilter">
113
+            <level>WARN</level>
114
+            <onMatch>ACCEPT</onMatch>
115
+            <onMismatch>DENY</onMismatch>
116
+        </filter>
117
+    </appender>
118
+    <logger name="org.apache.ibatis" level="DEBUG">
119
+        <appender-ref ref="STDOUT" />
120
+    </logger>
121
+
122
+
123
+    <!--  日志输出级别 -->
124
+    <root level="DEBUG">
125
+        <appender-ref ref="STDOUT" />
126
+        <appender-ref ref="file.error" />
127
+        <appender-ref ref="file.info" />
128
+        <appender-ref ref="file.warn" />
129
+    </root>
130
+
131
+</configuration>

+ 32 - 0
src/main/resources/mapper/JobOrderMapper.xml

@@ -0,0 +1,32 @@
1
+<?xml version="1.0" encoding="UTF-8" ?>
2
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
3
+<mapper namespace="cn.mrdear.mapper.JobOrderMapper">
4
+    <!--根据id查询用户详情-->
5
+    <update id="updateJobOrderExe">
6
+        UPDATE ${tableName}
7
+        SET
8
+            updated = NOW(),
9
+            exe_date_from = NOW(),
10
+            exe_date_to = NOW(),
11
+            status = 'FINISHED',
12
+            ad_user_id = '09BD8B43D0AE4FE9BE879D012F9739BC'
13
+        WHERE
14
+            to_char(created, 'yyyy-mm-dd') = to_char(CURRENT_DATE, 'yyyy-mm-dd')
15
+          AND route_name IN
16
+              (
17
+               '飞织作业', '整烫', '电雕', '画线', '辅料裁切作业', '烫压', '针车',
18
+               '熔断机作业', 'DIY作业', '车中底', '蒸湿入楦'
19
+                  )
20
+          AND status = 'CREATE';
21
+    </update>
22
+    <update id="updateJobOrder">
23
+        UPDATE ${tableName}
24
+        SET
25
+            updated = NOW(),
26
+            exe_date_from = NOW(),
27
+            status = 'START'
28
+        WHERE
29
+            to_char(created, 'yyyy-mm-dd') = to_char(CURRENT_DATE, 'yyyy-mm-dd')
30
+          AND status = 'CREATE';
31
+    </update>
32
+</mapper>

+ 10 - 0
src/main/resources/mapper/UserMapper.xml

@@ -0,0 +1,10 @@
1
+<?xml version="1.0" encoding="UTF-8" ?>
2
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
3
+<mapper namespace="cn.mrdear.mapper.UserMapper">
4
+    <!--开启二级缓存-->
5
+    <cache type="org.mybatis.caches.ehcache.EhcacheCache"/>
6
+    <!--根据id查询用户详情-->
7
+    <select id="findById" parameterType="java.lang.String" resultType="cn.mrdear.entity.User">
8
+        SELECT * FROM ad_alert WHERE ad_alert_id=#{id}
9
+    </select>
10
+</mapper>

Dosya farkı çok büyük olduğundan ihmal edildi
+ 5 - 0
src/main/resources/static/css/bootstrap.min.css


+ 9 - 0
src/main/resources/static/index.html

@@ -0,0 +1,9 @@
1
+<!DOCTYPE html>
2
+<html lang="en">
3
+<head>
4
+    <title>Title11123</title>
5
+</head>
6
+<body>
7
+
8
+</body>
9
+</html>

+ 9 - 0
src/main/resources/templates/error/404.html

@@ -0,0 +1,9 @@
1
+<!DOCTYPE html>
2
+<html lang="en">
3
+<head>
4
+    <title>404</title>
5
+</head>
6
+<body>
7
+
8
+</body>
9
+</html>

+ 76 - 0
src/main/resources/templates/execOrder.html

@@ -0,0 +1,76 @@
1
+<!DOCTYPE html>
2
+<html lang="en">
3
+<head>
4
+  <title>一键刷单</title>
5
+  <style>
6
+    body {
7
+      font-family: Arial, sans-serif;
8
+      text-align: center;
9
+      margin: 50px;
10
+      background-color: #f4f4f4;
11
+    }
12
+    button {
13
+      padding: 10px 20px;
14
+      font-size: 16px;
15
+      color: white;
16
+      background-color: #007bff;
17
+      border: none;
18
+      border-radius: 5px;
19
+      cursor: pointer;
20
+      transition: background-color 0.3s;
21
+      margin:0 20px;
22
+    }
23
+    button:hover {
24
+      background-color: #0056b3;
25
+    }
26
+    .button-link {
27
+      text-decoration: none; /* Remove underline from links */
28
+    }
29
+    #orderCount {
30
+      margin-top: 20px;
31
+      font-size: 18px;
32
+      color: #333;
33
+    }
34
+    .tip {
35
+      margin-bottom: 40px;
36
+      color: red;
37
+    }
38
+  </style>
39
+  <script>
40
+    function completeOrders() {
41
+      // 二次确认
42
+      if (confirm("您确定要完成工单吗?")) {
43
+        // 这里使用 AJAX 模拟调用
44
+        fetch('/runJobOrder', {
45
+          method: 'POST' // 或者根据实际情况使用 'GET'
46
+        })
47
+        .then(response => {
48
+          if (!response.ok) {
49
+            throw new Error('网络响应不是 OK');  // 如果响应状态不是 2xx, 抛出错误
50
+          }
51
+          return response.json();  // 返回解析后的 JSON 数据,或者进一步处理错误状态
52
+        })
53
+        .then(data => {
54
+           document.getElementById('orderCount').innerText = `本次共刷 ${data.order_count} 笔工单`;
55
+        })
56
+        .catch(error => {
57
+          console.error('Error:', error);
58
+          document.getElementById('orderCount').innerText = '请求失败,请稍后再试';
59
+        });
60
+      }
61
+    }
62
+  </script>
63
+</head>
64
+<body>
65
+<div class="tip">注意:如果您是双驰内部网络用户,请通过内网地址进行打标。外部用户请使用外网地址打标。</div>
66
+<button onclick="completeOrders()">一键完成工单</button>
67
+<a  href="http://192.168.40.101:40102/pda/index.jsp" target="_blank" class="button-link">
68
+  <button style="background-color: #46B39D">内网打标地址</button>
69
+</a>
70
+<a href="http://120.33.205.42:40102/pda/index.jsp" target="_blank" class="button-link">
71
+  <button style="background-color: #004175">外网打标地址</button>
72
+</a>
73
+
74
+<div id="orderCount"></div>
75
+</body>
76
+</html>

+ 17 - 0
src/main/resources/templates/hello.html

@@ -0,0 +1,17 @@
1
+<!DOCTYPE HTML>
2
+<html xmlns:th="http://www.thymeleaf.org">
3
+<head>
4
+    <title>hello</title>
5
+    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
6
+</head>
7
+<body>
8
+
9
+<!--/*@thymesVar id="name" type="java.lang.String"*/-->
10
+
11
+<p th:text="'Hello!, ' + ${name} + '!'" >3333</p>
12
+<a th:href="@{http://blog.csdn.net/u012706811}">绝对路径</a>
13
+<a th:href="@{/templates/hello.html}">相对路径</a>
14
+<a th:href="@{css/bootstrap.min.css}">Content路径,默认访问static下的css文件夹</a>
15
+
16
+</body>
17
+</html>

+ 39 - 0
src/main/resources/templates/index.html

@@ -0,0 +1,39 @@
1
+<!DOCTYPE html>
2
+<html lang="en">
3
+<head>
4
+    <title>fakeMes</title>
5
+    <style>
6
+        body {
7
+            font-family: Arial, sans-serif;
8
+            text-align: center;
9
+            margin: 50px;
10
+            background-color: #f4f4f4;
11
+        }
12
+        button {
13
+            padding: 10px 20px;
14
+            font-size: 16px;
15
+            color: white;
16
+            background-color: #007bff;
17
+            border: none;
18
+            border-radius: 5px;
19
+            cursor: pointer;
20
+            transition: background-color 0.3s;
21
+        }
22
+        button:hover {
23
+            background-color: #0056b3;
24
+        }
25
+        .button-link {
26
+            text-decoration: none; /* Remove underline from links */
27
+        }
28
+
29
+    </style>
30
+
31
+</head>
32
+<body>
33
+    <!-- 添加跳转按钮 -->
34
+    <a th:href="@{/execOrder}" class="button-link">
35
+        <button>刷作业工单</button>
36
+    </a>
37
+
38
+</body>
39
+</html>