fanxw 6 年之前
父節點
當前提交
d24623dc19
共有 22 個文件被更改,包括 4269 次插入0 次删除
  1. 6 0
      Dockerfile
  2. 162 0
      pom.xml
  3. 152 0
      src/main/java/com/chinaitop/depot/DatePermissionInterceptor.java
  4. 19 0
      src/main/java/com/chinaitop/depot/DepotKeeperAccountApplication.java
  5. 12 0
      src/main/java/com/chinaitop/depot/HelloWebXml.java
  6. 35 0
      src/main/java/com/chinaitop/depot/SwaggerConfig.java
  7. 118 0
      src/main/java/com/chinaitop/depot/keeperAccount/controller/StorageAccountRecordController.java
  8. 46 0
      src/main/java/com/chinaitop/depot/keeperAccount/mapper/StorageAccountRecordMapper.java
  9. 505 0
      src/main/java/com/chinaitop/depot/keeperAccount/mapper/StorageAccountRecordMapper.xml
  10. 384 0
      src/main/java/com/chinaitop/depot/keeperAccount/model/StorageAccountRecord.java
  11. 1540 0
      src/main/java/com/chinaitop/depot/keeperAccount/model/StorageAccountRecordExample.java
  12. 65 0
      src/main/java/com/chinaitop/depot/keeperAccount/service/StorageAccountRecordService.java
  13. 79 0
      src/main/java/com/chinaitop/depot/keeperAccount/service/impl/StorageAccountRecordServiceImpl.java
  14. 44 0
      src/main/java/com/chinaitop/depot/utils/CustomFilter.java
  15. 61 0
      src/main/java/com/chinaitop/depot/utils/DataPolicyEngine.java
  16. 38 0
      src/main/java/com/chinaitop/depot/utils/GeneratorSqlmap.java
  17. 242 0
      src/main/java/com/chinaitop/depot/utils/MyCommentGenerator.java
  18. 66 0
      src/main/java/com/chinaitop/depot/utils/RedisConfig.java
  19. 547 0
      src/main/java/com/chinaitop/depot/utils/RedisUtil.java
  20. 39 0
      src/main/java/com/chinaitop/depot/utils/WebConfig.java
  21. 51 0
      src/main/resources/bootstrap.yml
  22. 58 0
      src/main/resources/generatorConfig.xml

+ 6 - 0
Dockerfile

@@ -0,0 +1,6 @@
1
+FROM 192.168.123.25:31104/unis/java:8
2
+
3
+ADD ./target/depot-keeper-account.jar /root
4
+CMD ["sh", "-c", "cd /root; java -Djava.security.egd=file:/dev/./urandom -jar /root/depot-keeper-account.jar --depot-keeper-account.server.enable-self-preservation=false"]
5
+EXPOSE 9016
6
+

+ 162 - 0
pom.xml

@@ -0,0 +1,162 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4
+	<modelVersion>4.0.0</modelVersion>
5
+
6
+	<groupId>com.chinaitop</groupId>
7
+	<artifactId>depot-keeper-account</artifactId>
8
+	<version>0.0.1-SNAPSHOT</version>
9
+	<packaging>jar</packaging>
10
+
11
+	<name>depot-keeper-account</name>
12
+	<description>Demo project for Spring Boot</description>
13
+
14
+	<parent>
15
+		<groupId>org.springframework.boot</groupId>
16
+		<artifactId>spring-boot-starter-parent</artifactId>
17
+		<version>2.0.0.RELEASE</version>
18
+		<relativePath/> <!-- lookup parent from repository -->
19
+	</parent>
20
+
21
+	<properties>
22
+		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
23
+		<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
24
+		<java.version>1.8</java.version>
25
+		<spring-cloud.version>Finchley.M8</spring-cloud.version>
26
+	</properties>
27
+
28
+	<dependencies>
29
+		<dependency>
30
+			<groupId>org.springframework.boot</groupId>
31
+			<artifactId>spring-boot-starter-web</artifactId>
32
+		</dependency>
33
+		<dependency>
34
+			<groupId>org.mybatis.spring.boot</groupId>
35
+			<artifactId>mybatis-spring-boot-starter</artifactId>
36
+			<version>1.3.1</version>
37
+		</dependency>
38
+		<dependency>
39
+			<groupId>mysql</groupId>
40
+			<artifactId>mysql-connector-java</artifactId>
41
+		</dependency>
42
+		<!-- 引入spring boot自带的pagehelper插件 -->
43
+		<dependency>
44
+			<groupId>com.github.pagehelper</groupId>
45
+			<artifactId>pagehelper-spring-boot-starter</artifactId>
46
+			<version>1.2.3</version>
47
+		</dependency>
48
+		<dependency>
49
+			<groupId>org.springframework.cloud</groupId>
50
+			<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
51
+		</dependency>
52
+		<dependency>
53
+            <groupId>org.springframework.cloud</groupId>
54
+            <artifactId>spring-cloud-starter-config</artifactId>
55
+        </dependency>
56
+
57
+		<dependency>
58
+			<groupId>org.apache.commons</groupId>
59
+			<artifactId>commons-lang3</artifactId>
60
+		</dependency>
61
+
62
+		<!-- swagger2 -->
63
+		<dependency>
64
+			<groupId>io.springfox</groupId>
65
+			<artifactId>springfox-swagger2</artifactId>
66
+			<version>2.6.1</version>
67
+		</dependency>
68
+		<dependency>
69
+			<groupId>io.springfox</groupId>
70
+			<artifactId>springfox-swagger-ui</artifactId>
71
+			<version>2.6.1</version>
72
+		</dependency>
73
+		<dependency>
74
+			<groupId>org.springframework.boot</groupId>
75
+			<artifactId>spring-boot-starter-test</artifactId>
76
+			<scope>test</scope>
77
+		</dependency>
78
+		<dependency>
79
+			<groupId>org.apache.poi</groupId>
80
+			<artifactId>poi-ooxml</artifactId>
81
+			<version>3.9</version>
82
+		</dependency>
83
+		<!-- 阿里巴巴json -->
84
+		<dependency>
85
+		    <groupId>com.alibaba</groupId>
86
+		    <artifactId>fastjson</artifactId>
87
+		    <version>1.2.37</version>
88
+		</dependency>
89
+		<dependency>
90
+            <groupId>org.springframework.boot</groupId>
91
+            <artifactId>spring-boot-starter-data-redis</artifactId>
92
+        </dependency>
93
+        <dependency>
94
+            <groupId>org.springframework.session</groupId>
95
+            <artifactId>spring-session-data-redis</artifactId>
96
+        </dependency>
97
+        <!-- 加载mybatis逆向生成工具包 -->
98
+        <dependency>
99
+		    <groupId>org.mybatis.generator</groupId>
100
+		    <artifactId>mybatis-generator-core</artifactId>
101
+		    <!-- 注意版本.这里我使用的是1.3.2 -->
102
+		    <version>1.3.2</version>
103
+		</dependency>
104
+	</dependencies>
105
+
106
+	<dependencyManagement>
107
+		<dependencies>
108
+			<dependency>
109
+				<groupId>org.springframework.cloud</groupId>
110
+				<artifactId>spring-cloud-dependencies</artifactId>
111
+				<version>${spring-cloud.version}</version>
112
+				<type>pom</type>
113
+				<scope>import</scope>
114
+			</dependency>
115
+		</dependencies>
116
+	</dependencyManagement>
117
+
118
+	<build>
119
+		<finalName>${project.artifactId}</finalName>
120
+		<plugins>
121
+			<plugin>
122
+				<groupId>org.springframework.boot</groupId>
123
+				<artifactId>spring-boot-maven-plugin</artifactId>
124
+			</plugin>
125
+			<plugin>
126
+            	<groupId>org.apache.maven.plugins</groupId>
127
+            	<artifactId>maven-war-plugin</artifactId>
128
+            	<version>2.6</version>
129
+            	<configuration>
130
+                	<failOnMissingWebXml>false</failOnMissingWebXml>
131
+            	</configuration>
132
+        	</plugin>
133
+		</plugins>
134
+		<!-- 如果不添加此节点mybatis的mapper.xml文件都会被漏掉。 -->
135
+		<resources>
136
+			<resource>
137
+				<directory>src/main/java</directory>
138
+				<includes>
139
+					<include>**/*.properties</include>
140
+					<include>**/*.xml</include>
141
+				</includes>
142
+				<filtering>false</filtering>
143
+			</resource>
144
+			<resource>
145
+				<directory>src/main/resources</directory>
146
+			</resource>
147
+		</resources>
148
+	</build>
149
+
150
+	<repositories>
151
+		<repository>
152
+			<id>spring-milestones</id>
153
+			<name>Spring Milestones</name>
154
+			<url>https://repo.spring.io/milestone</url>
155
+			<snapshots>
156
+				<enabled>false</enabled>
157
+			</snapshots>
158
+		</repository>
159
+	</repositories>
160
+
161
+
162
+</project>

+ 152 - 0
src/main/java/com/chinaitop/depot/DatePermissionInterceptor.java

@@ -0,0 +1,152 @@
1
+package com.chinaitop.depot;
2
+
3
+import com.chinaitop.depot.utils.DataPolicyEngine;
4
+import com.chinaitop.depot.utils.RedisUtil;
5
+import net.sf.jsqlparser.parser.CCJSqlParserUtil;
6
+import net.sf.jsqlparser.statement.Statement;
7
+import net.sf.jsqlparser.statement.select.Select;
8
+import net.sf.jsqlparser.util.TablesNamesFinder;
9
+import org.apache.commons.lang.ObjectUtils;
10
+import org.apache.ibatis.executor.statement.StatementHandler;
11
+import org.apache.ibatis.mapping.BoundSql;
12
+import org.apache.ibatis.mapping.MappedStatement;
13
+import org.apache.ibatis.plugin.*;
14
+import org.apache.ibatis.reflection.DefaultReflectorFactory;
15
+import org.apache.ibatis.reflection.MetaObject;
16
+import org.apache.ibatis.reflection.ReflectorFactory;
17
+import org.apache.ibatis.reflection.factory.DefaultObjectFactory;
18
+import org.apache.ibatis.reflection.factory.ObjectFactory;
19
+import org.apache.ibatis.reflection.wrapper.DefaultObjectWrapperFactory;
20
+import org.apache.ibatis.reflection.wrapper.ObjectWrapperFactory;
21
+import org.springframework.beans.factory.annotation.Autowired;
22
+import org.springframework.stereotype.Component;
23
+
24
+import java.lang.reflect.Field;
25
+import java.sql.Connection;
26
+import java.util.HashSet;
27
+import java.util.List;
28
+import java.util.Properties;
29
+import java.util.Set;
30
+
31
+/**
32
+ * Sql执行时间记录拦截器
33
+ */
34
+@Intercepts({ @Signature(type = StatementHandler.class, method = "prepare", args = { Connection.class, Integer.class })})
35
+@Component
36
+public class DatePermissionInterceptor implements Interceptor {
37
+	
38
+	private static final ObjectFactory DEFAULT_OBJECT_FACTORY = new DefaultObjectFactory();
39
+    private static final ObjectWrapperFactory DEFAULT_OBJECT_WRAPPER_FACTORY = new DefaultObjectWrapperFactory();
40
+    private static final ReflectorFactory DEFAULT_REFLECTOR_FACTORY = new DefaultReflectorFactory();
41
+
42
+	@Autowired
43
+	private RedisUtil redisUtil;
44
+	
45
+	@Override
46
+	public Object intercept(Invocation invocation) throws Throwable {
47
+		
48
+		StatementHandler statementHandler = (StatementHandler) invocation.getTarget();
49
+        MetaObject metaStatementHandler = MetaObject.forObject(statementHandler, DEFAULT_OBJECT_FACTORY,
50
+                DEFAULT_OBJECT_WRAPPER_FACTORY, DEFAULT_REFLECTOR_FACTORY);
51
+        
52
+        MappedStatement mappedStatement = (MappedStatement) metaStatementHandler.getValue("delegate.mappedStatement");
53
+        
54
+		final BoundSql boundSql = statementHandler.getBoundSql();
55
+		String bouString = boundSql.getSql();// 获取执行sql 
56
+		
57
+		//sql是查询的才进行权限过滤
58
+	    if(mappedStatement.getSqlCommandType().toString().equals("select".toUpperCase())) {
59
+	    
60
+			//通过本地线程获取库id
61
+			Object threadLocalObj = DataPolicyEngine.get();
62
+			String orgId = null;
63
+			if(threadLocalObj != null) {
64
+				orgId = ObjectUtils.toString(threadLocalObj);
65
+			}
66
+			if(orgId!=null) {
67
+				//解析sql中的表名
68
+				Statement statement = CCJSqlParserUtil.parse(bouString);
69
+			    Select selectStatement = (Select)statement;
70
+			    TablesNamesFinder tablesNamesFinder = new TablesNamesFinder();
71
+			    List<String> result = tablesNamesFinder.getTableList(selectStatement);
72
+				
73
+				Set<String> tableNames = new HashSet<String>();// 定义需要替换的table信息列表
74
+				//获取业务表信息数据
75
+				List<String> tableList = (List<String>)redisUtil.lGetAll("tableList").get(0);
76
+				for(int i=0;i<result.size();i++) {
77
+					for (int j = 0; j < tableList.size(); j++) {// 处理查看sql中是否有业务表
78
+						if (result.get(i).equals(ObjectUtils.toString(tableList.get(j)))) {// 是否存在业务表
79
+							tableNames.add(result.get(i));
80
+						}
81
+					}
82
+				}
83
+				
84
+				if (tableNames != null && tableNames.size() > 0) {// sql中存在业务表进行sql拼接数据重新检索
85
+					if(result.size() >= 2) {//sql中存在2张及以上表
86
+						for (String table : tableNames) {// 进行业务表的数据权限替换
87
+							table += " ";//表名后面加空格,防止两个表名一部分相似,导致替换出错
88
+							bouString = bouString.replaceAll(table, "(SELECT * from " + table
89
+									+ " WHERE org_id = '"+orgId+"') ");
90
+						}
91
+					}else {//sql中是单表
92
+						for (String table : tableNames) {// 进行业务表的数据权限替换
93
+							if(bouString.contains(table+" ")) {//防止是单表查询,表后面没有空格的时候替换不了
94
+								table += " ";//表名后面加空格,防止两个表名一部分相似,导致替换出错
95
+							}
96
+							bouString = bouString.replaceAll(table, "(SELECT * from " + table
97
+									+ " WHERE org_id = '"+orgId+"') "+table+" ");
98
+						}
99
+					}
100
+					
101
+					/*bouString = bouString.replaceAll(table, "(SELECT b.* from " + table
102
+							+ " b,user_business u WHERE b.org_id = u.org_id AND u .user_id ='"+userId+"' AND u.business_type = '"+table+"') ");*/
103
+					
104
+				}
105
+				
106
+				//metaStatementHandler.setValue("delegate.boundSql.sql", bouString);
107
+				
108
+				Field field = getField(boundSql, "sql");
109
+				if (field != null) {
110
+					try {
111
+						field.setAccessible(true);
112
+						field.set(boundSql, bouString);
113
+					} catch (IllegalArgumentException e) {
114
+						// TODO Auto-generated catch block
115
+						e.printStackTrace();
116
+					} catch (IllegalAccessException e) {
117
+						// TODO Auto-generated catch block
118
+						e.printStackTrace();
119
+					}
120
+				}
121
+			}
122
+		
123
+	    }
124
+			
125
+		return invocation.proceed();
126
+		
127
+
128
+	}
129
+
130
+	private static Field getField(Object obj, String fieldName) {
131
+		Field field = null;
132
+		for (Class<?> clazz = obj.getClass(); clazz != Object.class; clazz = clazz.getSuperclass()) {
133
+			try {
134
+				field = clazz.getDeclaredField(fieldName);
135
+				break;
136
+			} catch (NoSuchFieldException e) {
137
+				// 这里不用做处理,子类没有该字段可能对应的父类有,都没有就返回null。
138
+			}
139
+		}
140
+		return field;
141
+	}
142
+
143
+	@Override
144
+	public Object plugin(Object target) {
145
+		return Plugin.wrap(target, this);
146
+	}
147
+
148
+	@Override
149
+	public void setProperties(Properties properties) {
150
+	}
151
+
152
+}

