Compare commits

..

No commits in common. 'master' and 'main' have entirely different histories.
master ... main

8
.idea/.gitignore vendored

@ -1,8 +0,0 @@
# 默认忽略的文件
/shelf/
/workspace.xml
# 基于编辑器的 HTTP 客户端请求
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

@ -1,9 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

@ -1,13 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<annotationProcessing>
<profile name="Maven default annotation processors profile" enabled="true">
<sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" />
<module name="WMS" />
</profile>
</annotationProcessing>
</component>
</project>

@ -1,20 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RemoteRepositoriesConfiguration">
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Central Repository" />
<option name="url" value="https://repo.maven.apache.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Maven Central repository" />
<option name="url" value="https://repo1.maven.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="jboss.community" />
<option name="name" value="JBoss Community repository" />
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
</remote-repository>
</component>
</project>

@ -1,14 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="MavenProjectsManager">
<option name="originalFiles">
<list>
<option value="$PROJECT_DIR$/WMS/pom.xml" />
</list>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_23" default="true" project-jdk-name="23" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/ck.iml" filepath="$PROJECT_DIR$/.idea/ck.iml" />
</modules>
</component>
</project>

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

@ -0,0 +1,2 @@
# csxm

8
WMS/.gitignore vendored

@ -1,8 +0,0 @@
## .gitignore
# .gitignore for maven
target/
# IDE support file
.idea
WMS.iml

@ -1,316 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<packaging>war</packaging>
<name>WMS</name>
<groupId>com.ken</groupId>
<artifactId>WMS</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<!-- version of dependence -->
<servlet.version>3.1.0</servlet.version>
<junit.version>4.12</junit.version>
<aopalliance.version>1.0</aopalliance.version>
<aspectjweaver.version>1.8.0</aspectjweaver.version>
<commons.fileuoload.version>1.3.1</commons.fileuoload.version>
<commons.io.version>2.1</commons.io.version>
<commons.beanutils.version>1.9.3</commons.beanutils.version>
<commons.lang3.version>3.4</commons.lang3.version>
<poi.version>3.15-beta2</poi.version>
<mybatis.version>3.4.0</mybatis.version>
<mybatisSpring.version>1.3.0</mybatisSpring.version>
<pagehelper.version>4.1.6</pagehelper.version>
<spring.version>4.3.0.RELEASE</spring.version>
<shiro.version>1.4.0</shiro.version>
<ehcache.version>2.10.2</ehcache.version>
<mysqlconnector.version>8.0.28</mysqlconnector.version>
<c3p0.version>0.9.5.5</c3p0.version>
<log4j.version>1.2.17</log4j.version>
<slf4j.version>1.7.21</slf4j.version>
<jackson.version>2.7.0</jackson.version>
<!-- plugin config -->
<plugin.tomcat.version>2.1</plugin.tomcat.version>
<plugin.tomcat.port>8080</plugin.tomcat.port>
<plugin.tomcat.path>/WMS</plugin.tomcat.path>
<plugin.maven.varsion>3.3</plugin.maven.varsion>
<plugin.maven.jdk>1.8</plugin.maven.jdk>
</properties>
<dependencies>
<!-- Servlet dependency -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>${servlet.version}</version>
<scope>provided</scope>
</dependency>
<!-- Junit dependency -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
</dependency>
<dependency>
<groupId>aopalliance</groupId>
<artifactId>aopalliance</artifactId>
<version>${aopalliance.version}</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>${aspectjweaver.version}</version>
</dependency>
<!-- Apache commons -->
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>${commons.fileuoload.version}</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>${commons.io.version}</version>
</dependency>
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
<version>${commons.beanutils.version}</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.4</version>
</dependency>
<!-- Apache poi dependency -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>${poi.version}</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-excelant</artifactId>
<version>${poi.version}</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>${poi.version}</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml-schemas</artifactId>
<version>${poi.version}</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-scratchpad</artifactId>
<version>${poi.version}</version>
</dependency>
<!-- MyBatis dependency -->
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>${mybatis.version}</version>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
<version>${mybatisSpring.version}</version>
</dependency>
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper</artifactId>
<version>${pagehelper.version}</version>
</dependency>
<!-- Spring FrameWork dependency -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-expression</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>
<!-- apache shiro -->
<dependency>
<groupId>org.apache.shiro</groupId>
<artifactId>shiro-core</artifactId>
<version>${shiro.version}</version>
</dependency>
<dependency>
<groupId>org.apache.shiro</groupId>
<artifactId>shiro-web</artifactId>
<version>${shiro.version}</version>
</dependency>
<dependency>
<groupId>org.apache.shiro</groupId>
<artifactId>shiro-spring</artifactId>
<version>${shiro.version}</version>
</dependency>
<dependency>
<groupId>org.apache.shiro</groupId>
<artifactId>shiro-ehcache</artifactId>
<version>${shiro.version}</version>
</dependency>
<!-- ehcache -->
<dependency>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache</artifactId>
<version>${ehcache.version}</version>
</dependency>
<!-- mysql-connector-java dependency -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>${mysqlconnector.version}</version>
</dependency>
<!-- C3P0 dependency -->
<dependency>
<groupId>com.mchange</groupId>
<artifactId>c3p0</artifactId>
<version>${c3p0.version}</version>
</dependency>
<!-- log4j dependency -->
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>${log4j.version}</version>
</dependency>
<!-- slf4j dependency -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>${slf4j.version}</version>
</dependency>
<!-- jackson dependency -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
</dependency>
</dependencies>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
</resource>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.xml</include>
</includes>
</resource>
</resources>
<sourceDirectory>src/main/java</sourceDirectory>
<plugins>
<!-- tomcat plugin -->
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>${plugin.tomcat.version}</version>
<configuration>
<port>${plugin.tomcat.port}</port>
<path>${plugin.tomcat.path}</path>
<uriEncoding>UTF-8</uriEncoding>
<server>tomcat7</server>
</configuration>
</plugin>
<!-- maven plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${plugin.maven.varsion}</version>
<configuration>
<source>${plugin.maven.jdk}</source>
<target>${plugin.maven.jdk}</target>
</configuration>
</plugin>
</plugins>
</build>
</project>

@ -1,224 +0,0 @@
create database wms_db
DEFAULT CHARACTER SET utf8mb4
DEFAULT COLLATE utf8mb4_general_ci;
use wms_db;
# 创建数据表
# 创建供应商信息表
create table wms_supplier
(
SUPPLIER_ID int not null auto_increment,
SUPPLIER_NAME varchar(30) not null,
SUPPLIER_PERSON varchar(10) not null,
SUPPLIER_TEL varchar(20) not null,
SUPPLIER_EMAIL varchar(20) not null,
SUPPLIER_ADDRESS varchar(30) not null,
primary key(SUPPLIER_ID)
)engine=innodb;
# 创建客户信息表
create table wms_customer
(
CUSTOMER_ID int not null auto_increment,
CUSTOMER_NAME varchar(30) not null,
CUSTOMER_PERSON varchar(10) not null,
CUSTOMER_TEL varchar(20) not null,
CUSTOMER_EMAIL varchar(20) not null,
CUSTOMER_ADDRESS varchar(30) not null,
primary key(CUSTOMER_ID)
)engine=innodb;
# 创建货物信息表
create table wms_goods
(
GOOD_ID int not null auto_increment,
GOOD_NAME varChar(30) not null,
GOOD_RYPE varchar(20),
GOOD_SIZE varchar(20),
GOOD_VALUE double not null,
primary key(GOOD_ID)
)engine=innodb;
# 创建仓库信息表
create table wms_respository
(
REPO_ID int not null auto_increment,
REPO_ADDRESS varchar(30) not null,
REPO_STATUS varchar(20) not null,
REPO_AREA varchar(20) not null,
REPO_DESC varchar(50),
primary key(REPO_ID)
)engine=innodb;
# 创建仓库管理员信息表
create table wms_repo_admin
(
REPO_ADMIN_ID int not null auto_increment,
REPO_ADMIN_NAME varchar(10) not null,
REPO_ADMIN_SEX varchar(10) not null,
REPO_ADMIN_TEL varchar(20) not null,
REPO_ADMIN_ADDRESS varchar(30) not null,
REPO_ADMIN_BIRTH datetime not null,
REPO_ADMIN_REPOID int,
primary key(REPO_ADMIN_ID),
foreign key (REPO_ADMIN_REPOID) references wms_respository(REPO_ID)
)engine=innodb;
# 创建入库记录表
create table wms_record_in
(
RECORD_ID int not null auto_increment,
RECORD_SUPPLIERID int not null,
RECORD_GOODID int not null,
RECORD_NUMBER int not null,
RECORD_TIME datetime not null,
RECORD_PERSON varchar(10) not null,
RECORD_REPOSITORYID int not null,
primary key(RECORD_ID),
foreign key(RECORD_SUPPLIERID) references wms_supplier(SUPPLIER_ID),
foreign key(RECORD_GOODID) references wms_goods(GOOD_ID),
foreign key(RECORD_REPOSITORYID) references wms_respository(REPO_ID)
)engine=innodb;
# 创建出库记录表
create table wms_record_out
(
RECORD_ID int not null auto_increment,
RECORD_CUSTOMERID int not null,
RECORD_GOODID int not null,
RECORD_NUMBER int not null,
RECORD_TIME datetime not null,
RECORD_PERSON varchar(10) not null,
RECORD_REPOSITORYID int not null,
primary key(RECORD_ID),
foreign key(RECORD_CUSTOMERID) references wms_customer(CUSTOMER_ID),
foreign key(RECORD_GOODID) references wms_goods(GOOD_ID),
foreign key(RECORD_REPOSITORYID) references wms_respository(REPO_ID)
)engine=innodb;
# 创建库存记录表
create table wms_record_storage
(
RECORD_GOODID int not null auto_increment,
RECORD_REPOSITORY int not null,
RECORD_NUMBER int not null,
primary key(RECORD_GOODID, RECORD_REPOSITORY),
foreign key (RECORD_GOODID) references wms_goods(GOOD_ID),
foreign key (RECORD_REPOSITORY) references wms_respository(REPO_ID)
)engine=innodb;
# 创建系统用户信息表
create table wms_user
(
USER_ID int not null auto_increment,
USER_USERNAME varchar(30) not null,
USER_PASSWORD varchar(40) not null,
USER_FIRST_LOGIN int not null,
primary key (USER_ID)
)engine=innodb;
# 创建用户角色表
create table wms_roles
(
ROLE_ID int not null auto_increment,
ROLE_NAME varchar(20) not null,
ROLE_DESC varchar(30),
ROLE_URL_PREFIX varchar(20) not null,
primary key(ROLE_ID)
)engine=innodb;
# 创建URL权限表
create table wms_action
(
ACTION_ID int not null auto_increment,
ACTION_NAME varchar(30) not null,
ACTION_DESC varchar(30),
ACTION_PARAM varchar(50) not null,
primary key(ACTION_ID)
)engine=innodb;
# 用户 - 角色关联表
create table wms_user_role
(
ROLE_ID int not null,
USER_ID int not null,
primary key(ROLE_ID,USER_ID),
foreign key(ROLE_ID) references wms_roles(ROLE_ID),
foreign key(USER_ID) references wms_user(USER_ID)
)engine=innodb;
# 角色 - URL权限关联表
create table wms_role_action
(
ACTION_ID int not null,
ROLE_ID int not null,
primary key(ACTION_ID,ROLE_ID),
foreign key(ROLE_ID) references wms_roles(ROLE_ID),
foreign key(ACTION_ID) references wms_action(ACTION_ID)
)engine=innodb;
# 系统登入登出记录表
create table wms_access_record
(
RECORD_ID int auto_increment primary key,
USER_ID int not null,
USER_NAME varchar(50) not null,
ACCESS_TYPE varchar(30) not null,
ACCESS_TIME datetime not null,
ACCESS_IP varchar(45) not null
);
# 用户系统操作记录表
create table wms_operation_record
(
RECORD_ID int auto_increment primary key,
USER_ID int not null,
USER_NAME varchar(50) not null,
OPERATION_NAME varchar(30) not null,
OPERATION_TIME datetime not null,
OPERATION_RESULT varchar(15) not null
);
# 导入数据
# 导入系统用户信息
INSERT INTO `wms_user` VALUES (1001,'admin','6f5379e73c1a9eac6163ab8eaec7e41c',0),(1018,'王皓','50f202f4862360e55635b0a9616ded13',1),(1019,'李富荣','c4b3af5a5ab3e3d5aac4c5a5436201b8',1);
# 导入系统角色信息
INSERT INTO `wms_roles` VALUES (1,'systemAdmin',NULL,'systemAdmin'),(2,'commonsAdmin',NULL,'commonsAdmin');
# 导入 系统用户 - 角色 信息
INSERT INTO `wms_user_role` VALUES (1,1001),(2,1018),(2,1019);
# 导入URL权限信息
INSERT INTO `wms_action` VALUES (1,'addSupplier',NULL,'/supplierManage/addSupplier'),(2,'deleteSupplier',NULL,'/supplierManage/deleteSupplier'),(3,'updateSupplier',NULL,'/supplierManage/updateSupplier'),(4,'selectSupplier',NULL,'/supplierManage/getSupplierList'),(5,'getSupplierInfo',NULL,'/supplierManage/getSupplierInfo'),(6,'importSupplier',NULL,'/supplierManage/importSupplier'),(7,'exportSupplier',NULL,'/supplierManage/exportSupplier'),(8,'selectCustomer',NULL,'/customerManage/getCustomerList'),(9,'addCustomer',NULL,'/customerManage/addCustomer'),(10,'getCustomerInfo',NULL,'/customerManage/getCustomerInfo'),(11,'updateCustomer',NULL,'/customerManage/updateCustomer'),(12,'deleteCustomer',NULL,'/customerManage/deleteCustomer'),(13,'importCustomer',NULL,'/customerManage/importCustomer'),(14,'exportCustomer',NULL,'/customerManage/exportCustomer'),(15,'selectGoods',NULL,'/goodsManage/getGoodsList'),(16,'addGoods',NULL,'/goodsManage/addGoods'),(17,'getGoodsInfo',NULL,'/goodsManage/getGoodsInfo'),(18,'updateGoods',NULL,'/goodsManage/updateGoods'),(19,'deleteGoods',NULL,'/goodsManage/deleteGoods'),(20,'importGoods',NULL,'/goodsManage/importGoods'),(21,'exportGoods',NULL,'/goodsManage/exportGoods'),(22,'selectRepository',NULL,'/repositoryManage/getRepositoryList'),(23,'addRepository',NULL,'/repositoryManage/addRepository'),(24,'getRepositoryInfo',NULL,'/repositoryManage/getRepository'),(25,'updateRepository',NULL,'/repositoryManage/updateRepository'),(26,'deleteRepository',NULL,'/repositoryManage/deleteRepository'),(27,'importRepository',NULL,'/repositoryManage/importRepository'),(28,'exportRepository',NULL,'/repositoryManage/exportRepository'),(29,'selectRepositoryAdmin',NULL,'/repositoryAdminManage/getRepositoryAdminList'),(30,'addRepositoryAdmin',NULL,'/repositoryAdminManage/addRepositoryAdmin'),(31,'getRepositoryAdminInfo',NULL,'/repositoryAdminManage/getRepositoryAdminInfo'),(32,'updateRepositoryAdmin',NULL,'/repositoryAdminManage/updateRepositoryAdmin'),(33,'deleteRepositoryAdmin',NULL,'/repositoryAdminManage/deleteRepositoryAdmin'),(34,'importRepositoryAd,om',NULL,'/repositoryAdminManage/importRepositoryAdmin'),(35,'exportRepository',NULL,'/repositoryAdminManage/exportRepositoryAdmin'),(36,'getUnassignRepository',NULL,'/repositoryManage/getUnassignRepository'),(37,'getStorageListWithRepository',NULL,'/storageManage/getStorageListWithRepository'),(38,'getStorageList',NULL,'/storageManage/getStorageList'),(39,'addStorageRecord',NULL,'/storageManage/addStorageRecord'),(40,'updateStorageRecord',NULL,'/storageManage/updateStorageRecord'),(41,'deleteStorageRecord',NULL,'/storageManage/deleteStorageRecord'),(42,'importStorageRecord',NULL,'/storageManage/importStorageRecord'),(43,'exportStorageRecord',NULL,'/storageManage/exportStorageRecord'),(44,' stockIn','货物进库操作','/stockRecordManage/stockIn'),(45,'stockOut','货物出库操作','/stockRecordManage/stockOut'),(46,'searchStockRecord','查询货物出入库记录','/stockRecordManage/searchStockRecord'),(47,'getAccessRecords','查询登入登出记录','/systemLog/getAccessRecords'),(48,'selectUserOperationRecords','查村用户操作记录','/systemLog/selectUserOperationRecords');
# 导入 角色 - URL权限 信息
INSERT INTO `wms_role_action` VALUES (1,1),(2,1),(3,1),(4,1),(5,1),(6,1),(7,1),(8,1),(9,1),(10,1),(11,1),(12,1),(13,1),(14,1),(15,1),(16,1),(17,1),(18,1),(19,1),(20,1),(21,1),(22,1),(23,1),(24,1),(25,1),(26,1),(27,1),(28,1),(29,1),(30,1),(31,1),(32,1),(33,1),(34,1),(35,1),(36,1),(37,1),(39,1),(40,1),(41,1),(42,1),(43,1),(44,1),(45,1),(46,1),(47,1),(48,1),(4,2),(8,2),(15,2),(38,2),(43,2),(44,2),(45,2);
# 导入供应商信息
INSERT INTO `wms_supplier` VALUES (1013,'浙江奇同电器有限公司','王泽伟','13777771126','86827868@126.com','中国 浙江 温州市龙湾区 龙湾区永强大道1648号'),(1014,'醴陵春天陶瓷实业有限公司','温仙容','13974167256','23267999@126.com','中国 湖南 醴陵市 东正街15号'),(1015,'洛阳嘉吉利饮品有限公司','郑绮云','26391678','22390898@qq.com','中国 广东 佛山市顺德区 北滘镇怡和路2号怡和中心14楼');
# 导入客户信息
INSERT INTO `wms_customer` VALUES (1214,'醴陵荣旗瓷业有限公司','陈娟','17716786888','23369888@136.com','中国 湖南 醴陵市 嘉树乡玉茶村柏树组'),(1215,'深圳市松林达电子有限公司','刘明','85263335-820','85264958@126.com','中国 广东 深圳市宝安区 深圳市宝安区福永社区桥头村桥塘路育'),(1216,'郑州绿之源饮品有限公司 ','赵志敬','87094196','87092165@qq.com','中国 河南 郑州市 郑州市嘉亿东方大厦609');
# 导入货物信息
INSERT INTO `wms_goods` VALUES (103,'五孔插座西门子墙壁开关','电器','86*86',1.85),(104,'陶瓷马克杯','陶瓷','9*9*11',3.5),(105,'精酿苹果醋','饮料','312ml',300);
# 导入仓库信息
INSERT INTO `wms_respository` VALUES (1003,'北京顺义南彩工业园区彩祥西路9号','可用','11000㎡','提供服务完整'),(1004,'广州白云石井石潭路大基围工业区','可用','1000㎡','物流极为便利'),(1005,' 香港北区文锦渡路(红桥新村)','可用','5000.00㎡',NULL);
# 导入仓库管理员信息
INSERT INTO `wms_repo_admin` VALUES (1018,'王皓','','12345874526','中国佛山','2016-12-09 00:00:00',1004),(1019,'李富荣','','1234','广州','2016-12-07 00:00:00',1003);
# 导入入库记录
INSERT INTO `wms_record_in` VALUES (15,1015,105,1000,'2016-12-31 00:00:00','admin',1004),(16,1015,105,200,'2017-01-02 00:00:00','admin',1004);
# 导入出库记录
INSERT INTO `wms_record_out` VALUES (7,1214,104,750,'2016-12-31 00:00:00','admin',1003);
# 导入库存信息
INSERT INTO `wms_record_storage` VALUES (103,1005,10000),(104,1003,1750),(105,1004,2000);

@ -1,280 +0,0 @@
package com.ken.wms.common.controller;
import com.ken.wms.common.service.Interface.CustomerManageService;
import com.ken.wms.common.util.Response;
import com.ken.wms.common.util.ResponseFactory;
import com.ken.wms.domain.Customer;
import com.ken.wms.domain.Supplier;
import com.ken.wms.exception.CustomerManageServiceException;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.List;
import java.util.Map;
/**
* Handler
*
* @author Ken
*/
@RequestMapping(value = "/**/customerManage")
@Controller
public class CustomerManageHandler {
@Autowired
private CustomerManageService customerManageService;
private static final String SEARCH_BY_ID = "searchByID";
private static final String SEARCH_BY_NAME = "searchByName";
private static final String SEARCH_ALL = "searchAll";
/**
*
*
* @param searchType
* @param keyWord
* @param offset
* @param limit
* @return
*/
private Map<String, Object> query(String searchType, String keyWord, int offset, int limit) throws CustomerManageServiceException {
Map<String, Object> queryResult = null;
switch (searchType) {
case SEARCH_BY_ID:
if (StringUtils.isNumeric(keyWord))
queryResult = customerManageService.selectById(Integer.valueOf(keyWord));
break;
case SEARCH_BY_NAME:
queryResult = customerManageService.selectByName(offset, limit, keyWord);
break;
case SEARCH_ALL:
queryResult = customerManageService.selectAll(offset, limit);
break;
default:
// do other thing
break;
}
return queryResult;
}
/**
*
*
* @param searchType
* @param offset
* @param limit
* @param keyWord
* @return rows total
*/
@SuppressWarnings("unchecked")
@RequestMapping(value = "getCustomerList", method = RequestMethod.GET)
public
@ResponseBody
Map<String, Object> getCustomerList(@RequestParam("searchType") String searchType,
@RequestParam("offset") int offset,
@RequestParam("limit") int limit,
@RequestParam("keyWord") String keyWord) throws CustomerManageServiceException {
// 初始化 Response
Response responseContent = ResponseFactory.newInstance();
List<Supplier> rows = null;
long total = 0;
Map<String, Object> queryResult = query(searchType, keyWord, offset, limit);
if (queryResult != null) {
rows = (List<Supplier>) queryResult.get("data");
total = (long) queryResult.get("total");
}
// 设置 Response
responseContent.setCustomerInfo("rows", rows);
responseContent.setResponseTotal(total);
responseContent.setResponseResult(Response.RESPONSE_RESULT_SUCCESS);
return responseContent.generateResponse();
}
/**
*
*
* @param customer
* @return mapkey resultsuccess error
*/
@RequestMapping(value = "addCustomer", method = RequestMethod.POST)
public
@ResponseBody
Map<String, Object> addCustomer(@RequestBody Customer customer) throws CustomerManageServiceException {
// 初始化 Response
Response responseContent = ResponseFactory.newInstance();
// 添加记录
String result = customerManageService.addCustomer(customer) ? Response.RESPONSE_RESULT_SUCCESS : Response.RESPONSE_RESULT_ERROR;
responseContent.setResponseResult(result);
return responseContent.generateResponse();
}
/**
* customer ID
*
* @param customerID ID
* @return mapkey result success errorkey data
*
*/
@RequestMapping(value = "getCustomerInfo", method = RequestMethod.GET)
public
@ResponseBody
Map<String, Object> getCustomerInfo(@RequestParam("customerID") String customerID) throws CustomerManageServiceException {
// 初始化 Response
Response responseContent = ResponseFactory.newInstance();
String result = Response.RESPONSE_RESULT_ERROR;
// 获取客户信息
Customer customer = null;
Map<String, Object> queryResult = query(SEARCH_BY_ID, customerID, -1, -1);
if (queryResult != null) {
customer = (Customer) queryResult.get("data");
if (customer != null) {
result = Response.RESPONSE_RESULT_SUCCESS;
}
}
// 设置 Response
responseContent.setResponseResult(result);
responseContent.setResponseData(customer);
return responseContent.generateResponse();
}
/**
*
*
* @param customer
* @return mapkey resultsuccess error
*/
@RequestMapping(value = "updateCustomer", method = RequestMethod.POST)
public
@ResponseBody
Map<String, Object> updateCustomer(@RequestBody Customer customer) throws CustomerManageServiceException {
// 初始化 Response
Response responseContent = ResponseFactory.newInstance();
// 更新
String result = customerManageService.updateCustomer(customer) ? Response.RESPONSE_RESULT_SUCCESS : Response.RESPONSE_RESULT_ERROR;
responseContent.setResponseResult(result);
return responseContent.generateResponse();
}
/**
*
*
* @param customerIDStr ID
* @return mapkey resultsuccess error
*/
@RequestMapping(value = "deleteCustomer", method = RequestMethod.GET)
public
@ResponseBody
Map<String, Object> deleteCustomer(@RequestParam("customerID") String customerIDStr) throws CustomerManageServiceException {
// 初始化 Response
Response responseContent = ResponseFactory.newInstance();
// 参数检查
if (StringUtils.isNumeric(customerIDStr)) {
// 转换为 Integer
Integer customerID = Integer.valueOf(customerIDStr);
// 刪除
String result = customerManageService.deleteCustomer(customerID) ? Response.RESPONSE_RESULT_SUCCESS : Response.RESPONSE_RESULT_ERROR;
responseContent.setResponseResult(result);
} else
responseContent.setResponseResult(Response.RESPONSE_RESULT_ERROR);
return responseContent.generateResponse();
}
/**
*
*
* @param file
* @return mapkey resultsuccess
* errorkeytotalkeyavailable
*/
@RequestMapping(value = "importCustomer", method = RequestMethod.POST)
public
@ResponseBody
Map<String, Object> importCustomer(@RequestParam("file") MultipartFile file) throws CustomerManageServiceException {
// 初始化 Response
Response responseContent = ResponseFactory.newInstance();
String result = Response.RESPONSE_RESULT_SUCCESS;
// 读取文件内容
int total = 0;
int available = 0;
if (file == null)
result = Response.RESPONSE_RESULT_ERROR;
Map<String, Object> importInfo = customerManageService.importCustomer(file);
if (importInfo != null) {
total = (int) importInfo.get("total");
available = (int) importInfo.get("available");
}
responseContent.setResponseResult(result);
responseContent.setResponseTotal(total);
responseContent.setCustomerInfo("available", available);
return responseContent.generateResponse();
}
/**
*
*
* @param searchType
* @param keyWord
* @param response HttpServletResponse
*/
@SuppressWarnings("unchecked")
@RequestMapping(value = "exportCustomer", method = RequestMethod.GET)
public void exportCustomer(@RequestParam("searchType") String searchType, @RequestParam("keyWord") String keyWord,
HttpServletResponse response) throws CustomerManageServiceException, IOException {
String fileName = "customerInfo.xlsx";
List<Customer> customers = null;
Map<String, Object> queryResult = query(searchType, keyWord, -1, -1);
if (queryResult != null) {
customers = (List<Customer>) queryResult.get("data");
}
// 获取生成的文件
File file = customerManageService.exportCustomer(customers);
// 写出文件
if (file != null) {
// 设置响应头
response.addHeader("Content-Disposition", "attachment;filename=" + fileName);
FileInputStream inputStream = new FileInputStream(file);
OutputStream outputStream = response.getOutputStream();
byte[] buffer = new byte[8192];
int len;
while ((len = inputStream.read(buffer, 0, buffer.length)) > 0) {
outputStream.write(buffer, 0, len);
outputStream.flush();
}
inputStream.close();
outputStream.close();
}
}
}

@ -1,43 +0,0 @@
package com.ken.wms.common.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
/**
*
*
* @author Ken
*/
@Controller
@RequestMapping("/commons/fileSource")
public class FileSourceHandler {
@RequestMapping(value = "download/{fileName:.+}", method = RequestMethod.GET)
public void fileDownload(@PathVariable("fileName") String fileName, HttpServletRequest request,
HttpServletResponse response) throws IOException {
if (fileName == null)
return;
// 获取文件
ServletContext context = request.getServletContext();
String directory = context.getRealPath("/WEB-INF/download");
Path file = Paths.get(directory, fileName);
if (Files.exists(file)) {
// 设置响应头
response.addHeader("Content-Disposition", "attachment;filename=" + file.getFileName());
Files.copy(file, response.getOutputStream());
response.getOutputStream().flush();
}
}
}

@ -1,278 +0,0 @@
package com.ken.wms.common.controller;
import com.ken.wms.common.service.Interface.GoodsManageService;
import com.ken.wms.common.util.Response;
import com.ken.wms.common.util.ResponseFactory;
import com.ken.wms.domain.Goods;
import com.ken.wms.domain.Supplier;
import com.ken.wms.exception.GoodsManageServiceException;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.List;
import java.util.Map;
/**
* Handler
*
* @author Ken
*/
@RequestMapping(value = "/**/goodsManage")
@Controller
public class GoodsManageHandler {
@Autowired
private GoodsManageService goodsManageService;
private static final String SEARCH_BY_ID = "searchByID";
private static final String SEARCH_BY_NAME = "searchByName";
private static final String SEARCH_ALL = "searchAll";
/**
*
*
* @param searchType
* @param keyWord
* @param offset
* @param limit
* @return Map
*/
private Map<String, Object> query(String searchType, String keyWord, int offset, int limit) throws GoodsManageServiceException {
Map<String, Object> queryResult = null;
switch (searchType) {
case SEARCH_BY_ID:
if (StringUtils.isNumeric(keyWord))
queryResult = goodsManageService.selectById(Integer.valueOf(keyWord));
break;
case SEARCH_BY_NAME:
queryResult = goodsManageService.selectByName(keyWord);
break;
case SEARCH_ALL:
queryResult = goodsManageService.selectAll(offset, limit);
break;
default:
// do other thing
break;
}
return queryResult;
}
/**
*
*
* @param searchType
* @param offset
* @param limit
* @param keyWord
* @return
*/
@SuppressWarnings("unchecked")
@RequestMapping(value = "getGoodsList", method = RequestMethod.GET)
public
@ResponseBody
Map<String, Object> getGoodsList(@RequestParam("searchType") String searchType,
@RequestParam("offset") int offset, @RequestParam("limit") int limit,
@RequestParam("keyWord") String keyWord) throws GoodsManageServiceException {
// 初始化 Response
Response responseContent = ResponseFactory.newInstance();
List<Supplier> rows = null;
long total = 0;
// 查询
Map<String, Object> queryResult = query(searchType, keyWord, offset, limit);
if (queryResult != null) {
rows = (List<Supplier>) queryResult.get("data");
total = (long) queryResult.get("total");
}
// 设置 Response
responseContent.setCustomerInfo("rows", rows);
responseContent.setResponseTotal(total);
return responseContent.generateResponse();
}
/**
*
*
* @param goods
* @return mapkey resultsuccess error
*/
@RequestMapping(value = "addGoods", method = RequestMethod.POST)
public
@ResponseBody
Map<String, Object> addGoods(@RequestBody Goods goods) throws GoodsManageServiceException {
// 初始化 Response
Response responseContent = ResponseFactory.newInstance();
// 添加记录
String result = goodsManageService.addGoods(goods) ? Response.RESPONSE_RESULT_SUCCESS : Response.RESPONSE_RESULT_ERROR;
// 设置 Response
responseContent.setResponseResult(result);
return responseContent.generateResponse();
}
/**
* goods ID
*
* @param goodsID ID
* @return mapkey result success errorkey data
*
*/
@RequestMapping(value = "getGoodsInfo", method = RequestMethod.GET)
public
@ResponseBody
Map<String, Object> getGoodsInfo(@RequestParam("goodsID") Integer goodsID) throws GoodsManageServiceException {
// 初始化 Response
Response responseContent = ResponseFactory.newInstance();
String result = Response.RESPONSE_RESULT_ERROR;
// 获取货物信息
Goods goods = null;
Map<String, Object> queryResult = goodsManageService.selectById(goodsID);
if (queryResult != null) {
goods = (Goods) queryResult.get("data");
if (goods != null) {
result = Response.RESPONSE_RESULT_SUCCESS;
}
}
// 设置 Response
responseContent.setResponseResult(result);
responseContent.setResponseData(goods);
return responseContent.generateResponse();
}
/**
*
*
* @param goods
* @return mapkey resultsuccess error
*/
@RequestMapping(value = "updateGoods", method = RequestMethod.POST)
public
@ResponseBody
Map<String, Object> updateGoods(@RequestBody Goods goods) throws GoodsManageServiceException {
// 初始化 Response
Response responseContent = ResponseFactory.newInstance();
// 更新
String result = goodsManageService.updateGoods(goods) ? Response.RESPONSE_RESULT_SUCCESS : Response.RESPONSE_RESULT_ERROR;
// 设置 Response
responseContent.setResponseResult(result);
return responseContent.generateResponse();
}
/**
*
*
* @param goodsID ID
* @return mapkey resultsuccess error
*/
@RequestMapping(value = "deleteGoods", method = RequestMethod.GET)
public
@ResponseBody
Map<String, Object> deleteGoods(@RequestParam("goodsID") Integer goodsID) throws GoodsManageServiceException {
// 初始化 Response
Response responseContent = ResponseFactory.newInstance();
// 删除
String result = goodsManageService.deleteGoods(goodsID) ? Response.RESPONSE_RESULT_SUCCESS : Response.RESPONSE_RESULT_ERROR;
// 设置 Response
responseContent.setResponseResult(result);
return responseContent.generateResponse();
}
/**
*
*
* @param file
* @return mapkey resultsuccess
* errorkeytotalkeyavailable
*/
@RequestMapping(value = "importGoods", method = RequestMethod.POST)
public
@ResponseBody
Map<String, Object> importGoods(@RequestParam("file") MultipartFile file) throws GoodsManageServiceException {
// 初始化 Response
Response responseContent = ResponseFactory.newInstance();
String result = Response.RESPONSE_RESULT_ERROR;
// 读取文件内容
int total = 0;
int available = 0;
if (file != null) {
Map<String, Object> importInfo = goodsManageService.importGoods(file);
if (importInfo != null) {
total = (int) importInfo.get("total");
available = (int) importInfo.get("available");
result = Response.RESPONSE_RESULT_SUCCESS;
}
}
// 设置 Response
responseContent.setResponseResult(result);
responseContent.setResponseTotal(total);
responseContent.setCustomerInfo("available", available);
return responseContent.generateResponse();
}
/**
*
*
* @param searchType
* @param keyWord
* @param response HttpServletResponse
*/
@SuppressWarnings("unchecked")
@RequestMapping(value = "exportGoods", method = RequestMethod.GET)
public void exportGoods(@RequestParam("searchType") String searchType, @RequestParam("keyWord") String keyWord,
HttpServletResponse response) throws GoodsManageServiceException, IOException {
String fileName = "goodsInfo.xlsx";
List<Goods> goodsList = null;
Map<String, Object> queryResult = query(searchType, keyWord, -1, -1);
if (queryResult != null) {
goodsList = (List<Goods>) queryResult.get("data");
}
// 获取生成的文件
File file = goodsManageService.exportGoods(goodsList);
// 写出文件
if (file != null) {
// 设置响应头
response.addHeader("Content-Disposition", "attachment;filename=" + fileName);
FileInputStream inputStream = new FileInputStream(file);
OutputStream outputStream = response.getOutputStream();
byte[] buffer = new byte[8192];
int len;
while ((len = inputStream.read(buffer, 0, buffer.length)) > 0) {
outputStream.write(buffer, 0, len);
outputStream.flush();
}
inputStream.close();
outputStream.close();
}
}
}

