Browse Source

first commit

YinBin 1 year ago
commit
34981f4998
100 changed files with 6931 additions and 0 deletions
  1. 4 0
      .gitignore
  2. 2 0
      README.md
  3. 215 0
      pom.xml
  4. 585 0
      src/logistics_system.sql
  5. 92 0
      src/main/java/com/logistics/conf/AdminAdd.java
  6. 168 0
      src/main/java/com/logistics/conf/Configurator.java
  7. 18 0
      src/main/java/com/logistics/conf/Constants.java
  8. 71 0
      src/main/java/com/logistics/controller/AddressController.java
  9. 212 0
      src/main/java/com/logistics/controller/AdminController.java
  10. 123 0
      src/main/java/com/logistics/controller/CarBusinessController.java
  11. 117 0
      src/main/java/com/logistics/controller/CargoController.java
  12. 133 0
      src/main/java/com/logistics/controller/CarrierBusinessController.java
  13. 125 0
      src/main/java/com/logistics/controller/CompanyController.java
  14. 201 0
      src/main/java/com/logistics/controller/GoodsController.java
  15. 166 0
      src/main/java/com/logistics/controller/GoodsRecordController.java
  16. 71 0
      src/main/java/com/logistics/controller/ImageController.java
  17. 72 0
      src/main/java/com/logistics/controller/OilBuyController.java
  18. 75 0
      src/main/java/com/logistics/controller/ReportController.java
  19. 163 0
      src/main/java/com/logistics/controller/StaffController.java
  20. 109 0
      src/main/java/com/logistics/controller/TransportTaskController.java
  21. 160 0
      src/main/java/com/logistics/controller/UserController.java
  22. 123 0
      src/main/java/com/logistics/controller/VehicleController.java
  23. 86 0
      src/main/java/com/logistics/controller/VehicleRepairController.java
  24. 119 0
      src/main/java/com/logistics/controller/VehicleTypeController.java
  25. 194 0
      src/main/java/com/logistics/crypto/AESCrypto.java
  26. 177 0
      src/main/java/com/logistics/crypto/CryptoBase.java
  27. 206 0
      src/main/java/com/logistics/crypto/RSACrypto.java
  28. 76 0
      src/main/java/com/logistics/crypto/RSAKeyCache.java
  29. 13 0
      src/main/java/com/logistics/dao/AddressDao.java
  30. 9 0
      src/main/java/com/logistics/dao/AdminDao.java
  31. 41 0
      src/main/java/com/logistics/dao/BaseDao.java
  32. 9 0
      src/main/java/com/logistics/dao/CarBusinessDao.java
  33. 9 0
      src/main/java/com/logistics/dao/CargoDao.java
  34. 9 0
      src/main/java/com/logistics/dao/CarrierBusinessDao.java
  35. 10 0
      src/main/java/com/logistics/dao/CompanyDao.java
  36. 9 0
      src/main/java/com/logistics/dao/GoodsDao.java
  37. 9 0
      src/main/java/com/logistics/dao/GoodsGroupDao.java
  38. 9 0
      src/main/java/com/logistics/dao/GoodsRecordDao.java
  39. 27 0
      src/main/java/com/logistics/dao/Impl/AddressDaoImpl.java
  40. 16 0
      src/main/java/com/logistics/dao/Impl/AdminDaoImpl.java
  41. 106 0
      src/main/java/com/logistics/dao/Impl/BaseDaoImpl.java
  42. 16 0
      src/main/java/com/logistics/dao/Impl/CarBusinessDaoImpl.java
  43. 16 0
      src/main/java/com/logistics/dao/Impl/CargoDaoImpl.java
  44. 16 0
      src/main/java/com/logistics/dao/Impl/CarrierBusinessDaoImpl.java
  45. 16 0
      src/main/java/com/logistics/dao/Impl/CompanyDaoImpl.java
  46. 16 0
      src/main/java/com/logistics/dao/Impl/GoodsDaoImpl.java
  47. 16 0
      src/main/java/com/logistics/dao/Impl/GoodsGroupDaoImpl.java
  48. 16 0
      src/main/java/com/logistics/dao/Impl/GoodsRecordDaoImpl.java
  49. 16 0
      src/main/java/com/logistics/dao/Impl/OilBuyDaoImpl.java
  50. 16 0
      src/main/java/com/logistics/dao/Impl/StaffDaoImpl.java
  51. 24 0
      src/main/java/com/logistics/dao/Impl/TransportTaskDaoImpl.java
  52. 16 0
      src/main/java/com/logistics/dao/Impl/UserDaoImpl.java
  53. 16 0
      src/main/java/com/logistics/dao/Impl/VehicleDaoImpl.java
  54. 16 0
      src/main/java/com/logistics/dao/Impl/VehicleRepairDaoImpl.java
  55. 16 0
      src/main/java/com/logistics/dao/Impl/VehicleTypeDaoImpl.java
  56. 9 0
      src/main/java/com/logistics/dao/OilBuyDao.java
  57. 9 0
      src/main/java/com/logistics/dao/StaffDao.java
  58. 9 0
      src/main/java/com/logistics/dao/TransportTaskDao.java
  59. 9 0
      src/main/java/com/logistics/dao/UserDao.java
  60. 9 0
      src/main/java/com/logistics/dao/VehicleDao.java
  61. 9 0
      src/main/java/com/logistics/dao/VehicleRepairDao.java
  62. 9 0
      src/main/java/com/logistics/dao/VehicleTypeDao.java
  63. 93 0
      src/main/java/com/logistics/entity/Address.java
  64. 85 0
      src/main/java/com/logistics/entity/Admin.java
  65. 86 0
      src/main/java/com/logistics/entity/BasicEntity.java
  66. 76 0
      src/main/java/com/logistics/entity/CarBusiness.java
  67. 95 0
      src/main/java/com/logistics/entity/Cargo.java
  68. 56 0
      src/main/java/com/logistics/entity/CarrierBusiness.java
  69. 74 0
      src/main/java/com/logistics/entity/Company.java
  70. 106 0
      src/main/java/com/logistics/entity/Goods.java
  71. 51 0
      src/main/java/com/logistics/entity/GoodsGroup.java
  72. 82 0
      src/main/java/com/logistics/entity/GoodsRecord.java
  73. 69 0
      src/main/java/com/logistics/entity/OilBuy.java
  74. 106 0
      src/main/java/com/logistics/entity/Report.java
  75. 177 0
      src/main/java/com/logistics/entity/Staff.java
  76. 203 0
      src/main/java/com/logistics/entity/TransportTask.java
  77. 95 0
      src/main/java/com/logistics/entity/User.java
  78. 93 0
      src/main/java/com/logistics/entity/Vehicle.java
  79. 66 0
      src/main/java/com/logistics/entity/VehicleRepair.java
  80. 123 0
      src/main/java/com/logistics/entity/VehicleType.java
  81. 16 0
      src/main/java/com/logistics/service/AddressService.java
  82. 20 0
      src/main/java/com/logistics/service/AdminService.java
  83. 31 0
      src/main/java/com/logistics/service/BaseService.java
  84. 16 0
      src/main/java/com/logistics/service/CarBusinessService.java
  85. 16 0
      src/main/java/com/logistics/service/CargoService.java
  86. 16 0
      src/main/java/com/logistics/service/CarrierBusinessService.java
  87. 9 0
      src/main/java/com/logistics/service/CompanyService.java
  88. 9 0
      src/main/java/com/logistics/service/GoodsRecordService.java
  89. 11 0
      src/main/java/com/logistics/service/GoodsService.java
  90. 22 0
      src/main/java/com/logistics/service/ImageService.java
  91. 47 0
      src/main/java/com/logistics/service/Impl/AddressServiceImpl.java
  92. 137 0
      src/main/java/com/logistics/service/Impl/AdminServiceImpl.java
  93. 60 0
      src/main/java/com/logistics/service/Impl/BaseServiceImpl.java
  94. 61 0
      src/main/java/com/logistics/service/Impl/CarBusinessServiceImpl.java
  95. 55 0
      src/main/java/com/logistics/service/Impl/CargoServiceImpl.java
  96. 66 0
      src/main/java/com/logistics/service/Impl/CarrierBusinessServiceImpl.java
  97. 22 0
      src/main/java/com/logistics/service/Impl/CompanyServiceImpl.java
  98. 22 0
      src/main/java/com/logistics/service/Impl/GoodsRecordServiceImpl.java
  99. 22 0
      src/main/java/com/logistics/service/Impl/GoodsServiceImpl.java
  100. 103 0
      src/main/java/com/logistics/service/Impl/ImageServiceImpl.java

+ 4 - 0
.gitignore

@@ -0,0 +1,4 @@
+.idea/
+target/
+src/test/
+*.iml

+ 2 - 0
README.md

@@ -0,0 +1,2 @@
+# tongkuaiwuliu
+简单的物流系统

+ 215 - 0
pom.xml

@@ -0,0 +1,215 @@
+<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>
+
+  <!--基本信息-->
+  <groupId>com.javaEE10.logistics</groupId>
+  <artifactId>logistics</artifactId>
+  <packaging>war</packaging>
+  <version>1.0-SNAPSHOT</version>
+
+  <name>diary Maven Webapp</name>
+  <url>http://maven.apache.org</url>
+
+
+  <!--版本属性配置-->
+  <properties>
+    <maven.compiler.encoding>UTF-8</maven.compiler.encoding>
+    <spring.version>4.2.0.RELEASE</spring.version>
+    <struts.version>2.3.16</struts.version>
+    <hibernate.version>4.2.0.Final</hibernate.version>
+  </properties>
+
+  <!--依赖-->
+  <dependencies>
+
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>4.11</version>
+      <scope>test</scope>
+    </dependency>
+
+    <!-- Servlet & Jsp -->
+    <dependency>
+      <groupId>javax.servlet</groupId>
+      <artifactId>jsp-api</artifactId>
+      <version>2.0</version>
+      <scope>provided</scope>
+    </dependency>
+
+    <!--添加fastjson依赖-->
+    <dependency>
+      <groupId>com.alibaba</groupId>
+      <artifactId>fastjson</artifactId>
+      <version>1.2.6</version>
+    </dependency>
+
+    <!-- 添加Log4J + slf4j依赖 -->
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-log4j12</artifactId>
+      <version>1.6.1</version>
+    </dependency>
+
+    <!--添加commons-fileupload依赖-->
+    <dependency>
+      <groupId>commons-fileupload</groupId>
+      <artifactId>commons-fileupload</artifactId>
+      <version>1.3.1</version>
+    </dependency>
+
+    <!--添加jstl支持-->
+    <dependency>
+      <groupId>jstl</groupId>
+      <artifactId>jstl</artifactId>
+      <version>1.2</version>
+    </dependency>
+
+    <dependency>
+      <groupId>taglibs</groupId>
+      <artifactId>standard</artifactId>
+      <version>1.1.2</version>
+    </dependency>
+
+    <!--添加aspectjweaver-->
+    <dependency>
+      <groupId>org.aspectj</groupId>
+      <artifactId>aspectjweaver</artifactId>
+      <version>1.8.6</version>
+    </dependency>
+
+    <!-- 添加SSH依赖 -->
+    <!-- Struts2 -->
+    <!--<dependency>-->
+    <!--<groupId>org.apache.struts</groupId>-->
+    <!--<artifactId>struts2-core</artifactId>-->
+    <!--<version>${struts.version}</version>-->
+    <!--</dependency>-->
+
+    <!--<dependency>-->
+    <!--<groupId>org.apache.struts</groupId>-->
+    <!--<artifactId>struts2-spring-plugin</artifactId>-->
+    <!--<version>${struts.version}</version>-->
+    <!--</dependency>-->
+
+    <!--<dependency>-->
+    <!--<groupId>org.apache.struts</groupId>-->
+    <!--<artifactId>struts2-convention-plugin</artifactId>-->
+    <!--<version>${struts.version}</version>-->
+    <!--</dependency>-->
+
+    <!--添加对缓存的支持-->
+    <dependency>
+      <groupId>net.sf.ehcache</groupId>
+      <artifactId>ehcache</artifactId>
+      <version>2.8.3</version>
+    </dependency>
+
+
+    <!-- 添加Hibernate依赖 -->
+    <dependency>
+      <groupId>org.hibernate</groupId>
+      <artifactId>hibernate-core</artifactId>
+      <version>${hibernate.version}</version>
+    </dependency>
+
+    <dependency>
+      <groupId>org.hibernate</groupId>
+      <artifactId>hibernate-c3p0</artifactId>
+      <version>${hibernate.version}</version>
+    </dependency>
+
+    <dependency>
+      <groupId>org.hibernate</groupId>
+      <artifactId>hibernate-ehcache</artifactId>
+      <version>${hibernate.version}</version>
+    </dependency>
+
+    <dependency>
+      <groupId>mysql</groupId>
+      <artifactId>mysql-connector-java</artifactId>
+      <version>5.1.36</version>
+    </dependency>
+
+    <!-- 添加javassist -->
+    <dependency>
+      <groupId>javassist</groupId>
+      <artifactId>javassist</artifactId>
+      <version>3.11.0.GA</version>
+    </dependency>
+
+    <!-- 添加Spring MVC依赖 -->
+    <dependency>
+      <groupId>org.springframework</groupId>
+      <artifactId>spring-webmvc</artifactId>
+      <version>${spring.version}</version>
+    </dependency>
+
+    <!-- 添加Spring依赖 -->
+    <dependency>
+      <groupId>org.springframework</groupId>
+      <artifactId>spring-core</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-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-web</artifactId>
+      <version>${spring.version}</version>
+    </dependency>
+
+    <dependency>
+      <groupId>org.springframework</groupId>
+      <artifactId>spring-test</artifactId>
+      <version>${spring.version}</version>
+      <scope>provided</scope>
+    </dependency>
+
+  </dependencies>
+
+
+  <build>
+    <finalName>logistics</finalName>
+
+    <!--Tomcat部署-->
+    <!--<plugins>-->
+      <!--<plugin>-->
+        <!--<groupId>org.apache.tomcat.maven</groupId>-->
+        <!--<artifactId>tomcat7-maven-plugin</artifactId>-->
+        <!--<version>2.2</version>-->
+        <!--<configuration>-->
+          <!--<url>http://localhost:8080/manager/text</url>-->
+          <!--<server>tomcat7</server>-->
+          <!--<path>/</path>-->
+        <!--</configuration>-->
+      <!--</plugin>-->
+    <!--</plugins>-->
+  </build>
+
+</project>

+ 585 - 0
src/logistics_system.sql