+ 19 - 0
src/main/java/com/chinaitop/depot/DepotKeeperAccountApplication.java

@@ -0,0 +1,19 @@
1
+package com.chinaitop.depot;
2
+
3
+import org.mybatis.spring.annotation.MapperScan;
4
+import org.springframework.boot.SpringApplication;
5
+import org.springframework.boot.autoconfigure.SpringBootApplication;
6
+import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
7
+import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
8
+
9
+
10
+@EnableEurekaClient
11
+@EnableDiscoveryClient
12
+@SpringBootApplication
13
+@MapperScan(basePackages = {"com.chinaitop.depot.*.mapper"})
14
+public class DepotKeeperAccountApplication {
15
+
16
+	public static void main(String[] args) {
17
+		SpringApplication.run(DepotKeeperAccountApplication.class, args);
18
+	}
19
+}

+ 12 - 0
src/main/java/com/chinaitop/depot/HelloWebXml.java

@@ -0,0 +1,12 @@
1
+package com.chinaitop.depot;
2
+ 
3
+import org.springframework.boot.builder.SpringApplicationBuilder;
4
+import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
5
+ 
6
+public class HelloWebXml extends SpringBootServletInitializer {
7
+    @Override
8
+    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
9
+        return application.sources(DepotKeeperAccountApplication.class);
10
+    }
11
+ 
12
+}

+ 35 - 0
src/main/java/com/chinaitop/depot/SwaggerConfig.java

@@ -0,0 +1,35 @@
1
+package com.chinaitop.depot;
2
+
3
+import org.springframework.context.annotation.Bean;
4
+import org.springframework.context.annotation.Configuration;
5
+
6
+import springfox.documentation.builders.ApiInfoBuilder;
7
+import springfox.documentation.builders.PathSelectors;
8
+import springfox.documentation.builders.RequestHandlerSelectors;
9
+import springfox.documentation.service.ApiInfo;
10
+import springfox.documentation.spi.DocumentationType;
11
+import springfox.documentation.spring.web.plugins.Docket;
12
+import springfox.documentation.swagger2.annotations.EnableSwagger2;
13
+
14
+@Configuration
15
+@EnableSwagger2
16
+public class SwaggerConfig {
17
+
18
+	@Bean
19
+    public Docket createRestApi() {
20
+        return new Docket(DocumentationType.SWAGGER_2)
21
+                .apiInfo(apiInfo())
22
+                .select()
23
+                .apis(RequestHandlerSelectors.basePackage("com.chinaitop.depot.keeperAccount.controller"))
24
+                .paths(PathSelectors.any())
25
+                .build();
26
+    }
27
+    private ApiInfo apiInfo() {
28
+        return new ApiInfoBuilder()
29
+                .title("智能粮库管理平台api文档")
30
+                .description("保管账")
31
+                .termsOfServiceUrl("http://192.168.80.25:9001")
32
+                .version("1.0")
33
+                .build();
34
+    }
35
+}

+ 118 - 0
src/main/java/com/chinaitop/depot/keeperAccount/controller/StorageAccountRecordController.java

@@ -0,0 +1,118 @@
1
+package com.chinaitop.depot.keeperAccount.controller;
2
+
3
+import java.util.HashMap;
4
+import java.util.List;
5
+import java.util.Map;
6
+
7
+import javax.annotation.Resource;
8
+
9
+import org.springframework.http.MediaType;
10
+import org.springframework.web.bind.annotation.RequestMapping;
11
+import org.springframework.web.bind.annotation.RequestMethod;
12
+import org.springframework.web.bind.annotation.RestController;
13
+
14
+import com.chinaitop.depot.keeperAccount.model.StorageAccountRecord;
15
+import com.chinaitop.depot.keeperAccount.service.StorageAccountRecordService;
16
+import com.fasterxml.jackson.databind.ObjectMapper;
17
+import com.github.pagehelper.PageHelper;
18
+import com.github.pagehelper.PageInfo;
19
+
20
+import io.swagger.annotations.Api;
21
+import io.swagger.annotations.ApiImplicitParam;
22
+import io.swagger.annotations.ApiImplicitParams;
23
+import io.swagger.annotations.ApiOperation;
24
+
25
+@RestController
26
+@RequestMapping(value="/StorageAccountRecord")
27
+@Api(value= "StorageAccountRecordController", description = "保管账记账控制类")
28
+public class StorageAccountRecordController {
29
+
30
+	@Resource
31
+	private StorageAccountRecordService recordService;
32
+
33
+	@RequestMapping(value="/sumAccountList", produces = MediaType.APPLICATION_JSON_VALUE, method=RequestMethod.GET)
34
+	@ApiOperation(value="保管总账列表,按月统计", notes = "支持分页")
35
+    @ApiImplicitParams({
36
+    	@ApiImplicitParam(name="pageNum", value="页数", paramType="query"),
37
+    	@ApiImplicitParam(name="pageSize", value="每页显示条数", paramType="query"),
38
+    	@ApiImplicitParam(name="lspz", value="粮食品种", paramType="query"),
39
+    	@ApiImplicitParam(name="lsxz", value="粮食性质", paramType="query"),
40
+    	@ApiImplicitParam(name="startDate", value="起始时间", paramType="query"),
41
+    	@ApiImplicitParam(name="endDate", value="结束时间", paramType="query")
42
+    })
43
+	public PageInfo<Map<String, Object>> sumAccountList(Integer pageNum, Integer pageSize, 
44
+			Integer lspz, Integer lsxz, String startDate, String endDate) {
45
+		Map<String, Object> map = new HashMap<String, Object>();
46
+		if (lspz != null) {
47
+			map.put("pz", lspz+"");
48
+		}
49
+		if (lsxz != null) {
50
+			map.put("hwxz", lsxz+"");
51
+		}
52
+		if (pageNum!=null && pageSize!=null) {
53
+			PageHelper.startPage(pageNum, pageSize);
54
+		}
55
+		List<Map<String, Object>> list = recordService.selectKeepSumAccountData(map);
56
+		if (null != list && list.size() > 0) {
57
+			Map<String, Object> kcsl_map = null;
58
+			List<Map<String, Object>> kcsl_list = null;
59
+			for (Map<String, Object> obj : list) {
60
+				kcsl_map = new HashMap<String, Object>();
61
+				kcsl_map.put("pz", obj.get("lspz"));
62
+				kcsl_map.put("hwxz", obj.get("hwxz"));
63
+				kcsl_map.put("rq", obj.get("rq"));
64
+				kcsl_list = recordService.selectKCSL(kcsl_map);
65
+				if (null != kcsl_list && kcsl_list.size() > 0) {
66
+					obj.put("kcsl", kcsl_list.get(0).get("kcsl"));
67
+				}
68
+			}
69
+		}
70
+		PageInfo<Map<String, Object>> pageInfo = new PageInfo<Map<String, Object>>(list);
71
+		return pageInfo;
72
+	}
73
+
74
+	@RequestMapping(value = "/edit", produces = MediaType.APPLICATION_JSON_VALUE, method=RequestMethod.GET)
75
+	@ApiOperation(value="查询一条记账数据", notes = "查询一条记账数据")
76
+    @ApiImplicitParams({
77
+    	@ApiImplicitParam(name="houseId", value="仓房ID", paramType="query"),
78
+    	@ApiImplicitParam(name="wareId", value="货位ID", paramType="query"),
79
+    	@ApiImplicitParam(name="hwxz", value="粮食性质", paramType="query"),
80
+    	@ApiImplicitParam(name="lspz", value="粮食品种", paramType="query"),
81
+    	@ApiImplicitParam(name="rq", value="日期", paramType="query"),
82
+    	@ApiImplicitParam(name="accountType", value="记账类型", paramType="query")
83
+    })
84
+	public Map<String, Object> edit(Integer houseId, Integer wareId, Integer hwxz, Integer lspz, String rq, Integer accountType) {
85
+		Map<String, Object> map = new HashMap<String, Object>();
86
+		
87
+		map = recordService.selectOrCheckStorageAccountRecord(houseId, wareId, hwxz, lspz, rq, accountType, map);
88
+
89
+		return map;
90
+	}
91
+
92
+	@RequestMapping(value = "/update", produces = MediaType.APPLICATION_JSON_VALUE, method=RequestMethod.POST)
93
+	@ApiOperation(value="记账", notes = "记账")
94
+    @ApiImplicitParams({
95
+    	@ApiImplicitParam(name="recordJson", value="数据集", paramType="form"),
96
+    	@ApiImplicitParam(name="accountType", value="记账类型", paramType="form"),
97
+    	@ApiImplicitParam(name="orgId", value="单位ID", paramType="form")
98
+    })
99
+	public Map<String, Object> update(String recordJson, Integer accountType, Integer orgId) {
100
+		Map<String, Object> map = new HashMap<String, Object>();
101
+		ObjectMapper mapper = new ObjectMapper();
102
+		try {
103
+			StorageAccountRecord record = mapper.readValue(recordJson, StorageAccountRecord.class);
104
+			if (record.getId() == null) {
105
+				record.setAccountType(accountType);
106
+				record.setOrgId(orgId);
107
+				recordService.add(record);
108
+			} else {
109
+				recordService.update(record);
110
+			}
111
+			map.put("status", "success");
112
+			map.put("msg", "保存成功!");
113
+		} catch (Exception e) {
114
+			e.printStackTrace();
115
+		}
116
+		return map;
117
+	}
118
+}

+ 46 - 0
src/main/java/com/chinaitop/depot/keeperAccount/mapper/StorageAccountRecordMapper.java

@@ -0,0 +1,46 @@
1
+package com.chinaitop.depot.keeperAccount.mapper;
2
+
3
+import com.chinaitop.depot.keeperAccount.model.StorageAccountRecord;
4
+import com.chinaitop.depot.keeperAccount.model.StorageAccountRecordExample;
5
+import java.util.List;
6
+import java.util.Map;
7
+
8
+import org.apache.ibatis.annotations.Param;
9
+
10
+public interface StorageAccountRecordMapper {
11
+    int countByExample(StorageAccountRecordExample example);
12
+
13
+    int deleteByExample(StorageAccountRecordExample example);
14
+
15
+    int deleteByPrimaryKey(Integer id);
16
+
17
+    int insert(StorageAccountRecord record);
18
+
19
+    int insertSelective(StorageAccountRecord record);
20
+
21
+    List<StorageAccountRecord> selectByExample(StorageAccountRecordExample example);
22
+
23
+    StorageAccountRecord selectByPrimaryKey(Integer id);
24
+
25
+    int updateByExampleSelective(@Param("record") StorageAccountRecord record, @Param("example") StorageAccountRecordExample example);
26
+
27
+    int updateByExample(@Param("record") StorageAccountRecord record, @Param("example") StorageAccountRecordExample example);
28
+
29
+    int updateByPrimaryKeySelective(StorageAccountRecord record);
30
+
31
+    int updateByPrimaryKey(StorageAccountRecord record);
32
+
33
+    /**
34
+     * 保管总账查询列表
35
+     * @param map
36
+     * @return
37
+     */
38
+    List<Map<String, Object>> selectKeepSumAccount(Map<String, Object> map);
39
+
40
+    /**
41
+     * 查询保管总账查询列表的库存数量
42
+     * @param map
43
+     * @return
44
+     */
45
+    List<Map<String, Object>> selectKCSL(Map<String, Object> map);
46
+}