@ -1,289 +0,0 @@
package com.ken.wms.common.controller;
import com.ken.wms.common.service.Interface.RepositoryAdminManageService;
import com.ken.wms.common.util.Response;
import com.ken.wms.common.util.ResponseFactory;
import com.ken.wms.domain.RepositoryAdmin;
import com.ken.wms.exception.RepositoryAdminManageServiceException;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* Handler
*
* @author Ken
*/
@Controller
@RequestMapping(value = "/**/repositoryAdminManage")
public class RepositoryAdminManageHandler {
@Autowired
private RepositoryAdminManageService repositoryAdminManageService;
// 查询类型
private static final String SEARCH_BY_ID = "searchByID";
private static final String SEARCH_BY_NAME = "searchByName";
private static final String SEARCH_BY_REPOSITORY_ID = "searchByRepositoryID";
private static final String SEARCH_ALL = "searchAll";
/**
*
*
* @param keyWord
* @param searchType
* @param offset
* @param limit
* @return
*/
private Map<String, Object> query(String keyWord, String searchType, int offset, int limit) throws RepositoryAdminManageServiceException {
Map<String, Object> queryResult = null;
// query
switch (searchType) {
case SEARCH_ALL:
queryResult = repositoryAdminManageService.selectAll(offset, limit);
break;
case SEARCH_BY_ID:
if (StringUtils.isNumeric(keyWord))
queryResult = repositoryAdminManageService.selectByID(Integer.valueOf(keyWord));
break;
case SEARCH_BY_NAME:
queryResult = repositoryAdminManageService.selectByName(offset, limit, keyWord);
break;
case SEARCH_BY_REPOSITORY_ID:
if (StringUtils.isNumeric(keyWord))
queryResult = repositoryAdminManageService.selectByRepositoryID(Integer.valueOf(keyWord));
break;
default:
// do other things
break;
}
return queryResult;
}
/**
*
*
* @param searchType
* @param offset
* @param limit
* @param keyWord
* @return Mapkey=rowskey=total
*/
@SuppressWarnings("unchecked")
@RequestMapping(value = "getRepositoryAdminList", method = RequestMethod.GET)
public
@ResponseBody
Map<String, Object> getRepositoryAdmin(@RequestParam("searchType") String searchType,
@RequestParam("keyWord") String keyWord, @RequestParam("offset") int offset,
@RequestParam("limit") int limit) throws RepositoryAdminManageServiceException {
// 初始化 Response
Response responseContent = ResponseFactory.newInstance();
List<RepositoryAdmin> rows = null;
long total = 0;
// 查询
Map<String, Object> queryResult = query(keyWord, searchType, offset, limit);
if (queryResult != null) {
rows = (List<RepositoryAdmin>) queryResult.get("data");
total = (long) queryResult.get("total");
}
// 设置 Response
responseContent.setCustomerInfo("rows", rows);
responseContent.setResponseTotal(total);
return responseContent.generateResponse();
}
/**
*
*
* @param repositoryAdmin
* @return mapkey resultsuccess error
*/
@RequestMapping(value = "addRepositoryAdmin", method = RequestMethod.POST)
public
@ResponseBody
Map<String, Object> addRepositoryAdmin(@RequestBody RepositoryAdmin repositoryAdmin) throws RepositoryAdminManageServiceException {
// 初始化 Response
Response responseContent = ResponseFactory.newInstance();
// 添加结果
String result = repositoryAdminManageService.addRepositoryAdmin(repositoryAdmin)
? Response.RESPONSE_RESULT_SUCCESS : Response.RESPONSE_RESULT_ERROR;
// 设置 Response
responseContent.setResponseResult(result);
return responseContent.generateResponse();
}
/**
* ID
*
* @param repositoryAdminID ID
* @return mapkey result success errorkey data
*
*/
@RequestMapping(value = "getRepositoryAdminInfo", method = RequestMethod.GET)
public
@ResponseBody
Map<String, Object> getRepositoryAdminInfo(Integer repositoryAdminID) throws RepositoryAdminManageServiceException {
// 初始化 Response
Response responseContent = ResponseFactory.newInstance();
String result = Response.RESPONSE_RESULT_ERROR;
// 查询
RepositoryAdmin repositoryAdmin = null;
Map<String, Object> queryResult = repositoryAdminManageService.selectByID(repositoryAdminID);
if (queryResult != null) {
if ((repositoryAdmin = (RepositoryAdmin) queryResult.get("data")) != null)
result = Response.RESPONSE_RESULT_SUCCESS;
}
// 设置 Response
responseContent.setResponseResult(result);
responseContent.setResponseData(repositoryAdmin);
return responseContent.generateResponse();
}
/**
*
*
* @param repositoryAdmin
* @return mapkey result success errorkey data
*
*/
@RequestMapping(value = "updateRepositoryAdmin", method = RequestMethod.POST)
public
@ResponseBody
Map<String, Object> updateRepositoryAdmin(@RequestBody RepositoryAdmin repositoryAdmin) throws RepositoryAdminManageServiceException {
// 初始化 Response
Response responseContent = ResponseFactory.newInstance();
// 更新
String result = repositoryAdminManageService.updateRepositoryAdmin(repositoryAdmin)
? Response.RESPONSE_RESULT_SUCCESS : Response.RESPONSE_RESULT_ERROR;
// 设置 Response
responseContent.setResponseResult(result);
return responseContent.generateResponse();
}
/**
* ID
*
* @param repositoryAdminID ID
* @return mapkey result success errorkey data
*
*/
@RequestMapping(value = "deleteRepositoryAdmin", method = RequestMethod.GET)
public
@ResponseBody
Map<String, Object> deleteRepositoryAdmin(Integer repositoryAdminID) throws RepositoryAdminManageServiceException {
// 初始化 Response
Response responseContent = ResponseFactory.newInstance();
// 删除记录
String result = repositoryAdminManageService.deleteRepositoryAdmin(repositoryAdminID)
? Response.RESPONSE_RESULT_SUCCESS : Response.RESPONSE_RESULT_ERROR;
// 设置 Response
responseContent.setResponseResult(result);
return responseContent.generateResponse();
}
/**
*
*
* @param file
* @return mapkey resultsuccess
* errorkeytotalkeyavailable
*/
@RequestMapping(value = "importRepositoryAdmin", method = RequestMethod.POST)
public
@ResponseBody
Map<String, Object> importRepositoryAdmin(MultipartFile file) throws RepositoryAdminManageServiceException {
// 初始化 Response
Response responseContent = ResponseFactory.newInstance();
String result = Response.RESPONSE_RESULT_ERROR;
// 读取文件
long total = 0;
long available = 0;
if (file != null) {
Map<String, Object> importInfo = repositoryAdminManageService.importRepositoryAdmin(file);
if (importInfo != null) {
total = (long) importInfo.get("total");
available = (long) importInfo.get("available");
result = Response.RESPONSE_RESULT_SUCCESS;
}
}
// 设置 Response
responseContent.setResponseResult(result);
responseContent.setResponseTotal(total);
responseContent.setCustomerInfo("available", available);
return responseContent.generateResponse();
}
/**
*
*
* @param searchType
* @param keyWord
* @param response HttpServletResponse
*/
@SuppressWarnings("unchecked")
@RequestMapping(value = "exportRepositoryAdmin", method = RequestMethod.GET)
public void exportRepositoryAdmin(@RequestParam("searchType") String searchType,
@RequestParam("keyWord") String keyWord, HttpServletResponse response) throws RepositoryAdminManageServiceException, IOException {
// 导出文件名
String fileName = "repositoryAdminInfo.xlsx";
// 查询
List<RepositoryAdmin> repositoryAdmins;
Map<String, Object> queryResult = query(keyWord, searchType, -1, -1);
if (queryResult != null)
repositoryAdmins = (List<RepositoryAdmin>) queryResult.get("data");
else
repositoryAdmins = new ArrayList<>();
// 生成文件
File file = repositoryAdminManageService.exportRepositoryAdmin(repositoryAdmins);
// 输出文件
if (file != null) {
// 设置响应头
response.addHeader("Content-Disposition", "attachment;filename=" + fileName);
FileInputStream inputStream = new FileInputStream(file);
OutputStream outputStream = response.getOutputStream();
byte[] buffer = new byte[8192];
int len;
while ((len = inputStream.read(buffer, 0, buffer.length)) > 0) {
outputStream.write(buffer, 0, len);
outputStream.flush();
}
inputStream.close();
outputStream.close();
}
}
}

@ -1,311 +0,0 @@
package com.ken.wms.common.controller;
import com.ken.wms.common.service.Interface.RepositoryService;
import com.ken.wms.common.util.Response;
import com.ken.wms.common.util.ResponseFactory;
import com.ken.wms.domain.Repository;
import com.ken.wms.exception.RepositoryManageServiceException;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Handler
*
* @author Ken
*/
@Controller
@RequestMapping(value = "/**/repositoryManage")
public class RepositoryManageHandler {
@Autowired
private RepositoryService repositoryService;
private static final String SEARCH_BY_ID = "searchByID";
private static final String SEARCH_BY_ADDRESS = "searchByAddress";
private static final String SEARCH_ALL = "searchAll";
/**
*
*
* @param searchType
* @param keyword
* @param offset
* @param limit
* @return
*/
private Map<String, Object> query(String searchType, String keyword, int offset, int limit) throws RepositoryManageServiceException {
Map<String, Object> queryResult = null;
switch (searchType) {
case SEARCH_BY_ID:
if (StringUtils.isNumeric(keyword)) {
queryResult = repositoryService.selectById(Integer.valueOf(keyword));
}
break;
case SEARCH_BY_ADDRESS:
queryResult = repositoryService.selectByAddress(offset, limit, keyword);
break;
case SEARCH_ALL:
queryResult = repositoryService.selectAll(offset, limit);
break;
default:
// do other thing
break;
}
return queryResult;
}
/**
*
*
* @param searchType
* @param offset
* @param limit
* @param keyWord
* @return Mapkey=rowskey=total
*/
@SuppressWarnings("unchecked")
@RequestMapping(value = "getRepositoryList", method = RequestMethod.GET)
public
@ResponseBody
Map<String, Object> getRepositoryList(@RequestParam("searchType") String searchType,
@RequestParam("offset") int offset, @RequestParam("limit") int limit,
@RequestParam("keyWord") String keyWord) throws RepositoryManageServiceException {
// 初始化 Response
Response responseContent = ResponseFactory.newInstance();
List<Repository> rows = null;
long total = 0;
// 查询
Map<String, Object> queryResult = query(searchType, keyWord, offset, limit);
if (queryResult != null) {
rows = (List<Repository>) queryResult.get("data");
total = (long) queryResult.get("total");
}
// 设置 Response
responseContent.setCustomerInfo("rows", rows);
responseContent.setResponseTotal(total);
return responseContent.generateResponse();
}
/**
*
*
* @return mapkey=datakey=total
*/
@SuppressWarnings("unchecked")
@RequestMapping(value = "getUnassignRepository", method = RequestMethod.GET)
public
@ResponseBody
Map<String, Object> getUnassignRepository() throws RepositoryManageServiceException {
// 初始化结果集
Map<String, Object> resultSet = new HashMap<>();
List<Repository> data;
long total = 0;
// 查询
Map<String, Object> queryResult = repositoryService.selectUnassign();
if (queryResult != null) {
data = (List<Repository>) queryResult.get("data");
total = (long) queryResult.get("total");
} else
data = new ArrayList<>();
resultSet.put("data", data);
resultSet.put("total", total);
return resultSet;
}
/**
*
*
* @param repository
* @return mapkey resultsuccess error
*/
@RequestMapping(value = "addRepository", method = RequestMethod.POST)
public
@ResponseBody
Map<String, Object> addRepository(@RequestBody Repository repository) throws RepositoryManageServiceException {
// 初始化 Response
Response responseContent = ResponseFactory.newInstance();
// 添加记录
String result = repositoryService.addRepository(repository) ? Response.RESPONSE_RESULT_SUCCESS : Response.RESPONSE_RESULT_ERROR;
// 设置 Response
responseContent.setResponseResult(result);
return responseContent.generateResponse();
}
/**
* ID
*
* @param repositoryID ID
* @return mapkey result success errorkey data
*
*/
@RequestMapping(value = "getRepositoryInfo", method = RequestMethod.GET)
public
@ResponseBody
Map<String, Object> getRepositoryInfo(@RequestParam("repositoryID") Integer repositoryID) throws RepositoryManageServiceException {
// 初始化 Response
Response responseContent = ResponseFactory.newInstance();
String result = Response.RESPONSE_RESULT_ERROR;
// 查询
Repository repository = null;
Map<String, Object> queryResult = repositoryService.selectById(repositoryID);
if (queryResult != null) {
repository = (Repository) queryResult.get("data");
if (repository != null)
result = Response.RESPONSE_RESULT_SUCCESS;
}
// 设置 Response
responseContent.setResponseResult(result);
responseContent.setResponseData(repository);
return responseContent.generateResponse();
}
/**
*
*
* @param repository
* @return mapkey result success errorkey data
*
*/
@RequestMapping(value = "updateRepository", method = RequestMethod.POST)
public
@ResponseBody
Map<String, Object> updateRepository(@RequestBody Repository repository) throws RepositoryManageServiceException {
// 初始化 Response
Response responseContent = ResponseFactory.newInstance();
// 更新
String result = repositoryService.updateRepository(repository) ? Response.RESPONSE_RESULT_SUCCESS : Response.RESPONSE_RESULT_ERROR;
// 设置 Response
responseContent.setResponseResult(result);
return responseContent.generateResponse();
}
/**
* ID
*
* @param repositoryID ID
* @return mapkey result success errorkey data
*
*/
@RequestMapping(value = "deleteRepository", method = RequestMethod.GET)
public
@ResponseBody
Map<String, Object> deleteRepository(@RequestParam("repositoryID") Integer repositoryID) throws RepositoryManageServiceException {
// 初始化 Response
Response responseContent = ResponseFactory.newInstance();
// 删除记录
String result = repositoryService.deleteRepository(repositoryID) ? Response.RESPONSE_RESULT_SUCCESS : Response.RESPONSE_RESULT_ERROR;
// 设置 Response
responseContent.setResponseResult(result);
return responseContent.generateResponse();
}
/**
*
*
* @param file
* @return mapkey resultsuccess
* errorkeytotalkeyavailable
*/
@RequestMapping(value = "importRepository", method = RequestMethod.POST)
public
@ResponseBody
Map<String, Object> importRepository(MultipartFile file) throws RepositoryManageServiceException {
// 初始化 Response
Response responseContent = ResponseFactory.newInstance();
String result = Response.RESPONSE_RESULT_ERROR;
// 读取文件
int total = 0;
int available = 0;
if (file != null) {
Map<String, Object> importInfo = repositoryService.importRepository(file);
if (importInfo != null) {
total = (int) importInfo.get("total");
available = (int) importInfo.get("available");
result = Response.RESPONSE_RESULT_SUCCESS;
}
}
// 设置 Response
responseContent.setResponseResult(result);
responseContent.setResponseTotal(total);
responseContent.setCustomerInfo("available", available);
return responseContent.generateResponse();
}
/**
*
*
* @param searchType
* @param keyWord
* @param response HttpServletResponse
*/
@SuppressWarnings("unchecked")
@RequestMapping(value = "exportRepository", method = RequestMethod.GET)
public void exportRepository(@RequestParam("searchType") String searchType, @RequestParam("keyWord") String keyWord,
HttpServletResponse response) throws RepositoryManageServiceException, IOException {
// 导出文件名
String fileName = "repositoryInfo.xlsx";
// 查询
List<Repository> repositories;
Map<String, Object> queryResult = query(searchType, keyWord, -1, -1);
if (queryResult != null)
repositories = (List<Repository>) queryResult.get("data");
else
repositories = new ArrayList<>();
// 生成文件
File file = repositoryService.exportRepository(repositories);
// 输出文件
if (file != null) {
// 设置响应头
response.addHeader("Content-Disposition", "attachment;filename=" + fileName);
FileInputStream inputStream = new FileInputStream(file);
OutputStream outputStream = response.getOutputStream();
byte[] buffer = new byte[8192];
int len;
while ((len = inputStream.read(buffer, 0, buffer.length)) > 0) {
outputStream.write(buffer, 0, len);
outputStream.flush();
}
inputStream.close();
outputStream.close();
}
}
}

@ -1,213 +0,0 @@
package com.ken.wms.common.controller;
import com.ken.wms.common.service.Interface.StockRecordManageService;
import com.ken.wms.common.util.Response;
import com.ken.wms.common.util.ResponseFactory;
import com.ken.wms.domain.StockRecordDTO;
import com.ken.wms.domain.UserInfoDTO;
import com.ken.wms.exception.StockRecordManageServiceException;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.session.Session;
import org.apache.shiro.subject.Subject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* Handler
*
* @author Ken
* @since 017/4/5.
*/
@Controller
@RequestMapping(value = "stockRecordManage")
public class StockRecordManageHandler {
@Autowired
private StockRecordManageService stockRecordManageService;
/**
*
*
* @param customerID ID
* @param goodsID ID
* @param repositoryIDStr ID
* @param number
* @return mapkeyresult
*/
@RequestMapping(value = "stockOut", method = RequestMethod.POST)
public
@ResponseBody
Map<String, Object> stockOut(@RequestParam("customerID") Integer customerID,
@RequestParam("goodsID") Integer goodsID,
@RequestParam(value = "repositoryID", required = false) String repositoryIDStr,
@RequestParam("number") long number) throws StockRecordManageServiceException {
// 初始化 Response
Response responseContent = ResponseFactory.newInstance();
String result = Response.RESPONSE_RESULT_ERROR;
boolean authorizeCheck = true;
boolean argumentCheck = true;
Integer repositoryID = null;
// 参数检查
if (repositoryIDStr != null) {
if (StringUtils.isNumeric(repositoryIDStr)) {
repositoryID = Integer.valueOf(repositoryIDStr);
} else {
argumentCheck = false;
responseContent.setResponseMsg("request argument error");
}
}
// 获取 session 中的信息
Subject currentUser = SecurityUtils.getSubject();
Session session = currentUser.getSession();
UserInfoDTO userInfo = (UserInfoDTO) session.getAttribute("userInfo");
String personInCharge = userInfo == null ? "none" : userInfo.getUserName();
Integer repositoryIDBelong = userInfo == null ? -1 : userInfo.getRepositoryBelong();
// 设置非管理员请求的仓库ID
if (!currentUser.hasRole("systemAdmin")) {
if (repositoryIDBelong < 0) {
authorizeCheck = false;
responseContent.setResponseMsg("You are not authorized");
} else {
repositoryID = repositoryIDBelong;
}
}
if (authorizeCheck && argumentCheck) {
if (stockRecordManageService.stockOutOperation(customerID, goodsID, repositoryID, number, personInCharge))
result = Response.RESPONSE_RESULT_SUCCESS;
}
// 设置 Response
responseContent.setResponseResult(result);
return responseContent.generateResponse();
}
/**
*
*
* @param supplierID ID
* @param goodsID ID
* @param repositoryIDStr ID
* @param number
* @return mapkeyresult
*/
@RequestMapping(value = "stockIn", method = RequestMethod.POST)
public
@ResponseBody
Map<String, Object> stockIn(@RequestParam("supplierID") Integer supplierID,
@RequestParam("goodsID") Integer goodsID,
@RequestParam(value = "repositoryID", required = false) String repositoryIDStr,
@RequestParam("number") long number) throws StockRecordManageServiceException {
// 初始化 Response
Response responseContent = ResponseFactory.newInstance();
String result = Response.RESPONSE_RESULT_ERROR;
boolean authorizeCheck = true;
boolean argumentCheck = true;
Integer repositoryID = null;
// 参数检查
if (repositoryIDStr != null) {
if (StringUtils.isNumeric(repositoryIDStr)) {
repositoryID = Integer.valueOf(repositoryIDStr);
} else {
argumentCheck = false;
responseContent.setResponseMsg("request argument error");
}
}
// 获取session中的信息
Subject currentUser = SecurityUtils.getSubject();
Session session = currentUser.getSession();
UserInfoDTO userInfo = (UserInfoDTO) session.getAttribute("userInfo");
String personInCharge = userInfo == null ? "none" : userInfo.getUserName();
Integer repositoryIDBelong = userInfo == null ? -1 : userInfo.getRepositoryBelong();
// 设置非管理员请求的仓库ID
if (!currentUser.hasRole("systemAdmin")) {
if (repositoryIDBelong < 0) {
authorizeCheck = false;
responseContent.setResponseMsg("You are not authorized");
} else {
repositoryID = repositoryIDBelong;
}
}
// 执行 Service
if (authorizeCheck && argumentCheck) {
if (stockRecordManageService.stockInOperation(supplierID, goodsID, repositoryID, number, personInCharge)) {
result = Response.RESPONSE_RESULT_SUCCESS;
}
}
// 设置 Response
responseContent.setResponseResult(result);
return responseContent.generateResponse();
}
/**
*
*
* @param searchType
* @param repositoryIDStr ID
* @param endDateStr
* @param startDateStr
* @param limit
* @param offset
* @return MapKeyrowsKeytotal
*/
@SuppressWarnings({"SingleStatementInBlock", "unchecked"})
@RequestMapping(value = "searchStockRecord", method = RequestMethod.GET)
public @ResponseBody
Map<String, Object> getStockRecord(@RequestParam("searchType") String searchType,
@RequestParam("repositoryID") String repositoryIDStr,
@RequestParam("startDate") String startDateStr,
@RequestParam("endDate") String endDateStr,
@RequestParam("limit") int limit,
@RequestParam("offset") int offset) throws ParseException, StockRecordManageServiceException {
// 初始化 Response
Response responseContent = ResponseFactory.newInstance();
List<StockRecordDTO> rows = null;
long total = 0;
// 参数检查
String regex = "([0-9]{4})-([0-9]{2})-([0-9]{2})";
boolean startDateFormatCheck = (StringUtils.isEmpty(startDateStr) || startDateStr.matches(regex));
boolean endDateFormatCheck = (StringUtils.isEmpty(endDateStr) || endDateStr.matches(regex));
boolean repositoryIDCheck = (StringUtils.isEmpty(repositoryIDStr) || StringUtils.isNumeric(repositoryIDStr));
if (startDateFormatCheck && endDateFormatCheck && repositoryIDCheck) {
Integer repositoryID = -1;
if (StringUtils.isNumeric(repositoryIDStr)) {
repositoryID = Integer.valueOf(repositoryIDStr);
}
// 转到 Service 执行查询
Map<String, Object> queryResult = stockRecordManageService.selectStockRecord(repositoryID, startDateStr, endDateStr, searchType, offset, limit);
if (queryResult != null) {
rows = (List<StockRecordDTO>) queryResult.get("data");
total = (long) queryResult.get("total");
}
} else
responseContent.setResponseMsg("Request argument error");
if (rows == null)
rows = new ArrayList<>(0);
responseContent.setCustomerInfo("rows", rows);
responseContent.setResponseTotal(total);
return responseContent.generateResponse();
}
}

@ -1,365 +0,0 @@
package com.ken.wms.common.controller;
import com.ken.wms.common.service.Interface.StockRecordManageService;
import com.ken.wms.common.service.Interface.StorageManageService;
import com.ken.wms.common.util.Response;
import com.ken.wms.common.util.ResponseFactory;
import com.ken.wms.domain.Storage;
import com.ken.wms.domain.UserInfoDTO;
import com.ken.wms.exception.StorageManageServiceException;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
*
*
* @author Ken
*/
@Controller
@RequestMapping(value = "/**/storageManage")
public class StorageManageHandler {
@Autowired
private StorageManageService storageManageService;
@Autowired
private StockRecordManageService stockRecordManageService;
private static final String SEARCH_BY_GOODS_ID = "searchByGoodsID";
private static final String SEARCH_BY_GOODS_NAME = "searchByGoodsName";
private static final String SEARCH_BY_GOODS_TYPE = "searchByGoodsType";
private static final String SEARCH_ALL = "searchAll";
/**
*
*
* @param searchType
* @param keyword
* @param repositoryBelong
* @param offset
* @param limit
* @return Map key data key total
*/
private Map<String, Object> query(String searchType, String keyword, String repositoryBelong, int offset,
int limit) throws StorageManageServiceException {
Map<String, Object> queryResult = null;
switch (searchType) {
case SEARCH_ALL:
if (StringUtils.isNumeric(repositoryBelong)) {
Integer repositoryID = Integer.valueOf(repositoryBelong);
queryResult = storageManageService.selectAll(repositoryID, offset, limit);
} else {
queryResult = storageManageService.selectAll(-1, offset, limit);
}
break;
case SEARCH_BY_GOODS_ID:
if (StringUtils.isNumeric(keyword)) {
Integer goodsID = Integer.valueOf(keyword);
if (StringUtils.isNumeric(repositoryBelong)) {
Integer repositoryID = Integer.valueOf(repositoryBelong);
queryResult = storageManageService.selectByGoodsID(goodsID, repositoryID, offset, limit);
} else
queryResult = storageManageService.selectByGoodsID(goodsID, -1, offset, limit);
}
break;
case SEARCH_BY_GOODS_TYPE:
if (StringUtils.isNumeric(repositoryBelong)) {
Integer repositoryID = Integer.valueOf(repositoryBelong);
queryResult = storageManageService.selectByGoodsType(keyword, repositoryID, offset, limit);
} else
queryResult = storageManageService.selectByGoodsType(keyword, -1, offset, limit);
break;
case SEARCH_BY_GOODS_NAME:
if (StringUtils.isNumeric(repositoryBelong)) {
Integer repositoryID = Integer.valueOf(repositoryBelong);
queryResult = storageManageService.selectByGoodsName(keyword, repositoryID, offset, limit);
} else
queryResult = storageManageService.selectByGoodsName(keyword, -1, offset, limit);
break;
default:
// do other thing
break;
}
return queryResult;
}
/**
*
*
* @param keyword
* @param searchType
* @param repositoryBelong
* @param offset
* @param limit
* @return Map key rows key total
*/
@SuppressWarnings("unchecked")
@RequestMapping(value = "getStorageListWithRepository", method = RequestMethod.GET)
public
@ResponseBody
Map<String, Object> getStorageListWithRepoID(@RequestParam("keyword") String keyword,
@RequestParam("searchType") String searchType, @RequestParam("repositoryBelong") String repositoryBelong,
@RequestParam("offset") int offset, @RequestParam("limit") int limit) throws StorageManageServiceException {
// 初始化 Response
Response responseContent = ResponseFactory.newInstance();
List<Storage> rows;
long total = 0;
// query
Map<String, Object> queryResult = query(searchType, keyword, repositoryBelong, offset, limit);
if (queryResult != null) {
rows = (List<Storage>) queryResult.get("data");
total = (long) queryResult.get("total");
} else
rows = new ArrayList<>();
// 设置 Response
responseContent.setCustomerInfo("rows", rows);
responseContent.setResponseTotal(total);
return responseContent.generateResponse();
}
/**
* session
*
* @param keyword
* @param searchType
* @param offset
* @param limit
* @param request
* @return Map key rows key total
*/
@SuppressWarnings("unchecked")
@RequestMapping(value = "getStorageList", method = RequestMethod.GET)
public
@ResponseBody
Map<String, Object> getStorageList(@RequestParam("keyword") String keyword,
@RequestParam("searchType") String searchType, @RequestParam("offset") int offset,
@RequestParam("limit") int limit, HttpServletRequest request) throws StorageManageServiceException {
// 初始化 Response
Response responseContent = ResponseFactory.newInstance();
List<Storage> rows = null;
long total = 0;
HttpSession session = request.getSession();
UserInfoDTO userInfo = (UserInfoDTO) session.getAttribute("userInfo");
Integer repositoryID = userInfo.getRepositoryBelong();
if (repositoryID > 0) {
Map<String, Object> queryResult = query(searchType, keyword, repositoryID.toString(), offset, limit);
if (queryResult != null) {
rows = (List<Storage>) queryResult.get("data");
total = (long) queryResult.get("total");
}
}
if (rows == null)
rows = new ArrayList<>();
// 设置 Response
responseContent.setCustomerInfo("rows", rows);
responseContent.setResponseTotal(total);
return responseContent.generateResponse();
}
/**
*
*
* @return mapkey resultsuccess error
*/
@RequestMapping(value = "addStorageRecord", method = RequestMethod.POST)
public
@ResponseBody
Map<String, Object> addStorageRecord(@RequestBody Map<String, Object> params) throws StorageManageServiceException {
// 初始化 Response
Response responseContent = ResponseFactory.newInstance();
String isSuccess = Response.RESPONSE_RESULT_ERROR;
boolean isAvailable = true;
String goodsID = (String) params.get("goodsID");
String repositoryID = (String) params.get("repositoryID");
String number = (String) params.get("number");
if (StringUtils.isBlank(goodsID) || !StringUtils.isNumeric(goodsID))
isAvailable = false;
if (StringUtils.isBlank(repositoryID) || !StringUtils.isNumeric(repositoryID))
isAvailable = false;
if (StringUtils.isBlank(number) || !StringUtils.isNumeric(number))
isAvailable = false;
if (isAvailable) {
isSuccess = storageManageService.addNewStorage(Integer.valueOf(goodsID), Integer.valueOf(repositoryID),
Integer.valueOf(number)) ? Response.RESPONSE_RESULT_SUCCESS : Response.RESPONSE_RESULT_ERROR;
}
// 设置 Response
responseContent.setResponseResult(isSuccess);
return responseContent.generateResponse();
}
/**
*
*
* @return mapkey resultsuccess error
*/
@RequestMapping(value = "updateStorageRecord", method = RequestMethod.POST)
public
@ResponseBody
Map<String, Object> updateStorageRecord(@RequestBody Map<String, Object> params) throws StorageManageServiceException {
// 初始化 Response
Response responseContent = ResponseFactory.newInstance();
boolean isAvailable = true;
String result = Response.RESPONSE_RESULT_ERROR;
String goodsID = (String) params.get("goodsID");
String repositoryID = (String) params.get("repositoryID");
String number = (String) params.get("number");
if (StringUtils.isBlank(goodsID) || !StringUtils.isNumeric(goodsID))
isAvailable = false;
if (StringUtils.isBlank(repositoryID) || !StringUtils.isNumeric(repositoryID))
isAvailable = false;
if (StringUtils.isBlank(number) || !StringUtils.isNumeric(number))
isAvailable = false;
if (isAvailable) {
result = storageManageService.updateStorage(Integer.valueOf(goodsID), Integer.valueOf(repositoryID),
Integer.valueOf(number)) ? Response.RESPONSE_RESULT_SUCCESS : Response.RESPONSE_RESULT_ERROR;
}
// 设置 Response
responseContent.setResponseResult(result);
return responseContent.generateResponse();
}
/**
*
*
* @param goodsID ID
* @param repositoryID ID
* @return mapkey resultsuccess error
*/
@RequestMapping(value = "deleteStorageRecord", method = RequestMethod.GET)
public
@ResponseBody
Map<String, Object> deleteStorageRecord(@RequestParam("goodsID") String goodsID,
@RequestParam("repositoryID") String repositoryID) throws StorageManageServiceException {
// 初始化 Response
Response responseContent = ResponseFactory.newInstance();
String result = Response.RESPONSE_RESULT_ERROR;
boolean isAvailable = true;
if (StringUtils.isBlank(goodsID) || !StringUtils.isNumeric(goodsID))
isAvailable = false;
if (StringUtils.isBlank(repositoryID) || !StringUtils.isNumeric(repositoryID))
isAvailable = false;
if (isAvailable) {
result = storageManageService.deleteStorage(Integer.valueOf(goodsID), Integer.valueOf(repositoryID))
? Response.RESPONSE_RESULT_SUCCESS : Response.RESPONSE_RESULT_ERROR;
}
// 设置 Response
responseContent.setResponseResult(result);
return responseContent.generateResponse();
}
/**
*
*
* @param file
* @return mapkey resultsuccess
* errorkeytotalkeyavailable
*/
@RequestMapping(value = "importStorageRecord", method = RequestMethod.POST)
public
@ResponseBody
Map<String, Object> importStorageRecord(@RequestParam("file") MultipartFile file) throws StorageManageServiceException {
// 初始化 Response
Response responseContent = ResponseFactory.newInstance();
String result = Response.RESPONSE_RESULT_ERROR;
int total = 0;
int available = 0;
if (file != null) {
Map<String, Object> importInfo = storageManageService.importStorage(file);
if (importInfo != null) {
total = (int) importInfo.get("total");
available = (int) importInfo.get("available");
result = Response.RESPONSE_RESULT_SUCCESS;
}
}
// 设置 Response
responseContent.setResponseResult(result);
responseContent.setResponseTotal(total);
responseContent.setCustomerInfo("available", available);
return responseContent.generateResponse();
}
/**
*
*
* @param searchType
* @param keyword
* @param repositoryBelong
* @param request
* @param response
*/
@SuppressWarnings("unchecked")
@RequestMapping(value = "exportStorageRecord", method = RequestMethod.GET)
public void exportStorageRecord(@RequestParam("searchType") String searchType,
@RequestParam("keyword") String keyword,
@RequestParam(value = "repositoryBelong", required = false) String repositoryBelong,
HttpServletRequest request, HttpServletResponse response) throws StorageManageServiceException, IOException {
String fileName = "storageRecord.xlsx";
HttpSession session = request.getSession();
UserInfoDTO userInfo = (UserInfoDTO) session.getAttribute("userInfo");
Integer sessionRepositoryBelong = userInfo.getRepositoryBelong();
if (sessionRepositoryBelong > 0)
repositoryBelong = sessionRepositoryBelong.toString();
List<Storage> storageList = null;
Map<String, Object> queryResult = query(searchType, keyword, repositoryBelong, -1, -1);
if (queryResult != null)
storageList = (List<Storage>) queryResult.get("data");
File file = storageManageService.exportStorage(storageList);
if (file != null) {
// 设置响应头
response.addHeader("Content-Disposition", "attachment;filename=" + fileName);
FileInputStream inputStream = new FileInputStream(file);
OutputStream outputStream = response.getOutputStream();
byte[] buffer = new byte[8192];
int len;
while ((len = inputStream.read(buffer, 0, buffer.length)) > 0) {
outputStream.write(buffer, 0, len);
outputStream.flush();
}
inputStream.close();
outputStream.close();
}
}
}