@@ -0,0 +1,585 @@
+/*
+Navicat MySQL Data Transfer
+
+Source Server         : 121.42.57.149
+Source Server Version : 50547
+Source Host           : 121.42.57.149:3306
+Source Database       : logistics_system
+
+Target Server Type    : MYSQL
+Target Server Version : 50547
+File Encoding         : 65001
+
+Date: 2016-05-04 20:34:04
+*/
+
+SET FOREIGN_KEY_CHECKS=0;
+
+-- ----------------------------
+-- Table structure for address
+-- ----------------------------
+DROP TABLE IF EXISTS `address`;
+CREATE TABLE `address` (
+  `ID` int(11) NOT NULL AUTO_INCREMENT,
+  `created_time` bigint(20) DEFAULT NULL,
+  `IsDeleted` tinyint(1) DEFAULT NULL,
+  `modify_time` bigint(20) DEFAULT NULL,
+  `AreaName` varchar(64) DEFAULT NULL,
+  `Level` int(11) DEFAULT NULL,
+  `Pinyin` varchar(32) DEFAULT NULL,
+  `parent` int(11) DEFAULT NULL,
+  PRIMARY KEY (`ID`),
+  KEY `FKBB979BF450F36A7B` (`parent`) USING BTREE,
+  CONSTRAINT `address_ibfk_1` FOREIGN KEY (`parent`) REFERENCES `address` (`ID`)
+) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;
+
+-- ----------------------------
+-- Records of address
+-- ----------------------------
+INSERT INTO `address` VALUES ('1', '1461246317974', '0', '1461554285837', '青岛市', '1', 'qingdaoshi', null);
+
+-- ----------------------------
+-- Table structure for admin
+-- ----------------------------
+DROP TABLE IF EXISTS `admin`;
+CREATE TABLE `admin` (
+  `ID` int(11) NOT NULL AUTO_INCREMENT,
+  `created_time` bigint(20) DEFAULT NULL,
+  `IsDeleted` tinyint(1) DEFAULT NULL,
+  `modify_time` bigint(20) DEFAULT NULL,
+  `adminName` varchar(255) DEFAULT NULL,
+  `password` tinyblob,
+  `salt` tinyblob,
+  `type` int(11) DEFAULT NULL,
+  PRIMARY KEY (`ID`)
+) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;
+
+-- ----------------------------
+-- Records of admin
+-- ----------------------------
+INSERT INTO `admin` VALUES ('2', '1461202916785', '0', '1461202916785', 'admin', 0x5DC7E80959C7A54C61DBB13C233AAC24, 0x524E7D57, '1');
+INSERT INTO `admin` VALUES ('3', '1461327332194', '0', '1461327332194', '李家沽', 0x250620AAAA4FB587C6EC4AD07F625BE0, 0xEA84E9D7, '3');
+
+-- ----------------------------
+-- Table structure for carbusiness
+-- ----------------------------
+DROP TABLE IF EXISTS `carbusiness`;
+CREATE TABLE `carbusiness` (
+  `ID` int(11) NOT NULL AUTO_INCREMENT,
+  `created_time` bigint(20) DEFAULT NULL,
+  `IsDeleted` tinyint(1) DEFAULT NULL,
+  `modify_time` bigint(20) DEFAULT NULL,
+  `DateOfFinishing` bigint(20) DEFAULT NULL,
+  `DateOfStarting` bigint(20) DEFAULT NULL,
+  `taskId` int(11) DEFAULT NULL,
+  `vehicle` int(11) DEFAULT NULL,
+  PRIMARY KEY (`ID`),
+  KEY `FKEA3D8FB4D76205CB` (`taskId`) USING BTREE,
+  KEY `FKEA3D8FB4F977E435` (`vehicle`) USING BTREE,
+  CONSTRAINT `carbusiness_ibfk_1` FOREIGN KEY (`taskId`) REFERENCES `transporttask` (`ID`),
+  CONSTRAINT `carbusiness_ibfk_2` FOREIGN KEY (`vehicle`) REFERENCES `vehicle` (`ID`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+-- ----------------------------
+-- Records of carbusiness
+-- ----------------------------
+
+-- ----------------------------
+-- Table structure for carBusiness
+-- ----------------------------
+DROP TABLE IF EXISTS `carBusiness`;
+CREATE TABLE `carBusiness` (
+  `ID` int(11) NOT NULL AUTO_INCREMENT,
+  `created_time` bigint(20) DEFAULT NULL,
+  `IsDeleted` tinyint(1) DEFAULT NULL,
+  `modify_time` bigint(20) DEFAULT NULL,
+  `DateOfFinishing` bigint(20) DEFAULT NULL,
+  `DateOfStarting` bigint(20) DEFAULT NULL,
+  `taskId` int(11) DEFAULT NULL,
+  `vehicle` int(11) DEFAULT NULL,
+  PRIMARY KEY (`ID`),
+  KEY `FKEA3D8FB4D76205CB` (`taskId`),
+  KEY `FKEA3D8FB4F977E435` (`vehicle`),
+  CONSTRAINT `FKEA3D8FB4F977E435` FOREIGN KEY (`vehicle`) REFERENCES `vehicle` (`ID`),
+  CONSTRAINT `FKEA3D8FB4D76205CB` FOREIGN KEY (`taskId`) REFERENCES `transportTask` (`ID`)
+) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;
+
+-- ----------------------------
+-- Records of carBusiness
+-- ----------------------------
+INSERT INTO `carBusiness` VALUES ('1', '1461554322418', '0', '1461554322418', '1464232721465', '1464146321465', null, '1');
+
+-- ----------------------------
+-- Table structure for cargo
+-- ----------------------------
+DROP TABLE IF EXISTS `cargo`;
+CREATE TABLE `cargo` (
+  `ID` int(11) NOT NULL AUTO_INCREMENT,
+  `created_time` bigint(20) DEFAULT NULL,
+  `IsDeleted` tinyint(1) DEFAULT NULL,
+  `modify_time` bigint(20) DEFAULT NULL,
+  `count` int(11) DEFAULT NULL,
+  `name` varchar(255) NOT NULL,
+  `price` int(11) DEFAULT NULL,
+  `weight` int(11) NOT NULL,
+  `taskId` int(11) DEFAULT NULL,
+  PRIMARY KEY (`ID`),
+  KEY `FK5A0E7BCD76205CB` (`taskId`) USING BTREE,
+  CONSTRAINT `cargo_ibfk_1` FOREIGN KEY (`taskId`) REFERENCES `transporttask` (`ID`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+-- ----------------------------
+-- Records of cargo
+-- ----------------------------
+
+-- ----------------------------
+-- Table structure for carrierbusiness
+-- ----------------------------
+DROP TABLE IF EXISTS `carrierbusiness`;
+CREATE TABLE `carrierbusiness` (
+  `ID` int(11) NOT NULL AUTO_INCREMENT,
+  `created_time` bigint(20) DEFAULT NULL,
+  `IsDeleted` tinyint(1) DEFAULT NULL,
+  `modify_time` bigint(20) DEFAULT NULL,
+  `isPayed` tinyint(1) DEFAULT NULL,
+  `companyId` int(11) DEFAULT NULL,
+  `taskId` int(11) DEFAULT NULL,
+  PRIMARY KEY (`ID`),
+  KEY `FK31178AD8B52220B2` (`companyId`) USING BTREE,
+  KEY `FK31178AD8D76205CB` (`taskId`) USING BTREE,
+  CONSTRAINT `carrierbusiness_ibfk_1` FOREIGN KEY (`companyId`) REFERENCES `company` (`ID`),
+  CONSTRAINT `carrierbusiness_ibfk_2` FOREIGN KEY (`taskId`) REFERENCES `transporttask` (`ID`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+-- ----------------------------
+-- Records of carrierbusiness
+-- ----------------------------
+
+-- ----------------------------
+-- Table structure for carrierBusiness
+-- ----------------------------
+DROP TABLE IF EXISTS `carrierBusiness`;
+CREATE TABLE `carrierBusiness` (
+  `ID` int(11) NOT NULL AUTO_INCREMENT,
+  `created_time` bigint(20) DEFAULT NULL,
+  `IsDeleted` tinyint(1) DEFAULT NULL,
+  `modify_time` bigint(20) DEFAULT NULL,
+  `isPayed` tinyint(1) DEFAULT NULL,
+  `companyId` int(11) DEFAULT NULL,
+  `taskId` int(11) DEFAULT NULL,
+  PRIMARY KEY (`ID`),
+  KEY `FK31178AD8B52220B2` (`companyId`),
+  KEY `FK31178AD8D76205CB` (`taskId`),
+  CONSTRAINT `FK31178AD8D76205CB` FOREIGN KEY (`taskId`) REFERENCES `transportTask` (`ID`),
+  CONSTRAINT `FK31178AD8B52220B2` FOREIGN KEY (`companyId`) REFERENCES `company` (`ID`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+-- ----------------------------
+-- Records of carrierBusiness
+-- ----------------------------
+
+-- ----------------------------
+-- Table structure for company
+-- ----------------------------
+DROP TABLE IF EXISTS `company`;
+CREATE TABLE `company` (
+  `ID` int(11) NOT NULL AUTO_INCREMENT,
+  `created_time` bigint(20) DEFAULT NULL,
+  `IsDeleted` tinyint(1) DEFAULT NULL,
+  `modify_time` bigint(20) DEFAULT NULL,
+  `companyName` varchar(255) DEFAULT NULL,
+  `corporation` varchar(255) DEFAULT NULL,
+  `introduction` varchar(255) DEFAULT NULL,
+  `phoneNumber` varchar(255) DEFAULT NULL,
+  PRIMARY KEY (`ID`)
+) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;
+
+-- ----------------------------
+-- Records of company
+-- ----------------------------
+INSERT INTO `company` VALUES ('2', '1461246269618', '0', '1461246269618', '顺丰', '王卫', '同城快递', '15345320123');
+
+-- ----------------------------
+-- Table structure for con_test
+-- ----------------------------
+DROP TABLE IF EXISTS `con_test`;
+CREATE TABLE `con_test` (
+  `a` char(1) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+-- ----------------------------
+-- Records of con_test
+-- ----------------------------
+
+-- ----------------------------
+-- Table structure for goods
+-- ----------------------------
+DROP TABLE IF EXISTS `goods`;
+CREATE TABLE `goods` (
+  `ID` int(11) NOT NULL AUTO_INCREMENT,
+  `created_time` bigint(20) DEFAULT NULL,
+  `IsDeleted` tinyint(1) DEFAULT NULL,
+  `modify_time` bigint(20) DEFAULT NULL,
+  `count` int(11) DEFAULT NULL,
+  `description` varchar(255) DEFAULT NULL,
+  `goodsName` varchar(255) DEFAULT NULL,
+  `price` int(11) DEFAULT NULL,
+  `sumPrice` int(11) NOT NULL,
+  `type` varchar(255) DEFAULT NULL,
+  `weight` varchar(255) DEFAULT NULL,
+  PRIMARY KEY (`ID`)
+) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;
+
+-- ----------------------------
+-- Records of goods
+-- ----------------------------
+INSERT INTO `goods` VALUES ('1', '1461246433696', '0', '1461554244830', '10', '快递车辆', '卡车', '1000000', '0', '1', '4000');
+INSERT INTO `goods` VALUES ('2', '1461327600412', '0', '1461327600412', '20', '上午公车', '汽车', '10000', '0', '2', '40000');
+
+-- ----------------------------
+-- Table structure for goodsgroup
+-- ----------------------------
+DROP TABLE IF EXISTS `goodsgroup`;
+CREATE TABLE `goodsgroup` (
+  `ID` int(11) NOT NULL AUTO_INCREMENT,
+  `created_time` bigint(20) DEFAULT NULL,
+  `IsDeleted` tinyint(1) DEFAULT NULL,
+  `modify_time` bigint(20) DEFAULT NULL,
+  `count` int(11) DEFAULT NULL,
+  `goods_ID` int(11) DEFAULT NULL,
+  `goodsRecord_ID` int(11) DEFAULT NULL,
+  PRIMARY KEY (`ID`),
+  KEY `FK102594C9475FC317` (`goods_ID`) USING BTREE,
+  KEY `FK102594C9A624C7D7` (`goodsRecord_ID`) USING BTREE,
+  CONSTRAINT `goodsgroup_ibfk_1` FOREIGN KEY (`goods_ID`) REFERENCES `goods` (`ID`),
+  CONSTRAINT `goodsgroup_ibfk_2` FOREIGN KEY (`goodsRecord_ID`) REFERENCES `goodsrecord` (`ID`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+-- ----------------------------
+-- Records of goodsgroup
+-- ----------------------------
+
+-- ----------------------------
+-- Table structure for goodsGroup
+-- ----------------------------
+DROP TABLE IF EXISTS `goodsGroup`;
+CREATE TABLE `goodsGroup` (
+  `ID` int(11) NOT NULL AUTO_INCREMENT,
+  `created_time` bigint(20) DEFAULT NULL,
+  `IsDeleted` tinyint(1) DEFAULT NULL,
+  `modify_time` bigint(20) DEFAULT NULL,
+  `count` int(11) DEFAULT NULL,
+  `goods_ID` int(11) DEFAULT NULL,
+  `goodsRecord_ID` int(11) DEFAULT NULL,
+  PRIMARY KEY (`ID`),
+  KEY `FK102594C9475FC317` (`goods_ID`),
+  KEY `FK102594C9A624C7D7` (`goodsRecord_ID`),
+  CONSTRAINT `FK102594C9A624C7D7` FOREIGN KEY (`goodsRecord_ID`) REFERENCES `goodsRecord` (`ID`),
+  CONSTRAINT `FK102594C9475FC317` FOREIGN KEY (`goods_ID`) REFERENCES `goods` (`ID`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+-- ----------------------------
+-- Records of goodsGroup
+-- ----------------------------
+
+-- ----------------------------
+-- Table structure for goodsrecord
+-- ----------------------------
+DROP TABLE IF EXISTS `goodsrecord`;
+CREATE TABLE `goodsrecord` (
+  `ID` int(11) NOT NULL AUTO_INCREMENT,
+  `created_time` bigint(20) DEFAULT NULL,
+  `IsDeleted` tinyint(1) DEFAULT NULL,
+  `modify_time` bigint(20) DEFAULT NULL,
+  `purpose` varchar(255) DEFAULT NULL,
+  `sumPrice` int(11) DEFAULT NULL,
+  `type` int(11) DEFAULT NULL,
+  `charger` int(11) DEFAULT NULL,
+  PRIMARY KEY (`ID`),
+  KEY `FK6959747F58A903B` (`charger`) USING BTREE,
+  CONSTRAINT `goodsrecord_ibfk_1` FOREIGN KEY (`charger`) REFERENCES `staff` (`ID`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+-- ----------------------------
+-- Records of goodsrecord
+-- ----------------------------
+
+-- ----------------------------
+-- Table structure for goodsRecord
+-- ----------------------------
+DROP TABLE IF EXISTS `goodsRecord`;
+CREATE TABLE `goodsRecord` (
+  `ID` int(11) NOT NULL AUTO_INCREMENT,
+  `created_time` bigint(20) DEFAULT NULL,
+  `IsDeleted` tinyint(1) DEFAULT NULL,
+  `modify_time` bigint(20) DEFAULT NULL,
+  `purpose` varchar(255) DEFAULT NULL,
+  `sumPrice` int(11) DEFAULT NULL,
+  `type` int(11) DEFAULT NULL,
+  `charger` int(11) DEFAULT NULL,
+  PRIMARY KEY (`ID`),
+  KEY `FK6959747F58A903B` (`charger`),
+  CONSTRAINT `FK6959747F58A903B` FOREIGN KEY (`charger`) REFERENCES `staff` (`ID`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+-- ----------------------------
+-- Records of goodsRecord
+-- ----------------------------
+
+-- ----------------------------
+-- Table structure for oilbuy
+-- ----------------------------
+DROP TABLE IF EXISTS `oilbuy`;
+CREATE TABLE `oilbuy` (
+  `ID` int(11) NOT NULL AUTO_INCREMENT,
+  `created_time` bigint(20) DEFAULT NULL,
+  `IsDeleted` tinyint(1) DEFAULT NULL,
+  `modify_time` bigint(20) DEFAULT NULL,
+  `litre` double DEFAULT NULL,
+  `price` double DEFAULT NULL,
+  `staff_ID` int(11) DEFAULT NULL,
+  `vehicle_ID` int(11) DEFAULT NULL,
+  PRIMARY KEY (`ID`),
+  KEY `FKC363AF54174A9ED7` (`staff_ID`) USING BTREE,
+  KEY `FKC363AF5492E7D817` (`vehicle_ID`) USING BTREE,
+  CONSTRAINT `oilbuy_ibfk_1` FOREIGN KEY (`staff_ID`) REFERENCES `staff` (`ID`),
+  CONSTRAINT `oilbuy_ibfk_2` FOREIGN KEY (`vehicle_ID`) REFERENCES `vehicle` (`ID`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+-- ----------------------------
+-- Records of oilbuy
+-- ----------------------------
+
+-- ----------------------------
+-- Table structure for oilBuy
+-- ----------------------------
+DROP TABLE IF EXISTS `oilBuy`;
+CREATE TABLE `oilBuy` (
+  `ID` int(11) NOT NULL AUTO_INCREMENT,
+  `created_time` bigint(20) DEFAULT NULL,
+  `IsDeleted` tinyint(1) DEFAULT NULL,
+  `modify_time` bigint(20) DEFAULT NULL,
+  `litre` double DEFAULT NULL,
+  `price` double DEFAULT NULL,
+  `staff_ID` int(11) DEFAULT NULL,
+  `vehicle_ID` int(11) DEFAULT NULL,
+  PRIMARY KEY (`ID`),
+  KEY `FKC363AF54174A9ED7` (`staff_ID`),
+  KEY `FKC363AF5492E7D817` (`vehicle_ID`),
+  CONSTRAINT `FKC363AF5492E7D817` FOREIGN KEY (`vehicle_ID`) REFERENCES `vehicle` (`ID`),
+  CONSTRAINT `FKC363AF54174A9ED7` FOREIGN KEY (`staff_ID`) REFERENCES `staff` (`ID`)
+) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;
+
+-- ----------------------------
+-- Records of oilBuy
+-- ----------------------------
+INSERT INTO `oilBuy` VALUES ('1', '1461246375873', '0', '1461246375873', '30', '210', '1', '1');
+
+-- ----------------------------
+-- Table structure for repair
+-- ----------------------------
+DROP TABLE IF EXISTS `repair`;
+CREATE TABLE `repair` (
+  `ID` int(11) NOT NULL AUTO_INCREMENT,
+  `created_time` bigint(20) DEFAULT NULL,
+  `IsDeleted` tinyint(1) DEFAULT NULL,
+  `modify_time` bigint(20) DEFAULT NULL,
+  `reasonDesc` varchar(255) DEFAULT NULL,
+  `goodsRecord_id` int(11) DEFAULT NULL,
+  `repairman` int(11) DEFAULT NULL,
+  `vehicle_id` int(11) DEFAULT NULL,
+  PRIMARY KEY (`ID`),
+  KEY `FKC84C1F8DA624C7D7` (`goodsRecord_id`) USING BTREE,
+  KEY `FKC84C1F8D9C0A9AAA` (`repairman`) USING BTREE,
+  KEY `FKC84C1F8D92E7D817` (`vehicle_id`) USING BTREE,
+  CONSTRAINT `repair_ibfk_1` FOREIGN KEY (`vehicle_id`) REFERENCES `vehicle` (`ID`),
+  CONSTRAINT `repair_ibfk_2` FOREIGN KEY (`repairman`) REFERENCES `staff` (`ID`),
+  CONSTRAINT `repair_ibfk_3` FOREIGN KEY (`goodsRecord_id`) REFERENCES `goodsrecord` (`ID`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+-- ----------------------------
+-- Records of repair
+-- ----------------------------
+
+-- ----------------------------
+-- Table structure for staff
+-- ----------------------------
+DROP TABLE IF EXISTS `staff`;
+CREATE TABLE `staff` (
+  `ID` int(11) NOT NULL AUTO_INCREMENT,
+  `created_time` bigint(20) DEFAULT NULL,
+  `IsDeleted` tinyint(1) DEFAULT NULL,
+  `modify_time` bigint(20) DEFAULT NULL,
+  `dateOfHire` bigint(20) DEFAULT NULL,
+  `gender` varchar(255) DEFAULT NULL,
+  `idCardNumber` varchar(255) NOT NULL,
+  `job` varchar(255) DEFAULT NULL,
+  `levelOfEducation` varchar(255) DEFAULT NULL,
+  `phoneNumber` varchar(255) DEFAULT NULL,
+  `politicalGroup` varchar(255) DEFAULT NULL,
+  `realName` varchar(255) NOT NULL,
+  `salary` int(11) DEFAULT NULL,
+  `state` varchar(255) DEFAULT NULL,
+  `typeOfEmployment` varchar(255) DEFAULT NULL,
+  PRIMARY KEY (`ID`)
+) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;
+
+-- ----------------------------
+-- Records of staff
+-- ----------------------------
+INSERT INTO `staff` VALUES ('1', '1461210956366', '0', '1461554216105', '-56615748184278', '男', '370785198911246514', '经理', '本科', '15335320821', '', 'thankful', '10000', '普通', null);
+INSERT INTO `staff` VALUES ('2', '1461211073536', '0', '1461211073536', '1423367873480', '男', '370785198911246514', '经理', '本科', '15335320821', '', 'thankful2', '10000', '普通', null);
+INSERT INTO `staff` VALUES ('3', '1461327397991', '0', '1461327397991', '1464005640957', '女', '370785198911146547', '2', '本科', '', '', '葵花', '2', '普通', null);
+
+-- ----------------------------
+-- Table structure for transporttask
+-- ----------------------------
+DROP TABLE IF EXISTS `transporttask`;
+CREATE TABLE `transporttask` (
+  `ID` int(11) NOT NULL AUTO_INCREMENT,
+  `created_time` bigint(20) DEFAULT NULL,
+  `IsDeleted` tinyint(1) DEFAULT NULL,
+  `modify_time` bigint(20) DEFAULT NULL,
+  `endDate` bigint(20) DEFAULT NULL,
+  `endPlace` varchar(255) NOT NULL,
+  `queryId` varchar(255) NOT NULL,
+  `rate` double DEFAULT NULL,
+  `startDate` bigint(20) DEFAULT NULL,
+  `startPlace` varchar(255) NOT NULL,
+  `state` int(11) DEFAULT NULL,
+  `sumPrice` int(11) DEFAULT NULL,
+  `title` varchar(255) DEFAULT NULL,
+  `type` int(11) DEFAULT NULL,
+  `customer` int(11) DEFAULT NULL,
+  PRIMARY KEY (`ID`),
+  KEY `FKA8D8E44EE04FBAEC` (`customer`) USING BTREE,
+  CONSTRAINT `transporttask_ibfk_1` FOREIGN KEY (`customer`) REFERENCES `user` (`ID`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+-- ----------------------------
+-- Records of transporttask
+-- ----------------------------
+
+-- ----------------------------
+-- Table structure for transportTask
+-- ----------------------------
+DROP TABLE IF EXISTS `transportTask`;
+CREATE TABLE `transportTask` (
+  `ID` int(11) NOT NULL AUTO_INCREMENT,
+  `created_time` bigint(20) DEFAULT NULL,
+  `IsDeleted` tinyint(1) DEFAULT NULL,
+  `modify_time` bigint(20) DEFAULT NULL,
+  `endDate` bigint(20) DEFAULT NULL,
+  `endPlace` varchar(255) NOT NULL,
+  `queryId` varchar(255) NOT NULL,
+  `rate` double DEFAULT NULL,
+  `startDate` bigint(20) DEFAULT NULL,
+  `startPlace` varchar(255) NOT NULL,
+  `state` int(11) DEFAULT NULL,
+  `sumPrice` int(11) DEFAULT NULL,
+  `title` varchar(255) DEFAULT NULL,
+  `type` int(11) DEFAULT NULL,
+  `customer` int(11) DEFAULT NULL,
+  PRIMARY KEY (`ID`),
+  KEY `FKA8D8E44EE04FBAEC` (`customer`),
+  CONSTRAINT `FKA8D8E44EE04FBAEC` FOREIGN KEY (`customer`) REFERENCES `user` (`ID`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+-- ----------------------------
+-- Records of transportTask
+-- ----------------------------
+
+-- ----------------------------
+-- Table structure for user
+-- ----------------------------
+DROP TABLE IF EXISTS `user`;
+CREATE TABLE `user` (
+  `ID` int(11) NOT NULL AUTO_INCREMENT,
+  `created_time` bigint(20) DEFAULT NULL,
+  `IsDeleted` tinyint(1) DEFAULT NULL,
+  `modify_time` bigint(20) DEFAULT NULL,
+  `address` varchar(255) DEFAULT NULL,
+  `email` varchar(255) DEFAULT NULL,
+  `name` varchar(255) DEFAULT NULL,
+  `password` varchar(255) NOT NULL,
+  `phone` varchar(255) DEFAULT NULL,
+  PRIMARY KEY (`ID`)
+) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;
+
+-- ----------------------------
+-- Records of user
+-- ----------------------------
+INSERT INTO `user` VALUES ('1', '1461134768217', '0', '1461249083843', '13-1301-130123-', '1@1.com', 'admin', '123456', '15335320821');
+
+-- ----------------------------
+-- Table structure for vehicle
+-- ----------------------------
+DROP TABLE IF EXISTS `vehicle`;
+CREATE TABLE `vehicle` (
+  `ID` int(11) NOT NULL AUTO_INCREMENT,
+  `created_time` bigint(20) DEFAULT NULL,
+  `IsDeleted` tinyint(1) DEFAULT NULL,
+  `modify_time` bigint(20) DEFAULT NULL,
+  `carNumber` varchar(255) DEFAULT NULL,
+  `color` varchar(255) DEFAULT NULL,
+  `identity` varchar(255) NOT NULL,
+  `driver` int(11) DEFAULT NULL,
+  `vehicleType` int(11) DEFAULT NULL,
+  PRIMARY KEY (`ID`),
+  KEY `FK14638F2C7A99F425` (`driver`) USING BTREE,
+  KEY `FK14638F2CF62F5449` (`vehicleType`) USING BTREE,
+  CONSTRAINT `vehicle_ibfk_1` FOREIGN KEY (`driver`) REFERENCES `staff` (`ID`),
+  CONSTRAINT `vehicle_ibfk_2` FOREIGN KEY (`vehicleType`) REFERENCES `vehicletype` (`ID`)
+) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;
+
+-- ----------------------------
+-- Records of vehicle
+-- ----------------------------
+INSERT INTO `vehicle` VALUES ('1', '1461210261208', '0', '1461554254773', '法拉利', '黄色', 'a', null, null);
+
+-- ----------------------------
+-- Table structure for vehicletype
+-- ----------------------------
+DROP TABLE IF EXISTS `vehicletype`;
+CREATE TABLE `vehicletype` (
+  `ID` int(11) NOT NULL AUTO_INCREMENT,
+  `created_time` bigint(20) DEFAULT NULL,
+  `IsDeleted` tinyint(1) DEFAULT NULL,
+  `modify_time` bigint(20) DEFAULT NULL,
+  `capacity` int(11) DEFAULT NULL,
+  `description` varchar(255) NOT NULL,
+  `height` int(11) DEFAULT NULL,
+  `length` int(11) DEFAULT NULL,
+  `oilType` int(11) DEFAULT NULL,
+  `seat` int(11) DEFAULT NULL,
+  `width` int(11) DEFAULT NULL,
+  PRIMARY KEY (`ID`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+-- ----------------------------
+-- Records of vehicletype
+-- ----------------------------
+
+-- ----------------------------
+-- Table structure for VehicleType
+-- ----------------------------
+DROP TABLE IF EXISTS `VehicleType`;
+CREATE TABLE `VehicleType` (
+  `ID` int(11) NOT NULL AUTO_INCREMENT,
+  `created_time` bigint(20) DEFAULT NULL,
+  `IsDeleted` tinyint(1) DEFAULT NULL,
+  `modify_time` bigint(20) DEFAULT NULL,
+  `capacity` int(11) DEFAULT NULL,
+  `description` varchar(255) NOT NULL,
+  `height` int(11) DEFAULT NULL,
+  `length` int(11) DEFAULT NULL,
+  `oilType` int(11) DEFAULT NULL,
+  `seat` int(11) DEFAULT NULL,
+  `width` int(11) DEFAULT NULL,
+  PRIMARY KEY (`ID`)
+) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;
+
+-- ----------------------------
+-- Records of VehicleType
+-- ----------------------------
+INSERT INTO `VehicleType` VALUES ('1', '1461246358156', '0', '1461554264251', '20', '卡车', '3', '10', '3', '30', '4');

+ 92 - 0
src/main/java/com/logistics/conf/AdminAdd.java

@@ -0,0 +1,92 @@
+package com.logistics.conf;
+
+import com.logistics.crypto.CryptoBase;
+import com.logistics.entity.Admin;
+import com.logistics.service.AdminService;
+import com.logistics.service.Impl.AdminServiceImpl;
+import org.hibernate.Criteria;
+import org.hibernate.Session;
+import org.hibernate.SessionFactory;
+import org.hibernate.criterion.DetachedCriteria;
+import org.hibernate.criterion.Restrictions;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+import org.springframework.web.context.ContextLoader;
+import org.springframework.web.context.WebApplicationContext;
+
+import java.nio.ByteBuffer;
+import java.util.List;
+
+/**
+ * Created by Mklaus on 15/9/3.
+ */
+
+public class AdminAdd {
+
+
+
+    public static void main(String[] args) {
+
+        ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext-common.xml");
+        SessionFactory sessionFactory = (SessionFactory) context.getBean("sessionFactory");
+        Session session = sessionFactory.openSession();
+
+        System.out.println("Admin Toolkit - AdminAdd");
+        System.out.println("WARNING: This tool is used to create admin id, WITHOUT any privilege check.");
+
+        AdminService adminService = new AdminServiceImpl();
+
+        System.out.println("Add Admin...");
+
+        String username = args[0];
+        System.out.println("Using username:"+username);
+        String password = args[1];
+        System.out.println("Using password:"+password);
+
+
+        try {
+            session.beginTransaction();
+
+            if (isExists(username, session)){
+                throw new Exception("username already exists : " + username);
+            }
+
+            register(new Admin(username, password.getBytes("UTF-8"), 1), session);
+
+            session.getTransaction().commit();
+
+        }catch (Exception ex){
+            ex.printStackTrace();
+            System.out.println("Operation failed.\nUSAGE: AdminAdd username password");
+            System.out.println("And check if:\n* username is unique\n* write access to database\n* your OS/JRE supports UTF-8");
+        }
+
+        System.out.println("create success.");
+    }
+
+
+    public static boolean isExists(String adminName,Session session) {
+        DetachedCriteria dc = DetachedCriteria.forClass(Admin.class);
+        dc.add(Restrictions.eq("adminName", adminName));
+        List<Admin> list = dc.getExecutableCriteria(session).list();
+        if (list.size() > 0){
+            return true;
+        }
+        return false;
+    }
+
+    public static void register(Admin admin,Session session){
+        CryptoBase cb = CryptoBase.getInstance();
+
+        byte[] salt = cb.randomBytes(Configurator.getInstance().getInt("logistics.admin.saltlength", 4));
+        admin.setSalt(salt);
+
+        byte[] buf = ByteBuffer.allocate(admin.getPassword().length + salt.length)
+                .put(admin.getPassword())
+                .put(salt)
+                .array();
+        admin.setPassword(cb.MD5Digest(buf));
+        session.save(admin);
+    }
+}

+ 168 - 0
src/main/java/com/logistics/conf/Configurator.java

@@ -0,0 +1,168 @@
+package com.logistics.conf;
+
+/**
+ * Created by Mklaus on 15/7/17.
+ */
+
+import java.io.InputStreamReader;
+import java.util.Properties;
+
+/**
+ * 从 /logistics.properties 读取参数并供应给应用程序
+ */
+public class Configurator
+{
+    // CONSTRUCT
+    private Properties prop;
+
+    private Configurator()
+    {
+        this.load();
+
+        return;
+    }
+
+    // SINGLETON
+    private static class Singleton
+    {
+        public static final Configurator INSTANCE = new Configurator();
+    }
+
+    public static Configurator getInstance()
+    {
+        return(Singleton.INSTANCE);
+    }
+
+    /** 加载配置文件
+     */
+    private void load()
+    {
+        try
+        {
+            InputStreamReader is;
+
+            is = new InputStreamReader(
+                    this.getClass()
+                            .getResourceAsStream("/logisticsSystem.properties"),
+                    "utf-8"
+            );
+
+            this.prop = new Properties();
+            this.prop.load(is);
+            is.close();
+        }
+        catch (Exception ex)
+        {
+            throw(new RuntimeException(ex));
+        }
+    }
+
+    /** 重载配置文件
+     */
+    public void reload()
+    {
+        this.load();
+    }
+
+    /** 获得整个属性库的只读副本
+     * 本质上是将原有 prop 作为默认表创建新表并返回.
+     * 因此, 对得到的表作出的修改不会影响到原表.
+     */
+    public Properties getProperties()
+    {
+        Properties prop = new Properties(this.prop);
+
+        return(prop);
+    }
+
+
+    /**
+     * 提取配置文件中的参数
+     */
+    public String get(String name)
+    {
+        return(
+                this.prop.getProperty(name)
+        );
+    }
+
+    public String get(String name, String defaultValue)
+    {
+        String v = this.prop.getProperty(name);
+
+        return(
+                v!=null ? v : null
+        );
+    }
+
+
+    public Integer getInt(String name)
+    {
+        try
+        {
+            String v = this.get(name);
+            return(
+                    v!=null ? Integer.valueOf(v) : null
+            );
+        }
+        catch (Exception ex)
+        {
+            throw(new RuntimeException(ex));
+        }
+    }
+
+    public Integer getInt(String name, Integer defaultValue)
+    {
+        Integer v = this.getInt(name);
+        return(
+                v!=null ? v : defaultValue
+        );
+    }
+
+    public Long getLong(String name)
+    {
+        try
+        {
+            String v = this.get(name);
+            return(
+                    v!=null ? Long.valueOf(v) : null
+            );
+        }
+        catch (Exception ex)
+        {
+            throw(new RuntimeException(ex));
+        }
+    }
+
+    public Long getLong(String name, Long defaultValue)
+    {
+        Long v = this.getLong(name);
+        return(
+                v!=null ? v : defaultValue
+        );
+    }
+
+    public Double getDouble(String name)
+    {
+        try
+        {
+            String v = this.get(name);
+            return(
+                    v!=null ? Double.valueOf(v) : null
+            );
+        }
+        catch (Exception ex)
+        {
+            throw(new RuntimeException(ex));
+        }
+    }
+
+    public Double getDouble(String name, Double defaultValue)
+    {
+        Double v = this.getDouble(name);
+        return(
+                v!=null ? v : defaultValue
+        );
+    }
+}
+

+ 18 - 0
src/main/java/com/logistics/conf/Constants.java

@@ -0,0 +1,18 @@
+package com.logistics.conf;
+
+/**
+ * Created by Mklaus on 15/7/30.
+ */
+public class Constants {
+
+    // ERROR HANDLING
+    public static final String KEY_EXCEPTION        = "logisticsSystem.exception";
+    //public static final String KEY_RESULT           = "result";
+    public static final String URI_ERROR_HANDLER    = "/sys/exception.api";
+
+    //ADMIN
+    public static final String ADMIN_UID = "ls.admin.uid";
+
+    //USER
+    public static final String USER_UID  = "ls.user.uid";
+}

+ 71 - 0
src/main/java/com/logistics/controller/AddressController.java

@@ -0,0 +1,71 @@
+package com.logistics.controller;
+
+import com.alibaba.fastjson.JSONObject;
+import com.logistics.conf.Configurator;
+import com.logistics.entity.Address;
+import com.logistics.service.AddressService;
+import com.logistics.util.JsonUtil;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.util.List;
+
+import static com.logistics.util.Params.needLongList;
+
+/**
+ * Created by Mklaus on 15/8/24.
+ */
+@Controller
+@RequestMapping("address")
+public class AddressController {
+    @Resource
+    private AddressService addressService;
+
+    @RequestMapping(method = RequestMethod.GET, params = "json")
+    public void address_GET_json_hql(Integer start, Integer size, HttpServletResponse resp) throws IOException {
+        start = start != null ? start : 0;
+        size = size != null ? size : Configurator.getInstance().getInt("defaultPageSize");
+        List<Address> l = addressService.get(start, size);
+        JSONObject json = new JSONObject();
+        json.put("addressLength", addressService.getAll().size());
+        JsonUtil.write(l, "addresses", json, resp);
+    }
+
+    @RequestMapping(method = RequestMethod.GET, params = "level")
+    public void address_GET_json_byLevel(int level, HttpServletResponse resp) throws IOException {
+        List<Address> l = addressService.getByLevel(level);
+        JsonUtil.write(l, resp);
+    }
+
+    @RequestMapping(method = RequestMethod.POST, params = "json")
+    public void address_CREATE_json(Address address, Integer parentId, HttpServletResponse resp) throws IOException {
+        Integer id = addressService.add(address, parentId);
+        JsonUtil.write(id.toString(), resp);
+    }
+
+    @RequestMapping(method = RequestMethod.DELETE, params = "json")
+    public void address_DELETE_json(Integer addressId, HttpServletResponse resp) throws IOException {
+        addressService.delete(addressId);
+        JsonUtil.write("1", resp);
+    }
+
+    @RequestMapping(method = RequestMethod.DELETE, params = "many")
+    public void address_DELETE_json_many(HttpServletRequest req, HttpServletResponse resp) throws IOException {
+        List<Long> ids = needLongList(req, "ids");
+        for (long id : ids) {
+            addressService.delete((int) id);
+        }
+        JsonUtil.writeMsg("1", resp);
+    }
+
+    @RequestMapping(method = RequestMethod.PUT, params = "json")
+    public void address_UPDATE_json(Address address, HttpServletResponse resp) throws IOException {
+        addressService.update(address);
+        JsonUtil.write("1", resp);
+    }
+}

+ 212 - 0
src/main/java/com/logistics/controller/AdminController.java

@@ -0,0 +1,212 @@
+package com.logistics.controller;
+
+import com.alibaba.fastjson.JSONObject;
+import com.logistics.conf.Constants;
+import com.logistics.crypto.RSAKeyCache;
+import com.logistics.entity.Admin;
+import com.logistics.service.AdminService;
+import com.logistics.util.JsonUtil;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+import java.io.IOException;
+import java.security.interfaces.RSAPublicKey;
+import java.util.Arrays;
+import java.util.List;
+
+import static com.logistics.crypto.CryptoBase.byteToHex;
+import static com.logistics.util.Params.needByteArray;
+import static com.logistics.util.Params.needString;
+
+/**
+ * Created by Mklaus on 15/8/16.
+ */
+@Controller
+@RequestMapping("admin")
+public class AdminController {
+    @Resource
+    private AdminService adminService;
+
+    /**
+     * <p>获取公钥</p>
+     * <p>POST      /admin/get_rsa_key</p>
+     * @param adminName
+     * @param resp
+     * @throws IOException
+     */
+    @RequestMapping(value = "get_rsa_key",method = RequestMethod.POST)
+    public void get_rsa_key(String adminName,HttpServletResponse resp) throws IOException {
+        System.out.println("rsa in " + adminName);
+        JSONObject json = new JSONObject();
+        int id;
+        if ((id = adminService.getIdByAdminName(adminName)) < 0){
+            System.out.println("error");
+            json.put("status",-1);
+        }else {
+
+            RSAPublicKey pk = (RSAPublicKey) RSAKeyCache.getInstance().genKey((long) id);
+
+
+            byte[] m = pk.getModulus().toByteArray();
+            if (m[0] == 0)
+                m = Arrays.copyOfRange(m, 1, m.length);
+            byte[] e = pk.getPublicExponent().toByteArray();
+            if (e[0] == 0)
+                e = Arrays.copyOfRange(e, 1, e.length);
+
+            json.put("m", byteToHex(m));
+            json.put("e", byteToHex(e));
+
+            System.out.println("OK");
+        }
+
+        JsonUtil.write(json,resp);
+    }
+
+
+    /**
+     * <p>跳转到管理员添加页面</p>
+     * <p>GET       /admin/register</p>
+     * @return
+     */
+    @RequestMapping(value = "register",method = RequestMethod.GET)
+    public String register(){
+        return "/admin/adminRegister";
+    }
+
+    /**
+     * <p>管理员注册</p>
+     * <p>POST      /admin/doRegister</p>
+     * @param req
+     * @param resp
+     * @throws IOException
+     */
+    @RequestMapping(method = RequestMethod.POST)
+    public void doRegister(Integer type,HttpServletRequest req,HttpServletResponse resp) throws IOException {
+        Admin login;
+        String password  = needString(req,"password");
+        String adminName = needString(req,"adminName");
+
+        if (!adminService.isExists(adminName)) {
+           if((login = adminService.register(new Admin(adminName,password.getBytes("UTF-8"),type))) != null) {
+               JsonUtil.writeMsg("1", resp);
+           }
+        }else {
+            JsonUtil.writeMsg("user already exists", resp);
+        }
+
+    }
+
+    @RequestMapping(method = RequestMethod.GET)
+    public void admin_GET(Integer start,Integer size,HttpServletResponse resp) throws IOException{
+        start = (start != null) ? start : 0;
+        size  = (size != null) ? size : 10;
+        List<Admin> l = adminService.get(start,size);
+        JSONObject json = new JSONObject();
+        json.put("adminLength",adminService.getAll().size());
+        JsonUtil.write(l,"admins",json,resp);
+    }
+
+    @RequestMapping(method = RequestMethod.DELETE)
+    public void admin_DELETE(Integer adminId,HttpServletResponse resp) throws IOException{
+        adminService.delete(adminId);
+        JsonUtil.writeMsg("1",resp);
+    }
+
+    /**
+     *  --------- login and logout ----------
+     * */
+
+    /**
+     * <p>跳转到登录页面</p>
+     * <p>GET       /admin/login</p>
+     * @return
+     */
+    @RequestMapping(value = "login",method = RequestMethod.GET)
+    public String login(){
+        return "/admin/adminLogin";
+    }
+
+    /**
+     * <p>登录处理</p>
+     * <p>POST      /admin/doLogin</p>
+     * @param session
+     * @param req
+     * @param resp
+     * @throws IOException
+     */
+    @RequestMapping("doLogin")
+    public void doLogin(HttpSession session,HttpServletRequest req,HttpServletResponse resp) throws IOException {
+        Admin login;
+        JSONObject json = new JSONObject();
+        byte[] password  = needByteArray(req,"password");
+        String adminName = needString(req,"adminName");
+
+        if ((login = adminService.login(new Admin(adminName,password))) != null){
+            System.out.println("success");
+            session.setAttribute(Constants.ADMIN_UID,login.getId());
+            json.put("status",0);
+        }else {
+            json.put("status",-1);
+        }
+        JsonUtil.write(json,resp);
+    }
+
+    /**
+     * <p>登录成功跳转</p>
+     * <p>GET       /admin/loginSuccess</p>
+     * @param session
+     * @param model
+     * @return
+     */
+    @RequestMapping("loginSuccess")
+    public String loginSuccess(HttpSession session,Model model){
+        int id = (Integer)session.getAttribute(Constants.ADMIN_UID);
+        Admin admin = adminService.get(id);
+        model.addAttribute("admin", admin);
+        return "/common/start";
+    }
+
+    /**
+     * <p>获取用户信息</p>
+     * <p>GET    /user?json</p>
+     *
+     * @throws IOException 返回JSON数据给前端时可能会抛出这个异常
+     */
+    @RequestMapping(method = RequestMethod.GET, params = "json")
+    public void user_GET_json(HttpSession session, HttpServletResponse resp) throws IOException {
+        Integer id = (Integer) session.getAttribute(Constants.ADMIN_UID);
+        Admin admin = adminService.get(id);
+        JsonUtil.write(admin, resp);
+    }
+
+
+    /**
+     * <p>登出</p>
+     * <P>GET       /admin/logout</P>
+     * @param req
+     * @return
+     */
+    @RequestMapping("logout")
+    public String logout(HttpServletRequest req){
+        req.getSession().removeAttribute(Constants.ADMIN_UID);
+        return "redirect:/index.jsp";
+    }
+
+    @RequestMapping(value = "passwd",method = RequestMethod.POST)
+    public void passwd(String oldPass,String newPass,HttpSession session,HttpServletResponse resp) throws IOException{
+        Integer id = (Integer)session.getAttribute(Constants.ADMIN_UID);
+        Admin admin = adminService.get(id);
+        if (adminService.passwd(admin,oldPass,newPass)){
+            JsonUtil.writeMsg("1",resp);
+        }else {
+            JsonUtil.writeMsg("-1",resp);
+        }
+    }
+}

+ 123 - 0
src/main/java/com/logistics/controller/CarBusinessController.java

@@ -0,0 +1,123 @@
+package com.logistics.controller;
+
+import com.alibaba.fastjson.JSONObject;
+import com.logistics.conf.Configurator;
+import com.logistics.entity.CarBusiness;
+import com.logistics.service.CarBusinessService;
+import com.logistics.util.JsonUtil;
+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.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.util.List;
+
+import static com.logistics.util.Params.needLongList;
+
+/**
+ * Created by Ranger on 2015/8/18.
+ */
+@Controller
+@RequestMapping("carBusiness")
+public class CarBusinessController {
+    @Resource
+    CarBusinessService carBusinessService;
+
+    /**
+     * <p>增加单车运营记录</p>
+     * <p>POST    /carBusiness</p>
+     *
+     * @param carBusiness 需要添加的单车运营记录
+     * @param taskId      任务单的ID
+     * @param vehicleId   运输车辆ID
+     * @throws java.io.IOException 返回JSON数据给前端可能会抛出这个异常
+     */
+    @RequestMapping(method = RequestMethod.POST)
+    public void addRec(CarBusiness carBusiness, Integer taskId, Integer vehicleId, HttpServletResponse response) throws IOException {
+        Integer returnValue;
+        if ((returnValue = carBusinessService.add(taskId, vehicleId, carBusiness)) != null) {
+            JsonUtil.writeMsg(returnValue.toString(), response);
+        } else {
+            JsonUtil.writeMsg("-1", response);
+        }
+    }
+
+    /**
+     * <p>删除单车运营记录</p>
+     * <p>DELETE    /carBusiness</p>
+     *
+     * @param id 需要删除的单车运营记录的ID数组
+     */
+    @RequestMapping(method = RequestMethod.DELETE)
+    public void deleteRec(int id, HttpServletResponse resp) throws IOException {
+        CarBusiness c = carBusinessService.get(id);
+        c.setTask(null);
+        c.setVehicle(null);
+        carBusinessService.delete(c);
+        JsonUtil.writeMsg("1", resp);
+    }
+
+    @RequestMapping(method = RequestMethod.DELETE, params = "many")
+    public void deleteMany(HttpServletRequest req, HttpServletResponse resp) throws IOException {
+        List<Long> ids = needLongList(req, "ids");
+        System.out.println(ids.size());
+        for (long id : ids) {
+            carBusinessService.delete((int) id);
+        }
+        JsonUtil.writeMsg("1", resp);
+    }
+
+    /**
+     * <p>获取单车运营记录</p>
+     * <p>GET    /carBusiness</p>
+     *
+     * @param start 从该条记录开始显示
+     * @param size  页面显示的记录条数
+     * @throws java.io.IOException 返回JSON数据给前端可能会抛出这个异常
+     */
+    @RequestMapping(method = RequestMethod.GET)
+    public void getJsonRec(Integer start, Integer size, HttpServletResponse response) throws IOException {
+        start = (start != null) ? start : 0;
+        size = (size != null) ? size : Configurator.getInstance().getInt("defaultPageSize");
+        List<CarBusiness> carBussinessList = carBusinessService.get(start, size);
+        JSONObject json = new JSONObject();
+        json.put("carBussinessLength", carBusinessService.getAll().size());
+        JsonUtil.write(carBussinessList, "carBussinessList", json, response);
+    }
+
+    /**
+     * <p>显示单个单车运营记录</p>
+     * <p>GET    /carBusiness</p>
+     *
+     * @param carBusinessID 需要查找的单车运营记录的ID
+     * @throws java.io.IOException 返回JSON数据给前端可能会抛出这个异常
+     */
+    @RequestMapping(value = "{carBusinessID}", method = RequestMethod.GET)
+    public void getJsonRec(@PathVariable("carBusinessID") Integer carBusinessID, HttpServletResponse response) throws IOException {
+        CarBusiness carBusiness = carBusinessService.get(carBusinessID);
+        JsonUtil.write(carBusiness, response);
+    }
+
+    /**
+     * <p>修改单车运营记录</p>
+     * <p>PUT    /carBusiness</p>
+     *  @param taskId      任务单的ID
+     * @param vehicleId   运输车辆ID
+     * @param carBusiness 修改后的单车运营记录
+     * @param resp
+     */
+    @RequestMapping(method = RequestMethod.PUT)
+    public void updateCarBusinessRec(Integer taskId, Integer vehicleId, CarBusiness carBusiness, HttpServletResponse resp) throws IOException {
+        carBusinessService.update(taskId, vehicleId, carBusiness);
+        JsonUtil.writeMsg("1", resp);
+    }
+
+    @RequestMapping(value = "{taskId}", method = RequestMethod.GET, params = "taskId")
+    public void getCargoByTaskId(@PathVariable("taskId") int taskId, HttpServletResponse response) throws IOException {
+        JsonUtil.write(carBusinessService.getCarBusinessByTaskId(taskId), response);
+    }
+}

+ 117 - 0
src/main/java/com/logistics/controller/CargoController.java

@@ -0,0 +1,117 @@
+package com.logistics.controller;
+
+import com.alibaba.fastjson.JSONObject;
+import com.logistics.conf.Configurator;
+import com.logistics.entity.Cargo;
+import com.logistics.service.CargoService;
+import com.logistics.util.JsonUtil;
+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.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.util.List;
+
+/**
+ * Created by Ranger on 2015/8/21.
+ */
+@Controller
+@RequestMapping("cargo")
+public class CargoController {
+    @Resource
+    private CargoService cargoService;
+
+    /**
+     * <p>添加货物信息</p>
+     * <p>POST    /cargo</p>
+     *
+     * @param cargo  需要添加的货物记录
+     * @param taskId 与货物相关联的运输任务的ID
+     * @throws IOException 传数据给前端时可能会抛出这个异常
+     */
+    @RequestMapping(method = RequestMethod.POST)
+    public void add(Cargo cargo, Integer taskId, HttpServletResponse response) throws IOException {
+        Integer id = cargoService.add(cargo, taskId);
+        if (id != null) {
+            JsonUtil.writeMsg(id.toString(), response);
+        } else {
+            JsonUtil.writeMsg("-1", response);
+        }
+    }
+
+    /**
+     * <p>删除货物信息</p>
+     * <p>DELETE    /cargo</p>
+     *
+     * @param request 需要在该参数中添加一个类型为int[]名为idArray的属性,
+     *                方法会取出所有在idArray里面的数据并以此作为id删除相应的记录
+     */
+    @RequestMapping(method = RequestMethod.DELETE)
+    public void delete(HttpServletRequest request) {
+        int[] idArray = (int[]) request.getAttribute("idArray");
+        for (int id : idArray) {
+            cargoService.delete(id);
+        }
+    }
+
+    /**
+     * <p>查询货物记录</p>
+     * <p>GET    /cargo</p>
+     *
+     * @param start 从该条记录开始显示
+     * @param size  页面显示的记录条数
+     * @throws IOException 传数据给前端时可能会抛出这个异常
+     */
+    @RequestMapping(method = RequestMethod.GET, params = "json")
+    public void get(Integer start, Integer size, HttpServletResponse response) throws IOException {
+        start = (start != null) ? start : 0;
+        size = (size != null) ? size : Configurator.getInstance().getInt("defaultPageSize");
+        List<Cargo> cargoList = cargoService.get(start, size);
+
+        JSONObject json = new JSONObject();
+        json.put("cargoListLength", cargoService.getAll().size());
+        JsonUtil.write(cargoList, "cargoList", json, response);
+    }
+
+    /**
+     * <p>查询单个货物记录</p>
+     * <p>GET    /cargo/{cargoId}</p>
+     *
+     * @param cargoId 需要查询的记录的ID
+     * @throws IOException 传数据给前端时可能会抛出这个异常
+     */
+    @RequestMapping(value = "{cargoId}", method = RequestMethod.GET, params = "json")
+    public void get(@PathVariable("cargoId") Integer cargoId, HttpServletResponse response) throws IOException {
+        JsonUtil.write(cargoService.get(cargoId), response);
+    }
+
+    /**
+     * <p>修改货物记录</p>
+     * <p>PUT    /cargo</p>
+     *
+     * @param cargo  修改后的货物信息
+     * @param taskId 与货物相关联的运输任务的ID
+     */
+    @RequestMapping(method = RequestMethod.PUT)
+    public void update(Cargo cargo, Integer taskId) {
+        cargoService.update(cargo, taskId);
+    }
+
+    /**
+     * 根据taskID取得记录
+     *
+     * @param taskId
+     * @param response
+     * @throws IOException
+     */
+    @RequestMapping(value = "{taskId}", method = RequestMethod.GET, params = "taskId")
+    public void getCargoByTaskId(@PathVariable("taskId") int taskId, HttpServletResponse response) throws IOException {
+        JSONObject json = new JSONObject();
+        json.put("cargoListLength", cargoService.getAll().size());
+        JsonUtil.write(cargoService.getCargoByTaskId(taskId), "cargoList", json, response);
+    }
+}

+ 133 - 0
src/main/java/com/logistics/controller/CarrierBusinessController.java

@@ -0,0 +1,133 @@
+package com.logistics.controller;
+
+import com.logistics.conf.Configurator;
+import com.logistics.entity.CarrierBusiness;
+import com.logistics.service.CarrierBusinessService;
+import com.logistics.util.JsonUtil;
+import com.logistics.util.Params;
+import org.hibernate.criterion.DetachedCriteria;
+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.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.util.List;
+
+/**
+ * Created by Ranger on 2015/8/26.
+ */
+@Controller
+@RequestMapping("carrierBusiness")
+public class CarrierBusinessController {
+    @Resource
+    private CarrierBusinessService carrierBusinessService;
+
+    /**
+     * <p>添加承运商业务记录</p>
+     * <p>POST    /carrierBusiness?json</p>
+     *
+     * @param carrierBusiness 需要保存的承运商业务记录
+     * @throws IOException 传数据给前端时可能会抛出的异常
+     */
+    @RequestMapping(method = RequestMethod.POST, params = "json")
+    public void add(CarrierBusiness carrierBusiness, Integer transTaskId, Integer companyId,
+                    HttpServletResponse response) throws IOException {
+        Integer id = carrierBusinessService.add(carrierBusiness, transTaskId, companyId);
+        if (id != null) {
+            JsonUtil.writeMsg(id.toString(), response);
+        } else {
+            JsonUtil.writeMsg("-1", response);
+        }
+    }
+
+    /**
+     * <p>删除单条运输记录</p>
+     * <p>DELETE    /carrierBusiness?single</p>
+     *
+     * @param id 需要删除的记录的ID
+     * @throws IOException 传数据给前端时可能会抛出的异常
+     */
+    @RequestMapping(method = RequestMethod.DELETE, params = "single")
+    public void deleteRec(Integer id, HttpServletResponse response) throws IOException {
+        carrierBusinessService.delete(id);
+        JsonUtil.writeMsg("1", response);
+    }
+
+    /**
+     * <p>批量删除承运商业务记录</p>
+     * <p>DELETE    /carrierBusiness?batch</p>
+     *
+     * @param request 需要在里面添加一个类型为int[]名称为idArray的参数
+     * @throws IOException 传数据给前端时可能会抛出的异常
+     */
+    @RequestMapping(method = RequestMethod.DELETE, params = "batch")
+    public void deleteRecs(HttpServletRequest request, HttpServletResponse response) throws IOException {
+        int[] idArray = Params.getIntArray(request, "idArray");
+        if (idArray == null) {
+            JsonUtil.writeMsg("-1", response);
+            return;
+        }
+        for (int id : idArray) {
+            carrierBusinessService.delete(id);
+        }
+        JsonUtil.writeMsg("1", response);
+    }
+
+    /**
+     * <p>查询单条承运商信息记录</p>
+     * <p>GET    /carrierBusinessId/{carrierBusinessId}?json</p>
+     *
+     * @param carrierBusinessId 需要查找的承运商业务记录的ID
+     * @throws IOException 传数据给前端时可能会抛出的异常
+     */
+    @RequestMapping(value = "{carrierBusinessId}", method = RequestMethod.GET, params = "json")
+    public void getRec(@PathVariable("carrierBusinessId") Integer carrierBusinessId, HttpServletResponse response) throws IOException {
+        JsonUtil.write(carrierBusinessService.get(carrierBusinessId), response);
+    }
+
+    /**
+     * <p>查询承运商信息记录</p>
+     * <p>GET    /carrierBusiness?json</p>
+     *
+     * @param start 从该条记录开始显示
+     * @param size  页面显示记录的条数
+     * @throws IOException 传数据给前端时可能会抛出的异常
+     */
+    @RequestMapping(method = RequestMethod.GET, params = "json")
+    public void getRecs(Integer start, Integer size, HttpServletResponse response) throws IOException {
+        start = (start != null) ? start : 0;
+        size = (size != null) ? size : Configurator.getInstance().getInt("defaultPageSize");
+        DetachedCriteria detachedCriteria = DetachedCriteria.forClass(CarrierBusiness.class);
+        List<CarrierBusiness> carrierBusinessList = carrierBusinessService.get(detachedCriteria, start, size);
+        JsonUtil.write(carrierBusinessList, response);
+    }
+
+    /**
+     * <p>修改承运商业务记录</p>
+     * <p>PUT    /carrierBusiness?json</p>
+     *
+     * @param carrierBusiness 修改后的承运商记录
+     * @throws IOException 传数据给前端时可能会抛出的异常
+     */
+    @RequestMapping(method = RequestMethod.PUT, params = "json")
+    public void update(CarrierBusiness carrierBusiness, Integer transTaskId, Integer companyId,
+                       HttpServletResponse response) throws IOException {
+        carrierBusinessService.update(carrierBusiness, transTaskId, companyId);
+        JsonUtil.writeMsg("1", response);
+    }
+
+    /**
+     * <p>根据任务单ID获取承运商业务记录</p>
+     * <p>GET    /carrierBusiness/{taskId}?byTaskId</p>
+     *
+     * @param taskId 任务单的ID
+     */
+    @RequestMapping(value = "{taskId}", method = RequestMethod.GET, params = "byTaskId")
+    public void getCarrierBusinessByTaskId(@PathVariable("taskId") int taskId, HttpServletResponse response) throws IOException {
+        JsonUtil.write(carrierBusinessService.getCarrierBusinessByTaskId(taskId), response);
+    }
+}

+ 125 - 0
src/main/java/com/logistics/controller/CompanyController.java

@@ -0,0 +1,125 @@
+package com.logistics.controller;
+
+import com.alibaba.fastjson.JSONObject;
+import com.logistics.conf.Configurator;
+import com.logistics.entity.Company;
+import com.logistics.service.CompanyService;
+import com.logistics.util.JsonUtil;
+import org.hibernate.criterion.DetachedCriteria;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+import java.io.IOException;
+import java.util.List;
+
+import static com.logistics.util.Params.needLongList;
+
+/**
+ * Created by wuhaibin on 15/8/19.
+ */
+
+@Controller
+@RequestMapping("company")
+public class CompanyController {
+
+    @Resource
+    private CompanyService companyService;
+
+    @RequestMapping(method = RequestMethod.GET)
+    public String company_GET(Integer start,Integer size,Model model,HttpSession session){
+        DetachedCriteria dc = DetachedCriteria.forClass(Company.class);
+        List<Company> companies = companyService.get(dc,start,size);
+        model.addAttribute("companies",companies);
+        return "/company/companyAdd";
+    }
+
+    @RequestMapping(method = RequestMethod.GET,params = "json")
+    public void company_GET_json(Integer start,Integer size,Model model,HttpSession session,HttpServletResponse resp) throws IOException {
+        start = start != null ? start : 0;
+        size  = size  != null ? size  : Configurator.getInstance().getInt("defaultPageSize");
+        List<Company> companies = companyService.get(start, size);
+        JSONObject json = new JSONObject();
+        json.put("companyLength",companyService.getAll().size());
+        JsonUtil.write(companies, "companies", json, resp);
+    }
+
+    @RequestMapping(method = RequestMethod.POST)
+    public String company_CREATE(Company company,Model model,HttpSession session){
+        companyService.add(company);
+        model.addAttribute("company", company);
+        return "/company/companyManage";
+    }
+
+    @RequestMapping(method = RequestMethod.POST,params = "json")
+    public void company_CREATE_JSON(Company company,HttpServletResponse resp) throws IOException {
+        Integer companyId = companyService.add(company);
+        if(companyId!=null){
+            JsonUtil.writeMsg(companyId.toString(),resp);
+        } else{
+            JsonUtil.writeMsg("-1",resp);
+        }
+    }
+
+    @RequestMapping(method = RequestMethod.PUT)
+    public String company_UPDATE(Company company,Model model,HttpSession session){
+        companyService.update(company);
+        model.addAttribute("company", company);
+        return "/company/companyManage";
+    }
+
+    @RequestMapping(method = RequestMethod.PUT,params = "json")
+    public void goods_UPDATE_json(Company company,HttpServletResponse resp) throws IOException {
+        companyService.update(company);
+        JsonUtil.writeMsg("1", resp);
+    }
+
+    @RequestMapping(method = RequestMethod.DELETE)
+    public String company_DELETE(Integer companyId){
+        companyService.delete(companyId);
+        return "redirect:/company";
+    }
+
+    @RequestMapping(value = "{companyId}",method = RequestMethod.GET)
+         public String company_id(@PathVariable("companyId") Integer companyId, Model model){
+        Company company = companyService.get(companyId);
+        model.addAttribute("company", company);
+        return "/company/companyInfo";
+    }
+
+    @RequestMapping(value = "{companyId}",method = RequestMethod.GET,params = "edit")
+    public String company_edit(@PathVariable("companyId") Integer companyId, Model model){
+        Company company = companyService.get(companyId);
+        model.addAttribute("company", company);
+        return "/company/companyEdit";
+    }
+
+    @RequestMapping(value = "{companyId}",method = RequestMethod.GET,params = "json")
+    public void company_id_json(@PathVariable("companyId") Integer companyId,HttpServletResponse resp) throws IOException {
+        Company company = companyService.get(companyId);
+        JsonUtil.write(company, resp);
+    }
+
+    @RequestMapping(method = RequestMethod.DELETE,params = "json")
+    public void goods_DELETE_json(Integer companyId,HttpServletResponse resp) throws IOException {
+        companyService.delete(companyId);
+        JsonUtil.writeMsg("1", resp);
+    }
+
+
+    @RequestMapping(method = RequestMethod.DELETE,params = "many")
+    public void company_DELETE_MANY(HttpServletRequest req,HttpServletResponse resp) throws IOException {
+        List<Long> ids = needLongList(req, "ids");
+        System.out.println(ids.size());
+        for (long id : ids){
+            companyService.delete((int) id);
+        }
+        JsonUtil.writeMsg("1", resp);
+    }
+}

+ 201 - 0
src/main/java/com/logistics/controller/GoodsController.java

@@ -0,0 +1,201 @@
+package com.logistics.controller;
+
+import com.alibaba.fastjson.JSONObject;
+import com.logistics.conf.Configurator;
+import com.logistics.entity.Goods;
+import com.logistics.service.GoodsService;
+import com.logistics.util.JsonUtil;
+import org.hibernate.criterion.DetachedCriteria;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.util.List;
+
+import static com.logistics.util.Params.needLongList;
+
+
+/**
+ * Created by Mklaus on 15/8/16.
+ */
+@Controller
+@RequestMapping("goods")
+public class GoodsController {
+
+    @Resource
+    private GoodsService goodsService;
+
+    /**
+     * <p>获取物资</p>
+     * <p>GET       /goods</p>
+     *
+     * @param start     开始获取位置 (默认为0)
+     * @param size      获取个数    (默认10)
+     * @param model
+     * @return
+     */
+    @RequestMapping(method = RequestMethod.GET)
+    public String goods_GET(Integer start,Integer size,Model model){
+        DetachedCriteria dc = DetachedCriteria.forClass(Goods.class);
+        start = start != null ? start : 0;
+        size  = size  != null ? size  : Configurator.getInstance().getInt("defaultPageSize");
+        List<Goods> goodses = goodsService.get(dc,start,size);
+        model.addAttribute("goodses",goodses);
+        return "/goods/goodsShowAll";
+    }
+
+    /**
+     * <p>获取物资 以Json形式返回</p>
+     * <p>GET       /goods</p>
+     *
+     * @param start     开始获取位置 (默认为0)
+     * @param size      获取个数      (默认10)
+     * @return
+     */
+    @RequestMapping(method = RequestMethod.GET,params = "json")
+    public void goods_GET_json(Integer start,Integer size,HttpServletResponse resp) throws IOException {
+        DetachedCriteria dc = DetachedCriteria.forClass(Goods.class);
+        start = start != null ? start : 0;
+        size  = size  != null ? size  : Configurator.getInstance().getInt("defaultPageSize");
+        List<Goods> goodses = goodsService.get(dc, start, size);
+
+        JSONObject json = new JSONObject();
+        json.put("goodsesLength",goodsService.getAll().size());
+        JsonUtil.write(goodses, "goodses", json, resp);
+    }
+
+    /**
+     * 创建物资
+     * <p>API</p>
+     *  POST      /goods
+     * <p>返回</p>
+     *  成功返回新物资ID,    错误返回 -1
+     * @param goods
+     * @param resp
+     * @throws IOException
+     */
+    @RequestMapping(method = RequestMethod.POST)
+    public void goods_CREATE(Goods goods,HttpServletResponse resp) throws IOException {
+        Integer goodsId = goodsService.add(goods);
+        if(goodsId!=null){
+            JsonUtil.writeMsg(goodsId.toString(),resp);
+        } else{
+            JsonUtil.writeMsg("-1",resp);
+        }
+    }
+
+    /**
+     * 更新物资
+     * <p>API</p>
+     *  PUT       /goods
+     * @param goods
+     * @param model
+     * @return  返回页面      /goods/goodsShow
+     */
+    @RequestMapping(method = RequestMethod.PUT)
+    public String goods_UPDATE(Goods goods,Model model){
+        goodsService.update(goods);
+        model.addAttribute("goods",goods);
+        return "/goods/goodsShow";
+    }
+
+    /**
+     * 更新物资 (供前端异步使用)
+     * <p>API</p>
+     *  PUT       /goods?json
+     * @param goods
+     * @param resp
+     * @throws IOException
+     */
+    @RequestMapping(method = RequestMethod.PUT,params = "json")
+    public void goods_UPDATE_json(Goods goods,HttpServletResponse resp) throws IOException {
+        goodsService.update(goods);
+        JsonUtil.writeMsg("1", resp);
+    }
+
+    /**
+     * 删除物资
+     * <p>API</p>
+     *  DELETE        /goods
+     * @param goodsId   要删除物资的ID(必需)
+     * @return
+     */
+    @RequestMapping(method = RequestMethod.DELETE)
+    public String goods_DELETE(Integer goodsId){
+        goodsService.delete(goodsId);
+        return "redirect:/goods";
+    }
+
+    /**
+     * 多项删除
+     * <p>API</p>
+     *  DELETE        /goods?many
+     * <p>参数</p>
+     *  ids=(1,2,3)
+     * @param req
+     * @param resp
+     * @throws IOException
+     */
+    @RequestMapping(method = RequestMethod.DELETE,params = "many")
+    public void goods_DELETE_MANY(HttpServletRequest req,HttpServletResponse resp) throws IOException {
+        List<Long> ids = needLongList(req,"ids");
+        System.out.println(ids.size());
+        for (long id : ids){
+            goodsService.delete((int) id);
+        }
+        JsonUtil.writeMsg("1",resp);
+    }
+
+    /**
+     * 删除物资 (异步删除)
+     * <p>API</p>
+     * DELETE       /goods?json
+     *
+     * <p>返回</p>
+     *  成功  1
+     * @param goodsId   要删除物资的ID(必需)
+     * @param resp
+     * @throws IOException
+     */
+    @RequestMapping(method = RequestMethod.DELETE,params = "json")
+    public void goods_DELETE_json(Integer goodsId,HttpServletResponse resp) throws IOException {
+        goodsService.delete(goodsId);
+        JsonUtil.writeMsg("1",resp);
+    }
+
+    /**
+     * 获取单个物资
+     * <p>API</p>
+     *  GET         /goods/{goodsId}
+     *
+     * @param goodsId
+     * @param model
+     * @return      跳转到 /goods/goodsShow
+     */
+    @RequestMapping(value = "{goodsId}",method = RequestMethod.GET)
+    public String goods_id(@PathVariable("goodsId") Integer goodsId, Model model){
+        Goods goods = goodsService.get(goodsId);
+        model.addAttribute("goods",goods);
+        return "/goods/goodsShow";
+    }
+
+    /**
+     * 获取单个或者 (json)
+     * <p>API</p>
+     *  GET         /goods/{goodsId}?json
+     * @param goodsId
+     * @param resp
+     * @throws IOException
+     */
+    @RequestMapping(value = "{goodsId}",method = RequestMethod.GET,params = "json")
+    public void goods_id_json(@PathVariable("goodsId") Integer goodsId,HttpServletResponse resp) throws IOException {
+        Goods goods = goodsService.get(goodsId);
+        JsonUtil.write(goods,resp);
+    }
+}

+ 166 - 0
src/main/java/com/logistics/controller/GoodsRecordController.java

@@ -0,0 +1,166 @@
+package com.logistics.controller;
+
+import com.logistics.conf.Configurator;
+import com.logistics.dao.GoodsGroupDao;
+import com.logistics.entity.GoodsGroup;
+import com.logistics.entity.GoodsRecord;
+import com.logistics.service.GoodsRecordService;
+import com.logistics.util.JsonUtil;
+import org.hibernate.criterion.DetachedCriteria;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+import java.io.IOException;
+import java.util.List;
+
+/**
+ * Created by Mklaus on 15/8/20.
+ */
+@Controller
+@RequestMapping("goodsRecord")
+public class GoodsRecordController {
+    @Resource
+    private GoodsRecordService goodsRecordService;
+    @Resource
+    private GoodsGroupDao goodsGroupDao;
+
+    /**
+     * 获取物资记录
+     * <p>API</p>
+     *  GET     /goodsRecord
+     * @param start     开始获取位置,默认0
+     * @param size      获取数量,默认10
+     * @param model
+     * @param session
+     * @return
+     */
+    @RequestMapping(method = RequestMethod.GET)
+    public String goodsRecord_GET(Integer start,Integer size,Model model,HttpSession session){
+        DetachedCriteria dc = DetachedCriteria.forClass(GoodsRecord.class);
+        start = start != null ? start : 0;
+        size  = size  != null ? size  : Configurator.getInstance().getInt("defaultPageSize");
+        List<GoodsRecord> goodses = goodsRecordService.get(dc,start,size);
+        model.addAttribute("goodses",goodses);
+        return "/goodsRecord/goodsRecordShowAll";
+    }
+
+    /**
+     * 创建物资记录
+     * <p>API</p>
+     *  POST    /goodsRecord
+     * @param goodsRecord
+     * @param resp
+     * @throws IOException
+     */
+    @RequestMapping(method = RequestMethod.POST)
+    public void goodsRecord_CREATE(GoodsRecord goodsRecord,HttpServletResponse resp) throws IOException {
+        Integer goodsRecordId = goodsRecordService.add(goodsRecord);
+        if(goodsRecordId!=null){
+            JsonUtil.writeMsg(goodsRecordId.toString(), resp);
+        } else{
+            JsonUtil.writeMsg("-1",resp);
+        }
+    }
+
+    /**
+     * 更新物资记录
+     * <p>API</p>
+     *  PUT     /goodsRecord
+     * @param goodsRecord
+     * @param model
+     * @return
+     * @throws IOException
+     */
+    @RequestMapping(method = RequestMethod.PUT)
+    public String goods_UPDATE(GoodsRecord goodsRecord,Model model) throws IOException {
+        goodsRecordService.update(goodsRecord);
+        model.addAttribute("goodsRecord", goodsRecord);
+        return "/goodsRecord/showALL";
+    }
+
+    /**
+     * 删除物资
+     * <p>API</p>
+     *  DELETE  /goodsRecord
+     * @param goodsRecordId     指定要删除物资的ID,必需
+     * @return
+     */
+    @RequestMapping(method = RequestMethod.DELETE)
+    public String goods_DELETE(Integer goodsRecordId){
+        goodsRecordService.delete(goodsRecordId);
+        return "redirect:/goodsRecord";
+    }
+
+    /**
+     * 获取单个物资
+     * <p>API</p>
+     *  GET     /goodsRecord/{goodsRecordId}
+     * @param goodsRecordId
+     * @param model
+     * @return  跳转到 /goodsRecord/show
+     */
+    @RequestMapping(value = "{goodsRecordId}",method = RequestMethod.GET)
+    public String goodsRecord_id(@PathVariable("goodsRecordId") int goodsRecordId,Model model){
+        GoodsRecord goodsRecord = goodsRecordService.get(goodsRecordId);
+        model.addAttribute("goodsRecord",goodsRecord);
+        return "/goodsRecord/show";
+    }
+
+    /**
+     * 获取单个物资 json形式
+     * <p>API</p>
+     *  GET     /goodsRecord/{goodsRecordId}?json
+     * @param goodsRecordId
+     * @param resp
+     * @throws IOException
+     */
+    @RequestMapping(value = "{goodsRecordId}",params = "json")
+    public void goodsRecord_id_json(@PathVariable("goodsRecordId") int goodsRecordId,
+                                    HttpServletResponse resp)throws IOException{
+        GoodsRecord goodsRecord = goodsRecordService.get(goodsRecordId);
+        JsonUtil.write(goodsRecord,resp);
+    }
+
+    /**
+     * 为指定物资记录添加物资组
+     * <p>API</p>
+     *  POST    /goodsRecord/{goodsRecordId}/goodsGroup
+     *
+     * @param goodRecordId      指定物资记录ID
+     * @param goodsGroup        物资组
+     * @param resp
+     * @throws IOException
+     */
+    @RequestMapping(value = "{goodsRecordId}/goodsGroup",method = RequestMethod.POST)
+    public void goodsRecord_addGoodGroup(@PathVariable("goodsRecordId") int goodRecordId,
+                                         GoodsGroup goodsGroup,HttpServletResponse resp) throws IOException{
+        GoodsRecord goodsRecord = goodsRecordService.get(goodRecordId);
+        goodsGroup.setGoodsRecord(goodsRecord);
+        int goodsGroupId = goodsGroupDao.save(goodsGroup);
+        JsonUtil.writeMsg(goodsGroupId+"",resp);
+
+    }
+
+    /**
+     * 删除指定物资记录的物资组
+     * <p>API</p>
+     *  DELETE      /goodsRecord/{goodsRecordId}/{goodsGroupId}
+     * @param goodGroupId       指定物资组ID,必需
+     * @param resp
+     * @throws IOException
+     */
+    @RequestMapping(value = "{goodsRecordId}/{goodsGroupId}",method = RequestMethod.DELETE)
+    public void goodsRecord_removeGoodGroup(@PathVariable("goodsGroupId") int goodGroupId,HttpServletResponse resp) throws IOException{
+        GoodsGroup goodsGroup = goodsGroupDao.get(goodGroupId);
+        goodsGroup.setGoodsRecord(null);
+        goodsGroupDao.delete(goodsGroup);
+        JsonUtil.write("1",resp);
+    }
+
+}

+ 71 - 0
src/main/java/com/logistics/controller/ImageController.java

@@ -0,0 +1,71 @@
+package com.logistics.controller;
+
+import com.logistics.conf.Configurator;
+import com.logistics.service.ImageService;
+import com.logistics.util.JsonUtil;
+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.multipart.MultipartFile;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+/**
+ * Created by Mklaus on 15/8/27.
+ */
+@Controller
+@RequestMapping("image")
+public class ImageController {
+    @Resource
+    private ImageService imageService;
+
+    /**
+     * ----------- 文件上传 ------------------
+     * */
+    @RequestMapping(value = "test",method = RequestMethod.GET)
+    public String showUploadPage(){
+        return "/admin/uploadFile";
+    }
+
+    @RequestMapping(value = "upload",method = RequestMethod.POST,params = "carId")
+    public void image_car_doUpload(@RequestParam("file") MultipartFile file,Integer carId,
+                                   HttpServletRequest req,HttpServletResponse resp) throws IOException {
+        String name = "car"+carId;
+        if (file != null){
+            imageService.upload(Configurator.getInstance().get("imagePathOnUnix"),name,file);
+        }
+        JsonUtil.writeMsg("1",resp);
+    }
+
+    @RequestMapping(value = "get",method = RequestMethod.GET,params = "carId")
+    public void image_car_GET(Integer carId,HttpServletResponse resp) throws IOException{
+        String name = "car" + carId;
+        InputStream is = imageService.load(name);
+        OutputStream os = resp.getOutputStream();
+        imageService.startPipe(is,os,4096);
+    }
+
+    @RequestMapping(value = "upload",method = RequestMethod.POST,params = "staffId")
+    public String image_staff_doUpload(@RequestParam("file") MultipartFile file,Integer staffId,
+                                       HttpServletRequest req,HttpServletResponse resp) throws IOException {
+        String name = "staff" + staffId;
+        if (file != null){
+            imageService.upload(Configurator.getInstance().get("imagePathOnUnix"),name,file);
+        }
+        return "redirect:/staff/" + staffId;
+    }
+
+    @RequestMapping(value = "get",method = RequestMethod.GET,params = "staffId")
+    public void image_staff_GET(Integer staffId,HttpServletResponse resp) throws IOException{
+        String name = "staff" + staffId;
+        InputStream is = imageService.load(name);
+        OutputStream os = resp.getOutputStream();
+        imageService.startPipe(is,os,4096);
+    }
+}

+ 72 - 0
src/main/java/com/logistics/controller/OilBuyController.java

@@ -0,0 +1,72 @@
+package com.logistics.controller;
+
+import com.alibaba.fastjson.JSONObject;
+import com.logistics.conf.Configurator;
+import com.logistics.entity.OilBuy;
+import com.logistics.service.OilBuyService;
+import com.logistics.util.JsonUtil;
+import org.hibernate.criterion.DetachedCriteria;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.util.List;
+
+import static com.logistics.util.Params.needLongList;
+
+/**
+ * Created by Mklaus on 15/8/21.
+ */
+@Controller
+@RequestMapping("oilBuy")
+public class OilBuyController {
+    @Resource
+    private OilBuyService oilBuyService;
+    
+    @RequestMapping(method = RequestMethod.GET,params = "json")
+    public void oilBuy_get_json(Integer start,Integer size,HttpServletResponse resp) throws IOException{
+        DetachedCriteria dc = DetachedCriteria.forClass(OilBuy.class);
+        start = start != null ? start : 0;
+        size  = size  != null ? size  : Configurator.getInstance().getInt("defaultPageSize");
+        JSONObject json = new JSONObject();
+        List<OilBuy> oilBuys = oilBuyService.get(dc,start,size);
+
+        json.put("oilBuysLength",oilBuyService.getAll().size());
+        JsonUtil.write(oilBuys, "oilBuys", json, resp);
+    }
+
+    @RequestMapping(method = RequestMethod.POST,params = "json")
+    public void oilBuy_create_json(OilBuy oilBuy,Integer staffId,Integer vehicleId,HttpServletResponse resp) throws IOException{
+        Integer oilBuyId = oilBuyService.add(oilBuy, staffId, vehicleId);
+        if(oilBuyId!=null){
+            JsonUtil.writeMsg(oilBuyId.toString(),resp);
+        } else{
+            JsonUtil.writeMsg("-1",resp);
+        }
+    }
+
+    @RequestMapping(method = RequestMethod.PUT,params = "json")
+    public void oilBuy_update_json(OilBuy oilBuy,Integer staffId,Integer vehicleId,HttpServletResponse resp) throws IOException{
+        oilBuyService.update(oilBuy,staffId,vehicleId);
+        JsonUtil.writeMsg("1", resp);
+    }
+
+    @RequestMapping(method = RequestMethod.DELETE,params = "json")
+    public void oilBuy_delete_json(Integer oilBuyId,HttpServletResponse resp) throws IOException{
+        oilBuyService.delete(oilBuyId);
+        JsonUtil.writeMsg("1",resp);
+    }
+
+    @RequestMapping(method = RequestMethod.DELETE,params = "many")
+    public void oilBuy_DELETE_MANY(HttpServletRequest req,HttpServletResponse resp) throws IOException {
+        List<Long> ids = needLongList(req,"ids");
+        for (long id : ids){
+            oilBuyService.delete((int) id);
+        }
+        JsonUtil.writeMsg("1",resp);
+    }
+}

+ 75 - 0
src/main/java/com/logistics/controller/ReportController.java

@@ -0,0 +1,75 @@
+package com.logistics.controller;
+
+import com.logistics.entity.Report;
+import com.logistics.service.ReportService;
+import com.logistics.util.JsonUtil;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+/**
+ * Created by Mklaus on 15/8/21.
+ */
+@Controller
+@RequestMapping("report")
+public class ReportController {
+    @Resource
+    private ReportService reportService;
+
+    /**
+     * 查看指定月报告
+     * <p>API</p>
+     *  GET     /report/month
+     * @param year      必需
+     * @param month     必需
+     * @param resp
+     */
+    @RequestMapping(value = "{month}",method = RequestMethod.GET)
+    public void getReport_month(int year,int month,HttpServletResponse resp) throws IOException {
+        Report report = reportService.getReportByMonth(year,month);
+//        System.out.println("吴海彬!!!!"+report.getOutput());
+        JsonUtil.write(report,resp);
+    }
+
+//    @RequestMapping(method = RequestMethod.GET,params = "json")
+//    public void getJsonRecs(Integer start, Integer size, HttpServletResponse response) throws IOException {
+//        DetachedCriteria detachedCriteria = DetachedCriteria.forClass(VehicleType.class);
+//        start = start != null ? start : 0;
+//        size  = size  != null ? size  : Configurator.getInstance().getInt("defaultPageSize");
+//        List<VehicleType> vehicleTypes = vehicleTypeService.get(detachedCriteria, start, size);
+//        JSONObject json = new JSONObject();
+//        json.put("vehicleTypesLength", vehicleTypeService.getAll().size());
+//        JsonUtil.write(vehicleTypes, "vehicleTypes", json, response);
+//    }
+
+    /**
+     * 查看指定季度报告
+     * <p>API</p>
+     *  GET     /report/quarter
+     * @param year      必需
+     * @param quarter   必需
+     * @param resp
+     */
+    @RequestMapping(value = "quarter",method = RequestMethod.GET)
+    public void getReport_quarter(int year,int quarter,HttpServletResponse resp) throws IOException {
+        Report report = reportService.getReportByQuarter(year,quarter);
+        JsonUtil.write(report,resp);
+    }
+
+    /**
+     * 查找指定年报告
+     * <p>API</p>
+     *  GET     /report/year
+     * @param year      必需
+     * @param resp
+     */
+    @RequestMapping(value = "year",method = RequestMethod.GET)
+    public void getReport_year(int year,HttpServletResponse resp) throws IOException {
+        Report report = reportService.getReportByYear(year);
+        JsonUtil.write(report,resp);
+    }
+}

+ 163 - 0
src/main/java/com/logistics/controller/StaffController.java

@@ -0,0 +1,163 @@
+package com.logistics.controller;
+
+import com.alibaba.fastjson.JSONObject;
+import com.logistics.conf.Configurator;
+import com.logistics.entity.Staff;
+import com.logistics.service.StaffService;
+import com.logistics.util.JsonUtil;
+import org.hibernate.criterion.DetachedCriteria;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.net.URLDecoder;
+import java.util.List;
+
+import static com.logistics.util.Params.needLongList;
+
+/**
+ * Created by Ranger on 2015/8/18.
+ */
+@Controller
+@RequestMapping("staff")
+public class StaffController {
+    @Resource
+    StaffService staffService;
+
+    /**
+     * <p>添加职员信息</p>
+     * <p>api     = /staff</p>
+     * <p>method  = POST</p>
+     *
+     * @param staff    需要添加的Staff对象
+     * @param response HttpServletResponse的一个实例
+     * @throws java.io.IOException 返回JSON数据给前端可能会抛出这个异常
+     */
+    @RequestMapping(method = RequestMethod.POST, params = "json")
+    public void addStaffRec(Staff staff, HttpServletResponse response) throws IOException {
+        Integer staffId = staffService.add(staff);
+        if (staffId != null) {
+            JsonUtil.writeMsg(staffId.toString(), response);
+        } else {
+            JsonUtil.writeMsg("-1", response);
+        }
+    }
+
+
+    /**
+     * <p>删除职员信息</p>
+     * <p>API</p>
+     * <p>DELETE        /staff</p>
+     *
+     * @param staffId 要删除的职员记录的ID(必需)
+     */
+    @RequestMapping(method = RequestMethod.DELETE)
+    public void staff_DELETE(Integer staffId, HttpServletResponse resp) throws IOException {
+        staffService.delete(staffId);
+        JsonUtil.writeMsg("1", resp);
+    }
+
+    /**
+     * <p>多项删除</p>
+     * <p>API</p>
+     * <p>DELETE        /staff?many</p>
+     * <p>参数</p>
+     * <p>ids=(1,2,3)</p>
+     *
+     * @throws IOException 返回JSON数据给前端可能会抛出这个异常
+     */
+    @RequestMapping(method = RequestMethod.DELETE, params = "many")
+    public void staff_DELETE_MANY(HttpServletRequest req, HttpServletResponse resp) throws IOException {
+        List<Long> ids = needLongList(req, "ids");
+        System.out.println(ids.size());
+        for (long id : ids) {
+            staffService.delete((int) id);
+        }
+        JsonUtil.writeMsg("1", resp);
+    }
+
+    /**
+     * <p>获取职员信息</p>
+     * <p>api     = /staff</p>
+     * <p>method  = GET</p>
+     *
+     * @param start    从第几条记录开始显示
+     * @param size     页面显示的数据条数
+     * @param response HttpServletResponse的一个实例
+     * @throws java.io.IOException 返回JSON数据给前端可能会抛出这个异常
+     */
+    @RequestMapping(method = RequestMethod.GET, params = "json")
+    public void getJsonRecs(Integer start, Integer size, HttpServletResponse response) throws IOException {
+        DetachedCriteria detachedCriteria = DetachedCriteria.forClass(Staff.class);
+        start = (start != null) ? start : 0;
+        size = (size != null) ? size : Configurator.getInstance().getInt("defaultPageSize");
+        List<Staff> staffs = staffService.get(detachedCriteria, start, size);
+
+        JSONObject json = new JSONObject();
+        json.put("staffLength", staffService.getAll().size());
+        JsonUtil.write(staffs, "staffs", json, response);
+    }
+
+    /**
+     * <p>获取单个职员的信息</p>
+     * <p>api     = /staff/staffId</p>
+     * <p>method  = GET</p>
+     *
+     * @param staffId  需要获取的职员的记录的ID
+     * @param response HttpServletResponse的一个实例
+     * @throws java.io.IOException 返回JSON数据给前端可能会抛出这个异常
+     */
+    @RequestMapping(value = "{staffId}", method = RequestMethod.GET, params = "json")
+    public void getJsonRec(@PathVariable("staffId") Integer staffId, HttpServletResponse response) throws IOException {
+        JsonUtil.write(staffService.get(staffId), response);
+    }
+
+    @RequestMapping(value = "{staffId}", method = RequestMethod.GET)
+    public String get_staff(@PathVariable("staffId") Integer staffId, Model model) throws IOException {
+        model.addAttribute("staff", staffService.get(staffId));
+        return "/staff/staffShow";
+    }
+
+    /**
+     * <p>获取可以调用的司机</p>
+     * <p>GET    /staff?availableDriver</p>
+     *
+     * @throws IOException 返回JSON数据给前端可能会抛出这个异常
+     */
+    @RequestMapping(method = RequestMethod.GET, params = "availableDriver")
+    public void getAvailableDriver(HttpServletResponse response) throws IOException {
+        JsonUtil.write(staffService.getAvailableDriver(), response);
+    }
+
+    /**
+     * <p>根据职位获取人员列表</p>
+     * <p>GET    /staff?job={job}&getByJob</p>
+     *
+     * @param job 人员职位
+     * @throws IOException 返回JSON数据给前端可能会抛出这个异常
+     */
+    @RequestMapping(method = RequestMethod.GET, params = "getByJob")
+    public void getStaffByJob(String job, HttpServletResponse response) throws IOException {
+        job = URLDecoder.decode(job, "UTF-8");
+        JsonUtil.write(staffService.getStaffList(job), response);
+    }
+
+    /**
+     * <p>修改职员记录</p>
+     * <p>api      = /staff</p>
+     * <p>method   = PUT</p>
+     *
+     * @param staff 修改后的对象
+     */
+    @RequestMapping(method = RequestMethod.PUT, params = "json")
+    public void updateStaff(Staff staff, HttpServletResponse resp) throws IOException {
+        staffService.update(staff);
+        JsonUtil.writeMsg("1", resp);
+    }
+}

+ 109 - 0
src/main/java/com/logistics/controller/TransportTaskController.java

@@ -0,0 +1,109 @@
+package com.logistics.controller;
+
+import com.alibaba.fastjson.JSONObject;
+import com.logistics.conf.Configurator;
+import com.logistics.entity.TransportTask;
+import com.logistics.service.TransportTaskService;
+import com.logistics.util.JsonUtil;
+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.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.util.List;
+
+/**
+ * Created by Ranger on 2015/8/21.
+ */
+@Controller
+@RequestMapping("transportTask")
+public class TransportTaskController {
+    @Resource
+    private TransportTaskService transportTaskService;
+
+    /**
+     * <p>增加运输单数据</p>
+     * <p>POST    /transportTask?json</p>
+     *
+     * @param transportTask 需要保存的运输任务单数据
+     * @throws IOException 传输数据的时候可能会抛出这个异常
+     */
+    @RequestMapping(method = RequestMethod.POST, params = "json")
+    public void add(TransportTask transportTask,
+                    Integer customerId, HttpServletResponse response) throws IOException {
+        Integer id = transportTaskService.add(transportTask, customerId);
+        if (id != null) {
+            JsonUtil.writeMsg(id.toString(), response);
+        } else {
+            JsonUtil.writeMsg("-1", response);
+        }
+    }
+
+    /**
+     * <p>删除运输任务单</p>
+     * <p>DELETE    /transportTask</p>
+     *
+     * @param request 需要在该参数中添加一个类型为int[]名为idArray的属性,
+     *                方法会取出所有在idArray里面的数据并以此作为id删除相应的记录
+     */
+    @RequestMapping(method = RequestMethod.DELETE)
+    public void delete(HttpServletRequest request) {
+        int[] idArray = (int[]) request.getAttribute("idArray");
+        for (int id : idArray) {
+            transportTaskService.delete(id);
+        }
+    }
+
+    /**
+     * <p>查询运输任务单</p>
+     * <p>GET    /transportTask?json</p>
+     *
+     * @param start 从该条记录开始显示
+     * @param size  页面显示的记录条数
+     * @throws IOException 传输数据的时候可能会抛出这个异常
+     */
+    @RequestMapping(method = RequestMethod.GET, params = "json")
+    public void get(Integer start, Integer size, HttpServletResponse response) throws IOException {
+        start = (start != null) ? start : 0;
+        size = (size != null) ? size : Configurator.getInstance().getInt("defaultPageSize");
+        List<TransportTask> tasks = transportTaskService.get(start, size);
+
+        JSONObject json = new JSONObject();
+        json.put("taskLength", transportTaskService.getAll().size());
+        JsonUtil.write(tasks, "tasks", json, response);
+    }
+
+    /**
+     * <p>查询单个任务单数据</p>
+     * <p>GET    /transportTask/{transportTaskId}?json</p>
+     *
+     * @param transportTaskId 需要获取的记录的ID
+     * @throws IOException 传输数据的时候可能会抛出这个异常
+     */
+    @RequestMapping(value = "{transportTaskId}", method = RequestMethod.GET, params = "json")
+    public void getJson(@PathVariable("transportTaskId") Integer transportTaskId, HttpServletResponse response) throws IOException {
+        JsonUtil.write(transportTaskService.get(transportTaskId), response);
+    }
+
+    /**
+     * <p>修改运输任务单</p>
+     * <p>PUT    /transportTask</p>
+     *
+     * @param transportTask 修改后的运输记录数据
+     * @param customerId    发布运输任务的用户的ID
+     */
+    @RequestMapping(method = RequestMethod.PUT)
+    public void update(TransportTask transportTask, Integer customerId, HttpServletResponse resp) throws IOException {
+        transportTaskService.update(transportTask, customerId);
+        JsonUtil.writeMsg("1", resp);
+    }
+
+    @RequestMapping(value = "{cusId}", method = RequestMethod.GET, params = "getByCusId")
+    public void getTransportTaskByCusId(@PathVariable("cusId") Integer cusId, HttpServletResponse response) throws IOException {
+        JsonUtil.write(transportTaskService.getTransportTaskByCusId(cusId), response);
+    }
+}

+ 160 - 0
src/main/java/com/logistics/controller/UserController.java

@@ -0,0 +1,160 @@
+package com.logistics.controller;
+
+import com.alibaba.fastjson.JSONObject;
+import com.logistics.conf.Constants;
+import com.logistics.entity.User;
+import com.logistics.service.UserService;
+import com.logistics.util.JsonUtil;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+import java.io.IOException;
+
+/**
+ * Created by Ranger on 2015/8/17.
+ */
+@Controller
+@RequestMapping("user")
+public class UserController {
+    @Resource
+    UserService userService;
+
+
+    @RequestMapping("home")
+    public String home(){
+        return "/home/mainPage";
+    }
+
+    /**
+     * <p>客户登录</p>
+     * <p>GET  /user/login</p>
+     *
+     * @param user 需要进行登录的用户
+     * @throws java.io.IOException 返回JSON数据给前端时可能会抛出这个异常
+     */
+    @RequestMapping(value = "login", method = RequestMethod.GET)
+    public void login(User user, Model model, HttpSession session, HttpServletResponse response) throws IOException {
+        User userRec = userService.login(user);
+        JSONObject json = new JSONObject();
+        if (userRec != null) {
+            System.out.println("success");
+            model.addAttribute("user", user);
+            System.out.println("ID in login = " + userRec.getId());
+            session.setAttribute(Constants.USER_UID, userRec.getId());
+            json.put("status", 0);
+        } else {
+            System.out.println("error");
+            json.put("status", -1);
+        }
+        JsonUtil.write(json, response);
+    }
+
+    /**
+     * <p>用户注册</p>
+     * <p>GET  /user/register</p>
+     *
+     * @param user 要进行注册的用户
+     * @throws java.io.IOException 返回JSON数据给前端时可能会抛出这个异常
+     */
+    @RequestMapping(value = "register", method = RequestMethod.POST)
+    public void register(User user, Model model, HttpSession session, HttpServletResponse response) throws IOException {
+        User userRec = userService.register(user);
+        if (userRec != null) {
+            model.addAttribute("user", user);
+            session.setAttribute(Constants.USER_UID, userRec.getId());
+            JsonUtil.writeMsg("1", response);
+        } else {
+            JsonUtil.writeMsg("-1", response);
+        }
+    }
+
+    /**
+     * <p>用户注销</p>
+     * <p>GET    /user/logout</p>
+     */
+    @RequestMapping(value = "logout", method = RequestMethod.GET)
+    public String logout(HttpSession session) {
+        session.removeAttribute(Constants.USER_UID);
+        return "/home/mainPage";
+    }
+
+    /**
+     * <p>删除用户</p>
+     * <p>DELETE    /user</p>
+     *
+     * @param idArray 需要删除的用户的ID数组
+     */
+    @RequestMapping(method = RequestMethod.DELETE)
+    public void delete(int[] idArray) {
+        for (int id : idArray) {
+            userService.delete(id);
+        }
+    }
+
+    /**
+     * <p>获取用户信息</p>
+     * <p>GET    /user?json</p>
+     *
+     * @throws IOException 返回JSON数据给前端时可能会抛出这个异常
+     */
+    @RequestMapping(method = RequestMethod.GET, params = "json")
+    public void user_GET_json(HttpSession session, HttpServletResponse resp) throws IOException {
+        Integer id = (Integer) session.getAttribute(Constants.USER_UID);
+        User user = userService.get(id);
+        JsonUtil.write(user, resp);
+}
+
+    /**
+     * <p>更新用户记录</p>
+     * <p>PUT    /user</p>
+     *
+     * @param user 修改后的用户记录
+     * @throws IOException
+     */
+    @RequestMapping(method = RequestMethod.PUT)
+    public void user_Update(User user, HttpSession session, HttpServletResponse resp) throws IOException {
+        Integer id = (Integer) session.getAttribute(Constants.USER_UID);
+        User login = userService.get(id);
+        user.setId(login.getId());
+        user.setPassword(login.getPassword());
+        userService.update(user);
+        JsonUtil.writeMsg("1", resp);
+    }
+
+    /**
+     * <p>修改用户密码</p>
+     * <p>POST    /user/passwd?oldPass={oldPass}&newPass={newPass}</p>
+     *
+     * @param oldPass 旧密码
+     * @param newPass 新密码
+     * @throws IOException 返回JSON数据给前端时可能会抛出这个异常
+     */
+    @RequestMapping(value = "passwd", method = RequestMethod.POST)
+    public void user_passwd(String oldPass, String newPass, HttpSession session,
+                            HttpServletResponse resp) throws IOException {
+        Integer id = (Integer) session.getAttribute(Constants.USER_UID);
+        if (userService.passwd(id, oldPass, newPass)) {
+            JsonUtil.writeMsg("1", resp);
+        } else {
+            JsonUtil.writeMsg("-1", resp);
+        }
+    }
+
+    /**
+     * <p>根据Id获取用户信息</p>
+     * <p>GET    /user/{userId}</p>
+     *
+     * @param userId 需要获取的用户的ID
+     * @throws IOException 返回JSON数据给前端时可能会抛出这个异常
+     */
+    @RequestMapping(value = "{userId}", method = RequestMethod.GET)
+    public void getJsonRec(@PathVariable("userId") Integer userId, HttpServletResponse response) throws IOException {
+        JsonUtil.write(userService.get(userId), response);
+    }
+}

+ 123 - 0
src/main/java/com/logistics/controller/VehicleController.java

@@ -0,0 +1,123 @@
+package com.logistics.controller;
+
+import com.alibaba.fastjson.JSONObject;
+import com.logistics.conf.Configurator;
+import com.logistics.entity.Vehicle;
+import com.logistics.service.VehicleService;
+import com.logistics.util.JsonUtil;
+import org.hibernate.criterion.DetachedCriteria;
+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.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.util.List;
+
+import static com.logistics.util.Params.needLongList;
+
+/**
+ * Created by Ranger on 2015/8/19.
+ */
+@Controller
+@RequestMapping("vehicle")
+public class VehicleController {
+    @Resource
+    private VehicleService vehicleService;
+
+    /**
+     * <p>添加车辆记录</p>
+     * <p>POST    /vehicle</p>
+     *
+     * @param vehicle       需要添加的车辆记录
+     * @param driverId      匹配的驾驶员记录ID
+     * @param vehicleTypeId 匹配的车型记录ID
+     * @throws IOException 传数据给前端时可能会抛出的异常
+     */
+    @RequestMapping(method = RequestMethod.POST)
+    public void addRec(Vehicle vehicle, Integer driverId, Integer vehicleTypeId, HttpServletResponse response) throws IOException {
+        Integer id = vehicleService.add(vehicle, driverId, vehicleTypeId);
+        if (id != null) {
+            JsonUtil.writeMsg(id.toString(), response);
+        } else {
+            JsonUtil.writeMsg("-1", response);
+        }
+    }
+
+    /**
+     * <p>删除多条车辆记录</p>
+     * <p>DELETE    /vehicle?many</p>
+     *
+     * @param req 需要在该参数里面添加一个名称为ids的长整型数组
+     * @throws IOException 传数据给前端时可能会抛出的异常
+     */
+    @RequestMapping(method = RequestMethod.DELETE, params = "many")
+    public void vehicle_DELETE_MANY(HttpServletRequest req, HttpServletResponse resp) throws IOException {
+        List<Long> ids = needLongList(req, "ids");
+        for (long id : ids) {
+            vehicleService.delete((int) id);
+        }
+        JsonUtil.writeMsg("1", resp);
+    }
+
+    /**
+     * <p>删除单条车辆记录</p>
+     * <p>DELETE    /vehicle?json</p>
+     *
+     * @param vehicleId 需要删除的车辆记录的ID
+     * @throws IOException 传数据给前端时可能会抛出的异常
+     */
+    @RequestMapping(method = RequestMethod.DELETE, params = "json")
+    public void vehicle_DELETE_json(Integer vehicleId, HttpServletResponse resp) throws IOException {
+        vehicleService.delete(vehicleId);
+        JsonUtil.writeMsg("1", resp);
+    }
+
+    /**
+     * <p>获取车辆记录</p>
+     * <p>GET    /vehicle?json</p>
+     *
+     * @param start 从该条记录开始显示
+     * @param size  页面显示记录的条数
+     * @throws IOException 传数据给前端时可能会抛出的异常
+     */
+    @RequestMapping(method = RequestMethod.GET, params = "json")
+    public void getRec(Integer start, Integer size, HttpServletResponse response) throws IOException {
+        DetachedCriteria detachedCriteria = DetachedCriteria.forClass(Vehicle.class);
+        start = (start == null) ? 0 : start;
+        size = (size == null) ? Configurator.getInstance().getInt("defaultPageSize") : size;
+        List<Vehicle> vehicles = vehicleService.get(detachedCriteria, start, size);
+        JSONObject json = new JSONObject();
+        json.put("vehiclesLength", vehicleService.getAll().size());
+        JsonUtil.write(vehicles, "vehicles", json, response);
+    }
+
+    /**
+     * <p>获取单条车辆记录</p>
+     * <p>GET    /vehicle/{vehicleId}</p>
+     *
+     * @param vehicleId 需要获取的车辆记录的ID
+     * @throws IOException 传数据给前端时可能会抛出的异常
+     */
+    @RequestMapping(value = "{vehicleId}", method = RequestMethod.GET)
+    public void getJsonRec(@PathVariable("vehicleId") int vehicleId, HttpServletResponse response) throws IOException {
+        JsonUtil.write(vehicleService.get(vehicleId), response);
+    }
+
+    /**
+     * <p>修改车辆记录</p>
+     * <p>PUT    /vehicle?json</p>
+     *
+     * @param vehicle 修改后的车辆记录
+     * @throws IOException 传数据给前端时可能会抛出的异常
+     */
+    @RequestMapping(method = RequestMethod.PUT, params = "json")
+    public void updateRec(Vehicle vehicle, Integer driverId, Integer vehicleTypeId, HttpServletResponse response) throws IOException {
+        System.out.println("VehicleId = " + vehicleTypeId);
+        vehicleService.update(vehicle, driverId, vehicleTypeId);
+        JsonUtil.writeMsg("1", response);
+    }
+}

+ 86 - 0
src/main/java/com/logistics/controller/VehicleRepairController.java

@@ -0,0 +1,86 @@
+package com.logistics.controller;
+
+import com.logistics.conf.Configurator;
+import com.logistics.entity.VehicleRepair;
+import com.logistics.service.VehicleRepairService;
+import com.logistics.util.JsonUtil;
+import org.hibernate.criterion.DetachedCriteria;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.util.List;
+
+/**
+ * Created by Ranger on 2015/8/21.
+ */
+@Controller
+@RequestMapping("vehicleRepair")
+public class VehicleRepairController {
+    @Resource
+    private VehicleRepairService vehicleRepairService;
+
+    /**
+     * <p>添加汽车维修记录</p>
+     * <p>POST    /vehicleRepair?json</p>
+     *
+     * @param vehicleRepair 需要添加的单车维修记录
+     * @throws IOException 传数据给前端时可能会抛出的异常
+     */
+    @RequestMapping(method = RequestMethod.POST, params = "json")
+    public void add(VehicleRepair vehicleRepair, HttpServletResponse response) throws IOException {
+        Integer id = vehicleRepairService.add(vehicleRepair);
+        if (id != null) {
+            JsonUtil.writeMsg(id.toString(), response);
+        } else {
+            JsonUtil.writeMsg("-1", response);
+        }
+    }
+
+    /**
+     * <p>删除汽车维修记录</p>
+     * <p>DELETE    /vehicleRepair</p>
+     *
+     * @param request 需要在该参数中添加一个类型为int[]名为idArray的属性,
+     *                方法会取出所有在idArray里面的数据并以此作为id删除相应的记录
+     */
+    @RequestMapping(method = RequestMethod.DELETE)
+    public void delete(HttpServletRequest request) {
+        int[] idArray = (int[]) request.getAttribute("idArray");
+        for (int id : idArray) {
+            vehicleRepairService.delete(id);
+        }
+    }
+
+    /**
+     * <p>查询汽车维修记录</p>
+     * <p>GET    /vehicleRepair?json</p>
+     *
+     * @param start 从该条记录开始显示
+     * @param size  页面显示的数据条数
+     * @throws IOException 传数据给前端时可能会抛出的异常
+     */
+    @RequestMapping(method = RequestMethod.GET, params = "json")
+    public void get(Integer start, Integer size, HttpServletResponse response) throws IOException {
+        start = (start != null) ? start : 0;
+        size = (size != null) ? size : Configurator.getInstance().getInt("defaultPageSize");
+        DetachedCriteria detachedCriteria = DetachedCriteria.forClass(VehicleRepair.class);
+        List<VehicleRepair> vehicleRepairList = vehicleRepairService.get(detachedCriteria, start, size);
+        JsonUtil.write(vehicleRepairList, response);
+    }
+
+    /**
+     * <p>修改汽车维修记录</p>
+     * <p>PUT    /vehicleRepair</p>
+     *
+     * @param vehicleRepair 修改后的汽车维修记录
+     */
+    @RequestMapping(method = RequestMethod.PUT)
+    public void update(VehicleRepair vehicleRepair) {
+        vehicleRepairService.update(vehicleRepair);
+    }
+}

+ 119 - 0
src/main/java/com/logistics/controller/VehicleTypeController.java

@@ -0,0 +1,119 @@
+package com.logistics.controller;
+
+import com.alibaba.fastjson.JSONObject;
+import com.logistics.conf.Configurator;
+import com.logistics.entity.VehicleType;
+import com.logistics.service.VehicleTypeService;
+import com.logistics.util.JsonUtil;
+import org.hibernate.criterion.DetachedCriteria;
+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.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.util.List;
+
+import static com.logistics.util.Params.needLongList;
+
+
+/**
+ * Created by Ranger on 2015/8/19.
+ */
+@Controller
+@RequestMapping("vehicleType")
+public class VehicleTypeController {
+    @Resource
+    VehicleTypeService vehicleTypeService;
+
+    /**
+     * <p>增加车型记录</p>
+     * <p>POST    /vehicleType</p>
+     *
+     * @param vehicleType 需要添加的车型记录
+     * @throws java.io.IOException 返回JSON数据给前端时可能会抛出这个异常
+     */
+    @RequestMapping(method = RequestMethod.POST)
+    public void addRec(VehicleType vehicleType, HttpServletResponse response) throws IOException {
+        Integer id = vehicleTypeService.add(vehicleType);
+        if (id != null) {
+            JsonUtil.writeMsg(id.toString(), response);
+        } else {
+            JsonUtil.writeMsg("-1", response);
+        }
+    }
+
+    /**
+     * <p>批量删除车型记录</p>
+     * <p>DELETE    /vehicleType?many</p>
+     *
+     * @param req 需要在里面添加一个id数组
+     * @throws IOException 返回JSON数据给前端时可能会抛出这个异常
+     */
+    @RequestMapping(method = RequestMethod.DELETE, params = "many")
+    public void vehicleType_DELETE_MANY(HttpServletRequest req, HttpServletResponse resp) throws IOException {
+        List<Long> ids = needLongList(req, "ids");
+        for (long id : ids) {
+            vehicleTypeService.delete((int) id);
+        }
+        JsonUtil.writeMsg("1", resp);
+    }
+
+    /**
+     * <p>删除单条车型记录</p>
+     * <p>DELETE    /vehicleType?json</p>
+     *
+     * @param vehicleTypeId 需要删除的记录的id
+     * @throws IOException 返回JSON数据给前端时可能会抛出这个异常
+     */
+    @RequestMapping(method = RequestMethod.DELETE, params = "json")
+    public void vehicleType_DELETE_json(Integer vehicleTypeId, HttpServletResponse resp) throws IOException {
+        vehicleTypeService.delete(vehicleTypeId);
+        JsonUtil.writeMsg("1", resp);
+    }
+
+    /**
+     * <p>获取车型记录</p>
+     * <p>GET    /vehicleType?json</p>
+     *
+     * @param start 从该条记录开始显示
+     * @param size  页面显示的记录条数
+     * @throws java.io.IOException 返回JSON数据给前端时可能会抛出这个异常
+     */
+    @RequestMapping(method = RequestMethod.GET, params = "json")
+    public void getJsonRecs(Integer start, Integer size, HttpServletResponse response) throws IOException {
+        start = start != null ? start : 0;
+        size = size != null ? size : Configurator.getInstance().getInt("defaultPageSize");
+        List<VehicleType> vehicleTypes = vehicleTypeService.get(start, size);
+        JSONObject json = new JSONObject();
+        json.put("vehicleTypesLength", vehicleTypeService.getAll().size());
+        JsonUtil.write(vehicleTypes, "vehicleTypes", json, response);
+    }
+
+    /**
+     * <p>获取单个车型记录</p>
+     * <p>GET    /vehicleType/{vehicleTypeId}</p>
+     *
+     * @param vehicleTypeId 在路径中指定的车型记录的ID
+     * @throws java.io.IOException 返回JSON数据给前端时可能会抛出这个异常
+     */
+    @RequestMapping(value = "{vehicleTypeId}", method = RequestMethod.GET)
+    public void getJsonRec(@PathVariable("vehicleTypeId") int vehicleTypeId, HttpServletResponse response) throws IOException {
+        JsonUtil.write(vehicleTypeService.get(vehicleTypeId), response);
+    }
+
+    /**
+     * <p>修改车型信息</p>
+     * <p>PUT    /vehicleType?json</p>
+     *
+     * @param vehicleType 修改后的车型记录
+     */
+    @RequestMapping(method = RequestMethod.PUT, params = "json")
+    public void updateRec(VehicleType vehicleType, HttpServletResponse response) throws IOException {
+        vehicleTypeService.update(vehicleType);
+        JsonUtil.writeMsg("1", response);
+    }
+}

+ 194 - 0
src/main/java/com/logistics/crypto/AESCrypto.java

@@ -0,0 +1,194 @@
+package com.logistics.crypto;
+
+
+import javax.crypto.Cipher;
+import javax.crypto.KeyGenerator;
+import javax.crypto.SecretKey;
+import javax.crypto.spec.SecretKeySpec;
+import javax.security.auth.kerberos.KerberosKey;
+import java.security.NoSuchAlgorithmException;
+
+
+/** Encapulated Java Security Framework (JSF)
+ * <br />
+ *
+ * @version 2.1.0-build.20141022
+ */
+public class AESCrypto extends CryptoBase
+{
+    private static final String BASE_ALGORITHM = "AES";
+
+    //AES/CBC/NoPadding (128)
+    //AES/CBC/PKCS5Padding (128)
+    //AES/ECB/NoPadding (128)
+    //AES/ECB/PKCS5Padding (128)
+    public static final String AES_CBC_NOPADDING = "AES/CBC/NoPadding";
+    public static final String AES_CBC_PKCS5 = "AES/CBC/PKCS5Padding";
+    public static final String AES_ECB_NOPADDING = "AES/ECB/NoPadding";
+    public static final String AES_ECB_PKCS5 = "AES/ECB/PKCS5Padding";
+
+    public static final int KEY_LENGTH_128 = 128;
+
+    public static final String DEFAULT_ALGORITHM = AES_ECB_PKCS5;
+    public static final int DEFAULT_KEY_LENGTH = KEY_LENGTH_128;
+
+    protected KeyGenerator keyGen;
+    //protected SecretKeyFactory keyFac;
+    protected String algorithm;
+
+    public void setKeyLength(Integer keyLength)
+    {
+        try
+        {
+            if (keyLength == null)
+                keyLength = DEFAULT_KEY_LENGTH;
+
+            this.keyGen = KeyGenerator.getInstance(BASE_ALGORITHM);
+            this.keyGen.init(keyLength, this.rng);
+        }
+        catch (NoSuchAlgorithmException ex)
+        {
+            throw(new RuntimeException(ex.getMessage(), ex));
+        }
+
+        return;
+    }
+
+    public void setAlgorithm(String newAlgorithm)
+    {
+        this.algorithm = newAlgorithm!=null?newAlgorithm:DEFAULT_ALGORITHM;
+
+        return;
+    }
+
+  // SINGLETON
+    public AESCrypto()
+    {
+        super();
+
+        //try
+        //{
+            //this.keyFac = SecretKeyFactory.getInstance(BASE_ALGORITHM);
+            this.setKeyLength(null);
+            this.setAlgorithm(null);
+        //}
+        //catch (NoSuchAlgorithmException ex)
+        //{
+            //throw(new RuntimeException(ex.getMessage(), ex));
+        //}
+
+        return;
+    }
+
+    public AESCrypto(String algorithm, Integer keyLength)
+    {
+        super();
+
+        //try
+        //{
+            //this.keyFac = SecretKeyFactory.getInstance(BASE_ALGORITHM);
+            this.setAlgorithm(algorithm);
+            this.setKeyLength(keyLength);
+        //}
+        //catch (NoSuchAlgorithmException ex)
+        //{
+            //throw(new RuntimeException(ex.getMessage(), ex));
+        //}
+
+        return;
+    }
+
+    private static class Singleton
+    {
+        public static final AESCrypto INSTANCE = new AESCrypto();
+    }
+
+    public static AESCrypto getInstance()
+    {
+        return(
+            Singleton.INSTANCE
+        );
+    }
+
+  // KEY
+    public SecretKey generateKey()
+    {
+        return(
+            this.keyGen.generateKey()
+        );
+    }
+
+    public SecretKey generateKey(byte[] k)
+    {
+        return(
+            new SecretKeySpec(k, BASE_ALGORITHM)
+        );
+    }
+
+    /** not guaranteed to work...
+     */
+    public byte[] extractKey(SecretKey key)
+    {
+        if (key instanceof SecretKeySpec)
+        {
+            SecretKeySpec sKey = (SecretKeySpec)key;
+            if (BASE_ALGORITHM.equals(sKey.getAlgorithm()))
+                return(sKey.getEncoded());
+        }
+
+        if (key instanceof KerberosKey)
+        {
+            KerberosKey sKey = (KerberosKey)key;
+            if (BASE_ALGORITHM.equals(sKey.getAlgorithm()))
+                return(sKey.getEncoded());
+        }
+
+        throw(new IllegalArgumentException("Illegal or unregconized key type:"+key.toString()));
+    }
+
+  // CRYPTO
+    public byte[] encrypt(byte[] in, SecretKey key)
+    {
+        if (in == null)
+            throw(new IllegalArgumentException("param in must not be null."));
+        if (key == null)
+            throw(new IllegalArgumentException("param key must not be null."));
+
+        try
+        {
+            Cipher c = Cipher.getInstance(this.algorithm);
+            c.init(Cipher.ENCRYPT_MODE, key);
+
+            byte[] out = c.doFinal(in);
+
+            return(out);
+        }
+        catch (Exception ex)
+        {
+            throw(new RuntimeException(ex));
+        }
+    }
+
+    public byte[] decrypt(byte[] in, SecretKey key)
+    {
+        if (in == null)
+            throw(new IllegalArgumentException("in must have walue."));
+        if (key == null)
+            throw(new IllegalArgumentException("key must have value."));
+
+        try
+        {
+            Cipher c = Cipher.getInstance(this.algorithm);
+            c.init(Cipher.DECRYPT_MODE, key);
+
+            byte[] out = c.doFinal(in);
+
+            return(out);
+        }
+        catch (Exception ex)
+        {
+            throw(new RuntimeException(ex));
+        }
+    }
+
+}

+ 177 - 0
src/main/java/com/logistics/crypto/CryptoBase.java

@@ -0,0 +1,177 @@
+package com.logistics.crypto;
+
+import java.nio.ByteBuffer;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.security.SecureRandom;
+
+
+/** Nyaguru Crypto Util
+ * Encapulated Java Cryptography Architecture endpoints
+ * @version 2.1.0-build.20141004
+ */
+public class CryptoBase
+{
+    public static final char[] base64char =
+        {'A','B','C','D','E','F','G','H',
+         'I','J','K','L','M','N','O','P',
+         'Q','R','S','T','U','V','W','X',
+         'Y','Z','a','b','c','d','e','f',
+         'g','h','i','j','k','l','m','n',
+         'o','p','q','r','s','t','u','v',
+         'w','x','y','z','0','1','2','3',
+         '4','5','6','7','8','9','+','/'};
+
+    public static final String SR_SHA1PRNG = "SHA1PRNG";
+
+    public static final String DEFAULT_RANDOM = SR_SHA1PRNG;
+
+    protected SecureRandom rng;
+
+    public void setRng(String algorithm)
+        throws NoSuchAlgorithmException
+    {
+        this.rng = SecureRandom.getInstance("SHA1PRNG");
+
+        return;
+    }
+
+  // SINGLETON
+    public CryptoBase()
+    {
+        try
+        {
+            this.setRng(SR_SHA1PRNG);
+        }
+        catch (Exception ex)
+        {
+            throw(new RuntimeException(ex));
+        }
+
+        return;
+    }
+
+    private static class Singleton
+    {
+        public static final CryptoBase INSTANCE = new CryptoBase();
+    }
+
+    public static CryptoBase getInstance()
+    {
+        return(
+            Singleton.INSTANCE
+        );
+    }
+
+  // DIGEST
+    public byte[] MD5Digest(byte[] in)
+    {
+        try
+        {
+            MessageDigest md = MessageDigest.getInstance("MD5");
+
+            byte[] out = md.digest(in);
+
+            return(out);
+        }
+        catch (NoSuchAlgorithmException ex)
+        {
+            // never occur
+            ex.printStackTrace();
+            return(null);
+        }
+    }
+
+  // BASE64
+    public String base64Encode(byte[] bytes)
+    {
+        final int[] patterns =
+            {0x0000, 0x0001, 0x0003, 0x0007, 0x000f, 0x001f, 0x003f, 0x007f,
+            0x00ff, 0x01ff, 0x03ff,0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff};
+
+        StringBuilder sb = new StringBuilder();
+        int inbuf = 0;
+        int inpos = 0;
+        int inbufsize = 0;
+
+        while (inpos < bytes.length)
+        {
+            inbuf = (inbuf << 8) | (bytes[inpos] & 0xff);
+            inpos += 1;
+            inbufsize += 8;
+
+            if ((inpos%57) == 0 )
+                sb.append("\n");
+
+            while (inbufsize >= 6)
+            {
+                int outbuf = inbuf >> (inbufsize - 6);
+                inbuf = inbuf & patterns[inbufsize - 6];
+                inbufsize -= 6;
+
+                sb.append(base64char[outbuf]);
+            }
+        }
+
+        if (inpos%3 != 0)
+        {
+            inbuf = (inbuf << 8);
+            inbufsize += 8;
+            int outbuf = inbuf >> (inbufsize - 6);
+            sb.append(base64char[outbuf]);
+
+            while (inpos%3 != 0)
+            {
+                sb.append("=");
+                inpos++;
+            }
+        }
+
+        return(sb.toString());
+    }
+
+  // RANDOM
+    public byte[] randomBytes(int length)
+    {
+        byte[] bytes = new byte[length];
+
+        this.rng.nextBytes(bytes);
+        return(bytes);
+    }
+
+  // CONVERT
+    public static byte[] hexToBytes(String s)
+    {
+        int l = s.length() / 2;
+
+        ByteBuffer buf = ByteBuffer.allocate(l);
+        for (int i=0; i<s.length(); i+=2)
+        {
+            buf.put(
+                Integer.valueOf(
+                    s.substring(i, i+2),
+                    16
+                ).byteValue()
+            );
+        }
+
+        return(buf.array());
+    }
+
+    public static String byteToHex(byte[] bytes)
+    {
+        StringBuilder sb = new StringBuilder(bytes.length*2);
+
+        for (int i=0; i<bytes.length; i++)
+            sb.append(
+                String.format("%02x", bytes[i] & 0xff)
+            );
+
+        return(sb.toString());
+    }
+
+    public static String bytesToHex(byte[] bytes)
+    {
+        return(byteToHex(bytes));
+    }
+}

+ 206 - 0
src/main/java/com/logistics/crypto/RSACrypto.java

@@ -0,0 +1,206 @@
+package com.logistics.crypto;
+
+import javax.crypto.Cipher;
+import java.math.BigInteger;
+import java.security.*;
+import java.security.interfaces.RSAPrivateKey;
+import java.security.interfaces.RSAPublicKey;
+import java.security.spec.InvalidKeySpecException;
+import java.security.spec.RSAPrivateKeySpec;
+import java.security.spec.RSAPublicKeySpec;
+
+
+/** Encapulated Java Security Framework (JSF)
+ * <br />
+ *
+ * @version 2.1.0-build.20141022
+ */
+public class  RSACrypto extends CryptoBase
+{
+    private static final String BASE_ALGORITHM = "RSA";
+
+    //RSA/ECB/PKCS1Padding (1024, 2048)
+    //RSA/ECB/OAEPWithSHA-1AndMGF1Padding (1024, 2048)
+    //RSA/ECB/OAEPWithSHA-256AndMGF1Padding (1024, 2048)
+    public static final String RSA_ECB_PKCS1 = "RSA/ECB/PKCS1Padding";
+    public static final String RSA_ECB_OAEPSHA1 = "RSA/ECB/OAEPWithSHA-1AndMGF1Padding";
+    public static final String RSA_ECB_OAEPSHA256 = "RSA/ECB/OAEPWithSHA-256AndMGF1Padding";
+
+    public static final int KEY_LENGTH_1024 = 1024;
+    public static final int KEY_LENGTH_2048 = 2048;
+
+    public static final String DEFAULT_ALGORITHM = RSA_ECB_PKCS1;
+    public static final int DEFAULT_KEY_LENGTH = KEY_LENGTH_1024;
+
+    protected KeyPairGenerator keyGen;
+    protected KeyFactory keyFac;
+    protected String algorithm;
+
+    public void setKeyLength(Integer keyLength)
+    {
+        try
+        {
+            if (keyLength == null)
+                keyLength = DEFAULT_KEY_LENGTH;
+
+            this.keyGen = KeyPairGenerator.getInstance(BASE_ALGORITHM);
+            this.keyGen.initialize(keyLength, this.rng);
+        }
+        catch (NoSuchAlgorithmException ex)
+        {
+            // never happen
+            ex.printStackTrace();
+        }
+
+        return;
+    }
+
+    public void setAlgorithm(String newAlgorithm)
+    {
+        this.algorithm = newAlgorithm!=null?newAlgorithm:DEFAULT_ALGORITHM;
+
+        return;
+    }
+
+  // SINGLETON
+    public RSACrypto()
+    {
+        super();
+
+        try
+        {
+            this.keyFac = KeyFactory.getInstance(BASE_ALGORITHM);
+            this.setKeyLength(null);
+            this.setAlgorithm(null);
+        }
+        catch (NoSuchAlgorithmException ex)
+        {
+            throw(new RuntimeException(ex.getMessage(), ex));
+        }
+
+        return;
+    }
+
+    public RSACrypto(String algorithm, Integer keyLength)
+    {
+        super();
+
+        try
+        {
+            this.keyFac = KeyFactory.getInstance(BASE_ALGORITHM);
+            this.setAlgorithm(algorithm);
+            this.setKeyLength(keyLength);
+        }
+        catch (NoSuchAlgorithmException ex)
+        {
+            throw(new RuntimeException(ex.getMessage(), ex));
+        }
+
+        return;
+    }
+
+    private static class Singleton
+    {
+        public static final RSACrypto INSTANCE = new RSACrypto();
+    }
+
+    public static RSACrypto getInstance()
+    {
+        return(
+            Singleton.INSTANCE
+        );
+    }
+
+  // KEY
+
+    public KeyPair generateKey()
+    {
+        return(
+            this.keyGen.generateKeyPair()
+        );
+    }
+
+    public RSAPublicKey generatePublic(byte[] m, byte[] e)
+    {
+        try
+        {
+            return((RSAPublicKey)
+                this.keyFac.generatePublic(
+                    new RSAPublicKeySpec(
+                        new BigInteger(m),
+                        new BigInteger(e)
+                    )
+                )
+            );
+        }
+        catch (InvalidKeySpecException ex)
+        {
+            throw(new RuntimeException(ex.getMessage(), ex));
+        }
+    }
+
+    public RSAPrivateKey generatePrivate(byte[] m, byte[] d)
+    {
+        try
+        {
+            return((RSAPrivateKey)
+                this.keyFac.generatePublic(
+                    new RSAPrivateKeySpec(
+                        new BigInteger(m),
+                        new BigInteger(d)
+                    )
+                )
+            );
+        }
+        catch (InvalidKeySpecException ex)
+        {
+            throw(new RuntimeException(ex.getMessage(), ex));
+        }
+    }
+
+  // CRYPTO
+    public byte[] encrypt(byte[] in, PublicKey key)
+    {
+        if (in == null)
+            throw(new IllegalArgumentException("param in must not be null."));
+        if (key == null)
+            throw(new IllegalArgumentException("param key must not be null."));
+
+        try
+        {
+            Cipher c = Cipher.getInstance(this.algorithm);
+            c.init(Cipher.ENCRYPT_MODE, key);
+
+            byte[] out = c.doFinal(in);
+
+            return(out);
+        }
+        catch (Exception ex)
+        {
+            throw(new RuntimeException(ex));
+        }
+    }
+
+    public byte[] decrypt(byte[] in, PrivateKey key)
+    {
+        if (in == null)
+            throw(new IllegalArgumentException("in must have walue."));
+        if (key == null)
+            throw(new IllegalArgumentException("key must have value."));
+
+        try
+        {
+            Cipher c = Cipher.getInstance(this.algorithm);
+            c.init(Cipher.DECRYPT_MODE, key);
+
+            byte[] out = c.doFinal(in);
+
+            return(out);
+        }
+        catch (Exception ex)
+        {
+            throw(new RuntimeException(ex));
+        }
+    }
+
+}

+ 76 - 0
src/main/java/com/logistics/crypto/RSAKeyCache.java

@@ -0,0 +1,76 @@
+package com.logistics.crypto;
+
+import com.logistics.conf.Configurator;
+import net.sf.ehcache.Cache;
+import net.sf.ehcache.CacheManager;
+import net.sf.ehcache.Element;
+
+import java.security.KeyPair;
+import java.security.PrivateKey;
+import java.security.PublicKey;
+
+/** 生成及缓存 RSA 密钥对
+ * 生成的公钥将直接返回, 以 Long 值为键稍后取回私钥
+ */
+public class RSAKeyCache
+{
+  // CONSTRUCT
+    protected Cache cache;
+
+    protected RSACrypto rsa;
+
+    public RSAKeyCache()
+    {
+        this.cache = CacheManager.getInstance().getCache("RSAKeyCache");
+        if (this.cache == null)
+            throw(new RuntimeException("Get RSAKeyCache failed, ehcache.xml missing or incorrect."));
+
+        Long ttl = Configurator.getInstance().getLong("logistics.admin.rsakeyttl");
+        if (ttl != null)
+        {
+            this.cache.getCacheConfiguration()
+                .setTimeToLiveSeconds(ttl);
+        }
+
+        this.rsa = RSACrypto.getInstance();
+
+        return;
+    }
+
+  // SINGLETON
+    private static class Singleton
+    {
+        public static final RSAKeyCache instance = new RSAKeyCache();
+    }
+
+    public static RSAKeyCache getInstance()
+    {
+        return(Singleton.instance);
+    }
+
+  //
+    public void put(Long id, PrivateKey key)
+    {
+        this.cache.put(new Element(id, key));
+
+        return;
+    }
+
+    public PrivateKey get(Long id)
+    {
+        Element e = this.cache.get(id);
+        return(
+            e!=null ? (PrivateKey)e.getObjectValue() : null
+        );
+    }
+
+    /** 生成一对密钥, 并返回其中的公钥
+     */
+    public PublicKey genKey(Long id)
+    {
+        KeyPair kp = this.rsa.generateKey();
+        this.put(id, kp.getPrivate());
+
+        return(kp.getPublic());
+    }
+}

+ 13 - 0
src/main/java/com/logistics/dao/AddressDao.java

@@ -0,0 +1,13 @@
+package com.logistics.dao;
+
+import com.logistics.entity.Address;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+
+/**
+ * Created by Mklaus on 15/8/24.
+ */
+public interface AddressDao extends BaseDao<Address> {
+    public List<Address> get(Integer start, Integer size);
+}

+ 9 - 0
src/main/java/com/logistics/dao/AdminDao.java

@@ -0,0 +1,9 @@
+package com.logistics.dao;
+
+import com.logistics.entity.Admin;
+
+/**
+ * Created by Mklaus on 15/7/23.
+ */
+public interface AdminDao extends BaseDao<Admin> {
+}

+ 41 - 0
src/main/java/com/logistics/dao/BaseDao.java

@@ -0,0 +1,41 @@
+package com.logistics.dao;
+
+import com.logistics.entity.BasicEntity;
+import org.hibernate.Query;
+import org.hibernate.SQLQuery;
+import org.hibernate.criterion.DetachedCriteria;
+
+import javax.persistence.MappedSuperclass;
+import java.util.List;
+
+/**
+ * Created by Mklaus on 15/7/23.
+ */
+@MappedSuperclass
+public interface BaseDao<T extends BasicEntity> {
+    Class classOfT();
+
+    T get(int id);
+
+    List<T> getAll();
+
+    Integer save(T t);
+
+    void update(T t);
+
+    void delete(int id);
+
+    void delete(T t);
+
+    int count(DetachedCriteria dc);
+
+    List<T> search(DetachedCriteria dc);
+
+    List<T> search(DetachedCriteria dc, Integer start, Integer size);
+
+    List<T> get(Integer start,Integer size);
+
+    Query createQuery(String hql);
+
+    SQLQuery createSQLQuery(String sql);
+}

+ 9 - 0
src/main/java/com/logistics/dao/CarBusinessDao.java

@@ -0,0 +1,9 @@
+package com.logistics.dao;
+
+import com.logistics.entity.CarBusiness;
+
+/**
+ * Created by Ranger on 2015/8/13.
+ */
+public interface CarBusinessDao extends BaseDao<CarBusiness>{
+}

+ 9 - 0
src/main/java/com/logistics/dao/CargoDao.java

@@ -0,0 +1,9 @@
+package com.logistics.dao;
+
+import com.logistics.entity.Cargo;
+
+/**
+ * Created by Ranger on 2015/8/13.
+ */
+public interface CargoDao extends BaseDao<Cargo>{
+}

+ 9 - 0
src/main/java/com/logistics/dao/CarrierBusinessDao.java

@@ -0,0 +1,9 @@
+package com.logistics.dao;
+
+import com.logistics.entity.CarrierBusiness;
+
+/**
+ * Created by Ranger on 2015/8/13.
+ */
+public interface CarrierBusinessDao extends BaseDao<CarrierBusiness>{
+}

+ 10 - 0
src/main/java/com/logistics/dao/CompanyDao.java

@@ -0,0 +1,10 @@
+package com.logistics.dao;
+
+import com.logistics.entity.Company;
+
+/**
+ * Created by Ranger on 2015/8/13.
+ */
+public interface CompanyDao extends BaseDao<Company> {
+
+}

+ 9 - 0
src/main/java/com/logistics/dao/GoodsDao.java

@@ -0,0 +1,9 @@
+package com.logistics.dao;
+
+import com.logistics.entity.Goods;
+
+/**
+ * Created by Mklaus on 15/7/24.
+ */
+public interface GoodsDao extends BaseDao<Goods> {
+}

+ 9 - 0
src/main/java/com/logistics/dao/GoodsGroupDao.java

@@ -0,0 +1,9 @@
+package com.logistics.dao;
+
+import com.logistics.entity.GoodsGroup;
+
+/**
+ * Created by Mklaus on 15/8/20.
+ */
+public interface GoodsGroupDao extends BaseDao<GoodsGroup> {
+}

+ 9 - 0
src/main/java/com/logistics/dao/GoodsRecordDao.java

@@ -0,0 +1,9 @@
+package com.logistics.dao;
+
+import com.logistics.entity.GoodsRecord;
+
+/**
+ * Created by Ranger on 2015/8/13.
+ */
+public interface GoodsRecordDao extends BaseDao<GoodsRecord> {
+}

+ 27 - 0
src/main/java/com/logistics/dao/Impl/AddressDaoImpl.java

@@ -0,0 +1,27 @@
+package com.logistics.dao.Impl;
+
+import com.logistics.dao.AddressDao;
+import com.logistics.entity.Address;
+import org.springframework.stereotype.Repository;
+
+/**
+ * Created by Mklaus on 15/8/24.
+ */
+@Repository
+public class AddressDaoImpl extends BaseDaoImpl<Address> implements AddressDao{
+    @Override
+    public Class classOfT() {
+        return Address.class;
+    }
+
+//    @Override
+//    public List<Address> get(Integer start, Integer size) {
+//
+//        List<Address> l = createQuery("from Address addr")
+//                .setFirstResult(start)
+//                .setMaxResults(size)
+//                .list();
+//
+//        return l;
+//    }
+}

+ 16 - 0
src/main/java/com/logistics/dao/Impl/AdminDaoImpl.java

@@ -0,0 +1,16 @@
+package com.logistics.dao.Impl;
+
+import com.logistics.dao.AdminDao;
+import com.logistics.entity.Admin;
+import org.springframework.stereotype.Repository;
+
+/**
+ * Created by Mklaus on 15/7/23.
+ */
+@Repository("adminDaoImpl")
+public class AdminDaoImpl extends BaseDaoImpl<Admin> implements AdminDao{
+    @Override
+    public Class classOfT(){
+        return Admin.class;
+    }
+}

+ 106 - 0
src/main/java/com/logistics/dao/Impl/BaseDaoImpl.java

@@ -0,0 +1,106 @@
+package com.logistics.dao.Impl;
+
+import com.logistics.dao.BaseDao;
+import com.logistics.entity.BasicEntity;
+import org.hibernate.*;
+import org.hibernate.criterion.DetachedCriteria;
+import org.hibernate.criterion.Projections;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import javax.persistence.MappedSuperclass;
+import java.util.List;
+
+/**
+ * Created by Mklaus on 15/7/23.
+ */
+@MappedSuperclass
+public abstract class BaseDaoImpl<T extends BasicEntity> implements BaseDao<T> {
+    @Autowired
+    private SessionFactory sessionFactory;
+
+    public Session getSession() {
+        return sessionFactory.getCurrentSession();
+    }
+
+    @Override
+    public T get(int id) {
+        return (T) getSession().get(classOfT(), id);
+    }
+
+    @Override
+    public List<T> getAll() {
+        DetachedCriteria dc = DetachedCriteria.forClass(classOfT());
+        return search(dc);
+    }
+
+    @Override
+    public Integer save(T t) {
+        t.setCreated_time(System.currentTimeMillis());
+        t.setModify_time(System.currentTimeMillis());
+        return (Integer) getSession().save(t);
+    }
+
+    @Override
+    public void update(T t) {
+        t.setModify_time(System.currentTimeMillis());
+        getSession().update(t);
+    }
+
+    @Override
+    public void delete(int id) {
+        getSession().delete(get(id));
+    }
+
+    @Override
+    public void delete(T t) {
+        getSession().delete(t);
+    }
+
+    @Override
+    public int count(DetachedCriteria dc) {
+        Criteria c = dc.getExecutableCriteria(getSession()).setProjection(Projections.rowCount());
+        return (Integer) c.uniqueResult();
+    }
+
+    @Override
+    public List search(DetachedCriteria dc) {
+        return search(dc, null, null);
+    }
+
+    @Override
+    public List search(DetachedCriteria dc, Integer start, Integer size) {
+        dc.setResultTransformer(DetachedCriteria.DISTINCT_ROOT_ENTITY);
+        Criteria c = dc.getExecutableCriteria(getSession());
+        if (start != null) {
+            c.setFirstResult(start);
+        }
+
+        if (size != null) {
+            c.setMaxResults(size);
+        }
+
+        return c.list();
+    }
+
+    @Override
+    public List<T> get(Integer start, Integer size) {
+        String className = classOfT().getName().substring(classOfT().getName().lastIndexOf(".") + 1);
+
+        List<T> l = createQuery("from " + className)
+                .setFirstResult(start)
+                .setMaxResults(size)
+                .list();
+
+        return l;
+    }
+
+    @Override
+    public Query createQuery(String hql) {
+        return getSession().createQuery(hql);
+    }
+
+    @Override
+    public SQLQuery createSQLQuery(String sql) {
+        return getSession().createSQLQuery(sql);
+    }
+}

+ 16 - 0
src/main/java/com/logistics/dao/Impl/CarBusinessDaoImpl.java

@@ -0,0 +1,16 @@
+package com.logistics.dao.Impl;
+
+import com.logistics.dao.CarBusinessDao;
+import com.logistics.entity.CarBusiness;
+import org.springframework.stereotype.Repository;
+
+/**
+ * Created by Ranger on 2015/8/13.
+ */
+@Repository("carBusinessDaoImpl")
+public class CarBusinessDaoImpl extends BaseDaoImpl<CarBusiness> implements CarBusinessDao {
+    @Override
+    public Class classOfT() {
+        return CarBusiness.class;
+    }
+}

+ 16 - 0
src/main/java/com/logistics/dao/Impl/CargoDaoImpl.java

@@ -0,0 +1,16 @@
+package com.logistics.dao.Impl;
+
+import com.logistics.dao.CargoDao;
+import com.logistics.entity.Cargo;
+import org.springframework.stereotype.Repository;
+
+/**
+ * Created by Ranger on 2015/8/13.
+ */
+@Repository("cargoDaoImpl")
+public class CargoDaoImpl extends BaseDaoImpl<Cargo> implements CargoDao {
+    @Override
+    public Class classOfT() {
+        return Cargo.class;
+    }
+}

+ 16 - 0
src/main/java/com/logistics/dao/Impl/CarrierBusinessDaoImpl.java

@@ -0,0 +1,16 @@
+package com.logistics.dao.Impl;
+
+import com.logistics.dao.CarrierBusinessDao;
+import com.logistics.entity.CarrierBusiness;
+import org.springframework.stereotype.Repository;
+
+/**
+ * Created by Ranger on 2015/8/13.
+ */
+@Repository("carrierBusinessDaoImpl")
+public class CarrierBusinessDaoImpl extends BaseDaoImpl<CarrierBusiness> implements CarrierBusinessDao {
+    @Override
+    public Class classOfT() {
+        return CarrierBusiness.class;
+    }
+}

+ 16 - 0
src/main/java/com/logistics/dao/Impl/CompanyDaoImpl.java

@@ -0,0 +1,16 @@
+package com.logistics.dao.Impl;
+
+import com.logistics.dao.CompanyDao;
+import com.logistics.entity.Company;
+import org.springframework.stereotype.Repository;
+
+/**
+ * Created by Ranger on 2015/8/13.
+ */
+@Repository("companyDaoImpl")
+public class CompanyDaoImpl extends BaseDaoImpl<Company> implements CompanyDao {
+    @Override
+    public Class classOfT() {
+        return Company.class;
+    }
+}

+ 16 - 0
src/main/java/com/logistics/dao/Impl/GoodsDaoImpl.java

@@ -0,0 +1,16 @@
+package com.logistics.dao.Impl;
+
+import com.logistics.dao.GoodsDao;
+import com.logistics.entity.Goods;
+import org.springframework.stereotype.Repository;
+
+/**
+ * Created by Mklaus on 15/7/24.
+ */
+@Repository
+public class GoodsDaoImpl extends BaseDaoImpl<Goods> implements GoodsDao {
+    @Override
+    public Class classOfT(){
+        return Goods.class;
+    }
+}

+ 16 - 0
src/main/java/com/logistics/dao/Impl/GoodsGroupDaoImpl.java

@@ -0,0 +1,16 @@
+package com.logistics.dao.Impl;
+
+import com.logistics.dao.GoodsGroupDao;
+import com.logistics.entity.GoodsGroup;
+import org.springframework.stereotype.Repository;
+
+/**
+ * Created by Mklaus on 15/8/20.
+ */
+@Repository
+public class GoodsGroupDaoImpl extends BaseDaoImpl<GoodsGroup> implements GoodsGroupDao {
+    @Override
+    public Class classOfT() {
+        return GoodsGroup.class;
+    }
+}

+ 16 - 0
src/main/java/com/logistics/dao/Impl/GoodsRecordDaoImpl.java

@@ -0,0 +1,16 @@
+package com.logistics.dao.Impl;
+
+import com.logistics.dao.GoodsRecordDao;
+import com.logistics.entity.GoodsRecord;
+import org.springframework.stereotype.Repository;
+
+/**
+ * Created by Ranger on 2015/8/13.
+ */
+@Repository
+public class GoodsRecordDaoImpl extends BaseDaoImpl<GoodsRecord> implements GoodsRecordDao {
+    @Override
+    public Class classOfT() {
+        return GoodsRecord.class;
+    }
+}

+ 16 - 0
src/main/java/com/logistics/dao/Impl/OilBuyDaoImpl.java

@@ -0,0 +1,16 @@
+package com.logistics.dao.Impl;
+
+import com.logistics.dao.OilBuyDao;
+import com.logistics.entity.OilBuy;
+import org.springframework.stereotype.Repository;
+
+/**
+ * Created by Mklaus on 15/8/21.
+ */
+@Repository
+public class OilBuyDaoImpl extends BaseDaoImpl<OilBuy> implements OilBuyDao {
+    @Override
+    public Class classOfT() {
+        return OilBuy.class;
+    }
+}

+ 16 - 0
src/main/java/com/logistics/dao/Impl/StaffDaoImpl.java

@@ -0,0 +1,16 @@
+package com.logistics.dao.Impl;
+
+import com.logistics.dao.StaffDao;
+import com.logistics.entity.Staff;
+import org.springframework.stereotype.Repository;
+
+/**
+ * Created by Ranger on 2015/8/13.
+ */
+@Repository
+public class StaffDaoImpl extends BaseDaoImpl<Staff> implements StaffDao {
+    @Override
+    public Class classOfT() {
+        return Staff.class;
+    }
+}

+ 24 - 0
src/main/java/com/logistics/dao/Impl/TransportTaskDaoImpl.java

@@ -0,0 +1,24 @@
+package com.logistics.dao.Impl;
+
+import com.logistics.dao.TransportTaskDao;
+import com.logistics.entity.TransportTask;
+import org.springframework.stereotype.Repository;
+
+import java.util.UUID;
+
+/**
+ * Created by Ranger on 2015/8/13.
+ */
+@Repository
+public class TransportTaskDaoImpl extends BaseDaoImpl<TransportTask> implements TransportTaskDao {
+    @Override
+    public Class classOfT() {
+        return TransportTask.class;
+    }
+
+    @Override
+    public Integer save(TransportTask transportTask) {
+        transportTask.setQueryId(UUID.randomUUID().toString().replaceAll("-", "").toUpperCase());
+        return super.save(transportTask);
+    }
+}

+ 16 - 0
src/main/java/com/logistics/dao/Impl/UserDaoImpl.java

@@ -0,0 +1,16 @@
+package com.logistics.dao.Impl;
+
+import com.logistics.dao.UserDao;
+import com.logistics.entity.User;
+import org.springframework.stereotype.Repository;
+
+/**
+ * Created by Ranger on 2015/8/13.
+ */
+@Repository
+public class UserDaoImpl extends BaseDaoImpl<User> implements UserDao{
+    @Override
+    public Class classOfT() {
+        return User.class;
+    }
+}

+ 16 - 0
src/main/java/com/logistics/dao/Impl/VehicleDaoImpl.java

@@ -0,0 +1,16 @@
+package com.logistics.dao.Impl;
+
+import com.logistics.dao.VehicleDao;
+import com.logistics.entity.Vehicle;
+import org.springframework.stereotype.Repository;
+
+/**
+ * Created by Ranger on 2015/8/13.
+ */
+@Repository
+public class VehicleDaoImpl extends BaseDaoImpl<Vehicle> implements VehicleDao {
+    @Override
+    public Class classOfT() {
+        return Vehicle.class;
+    }
+}

+ 16 - 0
src/main/java/com/logistics/dao/Impl/VehicleRepairDaoImpl.java

@@ -0,0 +1,16 @@
+package com.logistics.dao.Impl;
+
+import com.logistics.dao.VehicleRepairDao;
+import com.logistics.entity.VehicleRepair;
+import org.springframework.stereotype.Repository;
+
+/**
+ * Created by Ranger on 2015/8/13.
+ */
+@Repository
+public class VehicleRepairDaoImpl extends BaseDaoImpl<VehicleRepair> implements VehicleRepairDao {
+    @Override
+    public Class classOfT() {
+        return VehicleRepair.class;
+    }
+}

+ 16 - 0
src/main/java/com/logistics/dao/Impl/VehicleTypeDaoImpl.java

@@ -0,0 +1,16 @@
+package com.logistics.dao.Impl;
+
+import com.logistics.dao.VehicleTypeDao;
+import com.logistics.entity.VehicleType;
+import org.springframework.stereotype.Repository;
+
+/**
+ * Created by Ranger on 2015/8/13.
+ */
+@Repository
+public class VehicleTypeDaoImpl extends BaseDaoImpl<VehicleType> implements VehicleTypeDao {
+    @Override
+    public Class classOfT() {
+        return VehicleType.class;
+    }
+}

+ 9 - 0
src/main/java/com/logistics/dao/OilBuyDao.java

@@ -0,0 +1,9 @@
+package com.logistics.dao;
+
+import com.logistics.entity.OilBuy;
+
+/**
+ * Created by Mklaus on 15/8/21.
+ */
+public interface OilBuyDao extends BaseDao<OilBuy>{
+}

+ 9 - 0
src/main/java/com/logistics/dao/StaffDao.java

@@ -0,0 +1,9 @@
+package com.logistics.dao;
+
+import com.logistics.entity.Staff;
+
+/**
+ * Created by Ranger on 2015/8/13.
+ */
+public interface StaffDao extends BaseDao<Staff> {
+}

+ 9 - 0
src/main/java/com/logistics/dao/TransportTaskDao.java

@@ -0,0 +1,9 @@
+package com.logistics.dao;
+
+import com.logistics.entity.TransportTask;
+
+/**
+ * Created by Ranger on 2015/8/13.
+ */
+public interface TransportTaskDao extends BaseDao<TransportTask> {
+}

+ 9 - 0
src/main/java/com/logistics/dao/UserDao.java

@@ -0,0 +1,9 @@
+package com.logistics.dao;
+
+import com.logistics.entity.User;
+
+/**
+ * Created by Ranger on 2015/8/13.
+ */
+public interface UserDao extends BaseDao<User> {
+}

+ 9 - 0
src/main/java/com/logistics/dao/VehicleDao.java

@@ -0,0 +1,9 @@
+package com.logistics.dao;
+
+import com.logistics.entity.Vehicle;
+
+/**
+ * Created by Ranger on 2015/8/13.
+ */
+public interface VehicleDao extends BaseDao<Vehicle> {
+}

+ 9 - 0
src/main/java/com/logistics/dao/VehicleRepairDao.java

@@ -0,0 +1,9 @@
+package com.logistics.dao;
+
+import com.logistics.entity.VehicleRepair;
+
+/**
+ * Created by Ranger on 2015/8/13.
+ */
+public interface VehicleRepairDao extends BaseDao<VehicleRepair> {
+}

+ 9 - 0
src/main/java/com/logistics/dao/VehicleTypeDao.java

@@ -0,0 +1,9 @@
+package com.logistics.dao;
+
+import com.logistics.entity.VehicleType;
+
+/**
+ * Created by Ranger on 2015/8/13.
+ */
+public interface VehicleTypeDao extends BaseDao<VehicleType> {
+}

+ 93 - 0
src/main/java/com/logistics/entity/Address.java

@@ -0,0 +1,93 @@
+package com.logistics.entity;
+
+import javax.persistence.*;
+import java.util.Set;
+
+/**
+ * Created by Ranger on 2015/8/10.
+ * <p>
+ * 地址信息
+ */
+@Entity
+@Table(name = "address")
+public class Address extends BasicEntity {
+    /**
+     * 地域名,省、市、县、镇名称
+     */
+    @Column(name = "AreaName", length = 64)
+    private String areaName;
+
+    /**
+     * 代表地域级别,我国的地域级别划分如下:
+     * (一)全国分为省、自治区、直辖市;
+     * (二)省、自治区分为自治州、县、自治县、市;
+     * (三)县、自治县分为乡、民族乡、镇。
+     * 直辖市和较大的市分为区、县。自治州分为县、自治县、市。
+     * 编码可以采用字符串表示地域级别,比如:“省”。
+     * <p>
+     * 1 = 省,2 = 市,3 = 县
+     */
+    @Column(name = "Level")
+    private int level;
+
+    /**
+     * 地名拼音简称,例如痛快简称为PZH
+     */
+    @Column(name = "Pinyin", length = 32)
+    private String pinyin;
+
+    @ManyToOne
+    @JoinColumn(name = "parent")
+    private Address parent;
+
+    @OneToMany(mappedBy = "parent", cascade = CascadeType.ALL, fetch = FetchType.EAGER)
+    private Set<Address> children;
+
+    public Address() {
+    }
+
+    public Address(String areaName, int level) {
+        this.areaName = areaName;
+        this.level = level;
+    }
+
+    public String getAreaName() {
+        return areaName;
+    }
+
+    public void setAreaName(String areaName) {
+        this.areaName = areaName;
+    }
+
+    public int getLevel() {
+        return level;
+    }
+
+    public void setLevel(int level) {
+        this.level = level;
+    }
+
+    public String getPinyin() {
+        return pinyin;
+    }
+
+    public void setPinyin(String pinyin) {
+        this.pinyin = pinyin;
+    }
+
+    public Address getParent() {
+        return parent;
+    }
+
+    public void setParent(Address parent) {
+        this.parent = parent;
+    }
+
+    public Set<Address> getChildren() {
+        return children;
+    }
+
+    public void setChildren(Set<Address> children) {
+        this.children = children;
+    }
+}

+ 85 - 0
src/main/java/com/logistics/entity/Admin.java

@@ -0,0 +1,85 @@
+package com.logistics.entity;
+
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Table;
+
+/**
+ * Created by Mklaus on 15/7/23.
+ * <p/>
+ * 管理员信息表
+ */
+@Entity
+@Table(name = "admin")
+public class Admin extends BasicEntity {
+
+    @Column(name = "adminName")
+    private String adminName;
+
+    @Column(name = "salt", length = 8)
+    private byte[] salt;
+
+    @Column(name = "password")
+    private byte[] password;
+
+    /**
+     * 管理员的类型有:
+     * 1、超级管理员,具有所有表CRUD的权限;
+     * 2、物资管理员,具有对物资信息表CURD的权限;
+     * 3、运输管理员,具有对货物,地址,单车运营记录,承运商业务记录,运输任务CRUD的权限;
+     * 4、车辆管理员,具有对车辆信息CRUD的权限;
+     * 5、人力资源管理员,具有对雇员信息CRUD的权限(人员信息表还没有做);
+     * 6、公司信息管理员,具有对公司信息CRUD的权限;
+     * 7、财务管理员,具有对加油记录CRUD的权限。
+     */
+    @Column
+    private int type;
+
+
+    public Admin() {
+    }
+
+    public Admin(String adminName, byte[] password) {
+        this.adminName = adminName;
+        this.password = password;
+    }
+
+    public Admin(String adminName,byte[] password, int type) {
+        this.password = password;
+        this.type = type;
+        this.adminName = adminName;
+    }
+
+    public byte[] getSalt() {
+        return salt;
+    }
+
+    public void setSalt(byte[] salt) {
+        this.salt = salt;
+    }
+
+    public String getAdminName() {
+        return adminName;
+    }
+
+    public void setAdminName(String adminName) {
+        this.adminName = adminName;
+    }
+
+    public byte[] getPassword() {
+        return password;
+    }
+
+    public void setPassword(byte[] password) {
+        this.password = password;
+    }
+
+    public int getType() {
+        return type;
+    }
+
+    public void setType(int type) {
+        this.type = type;
+    }
+}

+ 86 - 0
src/main/java/com/logistics/entity/BasicEntity.java

@@ -0,0 +1,86 @@
+package com.logistics.entity;
+
+import javax.persistence.*;
+
+/**
+ * Created by Mklaus on 15/7/24.
+ */
+@MappedSuperclass
+public class BasicEntity implements java.io.Serializable {
+    @Id
+    @Column(name = "ID")
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    public int id;
+
+    @Column(name = "IsDeleted")
+    public boolean isDeleted;
+
+    /**
+     * The number of milliseconds since the standard base time known as "the epoch", namely January 1, 1970, 00:00:00 GMT.
+     */
+    @Column(name = "created_time")
+    public long created_time;
+
+    /**
+     * The number of milliseconds since the standard base time known as "the epoch", namely January 1, 1970, 00:00:00 GMT.
+     */
+    @Column(name = "modify_time")
+    public long modify_time;
+
+    public int getId() {
+        return id;
+    }
+
+    public void setId(int id) {
+        this.id = id;
+    }
+
+    public boolean isDeleted() {
+        return isDeleted;
+    }
+
+    public void setIsDeleted(boolean isDeleted) {
+        this.isDeleted = isDeleted;
+    }
+
+    public long getCreated_time() {
+        return created_time;
+    }
+
+    public void setCreated_time(long created_time) {
+        this.created_time = created_time;
+    }
+
+    public long getModify_time() {
+        return modify_time;
+    }
+
+    public void setModify_time(long modify_time) {
+        this.modify_time = modify_time;
+    }
+
+    @Override
+    public int hashCode() {
+        int hash = 17;
+
+        Integer ID = this.id;
+
+        hash = hash * 31 + ID.hashCode();
+
+        return (hash);
+    }
+
+    /**
+     * 该方法仅仅进行了最基本的辨别,如果需要精确地确定比较的对象是否相等,需要在子类中重写这个方法!
+     */
+    @Override
+    public boolean equals(Object o) {
+        if (this == o)
+            return true;
+
+        if (o == null || !this.getClass().equals(o.getClass()))
+            return false;
+
+        return this.id != ((BasicEntity) o).getId();
+    }
+}

+ 76 - 0
src/main/java/com/logistics/entity/CarBusiness.java

@@ -0,0 +1,76 @@
+package com.logistics.entity;
+
+import javax.persistence.*;
+
+/**
+ * Created by Ranger on 2015/8/10.
+ * <p/>
+ * 车辆,驾驶员运营信息表
+ */
+@Entity
+@Table(name = "carBusiness")
+public class CarBusiness extends BasicEntity {
+    /**
+     * 开始日期
+     */
+    @Column(name = "DateOfStarting")
+    private long dateOfStarting;
+
+    /**
+     * 结束日期
+     */
+    @Column(name = "DateOfFinishing")
+    private long dateOfFinishing;
+
+    /**
+     * 一个单车运营记录对应一辆车,一个司机,一个运输任务
+     */
+    @ManyToOne
+    @JoinColumn(name = "vehicle")
+    private Vehicle vehicle;
+
+    @ManyToOne
+    @JoinColumn(name = "taskId")
+    private TransportTask task;
+
+    public CarBusiness() {
+
+    }
+
+    public CarBusiness(Vehicle vehicle, TransportTask task) {
+        this.vehicle = vehicle;
+        this.task = task;
+    }
+
+    public Vehicle getVehicle() {
+        return vehicle;
+    }
+
+    public void setVehicle(Vehicle vehicle) {
+        this.vehicle = vehicle;
+    }
+
+    public TransportTask getTask() {
+        return task;
+    }
+
+    public void setTask(TransportTask task) {
+        this.task = task;
+    }
+
+    public long getDateOfFinishing() {
+        return dateOfFinishing;
+    }
+
+    public void setDateOfFinishing(long dateOfFinishing) {
+        this.dateOfFinishing = dateOfFinishing;
+    }
+
+    public long getDateOfStarting() {
+        return dateOfStarting;
+    }
+
+    public void setDateOfStarting(long dateOfStarting) {
+        this.dateOfStarting = dateOfStarting;
+    }
+}

+ 95 - 0
src/main/java/com/logistics/entity/Cargo.java

@@ -0,0 +1,95 @@
+package com.logistics.entity;
+
+import javax.persistence.*;
+
+/**
+ * Created by Mklaus on 15/8/13.
+ */
+@Entity
+@Table(name = "cargo")
+public class Cargo extends BasicEntity {
+    @Column(nullable = false)
+    private String name;
+
+    /**
+     * 重量 (吨)
+     */
+    @Column(nullable = false)
+    private int weight;
+
+    /**
+     * 单价 (分)
+     */
+    @Column
+    private int price;
+
+    @Column
+    private int count;
+
+    @ManyToOne
+    @JoinColumn(name = "taskId")
+    private TransportTask task;
+
+    public Cargo() {
+    }
+
+    public Cargo(int price, String name, int weight) {
+        this.price = price;
+        this.name = name;
+        this.weight = weight;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public int getWeight() {
+        return weight;
+    }
+
+    public void setWeight(int weight) {
+        this.weight = weight;
+    }
+
+    public int getPrice() {
+        return price;
+    }
+
+    public void setPrice(int price) {
+        this.price = price;
+    }
+
+    public int getCount() {
+        return count;
+    }
+
+    public void setCount(int count) {
+        this.count = count;
+    }
+
+    public TransportTask getTask() {
+        return task;
+    }
+
+    public void setTask(TransportTask task) {
+        this.task = task;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (!super.equals(o)) {
+            return false;
+        } else {
+            Cargo castObj = (Cargo) o;
+            if (!castObj.getName().equals(this.getName()))
+                return false;
+            if (!(castObj.getTask().getId() == task.getId()))
+                return false;
+        }
+        return true;
+    }
+}

+ 56 - 0
src/main/java/com/logistics/entity/CarrierBusiness.java

@@ -0,0 +1,56 @@
+package com.logistics.entity;
+
+import javax.persistence.*;
+
+/**
+ * Created by Ranger on 2015/8/10.
+ * <p/>
+ * <p>承运商承运信息表</p>
+ */
+@Entity
+@Table(name = "carrierBusiness")
+public class CarrierBusiness extends BasicEntity {
+
+    @OneToOne
+    @JoinColumn(name = "taskId")
+    private TransportTask task;
+
+    @OneToOne
+    @JoinColumn(name = "companyId")
+    private Company company;
+
+    @Column
+    private boolean isPayed;
+
+    public CarrierBusiness() {
+
+    }
+
+    public CarrierBusiness(TransportTask task) {
+        this.task = task;
+    }
+
+    public TransportTask getTask() {
+        return task;
+    }
+
+    public void setTask(TransportTask task) {
+        this.task = task;
+    }
+
+    public boolean getIsPayed() {
+        return isPayed;
+    }
+
+    public void setIsPayed(boolean isPayed) {
+        this.isPayed = isPayed;
+    }
+
+    public Company getCompany() {
+        return company;
+    }
+
+    public void setCompany(Company company) {
+        this.company = company;
+    }
+}

+ 74 - 0
src/main/java/com/logistics/entity/Company.java

@@ -0,0 +1,74 @@
+package com.logistics.entity;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Table;
+
+/**
+ * Created by Ranger on 2015/8/10.
+ * <p/>
+ * 公司基本信息
+ */
+@Entity
+@Table(name = "company")
+public class Company extends BasicEntity {
+    /**
+     * 公司单位名称
+     */
+    @Column
+    private String companyName;
+
+    /**
+     * 联系方式,就是电话号码
+     */
+    @Column
+    private String phoneNumber;
+
+    /**
+     * 法人代表姓名
+     */
+    @Column
+    private String corporation;
+
+    /**
+     * 公司简介
+     */
+    @Column
+    private String introduction;
+
+    public Company() {
+    }
+
+    public String getCompanyName() {
+        return companyName;
+    }
+
+    public void setCompanyName(String companyName) {
+        this.companyName = companyName;
+    }
+
+    public String getPhoneNumber() {
+        return phoneNumber;
+    }
+
+    public void setPhoneNumber(String phoneNumber) {
+        this.phoneNumber = phoneNumber;
+    }
+
+    public String getCorporation() {
+        return corporation;
+    }
+
+    public void setCorporation(String corporation) {
+        this.corporation = corporation;
+    }
+
+    public String getIntroduction() {
+        return introduction;
+    }
+
+    public void setIntroduction(String introduction) {
+        this.introduction = introduction;
+    }
+
+}

+ 106 - 0
src/main/java/com/logistics/entity/Goods.java

@@ -0,0 +1,106 @@
+package com.logistics.entity;
+
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Table;
+
+/**
+ * Created by Mklaus on 15/7/24.
+ * <p/>
+ * 物资基本信息
+ */
+@Entity
+@Table(name = "goods")
+public class Goods extends BasicEntity {
+//    @ManyToOne
+//    private GoodsRecord goodsRecord;
+
+    @Column(name = "type")
+    private String type;
+
+    @Column
+    private String goodsName;
+
+    @Column
+    private String description;
+
+    /**
+     * 以分为单位
+     */
+    @Column
+    private int price;
+
+    /**
+     * 剩余数量
+     */
+    @Column
+    private int count;
+
+    @Column
+    private String weight;
+
+    private int sumPrice;
+
+    public Goods() {
+    }
+
+    public Goods(String goodsName, String type) {
+        this.goodsName = goodsName;
+        this.type = type;
+    }
+
+    public String getType() {
+        return type;
+    }
+
+    public void setType(String type) {
+        this.type = type;
+    }
+
+    public String getGoodsName() {
+        return goodsName;
+    }
+
+    public void setGoodsName(String goodsName) {
+        this.goodsName = goodsName;
+    }
+
+
+    public String getWeight() {
+        return weight;
+    }
+
+    public void setWeight(String weight) {
+        this.weight = weight;
+    }
+
+    public String getDescription() {
+        return description;
+    }
+
+    public void setDescription(String description) {
+        this.description = description;
+    }
+
+    public int getPrice() {
+        return price;
+    }
+
+    public void setPrice(int price) {
+        this.price = price;
+    }
+
+    public int getCount() {
+        return count;
+    }
+
+    public void setCount(int count) {
+        this.count = count;
+    }
+
+    public int getSumPrice() {
+        return this.price * this.count;
+    }
+
+}

+ 51 - 0
src/main/java/com/logistics/entity/GoodsGroup.java

@@ -0,0 +1,51 @@
+package com.logistics.entity;
+
+import javax.persistence.*;
+
+/**
+ * Created by Mklaus on 15/8/20.
+ */
+@Entity
+@Table(name = "goodsGroup")
+public class GoodsGroup extends BasicEntity{
+    @OneToOne(fetch = FetchType.EAGER)
+    private Goods goods;
+
+    @ManyToOne
+    private GoodsRecord goodsRecord;
+
+    @Column
+    private int count;
+
+    public GoodsGroup() {
+    }
+
+    public GoodsGroup(Goods goods, int count) {
+        this.goods = goods;
+        this.count = count;
+    }
+
+    public Goods getGoods() {
+        return goods;
+    }
+
+    public void setGoods(Goods goods) {
+        this.goods = goods;
+    }
+
+    public int getCount() {
+        return count;
+    }
+
+    public void setCount(int count) {
+        this.count = count;
+    }
+
+    public GoodsRecord getGoodsRecord() {
+        return goodsRecord;
+    }
+
+    public void setGoodsRecord(GoodsRecord goodsRecord) {
+        this.goodsRecord = goodsRecord;
+    }
+}

+ 82 - 0
src/main/java/com/logistics/entity/GoodsRecord.java

@@ -0,0 +1,82 @@
+package com.logistics.entity;
+
+import javax.persistence.*;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * Created by Mklaus on 15/8/13.
+ * <p/>
+ * 物资信息记录
+ */
+@Entity
+@Table(name = "goodsRecord")
+public class GoodsRecord extends BasicEntity {
+    @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER, mappedBy = "goodsRecord")
+    private Set<GoodsGroup> goodsGroupSet = new HashSet<GoodsGroup>(8);
+
+    /**
+     * 0=使用,1=添加购买
+     */
+    @Column
+    private int type;
+
+    /**
+     * 相关负责人
+     */
+    @OneToOne
+    @JoinColumn(name = "charger")
+    private Staff charger;
+
+    /**
+     * 用途
+     */
+    @Column
+    private String purpose;
+
+    @Column
+    private int sumPrice;
+
+    public GoodsRecord() {
+    }
+
+    public int getType() {
+        return type;
+    }
+
+    public void setType(int type) {
+        this.type = type;
+    }
+
+    public Staff getCharger() {
+        return charger;
+    }
+
+    public void setCharger(Staff charger) {
+        this.charger = charger;
+    }
+
+    public String getPurpose() {
+        return purpose;
+    }
+
+    public void setPurpose(String purpose) {
+        this.purpose = purpose;
+    }
+
+    public int getSumPrice() {
+        return sumPrice;
+    }
+
+    public void setSumPrice(int sumPrice) {
+        this.sumPrice = sumPrice;
+    }
+
+    public Set<GoodsGroup> getGoodsGroupSet() {
+        return goodsGroupSet;
+    }
+
+    public void setGoodsGroupSet(Set<GoodsGroup> goodsGroupSet) {
+        this.goodsGroupSet = goodsGroupSet;
+    }
+}

+ 69 - 0
src/main/java/com/logistics/entity/OilBuy.java

@@ -0,0 +1,69 @@
+package com.logistics.entity;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.ManyToOne;
+import javax.persistence.Table;
+
+/**
+ * Created by Mklaus on 15/8/21.
+ */
+@Entity
+@Table(name = "oilBuy")
+public class OilBuy extends BasicEntity {
+    @ManyToOne
+    private Vehicle vehicle;
+
+    @ManyToOne
+    private Staff staff;
+
+    @Column
+    private double litre;
+
+    @Column
+    private double price;
+
+    public OilBuy() {
+    }
+
+    public OilBuy(Vehicle vehicle, Staff staff) {
+        this.vehicle = vehicle;
+        this.staff = staff;
+    }
+
+    public Vehicle getVehicle() {
+        return vehicle;
+    }
+
+    public void setVehicle(Vehicle vehicle) {
+        this.vehicle = vehicle;
+    }
+
+    public Staff getStaff() {
+        return staff;
+    }
+
+    public void setStaff(Staff staff) {
+        this.staff = staff;
+    }
+
+    public double getLitre() {
+        return litre;
+    }
+
+    public void setLitre(double litre) {
+        this.litre = litre;
+    }
+
+    public double getPrice() {
+        return price;
+    }
+
+    public void setPrice(double price) {
+        this.price = price;
+    }
+
+    public double getSumPrice() {
+        return (this.price * this.litre);
+    }
+}

+ 106 - 0
src/main/java/com/logistics/entity/Report.java

@@ -0,0 +1,106 @@
+package com.logistics.entity;
+
+/**
+ * Created by Mklaus on 15/8/21.
+ */
+public class Report extends BasicEntity{
+    /**
+     * 总支出
+     */
+    private int output;
+
+    /**
+     * 总收入
+     */
+
+    private int input;
+
+    /**
+     * 总利润
+     */
+    private int profit;
+
+
+    /**
+     * 公司运营任务收入
+     */
+    private int inputOfTask;
+
+    /**
+     * 公司外包承运收入
+     */
+    private int inputOfCarry;
+
+    /**
+     * 物资购买支出
+     */
+
+    private int outputOfGoodsBuy;
+
+    /**
+     * 员工工资
+     */
+
+    private int outputOfSalary;
+
+    /**
+     * 燃油支出
+     */
+
+    private int outputOfOil;
+
+    public Report() {
+    }
+
+    public int getOutput() {
+        return this.outputOfGoodsBuy + this.outputOfOil + this.outputOfSalary;
+    }
+
+    public int getInput() {
+        return this.inputOfTask + this.inputOfCarry;
+    }
+
+    public int getProfit() {
+        return this.getInput() - this.getOutput();
+    }
+
+    public int getInputOfTask() {
+        return inputOfTask;
+    }
+
+    public void setInputOfTask(int inputOfTask) {
+        this.inputOfTask = inputOfTask;
+    }
+
+    public int getInputOfCarry() {
+        return inputOfCarry;
+    }
+
+    public void setInputOfCarry(int inputOfCarry) {
+        this.inputOfCarry = inputOfCarry;
+    }
+
+    public int getOutputOfGoodsBuy() {
+        return outputOfGoodsBuy;
+    }
+
+    public void setOutputOfGoodsBuy(int outputOfGoodsBuy) {
+        this.outputOfGoodsBuy = outputOfGoodsBuy;
+    }
+
+    public int getOutputOfSalary() {
+        return outputOfSalary;
+    }
+
+    public void setOutputOfSalary(int outputOfSalary) {
+        this.outputOfSalary = outputOfSalary;
+    }
+
+    public int getOutputOfOil() {
+        return outputOfOil;
+    }
+
+    public void setOutputOfOil(int outputOfOil) {
+        this.outputOfOil = outputOfOil;
+    }
+}

+ 177 - 0
src/main/java/com/logistics/entity/Staff.java

@@ -0,0 +1,177 @@
+package com.logistics.entity;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Table;
+
+/**
+ * Created by Ranger on 2015/8/10.
+ * <p/>
+ * 公司内部的人员信息
+ */
+@Entity
+@Table(name = "staff")
+public class Staff extends BasicEntity {
+    /**
+     * 真实姓名,全名,不为空
+     */
+    @Column(nullable = false)
+    private String realName;
+
+    /**
+     * 联系方式,其实就是电话号码
+     */
+    @Column
+    private String phoneNumber;
+
+    /**
+     * 性别,取值限制为“男”或“女”
+     */
+    @Column
+    private String gender;
+
+    /**
+     * 身份证号码,可以唯一标识人员记录,字段值不为空
+     */
+    @Column(nullable = false)
+    private String idCardNumber;
+
+
+    /**
+     * 文化程度,取值限制为:“小学以下”、“小学”、“初中”、“高中”、“专科”、
+     * “技工学校”、“中技”、“中专”、“大专”、“本科”、“硕士”、“博士”
+     */
+    @Column
+    private String levelOfEducation;
+
+    /**
+     * 政治面貌,取值限制为:“中共党员”、“中共预备党员”、“共青团员”、“民革党员”、
+     * “民盟盟员”、“民建会员”、“民进会员”、“农工党党员”、“致公党党员”、
+     * “九三学社社员”、“台盟盟员”、“无党派人士”、“群众”
+     */
+    @Column
+    private String politicalGroup;
+
+    /**
+     * 职位,目前确定的职位有司机,运输管理人员,财务人员
+     */
+    @Column
+    private String job;
+
+    /**
+     * 参加工作时间
+     */
+    @Column
+    private Long dateOfHire;
+
+    /**
+     * 用工性质,取值限制为:“正式工”、“临时工”
+     */
+    @Column
+    private String typeOfEmployment;
+
+    /**
+     * 职工状态,取值限制为:“休假”、“离退”、“业务中”、“等待业务”
+     */
+    @Column
+    private String state;
+
+
+    /**
+     * 职工的月工资,单位为元
+     */
+    @Column
+    private int salary;
+
+    public Staff() {
+
+    }
+
+    public String getRealName() {
+        return realName;
+    }
+
+    public void setRealName(String realName) {
+        this.realName = realName;
+    }
+
+    public String getPhoneNumber() {
+        return phoneNumber;
+    }
+
+    public void setPhoneNumber(String phoneNumber) {
+        this.phoneNumber = phoneNumber;
+    }
+
+    public String getGender() {
+        return gender;
+    }
+
+    public void setGender(String gender) {
+        this.gender = gender;
+    }
+
+    public String getIdCardNumber() {
+        return idCardNumber;
+    }
+
+    public void setIdCardNumber(String idCardNumber) {
+        this.idCardNumber = idCardNumber;
+    }
+
+    public String getLevelOfEducation() {
+        return levelOfEducation;
+    }
+
+    public void setLevelOfEducation(String levelOfEducation) {
+        this.levelOfEducation = levelOfEducation;
+    }
+
+    public String getPoliticalGroup() {
+        return politicalGroup;
+    }
+
+    public void setPoliticalGroup(String politicalGroup) {
+        this.politicalGroup = politicalGroup;
+    }
+
+    public String getJob() {
+        return job;
+    }
+
+    public void setJob(String job) {
+        this.job = job;
+    }
+
+    public String getTypeOfEmployment() {
+        return typeOfEmployment;
+    }
+
+    public void setTypeOfEmployment(String typeOfEmployment) {
+        this.typeOfEmployment = typeOfEmployment;
+    }
+
+    public String getState() {
+        return state;
+    }
+
+    public void setState(String state) {
+        this.state = state;
+    }
+
+    public int getSalary() {
+        return salary;
+    }
+
+    public void setSalary(int salary) {
+        this.salary = salary;
+    }
+
+    public Long getDateOfHire() {
+        return dateOfHire;
+    }
+
+    public void setDateOfHire(Long dateOfHire) {
+        this.dateOfHire = dateOfHire;
+    }
+}

+ 203 - 0
src/main/java/com/logistics/entity/TransportTask.java

@@ -0,0 +1,203 @@
+package com.logistics.entity;
+
+import javax.persistence.*;
+import java.util.Set;
+
+/**
+ * Created by Mklaus on 15/8/13.
+ */
+@Entity
+@Table(name = "transportTask")
+public class TransportTask extends BasicEntity {
+    @Column
+    private String title;
+
+    /**
+     * 起运地,字段值不能为空
+     */
+    @Column(nullable = false)
+    private String startPlace;
+
+    /**
+     * 止运地,字段不能为空
+     */
+    @Column(nullable = false)
+    private String endPlace;
+
+    @Column
+    private long startDate;
+
+    @Column
+    private long endDate;
+
+    /**
+     * 自营 0 ,别人承运 1
+     */
+    @Column
+    private int type;
+
+    /**
+     * 当type = 1时,该字段有效,否则弃用
+     */
+    @Column
+    private double rate;
+
+    /**
+     * 申请 0, 进行 1,完成 2
+     */
+    @Column
+    private int state;
+
+    /**
+     * 总价格
+     */
+    @Column
+    private int sumPrice;
+
+    /**
+     * 给顾客查询订单的ID号
+     */
+    @Column(nullable = false)
+    private String queryId;
+
+    /**
+     * 委托人
+     */
+    @OneToOne
+    @JoinColumn(name = "customer")
+    private User customer;
+
+    /**
+     * 单车组
+     */
+    @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER, mappedBy = "task")
+    private Set<CarBusiness> carBusinesses;
+
+    /**
+     * 货物组
+     */
+    @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER, mappedBy = "task")
+    private Set<Cargo> cargoSet;
+
+    public TransportTask() {
+        this.state = 0;
+    }
+
+    public TransportTask(String title, String startPlace, String endPlace, long startDate, long endDate,
+                         int type, double rate, User customer, int sumPrice) {
+        this();
+        this.title = title;
+        this.startPlace = startPlace;
+        this.endPlace = endPlace;
+        this.startDate = startDate;
+        this.endDate = endDate;
+        this.type = type;
+        this.rate = rate;
+        this.customer = customer;
+        this.sumPrice = sumPrice;
+    }
+
+    public String getTitle() {
+        return title;
+    }
+
+    public void setTitle(String title) {
+        this.title = title;
+    }
+
+    public String getStartPlace() {
+        return startPlace;
+    }
+
+    public void setStartPlace(String startPlace) {
+        this.startPlace = startPlace;
+    }
+
+    public String getEndPlace() {
+        return endPlace;
+    }
+
+    public void setEndPlace(String endPlace) {
+        this.endPlace = endPlace;
+    }
+
+    public long getStartDate() {
+        return startDate;
+    }
+
+    public void setStartDate(long startDate) {
+        this.startDate = startDate;
+    }
+
+    public long getEndDate() {
+        return endDate;
+    }
+
+    public void setEndDate(long endDate) {
+        this.endDate = endDate;
+    }
+
+    public int getType() {
+        return type;
+    }
+
+    public void setType(int type) {
+        this.type = type;
+    }
+
+    public double getRate() {
+        return rate;
+    }
+
+    public void setRate(double rate) {
+        this.rate = rate;
+    }
+
+    public int getState() {
+        return state;
+    }
+
+    public void setState(int state) {
+        this.state = state;
+    }
+
+    public User getCustomer() {
+        return customer;
+    }
+
+    public void setCustomer(User customer) {
+        this.customer = customer;
+    }
+
+    public int getSumPrice() {
+        return sumPrice;
+    }
+
+    public void setSumPrice(int sumPrice) {
+        this.sumPrice = sumPrice;
+    }
+
+    public Set<Cargo> getCargoSet() {
+        return cargoSet;
+    }
+
+    public void setCargoSet(Set<Cargo> cargoSet) {
+        this.cargoSet = cargoSet;
+    }
+
+    public Set<CarBusiness> getCarBusinesses() {
+        return carBusinesses;
+    }
+
+    public void setCarBusinesses(Set<CarBusiness> carBusinesses) {
+        this.carBusinesses = carBusinesses;
+    }
+
+    public String getQueryId() {
+        return queryId;
+    }
+
+    public void setQueryId(String queryId) {
+        this.queryId = queryId;
+    }
+}

+ 95 - 0
src/main/java/com/logistics/entity/User.java

@@ -0,0 +1,95 @@
+package com.logistics.entity;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Table;
+
+/**
+ * Created by Mklaus on 15/8/13.
+ * <p/>
+ * 客户信息表
+ */
+@Entity
+@Table(name = "user")
+public class User extends BasicEntity {
+    @Column
+    private String name;
+
+    /**
+     * 用户的电话,可以用于注册帐号
+     */
+    @Column
+    private String phone;
+
+    /**
+     * 用户的住址
+     */
+    @Column
+    private String address;
+
+    /**
+     * 用户的Email,可以用于注册帐号
+     */
+    @Column
+    private String email;
+
+    /**
+     * 用户的密码,不能为空
+     */
+    @Column(nullable = false)
+    private String password;
+
+    public User() {
+    }
+
+    /**
+     * 登录以 email 为帐号
+     *
+     * @param email email
+     * @param password 密码
+     */
+    public User(String email, String password) {
+        this.email = email;
+        this.password = password;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getPhone() {
+        return phone;
+    }
+
+    public void setPhone(String phone) {
+        this.phone = phone;
+    }
+
+    public String getAddress() {
+        return address;
+    }
+
+    public void setAddress(String address) {
+        this.address = address;
+    }
+
+    public String getEmail() {
+        return email;
+    }
+
+    public void setEmail(String email) {
+        this.email = email;
+    }
+
+    public String getPassword() {
+        return password;
+    }
+
+    public void setPassword(String password) {
+        this.password = password;
+    }
+}

+ 93 - 0
src/main/java/com/logistics/entity/Vehicle.java

@@ -0,0 +1,93 @@
+package com.logistics.entity;
+
+import javax.persistence.*;
+import java.util.Set;
+
+/**
+ * Created by Ranger on 2015/8/10.
+ * <p/>
+ * 汽车详情表
+ */
+@Entity
+@Table(name = "vehicle")
+public class Vehicle extends BasicEntity {
+    /**
+     * 车牌号
+     */
+    @Column
+    private String carNumber;
+    /**
+     * 发动机编号,可以唯一确定车辆,插入时该字段不能为空
+     */
+    @Column(nullable = false)
+    private String identity;
+
+    /**
+     * 车身颜色
+     */
+    @Column
+    private String color;
+
+    @ManyToOne(fetch = FetchType.EAGER)
+    @JoinColumn(name = "vehicleType")
+    private VehicleType vehicleType;
+
+    @OneToOne
+    @JoinColumn(name = "driver")
+    private Staff driver;
+
+    @OneToMany(mappedBy = "vehicle",fetch = FetchType.EAGER)
+    private Set<CarBusiness> carBusinessRecords;
+
+    public Vehicle() {
+
+    }
+
+    public String getCarNumber() {
+        return carNumber;
+    }
+
+    public void setCarNumber(String carNumber) {
+        this.carNumber = carNumber;
+    }
+
+    public String getIdentity() {
+        return identity;
+    }
+
+    public void setIdentity(String identity) {
+        this.identity = identity;
+    }
+
+    public VehicleType getVehicleType() {
+        return vehicleType;
+    }
+
+    public void setVehicleType(VehicleType vehicleType) {
+        this.vehicleType = vehicleType;
+    }
+
+    public String getColor() {
+        return color;
+    }
+
+    public void setColor(String color) {
+        this.color = color;
+    }
+
+    public Staff getDriver() {
+        return driver;
+    }
+
+    public void setDriver(Staff driver) {
+        this.driver = driver;
+    }
+
+    public Set<CarBusiness> getCarBusinessRecords() {
+        return carBusinessRecords;
+    }
+
+    public void setCarBusinessRecords(Set<CarBusiness> carBusinessRecords) {
+        this.carBusinessRecords = carBusinessRecords;
+    }
+}

+ 66 - 0
src/main/java/com/logistics/entity/VehicleRepair.java

@@ -0,0 +1,66 @@
+package com.logistics.entity;
+
+import javax.persistence.*;
+
+/**
+ * Created by Mklaus on 15/8/13.
+ */
+@Entity
+@Table(name = "repair")
+public class VehicleRepair extends BasicEntity {
+
+    @OneToOne
+    @JoinColumn(name = "vehicle_id")
+    private Vehicle vehicle;
+
+    @OneToOne
+    @JoinColumn(name = "goodsRecord_id")
+    private GoodsRecord goodsRecord;
+
+    @Column
+    private String reasonDesc;
+
+    @OneToOne
+    @JoinColumn(name = "repairman")
+    private Staff repairman;
+
+    public VehicleRepair() {
+    }
+
+    public VehicleRepair(Vehicle vehicle, Staff repairman) {
+        this.vehicle = vehicle;
+        this.repairman = repairman;
+    }
+
+    public Vehicle getVehicle() {
+        return vehicle;
+    }
+
+    public void setVehicle(Vehicle vehicle) {
+        this.vehicle = vehicle;
+    }
+
+    public GoodsRecord getGoodsRecord() {
+        return goodsRecord;
+    }
+
+    public void setGoodsRecord(GoodsRecord goodsRecord) {
+        this.goodsRecord = goodsRecord;
+    }
+
+    public String getReasonDesc() {
+        return reasonDesc;
+    }
+
+    public void setReasonDesc(String reasonDesc) {
+        this.reasonDesc = reasonDesc;
+    }
+
+    public Staff getRepairman() {
+        return repairman;
+    }
+
+    public void setRepairman(Staff repairman) {
+        this.repairman = repairman;
+    }
+}

+ 123 - 0
src/main/java/com/logistics/entity/VehicleType.java

@@ -0,0 +1,123 @@
+package com.logistics.entity;
+
+import javax.persistence.*;
+import java.util.Set;
+
+/**
+ * Created by Mklaus on 15/8/13.
+ */
+@Entity
+@Table(name = "VehicleType")
+public class VehicleType extends BasicEntity {
+    /**
+     * 描述
+     */
+    @Column(nullable = false)
+    private String description;
+
+    /**
+     * 装载量 以吨为单位
+     */
+    @Column
+    private int capacity;
+
+    /**
+     * 耗油量,公里/升 为单位
+     */
+    @Column
+    private int oilType;
+
+    /**
+     * 车长 厘米单位,下同
+     */
+    @Column
+    private int length;
+
+    /**
+     * 宽
+     */
+    @Column
+    private int width;
+
+    /**
+     * 高
+     */
+    @Column
+    private int height;
+
+    /**
+     * 座位个数
+     */
+    @Column
+    private int seat;
+
+    @OneToMany(mappedBy = "vehicleType",fetch = FetchType.EAGER)
+    private Set<Vehicle> vehicles;
+
+    public VehicleType() {
+    }
+
+    public String getDescription() {
+        return description;
+    }
+
+    public void setDescription(String description) {
+        this.description = description;
+    }
+
+    public int getCapacity() {
+        return capacity;
+    }
+
+    public void setCapacity(int capacity) {
+        this.capacity = capacity;
+    }
+
+    public int getOilType() {
+        return oilType;
+    }
+
+    public void setOilType(int oilType) {
+        this.oilType = oilType;
+    }
+
+    public int getLength() {
+        return length;
+    }
+
+    public void setLength(int length) {
+        this.length = length;
+    }
+
+    public int getWidth() {
+        return width;
+    }
+
+    public void setWidth(int width) {
+        this.width = width;
+    }
+
+    public int getHeight() {
+        return height;
+    }
+
+    public void setHeight(int height) {
+        this.height = height;
+    }
+
+    public int getSeat() {
+        return seat;
+    }
+
+    public void setSeat(int seat) {
+        this.seat = seat;
+    }
+
+    public Set<Vehicle> getVehicles() {
+        return vehicles;
+    }
+
+    public void setVehicles(Set<Vehicle> vehicles) {
+        this.vehicles = vehicles;
+    }
+}

+ 16 - 0
src/main/java/com/logistics/service/AddressService.java

@@ -0,0 +1,16 @@
+package com.logistics.service;
+
+import com.logistics.entity.Address;
+import com.logistics.entity.Admin;
+
+import java.util.List;
+
+/**
+ * Created by Mklaus on 15/8/24.
+ */
+public interface AddressService extends BaseService<Address>{
+    public Integer add(Address address,Integer parent);
+
+    public List<Address> getByLevel(Integer level);
+
+}

+ 20 - 0
src/main/java/com/logistics/service/AdminService.java

@@ -0,0 +1,20 @@
+package com.logistics.service;
+
+import com.logistics.entity.Admin;
+
+import java.io.IOException;
+
+/**
+ * Created by Mklaus on 15/7/23.
+ */
+public interface AdminService extends BaseService<Admin>{
+    public Admin login(Admin admin);
+
+    public Admin register(Admin admin);
+
+    public boolean isExists(String adminName);
+
+    public int getIdByAdminName(String adminName);
+
+    public boolean passwd(Admin admin,String oldPass,String newPass) throws IOException;
+}

+ 31 - 0
src/main/java/com/logistics/service/BaseService.java

@@ -0,0 +1,31 @@
+package com.logistics.service;
+
+import com.logistics.dao.BaseDao;
+import org.hibernate.criterion.DetachedCriteria;
+
+import java.util.List;
+
+/**
+ * Created by Mklaus on 15/8/11.
+ */
+public interface BaseService<T> {
+    BaseDao getBaseDao();
+
+    Integer add(T t);
+
+    void delete(int id);
+
+    void delete(T t);
+
+    void update(T t);
+
+    T get(int id);
+
+    List<T> getAll();
+
+    List<T> get(DetachedCriteria dc);
+
+    List<T> get(Integer start,Integer size);
+
+    List<T> get(DetachedCriteria dc, Integer start, Integer size);
+}

+ 16 - 0
src/main/java/com/logistics/service/CarBusinessService.java

@@ -0,0 +1,16 @@
+package com.logistics.service;
+
+import com.logistics.entity.CarBusiness;
+
+import java.util.List;
+
+/**
+ * Created by Ranger on 2015/8/14.
+ */
+public interface CarBusinessService extends BaseService<CarBusiness> {
+    Integer add(Integer taskId, Integer vehicleId, CarBusiness carBusiness);
+
+    List<CarBusiness> getCarBusinessByTaskId(int taskId);
+
+    void update(Integer taskId, Integer vehicleId, CarBusiness carBusiness);
+}

+ 16 - 0
src/main/java/com/logistics/service/CargoService.java

@@ -0,0 +1,16 @@
+package com.logistics.service;
+
+import com.logistics.entity.Cargo;
+
+import java.util.List;
+
+/**
+ * Created by Ranger on 2015/8/14.
+ */
+public interface CargoService extends BaseService<Cargo> {
+    List<Cargo> getCargoByTaskId(int taskId);
+
+    Integer add(Cargo cargo, Integer taskId);
+
+    void update(Cargo cargo, Integer taskId);
+}

+ 16 - 0
src/main/java/com/logistics/service/CarrierBusinessService.java

@@ -0,0 +1,16 @@
+package com.logistics.service;
+
+import com.logistics.entity.CarrierBusiness;
+
+import java.util.List;
+
+/**
+ * Created by Ranger on 2015/8/14.
+ */
+public interface CarrierBusinessService extends BaseService<CarrierBusiness> {
+    Integer add(CarrierBusiness carrierBusiness, Integer transTaskId, Integer companyId);
+
+    boolean update(CarrierBusiness carrierBusiness, Integer transTaskId, Integer companyId);
+
+    List<CarrierBusiness> getCarrierBusinessByTaskId(int taskId);
+}

+ 9 - 0
src/main/java/com/logistics/service/CompanyService.java

@@ -0,0 +1,9 @@
+package com.logistics.service;
+
+import com.logistics.entity.Company;
+
+/**
+ * Created by Ranger on 2015/8/14.
+ */
+public interface CompanyService extends BaseService<Company> {
+}

+ 9 - 0
src/main/java/com/logistics/service/GoodsRecordService.java

@@ -0,0 +1,9 @@
+package com.logistics.service;
+
+import com.logistics.entity.GoodsRecord;
+
+/**
+ * Created by Ranger on 2015/8/14.
+ */
+public interface GoodsRecordService extends BaseService<GoodsRecord> {
+}

+ 11 - 0
src/main/java/com/logistics/service/GoodsService.java

@@ -0,0 +1,11 @@
+package com.logistics.service;
+
+
+import com.logistics.entity.Goods;
+
+/**
+ * Created by Mklaus on 15/7/24.
+ */
+public interface GoodsService extends BaseService<Goods>{
+
+}

+ 22 - 0
src/main/java/com/logistics/service/ImageService.java

@@ -0,0 +1,22 @@
+package com.logistics.service;
+
+import org.springframework.web.multipart.MultipartFile;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+/**
+ * Created by Mklaus on 15/8/27.
+ */
+public interface ImageService {
+    public void store(String name,InputStream is) throws IOException;
+
+    public void store(String name,InputStream is,Integer width,Integer height) throws IOException;
+
+    public InputStream load(String name) throws IOException;
+
+    public void upload(String parent,String name,MultipartFile file) throws IOException;
+
+    public void startPipe(InputStream is, OutputStream os, int bufferSize) throws IOException;
+}

+ 47 - 0
src/main/java/com/logistics/service/Impl/AddressServiceImpl.java

@@ -0,0 +1,47 @@
+package com.logistics.service.Impl;
+
+import com.logistics.dao.AddressDao;
+import com.logistics.dao.BaseDao;
+import com.logistics.entity.Address;
+import com.logistics.service.AddressService;
+import org.hibernate.criterion.DetachedCriteria;
+import org.hibernate.criterion.Restrictions;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+/**
+ * Created by Mklaus on 15/8/24.
+ */
+@Service
+public class AddressServiceImpl extends BaseServiceImpl<Address> implements AddressService {
+    @Resource
+    private AddressDao addressDao;
+
+    @Override
+    public BaseDao getBaseDao() {
+        return this.addressDao;
+    }
+
+    @Override
+    public Integer add(Address address, Integer parent) {
+        if (parent != null){
+            address.setParent(addressDao.get(parent));
+        }
+
+        return this.add(address);
+    }
+
+    @Override
+    public List<Address> getByLevel(Integer level) {
+        DetachedCriteria dc = DetachedCriteria.forClass(Address.class);
+
+        dc.add(Restrictions.eq("level",level));
+
+        List<Address> l = addressDao.search(dc);
+
+        return l;
+    }
+}
+

+ 137 - 0
src/main/java/com/logistics/service/Impl/AdminServiceImpl.java

@@ -0,0 +1,137 @@
+package com.logistics.service.Impl;
+
+import com.logistics.conf.Configurator;
+import com.logistics.crypto.CryptoBase;
+import com.logistics.crypto.RSACrypto;
+import com.logistics.crypto.RSAKeyCache;
+import com.logistics.dao.AdminDao;
+import com.logistics.dao.BaseDao;
+import com.logistics.entity.Admin;
+import com.logistics.service.AdminService;
+import org.hibernate.criterion.DetachedCriteria;
+import org.hibernate.criterion.Restrictions;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.security.PrivateKey;
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * Created by Mklaus on 15/7/23.
+ */
+@Service("adminServiceImpl")
+public class AdminServiceImpl extends BaseServiceImpl<Admin> implements AdminService{
+
+    @Autowired
+    private AdminDao adminDao;
+
+    @Override
+    public BaseDao getBaseDao() {
+        return adminDao;
+    }
+
+    @Override
+    public Admin login(Admin admin) {
+
+        int id = getIdByAdminName(admin.getAdminName());
+
+        PrivateKey key = RSAKeyCache.getInstance().get((long) id);
+        byte[] password = RSACrypto.getInstance().decrypt(admin.getPassword(),key);
+
+        admin.setPassword(password);
+
+        Admin login = null;
+        if ((login = verifyPassword(admin)) != null){
+            return login;
+        }
+        return null;
+    }
+
+    public Admin verifyPassword(Admin admin){
+        CryptoBase cb = CryptoBase.getInstance();
+
+        Admin login = null;
+        DetachedCriteria dc = DetachedCriteria.forClass(Admin.class);
+        dc.add(Restrictions.eq("adminName",admin.getAdminName()));
+        List<Admin> list = getBaseDao().search(dc);
+        if (list.size() > 0){
+            login = list.get(0);
+
+            byte[] salt = login.getSalt();
+            byte[] buf = ByteBuffer.allocate(admin.getPassword().length + salt.length).put(admin.getPassword()).put(salt).array();
+
+            System.out.println(new String(cb.MD5Digest(buf)));
+            System.out.println(new String(login.getPassword()));
+
+            if(Arrays.equals(cb.MD5Digest(buf),login.getPassword())){
+                return login;
+            }
+        }
+        return null;
+    }
+
+    @Override
+    public boolean passwd(Admin admin, String oldPass, String newPass) throws IOException{
+        admin.setPassword(oldPass.getBytes("UTF-8"));
+        if ((admin = this.verifyPassword(admin)) != null){
+            CryptoBase cb = CryptoBase.getInstance();
+            byte[] salt = cb.randomBytes(Configurator.getInstance().getInt("logistics.admin.saltlength", 4));
+            admin.setSalt(salt);
+            admin.setPassword(newPass.getBytes("UTF-8"));
+
+            byte[] buf = ByteBuffer.allocate(admin.getPassword().length + salt.length)
+                    .put(admin.getPassword())
+                    .put(salt)
+                    .array();
+            admin.setPassword(cb.MD5Digest(buf));
+
+            this.adminDao.update(admin);
+
+            return true;
+        }
+        return false;
+    }
+
+    @Override
+    public boolean isExists(String adminName) {
+        DetachedCriteria dc = DetachedCriteria.forClass(Admin.class);
+        dc.add(Restrictions.eq("adminName", adminName));
+        List<Admin> list = getBaseDao().search(dc);
+        if (list.size() > 0){
+            return true;
+        }
+        return false;
+    }
+
+    @Override
+    public int getIdByAdminName(String adminName) {
+        DetachedCriteria dc = DetachedCriteria.forClass(Admin.class);
+        dc.add(Restrictions.eq("adminName", adminName));
+        List<Admin> list = getBaseDao().search(dc);
+        if (list.size() > 0){
+            return list.get(0).getId();
+        }
+        return -1;
+    }
+
+    @Override
+    public Admin register(Admin admin) {
+        CryptoBase cb = CryptoBase.getInstance();
+
+        byte[] salt = cb.randomBytes(Configurator.getInstance().getInt("logistics.admin.saltlength", 4));
+        admin.setSalt(salt);
+
+        byte[] buf = ByteBuffer.allocate(admin.getPassword().length + salt.length)
+                .put(admin.getPassword())
+                .put(salt)
+                .array();
+        admin.setPassword(cb.MD5Digest(buf));
+
+        adminDao.save(admin);
+
+        return  admin;
+    }
+}

+ 60 - 0
src/main/java/com/logistics/service/Impl/BaseServiceImpl.java

@@ -0,0 +1,60 @@
+package com.logistics.service.Impl;
+
+import com.logistics.entity.BasicEntity;
+import com.logistics.service.BaseService;
+import org.hibernate.criterion.DetachedCriteria;
+
+import java.util.List;
+
+/**
+ * Created by Mklaus on 15/8/11.
+ */
+public abstract class BaseServiceImpl<T extends BasicEntity> implements BaseService<T> {
+    @Override
+    public Integer add(T t) {
+        return getBaseDao().save(t);
+    }
+
+    @Override
+    public void delete(int id) {
+        getBaseDao().delete(id);
+    }
+
+    @Override
+    public void delete(T t) {
+        getBaseDao().delete(t);
+    }
+
+    @Override
+    public void update(T t) {
+        BasicEntity temp = getBaseDao().get(t.id);
+        t.setIsDeleted(temp.isDeleted);
+        t.setCreated_time(temp.getCreated_time());
+        getBaseDao().update(t);
+    }
+
+    @Override
+    public T get(int id) {
+        return (T) getBaseDao().get(id);
+    }
+
+    @Override
+    public List<T> getAll() {
+        return getBaseDao().getAll();
+    }
+
+    @Override
+    public List<T> get(DetachedCriteria dc) {
+        return getBaseDao().search(dc);
+    }
+
+    @Override
+    public List<T> get(Integer start, Integer size) {
+        return getBaseDao().get(start,size);
+    }
+
+    @Override
+    public List<T> get(DetachedCriteria dc, Integer start, Integer size) {
+        return getBaseDao().search(dc, start, size);
+    }
+}

+ 61 - 0
src/main/java/com/logistics/service/Impl/CarBusinessServiceImpl.java

@@ -0,0 +1,61 @@
+package com.logistics.service.Impl;
+
+import com.logistics.dao.BaseDao;
+import com.logistics.dao.CarBusinessDao;
+import com.logistics.dao.TransportTaskDao;
+import com.logistics.dao.VehicleDao;
+import com.logistics.entity.CarBusiness;
+import com.logistics.service.CarBusinessService;
+import org.hibernate.criterion.DetachedCriteria;
+import org.hibernate.criterion.Restrictions;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * Created by Ranger on 2015/8/14.
+ */
+@Service("carBusinessServiceImpl")
+public class CarBusinessServiceImpl extends BaseServiceImpl<CarBusiness> implements CarBusinessService {
+    @Autowired
+    private CarBusinessDao carBusinessDao;
+    @Autowired
+    private TransportTaskDao transportTaskDao;
+    @Autowired
+    private VehicleDao vehicleDao;
+
+    @Override
+    public BaseDao getBaseDao() {
+        return carBusinessDao;
+    }
+
+    @Override
+    public List<CarBusiness> getCarBusinessByTaskId(int taskId) {
+        DetachedCriteria detachedCriteria = DetachedCriteria.forClass(CarBusiness.class);
+        detachedCriteria.add(Restrictions.eq("task", transportTaskDao.get(taskId)));
+        return carBusinessDao.search(detachedCriteria);
+    }
+
+    @Override
+    public Integer add(Integer taskId, Integer vehicleId, CarBusiness carBusiness) {
+        if (taskId != null) {
+            carBusiness.setTask(transportTaskDao.get(taskId));
+        }
+        if (vehicleId != null) {
+            carBusiness.setVehicle(vehicleDao.get(vehicleId));
+        }
+        return carBusinessDao.save(carBusiness);
+    }
+
+    @Override
+    public void update(Integer taskId, Integer vehicleId, CarBusiness carBusiness) {
+        if (vehicleId != null) {
+            carBusiness.setVehicle(vehicleDao.get(vehicleId));
+        }
+        if (taskId != null) {
+            carBusiness.setTask(transportTaskDao.get(taskId));
+        }
+        update(carBusiness);
+    }
+}

+ 55 - 0
src/main/java/com/logistics/service/Impl/CargoServiceImpl.java

@@ -0,0 +1,55 @@
+package com.logistics.service.Impl;
+
+import com.logistics.dao.BaseDao;
+import com.logistics.dao.CargoDao;
+import com.logistics.dao.TransportTaskDao;
+import com.logistics.entity.Cargo;
+import com.logistics.service.CargoService;
+import org.hibernate.criterion.DetachedCriteria;
+import org.hibernate.criterion.Restrictions;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * Created by Ranger on 2015/8/14.
+ */
+@Service
+public class CargoServiceImpl extends BaseServiceImpl<Cargo> implements CargoService {
+    @Autowired
+    private CargoDao cargoDao;
+    @Autowired
+    private TransportTaskDao transportTaskDao;
+
+    @Override
+    public BaseDao getBaseDao() {
+        return cargoDao;
+    }
+
+    @Override
+    public Integer add(Cargo cargo, Integer taskId) {
+        // 检测货物名称和货物重量
+        if (cargo.getWeight() <= 0) {
+            return null;
+        }
+        cargo.setTask(transportTaskDao.get(taskId));
+        return cargoDao.save(cargo);
+    }
+
+    @Override
+    public void update(Cargo cargo, Integer taskId) {
+        // 检测货物名称和货物重量
+        if (cargo.getWeight() > 0) {
+            cargo.setTask(transportTaskDao.get(taskId));
+            cargoDao.update(cargo);
+        }
+    }
+
+    @Override
+    public List<Cargo> getCargoByTaskId(int taskId) {
+        DetachedCriteria detachedCriteria = DetachedCriteria.forClass(Cargo.class);
+        detachedCriteria.add(Restrictions.eq("task", transportTaskDao.get(taskId)));
+        return cargoDao.search(detachedCriteria);
+    }
+}

+ 66 - 0
src/main/java/com/logistics/service/Impl/CarrierBusinessServiceImpl.java

@@ -0,0 +1,66 @@
+package com.logistics.service.Impl;
+
+import com.logistics.dao.BaseDao;
+import com.logistics.dao.CarrierBusinessDao;
+import com.logistics.dao.CompanyDao;
+import com.logistics.dao.TransportTaskDao;
+import com.logistics.entity.CarrierBusiness;
+import com.logistics.service.CarrierBusinessService;
+import org.hibernate.criterion.DetachedCriteria;
+import org.hibernate.criterion.Restrictions;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+/**
+ * Created by Ranger on 2015/8/14.
+ */
+@Service
+public class CarrierBusinessServiceImpl extends BaseServiceImpl<CarrierBusiness> implements CarrierBusinessService {
+    @Autowired
+    private CarrierBusinessDao carrierBusinessDao;
+    @Resource
+    private TransportTaskDao transportTaskDao;
+    @Resource
+    private CompanyDao companyDao;
+
+    @Override
+    public BaseDao getBaseDao() {
+        return carrierBusinessDao;
+    }
+
+    @Override
+    public Integer add(CarrierBusiness carrierBusiness, Integer transTaskId, Integer companyId) {
+        if (transTaskId != null) {
+            carrierBusiness.setTask(transportTaskDao.get(transTaskId));
+        }
+
+        if (companyId != null) {
+            carrierBusiness.setCompany(companyDao.get(companyId));
+        }
+
+        return this.add(carrierBusiness);
+    }
+
+    @Override
+    public boolean update(CarrierBusiness carrierBusiness, Integer transTaskId, Integer companyId) {
+        if (transTaskId != null) {
+            carrierBusiness.setTask(transportTaskDao.get(transTaskId));
+        }
+
+        if (companyId != null) {
+            carrierBusiness.setCompany(companyDao.get(companyId));
+        }
+        this.update(carrierBusiness);
+        return true;
+    }
+
+    @Override
+    public List<CarrierBusiness> getCarrierBusinessByTaskId(int taskId) {
+        DetachedCriteria detachedCriteria = DetachedCriteria.forClass(CarrierBusiness.class);
+        detachedCriteria.add(Restrictions.eq("task", transportTaskDao.get(taskId)));
+        return carrierBusinessDao.search(detachedCriteria);
+    }
+}

+ 22 - 0
src/main/java/com/logistics/service/Impl/CompanyServiceImpl.java

@@ -0,0 +1,22 @@
+package com.logistics.service.Impl;
+
+import com.logistics.dao.BaseDao;
+import com.logistics.dao.CompanyDao;
+import com.logistics.entity.Company;
+import com.logistics.service.CompanyService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Repository;
+
+/**
+ * Created by Ranger on 2015/8/14.
+ */
+@Repository
+public class CompanyServiceImpl extends BaseServiceImpl<Company> implements CompanyService {
+    @Autowired
+    private CompanyDao companyDao;
+
+    @Override
+    public BaseDao getBaseDao() {
+        return companyDao;
+    }
+}

+ 22 - 0
src/main/java/com/logistics/service/Impl/GoodsRecordServiceImpl.java

@@ -0,0 +1,22 @@
+package com.logistics.service.Impl;
+
+import com.logistics.dao.BaseDao;
+import com.logistics.dao.GoodsRecordDao;
+import com.logistics.entity.GoodsRecord;
+import com.logistics.service.GoodsRecordService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+/**
+ * Created by Ranger on 2015/8/14.
+ */
+@Service
+public class GoodsRecordServiceImpl extends BaseServiceImpl<GoodsRecord> implements GoodsRecordService {
+    @Autowired
+    private GoodsRecordDao goodsRecordDao;
+
+    @Override
+    public BaseDao getBaseDao() {
+        return goodsRecordDao;
+    }
+}

+ 22 - 0
src/main/java/com/logistics/service/Impl/GoodsServiceImpl.java

@@ -0,0 +1,22 @@
+package com.logistics.service.Impl;
+
+import com.logistics.dao.BaseDao;
+import com.logistics.dao.GoodsDao;
+import com.logistics.entity.Goods;
+import com.logistics.service.GoodsService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+/**
+ * Created by Mklaus on 15/7/24.
+ */
+@Service
+public class GoodsServiceImpl extends BaseServiceImpl<Goods> implements GoodsService{
+    @Autowired
+    private GoodsDao goodsDao;
+
+    @Override
+    public BaseDao getBaseDao() {
+        return this.goodsDao;
+    }
+}

+ 103 - 0
src/main/java/com/logistics/service/Impl/ImageServiceImpl.java

@@ -0,0 +1,103 @@
+package com.logistics.service.Impl;
+
+import com.logistics.conf.Configurator;
+import com.logistics.service.ImageService;
+import org.apache.commons.io.FileUtils;
+import org.springframework.stereotype.Service;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.imageio.ImageIO;
+import java.awt.*;
+import java.awt.image.BufferedImage;
+import java.awt.image.ImageObserver;
+import java.io.*;
+
+/**
+ * Created by Mklaus on 15/8/27.
+ */
+@Service
+public class ImageServiceImpl implements ImageService ,ImageObserver{
+    public static final String IMAGE_PATH = Configurator.getInstance().get("imagePathOnUnix");
+
+    public static final int DEFAULT_WIDTH  = 847;
+    public static final int DEFAULT_HEIGHT = 1270;
+
+    @Override
+    public boolean imageUpdate(Image img, int infoflags, int x, int y, int width, int height) {
+        return((infoflags & ImageObserver.ALLBITS) != ImageObserver.ALLBITS);
+    }
+
+    @Override
+    public void store(String name, InputStream is) throws IOException{
+        store(name,is,DEFAULT_WIDTH,DEFAULT_HEIGHT);
+    }
+
+    @Override
+    public void store(String name, InputStream is, Integer width, Integer height) throws IOException{
+        BufferedImage img = ImageIO.read(is);
+
+        // 设定图片大小的比例
+        double ratio = (height * 1.0000) / width;
+
+        double h = img.getHeight();
+        double w = img.getWidth();
+        double hwratio = h/w;
+        double clipH = hwratio <= ratio ? h : w*ratio ;
+        double clipW = hwratio >= ratio ? w : h*ratio ;
+
+        int sx1 = (int) (w-clipW) /2;
+        int sx2 = (int) w-sx1;
+        int sy1 = (int) (h-clipH) /2;
+        int sy2 = (int) h-sy1;
+
+        BufferedImage scaledImg = new BufferedImage(width, height, BufferedImage.TYPE_3BYTE_BGR);
+        ((Graphics2D)scaledImg.getGraphics())
+                .drawImage(img, 0, 0, width, height ,sx1, sy1, sx2, sy2, this);
+
+        File file = new File(IMAGE_PATH+ File.separator+name+".jpg");
+        if (!file.exists())
+            file.createNewFile();
+
+        ImageIO.write(scaledImg, "jpg", file);
+    }
+
+    @Override
+    public InputStream load(String name) throws IOException{
+        File file = new File(IMAGE_PATH+File.separator+name+".jpg");
+        if (!file.exists())
+            throw(new FileNotFoundException("Cover not found:name="+name));
+
+        FileInputStream is = new FileInputStream(file);
+
+        return(is);
+    }
+
+    @Override
+    public void upload(String parent,String name, MultipartFile file) throws IOException {
+
+        if (!file.isEmpty()){
+            FileUtils.copyInputStreamToFile(file.getInputStream(),
+                    new File(parent, name + ".jpg"));
+        }
+
+        if (new File(parent,name+".jpg").exists()){
+            System.out.println("parent = " + parent);
+        }else {
+            System.out.println("parent error = " + parent);
+        }
+    }
+
+    @Override
+    public void startPipe(InputStream is, OutputStream os, int bufferSize) throws IOException{
+        byte[] buffer = new byte[bufferSize];
+        boolean read = true;
+
+        int read1;
+        while((read1 = is.read(buffer, 0, bufferSize)) != -1) {
+            os.write(buffer, 0, read1);
+        }
+
+        is.close();
+        os.close();
+    }
+}

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