+ 505 - 0
src/main/java/com/chinaitop/depot/keeperAccount/mapper/StorageAccountRecordMapper.xml

@@ -0,0 +1,505 @@
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="com.chinaitop.depot.keeperAccount.mapper.StorageAccountRecordMapper">
4
+  <resultMap id="BaseResultMap" type="com.chinaitop.depot.keeperAccount.model.StorageAccountRecord">
5
+    <id column="id" jdbcType="INTEGER" property="id" />
6
+    <result column="org_id" jdbcType="INTEGER" property="orgId" />
7
+    <result column="account_type" jdbcType="INTEGER" property="accountType" />
8
+    <result column="house_id" jdbcType="INTEGER" property="houseId" />
9
+    <result column="ware_id" jdbcType="INTEGER" property="wareId" />
10
+    <result column="record_unite" jdbcType="VARCHAR" property="recordUnite" />
11
+    <result column="lspz" jdbcType="INTEGER" property="lspz" />
12
+    <result column="hwxz" jdbcType="INTEGER" property="hwxz" />
13
+    <result column="level" jdbcType="INTEGER" property="level" />
14
+    <result column="rq" jdbcType="VARCHAR" property="rq" />
15
+    <result column="rq_date" jdbcType="TIMESTAMP" property="rqDate" />
16
+    <result column="srsl" jdbcType="DECIMAL" property="srsl" />
17
+    <result column="zcsl" jdbcType="DECIMAL" property="zcsl" />
18
+    <result column="kcsl" jdbcType="DECIMAL" property="kcsl" />
19
+    <result column="remark" jdbcType="VARCHAR" property="remark" />
20
+    <result column="accounting_person" jdbcType="VARCHAR" property="accountingPerson" />
21
+    <result column="accounting_date" jdbcType="TIMESTAMP" property="accountingDate" />
22
+    <result column="auditor" jdbcType="VARCHAR" property="auditor" />
23
+    <result column="auditor_date" jdbcType="TIMESTAMP" property="auditorDate" />
24
+    <result column="auditor_opinion" jdbcType="VARCHAR" property="auditorOpinion" />
25
+    <result column="updatetime" jdbcType="TIMESTAMP" property="updatetime" />
26
+  </resultMap>
27
+  <sql id="Example_Where_Clause">
28
+    <where>
29
+      <foreach collection="oredCriteria" item="criteria" separator="or">
30
+        <if test="criteria.valid">
31
+          <trim prefix="(" prefixOverrides="and" suffix=")">
32
+            <foreach collection="criteria.criteria" item="criterion">
33
+              <choose>
34
+                <when test="criterion.noValue">
35
+                  and ${criterion.condition}
36
+                </when>
37
+                <when test="criterion.singleValue">
38
+                  and ${criterion.condition} #{criterion.value}
39
+                </when>
40
+                <when test="criterion.betweenValue">
41
+                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
42
+                </when>
43
+                <when test="criterion.listValue">
44
+                  and ${criterion.condition}
45
+                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
46
+                    #{listItem}
47
+                  </foreach>
48
+                </when>
49
+              </choose>
50
+            </foreach>
51
+          </trim>
52
+        </if>
53
+      </foreach>
54
+    </where>
55
+  </sql>
56
+  <sql id="Update_By_Example_Where_Clause">
57
+    <where>
58
+      <foreach collection="example.oredCriteria" item="criteria" separator="or">
59
+        <if test="criteria.valid">
60
+          <trim prefix="(" prefixOverrides="and" suffix=")">
61
+            <foreach collection="criteria.criteria" item="criterion">
62
+              <choose>
63
+                <when test="criterion.noValue">
64
+                  and ${criterion.condition}
65
+                </when>
66
+                <when test="criterion.singleValue">
67
+                  and ${criterion.condition} #{criterion.value}
68
+                </when>
69
+                <when test="criterion.betweenValue">
70
+                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
71
+                </when>
72
+                <when test="criterion.listValue">
73
+                  and ${criterion.condition}
74
+                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
75
+                    #{listItem}
76
+                  </foreach>
77
+                </when>
78
+              </choose>
79
+            </foreach>
80
+          </trim>
81
+        </if>
82
+      </foreach>
83
+    </where>
84
+  </sql>
85
+  <sql id="Base_Column_List">
86
+    id, org_id, account_type, house_id, ware_id, record_unite, lspz, hwxz, level, rq, 
87
+    rq_date, srsl, zcsl, kcsl, remark, accounting_person, accounting_date, auditor, auditor_date, 
88
+    auditor_opinion, updatetime
89
+  </sql>
90
+  <select id="selectByExample" parameterType="com.chinaitop.depot.keeperAccount.model.StorageAccountRecordExample" resultMap="BaseResultMap">
91
+    select
92
+    <if test="distinct">
93
+      distinct
94
+    </if>
95
+    <include refid="Base_Column_List" />
96
+    from storage_account_record
97
+    <if test="_parameter != null">
98
+      <include refid="Example_Where_Clause" />
99
+    </if>
100
+    <if test="orderByClause != null">
101
+      order by ${orderByClause}
102
+    </if>
103
+  </select>
104
+  <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
105
+    select 
106
+    <include refid="Base_Column_List" />
107
+    from storage_account_record
108
+    where id = #{id,jdbcType=INTEGER}
109
+  </select>
110
+  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
111
+    delete from storage_account_record
112
+    where id = #{id,jdbcType=INTEGER}
113
+  </delete>
114
+  <delete id="deleteByExample" parameterType="com.chinaitop.depot.keeperAccount.model.StorageAccountRecordExample">
115
+    delete from storage_account_record
116
+    <if test="_parameter != null">
117
+      <include refid="Example_Where_Clause" />
118
+    </if>
119
+  </delete>
120
+  <insert id="insert" parameterType="com.chinaitop.depot.keeperAccount.model.StorageAccountRecord">
121
+    insert into storage_account_record (id, org_id, account_type, 
122
+      house_id, ware_id, record_unite, 
123
+      lspz, hwxz, level, 
124
+      rq, rq_date, srsl, 
125
+      zcsl, kcsl, remark, 
126
+      accounting_person, accounting_date, auditor, 
127
+      auditor_date, auditor_opinion, updatetime
128
+      )
129
+    values (#{id,jdbcType=INTEGER}, #{orgId,jdbcType=INTEGER}, #{accountType,jdbcType=INTEGER}, 
130
+      #{houseId,jdbcType=INTEGER}, #{wareId,jdbcType=INTEGER}, #{recordUnite,jdbcType=VARCHAR}, 
131
+      #{lspz,jdbcType=INTEGER}, #{hwxz,jdbcType=INTEGER}, #{level,jdbcType=INTEGER}, 
132
+      #{rq,jdbcType=VARCHAR}, #{rqDate,jdbcType=TIMESTAMP}, #{srsl,jdbcType=DECIMAL}, 
133
+      #{zcsl,jdbcType=DECIMAL}, #{kcsl,jdbcType=DECIMAL}, #{remark,jdbcType=VARCHAR}, 
134
+      #{accountingPerson,jdbcType=VARCHAR}, #{accountingDate,jdbcType=TIMESTAMP}, #{auditor,jdbcType=VARCHAR}, 
135
+      #{auditorDate,jdbcType=TIMESTAMP}, #{auditorOpinion,jdbcType=VARCHAR}, #{updatetime,jdbcType=TIMESTAMP}
136
+      )
137
+  </insert>
138
+  <insert id="insertSelective" parameterType="com.chinaitop.depot.keeperAccount.model.StorageAccountRecord">
139
+    insert into storage_account_record
140
+    <trim prefix="(" suffix=")" suffixOverrides=",">
141
+      <if test="id != null">
142
+        id,
143
+      </if>
144
+      <if test="orgId != null">
145
+        org_id,
146
+      </if>
147
+      <if test="accountType != null">
148
+        account_type,
149
+      </if>
150
+      <if test="houseId != null">
151
+        house_id,
152
+      </if>
153
+      <if test="wareId != null">
154
+        ware_id,
155
+      </if>
156
+      <if test="recordUnite != null">
157
+        record_unite,
158
+      </if>
159
+      <if test="lspz != null">
160
+        lspz,
161
+      </if>
162
+      <if test="hwxz != null">
163
+        hwxz,
164
+      </if>
165
+      <if test="level != null">
166
+        level,
167
+      </if>
168
+      <if test="rq != null">
169
+        rq,
170
+      </if>
171
+      <if test="rqDate != null">
172
+        rq_date,
173
+      </if>
174
+      <if test="srsl != null">
175
+        srsl,
176
+      </if>
177
+      <if test="zcsl != null">
178
+        zcsl,
179
+      </if>
180
+      <if test="kcsl != null">
181
+        kcsl,
182
+      </if>
183
+      <if test="remark != null">
184
+        remark,
185
+      </if>
186
+      <if test="accountingPerson != null">
187
+        accounting_person,
188
+      </if>
189
+      <if test="accountingDate != null">
190
+        accounting_date,
191
+      </if>
192
+      <if test="auditor != null">
193
+        auditor,
194
+      </if>
195
+      <if test="auditorDate != null">
196
+        auditor_date,
197
+      </if>
198
+      <if test="auditorOpinion != null">
199
+        auditor_opinion,
200
+      </if>
201
+      <if test="updatetime != null">
202
+        updatetime,
203
+      </if>
204
+    </trim>
205
+    <trim prefix="values (" suffix=")" suffixOverrides=",">
206
+      <if test="id != null">
207
+        #{id,jdbcType=INTEGER},
208
+      </if>
209
+      <if test="orgId != null">
210
+        #{orgId,jdbcType=INTEGER},
211
+      </if>
212
+      <if test="accountType != null">
213
+        #{accountType,jdbcType=INTEGER},
214
+      </if>
215
+      <if test="houseId != null">
216
+        #{houseId,jdbcType=INTEGER},
217
+      </if>
218
+      <if test="wareId != null">
219
+        #{wareId,jdbcType=INTEGER},
220
+      </if>
221
+      <if test="recordUnite != null">
222
+        #{recordUnite,jdbcType=VARCHAR},
223
+      </if>
224
+      <if test="lspz != null">
225
+        #{lspz,jdbcType=INTEGER},
226
+      </if>
227
+      <if test="hwxz != null">
228
+        #{hwxz,jdbcType=INTEGER},
229
+      </if>
230
+      <if test="level != null">
231
+        #{level,jdbcType=INTEGER},
232
+      </if>
233
+      <if test="rq != null">
234
+        #{rq,jdbcType=VARCHAR},
235
+      </if>
236
+      <if test="rqDate != null">
237
+        #{rqDate,jdbcType=TIMESTAMP},
238
+      </if>
239
+      <if test="srsl != null">
240
+        #{srsl,jdbcType=DECIMAL},
241
+      </if>
242
+      <if test="zcsl != null">
243
+        #{zcsl,jdbcType=DECIMAL},
244
+      </if>
245
+      <if test="kcsl != null">
246
+        #{kcsl,jdbcType=DECIMAL},
247
+      </if>
248
+      <if test="remark != null">
249
+        #{remark,jdbcType=VARCHAR},
250
+      </if>
251
+      <if test="accountingPerson != null">
252
+        #{accountingPerson,jdbcType=VARCHAR},
253
+      </if>
254
+      <if test="accountingDate != null">
255
+        #{accountingDate,jdbcType=TIMESTAMP},
256
+      </if>
257
+      <if test="auditor != null">
258
+        #{auditor,jdbcType=VARCHAR},
259
+      </if>
260
+      <if test="auditorDate != null">
261
+        #{auditorDate,jdbcType=TIMESTAMP},
262
+      </if>
263
+      <if test="auditorOpinion != null">
264
+        #{auditorOpinion,jdbcType=VARCHAR},
265
+      </if>
266
+      <if test="updatetime != null">
267
+        #{updatetime,jdbcType=TIMESTAMP},
268
+      </if>
269
+    </trim>
270
+  </insert>
271
+  <select id="countByExample" parameterType="com.chinaitop.depot.keeperAccount.model.StorageAccountRecordExample" resultType="java.lang.Integer">
272
+    select count(*) from storage_account_record
273
+    <if test="_parameter != null">
274
+      <include refid="Example_Where_Clause" />
275
+    </if>
276
+  </select>
277
+  <update id="updateByExampleSelective" parameterType="map">
278
+    update storage_account_record
279
+    <set>
280
+      <if test="record.id != null">
281
+        id = #{record.id,jdbcType=INTEGER},
282
+      </if>
283
+      <if test="record.orgId != null">
284
+        org_id = #{record.orgId,jdbcType=INTEGER},
285
+      </if>
286
+      <if test="record.accountType != null">
287
+        account_type = #{record.accountType,jdbcType=INTEGER},
288
+      </if>
289
+      <if test="record.houseId != null">
290
+        house_id = #{record.houseId,jdbcType=INTEGER},
291
+      </if>
292
+      <if test="record.wareId != null">
293
+        ware_id = #{record.wareId,jdbcType=INTEGER},
294
+      </if>
295
+      <if test="record.recordUnite != null">
296
+        record_unite = #{record.recordUnite,jdbcType=VARCHAR},
297
+      </if>
298
+      <if test="record.lspz != null">
299
+        lspz = #{record.lspz,jdbcType=INTEGER},
300
+      </if>
301
+      <if test="record.hwxz != null">
302
+        hwxz = #{record.hwxz,jdbcType=INTEGER},
303
+      </if>
304
+      <if test="record.level != null">
305
+        level = #{record.level,jdbcType=INTEGER},
306
+      </if>
307
+      <if test="record.rq != null">
308
+        rq = #{record.rq,jdbcType=VARCHAR},
309
+      </if>
310
+      <if test="record.rqDate != null">
311
+        rq_date = #{record.rqDate,jdbcType=TIMESTAMP},
312
+      </if>
313
+      <if test="record.srsl != null">
314
+        srsl = #{record.srsl,jdbcType=DECIMAL},
315
+      </if>
316
+      <if test="record.zcsl != null">
317
+        zcsl = #{record.zcsl,jdbcType=DECIMAL},
318
+      </if>
319
+      <if test="record.kcsl != null">
320
+        kcsl = #{record.kcsl,jdbcType=DECIMAL},
321
+      </if>
322
+      <if test="record.remark != null">
323
+        remark = #{record.remark,jdbcType=VARCHAR},
324
+      </if>
325
+      <if test="record.accountingPerson != null">
326
+        accounting_person = #{record.accountingPerson,jdbcType=VARCHAR},
327
+      </if>
328
+      <if test="record.accountingDate != null">
329
+        accounting_date = #{record.accountingDate,jdbcType=TIMESTAMP},
330
+      </if>
331
+      <if test="record.auditor != null">
332
+        auditor = #{record.auditor,jdbcType=VARCHAR},
333
+      </if>
334
+      <if test="record.auditorDate != null">
335
+        auditor_date = #{record.auditorDate,jdbcType=TIMESTAMP},
336
+      </if>
337
+      <if test="record.auditorOpinion != null">
338
+        auditor_opinion = #{record.auditorOpinion,jdbcType=VARCHAR},
339
+      </if>
340
+      <if test="record.updatetime != null">
341
+        updatetime = #{record.updatetime,jdbcType=TIMESTAMP},
342
+      </if>
343
+    </set>
344
+    <if test="_parameter != null">
345
+      <include refid="Update_By_Example_Where_Clause" />
346
+    </if>
347
+  </update>
348
+  <update id="updateByExample" parameterType="map">
349
+    update storage_account_record
350
+    set id = #{record.id,jdbcType=INTEGER},
351
+      org_id = #{record.orgId,jdbcType=INTEGER},
352
+      account_type = #{record.accountType,jdbcType=INTEGER},
353
+      house_id = #{record.houseId,jdbcType=INTEGER},
354
+      ware_id = #{record.wareId,jdbcType=INTEGER},
355
+      record_unite = #{record.recordUnite,jdbcType=VARCHAR},
356
+      lspz = #{record.lspz,jdbcType=INTEGER},
357
+      hwxz = #{record.hwxz,jdbcType=INTEGER},
358
+      level = #{record.level,jdbcType=INTEGER},
359
+      rq = #{record.rq,jdbcType=VARCHAR},
360
+      rq_date = #{record.rqDate,jdbcType=TIMESTAMP},
361
+      srsl = #{record.srsl,jdbcType=DECIMAL},
362
+      zcsl = #{record.zcsl,jdbcType=DECIMAL},
363
+      kcsl = #{record.kcsl,jdbcType=DECIMAL},
364
+      remark = #{record.remark,jdbcType=VARCHAR},
365
+      accounting_person = #{record.accountingPerson,jdbcType=VARCHAR},
366
+      accounting_date = #{record.accountingDate,jdbcType=TIMESTAMP},
367
+      auditor = #{record.auditor,jdbcType=VARCHAR},
368
+      auditor_date = #{record.auditorDate,jdbcType=TIMESTAMP},
369
+      auditor_opinion = #{record.auditorOpinion,jdbcType=VARCHAR},
370
+      updatetime = #{record.updatetime,jdbcType=TIMESTAMP}
371
+    <if test="_parameter != null">
372
+      <include refid="Update_By_Example_Where_Clause" />
373
+    </if>
374
+  </update>
375
+  <update id="updateByPrimaryKeySelective" parameterType="com.chinaitop.depot.keeperAccount.model.StorageAccountRecord">
376
+    update storage_account_record
377
+    <set>
378
+      <if test="orgId != null">
379
+        org_id = #{orgId,jdbcType=INTEGER},
380
+      </if>
381
+      <if test="accountType != null">
382
+        account_type = #{accountType,jdbcType=INTEGER},
383
+      </if>
384
+      <if test="houseId != null">
385
+        house_id = #{houseId,jdbcType=INTEGER},
386
+      </if>
387
+      <if test="wareId != null">
388
+        ware_id = #{wareId,jdbcType=INTEGER},
389
+      </if>
390
+      <if test="recordUnite != null">
391
+        record_unite = #{recordUnite,jdbcType=VARCHAR},
392
+      </if>
393
+      <if test="lspz != null">
394
+        lspz = #{lspz,jdbcType=INTEGER},
395
+      </if>
396
+      <if test="hwxz != null">
397
+        hwxz = #{hwxz,jdbcType=INTEGER},
398
+      </if>
399
+      <if test="level != null">
400
+        level = #{level,jdbcType=INTEGER},
401
+      </if>
402
+      <if test="rq != null">
403
+        rq = #{rq,jdbcType=VARCHAR},
404
+      </if>
405
+      <if test="rqDate != null">
406
+        rq_date = #{rqDate,jdbcType=TIMESTAMP},
407
+      </if>
408
+      <if test="srsl != null">
409
+        srsl = #{srsl,jdbcType=DECIMAL},
410
+      </if>
411
+      <if test="zcsl != null">
412
+        zcsl = #{zcsl,jdbcType=DECIMAL},
413
+      </if>
414
+      <if test="kcsl != null">
415
+        kcsl = #{kcsl,jdbcType=DECIMAL},
416
+      </if>
417
+      <if test="remark != null">
418
+        remark = #{remark,jdbcType=VARCHAR},
419
+      </if>
420
+      <if test="accountingPerson != null">
421
+        accounting_person = #{accountingPerson,jdbcType=VARCHAR},
422
+      </if>
423
+      <if test="accountingDate != null">
424
+        accounting_date = #{accountingDate,jdbcType=TIMESTAMP},
425
+      </if>
426
+      <if test="auditor != null">
427
+        auditor = #{auditor,jdbcType=VARCHAR},
428
+      </if>
429
+      <if test="auditorDate != null">
430
+        auditor_date = #{auditorDate,jdbcType=TIMESTAMP},
431
+      </if>
432
+      <if test="auditorOpinion != null">
433
+        auditor_opinion = #{auditorOpinion,jdbcType=VARCHAR},
434
+      </if>
435
+      <if test="updatetime != null">
436
+        updatetime = #{updatetime,jdbcType=TIMESTAMP},
437
+      </if>
438
+    </set>
439
+    where id = #{id,jdbcType=INTEGER}
440
+  </update>
441
+  <update id="updateByPrimaryKey" parameterType="com.chinaitop.depot.keeperAccount.model.StorageAccountRecord">
442
+    update storage_account_record
443
+    set org_id = #{orgId,jdbcType=INTEGER},
444
+      account_type = #{accountType,jdbcType=INTEGER},
445
+      house_id = #{houseId,jdbcType=INTEGER},
446
+      ware_id = #{wareId,jdbcType=INTEGER},
447
+      record_unite = #{recordUnite,jdbcType=VARCHAR},
448
+      lspz = #{lspz,jdbcType=INTEGER},
449
+      hwxz = #{hwxz,jdbcType=INTEGER},
450
+      level = #{level,jdbcType=INTEGER},
451
+      rq = #{rq,jdbcType=VARCHAR},
452
+      rq_date = #{rqDate,jdbcType=TIMESTAMP},
453
+      srsl = #{srsl,jdbcType=DECIMAL},
454
+      zcsl = #{zcsl,jdbcType=DECIMAL},
455
+      kcsl = #{kcsl,jdbcType=DECIMAL},
456
+      remark = #{remark,jdbcType=VARCHAR},
457
+      accounting_person = #{accountingPerson,jdbcType=VARCHAR},
458
+      accounting_date = #{accountingDate,jdbcType=TIMESTAMP},
459
+      auditor = #{auditor,jdbcType=VARCHAR},
460
+      auditor_date = #{auditorDate,jdbcType=TIMESTAMP},
461
+      auditor_opinion = #{auditorOpinion,jdbcType=VARCHAR},
462
+      updatetime = #{updatetime,jdbcType=TIMESTAMP}
463
+    where id = #{id,jdbcType=INTEGER}
464
+  </update>
465
+  <!-- 保管总账查询列表 -->
466
+  <select id="selectKeepSumAccount" parameterType="java.util.Map" resultType="java.util.Map">
467
+	SELECT 
468
+		fcbgz.hwxz, fcbgz.lspz, DATE_FORMAT(fcbgz.rq,'%Y-%m') as rq, sum(fcbgz.srsl) as srsl, 
469
+		sum(fcbgz.zcsl) as zcsl, (sum(fcbgz.srsl)-sum(fcbgz.zcsl)) as kcsl 
470
+	FROM (
471
+		SELECT * FROM storage_account_record where 1=1 AND account_type=0 AND auditor_date IS NOT NULL 
472
+		<if test="pz != null">
473
+	        and lspz = #{pz} 
474
+	    </if>
475
+	    <if test="hwxz != null">
476
+	        and hwxz = #{hwxz} 
477
+	    </if>
478
+	) fcbgz 
479
+	group by fcbgz.hwxz, fcbgz.lspz, DATE_FORMAT(fcbgz.rq,'%Y-%m') 
480
+	order by fcbgz.rq
481
+  </select>
482
+  <!-- 查询保管总账查询列表的库存数量 -->
483
+  <select id="selectKCSL" parameterType="java.util.Map" resultType="java.util.Map">
484
+	SELECT c.lspz AS lspz,c.hwxz AS hwxz,SUM(c.kcsl) as kcsl FROM 
485
+	(
486
+	SELECT b.house_id,b.ware_id,b.lspz,b.hwxz,DATE_FORMAT(b.rq, '%Y-%m') AS rq,kcsl FROM ( SELECT * FROM storage_account_record ORDER BY rq DESC) b
487
+		WHERE 1=1 
488
+		<if test="rq != null">
489
+			AND DATE_FORMAT(b.rq, '%Y-%m') = #{rq} 
490
+		</if>
491
+		AND b.account_type = 0 
492
+		AND auditor_date IS NOT NULL 
493
+		GROUP BY b.house_id,b.ware_id,b.lspz,b.hwxz 
494
+		ORDER BY b.house_id,b.ware_id 
495
+	) c
496
+	WHERE 1=1 
497
+	<if test="pz != null">
498
+        and c.lspz = #{pz} 
499
+    </if>
500
+    <if test="hwxz != null">
501
+        and c.hwxz = #{hwxz} 
502
+    </if>
503
+	GROUP BY c.lspz,c.hwxz,c.rq
504
+  </select>
505
+</mapper>