@ -1,273 +0,0 @@
package com.ken.wms.common.controller;
import com.ken.wms.common.service.Interface.SupplierManageService;
import com.ken.wms.common.util.Response;
import com.ken.wms.common.util.ResponseFactory;
import com.ken.wms.domain.Supplier;
import com.ken.wms.exception.SupplierManageServiceException;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.List;
import java.util.Map;
/**
* Handler
*
* @author Ken
*/
@RequestMapping(value = "/**/supplierManage")
@Controller
public class SupplierManageHandler {
@Autowired
private SupplierManageService supplierManageService;
private static final String SEARCH_BY_ID = "searchByID";
private static final String SEARCH_BY_NAME = "searchByName";
private static final String SEARCH_ALL = "searchAll";
/**
*
*
* @param searchType
* @param keyWord
* @param offset
* @param limit
* @return
*/
private Map<String, Object> query(String searchType, String keyWord, int offset, int limit) throws SupplierManageServiceException {
Map<String, Object> queryResult = null;
switch (searchType) {
case SEARCH_BY_ID:
if (StringUtils.isNumeric(keyWord)) {
queryResult = supplierManageService.selectById(Integer.valueOf(keyWord));
}
break;
case SEARCH_BY_NAME:
queryResult = supplierManageService.selectByName(offset, limit, keyWord);
break;
case SEARCH_ALL:
queryResult = supplierManageService.selectAll(offset, limit);
break;
default:
// do other thing
break;
}
return queryResult;
}
/**
*
*
* @param searchType
* @param offset
* @param limit
* @param keyWord
* @return
*/
@RequestMapping(value = "getSupplierList", method = RequestMethod.GET)
@ResponseBody
public Map<String, Object> getSupplierList(@RequestParam("searchType") String searchType,
@RequestParam("offset") int offset, @RequestParam("limit") int limit,
@RequestParam("keyWord") String keyWord) throws SupplierManageServiceException {
// 初始化 Response
Response responseContent = ResponseFactory.newInstance();
List<Supplier> rows = null;
long total = 0;
Map<String, Object> queryResult = query(searchType, keyWord, offset, limit);
// 结果转换
if (queryResult != null) {
rows = (List<Supplier>) queryResult.get("data");
total = (long) queryResult.get("total");
}
responseContent.setCustomerInfo("rows", rows);
responseContent.setResponseTotal(total);
return responseContent.generateResponse();
}
/**
*
*
* @param supplier
* @return mapkey resultsuccess error
*/
@RequestMapping(value = "addSupplier", method = RequestMethod.POST)
public
@ResponseBody
Map<String, Object> addSupplier(@RequestBody Supplier supplier) throws SupplierManageServiceException {
// 初始化 Response
Response responseContent = ResponseFactory.newInstance();
// 添加记录
String result = supplierManageService.addSupplier(supplier) ? Response.RESPONSE_RESULT_SUCCESS : Response.RESPONSE_RESULT_ERROR;
// 设置 Response
responseContent.setResponseResult(result);
return responseContent.generateResponse();
}
/**
* supplierID
*
* @param supplierID ID
* @return mapkey result success errorkey data
*
*/
@RequestMapping(value = "getSupplierInfo", method = RequestMethod.GET)
public
@ResponseBody
Map<String, Object> getSupplierInfo(@RequestParam("supplierID") int supplierID) throws SupplierManageServiceException {
// 初始化 Response
Response responseContent = ResponseFactory.newInstance();
String result = Response.RESPONSE_RESULT_ERROR;
// 获取供应点信息
Supplier supplier = null;
Map<String, Object> queryResult = supplierManageService.selectById(supplierID);
if (queryResult != null) {
supplier = (Supplier) queryResult.get("data");
if (supplier != null)
result = Response.RESPONSE_RESULT_SUCCESS;
}
// 设置 Response
responseContent.setResponseResult(result);
responseContent.setResponseData(supplier);
return responseContent.generateResponse();
}
/**
*
*
* @param supplier
* @return mapkey resultsuccess error
*/
@RequestMapping(value = "updateSupplier", method = RequestMethod.POST)
public
@ResponseBody
Map<String, Object> updateSupplier(@RequestBody Supplier supplier) throws SupplierManageServiceException {
// 初始化 Response
Response responseContent = ResponseFactory.newInstance();
// 更新
String result = supplierManageService.updateSupplier(supplier) ? Response.RESPONSE_RESULT_SUCCESS : Response.RESPONSE_RESULT_ERROR;
// 设置 Response
responseContent.setResponseResult(result);
return responseContent.generateResponse();
}
/**
*
*
* @param supplierID ID
* @return mapkey resultsuccess error
*/
@RequestMapping(value = "deleteSupplier", method = RequestMethod.GET)
public
@ResponseBody
Map<String, Object> deleteSupplier(@RequestParam("supplierID") Integer supplierID) {
// 初始化 Response
Response responseContent = ResponseFactory.newInstance();
// 刪除
String result = supplierManageService.deleteSupplier(supplierID) ? Response.RESPONSE_RESULT_SUCCESS : Response.RESPONSE_RESULT_ERROR;
// 设置 Response
responseContent.setResponseResult(result);
return responseContent.generateResponse();
}
/**
*
*
* @param file
* @return mapkey resultsuccess
* errorkeytotalkeyavailable
*/
@RequestMapping(value = "importSupplier", method = RequestMethod.POST)
public
@ResponseBody
Map<String, Object> importSupplier(@RequestParam("file") MultipartFile file) throws SupplierManageServiceException {
// 初始化 Response
Response responseContent = ResponseFactory.newInstance();
String result = Response.RESPONSE_RESULT_SUCCESS;
// 读取文件内容
int total = 0;
int available = 0;
if (file == null)
result = Response.RESPONSE_RESULT_ERROR;
Map<String, Object> importInfo = supplierManageService.importSupplier(file);
if (importInfo != null) {
total = (int) importInfo.get("total");
available = (int) importInfo.get("available");
}
// 设置 Response
responseContent.setResponseResult(result);
responseContent.setResponseTotal(total);
responseContent.setCustomerInfo("available", available);
return responseContent.generateResponse();
}
/**
*
*
* @param searchType
* @param keyWord
* @param response HttpServletResponse
*/
@SuppressWarnings("unchecked")
@RequestMapping(value = "exportSupplier", method = RequestMethod.GET)
public void exportSupplier(@RequestParam("searchType") String searchType, @RequestParam("keyWord") String keyWord,
HttpServletResponse response) throws SupplierManageServiceException, IOException {
String fileName = "supplierInfo.xlsx";
// 根据查询类型进行查询
List<Supplier> suppliers = null;
Map<String, Object> queryResult;
queryResult = query(searchType, keyWord, -1, -1);
if (queryResult != null) {
suppliers = (List<Supplier>) queryResult.get("data");
}
// 获取生成的文件
File file = supplierManageService.exportSupplier(suppliers);
// 写出文件
if (file != null) {
// 设置响应头
response.addHeader("Content-Disposition", "attachment;filename=" + fileName);
FileInputStream inputStream = new FileInputStream(file);
OutputStream outputStream = response.getOutputStream();
byte[] buffer = new byte[8192];
int len;
while ((len = inputStream.read(buffer, 0, buffer.length)) > 0) {
outputStream.write(buffer, 0, len);
outputStream.flush();
}
inputStream.close();
outputStream.close();
}
}
}

@ -1,138 +0,0 @@
package com.ken.wms.common.controller;
import com.ken.wms.common.service.Interface.SystemLogService;
import com.ken.wms.common.util.Response;
import com.ken.wms.common.util.ResponseFactory;
import com.ken.wms.domain.AccessRecordDO;
import com.ken.wms.domain.UserOperationRecordDTO;
import com.ken.wms.exception.SystemLogServiceException;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* Handler
*
* @author Ken
* @since 2017/4/7.
*/
@Controller
@RequestMapping(value = "/systemLog")
public class SystemLogHandler {
@Autowired
private SystemLogService systemLogService;
/**
*
*
* @param userIDStr ID
* @param accessType
* @param startDateStr
* @param endDateStr
* @param offset
* @param limit
* @return JSON KeyrowsKeytotal
* @throws SystemLogServiceException SystemLogServiceException
*/
@SuppressWarnings("unchecked")
@RequestMapping(value = "getAccessRecords", method = RequestMethod.GET)
public @ResponseBody
Map<String, Object> getAccessRecords(@RequestParam("userID") String userIDStr,
@RequestParam("accessType") String accessType,
@RequestParam("startDate") String startDateStr,
@RequestParam("endDate") String endDateStr,
@RequestParam("offset") int offset,
@RequestParam("limit") int limit) throws SystemLogServiceException {
// 创建 Response 对象
Response response = ResponseFactory.newInstance();
List<AccessRecordDO> rows = null;
long total = 0;
// 检查参数
String regex = "([0-9]{4})-([0-9]{2})-([0-9]{2})";
boolean startDateFormatCheck = (StringUtils.isEmpty(startDateStr) || startDateStr.matches(regex));
boolean endDateFormatCheck = (StringUtils.isEmpty(endDateStr) || endDateStr.matches(regex));
boolean userIDCheck = (StringUtils.isEmpty(userIDStr) || StringUtils.isNumeric(userIDStr));
if (startDateFormatCheck && endDateFormatCheck && userIDCheck) {
// 转到 Service 执行查询
Integer userID = -1;
if (StringUtils.isNumeric(userIDStr))
userID = Integer.valueOf(userIDStr);
Map<String, Object> queryResult = systemLogService.selectAccessRecord(userID, accessType, startDateStr, endDateStr, offset, limit);
if (queryResult != null) {
rows = (List<AccessRecordDO>) queryResult.get("data");
total = (long) queryResult.get("total");
}
} else
response.setResponseMsg("Request Argument Error");
if (rows == null)
rows = new ArrayList<>(0);
// 返回 Response
response.setCustomerInfo("rows", rows);
response.setResponseTotal(total);
return response.generateResponse();
}
/**
*
*
* @param userIDStr ID
* @param startDateStr
* @param endDateStr
* @param offset
* @param limit
* @return JSON KeyrowsKeytotal
* @throws SystemLogServiceException SystemLogServiceException
*/
@SuppressWarnings("unchecked")
@RequestMapping(value = "getUserOperationRecords")
public @ResponseBody
Map<String, Object> selectUserOperationRecords(@RequestParam("userID") String userIDStr,
@RequestParam("startDate") String startDateStr,
@RequestParam("endDate") String endDateStr,
@RequestParam("offset") int offset,
@RequestParam("limit") int limit) throws SystemLogServiceException {
// 创建 Response
Response response = ResponseFactory.newInstance();
List<UserOperationRecordDTO> rows = null;
long total = 0;
// 检查参数
String regex = "([0-9]{4})-([0-9]{2})-([0-9]{2})";
boolean startDateFormatCheck = (StringUtils.isEmpty(startDateStr) || startDateStr.matches(regex));
boolean endDateFormatCheck = (StringUtils.isEmpty(endDateStr) || endDateStr.matches(regex));
boolean userIDCheck = (StringUtils.isEmpty(userIDStr) || StringUtils.isNumeric(userIDStr));
if (startDateFormatCheck && endDateFormatCheck && userIDCheck) {
// 转到 Service 进行查询
Integer userID = -1;
if (StringUtils.isNumeric(userIDStr))
userID = Integer.valueOf(userIDStr);
Map<String, Object> queryResult = systemLogService.selectUserOperationRecord(userID, startDateStr, endDateStr, offset, limit);
if (queryResult != null) {
rows = (List<UserOperationRecordDTO>) queryResult.get("data");
total = (long) queryResult.get("total");
}
} else
response.setResponseMsg("Request argument error");
if (rows == null)
rows = new ArrayList<>(0);
response.setCustomerInfo("rows", rows);
response.setResponseTotal(total);
return response.generateResponse();
}
}

@ -1,339 +0,0 @@
package com.ken.wms.common.service.Impl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ken.wms.common.service.Interface.CustomerManageService;
import com.ken.wms.common.util.EJConvertor;
import com.ken.wms.common.util.FileUtil;
import com.ken.wms.dao.CustomerMapper;
import com.ken.wms.dao.StockOutMapper;
import com.ken.wms.domain.Customer;
import com.ken.wms.domain.StockOutDO;
import com.ken.wms.exception.CustomerManageServiceException;
import com.ken.wms.util.aop.UserOperation;
import org.apache.ibatis.exceptions.PersistenceException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* service
*
* @author Ken
*/
@Service
public class CustomerManageServiceImpl implements CustomerManageService {
@Autowired
private CustomerMapper customerMapper;
@Autowired
private StockOutMapper stockOutMapper;
@Autowired
private EJConvertor ejConvertor;
/**
* customer id
*
* @param customerId ID
* @return Map key data key total
*/
@Override
public Map<String, Object> selectById(Integer customerId) throws CustomerManageServiceException {
// 初始化结果集
Map<String, Object> resultSet = new HashMap<>();
List<Customer> customers = new ArrayList<>();
long total = 0;
// 查询
Customer customer;
try {
customer = customerMapper.selectById(customerId);
} catch (PersistenceException e) {
System.out.println("exception catch");
e.printStackTrace();
throw new CustomerManageServiceException(e);
}
if (customer != null) {
customers.add(customer);
total = 1;
}
resultSet.put("data", customers);
resultSet.put("total", total);
return resultSet;
}
/**
* customer name
*
* @param offset
* @param limit
* @param customerName
* @return Map key data key total
*/
@Override
public Map<String, Object> selectByName(int offset, int limit, String customerName) throws CustomerManageServiceException {
// 初始化结果集
Map<String, Object> resultSet = new HashMap<>();
List<Customer> customers;
long total = 0;
boolean isPagination = true;
// validate
if (offset < 0 || limit < 0)
isPagination = false;
// query
try {
if (isPagination) {
PageHelper.offsetPage(offset, limit);
customers = customerMapper.selectApproximateByName(customerName);
if (customers != null) {
PageInfo<Customer> pageInfo = new PageInfo<>(customers);
total = pageInfo.getTotal();
} else
customers = new ArrayList<>();
} else {
customers = customerMapper.selectApproximateByName(customerName);
if (customers != null)
total = customers.size();
else
customers = new ArrayList<>();
}
} catch (PersistenceException e) {
throw new CustomerManageServiceException(e);
}
resultSet.put("data", customers);
resultSet.put("total", total);
return resultSet;
}
/**
* customer Name
*
* @param customerName
* @return Map key data key total
*/
@Override
public Map<String, Object> selectByName(String customerName) throws CustomerManageServiceException {
return selectByName(-1, -1, customerName);
}
/**
*
*
* @param offset
* @param limit
* @return Map key data key total
*/
@Override
public Map<String, Object> selectAll(int offset, int limit) throws CustomerManageServiceException {
// 初始化结果集
Map<String, Object> resultSet = new HashMap<>();
List<Customer> customers;
long total = 0;
boolean isPagination = true;
// validate
if (offset < 0 || limit < 0)
isPagination = false;
// query
try {
if (isPagination) {
PageHelper.offsetPage(offset, limit);
customers = customerMapper.selectAll();
if (customers != null) {
PageInfo<Customer> pageInfo = new PageInfo<>(customers);
total = pageInfo.getTotal();
} else
customers = new ArrayList<>();
} else {
customers = customerMapper.selectAll();
if (customers != null)
total = customers.size();
else
customers = new ArrayList<>();
}
} catch (PersistenceException e) {
throw new CustomerManageServiceException(e);
}
resultSet.put("data", customers);
resultSet.put("total", total);
return resultSet;
}
/**
*
*
* @return Map key data key total
*/
@Override
public Map<String, Object> selectAll() throws CustomerManageServiceException {
return selectAll(-1, -1);
}
/**
*
*
* @param customer
* @return
*/
private boolean customerCheck(Customer customer) {
return customer.getName() != null && customer.getPersonInCharge() != null && customer.getTel() != null
&& customer.getEmail() != null && customer.getAddress() != null;
}
/**
*
*
* @param customer
* @return booleantrue
*/
@UserOperation(value = "添加客户信息")
@Override
public boolean addCustomer(Customer customer) throws CustomerManageServiceException {
// 插入新的记录
if (customer != null) {
// 验证
if (customerCheck(customer)) {
try {
if (null == customerMapper.selectByName(customer.getName())) {
customerMapper.insert(customer);
return true;
}
} catch (PersistenceException e) {
throw new CustomerManageServiceException(e);
}
}
}
return false;
}
/**
*
*
* @param customer
* @return booleantrue
*/
@UserOperation(value = "修改客户信息")
@Override
public boolean updateCustomer(Customer customer) throws CustomerManageServiceException {
// 更新记录
if (customer != null) {
// 检验
if (customerCheck(customer)) {
try {
// 检查重名
Customer customerFromDB = customerMapper.selectByName(customer.getName());
if (customerFromDB == null || customerFromDB.getId().equals(customer.getId())) {
customerMapper.update(customer);
return true;
}
} catch (PersistenceException e) {
throw new CustomerManageServiceException(e);
}
}
}
return false;
}
/**
*
*
* @param customerId ID
* @return booleantrue
*/
@UserOperation(value = "删除客户信息")
@Override
public boolean deleteCustomer(Integer customerId) throws CustomerManageServiceException {
try {
// 查询该客户是否有出库记录
List<StockOutDO> records = stockOutMapper.selectByCustomerId(customerId);
if (records != null && records.size() > 0) {
return false;
} else {
// 删除该条客户记录
customerMapper.deleteById(customerId);
return true;
}
} catch (PersistenceException e) {
throw new CustomerManageServiceException(e);
}
}
/**
*
*
* @param file
* @return Mapkeytotalkeyavailable
*/
@UserOperation(value = "导入客户信息")
@Override
public Map<String, Object> importCustomer(MultipartFile file) throws CustomerManageServiceException {
// 初始化结果集
Map<String, Object> result = new HashMap<>();
int total = 0;
int available = 0;
// 从 Excel 文件中读取
try {
List<Customer> customers = ejConvertor.excelReader(Customer.class, FileUtil.convertMultipartFileToFile(file));
if (customers != null) {
total = customers.size();
// 验证每一条记录
List<Customer> availableList = new ArrayList<>();
for (Customer customer : customers) {
if (customerCheck(customer)) {
if (customerMapper.selectByName(customer.getName()) == null)
availableList.add(customer);
}
}
// 保存到数据库
available = availableList.size();
if (available > 0) {
customerMapper.insertBatch(availableList);
}
}
} catch (PersistenceException | IOException e) {
throw new CustomerManageServiceException(e);
}
result.put("total", total);
result.put("available", available);
return result;
}
/**
*
*
* @param customers customer List
* @return Excel
*/
@UserOperation(value = "导出客户信息")
@Override
public File exportCustomer(List<Customer> customers) {
if (customers == null)
return null;
return ejConvertor.excelWriter(Customer.class, customers);
}
}

@ -1,349 +0,0 @@
package com.ken.wms.common.service.Impl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ken.wms.common.service.Interface.GoodsManageService;
import com.ken.wms.common.util.EJConvertor;
import com.ken.wms.common.util.FileUtil;
import com.ken.wms.dao.GoodsMapper;
import com.ken.wms.dao.StockInMapper;
import com.ken.wms.dao.StockOutMapper;
import com.ken.wms.dao.StorageMapper;
import com.ken.wms.domain.Goods;
import com.ken.wms.domain.StockInDO;
import com.ken.wms.domain.StockOutDO;
import com.ken.wms.domain.Storage;
import com.ken.wms.exception.GoodsManageServiceException;
import com.ken.wms.util.aop.UserOperation;
import org.apache.ibatis.exceptions.PersistenceException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Service
*
* @author Ken
*/
@Service
public class GoodsManageServiceImpl implements GoodsManageService {
@Autowired
private GoodsMapper goodsMapper;
@Autowired
private StockInMapper stockInMapper;
@Autowired
private StockOutMapper stockOutMapper;
@Autowired
private StorageMapper storageMapper;
@Autowired
private EJConvertor ejConvertor;
/**
* goods ID
*
* @param goodsId ID
* @return Map key data key total
*/
@Override
public Map<String, Object> selectById(Integer goodsId) throws GoodsManageServiceException {
// 初始化结果集
Map<String, Object> resultSet = new HashMap<>();
List<Goods> goodsList = new ArrayList<>();
long total = 0;
// 查询
Goods goods;
try {
goods = goodsMapper.selectById(goodsId);
} catch (PersistenceException e) {
throw new GoodsManageServiceException(e);
}
if (goods != null) {
goodsList.add(goods);
total = 1;
}
resultSet.put("data", goodsList);
resultSet.put("total", total);
return resultSet;
}
/**
* goods name
*
* @param offset
* @param limit
* @param goodsName
* @return Map key data key total
*/
@Override
public Map<String, Object> selectByName(int offset, int limit, String goodsName) throws GoodsManageServiceException {
// 初始化结果集
Map<String, Object> resultSet = new HashMap<>();
List<Goods> goodsList;
long total = 0;
boolean isPagination = true;
// validate
if (offset < 0 || limit < 0)
isPagination = false;
// query
try {
if (isPagination) {
PageHelper.offsetPage(offset, limit);
goodsList = goodsMapper.selectApproximateByName(goodsName);
if (goodsList != null) {
PageInfo<Goods> pageInfo = new PageInfo<>(goodsList);
total = pageInfo.getTotal();
} else
goodsList = new ArrayList<>();
} else {
goodsList = goodsMapper.selectApproximateByName(goodsName);
if (goodsList != null)
total = goodsList.size();
else
goodsList = new ArrayList<>();
}
} catch (PersistenceException e) {
throw new GoodsManageServiceException(e);
}
resultSet.put("data", goodsList);
resultSet.put("total", total);
return resultSet;
}
/**
* goods name
*
* @param goodsName
* @return Map key data key total
*/
@Override
public Map<String, Object> selectByName(String goodsName) throws GoodsManageServiceException {
return selectByName(-1, -1, goodsName);
}
/**
*
*
* @param offset
* @param limit
* @return Map key data key total
*/
@Override
public Map<String, Object> selectAll(int offset, int limit) throws GoodsManageServiceException {
// 初始化结果集
Map<String, Object> resultSet = new HashMap<>();
List<Goods> goodsList;
long total = 0;
boolean isPagination = true;
// validate
if (offset < 0 || limit < 0)
isPagination = false;
// query
try {
if (isPagination) {
PageHelper.offsetPage(offset, limit);
goodsList = goodsMapper.selectAll();
if (goodsList != null) {
PageInfo<Goods> pageInfo = new PageInfo<>(goodsList);
total = pageInfo.getTotal();
} else
goodsList = new ArrayList<>();
} else {
goodsList = goodsMapper.selectAll();
if (goodsList != null)
total = goodsList.size();
else
goodsList = new ArrayList<>();
}
} catch (PersistenceException e) {
throw new GoodsManageServiceException(e);
}
resultSet.put("data", goodsList);
resultSet.put("total", total);
return resultSet;
}
/**
*
*
* @return Map key data key total
*/
@Override
public Map<String, Object> selectAll() throws GoodsManageServiceException {
return selectAll(-1, -1);
}
/**
*
*
* @param goods
* @return truefalse
*/
private boolean goodsCheck(Goods goods) {
if (goods != null) {
if (goods.getName() != null && goods.getValue() != null) {
return true;
}
}
return false;
}
/**
*
*
* @param goods
* @return booleantrue
*/
@UserOperation(value = "添加货物信息")
@Override
public boolean addGoods(Goods goods) throws GoodsManageServiceException {
try {
// 插入新的记录
if (goods != null) {
// 验证
if (goodsCheck(goods)) {
goodsMapper.insert(goods);
return true;
}
}
return false;
} catch (PersistenceException e) {
throw new GoodsManageServiceException(e);
}
}
/**
*
*
* @param goods
* @return booleantrue
*/
@UserOperation(value = "修改货物信息")
@Override
public boolean updateGoods(Goods goods) throws GoodsManageServiceException {
try {
// 更新记录
if (goods != null) {
// 检验
if (goodsCheck(goods)) {
goodsMapper.update(goods);
return true;
}
}
return false;
} catch (PersistenceException e) {
throw new GoodsManageServiceException(e);
}
}
/**
*
*
* @param goodsId ID
* @return booleantrue
*/
@UserOperation(value = "删除货物信息")
@Override
public boolean deleteGoods(Integer goodsId) throws GoodsManageServiceException {
try {
// 检查该货物是否有入库信息
List<StockInDO> stockInDORecord = stockInMapper.selectByGoodID(goodsId);
if (stockInDORecord != null && !stockInDORecord.isEmpty())
return false;
// 检查该货物是否有出库信息
List<StockOutDO> stockOutDORecord = stockOutMapper.selectByGoodId(goodsId);
if (stockOutDORecord != null && !stockOutDORecord.isEmpty())
return false;
// 检查该货物是否有存储信息
List<Storage> storageRecord = storageMapper.selectByGoodsIDAndRepositoryID(goodsId, null);
if (storageRecord != null && !storageRecord.isEmpty())
return false;
// 删除货物记录
goodsMapper.deleteById(goodsId);
return true;
} catch (PersistenceException e) {
throw new GoodsManageServiceException(e);
}
}
/**
*
*
* @param file
* @return Mapkeytotalkeyavailable
*/
@UserOperation(value = "导入货物信息")
@Override
public Map<String, Object> importGoods(MultipartFile file) throws GoodsManageServiceException {
// 初始化结果集
Map<String, Object> resultSet = new HashMap<>();
int total = 0;
int available = 0;
// 从 Excel 文件中读取
try {
List<Goods> goodsList = ejConvertor.excelReader(Goods.class, FileUtil.convertMultipartFileToFile(file));
if (goodsList != null) {
total = goodsList.size();
// 验证每一条记录
List<Goods> availableList = new ArrayList<>();
for (Goods goods : goodsList) {
if (goodsCheck(goods)) {
availableList.add(goods);
}
}
// 保存到数据库
available = availableList.size();
if (available > 0) {
goodsMapper.insertBatch(availableList);
}
}
} catch (PersistenceException | IOException e) {
throw new GoodsManageServiceException(e);
}
resultSet.put("total", total);
resultSet.put("available", available);
return resultSet;
}
/**
*
*
* @param goods Supplier List
* @return excel
*/
@UserOperation(value = "导出货物信息")
@Override
public File exportGoods(List<Goods> goods) {
if (goods == null)
return null;
return ejConvertor.excelWriter(Goods.class, goods);
}
}

@ -1,406 +0,0 @@
package com.ken.wms.common.service.Impl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ken.wms.common.service.Interface.RepositoryAdminManageService;
import com.ken.wms.common.util.EJConvertor;
import com.ken.wms.common.util.FileUtil;
import com.ken.wms.dao.RepositoryAdminMapper;
import com.ken.wms.domain.RepositoryAdmin;
import com.ken.wms.domain.UserInfoDTO;
import com.ken.wms.exception.RepositoryAdminManageServiceException;
import com.ken.wms.exception.UserInfoServiceException;
import com.ken.wms.security.service.Interface.UserInfoService;
import com.ken.wms.util.aop.UserOperation;
import org.apache.ibatis.exceptions.PersistenceException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import java.io.File;
import java.io.IOException;
import java.util.*;
/**
* service
*
* @author Ken
*/
@Service
public class RepositoryAdminManageServiceImpl implements RepositoryAdminManageService {
@Autowired
private RepositoryAdminMapper repositoryAdminMapper;
@Autowired
private EJConvertor ejConvertor;
@Autowired
private UserInfoService userInfoService;
/**
* repository id
*
* @param repositoryAdminID ID
* @return Map key data key total
*/
@Override
public Map<String, Object> selectByID(Integer repositoryAdminID) throws RepositoryAdminManageServiceException {
// 初始化结果集
Map<String, Object> resultSet = new HashMap<>();
List<RepositoryAdmin> repositoryAdmins = new ArrayList<>();
long total = 0;
// 查询
RepositoryAdmin repositoryAdmin;
try {
repositoryAdmin = repositoryAdminMapper.selectByID(repositoryAdminID);
} catch (PersistenceException e) {
throw new RepositoryAdminManageServiceException(e);
}
if (repositoryAdmin != null) {
repositoryAdmins.add(repositoryAdmin);
total = 1;
}
resultSet.put("data", repositoryAdmins);
resultSet.put("total", total);
return resultSet;
}
/**
* repository address
*
* @param offset
* @param limit
* @param name
* @return Map key data key total
*/
@Override
public Map<String, Object> selectByName(int offset, int limit, String name) {
// 初始化结果集
Map<String, Object> resultSet = new HashMap<>();
List<RepositoryAdmin> repositoryAdmins;
long total = 0;
boolean isPagination = true;
// validate
if (offset < 0 || limit < 0)
isPagination = false;
// query
if (isPagination) {
PageHelper.offsetPage(offset, limit);
repositoryAdmins = repositoryAdminMapper.selectByName(name);
if (repositoryAdmins != null) {
PageInfo<RepositoryAdmin> pageInfo = new PageInfo<>(repositoryAdmins);
total = pageInfo.getTotal();
} else
repositoryAdmins = new ArrayList<>();
} else {
repositoryAdmins = repositoryAdminMapper.selectByName(name);
if (repositoryAdmins != null)
total = repositoryAdmins.size();
else
repositoryAdmins = new ArrayList<>();
}
resultSet.put("data", repositoryAdmins);
resultSet.put("total", total);
return resultSet;
}
/**
* repository Name
*
* @param name
* @return Map key data key total
*/
@Override
public Map<String, Object> selectByName(String name) {
return selectByName(-1, -1, name);
}
/**
*
*
* @param offset
* @param limit
* @return Map key data key total
*/
@Override
public Map<String, Object> selectAll(int offset, int limit) throws RepositoryAdminManageServiceException {
// 初始化结果集
Map<String, Object> resultSet = new HashMap<>();
List<RepositoryAdmin> repositoryAdmins;
long total = 0;
boolean isPagination = true;
// validate
if (offset < 0 || limit < 0)
isPagination = false;
// query
try {
if (isPagination) {
PageHelper.offsetPage(offset, limit);
repositoryAdmins = repositoryAdminMapper.selectAll();
if (repositoryAdmins != null) {
PageInfo<RepositoryAdmin> pageInfo = new PageInfo<>(repositoryAdmins);
total = pageInfo.getTotal();
} else
repositoryAdmins = new ArrayList<>();
} else {
repositoryAdmins = repositoryAdminMapper.selectAll();
if (repositoryAdmins != null)
total = repositoryAdmins.size();
else
repositoryAdmins = new ArrayList<>();
}
} catch (PersistenceException e) {
throw new RepositoryAdminManageServiceException(e);
}
resultSet.put("data", repositoryAdmins);
resultSet.put("total", total);
return resultSet;
}
/**
*
*
* @return Map key data key total
*/
@Override
public Map<String, Object> selectAll() throws RepositoryAdminManageServiceException {
return selectAll(-1, -1);
}
/**
*
*
* @param repositoryAdmin
* @return booleantrue
*/
@UserOperation(value = "添加仓库管理员信息")
@Override
public boolean addRepositoryAdmin(RepositoryAdmin repositoryAdmin) throws RepositoryAdminManageServiceException {
if (repositoryAdmin != null) {
if (repositoryAdminCheck(repositoryAdmin)) {
try {
// 添加仓库管理员信息到数据库中
repositoryAdminMapper.insert(repositoryAdmin);
// 获取插入数据后返回的用户ID
Integer userID = repositoryAdmin.getId();
if (userID == null)
return false;
// 为仓库管理员创建账户
UserInfoDTO userInfo = new UserInfoDTO();
userInfo.setUserID(userID);
userInfo.setUserName(repositoryAdmin.getName());
userInfo.setPassword(repositoryAdmin.getId().toString());
userInfo.setRole(new ArrayList<>(Collections.singletonList("commonsAdmin")));
// 添加新创建的仓库管理员账户信息
return userInfoService.insertUserInfo(userInfo);
} catch (PersistenceException | UserInfoServiceException e) {
throw new RepositoryAdminManageServiceException(e, "Fail to persist repository admin info");
}
}
}
return false;
}
/**
*
*
* @param repositoryAdmin
* @return booleantrue
*/
@UserOperation(value = "修改仓库管理员信息")
@Override
public boolean updateRepositoryAdmin(RepositoryAdmin repositoryAdmin) throws RepositoryAdminManageServiceException {
if (repositoryAdmin != null) {
try {
// 检查属性
if (!repositoryAdminCheck(repositoryAdmin))
return false;
// 若有指派的仓库则检查
if (repositoryAdmin.getRepositoryBelongID() != null) {
RepositoryAdmin rAdminFromDB = repositoryAdminMapper.selectByRepositoryID(repositoryAdmin.getRepositoryBelongID());
if (rAdminFromDB != null && !Objects.equals(rAdminFromDB.getId(), repositoryAdmin.getId()))
return false;
}
// 更新
repositoryAdminMapper.update(repositoryAdmin);
return true;
} catch (PersistenceException e) {
throw new RepositoryAdminManageServiceException(e);
}
} else
return false;
}
/**
*
*
* @param repositoryAdminID ID
* @return booleantrue
*/
@UserOperation(value = "删除仓库管理员信息")
@Override
public boolean deleteRepositoryAdmin(Integer repositoryAdminID) throws RepositoryAdminManageServiceException {
try {
// 判断是否已指派仓库
RepositoryAdmin repositoryAdmin = repositoryAdminMapper.selectByID(repositoryAdminID);
if (repositoryAdmin != null && repositoryAdmin.getRepositoryBelongID() == null) {
// 删除仓库管理员信息
repositoryAdminMapper.deleteByID(repositoryAdminID);
// 删除账户信息
userInfoService.deleteUserInfo(repositoryAdminID);
return true;
} else
return false;
} catch (PersistenceException | UserInfoServiceException e) {
throw new RepositoryAdminManageServiceException(e);
}
}
/**
* ID
*
* @param repositoryAdminID ID
* @param repositoryID ID
* @return boolean true
*/
@UserOperation(value = "指派仓库管理员")
@Override
public boolean assignRepository(Integer repositoryAdminID, Integer repositoryID) throws RepositoryAdminManageServiceException {
try {
RepositoryAdmin repositoryAdmin = repositoryAdminMapper.selectByID(repositoryAdminID);
if (repositoryAdmin != null) {
repositoryAdmin.setRepositoryBelongID(repositoryID);
return updateRepositoryAdmin(repositoryAdmin);
} else
return false;
} catch (PersistenceException e) {
throw new RepositoryAdminManageServiceException(e);
}
}
/**
*
*
* @param file
* @return Mapkeytotalkeyavailable
*/
@UserOperation(value = "导入仓库管理员信息")
@Override
public Map<String, Object> importRepositoryAdmin(MultipartFile file) throws RepositoryAdminManageServiceException {
// 初始化结果集
Map<String, Object> resultSet = new HashMap<>();
long total = 0;
long available = 0;
// 从文件中读取
try {
List<RepositoryAdmin> repositoryAdmins = ejConvertor.excelReader(RepositoryAdmin.class, FileUtil.convertMultipartFileToFile(file));
if (repositoryAdmins != null) {
total = repositoryAdmins.size();
// 验证记录
List<RepositoryAdmin> availableList = new ArrayList<>();
for (RepositoryAdmin repositoryAdmin : repositoryAdmins) {
if (repositoryAdminCheck(repositoryAdmin))
availableList.add(repositoryAdmin);
}
// 保存到数据库
available = availableList.size();
if (available > 0)
repositoryAdminMapper.insertBatch(availableList);
}
} catch (PersistenceException | IOException e) {
throw new RepositoryAdminManageServiceException(e);
}
resultSet.put("total", total);
resultSet.put("available", available);
return resultSet;
}
/**
*
*
* @param repositoryAdmins repository List
* @return Excel
*/
@UserOperation(value = "导出仓库管理员信息")
@Override
public File exportRepositoryAdmin(List<RepositoryAdmin> repositoryAdmins) {
File file = null;
if (repositoryAdmins != null) {
file = ejConvertor.excelWriter(RepositoryAdmin.class, repositoryAdmins);
}
return file;
}
/**
* repositoryAdmin
*
* @param repositoryAdmin
* @return boolean true false
*/
private boolean repositoryAdminCheck(RepositoryAdmin repositoryAdmin) {
return repositoryAdmin.getName() != null && repositoryAdmin.getSex() != null && repositoryAdmin.getTel() != null
&& repositoryAdmin.getBirth() != null && repositoryAdmin.getBirth() != null;
}
/**
* repositoryID
*
* @param repositoryID ID key data key total
* @return Map
*/
@Override
public Map<String, Object> selectByRepositoryID(Integer repositoryID) throws RepositoryAdminManageServiceException {
// 初始化结果集
Map<String, Object> resultSet = new HashMap<>();
List<RepositoryAdmin> repositoryAdmins = new ArrayList<>();
long total = 0;
// 查询
RepositoryAdmin repositoryAdmin;
try {
repositoryAdmin = repositoryAdminMapper.selectByRepositoryID(repositoryID);
} catch (PersistenceException e) {
throw new RepositoryAdminManageServiceException(e);
}
if (repositoryAdmin != null) {
repositoryAdmins.add(repositoryAdmin);
total = 1;
}
resultSet.put("data", repositoryAdmins);
resultSet.put("total", total);
return resultSet;
}
}

