Jelajahi Sumber

第一次提交林业一张图后台管理系统

qiubo 4 tahun lalu
melakukan
b520078cc8
100 mengubah file dengan 12254 tambahan dan 0 penghapusan
  1. 249 0
      pom.xml
  2. 22 0
      src/main/java/com/hywa/map/SystemApplication.java
  3. 53 0
      src/main/java/com/hywa/map/common/ConstantPool.java
  4. 190 0
      src/main/java/com/hywa/map/common/enums/CommonEnum.java
  5. 62 0
      src/main/java/com/hywa/map/common/enums/DataSource.java
  6. 50 0
      src/main/java/com/hywa/map/common/enums/Gender.java
  7. 49 0
      src/main/java/com/hywa/map/common/enums/InformEvaluate.java
  8. 49 0
      src/main/java/com/hywa/map/common/enums/InformResult.java
  9. 50 0
      src/main/java/com/hywa/map/common/enums/InformState.java
  10. 15 0
      src/main/java/com/hywa/map/common/enums/Module.java
  11. 49 0
      src/main/java/com/hywa/map/common/enums/RegionType.java
  12. 79 0
      src/main/java/com/hywa/map/common/enums/WeatherConts.java
  13. 158 0
      src/main/java/com/hywa/map/common/exception/GlobalDefaultExceptionHandler.java
  14. 53 0
      src/main/java/com/hywa/map/common/exception/GlobalException.java
  15. 72 0
      src/main/java/com/hywa/map/common/log/AnnotationUtils.java
  16. 18 0
      src/main/java/com/hywa/map/common/log/Log.java
  17. 82 0
      src/main/java/com/hywa/map/common/log/LogAspect.java
  18. 30 0
      src/main/java/com/hywa/map/common/log/LogUtils.java
  19. 29 0
      src/main/java/com/hywa/map/common/param/PageBean.java
  20. 64 0
      src/main/java/com/hywa/map/common/reverseSQL/CreateHtmlUtils.java
  21. 235 0
      src/main/java/com/hywa/map/common/reverseSQL/GenEntityMappingUtils.java
  22. 815 0
      src/main/java/com/hywa/map/common/reverseSQL/GenEntityMysql.java
  23. 13 0
      src/main/java/com/hywa/map/common/strategy/importing/ImportExcel.java
  24. 40 0
      src/main/java/com/hywa/map/common/strategy/importing/ImportExcelFactory.java
  25. 84 0
      src/main/java/com/hywa/map/common/utils/CodeUtils.java
  26. 268 0
      src/main/java/com/hywa/map/common/utils/DateUtils.java
  27. 430 0
      src/main/java/com/hywa/map/common/utils/ExcelUtils.java
  28. 230 0
      src/main/java/com/hywa/map/common/utils/FileUtils.java
  29. 257 0
      src/main/java/com/hywa/map/common/utils/HttpClientUtils.java
  30. 265 0
      src/main/java/com/hywa/map/common/utils/HttpUtils.java
  31. 32 0
      src/main/java/com/hywa/map/common/utils/IDUtils.java
  32. 58 0
      src/main/java/com/hywa/map/common/utils/JsonUtils.java
  33. 57 0
      src/main/java/com/hywa/map/common/utils/ListUtils.java
  34. 74 0
      src/main/java/com/hywa/map/common/utils/LogKit.java
  35. 826 0
      src/main/java/com/hywa/map/common/utils/LunarCalendar.java
  36. 77 0
      src/main/java/com/hywa/map/common/utils/MD5Utils.java
  37. 18 0
      src/main/java/com/hywa/map/common/utils/MoneyUtils.java
  38. 29 0
      src/main/java/com/hywa/map/common/utils/PageUtils.java
  39. 76 0
      src/main/java/com/hywa/map/common/utils/PinYinUtil.java
  40. 216 0
      src/main/java/com/hywa/map/common/utils/PoiUtils.java
  41. 70 0
      src/main/java/com/hywa/map/common/utils/ReadTxtUtils.java
  42. 242 0
      src/main/java/com/hywa/map/common/utils/ReadXlsUtils.java
  43. 44 0
      src/main/java/com/hywa/map/common/utils/ReverseGeocodeUtils.java
  44. 51 0
      src/main/java/com/hywa/map/common/utils/SpringContext.java
  45. 134 0
      src/main/java/com/hywa/map/common/utils/StrKit.java
  46. 545 0
      src/main/java/com/hywa/map/common/utils/StringUtils.java
  47. 89 0
      src/main/java/com/hywa/map/common/utils/TextFileUtils.java
  48. 94 0
      src/main/java/com/hywa/map/common/utils/ThreeDESUtil.java
  49. 22 0
      src/main/java/com/hywa/map/common/utils/UUIDUtils.java
  50. 85 0
      src/main/java/com/hywa/map/common/utils/ZipUtils.java
  51. 84 0
      src/main/java/com/hywa/map/config/EnvProperties.java
  52. 39 0
      src/main/java/com/hywa/map/config/SwaggerConfig.java
  53. 45 0
      src/main/java/com/hywa/map/config/WebAppConfig.java
  54. 51 0
      src/main/java/com/hywa/map/config/datasource/AgribusinessDataSourceConfig.java
  55. 53 0
      src/main/java/com/hywa/map/config/druid/DruidConfig.java
  56. 17 0
      src/main/java/com/hywa/map/config/druid/DruidStatFilter.java
  57. 18 0
      src/main/java/com/hywa/map/config/druid/DruidStatViewServlet.java
  58. 12 0
      src/main/java/com/hywa/map/config/interceptor/ArrayUtils.java
  59. 20 0
      src/main/java/com/hywa/map/config/interceptor/AuthContext.java
  60. 24 0
      src/main/java/com/hywa/map/config/interceptor/AuthService.java
  61. 10 0
      src/main/java/com/hywa/map/config/interceptor/AuthStrategy.java
  62. 70 0
      src/main/java/com/hywa/map/config/interceptor/PermissionAuthConfig.java
  63. 19 0
      src/main/java/com/hywa/map/config/interceptor/PermissionModule.java
  64. 65 0
      src/main/java/com/hywa/map/config/interceptor/RedisTokenManager.java
  65. 143 0
      src/main/java/com/hywa/map/config/interceptor/TokenAuthorFilter.java
  66. 25 0
      src/main/java/com/hywa/map/config/interceptor/TokenManager.java
  67. 16 0
      src/main/java/com/hywa/map/config/interceptor/TokenModel.java
  68. 30 0
      src/main/java/com/hywa/map/config/interceptor/UserAuthContext.java
  69. 49 0
      src/main/java/com/hywa/map/config/redis/CacheKeyGenerator.java
  70. 35 0
      src/main/java/com/hywa/map/config/redis/FastJsonRedisSerializer.java
  71. 63 0
      src/main/java/com/hywa/map/config/redis/RedisConfig.java
  72. 110 0
      src/main/java/com/hywa/map/config/redis/RedisUtil.java
  73. 36 0
      src/main/java/com/hywa/map/config/thread/ThreadPoolConfig.java
  74. 64 0
      src/main/java/com/hywa/map/config/thread/VisiableThreadPoolTaskExecutor.java
  75. 37 0
      src/main/java/com/hywa/map/config/validation/FormValidation.java
  76. 17 0
      src/main/java/com/hywa/map/config/validation/JsonValidate.java
  77. 10 0
      src/main/java/com/hywa/map/config/validation/Validator.java
  78. 111 0
      src/main/java/com/hywa/map/controller/branch/BranchController.java
  79. 125 0
      src/main/java/com/hywa/map/controller/common/FileController.java
  80. 63 0
      src/main/java/com/hywa/map/controller/common/WeatherController.java
  81. 83 0
      src/main/java/com/hywa/map/controller/csv/CsvController.java
  82. 119 0
      src/main/java/com/hywa/map/controller/csv/DbController.java
  83. 97 0
      src/main/java/com/hywa/map/controller/depart/DepartController.java
  84. 144 0
      src/main/java/com/hywa/map/controller/dict/DictController.java
  85. 74 0
      src/main/java/com/hywa/map/controller/dict/DictValController.java
  86. 214 0
      src/main/java/com/hywa/map/controller/expert/AreaDataController.java
  87. 137 0
      src/main/java/com/hywa/map/controller/expert/DamController.java
  88. 145 0
      src/main/java/com/hywa/map/controller/expert/ExpertController.java
  89. 67 0
      src/main/java/com/hywa/map/controller/gis/GisController.java
  90. 45 0
      src/main/java/com/hywa/map/controller/log/LogController.java
  91. 136 0
      src/main/java/com/hywa/map/controller/login/AreaMenuController.java
  92. 235 0
      src/main/java/com/hywa/map/controller/login/MenuController.java
  93. 159 0
      src/main/java/com/hywa/map/controller/login/RoleController.java
  94. 377 0
      src/main/java/com/hywa/map/controller/login/UserController.java
  95. 66 0
      src/main/java/com/hywa/map/controller/login/validate/StateValidationValidate.java
  96. 481 0
      src/main/java/com/hywa/map/controller/map/MapAdviseController.java
  97. 188 0
      src/main/java/com/hywa/map/controller/map/MapController.java
  98. 563 0
      src/main/java/com/hywa/map/controller/map/MapDamController.java
  99. 564 0
      src/main/java/com/hywa/map/controller/map/MapDomainController.java
  100. 0 0
      src/main/java/com/hywa/map/controller/map/MapPwdController.java

+ 249 - 0
pom.xml

@@ -0,0 +1,249 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>com.hywa</groupId>
+  <artifactId>forest-map</artifactId>
+  <version>1.0</version>
+  <packaging>jar</packaging>
+
+  <name>forest-map</name>
+  <description>Demo project for Spring Boot</description>
+
+  <parent>
+    <groupId>org.springframework.boot</groupId>
+    <artifactId>spring-boot-starter-parent</artifactId>
+    <version>2.0.2.RELEASE</version>
+    <relativePath/> <!-- lookup parent from repository -->
+  </parent>
+
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
+    <java.version>1.8</java.version>
+    <shiro.version>1.3.2</shiro.version>
+    <fastJson.version>1.2.47</fastJson.version>
+    <mybatis.version>1.3.1</mybatis.version>
+    <pagehelper.version>1.2.4</pagehelper.version>
+    <jxl.version>2.6.12</jxl.version>
+    <druid.version>1.1.6</druid.version>
+    <common.version>2.5.0</common.version>
+    <jackson.version>2.9.4</jackson.version>
+    <docker.image.prefix>base_data</docker.image.prefix>
+    <dockerfile-maven-plugin.version>1.3.6</dockerfile-maven-plugin.version>
+    <commons-net.version>3.1</commons-net.version>
+    <guava.version>23.0</guava.version>
+    <swagger.version>2.8.0</swagger.version>
+    <poi.version>3.14</poi.version>
+    <poi.ooxml.version>3.14</poi.ooxml.version>
+    <commons.io.version>2.5</commons.io.version>
+  </properties>
+
+  <dependencies>
+
+    <dependency>
+      <groupId>io.springfox</groupId>
+      <artifactId>springfox-swagger2</artifactId>
+      <version>${swagger.version}</version>
+    </dependency>
+
+    <dependency>
+      <groupId>io.springfox</groupId>
+      <artifactId>springfox-swagger-ui</artifactId>
+      <version>${swagger.version}</version>
+    </dependency>
+
+    <dependency>
+      <groupId>commons-net</groupId>
+      <artifactId>commons-net</artifactId>
+      <version>${commons-net.version}</version>
+    </dependency>
+
+    <dependency>
+      <groupId>com.fasterxml.jackson.core</groupId>
+      <artifactId>jackson-core</artifactId>
+      <version>${jackson.version}</version>
+    </dependency>
+
+    <dependency>
+      <groupId>com.fasterxml.jackson.core</groupId>
+      <artifactId>jackson-annotations</artifactId>
+      <version>${jackson.version}</version>
+    </dependency>
+
+    <dependency>
+      <groupId>org.springframework.boot</groupId>
+      <artifactId>spring-boot-starter-web</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>org.springframework.boot</groupId>
+      <artifactId>spring-boot-starter-aop</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>org.springframework.boot</groupId>
+      <artifactId>spring-boot-starter-data-redis</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>org.springframework.boot</groupId>
+      <artifactId>spring-boot-starter-test</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>mysql</groupId>
+      <artifactId>mysql-connector-java</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.shiro</groupId>
+      <artifactId>shiro-spring</artifactId>
+      <version>${shiro.version}</version>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.commons</groupId>
+      <artifactId>commons-pool2</artifactId>
+      <version>${common.version}</version>
+    </dependency>
+
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-api</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>org.springframework.boot</groupId>
+      <artifactId>spring-boot-devtools</artifactId>
+      <optional>true</optional>
+    </dependency>
+
+    <dependency>
+      <groupId>org.springframework.boot</groupId>
+      <artifactId>spring-boot-starter-freemarker</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>org.mybatis.spring.boot</groupId>
+      <artifactId>mybatis-spring-boot-starter</artifactId>
+      <version>${mybatis.version}</version>
+    </dependency>
+
+    <dependency>
+      <groupId>net.sourceforge.jexcelapi</groupId>
+      <artifactId>jxl</artifactId>
+      <version>${jxl.version}</version>
+    </dependency>
+
+    <dependency>
+      <groupId>com.alibaba</groupId>
+      <artifactId>fastjson</artifactId>
+      <version>${fastJson.version}</version>
+    </dependency>
+
+    <dependency>
+      <groupId>com.github.pagehelper</groupId>
+      <artifactId>pagehelper-spring-boot-starter</artifactId>
+      <version>${pagehelper.version}</version>
+    </dependency>
+
+    <dependency>
+      <groupId>org.projectlombok</groupId>
+      <artifactId>lombok</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>com.alibaba</groupId>
+      <artifactId>druid</artifactId>
+      <version>${druid.version}</version>
+    </dependency>
+
+    <dependency>
+      <groupId>com.google.guava</groupId>
+      <artifactId>guava</artifactId>
+      <version>${guava.version}</version>
+    </dependency>
+
+    <!-- httpclient -->
+    <dependency>
+      <groupId>org.apache.httpcomponents</groupId>
+      <artifactId>httpmime</artifactId>
+      <version>4.5.3</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.httpcomponents</groupId>
+      <artifactId>httpclient</artifactId>
+      <version>4.5.9</version>
+    </dependency>
+    <dependency>
+      <groupId>org.springframework.amqp</groupId>
+      <artifactId>spring-rabbit</artifactId>
+      <version>2.0.2.RELEASE</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.poi</groupId>
+      <artifactId>poi</artifactId>
+      <version>${poi.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.poi</groupId>
+      <artifactId>poi-ooxml</artifactId>
+      <version>${poi.ooxml.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>commons-io</groupId>
+      <artifactId>commons-io</artifactId>
+      <version>${commons.io.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>com.belerweb</groupId>
+      <artifactId>pinyin4j</artifactId>
+      <version>2.5.0</version>
+    </dependency>
+    <dependency>
+      <groupId>com.opencsv</groupId>
+      <artifactId>opencsv</artifactId>
+      <version>4.4</version>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.springframework.boot</groupId>
+        <artifactId>spring-boot-maven-plugin</artifactId>
+      </plugin>
+      <plugin>
+        <groupId>org.mybatis.generator</groupId>
+        <artifactId>mybatis-generator-maven-plugin</artifactId>
+        <version>1.3.2</version>
+        <configuration>
+          <configurationFile>src/main/resources/mybatis-generator/generatorConfig.xml
+          </configurationFile>
+          <verbose>true</verbose>
+          <overwrite>true</overwrite>
+        </configuration>
+        <executions>
+          <execution>
+            <id>Generate MyBatis Artifacts</id>
+            <goals>
+              <goal>generate</goal>
+            </goals>
+          </execution>
+        </executions>
+        <dependencies>
+          <dependency>
+            <groupId>org.mybatis.generator</groupId>
+            <artifactId>mybatis-generator-core</artifactId>
+            <version>1.3.2</version>
+          </dependency>
+        </dependencies>
+      </plugin>
+    </plugins>
+  </build>
+
+</project>

+ 22 - 0
src/main/java/com/hywa/map/SystemApplication.java

@@ -0,0 +1,22 @@
+package com.hywa.map;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.web.servlet.ServletComponentScan;
+import org.springframework.scheduling.annotation.EnableAsync;
+import org.springframework.scheduling.annotation.EnableScheduling;
+
+@EnableScheduling
+@SpringBootApplication
+//配置druid必须加的注解,如果不加,访问页面打不开,filter和servlet、listener之类的需要单独进行注册才能使用,
+@ServletComponentScan
+@EnableAsync
+@EnableAutoConfiguration
+public class SystemApplication {
+
+    public static void main(String[] args) {
+        SpringApplication.run(SystemApplication.class, args);
+    }
+
+}

+ 53 - 0
src/main/java/com/hywa/map/common/ConstantPool.java

@@ -0,0 +1,53 @@
+package com.hywa.map.common;
+
+public class ConstantPool {
+    public static final Short NOT_DEL = 0;
+    public static final Short DEL = 1;
+    public static final String GD_STATUS_SUCCESS = "0";
+    public static final long TOKEN_EXPIRES_SECOND = 3600 * 10000;
+    public static final String REQUEST_MODE_ALL = "0";
+    public static final String SPLIT = "-";
+    public static final String DISAABLE = "1";
+    public static final String IMPORT_CHECK_RESULT = "检查结果文件";
+    public static final String IMPORT_TEMPLATE = "file";
+    /* 获取数据字典配置参数 start*/
+    //数据字典非标准库系统编码
+    public static final String DICT_N_SYSTEM_ID = "N0001";
+    //数据字典编码第1级长度
+    public static final int DICT_FIRST_LENGTH = 10;
+    //数据字典编码第2级长度
+    public static final int DICT_SECOND_LENGTH = 15;
+    //数据字典编码第3级长度
+    public static final int DICT_THIRD_LENGTH = 20;
+    //标准库配置-农业活动库
+    public static final String PLAN_LIBCODE = "HD";
+    //标准库配置-农投品库
+    public static final String INPUT_LIBCODE = "TR";
+    //标准库配置-农产品库
+    public static final String CORP_LIBCODE = "CP";
+    //标准库配置-其他配置库
+    public static final String OTHER_LIBCODE = "QT";
+    //数据字典编码第1级
+    public static final String DICTCODE_LEVEL_1 = "00001";
+    //数据字典编码第2级
+    public static final String DICTCODE_LEVEL_2 = "00002";
+    //数据字典编码第3级
+    public static final String DICTCODE_LEVEL_3 = "00003";
+    //数据字典编码第4级
+    public static final String DICTCODE_LEVEL_4 = "00004";
+    //数据字典编码第5级
+    public static final String DICTCODE_LEVEL_5 = "00005";
+    //数据字典编码第6级
+    public static final String DICTCODE_LEVEL_6 = "00006";
+    //数据字典编码第7级
+    public static final String DICTCODE_LEVEL_7 = "00007";
+    //数据字典编码第8级
+    public static final String DICTCODE_LEVEL_8 = "00008";
+    //数据字典编码第9级
+    public static final String DICTCODE_LEVEL_9 = "00009";
+    //数据字典编码第10级
+    public static final String DICTCODE_LEVEL_10 = "00010";
+    //数据字典编码,手工增加的场景
+    public static final String DICTCODE_LEVEL_91 = "90001";
+    /* 获取数据字典配置参数 end */
+}

+ 190 - 0
src/main/java/com/hywa/map/common/enums/CommonEnum.java

@@ -0,0 +1,190 @@
+package com.hywa.map.common.enums;
+
+import com.hywa.map.common.exception.GlobalException;
+
+public enum CommonEnum {
+    MEN("男", (short) 1),
+    WOMEN("女", (short) 2),
+
+    INCREASE("增长", (short) 1),
+    FALLING("下降", (short) 2),
+
+    COUNTRY("country", (short) 0),
+    PROVINCE("province", (short) 1),
+    CITY("city", (short) 2),
+    DISTRICT("county", (short) 3),
+    TOWN("town", (short) 4),
+    VILLAGE("village", (short) 5),
+
+    SUCCESS("成功", (short) 0),
+    FAILURE("失败", (short) 1),
+
+    USER_CANCEL("用户已经注销,请联系管理员", (short) 1001),
+    PASSWORD_ERROR("密码错误", (short) 1002),
+    USER_UNREGISTERED_ERROR("用户未注册", (short) 1003),
+    RE_LOGIN("认证失败,请重新登录!", (short) 1004),
+    UNBOUND_REGION_ERROR("此账户未绑定区域,请联系管理员!", (short) 1005),
+    USER_NAME_REPEATED("用户名称已经存在", (short) 1006),
+    USER_TELEPHONE_REPEATED("电话号码已经存在", (short) 1007),
+    TELEPHONE_FORMAL_ERROR("电话号码格式错误", (short) 1008),
+    RE_LOGOUT("未正确退出,请重新退出", (short) 1009),
+    UNIQUE_CHECK_ERROR("重复", (short) 1101),
+    ENCRYPTION_ERROR("加密操作失败", (short) 1102),
+    ILLEGAL_PARAMETER_ERROR("参数非法", (short) 2001),
+    PARAMETER_NOT_NULL("参数不能为空", (short) 2002),
+    ID_NOT_NULL("id不能为空", (short) 2009),
+    TYPE_REFERENCED("类型被引用,请先删除引用", (short) 2003),
+    FILE_NOT_NULL("文件不能为空", (short) 2004),
+    FILE_CONTENT_NOT_NULL("文件内容不能为空", (short) 2005),
+    FILE_UPLOAD_FAIL("文件上传失败", (short) 2006),
+    DATE_TIME_FORMAT_ERR("请按正确的时间格式填写,格式为:年-月-日,例如:2018-06-28", (short) 2007),
+    COORDINATE_PARSE_ERROR("坐标解析错误", (short) 2008),
+    DEL_FAILURE("删除失败,对应用户不存在", (short) 2009),
+    DEL_CURRENT_LOGIN_INFO("不能修改当前登录人信息", (short) 2010),
+    DEL_ADMIN("不能修改超级管理员信息", (short) 2011),
+    PERCENT_TO_DOUBLE_ERROR("百分数转换double格式错误", (short) 2012),
+    PRODUCT_NAME_REPEATED("该商品已经存在", (short) 3001),
+    FILE_NOT_FOUND("文件不存在", (short) 3002),
+    FILE_REPEATED("文件已存在", (short) 3003),
+    MAX_UPLOAD_SIZE_EXCEEDED("文件过大无法上传", (short) 3004),
+    ROLE_NAME_REPEATED("角色名称已经存在", (short) 3002),
+    ROLE_MENU_NOT_FOUND("权限范围不可为空", (short) 3014),
+    MENU_NAME_REPEATED("菜单名称已经存在", (short) 3003),
+    PASSWORD_REPEAT("修改前后密码不能相同", (short) 3004),
+    USER_INFO_ERROR("用户信息有误", (short) 3005),
+    TOO_BIG_A_DOCUMENT("文件内容过大,无法上传", (short) 3006),
+    FILE_TYPE_ERROR("上传文件格式错误,仅支持.xls和.xlsx两种格式的文件", (short) 3007),
+    NUMBER_FORMAT("格式异常", (short) 3009),
+    FILE_CANNOT_BE_FOUND("文件未找到", (short) 3010),
+    DATE_TIME_PARSE("时间格式异常,请使用指定时间格式", (short) 3011),
+    OPERATOR_ERROR("不是对应办理人无法办理", (short) 3012),
+    RECOMMEND_EXCEED("推荐文章不能超过五条", (short) 3013),
+    AREA_ID_REPEATED("区域名称已经存在", (short) 3015),
+    AREA_ID_NOT_FOUND("区域名称不存在", (short) 3016),
+    CRAWLER_ASTRICT("省级账号才能查看爬虫信息", (short) 3017),
+    IP_ERROR("无效IP", (short) 3018),
+    ADMIN_ASTRICT("超级管理员不涉及业务操作", (short) 3019),
+    NO_AUTHORITY("权限不足,请联系管理员!", (short) 3020),
+    EVIDENCE_NOT_FOUND("请上传相应证据再进行举报", (short) 3021),
+    EXCEL_DATA_VOID("数据为空无法下载", (short) 3022),
+    AUTH_CODE_ERROR("验证码错误", (short) 3023),
+    TIME_TYPE_ERROR("时间类型只能为天(1)和月(3)", (short) 3024),
+    TITLE_IS_NULL("文章标题不能为空", (short) 3025),
+    IS_RECOMMEND_IS_NULL("文章需表明是否首页推荐", (short) 3026),
+    CONTENT_IS_NULL("文章内容不能为空", (short) 3027),
+    COVER_IS_NULL("推荐文章必须上传封面图片", (short) 3028),
+    AUTH_CODE_TIME_OUT("验证码超时", (short) 3029),
+    LOGIN_TIMEOUT("秘钥错误",(short)3030),
+    AREA_NO_FOUND("地区不在当前用户范围内,请重新选择",(short)3031),
+    DATA_ERROR("导入数据时间格式异常",(short)3032),
+    INTEGER_VAIL("必须为整数",(short)3033),
+    AREA_UNMATCH_ROLE("用户角色不在地区范围内,请重新选择",(short)3034),
+    USER_INFO_RESTRICT("不是对应创建人无法进行相应操作",(short)3035),
+    ARG_NO_FOUND("参数名称与系统中名称不匹配",(short)3036),
+    DATA_NO_FOUND("导入数据中日期不能为空",(short)3037),
+    PRODUCT_NAME_NO_FOUND("导入数据中产品名称不能为空",(short)3038),
+    MARKET_NAME_FOUND("导入数据中市场名称不能为空",(short)3039),
+    DEL_STATE("事件已举报完成,证据无法删除",(short)3040),
+    ABNORMAL_ACCOUNT("账号异常",(short)3041),
+    AREA_USER_FOUND("区域被用户引用,请先删除区域下的用户",(short)3042),
+    ROLE_USER_FOUND("角色被用户引用,请先删除角色下的用户",(short)3043),
+    ROLE_SYS("不可以删除系统默认创建的角色",(short)3044),
+    ROLE_NO_FOUND("角色不存在",(short)3045),
+    MENU_NO_FOUND("请增加上级和本级默认角色的菜单权限",(short)3046),
+    AREA_NO_MATCH("只允许修改本级的菜单权限",(short)3047),
+    ROLE_DEFAULT("只允许上级修改系统创建的默认角色",(short)3048),
+    THE_CALLING_SYSTEM_DID_NOT_START("调用系统未正常启动",(short)3049),
+    BUSINESS_INFORMATION_CANNOT_BE_EMPTY("农企信息不能为空",(short)3050),
+    PRICING_RELEASES_CANNOT_BE_EMPTY("定价发布信息不能为空",(short)3051),
+    THE_ACCOUNT_IS_BANNED("账号被禁,无法使用",(short)3052),
+    THREAD_BLOCKING_EXCEPTION("账号被禁,无法使用",(short)3053),
+    ROLE_OF_SPOT("不允许修改或删除收购点权限角色",(short)3054),
+    INFORMATION_CANNOT_BE_REMOVED_BY_REFERENCE("信息被引用,无法删除",(short)3055),
+    THE_CONTENT_IS_TOO_LARGE_TO_SAVE("内容过长无法保存",(short)3056),
+    CANNOT_BE_DELETED_IN_USE("农企信息在使用中,不能删除",(short)3057),
+    ACQUISITION_POINT_CANNOT_BE_EMPTY("收购点不能为空",(short)3058),
+    ERROR_FORMAT("保存数据失败,请检查数据格式",(short)3059),
+    INDU_NAME_FOUND("行业名称已经存在",(short)3060),
+    INDU_CODE_FOUND("行业编码已经存在",(short)3061),
+    INDU_CODE_USED("行业编码被标准库引用,请先删除关联的标准库",(short)3062),
+    LIB_NAME_FOUND("库名称已经存在",(short)3063),
+    LIB_CODE_FOUND("库编码已经存在",(short)3064),
+    LIB_CODE_USED("库编码被标准数据引用,请先删除关联的标准数据",(short)3065),
+    SYS_DICT_NAME_FOUND("字典名称已经存在",(short)3066),
+    SYS_DICT_CODE_FOUND("字典编码已经存在",(short)3067),
+    SYS_DICT_CODE_USED("字典编码被下级数据引用,请先删除关联的下级数据",(short)3068),
+    FILE_TEMPLATE_ERROR("数据模版不符",(short)3069),
+    CHECK_DATA_ERROR("导入数据错误,请下载检查结果文件",(short)3070),
+    DISABLE_ADMIN("不能禁用超级管理员信息", (short) 3071),
+    DISABLE_SELF("不能禁用当前登录用户", (short) 3072),
+    BRANCH_USED("机构被引用,请先删除关联的下级机构",(short)3073),
+    BRANCH_NAME_FOUND("机构名称已经存在",(short)3074),
+    DICT_TYPE_FOUND("字典类型已经存在",(short)3075),
+    DICT_CODE_FOUND("字典编码已经存在",(short)3076),
+    DICT_TYPE_USED("字典类型被下级数据引用,请先删除关联的下级数据",(short)3078),
+    DICT_VALUE_FOUND("字典值已经存在",(short)3079),
+    DICT_SEQ_FOUND("字典序列号已经存在",(short)3080),
+    NOTICE_NAME_FOUND("标题名称已经存在",(short)3081),
+    REPORT_NO_FOUND("报告编号已经存在",(short)3082),
+    CORP_NAME_FOUND("企业名称已经存在",(short)3083),
+    CORP_TEL_FOUND("联系电话已经存在",(short)3084),
+    ID_NO_FOUND("id不存在",(short)3085),
+    EXE_NUMBER_FOUND("行政处罚决定案号已经存在",(short)3086),
+    USER_ICON_NO_FOUND("头像不能为空",(short)3087),
+    BRANCH_USER_USED("机构被用户引用,请先删除关联的用户",(short)3088),
+    NET_ERROR("通讯异常,请稍后重试!", (short) 3089),
+    TOPIC_NAME_FOUND("专题名称已经存在",(short)3090),
+    ORCHARD_CODE_FOUND("园区编码已经存在",(short)3091),
+    ORCHARD_NAME_FOUND("园区名称已经存在",(short)3092),
+    DB_SOURCE_NAME_FOUND("数据源名称已经存在",(short)3093),
+    DB_SOURCE_USED("数据源存在关联数据,请先删除关联数据配置",(short)3094),
+    MAP_NAME_FOUND("大屏名称已经存在",(short)3095),
+    AREA_DATA_USED("数据应用于大屏,不可以删除",(short)3096),
+    SCREEN_ERROR("口令错误",(short)3097),
+    INTERNAL_ERROR("系统错误,请联系管理员!", (short) 9999);
+
+
+    private String value;
+    private Short index;
+
+    CommonEnum(String sex, Short index) {
+        this.setValue(sex);
+        this.setIndex(index);
+    }
+
+    public String getValue() {
+        return value;
+    }
+
+    public static String getSex(Short index) {
+        if (index.equals(MEN.index)) {
+            return MEN.getValue();
+        } else if (index.equals(WOMEN.index)) {
+            return WOMEN.getValue();
+        } else {
+            return null;
+        }
+    }
+
+    public static short getIndex(String sex) {
+        if (sex.trim().equals(MEN.value)) {
+            return MEN.getIndex();
+        } else if (sex.trim().equals(WOMEN.value)) {
+            return WOMEN.getIndex();
+        } else {
+            throw new GlobalException("性别输入异常,性别只能为:男、女!");
+        }
+    }
+
+    public Short getIndex() {
+        return index;
+    }
+
+    public void setValue(String value) {
+        this.value = value;
+    }
+
+    public void setIndex(Short index) {
+        this.index = index;
+    }
+}

+ 62 - 0
src/main/java/com/hywa/map/common/enums/DataSource.java

@@ -0,0 +1,62 @@
+package com.hywa.map.common.enums;
+
+import com.hywa.map.common.exception.GlobalException;
+
+import java.util.Optional;
+
+/**
+ * 数据源
+ */
+public enum DataSource {
+
+    NORTHLOGISTICSPARK("北部物流园","northLogisticsPark"),BUSINESSBUREAU("商务局", "businessBureau");
+
+    private String value;
+    private String name;
+
+    DataSource(String value, String name) {
+        this.setValue(value);
+        this.setName(name);
+    }
+
+    public String getValue() {
+        return value;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setValue(String value) {
+        this.value = value;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public static String getValue(String name) {
+        for (DataSource i : DataSource.values()) {
+            if (i.getName().equals(name)) {
+                return i.value;
+            }
+        }
+        if (Optional.ofNullable(name).isPresent()) {
+            throw new GlobalException(CommonEnum.ILLEGAL_PARAMETER_ERROR.getIndex(), CommonEnum.ILLEGAL_PARAMETER_ERROR.getValue());
+        }
+        return null;
+    }
+
+    public static String getName(String value) {
+        for (DataSource i : DataSource.values()) {
+            if (i.getValue().equals(value)) {
+                return i.name;
+            }
+        }
+        if (Optional.ofNullable(value).isPresent()) {
+            throw new GlobalException(CommonEnum.ILLEGAL_PARAMETER_ERROR.getIndex(), CommonEnum.ILLEGAL_PARAMETER_ERROR.getValue());
+        }
+        return null;
+    }
+
+}

+ 50 - 0
src/main/java/com/hywa/map/common/enums/Gender.java

@@ -0,0 +1,50 @@
+package com.hywa.map.common.enums;
+
+import java.util.Optional;
+
+import com.hywa.map.common.exception.GlobalException;
+
+/**
+ * 性别
+ */
+public enum Gender {
+
+    WOMEN("女", (short) 0), MEN("男", (short) 1), UNKNOWN("未知", (short) 2);
+
+    private String value;
+    private Short index;
+
+    Gender(String sex, Short index) {
+        this.setValue(sex);
+        this.setIndex(index);
+    }
+
+    public String getValue() {
+        return value;
+    }
+
+    public Short getIndex() {
+        return index;
+    }
+
+    public void setValue(String value) {
+        this.value = value;
+    }
+
+    public void setIndex(Short index) {
+        this.index = index;
+    }
+
+    public static String getValue(Short index) {
+        for (Gender i : Gender.values()) {
+            if (i.getIndex().equals(index)) {
+                return i.value;
+            }
+        }
+        if(Optional.ofNullable(index).isPresent()){
+            throw new GlobalException(CommonEnum.ILLEGAL_PARAMETER_ERROR.getIndex(), CommonEnum.ILLEGAL_PARAMETER_ERROR.getValue());
+        }
+        return null;
+    }
+
+}

+ 49 - 0
src/main/java/com/hywa/map/common/enums/InformEvaluate.java

@@ -0,0 +1,49 @@
+package com.hywa.map.common.enums;
+
+import com.hywa.map.common.exception.GlobalException;
+
+import java.util.Optional;
+
+/**
+ * 举报事件评价
+ */
+public enum InformEvaluate {
+
+    VOID("无效办理", (short) 0), EVIDENCE("证据不足", (short) 1), COMPLETE("处理完成", (short) 2);
+
+    private String value;
+    private Short index;
+
+    InformEvaluate(String sex, Short index) {
+        this.setValue(sex);
+        this.setIndex(index);
+    }
+
+    public String getValue() {
+        return value;
+    }
+
+    public Short getIndex() {
+        return index;
+    }
+
+    public void setValue(String value) {
+        this.value = value;
+    }
+
+    public void setIndex(Short index) {
+        this.index = index;
+    }
+
+    public static String getValue(Short index){
+        for (InformEvaluate i : InformEvaluate.values()) {
+            if (i.getIndex().equals(index)) {
+                return i.value;
+            }
+        }
+        if(Optional.ofNullable(index).isPresent()){
+            throw new GlobalException(CommonEnum.ILLEGAL_PARAMETER_ERROR.getIndex(), CommonEnum.ILLEGAL_PARAMETER_ERROR.getValue());
+        }
+        return null;
+    }
+}

+ 49 - 0
src/main/java/com/hywa/map/common/enums/InformResult.java

@@ -0,0 +1,49 @@
+package com.hywa.map.common.enums;
+
+import com.hywa.map.common.exception.GlobalException;
+
+import java.util.Optional;
+
+/**
+ * 举报事件办理结果
+ */
+public enum InformResult {
+
+    GREATSATISFACTION("非常满意", (short) 0), SATISFACTION("满意", (short) 1), DISSATISFACTION("不满意", (short) 2);
+
+    private String value;
+    private Short index;
+
+    InformResult(String sex, Short index) {
+        this.setValue(sex);
+        this.setIndex(index);
+    }
+
+    public String getValue() {
+        return value;
+    }
+
+    public Short getIndex() {
+        return index;
+    }
+
+    public void setValue(String value) {
+        this.value = value;
+    }
+
+    public void setIndex(Short index) {
+        this.index = index;
+    }
+
+    public static String getValue(Short index){
+        for (InformResult i : InformResult.values()) {
+            if (i.getIndex().equals(index)) {
+                return i.value;
+            }
+        }
+        if(Optional.ofNullable(index).isPresent()){
+            throw new GlobalException(CommonEnum.ILLEGAL_PARAMETER_ERROR.getIndex(), CommonEnum.ILLEGAL_PARAMETER_ERROR.getValue());
+        }
+        return null;
+    }
+}

+ 50 - 0
src/main/java/com/hywa/map/common/enums/InformState.java

@@ -0,0 +1,50 @@
+package com.hywa.map.common.enums;
+
+import com.hywa.map.common.exception.GlobalException;
+
+import java.util.Optional;
+
+/**
+ * 举报事件状态
+ */
+public enum InformState {
+
+    PREPARE("未受理", (short) 0), START("等待受理", (short) 1),
+    END("已结束", (short) 2);
+
+    private String value;
+    private Short index;
+
+    InformState(String sex, Short index) {
+        this.setValue(sex);
+        this.setIndex(index);
+    }
+
+    public String getValue() {
+        return value;
+    }
+
+    public Short getIndex() {
+        return index;
+    }
+
+    public void setValue(String value) {
+        this.value = value;
+    }
+
+    public void setIndex(Short index) {
+        this.index = index;
+    }
+
+    public static String getValue(Short index){
+        for (InformState i : InformState.values()) {
+            if (i.getIndex().equals(index)) {
+                return i.value;
+            }
+        }
+        if(Optional.ofNullable(index).isPresent()){
+            throw new GlobalException(CommonEnum.ILLEGAL_PARAMETER_ERROR.getIndex(), CommonEnum.ILLEGAL_PARAMETER_ERROR.getValue());
+        }
+        return null;
+    }
+}

+ 15 - 0
src/main/java/com/hywa/map/common/enums/Module.java

@@ -0,0 +1,15 @@
+package com.hywa.map.common.enums;
+
+public enum Module {
+    ALL("所有权限"), COLLECT("采集模块"), TEST("测试模块");
+
+    private String moduleName;
+
+    Module(String moduleName) {
+        this.moduleName = moduleName;
+    }
+
+    public String getModuleName() {
+        return this.moduleName;
+    }
+}

+ 49 - 0
src/main/java/com/hywa/map/common/enums/RegionType.java

@@ -0,0 +1,49 @@
+package com.hywa.map.common.enums;
+
+import com.hywa.map.common.exception.GlobalException;
+
+import java.util.Optional;
+
+/**
+ * 区域类型
+ */
+public enum RegionType {
+
+    PROVINCE("省", (short) 1), CITY("市", (short) 2), COUNTY("区/县", (short) 3);
+
+    private String value;
+    private Short index;
+
+    RegionType(String sex, Short index) {
+        this.setValue(sex);
+        this.setIndex(index);
+    }
+
+    public String getValue() {
+        return value;
+    }
+
+    public Short getIndex() {
+        return index;
+    }
+
+    public void setValue(String value) {
+        this.value = value;
+    }
+
+    public void setIndex(Short index) {
+        this.index = index;
+    }
+
+    public static String getValue(Short index){
+        for (RegionType i : RegionType.values()) {
+            if (i.getIndex().equals(index)) {
+                return i.value;
+            }
+        }
+        if(Optional.ofNullable(index).isPresent()){
+            throw new GlobalException(CommonEnum.ILLEGAL_PARAMETER_ERROR.getIndex(), CommonEnum.ILLEGAL_PARAMETER_ERROR.getValue());
+        }
+        return null;
+    }
+}

+ 79 - 0
src/main/java/com/hywa/map/common/enums/WeatherConts.java

@@ -0,0 +1,79 @@
+package com.hywa.map.common.enums;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author hywa
+ * @create by 2018.08.09
+ * @description: 天气参数信息,包括:天气现象编码 风力编码 方向编码
+ */
+public class WeatherConts {
+    public static final Map<String, String> weatherMap;//天气现象编码
+    public static final Map<String, String> windpowerMap;//风力编码
+    public static final Map<String, String> winddireMap;//方向编码
+    static
+    {
+        //初始化天气现象编码
+        weatherMap = new HashMap<String, String>();
+        weatherMap.put("中雨", "中雨");
+        weatherMap.put("中雪", "中雪");
+        weatherMap.put("霰", "冰雹");
+        weatherMap.put("冰雹", "冰雹");
+        weatherMap.put("冻雨", "冻雨");
+        weatherMap.put("多云", "多云");
+        weatherMap.put("大暴雨", "大暴雨");
+        weatherMap.put("大雨", "大雨");
+        weatherMap.put("大雪", "大雪");
+        weatherMap.put("小雨", "小雨");
+        weatherMap.put("小雪", "小雪");
+        weatherMap.put("扬沙", "扬沙");
+        weatherMap.put("晴", "晴");
+        weatherMap.put("暴雨", "暴雨");
+        weatherMap.put("暴雪", "暴雪");
+        weatherMap.put("沙尘暴", "沙尘暴");
+        weatherMap.put("强沙尘暴", "沙尘暴");
+        weatherMap.put("浮尘", "浮尘");
+        weatherMap.put("霾", "浮尘");
+        weatherMap.put("大暴雨-特大暴雨", "特大暴雨");
+        weatherMap.put("特大暴雨", "特大暴雨");
+        weatherMap.put("阴", "阴");
+        weatherMap.put("阵雨", "阵雨");
+        weatherMap.put("阵雪", "阵雪");
+        weatherMap.put("雨夹雪", "雨夹雪");
+        weatherMap.put("雷阵雨", "雷阵雨");
+        weatherMap.put("雷阵雨并伴有冰雹", "雷阵雨加冰雹");
+        weatherMap.put("雷阵雨加冰雹", "雷阵雨加冰雹");
+        weatherMap.put("雾", "雾");
+        weatherMap.put("飑", "风");
+        weatherMap.put("龙卷风", "风");
+        //初始化风力编码
+        windpowerMap = new HashMap<String, String>();
+        windpowerMap.put("0", "无风");
+        windpowerMap.put("1", "软风");
+        windpowerMap.put("2", "轻风");
+        windpowerMap.put("3", "微风");
+        windpowerMap.put("4", "和风");
+        windpowerMap.put("5", "清风");
+        windpowerMap.put("6", "强风");
+        windpowerMap.put("7", "劲风");
+        windpowerMap.put("8", "大风");
+        windpowerMap.put("9", "烈风");
+        windpowerMap.put("10", "狂风");
+        windpowerMap.put("11", "暴风");
+        windpowerMap.put("12", "台风");
+        //初始化方向编码
+        winddireMap = new HashMap<String, String>();
+        winddireMap.put("0", "无风向");
+        winddireMap.put("1", "东北");
+        winddireMap.put("2", "东");
+        winddireMap.put("3", "东南");
+        winddireMap.put("4", "南");
+        winddireMap.put("5", "西南");
+        winddireMap.put("6", "西");
+        winddireMap.put("7", "西北");
+        winddireMap.put("8", "北");
+        winddireMap.put("9", "旋转不定");
+    }
+
+}

+ 158 - 0
src/main/java/com/hywa/map/common/exception/GlobalDefaultExceptionHandler.java

@@ -0,0 +1,158 @@
+package com.hywa.map.common.exception;
+
+import static com.hywa.map.common.ConstantPool.SPLIT;
+import static com.hywa.map.common.enums.CommonEnum.FAILURE;
+
+import com.hywa.map.common.enums.CommonEnum;
+import com.hywa.map.common.utils.StringUtils;
+import com.hywa.map.common.utils.UUIDUtils;
+import com.hywa.map.config.interceptor.TokenManager;
+import com.hywa.map.config.interceptor.TokenModel;
+import com.hywa.map.dao.entity.Log;
+import com.hywa.map.dao.mapper.LogMapper;
+import com.hywa.map.representation.ResponseBase;
+
+import java.io.FileNotFoundException;
+import java.util.Date;
+import java.util.List;
+import javax.servlet.http.HttpServletRequest;
+
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.dao.DataIntegrityViolationException;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.util.CollectionUtils;
+import org.springframework.validation.ObjectError;
+import org.springframework.web.bind.MethodArgumentNotValidException;
+import org.springframework.web.bind.MissingServletRequestParameterException;
+import org.springframework.web.bind.annotation.CrossOrigin;
+import org.springframework.web.bind.annotation.ExceptionHandler;
+import org.springframework.web.bind.annotation.RestControllerAdvice;
+import org.springframework.web.multipart.MaxUploadSizeExceededException;
+import org.springframework.web.multipart.support.MissingServletRequestPartException;
+
+
+@Slf4j
+@CrossOrigin
+@RestControllerAdvice
+public class GlobalDefaultExceptionHandler {
+    @Autowired
+    TokenManager tokenManager;
+    @Autowired
+    private LogMapper logMapper;
+
+    @ExceptionHandler(value = Exception.class)
+    public ResponseEntity<ResponseBase> defaultErrorHandler(
+            HttpServletRequest req, Exception e) {
+        String userId = "临时用户";
+        try {
+            TokenModel accessToken = tokenManager.getToken(req.getHeader("accessToken"));
+            userId = accessToken.getUserId().split(SPLIT)[1];
+        } catch (Exception internalException) {
+
+        }
+
+        Log operationLog = new Log();
+        operationLog.setId(UUIDUtils.randomUUID());
+        operationLog.setCreateTime(new Date());
+        operationLog.setReqIp(req.getRemoteAddr());
+        operationLog.setReqPort(req.getRemotePort());
+        operationLog.setReqUri(req.getRequestURI());
+        operationLog.setErrorMessage(e.getMessage());
+        operationLog.setParameter(req.getQueryString());
+        log.error(req.getRequestURL() + "<:=====:>" +
+                req.getMethod() + "<:=====:>" +
+                req.getQueryString() + "<:=====:>" +
+                e.getMessage());
+        e.printStackTrace();
+
+        ResponseBase responseBase = new ResponseBase<>();
+
+        if (e instanceof GlobalException) {
+            log.error(e.getClass().toString());
+            GlobalException globalException = (GlobalException) e;
+            Short errorCode = globalException.getErrorCode();
+            String message = globalException.getMessage();
+            operationLog.setErrorCode(errorCode);
+            operationLog.setErrorMessage(message);
+            operationLog.setUserId(globalException.getUserName() == null ? userId : globalException.getUserName());
+            if("/user/pcLogin".equals(req.getRequestURI())){
+                operationLog.setMenuName("登录");
+                operationLog.setContent("用户登录系统");
+            } else {
+                operationLog.setMenuName(globalException.getMenuName().split("\\-")[0]);
+                operationLog.setContent(globalException.getMenuName().split("\\-")[1]);
+            }
+
+            responseBase.setRetHead(errorCode, message);
+        } else if (e instanceof MethodArgumentNotValidException) {
+            log.error(e.getClass().toString());
+            List<ObjectError> allErrors = ((MethodArgumentNotValidException) e).getBindingResult()
+                    .getAllErrors();
+            if (!CollectionUtils.isEmpty(allErrors)) {
+                String errorMessage = allErrors.get(0).getDefaultMessage();
+                log.error(errorMessage);
+                responseBase.setRetHead(FAILURE.getIndex(), errorMessage);
+            }
+//            //获得所有错误提示码,将错误提示码拼接成字符串
+//            List<String> errorMessages = new ArrayList<>();
+//            allErrors.forEach(objectError -> {
+//                if (!errorMessages.contains(objectError.getDefaultMessage())) {
+//                    errorMessages.add(objectError.getDefaultMessage());
+//                }
+//                log.error(objectError.getDefaultMessage());
+//            });
+//            responseBase.setRetHead(FAILURE.getIndex(), Joiner.on(",").join(errorMessages));
+        } else if (e instanceof MissingServletRequestParameterException) {
+            log.error(e.getClass().toString());
+            responseBase.setRetHead(
+                    CommonEnum.PARAMETER_NOT_NULL.getIndex(),
+                    CommonEnum.PARAMETER_NOT_NULL.getValue());
+        } else if (e instanceof FileNotFoundException) {
+            log.error(e.getClass().toString());
+            responseBase.setRetHead(
+                    CommonEnum.FILE_NOT_FOUND.getIndex(),
+                    CommonEnum.FILE_NOT_FOUND.getValue());
+        } else if (e instanceof MaxUploadSizeExceededException) {
+            log.error(e.getClass().toString());
+            responseBase.setRetHead(
+                    CommonEnum.MAX_UPLOAD_SIZE_EXCEEDED.getIndex(),
+                    CommonEnum.MAX_UPLOAD_SIZE_EXCEEDED.getValue());
+        } else if (e instanceof MissingServletRequestPartException) {
+            log.error(e.getClass().toString());
+            responseBase.setRetHead(
+                    CommonEnum.FILE_NOT_NULL.getIndex(),
+                    CommonEnum.FILE_NOT_NULL.getValue());
+        } else if (e instanceof NumberFormatException) {
+            log.error(e.getClass().toString());
+            responseBase.setRetHead(
+                    CommonEnum.NUMBER_FORMAT.getIndex(),
+                    CommonEnum.NUMBER_FORMAT.getValue());
+        } else if (e instanceof MaxUploadSizeExceededException) {
+            log.error(e.getClass().toString());
+            responseBase.setRetHead(
+                    CommonEnum.TOO_BIG_A_DOCUMENT.getIndex(),
+                    CommonEnum.TOO_BIG_A_DOCUMENT.getValue());
+        } else if (e instanceof DataIntegrityViolationException) {
+            responseBase.setRetHead(
+                    CommonEnum.THE_CONTENT_IS_TOO_LARGE_TO_SAVE.getIndex(),
+                    CommonEnum.THE_CONTENT_IS_TOO_LARGE_TO_SAVE.getValue());
+        } else {
+            log.error(e.getClass().toString() + ":" + e.getMessage());
+            responseBase.setRetHead(
+                    CommonEnum.INTERNAL_ERROR.getIndex(),
+                    CommonEnum.INTERNAL_ERROR.getValue());
+        }
+
+        try {
+            if (!StringUtils.isEmpty(operationLog.getUserId())) {
+                logMapper.insert(operationLog);
+            }
+        } catch (Exception internalException) {
+            log.error(internalException.getMessage());
+        }
+
+        return new ResponseEntity<>(responseBase, HttpStatus.OK);
+    }
+}

+ 53 - 0
src/main/java/com/hywa/map/common/exception/GlobalException.java

@@ -0,0 +1,53 @@
+package com.hywa.map.common.exception;
+
+public class GlobalException extends RuntimeException {
+
+
+    private Short errorCode;
+
+    private String userName;
+    private String menuName;
+
+    public GlobalException(String errorMessage) {
+        super(errorMessage);
+    }
+
+    public GlobalException(Short errCode, String errorMessage) {
+        this(errorMessage);
+        this.setErrorCode(errCode);
+    }
+    public GlobalException(Short errCode, String errorMessage, String userName) {
+        this(errorMessage);
+        this.setErrorCode(errCode);
+        this.setUserName(userName);
+    }
+    public GlobalException(Short errCode, String errorMessage, String userName,String menuName) {
+        this(errorMessage);
+        this.setErrorCode(errCode);
+        this.setUserName(userName);
+        this.setMenuName(menuName);
+    }
+    public Short getErrorCode() {
+        return errorCode;
+    }
+
+    public void setErrorCode(Short errorCode) {
+        this.errorCode = errorCode;
+    }
+
+    public String getUserName() {
+        return userName;
+    }
+
+    public void setUserName(String userName) {
+        this.userName = userName;
+    }
+
+    public String getMenuName() {
+        return menuName;
+    }
+
+    public void setMenuName(String menuName) {
+        this.menuName = menuName;
+    }
+}

+ 72 - 0
src/main/java/com/hywa/map/common/log/AnnotationUtils.java

@@ -0,0 +1,72 @@
+package com.hywa.map.common.log;
+
+import javassist.ClassClassPath;
+import javassist.ClassPool;
+import javassist.CtClass;
+import javassist.CtMethod;
+import javassist.NotFoundException;
+import javassist.bytecode.AnnotationsAttribute;
+import javassist.bytecode.ConstPool;
+import javassist.bytecode.MethodInfo;
+import javassist.bytecode.annotation.Annotation;
+import javassist.bytecode.annotation.StringMemberValue;
+
+public class AnnotationUtils {
+
+    private static AnnotationUtils mInstance;
+
+    public AnnotationUtils() {
+    }
+
+    public static AnnotationUtils getInstance() {
+        if (mInstance == null) {
+            synchronized (AnnotationUtils.class) {
+                if (mInstance == null) {
+                    mInstance = new AnnotationUtils();
+                }
+            }
+        }
+        return mInstance;
+    }
+
+    public void setAnnotationFieldValue(String className, String methodName, String annoName,
+            String fieldName, String fieldValue) throws NotFoundException {
+        ClassPool classPool = ClassPool.getDefault();
+        ClassClassPath classClassPath = new ClassClassPath(this.getClass());
+        classPool.insertClassPath(classClassPath);
+        CtClass ctClass = classPool.get(className);
+        CtMethod ctMethod = ctClass.getDeclaredMethod(methodName);
+        MethodInfo methodInfo = ctMethod.getMethodInfo();
+        ConstPool constPool = methodInfo.getConstPool();
+        AnnotationsAttribute aa = (AnnotationsAttribute) methodInfo
+                .getAttribute(AnnotationsAttribute.visibleTag);
+        Annotation annotation = aa.getAnnotation(annoName);
+        if (annotation != null) {
+            annotation.addMemberValue(fieldName, new StringMemberValue(fieldValue, constPool));
+            aa.setAnnotation(annotation);
+            methodInfo.addAttribute(aa);
+        }
+
+    }
+
+    public String getAnnotationFieldValue(String className, String methodName, String annoName,
+            String fieldName)
+            throws NotFoundException {
+        ClassPool classPool = ClassPool.getDefault();
+        ClassClassPath classClassPath = new ClassClassPath(this.getClass());
+        classPool.insertClassPath(classClassPath);
+        CtClass ctClass = classPool.get(className);
+        CtMethod ctMethod = ctClass.getDeclaredMethod(methodName);
+        MethodInfo methodInfo = ctMethod.getMethodInfo();
+        AnnotationsAttribute aa = (AnnotationsAttribute) methodInfo
+                .getAttribute(AnnotationsAttribute.visibleTag);
+        String value = "";
+        if (aa != null) {
+            Annotation annotation = aa.getAnnotation(annoName);
+            if (annotation != null) {
+                value = ((StringMemberValue) annotation.getMemberValue(fieldName)).getValue();
+            }
+        }
+        return value;
+    }
+}

+ 18 - 0
src/main/java/com/hywa/map/common/log/Log.java

@@ -0,0 +1,18 @@
+package com.hywa.map.common.log;
+
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.METHOD)
+@Documented
+@Inherited
+public @interface Log {
+
+    String log() default "";
+}

+ 82 - 0
src/main/java/com/hywa/map/common/log/LogAspect.java

@@ -0,0 +1,82 @@
+package com.hywa.map.common.log;
+
+import static com.hywa.map.common.ConstantPool.SPLIT;
+import static com.hywa.map.common.enums.CommonEnum.SUCCESS;
+
+import com.hywa.map.common.utils.StringUtils;
+import com.hywa.map.common.utils.UUIDUtils;
+import com.hywa.map.config.interceptor.TokenManager;
+import com.hywa.map.config.interceptor.TokenModel;
+import com.hywa.map.dao.mapper.LogMapper;
+
+import java.util.Date;
+
+import javassist.NotFoundException;
+
+import javax.servlet.http.HttpServletRequest;
+
+import lombok.extern.slf4j.Slf4j;
+import org.aspectj.lang.JoinPoint;
+import org.aspectj.lang.annotation.AfterReturning;
+import org.aspectj.lang.annotation.Aspect;
+import org.aspectj.lang.annotation.Pointcut;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+import org.springframework.web.context.request.RequestContextHolder;
+import org.springframework.web.context.request.ServletRequestAttributes;
+
+@Slf4j
+@Aspect
+@Component
+public class LogAspect {
+
+    @Autowired
+    TokenManager tokenManager;
+    @Autowired
+    private LogMapper logMapper;
+
+    // 设置切点表达式
+    @Pointcut("execution(* com.hywa.map.controller..*(..))")
+    private void pointcut() {
+    }
+
+    //方法后置切面
+    //@After(value = "pointcut()")
+    @AfterReturning(value = "pointcut()")
+    public void after(JoinPoint joinPoint) throws NotFoundException {
+        String className = joinPoint.getTarget().getClass().getName();
+        String methodName = joinPoint.getSignature().getName();
+
+        String logStr = AnnotationUtils.getInstance()
+                .getAnnotationFieldValue(className, methodName,
+                        com.hywa.map.common.log.Log.class.getName(), "log");
+        if (StringUtils.isNotEmpty(logStr)) {
+            Date date = new Date();
+            HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder
+                    .getRequestAttributes()).getRequest();
+
+            String userId = null;
+            try {
+                TokenModel accessToken = tokenManager.getToken(request.getHeader("accessToken"));
+                userId = accessToken.getUserId().split(SPLIT)[1];
+            } catch (Exception internalException) {
+                try{
+                    userId = request.getSession().getAttribute("userId").toString();
+                }catch (Exception e){
+                    userId ="anonymous";
+                }
+            }
+            com.hywa.map.dao.entity.Log log = new com.hywa.map.dao.entity.Log();
+            log.setUserId(userId);
+            log.setId(UUIDUtils.randomUUID());
+            log.setReqUri(request.getRequestURI());
+            log.setCreateTime(date);
+            log.setMenuName(logStr.split("\\-")[0]);
+            log.setContent(logStr.split("\\-")[1]);
+            log.setReqPort(request.getRemotePort());
+            log.setErrorCode(SUCCESS.getIndex());
+            log.setReqIp(request.getRemoteAddr());
+            logMapper.insert(log);
+        }
+    }
+}

+ 30 - 0
src/main/java/com/hywa/map/common/log/LogUtils.java

@@ -0,0 +1,30 @@
+package com.hywa.map.common.log;
+
+import javassist.NotFoundException;
+
+public class LogUtils {
+
+    private static LogUtils mInstance;
+
+    private LogUtils() {
+    }
+
+    public static LogUtils getInstance() {
+        if (mInstance == null) {
+            synchronized (LogUtils.class) {
+                if (mInstance == null) {
+                    mInstance = new LogUtils();
+                }
+            }
+        }
+        return mInstance;
+    }
+
+    public void setLog(String logStr) throws NotFoundException {
+        String className = Thread.currentThread().getStackTrace()[2].getClassName();
+        String methodName = Thread.currentThread().getStackTrace()[2].getMethodName();
+        AnnotationUtils.getInstance()
+                .setAnnotationFieldValue(className, methodName, Log.class.getName(), "log",
+                        logStr);
+    }
+}

+ 29 - 0
src/main/java/com/hywa/map/common/param/PageBean.java

@@ -0,0 +1,29 @@
+package com.hywa.map.common.param;
+
+/**
+ * 分页接受参数公共类
+ * by yfw
+ * **/
+public class PageBean {
+	Integer page = 1;//默认显示当期第一页
+	Integer rows = 20;//默认每页显示20条数据
+	public PageBean(){
+	}
+	public PageBean(int page, int rows){
+		this.page=page;
+		this.rows=rows;
+	}
+	public Integer getPage() {
+		return page;
+	}
+	public void setPage(Integer page) {
+		this.page = page;
+	}
+	public Integer getRows() {
+		return rows;
+	}
+	public void setRows(Integer rows) {
+		this.rows = rows;
+	}
+
+}

+ 64 - 0
src/main/java/com/hywa/map/common/reverseSQL/CreateHtmlUtils.java

@@ -0,0 +1,64 @@
+package com.hywa.map.common.reverseSQL;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.util.List;
+
+
+/**
+ * @ClassName: CreateHtmlUtils  
+ * @Description: Java 根据模板创建 html
+ * @author 
+ * @date 2016422日 下午3:51:16
+ */
+public class CreateHtmlUtils {
+    
+    public static void main(String[] args) {
+        String filePath = "F://pkwork/boot/src/main/java/com/boot/common/utils/reverseSQL/template.html";
+       // String imagePath ="http://localhost:8080/ecp/upload/1461293787628/1461293787628.jpg";
+        String disrPath = "F://pkwork/boot/src/main/resources/templates/huwa";
+        String fileName = "lym";
+        MakeHtml(filePath,disrPath,fileName,null);
+    }
+    /**
+     * @Title: MakeHtml 
+     * @Description: 创建html
+     * @param    filePath 设定模板文件
+     * @param    disrPath  生成html的存放路径
+     * @param    fileName  生成html名字 
+     *  @param   list  替换的数据
+     * @return void    返回类型 
+     * @throws
+     */
+    public static void MakeHtml(String filePath,String disrPath,String fileName,List<String>list ){
+        try {
+           
+            System.out.print(filePath);
+            String templateContent = "";
+            FileInputStream fileinputstream = new FileInputStream(filePath);// 读取模板文件
+            int lenght = fileinputstream.available();
+            byte bytes[] = new byte[lenght];
+            fileinputstream.read(bytes);
+            fileinputstream.close();
+            templateContent = new String(bytes);
+            System.out.print(templateContent);
+            for (int i=0;i<list.size();i++){
+            	 templateContent = templateContent.replaceAll("#replace"+i, list.get(i));
+			}
+           
+            System.out.print(templateContent);
+            
+            String fileame = fileName + ".html";
+            fileame = disrPath+"/" + fileame;// 生成的html文件保存路径。
+            FileOutputStream fileoutputstream = new FileOutputStream(fileame);// 建立文件输出流
+            System.out.print("文件输出路径:");
+            System.out.print(fileame);
+            byte tag_bytes[] = templateContent.getBytes();
+            fileoutputstream.write(tag_bytes);
+            fileoutputstream.close();
+        } catch (Exception e) {
+            System.out.print(e.toString());
+        }
+    }
+    
+    
+}

+ 235 - 0
src/main/java/com/hywa/map/common/reverseSQL/GenEntityMappingUtils.java

@@ -0,0 +1,235 @@
+package com.hywa.map.common.reverseSQL;
+
+import java.sql.SQLException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+/**
+ * @description 逆向工程入口
+ * @author liuzhaohui
+ * @createtime 2018731日 上午10:43:12
+ */
+public class GenEntityMappingUtils {
+	protected SimpleDateFormat format =  new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");  
+	protected String[] colnames; // 列名数组  
+	protected String[] colTypes; //列名类型数组  
+	protected String[] colremarks; //列名描述备注  
+	protected Long[] colSizes; //列名大小数组  
+	protected String [] colisnull; //是否为空
+    protected static final String basePackage = "map";
+    protected String packageOutPath ="com.hywa."+basePackage;;//指定实体生成所在包的路径
+	protected String htmlAddress = "templates/hywa";//HTML //生成指定路径
+	protected String authorName = "hywa";//作者名字
+	protected String tablename = "sys_user";//表名  
+	protected String dbName= "meitan_smart_map";//数据库名字
+	protected static final String URL ="jdbc:mysql://127.0.0.1:3306";
+	protected static final String NAME = "root";  
+	protected static final String PASS = "123456";
+	protected static final String DRIVER ="com.mysql.jdbc.Driver";  
+
+    /** 
+     * 出口 
+     *
+     * @param args 
+     * @throws SQLException 
+     */  
+    public static void main(String[] args) throws SQLException {
+    	String[] tables = {
+    			"t_topic_info"};
+    	for (int i = 0; i < tables.length; i++) {
+    		new GenEntityMysql(tables[i]).generate();
+		}
+    	
+    }  
+	/** 
+     * 功能:获得列的数据类型 
+     * @param sqlType 
+     * @return 
+     */  
+    protected String sqlType2JavaType(String sqlType) {  
+          
+        if(sqlType.equalsIgnoreCase("bit")){  
+            return "boolean";  
+        }else if(sqlType.equalsIgnoreCase("tinyint")){  
+            return "byte";  
+        }else if(sqlType.equalsIgnoreCase("double")){  
+            return "Double";  
+        }else if(sqlType.equalsIgnoreCase("smallint")){  
+            return "short";  
+        }else if(sqlType.equalsIgnoreCase("int")){  
+            return "int";  
+        }else if(sqlType.equalsIgnoreCase("bigint")){  
+            return "long";  
+        }else if(sqlType.equalsIgnoreCase("float")){  
+            return "float";  
+        }else if(sqlType.equalsIgnoreCase("decimal") || sqlType.equalsIgnoreCase("numeric")   
+                || sqlType.equalsIgnoreCase("real") || sqlType.equalsIgnoreCase("money")   
+                || sqlType.equalsIgnoreCase("smallmoney")){  
+            return "BigDecimal";  
+        }else if(sqlType.equalsIgnoreCase("varchar") || sqlType.equalsIgnoreCase("char")   
+                || sqlType.equalsIgnoreCase("nvarchar") || sqlType.equalsIgnoreCase("nchar")   
+                || sqlType.equalsIgnoreCase("text") || sqlType.equalsIgnoreCase("tinytext")){  
+            return "String";  
+        }else if(sqlType.equalsIgnoreCase("datetime")||sqlType.equalsIgnoreCase("date")){  
+            return "Date";  
+        }else if(sqlType.equalsIgnoreCase("image")){  
+            return "Blod";  
+        }  
+     
+        return null;  
+    }  
+      
+	/**
+	 * 把第一个字母变为小写<br>
+	 * 如:<br>
+	 *     <code>str = "UserDao";</code><br>
+	 *     <code>return "userDao";</code>
+	 * @param str
+	 * @return
+	 */
+    protected String getLowercaseChar(String str){
+		return str.substring(0,1).toLowerCase()+str.substring(1);
+	}
+	/**
+	 * 显示信息
+	 * @param info
+	 */
+    protected void showInfo(String info){
+		System.out.println("创建文件:"+ info+ "成功!");
+	}
+
+	/**
+	 * 获取系统时间
+	 * @return
+	 */
+    protected static String getDate(){
+		SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
+		return simpleDateFormat.format(new Date());
+	}
+    
+    /** 
+     * 功能:将输入字符串的首字母改成大写 
+     * @param str 
+     * @return 
+     */  
+    protected String initcap(String str) {  
+        char[] ch = str.toCharArray();  
+        if(ch[0] >= 'a' && ch[0] <= 'z'){  
+            ch[0] = (char)(ch[0] - 32);  
+        }  
+        str=new String(ch);
+        while( str.indexOf("_")!=-1){
+   
+          String name=str.subSequence(str.indexOf("_")+1, str.indexOf("_")+2).toString();
+          str = str.replace( "_"+name, name.toUpperCase());
+        }
+        return str;  
+    } 
+
+    /** 
+     * 功能:生成实体类主体代码 
+     * @param colnames 
+     * @param colTypes 
+     * @param
+     * @return 
+     */  
+    protected String parse(String[] colnames, String[] colTypes, String[] colremarks) {  
+        StringBuffer sb = new StringBuffer();  
+        sb.append("package " + this.packageOutPath +"."+initcap(tablename).toLowerCase()+ ".entity"+";\r\n");
+        sb.append("import java.util.Date;\r\n");
+        sb.append("\r\n");  
+        //注释部分  
+        sb.append("   /**\r\n");  
+        sb.append("    * "+tablename+" 实体类 对应表名\r\n");  
+        sb.append("    * @create by "+format.format(new Date())+"\r\n");  
+        sb.append("    * @author "+this.authorName+"\r\n"); 
+        sb.append("    */ \r\n");  
+        //实体部分  
+        sb.append("public class " + initcap(tablename) +  " implements Serializable {\r\n");
+        sb.append("\r\n"); 
+        sb.append("\t private static final long serialVersionUID = 1L;\r\n");
+        processAllAttrs(sb);//属性  
+        processAllMethod(sb);//get set方法  
+        sb.append("}\r\n");    
+        return sb.toString();  
+    }  
+    
+    /** 
+     * 功能:生成所有属性 
+     * @param sb 
+     */  
+    private void processAllAttrs(StringBuffer sb) {  
+    	
+        for (int i = 0; i < colnames.length; i++) {  
+            //注释部分  
+            sb.append("   /**\r\n");  
+            sb.append("    * "+colremarks[i]+" \r\n");  
+            sb.append("    */ \r\n"); 
+            sb.append("\tprivate " + sqlType2JavaType(colTypes[i]) + " " + getLowercaseChar(initcap(colnames[i].toLowerCase())) + ";\r\n");  
+        }    
+    }  
+  
+    /** 
+     * 功能:生成所有方法 
+     * @param sb 
+     */  
+    private void processAllMethod(StringBuffer sb) {  
+        for (int i = 0; i < colnames.length; i++) {  
+            sb.append("\tpublic void set" + initcap(colnames[i].toLowerCase()) + "(" + sqlType2JavaType(colTypes[i]) + " " +   
+            		getLowercaseChar(initcap(colnames[i].toLowerCase())) + "){\r\n");  
+            sb.append("\tthis." + getLowercaseChar(initcap(colnames[i].toLowerCase())) + "=" + getLowercaseChar(initcap(colnames[i].toLowerCase())) + ";\r\n");  
+            sb.append("\t}\r\n");  
+            sb.append("\tpublic " + sqlType2JavaType(colTypes[i]) + " get" + initcap(colnames[i].toLowerCase()) + "(){\r\n");  
+            sb.append("\t\treturn " + getLowercaseChar(initcap(colnames[i].toLowerCase())) + ";\r\n");  
+            sb.append("\t}\r\n");  
+        }    
+    }  
+    
+    
+    // html 中 #replace2 位置替换
+    public StringBuffer replace2(){
+    	StringBuffer sbf = new StringBuffer(); 
+    	sbf.append("<th data-options=\"field:'id',width:80,hidden:'true'\">ID</th> \n"); 
+    	   for(int i = 0; i < colnames.length; i++){
+          	   if(!"id".equals(getLowercaseChar(initcap(colnames[i].toLowerCase())))){
+          		 sbf.append("\t\t\t\t<th data-options=\"field:'"+getLowercaseChar(initcap(colnames[i].toLowerCase()))+"',width:120\">"+colremarks[i]+"</th> \n"); 
+          	   }  
+    	   }
+    	return sbf;
+    }
+    // html 中 #replace3 位置替换
+    public StringBuffer replace3(){
+    	StringBuffer sbf = new StringBuffer();
+    	sbf.append("<input class=\"easyui-textbox\" type=\"hidden\" name=\"id\"/> \n"); 
+    	for(int i = 0; i < colnames.length; i++){
+    		if(!"id".equals(getLowercaseChar(initcap(colnames[i].toLowerCase())))){
+    			sbf.append("\t\t\t\t<tr align=\"center\"> \n"); 
+    			sbf.append("\t\t\t\t\t<td width=\"80\" align=\"right\">"+colremarks[i]+":</td> \n");
+    			sbf.append("\t\t\t\t\t<td><input");
+    		
+    			if(colTypes[i].equalsIgnoreCase("decimal") || colTypes[i].equalsIgnoreCase("numeric")   || colTypes[i].equalsIgnoreCase("real") || colTypes[i].equalsIgnoreCase("money")   || colTypes[i].equalsIgnoreCase("smallmoney")  || colTypes[i].equalsIgnoreCase("int") || colTypes[i].equalsIgnoreCase("double")|| colTypes[i].equalsIgnoreCase("long")|| colTypes[i].equalsIgnoreCase("float")){
+    				sbf.append(" class=\"easyui-numberbox\" type=\"text\"");
+    				
+    			}else if(colTypes[i].equalsIgnoreCase("datetime")||colTypes[i].equalsIgnoreCase("date")){
+    				sbf.append(" class=\"easyui-datebox\" type=\"text\"");
+    			}else{  
+    	        	sbf.append(" class=\"easyui-textbox\" type=\"text\"");
+    	        }
+    			sbf.append("name=\""+getLowercaseChar(initcap(colnames[i].toLowerCase()))+"\""); 
+    			//validType="length[0,3]"
+    			if("NO".equals(colisnull[i])){
+    				sbf.append(" data-options=\"required:true\"");
+    			}
+    			
+    			if(colSizes[i]!=0){
+    				sbf.append(" validType=\"length[0,"+colSizes[i]+"]\"");
+    				
+    			}
+    			sbf.append("/></td> \n");
+    			
+    			sbf.append("\t\t\t\t</tr> \n"); 
+    		}  
+    	}
+    	return sbf;
+    }
+
+}

+ 815 - 0
src/main/java/com/hywa/map/common/reverseSQL/GenEntityMysql.java

@@ -0,0 +1,815 @@
+package com.hywa.map.common.reverseSQL;
+
+
+import com.hywa.map.common.utils.StringUtils;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+
+/**
+ * @description 逆向工程工具类
+ * @author liuzhaohui
+ * @createtime 2018731日 上午10:43:30
+ */
+public class GenEntityMysql extends GenEntityMappingUtils{  
+	
+	
+	public GenEntityMysql(String tableName){
+		super.tablename=tableName;
+	}
+	public GenEntityMysql(){}
+	
+	
+    /***
+     * 生成对应代码
+     * controller层
+     * entity 实体层
+     * service 层
+     * serviceImp层
+     * mapper 接口层(用的mybatis)
+     * mapper .xml 层 (用的mybatis)
+     * jsp 层(暂时不写)
+     * by yfw 
+     * @throws SQLException 
+     * */
+    public  void generate() throws SQLException{
+    	//entity 实体层 生成
+    	 createEntityMysql();
+    	// * mapper 接口层(用的mybatis)//mapper .xml 层 (用的mybatis)
+    	 createMapperInterface();
+    	//service 层 接口
+    	 createServiceInterface();
+    	//serviceImpl 实现
+    	 createServiceImpl();
+    	//controller 层
+    	 createController();
+    	 //web html 层
+    	 //createWebHtml();
+
+    }
+    
+    
+    /**
+     * controller 层 
+     * 单表简单 增 删 改 查 实现
+     * 
+     * **/
+    public void createController(){
+ 	     try {  
+              File directory = new File("");  
+              //String path=this.getClass().getResource("").getPath();  
+              String outputPath = directory.getAbsolutePath()+ "/src/main/java/"+ packageOutPath.replace('.', '/')+"/"+initcap(tablename).toLowerCase()+"/controller/"+initcap(tablename)+ "Controller.java";  
+              File file3 = new File(directory.getAbsolutePath()+ "/src/main/java/"+ packageOutPath.replace('.', '/')+"/"+initcap(tablename).toLowerCase()+"/controller");
+              if (file3.mkdir()) {
+                  System.out.println("多级层文件夹下文件创建成功!创建了的文件为:" + file3.getAbsolutePath() + ",上级文件为:" + file3.getParent());
+              }
+              FileWriter fw = new FileWriter(outputPath);  
+              PrintWriter pw = new PrintWriter(fw);  
+              pw.println(controller());  
+              pw.flush();  
+              pw.close();  
+          } catch (IOException e) {  
+              e.printStackTrace();  
+          }  
+    }
+    /** 
+     * serviceImpl
+     * 功能:生成serviceImpl 接口 主体代码 
+     * 包括简单的 单表增删改查
+     * @return 
+     */  
+    private String controller() {  
+        StringBuffer sb = new StringBuffer();  
+        sb.append("package " + this.packageOutPath + "."+initcap(tablename).toLowerCase()+".controller;\r\n");  
+        //判断是否导入工具包  
+		sb.append("import java.util.HashMap;\r\n");
+		sb.append("import java.util.List;\r\n");
+		sb.append("import java.util.Map;\r\n");
+		sb.append("import org.springframework.beans.factory.annotation.Autowired;\r\n");
+		sb.append("import org.springframework.stereotype.Controller;\r\n");
+		sb.append("import org.springframework.util.StringUtils;\r\n");
+		sb.append("import org.springframework.web.bind.annotation.RequestMapping;\r\n");
+		sb.append("import org.springframework.web.bind.annotation.RequestMethod;\r\n");
+		sb.append("import org.springframework.web.bind.annotation.ResponseBody;\r\n");
+		sb.append("import "+this.packageOutPath+"."+initcap(tablename).toLowerCase()+".entity."+initcap(tablename)+";\r\n");
+		sb.append("import "+this.packageOutPath+"."+initcap(tablename).toLowerCase()+".service."+initcap(tablename)+"Service;\r\n");
+        sb.append("\r\n");  
+        //注释部分  
+        sb.append("/**\r\n"); 
+        sb.append("* "+tablename+"  对应Controller 实现类\r\n");  
+        sb.append("* @create by "+format.format(new Date())+"\r\n");
+        sb.append("* @author "+this.authorName+"\r\n"); 
+        sb.append("*/ \r\n");  
+        //贴注解部分
+        sb.append("@Controller \r\n");  
+        sb.append("@RequestMapping(\"/"+StringUtils.firstCharToLowerCase(initcap(tablename))+"\") \r\n");
+        sb.append("public class " + initcap(tablename) +  "Controller {\r\n");
+        sb.append("\r\n"); 
+        
+       // 简单接口部分属性  
+        processController(sb);
+        sb.append("}\r\n");    
+        return sb.toString();  
+    } 
+    
+    
+    
+    
+    /**
+     * 具体简单实现部分
+     * 
+    **/
+    private void processController(StringBuffer sb) {  
+        	sb.append("\t@Autowired \r\n");
+        	sb.append("\tprivate "+initcap(tablename)+"Service "+initcap(tablename).toLowerCase()+"Service; \r\n");
+
+            // 查询接口list
+            sb.append("\r\n");
+            sb.append("   /**\r\n"); 
+            sb.append("    * @description  这是一个 查所有 列表的 方法  Dao 层已经生成规则的 条件查询 如需要加条件,请自己按规则 DIV \r\n");  
+            sb.append("    */ \r\n");    
+            sb.append("\t@ResponseBody\r\n");
+            sb.append("\t@RequestMapping(value=\"/search\",method = RequestMethod.GET) \r\n");
+            sb.append("\tpublic AjaxJson search(PageBean pageBean){  \r\n"); 
+            sb.append("\t\t Map<String,Object> equal =new HashMap<String, Object>();//等于查询条件 \r\n");
+            sb.append("\t\t Map<String,Object> like =new HashMap<String, Object>();//模糊查询条件 \r\n");
+            sb.append("\t\t String order =null;//模糊查询条件 \r\n");
+            sb.append("\t\tList<Map<String, Object>> list= "+initcap(tablename).toLowerCase()+"Service.search(reMap(),equal,order,getPageBean(pageBean),like); \r\n"); 
+            sb.append("\t\tint total= "+initcap(tablename).toLowerCase()+"Service.searchTotals(equal,like); \r\n"); 
+            sb.append("\t\treturn fillingReturnBody(pageBean,list,total); \r\n");
+            sb.append("\t}\r\n"); 
+
+            
+            //查看 
+            sb.append("   /**\r\n"); 
+            sb.append("    * @description  "+initcap(tablename) +" 根据id 查看信息  \r\n");  
+            sb.append("    * @return  \r\n"); 
+            sb.append("    */ \r\n");  
+            sb.append("\t@ResponseBody\r\n");
+            sb.append("\t@RequestMapping(value=\"/select\",method = RequestMethod.GET) \r\n");
+            sb.append("\tpublic AjaxJson select(String id){  \r\n"); 
+            sb.append("\t\tMap<String,Object> map ="+initcap(tablename).toLowerCase()+"Service.selectById(id); \r\n"); 
+            sb.append("\r\n"); 
+            sb.append("\t\treturn fillingReturnBody(map);\r\n");
+            sb.append("\t}\r\n"); 
+            
+            
+          //新增 实现
+            sb.append("   /**\r\n"); 
+            sb.append("    * @description  "+initcap(tablename) +" 新增 修改 根据 id 判断 单表  考虑通用性,只封装了id 其他创建时间 创建人,自己根据表单需要来做调整 \r\n");  
+            sb.append("    */ \r\n"); 
+            sb.append("\t@ResponseBody\r\n");
+            sb.append("\t@RequestMapping(value=\"/save\",method = RequestMethod.POST) \r\n");
+            sb.append("\tpublic AjaxJson saveOrUpdate( "+initcap(tablename)+" "+initcap(tablename).toLowerCase()+"){  \r\n"); 
+            sb.append("\r\n"); 
+            sb.append("\tint num=0;//0失败1成功\r\n"); 
+            sb.append("\t\t if(StringUtils.isEmpty("+initcap(tablename).toLowerCase()+")){\r\n");
+            sb.append("\t\t\treturn new AjaxJson( AjaxJson.FAILURE,AjaxJson.MSGNULL);\r\n");   
+            sb.append("\t\t }         \r\n");
+            sb.append("\t\tif(StringUtils.isEmpty("+initcap(tablename).toLowerCase()+".getId())){\r\n");
+            sb.append("\t\t\t"+initcap(tablename).toLowerCase()+".setId(UUIDUtils.newGUID());\r\n");//生成id的工具类 
+            sb.append("\t\t\tnum="+initcap(tablename).toLowerCase()+"Service.add("+initcap(tablename).toLowerCase()+");//新增\r\n");
+            sb.append("\t\t}else{\r\n");
+            sb.append("\t\t\tnum="+initcap(tablename).toLowerCase()+"Service.update("+initcap(tablename).toLowerCase()+");//修改\r\n");
+            sb.append("\t\t}\r\n");
+            sb.append("\t\tif(num==1){\r\n");
+            sb.append("\t\t\treturn new AjaxJson(AjaxJson.SUCCESS,AjaxJson.MSGSUCCESS);  //成功返回\r\n");
+            sb.append("\t\t}\r\n");
+            sb.append("\t\treturn new AjaxJson(AjaxJson.FAILURE,AjaxJson.MSGFAILURE);  //失败返回\r\n");
+            sb.append("\t}\r\n"); 
+           
+            /**
+        	 * 物理删除
+        	 */
+            sb.append("   /**\r\n"); 
+            sb.append("    * @description  "+initcap(tablename) +" 删除 根据 id 判断 DAO层 有批量逻辑/物理删除  有需要自己div\r\n");  
+            sb.append("    * @return AjaxJson \r\n"); 
+            sb.append("    */ \r\n"); 
+            sb.append("\t@ResponseBody\r\n");
+            sb.append("\t@RequestMapping(value=\"/delete\",method = RequestMethod.GET) \r\n");
+            sb.append("\tpublic AjaxJson delete(String id){  \r\n"); 
+            sb.append("\r\n"); 
+            sb.append("\t\t if(StringUtils.isEmpty(id)){\r\n");
+            sb.append("\t\t\treturn new AjaxJson( AjaxJson.FAILURE,AjaxJson.MSGNULL);\r\n");   
+            sb.append("\t\t }         \r\n");
+            sb.append("\t\t\tfinal int num="+initcap(tablename).toLowerCase()+"Service.put(id);//删除\r\n");
+            sb.append("\t\tif(num==1){\r\n");
+            sb.append("\t\t\treturn new AjaxJson(AjaxJson.SUCCESS,AjaxJson.MSGSUCCESS);  //成功返回\r\n");
+            sb.append("\t\t}\r\n");
+            sb.append("\t\treturn new AjaxJson(AjaxJson.FAILURE,AjaxJson.MSGFAILURE);  //失败返回\r\n");
+            sb.append("\t}\r\n"); 
+        	
+            
+            /**
+             * 返回字段map封装
+             * */
+            sb.append("   /**\r\n"); 
+            sb.append("    * @description  返回字段map封装 \r\n");  
+            sb.append("    * @return Map \r\n"); 
+            sb.append("    */ \r\n"); 
+            sb.append("\tprivate Map<String,Object> reMap(){  \r\n"); 
+            sb.append("\r\n"); 
+            sb.append("\t\t Map<String,Object> reField =new HashMap<String, Object>();//返回字段 \r\n");
+            for(int i = 0; i < colnames.length; i++){
+          	   sb.append("\t\t\treField.put(\""+getLowercaseChar(initcap(colnames[i].toLowerCase()))+"\",\""+getLowercaseChar(initcap(colnames[i].toLowerCase()))+"\");//"+colremarks[i]+" \n"); 
+             }
+            sb.append("\t\t\t return reField;//返回字段 \r\n");
+            sb.append("\t}\r\n"); 
+            
+            
+    }
+            
+      
+    /**
+     * serviceimpl 接口层实现 
+     * 单表简单 增 删 改 查 实现
+     * 
+     * **/
+    public void createServiceImpl(){
+ 	     try {  
+              File directory = new File("");  
+              //String path=this.getClass().getResource("").getPath();  
+              String outputPath = directory.getAbsolutePath()+ "/src/main/java/"+ packageOutPath.replace('.', '/')+"/"+initcap(tablename).toLowerCase()+"/service/impl/"+initcap(tablename)+ "ServiceImpl.java";  
+              File file3 = new File(directory.getAbsolutePath()+ "/src/main/java/"+ packageOutPath.replace('.', '/')+"/"+initcap(tablename).toLowerCase()+"/service/impl");
+              if (file3.mkdir()) {
+                  System.out.println("多级层文件夹下文件创建成功!创建了的文件为:" + file3.getAbsolutePath() + ",上级文件为:" + file3.getParent());
+              }
+              FileWriter fw = new FileWriter(outputPath);  
+              PrintWriter pw = new PrintWriter(fw);  
+              pw.println(serviceImpl());  
+              pw.flush();  
+              pw.close();  
+          } catch (IOException e) {  
+              e.printStackTrace();  
+          }  
+    }
+    /** 
+     * serviceImpl
+     * 功能:生成serviceImpl 接口 主体代码 
+     * 包括简单的 单表增删改查
+     * @return 
+     */  
+    private String serviceImpl() {  
+        StringBuffer sb = new StringBuffer();  
+        sb.append("package " + this.packageOutPath + "."+initcap(tablename).toLowerCase()+".service.impl;\r\n");  
+        //判断是否导入工具包  
+        sb.append("import java.util.List;\r\n");
+		sb.append("import java.util.Map;\r\n");
+		sb.append("import org.springframework.beans.factory.annotation.Autowired;\r\n");
+		sb.append("import org.springframework.stereotype.Service;\r\n");
+		sb.append("import org.springframework.transaction.annotation.Transactional;\r\n");
+		sb.append("import "+this.packageOutPath+"."+initcap(tablename).toLowerCase()+".mapper."+initcap(tablename)+"Mapper;\r\n");
+		sb.append("import "+this.packageOutPath+"."+initcap(tablename).toLowerCase()+".service."+initcap(tablename)+"Service;\r\n");
+        sb.append("\r\n");  
+        //注释部分  
+        sb.append("/**\r\n"); 
+        sb.append("* "+tablename+"  对应ServiceImpl 实现类\r\n");  
+        sb.append("* @create by "+format.format(new Date())+"\r\n");
+        sb.append("* @author "+this.authorName+"\r\n"); 
+        sb.append("*/ \r\n");  
+        //贴注解部分
+        sb.append("@Service \r\n");  
+        sb.append("public class " + initcap(tablename) +  "ServiceImpl implements "+ initcap(tablename) + "Service{\r\n");
+        sb.append("\r\n"); 
+       // 简单接口部分属性  
+        processServiceIpml(sb);
+        sb.append("}\r\n");    
+        return sb.toString();  
+    }  
+    
+    
+    /**
+     * 具体简单接口部分
+     * 
+    **/
+    private void processServiceIpml(StringBuffer sb) {  
+        	sb.append("\t@Autowired \r\n");
+        	sb.append("\tprivate "+initcap(tablename)+"Mapper "+initcap(tablename).toLowerCase()+"Mapper; \r\n");
+        	
+    		//查询接口
+ 	   	   sb.append("\r\n");
+           sb.append("\t@Override \r\n");
+ 	       sb.append("\tpublic List<Map<String, Object>> search( Map<String,Object> reField, Map<String,Object> equal,String order,PageBean limit ,Map<String,Object> like ){  \r\n\n");  
+ 	       sb.append(" \t \t  return "+initcap(tablename).toLowerCase()+"Mapper.search(reField,equal,order,limit,like);\r\n"); 
+ 	       sb.append("\t}  \r\n");  
+		   
+
+ 			//查询总条数接口
+ 	   	   sb.append("\r\n");  
+ 	       sb.append("\tpublic int searchTotals( Map<String,Object> equal,Map<String,Object> like ){  \r\n\n");  
+ 	       sb.append(" \t \t  return "+initcap(tablename).toLowerCase()+"Mapper.searchTotals(equal,like);\r\n"); 
+ 	       sb.append("\t}  \r\n");  
+ 		   
+
+	   		//新增 接口
+       	   sb.append("\r\n");
+           sb.append("\tpublic int add(BaseEntity "+initcap(tablename).toLowerCase()+"){ \r\n");  
+           sb.append("\t\tint i= "+initcap(tablename).toLowerCase()+"Mapper.add("+initcap(tablename).toLowerCase()+");\r\n");
+ 	       sb.append("\t\tif(i<1){\r\n");
+ 	       sb.append("\t\t\t throw new GlobalException(EnumSet.FAILURE);        \r\n");
+ 	       sb.append("\t\t }\r\n");
+ 	       sb.append(" \t\treturn 1;\r\n"); 
+ 	       sb.append("\t}  \r\n");  
+
+ 	           
+           //修改 接口
+           sb.append("\r\n");
+          sb.append("\t@Transactional\r\n");
+           sb.append("\tpublic int update(BaseEntity "+initcap(tablename).toLowerCase()+"){  \r\n");  
+           sb.append("\t\tint i= "+initcap(tablename).toLowerCase()+"Mapper.update("+initcap(tablename).toLowerCase()+");\r\n");
+ 	       sb.append("\t\tif(i<1){\r\n");
+ 	       sb.append("\t\t\t throw new GlobalException(EnumSet.FAILURE);        \r\n");
+ 	       sb.append("\t\t }\r\n");
+ 	       sb.append(" \t\treturn 1;\r\n"); 
+ 	       sb.append("\t}  \r\n");  
+ 	           
+           // 删除接口
+           sb.append("\r\n");
+           sb.append("\tpublic int put(String id){  \r\n");    
+           sb.append("\t\tint i= "+initcap(tablename).toLowerCase()+"Mapper.put(id);\r\n");
+ 	       sb.append("\t\tif(i<1){\r\n");
+ 	       sb.append("\t\t\t throw new GlobalException(EnumSet.FAILURE);        \r\n");
+ 	       sb.append("\t\t }\r\n");
+ 	       sb.append(" \t\treturn 1;\r\n"); 
+ 	       sb.append("\t}  \r\n");  
+ 	           
+           // 删除接口
+           sb.append("\r\n");  
+           sb.append("\tpublic int delete(String id){  \r\n"); 
+           sb.append("\t\tint i= "+initcap(tablename).toLowerCase()+"Mapper.delete(id);\r\n");
+ 	       sb.append("\t\tif(i<1){\r\n");
+ 	       sb.append("\t\t\t throw new GlobalException(EnumSet.FAILURE);        \r\n");
+ 	       sb.append("\t\t }\r\n");
+ 	       sb.append(" \t\treturn 1;\r\n"); 
+ 	       sb.append("\t}  \r\n");
+ 	        
+           // 查询接口 根据id 来查询
+           sb.append("\r\n");
+           sb.append("\tpublic Map<String,Object> selectById(String id){  \r\n");  
+           sb.append(" \t\treturn "+initcap(tablename).toLowerCase()+"Mapper.selectById(id);\r\n"); 
+ 	       sb.append("\t}  \r\n");
+     
+        	
+    }  
+    /**
+     * service 接口层 
+     * 单表简单 增 删 改 查 接口
+     * 
+     * **/
+    public void createServiceInterface(){
+ 	     try {  
+              File directory = new File("");  
+              String outputPath = directory.getAbsolutePath()+ "/src/main/java/"+ packageOutPath.replace('.', '/')+"/"+initcap(tablename).toLowerCase()+"/service/"+"/"+initcap(tablename)+ "Service.java";  
+              File file3 = new File(directory.getAbsolutePath()+ "/src/main/java/"+ packageOutPath.replace('.', '/')+"/"+initcap(tablename).toLowerCase()+"/service");
+              if (file3.mkdir()) {
+                  System.out.println("多级层文件夹下文件创建成功!创建了的文件为:" + file3.getAbsolutePath() + ",上级文件为:" + file3.getParent());
+              }
+              FileWriter fw = new FileWriter(outputPath);  
+              PrintWriter pw = new PrintWriter(fw);  
+              pw.println(serviceInterface());  
+              pw.flush();  
+              pw.close();  
+          } catch (IOException e) {  
+              e.printStackTrace();  
+          }  
+    }
+    /** 
+     * 
+     * serviceInterface
+     * 功能:生成service 接口 主体代码 
+     * 包括简单的 单表增删改查
+     * @return 
+     */  
+    private String serviceInterface() {  
+        StringBuffer sb = new StringBuffer();  
+        sb.append("package " + this.packageOutPath + "."+initcap(tablename).toLowerCase()+".service;\r\n");
+        sb.append("\r\n");  
+        //注释部分  
+        sb.append("/**\r\n"); 
+        sb.append("* "+tablename+"  对应ServiceInterface 接口类\r\n");  
+        sb.append("* @create by "+format.format(new Date())+"\r\n");
+        sb.append("* @author "+this.authorName+"\r\n"); 
+        sb.append("*/ \r\n");  
+        //类部部分  
+        sb.append("public interface " + initcap(tablename) +  "Service {\r\n");
+        sb.append("\r\n"); 
+        sb.append("}\r\n");    
+        return sb.toString();  
+    }  
+
+    
+    
+    
+    
+   /**
+    * mapper 接口层(用的mybatis)
+    * 单表简单 增 删 改 查 接口
+    * 
+    * **/
+   public void createMapperInterface(){
+	     try {  
+             File directory = new File("");  
+             String outputPath = directory.getAbsolutePath()+ "/src/main/java/"+ packageOutPath.replace('.', '/')+"/"+initcap(tablename).toLowerCase()+"/mapper/"+"/"+initcap(tablename)+ "Mapper.java";  
+            // String outputPath1 = directory.getAbsolutePath()+ "/src/main/java/"+ packageOutPath.replace('.', '/')+"/"+initcap(tablename).toLowerCase()+"/mapper/"+"/"+initcap(tablename)+ "Mapper.xml";  
+             File file3 = new File(directory.getAbsolutePath()+ "/src/main/java/"+ packageOutPath.replace('.', '/')+"/"+initcap(tablename).toLowerCase()+"/mapper");
+             if (file3.mkdir()) {
+                 System.out.println("多级层文件夹下文件创建成功!创建了的文件为:" + file3.getAbsolutePath() + ",上级文件为:" + file3.getParent());
+             }
+             FileWriter fw = new FileWriter(outputPath);  
+           //  FileWriter fw1 = new FileWriter(outputPath1);  
+           //  PrintWriter pw1 = new PrintWriter(fw1);  
+            // pw1.println(mapperXml());  //XML
+            // pw1.flush();  
+            // pw1.close();  
+             PrintWriter pw = new PrintWriter(fw);  
+             pw.println(mapperInterface());  //接口
+             pw.flush();  
+             pw.close();  
+             createMapperXml();
+         } catch (IOException e) {  
+             e.printStackTrace();  
+         }  
+   }
+   
+   
+   /**
+    * mapper 接口层(用的mybatis)
+    * 单表简单 增 删 改 查 接口
+    * 
+    * **/
+   public void createMapperXml(){
+	     try {  
+             File directory = new File("");  
+             String outputPath1 = directory.getAbsolutePath()+ "/src/main/resources/com/hywa/"+GenEntityMappingUtils.basePackage+"/dao/mapper"+initcap(tablename).toLowerCase()+"/"+initcap(tablename)+ "Mapper.xml";
+             File file3 = new File(directory.getAbsolutePath()+ "/src/main/resources/com/hywa/"+GenEntityMappingUtils.basePackage+"/dao/mapper"+initcap(tablename).toLowerCase());
+             if (file3.mkdir()) {
+                 System.out.println("多级层文件夹下文件创建成功!创建了的文件为:" + file3.getAbsolutePath() + ",上级文件为:" + file3.getParent());
+             }
+             FileWriter fw1 = new FileWriter(outputPath1);  
+             PrintWriter pw1 = new PrintWriter(fw1);  
+             pw1.println(mapperXml());
+             pw1.flush();  
+             pw1.close(); 
+         } catch (IOException e) {  
+             e.printStackTrace();  
+         }  
+   }
+   
+
+   /** 
+    * 
+    * MapperInterface 实现祖始类
+    * 功能:生成mapper 接口 主体代码 
+    * 包括简单的 单表增删改查
+    * @return 
+    */  
+   private String mapperInterface() {  
+       StringBuffer sb = new StringBuffer();  
+       sb.append("package " + this.packageOutPath + "."+initcap(tablename).toLowerCase()+".mapper;\r\n");  
+       sb.append("import org.apache.ibatis.annotations.Mapper;\r\n");
+      // sb.append("import "+this.packageOutPath+"."+initcap(tablename).toLowerCase()+".entity."+initcap(tablename)+";\r\n");
+       sb.append("\r\n");  
+       //注释部分  
+       sb.append("/**\r\n"); 
+       sb.append("* "+tablename+"  对应mapperInterface 接口类\r\n");  
+       sb.append("* @create by "+format.format(new Date())+"\r\n");
+       sb.append("* @author "+this.authorName+"\r\n"); 
+       sb.append("*/ \r\n");  
+       //贴注解部分
+       sb.append("@Mapper \r\n");  
+       //类部部分  
+       sb.append("public interface " + initcap(tablename) +  "Mapper {\r\n");
+       sb.append("\r\n");    
+      // 简单接口部分属性  
+       //processInterface(sb);
+       sb.append("}\r\n");    
+       return sb.toString();  
+   }  
+   /** 
+    * 
+    * MapperInterface
+    * 功能:生成mapper 接口 主体代码 
+    * 包括简单的 单表增删改查
+    * @return 
+    */  
+   private String mapperXml() {  
+	   StringBuffer sb = new StringBuffer();  
+	   sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\r\n");  
+	   //判断是否导入工具包  
+	   sb.append("<!DOCTYPE mapper PUBLIC \"-//mybatis.org//DTD Mapper 3.0//EN\" \"http://mybatis.org/dtd/mybatis-3-mapper.dtd\" >\r\n");  
+	   sb.append("<mapper namespace=\""+packageOutPath+"."+"dao"+".mapper."+initcap(tablename)+ "Mapper\" >\r\n");
+	   processXml(sb);
+	   sb.append("</mapper>\r\n");    
+	   return sb.toString();  
+   }  
+
+   /**
+    * 具体简单接口部分
+    * 
+   **/
+   private void processXml(StringBuffer sb) {  
+	  
+	   
+	   //根据id查询  返回一个对象值  
+	   sb.append("\r\n");
+	   sb.append("\t<!-- 根据id查询 "+tablename+" 返回一个map 返回字段字段根据 接口传来的字段-->\r\n");
+	   sb.append("\t<select id=\"selectById\" resultType=\"java.util.HashMap\">\r\n");
+	   sb.append("\t\tSELECT \r\n");
+	   for (int i = 0; i < colnames.length; i++) { 
+		   if(!"id".equals(colnames[i].toLowerCase())){
+			   sb.append("\t\t\tA."+colnames[i]+" AS " +getLowercaseChar(initcap(colnames[i].toLowerCase()))+",\r\n"); 	   
+		   }
+       } 
+	   sb.append("\t\tA.id AS id\r\n");	
+	   sb.append("\t\tFROM \r\n");
+	   sb.append("\t\t\t"+tablename.toLowerCase()+" A \r\n");
+	   sb.append("\t\tWHERE \r\n");
+	   sb.append("\t\t\tA.id=#{id} \r\n");
+	   sb.append("\t\t</select> \r\n");
+	 
+	   
+	   
+	   
+	   //根据map 条件查询  返回一个list
+	   sb.append("\r\n");
+	   sb.append("\t<!-- 根据  条件 查询单表  分页、模糊、等于、排序、返回字段 返回一个list -->\r\n");
+	   sb.append("\t<select id=\"search\" resultType=\"java.util.HashMap\" >\r\n");
+	   sb.append("\t\tSELECT \r\n");
+   
+	   for (int i = 0; i < colnames.length; i++) { 
+		   if(!"id".equals(colnames[i].toLowerCase())){
+		
+			   if(colTypes[i].equalsIgnoreCase("varchar") || colTypes[i].equalsIgnoreCase("char")   
+		                || colTypes[i].equalsIgnoreCase("nvarchar") || colTypes[i].equalsIgnoreCase("nchar")   
+		                || colTypes[i].equalsIgnoreCase("text") || colTypes[i].equalsIgnoreCase("tinytext")){
+			    	  sb.append("\t\t\t<if test=\"reField."+getLowercaseChar(initcap(colnames[i].toLowerCase()))+"!= null and reField."+getLowercaseChar(initcap(colnames[i].toLowerCase()))+"!=''\"> \r\n"); 
+			    	    
+			      }else{
+			    	  sb.append("\t\t\t<if test=\"reField."+getLowercaseChar(initcap(colnames[i].toLowerCase()))+"!= null\"> \r\n"); 
+			      }
+			   sb.append("\t\t\tA."+colnames[i]+" AS " +getLowercaseChar(initcap(colnames[i].toLowerCase()))+",\r\n");  
+			   sb.append("\t\t</if>\r\n");		   
+		   }
+       } 
+	   sb.append("\t\tid\r\n");	
+	   sb.append("\t\tFROM \r\n");
+	   sb.append("\t\t\t"+tablename.toLowerCase()+" A \r\n");
+	   sb.append("\t\tWHERE  1=1 \r\n");
+	   for(int i = 0; i < colnames.length; i++){
+		   sb.append("\t\t\t<if test=\"equal."+getLowercaseChar(initcap(colnames[i].toLowerCase()))+"!= null and equal."+getLowercaseChar(initcap(colnames[i].toLowerCase()))+"!= ''\"> \r\n");
+		   sb.append("\t\t\t\tAND A."+colnames[i]+"=#{equal."+getLowercaseChar(initcap(colnames[i].toLowerCase()))+"} \r\n");
+		   sb.append("\t\t\t</if> \r\n");
+	   }
+	   for(int i = 0; i < colnames.length; i++){
+		   sb.append("\t\t\t<if test=\"like."+getLowercaseChar(initcap(colnames[i].toLowerCase()))+"!= null and like."+getLowercaseChar(initcap(colnames[i].toLowerCase()))+"!= ''\"> \r\n");
+		   sb.append("\t\t\t\tAND A."+colnames[i]+" LIKE concat(concat('%',#{like."+getLowercaseChar(initcap(colnames[i].toLowerCase()))+"},'%')) \r\n");
+		   sb.append("\t\t\t</if> \r\n");
+	   }
+	   sb.append("\t\t\t<if test=\"order!= null and order!= ''\"> \r\n");
+	    
+	   sb.append("\t\t\t\t order by ${order} desc \r\n");
+	   sb.append("\t\t\t</if> \r\n");
+	   
+	   sb.append("\t\t\t<if test=\"limit.page>-1  \"> \r\n");
+	   sb.append("\t\t\t\t<if test=\"limit.rows>-1\"> \r\n");
+	   sb.append("\t\t\t\t\t LIMIT #{limit.page},#{limit.rows} \r\n");
+	   sb.append("\t\t\t\t</if> \r\n");
+	   sb.append("\t\t\t</if> \r\n");
+	   sb.append("\t\t</select> \r\n");
+	   
+	   
+	   
+	   
+	   //根据map 条件查询  返回一个总条数
+	   sb.append("\r\n");
+	   sb.append("\t<!-- 根据  条件 查询单表  分页、模糊、等于、排序、返回字段 返回一个list -->\r\n");
+	   sb.append("\t<select id=\"searchTotals\" resultType=\"java.lang.Integer\" >\r\n");
+	   sb.append("\t\tSELECT \r\n");
+	    
+	   sb.append("\t\tcount(*) \r\n");
+	   
+	   sb.append("\t\tFROM \r\n");
+	   sb.append("\t\t\t"+tablename.toLowerCase()+" A \r\n");
+	   sb.append("\t\tWHERE  1=1 \r\n");
+	   for(int i = 0; i < colnames.length; i++){
+		   sb.append("\t\t\t<if test=\"equal."+getLowercaseChar(initcap(colnames[i].toLowerCase()))+"!= null and equal."+getLowercaseChar(initcap(colnames[i].toLowerCase()))+"!= ''\"> \r\n");
+		   sb.append("\t\t\t\tAND A."+colnames[i]+"=#{equal."+getLowercaseChar(initcap(colnames[i].toLowerCase()))+"} \r\n");
+		   sb.append("\t\t\t</if> \r\n");
+	   }
+	   for(int i = 0; i < colnames.length; i++){
+		   sb.append("\t\t\t<if test=\"like."+getLowercaseChar(initcap(colnames[i].toLowerCase()))+"!= null and like."+getLowercaseChar(initcap(colnames[i].toLowerCase()))+"!= ''\"> \r\n");
+		   sb.append("\t\t\t\tAND A."+colnames[i]+" LIKE concat(concat('%',#{like."+getLowercaseChar(initcap(colnames[i].toLowerCase()))+"},'%')) \r\n");
+		   sb.append("\t\t\t</if> \r\n");
+	   }
+	   
+	  
+	   sb.append("\t\t</select> \r\n");
+	   
+	   
+	   
+	   //根据id 物理删除  条件查询  返回一个
+	   sb.append("\r\n");
+	   sb.append("\t<!-- 根据id物理删除 "+tablename+" -->\r\n");
+	   sb.append("\t<delete id=\"delete\" parameterType=\"java.lang.String\">\r\n");
+	   sb.append("\t\tDELETE FROM \r\n");
+	   sb.append("\t\t\t"+tablename.toLowerCase()+" \r\n");
+	   sb.append("\t\tWHERE  \r\n");
+	   sb.append("\t\t\tID=#{id} \r\n");
+	   sb.append("\t</delete> \r\n");
+	   
+	   
+	   //根据id 逻辑删除  条件查询  返回一个 IS_DEL 
+	   sb.append("\r\n");
+	   sb.append("\t<!-- 根据id逻辑删除 "+tablename+"  IS_DEL 删除标识 1已删除 0未删除-->\r\n");
+	   sb.append("\t<update id=\"put\" parameterType=\"java.lang.String\">\r\n");
+	   sb.append("\t\tUPDATE "+tablename+" \r\n");
+	   sb.append("\t\t<set>\r\n");
+	   sb.append("\t\t\t IS_DEL=1\r\n");
+	   sb.append("\t\t</set>\r\n");
+	   sb.append("\t\tWHERE  \r\n");
+	   sb.append("\t\t\tID=#{id} \r\n");
+	   sb.append("\t\t</update> \r\n");
+	   
+	   
+	   
+	   //新增 
+	   sb.append("\r\n");
+	   sb.append("\t<!-- 新增 "+tablename+" -->\r\n");
+	   sb.append("\t<insert id=\"add\" parameterType=\""+this.packageOutPath+"."+"dao"+".entity."+initcap(tablename)+"\">\r\n");
+	   sb.append("\t\tINSERT INTO "+tablename+" \r\n");
+	   sb.append("\t\t<trim prefix=\"(\" suffix=\")\" suffixOverrides=\",\" >\r\n");
+	   for(int i = 0; i < colnames.length; i++) { 
+		   if(!"id".equals(colnames[i].toLowerCase())  ){
+			   if(colTypes[i].equalsIgnoreCase("varchar") || colTypes[i].equalsIgnoreCase("char")   
+		                || colTypes[i].equalsIgnoreCase("nvarchar") || colTypes[i].equalsIgnoreCase("nchar")   
+		                || colTypes[i].equalsIgnoreCase("text") || colTypes[i].equalsIgnoreCase("tinytext")){
+			    	  sb.append("\t\t\t<if test=\""+getLowercaseChar(initcap(colnames[i].toLowerCase()))+"!= null and "+getLowercaseChar(initcap(colnames[i].toLowerCase()))+"!=''\"> \r\n"); 
+			    	    
+			      }else{
+			    	  sb.append("\t\t\t<if test=\""+getLowercaseChar(initcap(colnames[i].toLowerCase()))+"!= null\"> \r\n"); 
+			      }
+			   sb.append("\t\t\t"+colnames[i]+",\r\n");
+			   sb.append("\t\t\t</if> \r\n");
+		   }
+	   }
+	   sb.append("\t\t\tid \r\n");
+	   sb.append("\t\t</trim>  \r\n");
+	   sb.append("\t\t<trim prefix=\"VALUES(\" suffix=\")\" suffixOverrides=\",\" >\r\n");
+	   for(int i = 0; i < colnames.length; i++) { 
+		   if(!"id".equals(colnames[i].toLowerCase())){
+			   if(colTypes[i].equalsIgnoreCase("varchar") || colTypes[i].equalsIgnoreCase("char")   
+		                || colTypes[i].equalsIgnoreCase("nvarchar") || colTypes[i].equalsIgnoreCase("nchar")   
+		                || colTypes[i].equalsIgnoreCase("text") || colTypes[i].equalsIgnoreCase("tinytext")){
+			    	  sb.append("\t\t\t<if test=\""+getLowercaseChar(initcap(colnames[i].toLowerCase()))+"!= null and "+getLowercaseChar(initcap(colnames[i].toLowerCase()))+"!=''\"> \r\n"); 
+			    	    
+			      }else{
+			    	  sb.append("\t\t\t<if test=\""+getLowercaseChar(initcap(colnames[i].toLowerCase()))+"!= null\"> \r\n"); 
+			      }
+			   sb.append("\t\t\t#{"+getLowercaseChar(initcap(colnames[i].toLowerCase()))+"},\r\n");
+			   sb.append("\t\t\t</if> \r\n");
+		   }
+	   }
+	   sb.append("\t\t\t#{id} \r\n");
+	   sb.append("\t\t</trim>  \r\n");
+	   sb.append("\t</insert> \r\n");
+	  
+	   
+	   
+	   
+	   //修改
+	   sb.append("\r\n");
+	   sb.append("\t<!-- 修改 "+tablename+" -->\r\n");
+	   sb.append("\t<update id=\"update\" parameterType=\""+this.packageOutPath+"."+"dao"+".entity."+initcap(tablename)+"\">\r\n");
+	   sb.append("\t\tUPDATE "+tablename+" \r\n");
+	   sb.append("\t\t<set>\r\n");
+	   for(int i = 0; i < colnames.length; i++) { 
+		   if(!"id".equals(colnames[i].toLowerCase())){
+			    if(colTypes[i].equalsIgnoreCase("varchar") || colTypes[i].equalsIgnoreCase("char")   
+		                || colTypes[i].equalsIgnoreCase("nvarchar") || colTypes[i].equalsIgnoreCase("nchar")   
+		                || colTypes[i].equalsIgnoreCase("text") || colTypes[i].equalsIgnoreCase("tinytext")){
+			    	  sb.append("\t\t\t<if test=\""+getLowercaseChar(initcap(colnames[i].toLowerCase()))+"!= null and "+getLowercaseChar(initcap(colnames[i].toLowerCase()))+"!=''\"> \r\n"); 
+			    	    
+			      }else{
+			    	  sb.append("\t\t\t<if test=\""+getLowercaseChar(initcap(colnames[i].toLowerCase()))+"!= null\"> \r\n"); 
+			      }
+				   sb.append("\t\t\t"+colnames[i]+"=#{"+getLowercaseChar(initcap(colnames[i].toLowerCase()))+"},\r\n");
+				   sb.append("\t\t\t</if> \r\n");  
+		   }
+		   
+	   } 
+	   sb.append("\t\tid =id</set>\r\n");
+	   sb.append("\t\tWHERE  \r\n");
+	   sb.append("\t\t\tID=#{id} \r\n");
+	   sb.append("\t</update> \r\n");
+	
+   }  
+   /* 
+     * 构造函数 ,实现祖始类
+     * entity 实体层 生成
+     */  
+    public void createEntityMysql() throws SQLException{  
+        //创建连接  
+        Connection con = null;  
+        //查要生成实体类的表  
+        con = DriverManager.getConnection(URL,NAME,PASS); 
+        String sql="SELECT   column_name,data_type, character_maximum_length,is_nullable,column_comment FROM  Information_schema. COLUMNS WHERE TABLE_SCHEMA = '"+dbName+"' AND table_Name = '"+tablename+"'";
+        System.out.println("查询sql:"+sql);
+        ResultSet	rs=con.createStatement().executeQuery(sql);
+		rs.last();//移到最后一行
+        int  count = rs.getRow();
+        rs.beforeFirst();//移到初始位置
+            
+        colnames = new String[count];  
+        colTypes = new String[count];  
+        colremarks = new String[count]; 
+        colSizes=new Long[count];
+        colisnull=new String[count];
+        int i=0;
+        while (rs.next()) {
+        	//获取列列名
+        	colnames[i] = rs.getString("COLUMN_NAME");
+            //备注
+        	colremarks[i] = rs.getString("column_comment");
+            //列类型
+           colTypes[i] = rs.getString("data_type"); 
+           //长度
+           colSizes[i]=  rs.getLong("character_maximum_length");
+           //是否为必填
+           colisnull[i]= rs.getString("is_nullable");
+           i++;
+        } 
+
+            String content = parse(colnames,colTypes,colremarks);   
+            try {  
+                File directory = new File("");  
+               // String path=this.getClass().getResource("").getPath();  
+                String outputPath = directory.getAbsolutePath()+ "/src/main/java/"+ packageOutPath.replace('.', '/')+"/"+initcap(tablename).toLowerCase()+"/entity/"+initcap(tablename)+ ".java";  
+                File file3 = new File(directory.getAbsolutePath()+ "/src/main/java/"+ packageOutPath.replace('.', '/')+"/"+initcap(tablename).toLowerCase());
+                File file4 = new File(directory.getAbsolutePath()+ "/src/main/java/"+ packageOutPath.replace('.', '/')+"/"+initcap(tablename).toLowerCase()+"/entity/");
+                if (file3.mkdir()) {
+                    System.out.println("多级层文件夹下文件创建成功!创建了的文件为:" + file3.getAbsolutePath() + ",上级文件为:" + file3.getParent());
+                }
+                if (file4.mkdir()) {
+                	System.out.println("多级层文件夹下文件创建成功!创建了的文件为:" + file3.getAbsolutePath() + ",上级文件为:" + file3.getParent());
+                }
+                FileWriter fw = new FileWriter(outputPath);  
+                PrintWriter pw = new PrintWriter(fw);  
+                pw.println(content);  
+                pw.flush();  
+                pw.close();  
+            } catch (IOException e) {  
+                e.printStackTrace();  
+            }  
+    }  
+
+   /**
+	     * web html  层 
+	     * 生成简单的html 实现 查分页  添加 修改 删除
+	     *  /**
+	     * @Title: MakeHtml 
+	     * @Description: 创建html
+	     * @return void    返回类型 
+	     * @throws
+	     * **/
+	    public void createWebHtml(){
+	 	     try {  
+	              File directory = new File("");  
+	            //  String path=this.getClass().getResource("").getPath();  
+	              String disrPath = directory.getAbsolutePath()+ "/src/main/resources/"+ htmlAddress+"/"+initcap(tablename).toLowerCase();  
+	              String filePath = directory.getAbsolutePath()+ "/src/main/resources/templates/common/template.html";  
+	              File file3 = new File(disrPath);
+	              if (file3.mkdir()) {
+	                  System.out.println("多级层文件夹下文件创建成功!创建了的文件为:" + file3.getAbsolutePath() + ",上级文件为:" + file3.getParent());
+	              }
+	              String fileName=initcap(tablename).toLowerCase();
+	              List<String> list =new ArrayList<String>();
+	              
+	              list.add("/system/sysDept/treeyfw");// 替换replace0 树结构的url 地址
+	              list.add(initcap(tablename).toLowerCase());// 替换replace1 列表请求url 地址
+	             
+	              list.add(replace2().toString());// html中 #replace2 位置替换
+	              list.add(replace3().toString());// html中 #replace3 位置替换
+	              list.add("/"+initcap(tablename).toLowerCase()+"/saveorupdate");// html中 #replace4 位置替换
+	              list.add("/"+initcap(tablename).toLowerCase()+"/saveorupdate");// html中 #replace5位置替换
+	              list.add("/"+initcap(tablename).toLowerCase()+"/delete");// html中 #replace6位置替换
+	              list.add("/"+initcap(tablename).toLowerCase()+"/selectById");// html中 #replace7位置替换
+	             
+	              CreateHtmlUtils.MakeHtml(filePath, disrPath, fileName, list);
+	            
+	 	     } catch (Exception e) {  
+	              e.printStackTrace();  
+	          }  
+	    }
+	   
+
+}

+ 13 - 0
src/main/java/com/hywa/map/common/strategy/importing/ImportExcel.java

@@ -0,0 +1,13 @@
+package com.hywa.map.common.strategy.importing;
+
+import org.springframework.web.multipart.MultipartFile;
+
+/**
+ * @Author: vic
+ * 导入策略
+ */
+public interface ImportExcel {
+
+    void uploadArtificialCollectExcel(String type, String userId, MultipartFile file);
+
+}

+ 40 - 0
src/main/java/com/hywa/map/common/strategy/importing/ImportExcelFactory.java

@@ -0,0 +1,40 @@
+package com.hywa.map.common.strategy.importing;
+
+import org.springframework.stereotype.Component;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/***
+ * @Author: vic
+ * 用于提供下载模板的工厂类
+ */
+@Component
+public class ImportExcelFactory {
+
+    private static Map<String, ImportExcel> DOWNLOADMAP = new HashMap<>();
+
+    private ImportExcelFactory() {
+    }
+
+    private static final ImportExcel EMPTY = new ImportExcel() {
+        @Override
+        public void uploadArtificialCollectExcel(String type, String userId, MultipartFile file) {
+
+        }
+    };
+
+    //获取
+    public static ImportExcel getImportExcel(String state) {
+        ImportExcel result = DOWNLOADMAP.get(state);
+        return result == null ? EMPTY : result;
+    }
+
+    //注册
+    public static void registerImportExcel(String state, ImportExcel o) {
+        DOWNLOADMAP.put(state, o);
+    }
+
+
+}

+ 84 - 0
src/main/java/com/hywa/map/common/utils/CodeUtils.java

@@ -0,0 +1,84 @@
+package com.hywa.map.common.utils;
+
+import java.awt.*;
+import java.awt.image.BufferedImage;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Random;
+
+public class CodeUtils {
+
+    private static int width = 120;// 定义图片的width
+    private static int height = 25;// 定义图片的height
+    private static int codeCount = 6;// 定义图片上显示验证码的个数
+    private static int xx = 15;
+    private static int fontHeight = 18;
+    private static int codeY = 16;
+    private static char[] codeSequence = {'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'};
+
+    /**
+     * 生成一个map集合
+     * code为生成的验证码
+     * codePic为生成的验证码BufferedImage对象
+     *
+     * @return
+     */
+    public static Map<String, Object> generateCodeAndPic() {
+        // 定义图像buffer
+        BufferedImage buffImg = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
+        Graphics gd = buffImg.getGraphics();
+        // 创建一个随机数生成器类
+        Random random = new Random();
+        // 将图像填充为白色
+        gd.setColor(Color.WHITE);
+        gd.fillRect(0, 0, width, height);
+
+        // 创建字体,字体的大小应该根据图片的高度来定。
+        Font font = new Font("Fixedsys", Font.BOLD, fontHeight);
+        // 设置字体。
+        gd.setFont(font);
+
+        // 画边框。
+        gd.setColor(Color.BLACK);
+        gd.drawRect(0, 0, width - 1, height - 1);
+
+        // 随机产生30条干扰线,使图象中的认证码不易被其它程序探测到。
+        gd.setColor(Color.BLACK);
+        for (int i = 0; i < 30; i++) {
+            int x = random.nextInt(width);
+            int y = random.nextInt(height);
+            int xl = random.nextInt(12);
+            int yl = random.nextInt(12);
+            gd.drawLine(x, y, x + xl, y + yl);
+        }
+
+        // randomCode用于保存随机产生的验证码,以便用户登录后进行验证。
+        StringBuffer randomCode = new StringBuffer();
+        int red = 0, green = 0, blue = 0;
+
+        // 随机产生codeCount数字的验证码。
+        for (int i = 0; i < codeCount; i++) {
+            // 得到随机产生的验证码数字。
+            String code = String.valueOf(codeSequence[random.nextInt(36)]);
+            // 产生随机的颜色分量来构造颜色值,这样输出的每位数字的颜色值都将不同。
+            red = random.nextInt(255);
+            green = random.nextInt(255);
+            blue = random.nextInt(255);
+
+            // 用随机产生的颜色将验证码绘制到图像中。
+            gd.setColor(new Color(red, green, blue));
+            gd.drawString(code, (i + 1) * xx, codeY);
+
+            // 将产生的随机数组合在一起。
+            randomCode.append(code);
+        }
+        Map<String, Object> map = new HashMap<String, Object>();
+        //存放验证码
+        map.put("code", randomCode.toString());
+        //存放生成的验证码BufferedImage对象
+        map.put("codePic", buffImg);
+        return map;
+    }
+
+}

+ 268 - 0
src/main/java/com/hywa/map/common/utils/DateUtils.java

@@ -0,0 +1,268 @@
+package com.hywa.map.common.utils;
+
+import java.text.DecimalFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Date;
+
+/**
+ * 日期工具类
+ */
+public class DateUtils {
+
+    /**
+     * 默认格式(2016-08-20
+     */
+    public static final String DEFAULT_FORMAT = "yyyy-MM-dd";
+    public static SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
+    /**
+     * 年月(2016-08
+     */
+    public static final String YEAR_MONTH = "yyyy-MM";
+
+    /**
+     * 详细日期格式(2016-08-20 17:30:30
+     */
+    public static final String DETAIL = "yyyy-MM-dd HH:mm:ss";
+
+    /**
+     * 带/的日期格式(2016/08/20
+     */
+    public static final String FORMAT_SLASH = "yyyy/MM/dd";
+
+    /**
+     * 中文的日期格式(20160820日)
+     */
+    public static final String CHINESE_FORMAT = "yyyy年MM月dd日";
+
+    public static final String CHINESE_FORMAT_DETAIL = "yyyy年MM月dd日 HH:mm:ss";
+
+    /*一天 时间毫秒数*/
+    public static final long ONE_DAY_MILLIS = 1000 * 3600 * 24;
+
+    /**
+     * 将String的日期转换为字符串中文格式
+     */
+    public static String formatChineseDate(String date) {
+        try {
+            if (null == date) {
+                return null;
+            }
+            Date dateStr = stringToDate(date, DETAIL);
+            SimpleDateFormat sdf = new SimpleDateFormat(CHINESE_FORMAT);
+            return sdf.format(dateStr);
+        } catch (ParseException e) {
+            return null;
+        }
+    }
+
+    /**
+     * 将Date类型转换为字符串类型
+     */
+    public static String formatDate(Date date, String format) {
+        if (null == date) {
+            return null;
+        }
+        if (StringUtils.isEmpty(format)) {
+            format = DEFAULT_FORMAT;
+        }
+        SimpleDateFormat sdf = new SimpleDateFormat(format);
+        return sdf.format(date);
+    }
+
+    /**
+     * 将String类型转换为date类型
+     */
+    public static Date stringToDate(String dateStr, String format) throws ParseException {
+        if (StringUtils.isEmpty(dateStr)) {
+            return null;
+        }
+        if (StringUtils.isEmpty(format)) {
+            format = DEFAULT_FORMAT;
+        }
+        SimpleDateFormat sdf = new SimpleDateFormat(format);
+        return sdf.parse(dateStr);
+    }
+
+    /**
+     * 得到本月最开始的时间
+     */
+    public static Date currentMonthStart() {
+        Calendar calendar = Calendar.getInstance();
+        calendar.set(Calendar.DAY_OF_MONTH, 1);
+        calendar.set(Calendar.HOUR_OF_DAY, 0);
+        calendar.set(Calendar.MINUTE, 0);
+        calendar.set(Calendar.SECOND, 0);
+        return calendar.getTime();
+    }
+
+    /**
+     * 得到本月最后一刻时间
+     */
+    public static Date currentMonthEnd() {
+        Calendar calendar = Calendar.getInstance();
+        calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMaximum(Calendar.DAY_OF_MONTH));
+        calendar.set(Calendar.HOUR_OF_DAY, 23);
+        calendar.set(Calendar.MINUTE, 59);
+        calendar.set(Calendar.SECOND, 59);
+        return calendar.getTime();
+    }
+
+    /**
+     * 得到本年年份
+     */
+    public static int currentYear() {
+        Calendar calendar = Calendar.getInstance();
+        return calendar.get(Calendar.YEAR);
+    }
+
+    /**
+     * 通过生日得到年龄
+     */
+    public static int getAge(Date birthDate) {
+        if (birthDate == null) {
+            throw new RuntimeException("出生日期不能为null");
+        }
+        int age = 0;
+        Date now = new Date();
+        SimpleDateFormat formatYear = new SimpleDateFormat("yyyy");
+        SimpleDateFormat formatMonth = new SimpleDateFormat("MM");
+        String birthYear = formatYear.format(birthDate);
+        String thisYear = formatYear.format(now);
+        String birthMonth = formatMonth.format(birthDate);
+        String thisMonth = formatMonth.format(now);
+        // 初步,估算
+        age = Integer.parseInt(thisYear) - Integer.parseInt(birthYear);
+        // 如果未到出生月份,则age - 1
+        if (thisMonth.compareTo(birthMonth) < 0) {
+            age -= 1;
+        }
+        if (age < 0) {
+            age = 0;
+        }
+        return age;
+    }
+
+    /**
+     * 通过日期生成惟一主键
+     */
+    public static synchronized String generateId() {
+        return System.currentTimeMillis() + "";
+    }
+
+    public static synchronized String generateDateId() {
+        Date date = new Date();
+        String dateStr = formatDate(date, "yyyyMMddHHmmss");
+        return dateStr;
+    }
+
+    /**
+     * 功能:获取当前日期 格式:20101010
+     *
+     * @return
+     */
+    public static String getCurrentDate() {
+        Date date = new Date();
+        return dateFormat.format(date);
+    }
+
+    /**
+     * 当前时间加 减days
+     *
+     * @param days
+     * @return yyyy-MM-dd
+     */
+    public static String getDiffDay(int days) {
+        SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
+        Calendar c = Calendar.getInstance();
+        c.add(Calendar.DAY_OF_MONTH, days);
+        return sf.format(c.getTime());
+    }
+
+    /**
+     * 功能:返回小时
+     *
+     * @param date
+     * @return
+     */
+    public static int getHour(Date date) {
+        if (date == null) {
+            date = new Date();
+        }
+        Calendar c = Calendar.getInstance();
+        c.setTime(date);
+        return c.get(Calendar.HOUR_OF_DAY);
+    }
+
+    /**
+     * 获取指定日期中的月份日期
+     *
+     * @return String 如1221
+     */
+    public static String getMDChina(String dateStr) {
+        String str = newLongYMDFormat().format(parseDate(dateStr));
+        return str.split("-")[1] + "月" + str.split("-")[2] + "日";
+    }
+
+    /**
+     * 创建一个"yyyy-MM-dd"日期的格式化对象
+     *
+     * @return "yyyy-MM-dd"日期的格式化对象
+     */
+    private static SimpleDateFormat newLongYMDFormat() {
+        return new SimpleDateFormat("yyyy-MM-dd");
+    }
+
+    /**
+     * 功能:解析数据库中的日期字符串 格式:yyyy-MM-dd
+     *
+     * @param dateStr
+     * @return
+     */
+    public static Date parseDate(String dateStr) {
+        Date date = null;
+        try {
+            date = dateFormat.parse(dateStr);
+        } catch (ParseException e) {
+            e.printStackTrace();
+        }
+        return date;
+    }
+
+    /**
+     * 获取指定日期是星期几<br>
+     *
+     * @param dt
+     * @return 指定日期是星期几
+     */
+    public static String getWeek(String dt) {
+        String[] weekDays = {"周日", "周一", "周二", "周三", "周四", "周五", "周六"};
+        Calendar cal = Calendar.getInstance();
+        cal.setTime(parseDate(dt));
+        int w = cal.get(Calendar.DAY_OF_WEEK) - 1;
+        if (w < 0) {
+            w = 0;
+        }
+        return weekDays[w];
+    }
+
+    public static void main(String[] args) {
+        System.out.println(formatDate(currentMonthStart(), DEFAULT_FORMAT));
+        System.out.println(getCurrentDate());
+        System.out.println(String.format("%.2f", (double) 32));
+        System.out.println(getDiffDay(-5));
+        System.out.println(1+(1/2)+(1/3)+(1/4));
+        String value="112.00";
+        DecimalFormat decimalFormat = new DecimalFormat("###################.###########");
+
+        System.out.println(currentYear());
+        String test = "2019 年2月6日".replaceAll(" ","");
+        String year = test.substring(0,4);
+        String month=test.substring(test.indexOf("年")+1,test.indexOf("月"));
+        String day=test.substring(test.indexOf("月")+1,test.indexOf("日"));
+        month=month.length()==1?"0"+month:month;
+        day=day.length()==1?"0"+day:day;
+        System.out.println(year+"==="+month+"==="+day);
+    }
+}

+ 430 - 0
src/main/java/com/hywa/map/common/utils/ExcelUtils.java

@@ -0,0 +1,430 @@
+package com.hywa.map.common.utils;
+
+import static com.hywa.map.common.enums.CommonEnum.FILE_CONTENT_NOT_NULL;
+
+import com.hywa.map.common.enums.CommonEnum;
+import com.hywa.map.common.exception.GlobalException;
+
+import java.io.File;
+import java.io.IOException;
+import java.lang.reflect.Method;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import javax.servlet.http.HttpServletResponse;
+
+import jxl.Cell;
+import jxl.CellType;
+import jxl.CellView;
+import jxl.NumberCell;
+import jxl.Sheet;
+import jxl.Workbook;
+import jxl.format.Alignment;
+import jxl.format.Border;
+import jxl.format.BorderLineStyle;
+import jxl.format.CellFormat;
+import jxl.format.Colour;
+import jxl.format.VerticalAlignment;
+import jxl.write.Label;
+import jxl.write.WritableCellFormat;
+import jxl.write.WritableFont;
+import jxl.write.WritableSheet;
+import jxl.write.WritableWorkbook;
+import jxl.write.WriteException;
+import jxl.write.biff.RowsExceededException;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.util.CollectionUtils;
+import org.springframework.web.multipart.MultipartFile;
+
+@Slf4j
+public class ExcelUtils {
+
+    /**
+     * 导出excel
+     */
+    public static void exportExcel(List<?> list, HttpServletResponse response, String tableName,
+                                   String tableTitle,
+                                   String sheetName, LinkedHashMap<String, String> filedNames, String fileName) {
+        try {
+            response.setContentType("application/vnd.ms-excel;charset=utf-8");
+            //中文文件名做iso-8859-1转码
+            String convertCode = new String(fileName.getBytes("gbk"), "iso8859-1") + ".xls";
+            response.setHeader("Content-Disposition", "attachment;filename=" + convertCode);
+            //创建Excel文件
+            WritableWorkbook workbook = Workbook.createWorkbook(response.getOutputStream());
+            //创建Sheet页
+            WritableSheet sheet = workbook.createSheet(sheetName, 0);
+
+            // 设置标题字体,字体为Arial,字号大小为22,采用黑体显示
+            WritableFont titleBold = new WritableFont(WritableFont.ARIAL, 22, WritableFont.BOLD);
+
+            // 设置列名字体,字体为COURIER,字号大小为14,采用黑体显示
+            WritableFont columnBold = new WritableFont(WritableFont.COURIER, 18, WritableFont.BOLD);
+
+            // 设置单元格字体,字体为COURIER,字号大小为14,采用黑体显示
+            WritableFont cellBold = new WritableFont(WritableFont.COURIER, 14,
+                    WritableFont.NO_BOLD);
+
+            // 标题单元格样式控制对象
+            WritableCellFormat titleFormat = new WritableCellFormat(titleBold);
+            titleFormat.setVerticalAlignment(VerticalAlignment.CENTRE);
+            titleFormat.setAlignment(Alignment.CENTRE);
+            titleFormat.setWrap(true);//是否自动换行
+            titleFormat.setBackground(Colour.WHITE);//单元格背景色
+            titleFormat.setBorder(Border.ALL, jxl.format.BorderLineStyle.THIN); //给单元格加边框
+
+            // 列名单元格样式控制对象
+            WritableCellFormat columnFormat = new WritableCellFormat(columnBold);
+            columnFormat.setVerticalAlignment(VerticalAlignment.CENTRE);
+            columnFormat.setAlignment(Alignment.CENTRE);
+            columnFormat.setBackground(Colour.GRAY_25);//单元格背景色
+            columnFormat.setBorder(Border.ALL, BorderLineStyle.THIN); //给单元格加边框
+            //columnFormat.setShrinkToFit(true);//设置缩放字体适应单元格大小
+            //columnFormat.setOrientation(Orientation.VERTICAL);//设置字体方向
+
+            // 列名单元格样式控制对象
+            WritableCellFormat cellFormat = new WritableCellFormat(cellBold);
+            cellFormat.setVerticalAlignment(VerticalAlignment.CENTRE);
+            cellFormat.setAlignment(Alignment.CENTRE);
+            cellFormat.setWrap(true);//是否自动换行
+            cellFormat.setBorder(Border.ALL, BorderLineStyle.THIN); //给单元格加边框
+
+            // 添加表头
+            Label label0 = new Label(0, 0, tableTitle, titleFormat);
+            sheet.setRowView(0, 1300, false); //设置行高
+            sheet.addCell(label0);
+            //添加列名
+            List<String> column = new ArrayList<>(filedNames.values());
+            addCell(sheet, columnFormat, column);
+            //添加数据
+            List<String> fields = new ArrayList<>(filedNames.keySet());
+            addData(list, sheet, fields, cellFormat);
+
+            //合并单元格,第一个参数是起始列,第二个参数是起始行,第三个参数是终止列,第四个参数是终止行
+            sheet.mergeCells(0, 0, column.size() - 1, 0);
+
+            //将数据写入文件
+            workbook.write();
+            workbook.close();
+        } catch (IOException e) {
+            e.printStackTrace();
+        } catch (RowsExceededException e) {
+            e.printStackTrace();
+        } catch (WriteException e) {
+            e.printStackTrace();
+        }
+    }
+
+
+    /**
+     * 导入excel
+     */
+    public static List<Map<String, String>> importExcel(MultipartFile file, String filePath)
+            throws GlobalException {
+        if (file == null) {
+            throw new GlobalException(CommonEnum.FILE_NOT_NULL.getIndex(),
+                    CommonEnum.FILE_NOT_NULL.getValue());
+        }
+        String fileName = file.getOriginalFilename();
+        String suffixName = fileName.substring(fileName.lastIndexOf("."));
+
+        if (!".xlsx".equals(suffixName) && !".xls".equals(suffixName)) {
+            throw new GlobalException(CommonEnum.FILE_TYPE_ERROR.getIndex(),
+                    CommonEnum.FILE_TYPE_ERROR.getValue());
+        }
+        File dest = new File(filePath + fileName);
+        // 检测是否存在目录
+        if (dest.exists()) {
+            throw new GlobalException(CommonEnum.FILE_REPEATED.getIndex(),
+                    CommonEnum.FILE_REPEATED.getValue());
+        } else if (!dest.getParentFile().exists()) {
+            dest.getParentFile().mkdirs();
+        }
+        try {
+            file.transferTo(dest);
+        } catch (Exception e) {
+            throw new GlobalException(CommonEnum.FILE_UPLOAD_FAIL.getIndex(),
+                    CommonEnum.FILE_UPLOAD_FAIL.getValue());
+        }
+        List<Map<String, String>> list = new ArrayList<>();
+        //打开文件
+        Workbook book = null;
+        try {
+            book = Workbook.getWorkbook(dest);
+        } catch (Exception e) {
+            e.printStackTrace();
+            throw new GlobalException(CommonEnum.FILE_UPLOAD_FAIL.getIndex(),
+                    CommonEnum.FILE_UPLOAD_FAIL.getValue());
+        }
+        Sheet sheet = book.getSheet(0);
+        boolean sw = true;
+        for (int i = 2; i < sheet.getRows(); i++) {//sheet.getRows()获取行数
+            Map<String, String> map = new HashMap<>();
+            for (int j = 0; j < sheet.getColumns(); j++) {
+                Cell cell = sheet.getCell(j, i);
+                if (!StringUtils.isEmpty(cell.getContents().trim())) {
+                    sw = false;
+                }
+            }
+            if (sw) {
+                break;
+            }
+            analyseData(sheet, i, map);
+            list.add(map);
+            sw = true;
+        }
+        book.close();
+        if (CollectionUtils.isEmpty(list)) {
+            throw new GlobalException(CommonEnum.FILE_CONTENT_NOT_NULL.getIndex(), CommonEnum.FILE_CONTENT_NOT_NULL.getValue());
+        }
+        return list;
+    }
+
+    private static void addData(List<?> list, WritableSheet sheet, List<String> fields,
+                                CellFormat cellFormat) throws WriteException {
+        for (int j = 0; j < list.size(); j++) {
+            for (int i = 0; i < fields.size(); i++) {
+                Object fieldValueByName = getFieldValueByName(fields.get(i), list.get(j));
+                Label label = new Label(i, j + 2,
+                        fieldValueByName == null ? " " : fieldValueByName.toString(), cellFormat);
+                sheet.addCell(label);
+            }
+        }
+    }
+
+    private static void addData(List<?> list, WritableSheet sheet, List<String> fields,
+                                CellFormat cellFormat, String cell) throws WriteException {
+        CellFormat cellFormatBak = cellFormat;
+        for (int j = 0; j < list.size(); j++) {
+            for (int i = 0; i < fields.size(); i++) {
+                Object fieldValueByName = getFieldValueByName(fields.get(i), list.get(j));
+                if(fieldValueByName==null){
+                    fieldValueByName = getValue((Map<String, String>) list.get(j),fields.get(i));
+                }
+                if (fields.get(i).equals(cell)) {
+                    WritableFont cellBold = new WritableFont(WritableFont.COURIER, 14,
+                            WritableFont.NO_BOLD);
+                    cellBold.setColour(Colour.RED);
+                    WritableCellFormat wCellFormat = new WritableCellFormat(cellBold);
+                    wCellFormat.setVerticalAlignment(VerticalAlignment.CENTRE);
+                    wCellFormat.setAlignment(Alignment.CENTRE);
+                    wCellFormat.setWrap(true);//是否自动换行
+                    wCellFormat.setBorder(Border.ALL, BorderLineStyle.THIN); //给单元格加边框
+                    cellFormat = wCellFormat;
+                }
+                String fieldValue = (fieldValueByName == null) ? "" : fieldValueByName.toString();
+                Label label = new Label(i, j + 2,
+                        fieldValueByName == null ? " " : (StringUtils.isEmpty(fieldValue) ? "" : fieldValue), cellFormat);
+                sheet.addCell(label);
+                cellFormat = cellFormatBak;
+            }
+        }
+    }
+
+    private static Object getFieldValueByName(String fieldName, Object o) {
+        try {
+            String firstLetter = fieldName.substring(0, 1).toUpperCase();
+            String methodName = "get" + firstLetter + fieldName.substring(1);
+            Method method = o.getClass().getMethod(methodName, new Class[]{});
+            Class<?> returnType = method.getReturnType();
+            if ("java.util.Date".equals(returnType.getTypeName())) {
+                if (!Optional.ofNullable(method.invoke(o, new Object[]{})).isPresent()) {
+                    return null;
+                }
+                Date date = (Date) (method.invoke(o, new Object[]{}).getClass().newInstance());
+                return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(date);
+            } else {
+                return method.invoke(o, new Object[]{});
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+            return null;
+        }
+    }
+
+    public static String getValue(Map<String, String> map, String key) {
+        String value;
+        try {
+            value = StringUtils.isEmpty(map.get(key)) ? "" : map.get(key);
+        } catch (Exception e) {
+            value = "";
+        }
+        return value;
+    }
+
+    /**
+     * 读取excel信息
+     */
+    public static List<Map<String, String>> viewDetails(
+            com.hywa.map.dao.entity.File file) {
+        File dest = new File(file.getPath() + file.getName());
+        List<Map<String, String>> list = new ArrayList<>();
+        //打开文件
+        Workbook book = null;
+        try {
+            book = Workbook.getWorkbook(dest);
+        } catch (Exception e) {
+            e.printStackTrace();
+            throw new GlobalException(CommonEnum.FILE_UPLOAD_FAIL.getIndex(),
+                    CommonEnum.FILE_UPLOAD_FAIL.getValue());
+        }
+        Sheet sheet = book.getSheet(0);
+        for (int i = 2; i < sheet.getRows(); i++) {//sheet.getRows()获取行数
+            Map<String, String> map = new HashMap<>();
+            analyseData(sheet, i, map);
+            if (StringUtils.isEmpty(map.get("产品名称"))) {
+                throw new GlobalException(FILE_CONTENT_NOT_NULL.getIndex(),
+                        FILE_CONTENT_NOT_NULL.getValue());
+            }
+            list.add(map);
+        }
+        book.close();
+        return list;
+    }
+
+    /**
+     * 解析数据
+     */
+    private static void analyseData(Sheet sheet, int i, Map<String, String> map) {
+        for (int j = 0; j < sheet.getColumns(); j++) {//sheet.getColumns()获取列数
+            Cell cell = sheet.getCell(j, i);
+            if (cell.getType() == CellType.NUMBER) { //取数字的时候强转一下,否则默认只取出小数点后3位
+                NumberCell numberCell = (NumberCell) cell;
+                double value = numberCell.getValue();
+                map.put(sheet.getCell(j, 1).getContents(), String.valueOf(value));
+                continue;
+            }
+            map.put(sheet.getCell(j, 1).getContents(), cell.getContents());
+        }
+    }
+
+    /**
+     * 导出excel生成文件形式
+     */
+    public static File exportExcelForFile(List<?> list, String tableTitle,
+                                          String sheetName, LinkedHashMap<String, String> filedNames, String filePath,
+                                          String fileName, String redCell) {
+        try {
+            new File(filePath).mkdirs();
+            File file = new File(filePath + fileName);
+            //创建Excel文件
+            WritableWorkbook workbook = Workbook.createWorkbook(file);
+            //创建Sheet页
+            WritableSheet sheet = workbook.createSheet(sheetName, 0);
+
+            // 设置标题字体,字体为Arial,字号大小为22,采用黑体显示
+            WritableFont titleBold = new WritableFont(WritableFont.ARIAL, 22, WritableFont.BOLD);
+
+            // 设置列名字体,字体为COURIER,字号大小为14,采用黑体显示
+            WritableFont columnBold = new WritableFont(WritableFont.COURIER, 18, WritableFont.BOLD);
+
+            // 设置单元格字体,字体为COURIER,字号大小为14,采用黑体显示
+            WritableFont cellBold = new WritableFont(WritableFont.COURIER, 14,
+                    WritableFont.NO_BOLD);
+            //cellBold.setColour(Colour.RED);
+
+            // 标题单元格样式控制对象
+            WritableCellFormat titleFormat = new WritableCellFormat(titleBold);
+            titleFormat.setVerticalAlignment(VerticalAlignment.CENTRE);
+            titleFormat.setAlignment(Alignment.CENTRE);
+            titleFormat.setWrap(true);//是否自动换行
+            titleFormat.setBackground(Colour.WHITE);//单元格背景色
+            titleFormat.setBorder(Border.ALL, jxl.format.BorderLineStyle.THIN); //给单元格加边框
+
+            // 列名单元格样式控制对象
+            WritableCellFormat columnFormat = new WritableCellFormat(columnBold);
+            columnFormat.setVerticalAlignment(VerticalAlignment.CENTRE);
+            columnFormat.setAlignment(Alignment.CENTRE);
+            columnFormat.setBackground(Colour.GRAY_25);//单元格背景色
+            columnFormat.setBorder(Border.ALL, BorderLineStyle.THIN); //给单元格加边框
+            // 列名单元格样式控制对象
+            WritableCellFormat cellFormat = new WritableCellFormat(cellBold);
+            cellFormat.setVerticalAlignment(VerticalAlignment.CENTRE);
+            cellFormat.setAlignment(Alignment.CENTRE);
+            cellFormat.setWrap(true);//是否自动换行
+            cellFormat.setBorder(Border.ALL, BorderLineStyle.THIN); //给单元格加边框
+
+            // 添加表头
+            Label label0 = new Label(0, 0, tableTitle, titleFormat);
+            sheet.setRowView(0, 1300, false); //设置行高
+            sheet.addCell(label0);
+
+            //添加列名
+            List<String> column = new ArrayList<>(filedNames.values());
+            addCell(sheet, columnFormat, column);
+
+            //添加数据
+            List<String> fields = new ArrayList<>(filedNames.keySet());
+            addData(list, sheet, fields, cellFormat, redCell);
+
+            //合并单元格,第一个参数是起始列,第二个参数是起始行,第三个参数是终止列,第四个参数是终止行
+            sheet.mergeCells(0, 0, column.size() - 1, 0);
+
+            //将数据写入文件
+            workbook.write();
+            workbook.close();
+            return file;
+        } catch (IOException e) {
+            e.printStackTrace();
+        } catch (RowsExceededException e) {
+            e.printStackTrace();
+        } catch (WriteException e) {
+            e.printStackTrace();
+        }
+        throw new GlobalException(CommonEnum.FAILURE.getIndex(), CommonEnum.FAILURE.getValue());
+    }
+
+    /**
+     * 增加列名
+     */
+    private static void addCell(WritableSheet sheet, WritableCellFormat columnFormat,
+                                List<String> column) throws WriteException {
+        for (int i = 0; i < column.size(); i++) {
+            Label label = new Label(i, 1, column.get(i), columnFormat);
+            CellView cellView = new CellView();
+            cellView.setAutosize(true); //设置自动大小
+            sheet.setColumnView(i, column.get(i).getBytes().length + 8);//根据内容自动设置列宽
+//            setColumnAutoSize(sheet, 10); //设置行宽
+            sheet.addCell(label);
+        }
+    }
+
+    /**
+     * 自动调节格式
+     */
+    private static void setColumnAutoSize(WritableSheet ws, int extraWith) {
+        // 获取本列的最宽单元格的宽度
+        for (int i = 0; i <= ws.getColumns(); i++) {
+            int colWith = 0;
+            for (int j = 0; j < ws.getRows(); j++) {
+                String content = ws.getCell(i, j).getContents();
+                byte[] bstrLength = content.getBytes();
+                int cellWith = bstrLength.length;
+                if (colWith < cellWith) {
+                    colWith = cellWith;
+                }
+            }
+            // 设置单元格的宽度为最宽宽度+额外宽度
+            ws.setColumnView(i, colWith + extraWith);
+        }
+    }
+
+    public static void main(String[] args) {
+        /*LinkedHashMap<String, String> filedNames = new LinkedHashMap<>();
+        filedNames.put("date", "日期");
+        filedNames.put("productName", "产品名称");
+        filedNames.put("price", "价格");
+        filedNames.put("unitName", "计量单位");
+        filedNames.put("marketName", "收购点名称");
+        filedNames.put("purchaseVolume", "收购量(公斤)");
+        List<SelfInfoRep> sellInfo = productMapper.findSellInfoByPurchasingPrice(selfTemplateRep);
+        String fileName = "收购点价格采集表";
+        File file = ExcelUtils.exportExcelForFile(null, "收购点价格采集表(红色信息为基础信息,不可修改)", "收购点价格采集表", filedNames,
+                "F:/upload/", fileName + ".xls");*/
+    }
+}

+ 230 - 0
src/main/java/com/hywa/map/common/utils/FileUtils.java

@@ -0,0 +1,230 @@
+package com.hywa.map.common.utils;
+
+import static com.hywa.map.common.enums.CommonEnum.FAILURE;
+import static com.hywa.map.common.enums.CommonEnum.SUCCESS;
+
+import com.hywa.map.common.enums.CommonEnum;
+import com.hywa.map.common.exception.GlobalException;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
+import java.util.List;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import lombok.extern.slf4j.Slf4j;
+import org.apache.tomcat.util.http.fileupload.FileUploadException;
+import org.springframework.web.multipart.MultipartFile;
+import org.springframework.web.multipart.MultipartHttpServletRequest;
+
+@Slf4j
+public class FileUtils {
+
+    public static CommonEnum upload(MultipartFile file, String filePath) {
+
+        if (file.isEmpty()) {
+            return FAILURE;
+        }
+        // 获取文件名
+        String fileName = file.getOriginalFilename();
+        log.info("上传的文件名为:" + fileName);
+        // 获取文件的后缀名
+        if(-1!=fileName.lastIndexOf(".")) {
+        String suffixName = fileName.substring(fileName.lastIndexOf("."));
+        log.info("上传的后缀名为:" + suffixName);
+        }
+        // 文件上传后的路径 解决中文问题,liunx下中文路径,图片显示问题
+        File dest = new File(filePath + fileName);
+        // 检测是否存在目录
+        if (!dest.getParentFile().exists()) {
+            dest.getParentFile().mkdirs();
+        }
+        try {
+            file.transferTo(dest);
+            return SUCCESS;
+        } catch (IllegalStateException e) {
+            e.printStackTrace();
+            return FAILURE;
+        } catch (IOException e) {
+            e.printStackTrace();
+            return FAILURE;
+        }
+    }
+
+    //文件下载相关代码
+    public static void downloadFile(String filePath, String fileName,
+                                    HttpServletResponse response, HttpServletRequest request,String menuName) throws UnsupportedEncodingException {
+        if (fileName != null) {
+            File file = new File(filePath);
+            if (!file.exists()) {
+                throw new GlobalException(CommonEnum.FILE_CANNOT_BE_FOUND.getIndex(), CommonEnum.FILE_CANNOT_BE_FOUND.getValue(),null,menuName);
+            } else {
+                response.setContentType("application/force-download");// 设置强制下载不打开
+                //不能直接在header中设置中文,普通浏览器要使用URLEncoder.encode方法encode一下,其中火狐浏览器要区别处理,要转成ISO-8859-1编码
+                if (request.getHeader("user-agent").toLowerCase().indexOf("firefox") > -1) {
+                    response.addHeader("Content-Disposition",
+                            "attachment;filename=" + new String(fileName.getBytes("utf-8"), "ISO-8859-1"));
+                } else {
+                    response.addHeader("Content-Disposition",
+                            "attachment;filename=" + URLEncoder.encode(fileName, "utf-8"));
+                }
+/*                response.addHeader("Content-Disposition",
+                        "attachment;fileName=" + fileName);// 设置文件名
+*/
+                byte[] buffer = new byte[1024];
+                FileInputStream fis = null;
+                BufferedInputStream bis = null;
+                try {
+                    fis = new FileInputStream(file);
+                    bis = new BufferedInputStream(fis);
+                    OutputStream os = response.getOutputStream();
+                    int i = bis.read(buffer);
+                    while (i != -1) {
+                        os.write(buffer, 0, i);
+                        i = bis.read(buffer);
+                    }
+                    log.info(fileName + ": 下载成功");
+                } catch (Exception e) {
+                    e.printStackTrace();
+                } finally {
+                    if (bis != null) {
+                        try {
+                            bis.close();
+                        } catch (IOException e) {
+                            e.printStackTrace();
+                        }
+                    }
+                    if (fis != null) {
+                        try {
+                            fis.close();
+                        } catch (IOException e) {
+                            e.printStackTrace();
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+    //图片查看
+    public static void showImage(String filePath, HttpServletResponse response) {
+        File file = new File(filePath);
+        FileInputStream fis = null;
+        if (!file.exists()) {
+            throw new GlobalException(CommonEnum.FILE_NOT_FOUND.getIndex(), CommonEnum.FILE_NOT_FOUND.getValue());
+        }
+        try {
+            response.setContentType("image/gif");
+            OutputStream out = response.getOutputStream();
+            fis = new FileInputStream(file);
+            byte[] b = new byte[fis.available()];
+            fis.read(b);
+            out.write(b);
+            out.flush();
+        } catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            if (fis != null) {
+                try {
+                    fis.close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+    }
+
+    //多文件下载
+    public static String handleFileUpload(HttpServletRequest request) throws FileUploadException {
+        List<MultipartFile> files = ((MultipartHttpServletRequest) request)
+                .getFiles("file");
+        MultipartFile file = null;
+        BufferedOutputStream stream = null;
+        for (int i = 0; i < files.size(); ++i) {
+            file = files.get(i);
+            if (!file.isEmpty()) {
+                try {
+                    byte[] bytes = file.getBytes();
+                    stream = new BufferedOutputStream(new FileOutputStream(
+                            new File(file.getOriginalFilename())));
+                    stream.write(bytes);
+                    stream.close();
+
+                } catch (Exception e) {
+                    stream = null;
+                    throw new FileUploadException("You failed to upload " + i + " => "
+                            + e.getMessage());
+                }
+            } else {
+                throw new FileUploadException("You failed to upload " + i
+                        + " because the file was empty.");
+            }
+        }
+        return "upload successful";
+    }
+
+    public static void delete(String filename, String filePath) {
+        File file = new File(filePath + filename);
+        if (file.exists() && file.isFile()) {
+            file.delete();
+        }
+    }
+
+    public static String uploadAndCreateNewName(MultipartFile file, String filePath) {
+        if (file.isEmpty()) {
+            throw new GlobalException(CommonEnum.FAILURE.getIndex(), CommonEnum.FAILURE.getValue());
+        }
+        // 获取文件名
+        String fileName = file.getOriginalFilename();
+        log.info("上传的文件名为:" + fileName);
+        // 获取文件的后缀名
+        String suffixName = fileName.substring(fileName.lastIndexOf("."));
+        log.info("上传的后缀名为:" + suffixName);
+        fileName = UUIDUtils.randomUUID() + suffixName;
+        String nowTime = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmSS"));
+        File dest = new File(filePath + nowTime + "/" + fileName);
+        // 检测是否存在目录
+        if (!dest.getParentFile().exists()) {
+            dest.getParentFile().mkdirs();
+        }
+        try {
+            file.transferTo(dest);
+            return File.separator + nowTime + File.separator + fileName;
+        } catch (Exception e) {
+            throw new GlobalException(CommonEnum.FAILURE.getIndex(), CommonEnum.FAILURE.getValue());
+        }
+    }
+
+    public static String uploadByNewName(MultipartFile file, String filePath) {
+        if (file.isEmpty()) {
+            throw new GlobalException(CommonEnum.FAILURE.getIndex(), CommonEnum.FAILURE.getValue());
+        }
+        // 获取文件名
+        String fileName = file.getOriginalFilename();
+        log.info("上传的文件名为:" + fileName);
+        // 获取文件的后缀名
+        String suffixName = fileName.substring(fileName.lastIndexOf("."));
+        log.info("上传的后缀名为:" + suffixName);
+        fileName = UUIDUtils.randomUUID() + suffixName;
+        File dest = new File(filePath + "/" + fileName);
+        // 检测是否存在目录
+        if (!dest.getParentFile().exists()) {
+            dest.getParentFile().mkdirs();
+        }
+        try {
+            file.transferTo(dest);
+            return fileName;
+        } catch (Exception e) {
+            throw new GlobalException(CommonEnum.FAILURE.getIndex(), CommonEnum.FAILURE.getValue());
+        }
+    }
+}

+ 257 - 0
src/main/java/com/hywa/map/common/utils/HttpClientUtils.java

@@ -0,0 +1,257 @@
+package com.hywa.map.common.utils;
+
+import org.apache.http.*;
+import org.apache.http.client.entity.UrlEncodedFormEntity;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.config.Registry;
+import org.apache.http.config.RegistryBuilder;
+import org.apache.http.conn.socket.ConnectionSocketFactory;
+import org.apache.http.conn.socket.PlainConnectionSocketFactory;
+import org.apache.http.conn.ssl.NoopHostnameVerifier;
+import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
+import org.apache.http.conn.ssl.TrustStrategy;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
+import org.apache.http.message.BasicNameValuePair;
+import org.apache.http.ssl.SSLContextBuilder;
+import org.apache.http.util.EntityUtils;
+
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+import java.security.cert.CertificateException;
+import java.security.cert.X509Certificate;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+public class HttpClientUtils {
+    private static final String HTTP = "http";
+    private static final String HTTPS = "https";
+    private static SSLConnectionSocketFactory sslsf = null;
+    private static PoolingHttpClientConnectionManager cm = null;
+    private static SSLContextBuilder builder = null;
+
+    static {
+        try {
+            builder = new SSLContextBuilder();
+            // 全部信任 不做身份鉴定
+            builder.loadTrustMaterial(null, new TrustStrategy() {
+                @Override
+                public boolean isTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException {
+                    return true;
+                }
+            });
+            sslsf = new SSLConnectionSocketFactory(builder.build(), new String[]{"SSLv2Hello", "SSLv3", "TLSv1", "TLSv1.2"}, null, NoopHostnameVerifier.INSTANCE);
+            Registry<ConnectionSocketFactory> registry = RegistryBuilder.<ConnectionSocketFactory>create()
+                    .register(HTTP, new PlainConnectionSocketFactory())
+                    .register(HTTPS, sslsf)
+                    .build();
+            cm = new PoolingHttpClientConnectionManager(registry);
+            cm.setMaxTotal(200);//max connection
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    /**
+     * Build queryString of the url
+     */
+    private static String buildUrlWithQueryString(String url, Map<String, String> queryParas) {
+        if (queryParas == null || queryParas.isEmpty()) {
+            return url;
+        }
+
+        StringBuilder sb = new StringBuilder(url);
+        boolean isFirst;
+        if (url.indexOf('?') == -1) {
+            isFirst = true;
+            sb.append('?');
+        } else {
+            isFirst = false;
+        }
+
+        for (Map.Entry<String, String> entry : queryParas.entrySet()) {
+            if (isFirst) {
+                isFirst = false;
+            } else {
+                sb.append('&');
+            }
+
+            String key = entry.getKey();
+            String value = entry.getValue();
+            if (StrKit.notBlank(value)) {
+                try {
+                    value = URLEncoder.encode(value, "UTF-8");
+                } catch (UnsupportedEncodingException e) {
+                    throw new RuntimeException(e);
+                }
+            }
+            sb.append(key).append('=').append(value);
+        }
+        return sb.toString();
+    }
+
+    public static String get(String url, Map<String, String> param) throws Exception {
+        return get(url, null, param, null);
+    }
+
+    /**
+     * httpClient post请求
+     *
+     * @param url    请求url
+     * @param header 头部信息
+     * @param param  请求参数 form提交适用
+     * @param entity 请求实体 json/xml提交适用
+     * @return 可能为空 需要处理
+     * @throws Exception
+     */
+    public static String get(String url, Map<String, String> header, Map<String, String> param, HttpEntity entity) throws Exception {
+        String result = "";
+        CloseableHttpClient httpClient = null;
+        try {
+            httpClient = getHttpClient();
+            url = buildUrlWithQueryString(url, param);
+            HttpGet httpGet = new HttpGet(url);
+            httpGet.setHeader("Content-type", "application/json");
+            // 设置头信息
+            if (header != null && header.size() > 0) {
+                for (Map.Entry<String, String> entry : header.entrySet()) {
+                    httpGet.addHeader(entry.getKey(), entry.getValue());
+                }
+            }
+            //HttpResponse httpResponse = httpClient.execute(httpGet);
+            CloseableHttpResponse  httpResponse = httpClient.execute(httpGet);
+            int statusCode = httpResponse.getStatusLine().getStatusCode();
+            if (statusCode == HttpStatus.SC_OK) {
+                HttpEntity resEntity = httpResponse.getEntity();
+                result = EntityUtils.toString(resEntity);
+            } else {
+                //readHttpResponse(httpResponse);
+                result = "";
+            }
+            httpResponse.close();
+        } catch (Exception e) {
+            throw e;
+        } finally {
+            if (httpClient != null) {
+                httpClient.close();
+            }
+
+        }
+        return result;
+    }
+
+    /**
+     * httpClient post请求
+     *
+     * @param url    请求url
+     * @param header 头部信息
+     * @param param  请求参数 form提交适用
+     * @param entity 请求实体 json/xml提交适用
+     * @return 可能为空 需要处理
+     * @throws Exception
+     */
+    public static String post(String url, Map<String, String> header, Map<String, String> param, HttpEntity entity) throws Exception {
+        String result = "";
+        CloseableHttpClient httpClient = null;
+        try {
+            httpClient = getHttpClient();
+            HttpPost httpPost = new HttpPost(url);
+            httpPost.setHeader("Content-type", "application/json");
+            // 设置头信息
+            if (header != null && header.size() > 0) {
+                for (Map.Entry<String, String> entry : header.entrySet()) {
+                    httpPost.addHeader(entry.getKey(), entry.getValue());
+                }
+            }
+            // 设置请求参数
+            if (param != null && param.size() > 0) {
+                List<NameValuePair> formparams = new ArrayList<NameValuePair>();
+                for (Map.Entry<String, String> entry : param.entrySet()) {
+                    //给参数赋值
+                    formparams.add(new BasicNameValuePair(entry.getKey(), entry.getValue()));
+                }
+                UrlEncodedFormEntity urlEncodedFormEntity = new UrlEncodedFormEntity(formparams, Consts.UTF_8);
+                httpPost.setEntity(urlEncodedFormEntity);
+            }
+            // 设置实体 优先级高
+            if (entity != null) {
+                httpPost.setEntity(entity);
+            }
+            HttpResponse httpResponse = httpClient.execute(httpPost);
+            int statusCode = httpResponse.getStatusLine().getStatusCode();
+            if (statusCode == HttpStatus.SC_OK) {
+                HttpEntity resEntity = httpResponse.getEntity();
+                result = EntityUtils.toString(resEntity);
+            } else {
+                //readHttpResponse(httpResponse);
+                result = "";
+            }
+        } catch (Exception e) {
+            throw e;
+        } finally {
+            if (httpClient != null) {
+                httpClient.close();
+            }
+        }
+        return result;
+    }
+
+    /**
+     * httpClient post请求
+     *
+     * @param url     请求url
+     * @param jsonStr 请求参数json格式
+     * @return 可能为空 需要处理
+     * @throws Exception
+     */
+    public static String post(String url, String jsonStr) throws Exception {
+        StringEntity requestEntity = new StringEntity(jsonStr, "utf-8");
+        requestEntity.setContentEncoding("UTF-8");
+        return HttpClientUtils.post(url, null, null, requestEntity);
+    }
+
+    public static CloseableHttpClient getHttpClient() throws Exception {
+        CloseableHttpClient httpClient = HttpClients.custom()
+                .setSSLSocketFactory(sslsf)
+                .setConnectionManager(cm)
+                .setConnectionManagerShared(true)
+                .build();
+        return httpClient;
+    }
+
+    public static String readHttpResponse(HttpResponse httpResponse)
+            throws ParseException, IOException {
+        StringBuilder builder = new StringBuilder();
+        // 获取响应消息实体
+        HttpEntity entity = httpResponse.getEntity();
+        // 响应状态
+        builder.append("status:" + httpResponse.getStatusLine());
+        builder.append("headers:");
+        HeaderIterator iterator = httpResponse.headerIterator();
+        while (iterator.hasNext()) {
+            builder.append("\t" + iterator.next());
+        }
+        // 判断响应实体是否为空
+        if (entity != null) {
+            String responseString = EntityUtils.toString(entity);
+            builder.append("response length:" + responseString.length());
+            builder.append("response content:" + responseString.replace("\r\n", ""));
+        }
+        return builder.toString();
+    }
+
+    public static void main(String[] args) {
+        try {
+            String str = HttpClientUtils.post("https://restapi.amap.com/v3/weather/weatherInfo", "{\"tel\":\"18515333265\"}");
+            System.out.println("http返回:" + str);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+}

+ 265 - 0
src/main/java/com/hywa/map/common/utils/HttpUtils.java

@@ -0,0 +1,265 @@
+package com.hywa.map.common.utils;
+
+import javax.net.ssl.*;
+import javax.servlet.http.HttpServletRequest;
+import java.io.*;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.net.URLEncoder;
+import java.security.KeyManagementException;
+import java.security.NoSuchAlgorithmException;
+import java.security.NoSuchProviderException;
+import java.security.cert.CertificateException;
+import java.security.cert.X509Certificate;
+import java.util.Map;
+
+public class HttpUtils {
+    private HttpUtils() {
+    }
+
+
+    /**
+     * https 域名校验
+     */
+    private static class TrustAnyHostnameVerifier implements HostnameVerifier {
+        public boolean verify(String hostname, SSLSession session) {
+            return true;
+        }
+    }
+
+    /**
+     * https 证书管理
+     */
+    private static class TrustAnyTrustManager implements X509TrustManager {
+        public X509Certificate[] getAcceptedIssuers() {
+            return null;
+        }
+
+        public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException {
+        }
+
+        public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException {
+        }
+    }
+
+    private static final String GET = "GET";
+    private static final String POST = "POST";
+    private static String CHARSET = "UTF-8";
+
+    private static final SSLSocketFactory sslSocketFactory = initSSLSocketFactory();
+    private static final TrustAnyHostnameVerifier trustAnyHostnameVerifier = new TrustAnyHostnameVerifier();
+
+    private static SSLSocketFactory initSSLSocketFactory() {
+        try {
+            TrustManager[] tm = {new TrustAnyTrustManager()};
+            SSLContext sslContext = SSLContext.getInstance("TLS");    // ("TLS", "SunJSSE");
+            sslContext.init(null, tm, new java.security.SecureRandom());
+            return sslContext.getSocketFactory();
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    public static void setCharSet(String charSet) {
+        if (StrKit.isBlank(charSet)) {
+            throw new IllegalArgumentException("charSet can not be blank.");
+        }
+        HttpUtils.CHARSET = charSet;
+    }
+
+    private static HttpURLConnection getHttpConnection(String url, String method, Map<String, String> headers) throws IOException, NoSuchAlgorithmException, NoSuchProviderException, KeyManagementException {
+        URL _url = new URL(url);
+        HttpURLConnection conn = (HttpURLConnection) _url.openConnection();
+        if (conn instanceof HttpsURLConnection) {
+            ((HttpsURLConnection) conn).setSSLSocketFactory(sslSocketFactory);
+            ((HttpsURLConnection) conn).setHostnameVerifier(trustAnyHostnameVerifier);
+        }
+
+        conn.setRequestMethod(method);
+        conn.setDoOutput(true);
+        conn.setDoInput(true);
+
+        conn.setConnectTimeout(19000);
+        conn.setReadTimeout(19000);
+
+        conn.setRequestProperty("Content-Type", "application/json");
+        conn.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.146 Safari/537.36");
+
+        if (headers != null && !headers.isEmpty()) {
+            for (Map.Entry<String, String> entry : headers.entrySet()) {
+                conn.setRequestProperty(entry.getKey(), entry.getValue());
+            }
+        }
+
+        return conn;
+    }
+
+    /**
+     * Send GET request
+     */
+    public static String get(String url, Map<String, String> queryParas, Map<String, String> headers) {
+        HttpURLConnection conn = null;
+        try {
+            conn = getHttpConnection(buildUrlWithQueryString(url, queryParas), GET, headers);
+            conn.connect();
+            return readResponseString(conn);
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        } finally {
+            if (conn != null) {
+                conn.disconnect();
+            }
+        }
+    }
+
+    public static String get(String url, Map<String, String> queryParas) {
+        return get(url, queryParas, null);
+    }
+
+    public static String get(String url) {
+        return get(url, null, null);
+    }
+
+    /**
+     * Send POST request
+     */
+    public static String post(String url, Map<String, String> queryParas, String data, Map<String, String> headers) {
+        HttpURLConnection conn = null;
+        try {
+            conn = getHttpConnection(buildUrlWithQueryString(url, queryParas), POST, headers);
+            conn.connect();
+
+            if (data != null) {
+                OutputStream out = conn.getOutputStream();
+                out.write(data.getBytes(CHARSET));
+                out.flush();
+                out.close();
+            }
+
+            return readResponseString(conn);
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        } finally {
+            if (conn != null) {
+                conn.disconnect();
+            }
+        }
+    }
+
+    public static String post(String url, Map<String, String> queryParas, String data) {
+        return post(url, queryParas, data, null);
+    }
+
+    public static String post(String url, String data, Map<String, String> headers) {
+        return post(url, null, data, headers);
+    }
+
+    public static String post(String url, String data) {
+        return post(url, null, data, null);
+    }
+
+    private static String readResponseString(HttpURLConnection conn) {
+        BufferedReader reader = null;
+        try {
+            StringBuilder ret;
+            reader = new BufferedReader(new InputStreamReader(conn.getInputStream(), CHARSET));
+            String line = reader.readLine();
+            if (line != null) {
+                ret = new StringBuilder();
+                ret.append(line);
+            } else {
+                return "";
+            }
+
+            while ((line = reader.readLine()) != null) {
+                ret.append('\n').append(line);
+            }
+            return ret.toString();
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        } finally {
+            if (reader != null) {
+                try {
+                    reader.close();
+                } catch (IOException e) {
+                    LogKit.error(e.getMessage(), e);
+                }
+            }
+        }
+    }
+
+    /**
+     * Build queryString of the url
+     */
+    private static String buildUrlWithQueryString(String url, Map<String, String> queryParas) {
+        if (queryParas == null || queryParas.isEmpty()) {
+            return url;
+        }
+
+        StringBuilder sb = new StringBuilder(url);
+        boolean isFirst;
+        if (url.indexOf('?') == -1) {
+            isFirst = true;
+            sb.append('?');
+        } else {
+            isFirst = false;
+        }
+
+        for (Map.Entry<String, String> entry : queryParas.entrySet()) {
+            if (isFirst) {
+                isFirst = false;
+            } else {
+                sb.append('&');
+            }
+
+            String key = entry.getKey();
+            String value = entry.getValue();
+            if (StrKit.notBlank(value)) {
+                try {
+                    value = URLEncoder.encode(value, CHARSET);
+                } catch (UnsupportedEncodingException e) {
+                    throw new RuntimeException(e);
+                }
+            }
+            sb.append(key).append('=').append(value);
+        }
+        return sb.toString();
+    }
+
+    public static String readData(HttpServletRequest request) {
+        BufferedReader br = null;
+        try {
+            StringBuilder ret;
+            br = request.getReader();
+
+            String line = br.readLine();
+            if (line != null) {
+                ret = new StringBuilder();
+                ret.append(line);
+            } else {
+                return "";
+            }
+
+            while ((line = br.readLine()) != null) {
+                ret.append('\n').append(line);
+            }
+
+            return ret.toString();
+        } catch (IOException e) {
+            throw new RuntimeException(e);
+        } finally {
+            if (br != null) {
+                try {
+                    br.close();
+                } catch (IOException e) {
+                    LogKit.error(e.getMessage(), e);
+                }
+            }
+        }
+    }
+
+    @Deprecated
+    public static String readIncommingRequestData(HttpServletRequest request) {
+        return readData(request);
+    }
+}

+ 32 - 0
src/main/java/com/hywa/map/common/utils/IDUtils.java

@@ -0,0 +1,32 @@
+package com.hywa.map.common.utils;
+
+import com.hywa.map.config.interceptor.TokenManager;
+import com.hywa.map.config.interceptor.TokenModel;
+
+import javax.servlet.http.HttpServletRequest;
+
+import static com.hywa.map.common.ConstantPool.SPLIT;
+
+public class IDUtils {
+    /**
+     * 生成随机数,用作查询码
+     */
+    public static long getSearchId() {
+        //取当前时间的长整形值包含毫秒
+        long millis = System.currentTimeMillis();
+        String str=millis+"";
+        long id = new Long(str.substring(0,11));
+        return id;
+    }
+
+    /**
+     * 获得用户id
+     */
+    public static String getUserId(HttpServletRequest req) {
+        TokenManager tokenManager=(TokenManager)SpringContext.getBean("redisTokenManager");
+        TokenModel accessToken = tokenManager.getToken(req.getHeader("accessToken"));
+        return accessToken.getUserId().split(SPLIT)[1];
+    }
+
+
+}

+ 58 - 0
src/main/java/com/hywa/map/common/utils/JsonUtils.java

@@ -0,0 +1,58 @@
+package com.hywa.map.common.utils;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.JavaType;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+import java.util.List;
+
+/**
+ * 自定义响应结构
+ */
+public class JsonUtils {
+
+    // 定义jackson对象
+    private static final ObjectMapper MAPPER = new ObjectMapper();
+
+    /**
+     * 将对象转换成json字符串。
+     */
+    public static String objectToJson(Object data) {
+        try {
+            String string = MAPPER.writeValueAsString(data);
+            return string;
+        } catch (JsonProcessingException e) {
+            e.printStackTrace();
+        }
+        return null;
+    }
+
+    /**
+     * 将json结果集转化为对象
+     */
+    public static <T> T jsonToPojo(String jsonData, Class<T> beanType) {
+        try {
+            T t = MAPPER.readValue(jsonData, beanType);
+            return t;
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return null;
+    }
+
+    /**
+     * 将json数据转换成pojo对象list
+     */
+    public static <T>List<T> jsonToList(String jsonData, Class<T> beanType) {
+        JavaType javaType = MAPPER.getTypeFactory().constructParametricType(List.class, beanType);
+        try {
+            List<T> list = MAPPER.readValue(jsonData, javaType);
+            return list;
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+        return null;
+    }
+
+}

+ 57 - 0
src/main/java/com/hywa/map/common/utils/ListUtils.java

@@ -0,0 +1,57 @@
+package com.hywa.map.common.utils;
+
+import java.util.*;
+
+public class ListUtils {
+
+    /**
+     * 根据map中的某个key 去除List中重复的map
+     *
+     * @param list
+     * @param mapKey
+     * @return
+     */
+    public static List<Map<String, String>> removeRepMapByKey(List<Map<String, String>>
+                                                                      list, String mapKey) {
+        if (list == null || list.size() <= 0) {
+            return null;
+        }
+        //把list中的数据转换成msp,去掉同一id值多余数据,保留查找到第一个id值对应的数据
+        List<Map<String, String>> listMap = new ArrayList<>();
+        Map<String, Map> msp = new HashMap<>();
+        for (int i = list.size() - 1; i >= 0; i--) {
+            Map map = list.get(i);
+            String id = (String) map.get(mapKey);
+            map.remove(mapKey);
+            msp.put(id, map);
+        }
+        //把msp再转换成list,就会得到根据某一字段去掉重复的数据的List<Map>
+        Set<String> mspKey = msp.keySet();
+        for (String key : mspKey) {
+            Map newMap = msp.get(key);
+            newMap.put(mapKey, key);
+            listMap.add(newMap);
+        }
+        return listMap;
+    }
+
+    /**
+     * 根据map中的某个key 排序
+     *
+     * @param list
+     * @param sortKey
+     * @param sortType 1-升序 2-降序
+     * @return
+     */
+    public static List<Map<String, String>> sortMapByKey(List<Map<String, String>>
+                                                                 list, String sortKey, int sortType) {
+        Collections.sort(list, new Comparator<Map<String, String>>() {
+            public int compare(Map<String, String> o1, Map<String, String> o2) {
+                Integer name1 = Integer.valueOf(o1.get(sortKey).toString());//name1是从list里面拿出来的一个
+                Integer name2 = Integer.valueOf(o2.get(sortKey).toString()); //name1是从list里面拿出来的第二个name
+                return 1 == sortType ? name1.compareTo(name2) : name2.compareTo(name1);
+            }
+        });
+        return list;
+    }
+}

+ 74 - 0
src/main/java/com/hywa/map/common/utils/LogKit.java

@@ -0,0 +1,74 @@
+package com.hywa.map.common.utils;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class LogKit {
+    private static class Holder {
+        private static Logger log = LoggerFactory.getLogger(LogKit.class);
+    }
+
+    /**
+     * 当通过 Constants.setLogFactory(...) 或者
+     * LogManager.me().setDefaultLogFacotyr(...)
+     * 指定默认日志工厂以后,重置一下内部 Log 对象,以便使内部日志实现与系统保持一致
+     */
+    public static void synchronizeLog() {
+        Holder.log = LoggerFactory.getLogger(LogKit.class);
+    }
+
+    /**
+     * Do nothing.
+     */
+    public static void logNothing(Throwable t) {
+
+    }
+
+    public static void debug(String message) {
+        Holder.log.debug(message);
+    }
+
+    public static void debug(String message, Throwable t) {
+        Holder.log.debug(message, t);
+    }
+
+    public static void info(String message) {
+        Holder.log.info(message);
+    }
+
+    public static void info(String message, Throwable t) {
+        Holder.log.info(message, t);
+    }
+
+    public static void warn(String message) {
+        Holder.log.warn(message);
+    }
+
+    public static void warn(String message, Throwable t) {
+        Holder.log.warn(message, t);
+    }
+
+    public static void error(String message) {
+        Holder.log.error(message);
+    }
+
+    public static void error(String message, Throwable t) {
+        Holder.log.error(message, t);
+    }
+
+    public static boolean isDebugEnabled() {
+        return Holder.log.isDebugEnabled();
+    }
+
+    public static boolean isInfoEnabled() {
+        return Holder.log.isInfoEnabled();
+    }
+
+    public static boolean isWarnEnabled() {
+        return Holder.log.isWarnEnabled();
+    }
+
+    public static boolean isErrorEnabled() {
+        return Holder.log.isErrorEnabled();
+    }
+}

+ 826 - 0
src/main/java/com/hywa/map/common/utils/LunarCalendar.java

@@ -0,0 +1,826 @@
+package com.hywa.map.common.utils;
+
+import java.io.Serializable;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
+
+/**
+ * 农历工具类
+ * solar2Lunar 返回农历如:二〇〇四年闰二月初四
+ *
+ * @author hywa
+ */
+public class LunarCalendar implements Serializable {
+    /**
+     * serialVersionUID
+     */
+    private static final long serialVersionUID = 7241031233810655166L;
+
+    /**
+     * 支持的最小年份
+     */
+    public final static int MINIYEAR = 1900;
+
+    /**
+     * 支持的最大年份
+     */
+    public final static int MAXYEAR = 2099;
+
+    /**
+     * 1900年-2099年间的农历信息.<br>
+     * <li>每个数组的第一个数表示该年闰月月份,为0表示不闰月</li>
+     * <li>数组中其他数表示该月初一对应的公历日期</li>
+     */
+    private final static int[][] LuarInfo = {{8, 131, 301, 331, 429, 528, 627, 726, 825, 924, 1023, 1122, 1222, 1320}, // 1900
+            {0, 219, 320, 419, 518, 616, 716, 814, 913, 1012, 1111, 1211, 1310}, // 1901
+            {0, 208, 310, 408, 508, 606, 705, 804, 902, 1002, 1031, 1130, 1230}, // 1902
+            {5, 129, 227, 329, 427, 527, 625, 724, 823, 921, 1020, 1119, 1219, 1317}, // 1903
+            {0, 216, 317, 416, 515, 614, 713, 811, 910, 1009, 1107, 1207, 1306}, // 1904
+            {0, 204, 306, 405, 504, 603, 703, 801, 830, 929, 1028, 1127, 1226}, // 1905
+            {4, 125, 223, 325, 424, 523, 622, 721, 820, 918, 1018, 1116, 1216, 1314}, // 1906
+            {0, 213, 314, 413, 512, 611, 710, 809, 908, 1007, 1106, 1205, 1304}, // 1907
+            {0, 202, 303, 401, 430, 530, 629, 728, 827, 925, 1025, 1124, 1223}, // 1908
+            {2, 122, 220, 322, 420, 519, 618, 717, 816, 914, 1014, 1113, 1213, 1311}, // 1909
+            {0, 210, 311, 410, 509, 607, 707, 805, 904, 1003, 1102, 1202, 1301}, // 1910
+            {6, 130, 301, 330, 429, 528, 626, 726, 824, 922, 1022, 1121, 1220, 1319}, // 1911
+            {0, 218, 319, 417, 517, 615, 714, 813, 911, 1010, 1109, 1209, 1307}, // 1912
+            {0, 206, 308, 407, 506, 605, 704, 802, 901, 930, 1029, 1128, 1227}, // 1913
+            {5, 126, 225, 327, 425, 525, 623, 723, 821, 920, 1019, 1117, 1217, 1315}, // 1914
+            {0, 214, 316, 414, 514, 613, 712, 811, 909, 1009, 1107, 1207, 1305}, // 1915
+            {0, 203, 304, 403, 502, 601, 630, 730, 829, 927, 1027, 1125, 1225}, // 1916
+            {2, 123, 222, 323, 421, 521, 619, 719, 818, 916, 1016, 1115, 1214, 1313}, // 1917
+            {0, 211, 313, 411, 510, 609, 708, 807, 905, 1005, 1104, 1203, 1302}, // 1918
+            {7, 201, 302, 401, 430, 529, 628, 727, 825, 924, 1024, 1122, 1222, 1321}, // 1919
+            {0, 220, 320, 419, 518, 616, 716, 814, 912, 1012, 1110, 1210, 1309}, // 1920
+            {0, 208, 310, 408, 508, 606, 705, 804, 902, 1001, 1031, 1129, 1229}, // 1921
+            {5, 128, 227, 328, 427, 527, 625, 724, 823, 921, 1020, 1119, 1218, 1317}, // 1922
+            {0, 216, 317, 416, 516, 614, 714, 812, 911, 1010, 1108, 1208, 1306}, // 1923
+            {0, 205, 305, 404, 504, 602, 702, 801, 830, 929, 1028, 1127, 1226}, // 1924
+            {4, 124, 223, 324, 423, 522, 621, 721, 819, 918, 1018, 1116, 1216, 1314}, // 1925
+            {0, 213, 314, 412, 512, 610, 710, 808, 907, 1007, 1105, 1205, 1304}, // 1926
+            {0, 202, 304, 402, 501, 531, 629, 729, 827, 926, 1025, 1124, 1224}, // 1927
+            {2, 123, 221, 322, 420, 519, 618, 717, 815, 914, 1013, 1112, 1212, 1311}, // 1928
+            {0, 210, 311, 410, 509, 607, 707, 805, 903, 1003, 1101, 1201, 1231}, // 1929
+            {6, 130, 228, 330, 429, 528, 626, 726, 824, 922, 1022, 1120, 1220, 1319}, // 1930
+            {0, 217, 319, 418, 517, 616, 715, 814, 912, 1011, 1110, 1209, 1308}, // 1931
+            {0, 206, 307, 406, 506, 604, 704, 802, 901, 930, 1029, 1128, 1227}, // 1932
+            {5, 126, 224, 326, 425, 524, 623, 722, 821, 920, 1019, 1118, 1217, 1315}, // 1933
+            {0, 214, 315, 414, 513, 612, 712, 810, 909, 1008, 1107, 1207, 1305}, // 1934
+            {0, 204, 305, 403, 503, 601, 701, 730, 829, 928, 1027, 1126, 1226}, // 1935
+            {3, 124, 223, 323, 421, 521, 619, 718, 817, 916, 1015, 1114, 1214, 1313}, // 1936
+            {0, 211, 313, 411, 510, 609, 708, 806, 905, 1004, 1103, 1203, 1302}, // 1937
+            {7, 131, 302, 401, 430, 529, 628, 727, 825, 924, 1023, 1122, 1222, 1320}, // 1938
+            {0, 219, 321, 420, 519, 617, 717, 815, 913, 1013, 1111, 1211, 1309}, // 1939
+            {0, 208, 309, 408, 507, 606, 705, 804, 902, 1001, 1031, 1129, 1229}, // 1940
+            {6, 127, 226, 328, 426, 526, 625, 724, 823, 921, 1020, 1119, 1218, 1317}, // 1941
+            {0, 215, 317, 415, 515, 614, 713, 812, 910, 1010, 1108, 1208, 1306}, // 1942
+            {0, 205, 306, 405, 504, 603, 702, 801, 831, 929, 1029, 1127, 1227}, // 1943
+            {4, 125, 224, 324, 423, 522, 621, 720, 819, 917, 1017, 1116, 1215, 1314}, // 1944
+            {0, 213, 314, 412, 512, 610, 709, 808, 906, 1006, 1105, 1205, 1303}, // 1945
+            {0, 202, 304, 402, 501, 531, 629, 728, 827, 925, 1025, 1124, 1223}, // 1946
+            {2, 122, 221, 323, 421, 520, 619, 718, 816, 915, 1014, 1113, 1212, 1311}, // 1947
+            {0, 210, 311, 409, 509, 607, 707, 805, 903, 1003, 1101, 1201, 1230}, // 1948
+            {7, 129, 228, 329, 428, 528, 626, 726, 824, 922, 1022, 1120, 1220, 1318}, // 1949
+            {0, 217, 318, 417, 517, 615, 715, 814, 912, 1011, 1110, 1209, 1308}, // 1950
+            {0, 206, 308, 406, 506, 605, 704, 803, 901, 1001, 1030, 1129, 1228}, // 1951
+            {5, 127, 225, 326, 424, 524, 622, 722, 820, 919, 1019, 1117, 1217, 1315}, // 1952
+            {0, 214, 315, 414, 513, 611, 711, 810, 908, 1008, 1107, 1206, 1305}, // 1953
+            {0, 203, 305, 403, 503, 601, 630, 730, 828, 927, 1027, 1126, 1225}, // 1954
+            {3, 124, 222, 324, 422, 522, 620, 719, 818, 916, 1016, 1114, 1214, 1313}, // 1955
+            {0, 212, 312, 411, 510, 609, 708, 806, 905, 1004, 1103, 1203, 1301}, // 1956
+            {8, 131, 302, 331, 430, 529, 628, 727, 825, 924, 1023, 1122, 1221, 1320}, // 1957
+            {0, 218, 320, 419, 519, 617, 717, 815, 913, 1013, 1111, 1211, 1309}, // 1958
+            {0, 208, 309, 408, 508, 606, 706, 804, 903, 1002, 1101, 1130, 1230}, // 1959
+            {6, 128, 227, 327, 426, 525, 624, 724, 822, 921, 1020, 1119, 1218, 1317}, // 1960
+            {0, 215, 317, 415, 515, 613, 713, 811, 910, 1010, 1108, 1208, 1306}, // 1961
+            {0, 205, 306, 405, 504, 602, 702, 731, 830, 929, 1028, 1127, 1227}, // 1962
+            {4, 125, 224, 325, 424, 523, 621, 721, 819, 918, 1017, 1116, 1216, 1315}, // 1963
+            {0, 213, 314, 412, 512, 610, 709, 808, 906, 1006, 1104, 1204, 1303}, // 1964
+            {0, 202, 303, 402, 501, 531, 629, 728, 827, 925, 1024, 1123, 1223}, // 1965
+            {3, 121, 220, 322, 421, 520, 619, 718, 816, 915, 1014, 1112, 1212, 1311}, // 1966
+            {0, 209, 311, 410, 509, 608, 708, 806, 904, 1004, 1102, 1202, 1231}, // 1967
+            {7, 130, 228, 329, 427, 527, 626, 725, 824, 922, 1022, 1120, 1220, 1318}, // 1968
+            {0, 217, 318, 417, 516, 615, 714, 813, 912, 1011, 1110, 1209, 1308}, // 1969
+            {0, 206, 308, 406, 505, 604, 703, 802, 901, 930, 1030, 1129, 1228}, // 1970
+            {5, 127, 225, 327, 425, 524, 623, 722, 821, 919, 1019, 1118, 1218, 1316}, // 1971
+            {0, 215, 315, 414, 513, 611, 711, 809, 908, 1007, 1106, 1206, 1304}, // 1972
+            {0, 203, 305, 403, 503, 601, 630, 730, 828, 926, 1026, 1125, 1224}, // 1973
+            {4, 123, 222, 324, 422, 522, 620, 719, 818, 916, 1015, 1114, 1214, 1312}, // 1974
+            {0, 211, 313, 412, 511, 610, 709, 807, 906, 1005, 1103, 1203, 1301}, // 1975
+            {8, 131, 301, 331, 429, 529, 627, 727, 825, 924, 1023, 1121, 1221, 1319}, // 1976
+            {0, 218, 320, 418, 518, 617, 716, 815, 913, 1013, 1111, 1211, 1309}, // 1977
+            {0, 207, 309, 407, 507, 606, 705, 804, 902, 1002, 1101, 1130, 1230}, // 1978
+            {6, 128, 227, 328, 426, 526, 624, 724, 823, 921, 1021, 1120, 1219, 1318}, // 1979
+            {0, 216, 317, 415, 514, 613, 712, 811, 909, 1009, 1108, 1207, 1306}, // 1980
+            {0, 205, 306, 405, 504, 602, 702, 731, 829, 928, 1028, 1126, 1226}, // 1981
+            {4, 125, 224, 325, 424, 523, 621, 721, 819, 917, 1017, 1115, 1215, 1314}, // 1982
+            {0, 213, 315, 413, 513, 611, 710, 809, 907, 1006, 1105, 1204, 1303}, // 1983
+            {10, 202, 303, 401, 501, 531, 629, 728, 827, 925, 1024, 1123, 1222, 1321}, // 1984
+            {0, 220, 321, 420, 520, 618, 718, 816, 915, 1014, 1112, 1212, 1310}, // 1985
+            {0, 209, 310, 409, 509, 607, 707, 806, 904, 1004, 1102, 1202, 1231}, // 1986
+            {6, 129, 228, 329, 428, 527, 626, 726, 824, 923, 1023, 1121, 1221, 1319}, // 1987
+            {0, 217, 318, 416, 516, 614, 714, 812, 911, 1011, 1109, 1209, 1308}, // 1988
+            {0, 206, 308, 406, 505, 604, 703, 802, 831, 930, 1029, 1128, 1228}, // 1989
+            {5, 127, 225, 327, 425, 524, 623, 722, 820, 919, 1018, 1117, 1217, 1316}, // 1990
+            {0, 215, 316, 415, 514, 612, 712, 810, 908, 1008, 1106, 1206, 1305}, // 1991
+            {0, 204, 304, 403, 503, 601, 630, 730, 828, 926, 1026, 1124, 1224}, // 1992
+            {3, 123, 221, 323, 422, 521, 620, 719, 818, 916, 1015, 1114, 1213, 1312}, // 1993
+            {0, 210, 312, 411, 511, 609, 709, 807, 906, 1005, 1103, 1203, 1301}, // 1994
+            {8, 131, 301, 331, 430, 529, 628, 727, 826, 925, 1024, 1122, 1222, 1320}, // 1995
+            {0, 219, 319, 418, 517, 616, 715, 814, 912, 1012, 1111, 1211, 1309}, // 1996
+            {0, 207, 309, 407, 507, 605, 705, 803, 902, 1002, 1031, 1130, 1230}, // 1997
+            {5, 128, 227, 328, 426, 526, 624, 723, 822, 921, 1020, 1119, 1219, 1317}, // 1998
+            {0, 216, 318, 416, 515, 614, 713, 811, 910, 1009, 1108, 1208, 1307}, // 1999
+            {0, 205, 306, 405, 504, 602, 702, 731, 829, 928, 1027, 1126, 1226}, // 2000
+            {4, 124, 223, 325, 423, 523, 621, 721, 819, 917, 1017, 1115, 1215, 1313}, // 2001
+            {0, 212, 314, 413, 512, 611, 710, 809, 907, 1006, 1105, 1204, 1303}, // 2002
+            {0, 201, 303, 402, 501, 531, 630, 729, 828, 926, 1025, 1124, 1223}, // 2003
+            {2, 122, 220, 321, 419, 519, 618, 717, 816, 914, 1014, 1112, 1212, 1310}, // 2004
+            {0, 209, 310, 409, 508, 607, 706, 805, 904, 1003, 1102, 1201, 1231}, // 2005
+            {7, 129, 228, 329, 428, 527, 626, 725, 824, 922, 1022, 1121, 1220, 1319}, // 2006
+            {0, 218, 319, 417, 517, 615, 714, 813, 911, 1011, 1110, 1210, 1308}, // 2007
+            {0, 207, 308, 406, 505, 604, 703, 801, 831, 929, 1029, 1128, 1227}, // 2008
+            {5, 126, 225, 327, 425, 524, 623, 722, 820, 919, 1018, 1117, 1216, 1315}, // 2009
+            {0, 214, 316, 414, 514, 612, 712, 810, 908, 1008, 1106, 1206, 1304}, // 2010
+            {0, 203, 305, 403, 503, 602, 701, 731, 829, 927, 1027, 1125, 1225}, // 2011
+            {4, 123, 222, 322, 421, 521, 619, 719, 817, 916, 1015, 1114, 1213, 1312}, // 2012
+            {0, 210, 312, 410, 510, 608, 708, 807, 905, 1005, 1103, 1203, 1301}, // 2013
+            {9, 131, 301, 331, 429, 529, 627, 727, 825, 924, 1024, 1122, 1222, 1320}, // 2014
+            {0, 219, 320, 419, 518, 616, 716, 814, 913, 1013, 1112, 1211, 1310}, // 2015
+            {0, 208, 309, 407, 507, 605, 704, 803, 901, 1001, 1031, 1129, 1229}, // 2016
+            {6, 128, 226, 328, 426, 526, 624, 723, 822, 920, 1020, 1118, 1218, 1317}, // 2017
+            {0, 216, 317, 416, 515, 614, 713, 811, 910, 1009, 1108, 1207, 1306}, // 2018
+            {0, 205, 307, 405, 505, 603, 703, 801, 830, 929, 1028, 1126, 1226}, // 2019
+            {4, 125, 223, 324, 423, 523, 621, 721, 819, 917, 1017, 1115, 1215, 1313}, // 2020
+            {0, 212, 313, 412, 512, 610, 710, 808, 907, 1006, 1105, 1204, 1303}, // 2021
+            {0, 201, 303, 401, 501, 530, 629, 729, 827, 926, 1025, 1124, 1223}, // 2022
+            {2, 122, 220, 322, 420, 519, 618, 718, 816, 915, 1015, 1113, 1213, 1311}, // 2023
+            {0, 210, 310, 409, 508, 606, 706, 804, 903, 1003, 1101, 1201, 1231}, // 2024
+            {6, 129, 228, 329, 428, 527, 625, 725, 823, 922, 1021, 1120, 1220, 1319}, // 2025
+            {0, 217, 319, 417, 517, 615, 714, 813, 911, 1010, 1109, 1209, 1308}, // 2026
+            {0, 206, 308, 407, 506, 605, 704, 802, 901, 930, 1029, 1128, 1228}, // 2027
+            {5, 126, 225, 326, 425, 524, 623, 722, 820, 919, 1018, 1116, 1216, 1315}, // 2028
+            {0, 213, 315, 414, 513, 612, 711, 810, 908, 1008, 1106, 1205, 1304}, // 2029
+            {0, 203, 304, 403, 502, 601, 701, 730, 829, 927, 1027, 1125, 1225}, // 2030
+            {3, 123, 221, 323, 422, 521, 620, 719, 818, 917, 1016, 1115, 1214, 1313}, // 2031
+            {0, 211, 312, 410, 509, 608, 707, 806, 905, 1004, 1103, 1203, 1301}, // 2032
+            {7, 131, 301, 331, 429, 528, 627, 726, 825, 923, 1023, 1122, 1222, 1320}, // 2033
+            {0, 219, 320, 419, 518, 616, 716, 814, 913, 1012, 1111, 1211, 1309}, // 2034
+            {0, 208, 310, 408, 508, 606, 705, 804, 902, 1001, 1031, 1130, 1229}, // 2035
+            {6, 128, 227, 328, 426, 526, 624, 723, 822, 920, 1019, 1118, 1217, 1316}, // 2036
+            {0, 215, 317, 416, 515, 614, 713, 811, 910, 1009, 1107, 1207, 1305}, // 2037
+            {0, 204, 306, 405, 504, 603, 702, 801, 830, 929, 1028, 1126, 1226}, // 2038
+            {5, 124, 223, 325, 423, 523, 622, 721, 820, 918, 1018, 1116, 1216, 1314}, // 2039
+            {0, 212, 313, 411, 511, 610, 709, 808, 906, 1006, 1105, 1204, 1303}, // 2040
+            {0, 201, 302, 401, 430, 530, 628, 728, 827, 925, 1025, 1124, 1223}, // 2041
+            {2, 122, 220, 322, 420, 519, 618, 717, 816, 914, 1014, 1113, 1212, 1311}, // 2042
+            {0, 210, 311, 410, 509, 607, 707, 805, 903, 1003, 1102, 1201, 1231}, // 2043
+            {7, 130, 229, 329, 428, 527, 625, 725, 823, 921, 1021, 1119, 1219, 1318}, // 2044
+            {0, 217, 319, 417, 517, 615, 714, 813, 911, 1010, 1109, 1208, 1307}, // 2045
+            {0, 206, 308, 406, 506, 604, 704, 802, 901, 930, 1029, 1128, 1227}, // 2046
+            {5, 126, 225, 326, 425, 525, 623, 723, 821, 920, 1019, 1117, 1217, 1315}, // 2047
+            {0, 214, 314, 413, 513, 611, 711, 810, 908, 1008, 1106, 1205, 1304}, // 2048
+            {0, 202, 304, 402, 502, 531, 630, 730, 828, 927, 1027, 1125, 1225}, // 2049
+            {3, 123, 221, 323, 421, 521, 619, 719, 817, 916, 1016, 1114, 1214, 1313}, // 2050
+            {0, 211, 313, 411, 510, 609, 708, 806, 905, 1005, 1103, 1203, 1302}, // 2051
+            {8, 201, 301, 331, 429, 528, 627, 726, 824, 923, 1022, 1121, 1221, 1320}, // 2052
+            {0, 219, 320, 419, 518, 616, 716, 814, 912, 1012, 1110, 1210, 1309}, // 2053
+            {0, 208, 309, 408, 508, 606, 705, 804, 902, 1001, 1031, 1129, 1229}, // 2054
+            {6, 128, 226, 328, 427, 526, 625, 724, 823, 921, 1020, 1119, 1218, 1317}, // 2055
+            {0, 215, 316, 415, 515, 613, 713, 811, 910, 1009, 1107, 1207, 1305}, // 2056
+            {0, 204, 305, 404, 504, 602, 702, 731, 830, 929, 1028, 1126, 1226}, // 2057
+            {4, 124, 223, 324, 423, 522, 621, 720, 819, 918, 1017, 1116, 1216, 1314}, // 2058
+            {0, 212, 314, 412, 512, 610, 710, 808, 907, 1006, 1105, 1205, 1304}, // 2059
+            {0, 202, 303, 401, 501, 530, 628, 727, 826, 924, 1024, 1123, 1223}, // 2060
+            {3, 121, 220, 322, 420, 519, 618, 717, 815, 914, 1013, 1112, 1212, 1311}, // 2061
+            {0, 209, 311, 410, 509, 607, 707, 805, 903, 1003, 1101, 1201, 1231}, // 2062
+            {7, 129, 228, 330, 428, 528, 626, 726, 824, 922, 1022, 1120, 1220, 1318}, // 2063
+            {0, 217, 318, 417, 516, 615, 714, 813, 911, 1010, 1109, 1208, 1307}, // 2064
+            {0, 205, 307, 406, 505, 604, 704, 802, 901, 930, 1029, 1128, 1227}, // 2065
+            {5, 126, 224, 326, 424, 524, 623, 722, 821, 919, 1019, 1117, 1217, 1315}, // 2066
+            {0, 214, 315, 414, 513, 612, 711, 810, 909, 1008, 1107, 1206, 1305}, // 2067
+            {0, 203, 304, 402, 502, 531, 629, 729, 828, 926, 1026, 1125, 1224}, // 2068
+            {4, 123, 221, 323, 421, 521, 619, 718, 817, 915, 1015, 1114, 1214, 1312}, // 2069
+            {0, 211, 312, 411, 510, 609, 708, 806, 905, 1004, 1103, 1203, 1301}, // 2070
+            {8, 131, 302, 331, 430, 529, 628, 727, 825, 924, 1023, 1122, 1221, 1320}, // 2071
+            {0, 219, 320, 418, 518, 616, 716, 814, 912, 1012, 1110, 1210, 1308}, // 2072
+            {0, 207, 309, 407, 507, 606, 705, 804, 902, 1001, 1031, 1129, 1229}, // 2073
+            {6, 127, 226, 327, 426, 526, 624, 724, 822, 921, 1020, 1119, 1218, 1317}, // 2074
+            {0, 215, 317, 415, 515, 613, 713, 812, 910, 1010, 1108, 1208, 1306}, // 2075
+            {0, 205, 305, 404, 503, 602, 701, 731, 829, 928, 1028, 1126, 1226}, // 2076
+            {4, 124, 223, 324, 423, 522, 620, 720, 818, 917, 1017, 1116, 1215, 1314}, // 2077
+            {0, 212, 314, 412, 512, 610, 709, 808, 906, 1006, 1105, 1204, 1303}, // 2078
+            {0, 202, 303, 402, 501, 531, 629, 728, 827, 925, 1025, 1123, 1223}, // 2079
+            {3, 122, 221, 321, 420, 519, 618, 717, 815, 914, 1013, 1111, 1211, 1310}, // 2080
+            {0, 209, 310, 409, 509, 607, 707, 805, 903, 1003, 1101, 1130, 1230}, // 2081
+            {7, 129, 227, 329, 428, 528, 626, 725, 824, 922, 1022, 1120, 1219, 1318}, // 2082
+            {0, 217, 318, 417, 517, 615, 715, 813, 912, 1011, 1110, 1209, 1308}, // 2083
+            {0, 206, 307, 405, 505, 603, 703, 802, 831, 930, 1029, 1128, 1227}, // 2084
+            {5, 126, 224, 326, 424, 523, 622, 722, 820, 919, 1019, 1117, 1217, 1315}, // 2085
+            {0, 214, 315, 414, 513, 611, 711, 809, 908, 1008, 1106, 1206, 1305}, // 2086
+            {0, 203, 305, 403, 503, 601, 630, 730, 828, 927, 1026, 1125, 1225}, // 2087
+            {4, 124, 222, 323, 421, 521, 619, 718, 817, 915, 1014, 1113, 1213, 1312}, // 2088
+            {0, 210, 312, 411, 510, 609, 708, 806, 904, 1004, 1102, 1202, 1301}, // 2089
+            {8, 130, 301, 331, 430, 529, 628, 727, 825, 924, 1023, 1121, 1221, 1320}, // 2090
+            {0, 218, 320, 419, 518, 617, 716, 815, 913, 1013, 1111, 1210, 1309}, // 2091
+            {0, 207, 308, 407, 506, 605, 705, 803, 902, 1001, 1031, 1129, 1229}, // 2092
+            {6, 127, 225, 327, 426, 525, 624, 723, 822, 921, 1020, 1119, 1218, 1317}, // 2093
+            {0, 215, 316, 415, 514, 613, 712, 811, 910, 1009, 1108, 1208, 1306}, // 2094
+            {0, 205, 306, 405, 504, 602, 702, 731, 830, 928, 1028, 1127, 1227}, // 2095
+            {4, 125, 224, 324, 423, 522, 620, 720, 818, 916, 1016, 1115, 1215, 1313}, // 2096
+            {0, 212, 314, 412, 512, 610, 709, 808, 906, 1005, 1104, 1204, 1302}, // 2097
+            {0, 201, 303, 402, 501, 531, 629, 728, 826, 925, 1024, 1123, 1222}, // 2098
+            {2, 121, 220, 322, 420, 520, 619, 718, 816, 915, 1014, 1112, 1212, 1310} // 2099
+    };
+
+    /**
+     * 10天干
+     */
+    private static final char[] LunarGan = {'甲', '乙', '丙', '丁', '戊', '己', '庚', '辛', '壬', '癸'};
+    /**
+     * 12地支
+     */
+    private static final char[] LunarZhi = {'子', '丑', '寅', '卯', '辰', '巳', '午', '未', '申', '酉', '戌', '亥'};
+
+    /**
+     * 12生肖
+     */
+    private static final char[] LunarAnimailName = {'鼠', '牛', '虎', '兔', '龙', '蛇', '马', '羊', '猴', '鸡', '狗', '猪'};
+
+    /**
+     * 农历年份名
+     */
+    private static final char[] LunarYearName = {'〇', '一', '二', '三', '四', '五', '六', '七', '八', '九'};
+
+    /**
+     * 农历月份名
+     */
+    private static final String[] LunarMonthName = {"正", "二", "三", "四", "五", "六", "七", "八", "九", "十", "十一", "十二"};
+
+    /**
+     * 农历日期名
+     */
+    private static final String[] LunarDayName = {"初一", "初二", "初三", "初四", "初五", "初六", "初七", "初八", "初九", "初十", "十一",
+            "十二", "十三", "十四", "十五", "十六", "十七", "十八", "十九", "二十", "廿一", "廿二", "廿三", "廿四", "廿五", "廿六", "廿七", "廿八", "廿九",
+            "三十"/* "卅一", "卅二", "卅三", "卅四", "卅五", "卅六", "卅七", "卅八", "卅九" */
+    };
+
+
+    // 农历年,和公历是一样的
+    private int year;
+    // 农历月
+    private int month;
+    // 农历日期
+    private int day;
+    // 是否为闰月日期
+    private boolean isLeapMonth = false;
+    // 农历这年闰月,如果不闰月,默认为0
+    private int leapMonth = 0;
+    // 公历日期
+    private GregorianCalendar solar = null;
+
+    /**
+     * 无参构造子,默认为当前日期
+     */
+    public LunarCalendar() {
+        solar = new GregorianCalendar();
+        this.computeBySolarDate(solar.get(Calendar.YEAR), solar.get(Calendar.MONTH) + 1, solar.get(Calendar.DATE));
+    }
+
+    /**
+     * 通过年、月、日构造LunarCalendar
+     *
+     * @param year
+     * @param month
+     * @param date
+     * @param isLunar     是否为农历日期
+     * @param isleapMonth 在为农历日期的前提下,是否闰月
+     */
+    public LunarCalendar(int year, int month, int date, boolean isLunar, boolean isleapMonth) {
+        if (isLunar) {
+            this.computeByLunarDate(year, month, date, isleapMonth);
+            this.year = year;
+            this.month = month;
+            this.day = date;
+        } else {
+            this.computeBySolarDate(year, month, date);
+            this.getSolar().set(Calendar.YEAR, year);
+            this.getSolar().set(Calendar.MONTH, month - 1);
+            this.getSolar().set(Calendar.DATE, date);
+        }
+    }
+
+    /**
+     * 创建LunarInfo中某一年的一列公历日历编码<br>
+     * 公历日历编码:年份+月份+天,用于查询某个公历日期在某个LunarInfo列的哪一个区间<br>
+     *
+     * @return int[]
+     */
+    private int[] builderSolarCodes(int solarYear) {
+        if (solarYear < MINIYEAR && solarYear > MAXYEAR) {
+            return null;
+        }
+        int lunarIndex = solarYear - MINIYEAR;
+        int solarCodes[] = new int[LuarInfo[lunarIndex].length];
+        for (int i = 0; i < solarCodes.length; i++) {
+            if (0 == i) { // 第一个数表示闰月,不用更改
+                solarCodes[i] = LuarInfo[lunarIndex][i];
+            } else if (1 == i) {
+                if (LuarInfo[lunarIndex][1] > 999) {
+                    // 这年农历一月一日对应的公历实际是上一年的
+                    solarCodes[i] = (solarYear - 1) * 10000 + LuarInfo[lunarIndex][i];
+                } else {
+                    solarCodes[i] = solarYear * 10000 + LuarInfo[lunarIndex][i];
+                }
+            } else {
+                solarCodes[i] = solarYear * 10000 + LuarInfo[lunarIndex][i];
+            }
+        }
+        return solarCodes;
+    }
+
+    /**
+     * 日期增加
+     *
+     * @param field
+     * @param amount
+     */
+    public void add(int field, int amount) {
+        this.getSolar().add(field, amount);
+        this.computeBySolarDate(this.getSolar().get(Calendar.YEAR),
+                this.getSolar().get(Calendar.MONTH) + 1,
+                this.getSolar().get(Calendar.DATE));
+    }
+
+    /**
+     * 通过给定的农历日期,公历日期
+     *
+     * @param lunarYear
+     * @param lunarMonth
+     * @param lunarDate
+     * @param isleapMonth
+     * @return boolean
+     */
+    private boolean computeByLunarDate(int lunarYear, int lunarMonth, int lunarDate, boolean isleapMonth) {
+        boolean isSuccess = true;
+        if (lunarYear < MINIYEAR && lunarYear > MAXYEAR) {
+            isSuccess = false;
+            return isSuccess;
+        }
+        this.year = lunarYear;
+        this.month = lunarMonth;
+        this.day = lunarDate;
+        int solarMontDate = LuarInfo[lunarYear - MINIYEAR][lunarMonth];
+        leapMonth = LuarInfo[lunarYear - MINIYEAR][0];
+        if (leapMonth != 0 && (lunarMonth > leapMonth || (lunarMonth == leapMonth && isleapMonth))) {
+            // 闰月,且当前农历月大于闰月月份,取下一个月的LunarInfo码
+            // 闰月,且当前农历月等于闰月月份,并且此农历月为闰月,取下一个月的LunarInfo码
+            solarMontDate = LuarInfo[lunarYear - MINIYEAR][lunarMonth + 1];
+        }
+        this.getSolar().set(Calendar.YEAR, lunarYear);
+        this.getSolar().set(Calendar.MONTH, solarMontDate / 100);
+        this.getSolar().set(Calendar.DATE, solarMontDate % 100);
+        this.add(Calendar.DATE, lunarDate);
+        return isSuccess;
+    }
+
+    /**
+     * 通过给定公历日期,计算农历日期
+     *
+     * @param solarYear
+     * @param solarMonth
+     * @param solarDate
+     * @return boolean
+     */
+    private boolean computeBySolarDate(int solarYear, int solarMonth, int solarDate) {
+        boolean isSuccess = true;
+        if (solarYear < MINIYEAR && solarYear > MAXYEAR) {
+            isSuccess = false;
+            return isSuccess;
+        }
+        int solarCode = solarYear * 10000 + 100 * solarMonth + solarDate; // 公历码
+        leapMonth = LuarInfo[solarYear - MINIYEAR][0];
+        int solarCodes[] = builderSolarCodes(solarYear);
+        int newMonth = binSearch(solarCodes, solarCode);
+        int xdate = Long.valueOf(solarDateCodesDiff(solarCode, solarCodes[newMonth], Calendar.DATE)).intValue();
+        if (-1 == newMonth) { // 出错
+            return !isSuccess;
+        } else if (0 == newMonth) {// 在上一年
+            solarYear--;
+            int[] preSolarCodes = LuarInfo[solarYear - MINIYEAR];
+            // 取上年农历12月1号公历日期码
+            int nearSolarCode = preSolarCodes[preSolarCodes.length - 1]; // 上一年12月1号
+            // 下一年公历1月表示为了13月,这里做翻译,并计算出日期码
+            nearSolarCode = (nearSolarCode / 100 == 13 ? solarYear + 1 : solarYear) * 10000
+                    + (nearSolarCode / 100 == 13 ? nearSolarCode - 1200 : nearSolarCode);
+            if (nearSolarCode > solarCode) {// 此公历日期在上一年农历12月1号,之前,即在上年农历11月内
+                newMonth = 11;
+                // 取农历11月的公历码
+                nearSolarCode = solarYear * 10000 + preSolarCodes[preSolarCodes.length - 2];
+            } else {// 此公历日期在上一年农历12月内
+                newMonth = 12;
+            }
+            xdate = Long.valueOf(solarDateCodesDiff(solarCode, nearSolarCode, Calendar.DATE)).intValue();
+            if (xdate < 0) {
+                throw new LunarException("Wrong solarCode: " + solarCode);
+            }
+            this.day = 1 + xdate;
+            this.year = solarYear;
+            this.month = newMonth;
+            this.isLeapMonth = false; // 农历12月不可能为闰月
+        } else if (solarCodes.length == newMonth + 1 && xdate >= 30) {// 在下一年(公历12月只有30天)
+            newMonth = 1; // 农历肯定是1月
+            // 取下一年的公历日期码
+            int[] nextSolarCodes = LuarInfo[solarYear + 1 - MINIYEAR];
+            // 取下一年农历1月1号公历日期码
+            int nearSolarCode = solarYear * 10000 + nextSolarCodes[1]; // 下一年农历1月1号公历日期码
+            xdate = Long.valueOf(solarDateCodesDiff(solarCode, nearSolarCode, Calendar.DATE)).intValue();
+            if (xdate < 0) {
+                throw new LunarException("Wrong solarCode: " + solarCode);
+            }
+            this.day = 1 + xdate;
+            this.year = solarYear + 1; // 农历年到了下一年
+            this.month = newMonth;
+            this.isLeapMonth = false; // 农历1月不可能为闰月
+        } else {
+            if (xdate < 0) {
+                throw new LunarException("Wrong solarCode: " + solarCode);
+            }
+            this.day = 1 + xdate;
+            this.year = solarYear;
+            this.isLeapMonth = 0 != leapMonth && (leapMonth + 1 == newMonth);
+            if (0 != leapMonth && leapMonth < newMonth) {
+                this.month = newMonth - 1;
+            } else {
+                this.month = newMonth;
+            }
+        }
+        return isSuccess;
+    }
+
+    /**
+     * 计算两个农历日期之差
+     *
+     * @param lc1
+     * @param lc2
+     * @param field
+     */
+    public static long luanrDiff(LunarCalendar lc1, LunarCalendar lc2, int field) {
+        return solarDiff(lc1.getSolar(), lc2.getSolar(), field);
+    }
+
+    /**
+     * 公历转农历
+     *
+     * @param solar
+     * @return LunarCalendar
+     */
+    public static LunarCalendar solar2Lunar(Calendar solar) {
+        LunarCalendar ret = new LunarCalendar();
+        if (ret.computeBySolarDate(solar.get(Calendar.YEAR), solar.get(Calendar.MONTH) + 1, solar.get(Calendar.DATE))) {
+            return ret;
+        } else {
+            ret = null;
+            return ret;
+        }
+    }
+
+    /**
+     * 农历转公历
+     *
+     * @param lunarYear
+     * @param lunarMonth
+     * @param LunarDate
+     * @param isLeapMonth
+     * @return Calendar
+     */
+    public static Calendar lunar2Solar(int lunarYear, int lunarMonth, int LunarDate, boolean isLeapMonth) {
+        LunarCalendar ret = new LunarCalendar();
+        if (ret.computeByLunarDate(lunarYear, lunarMonth, LunarDate, isLeapMonth)) {
+            return ret.getSolar();
+        } else {
+            return null;
+        }
+    }
+
+    /**
+     * @param field
+     * @param n
+     */
+    public void solarAdd(int field, int n) {
+        this.getSolar().add(field, n);
+    }
+
+    /**
+     * 获取天
+     *
+     * @return String
+     */
+    public String getDayName(int lunarDay) {
+        return LunarDayName[lunarDay - 1];
+    }
+
+    /**
+     * 获取农历月份
+     *
+     * @param lunarMonth
+     * @return String
+     */
+    public String getMonthName(int lunarMonth) {
+        return LunarMonthName[lunarMonth - 1];
+    }
+
+    /**
+     * 获取年
+     */
+    public String getYearName(int lunarYear) {
+        StringBuilder sb = new StringBuilder();
+        sb.append(LunarYearName[lunarYear / 1000]);
+        sb.append(LunarYearName[lunarYear % 1000 / 100]);
+        sb.append(LunarYearName[lunarYear % 100 / 10]);
+        sb.append(LunarYearName[lunarYear % 10]);
+        return sb.toString();
+    }
+
+    /**
+     * 判断两个整数所代表公历日期的差值<br>
+     * 一年按365天计算,一个月按30天计算<br>
+     *
+     * @param solarCode1
+     * @param solarCode2
+     * @return long
+     */
+    public static long solarDateCodesDiff(int solarCode1, int solarCode2, int field) {
+        GregorianCalendar c1 = new GregorianCalendar(solarCode1 / 10000, solarCode1 % 10000 / 100 - 1,
+                solarCode1 % 10000 % 100);
+        GregorianCalendar c2 = new GregorianCalendar(solarCode2 / 10000, solarCode2 % 10000 / 100 - 1,
+                solarCode2 % 10000 % 100);
+        return solarDiff(c1, c2, field);
+    }
+
+    /**
+     * 求两个公历日期之差,field可以为年月日,时分秒<br>
+     * 一年按365天计算,一个月按30天计算<br>
+     *
+     * @param solar1
+     * @param solar2
+     * @param field
+     * @return long
+     */
+    public static long solarDiff(Calendar solar1, Calendar solar2, int field) {
+        long t1 = solar1.getTimeInMillis();
+        long t2 = solar2.getTimeInMillis();
+        switch (field) {
+            case Calendar.SECOND:
+                return (long) Math.rint(Double.valueOf(t1 - t2) / Double.valueOf(1000));
+            case Calendar.MINUTE:
+                return (long) Math.rint(Double.valueOf(t1 - t2) / Double.valueOf(60 * 1000));
+            case Calendar.HOUR:
+                return (long) Math.rint(Double.valueOf(t1 - t2) / Double.valueOf(3600 * 1000));
+            case Calendar.DATE:
+                return (long) Math.rint(Double.valueOf(t1 - t2) / Double.valueOf(24 * 3600 * 1000));
+            case Calendar.MONTH:
+                return (long) Math.rint(Double.valueOf(t1 - t2) / Double.valueOf(30 * 24 * 3600 * 1000));
+            case Calendar.YEAR:
+                return (long) Math.rint(Double.valueOf(t1 - t2) / Double.valueOf(365 * 24 * 3600 * 1000));
+            default:
+                return -1;
+        }
+    }
+
+    // getter and setter
+    public int getYear() {
+        return year;
+    }
+
+    public void setYear(int year) {
+        this.year = year;
+    }
+
+    public int getMonth() {
+        return month;
+    }
+
+    public void setMonth(int month) {
+        this.month = month;
+    }
+
+    public int getDate() {
+        return day;
+    }
+
+    public void setDate(int date) {
+        this.day = date;
+    }
+
+    public int getLeapMonth() {
+        return leapMonth;
+    }
+
+    public void setLeapMonth(int leapMonth) {
+        this.leapMonth = leapMonth;
+    }
+
+    public GregorianCalendar getSolar() {
+        return solar;
+    }
+
+    public void setSolar(GregorianCalendar solar) {
+        this.solar = solar;
+    }
+
+    public boolean isLeapMonth() {
+        return isLeapMonth;
+    }
+
+    public void setLeapMonth(boolean isLeapMonth) {
+        this.isLeapMonth = isLeapMonth;
+    }
+
+    /**
+     * 一个简单的二分查找,返回查找到的元素坐标,用于查找农历二维数组信息
+     *
+     * @param array
+     * @param n
+     * @return int
+     */
+    public static int binSearch(int[] array, int n) {
+        if (null == array || array.length == 0) {
+            return -1;
+        }
+        int min = 0, max = array.length - 1;
+        if (n <= array[min]) {
+            return min;
+        } else if (n >= array[max]) {
+            return max;
+        }
+        while (max - min > 1) {
+            int newIndex = (max + min) / 2; // 二分
+            if (array[newIndex] > n) { // 取小区间
+                max = newIndex;
+            } else if (array[newIndex] < n) {// 取大区间
+                min = newIndex;
+            } else { // 相等,直接返回下标
+                return newIndex;
+            }
+        }
+        if (array[max] == n) {
+            return max;
+        } else if (array[min] == n) {
+            return min;
+        } else {
+            return min; // 返回 较小的一个
+        }
+    }
+
+    @Override
+    public String toString() {
+        if (this.year < 1900 || this.year > 2099 || this.month < 1 || this.month > 12 || this.day < 1
+                || this.day > 30) {
+            return "Wrong lunar date: " + year + " " + month + " " + day;
+        }
+        return this.getYearName(this.year) + "年" + (this.isLeapMonth() ? "闰" : "") + this.getMonthName(this.month) + "月"
+                + this.getDayName(this.day);
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + day;
+        result = prime * result + month;
+        result = prime * result + year;
+        return result;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        LunarCalendar other = (LunarCalendar) obj;
+        if (day != other.day)
+            return false;
+        if (month != other.month)
+            return false;
+        if (year != other.year)
+            return false;
+        return true;
+    }
+
+    /**
+     * 返回传统天干地支年名称
+     *
+     * @return String
+     */
+    public static String getTraditionalYearName(int y) {
+        y = y - MINIYEAR + 36;
+        return ("" + LunarGan[y % 10] + LunarZhi[y % 12] + "年");
+    }
+
+    /**
+     * 获取生肖名
+     *
+     * @return char
+     */
+    public static char getAnimalYearName(int y) {
+        return LunarAnimailName[(y - 4) % 12];
+    }
+
+    /**
+     * 返回中国农历的全名
+     *
+     * @return String
+     */
+    public String getFullLunarName() {
+        return this.toString() + " " + getTraditionalYearName(this.year) + " " + getAnimalYearName(this.year);
+    }
+
+    /**
+     * 农历日期异常
+     *
+     * @author joel
+     */
+    public class LunarException extends RuntimeException {
+
+        /**
+         * serialVersionUID
+         */
+        private static final long serialVersionUID = 3274596943314243191L;
+
+        private String message;
+
+        // constructor
+        public LunarException(String message) {
+            super(message);
+            this.message = message;
+        }
+
+        public LunarException() {
+            super();
+        }
+
+        public LunarException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
+            super(message, cause, writableStackTrace, writableStackTrace);
+        }
+
+        public LunarException(String message, Throwable t) {
+            super(message, t);
+            this.message = message;
+        }
+
+        public LunarException(Throwable t) {
+            super(t);
+        }
+
+        // getter and setter
+        public String getMessage() {
+            return message;
+        }
+
+        public void setMessage(String message) {
+            this.message = message;
+        }
+    }
+
+    /**
+     * 获取当前日期的农历月份日期
+     *
+     * @return char
+     */
+    public static String getCurrMDLunar() {
+        Calendar c1 = Calendar.getInstance();
+        c1.setTime(new Date());
+        LunarCalendar luanr = LunarCalendar.solar2Lunar(c1);
+        return (luanr.isLeapMonth() ? "闰" : "") + luanr.getMonthName(luanr.month) + "月" + luanr.getDayName(luanr.day);
+    }
+    /**
+     * 获取指定日期的农历月份日期
+     * @param dt 日期字符串 格式 yyyy-mm-dd
+     * @return char
+     */
+    public static String getMDLunar(String dt) {
+        Date date = DateUtils.parseDate(dt);
+        Calendar c1 = Calendar.getInstance();
+        c1.setTime(date);
+        LunarCalendar luanr = LunarCalendar.solar2Lunar(c1);
+        return (luanr.isLeapMonth() ? "闰" : "") + luanr.getMonthName(luanr.month) + "月" + luanr.getDayName(luanr.day);
+    }
+    public static void main(String[] args) {
+        java.text.SimpleDateFormat df = new java.text.SimpleDateFormat("yyyy-MM-dd");
+        Calendar c1 = Calendar.getInstance();
+        c1.set(Calendar.YEAR, 2004);
+        c1.set(Calendar.MONTH, 0);
+        c1.set(Calendar.DATE, 18);
+        LunarCalendar luanr = LunarCalendar.solar2Lunar(c1);
+        //System.out.println((luanr.isLeapMonth() ? "闰" : "") + luanr.getMonthName(luanr.month) + "月");
+        //System.out.println(luanr.getDayName(luanr.day));
+        //System.out.println("Solar:" + df.format(c1.getTime()) + " Lunar:" + luanr);
+        System.out.println(getCurrMDLunar());
+        System.out.println(getMDLunar("2018-06-22"));
+    }
+}

+ 77 - 0
src/main/java/com/hywa/map/common/utils/MD5Utils.java

@@ -0,0 +1,77 @@
+package com.hywa.map.common.utils;
+
+import java.security.MessageDigest;
+import java.util.Random;
+
+import com.hywa.map.common.exception.GlobalException;
+import org.apache.shiro.crypto.hash.SimpleHash;
+import org.apache.shiro.util.ByteSource;
+
+/**
+ * @Description 散列算法 生成数据的摘要信息,是一种不可逆的算法,一般适合存储密码之类的数据
+ */
+public class MD5Utils {
+
+    //干扰数据 盐 防破解
+    private static final String SALT = "1qazxsw2";
+    //散列算法类型为MD5
+    private static final String ALGORITH_NAME = "md5";
+    //hash的次数
+    private static final int HASH_ITERATIONS = 2;
+
+    public static String encrypt(String encryptedObject) {
+//		String newPassword = new SimpleHash(ALGORITH_NAME, pswd, ByteSource.Util.bytes(SALT), HASH_ITERATIONS).toHex();
+//		return newPassword;
+        try {
+            char hexDigits[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C',
+                    'D', 'E', 'F'};
+            MessageDigest md5 = MessageDigest.getInstance("MD5");
+            md5.update(encryptedObject.getBytes());
+
+            byte[] digest = md5.digest();
+            int j = digest.length;
+            char[] chars = new char[j * 2];
+            int k = 0;
+            for (int i = 0; i < j; i++) {
+                byte byte0 = digest[i];
+                chars[k++] = hexDigits[byte0 >>> 4 & 0xf];
+                chars[k++] = hexDigits[byte0 & 0xf];
+            }
+            return new String(chars);
+        } catch (Exception e) {
+            throw new GlobalException("加密操作失败");
+        }
+    }
+
+    public static String encrypt(String username, String pswd) {
+        String newPassword = new SimpleHash(ALGORITH_NAME, pswd,
+                ByteSource.Util.bytes(username + SALT),
+                HASH_ITERATIONS).toHex();
+        return newPassword;
+    }
+
+    public static void main(String[] args) {
+
+        System.out.println(MD5Utils.encrypt("33808479d49ca8a3cdc93d4f976d1e3d"));
+    }
+
+
+    public static String getRandomString(int length) {
+        //定义一个字符串(A-Z,a-z,0-9)即62位;
+        String str = "zxcvbnmlkjhgfdsaqwertyuiopQWERTYUIOPASDFGHJKLZXCVBNM1234567890";
+        //由Random生成随机数
+        Random random = new Random();
+        StringBuffer sb = new StringBuffer();
+        //长度为几就循环几次
+        for (int i = 0; i < length; ++i) {
+            //产生0-61的数字
+            int number = random.nextInt(62);
+            //将产生的数字通过length次承载到sb中
+            sb.append(str.charAt(number));
+        }
+        //将承载的字符转换成字符串
+        return sb.toString();
+    }
+
+}
+

+ 18 - 0
src/main/java/com/hywa/map/common/utils/MoneyUtils.java

@@ -0,0 +1,18 @@
+package com.hywa.map.common.utils;
+
+import java.text.DecimalFormat;
+import java.text.NumberFormat;
+
+public class MoneyUtils {
+
+    /**
+     * 格式化金额保留2位小数,每3位增加","
+     *
+     * @param data 需要格式化的金额
+     * @return 以逗号分隔的字符串,如1,234,344.08
+     */
+    public static String formatComma(double data) {
+        NumberFormat nf = new DecimalFormat(",##0.00");
+        return nf.format(data);
+    }
+}

+ 29 - 0
src/main/java/com/hywa/map/common/utils/PageUtils.java

@@ -0,0 +1,29 @@
+package com.hywa.map.common.utils;
+
+import java.util.List;
+
+public class PageUtils {
+
+    public static List<?> paging(List<?> List, int pageNo, int pageSize, int total) {
+        pageNo = pageNo == 0 ? 1 : pageNo;
+
+        Integer requestCount = (int) Math.ceil((double) total / (double) pageSize);
+        if (total <= pageSize) {
+            return List;
+        }
+
+        for (int i = 0; i < requestCount; i++) {
+            Integer fromIndex = i * pageSize;
+            int toIndex = Math.min(total, (i + 1) * pageSize);
+
+            List<?> subList = List.subList(fromIndex, toIndex);
+            if (i + 1 == pageNo) {
+                return subList;
+            }
+            if (toIndex == total) {
+                return subList;
+            }
+        }
+        return null;
+    }
+}

+ 76 - 0
src/main/java/com/hywa/map/common/utils/PinYinUtil.java

@@ -0,0 +1,76 @@
+package com.hywa.map.common.utils;
+
+import net.sourceforge.pinyin4j.PinyinHelper;
+import net.sourceforge.pinyin4j.format.HanyuPinyinCaseType;
+import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat;
+import net.sourceforge.pinyin4j.format.HanyuPinyinToneType;
+import net.sourceforge.pinyin4j.format.exception.BadHanyuPinyinOutputFormatCombination;
+
+/**
+ * 汉字转换为拼音
+ *
+ * @author Red
+ */
+public class PinYinUtil {
+    /**
+     * 测试main方法
+     *
+     * @param args
+     */
+    public static void main(String[] args) {
+        System.out.println(toFirstChar("汉字转换为拼音").toUpperCase()); //转为首字母大写
+        System.out.println(toPinyin("汉字转换为拼音"));
+    }
+
+    /**
+     * 获取字符串拼音的第一个字母
+     *
+     * @param chinese
+     * @return
+     */
+    public static String toFirstChar(String chinese) {
+        String pinyinStr = "";
+        char[] newChar = chinese.toCharArray();  //转为单个字符
+        HanyuPinyinOutputFormat defaultFormat = new HanyuPinyinOutputFormat();
+        defaultFormat.setCaseType(HanyuPinyinCaseType.LOWERCASE);
+        defaultFormat.setToneType(HanyuPinyinToneType.WITHOUT_TONE);
+        for (int i = 0; i < newChar.length; i++) {
+            if (newChar[i] > 128) {
+                try {
+                    pinyinStr += PinyinHelper.toHanyuPinyinStringArray(newChar[i], defaultFormat)[0].charAt(0);
+                } catch (BadHanyuPinyinOutputFormatCombination e) {
+                    e.printStackTrace();
+                }
+            } else {
+                pinyinStr += newChar[i];
+            }
+        }
+        return pinyinStr;
+    }
+
+    /**
+     * 汉字转为拼音
+     *
+     * @param chinese
+     * @return
+     */
+    public static String toPinyin(String chinese) {
+        String pinyinStr = "";
+        char[] newChar = chinese.toCharArray();
+        HanyuPinyinOutputFormat defaultFormat = new HanyuPinyinOutputFormat();
+        defaultFormat.setCaseType(HanyuPinyinCaseType.LOWERCASE);
+        defaultFormat.setToneType(HanyuPinyinToneType.WITHOUT_TONE);
+        for (int i = 0; i < newChar.length; i++) {
+            if (newChar[i] > 128) {
+                try {
+                    pinyinStr += PinyinHelper.toHanyuPinyinStringArray(newChar[i], defaultFormat)[0];
+                } catch (BadHanyuPinyinOutputFormatCombination e) {
+                    e.printStackTrace();
+                }
+            } else {
+                pinyinStr += newChar[i];
+            }
+        }
+        return pinyinStr;
+    }
+}

+ 216 - 0
src/main/java/com/hywa/map/common/utils/PoiUtils.java

@@ -0,0 +1,216 @@
+package com.hywa.map.common.utils;
+
+import java.io.*;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.log4j.Logger;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.Row;
+import org.apache.poi.ss.usermodel.Sheet;
+import org.apache.poi.ss.usermodel.Workbook;
+import org.apache.poi.ss.util.CellRangeAddress;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+import org.springframework.web.multipart.MultipartFile;
+
+/**
+ * excel读写工具类
+ *
+ * @author hywa
+ * 2016821
+ */
+public class PoiUtils {
+    private static Logger logger = Logger.getLogger(PoiUtils.class);
+    private final static String xls = "xls";
+    private final static String xlsx = "xlsx";
+
+    /**
+     * 读入excel文件,解析后返回
+     *
+     * @param file
+     * @throws IOException
+     */
+    public static List<String[]> readExcel(MultipartFile file, int numberOfRow, int numberOfCells) throws IOException {
+        //检查文件
+        checkFile(file);
+        //获得Workbook工作薄对象
+        Workbook workbook = getWorkBook(file);
+        //创建返回对象,把每行中的值作为一个数组,所有行作为一个集合返回
+        List<String[]> list = new ArrayList<String[]>();
+        if (workbook != null) {
+            //for(int sheetNum = 0;sheetNum < workbook.getNumberOfSheets();sheetNum++){
+            //获得当前sheet工作表
+            Sheet sheet = workbook.getSheetAt(0);
+                /*if(sheet == null){
+                    continue;
+                }*/
+            //获得当前sheet的开始行
+            int firstRowNum = sheet.getFirstRowNum();
+            //获得当前sheet的结束行
+            int lastRowNum = sheet.getLastRowNum();
+            //循环除了第一行的所有行
+            for (int rowNum = firstRowNum + numberOfRow; rowNum <= lastRowNum; rowNum++) {
+                //获得当前行
+                Row row = sheet.getRow(rowNum);
+                if (row == null) {
+                    continue;
+                }
+                //获得当前行的开始列
+                //int firstCellNum = row.getFirstCellNum();
+                int firstCellNum = 0;
+                //获得当前行的列数
+                int lastCellNum = row.getPhysicalNumberOfCells();
+                //int lastCellNum = numberOfCells;
+                String[] cells = new String[lastCellNum];
+                //循环当前行
+                for (int cellNum = firstCellNum; cellNum < lastCellNum; cellNum++) {
+                    Cell cell = row.getCell(cellNum);
+                    if (cell != null) {
+                        boolean isMerge = isMergedRegion(sheet, row.getRowNum(), cell.getColumnIndex());
+                        //判断是否具有合并单元格
+                        if (isMerge) {
+                            String rs = getMergedRegionValue(sheet, row.getRowNum(), cell.getColumnIndex());
+                            cells[cellNum] = getMergedRegionValue(sheet, row.getRowNum(), cell.getColumnIndex()).replaceAll("\n", "");
+                        } else {
+                            cells[cellNum] = getCellValue(cell).replaceAll("\n", "");
+                        }
+                    }
+                }
+                String cellStr = String.join("", cells);
+                if (StringUtils.isNotEmpty(cellStr)) {
+                    list.add(cells);
+                }
+            }
+            //}
+            workbook.close();
+        }
+        return list;
+    }
+
+    public static void checkFile(MultipartFile file) throws IOException {
+        //判断文件是否存在
+        if (null == file) {
+            logger.error("文件不存在!");
+            throw new FileNotFoundException("文件不存在!");
+        }
+        //获得文件名
+        String fileName = file.getOriginalFilename();
+        //判断文件是否是excel文件
+        if (!fileName.endsWith(xls) && !fileName.endsWith(xlsx)) {
+            logger.error(fileName + "不是excel文件");
+            throw new IOException(fileName + "不是excel文件");
+        }
+    }
+
+    public static Workbook getWorkBook(MultipartFile file) {
+        //获得文件名
+        String fileName = file.getOriginalFilename();
+        //创建Workbook工作薄对象,表示整个excel
+        Workbook workbook = null;
+        try {
+            //获取excel文件的io流
+            InputStream is = file.getInputStream();
+            //根据文件后缀名不同(xls和xlsx)获得不同的Workbook实现类对象
+            if (fileName.endsWith(xls)) {
+                //2003
+                workbook = new HSSFWorkbook(is);
+            } else if (fileName.endsWith(xlsx)) {
+                //2007
+                workbook = new XSSFWorkbook(is);
+            }
+        } catch (IOException e) {
+            logger.info(e.getMessage());
+        }
+        return workbook;
+    }
+
+    public static String getCellValue(Cell cell) {
+        String cellValue = "";
+        if (cell == null) {
+            return cellValue;
+        }
+        //把数字当成String来读,避免出现1读成1.0的情况
+        if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
+            cell.setCellType(Cell.CELL_TYPE_STRING);
+        }
+        //判断数据的类型
+        switch (cell.getCellType()) {
+            case Cell.CELL_TYPE_NUMERIC: //数字
+                cellValue = String.valueOf(cell.getNumericCellValue());
+                break;
+            case Cell.CELL_TYPE_STRING: //字符串
+                cellValue = String.valueOf(cell.getStringCellValue());
+                break;
+            case Cell.CELL_TYPE_BOOLEAN: //Boolean
+                cellValue = String.valueOf(cell.getBooleanCellValue());
+                break;
+            case Cell.CELL_TYPE_FORMULA: //公式
+                cellValue = String.valueOf(cell.getCellFormula());
+                break;
+            case Cell.CELL_TYPE_BLANK: //空值
+                cellValue = "";
+                break;
+            case Cell.CELL_TYPE_ERROR: //故障
+                cellValue = "非法字符";
+                break;
+            default:
+                cellValue = "未知类型";
+                break;
+        }
+        return cellValue;
+    }
+
+    /**
+     * 判断指定的单元格是否是合并单元格
+     *
+     * @param sheet
+     * @param row    行下标
+     * @param column 列下标
+     * @return
+     */
+    private static boolean isMergedRegion(Sheet sheet, int row, int column) {
+        int sheetMergeCount = sheet.getNumMergedRegions();
+        for (int i = 0; i < sheetMergeCount; i++) {
+            CellRangeAddress range = sheet.getMergedRegion(i);
+            int firstColumn = range.getFirstColumn();
+            int lastColumn = range.getLastColumn();
+            int firstRow = range.getFirstRow();
+            int lastRow = range.getLastRow();
+            if (row >= firstRow && row <= lastRow) {
+                if (column >= firstColumn && column <= lastColumn) {
+                    return true;
+                }
+            }
+        }
+        return false;
+    }
+
+    /**
+     * 获取合并单元格的值
+     *
+     * @param sheet
+     * @param row
+     * @param column
+     * @return
+     */
+    public static String getMergedRegionValue(Sheet sheet, int row, int column) {
+        int sheetMergeCount = sheet.getNumMergedRegions();
+        for (int i = 0; i < sheetMergeCount; i++) {
+            CellRangeAddress ca = sheet.getMergedRegion(i);
+            int firstColumn = ca.getFirstColumn();
+            int lastColumn = ca.getLastColumn();
+            int firstRow = ca.getFirstRow();
+            int lastRow = ca.getLastRow();
+            if (row >= firstRow && row <= lastRow) {
+                if (column >= firstColumn && column <= lastColumn) {
+                    Row fRow = sheet.getRow(firstRow);
+                    Cell fCell = fRow.getCell(firstColumn);
+                    return getCellValue(fCell);
+                }
+            }
+        }
+        return null;
+    }
+
+}

+ 70 - 0
src/main/java/com/hywa/map/common/utils/ReadTxtUtils.java

@@ -0,0 +1,70 @@
+package com.hywa.map.common.utils;
+
+import com.hywa.map.common.enums.CommonEnum;
+import com.hywa.map.common.exception.GlobalException;
+import jxl.*;
+import jxl.format.Alignment;
+import jxl.format.Border;
+import jxl.format.BorderLineStyle;
+import jxl.format.CellFormat;
+import jxl.format.Colour;
+import jxl.format.VerticalAlignment;
+import jxl.write.*;
+import jxl.write.biff.RowsExceededException;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.util.CollectionUtils;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.servlet.http.HttpServletResponse;
+import java.io.*;
+import java.lang.reflect.Method;
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+import static com.hywa.map.common.enums.CommonEnum.FILE_CONTENT_NOT_NULL;
+
+@Slf4j
+public class ReadTxtUtils {
+    public String readTxtFile(String filePath) {
+        StringBuffer appInfolistInput = new StringBuffer();
+        try {
+            String encoding = "gbk";
+            File file = new File(filePath);
+            if (file.isFile() && file.exists()) {
+                InputStreamReader read = new InputStreamReader(
+                        new FileInputStream(file), encoding);
+                BufferedReader bufferedReader = new BufferedReader(read);
+                String lineTxt = null;
+                while ((lineTxt = bufferedReader.readLine()) != null) {
+                    String [] field = lineTxt.split("\\,");
+                    String sql = "insert into t_sys_position_grid(pos_id,pos_name,pos_lon,pos_lat) values('"+field[1]+"','"+field[2]+"','"+field[3]+"','"+field[4]+"');\r\n";
+                    writeBuffer(sql);
+                    //appInfolistInput.append(lineTxt);
+                }
+                read.close();
+                bufferedReader.close();
+            } else {
+                System.out.println("找不到指定的文件");
+            }
+        } catch (Exception e) {
+            System.out.println("读取文件内容出错");
+            e.printStackTrace();
+        }
+        return appInfolistInput.toString();
+    }
+    public void writeBuffer(String text){
+        try {
+            File file = new File("d:\\乡镇经纬度.sql");
+            BufferedWriter output = new BufferedWriter(new FileWriter(file,true));
+            output.write(text);
+            output.close();
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+    }
+    public static void main(String[] args) {
+        ReadTxtUtils utils = new ReadTxtUtils();
+        String text = utils.readTxtFile("d:\\乡镇经纬度更新到2018-5-1.txt");
+        //System.out.println(text);
+    }
+}

+ 242 - 0
src/main/java/com/hywa/map/common/utils/ReadXlsUtils.java

@@ -0,0 +1,242 @@
+package com.hywa.map.common.utils;
+
+import org.apache.log4j.Logger;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.Row;
+import org.apache.poi.ss.usermodel.Sheet;
+import org.apache.poi.ss.usermodel.Workbook;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.io.*;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * excel读写工具类
+ *
+ * @author hywa
+ * 2016821
+ */
+public class ReadXlsUtils {
+    private static Logger logger = Logger.getLogger(ReadXlsUtils.class);
+    private final static String xls = "xls";
+    private final static String xlsx = "xlsx";
+
+    /**
+     * 读入excel文件,解析后返回
+     *
+     * @param file
+     * @throws IOException
+     */
+    public static List<String[]> readExcel(String file, int numberOfRow, int numberOfCells) throws IOException {
+
+
+        //获得Workbook工作薄对象
+        Workbook workbook = getWorkBook(file);
+        //创建返回对象,把每行中的值作为一个数组,所有行作为一个集合返回
+        List<String[]> list = new ArrayList<String[]>();
+        if (workbook != null) {
+            //for(int sheetNum = 0;sheetNum < workbook.getNumberOfSheets();sheetNum++){
+            //获得当前sheet工作表
+            Sheet sheet = workbook.getSheetAt(0);
+                /*if(sheet == null){
+                    continue;
+                }*/
+            //获得当前sheet的开始行
+            int firstRowNum = sheet.getFirstRowNum();
+            //获得当前sheet的结束行
+            int lastRowNum = sheet.getLastRowNum();
+            //循环除了第一行的所有行
+            for (int rowNum = firstRowNum + numberOfRow; rowNum <= lastRowNum; rowNum++) {
+                //获得当前行
+                Row row = sheet.getRow(rowNum);
+                if (row == null) {
+                    continue;
+                }
+                //获得当前行的开始列
+                //int firstCellNum = row.getFirstCellNum();
+                int firstCellNum = 0;
+                //获得当前行的列数
+                //int lastCellNum = row.getPhysicalNumberOfCells()+1;
+                int lastCellNum = numberOfCells;
+                String[] cells = new String[lastCellNum];
+                //循环当前行
+                for (int cellNum = firstCellNum; cellNum < lastCellNum; cellNum++) {
+                    Cell cell = row.getCell(cellNum);
+                    cells[cellNum] = getCellValue(cell).replaceAll("\n", "");
+                }
+                String cellStr = String.join("", cells);
+                if (StringUtils.isNotEmpty(cellStr)) {
+                    list.add(cells);
+                }
+            }
+            //}
+            workbook.close();
+        }
+        return list;
+    }
+
+    public static void checkFile(MultipartFile file) throws IOException {
+        //判断文件是否存在
+        if (null == file) {
+            logger.error("文件不存在!");
+            throw new FileNotFoundException("文件不存在!");
+        }
+        //获得文件名
+        String fileName = file.getOriginalFilename();
+        //判断文件是否是excel文件
+        if (!fileName.endsWith(xls) && !fileName.endsWith(xlsx)) {
+            logger.error(fileName + "不是excel文件");
+            throw new IOException(fileName + "不是excel文件");
+        }
+    }
+
+    public static Workbook getWorkBook(String fileName) {
+        File file = new File(fileName);
+        //获得文件名
+        //创建Workbook工作薄对象,表示整个excel
+        Workbook workbook = null;
+        try {
+            //获取excel文件的io流
+            InputStream is = new FileInputStream(file);
+            //根据文件后缀名不同(xls和xlsx)获得不同的Workbook实现类对象
+            if (fileName.endsWith(xls)) {
+                //2003
+                workbook = new HSSFWorkbook(is);
+            } else if (fileName.endsWith(xlsx)) {
+                //2007
+                workbook = new XSSFWorkbook(is);
+            }
+        } catch (IOException e) {
+            logger.info(e.getMessage());
+        }
+        return workbook;
+    }
+
+    public static String getCellValue(Cell cell) {
+        String cellValue = "";
+        if (cell == null) {
+            return cellValue;
+        }
+        //把数字当成String来读,避免出现1读成1.0的情况
+        if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
+            cell.setCellType(Cell.CELL_TYPE_STRING);
+        }
+        //判断数据的类型
+        switch (cell.getCellType()) {
+            case Cell.CELL_TYPE_NUMERIC: //数字
+                cellValue = String.valueOf(cell.getNumericCellValue());
+                break;
+            case Cell.CELL_TYPE_STRING: //字符串
+                cellValue = String.valueOf(cell.getStringCellValue());
+                break;
+            case Cell.CELL_TYPE_BOOLEAN: //Boolean
+                cellValue = String.valueOf(cell.getBooleanCellValue());
+                break;
+            case Cell.CELL_TYPE_FORMULA: //公式
+                cellValue = String.valueOf(cell.getCellFormula());
+                break;
+            case Cell.CELL_TYPE_BLANK: //空值
+                cellValue = "";
+                break;
+            case Cell.CELL_TYPE_ERROR: //故障
+                cellValue = "非法字符";
+                break;
+            default:
+                cellValue = "未知类型";
+                break;
+        }
+        return cellValue;
+    }
+    /**
+     * 将list数据写入文件
+     *
+     * @param list     数据集合
+     * @param fileName 文件名称
+     * @return String 0-写文件成功 1-写文件失败
+     */
+    public static boolean writeFile(ArrayList<String> list, String fileName, boolean isAppend) {
+        File file = new File(fileName);
+        try {
+            org.apache.commons.io.FileUtils.writeLines(file, "utf-8", list, isAppend);
+        } catch (IOException e) {
+            return false;
+        }
+        return true;
+    }
+    public static void main(String[] args) throws IOException {
+        List<String[]> list = readExcel("C:\\Users\\Administrator\\Desktop\\标准数据导入(农产品库).xlsx", 2, 3);
+        String[] nameArray = new String[list.size()];
+        String[] dataArray = new String[list.size()];
+        Map<String, String> idMap = new HashMap<>();
+        ArrayList<String> sqlList = new ArrayList();
+        for (int i = 0; i < list.size(); i++) {
+            dataArray[i] = list.get(i)[2];
+        }
+        for (int i = 0; i < list.size(); i++) {
+            String uuid = UUIDUtils.randomUUID();
+            String allParentId = "";
+            String parentId = "";
+            boolean flag = false;
+            String[] label = list.get(i);
+            String name = label[1];
+            String code = label[2];
+            String codeBak = label[2];
+            String codeTemp = "";
+            idMap.put(codeBak, uuid);
+            if (code.length() == 2) {
+                code = "000" + code;
+                allParentId = "#";
+                parentId = "#";
+            } else if (code.length() == 3) {
+                code = "000" + code.substring(0, 2) + "00" + code;
+                allParentId = idMap.get(codeBak.substring(0, 2)) + ",#";
+                parentId = idMap.get(codeBak.substring(0, 2));
+            } else if (code.length() == 4) {
+                code = "000" + code.substring(0, 2) + "00" + code.substring(0, 3) + "0" + code;
+                allParentId = idMap.get(codeBak.substring(0, 2)) + "," + idMap.get(codeBak.substring(0, 3)) + ",#";
+                parentId = idMap.get(codeBak.substring(0, 3));
+            } else if (code.length() == 5) {
+                code = "000" + code.substring(0, 2) + "00" + code.substring(0, 3) + "0" + code.substring(0, 4) + code;
+                allParentId = idMap.get(codeBak.substring(0, 2)) + "," + idMap.get(codeBak.substring(0, 3)) + "," + idMap.get(codeBak.substring(0, 4)) + ",#";
+                parentId = idMap.get(codeBak.substring(0, 4));
+            } else {
+                code = code.replaceAll(" ", "");
+                String[] codeArray = code.split("\\•");
+                codeTemp = codeArray[1];
+                if (codeTemp.endsWith("0")) {
+                    codeTemp = "00" + codeTemp;
+                    allParentId = idMap.get(codeBak.substring(0, 2)) + "," + idMap.get(codeBak.substring(0, 3)) + "," + idMap.get(codeBak.substring(0, 4)) + "," + idMap.get(codeBak.substring(0, 5)) + ",#";
+                    parentId = idMap.get(codeBak.substring(0, 5));
+                } else {
+                    for (int j = 0; j < dataArray.length; j++) {
+                        if (dataArray[j].equals(codeBak.substring(0, codeBak.length() - 1) + "0")) {
+                            flag = true;
+                            break;
+                        }
+                    }
+                    if (flag) {
+                        codeTemp = "00" + codeArray[1].substring(0, 2) + "0" + "00" + codeArray[1];
+                        allParentId = idMap.get(codeBak.substring(0, 2)) + "," + idMap.get(codeBak.substring(0, 3)) + "," + idMap.get(codeBak.substring(0, 4)) + "," + idMap.get(codeBak.substring(0, 5)) + "," + idMap.get(codeBak.substring(0, codeBak.length() - 1) + "0") + ",#";
+                        parentId = idMap.get(codeBak.substring(0, codeBak.length() - 1) + "0");
+                    } else {
+                        codeTemp = "00" + codeTemp;
+                        allParentId = idMap.get(codeBak.substring(0, 2)) + "," + idMap.get(codeBak.substring(0, 3)) + "," + idMap.get(codeBak.substring(0, 4)) + "," + idMap.get(codeBak.substring(0, 5)) + ",#";
+                        parentId = idMap.get(codeBak.substring(0, 5));
+                    }
+                }
+                String parentCode = "000" + codeArray[0].substring(0, 2) + "00" + codeArray[0].substring(0, 3) + "0" + codeArray[0].substring(0, 4) + codeArray[0];
+                code = parentCode + codeTemp;
+            }
+            String sqlTitle = "INSERT INTO sys_dict (id, lib_id, dict_name, dict_code, parent_id, remark, state, is_del, create_user, create_date, update_user,update_date, all_parent_id, system_id, dict_type) ";
+            String sqlValue = " VALUES(" + "'" + uuid + "'," + "'2178002a6ce345edb39dbcbea018ea3f','" + name + "','" + code + "','" + parentId + "',null" + ",0" + ",0" + ",'b8d11ee289394be688ef3a4f6968efed'" + ",now()" + ",null" + ",null,'" + allParentId + "','N0001'" + ",0" + ");";
+            //System.out.println("第" + i + "行:" + sqlTitle + sqlValue);
+            sqlList.add(sqlTitle + sqlValue);
+        }
+        writeFile(sqlList, "C:\\Users\\Administrator\\Desktop\\标准数据导入(农产品库).sql", false);
+    }
+}

+ 44 - 0
src/main/java/com/hywa/map/common/utils/ReverseGeocodeUtils.java

@@ -0,0 +1,44 @@
+package com.hywa.map.common.utils;
+
+import static com.hywa.map.common.enums.CommonEnum.COORDINATE_PARSE_ERROR;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.hywa.map.common.ConstantPool;
+import com.hywa.map.common.exception.GlobalException;
+import java.util.HashMap;
+import java.util.Map;
+import lombok.extern.slf4j.Slf4j;
+
+@Slf4j
+public class ReverseGeocodeUtils {
+
+    public static Map<String, String> getAddress(String coordinate, String gdKey) {
+        Map<String, String> params = new HashMap<>();
+        params.put("key", gdKey);
+        params.put("location", coordinate);
+        String json = HttpUtils.get("http://restapi.amap.com/v3/geocode/regeo", params);
+
+        JSONObject parse = JSON.parseObject(json);
+        String status = (String) parse.get("status");
+        if (status.equals(ConstantPool.GD_STATUS_SUCCESS)) {
+            JSONObject regeoCode = (JSONObject) parse.get("regeocode");
+            String formatted_address = (String) regeoCode.get("formatted_address");
+            JSONObject addressComponent = (JSONObject) regeoCode.get("addressComponent");
+
+            Map<String, String> map = new HashMap<>();
+            map.put("country", (String) addressComponent.get("country"));
+            map.put("province", (String) addressComponent.get("province"));
+            //当所在城市为北京、上海、天津、重庆四个直辖市时,该字段返回为空;当所在城市属于县级市的时候,此字段为空
+            map.put("city", (String) addressComponent.get("city"));
+            map.put("district", (String) addressComponent.get("district"));
+            map.put("detailedProcess", formatted_address);
+            return map;
+        } else {
+            log.error("坐标解析错误" + parse.get("info"));
+            throw new GlobalException(
+                    COORDINATE_PARSE_ERROR.getIndex(),
+                    COORDINATE_PARSE_ERROR.getValue());
+        }
+    }
+}

+ 51 - 0
src/main/java/com/hywa/map/common/utils/SpringContext.java

@@ -0,0 +1,51 @@
+package com.hywa.map.common.utils;
+
+import org.springframework.beans.BeansException;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
+import org.springframework.context.ApplicationEvent;
+import org.springframework.stereotype.Component;
+
+/**
+ * spring容器加载工具类
+ *
+ * @author jzz
+ */
+@Component
+public class SpringContext implements ApplicationContextAware {
+
+    private static ApplicationContext context;
+
+    @Override
+    public void setApplicationContext(ApplicationContext context) throws BeansException {
+        SpringContext.setContext(context);
+    }
+
+    public static ApplicationContext getContext() {
+        return context;
+    }
+
+    private static void setContext(ApplicationContext context) {
+        SpringContext.context = context;
+    }
+
+    public static Object getBean(String beanName) {
+        Object obj = getContext().getBean(beanName);
+        return obj;
+    }
+
+    public static <T> T getBean(String beanName, Class<T> type) {
+        T obj = getContext().getBean(beanName, type);
+        return obj;
+    }
+
+    public static <T> T getBean(Class<T> type) {
+        T obj = getContext().getBean(type);
+        return obj;
+    }
+
+    public static void pushEvent(ApplicationEvent event) {
+        context.publishEvent(event);
+    }
+
+}

+ 134 - 0
src/main/java/com/hywa/map/common/utils/StrKit.java

@@ -0,0 +1,134 @@
+package com.hywa.map.common.utils;
+
+public class StrKit {
+    /**
+     * 首字母变小写
+     */
+    public static String firstCharToLowerCase(String str) {
+        char firstChar = str.charAt(0);
+        if (firstChar >= 'A' && firstChar <= 'Z') {
+            char[] arr = str.toCharArray();
+            arr[0] += ('a' - 'A');
+            return new String(arr);
+        }
+        return str;
+    }
+
+    /**
+     * 首字母变大写
+     */
+    public static String firstCharToUpperCase(String str) {
+        char firstChar = str.charAt(0);
+        if (firstChar >= 'a' && firstChar <= 'z') {
+            char[] arr = str.toCharArray();
+            arr[0] -= ('a' - 'A');
+            return new String(arr);
+        }
+        return str;
+    }
+
+    /**
+     * 字符串为 null 或者内部字符全部为 ' ' '\t' '\n' '\r' 这四类字符时返回 true
+     */
+    public static boolean isBlank(String str) {
+        if (str == null) {
+            return true;
+        }
+        int len = str.length();
+        if (len == 0) {
+            return true;
+        }
+        for (int i = 0; i < len; i++) {
+            switch (str.charAt(i)) {
+                case ' ':
+                case '\t':
+                case '\n':
+                case '\r':
+                    // case '\b':
+                    // case '\f':
+                    break;
+                default:
+                    return false;
+            }
+        }
+        return true;
+    }
+
+    public static boolean notBlank(String str) {
+        return !isBlank(str);
+    }
+
+    public static boolean notBlank(String... strings) {
+        if (strings == null || strings.length == 0) {
+            return false;
+        }
+        for (String str : strings) {
+            if (isBlank(str)) {
+                return false;
+            }
+        }
+        return true;
+    }
+
+    public static boolean notNull(Object... paras) {
+        if (paras == null) {
+            return false;
+        }
+        for (Object obj : paras) {
+            if (obj == null) {
+                return false;
+            }
+        }
+        return true;
+    }
+
+    public static String toCamelCase(String stringWithUnderline) {
+        if (stringWithUnderline.indexOf('_') == -1) {
+            return stringWithUnderline;
+        }
+
+        stringWithUnderline = stringWithUnderline.toLowerCase();
+        char[] fromArray = stringWithUnderline.toCharArray();
+        char[] toArray = new char[fromArray.length];
+        int j = 0;
+        for (int i = 0; i < fromArray.length; i++) {
+            if (fromArray[i] == '_') {
+                // 当前字符为下划线时,将指针后移一位,将紧随下划线后面一个字符转成大写并存放
+                i++;
+                if (i < fromArray.length) {
+                    toArray[j++] = Character.toUpperCase(fromArray[i]);
+                }
+            } else {
+                toArray[j++] = fromArray[i];
+            }
+        }
+        return new String(toArray, 0, j);
+    }
+
+    public static String join(String[] stringArray) {
+        StringBuilder sb = new StringBuilder();
+        for (String s : stringArray) {
+            sb.append(s);
+        }
+        return sb.toString();
+    }
+
+    public static String join(String[] stringArray, String separator) {
+        StringBuilder sb = new StringBuilder();
+        for (int i = 0; i < stringArray.length; i++) {
+            if (i > 0) {
+                sb.append(separator);
+            }
+            sb.append(stringArray[i]);
+        }
+        return sb.toString();
+    }
+
+    public static boolean equals(String a, String b) {
+        return a == null ? b == null : a.equals(b);
+    }
+
+    public static String getRandomUUID() {
+        return java.util.UUID.randomUUID().toString().replace("-", "");
+    }
+}

+ 545 - 0
src/main/java/com/hywa/map/common/utils/StringUtils.java

@@ -0,0 +1,545 @@
+package com.hywa.map.common.utils;
+
+import static com.hywa.map.common.enums.CommonEnum.ENCRYPTION_ERROR;
+
+import com.hywa.map.common.exception.GlobalException;
+
+import java.io.File;
+import java.math.BigDecimal;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.text.DecimalFormat;
+import java.time.LocalDate;
+import java.util.*;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+
+public final class StringUtils {
+
+    final static Map<Integer, String> ZONE_NUM = new HashMap<>();
+
+    private static Pattern CELLPHONE = Pattern
+            .compile("^(13[0-9]{9})|(18[0-9]{9})|(14[0-9]{9})|(17[0-9]{9})|(15[0-9]{9})$");
+
+    private static Pattern EMAIL = Pattern.compile("^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(\\.([a-zA-Z0-9_-])+)+$");
+
+    private static Pattern INTEGER = Pattern.compile("[0-9]*");
+    public static DecimalFormat decimalFormat = new DecimalFormat("###################.###########");
+
+    static {
+        ZONE_NUM.put(11, "北京");
+        ZONE_NUM.put(12, "天津");
+        ZONE_NUM.put(13, "河北");
+        ZONE_NUM.put(14, "山西");
+        ZONE_NUM.put(15, "内蒙古");
+        ZONE_NUM.put(21, "辽宁");
+        ZONE_NUM.put(22, "吉林");
+        ZONE_NUM.put(23, "黑龙江");
+        ZONE_NUM.put(31, "上海");
+        ZONE_NUM.put(32, "江苏");
+        ZONE_NUM.put(33, "浙江");
+        ZONE_NUM.put(34, "安徽");
+        ZONE_NUM.put(35, "福建");
+        ZONE_NUM.put(36, "江西");
+        ZONE_NUM.put(37, "山东");
+        ZONE_NUM.put(41, "河南");
+        ZONE_NUM.put(42, "湖北");
+        ZONE_NUM.put(43, "湖南");
+        ZONE_NUM.put(44, "广东");
+        ZONE_NUM.put(45, "广西");
+        ZONE_NUM.put(46, "海南");
+        ZONE_NUM.put(50, "重庆");
+        ZONE_NUM.put(51, "四川");
+        ZONE_NUM.put(52, "贵州");
+        ZONE_NUM.put(53, "云南");
+        ZONE_NUM.put(54, "西藏");
+        ZONE_NUM.put(61, "陕西");
+        ZONE_NUM.put(62, "甘肃");
+        ZONE_NUM.put(63, "青海");
+        ZONE_NUM.put(64, "新疆");
+        ZONE_NUM.put(71, "台湾");
+        ZONE_NUM.put(81, "香港");
+        ZONE_NUM.put(82, "澳门");
+        ZONE_NUM.put(91, "外国");
+    }
+
+    final static int[] PARITYBIT = {'1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2'};
+    final static int[] POWER_LIST = {7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2};
+    final static char[] UPPER_LIST = {'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'};
+
+    /**
+     * 身份证验证
+     */
+    public static boolean isIDCard(String certNo) {
+        if (certNo == null || (certNo.length() != 15 && certNo.length() != 18)) {
+            return false;
+        }
+        final char[] cs = certNo.toUpperCase().toCharArray();
+        //校验位数
+        int power = 0;
+        for (int i = 0; i < cs.length; i++) {
+            if (i == cs.length - 1 && cs[i] == 'X') {
+                break;//最后一位可以 是X或x
+            }
+            if (cs[i] < '0' || cs[i] > '9') {
+                return false;
+            }
+            if (i < cs.length - 1) {
+                power += (cs[i] - '0') * POWER_LIST[i];
+            }
+        }
+
+        //校验区位码
+        if (!ZONE_NUM.containsKey(Integer.valueOf(certNo.substring(0, 2)))) {
+            return false;
+        }
+
+        //校验年份
+        String year = certNo.length() == 15 ? getIdcardCalendar() + certNo.substring(6, 8)
+                : certNo.substring(6, 10);
+
+        final int iyear = Integer.parseInt(year);
+        if (iyear < 1900 || iyear > Calendar.getInstance().get(Calendar.YEAR)) {
+            return false;
+            //1900年的PASS,超过今年的PASS
+        }
+
+        //校验月份
+        String month = certNo.length() == 15 ? certNo.substring(8, 10) : certNo.substring(10, 12);
+        final int imonth = Integer.parseInt(month);
+        if (imonth < 1 || imonth > 12) {
+            return false;
+        }
+
+        //校验天数
+        String day = certNo.length() == 15 ? certNo.substring(10, 12) : certNo.substring(12, 14);
+        final int iday = Integer.parseInt(day);
+        if (iday < 1 || iday > 31) {
+            return false;
+        }
+
+        //校验"校验码"
+        if (certNo.length() == 15) {
+            return true;
+        }
+        return cs[cs.length - 1] == PARITYBIT[power % 11];
+    }
+
+    private static int getIdcardCalendar() {
+        GregorianCalendar curDay = new GregorianCalendar();
+        int curYear = curDay.get(Calendar.YEAR);
+        int year2bit = Integer.parseInt(String.valueOf(curYear).substring(2));
+        return year2bit;
+    }
+
+    public static boolean isEmpty(String str) {
+        if (null == str || "".equals(str) || "null".equals(str)) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    public static boolean isNotEmpty(String str) {
+        return !isEmpty(str);
+    }
+
+    /**
+     * 通过文件路径得到文件后缀名。如:hello.txt得到.txt
+     *
+     * @param filePath 文件路径
+     */
+    public static String getFileSuffix(String filePath) {
+        int pointIndex = filePath.lastIndexOf(".");
+        return filePath.substring(pointIndex, filePath.length());
+    }
+
+    public static String getFileNameWithoutSuffix(File file) {
+        String fileName = file.getName();
+        int pointIndex = fileName.lastIndexOf(".");
+        return fileName.substring(0, pointIndex);
+    }
+
+    public static boolean isEmail(String str) {
+        if (StringUtils.isEmpty(str)) {
+            return false;
+        }
+
+        Matcher m = EMAIL.matcher(str);
+        return m.matches();
+    }
+
+    public static boolean isCellPhone(String str) {
+        if (isEmpty(str)) {
+            return false;
+        }
+
+        Matcher m = CELLPHONE.matcher(str);
+        return m.matches();
+    }
+
+    /**
+     * 生成手机验证码
+     *
+     * @return 长度为6的数字字符串
+     */
+    public static String getVilidateCode() {
+        char[] codeSequence = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'};
+        StringBuffer codeStr = new StringBuffer();
+        for (int i = 0; i < 6; i++) {
+            int j = (int) (Math.random() * 10);
+            codeStr.append(codeSequence[j]);
+        }
+        return codeStr.toString();
+    }
+
+    /**
+     * MD5加密
+     */
+    public static String md5(String encryptedObject) {
+        try {
+            char[] hexDigits = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C',
+                    'D', 'E', 'F'};
+            MessageDigest md5 = MessageDigest.getInstance("MD5");
+            md5.update(encryptedObject.getBytes());
+
+            byte[] digest = md5.digest();
+            int j = digest.length;
+            char[] chars = new char[j * 2];
+            int k = 0;
+            for (int i = 0; i < j; i++) {
+                byte byte0 = digest[i];
+                chars[k++] = hexDigits[byte0 >>> 4 & 0xf];
+                chars[k++] = hexDigits[byte0 & 0xf];
+            }
+            return new String(chars);
+        } catch (Exception e) {
+            throw new GlobalException(ENCRYPTION_ERROR.getIndex(), ENCRYPTION_ERROR.getValue());
+        }
+    }
+
+    public static String getToken() {
+
+        return null;
+    }
+
+    public static boolean isInteger(String str) {
+        if (isEmpty(str)) {
+            return false;
+        }
+        Matcher isNum = INTEGER.matcher(str);
+        return isNum.matches();
+    }
+
+    /**
+     * 小数点保留方法
+     *
+     * @param value 需要处理的数值
+     * @param scale 需要保留的小数位数
+     */
+    public static float round(double value, int scale) {
+        if (scale < 0) {
+            throw new IllegalArgumentException("The scale must be a positive integer or zero");
+        }
+        BigDecimal bigDecimal = new BigDecimal(Double.toString(value));
+        BigDecimal one = new BigDecimal("1");
+        return bigDecimal.divide(one, scale, BigDecimal.ROUND_HALF_UP).floatValue();
+    }
+
+    public static String sHA1(String decript) {
+        try {
+            MessageDigest digest = MessageDigest.getInstance("SHA-1");
+            digest.update(decript.getBytes());
+            byte[] messageDigest = digest.digest();
+            StringBuffer hexString = new StringBuffer();
+            for (int i = 0; i < messageDigest.length; i++) {
+                String shaHex = Integer.toHexString(messageDigest[i] & 0xFF);
+                if (shaHex.length() < 2) {
+                    hexString.append(0);
+                }
+                hexString.append(shaHex);
+            }
+            return hexString.toString();
+
+        } catch (NoSuchAlgorithmException e) {
+            e.printStackTrace();
+        }
+        return "";
+    }
+
+
+    public static String getFieldName(String fieldName) {
+        return fieldName.replaceFirst(fieldName.substring(0), fieldName.substring(0).toLowerCase());
+    }
+
+//    /**
+//     * 根据前端路由规则生成oauth2访问地址
+//     *
+//     * @param route
+//     * @return
+//     */
+//    public static String generateOauth2Address(String route) {
+//        route = route.replaceAll("/", "!");
+//        route = route.replaceAll("\\?", "~");
+//        return PropKit.use("config.properties").getChildren("oauth2BaseAddress").replaceFirst("PATH", route);
+//    }
+
+    /**
+     * 根据oauth2入口参数找到定向到前端的路由
+     */
+    public static String translateRoute(String route) {
+        route = StringUtils.isEmpty(route) ? "" : route;
+        String redirectRoute = route.replaceAll("!", "/").replaceAll("~", "?");
+        return redirectRoute;
+    }
+
+    public synchronized static String getRandomUpper(int lenght) {
+        Random random = new Random();
+        StringBuffer upperStr = new StringBuffer();
+        for (int i = 0; i < lenght; i++) {
+            upperStr.append(UPPER_LIST[random.nextInt(UPPER_LIST.length)]);
+        }
+        return upperStr.toString();
+    }
+
+    public static String getSameMonthLastYear(String yearAndMonth) {
+        String[] split = yearAndMonth.split("-");
+        LocalDate date = LocalDate.of(Integer.valueOf(split[0]), Integer.valueOf(split[1]), 1);
+        LocalDate localDate = date.minusYears(1);
+        return localDate.toString().substring(0, localDate.toString().lastIndexOf("-"));
+    }
+
+    public static String getLastMonth(String time) {
+        String[] split = time.split("-");
+
+        LocalDate date = LocalDate.of(Integer.valueOf(split[0]), Integer.valueOf(split[1]),
+                split.length == 2 ? 1 : Integer.valueOf(split[2]));
+
+        LocalDate localDate = date.minusMonths(1);
+
+        return localDate.toString().substring(0, localDate.toString().lastIndexOf("-"));
+    }
+
+    public static String getLastDay(String time) {
+        String[] split = time.split("-");
+        LocalDate date = LocalDate.of(Integer.valueOf(split[0]), Integer.valueOf(split[1]),
+                Integer.valueOf(split[2]));
+        LocalDate localDate = date.minusDays(1);
+        return localDate.toString();
+    }
+
+    public static String getThisMoth(String time) {
+        String[] split = time.split("-");
+
+        LocalDate date = LocalDate.of(Integer.valueOf(split[0]), Integer.valueOf(split[1]),
+                split.length == 2 ? 1 : Integer.valueOf(split[2]));
+
+        return date.toString().substring(0, date.toString().lastIndexOf("-"));
+    }
+
+    /**
+     * 首字母变小写
+     *
+     * @param str
+     * @return
+     */
+    public static String firstCharToLowerCase(String str) {
+        char firstChar = str.charAt(0);
+        if (firstChar >= 'A' && firstChar <= 'Z') {
+            char[] arr = str.toCharArray();
+            arr[0] += ('a' - 'A');
+            return new String(arr);
+        }
+        return str;
+    }
+
+    public static boolean isMulriple(String str, int i) {
+        if (isEmpty(str)) {
+            return false;
+        }
+        return str.length() % i == 0 ? true : false;
+    }
+
+    /**
+     * 返回int数组中的最大值
+     *
+     * @param arr 数组
+     * @return 最大值
+     */
+    public static int getMax(int[] arr) {
+        Arrays.sort(arr);
+        return arr[arr.length - 1];
+    }
+
+    /**
+     * 返回int数组中的最小值
+     *
+     * @param arr 数组
+     * @return 最小值
+     */
+    public static int getMin(int[] arr) {
+        Arrays.sort(arr);
+        return arr[0];
+    }
+
+    /**
+     * 返回int数组的平均值
+     *
+     * @param arr 数组
+     * @return 平均值
+     */
+    public static int getAvg(int[] arr) {
+        int temp = 0;
+        for (int i = 0; i < arr.length; i++) {
+            temp = temp + arr[i];
+        }
+        return temp / arr.length;
+    }
+
+    /**
+     * 返回int数组的总和
+     *
+     * @param arr 数组
+     * @return 总和
+     */
+    public static int getSum(int[] arr) {
+        int temp = 0;
+        for (int i = 0; i < arr.length; i++) {
+            temp = temp + arr[i];
+        }
+        return temp;
+    }
+
+    /**
+     * 返回double数组中的最大值
+     *
+     * @param arr 数组
+     * @return 最大值
+     */
+    public static double getMax(double[] arr) {
+        Arrays.sort(arr);
+        return arr[arr.length - 1];
+    }
+
+    /**
+     * 返回double数组中的最小值
+     *
+     * @param arr 数组
+     * @return 最小值
+     */
+    public static double getMin(double[] arr) {
+        Arrays.sort(arr);
+        return arr[0];
+    }
+
+    /**
+     * 返回double数组的平均值,保留2位小数
+     *
+     * @param arr 数组
+     * @return 平均值
+     */
+    public static double getAvg(double[] arr) {
+        double temp = 0;
+        for (int i = 0; i < arr.length; i++) {
+            temp = temp + arr[i];
+        }
+        return new BigDecimal(temp / arr.length).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
+    }
+
+    /**
+     * 返回double数组的总和
+     *
+     * @param arr 数组
+     * @return 总和
+     */
+    public static double getSum(double[] arr) {
+        double temp = 0;
+        for (int i = 0; i < arr.length; i++) {
+            temp = temp + arr[i];
+        }
+        return temp;
+    }
+
+    /**
+     * 获取数组下标
+     *
+     * @param arr 数组
+     * @return 指定元素的下标
+     */
+    public static int getArrayIndex(String[] arr, String field) {
+        for (int i = 0; i < arr.length; i++) {
+            if (arr[i].equals(field)) {
+                return i;
+            }
+        }
+        return -1;
+    }
+
+    // 删除ArrayList中重复元素,保持顺序
+    public static void removeDuplicateWithOrder(List list) {
+        Set set = new HashSet();
+        List newList = new ArrayList();
+        for (Iterator iter = list.iterator(); iter.hasNext(); ) {
+            Object element = iter.next();
+            if (set.add(element)) {
+                newList.add(element);
+            }
+        }
+        list.clear();
+        list.addAll(newList);
+    }
+
+    /**
+     * 检验sql是否合法
+     *
+     * @param sql 字符串
+     * @return boolean
+     */
+    public static boolean checkSql(String sql) {
+        sql = sql.toLowerCase();
+        return sql.contains("drop ") || sql.contains("create ") || sql.contains("delete ") || sql.contains("update ") || sql.contains("insert ");
+    }
+
+    /**
+     * @param MinLon:最小经度 MaxLon: 最大经度   MinLat:最小纬度   MaxLat:最大纬度    type:设置返回经度还是纬度
+     * @return
+     * @throws
+     * @Title: randomLonLat
+     * @Description: 在矩形内随机生成经纬度
+     */
+    public static String randomLonLat(double MinLon, double MaxLon, double MinLat, double MaxLat, String type) {
+        Random random = new Random();
+        BigDecimal db = new BigDecimal(Math.random() * (MaxLon - MinLon) + MinLon);
+        String lon = db.setScale(6, BigDecimal.ROUND_HALF_UP).toString();// 小数后6位
+        db = new BigDecimal(Math.random() * (MaxLat - MinLat) + MinLat);
+        String lat = db.setScale(6, BigDecimal.ROUND_HALF_UP).toString();
+        if (type.equals("Lon")) {
+            return lon;
+        } else if (type.equals("Lat")) {
+            return lat;
+        } else {
+            return lon + "|" + lat;
+        }
+    }
+
+    /*
+     * 计算经纬度的距离
+     */
+    // 第一点的纬度,经度 第二点纬度,经度
+    public static String calcDist(double lat1, double lng1, double lat2, double lng2) {
+        double radLat1 = (lat1 * Math.PI) / 180.0;
+        double radLat2 = (lat2 * Math.PI) / 180.0;
+        double a = radLat1 - radLat2;
+        double b = ((lng1 * Math.PI) / 180.0) - ((lng2 * Math.PI) / 180.0);
+        double s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2) + Math.cos(radLat1) * Math.cos(radLat2) * Math.pow(Math.sin(b / 2), 2)));
+        s = s * 6378.137; // EARTH_RADIUS;
+        s = Math.round(s * 10000) / 10000; //输出为公里
+        return decimalFormat.format(s);
+    }
+
+    public static void main(String[] args) {
+        System.out.println(isInteger("000"));
+    }
+}

+ 89 - 0
src/main/java/com/hywa/map/common/utils/TextFileUtils.java

@@ -0,0 +1,89 @@
+package com.hywa.map.common.utils;
+
+import com.opencsv.CSVReader;
+import com.opencsv.CSVReaderBuilder;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.LineIterator;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * 文件工具类
+ *
+ * @author hywa
+ * @version 1.0
+ */
+public class TextFileUtils {
+    private static Logger logger = LoggerFactory.getLogger(TextFileUtils.class);
+
+    /**
+     * 将list数据写入文件
+     *
+     * @param list     数据集合
+     * @param fileName 文件名称
+     * @return String 0-写文件成功 1-写文件失败
+     */
+    public static boolean writeFile(ArrayList<String> list, String fileName, boolean isAppend) {
+        File file = new File(fileName);
+        try {
+            FileUtils.writeLines(file, "utf-8", list, isAppend);
+        } catch (IOException e) {
+            return false;
+        }
+        return true;
+    }
+
+    /**
+     * 读文件数据到list
+     *
+     * @param fileName 文件名称
+     * @return LineIterator 数据集合
+     */
+    public static LineIterator readFile(String fileName,String encoding) {
+        File file = new File(fileName);
+        LineIterator iterator = null;
+        try {
+            iterator = FileUtils.lineIterator(file, encoding);
+        } catch (IOException e) {
+
+        }
+        return iterator;
+    }
+
+    /**
+     * 删除文件
+     *
+     * @param fileName 文件名称
+     * @return
+     */
+    public static boolean deleteFile(String fileName) {
+        File file = new File(fileName);
+        return FileUtils.deleteQuietly(file);
+    }
+
+    public static void main(String[] args) {
+        ArrayList<String> list = new ArrayList<>();
+        LineIterator iterator = readFile("C:\\Users\\Administrator\\Desktop\\农投品监管平台\\导入数据\\采购记录.csv","utf-8");
+        while(iterator.hasNext())
+        {
+            String newLine="";
+            String oneLine=iterator.nextLine();
+            String[] lineArray = oneLine.split("\\,");
+            for(int i=0;i<lineArray.length;i++){
+                lineArray[i]= StringUtils.isEmpty(lineArray[i])?"this is null":lineArray[i];
+                newLine=newLine+","+lineArray[i];
+            }
+            System.out.println(Arrays.toString(lineArray));
+            list.add(newLine.substring(1));
+        }
+        iterator.close();
+        list.remove(0);
+        //writeFile( list, "C:\\Users\\Administrator\\Desktop\\农投品监管平台\\导入数据\\采购记录jinyin.csv", false);
+    }
+}

+ 94 - 0
src/main/java/com/hywa/map/common/utils/ThreeDESUtil.java

@@ -0,0 +1,94 @@
+package com.hywa.map.common.utils;
+
+import org.apache.commons.codec.binary.Base64;
+import org.apache.commons.codec.digest.DigestUtils;
+
+import javax.crypto.Cipher;
+import javax.crypto.SecretKey;
+import javax.crypto.spec.SecretKeySpec;
+
+public class ThreeDESUtil {
+    /**
+     * 转换成十六进制字符串
+     */
+    public static byte[] hex(String key) {
+        String f = DigestUtils.md5Hex(key);
+        byte[] bkeys = new String(f).getBytes();
+        byte[] enk = new byte[24];
+        for (int i = 0; i < 24; i++) {
+            enk[i] = bkeys[i];
+        }
+        return enk;
+    }
+
+    /**
+     * 3DES加密
+     *
+     * @param key    密钥
+     * @param srcStr 将加密的字符串
+     */
+    public static String encode3Des(String key, String srcStr) {
+        if(StringUtils.isEmpty(srcStr)){
+            return null;
+        }
+        byte[] keybyte = hex(key);
+        byte[] src = srcStr.getBytes();
+        try {
+            //生成密钥
+            SecretKey deskey = new SecretKeySpec(keybyte, "DESede");
+            //加密
+            Cipher c1 = Cipher.getInstance("DESede");
+            c1.init(Cipher.ENCRYPT_MODE, deskey);
+            String pwd = Base64.encodeBase64String(c1.doFinal(src));
+            return pwd;
+        } catch (java.security.NoSuchAlgorithmException e1) {
+            e1.printStackTrace();
+        } catch (javax.crypto.NoSuchPaddingException e2) {
+            e2.printStackTrace();
+        } catch (java.lang.Exception e3) {
+            e3.printStackTrace();
+        }
+        return null;
+    }
+
+    /**
+     * 3DES解密
+     *
+     * @param key    加密密钥
+     * @param desStr 解密后的字符串
+     */
+    public static String decode3Des(String key, String desStr) {
+        if(StringUtils.isEmpty(desStr)){
+            return null;
+        }
+        Base64 base64 = new Base64();
+        byte[] keybyte = hex(key);
+        byte[] src = base64.decode(desStr);
+        try {
+            //生成密钥
+            SecretKey deskey = new SecretKeySpec(keybyte, "DESede");
+            //解密
+            Cipher c1 = Cipher.getInstance("DESede");
+            c1.init(Cipher.DECRYPT_MODE, deskey);
+            String pwd = new String(c1.doFinal(src));
+            return pwd;
+        } catch (java.security.NoSuchAlgorithmException e1) {
+            e1.printStackTrace();
+        } catch (javax.crypto.NoSuchPaddingException e2) {
+            e2.printStackTrace();
+        } catch (java.lang.Exception e3) {
+            e3.printStackTrace();
+        }
+        return null;
+    }
+
+    public static void main(String[] args) {
+        String key = "hywa!123456789*collector";
+        String idcard = "cryptolog123y";
+        String encode = ThreeDESUtil.encode3Des(key, idcard);
+        System.out.println("原串:" + idcard);
+        System.out.println("加密后的串:" + encode);
+        System.out.println("解密后的串:" + ThreeDESUtil.decode3Des(key, encode));
+        System.out.println("测试解密后的串:" + ThreeDESUtil.decode3Des("hywa#guiyang*0851", "n8aOG7dGd6U="));
+    }
+}

+ 22 - 0
src/main/java/com/hywa/map/common/utils/UUIDUtils.java

@@ -0,0 +1,22 @@
+package com.hywa.map.common.utils;
+
+import java.util.UUID;
+
+public class UUIDUtils {
+
+    public static String randomUUID() {
+        String uuid = UUID.randomUUID().toString();
+        return replace(uuid);
+    }
+
+    public static String replace(String uuid) {
+        return uuid.replaceAll("-", "");
+    }
+
+    public static void main(String[] args) {
+        for(int i=0;i<37;i++){
+            System.out.println(randomUUID());
+        }
+
+    }
+}

+ 85 - 0
src/main/java/com/hywa/map/common/utils/ZipUtils.java

@@ -0,0 +1,85 @@
+package com.hywa.map.common.utils;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipOutputStream;
+
+/**
+ * 批量压缩下载
+ */
+public class ZipUtils {
+    private ZipUtils() {
+    }
+
+    public static void doCompress(String srcFile, String zipFile) throws IOException {
+        doCompress(new File(srcFile), new File(zipFile));
+    }
+
+    /**
+     * 文件压缩
+     *
+     * @param srcFile 目录或者单个文件
+     * @param zipFile 压缩后的ZIP文件
+     */
+    public static void doCompress(File srcFile, File zipFile) throws IOException {
+        ZipOutputStream out = null;
+        try {
+            out = new ZipOutputStream(new FileOutputStream(zipFile));
+            doCompress(srcFile, out);
+        } catch (Exception e) {
+            throw e;
+        } finally {
+            out.close();//记得关闭资源
+        }
+    }
+
+    public static void doCompress(String filelName, ZipOutputStream out) throws IOException {
+        doCompress(new File(filelName), out);
+    }
+
+    public static void doCompress(File file, ZipOutputStream out) throws IOException {
+        doCompress(file, out, "");
+    }
+
+    public static void doCompress(File inFile, ZipOutputStream out, String dir) throws IOException {
+        if (inFile.isDirectory()) {
+            File[] files = inFile.listFiles();
+            if (files != null && files.length > 0) {
+                for (File file : files) {
+                    String name = inFile.getName();
+                    if (!"".equals(dir)) {
+                        name = dir + "/" + name;
+                    }
+                    ZipUtils.doCompress(file, out, name);
+                }
+            }
+        } else {
+            ZipUtils.doZip(inFile, out, dir);
+        }
+    }
+
+    public static void doZip(File inFile, ZipOutputStream out, String dir) throws IOException {
+        String entryName = null;
+        if (!"".equals(dir)) {
+            entryName = dir + "/" + inFile.getName();
+        } else {
+            entryName = inFile.getName();
+        }
+        ZipEntry entry = new ZipEntry(entryName);
+        out.putNextEntry(entry);
+
+        int len = 0;
+        byte[] buffer = new byte[1024];
+        FileInputStream fis = new FileInputStream(inFile);
+        while ((len = fis.read(buffer)) > 0) {
+            out.write(buffer, 0, len);
+            out.flush();
+        }
+        out.closeEntry();
+        fis.close();
+    }
+
+}

+ 84 - 0
src/main/java/com/hywa/map/config/EnvProperties.java

@@ -0,0 +1,84 @@
+package com.hywa.map.config;
+
+import lombok.Getter;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+
+@Getter
+@Component
+public class EnvProperties {
+    /**
+     * 超级用户id
+     */
+    @Value("${adminId}")
+    private String adminId;
+    /**
+     * 超级角色id
+     */
+    @Value("${adminRoleId}")
+    private String adminRoleId;
+    @Value("${local.http.url}")
+    private String localHttp;
+
+    /**
+     * csv文件上传路径
+     */
+    @Value("${csv.file.path}")
+    private String csvFilePath;
+    /**
+     * csv文件下载路径
+     */
+    @Value("${csv.download.url}")
+    private String csvDownloadUrl;
+    /**
+     * csv文件mysql数据库路径
+     */
+    @Value("${mysql.data.file.path}")
+    private String mysqlDataFilePath;
+    /**
+     * 3des密钥
+     */
+    @Value("${three.des.key}")
+    private String threeDesKey;
+    /**
+     * 文件统一下载路径
+     */
+    @Value("${public.file.download.url}")
+    private String pubFileDownloadUrl;
+    /**
+     * 大屏缩略图保存目录
+     */
+    @Value("${map.picture.path}")
+    private String mapPicturePath;
+    /**
+     * 上传文件统一保存目录
+     */
+    @Value("${common.file.path}")
+    private String comFilePath;
+    /**
+     * 上传文件统一下载路径
+     */
+    @Value("${common.file.download.url}")
+    private String comFileDownloadUrl;
+    /**
+     * 萤石开放平台appKey
+     */
+    @Value("${ys.open.appKey}")
+    private String ysAppkey;
+    /**
+     * 萤石开放平台secret
+     */
+    @Value("${ys.open.secret}")
+    private String ysSecret;
+    /**
+     * 萤石开放平台访问地址
+     */
+    @Value("${ys.server.url}")
+    private String ysServerUrl;
+    /**
+     * 物联网访问路径
+     */
+    @Value("${iot.server.url}")
+    private String iotServerUrl;
+
+}

+ 39 - 0
src/main/java/com/hywa/map/config/SwaggerConfig.java

@@ -0,0 +1,39 @@
+package com.hywa.map.config;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import springfox.documentation.builders.ApiInfoBuilder;
+import springfox.documentation.builders.PathSelectors;
+import springfox.documentation.builders.RequestHandlerSelectors;
+import springfox.documentation.service.ApiInfo;
+import springfox.documentation.service.Contact;
+import springfox.documentation.spi.DocumentationType;
+import springfox.documentation.spring.web.plugins.Docket;
+import springfox.documentation.swagger2.annotations.EnableSwagger2;
+
+@Configuration
+@EnableSwagger2
+public class SwaggerConfig {
+
+    @Bean
+    public Docket api() {
+        return new Docket(DocumentationType.SWAGGER_2)
+                .apiInfo(apiInfo())
+                .select()
+                // 自行修改为自己的包路径
+                .apis(RequestHandlerSelectors.basePackage("com.hywa.map.controller"))
+                .paths(PathSelectors.any())
+                .build();
+    }
+
+    private ApiInfo apiInfo() {
+        return new ApiInfoBuilder()
+                .title("价格发布系统api文档")
+                .description("价格发布系统:Restful风格接口")
+                //服务条款网址
+                //.termsOfServiceUrl("http://blog.csdn.net/forezp")
+                .version("1.0")
+                .contact(new Contact("慧云网安", "http://www.gyhywa.com/", "18111906525@163.com"))
+                .build();
+    }
+}

+ 45 - 0
src/main/java/com/hywa/map/config/WebAppConfig.java

@@ -0,0 +1,45 @@
+package com.hywa.map.config;
+
+import java.nio.charset.Charset;
+import java.util.List;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.http.MediaType;
+import org.springframework.http.converter.HttpMessageConverter;
+import org.springframework.http.converter.StringHttpMessageConverter;
+import org.springframework.web.servlet.config.annotation.ContentNegotiationConfigurer;
+import org.springframework.web.servlet.config.annotation.CorsRegistry;
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
+
+/**
+ * 解决中文乱码
+ */
+@Configuration
+public class WebAppConfig implements WebMvcConfigurer {
+
+    @Bean
+    public HttpMessageConverter<String> responseBodyConverter() {
+        StringHttpMessageConverter converter = new StringHttpMessageConverter(
+                Charset.forName("UTF-8"));
+        return converter;
+    }
+
+    @Override
+    public void configureMessageConverters(
+            List<HttpMessageConverter<?>> converters) {
+        converters.add(responseBodyConverter());
+    }
+
+    @Override
+    public void configureContentNegotiation(
+            ContentNegotiationConfigurer configurer) {
+        configurer.defaultContentType(MediaType.APPLICATION_JSON);
+        configurer.ignoreAcceptHeader(false);
+        configurer.favorPathExtension(false);
+    }
+
+    @Override
+    public void addCorsMappings(CorsRegistry registry) {
+        registry.addMapping("/*").allowedOrigins("*");
+    }
+}

+ 51 - 0
src/main/java/com/hywa/map/config/datasource/AgribusinessDataSourceConfig.java

@@ -0,0 +1,51 @@
+package com.hywa.map.config.datasource;
+
+import javax.sql.DataSource;
+import org.apache.ibatis.session.SqlSessionFactory;
+import org.mybatis.spring.SqlSessionFactoryBean;
+import org.mybatis.spring.SqlSessionTemplate;
+import org.mybatis.spring.annotation.MapperScan;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.boot.jdbc.DataSourceBuilder;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
+import org.springframework.jdbc.datasource.DataSourceTransactionManager;
+
+@Configuration
+@MapperScan(basePackages = "com.hywa.map.dao.mapper", sqlSessionTemplateRef = "agribusinessSqlSessionTemplate")
+public class AgribusinessDataSourceConfig {
+
+    @Bean(name = "agribusinessDataSource")
+    @ConfigurationProperties(prefix = "first.datasource")
+    public DataSource dataSource() {
+        return DataSourceBuilder.create().build();
+    }
+
+    @Bean(name = "agribusinessSqlSessionFactory")
+    public SqlSessionFactory sqlSessionFactory(
+            @Qualifier("agribusinessDataSource") DataSource dataSource) throws Exception {
+        SqlSessionFactoryBean bean = new SqlSessionFactoryBean();
+        bean.setDataSource(dataSource);
+        bean.setMapperLocations(new PathMatchingResourcePatternResolver()
+                .getResources("classpath:com/hywa/map/dao/mapper/*.xml"));
+        org.apache.ibatis.session.Configuration configuration = new org.apache.ibatis.session.Configuration();
+        configuration.setCallSettersOnNulls(true);
+        configuration.setMapUnderscoreToCamelCase(true);
+        bean.setConfiguration(configuration);
+        return bean.getObject();
+    }
+
+    @Bean(name = "agribusinessTransactionManager")
+    public DataSourceTransactionManager transactionManager(
+            @Qualifier("agribusinessDataSource") DataSource dataSource) {
+        return new DataSourceTransactionManager(dataSource);
+    }
+
+    @Bean(name = "agribusinessSqlSessionTemplate")
+    public SqlSessionTemplate sqlSessionTemplate(
+            @Qualifier("agribusinessSqlSessionFactory") SqlSessionFactory sqlSessionFactory) {
+        return new SqlSessionTemplate(sqlSessionFactory);
+    }
+}

+ 53 - 0
src/main/java/com/hywa/map/config/druid/DruidConfig.java

@@ -0,0 +1,53 @@
+package com.hywa.map.config.druid;
+
+import com.alibaba.druid.filter.Filter;
+import com.alibaba.druid.pool.DruidDataSource;
+import com.alibaba.druid.wall.WallConfig;
+import com.alibaba.druid.wall.WallFilter;
+import java.util.ArrayList;
+import java.util.List;
+import javax.sql.DataSource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.DependsOn;
+
+/**
+ * 配置druid需要的配置类,引入application.properties文件中以spring.datasource开头的信息
+ * 因此需要在application.properties文件中配置相关信息。
+ */
+//@Configuration
+public class DruidConfig {
+
+    @Autowired
+    WallFilter wallFilter;
+
+    private Logger logger = LoggerFactory.getLogger(this.getClass());
+
+    @Bean
+    @ConfigurationProperties(prefix = "spring.datasource")
+    public DataSource druidDataSource() {
+        DruidDataSource druidDataSource = new DruidDataSource();
+        List<Filter> filters = new ArrayList<>();
+        filters.add(wallFilter);
+        druidDataSource.setProxyFilters(filters);
+        return druidDataSource;
+    }
+
+    @Bean(name = "wallConfig")
+    public WallConfig wallFilterConfig() {
+        WallConfig wc = new WallConfig();
+        wc.setMultiStatementAllow(true);
+        return wc;
+    }
+
+    @Bean(name = "wallFilter")
+    @DependsOn("wallConfig")
+    WallFilter wallFilter(WallConfig wallConfig) {
+        WallFilter wfilter = new WallFilter();
+        wfilter.setConfig(wallConfig);
+        return wfilter;
+    }
+}

+ 17 - 0
src/main/java/com/hywa/map/config/druid/DruidStatFilter.java

@@ -0,0 +1,17 @@
+package com.hywa.map.config.druid;
+
+import com.alibaba.druid.support.http.WebStatFilter;
+import javax.servlet.annotation.WebFilter;
+import javax.servlet.annotation.WebInitParam;
+
+/**
+ * 配置druid过滤规则
+ */
+@WebFilter(filterName = "druidWebStatFilter", urlPatterns = "/*",
+        initParams = {
+                @WebInitParam(name = "exclusions", value = "*.js,*.gif,*.jpg,*.bmp,*.png,*.css,*.ico,/druid/*")
+// 忽略资源
+        })
+public class DruidStatFilter extends WebStatFilter {
+
+}

+ 18 - 0
src/main/java/com/hywa/map/config/druid/DruidStatViewServlet.java

@@ -0,0 +1,18 @@
+package com.hywa.map.config.druid;
+
+import com.alibaba.druid.support.http.StatViewServlet;
+import javax.servlet.annotation.WebInitParam;
+import javax.servlet.annotation.WebServlet;
+
+@WebServlet(urlPatterns = "/druid/*",
+        initParams = {
+//                @WebInitParam(name="allow",value="127.0.0.1,192.168.163.1"),// IP白名单(没有配置或者为空,则允许所有访问)
+//                @WebInitParam(name="deny",value="192.168.1.73"),// IP黑名单 (存在共同时,deny优先于allow)
+                @WebInitParam(name = "loginUsername", value = "admin"),// 用户名
+                @WebInitParam(name = "loginPassword", value = "123456"),// 密码
+                @WebInitParam(name = "resetEnable", value = "false")// 禁用HTML页面上的“Reset All”功能
+        })
+public class DruidStatViewServlet extends StatViewServlet {
+
+    private static final long serialVersionUID = -2688872071445249539L;
+}

+ 12 - 0
src/main/java/com/hywa/map/config/interceptor/ArrayUtils.java

@@ -0,0 +1,12 @@
+package com.hywa.map.config.interceptor;
+
+import java.util.Arrays;
+import java.util.List;
+
+public class ArrayUtils {
+
+    public static <T> boolean contains(T[] modules, T all) {
+        List<T> list = Arrays.asList(modules);
+        return list.contains(all);
+    }
+}

+ 20 - 0
src/main/java/com/hywa/map/config/interceptor/AuthContext.java

@@ -0,0 +1,20 @@
+package com.hywa.map.config.interceptor;
+
+/**
+ * 权限策略上下文控制类
+ */
+public class AuthContext {
+
+    private AuthStrategy authStrategy;
+
+    public AuthContext(AuthStrategy strategy) {
+        this.authStrategy = strategy;
+    }
+
+    /**
+     * 执行策略
+     */
+    public boolean execute(String userId,String servletPath) throws Exception {
+        return this.authStrategy.executeAuth(userId, servletPath);
+    }
+}

+ 24 - 0
src/main/java/com/hywa/map/config/interceptor/AuthService.java

@@ -0,0 +1,24 @@
+package com.hywa.map.config.interceptor;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.StringRedisTemplate;
+import org.springframework.stereotype.Component;
+
+import java.util.Set;
+
+@Component
+public class AuthService {
+
+    @Autowired
+    private StringRedisTemplate redis;
+
+    public Set<String> getPermission(String userId) {
+        //redis中获取用户权限列表
+        return redis.opsForSet().members(userId+"_authority");
+    }
+
+    public boolean isAuth(String userId,String servletPath) {
+        //redis中获取用户权限列表
+       return redis.opsForSet().isMember(userId+"_authority", servletPath);
+    }
+}

+ 10 - 0
src/main/java/com/hywa/map/config/interceptor/AuthStrategy.java

@@ -0,0 +1,10 @@
+package com.hywa.map.config.interceptor;
+
+/**
+ * 策略接口,所有策略都应该实现的接口
+ */
+public interface AuthStrategy {
+
+    boolean executeAuth(String userId,String servletPath) throws Exception;
+}
+

+ 70 - 0
src/main/java/com/hywa/map/config/interceptor/PermissionAuthConfig.java

@@ -0,0 +1,70 @@
+package com.hywa.map.config.interceptor;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.hywa.map.common.enums.CommonEnum;
+import com.hywa.map.representation.ResponseBase;
+import java.io.OutputStream;
+import java.lang.reflect.Method;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import lombok.extern.slf4j.Slf4j;
+import org.aspectj.lang.ProceedingJoinPoint;
+import org.aspectj.lang.Signature;
+import org.aspectj.lang.annotation.Around;
+import org.aspectj.lang.annotation.Aspect;
+import org.aspectj.lang.reflect.MethodSignature;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.context.request.RequestAttributes;
+import org.springframework.web.context.request.RequestContextHolder;
+import org.springframework.web.context.request.ServletRequestAttributes;
+
+@Slf4j
+@Aspect
+//@Component
+public class PermissionAuthConfig {
+
+    @Autowired
+    private AuthStrategy authStrategy;
+
+    @Around("execution(* com.hywa.map.controller..*.*(..)) && @annotation(org.springframework.web.bind.annotation.RequestMapping)")
+    public Object executeAround(ProceedingJoinPoint point) throws Throwable {
+        RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
+        HttpServletRequest request = (HttpServletRequest) requestAttributes
+                .resolveReference(RequestAttributes.REFERENCE_REQUEST);
+        HttpServletResponse response = ((ServletRequestAttributes) requestAttributes).getResponse();
+
+        //获取请求头里面用户的ID,此处只做简单处理,实际应该有加密,否则将会导致用户信息泄露,无法保证安全
+        String userId = request.getHeader("userId");
+
+        Signature signature = point.getSignature();
+        MethodSignature methodSignature = (MethodSignature) signature;
+        Method targetMethod = methodSignature.getMethod();
+        Method realMethod = point.getTarget().getClass()
+                .getDeclaredMethod(signature.getName(), targetMethod.getParameterTypes());
+
+        Object obj = null;
+        String servletPath = "";//需要实际修改
+        if (isHasPermission(userId, servletPath)) {
+            obj = point.proceed();
+        } else {
+            response.setHeader("Content-type", "application/json; charset=UTF-8");
+            OutputStream outputStream = response.getOutputStream();
+            ResponseBase<Object> responseBase = new ResponseBase<>();
+            responseBase.setRetHead(CommonEnum.FAILURE.getIndex(),
+                    "Not allowed to pass, you do not have the authority");
+            outputStream
+                    .write(new ObjectMapper().writeValueAsString(responseBase).getBytes("UTF-8"));
+        }
+        return obj;
+    }
+
+    private boolean isHasPermission(String userId,String servletPath) {
+        try {
+            //执行权限策略,判断用户权限
+            return new AuthContext(authStrategy).execute(userId, servletPath);
+        } catch (Exception e) {
+            System.out.println(e.getMessage());
+            return false;
+        }
+    }
+}

+ 19 - 0
src/main/java/com/hywa/map/config/interceptor/PermissionModule.java

@@ -0,0 +1,19 @@
+package com.hywa.map.config.interceptor;
+
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import com.hywa.map.common.enums.Module;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+@Retention(RUNTIME)
+@Target(METHOD)
+public @interface PermissionModule {
+
+    /**
+     * 执行方法所需要的权限,ALL表示所有权限都可以执行 belong的类型为数组,方便为接口添加多个模块,即一个接口可以属于多个模块 同时也可以反映出一个模块可以包含多个接口的关系
+     */
+    Module[] belong() default {Module.ALL};
+}
+

+ 65 - 0
src/main/java/com/hywa/map/config/interceptor/RedisTokenManager.java

@@ -0,0 +1,65 @@
+package com.hywa.map.config.interceptor;
+
+import com.hywa.map.common.ConstantPool;
+import com.hywa.map.common.utils.UUIDUtils;
+import java.util.concurrent.TimeUnit;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.StringRedisTemplate;
+import org.springframework.stereotype.Component;
+
+@Slf4j
+@Component
+public class RedisTokenManager implements TokenManager {
+
+    @Autowired
+    private StringRedisTemplate redis;
+
+    @Override
+    public TokenModel createToken(String userId) {
+        String token = UUIDUtils.randomUUID();
+        TokenModel model = new TokenModel(userId, token);
+        //存储到redis并设置过期时间
+        redis.boundValueOps(userId)
+                .set(token, ConstantPool.TOKEN_EXPIRES_SECOND, TimeUnit.SECONDS);
+        return model;
+    }
+
+    @Override
+    public boolean checkToken(TokenModel model) {
+        if (model == null) {
+            return false;
+        }
+        log.info("tokenModel : " + model.toString());
+        String token = redis.boundValueOps(model.getUserId()).get();
+        if (token == null || !token.equals(model.getToken())) {
+            return false;
+        }
+        //如果验证成功,说明此用户进行了一次有效操作,延长token的过期时间
+        redis.boundValueOps(model.getUserId())
+                .expire(ConstantPool.TOKEN_EXPIRES_SECOND, TimeUnit.HOURS);
+        return true;
+    }
+
+
+    @Override
+    public TokenModel getToken(String authentication) {
+        if (authentication == null || authentication.length() == 0) {
+            return null;
+        }
+        String[] param = authentication.split("_");
+        if (param.length != 2) {
+            return null;
+        }
+        //使用userId和源token简单拼接成的token,可以增加加密措施
+        String userId = param[0];
+        String token = param[1];
+        return new TokenModel(userId, token);
+    }
+
+    @Override
+    public void deleteToken(String userId) {
+        //应该对是否退出成功做出相应的判断
+        redis.delete(userId);
+    }
+}

+ 143 - 0
src/main/java/com/hywa/map/config/interceptor/TokenAuthorFilter.java

@@ -0,0 +1,143 @@
+package com.hywa.map.config.interceptor;
+
+import static com.hywa.map.common.ConstantPool.SPLIT;
+import static com.hywa.map.common.enums.CommonEnum.NO_AUTHORITY;
+import static com.hywa.map.common.enums.CommonEnum.RE_LOGIN;
+
+import com.alibaba.fastjson.JSON;
+import com.hywa.map.common.utils.StringUtils;
+import com.hywa.map.representation.ResponseBase;
+
+import java.io.*;
+import java.util.Arrays;
+import java.util.List;
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.annotation.WebFilter;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+
+@Slf4j
+@Component
+@WebFilter(urlPatterns = {"/*"}, filterName = "tokenAuthorFilter") //过滤规则
+public class TokenAuthorFilter implements Filter {
+
+    @Autowired
+    private TokenManager tokenManager;
+    @Autowired
+    private UserAuthContext userAuthContext;
+
+    private static final List<String> UN_FILTER_URL_LIST = Arrays
+            .asList("/user/login", "/user/pcLogin", "user/checkToken", "user/pcCheckToken","/statis","/gis","/public","/map",
+                    "/region", "/file", "/druid", "/downLoadZipFile", "/uploadImage", "/showImage", "/uploadFile","/web",
+                    "/getExcel", "/downloadExcel", "downloadTemplate", "downloadXls", "/tracing", "/downloadAttach", "/download");
+
+    /* 判断请求路径是否为不拦截的请求路径 */
+    private boolean isNotFilter(String url) {
+        for (String s : UN_FILTER_URL_LIST) {
+            if (url.contains(s)) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    @Override
+    public void init(FilterConfig filterConfig) {
+    }
+
+
+    @Override
+    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
+            throws IOException, ServletException {
+        HttpServletRequest req = (HttpServletRequest) request;
+        HttpServletResponse rep = (HttpServletResponse) response;
+
+        //设置允许跨域的配置
+        // 这里填写你允许进行跨域的主机ip(正式上线时可以动态配置具体允许的域名和IP)
+        rep.setHeader("Access-Control-Allow-Origin", "*");
+        // 允许的访问方法
+        rep.setHeader("Access-Control-Allow-Methods", "POST, GET, PUT, OPTIONS, DELETE, PATCH");
+        // Access-Control-Max-Age 用于 CORS 相关配置的缓存
+        rep.setHeader("Access-Control-Max-Age", "3600");
+        rep.setHeader("Access-Control-Allow-Headers",
+                "token,Origin, X-Requested-With, Content-Type, Accept, accessToken");
+
+        response.setCharacterEncoding("UTF-8");
+        response.setContentType("application/json; charset=utf-8");
+
+        String accessToken = req.getHeader("accessToken");
+        ResponseBase resultInfo = new ResponseBase();
+
+        boolean isFilter = false;
+
+        String method = ((HttpServletRequest) request).getMethod();
+        String servletPath = req.getServletPath();
+        servletPath = servletPath.endsWith("/") ? servletPath.substring(0, servletPath.length() - 1)
+                : servletPath;
+        if ("OPTIONS".equals(method)) {
+            rep.setStatus(HttpServletResponse.SC_OK);
+        } else {
+            if (isNotFilter(req.getRequestURL().toString())) {
+                isFilter = true;
+            } else if (StringUtils.isEmpty(accessToken)) {
+                resultInfo.setRetHead(RE_LOGIN.getIndex(), RE_LOGIN.getValue());
+            } else {
+                log.info(accessToken);
+                //验证token
+                TokenModel model = tokenManager.getToken(accessToken);
+                if (tokenManager.checkToken(model)) {
+                    //验证权限
+                    if (userAuthContext.executeAuth(model.getUserId().split(SPLIT)[1],
+                            servletPath + "|" + method)) {
+                        isFilter = true;
+                    } else {
+                        isFilter = false;
+                        resultInfo.setRetHead(NO_AUTHORITY.getIndex(), NO_AUTHORITY.getValue());
+                    }
+                } else {
+                    resultInfo.setRetHead(RE_LOGIN.getIndex(), RE_LOGIN.getValue());
+                }
+            }
+
+            if (isFilter) {
+                chain.doFilter(request, response);
+            } else {// 验证失败
+                PrintWriter writer = null;
+                OutputStreamWriter osw = null;
+                try {
+                    osw = new OutputStreamWriter(response.getOutputStream(),
+                            "UTF-8");
+                    writer = new PrintWriter(osw, true);
+                    String jsonStr = JSON.toJSONString(resultInfo);
+                    writer.write(jsonStr);
+                    writer.flush();
+                    writer.close();
+                    osw.close();
+                } catch (IOException e) {
+                    log.error("过滤器返回信息失败:" + e.getMessage(), e);
+                } finally {
+                    if (null != writer) {
+                        writer.close();
+                    }
+                    if (null != osw) {
+                        osw.close();
+                    }
+                }
+            }
+        }
+    }
+
+    @Override
+    public void destroy() {
+    }
+}

+ 25 - 0
src/main/java/com/hywa/map/config/interceptor/TokenManager.java

@@ -0,0 +1,25 @@
+package com.hywa.map.config.interceptor;
+
+public interface TokenManager {
+
+    /**
+     * 创建一个token关联上指定用户
+     */
+    TokenModel createToken(String userId);
+
+    /**
+     * 检查token是否有效
+     */
+    boolean checkToken(TokenModel model);
+
+    /**
+     * 从字符串中解析token
+     */
+    TokenModel getToken(String authentication);
+
+    /**
+     * 清除token
+     */
+    void deleteToken(String userId);
+
+}

+ 16 - 0
src/main/java/com/hywa/map/config/interceptor/TokenModel.java

@@ -0,0 +1,16 @@
+package com.hywa.map.config.interceptor;
+
+import lombok.Data;
+
+@Data
+public class TokenModel {
+
+    private String userId;
+
+    private String token;
+
+    public TokenModel(String userId, String token) {
+        this.setUserId(userId);
+        this.setToken(token);
+    }
+}

+ 30 - 0
src/main/java/com/hywa/map/config/interceptor/UserAuthContext.java

@@ -0,0 +1,30 @@
+package com.hywa.map.config.interceptor;
+
+import com.hywa.map.common.utils.StringUtils;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+
+@Component
+public class UserAuthContext implements AuthStrategy {
+
+    @Autowired
+    private AuthService authService;
+    @Value("${user.check.auth}")
+    private String isCheck;
+
+    @Override
+    public boolean executeAuth(String userId, String servletPath) {
+        if (!"1".equals(isCheck)) {
+            return true;
+        }
+        //用户ID为空,不允许通过,直接返回false
+        if (StringUtils.isEmpty(userId)) {
+            return false;
+        }
+        //如果用户拥有该接口所属模块权限则返回true,否则false
+        return authService.isAuth(userId, servletPath);
+    }
+
+}

+ 49 - 0
src/main/java/com/hywa/map/config/redis/CacheKeyGenerator.java

@@ -0,0 +1,49 @@
+package com.hywa.map.config.redis;
+
+
+import java.lang.reflect.Array;
+import java.lang.reflect.Method;
+
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.cache.interceptor.KeyGenerator;
+import org.springframework.stereotype.Component;
+import org.springframework.util.ClassUtils;
+
+@Slf4j
+@Component
+public class CacheKeyGenerator implements KeyGenerator {
+
+    public static final int NO_PARAM_KEY = 0;
+    public static final int NULL_PARAM_KEY = 53;
+
+    @Override
+    public Object generate(Object target, Method method, Object... params) {
+        StringBuilder key = new StringBuilder();
+        key.append(target.getClass().getSimpleName()).append(".").append(method.getName()).append(":");
+        if (params.length == 0) {
+            return key.append(NO_PARAM_KEY).toString();
+        }
+        for (Object param : params) {
+            if (param == null) {
+                log.warn("input null param for Spring cache, use default key={}", NULL_PARAM_KEY);
+                key.append(NULL_PARAM_KEY);
+            } else if (ClassUtils.isPrimitiveArray(param.getClass())) {
+                int length = Array.getLength(param);
+                for (int i = 0; i < length; i++) {
+                    key.append(Array.get(param, i));
+                    key.append(',');
+                }
+            } else if (ClassUtils.isPrimitiveOrWrapper(param.getClass()) || param instanceof String) {
+                key.append(param);
+            } else {
+                log.warn("Using an object as a cache key may lead to unexpected results. " +
+                        "Either use @Cacheable(key=..) or implement CacheKey. Method is " + target.getClass() + "#" + method.getName());
+                key.append(param.hashCode());
+            }
+            key.append('-');
+        }
+
+        return key.toString();
+
+    }
+}

+ 35 - 0
src/main/java/com/hywa/map/config/redis/FastJsonRedisSerializer.java

@@ -0,0 +1,35 @@
+package com.hywa.map.config.redis;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.serializer.SerializerFeature;
+import org.springframework.data.redis.serializer.RedisSerializer;
+import org.springframework.data.redis.serializer.SerializationException;
+
+import java.nio.charset.Charset;
+
+public class FastJsonRedisSerializer<T> implements RedisSerializer<T> {
+    private static final Charset DEFAULT_CHARSET = Charset.forName("UTF-8");
+    private Class<T> clazz;
+
+    public FastJsonRedisSerializer(Class<T> clazz) {
+        super();
+        this.clazz = clazz;
+    }
+
+    @Override
+    public byte[] serialize(T t) throws SerializationException {
+        if (null == t) {
+            return new byte[0];
+        }
+        return JSON.toJSONString(t, SerializerFeature.WriteClassName).getBytes(DEFAULT_CHARSET);
+    }
+
+    @Override
+    public T deserialize(byte[] bytes) throws SerializationException {
+        if (null == bytes || bytes.length <= 0) {
+            return null;
+        }
+        String str = new String(bytes, DEFAULT_CHARSET);
+        return (T) JSON.parseObject(str, clazz);
+    }
+}

+ 63 - 0
src/main/java/com/hywa/map/config/redis/RedisConfig.java

@@ -0,0 +1,63 @@
+package com.hywa.map.config.redis;
+
+import com.alibaba.fastjson.parser.ParserConfig;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
+import org.springframework.cache.CacheManager;
+import org.springframework.cache.annotation.CachingConfigurerSupport;
+import org.springframework.cache.annotation.EnableCaching;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.data.redis.cache.RedisCacheManager;
+import org.springframework.data.redis.connection.RedisConnectionFactory;
+import org.springframework.data.redis.core.RedisOperations;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.data.redis.core.StringRedisTemplate;
+import org.springframework.data.redis.serializer.StringRedisSerializer;
+
+@EnableCaching
+@Configuration
+@ConditionalOnClass(RedisOperations.class)
+public class RedisConfig extends CachingConfigurerSupport {
+
+    @Bean(name = "redisTemplate")
+    @SuppressWarnings("unchecked")
+    @ConditionalOnMissingBean(name = "redisTemplate")
+    public RedisTemplate<Object, Object> redisTemplate(
+            RedisConnectionFactory redisConnectionFactory) {
+        ParserConfig.getGlobalInstance().setAutoTypeSupport(true);
+        RedisTemplate<Object, Object> template = new RedisTemplate<>();
+
+        //使用fastjson序列化
+        FastJsonRedisSerializer fastJsonRedisSerializer = new FastJsonRedisSerializer(Object.class);
+        // value值的序列化采用fastJsonRedisSerializer
+        template.setValueSerializer(fastJsonRedisSerializer);
+        template.setHashValueSerializer(fastJsonRedisSerializer);
+        // key的序列化采用StringRedisSerializer
+        template.setKeySerializer(new StringRedisSerializer());
+        template.setHashKeySerializer(new StringRedisSerializer());
+
+        template.setConnectionFactory(redisConnectionFactory);
+        return template;
+    }
+
+    @Bean
+    @ConditionalOnMissingBean(StringRedisTemplate.class)
+    public StringRedisTemplate stringRedisTemplate(RedisConnectionFactory redisConnectionFactory) {
+        StringRedisTemplate template = new StringRedisTemplate();
+        template.setConnectionFactory(redisConnectionFactory);
+        return template;
+    }
+
+    //缓存管理器
+    @Bean
+    public CacheManager cacheManager(RedisConnectionFactory redisConnectionFactory) {
+        RedisCacheManager.RedisCacheManagerBuilder builder = RedisCacheManager
+                .RedisCacheManagerBuilder
+                .fromConnectionFactory(redisConnectionFactory);
+        return builder.build();
+    }
+
+
+
+}

+ 110 - 0
src/main/java/com/hywa/map/config/redis/RedisUtil.java

@@ -0,0 +1,110 @@
+package com.hywa.map.config.redis;
+
+import com.alibaba.fastjson.JSON;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.data.redis.core.ValueOperations;
+import org.springframework.data.redis.serializer.StringRedisSerializer;
+import org.springframework.stereotype.Component;
+
+import java.io.Serializable;
+import java.util.concurrent.TimeUnit;
+
+
+@Component
+public class RedisUtil {
+    private static final Logger LOGGER = LoggerFactory.getLogger(RedisUtil.class);
+
+    @Autowired
+    private RedisTemplate redisTemplate;
+
+    /**
+     * 设置缓存
+     */
+    public void set(String key, String value) {
+        try {
+            ValueOperations<String, Object> operations = redisTemplate.opsForValue();
+            operations.set(key, value);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        //LOGGER.debug("RedisUtil:set cache key={},value={}", key, value);
+    }
+
+    /**
+     * 设置缓存对象
+     */
+    public <T> void setObject(String key, T obj, int expireTime) {
+        ValueOperations<Serializable, Object> operations = redisTemplate.opsForValue();
+        operations.set(key, JSON.toJSONString(obj), expireTime, TimeUnit.SECONDS);
+    }
+
+    /**
+     * 获取指定key的缓存
+     */
+    public String getObject(String key) {
+        redisTemplate.setValueSerializer(new StringRedisSerializer());
+        ValueOperations<Serializable, Object> operations = redisTemplate.opsForValue();
+        return operations.get(key).toString();
+    }
+
+    /**
+     * 判断当前key值 是否存在
+     */
+    public boolean hasKey(String key) {
+        return redisTemplate.hasKey(key);
+    }
+
+
+    /**
+     * 设置缓存,并且自己指定过期时间
+     */
+    public void setWithExpireTime(String key, String value, int expireTime) {
+        ValueOperations<Serializable, Object> operations = redisTemplate.opsForValue();
+        operations.set(key, value, expireTime, TimeUnit.SECONDS);
+        LOGGER.debug("RedisUtil:setWithExpireTime cache key={},value={},expireTime={}", key, value, expireTime);
+    }
+
+    /**
+     * 获取指定key的缓存
+     */
+    public String get(String key) {
+        redisTemplate.setValueSerializer(new StringRedisSerializer());
+        ValueOperations<Serializable, Object> operations = redisTemplate.opsForValue();
+        Object value = operations.get(key);
+        if (value == null) {
+            return null;
+        }
+        //LOGGER.debug("RedisUtil:getChildren cache key={},value={}", key, value);
+        return value.toString();
+    }
+
+    /**
+     * 删除指定key的缓存
+     */
+    public void delete(String key) {
+        redisTemplate.delete(key);
+        LOGGER.debug("RedisUtil:delete cache key={}", key);
+    }
+
+    /**
+     * 设置过期时间
+     */
+    public void expire(String key, int seconds) {
+        if (seconds <= 0) {
+            return;
+        }
+        redisTemplate.expire(key, seconds, TimeUnit.SECONDS);
+    }
+}
+
+
+
+
+
+
+
+
+

+ 36 - 0
src/main/java/com/hywa/map/config/thread/ThreadPoolConfig.java

@@ -0,0 +1,36 @@
+package com.hywa.map.config.thread;
+
+import java.util.concurrent.Executor;
+import java.util.concurrent.ThreadPoolExecutor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.scheduling.annotation.EnableAsync;
+import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
+
+@Slf4j
+@Configuration
+@EnableAsync
+public class ThreadPoolConfig {
+
+    @Bean
+    public Executor asyncExecutor() {
+        log.info("start asyncServiceExecutor");
+        ThreadPoolTaskExecutor executor = new VisiableThreadPoolTaskExecutor();
+        //配置核心线程数
+        executor.setCorePoolSize(50);
+        //配置最大线程数
+        executor.setMaxPoolSize(1000);
+        //配置队列大小
+        executor.setQueueCapacity(99999);
+        //配置线程池中的线程的名称前缀
+        executor.setThreadNamePrefix("data-base-async-");
+
+        // rejection-policy:当pool已经达到max size的时候,如何处理新任务
+        // CALLER_RUNS:不在新线程中执行任务,而是有调用者所在的线程来执行
+        executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
+        //执行初始化
+        executor.initialize();
+        return executor;
+    }
+}

+ 64 - 0
src/main/java/com/hywa/map/config/thread/VisiableThreadPoolTaskExecutor.java

@@ -0,0 +1,64 @@
+package com.hywa.map.config.thread;
+
+import java.util.concurrent.Callable;
+import java.util.concurrent.Future;
+import java.util.concurrent.ThreadPoolExecutor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
+import org.springframework.util.concurrent.ListenableFuture;
+
+@Slf4j
+public class VisiableThreadPoolTaskExecutor extends ThreadPoolTaskExecutor {
+
+    private void showThreadPoolInfo(String prefix) {
+        ThreadPoolExecutor threadPoolExecutor = getThreadPoolExecutor();
+
+        if (null == threadPoolExecutor) {
+            return;
+        }
+
+        log.info("{}, {},taskCount [{}], completedTaskCount [{}], activeCount [{}], queueSize [{}]",
+                this.getThreadNamePrefix(),
+                prefix,
+                threadPoolExecutor.getTaskCount(),
+                threadPoolExecutor.getCompletedTaskCount(),
+                threadPoolExecutor.getActiveCount(),
+                threadPoolExecutor.getQueue().size());
+    }
+
+    @Override
+    public void execute(Runnable task) {
+        showThreadPoolInfo("1. do execute");
+        super.execute(task);
+    }
+
+    @Override
+    public void execute(Runnable task, long startTimeout) {
+        showThreadPoolInfo("2. do execute");
+        super.execute(task, startTimeout);
+    }
+
+    @Override
+    public Future<?> submit(Runnable task) {
+        showThreadPoolInfo("1. do submit");
+        return super.submit(task);
+    }
+
+    @Override
+    public <T> Future<T> submit(Callable<T> task) {
+        showThreadPoolInfo("2. do submit");
+        return super.submit(task);
+    }
+
+    @Override
+    public ListenableFuture<?> submitListenable(Runnable task) {
+        showThreadPoolInfo("1. do submitListenable");
+        return super.submitListenable(task);
+    }
+
+    @Override
+    public <T> ListenableFuture<T> submitListenable(Callable<T> task) {
+        showThreadPoolInfo("2. do submitListenable");
+        return super.submitListenable(task);
+    }
+}

+ 37 - 0
src/main/java/com/hywa/map/config/validation/FormValidation.java

@@ -0,0 +1,37 @@
+package com.hywa.map.config.validation;
+
+import com.hywa.map.common.exception.GlobalException;
+import org.aspectj.lang.ProceedingJoinPoint;
+import org.aspectj.lang.annotation.Around;
+import org.aspectj.lang.annotation.Aspect;
+import org.aspectj.lang.reflect.MethodSignature;
+import org.springframework.core.annotation.Order;
+import org.springframework.stereotype.Component;
+import java.lang.reflect.Method;
+
+@Component
+@Aspect
+public class FormValidation {
+
+    //注解式表单验证
+    @Around("@annotation(com.hywa.map.config.validation.JsonValidate)")
+    @Order(1)
+    public Object formValidation(ProceedingJoinPoint point) throws Throwable {
+        //获得对象方法
+        Method method = ((MethodSignature) point.getSignature()).getMethod();
+        JsonValidate annotation = method.getAnnotation(JsonValidate.class);
+        //通过反射调用注解中的方法
+        Class<?> clazz = Class.forName(annotation.value().getName());
+        Method clazzMethod = clazz.getMethod("validate", Object[].class);
+        Object invoke =null;
+        try {
+            invoke = clazzMethod.invoke(clazz.newInstance(), (Object) point.getArgs());
+        }catch(GlobalException e){
+            e.getCause();
+        }
+        if (null != invoke) {
+            return invoke;
+        }
+        return point.proceed();
+    }
+}

+ 17 - 0
src/main/java/com/hywa/map/config/validation/JsonValidate.java

@@ -0,0 +1,17 @@
+package com.hywa.map.config.validation;
+
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Component;
+import java.lang.annotation.*;
+
+//运行期保留
+@Retention(RetentionPolicy.RUNTIME)
+//作用于方法上
+@Target(ElementType.METHOD)
+@Documented
+@Component
+@Scope("prototype")
+public @interface JsonValidate {
+
+    Class<?> value();
+}

+ 10 - 0
src/main/java/com/hywa/map/config/validation/Validator.java

@@ -0,0 +1,10 @@
+package com.hywa.map.config.validation;
+
+import com.hywa.map.representation.ResponseBase;
+import org.springframework.http.ResponseEntity;
+
+public abstract class Validator {
+
+    public abstract ResponseEntity<ResponseBase> validate(Object... t);
+
+}

+ 111 - 0
src/main/java/com/hywa/map/controller/branch/BranchController.java

@@ -0,0 +1,111 @@
+package com.hywa.map.controller.branch;
+
+import com.hywa.map.common.log.Log;
+import com.hywa.map.config.EnvProperties;
+import com.hywa.map.config.interceptor.TokenManager;
+import com.hywa.map.config.interceptor.TokenModel;
+import com.hywa.map.representation.*;
+import com.hywa.map.service.branch.BranchService;
+import io.swagger.annotations.Api;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletRequest;
+
+import static com.hywa.map.common.ConstantPool.SPLIT;
+
+/**
+ * t_sys_branch  对应Controller 实现类
+ *
+ * @author hywa
+ * @create by 2018-12-12 10:01:56
+ */
+
+@Slf4j
+@Api(tags = "组织机构")
+@RestController
+@RequestMapping("/branch")
+public class BranchController {
+
+    @Autowired
+    private BranchService branchService;
+    @Autowired
+    EnvProperties envProperties;
+
+    @Autowired
+    TokenManager tokenManager;
+
+    @PostMapping
+    @Transactional
+    @Log(log = "组织机构-新增组织机构信息")
+    public ResponseEntity<ResponseBase> save(@RequestBody BranchReq reqInfo, HttpServletRequest req) {
+        TokenModel accessToken = tokenManager.getToken(req.getHeader("accessToken"));
+        String userId = accessToken.getUserId().split(SPLIT)[1];
+        try {
+            branchService.save(reqInfo, userId);
+        } catch (Exception e) {
+            log.error("新增组织机构信息异常,请求数据|" + reqInfo + ",异常信息|" + e);
+            throw e;
+        }
+        return new ResponseEntity<>(new ResponseBase().success(), HttpStatus.OK);
+    }
+
+    @DeleteMapping
+    @Log(log = "组织机构-删除组织机构信息")
+    public ResponseEntity<ResponseBase> delete(@RequestBody BranchReq reqInfo, HttpServletRequest req) {
+        TokenModel accessToken = tokenManager.getToken(req.getHeader("accessToken"));
+        String userId = accessToken.getUserId().split(SPLIT)[1];
+        try {
+            branchService.delete(reqInfo, userId);
+        } catch (Exception e) {
+            log.error("删除组织机构信息异常,请求数据|" + reqInfo + ",异常信息|" + e);
+            throw e;
+        }
+        return new ResponseEntity<>(new ResponseBase().success(), HttpStatus.OK);
+    }
+
+    @RequestMapping(value = "/findAll", method = RequestMethod.GET)
+    public ResponseEntity<ResponseBase> select() {
+        ResponseBase<BranchReps> responseBase = new ResponseBase<>();
+        responseBase.success().setRetBody(branchService.selectAll());
+        return new ResponseEntity<>(responseBase, HttpStatus.OK);
+    }
+
+    @RequestMapping(value = "/findById", method = RequestMethod.GET)
+    public ResponseEntity<ResponseBase<BranchRep>> findById(@RequestParam(required = false) String id) {
+        ResponseBase<BranchRep> responseBase = new ResponseBase<>();
+        responseBase.success().setRetBody(branchService.selectById(id));
+        responseBase.success();
+        return new ResponseEntity<>(responseBase, HttpStatus.OK);
+    }
+
+
+    @PutMapping
+    @Log(log = "组织机构-编辑组织机构信息")
+    public ResponseEntity<ResponseBase> update(@RequestBody BranchReq reqInfo, HttpServletRequest req) {
+        TokenModel accessToken = tokenManager.getToken(req.getHeader("accessToken"));
+        String userId = accessToken.getUserId().split(SPLIT)[1];
+        try {
+            branchService.update(reqInfo, userId);
+        } catch (Exception e) {
+            log.error("编辑组织机构信息异常,请求数据|" + reqInfo + ",异常信息|" + e);
+            throw e;
+        }
+        return new ResponseEntity<>(new ResponseBase().success(), HttpStatus.OK);
+    }
+
+    @RequestMapping(value = "/findByParam", method = RequestMethod.GET)
+    public ResponseEntity<ResponseBase> findByParam(@RequestParam(required = false) String queryParam,
+                                                    @RequestParam(defaultValue = "1") int pageNo,
+                                                    @RequestParam(defaultValue = "100") int pageSize) {
+        ResponseBase<BranchReps> responseBase = new ResponseBase<>();
+        responseBase.success().setRetBody(branchService.selectByParam(pageNo, pageSize, queryParam));
+        return new ResponseEntity<>(responseBase, HttpStatus.OK);
+    }
+
+}
+

+ 125 - 0
src/main/java/com/hywa/map/controller/common/FileController.java

@@ -0,0 +1,125 @@
+package com.hywa.map.controller.common;
+
+import com.hywa.map.common.exception.GlobalException;
+import com.hywa.map.common.utils.FileUtils;
+import com.hywa.map.common.utils.StringUtils;
+import com.hywa.map.config.EnvProperties;
+import com.hywa.map.representation.ResponseBase;
+import com.hywa.map.representation.UploadFileRep;
+import io.swagger.annotations.Api;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.UnsupportedEncodingException;
+
+import static com.hywa.map.common.enums.CommonEnum.ILLEGAL_PARAMETER_ERROR;
+
+/**
+ * dap_weather  对应Controller 实现类
+ *
+ * @author hywa
+ * @create by 2018-08-06 15:02:49
+ */
+@Slf4j
+@Api(tags = "文件管理")
+@RestController
+@RequestMapping("/file")
+public class FileController {
+    @Autowired
+    EnvProperties envProperties;
+
+    @RequestMapping(value = "/uploadFile", method = RequestMethod.POST)
+    @Transactional
+    public ResponseEntity<ResponseBase> uploadFile(@RequestParam("file") MultipartFile file, @RequestParam("fileType") String fileType,HttpServletRequest req) {
+        if (file.isEmpty()) {
+            throw new GlobalException(ILLEGAL_PARAMETER_ERROR.getIndex(), ILLEGAL_PARAMETER_ERROR.getValue() + ",文件为空", null, "上传文件");
+        }
+        if (StringUtils.isEmpty(fileType)) {
+            throw new GlobalException(ILLEGAL_PARAMETER_ERROR.getIndex(), ILLEGAL_PARAMETER_ERROR.getValue() + ",文件类型不能为空", null, "文件管理-上传文件");
+        }
+        String fileName = file.getOriginalFilename();
+        try {
+            String filePath=null;
+            if ("map".equals(fileType)) {
+                filePath = envProperties.getMapPicturePath();
+            }
+            FileUtils.upload(file, filePath);
+        } catch (Exception e) {
+            log.error("上传文件异常,请求数据|" + fileName + ",异常信息|" + e);
+            throw e;
+        }
+        ResponseBase<UploadFileRep> responseBase = new ResponseBase<>();
+        UploadFileRep uploadFileRep = new UploadFileRep();
+        uploadFileRep.setFileName(fileName);
+        String fileUrl=envProperties.getPubFileDownloadUrl() + fileName+"&fileType="+fileType;
+        uploadFileRep.setFileUrl(fileUrl);
+        responseBase.success().setRetBody( uploadFileRep);
+        log.info("上传文件成功,请求数据:fileName|" + fileName + ",fileType|" + fileType);
+        return new ResponseEntity<>(responseBase, HttpStatus.OK);
+    }
+
+    @RequestMapping(value = "/uploadDocument", method = RequestMethod.POST)
+    @Transactional
+    public ResponseEntity<ResponseBase> uploadDocument(@RequestParam("file") MultipartFile file,HttpServletRequest req) {
+        if (file.isEmpty()) {
+            throw new GlobalException(ILLEGAL_PARAMETER_ERROR.getIndex(), ILLEGAL_PARAMETER_ERROR.getValue() + ",文件为空", null, "上传文件");
+        }
+        String fileName = file.getOriginalFilename();
+        try {
+            String filePath = envProperties.getComFilePath();
+            fileName = FileUtils.uploadByNewName(file, filePath);
+        } catch (Exception e) {
+            log.error("上传文件异常,请求数据|" + fileName + ",异常信息|" + e);
+            throw e;
+        }
+        ResponseBase<UploadFileRep> responseBase = new ResponseBase<>();
+        UploadFileRep uploadFileRep = new UploadFileRep();
+        uploadFileRep.setFileName(fileName);
+        String fileUrl=envProperties.getComFileDownloadUrl() + fileName;
+        uploadFileRep.setFileUrl(fileUrl);
+        responseBase.success().setRetBody( uploadFileRep);
+        log.info("上传文件成功,请求数据:fileName|" + fileName);
+        return new ResponseEntity<>(responseBase, HttpStatus.OK);
+    }
+
+    /**
+     * 下载附件
+     */
+    @GetMapping(value = "/downloadDocument")
+    public void downloadDocument(
+            HttpServletResponse response,
+            HttpServletRequest request,
+            @RequestParam(required = false) String fileName) throws UnsupportedEncodingException {
+        String menuName = "文件管理-查看文件信息";
+        String filePath = envProperties.getComFilePath();
+        log.info("下载文件成功,请求数据:fileName|" + fileName);
+        FileUtils.downloadFile(filePath + fileName, fileName, response, request, menuName);
+    }
+
+    /**
+     * 下载附件
+     */
+    @GetMapping(value = "/downloadAttach")
+    public void downloadAttach(
+            HttpServletResponse response,
+            HttpServletRequest request,
+            @RequestParam(required = false) String fileName,
+            @RequestParam(required = false) String fileType) throws UnsupportedEncodingException {
+        String menuName = "文件管理-查看文件信息";
+        String filePath = "";
+        if ("map".equals(fileType)) {
+            filePath = envProperties.getMapPicturePath();
+        }
+        log.info("下载文件成功,请求数据:fileName|" + fileName + ",fileType|" + fileType);
+        FileUtils.downloadFile(filePath + fileName, fileName, response, request, menuName);
+    }
+
+}
+

+ 63 - 0
src/main/java/com/hywa/map/controller/common/WeatherController.java

@@ -0,0 +1,63 @@
+package com.hywa.map.controller.common;
+
+import com.hywa.map.representation.ResponseBase;
+import com.hywa.map.representation.TempHour;
+import com.hywa.map.representation.WeatherForecast;
+import com.hywa.map.service.common.WeatherService;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+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.ResponseBody;
+
+/**
+ * dap_weather  对应Controller 实现类
+ *
+ * @author hywa
+ * @create by 2018-08-06 15:02:49
+ */
+@Controller
+@RequestMapping("/public")
+public class WeatherController{
+    @Autowired
+    private WeatherService weatherService;
+
+    private static Log log = LogFactory.getLog(WeatherController.class);
+
+    /**
+     * 获取天气预报信息
+     */
+    @ResponseBody
+    @RequestMapping(value = "/weather", method = RequestMethod.GET)
+    public ResponseEntity<ResponseBase> forecast(String cityCode) {
+        try {
+            ResponseBase<WeatherForecast> responseBase = new ResponseBase<>();
+            responseBase.success().setRetBody(weatherService.getWeather(cityCode));
+            return new ResponseEntity<>(responseBase, HttpStatus.OK);
+        } catch (Exception e) {
+            log.error("查询天气信息,城市:" + cityCode + "|查询异常:" + e);
+            throw e;
+        }
+    }
+
+    /**
+     * 获取24小时天气预报信息
+     */
+    @ResponseBody
+    @RequestMapping(value = "/hourWeather", method = RequestMethod.GET)
+    public ResponseEntity<ResponseBase> getHourWeather(String cityCode) {
+        try {
+            ResponseBase<TempHour> responseBase = new ResponseBase<>();
+            responseBase.success().setRetBody(weatherService.getHourWeather(cityCode));
+            return new ResponseEntity<>(responseBase, HttpStatus.OK);
+        } catch (Exception e) {
+            log.error("查询24小时天气信息,城市:" + cityCode + "|查询异常:" + e);
+            throw e;
+        }
+    }
+}
+

+ 83 - 0
src/main/java/com/hywa/map/controller/csv/CsvController.java

@@ -0,0 +1,83 @@
+package com.hywa.map.controller.csv;
+
+import com.hywa.map.common.exception.GlobalException;
+import com.hywa.map.common.utils.FileUtils;
+import com.hywa.map.config.EnvProperties;
+import com.hywa.map.config.interceptor.TokenManager;
+import com.hywa.map.config.interceptor.TokenModel;
+import com.hywa.map.representation.*;
+import com.hywa.map.service.csv.CsvService;
+import io.swagger.annotations.Api;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.servlet.http.HttpServletRequest;
+
+import static com.hywa.map.common.ConstantPool.SPLIT;
+import static com.hywa.map.common.enums.CommonEnum.ILLEGAL_PARAMETER_ERROR;
+
+/**
+ * t_mon_dealer_invent  对应Controller 实现类
+ *
+ * @author hywa
+ * @create by 2019-03-04 13:49:14
+ */
+@Slf4j
+@Api(tags = "csv文件操作")
+@RestController
+@RequestMapping("/csv")
+public class CsvController {
+
+    @Autowired
+    private CsvService csvService;
+    @Autowired
+    EnvProperties envProperties;
+    @Autowired
+    TokenManager tokenManager;
+
+    /*
+     *查询csv数据
+     */
+    @RequestMapping(value = "/findAll", method = RequestMethod.GET)
+    public ResponseEntity<ResponseBase> findByParam(@RequestParam(defaultValue = "1") int pageNo,
+                                                    @RequestParam(defaultValue = "10") int pageSize,
+                                                    @RequestParam(required = false) String tableName) {
+        ResponseBase<CsvReps> responseBase = new ResponseBase<>();
+        responseBase.success().setRetBody(csvService.findAll(pageNo, pageSize, tableName));
+        return new ResponseEntity<>(responseBase, HttpStatus.OK);
+    }
+
+    /*
+     *上传csv文件
+     */
+    @RequestMapping(value = "/uploadFile", method = RequestMethod.POST)
+    @Transactional
+    public ResponseEntity<ResponseBase> uploadFile(@RequestParam("file") MultipartFile file, HttpServletRequest req) {
+        TokenModel accessToken = tokenManager.getToken(req.getHeader("accessToken"));
+        String userId = accessToken.getUserId().split(SPLIT)[1];
+        if (file.isEmpty()) {
+            throw new GlobalException(ILLEGAL_PARAMETER_ERROR.getIndex(), ILLEGAL_PARAMETER_ERROR.getValue() + ",文件为空", null, "上传文件");
+        }
+        String fileName = file.getOriginalFilename();
+        try {
+            FileUtils.upload(file, envProperties.getCsvFilePath());
+        } catch (Exception e) {
+            log.error("上传文件异常,请求数据|" + fileName + ",异常信息|" + e);
+            throw e;
+        }
+        String csvId = csvService.doCsvFile(envProperties.getCsvFilePath(), fileName, userId);
+        ResponseBase<UploadCsvRep> responseBase = new ResponseBase<>();
+        UploadCsvRep uploadCsvRep = new UploadCsvRep();
+        uploadCsvRep.setCsvId(csvId);
+        responseBase.success().setRetBody(uploadCsvRep);
+        return new ResponseEntity<>(responseBase, HttpStatus.OK);
+    }
+}

+ 119 - 0
src/main/java/com/hywa/map/controller/csv/DbController.java

@@ -0,0 +1,119 @@
+package com.hywa.map.controller.csv;
+
+import com.hywa.map.common.log.Log;
+import com.hywa.map.common.utils.FileUtils;
+import com.hywa.map.config.EnvProperties;
+import com.hywa.map.config.interceptor.TokenManager;
+import com.hywa.map.config.interceptor.TokenModel;
+import com.hywa.map.representation.DbRep;
+import com.hywa.map.representation.DbReps;
+import com.hywa.map.representation.DbReq;
+import com.hywa.map.representation.ResponseBase;
+import com.hywa.map.service.csv.DbService;
+import io.swagger.annotations.Api;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import java.io.UnsupportedEncodingException;
+
+import static com.hywa.map.common.ConstantPool.SPLIT;
+
+/**
+ * t_mon_dealer_invent  对应Controller 实现类
+ *
+ * @author hywa
+ * @create by 2019-03-04 13:49:14
+ */
+@Slf4j
+@Api(tags = "我的数据源")
+@RestController
+@RequestMapping("/db")
+public class DbController {
+
+    @Autowired
+    private DbService dbService;
+    @Autowired
+    EnvProperties envProperties;
+    @Autowired
+    TokenManager tokenManager;
+
+    @PostMapping
+    @Transactional
+    @Log(log = "我的数据源-新增数据源信息")
+    public ResponseEntity<ResponseBase> save(@RequestBody DbReq reqInfo, HttpServletRequest req) {
+        TokenModel accessToken = tokenManager.getToken(req.getHeader("accessToken"));
+        String userId = accessToken.getUserId().split(SPLIT)[1];
+        try {
+            dbService.save(reqInfo, userId);
+        } catch (Exception e) {
+            log.error("新增数据源信息异常,请求数据|" + reqInfo + ",异常信息|" + e);
+            throw e;
+        }
+        return new ResponseEntity<>(new ResponseBase().success(), HttpStatus.OK);
+    }
+
+    @PutMapping
+    @Log(log = "我的数据源-编辑数据源信息")
+    public ResponseEntity<ResponseBase> update(@RequestBody DbReq reqInfo, HttpServletRequest req) {
+        TokenModel accessToken = tokenManager.getToken(req.getHeader("accessToken"));
+        String userId = accessToken.getUserId().split(SPLIT)[1];
+        try {
+            dbService.update(reqInfo, userId);
+        } catch (Exception e) {
+            log.error("编辑数据源信息异常,请求数据|" + reqInfo + ",异常信息|" + e);
+            throw e;
+        }
+        return new ResponseEntity<>(new ResponseBase().success(), HttpStatus.OK);
+    }
+
+    @DeleteMapping
+    @Log(log = "我的数据源-删除数据源信息")
+    public ResponseEntity<ResponseBase> delete(@RequestBody DbReq reqInfo, HttpServletRequest req) {
+        TokenModel accessToken = tokenManager.getToken(req.getHeader("accessToken"));
+        String userId = accessToken.getUserId().split(SPLIT)[1];
+        try {
+            dbService.delete(reqInfo, userId);
+        } catch (Exception e) {
+            log.error("删除数据源信息异常,请求数据|" + reqInfo + ",异常信息|" + e);
+            throw e;
+        }
+        return new ResponseEntity<>(new ResponseBase().success(), HttpStatus.OK);
+    }
+
+    @RequestMapping(value = "/findAll", method = RequestMethod.GET)
+    public ResponseEntity<ResponseBase> findAll(@RequestParam(defaultValue = "1") int pageNo,
+                                                @RequestParam(defaultValue = "100") int pageSize,
+                                                @RequestParam(required = false) String sourceType,
+                                                @RequestParam(required = false) String sourceName) {
+        ResponseBase<DbReps> responseBase = new ResponseBase<>();
+        responseBase.success().setRetBody(dbService.selectAll(pageNo, pageSize, sourceType, sourceName));
+        return new ResponseEntity<>(responseBase, HttpStatus.OK);
+    }
+
+    @RequestMapping(value = "/findById", method = RequestMethod.GET)
+    public ResponseEntity<ResponseBase<DbRep>> findById(@RequestParam(required = false) String id) {
+        ResponseBase<DbRep> responseBase = new ResponseBase<>();
+        responseBase.success().setRetBody(dbService.selectById(id));
+        responseBase.success();
+        return new ResponseEntity<>(responseBase, HttpStatus.OK);
+    }
+
+    /**
+     * 下载附件
+     */
+    @GetMapping(value = "/downloadAttach")
+    public void downloadAttach(
+            HttpServletResponse response,
+            HttpServletRequest request, @RequestParam(required = false) String fileName) throws UnsupportedEncodingException {
+        String menuName = "我的数据源-下载csv文件";
+        String filePath = envProperties.getCsvFilePath();
+        FileUtils.downloadFile(filePath + fileName, fileName, response, request, menuName);
+    }
+}

+ 97 - 0
src/main/java/com/hywa/map/controller/depart/DepartController.java

@@ -0,0 +1,97 @@
+package com.hywa.map.controller.depart;
+
+import com.hywa.map.common.log.Log;
+import com.hywa.map.config.EnvProperties;
+import com.hywa.map.config.interceptor.TokenManager;
+import com.hywa.map.config.interceptor.TokenModel;
+import com.hywa.map.representation.*;
+import com.hywa.map.service.depart.DepartService;
+import io.swagger.annotations.Api;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletRequest;
+
+import static com.hywa.map.common.ConstantPool.SPLIT;
+
+/**
+ * t_sys_depart  对应Controller 实现类
+ *
+ * @author hywa
+ * @create by 2019-02-14 15:50:31
+ */
+@Slf4j
+@Api(tags = "单位基本信息")
+@RestController
+@RequestMapping("/depart")
+public class DepartController {
+    @Autowired
+    private DepartService departService;
+    @Autowired
+    EnvProperties envProperties;
+
+    @Autowired
+    TokenManager tokenManager;
+
+    @PostMapping
+    @Transactional
+    @Log(log = "单位基本信息-保存单位基本信息")
+    public ResponseEntity<ResponseBase> save(@RequestBody DepartReq reqInfo, HttpServletRequest req) {
+        TokenModel accessToken = tokenManager.getToken(req.getHeader("accessToken"));
+        String userId = accessToken.getUserId().split(SPLIT)[1];
+        try {
+            departService.save(reqInfo, userId);
+        } catch (Exception e) {
+            log.error("保存单位基本信息异常,请求数据|" + reqInfo + ",异常信息|" + e);
+            throw e;
+        }
+        return new ResponseEntity<>(new ResponseBase().success(), HttpStatus.OK);
+    }
+
+    @RequestMapping(value = "/findAll", method = RequestMethod.GET)
+    public ResponseEntity<ResponseBase> select() {
+        ResponseBase<DepartRep> responseBase = new ResponseBase<>();
+        responseBase.success().setRetBody(departService.select());
+        return new ResponseEntity<>(responseBase, HttpStatus.OK);
+    }
+
+    @RequestMapping(value = "/findProvince", method = RequestMethod.GET)
+    public ResponseEntity<ResponseBase> findProvince() {
+        ResponseBase<ProvinceReps> responseBase = new ResponseBase<>();
+        responseBase.success().setRetBody(departService.selectProvince());
+        return new ResponseEntity<>(responseBase, HttpStatus.OK);
+    }
+
+    @RequestMapping(value = "/findCity", method = RequestMethod.GET)
+    public ResponseEntity<ResponseBase> findCity(@RequestParam(required = false) String id) {
+        ResponseBase<CityReps> responseBase = new ResponseBase<>();
+        responseBase.success().setRetBody(departService.selectCity(id));
+        return new ResponseEntity<>(responseBase, HttpStatus.OK);
+    }
+
+    @RequestMapping(value = "/findCounty", method = RequestMethod.GET)
+    public ResponseEntity<ResponseBase> findCounty(@RequestParam(required = false) String id) {
+        ResponseBase<CountyReps> responseBase = new ResponseBase<>();
+        responseBase.success().setRetBody(departService.selectCounty(id));
+        return new ResponseEntity<>(responseBase, HttpStatus.OK);
+    }
+
+    @RequestMapping(value = "/findTown", method = RequestMethod.GET)
+    public ResponseEntity<ResponseBase> findTown(@RequestParam(required = false) String id) {
+        ResponseBase<TownReps> responseBase = new ResponseBase<>();
+        responseBase.success().setRetBody(departService.selectTown(id));
+        return new ResponseEntity<>(responseBase, HttpStatus.OK);
+    }
+
+    @RequestMapping(value = "/findVillage", method = RequestMethod.GET)
+    public ResponseEntity<ResponseBase> findVillage(@RequestParam(required = false) String id) {
+        ResponseBase<VillageReps> responseBase = new ResponseBase<>();
+        responseBase.success().setRetBody(departService.selectVillage(id));
+        return new ResponseEntity<>(responseBase, HttpStatus.OK);
+    }
+}
+

+ 144 - 0
src/main/java/com/hywa/map/controller/dict/DictController.java

@@ -0,0 +1,144 @@
+package com.hywa.map.controller.dict;
+
+import com.hywa.map.common.log.Log;
+import com.hywa.map.representation.*;
+import com.hywa.map.service.dict.DictService;
+import io.swagger.annotations.Api;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.bind.annotation.*;
+
+/**
+ * t_sys_dict  对应Controller 实现类
+ *
+ * @author hywa
+ * @create by 2019-02-15 09:56:54
+ */
+@Slf4j
+@Api(tags = "数据字典")
+@RestController
+@RequestMapping("/dict")
+public class DictController {
+
+    @Autowired
+    private DictService dictService;
+
+    @PostMapping
+    @Transactional
+    @Log(log = "数据字典-新增数据字典信息")
+    public ResponseEntity<ResponseBase> save(@RequestBody DictReq reqInfo) {
+        try {
+            dictService.save(reqInfo, null);
+        } catch (Exception e) {
+            log.error("新增数据字典信息异常,请求数据|" + reqInfo + ",异常信息|" + e);
+            throw e;
+        }
+        return new ResponseEntity<>(new ResponseBase().success(), HttpStatus.OK);
+    }
+
+    @PutMapping
+    @Log(log = "数据字典-编辑数据字典信息")
+    public ResponseEntity<ResponseBase> update(@RequestBody DictReq reqInfo) {
+        try {
+            dictService.update(reqInfo, null);
+        } catch (Exception e) {
+            log.error("编辑数据字典信息异常,请求数据|" + reqInfo + ",异常信息|" + e);
+            throw e;
+        }
+        return new ResponseEntity<>(new ResponseBase().success(), HttpStatus.OK);
+    }
+
+    @DeleteMapping
+    @Log(log = "数据字典-删除数据字典信息")
+    public ResponseEntity<ResponseBase> delete(@RequestBody DictReq reqInfo) {
+        try {
+            dictService.delete(reqInfo, null);
+        } catch (Exception e) {
+            log.error("删除数据字典信息异常,请求数据|" + reqInfo + ",异常信息|" + e);
+            throw e;
+        }
+        return new ResponseEntity<>(new ResponseBase().success(), HttpStatus.OK);
+    }
+
+    @RequestMapping(value = "/findAll", method = RequestMethod.GET)
+    public ResponseEntity<ResponseBase> findByParam(@RequestParam(required = false) String queryParam,
+                                                    @RequestParam(defaultValue = "1") int pageNo,
+                                                    @RequestParam(defaultValue = "10") int pageSize) {
+        ResponseBase<DictReps> responseBase = new ResponseBase<>();
+        responseBase.success().setRetBody(dictService.select(pageNo, pageSize, queryParam));
+        return new ResponseEntity<>(responseBase, HttpStatus.OK);
+    }
+
+    @RequestMapping(value = "/findById", method = RequestMethod.GET)
+    public ResponseEntity<ResponseBase<DictRep>> findById(@RequestParam(required = false) String id) {
+        ResponseBase<DictRep> responseBase = new ResponseBase<>();
+        responseBase.success().setRetBody(dictService.selectById(id));
+        responseBase.success();
+        return new ResponseEntity<>(responseBase, HttpStatus.OK);
+    }
+
+    @RequestMapping(value = "/findValue", method = RequestMethod.GET)
+    public ResponseEntity<ResponseBase> findValue(@RequestParam(required = false) String queryParam,
+                                                  @RequestParam(required = true) String dictId,
+                                                  @RequestParam(defaultValue = "1") int pageNo,
+                                                  @RequestParam(defaultValue = "10") int pageSize) {
+        ResponseBase<DictReps> responseBase = new ResponseBase<>();
+        responseBase.success().setRetBody(dictService.selectVal(pageNo, pageSize, dictId, queryParam));
+        return new ResponseEntity<>(responseBase, HttpStatus.OK);
+    }
+
+    @RequestMapping(value = "/saveVale", method = RequestMethod.POST)
+    @Log(log = "数据字典-新增字典值信息")
+    public ResponseEntity<ResponseBase> saveVale(@RequestBody DictReq reqInfo) {
+        try {
+            dictService.saveVal(reqInfo, null);
+        } catch (Exception e) {
+            log.error("新增字典值信息异常,请求数据|" + reqInfo + ",异常信息|" + e);
+            throw e;
+        }
+        return new ResponseEntity<>(new ResponseBase().success(), HttpStatus.OK);
+    }
+
+    @RequestMapping(value = "/updateVale", method = RequestMethod.POST)
+    @Log(log = "数据字典-编辑字典值信息")
+    public ResponseEntity<ResponseBase> updateVale(@RequestBody DictReq reqInfo) {
+        try {
+            dictService.updateVal(reqInfo, null);
+        } catch (Exception e) {
+            log.error("编辑字典值信息异常,请求数据|" + reqInfo + ",异常信息|" + e);
+            throw e;
+        }
+        return new ResponseEntity<>(new ResponseBase().success(), HttpStatus.OK);
+    }
+
+    @RequestMapping(value = "/deleteVale", method = RequestMethod.POST)
+    @Log(log = "数据字典-删除字典值信息")
+    public ResponseEntity<ResponseBase> deleteVale(@RequestBody DictReq reqInfo) {
+        try {
+            dictService.deleteVal(reqInfo, null);
+        } catch (Exception e) {
+            log.error("删除字典值信息异常,请求数据|" + reqInfo + ",异常信息|" + e);
+            throw e;
+        }
+        return new ResponseEntity<>(new ResponseBase().success(), HttpStatus.OK);
+    }
+
+    @RequestMapping(value = "/findValueById", method = RequestMethod.GET)
+    public ResponseEntity<ResponseBase<DictRep>> findValueById(@RequestParam(required = false) String id) {
+        ResponseBase<DictRep> responseBase = new ResponseBase<>();
+        responseBase.success().setRetBody(dictService.selectValById(id));
+        responseBase.success();
+        return new ResponseEntity<>(responseBase, HttpStatus.OK);
+    }
+
+    @RequestMapping(value = "/findValueByCode", method = RequestMethod.GET)
+    public ResponseEntity<ResponseBase> findValueByCode(@RequestParam(required = true) String dictCode) {
+        ResponseBase<DictReps> responseBase = new ResponseBase<>();
+        responseBase.success().setRetBody(dictService.selectVal(dictCode));
+        return new ResponseEntity<>(responseBase, HttpStatus.OK);
+    }
+}
+

+ 74 - 0
src/main/java/com/hywa/map/controller/dict/DictValController.java

@@ -0,0 +1,74 @@
+package com.hywa.map.controller.dict;
+
+import com.hywa.map.common.log.Log;
+import com.hywa.map.representation.DictRep;
+import com.hywa.map.representation.DictReq;
+import com.hywa.map.representation.ResponseBase;
+import com.hywa.map.service.dict.DictService;
+import io.swagger.annotations.Api;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.*;
+
+/**
+ * t_sys_dict  对应Controller 实现类
+ *
+ * @author hywa
+ * @create by 2019-02-15 09:56:54
+ */
+@Slf4j
+@Api(tags = "数据字典")
+@RestController
+@RequestMapping("/dictVal")
+public class DictValController {
+
+    @Autowired
+    private DictService dictService;
+
+    @PostMapping
+    @Log(log = "数据字典-新增字典值信息")
+    public ResponseEntity<ResponseBase> saveVale(@RequestBody DictReq reqInfo) {
+        try {
+            dictService.saveVal(reqInfo, null);
+        } catch (Exception e) {
+            log.error("新增字典值信息异常,请求数据|" + reqInfo + ",异常信息|" + e);
+            throw e;
+        }
+        return new ResponseEntity<>(new ResponseBase().success(), HttpStatus.OK);
+    }
+
+    @PutMapping
+    @Log(log = "数据字典-编辑字典值信息")
+    public ResponseEntity<ResponseBase> updateVale(@RequestBody DictReq reqInfo) {
+        try {
+            dictService.updateVal(reqInfo, null);
+        } catch (Exception e) {
+            log.error("编辑字典值信息异常,请求数据|" + reqInfo + ",异常信息|" + e);
+            throw e;
+        }
+        return new ResponseEntity<>(new ResponseBase().success(), HttpStatus.OK);
+    }
+
+    @DeleteMapping
+    @Log(log = "数据字典-删除字典值信息")
+    public ResponseEntity<ResponseBase> deleteVale(@RequestBody DictReq reqInfo) {
+        try {
+            dictService.deleteVal(reqInfo, null);
+        } catch (Exception e) {
+            log.error("删除字典值信息异常,请求数据|" + reqInfo + ",异常信息|" + e);
+            throw e;
+        }
+        return new ResponseEntity<>(new ResponseBase().success(), HttpStatus.OK);
+    }
+
+    @RequestMapping(value = "/findValueById", method = RequestMethod.GET)
+    public ResponseEntity<ResponseBase<DictRep>> findValueById(@RequestParam(required = false) String id) {
+        ResponseBase<DictRep> responseBase = new ResponseBase<>();
+        responseBase.success().setRetBody(dictService.selectValById(id));
+        responseBase.success();
+        return new ResponseEntity<>(responseBase, HttpStatus.OK);
+    }
+}
+

+ 214 - 0
src/main/java/com/hywa/map/controller/expert/AreaDataController.java

@@ -0,0 +1,214 @@
+package com.hywa.map.controller.expert;
+
+import com.hywa.map.common.ConstantPool;
+import com.hywa.map.common.log.Log;
+import com.hywa.map.common.utils.FileUtils;
+import com.hywa.map.config.EnvProperties;
+import com.hywa.map.config.interceptor.TokenManager;
+import com.hywa.map.config.interceptor.TokenModel;
+import com.hywa.map.representation.*;
+import com.hywa.map.service.expert.AreaDataService;
+import com.hywa.map.service.login.UserRoleService;
+import io.swagger.annotations.Api;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.io.IOUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.core.io.ClassPathResource;
+import org.springframework.core.io.Resource;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+import java.nio.charset.StandardCharsets;
+
+import static com.hywa.map.common.ConstantPool.SPLIT;
+
+
+@Slf4j
+@Api(tags = "区域数据管理")
+@RestController
+@RequestMapping("areaData")
+public class AreaDataController {
+
+    @Autowired
+    EnvProperties envProperties;
+
+    @Autowired
+    TokenManager tokenManager;
+
+    @Autowired
+    private AreaDataService areaDataService;
+
+    @Autowired
+    UserRoleService userRoleService;
+
+    /*
+     * 获取所有区域数据
+     */
+    @RequestMapping(value = "/findAll", method = RequestMethod.GET)
+    public ResponseEntity<ResponseBase> findAll(@RequestParam(defaultValue = "1") int pageNo,
+                                                @RequestParam(defaultValue = "500") int pageSize,
+                                                @RequestParam(required = false) String areaName,
+                                                @RequestParam(required = false) String dataType,
+                                                @RequestParam(required = false) String dataName,
+                                                @RequestParam(required = false) String dataTime) {
+        ResponseBase<AreaDataReps> responseBase = new ResponseBase<>();
+        responseBase.success().setRetBody(areaDataService.queryAll(pageNo, pageSize, areaName, dataType, dataName, dataTime));
+        return new ResponseEntity<>(responseBase, HttpStatus.OK);
+    }
+
+    /*
+     * 根据id查询区域数据信息
+     */
+    @RequestMapping(value = "/findById", method = RequestMethod.GET)
+    public ResponseEntity<ResponseBase> findById(@RequestParam(required = false) String id) {
+        ResponseBase<AreaDataDetailRep> responseBase = new ResponseBase<>();
+        responseBase.success().setRetBody(areaDataService.queryById(id));
+        return new ResponseEntity<>(responseBase, HttpStatus.OK);
+    }
+
+    /*
+     * 删除区域数据信息
+     */
+    @DeleteMapping
+    @Log(log = "区域数据管理-删除区域数据信息")
+    public ResponseEntity<ResponseBase> delete(@RequestBody DamInfoReq reqInfo, HttpServletRequest req) {
+        TokenModel accessToken = tokenManager.getToken(req.getHeader("accessToken"));
+        String userId = accessToken.getUserId().split(SPLIT)[1];
+        try {
+            areaDataService.delete(reqInfo, userId);
+        } catch (Exception e) {
+            log.error("坝区管理-删除坝区信息异常,请求数据:reqInfo|" + reqInfo + ",异常信息|" + e);
+            throw e;
+        }
+        return new ResponseEntity<>(new ResponseBase().success(), HttpStatus.OK);
+    }
+
+    /*
+     * 是否应用于大屏
+     */
+    @RequestMapping(value = "/updateState", method = RequestMethod.POST)
+    @Log(log = "区域数据管理-是否应用于大屏")
+    public ResponseEntity<ResponseBase> updateState(@RequestBody DamInfoReq reqInfo, HttpServletRequest req) {
+        TokenModel accessToken = tokenManager.getToken(req.getHeader("accessToken"));
+        String userId = accessToken.getUserId().split(SPLIT)[1];
+        try {
+            areaDataService.updateIsShow(reqInfo, userId);
+        } catch (Exception e) {
+            log.error("区域数据管理-是否应用于大屏异常,请求数据:reqInfo|" + reqInfo + ",异常信息|" + e);
+            throw e;
+        }
+        return new ResponseEntity<>(new ResponseBase().success(), HttpStatus.OK);
+    }
+
+    /*
+     * 导入excel数据
+     */
+    @RequestMapping(value = "/importXls", method = RequestMethod.POST)
+    @Log(log = "区域数据管理-导入excel数据")
+    public ResponseEntity<ResponseBase> importXls(@RequestParam("file") MultipartFile file, HttpServletRequest req) {
+        TokenModel accessToken = tokenManager.getToken(req.getHeader("accessToken"));
+        String userId = accessToken.getUserId().split(SPLIT)[1];
+        try {
+            areaDataService.importXls(file, userId);
+        } catch (Exception e) {
+            log.error("区域数据管理-导入excel数据异常,请求数据|" + file.getOriginalFilename() + ",异常信息|" + e);
+            throw e;
+        }
+        return new ResponseEntity<>(new ResponseBase().success(), HttpStatus.OK);
+    }
+
+    /**
+     * 下载结果文件
+     */
+    @GetMapping(value = "/downloadXls")
+    public void downloadExcel(
+            HttpServletResponse response,
+            HttpServletRequest request,
+            @RequestParam(required = false) String id) throws UnsupportedEncodingException {
+        String fileName = areaDataService.exportXls(id);
+        FileUtils.downloadFile(envProperties.getComFilePath() + fileName, fileName, response, request, "根据id导出区域数据信息");
+    }
+
+    /**
+     * 下载模版
+     */
+    /*@GetMapping(value = "/downloadTemplate")
+    public void downloadTemplate(
+            HttpServletResponse response,
+            HttpServletRequest request) throws UnsupportedEncodingException {
+        Resource resource = new ClassPathResource(ConstantPool.IMPORT_TEMPLATE + "/表单导入模版.rar");
+        File file = null;
+        try {
+            file = resource.getFile();
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        FileUtils.downloadFile(file.getPath(), file.getName(), response, request, "区域数据管理-下载模版文件");
+    }*/
+
+    /**
+     * 下载模板
+     *
+     * @param response
+     * @param request
+     */
+    @RequestMapping(value = "/downloadTemplate")
+    public void downloadTemp(HttpServletResponse response, HttpServletRequest request) {
+        InputStream inputStream = null;
+        ServletOutputStream servletOutputStream = null;
+        try {
+            String fileName = "表单导入模版.rar";
+            Resource resource = new ClassPathResource(ConstantPool.IMPORT_TEMPLATE + "/表单导入模版.rar");
+            response.setContentType("application/force-download");// 设置强制下载不打开
+            //不能直接在header中设置中文,普通浏览器要使用URLEncoder.encode方法encode一下,其中火狐浏览器要区别处理,要转成ISO-8859-1编码
+            if (request.getHeader("user-agent").toLowerCase().indexOf("firefox") > -1) {
+                response.addHeader("Content-Disposition",
+                        "attachment;filename=" + new String(fileName.getBytes("utf-8"), "ISO-8859-1"));
+            } else {
+                response.addHeader("Content-Disposition",
+                        "attachment;filename=" + URLEncoder.encode(fileName, "utf-8"));
+            }
+            String encodeName = URLEncoder.encode(fileName, StandardCharsets.UTF_8.toString());
+            response.setHeader("Content-Disposition", "attachment; filename=\"" + encodeName + "\"; filename*=utf-8''" + encodeName);
+
+            inputStream = resource.getInputStream();
+            servletOutputStream = response.getOutputStream();
+            IOUtils.copy(inputStream, servletOutputStream);
+            response.flushBuffer();
+        } catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            try {
+                if (servletOutputStream != null) {
+                    servletOutputStream.close();
+                }
+                if (inputStream != null) {
+                    inputStream.close();
+                }
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        }
+    }
+
+    /*
+     * 获取所属区域
+     */
+    @RequestMapping(value = "/findArea", method = RequestMethod.GET)
+    public ResponseEntity<ResponseBase> findArea(@RequestParam String sn) {
+        ResponseBase<SysAreaReps> responseBase = new ResponseBase<>();
+        responseBase.success().setRetBody(areaDataService.queryAreaBySn(sn));
+        return new ResponseEntity<>(responseBase, HttpStatus.OK);
+    }
+}
+
+

+ 137 - 0
src/main/java/com/hywa/map/controller/expert/DamController.java

@@ -0,0 +1,137 @@
+package com.hywa.map.controller.expert;
+
+import com.hywa.map.common.log.Log;
+import com.hywa.map.config.EnvProperties;
+import com.hywa.map.config.interceptor.TokenManager;
+import com.hywa.map.config.interceptor.TokenModel;
+import com.hywa.map.representation.*;
+import com.hywa.map.service.expert.DamService;
+import com.hywa.map.service.login.UserRoleService;
+import io.swagger.annotations.Api;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletRequest;
+
+import static com.hywa.map.common.ConstantPool.SPLIT;
+
+
+@Slf4j
+@Api(tags = "坝区管理")
+@RestController
+@RequestMapping("dam")
+public class DamController {
+
+    @Autowired
+    EnvProperties envProperties;
+
+    @Autowired
+    TokenManager tokenManager;
+
+    @Autowired
+    private DamService damService;
+
+    @Autowired
+    UserRoleService userRoleService;
+
+    /*
+     * 获取所有坝区
+     */
+    @RequestMapping(value = "/findAll", method = RequestMethod.GET)
+    public ResponseEntity<ResponseBase> findAll(@RequestParam(defaultValue = "1") int pageNo,
+                                                @RequestParam(defaultValue = "500") int pageSize,
+                                                @RequestParam(required = false) String areaCode,
+                                                @RequestParam(required = false) String damName) {
+        ResponseBase<DamInfoReps> responseBase = new ResponseBase<>();
+        String state = (500 == pageSize) ? "0" : "";
+        responseBase.success().setRetBody(damService.queryAll(pageNo, pageSize, areaCode, damName, state,null));
+        return new ResponseEntity<>(responseBase, HttpStatus.OK);
+    }
+
+    /*
+     * 根据id查询坝区信息
+     */
+    @RequestMapping(value = "/findById", method = RequestMethod.GET)
+    public ResponseEntity<ResponseBase> findById(@RequestParam(required = false) String id) {
+        ResponseBase<DamDetailInfoRep> responseBase = new ResponseBase<>();
+        responseBase.success().setRetBody(damService.queryById(id));
+        return new ResponseEntity<>(responseBase, HttpStatus.OK);
+    }
+
+    /*
+     * 新增坝区信息
+     */
+    @PostMapping
+    @Transactional
+    @Log(log = "坝区管理-新增坝区信息")
+    public ResponseEntity<ResponseBase> save(@RequestBody DamInfoReq reqInfo, HttpServletRequest req) {
+        TokenModel accessToken = tokenManager.getToken(req.getHeader("accessToken"));
+        String userId = accessToken.getUserId().split(SPLIT)[1];
+        ResponseBase<DamDetailInfoRep> responseBase = new ResponseBase<>();
+        try {
+            DamDetailInfoRep rep = damService.save(reqInfo, userId);
+            responseBase.success().setRetBody(rep);
+        } catch (Exception e) {
+            log.error("坝区管理-新增坝区信息异常,请求数据:reqInfo|" + reqInfo + ",异常信息|" + e);
+            throw e;
+        }
+        return new ResponseEntity<>(responseBase, HttpStatus.OK);
+    }
+
+    /*
+     * 修改坝区信息
+     */
+    @PutMapping
+    @Log(log = "坝区管理-修改坝区信息")
+    public ResponseEntity<ResponseBase> update(@RequestBody DamInfoReq reqInfo, HttpServletRequest req) {
+        TokenModel accessToken = tokenManager.getToken(req.getHeader("accessToken"));
+        String userId = accessToken.getUserId().split(SPLIT)[1];
+        try {
+            damService.update(reqInfo, userId);
+        } catch (Exception e) {
+            log.error("坝区管理-修改坝区信息异常,请求数据:reqInfo|" + reqInfo + ",异常信息|" + e);
+            throw e;
+        }
+        return new ResponseEntity<>(new ResponseBase().success(), HttpStatus.OK);
+    }
+
+    /*
+     * 删除坝区信息
+     */
+    @DeleteMapping
+    @Log(log = "坝区管理-删除坝区信息")
+    public ResponseEntity<ResponseBase> delete(@RequestBody DamInfoReq reqInfo, HttpServletRequest req) {
+        TokenModel accessToken = tokenManager.getToken(req.getHeader("accessToken"));
+        String userId = accessToken.getUserId().split(SPLIT)[1];
+        try {
+            damService.delete(reqInfo, userId);
+        } catch (Exception e) {
+            log.error("坝区管理-删除坝区信息异常,请求数据:reqInfo|" + reqInfo + ",异常信息|" + e);
+            throw e;
+        }
+        return new ResponseEntity<>(new ResponseBase().success(), HttpStatus.OK);
+    }
+
+    /*
+     * 是否启用
+     */
+    @RequestMapping(value = "/updateState", method = RequestMethod.POST)
+    @Log(log = "坝区管理-是否启用")
+    public ResponseEntity<ResponseBase> updateState(@RequestBody DamInfoReq reqInfo, HttpServletRequest req) {
+        TokenModel accessToken = tokenManager.getToken(req.getHeader("accessToken"));
+        String userId = accessToken.getUserId().split(SPLIT)[1];
+        try {
+            damService.updateState(reqInfo, userId);
+        } catch (Exception e) {
+            log.error("坝区管理-是否启用异常,请求数据:reqInfo|" + reqInfo + ",异常信息|" + e);
+            throw e;
+        }
+        return new ResponseEntity<>(new ResponseBase().success(), HttpStatus.OK);
+    }
+}
+
+

+ 145 - 0
src/main/java/com/hywa/map/controller/expert/ExpertController.java

@@ -0,0 +1,145 @@
+package com.hywa.map.controller.expert;
+
+import com.hywa.map.common.log.Log;
+import com.hywa.map.config.EnvProperties;
+import com.hywa.map.config.interceptor.TokenManager;
+import com.hywa.map.config.interceptor.TokenModel;
+import com.hywa.map.representation.*;
+import com.hywa.map.service.expert.ExpertService;
+import com.hywa.map.service.login.UserRoleService;
+import io.swagger.annotations.Api;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletRequest;
+
+import static com.hywa.map.common.ConstantPool.SPLIT;
+
+
+@Slf4j
+@Api(tags = "专家团队管理")
+@RestController
+@RequestMapping("expert")
+public class ExpertController {
+
+    @Autowired
+    EnvProperties envProperties;
+
+    @Autowired
+    TokenManager tokenManager;
+
+    @Autowired
+    private ExpertService expertService;
+
+    @Autowired
+    UserRoleService userRoleService;
+
+    /*
+     * 获取所属区域
+     */
+    @RequestMapping(value = "/findArea", method = RequestMethod.GET)
+    public ResponseEntity<ResponseBase> findArea(@RequestParam String sn) {
+        ResponseBase<SysAreaReps> responseBase = new ResponseBase<>();
+        responseBase.success().setRetBody(expertService.queryAreaBySn(sn));
+        return new ResponseEntity<>(responseBase, HttpStatus.OK);
+    }
+
+    /*
+     * 获取所有专家
+     */
+    @RequestMapping(value = "/findAll", method = RequestMethod.GET)
+    public ResponseEntity<ResponseBase> findAll(@RequestParam(defaultValue = "1") int pageNo,
+                                                @RequestParam(defaultValue = "10") int pageSize,
+                                                @RequestParam(required = false) String areaCode,
+                                                @RequestParam(required = false) String expertName,
+                                                @RequestParam(required = false) String typeId) {
+        ResponseBase<ExpertInfoReps> responseBase = new ResponseBase<>();
+        responseBase.success().setRetBody(expertService.queryAll(pageNo, pageSize, areaCode, expertName,typeId));
+        return new ResponseEntity<>(responseBase, HttpStatus.OK);
+    }
+
+    /*
+     * 根据id查询专家信息
+     */
+    @RequestMapping(value = "/findById", method = RequestMethod.GET)
+    public ResponseEntity<ResponseBase> findById(@RequestParam(required = false) String id) {
+        ResponseBase<ExpertInfoRep> responseBase = new ResponseBase<>();
+        responseBase.success().setRetBody(expertService.queryById(id));
+        return new ResponseEntity<>(responseBase, HttpStatus.OK);
+    }
+
+    /*
+     * 新增专家信息
+     */
+    @PostMapping
+    @Transactional
+    @Log(log = "专家团队管理-新增专家信息")
+    public ResponseEntity<ResponseBase> save(@RequestBody ExpertInfoReq reqInfo, HttpServletRequest req) {
+        TokenModel accessToken = tokenManager.getToken(req.getHeader("accessToken"));
+        String userId = accessToken.getUserId().split(SPLIT)[1];
+        try {
+            expertService.save(reqInfo, userId);
+        } catch (Exception e) {
+            log.error("专家团队管理-新增专家信息异常,请求数据:reqInfo|" + reqInfo + ",异常信息|" + e);
+            throw e;
+        }
+        return new ResponseEntity<>(new ResponseBase().success(), HttpStatus.OK);
+    }
+
+    /*
+     * 修改专家信息
+     */
+    @PutMapping
+    @Log(log = "专家团队管理-修改专家信息")
+    public ResponseEntity<ResponseBase> update(@RequestBody ExpertInfoReq reqInfo, HttpServletRequest req) {
+        TokenModel accessToken = tokenManager.getToken(req.getHeader("accessToken"));
+        String userId = accessToken.getUserId().split(SPLIT)[1];
+        try {
+            expertService.update(reqInfo, userId);
+        } catch (Exception e) {
+            log.error("专家团队管理-修改专家信息异常,请求数据:reqInfo|" + reqInfo + ",异常信息|" + e);
+            throw e;
+        }
+        return new ResponseEntity<>(new ResponseBase().success(), HttpStatus.OK);
+    }
+
+    /*
+     * 删除专家信息
+     */
+    @DeleteMapping
+    @Log(log = "专家团队管理-删除专家信息")
+    public ResponseEntity<ResponseBase> delete(@RequestBody ExpertInfoReq reqInfo, HttpServletRequest req) {
+        TokenModel accessToken = tokenManager.getToken(req.getHeader("accessToken"));
+        String userId = accessToken.getUserId().split(SPLIT)[1];
+        try {
+            expertService.delete(reqInfo, userId);
+        } catch (Exception e) {
+            log.error("专家团队管理-删除专家信息异常,请求数据:reqInfo|" + reqInfo + ",异常信息|" + e);
+            throw e;
+        }
+        return new ResponseEntity<>(new ResponseBase().success(), HttpStatus.OK);
+    }
+
+    /*
+     * 是否启用
+     */
+    @RequestMapping(value = "/updateState", method = RequestMethod.POST)
+    @Log(log = "专家团队管理-是否启用")
+    public ResponseEntity<ResponseBase> updateState(@RequestBody ExpertInfoReq reqInfo, HttpServletRequest req) {
+        TokenModel accessToken = tokenManager.getToken(req.getHeader("accessToken"));
+        String userId = accessToken.getUserId().split(SPLIT)[1];
+        try {
+            expertService.updateState(reqInfo, userId);
+        } catch (Exception e) {
+            log.error("专家团队管理-是否启用异常,请求数据:reqInfo|" + reqInfo + ",异常信息|" + e);
+            throw e;
+        }
+        return new ResponseEntity<>(new ResponseBase().success(), HttpStatus.OK);
+    }
+}
+
+

+ 67 - 0
src/main/java/com/hywa/map/controller/gis/GisController.java

@@ -0,0 +1,67 @@
+package com.hywa.map.controller.gis;
+
+import com.hywa.map.common.utils.FileUtils;
+import com.hywa.map.config.EnvProperties;
+import com.hywa.map.config.interceptor.TokenManager;
+import com.hywa.map.representation.*;
+import com.hywa.map.service.orchard.OrchardService;
+import com.hywa.map.service.topic.TopicInfoService;
+import io.swagger.annotations.Api;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.UnsupportedEncodingException;
+
+/**
+ * t_sys_branch  对应Controller 实现类
+ *
+ * @author hywa
+ * @create by 2018-12-12 10:01:56
+ */
+
+@Slf4j
+@Api(tags = "GIS地图")
+@RestController
+@RequestMapping("/gis")
+public class GisController {
+
+    @Autowired
+    private OrchardService orchardService;
+    @Autowired
+    private TopicInfoService topicInfoService;
+    @Autowired
+    EnvProperties envProperties;
+    @Autowired
+    TokenManager tokenManager;
+
+    @RequestMapping(value = "/findTopicInfo", method = RequestMethod.GET)
+    public ResponseEntity<ResponseBase> queryTopicInfo(@RequestParam(required = false) String topicName,
+                                                       @RequestParam(defaultValue = "1") int pageNo,
+                                                       @RequestParam(defaultValue = "10") int pageSize) {
+        ResponseBase<TopicInfoReps> responseBase = new ResponseBase<>();
+        responseBase.success().setRetBody(topicInfoService.selectTopicInfo(pageNo, pageSize, topicName));
+        return new ResponseEntity<>(responseBase, HttpStatus.OK);
+    }
+
+    @RequestMapping(value = "/findTopicDetail", method = RequestMethod.GET)
+    public ResponseEntity<ResponseBase> queryTopicDetail(@RequestParam(required = false) String id,
+                                                         @RequestParam(required = false) String areaName) {
+        ResponseBase<ViewTemplateReps> responseBase = new ResponseBase<>();
+        responseBase.success().setRetBody(topicInfoService.selectTopicDetail(id,areaName));
+        return new ResponseEntity<>(responseBase, HttpStatus.OK);
+    }
+
+    @RequestMapping(value = "/findGisPark", method = RequestMethod.GET)
+    public ResponseEntity<ResponseBase> queryGisPark(@RequestParam(required = false) String type,
+                                                     @RequestParam(required = false) String id) {
+        ResponseBase<GisParkReps> responseBase = new ResponseBase<>();
+        responseBase.success().setRetBody(orchardService.queryGisPark(type,id));
+        return new ResponseEntity<>(responseBase, HttpStatus.OK);
+    }
+}
+

+ 45 - 0
src/main/java/com/hywa/map/controller/log/LogController.java

@@ -0,0 +1,45 @@
+package com.hywa.map.controller.log;
+
+import com.hywa.map.representation.*;
+import com.hywa.map.service.log.LogService;
+import com.hywa.map.service.login.MenuService;
+import io.swagger.annotations.Api;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.*;
+
+@Api(tags = "系统日志")
+@RestController
+@RequestMapping("log")
+public class LogController {
+
+    @Autowired
+    LogService logService;
+
+    @Autowired
+    private MenuService menuService;
+
+    @RequestMapping(value = "/queryFuncName", method = RequestMethod.GET)
+    public ResponseEntity<ResponseBase> queryFuncName() {
+        ResponseBase menuRepResponseBase = new ResponseBase<>();
+        menuRepResponseBase.success();
+        menuRepResponseBase.setRetBody(menuService.searchSubMenu());
+        return new ResponseEntity<>(menuRepResponseBase, HttpStatus.OK);
+    }
+
+    @RequestMapping(value = "/queryAll", method = RequestMethod.GET)
+    public ResponseEntity<ResponseBase<LogReps>> findByName(@RequestParam(required = false) String menuName,
+                                                            @RequestParam(required = false) String userName,
+                                                            @RequestParam(required = false) String beginDate,
+                                                            @RequestParam(required = false) String endDate,
+                                                            @RequestParam(defaultValue = "1") Integer pageNo,
+                                                            @RequestParam(defaultValue = "10") Integer pageSize) {
+        ResponseBase<LogReps> responseBase = new ResponseBase<>();
+        responseBase.success().setRetBody(logService.queryAll(pageNo, pageSize, menuName, userName, beginDate, endDate));
+        responseBase.success();
+        return new ResponseEntity<>(responseBase, HttpStatus.OK);
+    }
+}
+
+

+ 136 - 0
src/main/java/com/hywa/map/controller/login/AreaMenuController.java

@@ -0,0 +1,136 @@
+package com.hywa.map.controller.login;
+
+import static com.hywa.map.common.ConstantPool.SPLIT;
+import static com.hywa.map.common.enums.CommonEnum.AREA_NO_FOUND;
+import static com.hywa.map.common.enums.CommonEnum.ILLEGAL_PARAMETER_ERROR;
+
+import com.hywa.map.common.exception.GlobalException;
+import com.hywa.map.common.utils.StringUtils;
+import com.hywa.map.config.EnvProperties;
+import com.hywa.map.config.interceptor.TokenManager;
+import com.hywa.map.config.interceptor.TokenModel;
+import com.hywa.map.representation.AreaMenuReq;
+import com.hywa.map.representation.MenuRep;
+import com.hywa.map.representation.MenuReps;
+import com.hywa.map.representation.ResponseBase;
+import com.hywa.map.service.login.AreaMenuService;
+import com.hywa.map.service.login.MenuService;
+import com.hywa.map.service.login.UserService;
+import io.swagger.annotations.Api;
+import java.lang.reflect.InvocationTargetException;
+import java.util.List;
+import java.util.Map;
+import javax.servlet.http.HttpServletRequest;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+@Slf4j
+@Api(tags = "区域菜单管理")
+@RestController
+@RequestMapping("area/menu")
+public class AreaMenuController {
+
+    @Autowired
+    private AreaMenuService areaMenuService;
+    @Autowired
+    EnvProperties envProperties;
+    @Autowired
+    TokenManager tokenManager;
+    @Autowired
+    private MenuService menuService;
+    @Autowired
+    private UserService userService;
+
+    @PostMapping
+    public ResponseEntity<ResponseBase> save(@Validated @RequestBody AreaMenuReq areaMenuReq,
+            HttpServletRequest req) {
+        TokenModel accessToken = tokenManager.getToken(req.getHeader("accessToken"));
+        String userId = accessToken.getUserId().split(SPLIT)[1];
+        if (!userService.checkArea(userId, areaMenuReq.getRegionId())) {
+            throw new GlobalException(AREA_NO_FOUND.getIndex(), AREA_NO_FOUND.getValue());
+        }
+        areaMenuService.save(areaMenuReq);
+        return new ResponseEntity<>(new ResponseBase<>().success(), HttpStatus.OK);
+    }
+
+    @PutMapping
+    public ResponseEntity<ResponseBase> update(@Validated @RequestBody AreaMenuReq areaMenuReq,
+            HttpServletRequest req) {
+        TokenModel accessToken = tokenManager.getToken(req.getHeader("accessToken"));
+        String userId = accessToken.getUserId().split(SPLIT)[1];
+        if (!userService.checkArea(userId, areaMenuReq.getRegionId())) {
+            throw new GlobalException(AREA_NO_FOUND.getIndex(), AREA_NO_FOUND.getValue());
+        }
+        areaMenuService.update(areaMenuReq);
+        return new ResponseEntity<>(new ResponseBase<>().success(), HttpStatus.OK);
+    }
+
+    @DeleteMapping
+    public ResponseEntity<ResponseBase> delete(@RequestParam String regionId) {
+        if (!StringUtils.isEmpty(regionId)) {
+            try {
+                areaMenuService.delete(regionId);
+            } catch (Exception e) {
+                log.error(e.getMessage());
+                return new ResponseEntity<>(new ResponseBase<>().success(), HttpStatus.OK);
+            }
+        } else {
+            throw new GlobalException(ILLEGAL_PARAMETER_ERROR.getIndex(),
+                    ILLEGAL_PARAMETER_ERROR.getValue() + ",regionId为空");
+        }
+        return new ResponseEntity<>(new ResponseBase<>().success(), HttpStatus.OK);
+    }
+
+    @RequestMapping(value = "/getAll", method = RequestMethod.GET)
+    public ResponseEntity<ResponseBase> get(
+            @RequestParam(required = false) String regionId,
+            @RequestParam(defaultValue = "1") Integer pageNo,
+            @RequestParam(defaultValue = "10") Integer pageSize, HttpServletRequest req)
+            throws IllegalAccessException, NoSuchMethodException, InvocationTargetException {
+        TokenModel accessToken = tokenManager.getToken(req.getHeader("accessToken"));
+        String userId = accessToken.getUserId().split(SPLIT)[1];
+        Map<String, Object> userMap = userService.findAllById(userId);
+        String userName = (String) userMap.get("name");
+        List<MenuRep> menuRepList = null;
+        menuRepList = areaMenuService.selectAll(userId, userName, regionId);
+        ResponseBase<MenuReps> menuRepResponseBase = new ResponseBase<>();
+        MenuReps menuReps = new MenuReps(menuRepList);
+        menuRepResponseBase.setRetBody(menuReps);
+        menuRepResponseBase.success();
+        return new ResponseEntity<>(menuRepResponseBase, HttpStatus.OK);
+    }
+
+    //根据区域代码,查询菜单
+    @RequestMapping(value = "/getByRegionId", method = RequestMethod.GET)
+    public ResponseEntity<ResponseBase> getAreaMenuTreeByRegionId(
+            @RequestParam(defaultValue = "") String type,
+            @RequestParam(defaultValue = "") String regionId, HttpServletRequest req)
+            throws IllegalAccessException, NoSuchMethodException, InvocationTargetException {
+        TokenModel accessToken = tokenManager.getToken(req.getHeader("accessToken"));
+        String userId = accessToken.getUserId().split(SPLIT)[1];
+        Map<String, Object> userMap = userService.findAllById(userId);
+        String userName = (String) userMap.get("name");
+        List<MenuRep> menuRepList = null;
+        if ("admin".equals(userName)) {
+            menuRepList = menuService.getMenuAllTreeByRegionId("", type, regionId);
+        } else {
+            menuRepList = menuService.getAreaMenuTreeByRegionId(userId, type, regionId);
+        }
+        ResponseBase<MenuReps> menuRepResponseBase = new ResponseBase<>();
+        MenuReps menuReps = new MenuReps(menuRepList);
+        menuRepResponseBase.setRetBody(menuReps);
+        menuRepResponseBase.success();
+        return new ResponseEntity<>(menuRepResponseBase, HttpStatus.OK);
+    }
+}

+ 235 - 0
src/main/java/com/hywa/map/controller/login/MenuController.java

@@ -0,0 +1,235 @@
+package com.hywa.map.controller.login;
+
+import static com.hywa.map.common.ConstantPool.SPLIT;
+import static com.hywa.map.common.enums.CommonEnum.FAILURE;
+import static com.hywa.map.common.enums.CommonEnum.ILLEGAL_PARAMETER_ERROR;
+
+import com.hywa.map.common.exception.GlobalException;
+import com.hywa.map.common.log.Log;
+import com.hywa.map.common.utils.StringUtils;
+import com.hywa.map.config.interceptor.TokenManager;
+import com.hywa.map.config.interceptor.TokenModel;
+import com.hywa.map.dao.entity.Menu;
+import com.hywa.map.representation.*;
+import com.hywa.map.service.login.MenuService;
+import com.hywa.map.service.login.UserService;
+import io.swagger.annotations.Api;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.List;
+import java.util.Map;
+import javax.servlet.http.HttpServletRequest;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+@Api(tags = "菜单管理")
+@RestController
+@RequestMapping("menu")
+public class MenuController {
+
+    @Autowired
+    private MenuService menuService;
+    @Autowired
+    private UserService userService;
+    @Autowired
+    TokenManager tokenManager;
+
+    @RequestMapping(value = "/getChildren", method = RequestMethod.GET)
+    public ResponseEntity<ResponseBase> getChildren(
+            @RequestParam String menuId,
+            @RequestParam String userId) {
+        List<MenuRep> menuRepList = menuService.getChildren(userId, menuId);
+        ResponseBase<MenuReps> menuRepResponseBase = new ResponseBase<>();
+        menuRepResponseBase.setRetBody(new MenuReps(menuRepList));
+        menuRepResponseBase.success();
+        return new ResponseEntity<>(menuRepResponseBase, HttpStatus.OK);
+    }
+
+    /*@RequestMapping(value = "/userMenuTree", method = RequestMethod.GET)
+    public ResponseEntity<ResponseBase> getMenuTreeById(
+            @RequestParam String userId,
+            @RequestParam String requestMode) {
+        List<MenuRep> menuRepList = menuService.getMenuTreeByUserId(userId, requestMode);
+
+        ResponseBase<MenuReps> menuRepResponseBase = new ResponseBase<>();
+        MenuReps menuReps = new MenuReps(menuRepList);
+        menuRepResponseBase.setRetBody(menuReps);
+        menuRepResponseBase.success();
+        return new ResponseEntity<>(menuRepResponseBase, HttpStatus.OK);
+    }*/
+
+    @RequestMapping(value = "/userMenuTree", method = RequestMethod.GET)
+    public ResponseEntity<ResponseBase> getMenuTreeById(@RequestParam(defaultValue = "900004") String sysId, HttpServletRequest req) {
+        TokenModel accessToken = tokenManager.getToken(req.getHeader("accessToken"));
+        String userId = accessToken.getUserId().split(SPLIT)[1];
+        List<MenuItemRep> menuRepList = menuService.getUserMenuTreeByUserId(userId, sysId);
+
+        ResponseBase<MenuItemReps> menuRepResponseBase = new ResponseBase<>();
+        MenuItemReps menuReps = new MenuItemReps(menuRepList);
+        menuRepResponseBase.setRetBody(menuReps);
+        menuRepResponseBase.success();
+        return new ResponseEntity<>(menuRepResponseBase, HttpStatus.OK);
+    }
+
+    @RequestMapping(value = "/menuAllTree", method = RequestMethod.GET)
+    public ResponseEntity<ResponseBase> getMenuAllTree(
+            @RequestParam(defaultValue = "") String roleId) {
+        List<MenuRep> menuRepList = menuService.getMenuAllTree(roleId, null);
+
+        ResponseBase<MenuReps> menuRepResponseBase = new ResponseBase<>();
+        MenuReps menuReps = new MenuReps(menuRepList);
+        menuRepResponseBase.setRetBody(menuReps);
+        menuRepResponseBase.success();
+        return new ResponseEntity<>(menuRepResponseBase, HttpStatus.OK);
+    }
+
+    @RequestMapping(value = "/getMenus", method = RequestMethod.GET)
+    public ResponseEntity<ResponseBase> getMenusByRoleId(@RequestParam String roleId,
+                                                         HttpServletRequest req)
+            throws IllegalAccessException, NoSuchMethodException, InvocationTargetException {
+        TokenModel accessToken = tokenManager.getToken(req.getHeader("accessToken"));
+        String userId = accessToken.getUserId().split(SPLIT)[1];
+        Map<String, Object> userMap = userService.findAllById(userId);
+        String userName = (String) userMap.get("name");
+
+        List<MenuRep> menuRepList = menuService.selectMenusByRoleId(roleId, userId, userName);
+        ResponseBase<MenuReps> responseBase = new ResponseBase<>();
+        MenuReps menuReps = new MenuReps(menuRepList);
+        responseBase.success();
+        responseBase.setRetBody(menuReps);
+        return new ResponseEntity<>(responseBase, HttpStatus.OK);
+    }
+
+    @PostMapping
+    public ResponseEntity<ResponseBase> save(@RequestBody MenuRep menuRep, HttpServletRequest req) {
+        TokenModel accessToken = tokenManager.getToken(req.getHeader("accessToken"));
+        menuRep.setCreateUser(accessToken.getUserId().split(SPLIT)[1]);
+        if (1 != menuService.save(menuRep)) {
+            throw new GlobalException(FAILURE.getIndex(), "保存失败");
+        }
+        ResponseBase<Menu> menuRepResponseBase = new ResponseBase<>();
+        menuRepResponseBase.setRetBody(menuRep);
+        menuRepResponseBase.success();
+        return new ResponseEntity<>(menuRepResponseBase, HttpStatus.OK);
+    }
+
+    @PutMapping
+    public ResponseEntity<ResponseBase> update(@RequestBody MenuRep menuRep,
+                                               HttpServletRequest req) {
+        TokenModel accessToken = tokenManager.getToken(req.getHeader("accessToken"));
+        menuRep.setUpdateUser(accessToken.getUserId().split(SPLIT)[1]);
+        if (1 != menuService.update(menuRep)) {
+            throw new GlobalException(FAILURE.getIndex(), "更新失败");
+        }
+        return new ResponseEntity<>(new ResponseBase<>().success(), HttpStatus.OK);
+    }
+
+    @DeleteMapping
+    public ResponseEntity<ResponseBase> delete(@RequestParam String menuId) {
+        menuService.delete(menuId);
+        return new ResponseEntity<>(new ResponseBase<>().success(), HttpStatus.OK);
+    }
+
+    //查询菜单基本信息
+    @RequestMapping(value = "/search", method = RequestMethod.GET)
+    public ResponseEntity<ResponseBase> search(
+            @RequestParam(defaultValue = "1") int pageNo,
+            @RequestParam(defaultValue = "10") int pageSize,
+            @RequestParam(required = false) String parentId,
+            @RequestParam(required = false) String id,
+            @RequestParam(required = false) String menuName
+    ) {
+
+        ResponseBase menuRepResponseBase = new ResponseBase<>();
+        menuRepResponseBase.success();
+        menuRepResponseBase
+                .setRetBody(menuService.search(pageNo, pageSize, parentId, id, menuName));
+        return new ResponseEntity<>(menuRepResponseBase, HttpStatus.OK);
+    }
+
+    //根据用户角色,地区查询菜单
+    @RequestMapping(value = "/areaMenuTree", method = RequestMethod.GET)
+    public ResponseEntity<ResponseBase> getAreaMenuTree(
+            @RequestParam(defaultValue = "") String type,
+            @RequestParam(defaultValue = "") String regionId, HttpServletRequest req)
+            throws IllegalAccessException, NoSuchMethodException, InvocationTargetException {
+        TokenModel accessToken = tokenManager.getToken(req.getHeader("accessToken"));
+        String userId = accessToken.getUserId().split(SPLIT)[1];
+        Map<String, Object> userMap = userService.findAllById(userId);
+        String userName = (String) userMap.get("name");
+        List<MenuRep> menuRepList = null;
+        if ("admin".equals(userName)) {
+            menuRepList = StringUtils.isEmpty(regionId) ? menuService.getMenuAllTree("", type)
+                    : menuService.getMenuAllTreeByRegionId("", type, regionId);
+        } else {
+            menuRepList = StringUtils.isEmpty(regionId) ? menuService.getAreaMenuTree(userId, type)
+                    : menuService.getAreaMenuTreeByRegionId(userId, type, regionId);
+        }
+        ResponseBase<MenuReps> menuRepResponseBase = new ResponseBase<>();
+        MenuReps menuReps = new MenuReps(menuRepList);
+        menuRepResponseBase.setRetBody(menuReps);
+        menuRepResponseBase.success();
+        return new ResponseEntity<>(menuRepResponseBase, HttpStatus.OK);
+    }
+
+    @RequestMapping(value = "/getMenuByRole", method = RequestMethod.GET)
+    public ResponseEntity<ResponseBase> getMenuByRole(@RequestParam String roleId) {
+        if (StringUtils.isEmpty(roleId)) {
+            throw new GlobalException(ILLEGAL_PARAMETER_ERROR.getIndex(),
+                    ILLEGAL_PARAMETER_ERROR.getValue() + ",角色ID为空");
+        }
+        MenuSysReps menuSysReps = menuService.getMenuByRole(roleId);
+        ResponseBase<MenuSysReps> responseBase = new ResponseBase<>();
+        responseBase.success();
+        responseBase.setRetBody(menuSysReps);
+        return new ResponseEntity<>(responseBase, HttpStatus.OK);
+    }
+
+    @Log(log = "角色管理-保存权限")
+    @RequestMapping(value = "/saveRoleMenu", method = RequestMethod.POST)
+    public ResponseEntity<ResponseBase> saveRoleMenu(@RequestBody MenuReq menuReq) {
+        menuService.saveRoleMenu(menuReq);
+        return new ResponseEntity<>(new ResponseBase<>().success(), HttpStatus.OK);
+    }
+
+    @RequestMapping(value = "/sysMenuTree", method = RequestMethod.GET)
+    public ResponseEntity<ResponseBase> getMenuTreeBySysId(@RequestParam String sysId, HttpServletRequest req) {
+        if (StringUtils.isEmpty(sysId)) {
+            throw new GlobalException(ILLEGAL_PARAMETER_ERROR.getIndex(),
+                    ILLEGAL_PARAMETER_ERROR.getValue() + ",系统ID为空");
+        }
+        TokenModel accessToken = tokenManager.getToken(req.getHeader("accessToken"));
+        String userId = accessToken.getUserId().split(SPLIT)[1];
+        List<MenuRep> menuRepList = menuService.getMenuTreeBySysId(userId, sysId);
+        ResponseBase<MenuReps> menuRepResponseBase = new ResponseBase<>();
+        MenuReps menuReps = new MenuReps(menuRepList);
+        menuRepResponseBase.setRetBody(menuReps);
+        menuRepResponseBase.success();
+        return new ResponseEntity<>(menuRepResponseBase, HttpStatus.OK);
+    }
+
+    @RequestMapping(value = "/getButtonByMenuId", method = RequestMethod.GET)
+    public ResponseEntity<ResponseBase> getButtonByMenuId(@RequestParam String menuId, HttpServletRequest req) {
+        if (StringUtils.isEmpty(menuId)) {
+            throw new GlobalException(ILLEGAL_PARAMETER_ERROR.getIndex(),
+                    ILLEGAL_PARAMETER_ERROR.getValue() + ",菜单ID为空");
+        }
+        TokenModel accessToken = tokenManager.getToken(req.getHeader("accessToken"));
+        String userId = accessToken.getUserId().split(SPLIT)[1];
+        ButtonReps buttonRep = menuService.selectButtonByMenuId(menuId, userId);
+        ResponseBase<ButtonReps> responseBase = new ResponseBase<>();
+        responseBase.success();
+        responseBase.setRetBody(buttonRep);
+        return new ResponseEntity<>(responseBase, HttpStatus.OK);
+    }
+}

+ 159 - 0
src/main/java/com/hywa/map/controller/login/RoleController.java

@@ -0,0 +1,159 @@
+package com.hywa.map.controller.login;
+
+import static com.hywa.map.common.ConstantPool.SPLIT;
+import static com.hywa.map.common.enums.CommonEnum.*;
+
+import com.hywa.map.common.exception.GlobalException;
+import com.hywa.map.common.log.Log;
+import com.hywa.map.common.utils.StringUtils;
+import com.hywa.map.config.EnvProperties;
+import com.hywa.map.config.interceptor.TokenManager;
+import com.hywa.map.config.interceptor.TokenModel;
+import com.hywa.map.representation.ResponseBase;
+import com.hywa.map.representation.RoleRep;
+import com.hywa.map.representation.RoleReps;
+import com.hywa.map.service.login.RoleService;
+import com.hywa.map.service.login.UserService;
+import io.swagger.annotations.Api;
+import java.lang.reflect.InvocationTargetException;
+import java.util.Map;
+import javax.servlet.http.HttpServletRequest;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+@Slf4j
+@Api(tags = "角色管理")
+@RestController
+@RequestMapping("role")
+public class RoleController {
+
+    @Autowired
+    private RoleService roleService;
+
+    @Autowired
+    EnvProperties envProperties;
+    @Autowired
+    TokenManager tokenManager;
+    @Autowired
+    private UserService userService;
+
+    @PostMapping
+    @Log(log = "角色管理-新增")
+    public ResponseEntity<ResponseBase> save(@Validated @RequestBody RoleRep roleRep,
+            HttpServletRequest req) {
+        TokenModel accessToken = tokenManager.getToken(req.getHeader("accessToken"));
+        String userId = accessToken.getUserId().split(SPLIT)[1];
+        roleRep.setCreateUser(userId);
+        roleService.save(roleRep);
+        return new ResponseEntity<>(new ResponseBase<>().success(), HttpStatus.OK);
+    }
+
+    @PutMapping
+    @Log(log = "角色管理-修改")
+    public ResponseEntity<ResponseBase> update(@RequestBody RoleRep roleRep,
+            HttpServletRequest req) {
+        if (StringUtils.isEmpty(roleRep.getId())) {
+            throw new GlobalException(ILLEGAL_PARAMETER_ERROR.getIndex(),
+                    ILLEGAL_PARAMETER_ERROR.getValue() + ",角色ID为空",null,"角色管理-修改");
+        }
+        if (envProperties.getAdminRoleId().equals(roleRep.getId())) {
+            throw new GlobalException(DEL_ADMIN.getIndex(),
+                    DEL_ADMIN.getValue(),null,"角色管理-修改");
+        }
+        TokenModel accessToken = tokenManager.getToken(req.getHeader("accessToken"));
+        String userId = accessToken.getUserId().split(SPLIT)[1];
+        roleRep.setUpdateUser(userId);
+        roleService.update(roleRep);
+        return new ResponseEntity<>(new ResponseBase<>().success(), HttpStatus.OK);
+    }
+
+    @DeleteMapping
+    @Log(log = "角色管理-删除")
+    public ResponseEntity<ResponseBase> delete(@RequestParam String roleId) {
+        if (StringUtils.isEmpty(roleId)) {
+            throw new GlobalException(ILLEGAL_PARAMETER_ERROR.getIndex(),
+                    ILLEGAL_PARAMETER_ERROR.getValue() + ",角色ID为空",null,"角色管理-删除");
+        }
+        if (envProperties.getAdminRoleId().equals(roleId)) {
+            throw new GlobalException(DEL_ADMIN.getIndex(),
+                    DEL_ADMIN.getValue(),null,"角色管理-删除");
+        }
+        roleService.delete(roleId);
+        return new ResponseEntity<>(new ResponseBase<>().success(), HttpStatus.OK);
+    }
+
+    /*@RequestMapping(value = "/getAll", method = RequestMethod.GET)
+    public ResponseEntity<ResponseBase> get(
+            @RequestParam(required = false) String name,
+            @RequestParam(defaultValue = "1") Integer pageNo,
+            @RequestParam(defaultValue = "10") Integer pageSize, HttpServletRequest req)
+            throws IllegalAccessException, NoSuchMethodException, InvocationTargetException {
+        TokenModel accessToken = tokenManager.getToken(req.getHeader("accessToken"));
+        String userId = accessToken.getUserId().split(SPLIT)[1];
+        Map<String, Object> userMap = userService.findAllById(userId);
+        String userName = (String) userMap.get("name");
+        RoleReps roleReps = roleService.selectAll(pageNo, pageSize, name, userName, userId);
+        ResponseBase<RoleReps> responseBase = new ResponseBase<>();
+        responseBase.success();
+        responseBase.setRetBody(roleReps);
+        return new ResponseEntity<>(responseBase, HttpStatus.OK);
+    }*/
+
+    @RequestMapping(value = "/getAll", method = RequestMethod.GET)
+    public ResponseEntity<ResponseBase> get(
+            @RequestParam(required = false) String name,@RequestParam(required = false) String flag) {
+        RoleReps roleReps = roleService.selectAll(name,flag);
+        ResponseBase<RoleReps> responseBase = new ResponseBase<>();
+        responseBase.success();
+        responseBase.setRetBody(roleReps);
+        return new ResponseEntity<>(responseBase, HttpStatus.OK);
+    }
+
+    @RequestMapping(value = "/getRoles", method = RequestMethod.GET)
+    public ResponseEntity<ResponseBase> getUserRoles(
+            @RequestParam String userId,
+            @RequestParam(defaultValue = "1") Integer pageNo,
+            @RequestParam(defaultValue = "10") Integer pageSize) {
+
+        RoleReps roleReps = roleService.selectRolesByUserId(pageNo, pageSize, userId);
+        ResponseBase<RoleReps> responseBase = new ResponseBase<>();
+        responseBase.success();
+        responseBase.setRetBody(roleReps);
+        return new ResponseEntity<>(responseBase, HttpStatus.OK);
+    }
+
+    @RequestMapping(value = "/findById", method = RequestMethod.GET)
+    public ResponseEntity<ResponseBase> findById(@RequestParam String id) {
+        RoleRep roleRep = roleService.findById(id);
+        ResponseBase<RoleRep> responseBase = new ResponseBase<>();
+        responseBase.success();
+        responseBase.setRetBody(roleRep);
+        return new ResponseEntity<>(responseBase, HttpStatus.OK);
+    }
+
+    @RequestMapping(value = "/getAreaRoles", method = RequestMethod.GET)
+    public ResponseEntity<ResponseBase> getAreaRoles(
+            @RequestParam String userId,
+            @RequestParam(defaultValue = "1") Integer pageNo,
+            @RequestParam(defaultValue = "10") Integer pageSize)
+            throws IllegalAccessException, NoSuchMethodException, InvocationTargetException {
+        Map<String, Object> userMap = userService.findAllById(userId);
+        String regionType = userMap.get("type") + "";
+        RoleReps roleReps = roleService.selectRolesByArea(pageNo, pageSize, userId, regionType);
+        ResponseBase<RoleReps> responseBase = new ResponseBase<>();
+        responseBase.success();
+        responseBase.setRetBody(roleReps);
+        return new ResponseEntity<>(responseBase, HttpStatus.OK);
+    }
+}

+ 377 - 0
src/main/java/com/hywa/map/controller/login/UserController.java

@@ -0,0 +1,377 @@
+package com.hywa.map.controller.login;
+
+import com.hywa.map.common.ConstantPool;
+import com.hywa.map.common.enums.CommonEnum;
+import com.hywa.map.common.exception.GlobalException;
+import com.hywa.map.common.log.Log;
+import com.hywa.map.common.utils.FileUtils;
+import com.hywa.map.common.utils.SpringContext;
+import com.hywa.map.common.utils.StringUtils;
+import com.hywa.map.config.EnvProperties;
+import com.hywa.map.config.interceptor.TokenManager;
+import com.hywa.map.config.interceptor.TokenModel;
+import com.hywa.map.config.validation.JsonValidate;
+import com.hywa.map.controller.login.validate.StateValidationValidate;
+import com.hywa.map.dao.entity.User;
+import com.hywa.map.dao.mapper.UserMapper;
+import com.hywa.map.representation.*;
+import com.hywa.map.representation.ext.UserRepExt;
+import com.hywa.map.service.login.MenuService;
+import com.hywa.map.service.login.UserRoleService;
+import com.hywa.map.service.login.UserService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.net.util.Base64;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.validation.Valid;
+import java.io.UnsupportedEncodingException;
+import java.lang.reflect.InvocationTargetException;
+import java.util.*;
+
+import static com.hywa.map.common.ConstantPool.SPLIT;
+import static com.hywa.map.common.enums.CommonEnum.*;
+
+@Slf4j
+@Api(tags = "用户管理")
+@RestController
+@RequestMapping("user")
+public class UserController {
+
+    private static final String MOBILE = "mobile";
+    private static final String PC = "pc";
+    private static final String SPOT = "spot";
+
+    @Autowired
+    EnvProperties envProperties;
+
+    @Autowired
+    TokenManager tokenManager;
+
+    @Autowired
+    private UserService userService;
+
+    @Autowired
+    private MenuService menuService;
+
+    @Autowired
+    UserRoleService userRoleService;
+
+
+    @ApiOperation(value = "移动端登录")
+    @PostMapping(value = "/login")
+    @Log(log = "登录-移动端用户登录系统")
+    //@JsonValidate(StateValidationValidate.class)
+    public ResponseEntity<ResponseBase> login(
+            @RequestBody LoginInfoRep loginInfoRep,
+            HttpServletRequest req) throws UnsupportedEncodingException {
+        validate(loginInfoRep);
+        String pwd = checkoutPwd(loginInfoRep.getPwd());
+        ResponseBase<UserRep> userRepResponseBase = getUserRepResponseBase(
+                loginInfoRep.getUserName(), pwd, req, MOBILE);
+        return new ResponseEntity<>(userRepResponseBase, HttpStatus.OK);
+    }
+
+    @ApiOperation(value = "PC端登录")
+    @PostMapping(value = "/pcLogin")
+    @Log(log = "登录-用户登录系统")
+    public ResponseEntity<ResponseBase> pcLogin(
+            @RequestBody LoginInfoRep loginInfoRep,
+            HttpServletRequest req) throws UnsupportedEncodingException {
+        validate(loginInfoRep);
+        String pwd = checkoutPwd(loginInfoRep.getPwd());
+        ResponseBase<UserRep> userRepResponseBase = getUserRepResponseBase(loginInfoRep.getUserName(), pwd, req, PC);
+        return new ResponseEntity<>(userRepResponseBase, HttpStatus.OK);
+    }
+
+
+    private ResponseBase<UserRep> getUserRepResponseBase(String userName,
+                                                         String password, HttpServletRequest req, String equipment) {
+        ResponseBase<UserRep> userRepResponseBase = new ResponseBase<>();
+        UserRep userRep = userService.userLogin(userName, password);
+        userService.setAuthority(userRep.getUserId());
+        TokenModel token = tokenManager.createToken(equipment + SPLIT + userRep.getUserId());
+        req.getSession().setAttribute("userId", userRep.getUserId());
+        userRep.setAccessToken(equipment + SPLIT + userRep.getUserId() + "_" + token.getToken());
+        userRep.setSysReps(userService.findSysInfoByUserId(userRep.getUserId(), userRep.getName()));
+        userRepResponseBase.success();
+        userRepResponseBase.setRetBody(userRep);
+        return userRepResponseBase;
+    }
+
+    @GetMapping(value = "/checkToken")
+    public ResponseEntity<ResponseBase> tokenVerify(
+            @RequestParam String userId,
+            @RequestParam String token) {
+        ResponseBase<UserRep> userRepResponseBase = checkUserToken(userId, token, MOBILE);
+        return new ResponseEntity<>(userRepResponseBase, HttpStatus.OK);
+    }
+
+    @GetMapping(value = "/pcCheckToken")
+    public ResponseEntity<ResponseBase> pcTokenVerify(
+            @RequestParam String userId,
+            @RequestParam String token) {
+        ResponseBase<UserRep> userRepResponseBase = checkUserToken(userId, token, PC);
+        return new ResponseEntity<>(userRepResponseBase, HttpStatus.OK);
+    }
+
+    private ResponseBase<UserRep> checkUserToken(String userId, String token, String equipment) {
+        String[] split = token.split("_");
+        boolean result = tokenManager
+                .checkToken(new TokenModel(equipment + SPLIT + userId, split[1]));
+        ResponseBase<UserRep> userRepResponseBase = new ResponseBase<>();
+        if (result) {
+            UserRep userRep = userService.findById(userId);
+            userRep.setAccessToken(token);
+            userRepResponseBase.setRetBody(userRep);
+            userRepResponseBase.success();
+        } else {
+            userRepResponseBase.setRetHead(RE_LOGIN.getIndex(), RE_LOGIN.getValue());
+        }
+        return userRepResponseBase;
+    }
+
+
+    @PostMapping
+    @Transactional
+    @Log(log = "账户管理-新增账户")
+    public ResponseEntity<ResponseBase> registerUser(@Valid @RequestBody UserRepExt userRep,
+                                                     HttpServletRequest req) {
+        TokenModel accessToken = tokenManager.getToken(req.getHeader("accessToken"));
+        String userId = accessToken.getUserId().split(SPLIT)[1];
+        if (StringUtils.isEmpty(userRep.getPwd())) {
+            throw new GlobalException(ILLEGAL_PARAMETER_ERROR.getIndex(),
+                    ILLEGAL_PARAMETER_ERROR.getValue() + ",密码为空",userId,"账户管理-新增账户");
+        }
+        String roleIds = userRep.getRoleIds();
+        List<String> roles = new ArrayList<>();
+        roles.add(roleIds);
+        userRep.setRoles(roles);
+        userRep.setCreateUser(userId);
+        userService.save(userRep);
+        return new ResponseEntity<>(new ResponseBase().success(), HttpStatus.OK);
+    }
+
+    @RequestMapping(value = "/logout", method = RequestMethod.DELETE)
+    public ResponseEntity<ResponseBase> logout(@RequestParam String userId) {
+        tokenManager.deleteToken(MOBILE + SPLIT + userId);
+        return new ResponseEntity<>(new ResponseBase().success(), HttpStatus.OK);
+
+    }
+
+    @RequestMapping(value = "/pcLogout", method = RequestMethod.DELETE)
+    public ResponseEntity<ResponseBase> pcLogout(@RequestParam(value = "userId") String userId) {
+        tokenManager.deleteToken(PC + SPLIT + userId);
+        return new ResponseEntity<>(new ResponseBase().success(), HttpStatus.OK);
+
+    }
+
+    @DeleteMapping
+    @Log(log = "账户管理-删除账户")
+    public ResponseEntity<ResponseBase> deleteUser(@RequestParam String userId,
+                                                   HttpServletRequest req) {
+        TokenModel accessToken = tokenManager.getToken(req.getHeader("accessToken"));
+        checkUpdateInfo(userId, accessToken.getUserId().split(SPLIT)[1],"账户管理-删除账户");
+        userService.delete(userId);
+        //用户删除时,删除token
+        deleteTokenByUserId(userId);
+        return new ResponseEntity<>(new ResponseBase().success(), HttpStatus.OK);
+    }
+
+    @RequestMapping(value = "/findAll", method = RequestMethod.GET)
+    public ResponseEntity<ResponseBase> findAllUser(
+            @RequestParam(required = false) String name,
+            @RequestParam(required = false) String region,
+            @RequestParam(required = false) String workUnit,
+            @RequestParam(defaultValue = "1") int pageNo,
+            @RequestParam(defaultValue = "10") int pageSize, HttpServletRequest req) {
+        TokenModel accessToken = tokenManager.getToken(req.getHeader("accessToken"));
+        String userId = accessToken.getUserId().split(SPLIT)[1];
+        //Map<String, Object> userMap = userService.findAllById(userId);
+        //String userName = (String) userMap.get("name");
+        ResponseBase<UserReps> responseBase = new ResponseBase<>();
+        responseBase.success()
+                .setRetBody(userService
+                        .findUsers(pageNo, pageSize, name, region, workUnit, null, userId));
+        return new ResponseEntity<>(responseBase, HttpStatus.OK);
+
+    }
+
+    @RequestMapping(value = "/findByName", method = RequestMethod.GET)
+    public ResponseEntity<ResponseBase<User>> findByName(String name) {
+        ResponseBase<User> responseBase = new ResponseBase<>();
+        responseBase.success()
+                .setRetBody(userService.findByName(name));
+        responseBase.success();
+        return new ResponseEntity<>(responseBase, HttpStatus.OK);
+    }
+
+    @RequestMapping(value = "/findById", method = RequestMethod.GET)
+    public ResponseEntity<ResponseBase<Map<String, Object>>> findAllById(String id)
+            throws IllegalAccessException, NoSuchMethodException, InvocationTargetException {
+        ResponseBase<Map<String, Object>> responseBase = new ResponseBase<>();
+        responseBase.success()
+                .setRetBody(userService.findAllById(id));
+        responseBase.success();
+        return new ResponseEntity<>(responseBase, HttpStatus.OK);
+    }
+
+    @PutMapping
+    @Log(log = "账户管理-修改账户")
+    public ResponseEntity<ResponseBase> update(
+            @RequestBody UserRepExt userRep, HttpServletRequest req) {
+        TokenModel accessToken = tokenManager.getToken(req.getHeader("accessToken"));
+        String userId = accessToken.getUserId().split(SPLIT)[1];
+        String roleIds = userRep.getRoleIds();
+        List<String> roles = new ArrayList<>();
+        roles.add(roleIds);
+        userRep.setRoles(roles);
+        checkUpdateInfo(userRep.getUserId(), userId,"账户管理-修改账户");
+        ResponseBase responseBase = new ResponseBase<>();
+        String pwd = userRep.getPwd();
+        userRep.setPwd(StringUtils.isNotEmpty(pwd) ? StringUtils.md5(pwd) : null);
+        userService.update(userRep, userId);
+        responseBase.success();
+        return new ResponseEntity<>(responseBase, HttpStatus.OK);
+    }
+
+    @PutMapping("updatePersonInfo")
+    @Log(log = "账户管理-个人资料")
+    public ResponseEntity<ResponseBase> updatePersonInfo(
+            @RequestBody UserRepExt userRep, HttpServletRequest req) {
+        TokenModel accessToken = tokenManager.getToken(req.getHeader("accessToken"));
+        String userId = accessToken.getUserId().split(SPLIT)[1];
+        ResponseBase responseBase = new ResponseBase<>();
+        userService.updatePersonInfo(userRep, userId);
+        responseBase.success();
+        return new ResponseEntity<>(responseBase, HttpStatus.OK);
+    }
+
+    @PutMapping("changePwd")
+    public ResponseEntity changePwd(@RequestBody @Valid NewUserInfoRep newUserInfoRep) {
+        if (newUserInfoRep.getNewpassword().equals(newUserInfoRep.getPassword())) {
+            throw new GlobalException(PASSWORD_REPEAT.getIndex(), PASSWORD_REPEAT.getValue(), null, "系统设置-修改密码");
+        }
+        userService.changePwd(newUserInfoRep);
+        return new ResponseEntity<>(new ResponseBase().success(), HttpStatus.OK);
+    }
+
+    @PutMapping("resetPwd")
+    public ResponseEntity resetPwd(@RequestBody NewUserInfoRep newUserInfoRep) {
+        newUserInfoRep.setNewpassword("123456");
+        userService.resetPwd(newUserInfoRep);
+        return new ResponseEntity<>(new ResponseBase().success(), HttpStatus.OK);
+    }
+
+    @RequestMapping(value = "/disableUser", method = RequestMethod.POST)
+    @Log(log = "账户管理-禁用账户")
+    public ResponseEntity<ResponseBase<User>> disableUser(@RequestBody UserRepExt userRep, HttpServletRequest req) {
+        String menuName = "账户管理-禁用账户";
+        TokenModel accessToken = tokenManager.getToken(req.getHeader("accessToken"));
+        Map<String, String> map = new HashMap();
+        String updateUserId=accessToken.getUserId().split(SPLIT)[1];
+        String userId=userRep.getUserId();
+        map.put("status", "0".equals(userRep.getStatus()) ? "1" : "0");
+        map.put("updateUserId", updateUserId);
+        map.put("userId", userId);
+        if (envProperties.getAdminId().equals(userId)) {
+            throw new GlobalException(CommonEnum.DISABLE_ADMIN.getIndex(),
+                    CommonEnum.DISABLE_ADMIN.getValue(),null,menuName);
+        }
+        if (updateUserId.equals(userId)) {
+            throw new GlobalException(CommonEnum.DISABLE_SELF.getIndex(),
+                    CommonEnum.DISABLE_SELF.getValue(),null,menuName);
+        }
+        userService.disableUser(map);
+        //用户禁用时,删除token
+        deleteTokenByUserId(userId);
+        return new ResponseEntity<>(new ResponseBase().success(), HttpStatus.OK);
+    }
+
+
+    private void checkUpdateInfo(@RequestParam String userId, String currentUserId,String menuName) {
+        if (currentUserId.equals(userId)) {
+            throw new GlobalException(CommonEnum.DEL_CURRENT_LOGIN_INFO.getIndex(),
+                    CommonEnum.DEL_CURRENT_LOGIN_INFO.getValue(),null,menuName);
+        }
+        if (envProperties.getAdminId().equals(userId)) {
+            throw new GlobalException(CommonEnum.DEL_ADMIN.getIndex(),
+                    CommonEnum.DEL_ADMIN.getValue(),null,menuName);
+        }
+    }
+
+    private String checkoutPwd(String pwd) throws UnsupportedEncodingException {
+        //需要进行对应的接密操作
+        //1.获取盐值
+        String salt = pwd.substring(0, 5);
+        String key = "b8d11ee289394be688ef3a4f6968efed";
+        String time1 = StringUtils.md5((key).substring(0, 8)).substring(0, 5);
+        //做超时判断
+        if (!time1.equalsIgnoreCase(salt)) {
+            throw new GlobalException(CommonEnum.LOGIN_TIMEOUT.getIndex(),
+                    CommonEnum.LOGIN_TIMEOUT.getValue());
+        }
+        //2.去除盐值
+        String replace = pwd.replace(salt, "");
+        //3.还原base64前的密码值
+        return new String(Base64.decodeBase64(replace), "utf-8");
+    }
+
+    /*
+     * 用户禁用、删除时,将用户的token删除
+     */
+    public void deleteTokenByUserId(String userId) {
+        try {
+            //tokenManager.deleteToken(MOBILE + SPLIT + userId);
+            tokenManager.deleteToken(PC + SPLIT + userId);
+            //tokenManager.deleteToken(SPOT + SPLIT + userId);
+        } catch (Exception e) {
+
+        }
+    }
+    public void validate(LoginInfoRep loginInfoRep) {
+        String menuName="用户登录-登录";
+        ResponseBase responseBase = new ResponseBase<>();
+        String userName=loginInfoRep.getUserName();
+        if(Objects.equals(userName,"admin")){
+            return ;
+        }
+        UserMapper userMapper = (UserMapper) SpringContext.getBean("userMapper");
+
+        User user = userMapper.selectByUserName(userName);
+        if(null==user){
+            throw new GlobalException(CommonEnum.USER_UNREGISTERED_ERROR.getIndex(), CommonEnum.USER_UNREGISTERED_ERROR.getValue(),userName, menuName);
+        }
+        if (Objects.equals(ConstantPool.DISAABLE,user.getStatus())){
+            throw new GlobalException(CommonEnum.THE_ACCOUNT_IS_BANNED.getIndex(), CommonEnum.THE_ACCOUNT_IS_BANNED.getValue(),userName, menuName);
+        }
+
+        Map<String, Integer> examine = userMapper.examine(userName);
+
+        if (null==examine){
+            throw new GlobalException(CommonEnum.USER_UNREGISTERED_ERROR.getIndex(), CommonEnum.USER_UNREGISTERED_ERROR.getValue(),userName, menuName);
+        }
+
+        switch (examine.get("roleInfo")){
+            case 0:
+                break;
+            case 1:
+            throw new GlobalException(CommonEnum.ABNORMAL_ACCOUNT.getIndex(),"该账户所属角色被锁定",userName, menuName);
+            case 2:
+            throw new GlobalException(CommonEnum.ABNORMAL_ACCOUNT.getIndex(),"该账户所属角色被禁用",userName, menuName);
+            default:
+                break;
+        }
+    }
+
+}
+
+

+ 66 - 0
src/main/java/com/hywa/map/controller/login/validate/StateValidationValidate.java

@@ -0,0 +1,66 @@
+package com.hywa.map.controller.login.validate;
+
+import com.hywa.map.common.ConstantPool;
+import com.hywa.map.common.enums.CommonEnum;
+import com.hywa.map.common.utils.SpringContext;
+import com.hywa.map.config.validation.Validator;
+import com.hywa.map.dao.entity.User;
+import com.hywa.map.dao.mapper.UserMapper;
+import com.hywa.map.representation.LoginInfoRep;
+import com.hywa.map.representation.ResponseBase;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+
+import java.util.Map;
+import java.util.Objects;
+
+/**
+ * @Author: vic
+ * 校验登录状态
+ */
+public class StateValidationValidate extends Validator{
+    @Override
+    public ResponseEntity<ResponseBase> validate(Object... t) {
+        String menuName="用户登录-登录";
+        ResponseBase responseBase = new ResponseBase<>();
+        LoginInfoRep loginInfoRep = (LoginInfoRep) t[0];
+            String userName=loginInfoRep.getUserName();
+        if(Objects.equals(userName,"admin")){
+            return null;
+        }
+        UserMapper userMapper = (UserMapper) SpringContext.getBean("userMapper");
+
+        User user = userMapper.selectByUserName(userName);
+        if(null==user){
+            responseBase.setRetHead(CommonEnum.USER_UNREGISTERED_ERROR.getIndex(),CommonEnum.USER_UNREGISTERED_ERROR.getValue());
+            return new ResponseEntity<>(responseBase, HttpStatus.OK);
+        }
+        if (Objects.equals(ConstantPool.DISAABLE,user.getStatus())){
+            responseBase.setRetHead(CommonEnum.THE_ACCOUNT_IS_BANNED.getIndex(),CommonEnum.THE_ACCOUNT_IS_BANNED.getValue());
+            return new ResponseEntity<>(responseBase, HttpStatus.OK);
+        }
+
+        Map<String, Integer> examine = userMapper.examine(userName);
+
+        if (null==examine){
+            responseBase.setRetHead(CommonEnum.USER_UNREGISTERED_ERROR.getIndex(), CommonEnum.USER_UNREGISTERED_ERROR.getValue());
+            return new ResponseEntity<>(responseBase, HttpStatus.OK);
+        }
+
+        switch (examine.get("roleInfo")){
+            case 0:
+                break;
+            case 1:
+                responseBase.setRetHead(CommonEnum.ABNORMAL_ACCOUNT.getIndex(),"该账号所属角色被锁定");
+                return new ResponseEntity<>(responseBase, HttpStatus.OK);
+            case 2:
+                responseBase.setRetHead(CommonEnum.ABNORMAL_ACCOUNT.getIndex(),"该账号所属角色被禁用");
+                return new ResponseEntity<>(responseBase, HttpStatus.OK);
+            default:
+                break;
+
+        }
+        return null;
+    }
+
+}

+ 481 - 0
src/main/java/com/hywa/map/controller/map/MapAdviseController.java

@@ -0,0 +1,481 @@
+package com.hywa.map.controller.map;
+
+import com.hywa.map.common.utils.StringUtils;
+import com.hywa.map.config.EnvProperties;
+import com.hywa.map.config.interceptor.TokenManager;
+import com.hywa.map.dao.mapper.ExpertInfoMapper;
+import com.hywa.map.representation.*;
+import com.hywa.map.service.dict.DictService;
+import com.hywa.map.service.expert.AreaDataService;
+import com.hywa.map.service.expert.DamService;
+import com.hywa.map.service.map.MapModuleDataService;
+import com.hywa.map.service.notice.NoticeService;
+import io.swagger.annotations.Api;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+import java.text.DecimalFormat;
+import java.util.*;
+
+/**
+ * t_sys_branch  对应Controller 实现类
+ *
+ * @author hywa
+ * @create by 2018-12-12 10:01:56
+ */
+
+@Slf4j
+@Api(tags = "一张图")
+@RestController
+@RequestMapping("/map")
+public class MapAdviseController {
+
+    @Autowired
+    private MapModuleDataService mapModuleDataService;
+    @Autowired
+    private DamService damService;
+    @Autowired
+    EnvProperties envProperties;
+    @Resource
+    private AreaDataService areaDataService;
+    @Autowired
+    private DictService dictService;
+    @Autowired
+    TokenManager tokenManager;
+    @Autowired
+    private NoticeService noticeService;
+    @Autowired
+    private ExpertInfoMapper expertInfoMapper;
+    public static String[] areaArrays = {"冠山街道", "龙山镇", "醒狮镇", "谷脚镇", "湾滩河镇", "洗马镇", "龙里县"};
+    public static String[] colorArrays = {"rgba(35, 104, 255, 1)", "rgba(9, 184, 209, 1)", "rgba(94, 139, 171, 1)", "rgba(172, 134, 240, 1)", "rgba(172, 134, 240, 1)",
+            "rgba(0, 139, 139, 1)", "rgba(255, 255, 205, 1)", "rgba(255, 228, 181, 1)", "rgba(112, 128, 144, 1)", "rgba(0, 0, 128, 1)",
+            "rgba(240, 255, 255, 1)", "rgba(230, 230, 250, 1)", "rgba(47, 79, 79, 1)", "rgba(106, 90, 205, 1)", "rgba(69, 139, 116, 1)",
+            "rgba(0, 191, 255, 1)", "rgba(70, 130, 180, 1)", "rgba(0, 0, 255, 1)", "rgba(255, 248, 220, 1)", "rgba(255, 228, 225, 1)",
+            "rgba(107, 142, 35, 1)", "rgba(189, 183, 107, 1)", "rgba(255, 215, 0, 1)", "rgba(238, 201, 0, 1)", "rgba(139, 101, 8, 1)",
+            "rgba(0, 207, 236, 1)", "rgba(135, 206, 255, 1)", "rgba(198, 226, 255, 1)", "rgba(191, 239, 255, 1)", "rgba(180, 205, 205, 1)",
+            "rgba(255, 225, 255, 1)", "rgba(255, 187, 255, 1)"};
+    public static String[] legendArrays = {"北京", "天津", "河北", "重庆", "云南", "贵州"
+            , "四川", "河南", "山东", "辽宁", "黑龙江", "内蒙古"
+            , "吉林", "湖南", "安徽", "浙江", "江西", "湖北"
+            , "江苏", "新疆", "甘肃", "山西", "青海", "陕西"
+            , "宁夏", "广西", "福建", "广东", "海南", "上海"
+            , "西藏", "台湾", "香港", "澳门", "南海诸岛"};
+
+    public static DecimalFormat decimalFormat = new DecimalFormat("###################.###########");
+
+    public ResponseEntity<ResponseBase> findSubDomainName(@RequestParam(required = false) String name) {
+        ResponseBase<MapDomainNameReps> responseBase = new ResponseBase<>();
+        name = StringUtils.isEmpty(name) ? "刺梨" : name;
+        List<MapDomainNameRep> list = new ArrayList<>();
+        AreaDataRep areaDataRep = areaDataService.queryDisplay("龙里县", "808b87b6e4ff403ca825f955031f6659");
+        if (areaDataRep != null) {
+            AreaDataDetailRep areaDataDetailRep = areaDataService.queryById(areaDataRep.getId());
+            MapDomainNameRep nameRep = new MapDomainNameRep();
+            nameRep.setIcon("icon-quanbushujumulu");
+            nameRep.setId("全部");
+            nameRep.setName("全部");
+            list.add(nameRep);
+            List<Map<String, String>> valList = areaDataDetailRep.getValList();
+            for (int i = 0; i < valList.size(); i++) {
+                MapDomainNameRep rep = new MapDomainNameRep();
+                Map<String, String> item = valList.get(i);
+                String subName = item.get("fieldVal2");
+                if (StringUtils.isNotEmpty(subName) && item.get("fieldVal1").contains(name)) {
+                    rep.setIcon("icon-moren_fenleiicon");
+                    rep.setId(subName);
+                    rep.setName(subName);
+                    list.add(rep);
+                }
+            }
+        }
+        MapDomainNameReps reps = new MapDomainNameReps();
+        reps.setId(name);
+        reps.setList(list);
+        responseBase.success().setRetBody(reps);
+        return new ResponseEntity<>(responseBase, HttpStatus.OK);
+    }
+
+    /*
+     * 获取产业销售区域分布
+     */
+    @RequestMapping(value = "/findDomainArea", method = RequestMethod.GET)
+    public ResponseEntity<ResponseBase> findDomainArea(@RequestParam(required = false) String id,
+                                                       @RequestParam(required = false) String domainName,
+                                                       @RequestParam(required = false) String subDomainName) {
+        ResponseBase<MapDomainAreaReps> responseBase = new ResponseBase<>();
+        String fields = "";
+        boolean isSignal = false;
+        if ("全部".equals(subDomainName)) {
+            ResponseEntity<ResponseBase> baseResponseEntity = findSubDomainName(domainName);
+            ResponseBase base = baseResponseEntity.getBody();
+            MapDomainNameReps mapDomainNameReps = (MapDomainNameReps) base.getRetBody();
+            List<MapDomainNameRep> subName = mapDomainNameReps.getList();
+            for (MapDomainNameRep item : subName) {
+                fields = fields + item.getName() + "|";
+            }
+            fields = fields.substring(0, fields.length() - 1);
+            if ("全部".equals(fields)) {
+                fields = domainName;
+                isSignal = true;
+            } else {
+                fields = fields.substring(3, fields.length());
+            }
+        } else {
+            fields = subDomainName;
+        }
+        id = StringUtils.isEmpty(id) ? "龙里县" : id;
+        //String[] areaNameArrays = new String[]{id};
+        String[] areaNameArrays = (StringUtils.isEmpty(id) || "龙里县".equals(id)) ? areaArrays : (new String[]{id});
+        String[] fieldArrays = fields.split("\\|");
+        List<MapDomainSellRep> list = new ArrayList<>();
+        double cnt1 = 0;
+        double cnt2 = 0;
+        List<Map<String, String>> allValList = new ArrayList<>();
+        for (int i = 0; i < areaNameArrays.length; i++) {
+            AreaDataRep areaDataRep = areaDataService.queryShow(areaNameArrays[i], "53e14d43e8154507b0ef2231f8a18da5");
+            if (areaDataRep != null) {
+                AreaDataDetailRep areaDataDetailRep = areaDataService.queryById(areaDataRep.getId());
+                List<Map<String, String>> valList = areaDataDetailRep.getValList();
+                for (Map<String, String> map : valList) {
+                    allValList.add(map);
+                }
+            }
+        }
+        domainName = "蔬菜|水果|中药材|茶叶|油茶|食用菌".indexOf(domainName) >= 0 ? domainName + "产业" : domainName;
+        List<Map<String, String>> sellList = new ArrayList<>();
+        List<String> sellAreaList = new ArrayList<>();
+        for (int j = 0; j < fieldArrays.length; j++) {
+            for (Map<String, String> map : allValList) {
+                if ("销售流向及占比".equals(map.get("fieldVal3")) && fieldArrays[j].equals(map.get("fieldVal1")) && (domainName.equals(map.get("fieldVal2")) || isSignal) && StringUtils.isNotEmpty(map.get("fieldVal4"))) {
+                    String[] val4s = map.get("fieldVal4").split("\\,");
+                    for (int k = 0; k < val4s.length; k++) {
+                        Map<String, String> valMap = new HashMap<>();
+                        valMap.put(val4s[k].split("\\=")[0], val4s[k].split("\\=")[1]);
+                        sellList.add(valMap);
+                        sellAreaList.add(val4s[k].split("\\=")[0]);
+                    }
+                }
+            }
+        }
+        HashSet h = new HashSet(sellAreaList);
+        sellAreaList.clear();
+        sellAreaList.addAll(h);
+        for (int m = 0; m < sellAreaList.size(); m++) {
+            String area = sellAreaList.get(m);
+            double cnt = 0;
+            MapDomainSellRep rep = new MapDomainSellRep();
+            for (Map<String, String> item : sellList) {
+                for (String key : item.keySet()) {
+                    String value = item.get(key);
+                    if (key.equals(area)) {
+                        cnt = cnt + Double.parseDouble(value);
+                    }
+                }
+            }
+            rep.setName(area);
+            rep.setColor(colorArrays[m]);
+            rep.setValue(decimalFormat.format(cnt));
+            list.add(rep);
+        }
+        MapDomainAreaReps reps = new MapDomainAreaReps();
+        reps.setId("");
+        reps.setTitle("建议销售区域分布");
+        reps.set_caveat("注意:城市对应值为图例序号减1");
+        List<MapDomainAreaRep> legend = new ArrayList<>();
+        MapDomainAreaRep areaRep = new MapDomainAreaRep();
+        areaRep.setColor("rgba(74, 255, 0, 1)");
+        areaRep.setName("销售区域");
+        legend.add(areaRep);
+        areaRep = new MapDomainAreaRep();
+        areaRep.setColor("rgba(0, 109, 201, 0.73)");
+        areaRep.setName("未销售区域");
+        legend.add(areaRep);
+        reps.setLegend(legend);
+        List<MapMerchantRep> repList = new ArrayList<>();
+        for (int i = 0; i < legendArrays.length; i++) {
+            MapMerchantRep rep = new MapMerchantRep();
+            rep.setName(legendArrays[i]);
+            rep.setValue(sellAreaList.contains(legendArrays[i]) ? "0" : "1");
+            repList.add(rep);
+        }
+        reps.setList(repList);
+        responseBase.success().setRetBody(reps);
+        return new ResponseEntity<>(responseBase, HttpStatus.OK);
+    }
+
+    /*
+     * 获取产业市场需求量
+     */
+    @RequestMapping(value = "/findDomainNeed", method = RequestMethod.GET)
+    public ResponseEntity<ResponseBase> findDomainNeed(@RequestParam(required = false) String id,
+                                                       @RequestParam(required = false) String domainName,
+                                                       @RequestParam(required = false) String subDomainName) {
+        ResponseBase<MapDomainNeedReps> responseBase = new ResponseBase<>();
+        String fields = "";
+        boolean isSignal = false;
+        if ("全部".equals(subDomainName)) {
+            ResponseEntity<ResponseBase> baseResponseEntity = findSubDomainName(domainName);
+            ResponseBase base = baseResponseEntity.getBody();
+            MapDomainNameReps mapDomainNameReps = (MapDomainNameReps) base.getRetBody();
+            List<MapDomainNameRep> subName = mapDomainNameReps.getList();
+            for (MapDomainNameRep item : subName) {
+                fields = fields + item.getName() + "|";
+            }
+            fields = fields.substring(0, fields.length() - 1);
+            if ("全部".equals(fields)) {
+                fields = domainName;
+                isSignal = true;
+            } else {
+                fields = fields.substring(3, fields.length());
+            }
+        } else {
+            fields = subDomainName;
+        }
+        id = StringUtils.isEmpty(id) ? "龙里县" : id;
+        //String[] areaNameArrays = new String[]{id};
+        String[] areaNameArrays = (StringUtils.isEmpty(id) || "龙里县".equals(id)) ? areaArrays : (new String[]{id});
+        String[] fieldArrays = fields.split("\\|");
+        List<MapDomainNeedRep> list = new ArrayList<>();
+        double cnt1 = 0;
+        double cnt2 = 0;
+        List<Map<String, String>> allValList = new ArrayList<>();
+        for (int i = 0; i < areaNameArrays.length; i++) {
+            AreaDataRep areaDataRep = areaDataService.queryShow(areaNameArrays[i], "53e14d43e8154507b0ef2231f8a18da5");
+            if (areaDataRep != null) {
+                AreaDataDetailRep areaDataDetailRep = areaDataService.queryById(areaDataRep.getId());
+                List<Map<String, String>> valList = areaDataDetailRep.getValList();
+                for (Map<String, String> map : valList) {
+                    allValList.add(map);
+                }
+            }
+        }
+        domainName = "蔬菜|水果|中药材|茶叶|油茶|食用菌".indexOf(domainName) >= 0 ? domainName + "产业" : domainName;
+        List<Map<String, String>> sellList = new ArrayList<>();
+        List<String> sellAreaList = new ArrayList<>();
+        for (int j = 0; j < fieldArrays.length; j++) {
+            for (Map<String, String> map : allValList) {
+                if ("市场需求量".equals(map.get("fieldVal3")) && fieldArrays[j].equals(map.get("fieldVal1")) && (domainName.equals(map.get("fieldVal2")) || isSignal) && StringUtils.isNotEmpty(map.get("fieldVal4"))) {
+                    String[] val4s = map.get("fieldVal4").split("\\,");
+                    for (int k = 0; k < val4s.length; k++) {
+                        Map<String, String> valMap = new HashMap<>();
+                        valMap.put(val4s[k].split("\\=")[0], val4s[k].split("\\=")[1]);
+                        sellList.add(valMap);
+                        sellAreaList.add(val4s[k].split("\\=")[0]);
+                    }
+                }
+            }
+        }
+        HashSet h = new HashSet(sellAreaList);
+        sellAreaList.clear();
+        sellAreaList.addAll(h);
+        for (int m = 0; m < sellAreaList.size(); m++) {
+            String area = sellAreaList.get(m);
+            double cnt = 0;
+            MapDomainNeedRep rep = new MapDomainNeedRep();
+            for (Map<String, String> item : sellList) {
+                for (String key : item.keySet()) {
+                    String value = item.get(key);
+                    if (key.equals(area)) {
+                        cnt = cnt + Double.parseDouble(value);
+                    }
+                }
+            }
+            rep.setName(area);
+            rep.setType("市场需求量");
+            rep.setValue(cnt);
+            list.add(rep);
+        }
+        MapDomainNeedReps reps = new MapDomainNeedReps();
+        reps.setId("");
+        reps.setTitle("市场需求量");
+        reps.setSubtitle("副标题");
+        List<MapDomainNeedRep> newList = new ArrayList<>();
+        for (int i = 1; i < 13; i++) {
+            String name = i + "";
+            MapDomainNeedRep rep = new MapDomainNeedRep();
+            rep.setType("市场需求量");
+            rep.setName(name);
+            double value = 0.0;
+            for (MapDomainNeedRep item : list) {
+                if (name.equals(item.getName())) {
+                    value = item.getValue();
+                    break;
+                }
+            }
+            rep.setValue(value);
+            newList.add(rep);
+        }
+        reps.setList(newList);
+        responseBase.success().setRetBody(reps);
+        return new ResponseEntity<>(responseBase, HttpStatus.OK);
+    }
+
+    /*
+     * 获取产业价格指数
+     */
+    @RequestMapping(value = "/findDomainPrice", method = RequestMethod.GET)
+    public ResponseEntity<ResponseBase> findDomainPrice(@RequestParam(required = false) String id,
+                                                        @RequestParam(required = false) String domainName,
+                                                        @RequestParam(required = false) String subDomainName) {
+        ResponseBase<MapDomainNeedReps> responseBase = new ResponseBase<>();
+        String fields = "";
+        boolean isSignal = false;
+        if ("全部".equals(subDomainName)) {
+            ResponseEntity<ResponseBase> baseResponseEntity = findSubDomainName(domainName);
+            ResponseBase base = baseResponseEntity.getBody();
+            MapDomainNameReps mapDomainNameReps = (MapDomainNameReps) base.getRetBody();
+            List<MapDomainNameRep> subName = mapDomainNameReps.getList();
+            for (MapDomainNameRep item : subName) {
+                fields = fields + item.getName() + "|";
+            }
+            fields = fields.substring(0, fields.length() - 1);
+            if ("全部".equals(fields)) {
+                fields = domainName;
+                isSignal = true;
+            } else {
+                fields = fields.substring(3, fields.length());
+            }
+        } else {
+            fields = subDomainName;
+        }
+        id = StringUtils.isEmpty(id) ? "龙里县" : id;
+        //String[] areaNameArrays = new String[]{id};
+        String[] areaNameArrays = (StringUtils.isEmpty(id) || "龙里县".equals(id)) ? areaArrays : (new String[]{id});
+        String[] fieldArrays = fields.split("\\|");
+        List<MapDomainNeedRep> list = new ArrayList<>();
+        double cnt1 = 0;
+        double cnt2 = 0;
+        List<Map<String, String>> allValList = new ArrayList<>();
+        for (int i = 0; i < areaNameArrays.length; i++) {
+            AreaDataRep areaDataRep = areaDataService.queryShow(areaNameArrays[i], "53e14d43e8154507b0ef2231f8a18da5");
+            if (areaDataRep != null) {
+                AreaDataDetailRep areaDataDetailRep = areaDataService.queryById(areaDataRep.getId());
+                List<Map<String, String>> valList = areaDataDetailRep.getValList();
+                for (Map<String, String> map : valList) {
+                    allValList.add(map);
+                }
+            }
+        }
+        domainName = "蔬菜|水果|中药材|茶叶|油茶|食用菌".indexOf(domainName) >= 0 ? domainName + "产业" : domainName;
+        List<Map<String, String>> sellList = new ArrayList<>();
+        List<String> sellAreaList = new ArrayList<>();
+        int record = 0;
+        for (int j = 0; j < fieldArrays.length; j++) {
+            for (Map<String, String> map : allValList) {
+                if ("平均价格".equals(map.get("fieldVal3")) && fieldArrays[j].equals(map.get("fieldVal1")) && (domainName.equals(map.get("fieldVal2")) || isSignal) && StringUtils.isNotEmpty(map.get("fieldVal4"))) {
+                    String[] val4s = map.get("fieldVal4").split("\\,");
+                    for (int k = 0; k < val4s.length; k++) {
+                        Map<String, String> valMap = new HashMap<>();
+                        valMap.put(val4s[k].split("\\=")[0], val4s[k].split("\\=")[1]);
+                        sellList.add(valMap);
+                        sellAreaList.add(val4s[k].split("\\=")[0]);
+                    }
+                    record = record + 1;
+                }
+            }
+        }
+        HashSet h = new HashSet(sellAreaList);
+        sellAreaList.clear();
+        sellAreaList.addAll(h);
+
+        for (int m = 0; m < sellAreaList.size(); m++) {
+            String area = sellAreaList.get(m);
+            double cnt = 0;
+            MapDomainNeedRep rep = new MapDomainNeedRep();
+            for (Map<String, String> item : sellList) {
+                for (String key : item.keySet()) {
+                    String value = item.get(key);
+                    if (key.equals(area)) {
+                        cnt = cnt + Double.parseDouble(value);
+                    }
+                }
+            }
+            rep.setName(area);
+            rep.setType("价格指数");
+            rep.setValue(cnt);
+            list.add(rep);
+        }
+        MapDomainNeedReps reps = new MapDomainNeedReps();
+        reps.setId("");
+        reps.setTitle("价格指数");
+        reps.setSubtitle("副标题");
+        List<MapDomainNeedRep> newList = new ArrayList<>();
+        for (int i = 1; i < 13; i++) {
+            String name = i + "";
+            MapDomainNeedRep rep = new MapDomainNeedRep();
+            rep.setType("价格指数");
+            rep.setName(name);
+            double value = 0.0;
+            for (MapDomainNeedRep item : list) {
+                if (name.equals(item.getName())) {
+                    value = item.getValue();
+                    break;
+                }
+            }
+            rep.setValue(Double.parseDouble(String.format("%.2f", value / (record == 0 ? 1 : record))));
+            newList.add(rep);
+        }
+        reps.setList(newList);
+        responseBase.success().setRetBody(reps);
+        return new ResponseEntity<>(responseBase, HttpStatus.OK);
+    }
+
+    /*
+     * 获取产业扶贫列表
+     */
+    @RequestMapping(value = "/findHelpAll", method = RequestMethod.GET)
+    public ResponseEntity<ResponseBase> findHelpAll(@RequestParam(defaultValue = "1") int pageNo,
+                                                    @RequestParam(defaultValue = "10") int pageSize) {
+        ResponseBase<MapHelpReps> responseBase = new ResponseBase<>();
+        MapHelpRep mapHelpRep = new MapHelpRep();
+        List<MapExpertTypeRep> list = new ArrayList<>();
+        NoticeReps noticeReps = noticeService.selectAll(pageNo, pageSize, null, null, null, "9", null);
+        if (noticeReps != null) {
+            List<NoticeRep> noticeRepList = noticeReps.getList();
+            for (NoticeRep item : noticeRepList) {
+                MapExpertTypeRep mapExpertTypeRep = new MapExpertTypeRep();
+                mapExpertTypeRep.setId(item.getId());
+                mapExpertTypeRep.setName(item.getTitle());
+                list.add(mapExpertTypeRep);
+            }
+            mapHelpRep.setList(list);
+        }
+        MapHelpReps reps = new MapHelpReps();
+        reps.setData(mapHelpRep);
+        responseBase.success().setRetBody(reps);
+        return new ResponseEntity<>(responseBase, HttpStatus.OK);
+    }
+
+    /*
+     * 获取产业扶贫列表
+     */
+    @RequestMapping(value = "/findHelpDetail", method = RequestMethod.GET)
+    public ResponseEntity<ResponseBase> findHelpDetail(@RequestParam(required = false) String id) {
+        ResponseBase<MapHelpDetailReps> responseBase = new ResponseBase<>();
+        MapHelpDetailRep mapHelpDetailRep = new MapHelpDetailRep();
+        List<MapHelpDetail> list = new ArrayList<>();
+        NoticeRep noticeRep = noticeService.selectById(id);
+        if (noticeRep != null) {
+            List<FileReq> noticeRepList = noticeRep.getFiles();
+            for (FileReq item : noticeRepList) {
+                MapHelpDetail mapHelpDetail = new MapHelpDetail();
+                mapHelpDetail.setSrc(item.getFileUrl());
+                mapHelpDetail.setValue(item.getFileDesc());
+                list.add(mapHelpDetail);
+            }
+            mapHelpDetailRep.setList(list);
+        }
+        MapHelpDetailReps reps = new MapHelpDetailReps();
+        reps.setData(mapHelpDetailRep);
+        responseBase.success().setRetBody(reps);
+        return new ResponseEntity<>(responseBase, HttpStatus.OK);
+    }
+}
+

+ 188 - 0
src/main/java/com/hywa/map/controller/map/MapController.java

@@ -0,0 +1,188 @@
+package com.hywa.map.controller.map;
+
+import com.hywa.map.common.log.Log;
+import com.hywa.map.common.utils.DateUtils;
+import com.hywa.map.common.utils.StringUtils;
+import com.hywa.map.config.EnvProperties;
+import com.hywa.map.config.interceptor.TokenManager;
+import com.hywa.map.config.interceptor.TokenModel;
+import com.hywa.map.config.redis.RedisUtil;
+import com.hywa.map.representation.*;
+import com.hywa.map.service.expert.AreaDataService;
+import com.hywa.map.service.map.MapModuleDataService;
+import com.hywa.map.timer.YsOpenPlatTimer;
+import io.swagger.annotations.Api;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+
+import static com.hywa.map.common.ConstantPool.SPLIT;
+
+/**
+ * t_sys_branch  对应Controller 实现类
+ *
+ * @author hywa
+ * @create by 2018-12-12 10:01:56
+ */
+
+@Slf4j
+@Api(tags = "一张图")
+@RestController
+@RequestMapping("/map")
+public class MapController {
+
+    @Autowired
+    private MapModuleDataService mapModuleDataService;
+    @Autowired
+    EnvProperties envProperties;
+    @Resource
+    private RedisUtil redisUtil;
+    @Autowired
+    TokenManager tokenManager;
+    @Autowired
+    private AreaDataService areaDataService;
+
+    @PostMapping
+    @Transactional
+    @Log(log = "一张图-新增大屏信息")
+    public ResponseEntity<ResponseBase> saveMap(@RequestBody MapInfoReq reqInfo, HttpServletRequest req) {
+        TokenModel accessToken = tokenManager.getToken(req.getHeader("accessToken"));
+        //String userId = accessToken.getUserId().split(SPLIT)[1];
+        String userId = "anonymous";
+        try {
+            mapModuleDataService.saveMap(reqInfo, userId);
+        } catch (Exception e) {
+            log.error("一张图-新增大屏信息异常,请求数据|" + reqInfo + ",异常信息|" + e);
+            throw e;
+        }
+        return new ResponseEntity<>(new ResponseBase().success(), HttpStatus.OK);
+    }
+
+    @DeleteMapping
+    @Log(log = "一张图-删除大屏信息")
+    public ResponseEntity<ResponseBase> deleteMap(@RequestBody MapInfoReq reqInfo, HttpServletRequest req) {
+        TokenModel accessToken = tokenManager.getToken(req.getHeader("accessToken"));
+        //String userId = accessToken.getUserId().split(SPLIT)[1];
+        String userId = "anonymous";
+        try {
+            mapModuleDataService.deleteMap(reqInfo, userId);
+        } catch (Exception e) {
+            log.error("一张图-删除大屏信息异常,请求数据|" + reqInfo + ",异常信息|" + e);
+            throw e;
+        }
+        return new ResponseEntity<>(new ResponseBase().success(), HttpStatus.OK);
+    }
+
+    @PutMapping
+    @Log(log = "一张图-更新大屏信息")
+    public ResponseEntity<ResponseBase> updateMap(@RequestBody MapInfoReq reqInfo, HttpServletRequest req) {
+        TokenModel accessToken = tokenManager.getToken(req.getHeader("accessToken"));
+        //String userId = accessToken.getUserId().split(SPLIT)[1];
+        String userId = "anonymous";
+        try {
+            mapModuleDataService.updateMap(reqInfo, userId);
+        } catch (Exception e) {
+            log.error("一张图-更新大屏信息异常,请求数据|" + reqInfo + ",异常信息|" + e);
+            throw e;
+        }
+        return new ResponseEntity<>(new ResponseBase().success(), HttpStatus.OK);
+    }
+
+    @RequestMapping(value = "/updateState", method = RequestMethod.POST)
+    @Transactional
+    @Log(log = "一张图-更新大屏状态信息")
+    public ResponseEntity<ResponseBase> updateMapState(@RequestBody MapInfoReq reqInfo, HttpServletRequest req) {
+        TokenModel accessToken = tokenManager.getToken(req.getHeader("accessToken"));
+        //String userId = accessToken.getUserId().split(SPLIT)[1];
+        String userId = "anonymous";
+        try {
+            mapModuleDataService.updateMapState(reqInfo, userId);
+        } catch (Exception e) {
+            log.error("一张图-更新大屏状态信息异常,请求数据|" + reqInfo + ",异常信息|" + e);
+            throw e;
+        }
+        return new ResponseEntity<>(new ResponseBase().success(), HttpStatus.OK);
+    }
+
+    @RequestMapping(value = "/findMapAll", method = RequestMethod.GET)
+    public ResponseEntity<ResponseBase> findMapAll(@RequestParam(required = false) String mapName,
+                                                   @RequestParam(defaultValue = "1") int pageNo,
+                                                   @RequestParam(defaultValue = "100") int pageSize) {
+        ResponseBase<MapInfoReps> responseBase = new ResponseBase<>();
+        responseBase.success().setRetBody(mapModuleDataService.selectMapAll(pageNo, pageSize, mapName));
+        return new ResponseEntity<>(responseBase, HttpStatus.OK);
+    }
+
+    @RequestMapping(value = "/findMapById", method = RequestMethod.GET)
+    public ResponseEntity<ResponseBase> findMapById(@RequestParam(required = false) String id) {
+        ResponseBase<MapInfoRep> responseBase = new ResponseBase<>();
+        responseBase.success().setRetBody(mapModuleDataService.selectMapById(id));
+        return new ResponseEntity<>(responseBase, HttpStatus.OK);
+    }
+
+    @RequestMapping(value = "/findMapTemplate", method = RequestMethod.GET)
+    public ResponseEntity<ResponseBase> findGoodsType() {
+        ResponseBase<ComboxReps> responseBase = new ResponseBase<>();
+        responseBase.success().setRetBody(mapModuleDataService.selectMapTemplate());
+        return new ResponseEntity<>(responseBase, HttpStatus.OK);
+    }
+
+    @RequestMapping(value = "/addModuleData", method = RequestMethod.POST)
+    @Transactional
+    @Log(log = "一张图-新增组件配置数据信息")
+    public ResponseEntity<ResponseBase> saveOrUpdate(@RequestBody MapModuleDataReq reqInfo, HttpServletRequest req) {
+        TokenModel accessToken = tokenManager.getToken(req.getHeader("accessToken"));
+        //String userId = accessToken.getUserId().split(SPLIT)[1];
+        String userId = "anonymous";
+        try {
+            mapModuleDataService.saveOrUpdate(reqInfo, userId);
+        } catch (Exception e) {
+            log.error("一张图-新增组件配置数据信息异常,请求数据|" + reqInfo + ",异常信息|" + e);
+            throw e;
+        }
+        return new ResponseEntity<>(new ResponseBase().success(), HttpStatus.OK);
+    }
+
+    @RequestMapping(value = "/findModuleData", method = RequestMethod.GET)
+    public ResponseEntity<ResponseBase<MapModuleDataRep>> findById(@RequestParam(required = false) String mapId,
+                                                                   @RequestParam(required = false) String moduleCode,
+                                                                   @RequestParam(required = false) String isShow) {
+        ResponseBase<MapModuleDataRep> responseBase = new ResponseBase<>();
+        responseBase.success().setRetBody(mapModuleDataService.selectModuleData(mapId, moduleCode, isShow));
+        responseBase.success();
+        return new ResponseEntity<>(responseBase, HttpStatus.OK);
+    }
+
+    @RequestMapping(value = "/findYsAccessToken", method = RequestMethod.GET)
+    public ResponseEntity<ResponseBase> findYsAccessToken() {
+        ResponseBase<YsTokenRep> responseBase = new ResponseBase<>();
+        YsTokenRep rep = new YsTokenRep();
+        String accessToken = redisUtil.get(YsOpenPlatTimer.ysOpenPlatAccessToken);
+        rep.setAccessToken(accessToken.split("\\_")[1]);
+        responseBase.success().setRetBody(rep);
+        responseBase.success();
+        return new ResponseEntity<>(responseBase, HttpStatus.OK);
+    }
+
+    @RequestMapping(value = "/findPrice", method = RequestMethod.GET)
+    public ResponseEntity<ResponseBase> findPrice(@RequestParam(defaultValue = "1") int pageNo,
+                                                  @RequestParam(defaultValue = "10") int pageSize,
+                                                  @RequestParam(required = false) String beginDate,
+                                                  @RequestParam(required = false) String endDate,
+                                                  @RequestParam(required = false) String cateName,
+                                                  @RequestParam(required = false) String areaName) {
+        ResponseBase<AreaDataPriceReps> responseBase = new ResponseBase<>();
+        beginDate = StringUtils.isEmpty(beginDate) ? "20000101" : beginDate;
+        endDate = StringUtils.isEmpty(endDate) ? "99991231" : endDate;
+        areaName = "1".equals(areaName) ? "贵阳农产品物流园" : "双龙农副产品交易中心";
+        responseBase.success().setRetBody(areaDataService.queryPrice(pageNo, pageSize, beginDate, endDate, cateName, areaName));
+        return new ResponseEntity<>(responseBase, HttpStatus.OK);
+    }
+}
+

+ 563 - 0
src/main/java/com/hywa/map/controller/map/MapDamController.java

@@ -0,0 +1,563 @@
+package com.hywa.map.controller.map;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.hywa.map.common.utils.DateUtils;
+import com.hywa.map.common.utils.HttpUtils;
+import com.hywa.map.common.utils.StringUtils;
+import com.hywa.map.common.utils.UUIDUtils;
+import com.hywa.map.config.EnvProperties;
+import com.hywa.map.config.interceptor.TokenManager;
+import com.hywa.map.dao.entity.AreaData;
+import com.hywa.map.dao.entity.Combox;
+import com.hywa.map.dao.entity.Dict;
+import com.hywa.map.dao.entity.OrchardProduct;
+import com.hywa.map.dao.mapper.ExpertInfoMapper;
+import com.hywa.map.dao.mapper.OrchardInfoMapper;
+import com.hywa.map.representation.*;
+import com.hywa.map.service.dict.DictService;
+import com.hywa.map.service.expert.AreaDataService;
+import com.hywa.map.service.expert.DamService;
+import com.hywa.map.service.map.MapModuleDataService;
+import com.hywa.map.service.orchard.OrchardService;
+import io.swagger.annotations.Api;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+import java.text.DecimalFormat;
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+/**
+ * t_sys_branch  对应Controller 实现类
+ *
+ * @author hywa
+ * @create by 2018-12-12 10:01:56
+ */
+
+@Slf4j
+@Api(tags = "一张图")
+@RestController
+@RequestMapping("/map")
+public class MapDamController {
+
+    @Autowired
+    private MapModuleDataService mapModuleDataService;
+    @Autowired
+    private DamService damService;
+    @Autowired
+    EnvProperties envProperties;
+    @Resource
+    private AreaDataService areaDataService;
+    @Autowired
+    private DictService dictService;
+    @Autowired
+    TokenManager tokenManager;
+    @Autowired
+    private ExpertInfoMapper expertInfoMapper;
+    @Autowired
+    private OrchardInfoMapper orchardInfoMapper;
+    @Autowired
+    private OrchardService orchardService;
+    public static String[] areaArrays = {"冠山街道", "龙山镇", "醒狮镇", "谷脚镇", "湾滩河镇", "洗马镇", "龙里县"};
+    public static DecimalFormat decimalFormat = new DecimalFormat("###################.###########");
+    public static HashMap<String, String> iconMap = new HashMap<String, String>() {{
+        put("空气温度", "icon-wendu");
+        put("空气湿度", "icon-icon-temperature");
+        put("土壤温度", "icon-turangwendu");
+        put("土壤湿度", "icon-turangshidu");
+        put("土壤PH", "icon-shiguan");
+        put("光照度", "icon-guangzhao");
+        put("风速", "icon-fengsu");
+        put("风向", "icon-tianqi-fengxiang");
+        put("二氧化碳", "icon-co");
+        put("降雨量", "icon-jiangyuliang");
+        put("大气压力", "icon-daqiyali");
+        put("PM2.5", "icon-PM");
+        put("土壤盐分", "icon-turangyanfen");
+    }};
+    public static String custName = "湄潭县竹香米业有限责任公司";
+    public static double custLng = 107.605340;
+    public static double custLat = 27.884780;
+    /*
+     * 获取监控点列表信息
+     */
+    @RequestMapping(value = "/findMonitorPoint", method = RequestMethod.GET)
+    public ResponseEntity<ResponseBase> findMonitorPoint(@RequestParam(required = false) String id) {
+        ResponseBase<MapDamTypeReps> responseBase = new ResponseBase<>();
+        List<MapDamTypeRep> list = new ArrayList<>();
+        OrchardRep orchardRep = orchardService.selectById(id);
+        if (orchardRep != null) {
+            Map<String, String> queryParas = new HashMap<>();
+            queryParas.put("enter", custName);
+            queryParas.put("base", orchardRep.getOrchardName());
+            String responseMsg = HttpUtils.get(envProperties.getIotServerUrl() + "oneMap/getPoint", queryParas);
+            if (StringUtils.isNotEmpty(responseMsg)) {
+                JSONObject jsonObject = JSONObject.parseObject(responseMsg);
+                JSONObject retBody = jsonObject.getJSONObject("retBody");
+                if (retBody != null) {
+                    JSONArray data = retBody.getJSONArray("list");
+                    for (int i = 0; i < data.size(); i++) {
+                        JSONObject item = (JSONObject) data.get(i);
+                        String name = item.getString("collection_point_name");
+                        String monId = item.getString("id");
+                        MapDamTypeRep rep = new MapDamTypeRep();
+                        rep.setName(name);
+                        rep.setMonId(monId);
+                        list.add(rep);
+                    }
+                    log.info("获取物联网采集点成功,请求数据:id|" + id);
+                }
+            }
+        }
+        MapDamTypeReps reps = new MapDamTypeReps(list);
+        reps.setId(id);
+        responseBase.success().setRetBody(reps);
+        return new ResponseEntity<>(responseBase, HttpStatus.OK);
+    }
+
+    /**
+     * 根据风向度数取风向
+     *
+     * @param degree 风向度数
+     * @return 中文风向
+     */
+    public String getWindDire(int degree) {
+        String windDire = "东北";
+        if ((degree >= 348 && degree <= 360) || (degree >= 0 && degree <= 11)) {
+            windDire = "北";
+        } else if (degree >= 12 && degree <= 79) {
+            windDire = "东北";
+        } else if (degree >= 80 && degree <= 101) {
+            windDire = "东";
+        } else if (degree >= 102 && degree <= 168) {
+            windDire = "东南";
+        } else if (degree >= 169 && degree <= 191) {
+            windDire = "南";
+        } else if (degree >= 192 && degree <= 258) {
+            windDire = "西南";
+        } else if (degree >= 259 && degree <= 281) {
+            windDire = "西";
+        } else if (degree >= 282 && degree <= 347) {
+            windDire = "西北";
+        }
+        return windDire;
+    }
+
+    /*
+     * 获取监控点数据信息
+     */
+    @RequestMapping(value = "/findMonitorData", method = RequestMethod.GET)
+    public ResponseEntity<ResponseBase> findMonitorData(@RequestParam(required = false) String id,
+                                                        @RequestParam(required = false) String monId) {
+        ResponseBase<MapMonDataReps> responseBase = new ResponseBase<>();
+        List<MapMonDataRep> list = new ArrayList<>();
+        Map<String, String> queryParas = new HashMap<>();
+        queryParas.put("point", monId);
+        String responseMsg = HttpUtils.get(envProperties.getIotServerUrl() + "oneMap/devices", queryParas);
+        if (StringUtils.isNotEmpty(responseMsg)) {
+            JSONObject jsonObject = JSONObject.parseObject(responseMsg);
+            JSONObject retBody = jsonObject.getJSONObject("retBody");
+            if (retBody != null) {
+                JSONArray data = retBody.getJSONArray("list");
+                for (int i = 0; i < data.size(); i++) {
+                    JSONObject item = (JSONObject) data.get(i);
+                    String name = item.getString("sensor_name");
+                    String value = item.getString("data_value");
+                    String unit = item.getString("sensor_unit");
+                    MapMonDataRep rep = new MapMonDataRep();
+                    rep.setName(name);
+                    rep.setValue("风向".equals(name) ? getWindDire(Integer.parseInt(value)) + "风" : value);
+                    rep.setUnit(StringUtils.isEmpty(unit) ? "" : unit);
+                    rep.setIcon(iconMap.get(name));
+                    rep.setAuthCode(item.getString("authorize_code"));
+                    rep.setSensorCode(item.getString("sensor_code"));
+                    list.add(rep);
+                }
+                log.info("获取物联网采集点实时数据成功,请求数据:id|" + id + ",monId|" + monId);
+            }
+        }
+        MapMonDataReps reps = new MapMonDataReps();
+        reps.setId(id);
+        reps.setList(list);
+        reps.setMonId(monId);
+        responseBase.success().setRetBody(reps);
+        return new ResponseEntity<>(responseBase, HttpStatus.OK);
+    }
+
+    /*
+     * 获取监控点24小时列表信息
+     */
+    @RequestMapping(value = "/findMonitorHourData", method = RequestMethod.GET)
+    public ResponseEntity<ResponseBase> findMonitorHourData(@RequestParam(required = false) String authCode,
+                                                            @RequestParam(required = false) String sensorCode) {
+        ResponseBase<MapMonHourDataReps> responseBase = new ResponseBase<>();
+        List<List<String>> chartData = new ArrayList<>();
+        Map<String, String> queryParas = new HashMap<>();
+        queryParas.put("authorize", authCode);
+        queryParas.put("sensor_code", sensorCode);
+        String responseMsg = HttpUtils.get(envProperties.getIotServerUrl() + "oneMap/iotData", queryParas);
+        List<String> dataTime = new ArrayList<>();
+        if (StringUtils.isNotEmpty(responseMsg)) {
+            JSONObject jsonObject = JSONObject.parseObject(responseMsg);
+            JSONObject retBody = jsonObject.getJSONObject("retBody");
+            if (retBody != null) {
+                JSONArray data = retBody.getJSONArray("list");
+                List<String> values = new ArrayList<>();
+                for (int i = 0; i < data.size(); i++) {
+                    JSONObject item = (JSONObject) data.get(i);
+                    String time = item.getString("time");
+                    time = StringUtils.isEmpty(time) ? "00:00" : time.substring(11, 13) + ":00";
+                    String value = item.getString("value");
+                    values.add(value);
+                    dataTime.add(time);
+                }
+                chartData.add(values);
+                log.info("获取物联网采集点24小时数据成功,请求数据:authCode|" + authCode + ",sensorCode|" + sensorCode);
+            }
+        }
+        MapMonHourDataReps reps = new MapMonHourDataReps();
+        /*List<Integer> dataTime = new ArrayList<>();
+        for (int i = 0; i < 24; i++) {
+            dataTime.add(i);
+        }*/
+        MapMonHourDataRep dataRep = new MapMonHourDataRep();
+        dataRep.setData(dataTime);
+        reps.setX(dataRep);
+        reps.setChartData(chartData);
+        responseBase.success().setRetBody(reps);
+        return new ResponseEntity<>(responseBase, HttpStatus.OK);
+    }
+
+    /*
+     * 获取坝区详细信息
+     */
+    @RequestMapping(value = "/findDamInfo", method = RequestMethod.GET)
+    public ResponseEntity<ResponseBase> findDamInfo(@RequestParam(required = false) String damId) {
+        ResponseBase<MapGeogReps> responseBase = new ResponseBase<>();
+        List<MapMerchantRep> list = new ArrayList<>();
+        DamDetailInfoRep damDetailInfoRep = damService.queryById(damId);
+        String address = "";
+        String title = "";
+        if (damDetailInfoRep != null) {
+            MapMerchantRep rep = new MapMerchantRep();
+            rep.setName("海拔(米)");
+            rep.setValue(damDetailInfoRep.getElevation());
+            list.add(rep);
+            rep = new MapMerchantRep();
+            rep.setName("种植面积(亩)");
+            rep.setValue(damDetailInfoRep.getTotalArea());
+            list.add(rep);
+            rep = new MapMerchantRep();
+            rep.setName("主要产品");
+            rep.setValue(damDetailInfoRep.getPlantName());
+            list.add(rep);
+            rep = new MapMerchantRep();
+            rep.setName("耕地产出值(元)");
+            rep.setValue(damDetailInfoRep.getPlantVal());
+            list.add(rep);
+            rep = new MapMerchantRep();
+            rep.setName("土地流转率");
+            rep.setValue(damDetailInfoRep.getLandRate() + "%");
+            list.add(rep);
+            rep = new MapMerchantRep();
+            rep.setName("农民收入贡献率");
+            rep.setValue(damDetailInfoRep.getFarmerRate() + "%");
+            list.add(rep);
+            rep = new MapMerchantRep();
+            rep.setName("产销对接率");
+            rep.setValue(damDetailInfoRep.getMarketRate() + "%");
+            list.add(rep);
+            rep = new MapMerchantRep();
+            rep.setName("产业参保率");
+            rep.setValue(damDetailInfoRep.getInsureRate() + "%");
+            list.add(rep);
+            address = "地址:龙里县" + damDetailInfoRep.getAreaCodeName();
+            title = damDetailInfoRep.getDamName();
+        }
+        MapGeogReps reps = new MapGeogReps(list);
+        reps.setId("");
+        reps.setTitle(title);
+        reps.setIntroduce(address);
+        responseBase.success().setRetBody(reps);
+        return new ResponseEntity<>(responseBase, HttpStatus.OK);
+    }
+
+    /*
+     * 获取坝区简介信息
+     */
+    @RequestMapping(value = "/findDamDesc", method = RequestMethod.GET)
+    public ResponseEntity<ResponseBase> findDamDesc(@RequestParam(required = false) String damId) {
+        ResponseBase<MapDamDescRep> responseBase = new ResponseBase<>();
+        DamDetailInfoRep damDetailInfoRep = damService.queryById(damId);
+        String info = "";
+        if (damDetailInfoRep != null) {
+            info = damDetailInfoRep.getDamDesc();
+        }
+        MapDamDescRep reps = new MapDamDescRep();
+        reps.setId(damId);
+        reps.setInfo(info);
+        responseBase.success().setRetBody(reps);
+        return new ResponseEntity<>(responseBase, HttpStatus.OK);
+    }
+
+    /*
+     * 获取专家列表信息
+     */
+    @RequestMapping(value = "/findDamExpert", method = RequestMethod.GET)
+    public ResponseEntity<ResponseBase> findDamExpert(@RequestParam(required = false) String damId,
+                                                      @RequestParam(required = false) String typeId) {
+        ResponseBase<MapExpertListReps> responseBase = new ResponseBase<>();
+        List<MapExpertListRep> list = expertInfoMapper.selectByDamId(damId, typeId);
+        for (MapExpertListRep item : list) {
+            item.setImgUrl(envProperties.getComFileDownloadUrl() + item.getImgUrl());
+        }
+        MapExpertListReps reps = new MapExpertListReps(list);
+        reps.setId(damId);
+        responseBase.success().setRetBody(reps);
+        return new ResponseEntity<>(responseBase, HttpStatus.OK);
+    }
+
+    /*
+     * 获取园区种植统计信息
+     */
+    @RequestMapping(value = "/findOrchardStatis", method = RequestMethod.GET)
+    public ResponseEntity<ResponseBase> findOrchardStatis(@RequestParam(required = false) String id) {
+        ResponseBase<MapMerchantReps> responseBase = new ResponseBase<>();
+        String[] fieldArrays = {"园区总数", "社员人数(人)", "总种植面积(亩)", "总年产量(公斤)"};
+        List<MapMerchantRep> list = new ArrayList<>();
+        MapOrchardStatisRep statisRep = orchardInfoMapper.selectStatis();
+        if (statisRep != null) {
+            DecimalFormat df = new DecimalFormat("###########0"); //四舍五入转换成整数
+            for (int j = 0; j < fieldArrays.length; j++) {
+                MapMerchantRep rep = new MapMerchantRep();
+                if ("园区总数".equals(fieldArrays[j])) {
+                    rep.setName("园区总数");
+                    rep.setValue(statisRep.getOrchardCount());
+                } else if ("社员人数(人)".equals(fieldArrays[j])) {
+                    rep.setName("社员人数(人)");
+                    rep.setValue(df.format(Double.parseDouble(statisRep.getWorkerCount())));
+                } else if ("总种植面积(亩)".equals(fieldArrays[j])) {
+                    rep.setName("总种植面积(亩)");
+                    rep.setValue(df.format(Double.parseDouble(statisRep.getProdArea())));
+                } else if ("总年产量(公斤)".equals(fieldArrays[j])) {
+                    rep.setName("总年产量(公斤)");
+                    rep.setValue(df.format(Double.parseDouble(statisRep.getProdVol())));
+                }
+                list.add(rep);
+            }
+        }
+        MapMerchantReps reps = new MapMerchantReps(list);
+        reps.setId("");
+        reps.setTitle("竹香米业有限责任公司种植统计");
+        responseBase.success().setRetBody(reps);
+        return new ResponseEntity<>(responseBase, HttpStatus.OK);
+    }
+
+    /*
+     * 获取园区列表
+     */
+    @RequestMapping(value = "/findOrchardAll", method = RequestMethod.GET)
+    public ResponseEntity<ResponseBase> findOrchardAll(@RequestParam(required = false) String name,
+                                                       @RequestParam(required = false) String id,
+                                                       @RequestParam(defaultValue = "1") int pageNo,
+                                                       @RequestParam(defaultValue = "200") int pageSize) {
+        String title = "";
+        ResponseBase<MapDamListReps> responseBase = new ResponseBase<>();
+        OrchardReps orchardReps = orchardService.selectAll(pageNo, pageSize, name, null, null);
+        List<MapDamListRep> list = new ArrayList<>();
+        List<OrchardRep> orchardRep = orchardReps.getList();
+        for (OrchardRep infoRep : orchardRep) {
+            MapDamListRep mapDamRep = new MapDamListRep();
+            mapDamRep.setId(infoRep.getId());
+            //mapDamRep.setAreaId(infoRep.getTownName());
+            mapDamRep.setName(infoRep.getOrchardName());
+            String vol = infoRep.getProductVol();
+            double totalVol = 0.0;
+            if (StringUtils.isNotEmpty(vol)) {
+                String[] vols = vol.split("\\,");
+                for (int i = 0; i < vols.length; i++) {
+                    totalVol = totalVol + Double.parseDouble(vols[i]);
+                }
+            }
+            List<MapPriceValueRep> info = new ArrayList<>();
+            MapPriceValueRep valueRep = new MapPriceValueRep();
+            valueRep.setValue("产量:" + totalVol + "吨");
+            info.add(valueRep);
+            valueRep = new MapPriceValueRep();
+            valueRep.setValue("规模:" + infoRep.getOrchardArea() + "亩");
+            info.add(valueRep);
+            mapDamRep.setUrl("");
+            String border = infoRep.getOrchardBorder();
+            String lon = "";
+            String lat = "";
+            if (StringUtils.isNotEmpty(border)) {
+                JSONArray jsonArray = JSONArray.parseArray(border);
+                for (int i = 0; i < jsonArray.size(); i++) {
+                    JSONObject jsonObject = jsonArray.getJSONObject(i);
+                    String position = jsonObject.getString("position");
+                    if (StringUtils.isNotEmpty(position)) {
+                        JSONObject pos = JSONObject.parseObject(position);
+                        lon = pos.getString("lng");
+                        lat = pos.getString("lat");
+                    }
+                }
+            }
+            List<String> lnglat = new ArrayList<>();
+            lnglat.add(lon);
+            lnglat.add(lat);
+            if(StringUtils.isNotEmpty(lon) && StringUtils.isNotEmpty(lat)){
+                valueRep = new MapPriceValueRep();
+                valueRep.setValue("距公司:" + StringUtils.calcDist(custLat,custLng,Double.parseDouble(lat),Double.parseDouble(lon)) + "km");
+                info.add(valueRep);
+            }
+            mapDamRep.setInfo(info);
+            mapDamRep.setLnglat(lnglat);
+            //mapDamRep.setLegend(1);
+            list.add(mapDamRep);
+        }
+        MapDamListReps mapDamReps = new MapDamListReps(list);
+        mapDamReps.setId("");
+        mapDamReps.setTitle(title);
+        mapDamReps.setTotal((orchardReps == null) ? 0 : orchardReps.getTotal());
+        responseBase.success().setRetBody(mapDamReps);
+        return new ResponseEntity<>(responseBase, HttpStatus.OK);
+    }
+
+    /*
+     * 获取园区详细信息
+     */
+    @RequestMapping(value = "/findOrchardInfo", method = RequestMethod.GET)
+    public ResponseEntity<ResponseBase> findOrchardInfo(@RequestParam(required = false) String id) {
+        ResponseBase<MapGeogReps> responseBase = new ResponseBase<>();
+        List<MapMerchantRep> list = new ArrayList<>();
+        OrchardRep orchardRep = orchardService.selectById(id);
+        String address = "";
+        String title = "";
+        if (orchardRep != null) {
+            MapMerchantRep rep = new MapMerchantRep();
+            rep.setName("坝区面积(亩)");
+            rep.setValue(orchardRep.getOrchardArea());
+            list.add(rep);
+            rep = new MapMerchantRep();
+            rep.setName("园区年产量(吨)");
+            String vol = orchardRep.getProductVol();
+            double totalVol = 0.0;
+            if (StringUtils.isNotEmpty(vol)) {
+                String[] vols = vol.split("\\,");
+                for (int i = 0; i < vols.length; i++) {
+                    totalVol = totalVol + Double.parseDouble(vols[i]);
+                }
+            }
+            rep.setValue(totalVol + "");
+            list.add(rep);
+            rep = new MapMerchantRep();
+            rep.setName("人员数(人)");
+            rep.setValue(orchardRep.getWorkerCount());
+            list.add(rep);
+            rep = new MapMerchantRep();
+            rep.setName("建园日期");
+            rep.setValue(orchardRep.getBeginDate());
+            list.add(rep);
+            rep = new MapMerchantRep();
+            rep.setName("海拔");
+            rep.setValue(orchardRep.getElevation());
+            list.add(rep);
+            rep = new MapMerchantRep();
+            rep.setName("负责人");
+            rep.setValue(orchardRep.getLeaderName());
+            list.add(rep);
+            rep = new MapMerchantRep();
+            rep.setName("联系方式");
+            rep.setValue(orchardRep.getTelNo());
+            list.add(rep);
+            rep = new MapMerchantRep();
+            rep.setName("地址");
+            String provinceName = StringUtils.isEmpty(orchardRep.getProvinceName()) ? "" : orchardRep.getProvinceName();
+            String cityName = StringUtils.isEmpty(orchardRep.getCityName()) ? "" : orchardRep.getCityName();
+            String countyName = StringUtils.isEmpty(orchardRep.getCountyName()) ? "" : orchardRep.getCountyName();
+            rep.setValue(provinceName + cityName + countyName);
+            list.add(rep);
+            title = orchardRep.getOrchardName();
+        }
+        MapGeogReps reps = new MapGeogReps(list);
+        reps.setId("");
+        reps.setTitle(title);
+        reps.setIntroduce(orchardRep == null ? "" : orchardRep.getOrchardDesc());
+        responseBase.success().setRetBody(reps);
+        return new ResponseEntity<>(responseBase, HttpStatus.OK);
+    }
+
+    /*
+     * 获取园区简介信息
+     */
+    @RequestMapping(value = "/findOrchardDesc", method = RequestMethod.GET)
+    public ResponseEntity<ResponseBase> findOrchardDesc(@RequestParam(required = false) String id) {
+        ResponseBase<MapDamDescRep> responseBase = new ResponseBase<>();
+        OrchardRep orchardRep = orchardService.selectById(id);
+        String info = "";
+        if (orchardRep != null) {
+            info = orchardRep.getOrchardDesc();
+        }
+        MapDamDescRep reps = new MapDamDescRep();
+        reps.setId(id);
+        reps.setInfo(info);
+        responseBase.success().setRetBody(reps);
+        return new ResponseEntity<>(responseBase, HttpStatus.OK);
+    }
+
+    /*
+     * 获取园区产出物信息
+     */
+    @RequestMapping(value = "/findOrchardProd", method = RequestMethod.GET)
+    public ResponseEntity<ResponseBase> findOrchardProd(@RequestParam(required = false) String id) {
+        ResponseBase<MapOrchardProdReps> responseBase = new ResponseBase<>();
+        OrchardRep orchardRep = orchardService.selectById(id);
+        List<MapOrchardProdRep> list = new ArrayList<>();
+        if (orchardRep != null) {
+            List<OrchardProduct> products = orchardRep.getProducts();
+            if (products != null) {
+                for (OrchardProduct item : products) {
+                    MapOrchardProdRep prodRep = new MapOrchardProdRep();
+                    prodRep.setInfo("产出物:" + item.getProdName());
+                    double area = (item.getProdArea() == null) ? 0 : Double.parseDouble(item.getProdArea());
+                    double vol = (item.getProdVol() == null) ? 0 : Double.parseDouble(item.getProdVol());
+                    prodRep.setInfo1("产出面积:" + decimalFormat.format(area) + "亩");
+                    prodRep.setInfo2("预估产量:" + decimalFormat.format(vol) + "吨");
+                    list.add(prodRep);
+                }
+            }
+        }
+        MapOrchardProdReps reps = new MapOrchardProdReps();
+        reps.setList(list);
+        responseBase.success().setRetBody(reps);
+        return new ResponseEntity<>(responseBase, HttpStatus.OK);
+    }
+
+    /*
+     * 获取园区地图编辑信息
+     */
+    @RequestMapping(value = "/findOrchardBorder", method = RequestMethod.GET)
+    public ResponseEntity<ResponseBase> findOrchardBorder(@RequestParam(required = false) String id) {
+        ResponseBase<MapDamBorderRep> responseBase = new ResponseBase<>();
+        OrchardRep orchardRep = orchardService.selectById(id);
+        String info = "";
+        if (orchardRep != null) {
+            info = orchardRep.getOrchardBorder();
+        }
+        MapDamBorderRep reps = new MapDamBorderRep();
+        reps.setId(id);
+        reps.setInfo(JSON.parseArray(info));
+        responseBase.success().setRetBody(reps);
+        return new ResponseEntity<>(responseBase, HttpStatus.OK);
+    }
+}
+

+ 564 - 0
src/main/java/com/hywa/map/controller/map/MapDomainController.java

@@ -0,0 +1,564 @@
+package com.hywa.map.controller.map;
+
+import com.hywa.map.common.utils.StringUtils;
+import com.hywa.map.config.EnvProperties;
+import com.hywa.map.config.interceptor.TokenManager;
+import com.hywa.map.dao.mapper.ExpertInfoMapper;
+import com.hywa.map.representation.*;
+import com.hywa.map.service.dict.DictService;
+import com.hywa.map.service.expert.AreaDataService;
+import com.hywa.map.service.expert.DamService;
+import com.hywa.map.service.map.MapModuleDataService;
+import io.swagger.annotations.Api;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+import java.text.DecimalFormat;
+import java.util.*;
+
+/**
+ * t_sys_branch  对应Controller 实现类
+ *
+ * @author hywa
+ * @create by 2018-12-12 10:01:56
+ */
+
+@Slf4j
+@Api(tags = "一张图")
+@RestController
+@RequestMapping("/map")
+public class MapDomainController {
+
+    @Autowired
+    private MapModuleDataService mapModuleDataService;
+    @Autowired
+    private DamService damService;
+    @Autowired
+    EnvProperties envProperties;
+    @Resource
+    private AreaDataService areaDataService;
+    @Autowired
+    private DictService dictService;
+    @Autowired
+    TokenManager tokenManager;
+    @Autowired
+    private ExpertInfoMapper expertInfoMapper;
+    public static String[] areaArrays = {"冠山街道", "龙山镇", "醒狮镇", "谷脚镇", "湾滩河镇", "洗马镇", "龙里县"};
+    public static String[] colorArrays = {"rgba(35, 104, 255, 1)", "rgba(9, 184, 209, 1)", "rgba(94, 139, 171, 1)", "rgba(172, 134, 240, 1)", "rgba(172, 134, 240, 1)",
+            "rgba(0, 139, 139, 1)", "rgba(255, 255, 205, 1)", "rgba(255, 228, 181, 1)", "rgba(112, 128, 144, 1)", "rgba(0, 0, 128, 1)",
+            "rgba(240, 255, 255, 1)", "rgba(230, 230, 250, 1)", "rgba(47, 79, 79, 1)", "rgba(106, 90, 205, 1)", "rgba(69, 139, 116, 1)",
+            "rgba(0, 191, 255, 1)", "rgba(70, 130, 180, 1)", "rgba(0, 0, 255, 1)", "rgba(255, 248, 220, 1)", "rgba(255, 228, 225, 1)",
+            "rgba(107, 142, 35, 1)", "rgba(189, 183, 107, 1)", "rgba(255, 215, 0, 1)", "rgba(238, 201, 0, 1)", "rgba(139, 101, 8, 1)",
+            "rgba(0, 207, 236, 1)", "rgba(135, 206, 255, 1)", "rgba(198, 226, 255, 1)", "rgba(191, 239, 255, 1)", "rgba(180, 205, 205, 1)",
+            "rgba(255, 225, 255, 1)", "rgba(255, 187, 255, 1)"};
+    public static DecimalFormat decimalFormat = new DecimalFormat("###################.###########");
+
+    /*
+     * 获取8大产业信息信息
+     */
+    @RequestMapping(value = "/findDomainName", method = RequestMethod.GET)
+    public ResponseEntity<ResponseBase> findDomainName(@RequestParam(required = false) String name) {
+        ResponseBase<MapDomainNameReps> responseBase = new ResponseBase<>();
+        name = StringUtils.isEmpty(name) ? "龙里县" : name;
+        List<MapDomainNameRep> list = new ArrayList<>();
+        AreaDataRep areaDataRep = areaDataService.queryDisplay(name, "808b87b6e4ff403ca825f955031f6659");
+        if (areaDataRep != null) {
+            AreaDataDetailRep areaDataDetailRep = areaDataService.queryById(areaDataRep.getId());
+            List<Map<String, String>> valList = areaDataDetailRep.getValList();
+            boolean flag1 = false;
+            boolean flag2 = false;
+            boolean flag3 = false;
+            boolean flag4 = false;
+            boolean flag5 = false;
+            boolean flag6 = false;
+            boolean flag7 = false;
+            boolean flag8 = false;
+            boolean flag9 = false;
+            for (Map<String, String> item : valList) {
+                MapDomainNameRep rep = new MapDomainNameRep();
+                if (item.get("fieldVal1").contains("刺梨") && !flag1) {
+                    rep.setIcon("icon-chudian_shuiguo");
+                    rep.setId(item.get("fieldVal1"));
+                    rep.setName(item.get("fieldVal1"));
+                    flag1 = true;
+                } else if (item.get("fieldVal1").contains("蔬菜") && !flag2) {
+                    rep.setIcon("icon-shucai");
+                    rep.setId(item.get("fieldVal1"));
+                    rep.setName(item.get("fieldVal1"));
+                    flag2 = true;
+                } else if (item.get("fieldVal1").contains("水果") && !flag3) {
+                    rep.setIcon("icon-shuiguo");
+                    rep.setId(item.get("fieldVal1"));
+                    rep.setName(item.get("fieldVal1"));
+                    flag3 = true;
+                } else if (item.get("fieldVal1").contains("中药材") && !flag4) {
+                    rep.setIcon("icon-xianzhuanghaicao");
+                    rep.setId(item.get("fieldVal1"));
+                    rep.setName(item.get("fieldVal1"));
+                    flag4 = true;
+                } else if (item.get("fieldVal1").contains("茶叶") && !flag5) {
+                    rep.setIcon("icon-chaye");
+                    rep.setId(item.get("fieldVal1"));
+                    rep.setName(item.get("fieldVal1"));
+                    flag5 = true;
+                } else if (item.get("fieldVal1").contains("油茶") && !flag6) {
+                    rep.setIcon("icon-chahu");
+                    rep.setId(item.get("fieldVal1"));
+                    rep.setName(item.get("fieldVal1"));
+                    flag6 = true;
+                } else if (item.get("fieldVal1").contains("食用菌") && !flag7) {
+                    rep.setIcon("icon--jungulei");
+                    rep.setId(item.get("fieldVal1"));
+                    rep.setName(item.get("fieldVal1"));
+                    flag7 = true;
+                } else if (item.get("fieldVal1").contains("生态畜牧业") && !flag8) {
+                    rep.setIcon("icon-nongmuye");
+                    rep.setId(item.get("fieldVal1"));
+                    rep.setName(item.get("fieldVal1"));
+                    flag8 = true;
+                } else if (item.get("fieldVal1").contains("其他") && !flag9) {
+                    rep.setIcon("icon-other");
+                    rep.setId(item.get("fieldVal1"));
+                    rep.setName(item.get("fieldVal1"));
+                    flag9 = true;
+                }
+                if (StringUtils.isNotEmpty(rep.getIcon())) {
+                    list.add(rep);
+                }
+
+            }
+        }
+        MapDomainNameReps reps = new MapDomainNameReps();
+        reps.setId("");
+        reps.setList(list);
+        responseBase.success().setRetBody(reps);
+        return new ResponseEntity<>(responseBase, HttpStatus.OK);
+    }
+
+    /*
+     * 获取8大产业子类信息
+     */
+    @RequestMapping(value = "/findSubDomainName", method = RequestMethod.GET)
+    public ResponseEntity<ResponseBase> findSubDomainName(@RequestParam(required = false) String name) {
+        ResponseBase<MapDomainNameReps> responseBase = new ResponseBase<>();
+        name = StringUtils.isEmpty(name) ? "刺梨" : name;
+        List<MapDomainNameRep> list = new ArrayList<>();
+        AreaDataRep areaDataRep = areaDataService.queryDisplay("龙里县", "808b87b6e4ff403ca825f955031f6659");
+        if (areaDataRep != null) {
+            AreaDataDetailRep areaDataDetailRep = areaDataService.queryById(areaDataRep.getId());
+            MapDomainNameRep nameRep = new MapDomainNameRep();
+            //nameRep.setIcon("icon-quanbushujumulu");
+            nameRep.setIcon("");
+            nameRep.setId("全部");
+            nameRep.setName("全部");
+            list.add(nameRep);
+            List<Map<String, String>> valList = areaDataDetailRep.getValList();
+            for (int i = 0; i < valList.size(); i++) {
+                MapDomainNameRep rep = new MapDomainNameRep();
+                Map<String, String> item = valList.get(i);
+                String subName = item.get("fieldVal2");
+                if (StringUtils.isNotEmpty(subName) && item.get("fieldVal1").contains(name)) {
+                    //rep.setIcon("icon-moren_fenleiicon");
+                    rep.setIcon("");
+                    rep.setId(subName);
+                    rep.setName(subName);
+                    list.add(rep);
+                }
+            }
+        }
+        MapDomainNameReps reps = new MapDomainNameReps();
+        reps.setId(name);
+        reps.setList(list);
+        responseBase.success().setRetBody(reps);
+        return new ResponseEntity<>(responseBase, HttpStatus.OK);
+    }
+
+    /*
+     * 获取产业现状统计类型列表
+     */
+    @RequestMapping(value = "/findDomainType", method = RequestMethod.GET)
+    public ResponseEntity<ResponseBase> findIndustryType(@RequestParam(required = false) String id,
+                                                         @RequestParam(required = false) String domainName,
+                                                         @RequestParam(required = false) String subDomainName) {
+        ResponseBase<MapIndustryReps> responseBase = new ResponseBase<>();
+        domainName = StringUtils.isEmpty(domainName) ? "刺梨" : domainName;
+        subDomainName = "全部".equals(subDomainName) ? domainName : subDomainName;
+        List<MapIndustryRep> list = new ArrayList<>();
+        String[] fieldArrays = {"种植面积|亩", "产量|吨", "产值|元"};
+        if (domainName.contains("生态畜牧业")) {
+            fieldArrays = new String[]{"养殖场|个", "产量|头", "产值|元"};
+        }
+        id = StringUtils.isEmpty(id) ? "龙里县" : id;
+        for (int i = 0; i < fieldArrays.length; i++) {
+            MapIndustryRep mapIndustryRep = new MapIndustryRep();
+            String name = fieldArrays[i].split("\\|")[0];
+            String unit = fieldArrays[i].split("\\|")[1];
+            mapIndustryRep.setId(i + "");
+            mapIndustryRep.setName(name);
+            mapIndustryRep.setTitle(id + subDomainName + "统计");
+            mapIndustryRep.setUnit("单位:" + unit);
+            list.add(mapIndustryRep);
+        }
+        MapIndustryReps reps = new MapIndustryReps(list);
+        reps.setId("");
+        reps.setList(list);
+        responseBase.success().setRetBody(reps);
+        return new ResponseEntity<>(responseBase, HttpStatus.OK);
+    }
+
+    /*
+     * 获取产业现状统计明细信息
+     */
+    @RequestMapping(value = "/findDomainDetail", method = RequestMethod.GET)
+    public ResponseEntity<ResponseBase> findDomainDetail(@RequestParam(required = false) String id,
+                                                         @RequestParam(required = false) String typeId,
+                                                         @RequestParam(required = false) String domainName,
+                                                         @RequestParam(required = false) String subDomainName) {
+        ResponseBase<MapIndustryDetailReps> responseBase = new ResponseBase<>();
+        String fields = "";
+        boolean isSignal = false;
+        if ("全部".equals(subDomainName)) {
+            ResponseEntity<ResponseBase> baseResponseEntity = findSubDomainName(domainName);
+            ResponseBase base = baseResponseEntity.getBody();
+            MapDomainNameReps mapDomainNameReps = (MapDomainNameReps) base.getRetBody();
+            List<MapDomainNameRep> subName = mapDomainNameReps.getList();
+            for (MapDomainNameRep item : subName) {
+                fields = fields + item.getName() + "|";
+            }
+            fields = fields.substring(0, fields.length() - 1);
+            if ("全部".equals(fields)) {
+                fields = domainName;
+                isSignal = true;
+            } else {
+                fields = fields.substring(3, fields.length());
+            }
+        } else {
+            fields = subDomainName;
+        }
+        String typeName = "";
+        if ("0".equals(typeId)) {
+            typeName = "生态畜牧业".equals(domainName) ? "养殖场" : "种植面积";
+        } else if ("1".equals(typeId)) {
+            typeName = "产量";
+        } else if ("2".equals(typeId)) {
+            typeName = "产值";
+        }
+
+        String[] areaNameArrays = (StringUtils.isEmpty(id) || "龙里县".equals(id)) ? areaArrays : (new String[]{id});
+        id = StringUtils.isEmpty(id) ? "龙里县" : id;
+        String[] fieldArrays = fields.split("\\|");
+        List<MapIndustryDetailRep> list = new ArrayList<>();
+        double cnt1 = 0;
+        List<Map<String, String>> allValList = new ArrayList<>();
+        for (int i = 0; i < areaNameArrays.length; i++) {
+            AreaDataRep areaDataRep = areaDataService.queryShow(areaNameArrays[i], "894bb259e92c439cbeb2177974e27050");
+            if (areaDataRep != null) {
+                AreaDataDetailRep areaDataDetailRep = areaDataService.queryById(areaDataRep.getId());
+                List<Map<String, String>> valList = areaDataDetailRep.getValList();
+                for (Map<String, String> map : valList) {
+                    allValList.add(map);
+                }
+            }
+        }
+        domainName = "蔬菜|水果|中药材|茶叶|油茶|食用菌".indexOf(domainName) >= 0 ? domainName + "产业" : domainName;
+        for (int j = 0; j < fieldArrays.length; j++) {
+            cnt1 = 0;
+            for (Map<String, String> map : allValList) {
+                if (fieldArrays[j].equals(map.get("fieldVal1")) && (domainName.equals(map.get("fieldVal2")) || isSignal) && typeName.equals(map.get("fieldVal3"))) {
+                    cnt1 = cnt1 + Double.parseDouble(map.get("fieldVal4"));
+                    continue;
+                }
+            }
+            MapIndustryDetailRep rep = new MapIndustryDetailRep();
+            rep.setViewName(fieldArrays[j]);
+            rep.setViewVal(decimalFormat.format(cnt1));
+            rep.setId(j + "");
+            list.add(rep);
+        }
+        //20191210 根据需求修改为前10条 start
+        List<MapIndustryDetailRep> topTenList = new ArrayList<>();
+        if (list != null && list.size() > 0) {
+            for (int k = 0; k < list.size(); k++) {
+                if (k < 10) {
+                    topTenList.add(list.get(k));
+                }
+            }
+        }
+        //20191210 根据需求修改为前10条 end
+        MapIndustryDetailReps reps = new MapIndustryDetailReps(topTenList);
+        reps.setId("");
+        responseBase.success().setRetBody(reps);
+        return new ResponseEntity<>(responseBase, HttpStatus.OK);
+    }
+
+    /*
+     * 获取产业现状销售统计明细信息
+     */
+    @RequestMapping(value = "/findDomainSell", method = RequestMethod.GET)
+    public ResponseEntity<ResponseBase> findDomainSell(@RequestParam(required = false) String id,
+                                                       @RequestParam(required = false) String typeId,
+                                                       @RequestParam(required = false) String domainName,
+                                                       @RequestParam(required = false) String subDomainName) {
+        ResponseBase<MapDomainSellReps> responseBase = new ResponseBase<>();
+        String title = "1".equals(typeId) ? "销售渠道" : "销售流向";
+        String fields = "";
+        boolean isSignal = false;
+        if ("全部".equals(subDomainName)) {
+            ResponseEntity<ResponseBase> baseResponseEntity = findSubDomainName(domainName);
+            ResponseBase base = baseResponseEntity.getBody();
+            MapDomainNameReps mapDomainNameReps = (MapDomainNameReps) base.getRetBody();
+            List<MapDomainNameRep> subName = mapDomainNameReps.getList();
+            for (MapDomainNameRep item : subName) {
+                fields = fields + item.getName() + "|";
+            }
+            fields = fields.substring(0, fields.length() - 1);
+            if ("全部".equals(fields)) {
+                fields = domainName;
+                isSignal = true;
+            } else {
+                fields = fields.substring(3, fields.length());
+            }
+        } else {
+            fields = subDomainName;
+        }
+        id = StringUtils.isEmpty(id) ? "龙里县" : id;
+        //String[] areaNameArrays = new String[]{id};
+        String[] areaNameArrays = (StringUtils.isEmpty(id) || "龙里县".equals(id)) ? areaArrays : (new String[]{id});
+        String[] fieldArrays = fields.split("\\|");
+        List<MapDomainSellRep> list = new ArrayList<>();
+        double cnt1 = 0;
+        double cnt2 = 0;
+        List<Map<String, String>> allValList = new ArrayList<>();
+        int areaCount = 0;
+        for (int i = 0; i < areaNameArrays.length; i++) {
+            AreaDataRep areaDataRep = areaDataService.queryShow(areaNameArrays[i], "f7251c484d3c4a4399beca397241f3e6");
+            if (areaDataRep != null) {
+                AreaDataDetailRep areaDataDetailRep = areaDataService.queryById(areaDataRep.getId());
+                List<Map<String, String>> valList = areaDataDetailRep.getValList();
+                for (Map<String, String> map : valList) {
+                    allValList.add(map);
+                }
+                areaCount++;
+            }
+        }
+        domainName = "蔬菜|水果|中药材|茶叶|油茶|食用菌".indexOf(domainName) >= 0 ? domainName + "产业" : domainName;
+        List<Map<String, String>> sellList = new ArrayList<>();
+        List<String> sellAreaList = new ArrayList<>();
+        for (int j = 0; j < fieldArrays.length; j++) {
+            for (Map<String, String> map : allValList) {
+                if ("线上销售占比".equals(map.get("fieldVal3")) && fieldArrays[j].equals(map.get("fieldVal1")) && (domainName.equals(map.get("fieldVal2")) || isSignal)) {
+                    cnt1 = cnt1 + Double.parseDouble(map.get("fieldVal4"));
+                    continue;
+                }
+                if ("线下销售占比".equals(map.get("fieldVal3")) && fieldArrays[j].equals(map.get("fieldVal1")) && (domainName.equals(map.get("fieldVal2")) || isSignal)) {
+                    cnt2 = cnt2 + Double.parseDouble(map.get("fieldVal4"));
+                    continue;
+                }
+                if ("销售流向及占比".equals(map.get("fieldVal3")) && fieldArrays[j].equals(map.get("fieldVal1")) && (domainName.equals(map.get("fieldVal2")) || isSignal)) {
+                    String[] val4s = map.get("fieldVal4").split("\\#");
+                    for (int k = 0; k < val4s.length; k++) {
+                        Map<String, String> valMap = new HashMap<>();
+                        valMap.put(val4s[k].split("\\=")[0], val4s[k].split("\\=")[1]);
+                        sellList.add(valMap);
+                        sellAreaList.add(val4s[k].split("\\=")[0]);
+                    }
+                    continue;
+                }
+            }
+        }
+        String onlineRate = String.format("%.2f", ((cnt1 / fieldArrays.length)) / ((areaCount == 0) ? 1 : areaCount));
+        String offRate = String.format("%.2f", ((cnt2 / fieldArrays.length)) / ((areaCount == 0) ? 1 : areaCount));
+        if ("1".equals(typeId)) {
+            MapDomainSellRep rep = new MapDomainSellRep();
+            rep.setName("线上销售占比");
+            rep.setColor("rgba(35, 104, 255, 1)");
+            rep.setValue(cnt1 == 0 ? "0" : decimalFormat.format(Double.parseDouble(onlineRate)));
+            list.add(rep);
+            rep = new MapDomainSellRep();
+            rep.setName("线下销售占比");
+            rep.setColor("rgba(0, 207, 236, 1)");
+            rep.setValue(cnt2 == 0 ? "0" : decimalFormat.format(Double.parseDouble(offRate)));
+            list.add(rep);
+        } else {
+            //获取销售流向 start
+            allValList.clear();
+            for (int i = 0; i < areaNameArrays.length; i++) {
+                AreaDataRep areaDataRep = areaDataService.queryShow(areaNameArrays[i], "53e14d43e8154507b0ef2231f8a18da5");
+                if (areaDataRep != null) {
+                    AreaDataDetailRep areaDataDetailRep = areaDataService.queryById(areaDataRep.getId());
+                    List<Map<String, String>> valList = areaDataDetailRep.getValList();
+                    for (Map<String, String> map : valList) {
+                        allValList.add(map);
+                    }
+                }
+            }
+            sellList.clear();
+            sellAreaList.clear();
+            for (int j = 0; j < fieldArrays.length; j++) {
+                for (Map<String, String> map : allValList) {
+                    if ("销售流向及占比".equals(map.get("fieldVal3")) && fieldArrays[j].equals(map.get("fieldVal1")) && (domainName.equals(map.get("fieldVal2")) || isSignal) && StringUtils.isNotEmpty(map.get("fieldVal4"))) {
+                        String[] val4s = map.get("fieldVal4").split("\\,");
+                        for (int k = 0; k < val4s.length; k++) {
+                            Map<String, String> valMap = new HashMap<>();
+                            valMap.put(val4s[k].split("\\=")[0], val4s[k].split("\\=")[1]);
+                            sellList.add(valMap);
+                            sellAreaList.add(val4s[k].split("\\=")[0]);
+                        }
+                    }
+                }
+            }
+            //获取销售流向 end
+            HashSet h = new HashSet(sellAreaList);
+            sellAreaList.clear();
+            sellAreaList.addAll(h);
+            for (int m = 0; m < sellAreaList.size(); m++) {
+                String area = sellAreaList.get(m);
+                double cnt = 0;
+                MapDomainSellRep rep = new MapDomainSellRep();
+                for (Map<String, String> item : sellList) {
+                    for (String key : item.keySet()) {
+                        String value = item.get(key);
+                        if (key.equals(area)) {
+                            cnt = cnt + Double.parseDouble(value);
+                        }
+                    }
+                }
+                rep.setName(area);
+                rep.setColor(colorArrays[m]);
+                rep.setValue(decimalFormat.format(cnt));
+                list.add(rep);
+            }
+        }
+        MapDomainSellReps reps = new MapDomainSellReps(list);
+        reps.setId("");
+        reps.setSubtitle(title);
+        responseBase.success().setRetBody(reps);
+        return new ResponseEntity<>(responseBase, HttpStatus.OK);
+    }
+
+    /*
+     * 获取产业现状图列信息
+     */
+    @RequestMapping(value = "/findDomainLegend", method = RequestMethod.GET)
+    public ResponseEntity<ResponseBase> findDomainLegend(@RequestParam(required = false) String id,
+                                                         @RequestParam(required = false) String typeId,
+                                                         @RequestParam(required = false) String domainName,
+                                                         @RequestParam(required = false) String subDomainName) {
+        ResponseBase<MapDomainLegendReps> responseBase = new ResponseBase<>();
+        subDomainName = StringUtils.isEmpty(subDomainName) ? "全部" : subDomainName;
+        String fields = "";
+        boolean isSignal = false;
+        if ("全部".equals(subDomainName)) {
+            ResponseEntity<ResponseBase> baseResponseEntity = findSubDomainName(domainName);
+            ResponseBase base = baseResponseEntity.getBody();
+            MapDomainNameReps mapDomainNameReps = (MapDomainNameReps) base.getRetBody();
+            List<MapDomainNameRep> subName = mapDomainNameReps.getList();
+            for (MapDomainNameRep item : subName) {
+                fields = fields + item.getName() + "|";
+            }
+            fields = fields.substring(0, fields.length() - 1);
+            if ("全部".equals(fields)) {
+                fields = domainName;
+                isSignal = true;
+            } else {
+                fields = fields.substring(3, fields.length());
+            }
+        } else {
+            fields = subDomainName;
+        }
+        String typeName = "";
+        if ("0".equals(typeId)) {
+            typeName = "生态畜牧业".equals(domainName) ? "养殖场" : "种植面积";
+        } else if ("1".equals(typeId)) {
+            typeName = "产量";
+        } else if ("2".equals(typeId)) {
+            typeName = "产值";
+        }
+
+        String[] areaNameArrays = (StringUtils.isEmpty(id) || "龙里县".equals(id)) ? areaArrays : (new String[]{id});
+        id = StringUtils.isEmpty(id) ? "龙里县" : id;
+        String[] fieldArrays = fields.split("\\|");
+        List<MapIndustryDetailRep> list = new ArrayList<>();
+        double cnt1 = 0;
+        List<Map<String, String>> allValList = new ArrayList<>();
+        List<MapDomainCoverRep> covers = new ArrayList<>();
+
+        domainName = "蔬菜|水果|中药材|茶叶|油茶|食用菌".indexOf(domainName) >= 0 ? domainName + "产业" : domainName;
+        for (int i = 0; i < areaNameArrays.length; i++) {
+            list.clear();
+            AreaDataRep areaDataRep = areaDataService.queryShow(areaNameArrays[i], "894bb259e92c439cbeb2177974e27050");
+            if (areaDataRep != null) {
+                AreaDataDetailRep areaDataDetailRep = areaDataService.queryById(areaDataRep.getId());
+                List<Map<String, String>> valList = areaDataDetailRep.getValList();
+                for (int j = 0; j < fieldArrays.length; j++) {
+                    cnt1 = 0;
+                    for (Map<String, String> map : valList) {
+                        if (fieldArrays[j].equals(map.get("fieldVal1")) && (domainName.equals(map.get("fieldVal2")) || isSignal) && typeName.equals(map.get("fieldVal3"))) {
+                            cnt1 = cnt1 + Double.parseDouble(map.get("fieldVal4"));
+                            continue;
+                        }
+                    }
+                    MapIndustryDetailRep rep = new MapIndustryDetailRep();
+                    rep.setViewName(fieldArrays[j]);
+                    rep.setViewVal(cnt1 + "");
+                    rep.setId(j + "");
+                    list.add(rep);
+                }
+                MapDomainCoverRep coverRep = new MapDomainCoverRep();
+                double value = 0;
+                for (MapIndustryDetailRep item : list) {
+                    value = value + Double.parseDouble(item.getViewVal());
+                }
+                coverRep.setValue((decimalFormat.format(value)) + ("生态畜牧业".equals(domainName) ? "个" : "亩"));
+                coverRep.setId("");
+                coverRep.setType("Marker");
+                coverRep.setLegend("1");
+                MapDomainPosRep posRep = new MapDomainPosRep();
+                posRep.setLat(areaDataRep.getPosLat());
+                posRep.setLng(areaDataRep.getPosLon());
+                posRep.setP(areaDataRep.getPosLat());
+                posRep.setQ(areaDataRep.getPosLon());
+                coverRep.setPosition(posRep);
+                MapDomainStyleRep styleRep = new MapDomainStyleRep();
+                styleRep.setFillColor("#9C427E");
+                styleRep.setStrokeColor("#9C427E");
+                coverRep.setStyle(styleRep);
+                covers.add(coverRep);
+            }
+        }
+        MapDomainLegendReps reps = new MapDomainLegendReps();
+        reps.setId("");
+        reps.set_caveat("提示:目前地图配置使用高德地图API。(图例内容:图标、图片地址、文字)");
+        reps.setAmapkey("");
+        MapDomainMapRep mapRep = new MapDomainMapRep();
+        mapRep.setMapStyle("");
+        mapRep.setZoom(10);
+        List<Double> center = new ArrayList<>();
+        center.add(106.979524);
+        center.add(26.453154);
+        mapRep.setCenter(center);
+        reps.setMap(mapRep);
+        List<MapDomainLegendRep> legend = new ArrayList<>();
+        MapDomainLegendRep legendRep = new MapDomainLegendRep();
+        legendRep.setColor("#9C427E");
+        String name = "全部".equals(subDomainName) ? domainName : subDomainName;
+        String title = "生态畜牧业".equals(domainName) ? "养殖场分布(个)" : "种植面积分布(亩)";
+        legendRep.setName(name + title);
+        legendRep.setIcon("");
+        legend.add(legendRep);
+        reps.setLegend(legend);
+        //统计各乡镇信息
+
+        reps.setCovers(covers);
+        responseBase.success().setRetBody(reps);
+        return new ResponseEntity<>(responseBase, HttpStatus.OK);
+    }
+}
+

+ 0 - 0
src/main/java/com/hywa/map/controller/map/MapPwdController.java


Beberapa file tidak ditampilkan karena terlalu banyak file yang berubah dalam diff ini