+ 384 - 0
src/main/java/com/chinaitop/depot/keeperAccount/model/StorageAccountRecord.java

@@ -0,0 +1,384 @@
1
+package com.chinaitop.depot.keeperAccount.model;
2
+
3
+import java.math.BigDecimal;
4
+import java.util.Date;
5
+
6
+public class StorageAccountRecord {
7
+    private Integer id;
8
+
9
+    private Integer orgId;
10
+
11
+    private Integer accountType;
12
+
13
+    private Integer houseId;
14
+
15
+    private Integer wareId;
16
+
17
+    private String recordUnite;
18
+
19
+    private Integer lspz;
20
+
21
+    private Integer hwxz;
22
+
23
+    private Integer level;
24
+
25
+    private String rq;
26
+
27
+    private Date rqDate;
28
+
29
+    private BigDecimal srsl;
30
+
31
+    private BigDecimal zcsl;
32
+
33
+    private BigDecimal kcsl;
34
+
35
+    private String remark;
36
+
37
+    private String accountingPerson;
38
+
39
+    private Date accountingDate;
40
+
41
+    private String auditor;
42
+
43
+    private Date auditorDate;
44
+
45
+    private String auditorOpinion;
46
+
47
+    private Date updatetime;
48
+
49
+    /**
50
+     * 主键编号
51
+     * @return id 主键编号
52
+     */
53
+    public Integer getId() {
54
+        return id;
55
+    }
56
+
57
+    /**
58
+     * 主键编号
59
+     * @param id 主键编号
60
+     */
61
+    public void setId(Integer id) {
62
+        this.id = id;
63
+    }
64
+
65
+    /**
66
+     * 粮库ID
67
+     * @return org_id 粮库ID
68
+     */
69
+    public Integer getOrgId() {
70
+        return orgId;
71
+    }
72
+
73
+    /**
74
+     * 粮库ID
75
+     * @param orgId 粮库ID
76
+     */
77
+    public void setOrgId(Integer orgId) {
78
+        this.orgId = orgId;
79
+    }
80
+
81
+    /**
82
+     * 账目类型(0分仓账,1总账)
83
+     * @return account_type 账目类型(0分仓账,1总账)
84
+     */
85
+    public Integer getAccountType() {
86
+        return accountType;
87
+    }
88
+
89
+    /**
90
+     * 账目类型(0分仓账,1总账)
91
+     * @param accountType 账目类型(0分仓账,1总账)
92
+     */
93
+    public void setAccountType(Integer accountType) {
94
+        this.accountType = accountType;
95
+    }
96
+
97
+    /**
98
+     * 仓房ID
99
+     * @return house_id 仓房ID
100
+     */
101
+    public Integer getHouseId() {
102
+        return houseId;
103
+    }
104
+
105
+    /**
106
+     * 仓房ID
107
+     * @param houseId 仓房ID
108
+     */
109
+    public void setHouseId(Integer houseId) {
110
+        this.houseId = houseId;
111
+    }
112
+
113
+    /**
114
+     * 货位ID
115
+     * @return ware_id 货位ID
116
+     */
117
+    public Integer getWareId() {
118
+        return wareId;
119
+    }
120
+
121
+    /**
122
+     * 货位ID
123
+     * @param wareId 货位ID
124
+     */
125
+    public void setWareId(Integer wareId) {
126
+        this.wareId = wareId;
127
+    }
128
+
129
+    /**
130
+     * 粮权单位
131
+     * @return record_unite 粮权单位
132
+     */
133
+    public String getRecordUnite() {
134
+        return recordUnite;
135
+    }
136
+
137
+    /**
138
+     * 粮权单位
139
+     * @param recordUnite 粮权单位
140
+     */
141
+    public void setRecordUnite(String recordUnite) {
142
+        this.recordUnite = recordUnite == null ? null : recordUnite.trim();
143
+    }
144
+
145
+    /**
146
+     * 粮食品种
147
+     * @return lspz 粮食品种
148
+     */
149
+    public Integer getLspz() {
150
+        return lspz;
151
+    }
152
+
153
+    /**
154
+     * 粮食品种
155
+     * @param lspz 粮食品种
156
+     */
157
+    public void setLspz(Integer lspz) {
158
+        this.lspz = lspz;
159
+    }
160
+
161
+    /**
162
+     * 货物性质
163
+     * @return hwxz 货物性质
164
+     */
165
+    public Integer getHwxz() {
166
+        return hwxz;
167
+    }
168
+
169
+    /**
170
+     * 货物性质
171
+     * @param hwxz 货物性质
172
+     */
173
+    public void setHwxz(Integer hwxz) {
174
+        this.hwxz = hwxz;
175
+    }
176
+
177
+    /**
178
+     * 粮食等级
179
+     * @return level 粮食等级
180
+     */
181
+    public Integer getLevel() {
182
+        return level;
183
+    }
184
+
185
+    /**
186
+     * 粮食等级
187
+     * @param level 粮食等级
188
+     */
189
+    public void setLevel(Integer level) {
190
+        this.level = level;
191
+    }
192
+
193
+    /**
194
+     * 日期(总账)
195
+     * @return rq 日期(总账)
196
+     */
197
+    public String getRq() {
198
+        return rq;
199
+    }
200
+
201
+    /**
202
+     * 日期(总账)
203
+     * @param rq 日期(总账)
204
+     */
205
+    public void setRq(String rq) {
206
+        this.rq = rq == null ? null : rq.trim();
207
+    }
208
+
209
+    /**
210
+     * 日期(分仓账)
211
+     * @return rq_date 日期(分仓账)
212
+     */
213
+    public Date getRqDate() {
214
+        return rqDate;
215
+    }
216
+
217
+    /**
218
+     * 日期(分仓账)
219
+     * @param rqDate 日期(分仓账)
220
+     */
221
+    public void setRqDate(Date rqDate) {
222
+        this.rqDate = rqDate;
223
+    }
224
+
225
+    /**
226
+     * 收入数量
227
+     * @return srsl 收入数量
228
+     */
229
+    public BigDecimal getSrsl() {
230
+        return srsl;
231
+    }
232
+
233
+    /**
234
+     * 收入数量
235
+     * @param srsl 收入数量
236
+     */
237
+    public void setSrsl(BigDecimal srsl) {
238
+        this.srsl = srsl;
239
+    }
240
+
241
+    /**
242
+     * 支出数量
243
+     * @return zcsl 支出数量
244
+     */
245
+    public BigDecimal getZcsl() {
246
+        return zcsl;
247
+    }
248
+
249
+    /**
250
+     * 支出数量
251
+     * @param zcsl 支出数量
252
+     */
253
+    public void setZcsl(BigDecimal zcsl) {
254
+        this.zcsl = zcsl;
255
+    }
256
+
257
+    /**
258
+     * 库存数量
259
+     * @return kcsl 库存数量
260
+     */
261
+    public BigDecimal getKcsl() {
262
+        return kcsl;
263
+    }
264
+
265
+    /**
266
+     * 库存数量
267
+     * @param kcsl 库存数量
268
+     */
269
+    public void setKcsl(BigDecimal kcsl) {
270
+        this.kcsl = kcsl;
271
+    }
272
+
273
+    /**
274
+     * 摘要
275
+     * @return remark 摘要
276
+     */
277
+    public String getRemark() {
278
+        return remark;
279
+    }
280
+
281
+    /**
282
+     * 摘要
283
+     * @param remark 摘要
284
+     */
285
+    public void setRemark(String remark) {
286
+        this.remark = remark == null ? null : remark.trim();
287
+    }
288
+
289
+    /**
290
+     * 记账人
291
+     * @return accounting_person 记账人
292
+     */
293
+    public String getAccountingPerson() {
294
+        return accountingPerson;
295
+    }
296
+
297
+    /**
298
+     * 记账人
299
+     * @param accountingPerson 记账人
300
+     */
301
+    public void setAccountingPerson(String accountingPerson) {
302
+        this.accountingPerson = accountingPerson == null ? null : accountingPerson.trim();
303
+    }
304
+
305
+    /**
306
+     * 记账时间
307
+     * @return accounting_date 记账时间
308
+     */
309
+    public Date getAccountingDate() {
310
+        return accountingDate;
311
+    }
312
+
313
+    /**
314
+     * 记账时间
315
+     * @param accountingDate 记账时间
316
+     */
317
+    public void setAccountingDate(Date accountingDate) {
318
+        this.accountingDate = accountingDate;
319
+    }
320
+
321
+    /**
322
+     * 审核人
323
+     * @return auditor 审核人
324
+     */
325
+    public String getAuditor() {
326
+        return auditor;
327
+    }
328
+
329
+    /**
330
+     * 审核人
331
+     * @param auditor 审核人
332
+     */
333
+    public void setAuditor(String auditor) {
334
+        this.auditor = auditor == null ? null : auditor.trim();
335
+    }
336
+
337
+    /**
338
+     * 审核时间
339
+     * @return auditor_date 审核时间
340
+     */
341
+    public Date getAuditorDate() {
342
+        return auditorDate;
343
+    }
344
+
345
+    /**
346
+     * 审核时间
347
+     * @param auditorDate 审核时间
348
+     */
349
+    public void setAuditorDate(Date auditorDate) {
350
+        this.auditorDate = auditorDate;
351
+    }
352
+
353
+    /**
354
+     * 审核意见
355
+     * @return auditor_opinion 审核意见
356
+     */
357
+    public String getAuditorOpinion() {
358
+        return auditorOpinion;
359
+    }
360
+
361
+    /**
362
+     * 审核意见
363
+     * @param auditorOpinion 审核意见
364
+     */
365
+    public void setAuditorOpinion(String auditorOpinion) {
366
+        this.auditorOpinion = auditorOpinion == null ? null : auditorOpinion.trim();
367
+    }
368
+
369
+    /**
370
+     * 
371
+     * @return updatetime 
372
+     */
373
+    public Date getUpdatetime() {
374
+        return updatetime;
375
+    }
376
+
377
+    /**
378
+     * 
379
+     * @param updatetime 
380
+     */
381
+    public void setUpdatetime(Date updatetime) {
382
+        this.updatetime = updatetime;
383
+    }
384
+}

