fanxw 6 lat temu
rodzic
commit
6fbd0cac16
22 zmienionych plików z 3646 dodań i 0 usunięć
  1. 6 0
      Dockerfile
  2. 152 0
      pom.xml
  3. 152 0
      src/main/java/com/chinaitop/DatePermissionInterceptor.java
  4. 18 0
      src/main/java/com/chinaitop/DepotNumbermanageApplication.java
  5. 12 0
      src/main/java/com/chinaitop/HelloWebXml.java
  6. 35 0
      src/main/java/com/chinaitop/SwaggerConfig.java
  7. 196 0
      src/main/java/com/chinaitop/depot/controller/StorageProfitlossSheetController.java
  8. 30 0
      src/main/java/com/chinaitop/depot/mapper/StorageProfitlossSheetMapper.java
  9. 401 0
      src/main/java/com/chinaitop/depot/mapper/StorageProfitlossSheetMapper.xml
  10. 175 0
      src/main/java/com/chinaitop/depot/model/StorageProfitlossSheet.java
  11. 1281 0
      src/main/java/com/chinaitop/depot/model/StorageProfitlossSheetExample.java
  12. 24 0
      src/main/java/com/chinaitop/depot/service/StorageProfitlossSheetService.java
  13. 54 0
      src/main/java/com/chinaitop/depot/service/impl/StorageProfitlossSheetServiceImpl.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. 66 0
      src/main/java/com/chinaitop/depot/utils/RedisConfig.java
  17. 547 0
      src/main/java/com/chinaitop/depot/utils/RedisUtil.java
  18. 39 0
      src/main/java/com/chinaitop/depot/utils/WebConfig.java
  19. 113 0
      src/main/java/com/chinaitop/utils/PageUtils.java
  20. 173 0
      src/main/java/com/chinaitop/utils/ParameterUtil.java
  21. 51 0
      src/main/resources/bootstrap.yml
  22. 16 0
      src/test/java/com/chinaitop/DepotNumbermanageApplicationTests.java

+ 6 - 0
Dockerfile

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

+ 152 - 0
pom.xml