@ -1,378 +0,0 @@
package com.ken.wms.common.service.Impl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ken.wms.common.service.Interface.RepositoryService;
import com.ken.wms.common.util.EJConvertor;
import com.ken.wms.common.util.FileUtil;
import com.ken.wms.dao.*;
import com.ken.wms.domain.*;
import com.ken.wms.exception.RepositoryManageServiceException;
import com.ken.wms.util.aop.UserOperation;
import org.apache.ibatis.exceptions.PersistenceException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* service
*
* @author Ken
*/
@Service
public class RepositoryManageServiceImpl implements RepositoryService {
@Autowired
private RepositoryMapper repositoryMapper;
@Autowired
private EJConvertor ejConvertor;
@Autowired
private StockInMapper stockInMapper;
@Autowired
private StockOutMapper stockOutMapper;
@Autowired
private StorageMapper storageMapper;
@Autowired
private RepositoryAdminMapper repositoryAdminMapper;
/**
* repository ID
*
* @param repositoryId ID
* @return Map key data key total
*/
@Override
public Map<String, Object> selectById(Integer repositoryId) throws RepositoryManageServiceException {
// 初始化結果集
Map<String, Object> resultSet = new HashMap<>();
List<Repository> repositories = new ArrayList<>();
long total = 0;
// 查詢
Repository repository;
try {
repository = repositoryMapper.selectByID(repositoryId);
} catch (PersistenceException e) {
throw new RepositoryManageServiceException(e);
}
if (repository != null) {
repositories.add(repository);
total = 1;
}
resultSet.put("data", repositories);
resultSet.put("total", total);
return resultSet;
}
/**
* repository address
*
* @param offset
* @param limit
* @param address
* @return Map key data key total
*/
@Override
public Map<String, Object> selectByAddress(int offset, int limit, String address) throws RepositoryManageServiceException {
// 初始化結果集
Map<String, Object> resultSet = new HashMap<>();
List<Repository> repositories;
long total = 0;
boolean isPagination = true;
// validate
if (offset < 0 || limit < 0)
isPagination = false;
// query
try {
if (isPagination) {
PageHelper.offsetPage(offset, limit);
repositories = repositoryMapper.selectByAddress(address);
if (repositories != null) {
PageInfo<Repository> pageInfo = new PageInfo<>(repositories);
total = pageInfo.getTotal();
} else
repositories = new ArrayList<>();
} else {
repositories = repositoryMapper.selectByAddress(address);
if (repositories != null)
total = repositories.size();
else
repositories = new ArrayList<>();
}
} catch (PersistenceException e) {
throw new RepositoryManageServiceException(e);
}
resultSet.put("data", repositories);
resultSet.put("total", total);
return resultSet;
}
/**
* repository address
*
* @param address
* @return Map key data key total
*/
@Override
public Map<String, Object> selectByAddress(String address) throws RepositoryManageServiceException {
return selectByAddress(-1, -1, address);
}
/**
*
*
* @param offset
* @param limit
* @return Map key data key total
*/
@Override
public Map<String, Object> selectAll(int offset, int limit) throws RepositoryManageServiceException {
// 初始化结果集
Map<String, Object> resultSet = new HashMap<>();
List<Repository> repositories;
long total = 0;
boolean isPagination = true;
// validate
if (offset < 0 || limit < 0)
isPagination = false;
//query
try {
if (isPagination) {
PageHelper.offsetPage(offset, limit);
repositories = repositoryMapper.selectAll();
if (repositories != null) {
PageInfo<Repository> pageInfo = new PageInfo<>(repositories);
total = pageInfo.getTotal();
} else
repositories = new ArrayList<>();
} else {
repositories = repositoryMapper.selectAll();
if (repositories != null)
total = repositories.size();
else
repositories = new ArrayList<>();
}
} catch (PersistenceException e) {
throw new RepositoryManageServiceException(e);
}
resultSet.put("data", repositories);
resultSet.put("total", total);
return resultSet;
}
/**
*
*
* @return Map key data key total
*/
@Override
public Map<String, Object> selectAll() throws RepositoryManageServiceException {
return selectAll(-1, -1);
}
/**
*
*
* @param repository
* @return truefalse
*/
private boolean repositoryCheck(Repository repository) {
return repository.getAddress() != null && repository.getStatus() != null && repository.getArea() != null;
}
/**
*
*
* @param repository
* @return booleantrue
*/
@UserOperation(value = "添加仓库信息")
@Override
public boolean addRepository(Repository repository) throws RepositoryManageServiceException {
// 插入一条新的记录
if (repository != null) {
try {
// 有效性验证
if (repositoryCheck(repository))
repositoryMapper.insert(repository);
if (repository.getId() != null) {
return true;
}
} catch (PersistenceException e) {
throw new RepositoryManageServiceException(e);
}
}
return false;
}
/**
*
*
* @param repository
* @return booleantrue
*/
@UserOperation(value = "修改仓库信息")
@Override
public boolean updateRepository(Repository repository) throws RepositoryManageServiceException {
// 更新仓库记录
if (repository != null) {
// 有效性验证
try {
if (repositoryCheck(repository)) {
if (repository.getId() != null) {
repositoryMapper.update(repository);
return true;
}
}
} catch (PersistenceException e) {
throw new RepositoryManageServiceException(e);
}
}
return false;
}
/**
*
*
* @param repositoryId ID
* @return booleantrue
*/
@UserOperation(value = "删除仓库信息")
@Override
public boolean deleteRepository(Integer repositoryId) throws RepositoryManageServiceException {
try {
// 检查是否存在出库记录
List<StockOutDO> stockOutDOList = stockOutMapper.selectByRepositoryID(repositoryId);
if (stockOutDOList != null && !stockOutDOList.isEmpty())
return false;
// 检查是否存在入库记录
List<StockInDO> stockInDOList = stockInMapper.selectByRepositoryID(repositoryId);
if (stockInDOList != null && !stockInDOList.isEmpty())
return false;
// 检查是否存在库存记录
List<Storage> storageRecords = storageMapper.selectAllAndRepositoryID(repositoryId);
if (storageRecords != null && !storageRecords.isEmpty())
return false;
// 检查是否已指派仓库管理员
RepositoryAdmin repositoryAdmin = repositoryAdminMapper.selectByRepositoryID(repositoryId);
if (repositoryAdmin != null)
return false;
// 删除记录
repositoryMapper.deleteByID(repositoryId);
return true;
} catch (PersistenceException e) {
throw new RepositoryManageServiceException(e);
}
}
/**
*
*
* @param file
* @return Mapkeytotalkeyavailable
*/
@UserOperation(value = "导入仓库信息")
@Override
public Map<String, Object> importRepository(MultipartFile file) throws RepositoryManageServiceException {
// 初始化结果集
Map<String, Object> resultSet = new HashMap<>();
int total = 0;
int available = 0;
// 从文件中读取
try {
List<Repository> repositories = ejConvertor.excelReader(Repository.class, FileUtil.convertMultipartFileToFile(file));
if (repositories != null) {
total = repositories.size();
// 验证每一条记录
List<Repository> availableList = new ArrayList<>();
for (Repository repository : repositories) {
if (repository.getAddress() != null && repository.getStatus() != null && repository.getArea() != null)
availableList.add(repository);
}
// 保存到数据库
available = availableList.size();
if (available > 0)
repositoryMapper.insertbatch(availableList);
}
} catch (PersistenceException | IOException e) {
throw new RepositoryManageServiceException(e);
}
resultSet.put("total", total);
resultSet.put("available", available);
return resultSet;
}
/**
*
*
* @param repositories Supplier List
* @return excel
*/
@UserOperation(value = "导出仓库信息")
@Override
public File exportRepository(List<Repository> repositories) {
if (repositories == null)
return null;
// 导出为文件
return ejConvertor.excelWriter(Repository.class, repositories);
}
/**
*
*
* @return Map key data key total
*/
@Override
public Map<String, Object> selectUnassign() throws RepositoryManageServiceException {
// 初始化结果集
Map<String, Object> resultSet = new HashMap<>();
List<Repository> repositories;
long total = 0;
// 查询
try {
repositories = repositoryMapper.selectUnassign();
} catch (PersistenceException e) {
throw new RepositoryManageServiceException(e);
}
if (repositories != null)
total = repositories.size();
else
repositories = new ArrayList<>();
resultSet.put("data", repositories);
resultSet.put("total", total);
return resultSet;
}
}

@ -1,443 +0,0 @@
package com.ken.wms.common.service.Impl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ken.wms.common.service.Interface.StockRecordManageService;
import com.ken.wms.common.service.Interface.StorageManageService;
import com.ken.wms.dao.*;
import com.ken.wms.domain.*;
import com.ken.wms.exception.StockRecordManageServiceException;
import com.ken.wms.exception.StorageManageServiceException;
import com.ken.wms.util.aop.UserOperation;
import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.exceptions.PersistenceException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
@Service
public class StockRecordManageServiceImpl implements StockRecordManageService {
@Autowired
private SupplierMapper supplierMapper;
@Autowired
private CustomerMapper customerMapper;
@Autowired
private GoodsMapper goodsMapper;
@Autowired
private RepositoryMapper repositoryMapper;
@Autowired
private StorageManageService storageManageService;
@Autowired
private StockInMapper stockinMapper;
@Autowired
private StockOutMapper stockOutMapper;
/**
*
*
* @param supplierID ID
* @param goodsID ID
* @param repositoryID ID
* @param number
* @return boolean true
*/
@UserOperation(value = "货物入库")
@Override
public boolean stockInOperation(Integer supplierID, Integer goodsID, Integer repositoryID, long number, String personInCharge) throws StockRecordManageServiceException {
// ID对应的记录是否存在
if (!(supplierValidate(supplierID) && goodsValidate(goodsID) && repositoryValidate(repositoryID)))
return false;
if (personInCharge == null)
return false;
// 检查入库数量有效性
if (number < 0)
return false;
try {
// 更新库存记录
boolean isSuccess;
isSuccess = storageManageService.storageIncrease(goodsID, repositoryID, number);
// 保存入库记录
if (isSuccess) {
StockInDO stockInDO = new StockInDO();
stockInDO.setGoodID(goodsID);
stockInDO.setSupplierID(supplierID);
stockInDO.setNumber(number);
stockInDO.setPersonInCharge(personInCharge);
stockInDO.setTime(new Date());
stockInDO.setRepositoryID(repositoryID);
stockinMapper.insert(stockInDO);
}
return isSuccess;
} catch (PersistenceException | StorageManageServiceException e) {
throw new StockRecordManageServiceException(e);
}
}
/**
*
*
* @param customerID ID
* @param goodsID ID
* @param repositoryID ID
* @param number
* @return booleantrue
*/
@UserOperation(value = "货物出库")
@Override
public boolean stockOutOperation(Integer customerID, Integer goodsID, Integer repositoryID, long number, String personInCharge) throws StockRecordManageServiceException {
// 检查ID对应的记录是否存在
if (!(customerValidate(customerID) && goodsValidate(goodsID) && repositoryValidate(repositoryID)))
return false;
// 检查出库数量范围是否有效
if (number < 0)
return false;
try {
// 更新库存信息
boolean isSuccess;
isSuccess = storageManageService.storageDecrease(goodsID, repositoryID, number);
// 保存出库记录
if (isSuccess) {
StockOutDO stockOutDO = new StockOutDO();
stockOutDO.setCustomerID(customerID);
stockOutDO.setGoodID(goodsID);
stockOutDO.setNumber(number);
stockOutDO.setPersonInCharge(personInCharge);
stockOutDO.setRepositoryID(repositoryID);
stockOutDO.setTime(new Date());
stockOutMapper.insert(stockOutDO);
}
return isSuccess;
} catch (PersistenceException | StorageManageServiceException e) {
throw new StockRecordManageServiceException(e);
}
}
/**
*
*
* @param repositoryID ID
* @param endDateStr
* @param startDateStr
* @param searchType
* @return Map key data key total
*/
@Override
public Map<String, Object> selectStockRecord(Integer repositoryID, String startDateStr, String endDateStr, String searchType) throws StockRecordManageServiceException {
return selectStockRecord(repositoryID, startDateStr, endDateStr, searchType, -1, -1);
}
/**
*
*
* @param repositoryID ID
* @param endDateStr
* @param startDateStr
* @param searchType
* @param offset
* @param limit
* @return Map key data key total
*/
@SuppressWarnings("unchecked")
@Override
public Map<String, Object> selectStockRecord(Integer repositoryID, String startDateStr, String endDateStr, String searchType, int offset, int limit) throws StockRecordManageServiceException {
// 初始化结果集
Map<String, Object> resultSet = new HashMap<>();
long total = 0;
// 检查传入参数
if (repositoryID == null || searchType == null)
throw new StockRecordManageServiceException("exception");
// 转换 Date 对象
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
Date startDate = null;
Date endDate = null;
try {
if (StringUtils.isNotEmpty(startDateStr))
startDate = dateFormat.parse(startDateStr);
if (StringUtils.isNotEmpty(endDateStr))
endDate = dateFormat.parse(endDateStr);
} catch (ParseException e) {
throw new StockRecordManageServiceException(e);
}
// 根据查询模式执行查询
List<StockRecordDTO> stockRecordDTOS = new ArrayList<>();
Map<String, Object> stockInTemp;
Map<String, Object> stockOutTemp;
List<StockInDO> stockInRecordDOS = null;
List<StockOutDO> stockOutRecordDOS = null;
switch (searchType) {
case "all": {
if (offset < 0 || limit < 0) {
stockInTemp = selectStockInRecord(repositoryID, startDate, endDate, offset, limit);
stockOutTemp = selectStockOutRecord(repositoryID, startDate, endDate, offset, limit);
stockInRecordDOS = (List<StockInDO>) stockInTemp.get("data");
stockOutRecordDOS = (List<StockOutDO>) stockOutTemp.get("data");
} else {
int stockInRecordOffset = offset / 2;
int stockOutRecordOffset = stockInRecordOffset * 2 < offset ? stockInRecordOffset + 1 : stockInRecordOffset;
int stockInRecordLimit = limit / 2;
int stockOutRecordLimit = stockInRecordLimit * 2 < limit ? stockInRecordLimit + 1 : stockInRecordLimit;
stockInTemp = selectStockInRecord(repositoryID, startDate, endDate, stockInRecordOffset, limit);
stockOutTemp = selectStockOutRecord(repositoryID, startDate, endDate, stockOutRecordOffset, limit);
stockInRecordDOS = (List<StockInDO>) stockInTemp.get("data");
stockOutRecordDOS = (List<StockOutDO>) stockOutTemp.get("data");
int stockInRecordDosSize = stockInRecordDOS.size();
int stockOutRecordDoSize = stockOutRecordDOS.size();
if (stockInRecordDosSize >= stockInRecordLimit && stockOutRecordDoSize >= stockOutRecordLimit) {
stockInRecordDOS = stockInRecordDOS.subList(0, stockInRecordLimit);
stockOutRecordDOS = stockOutRecordDOS.subList(0, stockOutRecordLimit);
} else if (stockInRecordDosSize < stockInRecordLimit && stockOutRecordDoSize > stockOutRecordLimit) {
int appendSize = (stockOutRecordDoSize - stockOutRecordLimit) > (stockInRecordLimit - stockInRecordDosSize) ?
(stockInRecordLimit - stockInRecordDosSize) : (stockOutRecordDoSize - stockOutRecordLimit);
stockOutRecordDOS = stockOutRecordDOS.subList(0, stockInRecordLimit + appendSize - 1);
} else if (stockOutRecordDoSize < stockOutRecordLimit && stockInRecordDosSize > stockInRecordLimit) {
int appendSize = (stockInRecordDosSize - stockInRecordLimit) > (stockOutRecordLimit - stockOutRecordDoSize) ?
(stockOutRecordLimit - stockOutRecordDoSize) : (stockInRecordDosSize - stockInRecordLimit);
stockInRecordDOS = stockInRecordDOS.subList(0, stockInRecordLimit + appendSize);
}
}
long stockInRecordDOSTotal = (long) stockInTemp.get("total");
long stockOutRecordDOSTotal = (long) stockOutTemp.get("total");
total = stockInRecordDOSTotal + stockOutRecordDOSTotal;
break;
}
case "stockInOnly": {
stockInTemp = selectStockInRecord(repositoryID, startDate, endDate, offset, limit);
total = (long) stockInTemp.get("total");
stockInRecordDOS = (List<StockInDO>) stockInTemp.get("data");
break;
}
case "stockOutOnly": {
stockOutTemp = selectStockOutRecord(repositoryID, startDate, endDate, offset, limit);
total = (long) stockOutTemp.get("total");
stockOutRecordDOS = (List<StockOutDO>) stockOutTemp.get("data");
break;
}
case "none": {
break;
}
}
if (stockInRecordDOS != null)
stockInRecordDOS.forEach(stockInDO -> stockRecordDTOS.add(stockInRecordConvertToStockRecordDTO(stockInDO)));
if (stockOutRecordDOS != null)
stockOutRecordDOS.forEach(stockOutDO -> stockRecordDTOS.add(stockOutDoConvertToStockRecordDTO(stockOutDO)));
resultSet.put("data", stockRecordDTOS);
resultSet.put("total", total);
return resultSet;
}
/**
*
*
* @param repositoryID ID
* @param startDate
* @param endDate
* @param offset
* @param limit
* @return
*/
private Map<String, Object> selectStockInRecord(Integer repositoryID, Date startDate, Date endDate, int offset, int limit) throws StockRecordManageServiceException {
Map<String, Object> result = new HashMap<>();
List<StockInDO> stockInRecords;
long stockInTotal = 0;
boolean isPagination = true;
// 检查是否需要分页查询
if (offset < 0 || limit < 0)
isPagination = false;
// 查询记录
try {
if (isPagination) {
PageHelper.offsetPage(offset, limit);
stockInRecords = stockinMapper.selectByRepositoryIDAndDate(repositoryID, startDate, endDate);
if (stockInRecords != null)
stockInTotal = new PageInfo<>(stockInRecords).getTotal();
else
stockInRecords = new ArrayList<>(10);
} else {
stockInRecords = stockinMapper.selectByRepositoryIDAndDate(repositoryID, startDate, endDate);
if (stockInRecords != null)
stockInTotal = stockInRecords.size();
else
stockInRecords = new ArrayList<>(10);
}
} catch (PersistenceException e) {
throw new StockRecordManageServiceException(e);
}
result.put("data", stockInRecords);
result.put("total", stockInTotal);
return result;
}
/**
*
*
* @param repositoryID ID
* @param startDate
* @param endDate
* @param offset
* @param limit
* @return
*/
private Map<String, Object> selectStockOutRecord(Integer repositoryID, Date startDate, Date endDate, int offset, int limit) throws StockRecordManageServiceException {
Map<String, Object> result = new HashMap<>();
List<StockOutDO> stockOutRecords;
long stockOutRecordTotal = 0;
boolean isPagination = true;
// 检查是否需要分页
if (offset < 0 || limit < 0)
isPagination = false;
// 查询记录
try {
if (isPagination) {
PageHelper.offsetPage(offset, limit);
stockOutRecords = stockOutMapper.selectByRepositoryIDAndDate(repositoryID, startDate, endDate);
if (stockOutRecords != null)
stockOutRecordTotal = new PageInfo<>(stockOutRecords).getTotal();
else
stockOutRecords = new ArrayList<>(10);
} else {
stockOutRecords = stockOutMapper.selectByRepositoryIDAndDate(repositoryID, startDate, endDate);
if (stockOutRecords != null)
stockOutRecordTotal = stockOutRecords.size();
else
stockOutRecords = new ArrayList<>(10);
}
} catch (PersistenceException e) {
throw new StockRecordManageServiceException(e);
}
result.put("data", stockOutRecords);
result.put("total", stockOutRecordTotal);
return result;
}
private DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd-hh-mm");
/**
* StockInDO StockRecordDTO
*
* @param stockInDO StockInDO
* @return StockRecordDTO
*/
private StockRecordDTO stockInRecordConvertToStockRecordDTO(StockInDO stockInDO) {
StockRecordDTO stockRecordDTO = new StockRecordDTO();
stockRecordDTO.setRecordID(stockInDO.getId());
stockRecordDTO.setSupplierOrCustomerName(stockInDO.getSupplierName());
stockRecordDTO.setGoodsName(stockInDO.getGoodName());
stockRecordDTO.setNumber(stockInDO.getNumber());
stockRecordDTO.setTime(dateFormat.format(stockInDO.getTime()));
stockRecordDTO.setRepositoryID(stockInDO.getRepositoryID());
stockRecordDTO.setPersonInCharge(stockInDO.getPersonInCharge());
stockRecordDTO.setType("入库");
return stockRecordDTO;
}
/**
* StockOutDO StockRecordDTO
*
* @param stockOutDO StockOutDO
* @return StockRecordDTO
*/
private StockRecordDTO stockOutDoConvertToStockRecordDTO(StockOutDO stockOutDO) {
StockRecordDTO stockRecordDTO = new StockRecordDTO();
stockRecordDTO.setRecordID(stockOutDO.getId());
stockRecordDTO.setSupplierOrCustomerName(stockOutDO.getCustomerName());
stockRecordDTO.setGoodsName(stockOutDO.getGoodName());
stockRecordDTO.setNumber(stockOutDO.getNumber());
stockRecordDTO.setTime(dateFormat.format(stockOutDO.getTime()));
stockRecordDTO.setRepositoryID(stockOutDO.getRepositoryID());
stockRecordDTO.setPersonInCharge(stockOutDO.getPersonInCharge());
stockRecordDTO.setType("出库");
return stockRecordDTO;
}
/**
* ID
*
* @param goodsID ID
* @return truefalse
*/
private boolean goodsValidate(Integer goodsID) throws StockRecordManageServiceException {
try {
Goods goods = goodsMapper.selectById(goodsID);
return goods != null;
} catch (PersistenceException e) {
throw new StockRecordManageServiceException(e);
}
}
/**
* ID
*
* @param repositoryID ID
* @return truefalse
*/
private boolean repositoryValidate(Integer repositoryID) throws StockRecordManageServiceException {
try {
Repository repository = repositoryMapper.selectByID(repositoryID);
return repository != null;
} catch (PersistenceException e) {
throw new StockRecordManageServiceException(e);
}
}
/**
* ID
*
* @param supplierID ID
* @return truefalse
*/
private boolean supplierValidate(Integer supplierID) throws StockRecordManageServiceException {
try {
Supplier supplier = supplierMapper.selectById(supplierID);
return supplier != null;
} catch (PersistenceException e) {
throw new StockRecordManageServiceException(e);
}
}
/**
* ID
*
* @param cumtomerID ID
* @return truefalse
*/
private boolean customerValidate(Integer cumtomerID) throws StockRecordManageServiceException {
try {
Customer customer = customerMapper.selectById(cumtomerID);
return customer != null;
} catch (PersistenceException e) {
throw new StockRecordManageServiceException(e);
}
}
}

@ -1,515 +0,0 @@
package com.ken.wms.common.service.Impl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ken.wms.common.service.Interface.StorageManageService;
import com.ken.wms.common.util.EJConvertor;
import com.ken.wms.common.util.FileUtil;
import com.ken.wms.dao.GoodsMapper;
import com.ken.wms.dao.RepositoryMapper;
import com.ken.wms.dao.StorageMapper;
import com.ken.wms.domain.Goods;
import com.ken.wms.domain.Repository;
import com.ken.wms.domain.Storage;
import com.ken.wms.exception.StorageManageServiceException;
import com.ken.wms.util.aop.UserOperation;
import org.apache.ibatis.exceptions.PersistenceException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* service
*
* @author Ken
*/
@Service
public class StorageManageServiceImpl implements StorageManageService {
@Autowired
private StorageMapper storageMapper;
@Autowired
private GoodsMapper goodsMapper;
@Autowired
private RepositoryMapper repositoryMapper;
@Autowired
private EJConvertor ejConvertor;
/**
*
*
* @return Map key data key total
*/
@Override
public Map<String, Object> selectAll(Integer repository) throws StorageManageServiceException {
return selectAll(repository, -1, -1);
}
/**
*
*
* @param offset
* @param limit
* @return Map key data key total
*/
@Override
public Map<String, Object> selectAll(Integer repositoryID, int offset, int limit) throws StorageManageServiceException {
// 初始化结果集
Map<String, Object> resultSet = new HashMap<>();
List<Storage> storageList;
long total = 0;
boolean isPagination = true;
// validate
if (offset < 0 || limit < 0)
isPagination = false;
// query
try {
if (isPagination) {
PageHelper.offsetPage(offset, limit);
storageList = storageMapper.selectAllAndRepositoryID(repositoryID);
if (storageList != null) {
PageInfo<Storage> pageInfo = new PageInfo<>(storageList);
total = pageInfo.getTotal();
} else
storageList = new ArrayList<>();
} else {
storageList = storageMapper.selectAllAndRepositoryID(repositoryID);
if (storageList != null)
total = storageList.size();
else
storageList = new ArrayList<>();
}
} catch (PersistenceException e) {
throw new StorageManageServiceException(e);
}
resultSet.put("data", storageList);
resultSet.put("total", total);
return resultSet;
}
/**
* ID
*
* @param goodsID ID
* @return Map key data key total
*/
@Override
public Map<String, Object> selectByGoodsID(Integer goodsID, Integer repository) throws StorageManageServiceException {
return selectByGoodsID(goodsID, repository, -1, -1);
}
/**
*
*
* @param goodsID ID
* @param offset
* @param limit
* @return Map key data key total
*/
@Override
public Map<String, Object> selectByGoodsID(Integer goodsID, Integer repositoryID, int offset, int limit) throws StorageManageServiceException {
// 初始化结果集
Map<String, Object> resultSet = new HashMap<>();
List<Storage> storageList;
long total = 0;
boolean isPagination = true;
// validate
if (offset < 0 || limit < 0)
isPagination = false;
// query
try {
if (isPagination) {
PageHelper.offsetPage(offset, limit);
storageList = storageMapper.selectByGoodsIDAndRepositoryID(goodsID, repositoryID);
if (storageList != null) {
PageInfo<Storage> pageInfo = new PageInfo<>(storageList);
total = pageInfo.getTotal();
} else
storageList = new ArrayList<>();
} else {
storageList = storageMapper.selectByGoodsIDAndRepositoryID(goodsID, repositoryID);
if (storageList != null)
total = storageList.size();
else
storageList = new ArrayList<>();
}
} catch (PersistenceException e) {
throw new StorageManageServiceException(e);
}
resultSet.put("data", storageList);
resultSet.put("total", total);
return resultSet;
}
/**
*
*
* @param goodsName
* @return Map key data key total
*/
@Override
public Map<String, Object> selectByGoodsName(String goodsName, Integer repository) throws StorageManageServiceException {
return selectByGoodsName(goodsName, repository, -1, -1);
}
/**
*
*
* @param goodsName
* @param offset
* @param limit
* @return Map key data key total
*/
@Override
public Map<String, Object> selectByGoodsName(String goodsName, Integer repositoryID, int offset, int limit) throws StorageManageServiceException {
// 初始化结果集
Map<String, Object> resultSet = new HashMap<>();
List<Storage> storageList;
long total = 0;
boolean isPagination = true;
// validate
if (offset < 0 || limit < 0)
isPagination = false;
// query
try {
if (isPagination) {
PageHelper.offsetPage(offset, limit);
storageList = storageMapper.selectByGoodsNameAndRepositoryID(goodsName, repositoryID);
if (storageList != null) {
PageInfo<Storage> pageInfo = new PageInfo<>(storageList);
total = pageInfo.getTotal();
} else
storageList = new ArrayList<>();
} else {
storageList = storageMapper.selectByGoodsNameAndRepositoryID(goodsName, repositoryID);
if (storageList != null)
total = storageList.size();
else
storageList = new ArrayList<>();
}
} catch (PersistenceException e) {
throw new StorageManageServiceException(e);
}
resultSet.put("data", storageList);
resultSet.put("total", total);
return resultSet;
}
/**
*
*
* @param goodsType
* @return Map key data key total
*/
@Override
public Map<String, Object> selectByGoodsType(String goodsType, Integer repositoryID) throws StorageManageServiceException {
return selectByGoodsType(goodsType, repositoryID, -1, -1);
}
/**
*
*
* @param goodsType
* @param offset
* @param limit
* @return Map key data key total
*/
@Override
public Map<String, Object> selectByGoodsType(String goodsType, Integer repositoryID, int offset, int limit) throws StorageManageServiceException {
// 初始化结果集
Map<String, Object> resultSet = new HashMap<>();
List<Storage> storageList;
long total = 0;
boolean isPaginatin = true;
// validate
if (offset < 0 || limit < 0)
isPaginatin = false;
// query
try {
if (isPaginatin) {
PageHelper.offsetPage(offset, limit);
storageList = storageMapper.selectByGoodsTypeAndRepositoryID(goodsType, repositoryID);
if (storageList != null) {
PageInfo<Storage> pageInfo = new PageInfo<>(storageList);
total = pageInfo.getTotal();
} else
storageList = new ArrayList<>();
} else {
storageList = storageMapper.selectByGoodsTypeAndRepositoryID(goodsType, repositoryID);
if (storageList != null)
total = storageList.size();
else
storageList = new ArrayList<>();
}
} catch (PersistenceException e) {
throw new StorageManageServiceException(e);
}
resultSet.put("data", storageList);
resultSet.put("total", total);
return resultSet;
}
/**
*
*
* @param goodsID ID
* @param repositoryID ID
* @param number
* @return booleantrue
*/
@UserOperation(value = "添加库存记录")
@Override
public boolean addNewStorage(Integer goodsID, Integer repositoryID, long number) throws StorageManageServiceException {
try {
boolean isAvailable = true;
// validate
Goods goods = goodsMapper.selectById(goodsID);
Repository repository = repositoryMapper.selectByID(repositoryID);
if (goods == null)
isAvailable = false;
if (repository == null)
isAvailable = false;
if (number < 0)
isAvailable = false;
List<Storage> storageList = storageMapper.selectByGoodsIDAndRepositoryID(goodsID, repositoryID);
if (!(storageList != null && storageList.isEmpty()))
isAvailable = false;
if (isAvailable) {
// insert
Storage storage = new Storage();
storage.setGoodsID(goodsID);
storage.setRepositoryID(repositoryID);
storage.setNumber(number);
storageMapper.insert(storage);
}
return isAvailable;
} catch (PersistenceException e) {
throw new StorageManageServiceException(e);
}
}
/**
*
*
* @param goodsID ID
* @param repositoryID ID
* @param number
* @return booleantrue
*/
@UserOperation(value = "修改库存记录")
@Override
public boolean updateStorage(Integer goodsID, Integer repositoryID, long number) throws StorageManageServiceException {
try {
boolean isUpdate = false;
// validate
List<Storage> storageList = storageMapper.selectByGoodsIDAndRepositoryID(goodsID, repositoryID);
if (storageList != null && !storageList.isEmpty()) {
if (number >= 0) {
// update
Storage storage = storageList.get(0);
storage.setNumber(number);
storageMapper.update(storage);
isUpdate = true;
}
}
return isUpdate;
} catch (PersistenceException e) {
throw new StorageManageServiceException(e);
}
}
/**
*
* IDID
*
* @param goodsID ID
* @param repositoryID ID
* @return booleantrue
*/
@UserOperation(value = "删除库存记录")
@Override
public boolean deleteStorage(Integer goodsID, Integer repositoryID) throws StorageManageServiceException {
try {
boolean isDelete = false;
// validate
List<Storage> storageList = storageMapper.selectByGoodsIDAndRepositoryID(goodsID, repositoryID);
if (storageList != null && !storageList.isEmpty()) {
// delete
storageMapper.deleteByRepositoryIDAndGoodsID(goodsID, repositoryID);
isDelete = true;
}
return isDelete;
} catch (PersistenceException e) {
throw new StorageManageServiceException(e);
}
}
/**
*
*
* @param file
* @return Mapkeytotalkeyavailable
*/
@UserOperation(value = "导入库存记录")
@Override
public Map<String, Object> importStorage(MultipartFile file) throws StorageManageServiceException {
// 初始化结果集
Map<String, Object> resultSet = new HashMap<>();
int total = 0;
int available = 0;
// 从文件中读取
try {
List<Storage> storageList = ejConvertor.excelReader(Storage.class, FileUtil.convertMultipartFileToFile(file));
if (storageList != null) {
total = storageList.size();
boolean isAvailable;
List<Storage> availableList = new ArrayList<>();
Goods goods;
Repository repository;
for (Storage storage : storageList) {
isAvailable = true;
// validate
goods = goodsMapper.selectById(storage.getGoodsID());
repository = repositoryMapper.selectByID(storage.getRepositoryID());
if (goods == null)
isAvailable = false;
if (repository == null)
isAvailable = false;
if (storage.getNumber() < 0)
isAvailable = false;
List<Storage> temp = storageMapper.selectByGoodsIDAndRepositoryID(storage.getGoodsID(), storage.getRepositoryID());
if (!(temp != null && temp.isEmpty()))
isAvailable = false;
if (isAvailable) {
availableList.add(storage);
}
}
// 保存到数据库
available = availableList.size();
System.out.println(available);
if (available > 0)
storageMapper.insertBatch(availableList);
}
} catch (PersistenceException | IOException e) {
throw new StorageManageServiceException(e);
}
resultSet.put("total", total);
resultSet.put("available", available);
return resultSet;
}
/**
*
*
* @param storageList List
* @return excel
*/
@UserOperation(value = "导出库存记录")
@Override
public File exportStorage(List<Storage> storageList) {
if (storageList == null)
return null;
return ejConvertor.excelWriter(Storage.class, storageList);
}
/**
*
*
* @param goodsID ID
* @param repositoryID ID
* @param number
* @return boolean true
*/
@Override
public boolean storageIncrease(Integer goodsID, Integer repositoryID, long number) throws StorageManageServiceException {
// 检查货物库存增加数目的有效性
if (number < 0)
return false;
synchronized (this) {
// 检查对应的库存记录是否存在
Storage storage = getStorage(goodsID, repositoryID);
if (storage != null) {
long newStorage = storage.getNumber() + number;
updateStorage(goodsID, repositoryID, newStorage);
} else {
addNewStorage(goodsID, repositoryID, number);
}
}
return true;
}
/**
*
*
* @param goodsID ID
* @param repositoryID ID
* @param number
* @return boolean true
*/
@Override
public boolean storageDecrease(Integer goodsID, Integer repositoryID, long number) throws StorageManageServiceException {
synchronized (this) {
// 检查对应的库存记录是否存在
Storage storage = getStorage(goodsID, repositoryID);
if (null != storage) {
// 检查库存减少数目的范围是否合理
if (number < 0 || storage.getNumber() < number)
return false;
long newStorage = storage.getNumber() - number;
updateStorage(goodsID, repositoryID, newStorage);
return true;
} else
return false;
}
}
/**
* IDID
*
* @param goodsID ID
* @param repositoryID ID
* @return null
*/
private Storage getStorage(Integer goodsID, Integer repositoryID) {
Storage storage = null;
List<Storage> storageList = storageMapper.selectByGoodsIDAndRepositoryID(goodsID, repositoryID);
if (!storageList.isEmpty())
storage = storageList.get(0);
return storage;
}
}