File diff suppressed because it is too large
+ 1540 - 0
src/main/java/com/chinaitop/depot/keeperAccount/model/StorageAccountRecordExample.java


+ 65 - 0
src/main/java/com/chinaitop/depot/keeperAccount/service/StorageAccountRecordService.java

@@ -0,0 +1,65 @@
1
+package com.chinaitop.depot.keeperAccount.service;
2
+
3
+import java.util.List;
4
+import java.util.Map;
5
+
6
+import com.chinaitop.depot.keeperAccount.model.StorageAccountRecord;
7
+import com.chinaitop.depot.keeperAccount.model.StorageAccountRecordExample;
8
+
9
+public interface StorageAccountRecordService {
10
+
11
+	/**
12
+	 * 新增
13
+	 * 
14
+	 * @param record
15
+	 *            数据对象
16
+	 */
17
+	void add(StorageAccountRecord record);
18
+
19
+	/**
20
+	 * 修改
21
+	 * 
22
+	 * @param record
23
+	 *            数据对象
24
+	 */
25
+	void update(StorageAccountRecord record);
26
+
27
+	/**
28
+	 * 按条件查询数据
29
+	 * 
30
+	 * @param example
31
+	 *            条件
32
+	 * @return
33
+	 */
34
+	List<StorageAccountRecord> findByConditon(StorageAccountRecordExample example);
35
+
36
+	/**
37
+	 * 查询数据
38
+	 * 
39
+	 * @param houseId 仓房ID
40
+	 * @param wareId 货位ID
41
+	 * @param hwxz 货物性质
42
+	 * @param lspz lspz
43
+	 * @param rq 日期
44
+	 * @param map 返回对象
45
+	 * @return
46
+	 */
47
+	Map<String, Object> selectOrCheckStorageAccountRecord(Integer houseId, Integer wareId, Integer hwxz, Integer lspz,
48
+			String rq, Integer accountType, Map<String, Object> map);
49
+
50
+	/**
51
+	 * 保管总账列表
52
+	 * 
53
+	 * @param map
54
+	 * @return
55
+	 */
56
+	List<Map<String, Object>> selectKeepSumAccountData(Map<String, Object> map);
57
+
58
+	/**
59
+	 * 查询保管总账查询列表的库存数量
60
+	 * 
61
+	 * @param map
62
+	 * @return
63
+	 */
64
+	List<Map<String, Object>> selectKCSL(Map<String, Object> map);
65
+}

+ 79 - 0
src/main/java/com/chinaitop/depot/keeperAccount/service/impl/StorageAccountRecordServiceImpl.java

@@ -0,0 +1,79 @@
1
+package com.chinaitop.depot.keeperAccount.service.impl;
2
+
3
+import java.util.List;
4
+import java.util.Map;
5
+
6
+import javax.annotation.Resource;
7
+
8
+import org.springframework.stereotype.Service;
9
+
10
+import com.chinaitop.depot.keeperAccount.mapper.StorageAccountRecordMapper;
11
+import com.chinaitop.depot.keeperAccount.model.StorageAccountRecord;
12
+import com.chinaitop.depot.keeperAccount.model.StorageAccountRecordExample;
13
+import com.chinaitop.depot.keeperAccount.service.StorageAccountRecordService;
14
+
15
+@Service
16
+public class StorageAccountRecordServiceImpl implements StorageAccountRecordService {
17
+
18
+	@Resource
19
+	private StorageAccountRecordMapper mapper;
20
+
21
+	@Override
22
+	public void add(StorageAccountRecord record) {
23
+		mapper.insertSelective(record);
24
+	}
25
+
26
+	@Override
27
+	public void update(StorageAccountRecord record) {
28
+		mapper.updateByPrimaryKeySelective(record);
29
+	}
30
+
31
+	@Override
32
+	public List<StorageAccountRecord> findByConditon(StorageAccountRecordExample example) {
33
+		return mapper.selectByExample(example);
34
+	}
35
+
36
+	@Override
37
+	public Map<String, Object> selectOrCheckStorageAccountRecord(Integer houseId, Integer wareId, Integer hwxz,
38
+			Integer lspz, String rq, Integer accountType, Map<String, Object> map) {
39
+		
40
+		StorageAccountRecord record = null;
41
+		StorageAccountRecordExample example = new StorageAccountRecordExample();
42
+		StorageAccountRecordExample.Criteria criteria = example.createCriteria();
43
+		if (houseId != null) {
44
+			criteria.andHouseIdEqualTo(houseId);
45
+		}
46
+		if (wareId != null) {
47
+			criteria.andWareIdEqualTo(wareId);
48
+		}
49
+		criteria.andHwxzEqualTo(hwxz);
50
+		criteria.andLspzEqualTo(lspz);
51
+		criteria.andAccountTypeEqualTo(accountType);
52
+		if (accountType == 1) {
53
+			criteria.andRqEqualTo(rq);
54
+		} else {
55
+			criteria.andRqEqualTo(rq);
56
+		}
57
+
58
+		List<StorageAccountRecord> list = mapper.selectByExample(example);
59
+		if (null != list && list.size() > 0) {
60
+			record = list.get(0);
61
+		} else {
62
+			record = new StorageAccountRecord();
63
+		}
64
+		map.put("obj", record);
65
+
66
+		return map;
67
+	}
68
+
69
+	@Override
70
+	public List<Map<String, Object>> selectKeepSumAccountData(Map<String, Object> map) {
71
+		return mapper.selectKeepSumAccount(map);
72
+	}
73
+
74
+	@Override
75
+	public List<Map<String, Object>> selectKCSL(Map<String, Object> map) {
76
+		return mapper.selectKCSL(map);
77
+	}
78
+
79
+}