@@ -0,0 +1,152 @@
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-number-manage</artifactId>
8
+    <version>0.0.1-SNAPSHOT</version>
9
+    <packaging>jar</packaging>
10
+
11
+    <name>depot-number-manage</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
+        <!-- web模块 -->
30
+        <dependency>
31
+            <groupId>org.springframework.boot</groupId>
32
+            <artifactId>spring-boot-starter-web</artifactId>
33
+        </dependency>
34
+        <!-- test模块 -->
35
+        <dependency>
36
+            <groupId>org.springframework.boot</groupId>
37
+            <artifactId>spring-boot-starter-test</artifactId>
38
+            <scope>test</scope>
39
+        </dependency>
40
+        <!-- mysql -->
41
+        <dependency>
42
+            <groupId>mysql</groupId>
43
+            <artifactId>mysql-connector-java</artifactId>
44
+        </dependency>
45
+        <!-- mybatis -->
46
+        <dependency>
47
+            <groupId>org.mybatis.spring.boot</groupId>
48
+            <artifactId>mybatis-spring-boot-starter</artifactId>
49
+            <version>1.3.1</version>
50
+        </dependency>
51
+        <!-- 导入eureka-server服务的依赖 -->
52
+        <dependency>
53
+            <groupId>org.springframework.cloud</groupId>
54
+            <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
55
+        </dependency>
56
+        <dependency>
57
+            <groupId>org.springframework.cloud</groupId>
58
+            <artifactId>spring-cloud-starter-config</artifactId>
59
+        </dependency>
60
+        <!-- swagger2 -->
61
+        <dependency>
62
+            <groupId>io.springfox</groupId>
63
+            <artifactId>springfox-swagger2</artifactId>
64
+            <version>2.6.1</version>
65
+        </dependency>
66
+        <dependency>
67
+            <groupId>io.springfox</groupId>
68
+            <artifactId>springfox-swagger-ui</artifactId>
69
+            <version>2.6.1</version>
70
+        </dependency>
71
+        <!-- 引入spring boot自带的pagehelper插件 -->
72
+        <dependency>
73
+            <groupId>com.github.pagehelper</groupId>
74
+            <artifactId>pagehelper-spring-boot-starter</artifactId>
75
+            <version>1.2.3</version>
76
+        </dependency>
77
+        <!-- commons工具类jar -->
78
+        <dependency>
79
+            <groupId>org.apache.commons</groupId>
80
+            <artifactId>commons-lang3</artifactId>
81
+            <version>3.7</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
+    </dependencies>
98
+
99
+    <!-- 导入Spring Cloud的依赖管理 -->
100
+   <dependencyManagement>
101
+		<dependencies>
102
+			<dependency>
103
+				<groupId>org.springframework.cloud</groupId>
104
+				<artifactId>spring-cloud-dependencies</artifactId>
105
+				<version>${spring-cloud.version}</version>
106
+				<type>pom</type>
107
+				<scope>import</scope>
108
+			</dependency>
109
+		</dependencies>
110
+	</dependencyManagement>
111
+
112
+    <build>
113
+        <finalName>${project.artifactId}</finalName>
114
+        <plugins>
115
+            <plugin>
116
+                <groupId>org.springframework.boot</groupId>
117
+                <artifactId>spring-boot-maven-plugin</artifactId>
118
+            </plugin>
119
+            <plugin>
120
+                <groupId>org.apache.maven.plugins</groupId>
121
+                <artifactId>maven-surefire-plugin</artifactId>
122
+                <configuration>
123
+                    <skip>true</skip>
124
+                </configuration>
125
+            </plugin>
126
+        </plugins>
127
+        <!-- 配置资源节点 -->
128
+        <resources>
129
+            <resource>
130
+                <directory>src/main/java</directory>
131
+                <includes>
132
+                    <include>**/*.xml</include>
133
+                </includes>
134
+            </resource>
135
+            <resource>
136
+                <directory>src/main/resources</directory>
137
+            </resource>
138
+        </resources>
139
+    </build>
140
+
141
+    <repositories>
142
+        <repository>
143
+            <id>spring-milestones</id>
144
+            <name>Spring Milestones</name>
145
+            <url>https://repo.spring.io/milestone</url>
146
+            <snapshots>
147
+                <enabled>false</enabled>
148
+            </snapshots>
149
+        </repository>
150
+    </repositories>
151
+
152
+</project>

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

@@ -0,0 +1,152 @@
1
+package com.chinaitop;
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
+}

+ 18 - 0
src/main/java/com/chinaitop/DepotNumbermanageApplication.java

@@ -0,0 +1,18 @@
1
+package com.chinaitop;
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
+@SpringBootApplication
10
+@EnableDiscoveryClient
11
+@EnableEurekaClient
12
+@MapperScan(basePackages = {"com.chinaitop.depot.mapper"})
13
+public class DepotNumbermanageApplication {
14
+
15
+    public static void main(String[] args) {
16
+        SpringApplication.run(DepotNumbermanageApplication.class, args);
17
+    }
18
+}

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

@@ -0,0 +1,12 @@
1
+package com.chinaitop;
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(DepotNumbermanageApplication.class);
10
+    }
11
+ 
12
+}

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

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

+ 196 - 0
src/main/java/com/chinaitop/depot/controller/StorageProfitlossSheetController.java

@@ -0,0 +1,196 @@
1
+package com.chinaitop.depot.controller;
2
+
3
+import java.io.IOException;
4
+import java.util.HashMap;
5
+import java.util.List;
6
+import java.util.Map;
7
+
8
+import javax.annotation.Resource;
9
+import javax.servlet.http.HttpServletRequest;
10
+
11
+import org.apache.commons.lang.ObjectUtils;
12
+import org.springframework.http.MediaType;
13
+import org.springframework.web.bind.annotation.RequestMapping;
14
+import org.springframework.web.bind.annotation.RequestMethod;
15
+import org.springframework.web.bind.annotation.RestController;
16
+
17
+import com.alibaba.fastjson.JSONObject;
18
+import com.chinaitop.depot.model.StorageProfitlossSheet;
19
+import com.chinaitop.depot.model.StorageProfitlossSheetExample;
20
+import com.chinaitop.depot.service.StorageProfitlossSheetService;
21
+import com.chinaitop.utils.ParameterUtil;
22
+import com.fasterxml.jackson.databind.ObjectMapper;
23
+import com.github.pagehelper.PageHelper;
24
+import com.github.pagehelper.PageInfo;
25
+
26
+import io.swagger.annotations.Api;
27
+import io.swagger.annotations.ApiImplicitParam;
28
+import io.swagger.annotations.ApiImplicitParams;
29
+import io.swagger.annotations.ApiOperation;
30
+
31
+/**
32
+ * @author qingsong.han
33
+ * @description: 损益单管理
34
+ * @create 2018-06-27 11:03
35
+ */
36
+@RestController
37
+@RequestMapping(value = "/storageSheet")
38
+@Api(value = "StorageProfitlossSheetController", description = "损益单管理类")
39
+public class StorageProfitlossSheetController {
40
+    @Resource
41
+    private StorageProfitlossSheetService storageProfitlossSheetService;
42
+
43
+    /**
44
+     * 损益单管理列表
45
+     *
46
+     * @param pageNum
47
+     * @param pageSize
48
+     * @return pageInfo
49
+     */
50
+    @RequestMapping(value = "/getList", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
51
+    @ApiOperation(value = "损益单管理列表", notes = "损益单管理列表信息, 支持分页")
52
+    @ApiImplicitParams({
53
+            @ApiImplicitParam(name = "pageNum", value = "页码", paramType = "query", defaultValue = "1"),
54
+            @ApiImplicitParam(name = "pageSize", value = "每页条数", paramType = "query", defaultValue = "10"),
55
+            @ApiImplicitParam(name = "houseId", value = "仓房id", paramType = "query"),
56
+            @ApiImplicitParam(name = "warehouseId", value = "货位号id", paramType = "query"),
57
+            @ApiImplicitParam(name = "searchStartDate", value = "条件搜索开始日期(例:2018-07-04)", paramType = "query"),
58
+            @ApiImplicitParam(name = "searchEndDate", value = "条件搜索结束日期(例:2018-07-04)", paramType = "query")
59
+    })
60
+    public PageInfo<StorageProfitlossSheet> getpaymentList(HttpServletRequest request, Integer pageNum, Integer pageSize, Integer houseId, Integer warehouseId, String searchStartDate, String searchEndDate) {
61
+        StorageProfitlossSheetExample example = new StorageProfitlossSheetExample();
62
+        //查询对象条件查询
63
+        StorageProfitlossSheetExample.Criteria createCriteria = example.createCriteria();
64
+        if (null != houseId) {
65
+            createCriteria.andHouseIdEqualTo(houseId);
66
+        }
67
+        if (null != warehouseId) {
68
+            createCriteria.andWarehouseIdEqualTo(warehouseId);
69
+        }
70
+        if (ParameterUtil.isnotnull(searchStartDate) && ParameterUtil.isnotnull(searchEndDate)) {
71
+            createCriteria.andFillTimeBetween(ParameterUtil.string2datetime(searchStartDate+ParameterUtil.startTime), ParameterUtil.string2datetime(searchEndDate+ParameterUtil.endTime));
72
+        }
73
+        String orgId = ObjectUtils.toString(request.getSession().getAttribute("orgId"));
74
+        createCriteria.andOrgIdEqualTo(orgId);
75
+        
76
+        //分页
77
+        PageHelper.startPage(pageNum, pageSize);
78
+        example.setOrderByClause("fill_time desc, id desc");
79
+        List<StorageProfitlossSheet> list = storageProfitlossSheetService.queryByExample(example);
80
+        PageInfo<StorageProfitlossSheet> pageInfo = new PageInfo<StorageProfitlossSheet>(list);
81
+        return pageInfo;
82
+    }
83
+
84
+    /**
85
+     * 根据仓号,货位号查询实际库存
86
+     * @param pageNum
87
+     * @param pageSize
88
+     * @param houseId
89
+     * @param warehouseId
90
+     * @return pageInfo
91
+     */
92
+    @RequestMapping(value = "/getLists", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
93
+    @ApiOperation(value = "获取上一次的损益单", notes = "获取上一次的损益单列表信息, 支持分页")
94
+    @ApiImplicitParams({
95
+            @ApiImplicitParam(name = "pageNum", value = "页码", paramType = "query", defaultValue = "1"),
96
+            @ApiImplicitParam(name = "pageSize", value = "每页条数", paramType = "query", defaultValue = "10"),
97
+            @ApiImplicitParam(name = "houseId", value = "仓房id", paramType = "query"),
98
+            @ApiImplicitParam(name = "warehouseId", value = "货位号id", paramType = "query")
99
+    })
100
+    public PageInfo<StorageProfitlossSheet> getpaymentLists(Integer pageNum, Integer pageSize, Integer houseId, Integer warehouseId) {
101
+        StorageProfitlossSheetExample example = new StorageProfitlossSheetExample();
102
+        StorageProfitlossSheetExample.Criteria createCriteria = example.createCriteria();
103
+        //查询条件
104
+        if (null != houseId && null != warehouseId) {
105
+            createCriteria.andHouseIdEqualTo(houseId);
106
+            createCriteria.andWarehouseIdEqualTo(warehouseId);
107
+            PageHelper.startPage(pageNum, pageSize);
108
+            example.setOrderByClause("fill_time desc, id desc");
109
+            List<StorageProfitlossSheet> list = storageProfitlossSheetService.queryByExample(example);
110
+            PageInfo<StorageProfitlossSheet> pageInfo = new PageInfo<StorageProfitlossSheet>(list);
111
+
112
+            return pageInfo;
113
+        }
114
+        return null;
115
+
116
+    }
117
+
118
+    /**
119
+     * 保存方法
120
+     *
121
+     * @param storageProfitlossSheetJson
122
+     * @return
123
+     */
124
+    @RequestMapping(value = "/save", produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.POST)
125
+    @ApiOperation(value = "损益单管理新增列表", notes = "损益单管理新增信息")
126
+    @ApiImplicitParams({
127
+            @ApiImplicitParam(name = "storageProfitlossSheetJson", value = "数据对象", paramType = "form"),
128
+            @ApiImplicitParam(name = "storageProfitlossSheetJson", value = "数据对象", paramType = "form")
129
+    })
130
+    public Map<String, Object> save(String storageProfitlossSheetJson, String userInfo) {
131
+        //登录用户名
132
+        JSONObject user = null;
133
+        String realName = "";
134
+        String orgId = "";
135
+        if (null != userInfo && !"".equals(userInfo)) {
136
+        	user = JSONObject.parseObject(userInfo);
137
+        	realName = user.get("realName") == null?"":user.get("realName").toString();
138
+        	orgId = user.get("orgId") == null?"":user.get("orgId").toString();
139
+        }
140
+        Map<String, Object> modelMap = new HashMap<>();
141
+        try {
142
+            // JSON字符串转对象
143
+            ObjectMapper mapper = new ObjectMapper();
144
+            StorageProfitlossSheet storageProfitlossSheets = mapper.readValue(storageProfitlossSheetJson, StorageProfitlossSheet.class);
145
+            storageProfitlossSheets.setOrgId(orgId);
146
+            if (storageProfitlossSheets.getId() == null) {
147
+                storageProfitlossSheetService.add(storageProfitlossSheets, realName); //使用到userInfo.realName
148
+            } else {
149
+                storageProfitlossSheetService.update(storageProfitlossSheets);
150
+            }
151
+            modelMap.put("status", "success");
152
+        } catch (Exception e) {
153
+            modelMap.put("status", "error");
154
+            e.printStackTrace();
155
+        }
156
+        return modelMap;
157
+    }
158
+
159
+    /**
160
+     * 根据id查询
161
+     *
162
+     * @param id 主键
163
+     * @return
164
+     */
165
+    @RequestMapping(value = "/edit", produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.GET)
166
+    @ApiOperation(value = "损益单管理查看", notes = "损益单管理查看信息")
167
+    @ApiImplicitParam(name = "id", value = "修改信息id", paramType = "query")
168
+    public StorageProfitlossSheet edit(Integer id) {
169
+        StorageProfitlossSheet storageProfitlossSheet = new StorageProfitlossSheet();
170
+        if (id != null) {
171
+            storageProfitlossSheet = storageProfitlossSheetService.findById(id);
172
+        }
173
+        return storageProfitlossSheet;
174
+    }
175
+
176
+    /**
177
+     * 删除(同时删除流程)
178
+     *
179
+     * @param id 主键
180
+     * @return
181
+     * @throws IOException
182
+     */
183
+    @RequestMapping(value = "/remove", produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.POST)
184
+    @ApiOperation(value = "损益单管理删除", notes = "损益单管理删除列表信息")
185
+    @ApiImplicitParam(name = "integerId", value = "删除的信息Id", paramType = "form")
186
+    public Map<String, Object> remove(Integer id) {
187
+        Map<String, Object> modelMap = new HashMap<>();
188
+        if (id != null) {
189
+            storageProfitlossSheetService.remove(id);
190
+            modelMap.put("status", "success");
191
+        } else {
192
+            modelMap.put("status", "error");
193
+        }
194
+        return modelMap;
195
+    }
196
+}

+ 30 - 0
src/main/java/com/chinaitop/depot/mapper/StorageProfitlossSheetMapper.java

@@ -0,0 +1,30 @@
1
+package com.chinaitop.depot.mapper;
2
+
3
+import com.chinaitop.depot.model.StorageProfitlossSheet;
4
+import com.chinaitop.depot.model.StorageProfitlossSheetExample;
5
+import java.util.List;
6
+import org.apache.ibatis.annotations.Param;
7
+
8
+public interface StorageProfitlossSheetMapper {
9
+    int countByExample(StorageProfitlossSheetExample example);
10
+
11
+    int deleteByExample(StorageProfitlossSheetExample example);
12
+
13
+    int deleteByPrimaryKey(Integer id);
14
+
15
+    int insert(StorageProfitlossSheet record);
16
+
17
+    int insertSelective(StorageProfitlossSheet record);
18
+
19
+    List<StorageProfitlossSheet> selectByExample(StorageProfitlossSheetExample example);
20
+
21
+    StorageProfitlossSheet selectByPrimaryKey(Integer id);
22
+
23
+    int updateByExampleSelective(@Param("record") StorageProfitlossSheet record, @Param("example") StorageProfitlossSheetExample example);
24
+
25
+    int updateByExample(@Param("record") StorageProfitlossSheet record, @Param("example") StorageProfitlossSheetExample example);
26
+
27
+    int updateByPrimaryKeySelective(StorageProfitlossSheet record);
28
+
29
+    int updateByPrimaryKey(StorageProfitlossSheet record);
30
+}

+ 401 - 0
src/main/java/com/chinaitop/depot/mapper/StorageProfitlossSheetMapper.xml

@@ -0,0 +1,401 @@
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.mapper.StorageProfitlossSheetMapper" >
4
+  <resultMap id="BaseResultMap" type="com.chinaitop.depot.model.StorageProfitlossSheet" >
5
+    <id column="id" property="id" jdbcType="INTEGER" />
6
+    <result column="org_id" property="orgId" jdbcType="VARCHAR" />
7
+    <result column="house_id" property="houseId" jdbcType="INTEGER" />
8
+    <result column="warehouse_id" property="warehouseId" jdbcType="INTEGER" />
9
+    <result column="lsxz_id" property="lsxzId" jdbcType="INTEGER" />
10
+    <result column="grain_kind" property="grainKind" jdbcType="INTEGER" />
11
+    <result column="grain_grade" property="grainGrade" jdbcType="INTEGER" />
12
+    <result column="income_tonnage" property="incomeTonnage" jdbcType="VARCHAR" />
13
+    <result column="inventory_year" property="inventoryYear" jdbcType="INTEGER" />
14
+    <result column="loss_type" property="lossType" jdbcType="INTEGER" />
15
+    <result column="profit_ratio" property="profitRatio" jdbcType="VARCHAR" />
16
+    <result column="actual_stock" property="actualStock" jdbcType="VARCHAR" />
17
+    <result column="production_year" property="productionYear" jdbcType="INTEGER" />
18
+    <result column="remark" property="remark" jdbcType="VARCHAR" />
19
+    <result column="fill_time" property="fillTime" jdbcType="TIMESTAMP" />
20
+    <result column="fill_person" property="fillPerson" jdbcType="VARCHAR" />
21
+    <result column="updatetime" property="updatetime" jdbcType="TIMESTAMP" />
22
+  </resultMap>
23
+  <sql id="Example_Where_Clause" >
24
+    <where >
25
+      <foreach collection="oredCriteria" item="criteria" separator="or" >
26
+        <if test="criteria.valid" >
27
+          <trim prefix="(" suffix=")" prefixOverrides="and" >
28
+            <foreach collection="criteria.criteria" item="criterion" >
29
+              <choose >
30
+                <when test="criterion.noValue" >
31
+                  and ${criterion.condition}
32
+                </when>
33
+                <when test="criterion.singleValue" >
34
+                  and ${criterion.condition} #{criterion.value}
35
+                </when>
36
+                <when test="criterion.betweenValue" >
37
+                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
38
+                </when>
39
+                <when test="criterion.listValue" >
40
+                  and ${criterion.condition}
41
+                  <foreach collection="criterion.value" item="listItem" open="(" close=")" separator="," >
42
+                    #{listItem}
43
+                  </foreach>
44
+                </when>
45
+              </choose>
46
+            </foreach>
47
+          </trim>
48
+        </if>
49
+      </foreach>
50
+    </where>
51
+  </sql>
52
+  <sql id="Update_By_Example_Where_Clause" >
53
+    <where >
54
+      <foreach collection="example.oredCriteria" item="criteria" separator="or" >
55
+        <if test="criteria.valid" >
56
+          <trim prefix="(" suffix=")" prefixOverrides="and" >
57
+            <foreach collection="criteria.criteria" item="criterion" >
58
+              <choose >
59
+                <when test="criterion.noValue" >
60
+                  and ${criterion.condition}
61
+                </when>
62
+                <when test="criterion.singleValue" >
63
+                  and ${criterion.condition} #{criterion.value}
64
+                </when>
65
+                <when test="criterion.betweenValue" >
66
+                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
67
+                </when>
68
+                <when test="criterion.listValue" >
69
+                  and ${criterion.condition}
70
+                  <foreach collection="criterion.value" item="listItem" open="(" close=")" separator="," >
71
+                    #{listItem}
72
+                  </foreach>
73
+                </when>
74
+              </choose>
75
+            </foreach>
76
+          </trim>
77
+        </if>
78
+      </foreach>
79
+    </where>
80
+  </sql>
81
+  <sql id="Base_Column_List" >
82
+    id, org_id, house_id, warehouse_id, lsxz_id, grain_kind, grain_grade, income_tonnage, 
83
+    inventory_year, loss_type, profit_ratio, actual_stock, production_year, remark, fill_time, 
84
+    fill_person, updatetime
85
+  </sql>
86
+  <select id="selectByExample" resultMap="BaseResultMap" parameterType="com.chinaitop.depot.model.StorageProfitlossSheetExample" >
87
+    select
88
+    <if test="distinct" >
89
+      distinct
90
+    </if>
91
+    <include refid="Base_Column_List" />
92
+    from storage_profitloss_sheet
93
+    <if test="_parameter != null" >
94
+      <include refid="Example_Where_Clause" />
95
+    </if>
96
+    <if test="orderByClause != null" >
97
+      order by ${orderByClause}
98
+    </if>
99
+  </select>
100
+  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
101
+    select 
102
+    <include refid="Base_Column_List" />
103
+    from storage_profitloss_sheet
104
+    where id = #{id,jdbcType=INTEGER}
105
+  </select>
106
+  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
107
+    delete from storage_profitloss_sheet
108
+    where id = #{id,jdbcType=INTEGER}
109
+  </delete>
110
+  <delete id="deleteByExample" parameterType="com.chinaitop.depot.model.StorageProfitlossSheetExample" >
111
+    delete from storage_profitloss_sheet
112
+    <if test="_parameter != null" >
113
+      <include refid="Example_Where_Clause" />
114
+    </if>
115
+  </delete>
116
+  <insert id="insert" parameterType="com.chinaitop.depot.model.StorageProfitlossSheet" >
117
+    insert into storage_profitloss_sheet (id, org_id, house_id, 
118
+      warehouse_id, lsxz_id, grain_kind, 
119
+      grain_grade, income_tonnage, inventory_year, 
120
+      loss_type, profit_ratio, actual_stock, 
121
+      production_year, remark, fill_time, 
122
+      fill_person, updatetime)
123
+    values (#{id,jdbcType=INTEGER}, #{orgId,jdbcType=VARCHAR}, #{houseId,jdbcType=INTEGER}, 
124
+      #{warehouseId,jdbcType=INTEGER}, #{lsxzId,jdbcType=INTEGER}, #{grainKind,jdbcType=INTEGER}, 
125
+      #{grainGrade,jdbcType=INTEGER}, #{incomeTonnage,jdbcType=VARCHAR}, #{inventoryYear,jdbcType=INTEGER}, 
126
+      #{lossType,jdbcType=INTEGER}, #{profitRatio,jdbcType=VARCHAR}, #{actualStock,jdbcType=VARCHAR}, 
127
+      #{productionYear,jdbcType=INTEGER}, #{remark,jdbcType=VARCHAR}, #{fillTime,jdbcType=TIMESTAMP}, 
128
+      #{fillPerson,jdbcType=VARCHAR}, #{updatetime,jdbcType=TIMESTAMP})
129
+  </insert>
130
+  <insert id="insertSelective" parameterType="com.chinaitop.depot.model.StorageProfitlossSheet" >
131
+    insert into storage_profitloss_sheet
132
+    <trim prefix="(" suffix=")" suffixOverrides="," >
133
+      <if test="id != null" >
134
+        id,
135
+      </if>
136
+      <if test="orgId != null" >
137
+        org_id,
138
+      </if>
139
+      <if test="houseId != null" >
140
+        house_id,
141
+      </if>
142
+      <if test="warehouseId != null" >
143
+        warehouse_id,
144
+      </if>
145
+      <if test="lsxzId != null" >
146
+        lsxz_id,
147
+      </if>
148
+      <if test="grainKind != null" >
149
+        grain_kind,
150
+      </if>
151
+      <if test="grainGrade != null" >
152
+        grain_grade,
153
+      </if>
154
+      <if test="incomeTonnage != null" >
155
+        income_tonnage,
156
+      </if>
157
+      <if test="inventoryYear != null" >
158
+        inventory_year,
159
+      </if>
160
+      <if test="lossType != null" >
161
+        loss_type,
162
+      </if>
163
+      <if test="profitRatio != null" >
164
+        profit_ratio,
165
+      </if>
166
+      <if test="actualStock != null" >
167
+        actual_stock,
168
+      </if>
169
+      <if test="productionYear != null" >
170
+        production_year,
171
+      </if>
172
+      <if test="remark != null" >
173
+        remark,
174
+      </if>
175
+      <if test="fillTime != null" >
176
+        fill_time,
177
+      </if>
178
+      <if test="fillPerson != null" >
179
+        fill_person,
180
+      </if>
181
+      <if test="updatetime != null" >
182
+        updatetime,
183
+      </if>
184
+    </trim>
185
+    <trim prefix="values (" suffix=")" suffixOverrides="," >
186
+      <if test="id != null" >
187
+        #{id,jdbcType=INTEGER},
188
+      </if>
189
+      <if test="orgId != null" >
190
+        #{orgId,jdbcType=VARCHAR},
191
+      </if>
192
+      <if test="houseId != null" >
193
+        #{houseId,jdbcType=INTEGER},
194
+      </if>
195
+      <if test="warehouseId != null" >
196
+        #{warehouseId,jdbcType=INTEGER},
197
+      </if>
198
+      <if test="lsxzId != null" >
199
+        #{lsxzId,jdbcType=INTEGER},
200
+      </if>
201
+      <if test="grainKind != null" >
202
+        #{grainKind,jdbcType=INTEGER},
203
+      </if>
204
+      <if test="grainGrade != null" >
205
+        #{grainGrade,jdbcType=INTEGER},
206
+      </if>
207
+      <if test="incomeTonnage != null" >
208
+        #{incomeTonnage,jdbcType=VARCHAR},
209
+      </if>
210
+      <if test="inventoryYear != null" >
211
+        #{inventoryYear,jdbcType=INTEGER},
212
+      </if>
213
+      <if test="lossType != null" >
214
+        #{lossType,jdbcType=INTEGER},
215
+      </if>
216
+      <if test="profitRatio != null" >
217
+        #{profitRatio,jdbcType=VARCHAR},
218
+      </if>
219
+      <if test="actualStock != null" >
220
+        #{actualStock,jdbcType=VARCHAR},
221
+      </if>
222
+      <if test="productionYear != null" >
223
+        #{productionYear,jdbcType=INTEGER},
224
+      </if>
225
+      <if test="remark != null" >
226
+        #{remark,jdbcType=VARCHAR},
227
+      </if>
228
+      <if test="fillTime != null" >
229
+        #{fillTime,jdbcType=TIMESTAMP},
230
+      </if>
231
+      <if test="fillPerson != null" >
232
+        #{fillPerson,jdbcType=VARCHAR},
233
+      </if>
234
+      <if test="updatetime != null" >
235
+        #{updatetime,jdbcType=TIMESTAMP},
236
+      </if>
237
+    </trim>
238
+  </insert>
239
+  <select id="countByExample" parameterType="com.chinaitop.depot.model.StorageProfitlossSheetExample" resultType="java.lang.Integer" >
240
+    select count(*) from storage_profitloss_sheet
241
+    <if test="_parameter != null" >
242
+      <include refid="Example_Where_Clause" />
243
+    </if>
244
+  </select>
245
+  <update id="updateByExampleSelective" parameterType="map" >
246
+    update storage_profitloss_sheet
247
+    <set >
248
+      <if test="record.id != null" >
249
+        id = #{record.id,jdbcType=INTEGER},
250
+      </if>
251
+      <if test="record.orgId != null" >
252
+        org_id = #{record.orgId,jdbcType=VARCHAR},
253
+      </if>
254
+      <if test="record.houseId != null" >
255
+        house_id = #{record.houseId,jdbcType=INTEGER},
256
+      </if>
257
+      <if test="record.warehouseId != null" >
258
+        warehouse_id = #{record.warehouseId,jdbcType=INTEGER},
259
+      </if>
260
+      <if test="record.lsxzId != null" >
261
+        lsxz_id = #{record.lsxzId,jdbcType=INTEGER},
262
+      </if>
263
+      <if test="record.grainKind != null" >
264
+        grain_kind = #{record.grainKind,jdbcType=INTEGER},
265
+      </if>
266
+      <if test="record.grainGrade != null" >
267
+        grain_grade = #{record.grainGrade,jdbcType=INTEGER},
268
+      </if>
269
+      <if test="record.incomeTonnage != null" >
270
+        income_tonnage = #{record.incomeTonnage,jdbcType=VARCHAR},
271
+      </if>
272
+      <if test="record.inventoryYear != null" >
273
+        inventory_year = #{record.inventoryYear,jdbcType=INTEGER},
274
+      </if>
275
+      <if test="record.lossType != null" >
276
+        loss_type = #{record.lossType,jdbcType=INTEGER},
277
+      </if>
278
+      <if test="record.profitRatio != null" >
279
+        profit_ratio = #{record.profitRatio,jdbcType=VARCHAR},
280
+      </if>
281
+      <if test="record.actualStock != null" >
282
+        actual_stock = #{record.actualStock,jdbcType=VARCHAR},
283
+      </if>
284
+      <if test="record.productionYear != null" >
285
+        production_year = #{record.productionYear,jdbcType=INTEGER},
286
+      </if>
287
+      <if test="record.remark != null" >
288
+        remark = #{record.remark,jdbcType=VARCHAR},
289
+      </if>
290
+      <if test="record.fillTime != null" >
291
+        fill_time = #{record.fillTime,jdbcType=TIMESTAMP},
292
+      </if>
293
+      <if test="record.fillPerson != null" >
294
+        fill_person = #{record.fillPerson,jdbcType=VARCHAR},
295
+      </if>
296
+      <if test="record.updatetime != null" >
297
+        updatetime = #{record.updatetime,jdbcType=TIMESTAMP},
298
+      </if>
299
+    </set>
300
+    <if test="_parameter != null" >
301
+      <include refid="Update_By_Example_Where_Clause" />
302
+    </if>
303
+  </update>
304
+  <update id="updateByExample" parameterType="map" >
305
+    update storage_profitloss_sheet
306
+    set id = #{record.id,jdbcType=INTEGER},
307
+      org_id = #{record.orgId,jdbcType=VARCHAR},
308
+      house_id = #{record.houseId,jdbcType=INTEGER},
309
+      warehouse_id = #{record.warehouseId,jdbcType=INTEGER},
310
+      lsxz_id = #{record.lsxzId,jdbcType=INTEGER},
311
+      grain_kind = #{record.grainKind,jdbcType=INTEGER},
312
+      grain_grade = #{record.grainGrade,jdbcType=INTEGER},
313
+      income_tonnage = #{record.incomeTonnage,jdbcType=VARCHAR},
314
+      inventory_year = #{record.inventoryYear,jdbcType=INTEGER},
315
+      loss_type = #{record.lossType,jdbcType=INTEGER},
316
+      profit_ratio = #{record.profitRatio,jdbcType=VARCHAR},
317
+      actual_stock = #{record.actualStock,jdbcType=VARCHAR},
318
+      production_year = #{record.productionYear,jdbcType=INTEGER},
319
+      remark = #{record.remark,jdbcType=VARCHAR},
320
+      fill_time = #{record.fillTime,jdbcType=TIMESTAMP},
321
+      fill_person = #{record.fillPerson,jdbcType=VARCHAR},
322
+      updatetime = #{record.updatetime,jdbcType=TIMESTAMP}
323
+    <if test="_parameter != null" >
324
+      <include refid="Update_By_Example_Where_Clause" />
325
+    </if>
326
+  </update>
327
+  <update id="updateByPrimaryKeySelective" parameterType="com.chinaitop.depot.model.StorageProfitlossSheet" >
328
+    update storage_profitloss_sheet
329
+    <set >
330
+      <if test="orgId != null" >
331
+        org_id = #{orgId,jdbcType=VARCHAR},
332
+      </if>
333
+      <if test="houseId != null" >
334
+        house_id = #{houseId,jdbcType=INTEGER},
335
+      </if>
336
+      <if test="warehouseId != null" >
337
+        warehouse_id = #{warehouseId,jdbcType=INTEGER},
338
+      </if>
339
+      <if test="lsxzId != null" >
340
+        lsxz_id = #{lsxzId,jdbcType=INTEGER},
341
+      </if>
342
+      <if test="grainKind != null" >
343
+        grain_kind = #{grainKind,jdbcType=INTEGER},
344
+      </if>
345
+      <if test="grainGrade != null" >
346
+        grain_grade = #{grainGrade,jdbcType=INTEGER},
347
+      </if>
348
+      <if test="incomeTonnage != null" >
349
+        income_tonnage = #{incomeTonnage,jdbcType=VARCHAR},
350
+      </if>
351
+      <if test="inventoryYear != null" >
352
+        inventory_year = #{inventoryYear,jdbcType=INTEGER},
353
+      </if>
354
+      <if test="lossType != null" >
355
+        loss_type = #{lossType,jdbcType=INTEGER},
356
+      </if>
357
+      <if test="profitRatio != null" >
358
+        profit_ratio = #{profitRatio,jdbcType=VARCHAR},
359
+      </if>
360
+      <if test="actualStock != null" >
361
+        actual_stock = #{actualStock,jdbcType=VARCHAR},
362
+      </if>
363
+      <if test="productionYear != null" >
364
+        production_year = #{productionYear,jdbcType=INTEGER},
365
+      </if>
366
+      <if test="remark != null" >
367
+        remark = #{remark,jdbcType=VARCHAR},
368
+      </if>
369
+      <if test="fillTime != null" >
370
+        fill_time = #{fillTime,jdbcType=TIMESTAMP},
371
+      </if>
372
+      <if test="fillPerson != null" >
373
+        fill_person = #{fillPerson,jdbcType=VARCHAR},
374
+      </if>
375
+      <if test="updatetime != null" >
376
+        updatetime = #{updatetime,jdbcType=TIMESTAMP},
377
+      </if>
378
+    </set>
379
+    where id = #{id,jdbcType=INTEGER}
380
+  </update>
381
+  <update id="updateByPrimaryKey" parameterType="com.chinaitop.depot.model.StorageProfitlossSheet" >
382
+    update storage_profitloss_sheet
383
+    set org_id = #{orgId,jdbcType=VARCHAR},
384
+      house_id = #{houseId,jdbcType=INTEGER},
385
+      warehouse_id = #{warehouseId,jdbcType=INTEGER},
386
+      lsxz_id = #{lsxzId,jdbcType=INTEGER},
387
+      grain_kind = #{grainKind,jdbcType=INTEGER},
388
+      grain_grade = #{grainGrade,jdbcType=INTEGER},
389
+      income_tonnage = #{incomeTonnage,jdbcType=VARCHAR},
390
+      inventory_year = #{inventoryYear,jdbcType=INTEGER},
391
+      loss_type = #{lossType,jdbcType=INTEGER},
392
+      profit_ratio = #{profitRatio,jdbcType=VARCHAR},
393
+      actual_stock = #{actualStock,jdbcType=VARCHAR},
394
+      production_year = #{productionYear,jdbcType=INTEGER},
395
+      remark = #{remark,jdbcType=VARCHAR},
396
+      fill_time = #{fillTime,jdbcType=TIMESTAMP},
397
+      fill_person = #{fillPerson,jdbcType=VARCHAR},
398
+      updatetime = #{updatetime,jdbcType=TIMESTAMP}
399
+    where id = #{id,jdbcType=INTEGER}
400
+  </update>
401
+</mapper>

+ 175 - 0
src/main/java/com/chinaitop/depot/model/StorageProfitlossSheet.java

@@ -0,0 +1,175 @@
1
+package com.chinaitop.depot.model;
2
+
3
+import java.util.Date;
4
+
5
+public class StorageProfitlossSheet {
6
+    private Integer id;
7
+
8
+    private String orgId;
9
+
10
+    private Integer houseId;
11
+
12
+    private Integer warehouseId;
13
+
14
+    private Integer lsxzId;
15
+
16
+    private Integer grainKind;
17
+
18
+    private Integer grainGrade;
19
+
20
+    private String incomeTonnage;
21
+
22
+    private Integer inventoryYear;
23
+
24
+    private Integer lossType;
25
+
26
+    private String profitRatio;
27
+
28
+    private String actualStock;
29
+
30
+    private Integer productionYear;
31
+
32
+    private String remark;
33
+
34
+    private Date fillTime;
35
+
36
+    private String fillPerson;
37
+
38
+    private Date updatetime;
39
+
40
+    public Integer getId() {
41
+        return id;
42
+    }
43
+
44
+    public void setId(Integer id) {
45
+        this.id = id;
46
+    }
47
+
48
+    public String getOrgId() {
49
+        return orgId;
50
+    }
51
+
52
+    public void setOrgId(String orgId) {
53
+        this.orgId = orgId == null ? null : orgId.trim();
54
+    }
55
+
56
+    public Integer getHouseId() {
57
+        return houseId;
58
+    }
59
+
60
+    public void setHouseId(Integer houseId) {
61
+        this.houseId = houseId;
62
+    }
63
+
64
+    public Integer getWarehouseId() {
65
+        return warehouseId;
66
+    }
67
+
68
+    public void setWarehouseId(Integer warehouseId) {
69
+        this.warehouseId = warehouseId;
70
+    }
71
+
72
+    public Integer getLsxzId() {
73
+        return lsxzId;
74
+    }
75
+
76
+    public void setLsxzId(Integer lsxzId) {
77
+        this.lsxzId = lsxzId;
78
+    }
79
+
80
+    public Integer getGrainKind() {
81
+        return grainKind;
82
+    }
83
+
84
+    public void setGrainKind(Integer grainKind) {
85
+        this.grainKind = grainKind;
86
+    }
87
+
88
+    public Integer getGrainGrade() {
89
+        return grainGrade;
90
+    }
91
+
92
+    public void setGrainGrade(Integer grainGrade) {
93
+        this.grainGrade = grainGrade;
94
+    }
95
+
96
+    public String getIncomeTonnage() {
97
+        return incomeTonnage;
98
+    }
99
+
100
+    public void setIncomeTonnage(String incomeTonnage) {
101
+        this.incomeTonnage = incomeTonnage == null ? null : incomeTonnage.trim();
102
+    }
103
+
104
+    public Integer getInventoryYear() {
105
+        return inventoryYear;
106
+    }
107
+
108
+    public void setInventoryYear(Integer inventoryYear) {
109
+        this.inventoryYear = inventoryYear;
110
+    }
111
+
112
+    public Integer getLossType() {
113
+        return lossType;
114
+    }
115
+
116
+    public void setLossType(Integer lossType) {
117
+        this.lossType = lossType;
118
+    }
119
+
120
+    public String getProfitRatio() {
121
+        return profitRatio;
122
+    }
123
+
124
+    public void setProfitRatio(String profitRatio) {
125
+        this.profitRatio = profitRatio == null ? null : profitRatio.trim();
126
+    }
127
+
128
+    public String getActualStock() {
129
+        return actualStock;
130
+    }
131
+
132
+    public void setActualStock(String actualStock) {
133
+        this.actualStock = actualStock == null ? null : actualStock.trim();
134
+    }
135
+
136
+    public Integer getProductionYear() {
137
+        return productionYear;
138
+    }
139
+
140
+    public void setProductionYear(Integer productionYear) {
141
+        this.productionYear = productionYear;
142
+    }
143
+
144
+    public String getRemark() {
145
+        return remark;
146
+    }
147
+
148
+    public void setRemark(String remark) {
149
+        this.remark = remark == null ? null : remark.trim();
150
+    }
151
+
152
+    public Date getFillTime() {
153
+        return fillTime;
154
+    }
155
+
156
+    public void setFillTime(Date fillTime) {
157
+        this.fillTime = fillTime;
158
+    }
159
+
160
+    public String getFillPerson() {
161
+        return fillPerson;
162
+    }
163
+
164
+    public void setFillPerson(String fillPerson) {
165
+        this.fillPerson = fillPerson == null ? null : fillPerson.trim();
166
+    }
167
+
168
+    public Date getUpdatetime() {
169
+        return updatetime;
170
+    }
171
+
172
+    public void setUpdatetime(Date updatetime) {
173
+        this.updatetime = updatetime;
174
+    }
175
+}

Plik diff jest za duży
+ 1281 - 0
src/main/java/com/chinaitop/depot/model/StorageProfitlossSheetExample.java


+ 24 - 0
src/main/java/com/chinaitop/depot/service/StorageProfitlossSheetService.java

@@ -0,0 +1,24 @@
1
+package com.chinaitop.depot.service;
2
+
3
+
4
+import com.chinaitop.depot.model.StorageProfitlossSheet;
5
+import com.chinaitop.depot.model.StorageProfitlossSheetExample;
6
+
7
+import java.util.List;
8
+
9
+/**
10
+ * @author qingsong.han
11
+ * @description:
12
+ * @create 2018-06-27 11:13
13
+ */
14
+public interface StorageProfitlossSheetService {
15
+    List<StorageProfitlossSheet> queryByExample(StorageProfitlossSheetExample example);
16
+
17
+    StorageProfitlossSheet findById(Integer id);
18
+
19
+    void add(StorageProfitlossSheet plan, String realName);
20
+
21
+    void update(StorageProfitlossSheet plan);
22
+
23
+    void remove(Integer id);
24
+}

+ 54 - 0
src/main/java/com/chinaitop/depot/service/impl/StorageProfitlossSheetServiceImpl.java

@@ -0,0 +1,54 @@
1
+package com.chinaitop.depot.service.impl;
2
+
3
+import com.chinaitop.depot.mapper.StorageProfitlossSheetMapper;
4
+import com.chinaitop.depot.model.StorageProfitlossSheet;
5
+import com.chinaitop.depot.model.StorageProfitlossSheetExample;
6
+import com.chinaitop.depot.service.StorageProfitlossSheetService;
7
+import org.springframework.stereotype.Service;
8
+import javax.annotation.Resource;
9
+import java.util.Date;
10
+import java.util.List;
11
+
12
+/**
13
+ * @auther xujh
14
+ */
15
+@Service
16
+public class StorageProfitlossSheetServiceImpl implements StorageProfitlossSheetService {
17
+	@Resource
18
+	private StorageProfitlossSheetMapper storageProfitlossSheetMapper;
19
+
20
+	/**
21
+	 * 损益单管理列表
22
+	 * @param example
23
+	 * @return
24
+	 */
25
+	@Override
26
+	public List<StorageProfitlossSheet> queryByExample(StorageProfitlossSheetExample example) {
27
+		return storageProfitlossSheetMapper.selectByExample(example);
28
+	}
29
+
30
+	@Override
31
+	public StorageProfitlossSheet findById(Integer id) {
32
+		return storageProfitlossSheetMapper.selectByPrimaryKey(id);
33
+	}
34
+
35
+	@Override
36
+	public void add(StorageProfitlossSheet storageProfitlossSheet, String realName) {
37
+    	storageProfitlossSheet.setFillPerson(realName);
38
+    	storageProfitlossSheet.setFillTime(new Date());
39
+		storageProfitlossSheetMapper.insertSelective(storageProfitlossSheet);
40
+
41
+	}
42
+
43
+	@Override
44
+	public void update(StorageProfitlossSheet storageProfitlossSheet) {
45
+		storageProfitlossSheetMapper.updateByPrimaryKeySelective(storageProfitlossSheet);
46
+		
47
+	}
48
+
49
+	@Override
50
+	public void remove(Integer id) {
51
+		storageProfitlossSheetMapper.deleteByPrimaryKey(id);
52
+	}
53
+
54
+}

+ 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
+}

+ 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
+}

+ 113 - 0
src/main/java/com/chinaitop/utils/PageUtils.java

@@ -0,0 +1,113 @@
1
+package com.chinaitop.utils;
2
+
3
+import com.github.pagehelper.Page;
4
+import com.github.pagehelper.PageInfo;
5
+
6
+import java.util.ArrayList;
7
+import java.util.List;
8
+
9
+public class PageUtils {
10
+	
11
+	public static <T> PageInfo<T> page(List<T> list, Integer pageNum, Integer pageSize) {
12
+		
13
+		if(pageNum <= 0) {
14
+			pageNum = 0;
15
+		} else {
16
+			pageNum --;
17
+		}
18
+		
19
+    	int totalCount = list.size();
20
+        int pageCount;
21
+        int m = totalCount % pageSize;
22
+
23
+        if (m > 0) {
24
+            pageCount = totalCount / pageSize + 1;
25
+        } else {
26
+            pageCount = totalCount / pageSize;
27
+        }
28
+
29
+        List<List<T>> totalList = new ArrayList<List<T>>();
30
+        for (int i = 1; i <= pageCount; i++) {
31
+            if (m == 0) {
32
+                List<T> subList = list.subList((i - 1) * pageSize, pageSize * (i));
33
+                totalList.add(subList);
34
+            } else {
35
+                if (i == pageCount) {
36
+                    List<T> subList = list.subList((i - 1) * pageSize, totalCount);
37
+                    totalList.add(subList);
38
+                } else {
39
+                    List<T> subList = list.subList((i - 1) * pageSize, pageSize * i);
40
+                    totalList.add(subList);
41
+                }
42
+            }
43
+        }
44
+        
45
+        List<T> result = totalList.get(pageNum);
46
+        int count = list.size();
47
+        int size = totalList.size();
48
+        PageInfo<T> pageInfo =new PageInfo<T>((List<T>) result, size);
49
+        pageInfo.setPages(size);
50
+        pageInfo.setTotal(count);
51
+        System.out.println("总条数:" + count);
52
+        System.out.println("总页数:" + size);
53
+        return pageInfo;
54
+    }
55
+	
56
+	
57
+	public static <T> PageInfo<T> page2(List<T> list, Integer pageNum, Integer pageSize) {
58
+		
59
+		if(pageNum <= 0) {
60
+			pageNum = 0;
61
+		} else {
62
+			pageNum --;
63
+		}
64
+		
65
+    	int totalCount = list.size();
66
+        int pageCount;
67
+        int m = totalCount % pageSize;
68
+
69
+        if (m > 0) {
70
+            pageCount = totalCount / pageSize + 1;
71
+        } else {
72
+            pageCount = totalCount / pageSize;
73
+        }
74
+
75
+        List<List<T>> totalList = new ArrayList<List<T>>();
76
+        for (int i = 1; i <= pageCount; i++) {
77
+            if (m == 0) {
78
+                List<T> subList = list.subList((i - 1) * pageSize, pageSize * (i));
79
+                totalList.add(subList);
80
+            } else {
81
+                if (i == pageCount) {
82
+                    List<T> subList = list.subList((i - 1) * pageSize, totalCount);
83
+                    totalList.add(subList);
84
+                } else {
85
+                    List<T> subList = list.subList((i - 1) * pageSize, pageSize * i);
86
+                    totalList.add(subList);
87
+                }
88
+            }
89
+        }
90
+        if(!totalList.isEmpty()){
91
+        	List<T> result = totalList.get(pageNum);
92
+        	Page<T> page = new Page<T>();
93
+        	for (T t : result) {
94
+        		page.add(t);
95
+        	}
96
+        	int count = list.size();
97
+        	int size = totalList.size();
98
+        	
99
+        	page.setPages(size);
100
+        	page.setPageNum(pageNum + 1);
101
+        	page.setPageSize(pageSize);
102
+        	page.setTotal(count);
103
+        	page.setStartRow(pageNum*pageSize);
104
+        	
105
+        	PageInfo<T> pageInfo =new PageInfo<T>(page, size);
106
+        	System.out.println("总条数:" + count);
107
+        	System.out.println("总页数:" + size);
108
+        	return pageInfo;
109
+        }
110
+		return null;
111
+    }
112
+
113
+}

+ 173 - 0
src/main/java/com/chinaitop/utils/ParameterUtil.java

@@ -0,0 +1,173 @@
1
+package com.chinaitop.utils;
2
+
3
+import java.io.BufferedInputStream;
4
+import java.io.InputStream;
5
+import java.text.ParseException;
6
+import java.text.SimpleDateFormat;
7
+import java.util.Date;
8
+import java.util.List;
9
+import java.util.Properties;
10
+
11
+public class ParameterUtil {
12
+
13
+    public static String startTime = " 00:00:00";
14
+    public static String endTime = " 23:59:59";
15
+
16
+    public static String getSysDateTime(){
17
+        String temp_str="";
18
+        Date dt = new Date();
19
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
20
+        temp_str=sdf.format(dt);
21
+        System.out.println("获取当前时间"+temp_str);
22
+        return temp_str;
23
+    }
24
+    
25
+    public static String getDateYMDHMS(Date date) {
26
+    	String str = "";
27
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
28
+        str=sdf.format(date);
29
+        System.out.println("获取当前时间"+str);
30
+        return str;
31
+    }
32
+    
33
+    public static String getSysDate(){
34
+        String temp_str="";
35
+        Date dt = new Date();
36
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
37
+        temp_str=sdf.format(dt);
38
+        return temp_str;
39
+    }
40
+
41
+    public static Date string2datetime(String dateTime){
42
+        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
43
+        Date date = null;
44
+        try {
45
+            date = dateFormat.parse(dateTime);
46
+        } catch (ParseException e) {
47
+            e.printStackTrace();
48
+        }
49
+        return date;
50
+    }
51
+    public static Date string2date(String dateTime){
52
+        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
53
+        Date date = null;
54
+        try {
55
+            date = dateFormat.parse(dateTime);
56
+        } catch (ParseException e) {
57
+            e.printStackTrace();
58
+        }
59
+        return date;
60
+    }
61
+
62
+    public static String date2string(Date date){
63
+        SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
64
+        String str=sdf.format(date);
65
+        return str;
66
+    }
67
+
68
+    /**
69
+     * 获取指定时间的时间戳
70
+     * @param datatime
71
+     * @return
72
+     */
73
+    public static String getTimeStamp(String datatime){
74
+        long timeStamp = 0;
75
+        SimpleDateFormat format =  new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
76
+        try {
77
+            Date date = format.parse(datatime);
78
+            timeStamp = date.getTime();
79
+        } catch (ParseException e) {
80
+            e.printStackTrace();
81
+        }
82
+        return String.valueOf(timeStamp);
83
+    }
84
+
85
+    /*
86
+     * 将时间戳转换为时间
87
+     */
88
+    public static String stampToDate(String s){
89
+        String res;
90
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
91
+        long lt = new Long(s);
92
+        Date date = new Date(lt);
93
+        res = simpleDateFormat.format(date);
94
+        return res;
95
+    }
96
+
97
+    public static void main(String[] args) {
98
+        System.out.println(stampToDate("1504689208643"));
99
+        System.out.println(getTimeStamp(getSysDateTime()));
100
+    }
101
+    public static String getBHS(String BHS){
102
+        String[] str = BHS.split(",");
103
+        StringBuffer sb = new StringBuffer();
104
+        for(int i=0;i<str.length;i++){
105
+            sb.append("'").append(str[i]).append("'").append(",");
106
+        }
107
+        String s=sb.toString();
108
+        String t=s.substring(0,s.length()-1);
109
+        return t;
110
+    }
111
+
112
+    //判断字段值是为空 不为空返回ture
113
+    public static boolean isnotnull(Object name){
114
+        return (null!=name&&!"".equals(name) && !"null".equals(name) && "null" != name);
115
+    }
116
+    
117
+    //判断字段值是为空,为空返回ture
118
+    public static boolean isnull(Object name){
119
+        return (null==name || "".equals(name) || "null".equals(name) || "null" == name);
120
+    }
121
+
122
+    //判断字段值是相等  相等返回ture
123
+    public static boolean isequal(Object name,Object value){
124
+        if(name==value||name.equals(value)){
125
+            return true;
126
+        }
127
+        return false;
128
+    }
129
+
130
+    /**
131
+     * 判断list和str数组是否全等
132
+     * @param list
133
+     * @param str
134
+     * @return
135
+     */
136
+    public static boolean isAllequal(List<String> list,String[] str){
137
+        boolean isbz = true;
138
+        for(int z=0;z<str.length;z++){
139
+            if(!isequal(list.get(z),str[z])){
140
+                isbz = false;
141
+                break;
142
+            }
143
+        }
144
+        return !isbz || !(str.length == list.size());
145
+    }
146
+
147
+    //判断字段值是否在某个集合里  在返回ture
148
+    public static boolean isallequal(Object name,String[] value){
149
+        for(int i=0;i<value.length;i++){
150
+            if(name==value[i]||name.equals(value[i])){
151
+                return true;
152
+            }
153
+        }
154
+        return false;
155
+    }
156
+
157
+    /**
158
+     * 从properties得到路径
159
+     * @param filePath
160
+     * @return
161
+     */
162
+    public static Properties readProperties(String filePath) {
163
+        Properties props = new Properties();
164
+        try {
165
+            InputStream in = new BufferedInputStream(ParameterUtil.class.getResourceAsStream(filePath));
166
+            props.load(in);
167
+        } catch (Exception e) {
168
+            e.printStackTrace();
169
+        }
170
+        return props;
171
+    }
172
+
173
+}

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

@@ -0,0 +1,51 @@
1
+server:
2
+  port: 9011
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-number-manage
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

+ 16 - 0
src/test/java/com/chinaitop/DepotNumbermanageApplicationTests.java

@@ -0,0 +1,16 @@
1
+package com.chinaitop;
2
+
3
+import org.junit.Test;
4
+import org.junit.runner.RunWith;
5
+import org.springframework.boot.test.context.SpringBootTest;
6
+import org.springframework.test.context.junit4.SpringRunner;
7
+
8
+@RunWith(SpringRunner.class)
9
+@SpringBootTest
10
+public class DepotNumbermanageApplicationTests {
11
+
12
+    @Test
13
+    public void contextLoads() {
14
+    }
15
+
16
+}