@ -1,334 +0,0 @@
package com.ken.wms.common.service.Impl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ken.wms.common.service.Interface.SupplierManageService;
import com.ken.wms.common.util.EJConvertor;
import com.ken.wms.common.util.FileUtil;
import com.ken.wms.dao.StockInMapper;
import com.ken.wms.dao.SupplierMapper;
import com.ken.wms.domain.StockInDO;
import com.ken.wms.domain.Supplier;
import com.ken.wms.exception.SupplierManageServiceException;
import com.ken.wms.util.aop.UserOperation;
import org.apache.ibatis.exceptions.PersistenceException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* service
*
* @author Ken
*/
@Service
public class SupplierManageServiceImpl implements SupplierManageService {
@Autowired
private SupplierMapper supplierMapper;
@Autowired
private StockInMapper stockInMapper;
@Autowired
private EJConvertor ejConvertor;
/**
* supplierID
*
* @param supplierId ID
* @return Map key data key total
*/
@Override
public Map<String, Object> selectById(Integer supplierId) throws SupplierManageServiceException {
// 初始化结果集
Map<String, Object> resultSet = new HashMap<>();
List<Supplier> suppliers = new ArrayList<>();
long total = 0;
// 查询
Supplier supplier;
try {
supplier = supplierMapper.selectById(supplierId);
} catch (PersistenceException e) {
throw new SupplierManageServiceException(e);
}
if (supplier != null) {
suppliers.add(supplier);
total = 1;
}
resultSet.put("data", suppliers);
resultSet.put("total", total);
return resultSet;
}
/**
* supplierName
*
* @param offset
* @param limit
* @param supplierName
* @return Map key data key total
*/
@Override
public Map<String, Object> selectByName(int offset, int limit, String supplierName) throws SupplierManageServiceException {
// 初始化结果集
Map<String, Object> resultSet = new HashMap<>();
List<Supplier> suppliers;
long total = 0;
boolean isPagination = true;
// validate
if (offset < 0 || limit < 0)
isPagination = false;
// query
try {
if (isPagination) {
PageHelper.offsetPage(offset, limit);
suppliers = supplierMapper.selectApproximateByName(supplierName);
if (suppliers != null) {
PageInfo<Supplier> pageInfo = new PageInfo<>(suppliers);
total = pageInfo.getTotal();
} else
suppliers = new ArrayList<>();
} else {
suppliers = supplierMapper.selectApproximateByName(supplierName);
if (suppliers != null)
total = suppliers.size();
else
suppliers = new ArrayList<>();
}
} catch (PersistenceException e) {
throw new SupplierManageServiceException(e);
}
resultSet.put("data", suppliers);
resultSet.put("total", total);
return resultSet;
}
/**
* supplierName
*
* @param supplierName supplierName
* @return Map key data key total
*/
@Override
public Map<String, Object> selectByName(String supplierName) throws SupplierManageServiceException {
return selectByName(-1, -1, supplierName);
}
/**
*
*
* @param offset
* @param limit
* @return Map key data key total
*/
@Override
public Map<String, Object> selectAll(int offset, int limit) throws SupplierManageServiceException {
// 初始化结果集
Map<String, Object> resultSet = new HashMap<>();
List<Supplier> suppliers;
long total = 0;
boolean isPagination = true;
// validate
if (offset < 0 || limit < 0)
isPagination = false;
// query
try {
if (isPagination) {
PageHelper.offsetPage(offset, limit);
suppliers = supplierMapper.selectAll();
if (suppliers != null) {
PageInfo<Supplier> pageInfo = new PageInfo<>(suppliers);
total = pageInfo.getTotal();
} else
suppliers = new ArrayList<>();
} else {
suppliers = supplierMapper.selectAll();
if (suppliers != null)
total = suppliers.size();
else
suppliers = new ArrayList<>();
}
} catch (PersistenceException e) {
throw new SupplierManageServiceException(e);
}
resultSet.put("data", suppliers);
resultSet.put("total", total);
return resultSet;
}
/**
*
*
* @return Map key data key total
*/
@Override
public Map<String, Object> selectAll() throws SupplierManageServiceException {
return selectAll(-1, -1);
}
/**
*
*
* @param supplier
* @return truefalse
*/
private boolean supplierCheck(Supplier supplier) {
// 检查是否已填写属性
return supplier.getName() != null && supplier.getPersonInCharge() != null
&& supplier.getTel() != null && supplier.getEmail() != null && supplier.getAddress() != null;
}
/**
*
*
* @param supplier
* @return
*/
@UserOperation(value = "添加供应商信息")
@Override
public boolean addSupplier(Supplier supplier) throws SupplierManageServiceException {
// 插入新的记录
if (supplier != null) {
try {
if (supplierCheck(supplier)) {
// 检查重名
if (null == supplierMapper.selectBuName(supplier.getName())) {
supplierMapper.insert(supplier);
if (supplier.getId() != null) {
return true;
}
}
}
} catch (PersistenceException e) {
throw new SupplierManageServiceException(e);
}
}
return false;
}
/**
*
*
* @param supplier
* @return booleantrue
*/
@UserOperation(value = "修改供应商信息")
@Override
public boolean updateSupplier(Supplier supplier) throws SupplierManageServiceException {
// 更新记录
if (supplier != null) {
// 检验
try {
if (supplierCheck(supplier)) {
if (supplier.getId() != null) {
// 检查重名
Supplier supplierFromDB = supplierMapper.selectBuName(supplier.getName());
if (supplierFromDB == null || supplier.getId().equals(supplierFromDB.getId())) {
supplierMapper.update(supplier);
return true;
}
}
}
} catch (PersistenceException e) {
throw new SupplierManageServiceException(e);
}
}
return false;
}
/**
*
*
* @param supplierId ID
* @return booleantrue
*/
@UserOperation(value = "删除供应商信息")
@Override
public boolean deleteSupplier(Integer supplierId) {
// 查询该供应商是否有入库记录
List<StockInDO> records = stockInMapper.selectBySupplierId(supplierId);
if (records == null || records.size() > 0)
return false;
// 删除该条供应商记录
supplierMapper.deleteById(supplierId);
return true;
}
/**
*
*
* @param file
* @return Mapkeytotalkeyavailable
*/
@UserOperation(value = "导入供应商信息")
@Override
public Map<String, Object> importSupplier(MultipartFile file) throws SupplierManageServiceException {
// 初始化结果集
Map<String, Object> result = new HashMap<>();
int total = 0;
int available = 0;
// 从 Excel 文件中读取
try {
List<Supplier> suppliers = ejConvertor.excelReader(Supplier.class, FileUtil.convertMultipartFileToFile(file));
if (suppliers != null) {
total = suppliers.size();
// 验证每一条供应商记录
List<Supplier> availableList = new ArrayList<>();
for (Supplier supplier : suppliers) {
if (supplierCheck(supplier)) {
// 检查重名
if (null == supplierMapper.selectBuName(supplier.getName()))
availableList.add(supplier);
}
}
// 保存到数据库
available = availableList.size();
if (available > 0) {
supplierMapper.insertBatch(availableList);
}
}
} catch (IOException | PersistenceException e) {
throw new SupplierManageServiceException(e);
}
result.put("total", total);
result.put("available", available);
return result;
}
/**
*
*
* @param suppliers Supplier List
* @return excel
*/
@UserOperation(value = "导出供应商信息")
@Override
public File exportSupplier(List<Supplier> suppliers) {
if (suppliers == null)
return null;
return ejConvertor.excelWriter(Supplier.class, suppliers);
}
}

@ -1,294 +0,0 @@
package com.ken.wms.common.service.Impl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ken.wms.common.service.Interface.SystemLogService;
import com.ken.wms.dao.AccessRecordMapper;
import com.ken.wms.dao.UserOperationRecordMapper;
import com.ken.wms.domain.AccessRecordDO;
import com.ken.wms.domain.AccessRecordDTO;
import com.ken.wms.domain.UserOperationRecordDO;
import com.ken.wms.domain.UserOperationRecordDTO;
import com.ken.wms.exception.SystemLogServiceException;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.apache.ibatis.exceptions.PersistenceException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
/**
* Service
*
* @author Ken
* @since 2017/4/7.
*/
@Service
public class SystemLogServiceImpl implements SystemLogService {
@Autowired
private AccessRecordMapper accessRecordMapper;
@Autowired
private UserOperationRecordMapper userOperationRecordMapper;
/**
*
*
* @param userID ID
* @param userName
* @param accessIP IP
* @param accessType
*/
@Override
public void insertAccessRecord(Integer userID, String userName, String accessIP, String accessType) throws SystemLogServiceException {
// 创建 AccessRecordDO 对象
AccessRecordDO accessRecordDO = new AccessRecordDO();
accessRecordDO.setUserID(userID);
accessRecordDO.setUserName(userName);
accessRecordDO.setAccessTime(new Date());
accessRecordDO.setAccessIP(accessIP);
accessRecordDO.setAccessType(accessType);
// 持久化 AccessRecordDO 对象到数据库
try {
accessRecordMapper.insertAccessRecord(accessRecordDO);
} catch (PersistenceException e) {
throw new SystemLogServiceException(e, "Fail to persist AccessRecordDO Object");
}
}
/**
* ID
*
* @param userID ID
* @param accessType
* @param startDateStr
* @param endDateStr
* @return Map data total
*/
@Override
public Map<String, Object> selectAccessRecord(Integer userID, String accessType, String startDateStr, String endDateStr) throws SystemLogServiceException {
return selectAccessRecord(userID, accessType, startDateStr, endDateStr, -1, -1);
}
/**
* ID
*
* @param userID ID
* @param accessType
* @param startDateStr
* @param endDateStr
* @param offset
* @param limit
* @return Map data total
*/
@Override
public Map<String, Object> selectAccessRecord(Integer userID, String accessType, String startDateStr, String endDateStr, int offset, int limit) throws SystemLogServiceException {
// 准备结果集
Map<String, Object> resultSet = new HashMap<>();
List<AccessRecordDTO> accessRecordDTOS = new ArrayList<>();
long total = 0;
boolean isPagination = true;
// 检查是否需要分页查询
if (offset < 0 || limit < 0)
isPagination = false;
// 转换 Date 对象
Date startDate = null;
Date endDate = null;
try {
if (StringUtils.isNotEmpty(startDateStr))
startDate = dateFormatSimple.parse(startDateStr);
if (StringUtils.isNotEmpty(endDateStr)) {
endDate = dateFormatSimple.parse(endDateStr);
endDate = DateUtils.addDays(endDate, 1);
}
} catch (ParseException e) {
throw new SystemLogServiceException(e, "Fail to convert string to Date Object");
}
// 转换 accessType
switch (accessType) {
case "loginOnly":
accessType = SystemLogService.ACCESS_TYPE_LOGIN;
break;
case "logoutOnly":
accessType = SystemLogService.ACCESS_TYPE_LOGOUT;
break;
default:
accessType = "all";
break;
}
// 执行查询操作
List<AccessRecordDO> accessRecordDOS;
try {
if (isPagination) {
PageHelper.offsetPage(offset, limit);
accessRecordDOS = accessRecordMapper.selectAccessRecords(userID, accessType, startDate, endDate);
if (accessRecordDOS != null) {
accessRecordDOS.forEach(accessRecordDO -> accessRecordDTOS.add(convertAccessRecordDOToAccessRecordDTO(accessRecordDO)));
total = new PageInfo<>(accessRecordDOS).getTotal();
}
} else {
accessRecordDOS = accessRecordMapper.selectAccessRecords(userID, accessType, startDate, endDate);
if (accessRecordDOS != null) {
accessRecordDOS.forEach(accessRecordDO -> accessRecordDTOS.add(convertAccessRecordDOToAccessRecordDTO(accessRecordDO)));
total = accessRecordDOS.size();
}
}
} catch (PersistenceException e) {
throw new SystemLogServiceException(e);
}
resultSet.put("data", accessRecordDTOS);
resultSet.put("total", total);
return resultSet;
}
/**
*
*
* @param userID ID
* @param userName
* @param operationName
* @param operationResult
*/
@Override
public void insertUserOperationRecord(Integer userID, String userName, String operationName, String operationResult) throws SystemLogServiceException {
// 创建 UserOperationRecordDO 对象
UserOperationRecordDO userOperationRecordDO = new UserOperationRecordDO();
userOperationRecordDO.setUserID(userID);
userOperationRecordDO.setUserName(userName);
userOperationRecordDO.setOperationName(operationName);
userOperationRecordDO.setOperationResult(operationResult);
userOperationRecordDO.setOperationTime(new Date());
// 将数据持久化到数据库
try {
userOperationRecordMapper.insertUserOperationRecord(userOperationRecordDO);
} catch (PersistenceException e) {
throw new SystemLogServiceException(e, "Fail to persist usrOperationRecordDo Object");
}
}
/**
* ID
*
* @param userID ID
* @param startDateStr
* @param endDateStr
* @return Map data total
*/
@Override
public Map<String, Object> selectUserOperationRecord(Integer userID, String startDateStr, String endDateStr) throws SystemLogServiceException {
return selectUserOperationRecord(userID, startDateStr, endDateStr, -1, -1);
}
/**
* ID
*
* @param userID ID
* @param startDateStr
* @param endDateStr
* @param offset
* @param limit
* @return Map data total
*/
@Override
public Map<String, Object> selectUserOperationRecord(Integer userID, String startDateStr, String endDateStr, int offset, int limit) throws SystemLogServiceException {
// 准备结果集
Map<String, Object> resultSet = new HashMap<>();
List<UserOperationRecordDTO> userOperationRecordDTOS = new ArrayList<>();
long total = 0;
boolean isPagination = true;
// 检查是否需要分页
if (offset < 0 && limit < 0)
isPagination = false;
// Date 转换
Date startDate = null;
Date endDate = null;
try {
if (StringUtils.isNotEmpty(startDateStr))
startDate = dateFormatSimple.parse(startDateStr);
if (StringUtils.isNotEmpty(endDateStr)) {
endDate = dateFormatSimple.parse(endDateStr);
endDate = DateUtils.addDays(endDate, 1);
}
} catch (ParseException e) {
throw new SystemLogServiceException(e, "Fail to convert String format date to Date Object");
}
// 执行查询操作
List<UserOperationRecordDO> userOperationRecordDOS;
try {
if (isPagination) {
PageHelper.offsetPage(offset, limit);
userOperationRecordDOS = userOperationRecordMapper.selectUserOperationRecord(userID, startDate, endDate);
if (userOperationRecordDOS != null) {
userOperationRecordDOS.forEach(userOperationRecordDO -> userOperationRecordDTOS.add(convertUserOperationRecordDOToUserOperationRecordDTO(userOperationRecordDO)));
total = new PageInfo<>(userOperationRecordDOS).getTotal();
}
} else {
userOperationRecordDOS = userOperationRecordMapper.selectUserOperationRecord(userID, startDate, endDate);
if (userOperationRecordDOS != null)
userOperationRecordDOS.forEach(userOperationRecordDO -> userOperationRecordDTOS.add(convertUserOperationRecordDOToUserOperationRecordDTO(userOperationRecordDO)));
}
} catch (PersistenceException e) {
throw new SystemLogServiceException(e);
}
resultSet.put("data", userOperationRecordDTOS);
resultSet.put("total", total);
return resultSet;
}
/**
* Date
*/
private DateFormat dateFormatDetail = new SimpleDateFormat("yyyy-MM-dd hh:mm");
private DateFormat dateFormatSimple = new SimpleDateFormat("yyyy-MM-dd");
/**
* AccessRecordDO AccessRecordDTO
*
* @param accessRecordDO AccessRecordDO
* @return AccessRecordDTO
*/
private AccessRecordDTO convertAccessRecordDOToAccessRecordDTO(AccessRecordDO accessRecordDO) {
AccessRecordDTO accessRecordDTO = new AccessRecordDTO();
accessRecordDTO.setId(accessRecordDO.getId());
accessRecordDTO.setUserID(accessRecordDO.getUserID());
accessRecordDTO.setUserName(accessRecordDO.getUserName());
accessRecordDTO.setAccessIP(accessRecordDO.getAccessIP());
accessRecordDTO.setAccessType(accessRecordDO.getAccessType().equals(SystemLogService.ACCESS_TYPE_LOGIN) ? "登入" : "登出");
accessRecordDTO.setAccessTime(dateFormatDetail.format(accessRecordDO.getAccessTime()));
return accessRecordDTO;
}
/**
* UserOperationRecordDO UserOperationRecordDTO
*
* @param userOperationRecordDO UserOperationRecordDO
* @return UserOperationRecordDTO
*/
private UserOperationRecordDTO convertUserOperationRecordDOToUserOperationRecordDTO(UserOperationRecordDO userOperationRecordDO) {
UserOperationRecordDTO userOperationRecordDTO = new UserOperationRecordDTO();
userOperationRecordDTO.setId(userOperationRecordDO.getId());
userOperationRecordDTO.setUserID(userOperationRecordDO.getUserID());
userOperationRecordDTO.setUserName(userOperationRecordDO.getUserName());
userOperationRecordDTO.setOperationName(userOperationRecordDO.getOperationName());
userOperationRecordDTO.setOperationResult(userOperationRecordDO.getOperationResult());
userOperationRecordDTO.setOperationTime(dateFormatDetail.format(userOperationRecordDO.getOperationTime()));
return userOperationRecordDTO;
}
}

@ -1,102 +0,0 @@
package com.ken.wms.common.service.Interface;
import com.ken.wms.domain.Customer;
import com.ken.wms.exception.CustomerManageServiceException;
import org.springframework.web.multipart.MultipartFile;
import java.io.File;
import java.util.List;
import java.util.Map;
/**
* service
*
* @author Ken
*/
public interface CustomerManageService {
/**
* customer id
*
* @param customerId ID
* @return Map key data key total
*/
Map<String, Object> selectById(Integer customerId) throws CustomerManageServiceException;
/**
* customer name
*
*
* @param offset
* @param limit
* @param customerName
* @return Map key data key total
*/
Map<String, Object> selectByName(int offset, int limit, String customerName) throws CustomerManageServiceException;
/**
* customer Name
*
*
* @param customerName
* @return Map key data key total
*/
Map<String, Object> selectByName(String customerName) throws CustomerManageServiceException;
/**
*
*
* @param offset
* @param limit
* @return Map key data key total
*/
Map<String, Object> selectAll(int offset, int limit) throws CustomerManageServiceException;
/**
*
*
* @return Map key data key total
*/
Map<String, Object> selectAll() throws CustomerManageServiceException;
/**
*
*
* @param customer
* @return booleantrue
*/
boolean addCustomer(Customer customer) throws CustomerManageServiceException;
/**
*
*
* @param customer
* @return booleantrue
*/
boolean updateCustomer(Customer customer) throws CustomerManageServiceException;
/**
*
*
* @param customerId ID
* @return booleantrue
*/
boolean deleteCustomer(Integer customerId) throws CustomerManageServiceException;
/**
*
*
* @param file
* @return Mapkeytotalkeyavailable
*/
Map<String, Object> importCustomer(MultipartFile file) throws CustomerManageServiceException;
/**
*
*
* @param customers customer List
* @return Excel
*/
File exportCustomer(List<Customer> customers);
}

@ -1,102 +0,0 @@
package com.ken.wms.common.service.Interface;
import com.ken.wms.domain.Goods;
import com.ken.wms.exception.GoodsManageServiceException;
import org.springframework.web.multipart.MultipartFile;
import java.io.File;
import java.util.List;
import java.util.Map;
/**
* service
*
* @author Ken
*/
public interface GoodsManageService {
/**
* goods ID
*
* @param goodsId ID
* @return Map key data key total
*/
Map<String, Object> selectById(Integer goodsId) throws GoodsManageServiceException;
/**
* goods name
*
*
* @param offset
* @param limit
* @param goodsName
* @return Map key data key total
*/
Map<String, Object> selectByName(int offset, int limit, String goodsName) throws GoodsManageServiceException;
/**
* goods name
*
*
* @param goodsName
* @return Map key data key total
*/
Map<String, Object> selectByName(String goodsName) throws GoodsManageServiceException;
/**
*
*
* @param offset
* @param limit
* @return Map key data key total
*/
Map<String, Object> selectAll(int offset, int limit) throws GoodsManageServiceException;
/**
*
*
* @return Map key data key total
*/
Map<String, Object> selectAll() throws GoodsManageServiceException;
/**
*
*
* @param goods
* @return booleantrue
*/
boolean addGoods(Goods goods) throws GoodsManageServiceException;
/**
*
*
* @param goods
* @return booleantrue
*/
boolean updateGoods(Goods goods) throws GoodsManageServiceException;
/**
*
*
* @param goodsId ID
* @return booleantrue
*/
boolean deleteGoods(Integer goodsId) throws GoodsManageServiceException;
/**
*
*
* @param file
* @return Mapkeytotalkeyavailable
*/
Map<String, Object> importGoods(MultipartFile file) throws GoodsManageServiceException;
/**
*
*
* @param goods Supplier List
* @return excel
*/
File exportGoods(List<Goods> goods);
}

@ -1,119 +0,0 @@
package com.ken.wms.common.service.Interface;
import com.ken.wms.domain.RepositoryAdmin;
import com.ken.wms.exception.RepositoryAdminManageServiceException;
import org.springframework.web.multipart.MultipartFile;
import java.io.File;
import java.util.List;
import java.util.Map;
/**
* service
*
* @author Ken
*/
public interface RepositoryAdminManageService {
/**
* repository id
*
* @param repositoryAdminID ID
* @return Map key data key total
*/
Map<String, Object> selectByID(Integer repositoryAdminID) throws RepositoryAdminManageServiceException;
/**
* repositoryID
*
* @param repositoryID ID key data key total
* @return Map
*/
Map<String, Object> selectByRepositoryID(Integer repositoryID) throws RepositoryAdminManageServiceException;
/**
* repository address
*
*
* @param offset
* @param limit
* @param name
* @return Map key data key total
*/
Map<String, Object> selectByName(int offset, int limit, String name);
/**
* repository Name
*
*
* @param name
* @return Map key data key total
*/
Map<String, Object> selectByName(String name);
/**
*
*
* @param offset
* @param limit
* @return Map key data key total
*/
Map<String, Object> selectAll(int offset, int limit) throws RepositoryAdminManageServiceException;
/**
*
*
* @return Map key data key total
*/
Map<String, Object> selectAll() throws RepositoryAdminManageServiceException;
/**
*
*
* @param repositoryAdmin
* @return booleantrue
*/
boolean addRepositoryAdmin(RepositoryAdmin repositoryAdmin) throws RepositoryAdminManageServiceException;
/**
*
*
* @param repositoryAdmin
* @return booleantrue
*/
boolean updateRepositoryAdmin(RepositoryAdmin repositoryAdmin) throws RepositoryAdminManageServiceException;
/**
*
*
* @param repositoryAdminID ID
* @return booleantrue
*/
boolean deleteRepositoryAdmin(Integer repositoryAdminID) throws RepositoryAdminManageServiceException;
/**
* ID
*
* @param repositoryAdminID ID
* @param repositoryID ID
* @return boolean true
*/
boolean assignRepository(Integer repositoryAdminID, Integer repositoryID) throws RepositoryAdminManageServiceException;
/**
*
*
* @param file
* @return Mapkeytotalkeyavailable
*/
Map<String, Object> importRepositoryAdmin(MultipartFile file) throws RepositoryAdminManageServiceException;
/**
*
*
* @param repositoryAdmins repository List
* @return Excel
*/
File exportRepositoryAdmin(List<RepositoryAdmin> repositoryAdmins);
}

@ -1,109 +0,0 @@
package com.ken.wms.common.service.Interface;
import com.ken.wms.domain.Repository;
import com.ken.wms.exception.RepositoryManageServiceException;
import org.springframework.web.multipart.MultipartFile;
import java.io.File;
import java.util.List;
import java.util.Map;
/**
* service
*
* @author Ken
*/
public interface RepositoryService {
/**
* repository ID
*
* @param repositoryId ID
* @return Map key data key total
*/
Map<String, Object> selectById(Integer repositoryId) throws RepositoryManageServiceException;
/**
* repository address
*
*
* @param offset
* @param limit
* @param address
* @return Map key data key total
*/
Map<String, Object> selectByAddress(int offset, int limit, String address) throws RepositoryManageServiceException;
/**
* repository address
*
*
* @param address
* @return Map key data key total
*/
Map<String, Object> selectByAddress(String address) throws RepositoryManageServiceException;
/**
*
*
* @param offset
* @param limit
* @return Map key data key total
*/
Map<String, Object> selectAll(int offset, int limit) throws RepositoryManageServiceException;
/**
*
*
* @return Map key data key total
*/
Map<String, Object> selectAll() throws RepositoryManageServiceException;
/**
*
*
* @return Map key data key total
*/
Map<String, Object> selectUnassign() throws RepositoryManageServiceException;
/**
*
*
* @param repository
* @return booleantrue
*/
boolean addRepository(Repository repository) throws RepositoryManageServiceException;
/**
*
*
* @param repository
* @return booleantrue
*/
boolean updateRepository(Repository repository) throws RepositoryManageServiceException;
/**
*
*
* @param repositoryId ID
* @return booleantrue
*/
boolean deleteRepository(Integer repositoryId) throws RepositoryManageServiceException;
/**
*
*
* @param file
* @return Mapkeytotalkeyavailable
*/
Map<String, Object> importRepository(MultipartFile file) throws RepositoryManageServiceException;
/**
*
*
* @param repositories Supplier List
* @return excel
*/
File exportRepository(List<Repository> repositories);
}

@ -1,59 +0,0 @@
package com.ken.wms.common.service.Interface;
import com.ken.wms.exception.StockRecordManageServiceException;
import java.util.Map;
/**
*
*
* @author Ken
*/
public interface StockRecordManageService {
/**
*
*
* @param supplierID ID
* @param goodsID ID
* @param repositoryID ID
* @param number
* @return boolean true
*/
boolean stockInOperation(Integer supplierID, Integer goodsID, Integer repositoryID, long number, String personInCharge) throws StockRecordManageServiceException;
/**
*
*
* @param customerID ID
* @param goodsID ID
* @param repositoryID ID
* @param number
* @return booleantrue
*/
boolean stockOutOperation(Integer customerID, Integer goodsID, Integer repositoryID, long number, String personInCharge) throws StockRecordManageServiceException;
/**
*
*
* @param repositoryID ID
* @param endDateStr
* @param startDateStr
* @param searchType
* @return Map key data key total
*/
Map<String, Object> selectStockRecord(Integer repositoryID, String startDateStr, String endDateStr, String searchType) throws StockRecordManageServiceException;
/**
*
*
* @param repositoryID ID
* @param endDateStr
* @param startDateStr
* @param searchType
* @param offset
* @param limit
* @return Map key data key total
*/
Map<String, Object> selectStockRecord(Integer repositoryID, String startDateStr, String endDateStr, String searchType, int offset, int limit) throws StockRecordManageServiceException;
}

@ -1,154 +0,0 @@
package com.ken.wms.common.service.Interface;
import com.ken.wms.domain.Storage;
import com.ken.wms.exception.StorageManageServiceException;
import org.springframework.web.multipart.MultipartFile;
import java.io.File;
import java.util.List;
import java.util.Map;
/**
* service
*
* @author Ken
*/
public interface StorageManageService {
/**
*
*
* @return Map key data key total
*/
Map<String, Object> selectAll(Integer repositoryID) throws StorageManageServiceException;
/**
*
*
* @param offset
* @param limit
* @return Map key data key total
*/
Map<String, Object> selectAll(Integer repositoryID, int offset, int limit) throws StorageManageServiceException;
/**
* ID
*
* @param goodsID ID
* @return Map key data key total
*/
Map<String, Object> selectByGoodsID(Integer goodsID, Integer repositoryID) throws StorageManageServiceException;
/**
*
*
* @param goodsID ID
* @param offset
* @param limit
* @return Map key data key total
*/
Map<String, Object> selectByGoodsID(Integer goodsID, Integer repositoryID, int offset, int limit) throws StorageManageServiceException;
/**
*
*
* @param goodsName
* @return Map key data key total
*/
Map<String, Object> selectByGoodsName(String goodsName, Integer repositoryID) throws StorageManageServiceException;
/**
*
*
* @param goodsName
* @param offset
* @param limit
* @return Map key data key total
*/
Map<String, Object> selectByGoodsName(String goodsName, Integer repositoryID, int offset, int limit) throws StorageManageServiceException;
/**
*
*
* @param goodsType
* @return Map key data key total
*/
Map<String, Object> selectByGoodsType(String goodsType, Integer Repository) throws StorageManageServiceException;
/**
*
*
* @param goodsType
* @param offset
* @param limit
* @return Map key data key total
*/
Map<String, Object> selectByGoodsType(String goodsType, Integer repositoryID, int offset, int limit) throws StorageManageServiceException;
/**
*
*
* @param goodsID ID
* @param repositoryID ID
* @param number
* @return booleantrue
*/
boolean addNewStorage(Integer goodsID, Integer repositoryID, long number) throws StorageManageServiceException;
/**
*
*
* @param goodsID ID
* @param repositoryID ID
* @param number
* @return booleantrue
*/
boolean updateStorage(Integer goodsID, Integer repositoryID, long number) throws StorageManageServiceException;
/**
*
*
* @param goodsID ID
* @param repositoryID ID
* @param number
* @return boolean true
*/
boolean storageIncrease(Integer goodsID, Integer repositoryID, long number) throws StorageManageServiceException;
/**
*
*
* @param goodsID ID
* @param repositoryID ID
* @param number
* @return boolean true
*/
boolean storageDecrease(Integer goodsID, Integer repositoryID, long number) throws StorageManageServiceException;
/**
*
* IDID
*
* @param goodsID ID
* @param repositoryID ID
* @return booleantrue
*/
boolean deleteStorage(Integer goodsID, Integer repositoryID) throws StorageManageServiceException;
/**
*
*
* @param file
* @return Mapkeytotalkeyavailable
*/
Map<String, Object> importStorage(MultipartFile file) throws StorageManageServiceException;
/**
*
*
* @param storages List
* @return excel
*/
File exportStorage(List<Storage> storages);
}

@ -1,102 +0,0 @@
package com.ken.wms.common.service.Interface;
import com.ken.wms.domain.Supplier;
import com.ken.wms.exception.SupplierManageServiceException;
import org.springframework.web.multipart.MultipartFile;
import java.io.File;
import java.util.List;
import java.util.Map;
/**
* service
*
* @author Ken
*/
public interface SupplierManageService {
/**
* supplierID
*
* @param supplierId ID
* @return Map key data key total
*/
Map<String, Object> selectById(Integer supplierId) throws SupplierManageServiceException;
/**
* supplierName
*
*
* @param offset
* @param limit
* @param supplierName
* @return Map key data key total
*/
Map<String, Object> selectByName(int offset, int limit, String supplierName) throws SupplierManageServiceException;
/**
* supplierName
*
*
* @param supplierName supplierName
* @return Map key data key total
*/
Map<String, Object> selectByName(String supplierName) throws SupplierManageServiceException;
/**
*
*
* @param offset
* @param limit
* @return Map key data key total
*/
Map<String, Object> selectAll(int offset, int limit) throws SupplierManageServiceException;
/**
*
*
* @return Map key data key total
*/
Map<String, Object> selectAll() throws SupplierManageServiceException;
/**
*
*
* @param supplier
* @return booleantrue
*/
boolean addSupplier(Supplier supplier) throws SupplierManageServiceException;
/**
*
*
* @param supplier
* @return booleantrue
*/
boolean updateSupplier(Supplier supplier) throws SupplierManageServiceException;
/**
*
*
* @param supplierId ID
* @return booleantrue
*/
boolean deleteSupplier(Integer supplierId);
/**
*
*
* @param file
* @return Mapkeytotalkeyavailable
*/
Map<String, Object> importSupplier(MultipartFile file) throws SupplierManageServiceException;
/**
*
*
* @param suppliers Supplier List
* @return excel
*/
File exportSupplier(List<Supplier> suppliers);
}

@ -1,83 +0,0 @@
package com.ken.wms.common.service.Interface;
import com.ken.wms.exception.SystemLogServiceException;
import java.util.Map;
/**
* Service
*
* @author Ken
* @since 2017/4/7.
*/
public interface SystemLogService {
String ACCESS_TYPE_LOGIN = "login";
String ACCESS_TYPE_LOGOUT = "logout";
/**
*
*
* @param userID ID
* @param userName
* @param accessIP IP
* @param accessType
*/
void insertAccessRecord(Integer userID, String userName, String accessIP, String accessType) throws SystemLogServiceException;
/**
* ID
*
* @param userID ID
* @param accessType
* @param startDateStr
* @param endDateStr
* @return Map data total
*/
Map<String, Object> selectAccessRecord(Integer userID, String accessType, String startDateStr, String endDateStr) throws SystemLogServiceException;
/**
* ID
*
* @param userID ID
* @param accessType
* @param startDateStr
* @param endDateStr
* @param offset
* @param limit
* @return Map data total
*/
Map<String, Object> selectAccessRecord(Integer userID, String accessType, String startDateStr, String endDateStr, int offset, int limit) throws SystemLogServiceException;
/**
*
*
* @param userID ID
* @param userName
* @param operationName
* @param operationResult
*/
void insertUserOperationRecord(Integer userID, String userName, String operationName, String operationResult) throws SystemLogServiceException;
/**
* ID
*
* @param userID ID
* @param startDateStr
* @param endDateStr
* @return Map data total
*/
Map<String, Object> selectUserOperationRecord(Integer userID, String startDateStr, String endDateStr) throws SystemLogServiceException;
/**
* ID
*
* @param userID ID
* @param startDateStr
* @param endDateStr
* @param offset
* @param limit
* @return Map data total
*/
Map<String, Object> selectUserOperationRecord(Integer userID, String startDateStr, String endDateStr, int offset, int limit) throws SystemLogServiceException;
}