+ 44 - 0
src/main/java/com/chinaitop/depot/utils/CustomFilter.java

@@ -0,0 +1,44 @@
1
+package com.chinaitop.depot.utils;
2
+
3
+import java.io.IOException;
4
+
5
+import javax.servlet.Filter;
6
+import javax.servlet.FilterChain;
7
+import javax.servlet.FilterConfig;
8
+import javax.servlet.ServletException;
9
+import javax.servlet.ServletRequest;
10
+import javax.servlet.ServletResponse;
11
+import javax.servlet.http.HttpServletRequest;
12
+import javax.servlet.http.HttpSession;
13
+
14
+import org.apache.commons.lang.ObjectUtils;
15
+
16
+public class CustomFilter implements Filter {
17
+
18
+	@Override
19
+    public void init(FilterConfig filterConfig) throws ServletException {
20
+ 
21
+    }
22
+	
23
+	@Override
24
+	public void doFilter(ServletRequest arg0, ServletResponse arg1, FilterChain arg2)
25
+			throws IOException, ServletException {
26
+		HttpServletRequest request = (HttpServletRequest) arg0;
27
+		HttpSession session = request.getSession();
28
+		String orgId = "";
29
+		if (session != null){
30
+			orgId = ObjectUtils.toString(session.getAttribute("orgId"),"");
31
+		}
32
+		if (!orgId.isEmpty()) {
33
+			DataPolicyEngine.set(orgId);
34
+		}
35
+		arg2.doFilter(arg0, arg1);
36
+		DataPolicyEngine.remove();
37
+	}
38
+	
39
+	@Override
40
+    public void destroy() {
41
+ 
42
+    }
43
+
44
+}

+ 61 - 0
src/main/java/com/chinaitop/depot/utils/DataPolicyEngine.java

@@ -0,0 +1,61 @@
1
+package com.chinaitop.depot.utils;
2
+
3
+import org.apache.commons.logging.Log;
4
+import org.apache.commons.logging.LogFactory;
5
+
6
+
7
+/**
8
+ * 
9
+ * @author hf
10
+ * 
11
+ * @description 数据策略(数据权限控制使用)
12
+ * 
13
+ * 
14
+ */
15
+public class DataPolicyEngine {
16
+	//log信息输出对象
17
+	protected static final Log log = LogFactory.getLog(DataPolicyEngine.class); 
18
+
19
+	//本地线程,用于存储线程公共对象
20
+	private static ThreadLocal threadLocalSession = new ThreadLocal();
21
+	
22
+	
23
+	/**
24
+	 * @description 获取本地执行线程
25
+	 *
26
+	 * @return ThreadLocal 
27
+	 * 
28
+	 */
29
+	public static ThreadLocal getThreadLocalSession() {
30
+		return threadLocalSession;
31
+	}
32
+	
33
+	/**
34
+	 * @description 在线程内设置存储对象
35
+	 * 
36
+	 */
37
+	public static void set(Object obj) {
38
+		threadLocalSession.set(obj);
39
+
40
+	}
41
+	
42
+	/**
43
+	 * @description 获取在线程内设置存储的对象
44
+	 * 
45
+	 */
46
+	public static Object get() {
47
+		return threadLocalSession.get();
48
+
49
+	}
50
+
51
+	/**
52
+	 * @description 移除在线程内设置存储的对象
53
+	 * 
54
+	 */
55
+	public static void remove() {
56
+		threadLocalSession.remove();
57
+
58
+	}
59
+	
60
+	
61
+}

+ 38 - 0
src/main/java/com/chinaitop/depot/utils/GeneratorSqlmap.java

@@ -0,0 +1,38 @@
1
+package com.chinaitop.depot.utils;
2
+
3
+import org.mybatis.generator.api.MyBatisGenerator;
4
+import org.mybatis.generator.config.Configuration;
5
+import org.mybatis.generator.config.xml.ConfigurationParser;
6
+import org.mybatis.generator.internal.DefaultShellCallback;
7
+
8
+import java.io.File;
9
+import java.util.ArrayList;
10
+import java.util.List;
11
+
12
+public class GeneratorSqlmap {
13
+
14
+	public void generator() throws Exception{
15
+
16
+		List<String> warnings = new ArrayList<String>();
17
+		boolean overwrite = true;
18
+		//指定 逆向工程配置文件(写自己电脑的路径)
19
+		File configFile = new File("D:\\git_local\\depot-keeper-account\\src\\main\\resources\\generatorConfig.xml");
20
+		ConfigurationParser cp = new ConfigurationParser(warnings);
21
+		Configuration config = cp.parseConfiguration(configFile);
22
+		DefaultShellCallback callback = new DefaultShellCallback(overwrite);
23
+		MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config,
24
+				callback, warnings);
25
+		myBatisGenerator.generate(null);
26
+
27
+	} 
28
+	public static void main(String[] args) throws Exception {
29
+		try {
30
+			GeneratorSqlmap generatorSqlmap = new GeneratorSqlmap();
31
+			generatorSqlmap.generator();
32
+		} catch (Exception e) {
33
+			e.printStackTrace();
34
+		}
35
+		
36
+	}
37
+
38
+}

+ 242 - 0
src/main/java/com/chinaitop/depot/utils/MyCommentGenerator.java

@@ -0,0 +1,242 @@
1
+package com.chinaitop.depot.utils;
2
+import java.text.SimpleDateFormat;
3
+import java.util.Date;
4
+import java.util.Properties;
5
+
6
+import static org.mybatis.generator.internal.util.StringUtility.isTrue;
7
+import org.mybatis.generator.api.CommentGenerator;
8
+import org.mybatis.generator.api.IntrospectedColumn;
9
+import org.mybatis.generator.api.IntrospectedTable;
10
+import org.mybatis.generator.api.dom.java.CompilationUnit;
11
+import org.mybatis.generator.api.dom.java.Field;
12
+import org.mybatis.generator.api.dom.java.InnerClass;
13
+import org.mybatis.generator.api.dom.java.InnerEnum;
14
+import org.mybatis.generator.api.dom.java.JavaElement;
15
+import org.mybatis.generator.api.dom.java.Method;
16
+import org.mybatis.generator.api.dom.java.Parameter;
17
+import org.mybatis.generator.api.dom.xml.XmlElement;
18
+import org.mybatis.generator.config.MergeConstants;
19
+import org.mybatis.generator.config.PropertyRegistry;
20
+
21
+public class MyCommentGenerator implements CommentGenerator {
22
+
23
+	private Properties properties;
24
+	private Properties systemPro;
25
+	private boolean suppressDate;
26
+	private boolean suppressAllComments;
27
+	private String currentDateStr;
28
+
29
+	public MyCommentGenerator() {
30
+	    super();
31
+	    properties = new Properties();
32
+	    systemPro = System.getProperties();
33
+	    suppressDate = false;
34
+	    suppressAllComments = false;
35
+	    currentDateStr = (new SimpleDateFormat("yyyy-MM-dd")).format(new Date());
36
+	}
37
+
38
+	
39
+	@Override
40
+	public void addClassComment(InnerClass innerClass, IntrospectedTable introspectedTable) {
41
+		if (suppressAllComments) {
42
+	        return;
43
+	    }
44
+	    StringBuilder sb = new StringBuilder();
45
+	    innerClass.addJavaDocLine("/**");
46
+	    sb.append(" * ");
47
+	    sb.append(introspectedTable.getFullyQualifiedTable());
48
+	    sb.append(" ");
49
+	    sb.append(getDateString());
50
+	    innerClass.addJavaDocLine(sb.toString());
51
+	    innerClass.addJavaDocLine(" */");
52
+
53
+	}
54
+
55
+	@Override
56
+	public void addClassComment(InnerClass innerClass, IntrospectedTable introspectedTable, boolean arg2) {
57
+		if (suppressAllComments) {
58
+	        return;
59
+	    }
60
+
61
+	    StringBuilder sb = new StringBuilder();
62
+
63
+	    innerClass.addJavaDocLine("/**");
64
+	    sb.append(" * ");
65
+	    sb.append(introspectedTable.getFullyQualifiedTable());
66
+	    innerClass.addJavaDocLine(sb.toString());
67
+
68
+	    sb.setLength(0);
69
+	    sb.append(" * @author ");
70
+	    sb.append(systemPro.getProperty("user.name"));
71
+	    sb.append(" ");
72
+	    sb.append(currentDateStr);
73
+
74
+	    //      addJavadocTag(innerClass, markAsDoNotDelete);
75
+
76
+	    innerClass.addJavaDocLine(" */");
77
+
78
+	}
79
+
80
+	@Override
81
+	public void addComment(XmlElement arg0) {
82
+		return;
83
+	}
84
+
85
+	@Override
86
+	public void addConfigurationProperties(Properties properties) {
87
+		this.properties.putAll(properties);
88
+
89
+	    suppressDate = isTrue(properties.getProperty(PropertyRegistry.COMMENT_GENERATOR_SUPPRESS_DATE));
90
+
91
+	    suppressAllComments = isTrue(properties.getProperty(PropertyRegistry.COMMENT_GENERATOR_SUPPRESS_ALL_COMMENTS));
92
+
93
+	}
94
+	
95
+	/**
96
+	 * This method adds the custom javadoc tag for. You may do nothing if you do
97
+	 * not wish to include the Javadoc tag - however, if you do not include the
98
+	 * Javadoc tag then the Java merge capability of the eclipse plugin will
99
+	 * break.
100
+	 * 
101
+	 * @param javaElement
102
+	 *            the java element
103
+	 */
104
+	protected void addJavadocTag(JavaElement javaElement, boolean markAsDoNotDelete) {
105
+	    javaElement.addJavaDocLine(" *");
106
+	    StringBuilder sb = new StringBuilder();
107
+	    sb.append(" * ");
108
+	    sb.append(MergeConstants.NEW_ELEMENT_TAG);
109
+	    if (markAsDoNotDelete) {
110
+	        sb.append(" do_not_delete_during_merge");
111
+	    }
112
+	    String s = getDateString();
113
+	    if (s != null) {
114
+	        sb.append(' ');
115
+	        sb.append(s);
116
+	    }
117
+	    javaElement.addJavaDocLine(sb.toString());
118
+	}
119
+	
120
+	protected String getDateString() {
121
+	    String result = null;
122
+	    if (!suppressDate) {
123
+	        result = currentDateStr;
124
+	    }
125
+	    return result;
126
+	}
127
+
128
+
129
+	@Override
130
+	public void addEnumComment(InnerEnum innerEnum, IntrospectedTable introspectedTable) {
131
+		if (suppressAllComments) {
132
+	        return;
133
+	    }
134
+
135
+	    StringBuilder sb = new StringBuilder();
136
+
137
+	    innerEnum.addJavaDocLine("/**");
138
+	    //      addJavadocTag(innerEnum, false);
139
+	    sb.append(" * ");
140
+	    sb.append(introspectedTable.getFullyQualifiedTable());
141
+	    innerEnum.addJavaDocLine(sb.toString());
142
+	    innerEnum.addJavaDocLine(" */");
143
+
144
+	}
145
+
146
+	@Override
147
+	public void addFieldComment(Field field, IntrospectedTable introspectedTable) {
148
+		if (suppressAllComments) {
149
+	        return;
150
+	    }
151
+
152
+	    StringBuilder sb = new StringBuilder();
153
+
154
+	    field.addJavaDocLine("/**");
155
+	    sb.append(" * ");
156
+	    sb.append(introspectedTable.getFullyQualifiedTable());
157
+	    field.addJavaDocLine(sb.toString());
158
+	    field.addJavaDocLine(" */");
159
+
160
+	}
161
+
162
+	@Override
163
+	public void addFieldComment(Field arg0, IntrospectedTable arg1, IntrospectedColumn arg2) {
164
+		// TODO Auto-generated method stub
165
+
166
+	}
167
+
168
+	@Override
169
+	public void addGeneralMethodComment(Method arg0, IntrospectedTable arg1) {
170
+		if (suppressAllComments) {
171
+	        return;
172
+	    }
173
+	    //      method.addJavaDocLine("/**");
174
+	    //      addJavadocTag(method, false);
175
+	    //      method.addJavaDocLine(" */");
176
+
177
+	}
178
+
179
+	@Override
180
+	public void addGetterComment(Method method, IntrospectedTable arg1, IntrospectedColumn introspectedColumn) {
181
+		if (suppressAllComments) {
182
+	        return;
183
+	    }
184
+
185
+	    method.addJavaDocLine("/**");
186
+
187
+	    StringBuilder sb = new StringBuilder();
188
+	    sb.append(" * ");
189
+	    sb.append(introspectedColumn.getRemarks());
190
+	    method.addJavaDocLine(sb.toString());
191
+
192
+	    sb.setLength(0);
193
+	    sb.append(" * @return ");
194
+	    sb.append(introspectedColumn.getActualColumnName());
195
+	    sb.append(" ");
196
+	    sb.append(introspectedColumn.getRemarks());
197
+	    method.addJavaDocLine(sb.toString());
198
+
199
+	    //      addJavadocTag(method, false);
200
+
201
+	    method.addJavaDocLine(" */");
202
+
203
+	}
204
+
205
+	@Override
206
+	public void addJavaFileComment(CompilationUnit arg0) {
207
+		return;
208
+	}
209
+
210
+	@Override
211
+	public void addRootComment(XmlElement arg0) {
212
+		return;
213
+	}
214
+
215
+	@Override
216
+	public void addSetterComment(Method method, IntrospectedTable arg1, IntrospectedColumn introspectedColumn) {
217
+		if (suppressAllComments) {
218
+	        return;
219
+	    }
220
+
221
+
222
+	    method.addJavaDocLine("/**");
223
+	    StringBuilder sb = new StringBuilder();
224
+	    sb.append(" * ");
225
+	    sb.append(introspectedColumn.getRemarks());
226
+	    method.addJavaDocLine(sb.toString());
227
+
228
+	    Parameter parm = method.getParameters().get(0);
229
+	    sb.setLength(0);
230
+	    sb.append(" * @param ");
231
+	    sb.append(parm.getName());
232
+	    sb.append(" ");
233
+	    sb.append(introspectedColumn.getRemarks());
234
+	    method.addJavaDocLine(sb.toString());
235
+
236
+	    //      addJavadocTag(method, false);
237
+
238
+	    method.addJavaDocLine(" */");
239
+
240
+	}
241
+
242
+}

+ 66 - 0
src/main/java/com/chinaitop/depot/utils/RedisConfig.java

@@ -0,0 +1,66 @@
1
+package com.chinaitop.depot.utils;
2
+
3
+import com.fasterxml.jackson.annotation.JsonAutoDetect;
4
+import com.fasterxml.jackson.annotation.PropertyAccessor;
5
+import com.fasterxml.jackson.databind.ObjectMapper;
6
+import org.springframework.beans.factory.annotation.Autowired;
7
+import org.springframework.context.annotation.Bean;
8
+import org.springframework.context.annotation.Configuration;
9
+import org.springframework.data.redis.connection.RedisConnectionFactory;
10
+import org.springframework.data.redis.core.HashOperations;
11
+import org.springframework.data.redis.core.ListOperations;
12
+import org.springframework.data.redis.core.RedisTemplate;
13
+import org.springframework.data.redis.core.SetOperations;
14
+import org.springframework.data.redis.core.ValueOperations;
15
+import org.springframework.data.redis.core.ZSetOperations;
16
+import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
17
+import org.springframework.data.redis.serializer.StringRedisSerializer;
18
+
19
+@Configuration
20
+public class RedisConfig {
21
+    @Autowired
22
+    private RedisConnectionFactory factory;
23
+
24
+    @Bean
25
+    public RedisTemplate<String, Object> redisTemplate() {
26
+        Jackson2JsonRedisSerializer<Object> jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer<Object>(Object.class);
27
+        ObjectMapper om = new ObjectMapper();
28
+        om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
29
+        om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
30
+        jackson2JsonRedisSerializer.setObjectMapper(om);
31
+        RedisTemplate<String, Object> template = new RedisTemplate<String, Object>();
32
+        template.setConnectionFactory(factory);
33
+        template.setKeySerializer(new StringRedisSerializer());
34
+        template.setValueSerializer(jackson2JsonRedisSerializer);
35
+        template.setHashKeySerializer(jackson2JsonRedisSerializer);
36
+        template.setHashValueSerializer(jackson2JsonRedisSerializer);
37
+        template.setDefaultSerializer(new StringRedisSerializer());
38
+        template.afterPropertiesSet();
39
+        return template;
40
+    }
41
+
42
+    @Bean
43
+    public HashOperations<String, String, Object> hashOperations(RedisTemplate<String, Object> redisTemplate) {
44
+        return redisTemplate.opsForHash();
45
+    }
46
+
47
+    @Bean
48
+    public ValueOperations<String, String> valueOperations(RedisTemplate<String, String> redisTemplate) {
49
+        return redisTemplate.opsForValue();
50
+    }
51
+
52
+    @Bean
53
+    public ListOperations<String, Object> listOperations(RedisTemplate<String, Object> redisTemplate) {
54
+        return redisTemplate.opsForList();
55
+    }
56
+
57
+    @Bean
58
+    public SetOperations<String, Object> setOperations(RedisTemplate<String, Object> redisTemplate) {
59
+        return redisTemplate.opsForSet();
60
+    }
61
+
62
+    @Bean
63
+    public ZSetOperations<String, Object> zSetOperations(RedisTemplate<String, Object> redisTemplate) {
64
+        return redisTemplate.opsForZSet();
65
+    }
66
+}

+ 547 - 0
src/main/java/com/chinaitop/depot/utils/RedisUtil.java

@@ -0,0 +1,547 @@
1
+package com.chinaitop.depot.utils;
2
+
3
+import java.util.List;
4
+import java.util.Map;
5
+import java.util.Set;
6
+import java.util.concurrent.TimeUnit;
7
+import org.springframework.beans.factory.annotation.Autowired;
8
+import org.springframework.data.redis.core.HashOperations;
9
+import org.springframework.data.redis.core.ListOperations;
10
+import org.springframework.data.redis.core.RedisTemplate;
11
+import org.springframework.data.redis.core.SetOperations;
12
+import org.springframework.data.redis.core.ValueOperations;
13
+import org.springframework.stereotype.Component;
14
+import org.springframework.util.CollectionUtils;
15
+
16
+@Component
17
+public class RedisUtil {
18
+
19
+    @Autowired
20
+    private RedisTemplate<String, Object> redisTemplate;
21
+    @Autowired
22
+    private ValueOperations<String, String> valueOperations;
23
+    @Autowired
24
+    private HashOperations<String, String, Object> hashOperations;
25
+    @Autowired
26
+    private ListOperations<String, Object> listOperations;
27
+    @Autowired
28
+    private SetOperations<String, Object> setOperations;
29
+
30
+    //=============================common============================
31
+    /**
32
+     * 指定缓存失效时间
33
+     * @param key 键
34
+     * @param time 时间(秒)
35
+     * @return
36
+     */
37
+    public boolean expire(String key,long time){
38
+        try {
39
+            if(time>0){
40
+                redisTemplate.expire(key, time, TimeUnit.SECONDS);
41
+            }
42
+            return true;
43
+        } catch (Exception e) {
44
+            e.printStackTrace();
45
+            return false;
46
+        }
47
+    }
48
+
49
+    /**
50
+     * 根据key 获取过期时间
51
+     * @param key 键 不能为null
52
+     * @return 时间(秒) 返回0代表为永久有效
53
+     */
54
+    public long getExpire(String key){
55
+        return redisTemplate.getExpire(key,TimeUnit.SECONDS);
56
+    }
57
+
58
+    /**
59
+     * 判断key是否存在
60
+     * @param key 键
61
+     * @return true 存在 false不存在
62
+     */
63
+    public boolean hasKey(String key){
64
+        try {
65
+            return redisTemplate.hasKey(key);
66
+        } catch (Exception e) {
67
+            e.printStackTrace();
68
+            return false;
69
+        }
70
+    }
71
+
72
+    /**
73
+     * 删除缓存
74
+     * @param key 可以传一个值 或多个
75
+     */
76
+    @SuppressWarnings("unchecked")
77
+    public void del(String ... key){
78
+        if(key!=null&&key.length>0){
79
+            if(key.length==1){
80
+                redisTemplate.delete(key[0]);
81
+            }else{
82
+                redisTemplate.delete(CollectionUtils.arrayToList(key));
83
+            }
84
+        }
85
+    }
86
+
87
+    //============================String=============================
88
+    /**
89
+     * 普通缓存获取
90
+     * @param key 键
91
+     * @return 值
92
+     */
93
+    public Object get(String key){
94
+        return key==null?null:valueOperations.get(key);
95
+    }
96
+
97
+    /**
98
+     * 普通缓存放入
99
+     * @param key 键
100
+     * @param value 值
101
+     * @return true成功 false失败
102
+     */
103
+    public boolean set(String key,String value) {
104
+        try {
105
+            valueOperations.set(key, value);
106
+            return true;
107
+        } catch (Exception e) {
108
+            e.printStackTrace();
109
+            return false;
110
+        }
111
+
112
+    }
113
+
114
+    /**
115
+     * 普通缓存放入并设置时间
116
+     * @param key 键
117
+     * @param value 值
118
+     * @param time 时间(秒) time要大于0 如果time小于等于0 将设置无限期
119
+     * @return true成功 false 失败
120
+     */
121
+    public boolean set(String key,String value,long time){
122
+        try {
123
+            if(time>0){
124
+                valueOperations.set(key, value, time, TimeUnit.SECONDS);
125
+            }else{
126
+                set(key, value);
127
+            }
128
+            return true;
129
+        } catch (Exception e) {
130
+            e.printStackTrace();
131
+            return false;
132
+        }
133
+    }
134
+
135
+    /**
136
+     * 递增
137
+     * @param key 键
138
+     * @param by 要增加几(大于0)
139
+     * @return
140
+     */
141
+    public long incr(String key, long delta){
142
+        if(delta<0){
143
+            throw new RuntimeException("递增因子必须大于0");
144
+        }
145
+        return valueOperations.increment(key, delta);
146
+    }
147
+
148
+    /**
149
+     * 递减
150
+     * @param key 键
151
+     * @param by 要减少几(小于0)
152
+     * @return
153
+     */
154
+    public long decr(String key, long delta){
155
+        if(delta<0){
156
+            throw new RuntimeException("递减因子必须大于0");
157
+        }
158
+        return valueOperations.increment(key, -delta);
159
+    }
160
+
161
+    //================================Map=================================
162
+    /**
163
+     * HashGet
164
+     * @param key 键 不能为null
165
+     * @param item 项 不能为null
166
+     * @return 值
167
+     */
168
+    public Object hget(String key,String item){
169
+        return hashOperations.get(key, item);
170
+    }
171
+
172
+    /**
173
+     * 获取hashKey对应的所有键值
174
+     * @param key 键
175
+     * @return 对应的多个键值
176
+     */
177
+    public Map<String, Object> hmget(String key){
178
+        return hashOperations.entries(key);
179
+    }
180
+
181
+    /**
182
+     * HashSet
183
+     * @param key 键
184
+     * @param map 对应多个键值
185
+     * @return true 成功 false 失败
186
+     */
187
+    public boolean hmset(String key, Map<String,Object> map){
188
+        try {
189
+            hashOperations.putAll(key, map);
190
+            return true;
191
+        } catch (Exception e) {
192
+            e.printStackTrace();
193
+            return false;
194
+        }
195
+    }
196
+
197
+    /**
198
+     * HashSet 并设置时间
199
+     * @param key 键
200
+     * @param map 对应多个键值
201
+     * @param time 时间(秒)
202
+     * @return true成功 false失败
203
+     */
204
+    public boolean hmset(String key, Map<String,Object> map, long time){
205
+        try {
206
+            hashOperations.putAll(key, map);
207
+            if(time>0){
208
+                expire(key, time);
209
+            }
210
+            return true;
211
+        } catch (Exception e) {
212
+            e.printStackTrace();
213
+            return false;
214
+        }
215
+    }
216
+
217
+    /**
218
+     * 向一张hash表中放入数据,如果不存在将创建
219
+     * @param key 键
220
+     * @param item 项
221
+     * @param value 值
222
+     * @return true 成功 false失败
223
+     */
224
+    public boolean hset(String key,String item,Object value) {
225
+        try {
226
+            hashOperations.put(key, item, value);
227
+            return true;
228
+        } catch (Exception e) {
229
+            e.printStackTrace();
230
+            return false;
231
+        }
232
+    }
233
+
234
+    /**
235
+     * 向一张hash表中放入数据,如果不存在将创建
236
+     * @param key 键
237
+     * @param item 项
238
+     * @param value 值
239
+     * @param time 时间(秒)  注意:如果已存在的hash表有时间,这里将会替换原有的时间
240
+     * @return true 成功 false失败
241
+     */
242
+    public boolean hset(String key,String item,Object value,long time) {
243
+        try {
244
+            hashOperations.put(key, item, value);
245
+            if(time>0){
246
+                expire(key, time);
247
+            }
248
+            return true;
249
+        } catch (Exception e) {
250
+            e.printStackTrace();
251
+            return false;
252
+        }
253
+    }
254
+
255
+    /**
256
+     * 删除hash表中的值
257
+     * @param key 键 不能为null
258
+     * @param item 项 可以使多个 不能为null
259
+     */
260
+    public void hdel(String key, Object... item){
261
+        hashOperations.delete(key,item);
262
+    }
263
+
264
+    /**
265
+     * 判断hash表中是否有该项的值
266
+     * @param key 键 不能为null
267
+     * @param item 项 不能为null
268
+     * @return true 存在 false不存在
269
+     */
270
+    public boolean hHasKey(String key, String item){
271
+        return hashOperations.hasKey(key, item);
272
+    }
273
+
274
+    /**
275
+     * hash递增 如果不存在,就会创建一个 并把新增后的值返回
276
+     * @param key 键
277
+     * @param item 项
278
+     * @param by 要增加几(大于0)
279
+     * @return
280
+     */
281
+    public double hincr(String key, String item,double by){
282
+        return hashOperations.increment(key, item, by);
283
+    }
284
+
285
+    /**
286
+     * hash递减
287
+     * @param key 键
288
+     * @param item 项
289
+     * @param by 要减少记(小于0)
290
+     * @return
291
+     */
292
+    public double hdecr(String key, String item,double by){
293
+        return hashOperations.increment(key, item,-by);
294
+    }
295
+
296
+    //============================set=============================
297
+    /**
298
+     * 根据key获取Set中的所有值
299
+     * @param key 键
300
+     * @return
301
+     */
302
+    public Set<Object> sGet(String key){
303
+        try {
304
+            return setOperations.members(key);
305
+        } catch (Exception e) {
306
+            e.printStackTrace();
307
+            return null;
308
+        }
309
+    }
310
+
311
+    /**
312
+     * 根据value从一个set中查询,是否存在
313
+     * @param key 键
314
+     * @param value 值
315
+     * @return true 存在 false不存在
316
+     */
317
+    public boolean sHasKey(String key,Object value){
318
+        try {
319
+            return setOperations.isMember(key, value);
320
+        } catch (Exception e) {
321
+            e.printStackTrace();
322
+            return false;
323
+        }
324
+    }
325
+
326
+    /**
327
+     * 将数据放入set缓存
328
+     * @param key 键
329
+     * @param values 值 可以是多个
330
+     * @return 成功个数
331
+     */
332
+    public long sSet(String key, Object...values) {
333
+        try {
334
+            return setOperations.add(key, values);
335
+        } catch (Exception e) {
336
+            e.printStackTrace();
337
+            return 0;
338
+        }
339
+    }
340
+
341
+    /**
342
+     * 将set数据放入缓存
343
+     * @param key 键
344
+     * @param time 时间(秒)
345
+     * @param values 值 可以是多个
346
+     * @return 成功个数
347
+     */
348
+    public long sSetAndTime(String key,long time,Object...values) {
349
+        try {
350
+            Long count = setOperations.add(key, values);
351
+            if(time>0) expire(key, time);
352
+            return count;
353
+        } catch (Exception e) {
354
+            e.printStackTrace();
355
+            return 0;
356
+        }
357
+    }
358
+
359
+    /**
360
+     * 获取set缓存的长度
361
+     * @param key 键
362
+     * @return
363
+     */
364
+    public long sGetSetSize(String key){
365
+        try {
366
+            return setOperations.size(key);
367
+        } catch (Exception e) {
368
+            e.printStackTrace();
369
+            return 0;
370
+        }
371
+    }
372
+
373
+    /**
374
+     * 移除值为value的
375
+     * @param key 键
376
+     * @param values 值 可以是多个
377
+     * @return 移除的个数
378
+     */
379
+    public long setRemove(String key, Object ...values) {
380
+        try {
381
+            Long count = setOperations.remove(key, values);
382
+            return count;
383
+        } catch (Exception e) {
384
+            e.printStackTrace();
385
+            return 0;
386
+        }
387
+    }
388
+    //===============================list=================================
389
+
390
+    /**
391
+     * 获取list缓存的内容
392
+     * @param key 键
393
+     * @param start 开始
394
+     * @param end 结束  0 到 -1代表所有值
395
+     * @return
396
+     */
397
+    public List<Object> lGet(String key, long start, long end){
398
+        try {
399
+            return listOperations.range(key, start, end);
400
+        } catch (Exception e) {
401
+            e.printStackTrace();
402
+            return null;
403
+        }
404
+    }
405
+
406
+    /**
407
+     * 获取list缓存的所有内容
408
+     * @param key
409
+     * @return
410
+     */
411
+    public List<Object> lGetAll(String key){
412
+        return lGet(key,0,-1);
413
+    }
414
+
415
+    /**
416
+     * 获取list缓存的长度
417
+     * @param key 键
418
+     * @return
419
+     */
420
+    public long lGetListSize(String key){
421
+        try {
422
+            return listOperations.size(key);
423
+        } catch (Exception e) {
424
+            e.printStackTrace();
425
+            return 0;
426
+        }
427
+    }
428
+
429
+    /**
430
+     * 通过索引 获取list中的值
431
+     * @param key 键
432
+     * @param index 索引  index>=0时, 0 表头,1 第二个元素,依次类推;index<0时,-1,表尾,-2倒数第二个元素,依次类推
433
+     * @return
434
+     */
435
+    public Object lGetIndex(String key,long index){
436
+        try {
437
+            return listOperations.index(key, index);
438
+        } catch (Exception e) {
439
+            e.printStackTrace();
440
+            return null;
441
+        }
442
+    }
443
+
444
+    /**
445
+     * 将list放入缓存
446
+     * @param key 键
447
+     * @param value 值
448
+     * @param time 时间(秒)
449
+     * @return
450
+     */
451
+    public boolean lSet(String key, Object value) {
452
+        try {
453
+            listOperations.rightPush(key, value);
454
+            return true;
455
+        } catch (Exception e) {
456
+            e.printStackTrace();
457
+            return false;
458
+        }
459
+    }
460
+
461
+    /**
462
+     * 将list放入缓存
463
+     * @param key 键
464
+     * @param value 值
465
+     * @param time 时间(秒)
466
+     * @return
467
+     */
468
+    public boolean lSet(String key, Object value, long time) {
469
+        try {
470
+            listOperations.rightPush(key, value);
471
+            if (time > 0) expire(key, time);
472
+            return true;
473
+        } catch (Exception e) {
474
+            e.printStackTrace();
475
+            return false;
476
+        }
477
+    }
478
+
479
+    /**
480
+     * 将list放入缓存
481
+     * @param key 键
482
+     * @param value 值
483
+     * @param time 时间(秒)
484
+     * @return
485
+     */
486
+    public boolean lSet(String key, List<Object> value) {
487
+        try {
488
+            listOperations.rightPushAll(key, value);
489
+            return true;
490
+        } catch (Exception e) {
491
+            e.printStackTrace();
492
+            return false;
493
+        }
494
+    }
495
+
496
+    /**
497
+     * 将list放入缓存
498
+     * @param key 键
499
+     * @param value 值
500
+     * @param time 时间(秒)
501
+     * @return
502
+     */
503
+    public boolean lSet(String key, List<Object> value, long time) {
504
+        try {
505
+            listOperations.rightPushAll(key, value);
506
+            if (time > 0) expire(key, time);
507
+            return true;
508
+        } catch (Exception e) {
509
+            e.printStackTrace();
510
+            return false;
511
+        }
512
+    }
513
+
514
+    /**
515
+     * 根据索引修改list中的某条数据
516
+     * @param key 键
517
+     * @param index 索引
518
+     * @param value 值
519
+     * @return
520
+     */
521
+    public boolean lUpdateIndex(String key, long index,Object value) {
522
+        try {
523
+            listOperations.set(key, index, value);
524
+            return true;
525
+        } catch (Exception e) {
526
+            e.printStackTrace();
527
+            return false;
528
+        }
529
+    }
530
+
531
+    /**
532
+     * 移除N个值为value
533
+     * @param key 键
534
+     * @param count 移除多少个
535
+     * @param value 值
536
+     * @return 移除的个数
537
+     */
538
+    public long lRemove(String key,long count,Object value) {
539
+        try {
540
+            Long remove = listOperations.remove(key, count, value);
541
+            return remove;
542
+        } catch (Exception e) {
543
+            e.printStackTrace();
544
+            return 0;
545
+        }
546
+    }
547
+}