@ -1,686 +0,0 @@
package com.ken.wms.common.util;
import org.apache.commons.lang3.math.NumberUtils;
import org.apache.poi.hssf.usermodel.HSSFDateUtil;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.XSSFFont;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.core.io.ClassPathResource;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.*;
/**
* Excel -JavaBean
*
* @author Ken
* @since 2017/3/27.
*/
public class EJConvertor {
/**
*
*/
private static final String DEFAULT_CONFIG_FILE_NAME = "EJConvertorConfig.xml";
/**
* Entity
*/
private static final String ENTITY_ELEMENT = "entity";
/**
* Property
*/
private static final String PROPERTY_ELEMENT = "property";
/**
* Field
*/
private static final String FIELD_ELEMENT = "field";
/**
* Value
*/
private static final String VALUE_ELEMENT = "value";
/**
* class
*/
private static final String CLASS_ATTRIBUTE = "class";
/**
* sheetName
*/
private static final String SHEET_NAME_ATTRIBUTE = "sheetName";
/**
* boldHeading
*/
private static final String BOLD_HEADING_ATTRIBUTE = "boldHeading";
/**
* JavaBean
*/
private Map<String, MappingInfo> excelJavaBeanMap;
public EJConvertor() {
init(DEFAULT_CONFIG_FILE_NAME);
}
public EJConvertor(String filePath) {
init(filePath);
}
/**
*
*
* @param fileLocation
*/
private void init(String fileLocation) {
try {
// 读取配置文件
File configFile = new ClassPathResource(fileLocation).getFile();
DocumentBuilder documentBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
Document doc = documentBuilder.parse(configFile);
// 解析配置文件
this.excelJavaBeanMap = parseMappingInfo(doc);
} catch (ParserConfigurationException | SAXException | IOException e) {
e.printStackTrace();
}
}
/**
* Document root excel-javaBean
*
* @param root Document
* @return excel-javaBean
*/
private Map<String, MappingInfo> parseMappingInfo(Document root) {
// 获取 root 下的所有 entity 节点
NodeList entities = root.getElementsByTagName(ENTITY_ELEMENT);
// 创建承载 MappingInfo 信息的Map
Map<String, MappingInfo> mappingInfoMap = new HashMap<>(entities.getLength());
// 解析 entity 节点
for (int index = 0; index < entities.getLength(); index++) {
// 创建 mappingInfo
MappingInfo mappingInfo = new MappingInfo();
// 解析节点信息
Node entityNode = entities.item(index);
if (entityNode.getNodeType() == Node.ELEMENT_NODE) {
Element entityElement = (Element) entityNode;
parseEntityElement(entityElement, mappingInfo);
}
// 保存节点信息
mappingInfoMap.put(mappingInfo.getClassName(), mappingInfo);
}
return mappingInfoMap;
}
/**
* entity
*
* @param entityElement entity
* @param mappingInfo entity
*/
private void parseEntityElement(Element entityElement, MappingInfo mappingInfo) {
// 解析 entity 的 class 属性
String className = entityElement.getAttribute(CLASS_ATTRIBUTE);
mappingInfo.setClassName(className);
// 解析 entity 的 sheetName 属性
if (entityElement.hasAttribute(SHEET_NAME_ATTRIBUTE))
mappingInfo.setSheetName(entityElement.getAttribute(SHEET_NAME_ATTRIBUTE));
// 解析 entity 的 boldHeading 属性
if (entityElement.hasAttribute(BOLD_HEADING_ATTRIBUTE)) {
String isBoldHeading = entityElement.getAttribute(BOLD_HEADING_ATTRIBUTE);
mappingInfo.setBoldHeading(isBoldHeading.equals("true"));
}
// 读取并解析 property 节点
NodeList properties = entityElement.getElementsByTagName(PROPERTY_ELEMENT);
for (int index = 0; index < properties.getLength(); index++) {
Node propertyNode = properties.item(index);
if (propertyNode.getNodeType() == Node.ELEMENT_NODE) {
Element propertyElement = (Element) propertyNode;
parsePropertyElement(propertyElement, mappingInfo);
}
}
}
/**
* property
*
* @param propertyElement property
* @param mappingInfo
*/
private void parsePropertyElement(Element propertyElement, MappingInfo mappingInfo) {
NodeList infoNodes = propertyElement.getChildNodes();
String field = null;
String value = null;
for (int infoNode_index = 0; infoNode_index < infoNodes.getLength(); infoNode_index++) {
Node infoNode = infoNodes.item(infoNode_index);
if (infoNode.getNodeName().equals(FIELD_ELEMENT))
field = infoNode.getTextContent();
if (infoNode.getNodeName().equals(VALUE_ELEMENT))
value = infoNode.getTextContent();
}
// 添加到映射信息中
if (field != null && value != null) {
mappingInfo.addFieldValueMapping(field, value);
mappingInfo.addValueFieldMapping(value, field);
}
}
/**
* Excel Excel
*
*
* @param javaBeanClass
* @param file Excel
* @return List
*/
public <T> List<T> excelReader(Class<T> javaBeanClass, File file) {
// 参数检查
if (file == null || javaBeanClass == null)
return null;
// 初始化存放读取结果的 List
List<T> javaBeans = new ArrayList<>();
// 获取类名和映射信息
String className = javaBeanClass.getName();
MappingInfo mappingInfo = excelJavaBeanMap.get(className);
if (mappingInfo == null)
return null;
// 读取 Excel 文件
try (Workbook workbook = new XSSFWorkbook(new FileInputStream(file))) {
Sheet dataSheet = workbook.getSheetAt(0);
Row row;
Cell cell;
Iterator<Row> rowIterator = dataSheet.iterator();
Iterator<Cell> cellIterator;
// 读取第一行表头信息
if (!rowIterator.hasNext())
return null;
String fieldName;
Field fieldInstance;
Class<?> fieldClass;
List<String> fieldNameList = new ArrayList<>();// 目标对象的 field 名称列表
List<Class<?>> fieldClassList = new ArrayList<>();// 目标对象 field 类型列表
row = rowIterator.next();
cellIterator = row.iterator();
while (cellIterator.hasNext()) {
cell = cellIterator.next();
// 获取 value 对应的 field 的名称以及类型
fieldName = mappingInfo.getValueFieldMapping(cell.getStringCellValue());
fieldClass = (fieldName != null && (fieldInstance = javaBeanClass.getDeclaredField(fieldName)) != null) ?
fieldInstance.getType() : null;
// 保存 value 对应的 field 的名称和类型
fieldClassList.add(cell.getColumnIndex(), fieldClass);
fieldNameList.add(cell.getColumnIndex(), fieldName);
}
// 读取表格内容
while (rowIterator.hasNext()) {
row = rowIterator.next();
cellIterator = row.iterator();
T javaBean = javaBeanClass.newInstance();
// 读取单元格
while (cellIterator.hasNext()) {
cell = cellIterator.next();
int columnIndex = cell.getColumnIndex();
// 获取单元格的值,并设置对象中对应的属性
Object fieldValue = getCellValue(fieldClassList.get(columnIndex), cell);
if (fieldValue == null) continue;
setField(javaBean, fieldNameList.get(columnIndex), fieldValue);
}
// 放入结果
javaBeans.add(javaBean);
}
} catch (Exception e) {
e.printStackTrace();
}
return javaBeans;
}
/**
* List Excel
*
* @param classType
* @param javaBeans List
* @return excel
*/
public File excelWriter(Class<?> classType, List<?> javaBeans) {
// 参数检查
if (classType == null || javaBeans == null)
return null;
// 获取类名和映射信息
String className = classType.getName();
MappingInfo mappingInfo = excelJavaBeanMap.get(className);
if (mappingInfo == null)
return null;
// 获取该 javaBean 注册需要写到 excel 的 field
Set<String> fields = mappingInfo.getFieldValueMapping().keySet();// 注册的 field 列表
List<String> valuesList = new ArrayList<>();// field 对应的 excel 表头 value 列表
fields.forEach(field -> valuesList.add(mappingInfo.getFieldValueMapping(field)));
// 创建对应的 excel 文件
File excel = null;
try {
// 创建临时文件
excel = File.createTempFile("excel", ".xlsx");
// 创建 workBook 对象
Workbook workbook = new XSSFWorkbook();
// 创建 sheet 对象
Sheet sheet = workbook.createSheet(mappingInfo.getSheetName());
int rowIndex = 0;
int cellIndex;
Row row;
Cell cell;
// 写入第一行表头
cellIndex = 0;
row = sheet.createRow(rowIndex++);
XSSFFont font = (XSSFFont) workbook.createFont();
font.setBold(mappingInfo.isBoldHeading());
CellStyle cellStyle = workbook.createCellStyle();
cellStyle.setFont(font);
for (String value : valuesList) {
cell = row.createCell(cellIndex);
cell.setCellValue(value);
cellIndex++;
// 设置样式
cell.setCellStyle(cellStyle);
}
// 写入内容数据
for (Object javaBean : javaBeans) {
row = sheet.createRow(rowIndex++);
cellIndex = 0;
for (String fieldName : fields) {
Object value = getField(javaBean, getGetterMethodName(fieldName));
cell = row.createCell(cellIndex++);
setCellValue1(value, workbook, cell);
}
}
// 调整 cell 大小
for (int i = 0; i < valuesList.size(); i++) {
sheet.autoSizeColumn(i);
}
// 将 workBook 写入到 tempFile 中
FileOutputStream outputStream = new FileOutputStream(excel);
workbook.write(outputStream);
outputStream.flush();
outputStream.close();
workbook.close();
} catch (Exception e) {
e.printStackTrace();
}
return excel;
}
/**
* Excel
*
* @param fieldClass JavaBean
* @param cell
* @param <T>
* @return JavaBean
*/
@SuppressWarnings("unchecked")
private <T> T getCellValue(Class<T> fieldClass, Cell cell) {
// field 对值
T fieldValue = null;
if (fieldClass == int.class || fieldClass == Integer.class) {
// convert to Integer
cell.setCellType(Cell.CELL_TYPE_STRING);
String cellValue = cell.getStringCellValue();
Integer integer = NumberUtils.isNumber(cellValue) ? Double.valueOf(cellValue).intValue() : 0;
fieldValue = (T) integer;
} else if (fieldClass == long.class || fieldClass == Long.class) {
// convert to Long
cell.setCellType(Cell.CELL_TYPE_STRING);
String cellValue = cell.getStringCellValue();
Long l = NumberUtils.isNumber(cellValue) ? Double.valueOf(cellValue).longValue() : 0;
fieldValue = (T) l;
} else if (fieldClass == float.class || fieldClass == Float.class) {
// convert to Float
cell.setCellType(Cell.CELL_TYPE_STRING);
String cellValue = cell.getStringCellValue();
Float f = NumberUtils.isNumber(cellValue) ? Float.valueOf(cellValue) : 0;
fieldValue = (T) f;
} else if (fieldClass == double.class || fieldClass == Double.class) {
// convert to Double
cell.setCellType(Cell.CELL_TYPE_STRING);
String cellValue = cell.getStringCellValue();
Double d = NumberUtils.isNumber(cellValue) ? Double.valueOf(cellValue) : 0;
fieldValue = (T) d;
} else if (fieldClass == short.class || fieldClass == Short.class) {
// convert to Short
cell.setCellType(Cell.CELL_TYPE_STRING);
String cellValue = cell.getStringCellValue();
Short s = NumberUtils.isNumber(cellValue) ? Double.valueOf(cellValue).shortValue() : 0;
fieldValue = (T) s;
} else if (fieldClass == boolean.class || fieldClass == Boolean.class) {
// get Boolean
cell.setCellType(Cell.CELL_TYPE_BOOLEAN);
Boolean b = cell.getBooleanCellValue();
fieldValue = (T) b;
} else if (fieldClass == char.class || fieldClass == Character.class) {
// convert to Character
cell.setCellType(Cell.CELL_TYPE_STRING);
String cellValue = cell.getStringCellValue();
Character c = cellValue.charAt(0);
fieldValue = (T) c;
} else if (fieldClass == byte.class || fieldClass == Byte.class) {
// convert to Byte
cell.setCellType(Cell.CELL_TYPE_STRING);
String cellValue = cell.getStringCellValue();
Byte b = NumberUtils.isNumber(cellValue) ? Double.valueOf(cellValue).byteValue() : 0;
fieldValue = (T) b;
} else if (fieldClass == String.class) {
// convert to String
cell.setCellType(Cell.CELL_TYPE_STRING);
String cellValue = cell.getStringCellValue();
fieldValue = (T) cellValue;
} else if (fieldClass == Date.class) {
// convert to java.util.Date
fieldValue = HSSFDateUtil.isCellDateFormatted(cell) ? (T) cell.getDateCellValue() : null;
} else if (fieldClass == java.sql.Date.class) {
// convert to java.sql.Date
fieldValue = null;
if (HSSFDateUtil.isCellDateFormatted(cell)) {
java.sql.Date date = new java.sql.Date(cell.getDateCellValue().getTime());
fieldValue = (T) date;
}
}
return fieldValue;
}
/**
*
*
* @param cellValue
* @param workbook workbook
* @param cell
*/
private void setCellValue1(Object cellValue, Workbook workbook, Cell cell) {
// 参数检查
if (cell == null || cellValue == null || workbook == null)
return;
Class<?> cellValueClass = cellValue.getClass();
if (cellValueClass == boolean.class || cellValueClass == Boolean.class) {
cell.setCellValue((Boolean) cellValue);
} else if (cellValueClass == char.class || cellValueClass == Character.class) {
cell.setCellValue(String.valueOf(cellValue));
} else if (cellValueClass == byte.class || cellValueClass == Byte.class) {
cell.setCellValue((Byte) cellValue);
} else if (cellValueClass == short.class || cellValueClass == Short.class) {
cell.setCellValue((Short) cellValue);
} else if (cellValueClass == int.class || cellValueClass == Integer.class) {
cell.setCellValue((Integer) cellValue);
} else if (cellValueClass == long.class || cellValueClass == Long.class) {
cell.setCellValue((Long) cellValue);
} else if (cellValueClass == float.class || cellValueClass == Float.class) {
cell.setCellValue(String.valueOf(cellValue));
// cell.setCellValue((Float) cellValue);
} else if (cellValueClass == double.class || cellValueClass == Double.class) {
cell.setCellValue((Double) cellValue);
} else if (cellValueClass == String.class) {
cell.setCellValue((String) cellValue);
} else if (cellValueClass == Date.class) {
Date v = (Date) cellValue;
CellStyle cellStyle = workbook.createCellStyle();
CreationHelper creationHelper = workbook.getCreationHelper();
cellStyle.setDataFormat(creationHelper.createDataFormat().getFormat("yyyy/mm/dd"));
cell.setCellValue(v);
cell.setCellStyle(cellStyle);
} else if (cellValueClass == java.sql.Date.class) {
java.sql.Date v = (java.sql.Date) cellValue;
CellStyle cellStyle = workbook.createCellStyle();
CreationHelper creationHelper = workbook.getCreationHelper();
cellStyle.setDataFormat(creationHelper.createDataFormat().getFormat("yyyy/mm/dd"));
cell.setCellValue(v);
cell.setCellStyle(cellStyle);
}
}
/**
* JavaBean field
*
* @param targetObject JavaBean
* @param fieldName
* @param fieldValue
* @throws Exception Exception
*/
private void setField(Object targetObject, String fieldName, Object fieldValue) throws Exception {
// 获取对应的 setter 方法
Class<?> targetObjectClass = targetObject.getClass();
Class<?> fieldClass = targetObjectClass.getDeclaredField(fieldName).getType();
Method setterMethod = targetObjectClass.getMethod(getSetterMethodName(fieldName), fieldClass);
// 调用 setter 方法,设置 field 的值
setterMethod.invoke(targetObject, fieldValue);
}
/**
* getter getter
*
* @param targetObject
* @param methodName getter
* @return
* @throws Exception Exception
*/
private Object getField(Object targetObject, String methodName) throws Exception {
// 获得 getter 方法实例
Class<?> targetObjectType = targetObject.getClass();
Method getterMethod = targetObjectType.getMethod(methodName);
// 调用方法
return getterMethod.invoke(targetObject);
}
/**
* setter
*/
private Map<String, String> setterMethodNameCache = new HashMap<>(64);
/**
* getter
*/
private Map<String, String> getterMethodNameCache = new HashMap<>(64);
/**
* setter
*
* @param fieldName
* @return fieldSetter
*/
private String getSetterMethodName(String fieldName) {
// 尝试从缓存中取出, 若没有则生成再放入
return setterMethodNameCache.computeIfAbsent(fieldName, n -> "set" + n.replaceFirst(n.substring(0, 1), n.substring(0, 1).toUpperCase()));
}
/**
* getter
*
* @param fieldName
* @return fieldGetter
*/
private String getGetterMethodName(String fieldName) {
return getterMethodNameCache.computeIfAbsent(fieldName, n -> "get" + n.replaceFirst(n.substring(0, 1), n.substring(0, 1).toUpperCase()));
}
/**
* Excel-JavaBean
*/
private class MappingInfo {
/**
* JavaBean
*/
private String className;
/**
* excel sheet
*/
private String sheetName = "sheet1";
/**
*
*/
private boolean boldHeading = false;
/**
* Field - Value
*/
private Map<String, String> fieldValueMapping = new LinkedHashMap<>();
/**
* Value - Field
*/
private Map<String, String> valueFieldMapping = new LinkedHashMap<>();
/**
* JavaBean
*
* @param className JavaBean
*/
void setClassName(String className) {
this.className = className;
}
/**
* mappingInfo className
*
* @return className
*/
String getClassName() {
return className;
}
/**
* sheet
*
* @param sheetName sheet
*/
void setSheetName(String sheetName) {
this.sheetName = sheetName;
}
/**
* sheet
*
* @return sheet
*/
String getSheetName() {
return sheetName;
}
/**
*
*
* @param boldHeading
*/
void setBoldHeading(boolean boldHeading) {
this.boldHeading = boldHeading;
}
/**
*
*
* @return
*/
boolean isBoldHeading() {
return boldHeading;
}
/**
* Field - Value
*
* @param field Field
* @param value Value
*/
void addFieldValueMapping(String field, String value) {
fieldValueMapping.put(field, value);
}
/**
* FieldValue
*
* @param field Field
* @return Value
*/
String getFieldValueMapping(String field) {
return fieldValueMapping.get(field);
}
/**
* Value - Field
*
* @param value Value
* @param field Field
*/
void addValueFieldMapping(String value, String field) {
valueFieldMapping.put(value, field);
}
/**
* Value Field
*
* @param value Value
* @return Field
*/
String getValueFieldMapping(String value) {
return valueFieldMapping.get(value);
}
/**
* Field - Value
*
* @return Field - Value
*/
Map<String, String> getFieldValueMapping() {
return fieldValueMapping;
}
}
}

@ -1,28 +0,0 @@
package com.ken.wms.common.util;
import org.springframework.web.multipart.MultipartFile;
import java.io.File;
import java.io.IOException;
/**
*
*
* @author Ken
* @since 2017/4/22.
*/
public class FileUtil {
/**
* org.springframework.web.multipart.MultipartFile java.io.File
*
* @param multipartFile org.springframework.web.multipart.MultipartFile
* @return java.io.File
* @throws IOException IOException
*/
public static File convertMultipartFileToFile(MultipartFile multipartFile) throws IOException {
File convertedFile = new File(multipartFile.getOriginalFilename());
multipartFile.transferTo(convertedFile);
return convertedFile;
}
}

@ -1,80 +0,0 @@
package com.ken.wms.common.util;
import org.apache.commons.collections.map.HashedMap;
import java.util.Map;
/**
* controller response
* @author ken
*
* Created by Ken on 2017/1/18.
*/
public class Response {
public static final String RESPONSE_RESULT_SUCCESS = "success";
public static final String RESPONSE_RESULT_ERROR = "error";
// response 中可能使用的值
private static final String RESPONSE_RESULT = "result";
private static final String RESPONSE_MSG = "msg";
private static final String RESPONSE_DATA = "data";
private static final String RESPONSE_TOTAL = "total";
// 存放响应中的信息
private Map<String,Object> responseContent;
// Constructor
Response() {
this.responseContent = new HashedMap(10);
}
/**
* response
* @param result response success error
*/
public void setResponseResult(String result){
this.responseContent.put(Response.RESPONSE_RESULT,result);
}
/**
* response
* @param msg response
*/
public void setResponseMsg(String msg){
this.responseContent.put(Response.RESPONSE_MSG,msg);
}
/**
* response
* @param data response
*/
public void setResponseData(Object data){
this.responseContent.put(Response.RESPONSE_DATA,data);
}
/**
* response RESPONSE_DATA 使
* @param total
*/
public void setResponseTotal(long total){
this.responseContent.put(Response.RESPONSE_TOTAL,total);
}
/**
* response
* @param key key
* @param value
*/
public void setCustomerInfo(String key, Object value){
this.responseContent.put(key,value);
}
/**
* response
* @return response Map
*/
public Map<String, Object> generateResponse(){
return this.responseContent;
}
}

@ -1,20 +0,0 @@
package com.ken.wms.common.util;
/**
* Response
*
* @author ken
* @since 2017/1/18.
*/
public class ResponseFactory {
/**
* Response
*
* @return response
*/
public static Response newInstance() {
return new Response();
}
}

@ -1,37 +0,0 @@
package com.ken.wms.dao;
import com.ken.wms.domain.AccessRecordDO;
import org.apache.ibatis.annotations.Param;
import java.util.Date;
import java.util.List;
/**
*
*
* @author Ken
* @since 2017/3/5.
*/
public interface AccessRecordMapper {
/**
*
*
* @param accessRecordDO
*/
void insertAccessRecord(AccessRecordDO accessRecordDO);
/**
* ID
*
* @param userID ID
* @param accessType
* @param startDate
* @param endDate
* @return
*/
List<AccessRecordDO> selectAccessRecords(@Param("userID") Integer userID,
@Param("accessType") String accessType,
@Param("startDate") Date startDate,
@Param("endDate") Date endDate);
}