+ 39 - 0
src/main/java/com/chinaitop/depot/utils/WebConfig.java

@@ -0,0 +1,39 @@
1
+package com.chinaitop.depot.utils;
2
+
3
+import org.springframework.boot.web.servlet.FilterRegistrationBean;
4
+import org.springframework.context.annotation.Bean;
5
+import org.springframework.context.annotation.Configuration;
6
+import java.util.ArrayList;
7
+import java.util.List;
8
+
9
+/**
10
+ * @desc 注册bean, 将自定义过滤器添加到过滤器链中
11
+ * @Author hf
12
+ * @date 2019/3/11
13
+ * @return
14
+ */
15
+@Configuration
16
+public class WebConfig {
17
+
18
+   /**
19
+    * 注册过滤器,有两种方式:
20
+    * 1) 使用 @Component 注解<br>
21
+    * 2) 添加到过滤器链中,此方式适用于使用第三方的过滤器。将过滤器写到 WebConfig 类中,如下:
22
+    */
23
+   @Bean
24
+   public FilterRegistrationBean filterRegistrationBean() {
25
+
26
+      FilterRegistrationBean registrationBean = new FilterRegistrationBean();
27
+
28
+      CustomFilter filter = new CustomFilter();
29
+      registrationBean.setFilter(filter);
30
+
31
+      //设置过滤器拦截请求
32
+      List<String> urls = new ArrayList<>();
33
+      urls.add("/*");
34
+      registrationBean.setUrlPatterns(urls);
35
+
36
+      return registrationBean;
37
+   }
38
+
39
+}

+ 51 - 0
src/main/resources/bootstrap.yml

@@ -0,0 +1,51 @@
1
+server:
2
+  port: 9008
3
+  tomcat:
4
+    uri-encoding: utf-8
5
+
6
+# 注册中心配置
7
+eureka:
8
+  client:
9
+    service-url:
10
+      defaultZone: http://eureka-depot-yn:9001/eureka/
11
+  instance:
12
+    prefer-ip-address: true
13
+    # 每隔10s发送一次心跳(默认30s)
14
+    lease-renewal-interval-in-seconds: 10
15
+    # 告知服务端30秒还未收到心跳的话,就将该服务移除列表(默认90s)
16
+    lease-expiration-duration-in-seconds: 30
17
+
18
+spring:
19
+  application:
20
+    name: depot-keeper-house
21
+  # 数据库配置
22
+  datasource:
23
+    driver-class-name: com.mysql.jdbc.Driver
24
+    url: jdbc:mysql://192.168.123.38:3306/depot_yunnan?useUnicode=true&characterEncoding=utf-8
25
+    username: root
26
+    password: 123456
27
+  # 缓存配置
28
+  session:
29
+    store-type: redis
30
+  redis:
31
+    database: 0
32
+    host: 192.168.123.98
33
+    port: 6666
34
+    password: depotredis
35
+    timeout: 3000
36
+    jedis:
37
+      pool:
38
+        max-active: 8
39
+        max-wait: -1
40
+        max-idle: 8
41
+        min-idle: 0
42
+  # 静态资源配置
43
+  resources:
44
+    static-locations: classpath:/META-INF/resources/,classpath:/resources/,classpath:/static/,classpath:/public/,file:${web.upload-path}
45
+ 
46
+web:
47
+  upload-path: /home/depot/depot-web/apache-tomcat-8.0.53/webapps/ROOT/WEB-INF/classes/static
48
+
49
+  jackson:
50
+    date-format: yyyy-MM-dd
51
+    time-zone: GMT+8

+ 58 - 0
src/main/resources/generatorConfig.xml

@@ -0,0 +1,58 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<!DOCTYPE generatorConfiguration
3
+  PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
4
+  "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">
5
+
6
+<generatorConfiguration>
7
+	<context id="testTables" targetRuntime="MyBatis3">
8
+		<!-- 生成注释时,必须加type="MyCommentGenerator" -->
9
+		<commentGenerator type="com.chinaitop.depot.utils.MyCommentGenerator">
10
+			<!-- 是否去除自动生成的注释 true:是 : false:否 -->
11
+			<property name="suppressAllComments" value="false" />
12
+		</commentGenerator>
13
+		
14
+		<!--数据库连接的信息:驱动类、连接地址、用户名、密码 -->
15
+		<jdbcConnection 
16
+			driverClass="com.mysql.jdbc.Driver"
17
+			connectionURL="jdbc:mysql://192.168.123.98:3306/depot" 
18
+			userId="root"
19
+			password="123456">
20
+		</jdbcConnection>
21
+		
22
+		<!-- 默认false,把JDBC DECIMAL 和 NUMERIC 类型解析为 Integer,为 true时把JDBC DECIMAL 和 
23
+			NUMERIC 类型解析为java.math.BigDecimal -->
24
+		<javaTypeResolver>
25
+			<property name="forceBigDecimals" value="false" />
26
+		</javaTypeResolver>
27
+
28
+		<!-- targetProject:生成PO类的位置 -->
29
+		<javaModelGenerator targetPackage="com.chinaitop.depot.keeperAccount.model"
30
+			targetProject=".\src\main\java">
31
+			<!-- enableSubPackages:是否让schema作为包的后缀 -->
32
+			<property name="enableSubPackages" value="false" />
33
+			<!-- 从数据库返回的值被清理前后的空格 -->
34
+			<property name="trimStrings" value="true" />
35
+		</javaModelGenerator>
36
+		
37
+        <!-- targetProject:mapper映射文件生成的位置 -->
38
+		<sqlMapGenerator targetPackage="com.chinaitop.depot.keeperAccount.mapper" 
39
+			targetProject=".\src\main\java">
40
+			<!-- enableSubPackages:是否让schema作为包的后缀 -->
41
+			<property name="enableSubPackages" value="false" />
42
+		</sqlMapGenerator>
43
+		
44
+		<!-- targetPackage:mapper接口生成的位置 -->
45
+		<javaClientGenerator type="XMLMAPPER"
46
+			targetPackage="com.chinaitop.depot.keeperAccount.mapper" 
47
+			targetProject=".\src\main\java">
48
+			<!-- enableSubPackages:是否让schema作为包的后缀 -->
49
+			<property name="enableSubPackages" value="false" />
50
+		</javaClientGenerator>
51
+		
52
+		<!-- 指定要反向生成的数据库表 -->
53
+		<table schema="" tableName="storage_account_record"></table>
54
+<!-- 		<table schema="" tableName="basic_process_sub"></table> -->
55
+<!-- 		<table schema="" tableName="basic_process_contrail"></table> -->
56
+
57
+	</context>
58
+</generatorConfiguration>