@ -1,46 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ken.wms.dao.AccessRecordMapper">
<resultMap id="accessRecordDO" type="com.ken.wms.domain.AccessRecordDO">
<id column="RECORD_ID" property="id"/>
<result column="USER_ID" property="userID"/>
<result column="USER_NAME" property="userName"/>
<result column="ACCESS_TYPE" property="accessType"/>
<result column="ACCESS_TIME" property="accessTime"/>
<result column="ACCESS_IP" property="accessIP"/>
</resultMap>
<insert id="insertAccessRecord">
insert into wms_access_record(USER_ID, USER_NAME, ACCESS_TYPE, ACCESS_TIME, ACCESS_IP)
values(#{userID}, #{userName}, #{accessType}, #{accessTime}, #{accessIP})
</insert>
<select id="selectAccessRecords" resultMap="accessRecordDO">
select
RECORD_ID,
USER_ID,
USER_NAME,
ACCESS_TYPE,
ACCESS_TIME,
ACCESS_IP
from
wms_access_record
<where>
<if test="userID != -1">
USER_ID = #{userID}
</if>
<if test="accessType != 'all'">
and ACCESS_TYPE = #{accessType}
</if>
<if test="startDate != null">
and ACCESS_TIME >= #{startDate}
</if>
<if test="endDate != null">
<![CDATA[and ACCESS_TIME <= #{endDate}]]>
</if>
</where>
</select>
</mapper>

@ -1,73 +0,0 @@
package com.ken.wms.dao;
import com.ken.wms.domain.Customer;
import java.util.List;
/**
* Customer
* @author Ken
*
*/
public interface CustomerMapper {
/**
* Customer
* @return Customer
*/
List<Customer> selectAll();
/**
* id Supplier
* @param id CustomerID
* @return IDCustomer
*/
Customer selectById(Integer id);
/**
* Customer name customer
* @param customerName
* @return CustomerNameCustomer
*/
Customer selectByName(String customerName);
/**
* customer name Customer
* selectByName
* @param customerName Customer
* @return customerName Customer
*/
List<Customer> selectApproximateByName(String customerName);
/**
* Customer
* Customer AI
* @param customer Customer
*/
void insert(Customer customer);
/**
* Customer
* @param customers Customer List
*/
void insertBatch(List<Customer> customers);
/**
* Customer
* Customer
* @param customer customer
*/
void update(Customer customer);
/**
* id customer
* @param id customer ID
*/
void deleteById(Integer id);
/**
* customerName customer
* @param customerName
*/
void deleteByName(String customerName);
}

@ -1,106 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ken.wms.dao.CustomerMapper">
<resultMap type="com.ken.wms.domain.Customer" id="customer">
<id property="id" column="CUSTOMER_ID"/>
<result property="name" column="CUSTOMER_NAME"/>
<result property="personInCharge" column="CUSTOMER_PERSON"/>
<result property="tel" column="CUSTOMER_TEL"/>
<result property="email" column="CUSTOMER_EMAIL"/>
<result property="address" column="CUSTOMER_ADDRESS"/>
</resultMap>
<select id="selectAll" resultMap="customer">
select
c.CUSTOMER_ID,
c.CUSTOMER_NAME,
c.CUSTOMER_PERSON,
c.CUSTOMER_TEL,
c.CUSTOMER_EMAIL,
c.CUSTOMER_ADDRESS
from
wms_customer c
</select>
<select id="selectById" resultMap="customer">
select
c.CUSTOMER_ID,
c.CUSTOMER_NAME,
c.CUSTOMER_PERSON,
c.CUSTOMER_TEL,
c.CUSTOMER_EMAIL,
c.CUSTOMER_ADDRESS
from
wms_customer c
where
c.CUSTOMER_ID = #{id}
</select>
<select id="selectByName" resultMap="customer">
select
c.CUSTOMER_ID,
c.CUSTOMER_NAME,
c.CUSTOMER_PERSON,
c.CUSTOMER_TEL,
c.CUSTOMER_EMAIL,
c.CUSTOMER_ADDRESS
from
wms_customer c
where
c.CUSTOMER_NAME = #{customerName}
</select>
<select id="selectApproximateByName" resultMap="customer">
select
c.CUSTOMER_ID,
c.CUSTOMER_NAME,
c.CUSTOMER_PERSON,
c.CUSTOMER_TEL,
c.CUSTOMER_EMAIL,
c.CUSTOMER_ADDRESS
from
wms_customer c
where
c.CUSTOMER_NAME like concat(concat('%',#{customerName}),'%')
</select>
<insert id="insert">
insert into wms_customer(CUSTOMER_NAME,CUSTOMER_PERSON,CUSTOMER_TEL,CUSTOMER_EMAIL,CUSTOMER_ADDRESS)
values (#{name},#{personInCharge},#{tel},#{email},#{address})
</insert>
<insert id="insertBatch">
insert into wms_customer(CUSTOMER_NAME,CUSTOMER_PERSON,CUSTOMER_TEL,CUSTOMER_EMAIL,CUSTOMER_ADDRESS)
values
<foreach collection="list" item="customer" separator=",">
(#{customer.name},#{customer.personInCharge},#{customer.tel},#{customer.email},#{customer.address})
</foreach>
</insert>
<update id="update">
update
wms_customer
set
CUSTOMER_NAME = #{name},
CUSTOMER_PERSON = #{personInCharge},
CUSTOMER_TEL = #{tel},
CUSTOMER_EMAIL = #{email},
CUSTOMER_ADDRESS = #{address}
where
CUSTOMER_ID = #{id}
</update>
<delete id="deleteById">
delete from wms_customer
where CUSTOMER_ID = #{id}
</delete>
<delete id="deleteByName">
delete from wms_customer
where CUSTOMER_NAME = #{name}
</delete>
</mapper>

@ -1,73 +0,0 @@
package com.ken.wms.dao;
import com.ken.wms.domain.Goods;
import java.util.List;
/**
*
* @author Ken
*
*/
public interface GoodsMapper {
/**
* Goods
* @return Goods
*/
List<Goods> selectAll();
/**
* id Goods
* @param id ID
* @return IDGoods
*/
Goods selectById(Integer id);
/**
* Goods name Goods
* @param goodsName
* @return GoodsName
*/
Goods selectByName(String goodsName);
/**
* goods name goods
*
* @param goodsName
* @return goodsName
*/
List<Goods> selectApproximateByName(String goodsName);
/**
*
* @param goods
*/
void insert(Goods goods);
/**
*
* @param goods goods List
*/
void insertBatch(List<Goods> goods);
/**
* Goods
* Customer
* @param goods
*/
void update(Goods goods);
/**
* id goods
* @param id ID
*/
void deleteById(Integer id);
/**
* goods name goods
* @param goodsName
*/
void deleteByName(String goodsName);
}

@ -1,100 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ken.wms.dao.GoodsMapper">
<resultMap type="com.ken.wms.domain.Goods" id="goods">
<id property="id" column="GOOD_ID"/>
<result property="name" column="GOOD_NAME"/>
<result property="type" column="GOOD_RYPE"/>
<result property="size" column="GOOD_SIZE"/>
<result property="value" column="GOOD_VALUE"/>
</resultMap>
<select id="selectAll" resultMap="goods">
select
g.GOOD_ID,
g.GOOD_NAME,
g.GOOD_RYPE,
g.GOOD_SIZE,
g.GOOD_VALUE
from
wms_goods g
</select>
<select id="selectById" resultMap="goods">
select
g.GOOD_ID,
g.GOOD_NAME,
g.GOOD_RYPE,
g.GOOD_SIZE,
g.GOOD_VALUE
from
wms_goods g
where
g.GOOD_ID = #{id}
</select>
<select id="selectByName" resultMap="goods">
select
g.GOOD_ID,
g.GOOD_NAME,
g.GOOD_RYPE,
g.GOOD_SIZE,
g.GOOD_VALUE
from
wms_goods g
where
g.GOOD_NAME = #{goodsName}
</select>
<select id="selectApproximateByName" resultMap="goods">
select
g.GOOD_ID,
g.GOOD_NAME,
g.GOOD_RYPE,
g.GOOD_SIZE,
g.GOOD_VALUE
from
wms_goods g
where
g.GOOD_NAME like concat(concat('%',#{goodsName}),'%')
</select>
<insert id="insert">
insert into wms_goods(GOOD_NAME,GOOD_RYPE,GOOD_SIZE,GOOD_VALUE)
values (#{name},#{type},#{size},#{value})
</insert>
<insert id="insertBatch">
insert into wms_goods(GOOD_NAME,GOOD_RYPE,GOOD_SIZE,GOOD_VALUE)
values
<foreach collection="list" item="goods" separator=",">
(#{goods.name},#{goods.type},#{goods.size},#{goods.value})
</foreach>
</insert>
<update id="update">
update
wms_goods
set
GOOD_NAME = #{name},
GOOD_RYPE = #{type},
GOOD_SIZE = #{size},
GOOD_VALUE = #{value}
where
GOOD_ID = #{id}
</update>
<delete id="deleteById">
delete from wms_goods
where GOOD_ID = #{id}
</delete>
<delete id="deleteByName">
delete from wms_goods
where GOOD_NAME = #{goodsName}
</delete>
</mapper>

@ -1,65 +0,0 @@
package com.ken.wms.dao;
import com.ken.wms.domain.RepositoryAdmin;
import java.util.List;
/**
* RepositoryAdmin
* @author Ken
*
*/
public interface RepositoryAdminMapper {
/**
* ID
* @param id ID
* @return ID
*/
RepositoryAdmin selectByID(Integer id);
/**
* name
*
* @param name
* @return name
*/
List<RepositoryAdmin> selectByName(String name);
/**
*
* @return
*/
List<RepositoryAdmin> selectAll();
/**
* repositoryID
* @param repositoryID ID
* @return repositoryID
*/
RepositoryAdmin selectByRepositoryID(Integer repositoryID);
/**
*
* @param repositoryAdmin
*/
void insert(RepositoryAdmin repositoryAdmin);
/**
*
* @param repositoryAdmins List
*/
void insertBatch(List<RepositoryAdmin> repositoryAdmins);
/**
*
* @param repositoryAdmin
*/
void update(RepositoryAdmin repositoryAdmin);
/**
* ID
* @param id ID
*/
void deleteByID(Integer id);
}

@ -1,107 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ken.wms.dao.RepositoryAdminMapper">
<resultMap type="com.ken.wms.domain.RepositoryAdmin" id="repositoryAdmin">
<id property="id" column="REPO_ADMIN_ID"/>
<result property="name" column="REPO_ADMIN_NAME"/>
<result property="sex" column="REPO_ADMIN_SEX"/>
<result property="tel" column="REPO_ADMIN_TEL"/>
<result property="address" column="REPO_ADMIN_ADDRESS"/>
<result property="birth" column="REPO_ADMIN_BIRTH"/>
<result property="repositoryBelongID" column="REPO_ADMIN_REPOID"/>
</resultMap>
<select id="selectAll" resultMap="repositoryAdmin">
select
REPO_ADMIN_ID,
REPO_ADMIN_NAME,
REPO_ADMIN_SEX,
REPO_ADMIN_TEL,
REPO_ADMIN_ADDRESS,
REPO_ADMIN_BIRTH,
REPO_ADMIN_REPOID
from
wms_repo_admin
</select>
<select id="selectByID" resultMap="repositoryAdmin">
select
REPO_ADMIN_ID,
REPO_ADMIN_NAME,
REPO_ADMIN_SEX,
REPO_ADMIN_TEL,
REPO_ADMIN_ADDRESS,
REPO_ADMIN_BIRTH,
REPO_ADMIN_REPOID
from
wms_repo_admin
where
REPO_ADMIN_ID = #{id}
</select>
<select id="selectByName" resultMap="repositoryAdmin">
select
REPO_ADMIN_ID,
REPO_ADMIN_NAME,
REPO_ADMIN_SEX,
REPO_ADMIN_TEL,
REPO_ADMIN_ADDRESS,
REPO_ADMIN_BIRTH,
REPO_ADMIN_REPOID
from
wms_repo_admin
where
REPO_ADMIN_NAME like concat(concat("%",#{name}),"%")
</select>
<select id="selectByRepositoryID" resultMap="repositoryAdmin">
select
REPO_ADMIN_ID,
REPO_ADMIN_NAME,
REPO_ADMIN_SEX,
REPO_ADMIN_TEL,
REPO_ADMIN_ADDRESS,
REPO_ADMIN_BIRTH,
REPO_ADMIN_REPOID
from
wms_repo_admin
where
REPO_ADMIN_REPOID = #{repositoryID}
</select>
<insert id="insert" keyProperty="id" useGeneratedKeys="true">
insert into wms_repo_admin(REPO_ADMIN_NAME,REPO_ADMIN_SEX,REPO_ADMIN_TEL,REPO_ADMIN_ADDRESS,REPO_ADMIN_BIRTH,REPO_ADMIN_REPOID)
values(#{name},#{sex},#{tel},#{address},#{birth},#{repositoryBelongID})
</insert>
<insert id="insertBatch">
insert into wms_repo_admin(REPO_ADMIN_NAME,REPO_ADMIN_SEX,REPO_ADMIN_TEL,REPO_ADMIN_ADDRESS,REPO_ADMIN_BIRTH,REPO_ADMIN_REPOID)
values
<foreach collection="list" item="repositoryAdmin" separator=",">
(#{repositoryAdmin.name},#{repositoryAdmin.sex},#{repositoryAdmin.tel},#{repositoryAdmin.address},#{repositoryAdmin.birth},#{repositoryAdmin.repositoryBelongID})
</foreach>
</insert>
<update id="update">
update
wms_repo_admin
set
REPO_ADMIN_NAME = #{name},
REPO_ADMIN_SEX = #{sex},
REPO_ADMIN_TEL = #{tel},
REPO_ADMIN_ADDRESS = #{address},
REPO_ADMIN_BIRTH = #{birth},
REPO_ADMIN_REPOID = #{repositoryBelongID}
where
REPO_ADMIN_ID = #{id}
</update>
<delete id="deleteByID">
delete from wms_repo_admin
where REPO_ADMIN_ID = #{id}
</delete>
</mapper>

@ -1,63 +0,0 @@
package com.ken.wms.dao;
import com.ken.wms.domain.Repository;
import java.util.List;
/**
* Repository
* @author Ken
*
*/
public interface RepositoryMapper {
/**
* Repository
* @return Repository
*/
List<Repository> selectAll();
/**
* repository
* @return Repository
*/
List<Repository> selectUnassign();
/**
* Repository ID Repository
* @param repositoryID ID
* @return Repository
*/
Repository selectByID(Integer repositoryID);
/**
* repository Address repository
* @param address
* @return Repository
*/
List<Repository> selectByAddress(String address);
/**
* Repository
* @param repository
*/
void insert(Repository repository);
/**
* Repository
* @param repositories List
*/
void insertbatch(List<Repository> repositories);
/**
* Repository
* @param repository
*/
void update(Repository repository);
/**
* Repository ID Repository
* @param repositoryID ID
*/
void deleteByID(Integer repositoryID);
}

@ -1,105 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ken.wms.dao.RepositoryMapper">
<resultMap type="com.ken.wms.domain.Repository" id="repository">
<id property="id" column="REPO_ID"/>
<result property="address" column="REPO_ADDRESS"/>
<result property="status" column="REPO_STATUS"/>
<result property="area" column="REPO_AREA"/>
<result property="desc" column="REPO_DESC"/>
<result property="adminName" column="REPO_ADMIN_NAME"/>
</resultMap>
<select id="selectAll" resultMap="repository">
select
r.REPO_ID,
r.REPO_ADDRESS,
r.REPO_STATUS,
r.REPO_AREA,
r.REPO_DESC,
ra.REPO_ADMIN_NAME
from
wms_respository r left join wms_repo_admin ra on(r.REPO_ID = ra.REPO_ADMIN_REPOID)
</select>
<select id="selectUnassign" resultMap="repository">
select
r.REPO_ID,
r.REPO_ADDRESS,
r.REPO_STATUS,
r.REPO_AREA,
r.REPO_DESC
from
wms_respository r
where not exists
(
select *
from
wms_repo_admin ra
where
ra.REPO_ADMIN_REPOID = r.REPO_ID
)
</select>
<select id="selectByID" resultMap="repository">
select
r.REPO_ID,
r.REPO_ADDRESS,
r.REPO_STATUS,
r.REPO_AREA,
r.REPO_DESC,
ra.REPO_ADMIN_NAME
from
wms_respository r left join wms_repo_admin ra on(r.REPO_ID = ra.REPO_ADMIN_REPOID)
where
r.REPO_ID = #{repositoryID}
</select>
<select id="selectByAddress" resultMap="repository">
select
r.REPO_ID,
r.REPO_ADDRESS,
r.REPO_STATUS,
r.REPO_AREA,
r.REPO_DESC,
ra.REPO_ADMIN_NAME
from
wms_respository r left join wms_repo_admin ra on(r.REPO_ID = ra.REPO_ADMIN_REPOID)
where
r.REPO_ADDRESS like concat(concat("%",#{address},"%"))
</select>
<insert id="insert" keyProperty="id" useGeneratedKeys="true">
insert into wms_respository(REPO_ADDRESS,REPO_STATUS,REPO_AREA,REPO_DESC)
values(#{address},#{status},#{area},#{desc})
</insert>
<insert id="insertbatch">
insert into wms_respository(REPO_ADDRESS,REPO_STATUS,REPO_AREA,REPO_DESC)
values
<foreach collection="list" item="repository" separator=",">
(#{repository.address},#{repository.status},#{repository.area},#{repository.desc})
</foreach>
</insert>
<update id="update">
update
wms_respository
set
REPO_ADDRESS = #{address},
REPO_STATUS = #{status},
REPO_AREA = #{area},
REPO_desc = #{desc}
where
REPO_ID = #{id}
</update>
<delete id="deleteByID">
delete from wms_respository
where REPO_ID = #{id}
</delete>
</mapper>

@ -1,16 +0,0 @@
package com.ken.wms.dao;
import com.ken.wms.domain.RolePermissionDO;
import java.util.List;
/**
* Mapper
*
* @author ken
* @since 2017/2/26.
*/
public interface RolePermissionMapper {
List<RolePermissionDO> selectAll();
}

@ -1,23 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ken.wms.dao.RolePermissionMapper">
<resultMap id="rolePermission" type="com.ken.wms.domain.RolePermissionDO">
<result property="name" column="ACTION_NAME"/>
<result property="url" column="ACTION_PARAM"/>
<result property="role" column="ROLE_NAME"/>
</resultMap>
<select id="selectAll" resultMap="rolePermission">
select
ACTION_NAME, ACTION_PARAM, ROLE_NAME
from
wms_roles r, wms_action a, wms_role_action ra
where
r.ROLE_ID = ra.ROLE_ID and
a.ACTION_ID = ra.ACTION_ID
</select>
</mapper>

@ -1,17 +0,0 @@
package com.ken.wms.dao;
/**
*
* @author Ken
* @since 2017/3/1.
*/
public interface RolesMapper {
/**
* ID
* @param roleName
* @return ID
*/
Integer getRoleID(String roleName);
}

@ -1,16 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ken.wms.dao.RolesMapper">
<select id="getRoleID" resultType="java.lang.Integer">
select
ROLE_ID
from
wms_roles
where
ROLE_NAME = #{roleName}
</select>
</mapper>

@ -1,87 +0,0 @@
package com.ken.wms.dao;
import com.ken.wms.domain.StockInDO;
import org.apache.ibatis.annotations.Param;
import java.util.Date;
import java.util.List;
/**
*
*
* @author Ken
*/
public interface StockInMapper {
/**
*
*
* @return
*/
List<StockInDO> selectAll();
/**
* ID
*
* @param supplierID ID
* @return
*/
List<StockInDO> selectBySupplierId(Integer supplierID);
/**
* ID
*
* @param goodID ID
* @return
*/
List<StockInDO> selectByGoodID(Integer goodID);
/**
* ID
*
* @param repositoryID ID
* @return
*/
List<StockInDO> selectByRepositoryID(Integer repositoryID);
/**
* ID
*
* @param repositoryID ID
* @param startDate
* @param endDate
* @return
*/
List<StockInDO> selectByRepositoryIDAndDate(@Param("repositoryID") Integer repositoryID,
@Param("startDate") Date startDate,
@Param("endDate") Date endDate);
/**
* ID
*
* @param id ID
* @return ID
*/
StockInDO selectByID(Integer id);
/**
*
*
* @param stockInDO
*/
void insert(StockInDO stockInDO);
/**
*
*
* @param stockInDO
*/
void update(StockInDO stockInDO);
/**
* ID
*
* @param id ID
*/
void deleteByID(Integer id);
}

@ -1,163 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ken.wms.dao.StockInMapper">
<resultMap type="com.ken.wms.domain.StockInDO" id="stockInDO">
<id property="id" column="STOCKIN_ID"/>
<result property="supplierID" column="STOCKIN_SUPPLIER_ID"/>
<result property="supplierName" column="STOCKIN_SUPPLIER_NAME"/>
<result property="goodID" column="STOCKIN_GOOD_ID"/>
<result property="goodName" column="STOCKIN_GOOD_NAME"/>
<result property="number" column="STOCKIN_NUMBER"/>
<result property="time" column="STOCKIN_TIME"/>
<result property="personInCharge" column="STOCKIN_PERSON"/>
<result property="repositoryID" column="STOCKIN_REPOSITORY_ID"/>
</resultMap>
<select id="selectAll" resultMap="stockInDO">
select
r.RECORD_ID as STOCKIN_ID,
r.RECORD_SUPPLIERID as STOCKIN_SUPPLIER_ID,
s.SUPPLIER_NAME as STOCKIN_SUPPLIER_NAME,
r.RECORD_GOODID as STOCKIN_GOOD_ID,
g.GOOD_NAME as STOCKIN_GOOD_NAME,
r.RECORD_NUMBER as STOCKIN_NUMBER,
r.RECORD_TIME as STOCKIN_TIME,
r.RECORD_PERSON as STOCKIN_PERSON,
r.RECORD_REPOSITORYID as STOCKIN_REPOSITORY_ID
from
wms_record_in r,wms_goods g,wms_supplier s
where
r.RECORD_SUPPLIERID = s.SUPPLIER_ID and
r.RECORD_GOODID = g.GOOD_ID
</select>
<select id="selectBySupplierId" resultMap="stockInDO">
select
r.RECORD_ID as STOCKIN_ID,
r.RECORD_SUPPLIERID as STOCKIN_SUPPLIER_ID,
s.SUPPLIER_NAME as STOCKIN_SUPPLIER_NAME,
r.RECORD_GOODID as STOCKIN_GOOD_ID,
g.GOOD_NAME as STOCKIN_GOOD_NAME,
r.RECORD_NUMBER as STOCKIN_NUMBER,
r.RECORD_TIME as STOCKIN_TIME,
r.RECORD_PERSON as STOCKIN_PERSON,
r.RECORD_REPOSITORYID as STOCKIN_REPOSITORY_ID
from
wms_record_in r,wms_goods g,wms_supplier s
where
r.RECORD_SUPPLIERID = s.SUPPLIER_ID and
r.RECORD_GOODID = g.GOOD_ID and
r.RECORD_SUPPLIERID = #{supplierID}
</select>
<select id="selectByGoodID" resultMap="stockInDO">
select
r.RECORD_ID as STOCKIN_ID,
r.RECORD_SUPPLIERID as STOCKIN_SUPPLIER_ID,
s.SUPPLIER_NAME as STOCKIN_SUPPLIER_NAME,
r.RECORD_GOODID as STOCKIN_GOOD_ID,
g.GOOD_NAME as STOCKIN_GOOD_NAME,
r.RECORD_NUMBER as STOCKIN_NUMBER,
r.RECORD_TIME as STOCKIN_TIME,
r.RECORD_PERSON as STOCKIN_PERSON,
r.RECORD_REPOSITORYID as STOCKIN_REPOSITORY_ID
from
wms_record_in r,wms_goods g,wms_supplier s
where
r.RECORD_SUPPLIERID = s.SUPPLIER_ID and
r.RECORD_GOODID = g.GOOD_ID and
r.RECORD_GOODID = #{goodID}
</select>
<select id="selectByID" resultMap="stockInDO">
select
r.RECORD_ID as STOCKIN_ID,
r.RECORD_SUPPLIERID as STOCKIN_SUPPLIER_ID,
s.SUPPLIER_NAME as STOCKIN_SUPPLIER_NAME,
r.RECORD_GOODID as STOCKIN_GOOD_ID,
g.GOOD_NAME as STOCKIN_GOOD_NAME,
r.RECORD_NUMBER as STOCKIN_NUMBER,
r.RECORD_TIME as STOCKIN_TIME,
r.RECORD_PERSON as STOCKIN_PERSON,
r.RECORD_REPOSITORYID as STOCKIN_REPOSITORY_ID
from
wms_record_in r,wms_goods g,wms_supplier s
where
r.RECORD_SUPPLIERID = s.SUPPLIER_ID and
r.RECORD_GOODID = g.GOOD_ID and
r.RECORD_ID = #{id}
</select>
<select id="selectByRepositoryID" resultMap="stockInDO">
select
r.RECORD_ID as STOCKIN_ID,
r.RECORD_SUPPLIERID as STOCKIN_SUPPLIER_ID,
s.SUPPLIER_NAME as STOCKIN_SUPPLIER_NAME,
r.RECORD_GOODID as STOCKIN_GOOD_ID,
g.GOOD_NAME as STOCKIN_GOOD_NAME,
r.RECORD_NUMBER as STOCKIN_NUMBER,
r.RECORD_TIME as STOCKIN_TIME,
r.RECORD_PERSON as STOCKIN_PERSON,
r.RECORD_REPOSITORYID as STOCKIN_REPOSITORY_ID
from
wms_record_in r,wms_goods g,wms_supplier s
where
r.RECORD_SUPPLIERID = s.SUPPLIER_ID and
r.RECORD_GOODID = g.GOOD_ID and
r.RECORD_REPOSITORYID = #{repositoryID}
</select>
<select id="selectByRepositoryIDAndDate" resultMap="stockInDO">
select
r.RECORD_ID as STOCKIN_ID,
r.RECORD_SUPPLIERID as STOCKIN_SUPPLIER_ID,
s.SUPPLIER_NAME as STOCKIN_SUPPLIER_NAME,
r.RECORD_GOODID as STOCKIN_GOOD_ID,
g.GOOD_NAME as STOCKIN_GOOD_NAME,
r.RECORD_NUMBER as STOCKIN_NUMBER,
r.RECORD_TIME as STOCKIN_TIME,
r.RECORD_PERSON as STOCKIN_PERSON,
r.RECORD_REPOSITORYID as STOCKIN_REPOSITORY_ID
from
wms_record_in r,wms_goods g,wms_supplier s
where
r.RECORD_SUPPLIERID = s.SUPPLIER_ID and
r.RECORD_GOODID = g.GOOD_ID
<if test="repositoryID > 0">
and r.RECORD_REPOSITORYID = #{repositoryID}
</if>
<if test="startDate != null">
and r.RECORD_TIME >= #{startDate}
</if>
<if test="endDate != null">
<![CDATA[and r.RECORD_TIME <= #{endDate}]]>
</if>
</select>
<insert id="insert">
insert into wms_record_in(RECORD_SUPPLIERID,RECORD_GOODID,RECORD_NUMBER,RECORD_TIME,RECORD_PERSON,RECORD_REPOSITORYID)
values(#{supplierID},#{goodID},#{number},#{time},#{personInCharge},#{repositoryID})
</insert>
<update id="update">
update
wms_record_in
set
RECORD_SUPPLIERID = #{supplierID},
RECORD_GOODID = #{goodID},
RECORD_NUMBER = #{number},
RECORD_TIME = #{time},
RECORD_PERSON = #{personInCharge}
where
RECORD_ID = #{id}
</update>
<delete id="deleteByID">
delete from wms_record_in
where RECORD_ID = #{id}
</delete>
</mapper>

@ -1,87 +0,0 @@
package com.ken.wms.dao;
import com.ken.wms.domain.StockOutDO;
import org.apache.ibatis.annotations.Param;
import java.util.Date;
import java.util.List;
/**
*
*
* @author Ken
*/
public interface StockOutMapper {
/**
*
*
* @return
*/
List<StockOutDO> selectAll();
/**
* ID
*
* @param customerId ID
* @return
*/
List<StockOutDO> selectByCustomerId(Integer customerId);
/**
* ID
*
* @param goodId ID
* @return ID
*/
List<StockOutDO> selectByGoodId(Integer goodId);
/**
* ID
*
* @param repositoryID ID
* @return ID
*/
List<StockOutDO> selectByRepositoryID(Integer repositoryID);
/**
* ID
*
* @param repositoryID ID
* @param startDate
* @param endDate
* @return
*/
List<StockOutDO> selectByRepositoryIDAndDate(@Param("repositoryID") Integer repositoryID,
@Param("startDate") Date startDate,
@Param("endDate") Date endDate);
/**
* ID
*
* @param id ID
* @return ID
*/
StockOutDO selectById(Integer id);
/**
*
*
* @param stockOutDO
*/
void insert(StockOutDO stockOutDO);
/**
*
*
* @param stockOutDO
*/
void update(StockOutDO stockOutDO);
/**
* ID
*
* @param id ID
*/
void deleteById(Integer id);
}

@ -1,163 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ken.wms.dao.StockOutMapper">
<resultMap type="com.ken.wms.domain.StockOutDO" id="stockOutDO">
<id property="id" column="STOCKOUT_ID"/>
<result property="customerID" column="STOCKOUT_CUSTOMER_ID"/>
<result property="customerName" column="STOCKOUT_CUSTOMER_NAME"/>
<result property="goodID" column="STOCKOUT_GOOD_ID"/>
<result property="goodName" column="STOCKOUT_GOOD_NAME"/>
<result property="number" column="STOCKOUT_NUMBER"/>
<result property="time" column="STOCKOUT_TIME"/>
<result property="personInCharge" column="STOCKOUT_PERSON"/>
<result property="repositoryID" column="STOCKOUT_REPOSITORY_ID"/>
</resultMap>
<select id="selectAll" resultMap="stockOutDO">
select
r.RECORD_ID as STOCKOUT_ID,
r.RECORD_CUSTOMERID as STOCKOUT_CUSTOMER_ID,
c.CUSTOMER_NAME as STOCKOUT_CUSTOMER_NAME,
r.RECORD_GOODID as STOCKOUT_GOOD_ID,
g.GOOD_NAME as STOCKOUT_GOOD_NAME,
r.RECORD_NUMBER as STOCKOUT_NUMBER,
r.RECORD_TIME as STOCKOUT_TIME,
r.RECORD_PERSON as STOCKOUT_PERSON,
r.RECORD_REPOSITORYID asSTOCKOUT_REPOSITORY_ID
from
wms_record_out r,wms_goods g,wms_customer c
where
r.RECORD_CUSTOMERID = c.CUSTOMER_ID and
r.RECORD_GOODID = g.GOOD_ID
</select>
<select id="selectByCustomerId" resultMap="stockOutDO">
select
r.RECORD_ID as STOCKOUT_ID,
r.RECORD_CUSTOMERID as STOCKOUT_CUSTOMER_ID,
c.CUSTOMER_NAME as STOCKOUT_CUSTOMER_NAME,
r.RECORD_GOODID as STOCKOUT_GOOD_ID,
g.GOOD_NAME as STOCKOUT_GOOD_NAME,
r.RECORD_NUMBER as STOCKOUT_NUMBER,
r.RECORD_TIME as STOCKOUT_TIME,
r.RECORD_PERSON as STOCKOUT_PERSON,
r.RECORD_REPOSITORYID asSTOCKOUT_REPOSITORY_ID
from
wms_record_out r,wms_goods g,wms_customer c
where
r.RECORD_CUSTOMERID = c.CUSTOMER_ID and
r.RECORD_GOODID = g.GOOD_ID and
r.RECORD_CUSTOMERID = #{customerId}
</select>
<select id="selectByGoodId" resultMap="stockOutDO">
select
r.RECORD_ID as STOCKOUT_ID,
r.RECORD_CUSTOMERID as STOCKOUT_CUSTOMER_ID,
c.CUSTOMER_NAME as STOCKOUT_CUSTOMER_NAME,
r.RECORD_GOODID as STOCKOUT_GOOD_ID,
g.GOOD_NAME as STOCKOUT_GOOD_NAME,
r.RECORD_NUMBER as STOCKOUT_NUMBER,
r.RECORD_TIME as STOCKOUT_TIME,
r.RECORD_PERSON as STOCKOUT_PERSON,
r.RECORD_REPOSITORYID asSTOCKOUT_REPOSITORY_ID
from
wms_record_out r,wms_goods g,wms_customer c
where
r.RECORD_CUSTOMERID = c.CUSTOMER_ID and
r.RECORD_GOODID = g.GOOD_ID and
r.RECORD_GOODID = #{goodId}
</select>
<select id="selectById" resultMap="stockOutDO">
select
r.RECORD_ID as STOCKOUT_ID,
r.RECORD_CUSTOMERID as STOCKOUT_CUSTOMER_ID,
c.CUSTOMER_NAME as STOCKOUT_CUSTOMER_NAME,
r.RECORD_GOODID as STOCKOUT_GOOD_ID,
g.GOOD_NAME as STOCKOUT_GOOD_NAME,
r.RECORD_NUMBER as STOCKOUT_NUMBER,
r.RECORD_TIME as STOCKOUT_TIME,
r.RECORD_PERSON as STOCKOUT_PERSON,
r.RECORD_REPOSITORYID asSTOCKOUT_REPOSITORY_ID
from
wms_record_out r,wms_goods g,wms_customer c
where
r.RECORD_CUSTOMERID = c.CUSTOMER_ID and
r.RECORD_GOODID = g.GOOD_ID and
r.RECORD_ID = #{id}
</select>
<select id="selectByRepositoryID" resultMap="stockOutDO">
select
r.RECORD_ID as STOCKOUT_ID,
r.RECORD_CUSTOMERID as STOCKOUT_CUSTOMER_ID,
c.CUSTOMER_NAME as STOCKOUT_CUSTOMER_NAME,
r.RECORD_GOODID as STOCKOUT_GOOD_ID,
g.GOOD_NAME as STOCKOUT_GOOD_NAME,
r.RECORD_NUMBER as STOCKOUT_NUMBER,
r.RECORD_TIME as STOCKOUT_TIME,
r.RECORD_PERSON as STOCKOUT_PERSON,
r.RECORD_REPOSITORYID as STOCKOUT_REPOSITORY_ID
from
wms_record_out r,wms_goods g,wms_customer c
where
r.RECORD_CUSTOMERID = c.CUSTOMER_ID and
r.RECORD_GOODID = g.GOOD_ID and
r.RECORD_REPOSITORYID = 1007
</select>
<select id="selectByRepositoryIDAndDate" resultMap="stockOutDO">
select
r.RECORD_ID as STOCKOUT_ID,
r.RECORD_CUSTOMERID as STOCKOUT_CUSTOMER_ID,
c.CUSTOMER_NAME as STOCKOUT_CUSTOMER_NAME,
r.RECORD_GOODID as STOCKOUT_GOOD_ID,
g.GOOD_NAME as STOCKOUT_GOOD_NAME,
r.RECORD_NUMBER as STOCKOUT_NUMBER,
r.RECORD_TIME as STOCKOUT_TIME,
r.RECORD_PERSON as STOCKOUT_PERSON,
r.RECORD_REPOSITORYID as STOCKOUT_REPOSITORY_ID
from
wms_record_out r,wms_goods g,wms_customer c
where
r.RECORD_CUSTOMERID = c.CUSTOMER_ID and
r.RECORD_GOODID = g.GOOD_ID
<if test="repositoryID > 0">
and r.RECORD_REPOSITORYID = #{repositoryID}
</if>
<if test="startDate != null">
and r.RECORD_TIME >= #{startDate}
</if>
<if test="endDate != null">
<![CDATA[and r.RECORD_TIME <= #{endDate}]]>
</if>
</select>
<insert id="insert">
insert into wms_record_out(RECORD_CUSTOMERID,RECORD_GOODID,RECORD_NUMBER,RECORD_TIME,RECORD_PERSON,RECORD_REPOSITORYID)
values(#{customerID},#{goodID},#{number},#{time},#{personInCharge},#{repositoryID})
</insert>
<update id="update">
update
wms_record_out
set
RECORD_CUSTOMERID = #{customerID},
RECORD_GOODID = #{goodID},
RECORD_NUMBER = #{number},
RECORD_TIME = #{time},
RECORD_PERSON = #{personInCharge}
where
RECORD_ID = #{id}
</update>
<delete id="deleteById">
delete from wms_record_out
where RECORD_ID = #{id}
</delete>
</mapper>

@ -1,84 +0,0 @@
package com.ken.wms.dao;
import com.ken.wms.domain.Storage;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
*
* @author Ken
*
*/
public interface StorageMapper {
/**
*
* @return
*/
List<Storage> selectAllAndRepositoryID(@Param("repositoryID") Integer repositoryID);
/**
* IDID
* @param goodsID ID
* @param repositoryID ID
* @return IDID
*/
List<Storage> selectByGoodsIDAndRepositoryID(@Param("goodsID") Integer goodsID,
@Param("repositoryID") Integer repositoryID);
/**
*
* @param goodsName
* @return
*/
List<Storage> selectByGoodsNameAndRepositoryID(@Param("goodsName") String goodsName,
@Param("repositoryID") Integer repositoryID);
/**
*
* @param goodsType
* @return
*/
List<Storage> selectByGoodsTypeAndRepositoryID(@Param("goodsType") String goodsType,
@Param("repositoryID") Integer repositoryID);
/**
*
*
* @param storage
*/
void update(Storage storage);
/**
*
* @param storage
*/
void insert(Storage storage);
/**
*
* @param storages
*/
void insertBatch(List<Storage> storages);
/**
* ID
* @param goodsID ID
*/
void deleteByGoodsID(Integer goodsID);
/**
*
* @param repositoryID ID
*/
void deleteByRepositoryID(Integer repositoryID);
/**
*
* @param goodsID ID
* @param repositoryID ID
*/
void deleteByRepositoryIDAndGoodsID(@Param("goodsID") Integer goodsID, @Param("repositoryID") Integer repositoryID);
}

@ -1,168 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ken.wms.dao.StorageMapper">
<!-- 结果映射 -->
<resultMap type="com.ken.wms.domain.Storage" id="storage">
<id property="goodsID" column="goodsID"/>
<result property="goodsName" column="goodsName"/>
<result property="goodsSize" column="goodsSize"/>
<result property="goodsType" column="goodsType"/>
<result property="goodsValue" column="goodsValue"/>
<result property="repositoryID" column="repositoryID"/>
<result property="number" column="number"/>
<!--
<association property="goodsInfo" javaType="com.ken.Goods" resultMap="goods"/>
-->
</resultMap>
<!--
<resultMap type="com.ken.Goods" id="goods">
<id property="id" column="goodsID"/>
<result property="name" column="goodsName"/>
<result property="size" column="goodsSize"/>
<result property="type" column="goodsType"/>
<result property="value" column="goodsValue"/>
</resultMap>
-->
<select id="selectAllAndRepositoryID" resultMap="storage">
select
r.REPO_ID as repositoryID,
s.RECORD_NUMBER as number,
g.GOOD_ID as goodsID,
g.GOOD_NAME as goodsName,
g.GOOD_RYPE as goodsType,
g.GOOD_SIZE as goodsSize,
g.GOOD_VALUE as goodsValue
from
wms_record_storage s,wms_respository r, wms_goods g
where
s.RECORD_GOODID = g.GOOD_ID and
s.RECORD_REPOSITORY = r.REPO_ID
<if test="repositoryID > 0">
and r.REPO_ID = #{repositoryID}
</if>
</select>
<select id="selectByGoodsIDAndRepositoryID" resultMap="storage">
select
r.REPO_ID as repositoryID,
s.RECORD_NUMBER as number,
g.GOOD_ID as goodsID,
g.GOOD_NAME as goodsName,
g.GOOD_RYPE as goodsType,
g.GOOD_SIZE as goodsSize,
g.GOOD_VALUE as goodsValue
from
wms_record_storage s,wms_respository r, wms_goods g
where
s.RECORD_GOODID = g.GOOD_ID and
s.RECORD_REPOSITORY = r.REPO_ID and
g.GOOD_ID = #{goodsID}
<if test="repositoryID > 0">
and r.REPO_ID = #{repositoryID}
</if>
</select>
<select id="selectByGoodsNameAndRepositoryID" resultMap="storage">
select
r.REPO_ID as repositoryID,
s.RECORD_NUMBER as number,
g.GOOD_ID as goodsID,
g.GOOD_NAME as goodsName,
g.GOOD_RYPE as goodsType,
g.GOOD_SIZE as goodsSize,
g.GOOD_VALUE as goodsValue
from
wms_record_storage s,wms_respository r, wms_goods g
where
s.RECORD_GOODID = g.GOOD_ID and
s.RECORD_REPOSITORY = r.REPO_ID and
g.GOOD_NAME like concat("%",concat(#{goodsName},"%"))
<if test="repositoryID > 0">
and r.REPO_ID = #{repositoryID}
</if>
</select>
<select id="selectByGoodsTypeAndRepositoryID" resultMap="storage">
select
r.REPO_ID as repositoryID,
s.RECORD_NUMBER as number,
g.GOOD_ID as goodsID,
g.GOOD_NAME as goodsName,
g.GOOD_RYPE as goodsType,
g.GOOD_SIZE as goodsSize,
g.GOOD_VALUE as goodsValue
from
wms_record_storage s,wms_respository r, wms_goods g
where
s.RECORD_GOODID = g.GOOD_ID and
s.RECORD_REPOSITORY = r.REPO_ID and
g.GOOD_RYPE like concat("%",concat(#{goodsType},"%"))
<if test="repositoryID > 0">
and r.REPO_ID = #{repositoryID}
</if>
</select>
<update id="update">
update
wms_record_storage
set
RECORD_GOODID = #{goodsID},
RECORD_REPOSITORY = #{repositoryID},
RECORD_NUMBER = #{number}
where
RECORD_GOODID = #{goodsID} and
RECORD_REPOSITORY = #{repositoryID}
</update>
<insert id="insert">
insert into wms_record_storage
(
RECORD_GOODID,
RECORD_REPOSITORY,
RECORD_NUMBER
)
values
(
#{goodsID},
#{repositoryID},
#{number}
)
</insert>
<insert id="insertBatch">
insert into wms_record_storage(RECORD_GOODID,RECORD_REPOSITORY,RECORD_NUMBER)
values
<foreach collection="list" item="storage" separator=",">
(
#{storage.goodsID},#{storage.repositoryID},#{storage.number})
</foreach>
</insert>
<delete id="deleteByGoodsID">
delete from
wms_record_storage
where
RECORD_GOODID = #{goodsID}
</delete>
<delete id="deleteByRepositoryID">
delete from
wms_record_storage
where
wms_record_storage.RECORD_REPOSITORY = #{repositoryID}
</delete>
<delete id="deleteByRepositoryIDAndGoodsID">
delete from
wms_record_storage
where
RECORD_GOODID = #{goodsID} and
wms_record_storage.RECORD_REPOSITORY = #{repositoryID}
</delete>
</mapper>

@ -1,74 +0,0 @@
package com.ken.wms.dao;
import com.ken.wms.domain.Supplier;
import java.util.List;
/**
* Supplier
* @author Ken
*
*/
public interface SupplierMapper {
/**
* Supplier
* @return
*/
List<Supplier> selectAll();
/**
* id Supplier
* @param id ID
* @return ID
*/
Supplier selectById(Integer id);
/**
* supplier name Supplier
* @param supplierName
* @return supplierName
*/
Supplier selectBuName(String supplierName);
/**
* supplier name Supplier
* selectBuName
* @param supplierName
* @return supplierName
*/
List<Supplier> selectApproximateByName(String supplierName);
/**
* Supplier
* Supplier AI
* @param supplier Supplier
*/
void insert(Supplier supplier);
/**
* Supplier
* @param suppliers Supplier Lists
*/
void insertBatch(List<Supplier> suppliers);
/**
* Supplier
* Supplier
* @param supplier Supplier
*/
void update(Supplier supplier);
/**
* id Supplier
* @param id ID
*/
void deleteById(Integer id);
/**
* supplierName Supplier
* @param supplierName
*/
void deleteByName(String supplierName);
}

@ -1,106 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ken.wms.dao.SupplierMapper">
<resultMap type="com.ken.wms.domain.Supplier" id="supplier">
<id property="id" column="SUPPLIER_ID"/>
<result property="name" column="SUPPLIER_NAME"/>
<result property="personInCharge" column="SUPPLIER_PERSON"/>
<result property="tel" column="SUPPLIER_TEL"/>
<result property="email" column="SUPPLIER_EMAIL"/>
<result property="address" column="SUPPLIER_ADDRESS"/>
</resultMap>
<select id="selectAll" resultMap="supplier">
select
s.SUPPLIER_ID,
s.SUPPLIER_NAME,
s.SUPPLIER_PERSON,
s.SUPPLIER_TEL,
s.SUPPLIER_EMAIL,
s.SUPPLIER_ADDRESS
from
wms_supplier s
</select>
<select id="selectById" resultMap="supplier">
select
s.SUPPLIER_ID,
s.SUPPLIER_NAME,
s.SUPPLIER_PERSON,
s.SUPPLIER_TEL,
s.SUPPLIER_EMAIL,
s.SUPPLIER_ADDRESS
from
wms_supplier s
where
s.SUPPLIER_ID = #{id}
</select>
<select id="selectBuName" resultMap="supplier">
select
s.SUPPLIER_ID,
s.SUPPLIER_NAME,
s.SUPPLIER_PERSON,
s.SUPPLIER_TEL,
s.SUPPLIER_EMAIL,
s.SUPPLIER_ADDRESS
from
wms_supplier s
where
s.SUPPLIER_NAME = #{supplierName}
</select>
<select id="selectApproximateByName" resultMap="supplier">
select
s.SUPPLIER_ID,
s.SUPPLIER_NAME,
s.SUPPLIER_PERSON,
s.SUPPLIER_TEL,
s.SUPPLIER_EMAIL,
s.SUPPLIER_ADDRESS
from
wms_supplier s
where
s.SUPPLIER_NAME like concat(concat('%',#{supplierName}),'%')
</select>
<insert id="insert" keyProperty="id" useGeneratedKeys="true">
insert into wms_supplier(SUPPLIER_NAME,SUPPLIER_PERSON,SUPPLIER_TEL,SUPPLIER_EMAIL,SUPPLIER_ADDRESS)
values(#{name},#{personInCharge},#{tel},#{email},#{address})
</insert>
<insert id="insertBatch">
insert into wms_supplier(SUPPLIER_NAME,SUPPLIER_PERSON,SUPPLIER_TEL,SUPPLIER_EMAIL,SUPPLIER_ADDRESS)
values
<foreach collection="list" item="supplier" separator=",">
(#{supplier.name},#{supplier.personInCharge},#{supplier.tel},#{supplier.email},#{supplier.address})
</foreach>
</insert>
<update id="update">
update
wms_supplier
set
SUPPLIER_NAME = #{name},
SUPPLIER_PERSON = #{personInCharge},
SUPPLIER_TEL = #{tel},
SUPPLIER_EMAIL = #{email},
SUPPLIER_ADDRESS = #{address}
where
SUPPLIER_ID = #{id}
</update>
<delete id="deleteById">
delete from wms_supplier
where SUPPLIER_ID = #{id}
</delete>
<delete id="deleteByName">
delete from wms_supplier
where SUPPLIER_NAME = #{name}
</delete>
</mapper>

@ -1,61 +0,0 @@
package com.ken.wms.dao;
import com.ken.wms.domain.UserInfoDO;
import java.util.List;
/**
* Mapper
*
* @author ken
* @since 2017/2/26.
*/
public interface UserInfoMapper {
/**
* id user
*
* @param userID ID
* @return userID user
*/
UserInfoDO selectByUserID(Integer userID);
/**
* userName user
*
* @param userName
* @return userName user
*/
UserInfoDO selectByName(String userName);
/**
* user
*
* @return user
*/
List<UserInfoDO> selectAll();
/**
* user
*
* @param user user
*/
void update(UserInfoDO user);
/**
* id user
*
* @param id ID
*/
void deleteById(Integer id);
/**
* user
* id
*
* @param user
*/
void insert(UserInfoDO user);
}

@ -1,68 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ken.wms.dao.UserInfoMapper">
<resultMap id="user" type="com.ken.wms.domain.UserInfoDO">
<result property="userID" column="USER_ID"/>
<result property="userName" column="USER_USERNAME"/>
<result property="password" column="USER_PASSWORD"/>
<result property="firstLogin" column="USER_FIRST_LOGIN"/>
</resultMap>
<select id="selectByUserID" resultMap="user">
select
u.USER_ID,
u.USER_USERNAME,
u.USER_PASSWORD,
u.USER_FIRST_LOGIN
from
wms_user u
where
u.USER_ID = #{userID}
</select>
<select id="selectByName" resultMap="user">
select
s.USER_ID,
s.USER_USERNAME,
s.USER_PASSWORD,
s.USER_FIRST_LOGIN
from
wms_user s
where
s.USER_USERNAME = #{userName}
</select>
<select id="selectAll" resultMap="user">
select
s.USER_ID,
s.USER_USERNAME,
s.USER_PASSWORD,
s.USER_FIRST_LOGIN
from
wms_user s
</select>
<insert id="insert" useGeneratedKeys="true">
insert into wms_user(USER_ID,USER_USERNAME,USER_PASSWORD, USER_FIRST_LOGIN)
values (#{userID},#{userName},#{password}, #{firstLogin})
</insert>
<update id="update">
update wms_user set
USER_USERNAME = #{userName},
USER_PASSWORD = #{password},
USER_FIRST_LOGIN = #{firstLogin}
where
USER_ID = #{userID}
</update>
<delete id="deleteById">
delete from wms_user
where
USER_ID = #{userID}
</delete>
</mapper>

@ -1,35 +0,0 @@
package com.ken.wms.dao;
import com.ken.wms.domain.UserOperationRecordDO;
import org.apache.ibatis.annotations.Param;
import java.util.Date;
import java.util.List;
/**
* Mapper
*
* @author Ken
* @since 2017/4/9.
*/
public interface UserOperationRecordMapper {
/**
* ID
*
* @param userID ID
* @param startDate
* @param endDate
* @return
*/
List<UserOperationRecordDO> selectUserOperationRecord(@Param("userID") Integer userID,
@Param("startDate") Date startDate,
@Param("endDate") Date endDate);
/**
*
*
* @param userOperationRecordDO
*/
void insertUserOperationRecord(UserOperationRecordDO userOperationRecordDO);
}

@ -1,42 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ken.wms.dao.UserOperationRecordMapper">
<resultMap id="userOperationRecord" type="com.ken.wms.domain.UserOperationRecordDO">
<id property="id" column="RECORD_ID"/>
<result property="userID" column="USER_ID"/>
<result property="userName" column="USER_NAME"/>
<result property="operationName" column="OPERATION_NAME"/>
<result property="operationTime" column="OPERATION_TIME"/>
<result property="operationResult" column="OPERATION_RESULT"/>
</resultMap>
<select id="selectUserOperationRecord" resultMap="userOperationRecord">
select
RECORD_ID,
USER_ID,
USER_NAME,
OPERATION_NAME,
OPERATION_TIME,
OPERATION_RESULT
from
wms_operation_record
<where>
<if test="userID > 0">
USER_ID = #{userID}
</if>
<if test="startDate != null">
and OPERATION_TIME >= #{startDate}
</if>
<if test="endDate != null">
<![CDATA[and OPERATION_TIME <= #{endDate}]]>
</if>
</where>
</select>
<insert id="insertUserOperationRecord">
insert into wms_operation_record(USER_ID, USER_NAME, OPERATION_NAME, OPERATION_TIME, OPERATION_RESULT)
values(#{userID}, #{userName}, #{operationName}, #{operationTime}, #{operationResult})
</insert>
</mapper>

@ -1,34 +0,0 @@
package com.ken.wms.dao;
import com.ken.wms.domain.RoleDO;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
*
* @author Ken
*
*/
public interface UserPermissionMapper {
/**
* userID roleID
* @param userID ID
* @param roleID ID
*/
void insert(@Param("userID") Integer userID, @Param("roleID") Integer roleID);
/**
*
* @param userID ID
*/
void deleteByUserID(Integer userID);
/**
* userID
* @param userID ID
* @return userID
*/
List<RoleDO> selectUserRole(Integer userID);
}

@ -1,35 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ken.wms.dao.UserPermissionMapper">
<resultMap id="role" type="com.ken.wms.domain.RoleDO">
<id property="id" column="ROLE_ID"/>
<result property="roleName" column="ROLE_NAME"/>
<result property="roleDesc" column="ROLE_DESC"/>
</resultMap>
<select id="selectUserRole" resultMap="role">
select
r.ROLE_ID,
r.ROLE_NAME,
r.ROLE_DESC
from
wms_roles r, wms_user_role ur
where
r.ROLE_ID = ur.ROLE_ID and
ur.USER_ID = #{userID}
</select>
<insert id="insert">
insert into wms_user_role(ROLE_ID,USER_ID)
values(#{roleID},#{userID})
</insert>
<delete id="deleteByUserID">
delete from wms_user_role
where USER_ID = #{userID}
</delete>
</mapper>

@ -1,104 +0,0 @@
package com.ken.wms.domain;
import java.io.Serializable;
import java.util.Date;
/**
*
*
* @author Ken
* @since 2017/3/5.
*/
public class AccessRecordDO implements Serializable {
/**
* ID
*
*/
private Integer id;
/**
* ID
*/
private Integer userID;
/**
*
*/
private String userName;
/**
*
*/
private String accessType;
/**
*
*/
private Date accessTime;
/**
* IP
*/
private String accessIP;
public Integer getId() {
return id;
}
public Integer getUserID() {
return userID;
}
public String getUserName() {
return userName;
}
public String getAccessIP() {
return accessIP;
}
public String getAccessType() {
return accessType;
}
public Date getAccessTime() {
return accessTime;
}
public void setId(Integer id) {
this.id = id;
}
public void setUserID(Integer userID) {
this.userID = userID;
}
public void setUserName(String userName) {
this.userName = userName;
}
public void setAccessType(String accessType) {
this.accessType = accessType;
}
public void setAccessTime(Date accessTime) {
this.accessTime = accessTime;
}
public void setAccessIP(String accessIP) {
this.accessIP = accessIP;
}
@Override
public String toString() {
return "AccessRecordDO{" +
"id=" + id +
", userID=" + userID +
", userName='" + userName + '\'' +
", accessType='" + accessType + '\'' +
", accessTime=" + accessTime +
", accessIP='" + accessIP + '\'' +
'}';
}
}

@ -1,102 +0,0 @@
package com.ken.wms.domain;
import java.io.Serializable;
/**
* DTO
*
* @author Ken
* @since 2017/4/8.
*/
public class AccessRecordDTO implements Serializable {
/**
* ID
*/
private Integer id;
/**
* ID
*/
private Integer userID;
/**
*
*/
private String userName;
/**
*
*/
private String accessTime;
/**
* IP
*/
private String accessIP;
/**
*
*/
private String accessType;
public Integer getId() {
return id;
}
public Integer getUserID() {
return userID;
}
public String getUserName() {
return userName;
}
public String getAccessTime() {
return accessTime;
}
public String getAccessIP() {
return accessIP;
}
public String getAccessType() {
return accessType;
}
public void setId(Integer id) {
this.id = id;
}
public void setUserID(Integer userID) {
this.userID = userID;
}
public void setUserName(String userName) {
this.userName = userName;
}
public void setAccessTime(String accessTime) {
this.accessTime = accessTime;
}
public void setAccessIP(String accessIP) {
this.accessIP = accessIP;
}
public void setAccessType(String accessType) {
this.accessType = accessType;
}
@Override
public String toString() {
return "AccessRecordDTO{" +
"id=" + id +
", userID=" + userID +
", userName='" + userName + '\'' +
", accessTime='" + accessTime + '\'' +
", accessIP='" + accessIP + '\'' +
", accessType='" + accessType + '\'' +
'}';
}
}

@ -1,73 +0,0 @@
package com.ken.wms.domain;
import java.io.Serializable;
/**
*
* @author Ken
*
*/
public class Customer implements Serializable {
private Integer id;// 客户ID
private String name;// 客户名
private String personInCharge;// 负责人
private String tel;// 联系电话
private String email;// 电子邮件
private String address;// 地址
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPersonInCharge() {
return personInCharge;
}
public void setPersonInCharge(String personInCharge) {
this.personInCharge = personInCharge;
}
public String getTel() {
return tel;
}
public void setTel(String tel) {
this.tel = tel;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
@Override
public String toString() {
return "Customer [id=" + id + ", name=" + name + ", personInCharge=" + personInCharge + ", tel=" + tel
+ ", email=" + email + ", address=" + address + "]";
}
}

@ -1,63 +0,0 @@
package com.ken.wms.domain;
import java.io.Serializable;
/**
*
* @author Ken
*
*/
public class Goods implements Serializable {
private Integer id;// 货物ID
private String name;// 货物名
private String type;// 货物类型
private String size;// 货物规格
private Double value;// 货物价值
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getSize() {
return size;
}
public void setSize(String size) {
this.size = size;
}
public Double getValue() {
return value;
}
public void setValue(Double value) {
this.value = value;
}
@Override
public String toString() {
return "Goods [id=" + id + ", name=" + name + ", type=" + type + ", size=" + size + ", value=" + value + "]";
}
}

@ -1,82 +0,0 @@
package com.ken.wms.domain;
import java.io.Serializable;
/**
*
* @author Ken
*
*/
public class Repository implements Serializable {
private Integer id;// 仓库ID
private String address;// 仓库地址
private String status;// 仓库状态
private String area;// 仓库面积
private String desc;// 仓库描述
private Integer adminID;//仓库管理员ID
private String adminName; //仓库管理员名字
public Integer getAdminID() {
return adminID;
}
public void setAdminID(Integer adminID) {
this.adminID = adminID;
}
public String getArea() {
return area;
}
public void setArea(String area) {
this.area = area;
}
public String getDesc() {
return desc;
}
public void setDesc(String desc) {
this.desc = desc;
}
public String getAdminName() {
return adminName;
}
public void setAdminName(String adminName) {
this.adminName = adminName;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
@Override
public String toString() {
return "Repository [id=" + id + ", address=" + address + ", status=" + status + ", area=" + area + ", desc="
+ desc + ", adminID=" + adminID + ", adminName=" + adminName + "]";
}
}

@ -1,84 +0,0 @@
package com.ken.wms.domain;
import java.io.Serializable;
import java.sql.Date;
/**
*
* @author Ken
*
*/
public class RepositoryAdmin implements Serializable {
private Integer id;// 仓库管理员ID
private String name;// 姓名
private String sex;// 性别
private String tel;// 联系电话
private String address;// 地址
private Date birth;// 出生日期
private Integer repositoryBelongID;// 所属仓库ID
public Integer getRepositoryBelongID() {
return repositoryBelongID;
}
public void setRepositoryBelongID(Integer repositoryBelongID) {
this.repositoryBelongID = repositoryBelongID;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getSex() {
return sex;
}
public void setSex(String sex) {
this.sex = sex;
}
public String getTel() {
return tel;
}
public void setTel(String tel) {
this.tel = tel;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public Date getBirth() {
return birth;
}
public void setBirth(Date birth) {
this.birth = birth;
}
@Override
public String toString() {
return "RepositoryAdmin [id=" + id + ", name=" + name + ", sex=" + sex + ", tel=" + tel + ", address=" + address
+ ", birth=" + birth + ", repositoryBelongID=" + repositoryBelongID + "]";
}
}

@ -1,48 +0,0 @@
package com.ken.wms.domain;
import java.io.Serializable;
/**
* 使
* @author Ken
*
*/
public class RoleDO implements Serializable {
private Integer id;// 角色ID
private String roleName;// 角色名
private String roleDesc;// 角色描述
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getRoleName() {
return roleName;
}
public void setRoleName(String roleName) {
this.roleName = roleName;
}
public String getRoleDesc() {
return roleDesc;
}
public void setRoleDesc(String roleDesc) {
this.roleDesc = roleDesc;
}
@Override
public String toString() {
return "RoleDO{" +
"id=" + id +
", roleName='" + roleName + '\'' +
", roleDesc='" + roleDesc + '\'' +
'}';
}
}

@ -1,65 +0,0 @@
package com.ken.wms.domain;
import java.io.Serializable;
/**
* URL
*
* @author ken
* @since 2017/2/26
*/
public class RolePermissionDO implements Serializable {
/**
* URL
*/
private String name;
/**
* URL URL
*/
private String url;
/**
* URL
*/
private String role;
/**
* getter & setter
*/
public void setName(String name) {
this.name = name;
}
public void setUrl(String url) {
this.url = url;
}
public void setRole(String role) {
this.role = role;
}
public String getName() {
return name;
}
public String getUrl() {
return url;
}
public String getRole() {
return role;
}
@Override
public String toString() {
return "RolePermissionDO{" +
"name='" + name + '\'' +
", url='" + url + '\'' +
", role='" + role + '\'' +
'}';
}
}

@ -1,138 +0,0 @@
package com.ken.wms.domain;
import java.io.Serializable;
import java.util.Date;
/**
*
*
* @author Ken
*/
public class StockInDO implements Serializable {
/**
*
*/
private Integer id;
/**
* ID
*/
private Integer supplierID;
/**
*
*/
private String supplierName;
/**
* ID
*/
private Integer goodID;
/**
*
*/
private String goodName;
/**
* ID
*/
private Integer repositoryID;
/**
*
*/
private long number;
/**
*
*/
private Date time;
/**
*
*/
private String personInCharge;
public Integer getRepositoryID() {
return repositoryID;
}
public void setRepositoryID(Integer repositoryID) {
this.repositoryID = repositoryID;
}
public Integer getSupplierID() {
return supplierID;
}
public void setSupplierID(Integer supplierID) {
this.supplierID = supplierID;
}
public Integer getGoodID() {
return goodID;
}
public void setGoodID(Integer goodID) {
this.goodID = goodID;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getSupplierName() {
return supplierName;
}
public void setSupplierName(String supplierName) {
this.supplierName = supplierName;
}
public String getGoodName() {
return goodName;
}
public void setGoodName(String goodName) {
this.goodName = goodName;
}
public long getNumber() {
return number;
}
public void setNumber(long number) {
this.number = number;
}
public Date getTime() {
return time;
}
public void setTime(Date time) {
this.time = time;
}
public String getPersonInCharge() {
return personInCharge;
}
public void setPersonInCharge(String personInCharge) {
this.personInCharge = personInCharge;
}
@Override
public String toString() {
return "StockInDO [id=" + id + ", supplierID=" + supplierID + ", supplierName=" + supplierName + ", goodID="
+ goodID + ", goodName=" + goodName + ", repositoryID=" + repositoryID + ", number=" + number
+ ", time=" + time + ", personInCharge=" + personInCharge + "]";
}
}

@ -1,138 +0,0 @@
package com.ken.wms.domain;
import java.io.Serializable;
import java.util.Date;
/**
*
*
* @author Ken
*/
public class StockOutDO implements Serializable {
/**
* ID
*/
private Integer id;
/**
* ID
*/
private Integer customerID;
/**
*
*/
private String customerName;
/**
* ID
*/
private Integer goodID;
/**
*
*/
private String goodName;
/**
* ID
*/
private Integer repositoryID;
/**
*
*/
private long number;
/**
*
*/
private Date time;
/**
*
*/
private String personInCharge;// 经手人
public Integer getRepositoryID() {
return repositoryID;
}
public void setRepositoryID(Integer repositoryID) {
this.repositoryID = repositoryID;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Integer getCustomerID() {
return customerID;
}
public void setCustomerID(Integer customerID) {
this.customerID = customerID;
}
public String getCustomerName() {
return customerName;
}
public void setCustomerName(String customerName) {
this.customerName = customerName;
}
public Integer getGoodID() {
return goodID;
}
public void setGoodID(Integer goodID) {
this.goodID = goodID;
}
public String getGoodName() {
return goodName;
}
public void setGoodName(String goodName) {
this.goodName = goodName;
}
public long getNumber() {
return number;
}
public void setNumber(long number) {
this.number = number;
}
public Date getTime() {
return time;
}
public void setTime(Date time) {
this.time = time;
}
public String getPersonInCharge() {
return personInCharge;
}
public void setPersonInCharge(String personInCharge) {
this.personInCharge = personInCharge;
}
@Override
public String toString() {
return "StockOutDO [id=" + id + ", customerID=" + customerID + ", customerName=" + customerName + ", goodID="
+ goodID + ", goodName=" + goodName + ", repositoryID=" + repositoryID + ", number=" + number
+ ", time=" + time + ", personInCharge=" + personInCharge + "]";
}
}

@ -1,131 +0,0 @@
package com.ken.wms.domain;
import java.io.Serializable;
/**
* /DO
*
* @author Ken
* @since 2017/4/5.
*/
public class StockRecordDTO implements Serializable {
/**
* ID
*/
private Integer recordID;
/**
* /
*/
private String type;
/**
*
*/
private String supplierOrCustomerName;
/**
*
*/
private String goodsName;
/**
* ID
*/
private Integer repositoryID;
/**
*
*/
private long number;
/**
*
*/
private String time;
/**
*
*/
private String personInCharge;
public Integer getRecordID() {
return recordID;
}
public String getType() {
return type;
}
public String getSupplierOrCustomerName() {
return supplierOrCustomerName;
}
public String getGoodsName() {
return goodsName;
}
public Integer getRepositoryID() {
return repositoryID;
}
public long getNumber() {
return number;
}
public String getTime() {
return time;
}
public String getPersonInCharge() {
return personInCharge;
}
public void setRecordID(Integer recordID) {
this.recordID = recordID;
}
public void setType(String type) {
this.type = type;
}
public void setSupplierOrCustomerName(String supplierOrCustomerName) {
this.supplierOrCustomerName = supplierOrCustomerName;
}
public void setGoodsName(String goodsName) {
this.goodsName = goodsName;
}
public void setRepositoryID(Integer repositoryID) {
this.repositoryID = repositoryID;
}
public void setNumber(long number) {
this.number = number;
}
public void setTime(String time) {
this.time = time;
}
public void setPersonInCharge(String personInCharge) {
this.personInCharge = personInCharge;
}
@Override
public String toString() {
return "StockRecordDTO{" +
"recordID=" + recordID +
", type='" + type + '\'' +
", supplierOrCustomerName='" + supplierOrCustomerName + '\'' +
", goodsName='" + goodsName + '\'' +
", repositoryID=" + repositoryID +
", number=" + number +
", time=" + time +
", personInCharge='" + personInCharge + '\'' +
'}';
}
}

@ -1,84 +0,0 @@
package com.ken.wms.domain;
import java.io.Serializable;
/**
*
*
* @author Ken
*
*/
public class Storage implements Serializable {
private Integer goodsID;// 货物ID
private String goodsName;// 货物名称
private String goodsSize;// 货物规格
private String goodsType;// 货物类型
private Double goodsValue;// 货物价值
private Integer repositoryID;// 仓库ID
private Long number;// 库存数量
public Integer getGoodsID() {
return goodsID;
}
public void setGoodsID(Integer goodsID) {
this.goodsID = goodsID;
}
public String getGoodsName() {
return goodsName;
}
public void setGoodsName(String goodsName) {
this.goodsName = goodsName;
}
public String getGoodsSize() {
return goodsSize;
}
public void setGoodsSize(String goodsSize) {
this.goodsSize = goodsSize;
}
public String getGoodsType() {
return goodsType;
}
public void setGoodsType(String goodsType) {
this.goodsType = goodsType;
}
public Double getGoodsValue() {
return goodsValue;
}
public void setGoodsValue(Double goodsValue) {
this.goodsValue = goodsValue;
}
public Integer getRepositoryID() {
return repositoryID;
}
public void setRepositoryID(Integer repositoryID) {
this.repositoryID = repositoryID;
}
public Long getNumber() {
return number;
}
public void setNumber(Long number) {
this.number = number;
}
@Override
public String toString() {
return "Storage [goodsID=" + goodsID + ", goodsName=" + goodsName + ", goodsSize=" + goodsSize + ", goodsType="
+ goodsType + ", goodsValue=" + goodsValue + ", repositoryID=" + repositoryID + ", number=" + number
+ "]";
}
}

@ -1,74 +0,0 @@
package com.ken.wms.domain;
import java.io.Serializable;
/**
*
*
* @author Ken
*
*/
public class Supplier implements Serializable {
private Integer id;// 供应商ID
private String name;// 供应商名
private String personInCharge;// 负责人
private String tel;// 联系电话
private String email;// 电子邮件
private String address;// 供应商地址
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPersonInCharge() {
return personInCharge;
}
public void setPersonInCharge(String personInCharge) {
this.personInCharge = personInCharge;
}
public String getTel() {
return tel;
}
public void setTel(String tel) {
this.tel = tel;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
@Override
public String toString() {
return "Supplier [id=" + id + ", name=" + name + ", personInCharge=" + personInCharge + ", tel=" + tel
+ ", email=" + email + ", address=" + address + "]";
}
}

@ -1,45 +0,0 @@
package com.ken.wms.domain;
import java.io.Serializable;
/**
* 使
* @author Ken
*
*/
public class User implements Serializable {
private Integer id;// 用户ID
private String userName;// 用户名
private String password;// 用户密码
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
@Override
public String toString() {
return "User [id=" + id + ", userName=" + userName + ", password=" + password + "]";
}
}

@ -1,77 +0,0 @@
package com.ken.wms.domain;
import java.io.Serializable;
/**
* ()
* @author ken
* @since 2017/2/26.
*/
public class UserInfoDO implements Serializable {
/**
* ID
*/
private Integer userID;
/**
*
*/
private String userName;
/**
*
*/
private String password;
/**
*
*/
private int firstLogin;
/**
* getter setter
*/
public String getUserName() {
return userName;
}
public int getFirstLogin() {
return firstLogin;
}
public void setFirstLogin(int firstLogin) {
this.firstLogin = firstLogin;
}
public Integer getUserID() {
return userID;
}
public String getPassword() {
return password;
}
public void setUserID(Integer userID) {
this.userID = userID;
}
public void setUserName(String userName) {
this.userName = userName;
}
public void setPassword(String password) {
this.password = password;
}
@Override
public String toString() {
return "UserInfoDO{" +
"userID=" + userID +
", userName='" + userName + '\'' +
", password='" + password + '\'' +
", firstLogin=" + firstLogin +
'}';
}
}

@ -1,120 +0,0 @@
package com.ken.wms.domain;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
/**
*
*
* @author ken
* @since 2017/2/26.
*/
public class UserInfoDTO implements Serializable {
/**
* ID
*/
private Integer userID;
/**
*
*/
private String userName;
/**
*
*/
private String password;
/**
*
*/
private boolean firstLogin;
/**
* IP
*/
private String accessIP;
/**
*
*/
private List<String> role = new ArrayList<>();
/**
*
*/
private Integer repositoryBelong;
/**
* getter setter
*/
public String getUserName() {
return userName;
}
public void setFirstLogin(boolean firstLogin) {
this.firstLogin = firstLogin;
}
public List<String> getRole() {
return role;
}
public Integer getUserID() {
return userID;
}
public String getPassword() {
return password;
}
public void setUserID(Integer userID) {
this.userID = userID;
}
public void setUserName(String userName) {
this.userName = userName;
}
public void setPassword(String password) {
this.password = password;
}
public void setRole(List<String> role) {
this.role = role;
}
public boolean isFirstLogin() {
return firstLogin;
}
public Integer getRepositoryBelong() {
return repositoryBelong;
}
public void setRepositoryBelong(Integer repositoryBelong) {
this.repositoryBelong = repositoryBelong;
}
public String getAccessIP() {
return accessIP;
}
public void setAccessIP(String accessIP) {
this.accessIP = accessIP;
}
@Override
public String toString() {
return "UserInfoDTO{" +
"userID=" + userID +
", userName='" + userName + '\'' +
", password='" + password + '\'' +
", firstLogin=" + firstLogin +
", role=" + role +
'}';
}
}

@ -1,103 +0,0 @@
package com.ken.wms.domain;
import java.io.Serializable;
import java.util.Date;
/**
* DO
*
* @author Ken
* @since 2017/4/9.
*/
public class UserOperationRecordDO implements Serializable {
/**
* ID
*/
private Integer id;
/**
* ID
*/
private Integer userID;
/**
*
*/
private String userName;
/**
*
*/
private String operationName;
/**
*
*/
private Date operationTime;
/**
*
*/
private String operationResult;
public void setId(Integer id) {
this.id = id;
}
public void setUserID(Integer userID) {
this.userID = userID;
}
public void setUserName(String userName) {
this.userName = userName;
}
public void setOperationName(String operationName) {
this.operationName = operationName;
}
public void setOperationTime(Date operationTime) {
this.operationTime = operationTime;
}
public void setOperationResult(String operationResult) {
this.operationResult = operationResult;
}
public Integer getId() {
return id;
}
public Integer getUserID() {
return userID;
}
public String getUserName() {
return userName;
}
public String getOperationName() {
return operationName;
}
public Date getOperationTime() {
return operationTime;
}
public String getOperationResult() {
return operationResult;
}
@Override
public String toString() {
return "UserOperationRecordDO{" +
"id=" + id +
", userID=" + userID +
", userName='" + userName + '\'' +
", operationName='" + operationName + '\'' +
", operationTime=" + operationTime +
", operationResult='" + operationResult + '\'' +
'}';
}
}

@ -1,102 +0,0 @@
package com.ken.wms.domain;
import java.io.Serializable;
/**
* DTO
*
* @author Ken
* @since 2017/4/9.
*/
public class UserOperationRecordDTO implements Serializable {
/**
* ID
*/
private Integer id;
/**
* ID
*/
private Integer userID;
/**
*
*/
private String userName;
/**
*
*/
private String operationName;
/**
*
*/
private String operationTime;
/**
*
*/
private String operationResult;
public Integer getId() {
return id;
}
public Integer getUserID() {
return userID;
}
public String getUserName() {
return userName;
}
public String getOperationName() {
return operationName;
}
public String getOperationTime() {
return operationTime;
}
public String getOperationResult() {
return operationResult;
}
public void setId(Integer id) {
this.id = id;
}
public void setUserID(Integer userID) {
this.userID = userID;
}
public void setUserName(String userName) {
this.userName = userName;
}
public void setOperationName(String operationName) {
this.operationName = operationName;
}
public void setOperationTime(String operationTime) {
this.operationTime = operationTime;
}
public void setOperationResult(String operationResult) {
this.operationResult = operationResult;
}
@Override
public String toString() {
return "UserOperationRecordDTO{" +
"id=" + id +
", userID=" + userID +
", userName='" + userName + '\'' +
", operationName='" + operationName + '\'' +
", operationTime='" + operationTime + '\'' +
", operationResult='" + operationResult + '\'' +
'}';
}
}

@ -1,35 +0,0 @@
package com.ken.wms.exception;
/**
*
*
* @author Ken
* @since 2017/3/8.
*/
public class BusinessException extends Exception{
private String exceptionDesc;
public BusinessException(Exception e){
super(e);
}
BusinessException(Exception e, String exceptionDesc){
super(e);
this.exceptionDesc = exceptionDesc;
}
BusinessException(String exceptionDesc){
this.exceptionDesc = exceptionDesc;
}
BusinessException(){}
public String getExceptionDesc() {
return exceptionDesc;
}
public void setExceptionDesc(String exceptionDesc) {
this.exceptionDesc = exceptionDesc;
}
}

@ -1,22 +0,0 @@
package com.ken.wms.exception;
/**
* CustomerManageService
*
* @author Ken
* @since 2017/3/8.
*/
public class CustomerManageServiceException extends BusinessException{
public CustomerManageServiceException(){
super();
}
public CustomerManageServiceException(Exception e, String exception){
super(e, exception);
}
public CustomerManageServiceException(Exception e){
super(e);
}
}

@ -1,23 +0,0 @@
package com.ken.wms.exception;
/**
* GoodsManageService
*
* @author Ken
* @since 2017/3/8.
*/
public class GoodsManageServiceException extends BusinessException {
GoodsManageServiceException(){
super();
}
public GoodsManageServiceException(Exception e){
super(e);
}
GoodsManageServiceException(Exception e, String exceptionDesc){
super(e, exceptionDesc);
}
}

@ -1,26 +0,0 @@
package com.ken.wms.exception;
/**
* RepositoryAdminManageService
*
* @author Ken
* @since 2017/3/8.
*/
public class RepositoryAdminManageServiceException extends BusinessException {
public RepositoryAdminManageServiceException(){
super();
}
public RepositoryAdminManageServiceException(Exception e){
super(e);
}
public RepositoryAdminManageServiceException(Exception e, String exceptionDesc){
super(e, exceptionDesc);
}
public RepositoryAdminManageServiceException(String exceptionDesc){
super(exceptionDesc);
}
}

@ -1,23 +0,0 @@
package com.ken.wms.exception;
/**
* RepositoryManageService
*
* @author Ken
* @since 2017/3/8.
*/
public class RepositoryManageServiceException extends BusinessException {
RepositoryManageServiceException(){
super();
}
public RepositoryManageServiceException(Exception e){
super(e);
}
RepositoryManageServiceException(Exception e, String exceptionDesc){
super(e, exceptionDesc);
}
}

@ -1,27 +0,0 @@
package com.ken.wms.exception;
/**
* StockRecordManageService
*
* @author Ken
* @since 2017/3/8.
*/
public class StockRecordManageServiceException extends BusinessException {
public StockRecordManageServiceException(){
super();
}
public StockRecordManageServiceException(Exception e){
super(e);
}
public StockRecordManageServiceException(Exception e, String exceptionDesc){
super(e, exceptionDesc);
}
public StockRecordManageServiceException(String exceptionDesc){
super(exceptionDesc);
}
}

@ -1,23 +0,0 @@
package com.ken.wms.exception;
/**
* StorageManageServiceException
*
* @author Ken
* @since 2017/3/8.
*/
public class StorageManageServiceException extends BusinessException {
StorageManageServiceException(){
super();
}
public StorageManageServiceException(Exception e){
super(e);
}
StorageManageServiceException(Exception e, String exceptionDesc){
super(e, exceptionDesc);
}
}

@ -1,23 +0,0 @@
package com.ken.wms.exception;
/**
* SupplierManageService
*
* @author Ken
* @since 2017/3/8.
*/
public class SupplierManageServiceException extends BusinessException {
SupplierManageServiceException(){
super();
}
public SupplierManageServiceException(Exception e){
super(e);
}
SupplierManageServiceException(Exception e, String exceptionDesc){
super(e, exceptionDesc);
}
}

@ -1,26 +0,0 @@
package com.ken.wms.exception;
/**
* Service
*
* @author Ken
* @since 2017/4/7.
*/
public class SystemLogServiceException extends BusinessException {
public SystemLogServiceException(){
super();
}
public SystemLogServiceException(Exception e){
super(e);
}
public SystemLogServiceException(Exception e, String exceptionDesc){
super(e, exceptionDesc);
}
public SystemLogServiceException(String exceptionDesc){
super(exceptionDesc);
}
}

@ -1,30 +0,0 @@
package com.ken.wms.exception;
/**
* AccountServiceException
*
* @author Ken
* @since 2017/3/8.
*/
public class UserAccountServiceException extends BusinessException {
public static final String PASSWORD_ERROR = "passwordError";
public static final String PASSWORD_UNMATCH = "passwordUnmatched";
public UserAccountServiceException() {
super();
}
public UserAccountServiceException(String exceptionDesc) {
super(null, exceptionDesc);
}
UserAccountServiceException(Exception e) {
super(e);
}
UserAccountServiceException(Exception e, String exceptionDesc) {
super(e, exceptionDesc);
}
}

@ -1,27 +0,0 @@
package com.ken.wms.exception;
/**
* UserInfoService
*
* @author Ken
* @since 2017/3/8.
*/
public class UserInfoServiceException extends BusinessException {
public UserInfoServiceException(){
super();
}
public UserInfoServiceException(Exception e){
super(e);
}
public UserInfoServiceException(Exception e, String exceptionDesc){
super(e, exceptionDesc);
}
public UserInfoServiceException(String exceptionDesc){
super(exceptionDesc);
}
}

@ -1,234 +0,0 @@
package com.ken.wms.security.controller;
import com.ken.wms.common.service.Interface.RepositoryAdminManageService;
import com.ken.wms.common.service.Interface.SystemLogService;
import com.ken.wms.common.util.Response;
import com.ken.wms.common.util.ResponseFactory;
import com.ken.wms.domain.RepositoryAdmin;
import com.ken.wms.domain.UserInfoDTO;
import com.ken.wms.exception.RepositoryAdminManageServiceException;
import com.ken.wms.exception.SystemLogServiceException;
import com.ken.wms.exception.UserAccountServiceException;
import com.ken.wms.security.service.Interface.AccountService;
import com.ken.wms.security.util.CaptchaGenerator;
import org.apache.log4j.Logger;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.AuthenticationException;
import org.apache.shiro.authc.IncorrectCredentialsException;
import org.apache.shiro.authc.UnknownAccountException;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.session.Session;
import org.apache.shiro.subject.Subject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import javax.imageio.ImageIO;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.util.List;
import java.util.Map;
/**
* Handler
*
* @author Ken
* @since 017/2/26.
*/
@Controller
@RequestMapping("/account")
public class AccountHandler {
private static Logger log = Logger.getLogger("application");
@Autowired
private AccountService accountService;
@Autowired
private SystemLogService systemLogService;
@Autowired
private RepositoryAdminManageService repositoryAdminManageService;
private static final String USER_ID = "id";
private static final String USER_NAME = "userName";
private static final String USER_PASSWORD = "password";
/**
*
*
* @param user
* @return Map
*/
@RequestMapping(value = "login", method = RequestMethod.POST)
@ResponseBody
public Map<String, Object> login(@RequestBody Map<String, Object> user) {
// 初始化 Response
Response response = ResponseFactory.newInstance();
String result = Response.RESPONSE_RESULT_ERROR;
String errorMsg = "";
// 获取当前的用户的 Subject
Subject currentUser = SecurityUtils.getSubject();
// 判断用户是否已经登陆
if (currentUser != null && !currentUser.isAuthenticated()) {
String id = (String) user.get(USER_ID);
String password = (String) user.get(USER_PASSWORD);
Session session = currentUser.getSession();
UsernamePasswordToken token = new UsernamePasswordToken(id, password);
try {
// 执行登陆操作
currentUser.login(token);
/* 设置 session 中 userInfo 的其他信息 */
UserInfoDTO userInfo = (UserInfoDTO) session.getAttribute("userInfo");
// 设置登陆IP
userInfo.setAccessIP(session.getHost());
// 查询并设置用户所属的仓库ID
List<RepositoryAdmin> repositoryAdmin = (List<RepositoryAdmin>) repositoryAdminManageService.selectByID(userInfo.getUserID()).get("data");
userInfo.setRepositoryBelong(-1);
if (!repositoryAdmin.isEmpty()) {
Integer repositoryBelong = repositoryAdmin.get(0).getRepositoryBelongID();
if (repositoryBelong != null) {
userInfo.setRepositoryBelong(repositoryBelong);
}
}
// 记录登陆日志
systemLogService.insertAccessRecord(userInfo.getUserID(), userInfo.getUserName(),
userInfo.getAccessIP(), SystemLogService.ACCESS_TYPE_LOGIN);
// 设置登陆成功响应
result = Response.RESPONSE_RESULT_SUCCESS;
} catch (UnknownAccountException e) {
errorMsg = "unknownAccount";
} catch (IncorrectCredentialsException e) {
errorMsg = "incorrectCredentials";
} catch (AuthenticationException e) {
errorMsg = "authenticationError";
e.printStackTrace();
} catch (SystemLogServiceException | RepositoryAdminManageServiceException e) {
errorMsg = "ServerError";
} finally {
// 当登陆失败则清除session中的用户信息
if (result.equals(Response.RESPONSE_RESULT_ERROR)) {
session.setAttribute("userInfo", null);
}
}
} else {
errorMsg = "already login";
}
// 设置 Response
response.setResponseResult(result);
response.setResponseMsg(errorMsg);
return response.generateResponse();
}
/**
*
*
* @return Map result success error
*/
@RequestMapping(value = "logout", method = RequestMethod.GET)
public
@ResponseBody
Map<String, Object> logout() {
// 初始化 Response
Response response = ResponseFactory.newInstance();
Subject currentSubject = SecurityUtils.getSubject();
if (currentSubject != null && currentSubject.isAuthenticated()) {
// 执行账户注销操作
currentSubject.logout();
response.setResponseResult(Response.RESPONSE_RESULT_SUCCESS);
} else {
response.setResponseResult(Response.RESPONSE_RESULT_ERROR);
response.setResponseMsg("did not login");
}
return response.generateResponse();
}
/**
*
*
* @param passwordInfo
* @param request
* @return Map result
* success error msg
*/
@RequestMapping(value = "passwordModify", method = RequestMethod.POST)
public
@ResponseBody
Map<String, Object> passwordModify(@RequestBody Map<String, Object> passwordInfo,
HttpServletRequest request) {
//初始化 Response
Response responseContent = ResponseFactory.newInstance();
String errorMsg = null;
String result = Response.RESPONSE_RESULT_ERROR;
// 获取用户 ID
HttpSession session = request.getSession();
UserInfoDTO userInfo = (UserInfoDTO) session.getAttribute("userInfo");
Integer userID = userInfo.getUserID();
try {
// 更改密码
accountService.passwordModify(userID, passwordInfo);
result = Response.RESPONSE_RESULT_SUCCESS;
} catch (UserAccountServiceException e) {
errorMsg = e.getExceptionDesc();
}
// 设置 Response
responseContent.setResponseResult(result);
responseContent.setResponseMsg(errorMsg);
return responseContent.generateResponse();
}
/**
* 4 session
*
* @param time
* @param response HttpServletResponse
*/
@RequestMapping(value = "checkCode/{time}", method = RequestMethod.GET)
public void getCheckCode(@PathVariable("time") String time, HttpServletResponse response, HttpServletRequest request) {
BufferedImage checkCodeImage = null;
String checkCodeString = null;
// 获取图形验证码
Map<String, Object> checkCode = CaptchaGenerator.generateCaptcha();
if (checkCode != null) {
checkCodeString = (String) checkCode.get("captchaString");
checkCodeImage = (BufferedImage) checkCode.get("captchaImage");
}
if (checkCodeString != null && checkCodeImage != null) {
try (ServletOutputStream outputStream = response.getOutputStream()) {
// 设置 Session
HttpSession session = request.getSession();
session.setAttribute("checkCode", checkCodeString);
// 将验证码输出
ImageIO.write(checkCodeImage, "png", outputStream);
response.setHeader("Pragma", "no-cache");
response.setHeader("Cache-Control", "no-cache");
response.setDateHeader("Expires", 0);
response.setContentType("image/png");
} catch (IOException e) {
log.error("fail to get the ServletOutputStream");
}
}
}
}

@ -1,42 +0,0 @@
package com.ken.wms.security.controller;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
/**
*
*
* @author ken
* @since 2017/2/27.
*/
@RequestMapping("/")
@Controller
public class PageForwardHandler {
/**
*
*
* @return jsp
*/
@RequestMapping("login")
public String loginPageForward() {
// 判断但钱用户是否已经登陆
Subject currentSubject = SecurityUtils.getSubject();
if (!currentSubject.isAuthenticated())
return "login";
else
return "mainPage";
}
/**
*
*
* @return jsp
*/
@RequestMapping("")
public String showLoginView() {
return "mainPage";
}
}

@ -1,39 +0,0 @@
package com.ken.wms.security.filter;
import org.apache.shiro.subject.Subject;
import org.apache.shiro.web.filter.authz.RolesAuthorizationFilter;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import java.io.IOException;
/**
* RolesAuthorizationFilter 访url
* @author Ken
* @since 2017/3/3.
*/
public class AnyOfRolesAuthorizationFilter extends RolesAuthorizationFilter{
@Override
public boolean isAccessAllowed(ServletRequest request, ServletResponse response,
Object mappedValue) throws IOException{
final Subject subject = getSubject(request, response);
final String[] rolesArray = (String[]) mappedValue;
if (rolesArray == null || rolesArray.length == 0){
// no roles specified, so nothing to check - allow access
// System.out.println("no roles");
return true;
}
for (String role : rolesArray){
// System.out.println(role);
if (subject.hasRole(role)){
return true;
}
}
return false;
}
}

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save