瀏覽代碼

项目迁移

zhang-kan-kan 2 年之前
當前提交
35c3579d0d
共有 44 個文件被更改,包括 5262 次插入0 次删除
  1. 37 0
      .gitignore
  2. 299 0
      pom.xml
  3. 19 0
      src/main/java/com/muzhi/zgd/ZGDApplication.java
  4. 42 0
      src/main/java/com/muzhi/zgd/controller/AccessTokenController.java
  5. 56 0
      src/main/java/com/muzhi/zgd/controller/EmployeeController.java
  6. 28 0
      src/main/java/com/muzhi/zgd/controller/LianJieQiController.java
  7. 64 0
      src/main/java/com/muzhi/zgd/controller/ZGDjiaozhigongController.java
  8. 22 0
      src/main/java/com/muzhi/zgd/entity/Bumen.java
  9. 181 0
      src/main/java/com/muzhi/zgd/entity/Employee.java
  10. 73 0
      src/main/java/com/muzhi/zgd/entity/Jiaozhigong.java
  11. 16 0
      src/main/java/com/muzhi/zgd/entity/vo/BumenVo.java
  12. 14 0
      src/main/java/com/muzhi/zgd/entity/vo/EmployeeDataVo.java
  13. 17 0
      src/main/java/com/muzhi/zgd/entity/vo/EmployeeQuery.java
  14. 176 0
      src/main/java/com/muzhi/zgd/entity/vo/EmployeeVo.java
  15. 35 0
      src/main/java/com/muzhi/zgd/exception/HttpResponseException.java
  16. 41 0
      src/main/java/com/muzhi/zgd/handler/JSONResponseHandler.java
  17. 32 0
      src/main/java/com/muzhi/zgd/handler/PlainTextResponseHandler.java
  18. 26 0
      src/main/java/com/muzhi/zgd/handler/ResponseHandler.java
  19. 99 0
      src/main/java/com/muzhi/zgd/http/ApiHttpClientUtils.java
  20. 27 0
      src/main/java/com/muzhi/zgd/http/ContentType.java
  21. 304 0
      src/main/java/com/muzhi/zgd/http/HttpConnectionUtils.java
  22. 183 0
      src/main/java/com/muzhi/zgd/http/HttpHeaders.java
  23. 175 0
      src/main/java/com/muzhi/zgd/http/HttpIOUtils.java
  24. 123 0
      src/main/java/com/muzhi/zgd/http/HttpStatus.java
  25. 11 0
      src/main/java/com/muzhi/zgd/mapper/BumenMapper.java
  26. 11 0
      src/main/java/com/muzhi/zgd/mapper/EmployeeMapper.java
  27. 12 0
      src/main/java/com/muzhi/zgd/mapper/JiaozhigongMapper.java
  28. 5 0
      src/main/java/com/muzhi/zgd/mapper/xml/BumenMapper.xml
  29. 5 0
      src/main/java/com/muzhi/zgd/mapper/xml/EmployeeMapper.xml
  30. 5 0
      src/main/java/com/muzhi/zgd/mapper/xml/JiaozhigongMapper.xml
  31. 54 0
      src/main/java/com/muzhi/zgd/oauth2/ApiClientConfig.java
  32. 85 0
      src/main/java/com/muzhi/zgd/oauth2/ApiToken.java
  33. 14 0
      src/main/java/com/muzhi/zgd/service/DingAccessTokenService.java
  34. 19 0
      src/main/java/com/muzhi/zgd/service/EmployeeService.java
  35. 13 0
      src/main/java/com/muzhi/zgd/service/LianJieQiService.java
  36. 20 0
      src/main/java/com/muzhi/zgd/service/ZGDjiaozhigongService.java
  37. 72 0
      src/main/java/com/muzhi/zgd/service/impl/DingAccessTokenServiceImpl.java
  38. 191 0
      src/main/java/com/muzhi/zgd/service/impl/EmployeeServiceImpl.java
  39. 39 0
      src/main/java/com/muzhi/zgd/service/impl/LianJieQiServiceImpl.java
  40. 2227 0
      src/main/java/com/muzhi/zgd/service/impl/ZGDjiaozhigongServiceImpl.java
  41. 50 0
      src/main/resources/application.properties
  42. 313 0
      src/test/java/com/muzhi/zgd/APITest/ApiHttpClientTest.java
  43. 14 0
      src/test/java/com/muzhi/zgd/APITest/Test1.java
  44. 13 0
      src/test/java/com/muzhi/zgd/TestApplicationTests.java

+ 37 - 0
.gitignore

@@ -0,0 +1,37 @@
+# IntelliJ project files
+.idea
+*.iml
+out
+gen
+### Java template
+# Compiled class file
+*.class
+
+# Log file
+*.log
+/log/
+
+# BlueJ files
+*.ctxt
+
+# Mobile Tools for Java (J2ME)
+.mtj.tmp/
+
+# Package Files #
+*.jar
+*.war
+*.nar
+*.ear
+*.zip
+*.tar.gz
+*.rar
+
+# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
+hs_err_pid*
+
+mvnw
+mvnw.cmd
+
+# tmp file
+.tmp
+/tmp/

+ 299 - 0
pom.xml

@@ -0,0 +1,299 @@
+<?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>
+    <parent>
+        <groupId>org.springframework.boot</groupId>
+        <artifactId>spring-boot-starter-parent</artifactId>
+        <version>2.3.3.RELEASE</version>
+        <relativePath/> <!-- lookup parent from repository -->
+    </parent>
+    <groupId>com.muzhi.nuodingshan</groupId>
+    <artifactId>nuodingshan</artifactId>
+    <packaging>jar</packaging>
+    <version>1.0-SNAPSHOT</version>
+
+    <properties>
+        <java.version>1.8</java.version>
+        <fastjson.version>1.2.33</fastjson.version>
+        <gson.version>2.8.2</gson.version>
+        <json.version>20170516</json.version>
+        <poi.version>3.17</poi.version>
+        <jodatime.version>2.10.1</jodatime.version>
+        <swagger.version>2.7.0</swagger.version>
+        <commons-fileupload.version>1.3.1</commons-fileupload.version>
+        <!--        <thymeleaf.version>3.0.2.RELEASE</thymeleaf.version>-->
+        <!-- 布局功能的支持程序 thymeleaf3主程序 layout2以上版本-->
+        <!--        <thymeleaf-layout-dialect.version>2.1.1</thymeleaf-layout-dialect.version>-->
+    </properties>
+
+    <repositories>
+        <repository>
+            <id>sonatype-nexus-staging</id>
+            <name>Sonatype Nexus Staging</name>
+            <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
+            <releases>
+                <enabled>true</enabled>
+            </releases>
+            <snapshots>
+                <enabled>true</enabled>
+            </snapshots>
+        </repository>
+    </repositories>
+
+    <dependencies>
+        <!-- httpClient -->
+        <dependency>
+            <groupId>org.apache.httpcomponents</groupId>
+            <artifactId>httpclient</artifactId>
+            <version>4.5.2</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.httpcomponents</groupId>
+            <artifactId>httpcore</artifactId>
+            <version>4.4.13</version>
+        </dependency>
+
+        <dependency>
+            <groupId>commons-httpclient</groupId>
+            <artifactId>commons-httpclient</artifactId>
+            <version>3.1</version>
+        </dependency>
+
+<!--        <dependency>-->
+<!--            <groupId>org.slf4j</groupId>-->
+<!--            <artifactId>slf4j-api</artifactId>-->
+<!--        </dependency>-->
+
+<!--        <dependency>-->
+<!--            <groupId>commons-io</groupId>-->
+<!--            <artifactId>commons-io</artifactId>-->
+<!--        </dependency>-->
+
+        <!--json 组件 -->
+<!--        <dependency>-->
+<!--            <groupId>com.alibaba</groupId>-->
+<!--            <artifactId>fastjson</artifactId>-->
+<!--            <scope>provided</scope>-->
+<!--        </dependency>-->
+
+        <!--        <dependency>-->
+        <!--            <groupId>org.apache.cxf</groupId>-->
+        <!--            <artifactId>cxf-spring-boot-starter-jaxws</artifactId>-->
+        <!--            <version>3.3.1</version>-->
+        <!--        </dependency>-->
+
+        <!--        <dependency>-->
+        <!--            <groupId>org.springframework.boot</groupId>-->
+        <!--            <artifactId>spring-boot-starter-thymeleaf</artifactId>-->
+        <!--&lt;!&ndash;            <version>2.3.3.RELEASE</version>&ndash;&gt;-->
+        <!--        </dependency>-->
+
+        <!--钉钉相关-->
+        <dependency>
+            <groupId>com.aliyun</groupId>
+            <artifactId>alibaba-dingtalk-service-sdk</artifactId>
+            <version>1.0.1</version>
+        </dependency>
+
+        <!--json相关-->
+        <dependency>
+            <groupId>com.alibaba</groupId>
+            <artifactId>fastjson</artifactId>
+            <version>${fastjson.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.json</groupId>
+            <artifactId>json</artifactId>
+            <version>${json.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>com.google.code.gson</groupId>
+            <artifactId>gson</artifactId>
+            <version>${gson.version}</version>
+        </dependency>
+
+        <!--        <dependency>-->
+        <!--            <groupId>net.sf.json-lib</groupId>-->
+        <!--            <artifactId>json-lib</artifactId>-->
+        <!--            <version>2.4</version>-->
+        <!--        </dependency>-->
+
+
+        <!-- JSONObject对象依赖的jar包 -->
+        <dependency>
+            <groupId>commons-beanutils</groupId>
+            <artifactId>commons-beanutils</artifactId>
+            <version>1.9.3</version>
+        </dependency>
+        <dependency>
+            <groupId>commons-collections</groupId>
+            <artifactId>commons-collections</artifactId>
+            <version>3.2.1</version>
+        </dependency>
+        <dependency>
+            <groupId>commons-lang</groupId>
+            <artifactId>commons-lang</artifactId>
+            <version>2.6</version>
+        </dependency>
+        <dependency>
+            <groupId>commons-logging</groupId>
+            <artifactId>commons-logging</artifactId>
+            <version>1.1.1</version>
+        </dependency>
+        <dependency>
+            <groupId>net.sf.ezmorph</groupId>
+            <artifactId>ezmorph</artifactId>
+            <version>1.0.6</version>
+        </dependency>
+        <dependency>
+            <groupId>net.sf.json-lib</groupId>
+            <artifactId>json-lib</artifactId>
+            <version>2.2.3</version>
+            <classifier>jdk15</classifier><!-- 指定jdk版本 -->
+        </dependency>
+
+
+        <!--xls-->
+        <dependency>
+            <groupId>org.apache.poi</groupId>
+            <artifactId>poi</artifactId>
+            <version>${poi.version}</version>
+        </dependency>
+        <!--xlsx-->
+        <dependency>
+            <groupId>org.apache.poi</groupId>
+            <artifactId>poi-ooxml</artifactId>
+            <version>${poi.version}</version>
+        </dependency>
+        <!--文件上传-->
+        <dependency>
+            <groupId>commons-fileupload</groupId>
+            <artifactId>commons-fileupload</artifactId>
+            <version>${commons-fileupload.version}</version>
+        </dependency>
+
+        <!--        <dependency>-->
+        <!--            <groupId>org.springframework.boot</groupId>-->
+        <!--            <artifactId>spring-boot-starter-thymeleaf</artifactId>-->
+        <!--        </dependency>-->
+
+        <!--引入web模块-->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-web</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-devtools</artifactId>
+            <version>2.3.3.RELEASE</version>
+        </dependency>
+        <dependency>
+            <groupId>org.projectlombok</groupId>
+            <artifactId>lombok</artifactId>
+            <optional>true</optional>
+            <version>1.18.10</version>
+        </dependency>
+
+        <!--mybatis-plus数据库连接-->
+        <dependency>
+            <groupId>com.baomidou</groupId>
+            <artifactId>mybatis-plus-boot-starter</artifactId>
+            <version>3.2.0</version>
+        </dependency>
+        <!--引入mysql:数据库驱动-->
+        <dependency>
+            <groupId>mysql</groupId>
+            <artifactId>mysql-connector-java</artifactId>
+            <scope>runtime</scope>
+        </dependency>
+        <!--引入druid数据源-->
+        <!-- https://mvnrepository.com/artifact/com.alibaba/druid -->
+        <dependency>
+            <groupId>com.alibaba</groupId>
+            <artifactId>druid</artifactId>
+            <version>1.1.9</version>
+        </dependency>
+        <dependency>
+            <groupId>com.alibaba</groupId>
+            <artifactId>druid-spring-boot-starter</artifactId>
+            <version>1.1.9</version>
+        </dependency>
+
+        <!--引入jpa模块-->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-data-jpa</artifactId>
+        </dependency>
+
+        <!--日期时间工具-->
+        <dependency>
+            <groupId>joda-time</groupId>
+            <artifactId>joda-time</artifactId>
+            <version>${jodatime.version}</version>
+        </dependency>
+
+        <!--log4j-->
+        <dependency>
+            <groupId>log4j</groupId>
+            <artifactId>log4j</artifactId>
+            <version>1.2.17</version>
+        </dependency>
+
+        <!--swagger-->
+        <dependency>
+            <groupId>io.springfox</groupId>
+            <artifactId>springfox-swagger2</artifactId>
+            <version>${swagger.version}</version>
+        </dependency>
+        <!--swagger ui-->
+        <dependency>
+            <groupId>io.springfox</groupId>
+            <artifactId>springfox-swagger-ui</artifactId>
+            <version>${swagger.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-test</artifactId>
+            <scope>test</scope>
+            <exclusions>
+                <exclusion>
+                    <groupId>org.junit.vintage</groupId>
+                    <artifactId>junit-vintage-engine</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-maven-plugin</artifactId>
+                <configuration>
+                    <fork>true</fork>
+                </configuration>
+            </plugin>
+        </plugins>
+
+        <!--映射mapper中对应的xml配置文件,如果没有mapper.xml文件则将下列注释-->
+        <resources>
+            <resource>
+                <directory>src/main/java</directory>
+                <includes>
+                    <include>**/*.xml</include>
+
+                    <include>**/*.properties</include>
+                    <include>**/*.tld</include>
+                    <include>**/*.xls</include>
+                    <include>**/*.xlsx</include>
+                </includes>
+                <filtering>false</filtering>
+            </resource>
+        </resources>
+    </build>
+
+</project>

+ 19 - 0
src/main/java/com/muzhi/zgd/ZGDApplication.java

@@ -0,0 +1,19 @@
+package com.muzhi.zgd;
+
+import org.mybatis.spring.annotation.MapperScan;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.scheduling.annotation.EnableScheduling;
+
+
+@MapperScan("com.muzhi.zgd.mapper")
+@SpringBootApplication
+@EnableScheduling//开启定时任务
+//@ComponentScan(basePackages = {"com.muzhi"})
+public class ZGDApplication {
+
+    public static void main(String[] args) {
+        SpringApplication.run(ZGDApplication.class, args);
+    }
+
+}

+ 42 - 0
src/main/java/com/muzhi/zgd/controller/AccessTokenController.java

@@ -0,0 +1,42 @@
+package com.muzhi.zgd.controller;
+
+import com.muzhi.zgd.service.DingAccessTokenService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * @Author ZhangKan
+ * @Data 15:03
+ */
+
+@Api(description = "钉钉授权AccessToken")
+@RestController
+@RequestMapping("/dingservice")
+public class AccessTokenController {
+
+    @Autowired
+    private DingAccessTokenService dingAccessTokenService;
+
+    //获取钉钉中的access_token(浙工大)
+    @ApiOperation(value = "获取钉钉中的access_token")
+    @GetMapping("getAccessToken")
+    public String getAccessToken(){
+
+        String accessToken = dingAccessTokenService.getAccessToken();
+        return accessToken;
+    }
+
+    //获取钉钉中的access_token(牧之测试架构3)
+    @ApiOperation(value = "获取钉钉中的access_token")
+    @GetMapping("getMuZhiAccessToken")
+    public String getMuZhiAccessToken(){
+
+        String muZhiAccessToken = dingAccessTokenService.getMuZhiAccessToken();
+        return muZhiAccessToken;
+    }
+}

+ 56 - 0
src/main/java/com/muzhi/zgd/controller/EmployeeController.java

@@ -0,0 +1,56 @@
+package com.muzhi.zgd.controller;
+
+
+import com.muzhi.zgd.entity.vo.EmployeeDataVo;
+import com.muzhi.zgd.entity.vo.EmployeeQuery;
+import com.muzhi.zgd.service.EmployeeService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+
+@Api(description = "钉钉花名册")
+@RestController
+//produces = {"application/json;charset=UTF-8"}为了解决后端返回json数据给前端显示乱码问题(中文问号?)
+@RequestMapping(value = "/employeeservice/employee", produces = {"application/json;charset=UTF-8"})
+public class EmployeeController {
+
+    @Autowired
+    private EmployeeService employeeService;
+
+    //获取公司在职员工id列表(已去除",[])
+    @ApiOperation(value = "获取公司在职员工id列表(已去除\",[])")
+    @GetMapping("getEmployeeId")
+    public String getEmployeeId(){
+
+        String employeeId = employeeService.getEmployeeId();
+        return employeeId;
+    }
+
+    //查询钉钉接口中的花名册信息
+    @ApiOperation(value = "查询钉钉接口中的花名册信息")
+    @GetMapping("getDingHuamingce")
+    public String getDingHuamingce(){
+
+        String dingHuamingce = employeeService.getDingHuamingce();
+        return dingHuamingce;
+    }
+
+    //获取数据库中员工花名册employee实体类表数据并放入vo对象进行前端接口调用展示数据
+    @ApiOperation(value = "获取员工花名册字段信息")
+    @GetMapping("getHuamingce")
+    public EmployeeDataVo getHuamingce(Integer page, Integer limit,
+                                       EmployeeQuery employeeQuery){
+
+//        @RequestBody是使用json传递数据,把json数据封装到对应的对象里面,注意:需要用Post提交方式,Get取不到值
+//        (required = false)表示参数值可以为空
+//        @ApiParam(name = "teacherQuery", value = "自定义讲师查询条件", required = true)
+//        @RequestBody(required = false) EmployeeQuery employeeVoQuery
+
+        EmployeeDataVo huamingce = employeeService.getHuamingce(page,limit,employeeQuery);
+        return huamingce;
+    }
+}

+ 28 - 0
src/main/java/com/muzhi/zgd/controller/LianJieQiController.java

@@ -0,0 +1,28 @@
+package com.muzhi.zgd.controller;
+
+import com.muzhi.zgd.service.LianJieQiService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+
+@Api(description = "连接器测试")
+@RestController
+@RequestMapping("/lianjieqiservice")
+@CrossOrigin//解决跨域问题
+public class LianJieQiController {
+
+    @Autowired
+    private LianJieQiService lianJieQiService;
+
+    //获取宜搭表单返回的表单id,然后通过id获取表单其他数据进行业务处理
+    @ApiOperation(value = "获取宜搭表单返回的表单id,然后通过id获取表单其他数据进行业务处理")
+    @PostMapping("getSPid")
+    public String getSPid(String id){
+
+        String SPid = lianJieQiService.getSPid(id);
+
+        return SPid;
+    }
+}

+ 64 - 0
src/main/java/com/muzhi/zgd/controller/ZGDjiaozhigongController.java

@@ -0,0 +1,64 @@
+package com.muzhi.zgd.controller;
+
+import com.muzhi.zgd.service.ZGDjiaozhigongService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * @Author ZhangKan
+ * @Data 15:03
+ */
+
+@Api(description = "浙工大教职工接口")
+@RestController
+@RequestMapping("/zgdservice")
+public class ZGDjiaozhigongController {
+
+    @Autowired
+    private ZGDjiaozhigongService zgDjiaozhigongService;
+
+    //获取浙工大教职工信息
+    /*
+    姓名,部门,手机号,工号,职称,性别,党政职务,职称等级,校内管理岗聘任岗位,党政职务级别,行政职级,技术职称,专业技术岗等级
+     */
+    @ApiOperation(value = "获取浙工大教职工信息")
+    @GetMapping("getJiaozhigong")
+    public String getJiaozhigong() throws Exception{
+
+        String jiaozhigong = zgDjiaozhigongService.getJiaozhigong();
+        return jiaozhigong;
+    }
+
+
+    //向牧之测试架构4同步测试人员数据【主要用于测试浙工大需求:抓取浙工大教职工数据创建到钉钉中,并同时修改更新每个人员的其他字段信息】
+    @ApiOperation(value = "测试同步浙工大教职工信息")
+    @PostMapping("addJiaozhigong")
+    public String addJiaozhigong(){
+
+        String result = zgDjiaozhigongService.addJiaozhigong();
+        return result;
+    }
+
+    //向浙工大架构同步教职工人员数据【主要用于浙工大需求:抓取浙工大教职工数据创建到钉钉中,并同时修改更新每个人员的其他字段信息】
+    @ApiOperation(value = "同步浙工大教职工信息")
+    @PostMapping("addJiaozhigongZGD")
+    public String addJiaozhigongZGD() throws Exception{
+
+        String result = zgDjiaozhigongService.addJiaozhigongZGD();
+        return result;
+    }
+
+    //浙工大教职工数据同步至本地数据库
+    @ApiOperation(value = "同步浙工大教职工信息")
+    @PostMapping("addJiaozhigongToBD")
+    public String addJiaozhigongToBD() throws Exception{
+
+        String s = zgDjiaozhigongService.addJiaozhigongToBD();
+        return s;
+    }
+}

+ 22 - 0
src/main/java/com/muzhi/zgd/entity/Bumen.java

@@ -0,0 +1,22 @@
+package com.muzhi.zgd.entity;
+
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+
+@Data
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value = "Bumen教职工部门列表", description = "教职工部门")
+public class Bumen {
+
+    @ApiModelProperty(value = "部门id")
+    private String bmid;
+
+    @ApiModelProperty(value = "部门")
+    private String bmmc;
+}

+ 181 - 0
src/main/java/com/muzhi/zgd/entity/Employee.java

@@ -0,0 +1,181 @@
+package com.muzhi.zgd.entity;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+import java.util.Date;
+
+@Data
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value = "Employee员工花名册对象", description = "员工花名册")
+public class Employee {
+
+    @ApiModelProperty(value = "员工ID")
+    private String id;
+
+    @ApiModelProperty(value = "姓名")
+    private String sys00Name;
+
+    @ApiModelProperty(value = "邮箱")
+    private String sys00Email;
+
+    @ApiModelProperty(value = "部门id")
+    private String sys00DeptIds;
+
+    @ApiModelProperty(value = "部门")
+    private String sys00Dept;
+
+    @ApiModelProperty(value = "主部门id")
+    private String sys00MainDeptId;
+
+    @ApiModelProperty(value = "主部门")
+    private String sys00MainDept;
+
+    @ApiModelProperty(value = "职位")
+    private String sys00Position;
+
+    @ApiModelProperty(value = "手机号")
+    private String sys00Mobile;
+
+    @ApiModelProperty(value = "工号")
+    private String sys00JobNumber;
+
+    @ApiModelProperty(value = "分机号")
+    private String sys00Tel;
+
+    @ApiModelProperty(value = "办公地点")
+    private String sys00WorkPlace;
+
+    @ApiModelProperty(value = "备注")
+    private String sys00Remark;
+
+    @ApiModelProperty(value = "入职时间")
+    private Date sys00ConfirmJoinTime;
+
+    @ApiModelProperty(value = "员工类型")
+    private Integer sys01EmployeeType;
+
+    @ApiModelProperty(value = "员工状态")
+    private Integer sys01EmployeeStatus;
+
+    @ApiModelProperty(value = "试用期")
+    private String sys01ProbationPeriodType;
+
+    @ApiModelProperty(value = "转正日期")
+    private Date sys01RegularTime;
+
+    @ApiModelProperty(value = "岗位职级")
+    private String sys01PositionLevel;
+
+    @ApiModelProperty(value = "身份证姓名")
+    private String sys02RealName;
+
+    @ApiModelProperty(value = "证件号码")
+    private String sys02CertNo;
+
+    @ApiModelProperty(value = "出生日期")
+    private Date sys02BirthTime;
+
+    @ApiModelProperty(value = "性别(0:男;1:女)")
+    private Integer sys02SexType;
+
+    @ApiModelProperty(value = "民族")
+    private String sys02NationType;
+
+    @ApiModelProperty(value = "身份证地址")
+    private String sys02CertAddress;
+
+    @ApiModelProperty(value = "证件有效期")
+    private Date sys02CertEndTime;
+
+    @ApiModelProperty(value = "婚姻状况")
+    private String sys02Marriage;
+
+    @ApiModelProperty(value = "首次参加工作时间")
+    private Date sys02JoinWorkingTime;
+
+    @ApiModelProperty(value = "户籍类型")
+    private Integer sys02ResidenceType;
+
+    @ApiModelProperty(value = "住址")
+    private String sys02Address;
+
+    @ApiModelProperty(value = "政治面貌")
+    private Integer sys02PoliticalStatus;
+
+    @ApiModelProperty(value = "个人社保账号")
+    private String sys09PersonalSi;
+
+    @ApiModelProperty(value = "个人公积金账号")
+    private String sys09PersonalHf;
+
+    @ApiModelProperty(value = "最高学历")
+    private String sys03HighestEdu;
+
+    @ApiModelProperty(value = "毕业院校")
+    private String sys03GraduateSchool;
+
+    @ApiModelProperty(value = "毕业时间")
+    private Date sys03GraduationTime;
+
+    @ApiModelProperty(value = "所学专业")
+    private String sys03Major;
+
+    @ApiModelProperty(value = "银行卡号")
+    private String sys04BankAccountNo;
+
+    @ApiModelProperty(value = "开户行")
+    private String sys04AccountBank;
+
+    @ApiModelProperty(value = "合同公司")
+    private String sys05ContractCompanyName;
+
+    @ApiModelProperty(value = "合同类型")
+    private Integer sys05ContractType;
+
+    @ApiModelProperty(value = "首次合同起始日")
+    private Date sys05FirstContractStartTime;
+
+    @ApiModelProperty(value = "首次合同到期日")
+    private Date sys05FirstContractEndTime;
+
+    @ApiModelProperty(value = "现合同起始日")
+    private Date sys05NowContractStartTime;
+
+    @ApiModelProperty(value = "现合同到期日")
+    private Date sys05NowContractEndTime;
+
+    @ApiModelProperty(value = "合同期限")
+    private String sys05ContractPeriodType;
+
+    @ApiModelProperty(value = "续签次数")
+    private Integer sys05ContractRenewCount;
+
+    @ApiModelProperty(value = "紧急联系人姓名")
+    private String sys06UrgentContactsName;
+
+    @ApiModelProperty(value = "联系人关系")
+    private String sys06UrgentContactsRelation;
+
+    @ApiModelProperty(value = "联系人电话")
+    private String sys06UrgentContactsPhone;
+
+    @ApiModelProperty(value = "有无子女")
+    private String sys07HaveChild;
+
+    @ApiModelProperty(value = "子女姓名")
+    private String sys07ChildName;
+
+    @ApiModelProperty(value = "子女性别")
+    private Integer sys07ChildSex;
+
+    @ApiModelProperty(value = "子女出生日期")
+    private Date sys07ChildBirthDate;
+
+    @ApiModelProperty(value = "自定义字段")
+    private String customField;
+}

+ 73 - 0
src/main/java/com/muzhi/zgd/entity/Jiaozhigong.java

@@ -0,0 +1,73 @@
+package com.muzhi.zgd.entity;
+
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+
+@Data
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value = "Bumen教职工部门列表", description = "教职工部门")
+public class Jiaozhigong {
+
+    @ApiModelProperty(value = "姓名")
+    private String xm;
+
+    @ApiModelProperty(value = "手机号")
+    private String sjhm;
+
+    @ApiModelProperty(value = "工号")
+    private String gh;
+
+    @ApiModelProperty(value = "性别")
+    private String xb;
+
+    @ApiModelProperty(value = "部门名称")
+    private String bmmc;
+
+    @ApiModelProperty(value = "职称")
+    private String zc;
+
+    @ApiModelProperty(value = "职称等级")
+    private String zcdj;
+
+    @ApiModelProperty(value = "职称等级名称")
+    private String zcdjmc;
+
+    @ApiModelProperty(value = "党政职务等级")
+    private String dzzwjb;
+
+    @ApiModelProperty(value = "党政职务名称")
+    private String dzzwmc;
+
+    @ApiModelProperty(value = "党政职务级别名称")
+    private String dzzwjbmc;
+
+    @ApiModelProperty(value = "行政职级等级")
+    private String xzzj;
+
+    @ApiModelProperty(value = "行政职级名称")
+    private String xzzjmc;
+
+    @ApiModelProperty(value = "技术职称等级")
+    private String jszc;
+
+    @ApiModelProperty(value = "技术职称名称")
+    private String jszcmc;
+
+    @ApiModelProperty(value = "专业技术岗等级")
+    private String zyjsgdj;
+
+    @ApiModelProperty(value = "专业技术岗等级名称")
+    private String zyjsgdjmc;
+
+    @ApiModelProperty(value = "校内管理岗聘任岗位等级")
+    private String glzygdj;
+
+    @ApiModelProperty(value = "校内管理岗聘任岗位名称")
+    private String glzygdjmc;
+}

+ 16 - 0
src/main/java/com/muzhi/zgd/entity/vo/BumenVo.java

@@ -0,0 +1,16 @@
+package com.muzhi.zgd.entity.vo;
+
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+
+@Data
+public class BumenVo {
+
+    @ApiModelProperty(value = "部门id")
+    private String bmid;
+
+    @ApiModelProperty(value = "部门")
+    private String bmmc;
+}

+ 14 - 0
src/main/java/com/muzhi/zgd/entity/vo/EmployeeDataVo.java

@@ -0,0 +1,14 @@
+package com.muzhi.zgd.entity.vo;
+
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class EmployeeDataVo<T> {
+
+    private Integer code;
+    private String msg;
+    private Long count;
+    private List<T> data;
+}

+ 17 - 0
src/main/java/com/muzhi/zgd/entity/vo/EmployeeQuery.java

@@ -0,0 +1,17 @@
+package com.muzhi.zgd.entity.vo;
+
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+@Data
+public class EmployeeQuery {
+    @ApiModelProperty(value = "员工名称,模糊查询")
+    private String name;
+
+    @ApiModelProperty(value = "性别 0男 1女")
+    private Integer sex;
+
+    @ApiModelProperty(value = "入职时间", example = "2019-01-01 10:10:10")
+    private String date;//注意,这里使用的是String类型,前端传过来的数据无需进行类型转换
+}

+ 176 - 0
src/main/java/com/muzhi/zgd/entity/vo/EmployeeVo.java

@@ -0,0 +1,176 @@
+package com.muzhi.zgd.entity.vo;
+
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.Date;
+
+@Data
+public class EmployeeVo {
+
+    @ApiModelProperty(value = "员工ID")
+    private String id;
+
+    @ApiModelProperty(value = "姓名")
+    private String sys00Name;
+
+    @ApiModelProperty(value = "邮箱")
+    private String sys00Email;
+
+    @ApiModelProperty(value = "部门id")
+    private String sys00DeptIds;
+
+    @ApiModelProperty(value = "部门")
+    private String sys00Dept;
+
+    @ApiModelProperty(value = "主部门id")
+    private String sys00MainDeptId;
+
+    @ApiModelProperty(value = "主部门")
+    private String sys00MainDept;
+
+    @ApiModelProperty(value = "职位")
+    private String sys00Position;
+
+    @ApiModelProperty(value = "手机号")
+    private String sys00Mobile;
+
+    @ApiModelProperty(value = "工号")
+    private String sys00JobNumber;
+
+    @ApiModelProperty(value = "分机号")
+    private String sys00Tel;
+
+    @ApiModelProperty(value = "办公地点")
+    private String sys00WorkPlace;
+
+    @ApiModelProperty(value = "备注")
+    private String sys00Remark;
+
+    @ApiModelProperty(value = "入职时间")
+    private Date sys00ConfirmJoinTime;
+
+    @ApiModelProperty(value = "员工类型")
+    private Integer sys01EmployeeType;
+
+    @ApiModelProperty(value = "员工状态")
+    private Integer sys01EmployeeStatus;
+
+    @ApiModelProperty(value = "试用期")
+    private String sys01ProbationPeriodType;
+
+    @ApiModelProperty(value = "转正日期")
+    private Date sys01RegularTime;
+
+    @ApiModelProperty(value = "岗位职级")
+    private String sys01PositionLevel;
+
+    @ApiModelProperty(value = "身份证姓名")
+    private String sys02RealName;
+
+    @ApiModelProperty(value = "证件号码")
+    private String sys02CertNo;
+
+    @ApiModelProperty(value = "出生日期")
+    private Date sys02BirthTime;
+
+    @ApiModelProperty(value = "性别(0:男;1:女)")
+    private Integer sys02SexType;
+
+    @ApiModelProperty(value = "民族")
+    private String sys02NationType;
+
+    @ApiModelProperty(value = "身份证地址")
+    private String sys02CertAddress;
+
+    @ApiModelProperty(value = "证件有效期")
+    private Date sys02CertEndTime;
+
+    @ApiModelProperty(value = "婚姻状况")
+    private String sys02Marriage;
+
+    @ApiModelProperty(value = "首次参加工作时间")
+    private Date sys02JoinWorkingTime;
+
+    @ApiModelProperty(value = "户籍类型")
+    private Integer sys02ResidenceType;
+
+    @ApiModelProperty(value = "住址")
+    private String sys02Address;
+
+    @ApiModelProperty(value = "政治面貌")
+    private Integer sys02PoliticalStatus;
+
+    @ApiModelProperty(value = "个人社保账号")
+    private String sys09PersonalSi;
+
+    @ApiModelProperty(value = "个人公积金账号")
+    private String sys09PersonalHf;
+
+    @ApiModelProperty(value = "最高学历")
+    private String sys03HighestEdu;
+
+    @ApiModelProperty(value = "毕业院校")
+    private String sys03GraduateSchool;
+
+    @ApiModelProperty(value = "毕业时间")
+    private Date sys03GraduationTime;
+
+    @ApiModelProperty(value = "所学专业")
+    private String sys03Major;
+
+    @ApiModelProperty(value = "银行卡号")
+    private String sys04BankAccountNo;
+
+    @ApiModelProperty(value = "开户行")
+    private String sys04AccountBank;
+
+    @ApiModelProperty(value = "合同公司")
+    private String sys05ContractCompanyName;
+
+    @ApiModelProperty(value = "合同类型")
+    private Integer sys05ContractType;
+
+    @ApiModelProperty(value = "首次合同起始日")
+    private Date sys05FirstContractStartTime;
+
+    @ApiModelProperty(value = "首次合同到期日")
+    private Date sys05FirstContractEndTime;
+
+    @ApiModelProperty(value = "现合同起始日")
+    private Date sys05NowContractStartTime;
+
+    @ApiModelProperty(value = "现合同到期日")
+    private Date sys05NowContractEndTime;
+
+    @ApiModelProperty(value = "合同期限")
+    private String sys05ContractPeriodType;
+
+    @ApiModelProperty(value = "续签次数")
+    private Integer sys05ContractRenewCount;
+
+    @ApiModelProperty(value = "紧急联系人姓名")
+    private String sys06UrgentContactsName;
+
+    @ApiModelProperty(value = "联系人关系")
+    private String sys06UrgentContactsRelation;
+
+    @ApiModelProperty(value = "联系人电话")
+    private String sys06UrgentContactsPhone;
+
+    @ApiModelProperty(value = "有无子女")
+    private String sys07HaveChild;
+
+    @ApiModelProperty(value = "子女姓名")
+    private String sys07ChildName;
+
+    @ApiModelProperty(value = "子女性别")
+    private Integer sys07ChildSex;
+
+    @ApiModelProperty(value = "子女出生日期")
+    private Date sys07ChildBirthDate;
+
+    @ApiModelProperty(value = "自定义字段")
+    private String customField;
+}

+ 35 - 0
src/main/java/com/muzhi/zgd/exception/HttpResponseException.java

@@ -0,0 +1,35 @@
+package com.muzhi.zgd.exception;
+
+import java.io.IOException;
+
+/**
+ * 
+ * @className	: HttpResponseException
+ * @description	: TODO(描述这个类的作用)
+ * @author 		:万大龙(743)
+ * @date		: 2017年10月27日 上午10:41:25
+ * @version 	V1.0
+ */
+@SuppressWarnings("serial")
+public class HttpResponseException extends IOException {
+	
+	private int statusCode = 200;
+
+	public HttpResponseException(String message) {
+		super(message);
+	}
+	
+	public HttpResponseException(String message, Throwable cause) {
+		super(message, cause);
+	}
+	
+	public HttpResponseException(final int statusCode, final String s) {
+		super(s);
+		this.statusCode = statusCode;
+	}
+
+	public int getStatusCode() {
+		return this.statusCode;
+	}
+
+}

+ 41 - 0
src/main/java/com/muzhi/zgd/handler/JSONResponseHandler.java

@@ -0,0 +1,41 @@
+package com.muzhi.zgd.handler;
+
+import com.alibaba.fastjson.JSONObject;
+import com.muzhi.zgd.exception.HttpResponseException;
+import com.muzhi.zgd.http.HttpIOUtils;
+import com.muzhi.zgd.http.HttpStatus;
+
+import java.io.IOException;
+import java.net.HttpURLConnection;
+
+/**
+ * 
+ * @className	: JSONResponseHandler
+ * @description	: http请求响应处理:返回JSONObject对象
+ * @date		: 2017年6月13日 下午9:19:46
+ * @version 	V1.0
+ */
+public class JSONResponseHandler implements ResponseHandler<JSONObject> {
+
+	@Override
+	public void preHandle(HttpURLConnection httpConn) {
+		
+	}
+	
+	@Override
+	public JSONObject handleResponse(HttpURLConnection httpConn, String charset) throws IOException {
+		int status = httpConn.getResponseCode();
+		if (status >= HttpURLConnection.HTTP_OK && status < HttpURLConnection.HTTP_MULT_CHOICE) {
+			String result = HttpIOUtils.toInputText(httpConn.getErrorStream(), charset);
+			return JSONObject.parseObject(result);
+		} else {
+			String result = HttpIOUtils.toInputText(httpConn.getErrorStream(), charset);
+			if(result != null && result.length() > 0) {
+				throw new HttpResponseException(status, result.toString());
+			}
+			throw new HttpResponseException(status, HttpStatus.getStatusText(status));
+		}
+	}
+	
+	 
+}

+ 32 - 0
src/main/java/com/muzhi/zgd/handler/PlainTextResponseHandler.java

@@ -0,0 +1,32 @@
+package com.muzhi.zgd.handler;
+
+import com.muzhi.zgd.exception.HttpResponseException;
+import com.muzhi.zgd.http.HttpIOUtils;
+import com.muzhi.zgd.http.HttpStatus;
+import java.io.IOException;
+import java.net.HttpURLConnection;
+
+
+public class PlainTextResponseHandler implements ResponseHandler<String> {
+
+	@Override
+	public void preHandle(HttpURLConnection httpConn) {
+		httpConn.setConnectTimeout(5000);
+		httpConn.setReadTimeout(10000);
+	}
+
+	@Override
+	public String handleResponse(HttpURLConnection httpConn, String charset) throws IOException {
+		int status = httpConn.getResponseCode();
+		if (status >= HttpURLConnection.HTTP_OK && status < HttpURLConnection.HTTP_MULT_CHOICE) {
+			return HttpIOUtils.toInputText(httpConn.getInputStream(), charset);
+		} else {
+			String result = HttpIOUtils.toInputText(httpConn.getErrorStream(), charset);
+			if(result != null && result.length() > 0) {
+				throw new HttpResponseException(status, result.toString());
+			}
+			throw new HttpResponseException(status, HttpStatus.getStatusText(status));
+		}
+	}
+
+}

+ 26 - 0
src/main/java/com/muzhi/zgd/handler/ResponseHandler.java

@@ -0,0 +1,26 @@
+package com.muzhi.zgd.handler;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.net.HttpURLConnection;
+
+
+/**
+ * Handler that encapsulates the process of generating a response object
+ * from a {@link HttpResponse}.
+ */
+public interface ResponseHandler<T> {
+
+	/**
+	 * 对HttpURLConnection进行预处理
+	 * @param httpConn
+	 */
+	void preHandle(HttpURLConnection httpConn);
+	
+    /**
+     * Processes an {@link OutputStream} and returns some value corresponding to that response.
+     * @throws IOException in case of a problem or the connection was aborted
+     */
+    T handleResponse(HttpURLConnection httpConn, String charset) throws IOException;
+
+}

+ 99 - 0
src/main/java/com/muzhi/zgd/http/ApiHttpClientUtils.java

@@ -0,0 +1,99 @@
+package com.muzhi.zgd.http;
+
+import com.muzhi.zgd.exception.HttpResponseException;
+import com.muzhi.zgd.handler.PlainTextResponseHandler;
+import com.muzhi.zgd.handler.ResponseHandler;
+import com.muzhi.zgd.oauth2.ApiClientConfig;
+import com.muzhi.zgd.oauth2.ApiToken;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+public class ApiHttpClientUtils {
+
+	public static ResponseHandler<String> textHandler = new PlainTextResponseHandler();
+
+	private static ApiHttpClientUtils client;
+
+	private ApiHttpClientUtils() {
+	}
+
+	public static synchronized ApiHttpClientUtils get() {
+		if (client == null) {
+			client = new ApiHttpClientUtils();
+		}
+		return client;
+	}
+	
+	public static synchronized ApiHttpClientUtils get(ApiClientConfig config) {
+		if (client == null) {
+			ApiToken.get().set(config);
+			client = new ApiHttpClientUtils();
+		}
+		return client;
+	}
+	
+	/**
+	 * 
+	 * @description	: Get方式调用API带认证权限
+	 * @author 		: 万大龙(743)
+	 * @date 		:2017年10月27日 上午10:52:20
+	 * @param baseURL
+	 * @param paramsMap
+	 * @return
+	 * @throws IOException
+	 */
+	public String invokeApiWithGet(String baseURL, Map<String, Object> paramsMap) throws HttpResponseException, IOException {
+		Map<String, String> headers = new HashMap<String, String>();
+		headers.put(HttpHeaders.AUTHORIZATION, "Bearer " + ApiToken.get().getAccessToken());
+		return HttpConnectionUtils.httpRequestWithGet(baseURL, paramsMap, ContentType.UTF_8, headers, textHandler);
+	}
+	
+	/**
+	 * 
+	 * @description	: Post方式调用API带认证权限
+	 * @author 		: 万大龙(743)
+	 * @date 		:2017年10月27日 上午10:52:46
+	 * @param baseURL
+	 * @param paramsMap
+	 * @return
+	 * @throws IOException
+	 */
+	public String invokeApiWithPost(String baseURL, Map<String, Object> paramsMap) throws HttpResponseException, IOException {
+		Map<String, String> headers = new HashMap<String, String>();
+		headers.put(HttpHeaders.AUTHORIZATION, "Bearer " + ApiToken.get().getAccessToken());
+		return HttpConnectionUtils.httpRequestWithPost(baseURL, paramsMap, ContentType.UTF_8, ContentType.APPLICATION_FORM_URLENCODED + "; charset=" + ContentType.UTF_8, headers, textHandler);
+	}
+	
+	/**
+	 * 
+	 * @description	: Get方式调用API不带认证权限
+	 * @author 		: 樊新亮(1505)
+	 * @date 		:2017年11月9日 上午11:08:34
+	 * @param baseURL
+	 * @param paramsMap
+	 * @return
+	 * @throws IOException
+	 */
+	public String invokeApiWithGetNotToken(String baseURL, Map<String, Object> paramsMap) throws IOException {
+		Map<String, String> headers = new HashMap<String, String>();
+		return HttpConnectionUtils.httpRequestWithGet(baseURL, paramsMap, ContentType.UTF_8, headers, textHandler);
+	}
+	
+	/**
+	 * 
+	 * @description	: Post方式调用API不带认证权限
+	 * @author 		: 樊新亮(1505)
+	 * @date 		:2017年11月9日 上午11:08:55
+	 * @param baseURL
+	 * @param paramsMap
+	 * @return
+	 * @throws IOException
+	 */
+	public String invokeApiWithPostNotToken(String baseURL, Map<String, Object> paramsMap) throws IOException {
+		Map<String, String> headers = new HashMap<String, String>();
+		return HttpConnectionUtils.httpRequestWithPost(baseURL, paramsMap, ContentType.UTF_8, ContentType.APPLICATION_FORM_URLENCODED + "; charset=" + ContentType.UTF_8, headers, textHandler);
+	}
+	
+}

+ 27 - 0
src/main/java/com/muzhi/zgd/http/ContentType.java

@@ -0,0 +1,27 @@
+package com.muzhi.zgd.http;
+
+public abstract class ContentType {
+	
+	// constants
+	public static final String APPLICATION_ATOM_XML = "application/atom+xml";
+	public static final String APPLICATION_JSON = "application/json";
+	public static final String APPLICATION_FORM_URLENCODED = "application/x-www-form-urlencoded";
+	public static final String APPLICATION_OCTET_STREAM = "application/octet-stream";
+	public static final String APPLICATION_JAVA_SERIALIZED_OBJECT = "application/x-java-serialized-object";
+	
+	public static final String APPLICATION_SVG_XML = "application/svg+xml";
+	public static final String APPLICATION_XHTML_XML = "application/xhtml+xml";
+	public static final String APPLICATION_XML = "application/xml";
+	public static final String MULTIPART_FORM_DATA = "multipart/form-data";
+	public static final String TEXT_HTML = "text/html";
+	public static final String TEXT_PLAIN = "text/plain";
+	public static final String TEXT_JSON = "text/json";
+	public static final String TEXT_XML = "text/xml";
+	public static final String WILDCARD = "*/*";
+
+	public static final String UTF_8 = "UTF-8";
+	public static final String ASCII = "US-ASCII";
+	public static final String ISO_8859_1 = "ISO-8859-1";
+ 
+	
+}

+ 304 - 0
src/main/java/com/muzhi/zgd/http/HttpConnectionUtils.java

@@ -0,0 +1,304 @@
+package com.muzhi.zgd.http;
+
+import com.muzhi.zgd.handler.ResponseHandler;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.io.ObjectOutputStream;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.net.URLEncoder;
+import java.util.Map;
+import java.util.Set;
+
+
+/**
+ * 
+ * @className	: HttpConnectionUtils
+ * @description	:使用java内置HttpURLConnection对象进行get,post方式的请求
+ * @date		: 2015-6-24 下午05:08:14
+ * <pre>
+ * 总结:
+ * a:) HttpURLConnection的connect()函数,实际上只是建立了一个与服务器的tcp连接,并没有实际发送http请求。
+ * 	        无论是post还是get,http请求实际上直到HttpURLConnection的getInputStream()这个函数里面才正式发送出去。
+	       b:) 在用POST方式发送URL请求时,URL请求参数的设定顺序是重中之重,
+	    对connection对象的一切配置(那一堆set函数)
+	    都必须要在connect()函数执行之前完成。而对outputStream的写操作,又必须要在inputStream的读操作之前。
+	    这些顺序实际上是由http请求的格式决定的。
+	    如果inputStream读操作在outputStream的写操作之前,会抛出例外:
+	    java.net.ProtocolException: Cannot write output after reading input.......
+	      
+	       c:) http请求实际上由两部分组成,
+	    一个是http头,所有关于此次http请求的配置都在http头里面定义,
+	           一个是正文content。
+	    connect()函数会根据HttpURLConnection对象的配置值生成http头部信息,因此在调用connect函数之前,
+	    就必须把所有的配置准备好。
+	       d:) 在http头后面紧跟着的是http请求的正文,正文的内容是通过outputStream流写入的,
+	    实际上outputStream不是一个网络流,充其量是个字符串流,往里面写入的东西不会立即发送到网络,
+	    而是存在于内存缓冲区中,待outputStream流关闭时,根据输入的内容生成http正文。
+	    至此,http请求的东西已经全部准备就绪。在getInputStream()函数调用的时候,就会把准备好的http请求
+	    正式发送到服务器了,然后返回一个输入流,用于读取服务器对于此次http请求的返回信息。由于http
+	    请求在getInputStream的时候已经发送出去了(包括http头和正文),因此在getInputStream()函数
+	    之后对connection对象进行设置(对http头的信息进行修改)或者写入outputStream(对正文进行修改)
+	    都是没有意义的了,执行这些操作会导致异常的发生。 
+ * </pre>
+ */
+public class HttpConnectionUtils {
+	
+	protected static Logger LOG = LoggerFactory.getLogger(HttpConnectionUtils.class);
+	
+	//连接超时 单位毫秒
+	public static int connectTimeout = 10000;
+	//读取超时 单位毫秒
+	public static int readTimeout = 3000;
+	
+	protected static String sessionID = "";
+	
+	public static String buildURL(String baseURL,Map<String,Object> paramsMap){
+		if(paramsMap == null){
+			return baseURL;
+		}
+		StringBuilder builder = new StringBuilder(baseURL);
+		for (String key : paramsMap.keySet()) {
+			builder.append(builder.indexOf("?") > 0 ? "&" : "?").append(key).append("=").append(String.valueOf(paramsMap.get(key)));
+		}
+		return builder.toString();
+	}
+	
+
+	public static HttpURLConnection getPreparedHttpURLConnection(HttpURLConnection httpConn,String method,Map<String, String> headers,String contentType,String charset) throws IOException {
+			    
+        // 设定请求的方法为指定方法,默认是GET 
+	    httpConn.setRequestMethod(method);  
+        // 表示从服务器获取数据
+		httpConn.setDoInput(true);
+		// 设置是否向服务器写数据  ;如果是post请求,参数要放在 http正文内,因此需要设为true, 默认情况下是false;  
+		httpConn.setDoOutput("POST".equalsIgnoreCase(method) ? true : false ); 
+		// Post 请求不能使用缓存
+		httpConn.setUseCaches(false);  
+		 
+	    // This method takes effects to
+        // every instances of this class.
+        // URLConnection.setFollowRedirects是static函数,作用于所有的URLConnection对象。
+        // connection.setFollowRedirects(true);
+      
+        // This methods only
+        // takes effacts to this
+        // instance.
+        // URLConnection.setInstanceFollowRedirects是成员函数,仅作用于当前函数
+	    httpConn.setInstanceFollowRedirects(false);
+       
+	    //设置Session ID 解决多次请求不同会话问题
+	    httpConn.setRequestProperty("Cookie", sessionID);
+	    
+	    // 设置通用的请求属性 (模拟浏览器请求头) 
+	    httpConn.setRequestProperty(HttpHeaders.ACCEPT, "*/*");  
+	    httpConn.setRequestProperty(HttpHeaders.CONNECTION, "Keep-Alive");  
+		httpConn.setRequestProperty(HttpHeaders.USER_AGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows 2000)");
+		/**增加headers*/
+		if(headers != null) {
+			Set<String> keys = headers.keySet();
+			for (String key : keys) {
+				httpConn.setRequestProperty(key, headers.get(key));
+			}
+		}
+		/* 
+		 * 配置本次连接的Content-type,配置为application/x-www-form-urlencoded的
+		 * 意思是正文是urlencoded编码过的form参数,下面我们可以看到我们对正文内容使用URLEncoder.encode进行编码
+		 */	
+		if (contentType != null) {
+			httpConn.setRequestProperty(HttpHeaders.CONTENT_TYPE, contentType);
+		} else {
+			httpConn.setRequestProperty(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_FORM_URLENCODED + ";charset=" + charset);
+		}
+		
+		/*
+		
+		HttpURLConnection是基于HTTP协议的,其底层通过socket通信实现。如果不设置超时(timeout),在网络异常的情况下,可能会导致程序僵死而不继续往下执行。可以通过以下两个语句来设置相应的超时:
+		System.setProperty("sun.net.client.defaultConnectTimeout", 超时毫秒数字符串);
+		System.setProperty("sun.net.client.defaultReadTimeout", 超时毫秒数字符串);
+		
+		其中: sun.net.client.defaultConnectTimeout:连接主机的超时时间(单位:毫秒)
+		sun.net.client.defaultReadTimeout:从主机读取数据的超时时间(单位:毫秒)
+		
+		例如:
+		System.setProperty("sun.net.client.defaultConnectTimeout", "30000");
+		System.setProperty("sun.net.client.defaultReadTimeout", "30000");
+		
+		JDK 1.5以前的版本,只能通过设置这两个系统属性来控制网络超时。在1.5中,还可以使用HttpURLConnection的父类URLConnection的以下两个方法:
+		setConnectTimeout:设置连接主机超时(单位:毫秒)
+		setReadTimeout:设置从主机读取数据超时(单位:毫秒) 
+
+		*/
+		System.setProperty("sun.net.client.defaultConnectTimeout", connectTimeout+"");
+		System.setProperty("sun.net.client.defaultReadTimeout", readTimeout+""); 
+		httpConn.setConnectTimeout(connectTimeout);
+		httpConn.setReadTimeout(readTimeout);
+		
+		return httpConn;
+	}
+	
+	public static HttpURLConnection getHttpURLConnectionWithGet(String baseURL,Map<String,Object> paramsMap,Map<String, String> headers,String charset) throws IOException{
+		URL urlGet = new URL(buildURL(baseURL,paramsMap));
+		// 此处的urlConnection对象实际上是根据URL的 请求协议(此处是http)生成的URLConnection类 的子类HttpURLConnection,故此处最好将其转化 为HttpURLConnection类型的对象,以便用到HttpURLConnection更多的API.如下: 
+		HttpURLConnection httpConn = (HttpURLConnection) urlGet.openConnection();
+		httpConn = getPreparedHttpURLConnection( httpConn , "GET", headers, ContentType.TEXT_PLAIN, charset);
+	    httpConn.connect();
+		return httpConn;
+	}
+	
+	public static HttpURLConnection getHttpURLConnectionWithPost(String baseURL,Map<String,Object> paramsMap,Map<String, String> headers, String contentType ,String charset) throws IOException{
+		URL urlPost = new URL(baseURL);
+		// 此处的urlConnection对象实际上是根据URL的 请求协议(此处是http)生成的URLConnection类 的子类HttpURLConnection,故此处最好将其转化 为HttpURLConnection类型的对象,以便用到HttpURLConnection更多的API.如下: 
+		HttpURLConnection httpConn = (HttpURLConnection) urlPost.openConnection();
+						  httpConn = getPreparedHttpURLConnection( httpConn , "POST", headers, contentType , charset);
+		/* 
+	        Post请求的OutputStream实际上不是网络流,而是写入内存,在 getInputStream中才真正把写道流里面的内容作为正文与根据之前的配置生成的http request头合并成真正的http request,并在此时才真正向服务器发送。
+	        HttpURLConnection.setChunkedStreamingMode函 数可以改变这个模式,设置了ChunkedStreamingMode后,
+			不再等待OutputStream关闭后生成完整的http request一次过发送,而是先发送http request头, 正文内容则是网路流的方式实时传送到服务器。
+	                       实际上是不告诉服务器http正文的长度,这种模式适用于向服务器传送较大的或者是不容易 获取长度的数据,如文件上传。
+	                       与readContentFromPost()最大的不同,设置了块大小为5字节 
+	    */
+	    httpConn.setChunkedStreamingMode(5);  
+	    /* 
+	     * 注意,下面的getOutputStream函数工作方式于在readContentFromPost()里面的不同 ;在readContentFromPost()里面该函数仍在准备http request,没有向服务器发送任何数据 
+	     * 而在这里由于设置了ChunkedStreamingMode,getOutputStream函数会根据connect之前的配置  生成http request头,先发送到服务器。 
+	     */  
+	    if(ContentType.APPLICATION_JAVA_SERIALIZED_OBJECT.equalsIgnoreCase(contentType)){
+	    	// 连接,从urlPost.openConnection()至此的配置必须要在connect之前完成,要注意的是connection.getOutputStream会隐含的进行connect(即:如同调用上面的connect()方法,  所以在开发中不调用上述的connect()也可以)。  
+	        httpConn.connect();
+	    	//  现在通过输出流对象构建对象输出流对象,以实现输出可序列化的对象。 
+	    	ObjectOutputStream output  =  new ObjectOutputStream(httpConn.getOutputStream()); 
+	    	//  向对象输出流写出数据,这些数据将存到内存缓冲区中 
+	    	output.writeObject(paramsMap);
+	    	//  刷新对象输出流,将任何字节都写入潜在的流中(些处为ObjectOutputStream) 
+	    	output.flush(); 
+	    	//  关闭流对象。此时,不能再向对象输出流写入任何数据,先前写入的数据存在于内存缓冲区中, 在调用下边的getInputStream()函数时才把准备好的http请求正式发送到服务器 
+	    	output.close(); 
+	    }else {
+	    	//组织参数内容
+			StringBuilder buffer = new StringBuilder();
+			if(paramsMap != null && paramsMap.size() > 0 ){
+				for (String key : paramsMap.keySet()) {
+					buffer.append("&").append(key).append("=").append(URLEncoder.encode(String.valueOf(paramsMap.get(key)), charset));
+				}
+				buffer.deleteCharAt(0);
+			}
+			// 获得上传信息的字节大小以及长度  
+            //byte[] postdata = buffer.toString().getBytes();  
+	        httpConn.setRequestProperty(HttpHeaders.CONTENT_LENGTH, String.valueOf(buffer.length()));
+	        // 连接,从urlPost.openConnection()至此的配置必须要在connect之前完成,要注意的是connection.getOutputStream会隐含的进行connect(即:如同调用上面的connect()方法,  所以在开发中不调用上述的connect()也可以)。 
+	        httpConn.connect();
+	    	//建立输入流,向指向的URL传入参数
+		    DataOutputStream output = new DataOutputStream(httpConn.getOutputStream());
+		    // DataOutputStream.writeBytes将字符串中的16位的unicode字符以8位的字符形式写到流里面
+		    output.writeBytes(buffer.toString());
+		    //output.write(postdata , 0 , postdata.length );
+		    // flush输出流的缓冲  
+		    output.flush();
+		    // 到此时服务器已经收到了完整的http request了,而在readContentFromPost()函数里,要等到下一句服务器才能收到http请求。
+		    output.close(); 
+		}
+		return httpConn;
+	}
+	
+	public static <T> T httpRequestWithGet(String baseURL, ResponseHandler<T> handler) throws IOException {
+		return httpRequestWithGet(baseURL, null, handler);
+	}
+
+	public static <T> T httpRequestWithGet(String baseURL,
+			Map<String, Object> paramsMap, ResponseHandler<T> handler)
+			throws IOException {
+		return httpRequestWithGet(baseURL, paramsMap, ContentType.UTF_8, handler);
+	}
+
+	public static <T> T httpRequestWithGet(String baseURL,
+			Map<String, Object> paramsMap, String charset,
+			ResponseHandler<T> handler) throws IOException {
+		return httpRequestWithGet(baseURL, paramsMap, charset, null, handler);
+	}
+
+	public static <T> T httpRequestWithGet(String baseURL,
+			Map<String, Object> paramsMap, String charset,
+			Map<String, String> headers, ResponseHandler<T> handler)
+			throws IOException {
+		// 创建默认的HttpURLConnection实例.
+		HttpURLConnection httpConn = getHttpURLConnectionWithGet(baseURL, paramsMap, headers, charset);
+		try {
+			// 对HttpURLConnection进行预处理
+			handler.preHandle(httpConn);
+			// 处理最终的响应结果
+			return handler.handleResponse(httpConn, charset);
+		} finally {
+			//在一次请求发送后获取SessionID
+			sessionID = getSessionID(httpConn);
+			//释放链接
+			HttpIOUtils.closeConnect(httpConn);
+		}
+	}
+
+	public static <T> T httpRequestWithPost(String baseURL,
+			Map<String, Object> paramsMap, ResponseHandler<T> handler)
+			throws IOException {
+		return httpRequestWithPost(baseURL, paramsMap, ContentType.UTF_8, handler);
+	}
+
+	/**
+	 * 进行post方式的请求;Content-Type 为 application/x-www-form-urlencoded
+	 */
+	public static <T> T httpRequestWithPost(String baseURL,
+			Map<String, Object> paramsMap, String charset,
+			ResponseHandler<T> handler) throws IOException {
+		return httpRequestWithPost(baseURL, paramsMap, charset, ContentType.APPLICATION_FORM_URLENCODED + "; charset=" + charset, handler);
+	}
+
+	public static <T> T httpRequestWithPost(String baseURL,Map<String, Object> paramsMap, final String charset, String contentType, ResponseHandler<T> handler) throws IOException {
+		return httpRequestWithPost(baseURL, paramsMap, charset, contentType, null, handler);
+	}
+
+	public static <T> T httpRequestWithPost(String baseURL,
+			Map<String, Object> paramsMap, String charset, String contentType,
+			Map<String, String> headers, ResponseHandler<T> handler) throws IOException{
+		// 创建默认的HttpURLConnection实例.
+		HttpURLConnection httpConn = getHttpURLConnectionWithPost(baseURL, paramsMap, headers, contentType, charset);
+		try {
+			// 对HttpURLConnection进行预处理
+			handler.preHandle(httpConn);
+			// 处理最终的响应结果
+			return handler.handleResponse(httpConn, charset);
+		} finally {
+			//在一次请求发送后获取SessionID
+			sessionID = getSessionID(httpConn);
+			//释放链接
+			HttpIOUtils.closeConnect(httpConn);
+		}
+	}
+	
+	/**
+	 * 
+	 * ******************************************************************
+	 * @description	: 在一次请求发送后获取SessionID
+	 * @author 		: <a href="mailto:hnxyhcwdl1003@163.com">vindell</a>
+	 * @date 		:Dec 15, 2016 2:53:57 PM
+	 * @param httpConn
+	 * @return
+	 * ******************************************************************
+	 */
+	public static String getSessionID(HttpURLConnection httpConn){
+		// Get Session ID
+		String key = "";
+		String sessionId = "";
+		if (httpConn != null) {
+			for (int i = 1; (key = httpConn.getHeaderFieldKey(i)) != null; i++) {
+				if (key.equalsIgnoreCase("set-cookie")) {
+					sessionId = httpConn.getHeaderField(key);
+					sessionId = sessionId.substring(0, sessionId.indexOf(";"));
+				}
+			}
+		}
+		return sessionId;
+	}
+	
+}

+ 183 - 0
src/main/java/com/muzhi/zgd/http/HttpHeaders.java

@@ -0,0 +1,183 @@
+package com.muzhi.zgd.http;
+
+/**
+ * Constants enumerating the HTTP headers. All headers defined in RFC1945 (HTTP/1.0), RFC2616 (HTTP/1.1), and RFC2518
+ * (WebDAV) are listed.
+ *
+ * @since 4.1
+ */
+public final class HttpHeaders {
+
+    private HttpHeaders() {
+    }
+
+    /** RFC 2616 (HTTP/1.1) Section 14.1 */
+    public static final String ACCEPT = "Accept";
+
+    /** RFC 2616 (HTTP/1.1) Section 14.2 */
+    public static final String ACCEPT_CHARSET = "Accept-Charset";
+
+    /** RFC 2616 (HTTP/1.1) Section 14.3 */
+    public static final String ACCEPT_ENCODING = "Accept-Encoding";
+
+    /** RFC 2616 (HTTP/1.1) Section 14.4 */
+    public static final String ACCEPT_LANGUAGE = "Accept-Language";
+
+    /** RFC 2616 (HTTP/1.1) Section 14.5 */
+    public static final String ACCEPT_RANGES = "Accept-Ranges";
+
+    /** RFC 2616 (HTTP/1.1) Section 14.6 */
+    public static final String AGE = "Age";
+
+    /** RFC 1945 (HTTP/1.0) Section 10.1, RFC 2616 (HTTP/1.1) Section 14.7 */
+    public static final String ALLOW = "Allow";
+
+    /** RFC 1945 (HTTP/1.0) Section 10.2, RFC 2616 (HTTP/1.1) Section 14.8 */
+    public static final String AUTHORIZATION = "Authorization";
+
+    /** RFC 2616 (HTTP/1.1) Section 14.9 */
+    public static final String CACHE_CONTROL = "Cache-Control";
+
+    /** RFC 2616 (HTTP/1.1) Section 14.10 */
+    public static final String CONNECTION = "Connection";
+
+    /** RFC 1945 (HTTP/1.0) Section 10.3, RFC 2616 (HTTP/1.1) Section 14.11 */
+    public static final String CONTENT_ENCODING = "Content-Encoding";
+
+    /** RFC 2616 (HTTP/1.1) Section 14.12 */
+    public static final String CONTENT_LANGUAGE = "Content-Language";
+
+    /** RFC 1945 (HTTP/1.0) Section 10.4, RFC 2616 (HTTP/1.1) Section 14.13 */
+    public static final String CONTENT_LENGTH = "Content-Length";
+
+    /** RFC 2616 (HTTP/1.1) Section 14.14 */
+    public static final String CONTENT_LOCATION = "Content-Location";
+
+    /** RFC 2616 (HTTP/1.1) Section 14.15 */
+    public static final String CONTENT_MD5 = "Content-MD5";
+
+    /** RFC 2616 (HTTP/1.1) Section 14.16 */
+    public static final String CONTENT_RANGE = "Content-Range";
+
+    /** RFC 1945 (HTTP/1.0) Section 10.5, RFC 2616 (HTTP/1.1) Section 14.17 */
+    public static final String CONTENT_TYPE = "Content-Type";
+
+    /** RFC 1945 (HTTP/1.0) Section 10.6, RFC 2616 (HTTP/1.1) Section 14.18 */
+    public static final String DATE = "Date";
+
+    /** RFC 2518 (WevDAV) Section 9.1 */
+    public static final String DAV = "Dav";
+
+    /** RFC 2518 (WevDAV) Section 9.2 */
+    public static final String DEPTH = "Depth";
+
+    /** RFC 2518 (WevDAV) Section 9.3 */
+    public static final String DESTINATION = "Destination";
+
+    /** RFC 2616 (HTTP/1.1) Section 14.19 */
+    public static final String ETAG = "ETag";
+
+    /** RFC 2616 (HTTP/1.1) Section 14.20 */
+    public static final String EXPECT = "Expect";
+
+    /** RFC 1945 (HTTP/1.0) Section 10.7, RFC 2616 (HTTP/1.1) Section 14.21 */
+    public static final String EXPIRES = "Expires";
+
+    /** RFC 1945 (HTTP/1.0) Section 10.8, RFC 2616 (HTTP/1.1) Section 14.22 */
+    public static final String FROM = "From";
+
+    /** RFC 2616 (HTTP/1.1) Section 14.23 */
+    public static final String HOST = "Host";
+
+    /** RFC 2518 (WevDAV) Section 9.4 */
+    public static final String IF = "If";
+
+    /** RFC 2616 (HTTP/1.1) Section 14.24 */
+    public static final String IF_MATCH = "If-Match";
+
+    /** RFC 1945 (HTTP/1.0) Section 10.9, RFC 2616 (HTTP/1.1) Section 14.25 */
+    public static final String IF_MODIFIED_SINCE = "If-Modified-Since";
+
+    /** RFC 2616 (HTTP/1.1) Section 14.26 */
+    public static final String IF_NONE_MATCH = "If-None-Match";
+
+    /** RFC 2616 (HTTP/1.1) Section 14.27 */
+    public static final String IF_RANGE = "If-Range";
+
+    /** RFC 2616 (HTTP/1.1) Section 14.28 */
+    public static final String IF_UNMODIFIED_SINCE = "If-Unmodified-Since";
+
+    /** RFC 1945 (HTTP/1.0) Section 10.10, RFC 2616 (HTTP/1.1) Section 14.29 */
+    public static final String LAST_MODIFIED = "Last-Modified";
+
+    /** RFC 1945 (HTTP/1.0) Section 10.11, RFC 2616 (HTTP/1.1) Section 14.30 */
+    public static final String LOCATION = "Location";
+
+    /** RFC 2518 (WevDAV) Section 9.5 */
+    public static final String LOCK_TOKEN = "Lock-Token";
+
+    /** RFC 2616 (HTTP/1.1) Section 14.31 */
+    public static final String MAX_FORWARDS = "Max-Forwards";
+
+    /** RFC 2518 (WevDAV) Section 9.6 */
+    public static final String OVERWRITE = "Overwrite";
+
+    /** RFC 1945 (HTTP/1.0) Section 10.12, RFC 2616 (HTTP/1.1) Section 14.32 */
+    public static final String PRAGMA = "Pragma";
+
+    /** RFC 2616 (HTTP/1.1) Section 14.33 */
+    public static final String PROXY_AUTHENTICATE = "Proxy-Authenticate";
+
+    /** RFC 2616 (HTTP/1.1) Section 14.34 */
+    public static final String PROXY_AUTHORIZATION = "Proxy-Authorization";
+
+    /** RFC 2616 (HTTP/1.1) Section 14.35 */
+    public static final String RANGE = "Range";
+
+    /** RFC 1945 (HTTP/1.0) Section 10.13, RFC 2616 (HTTP/1.1) Section 14.36 */
+    public static final String REFERER = "Referer";
+
+    /** RFC 2616 (HTTP/1.1) Section 14.37 */
+    public static final String RETRY_AFTER = "Retry-After";
+
+    /** RFC 1945 (HTTP/1.0) Section 10.14, RFC 2616 (HTTP/1.1) Section 14.38 */
+    public static final String SERVER = "Server";
+
+    /** RFC 2518 (WevDAV) Section 9.7 */
+    public static final String STATUS_URI = "Status-URI";
+
+    /** RFC 2616 (HTTP/1.1) Section 14.39 */
+    public static final String TE = "TE";
+
+    /** RFC 2518 (WevDAV) Section 9.8 */
+    public static final String TIMEOUT = "Timeout";
+
+    /** RFC 2616 (HTTP/1.1) Section 14.40 */
+    public static final String TRAILER = "Trailer";
+
+    /** RFC 2616 (HTTP/1.1) Section 14.41 */
+    public static final String TRANSFER_ENCODING = "Transfer-Encoding";
+
+    /** RFC 2616 (HTTP/1.1) Section 14.42 */
+    public static final String UPGRADE = "Upgrade";
+
+    /** RFC 1945 (HTTP/1.0) Section 10.15, RFC 2616 (HTTP/1.1) Section 14.43 */
+    public static final String USER_AGENT = "User-Agent";
+
+    /** RFC 2616 (HTTP/1.1) Section 14.44 */
+    public static final String VARY = "Vary";
+
+    /** RFC 2616 (HTTP/1.1) Section 14.45 */
+    public static final String VIA = "Via";
+
+    /** RFC 2616 (HTTP/1.1) Section 14.46 */
+    public static final String WARNING = "Warning";
+
+    /** RFC 1945 (HTTP/1.0) Section 10.16, RFC 2616 (HTTP/1.1) Section 14.47 */
+    public static final String WWW_AUTHENTICATE = "WWW-Authenticate";
+
+	public static final String X_FORWARDED_FOR = "x-forwarded-for";
+	
+	public static final String X_REQUESTED_WITH = "X-Requested-With";
+	
+}

+ 175 - 0
src/main/java/com/muzhi/zgd/http/HttpIOUtils.java

@@ -0,0 +1,175 @@
+package com.muzhi.zgd.http;
+
+
+import java.io.*;
+import java.net.HttpURLConnection;
+import java.net.URLConnection;
+
+/**
+ * 
+ * @className	: HttpIOUtils
+ * @description	:  扩展org.apache.commons.io.IOUtils工具对象
+ * @date		: 2017年6月13日 下午9:20:40
+ * @version 	V1.0
+ */
+public abstract class HttpIOUtils extends org.apache.commons.io.IOUtils{
+	
+
+	public static final int BUFFER_SIZE = 1024 * 4;
+	
+    public static void closeConnect(final URLConnection conn) {
+        try {
+            if (conn != null) {
+            	if (conn instanceof HttpURLConnection) {
+                    ((HttpURLConnection) conn).disconnect();
+                }
+            }
+        } catch (final Exception ioe) {
+            // ignore
+        }
+    }
+    
+	//---------------------------------------------------------------------
+	// Stream Warp methods for java.io.InputStream / java.io.OutputStream
+	//---------------------------------------------------------------------
+
+	public static InputStream toBufferedInputStream(File localFile,int bufferSize) throws IOException {
+		// 包装文件输入流  
+		return toBufferedInputStream(new FileInputStream(localFile),bufferSize);
+    }
+	
+    public static InputStream toBufferedInputStream(InputStream input) throws IOException {
+    	if(isBuffered(input)){
+    		 return (BufferedInputStream) input ;
+    	}else{
+            return org.apache.commons.io.output.ByteArrayOutputStream.toBufferedInputStream(input);
+    	}
+    }
+	
+	public static InputStream toBufferedInputStream(InputStream input,int bufferSize) throws IOException {
+    	if(isBuffered(input)){
+    		 return (BufferedInputStream) input ;
+    	}else{
+    		if (bufferSize > 0) {
+	            return new BufferedInputStream(input, bufferSize);
+	        }
+	        return new BufferedInputStream(input);
+    	}
+    }
+	
+	public static OutputStream toBufferedOutputStream(OutputStream output) throws IOException {
+		if(isBuffered(output)){
+	   		return (BufferedOutputStream) output ;
+	   	}else{
+	        return toBufferedOutputStream(output , BUFFER_SIZE);
+	   	}
+    }
+	
+	public static OutputStream toBufferedOutputStream(OutputStream output,int bufferSize) throws IOException {
+		if(isBuffered(output)){
+	   		 return (BufferedOutputStream) output ;
+	   	}else{
+	   		if (bufferSize > 0) {
+	            return new BufferedOutputStream(output, bufferSize);
+	        }
+	        return new BufferedOutputStream(output);
+	   	}
+    }
+	
+	public static boolean isBuffered(InputStream input) {
+        return input instanceof BufferedInputStream;
+    }
+
+    public static boolean isBuffered(OutputStream output) {
+        return output instanceof BufferedOutputStream;
+    }
+    
+    public static BufferedReader toBufferedReader(InputStream input){
+		return new BufferedReader(new InputStreamReader(input));
+	}
+    
+    public static BufferedWriter toBufferedWriter(OutputStream output){
+		return new BufferedWriter(new OutputStreamWriter(output));
+	}
+    
+    public static boolean isPrint(OutputStream output) {
+        return output instanceof PrintStream;
+    }
+
+    public static InputStream toByteArrayInputStream(byte[] inputBytes){
+        return new ByteArrayInputStream(inputBytes);
+    }
+    
+    public static InputStream toByteArrayInputStream(String text) {
+        return toByteArrayInputStream(text.getBytes());
+    }
+    
+    public static DataInputStream toDataInputStream(InputStream input) {
+        return isDataInput(input) ? (DataInputStream) input : new DataInputStream(input);
+    }
+    
+    private static boolean isDataInput(InputStream input) {
+        return input instanceof DataInputStream;
+    }
+    
+	public static DataOutputStream toDataOutputStream(OutputStream output){
+		return isDataOutput(output) ? (DataOutputStream) output : new DataOutputStream(output);
+	}
+	
+	private static boolean isDataOutput(OutputStream output) {
+        return output instanceof DataOutputStream;
+    }
+	
+    
+    public static FileInputStream toFileInputStream(File file) throws IOException {
+        return new FileInputStream(file);
+    }
+    
+    /**
+     * 获得一个FileOutputStream对象
+     * @param file
+     * @param append : true:向文件尾部追见数据; false:清楚旧数据
+     * @return
+     * @throws FileNotFoundException
+     */
+    public static FileOutputStream toFileOutputStream(File file,boolean append) throws FileNotFoundException {
+		return new FileOutputStream(file, append);
+	}
+    
+	public static PrintStream toPrintStream(File file) {
+    	FileOutputStream stream = null;
+        try {
+        	stream = new FileOutputStream(file,true);
+			return toPrintStream(stream);
+		} catch (FileNotFoundException e) {
+			throw new RuntimeException(e);
+		}
+    }
+    
+    public static PrintStream toPrintStream(OutputStream output) {
+        return isPrint(output) ? (PrintStream) output : new PrintStream(output);
+    }
+	
+    public static String toInputText(InputStream input, String charset) throws IOException {
+		BufferedReader reader = null;
+		try {
+			StringBuffer result = new StringBuffer();
+			reader = new BufferedReader(new InputStreamReader(input, charset));
+			String strRead = null;
+			int row = 0;
+			while ((strRead = reader.readLine()) != null) {
+				// 多行数据,且当前行读取到数据,则在上一行之后添加换行符
+				if (row > 0 && strRead != null && strRead.length() > 0) {
+					result.append("\r\n");
+				}
+				result.append(strRead);
+				row++;
+			}
+			return result.toString();
+		} finally {
+			// 释放资源
+			HttpIOUtils.closeQuietly(input);
+			HttpIOUtils.closeQuietly(reader);
+		}
+    }
+}

+ 123 - 0
src/main/java/com/muzhi/zgd/http/HttpStatus.java

@@ -0,0 +1,123 @@
+package com.muzhi.zgd.http;
+
+import java.net.HttpURLConnection;
+
+/**
+ * @className	: HttpStatus
+ * @description	:  Constants enumerating the HTTP status codes.
+ * @date		: 2017年6月13日 下午9:20:54
+ * @version 	V1.0
+ */
+public class HttpStatus {
+
+    // -------------------------------------------------------- Class Variables
+
+    /** Reason phrases lookup table. */
+    private static final String[][] REASON_PHRASES = new String[][]{
+        new String[0],
+        new String[3],
+        new String[8],
+        new String[8],
+        new String[25],
+        new String[8]
+    };
+
+
+    // --------------------------------------------------------- Public Methods
+
+    /**
+     * Get the reason phrase for a particular status code.
+     * 
+     * This method always returns the English text as specified in the
+     * relevent RFCs and is not internationalized.
+     * 
+     * @param statusCode the numeric status code
+     * @return the reason phrase associated with the given status code
+     * or null if the status code is not recognized.
+     * 
+     * TODO: getStatusText should be called getReasonPhrase to match RFC
+     */
+    public static String getStatusText(int statusCode) {
+
+        if (statusCode < 0) {
+            throw new IllegalArgumentException("status code may not be negative");
+        }
+        int classIndex = statusCode / 100;
+        int codeIndex = statusCode - classIndex * 100;
+        if (classIndex < 1 || classIndex > (REASON_PHRASES.length - 1)  || codeIndex < 0 || codeIndex > (REASON_PHRASES[classIndex].length - 1)) {
+            return null;
+        }
+        return "HTTP Status-Code " + statusCode + ": " + REASON_PHRASES[classIndex][codeIndex];
+    }
+
+
+    // -------------------------------------------------------- Private Methods
+
+    /**
+     * Store the given reason phrase, by status code.
+     * @param statusCode The status code to lookup
+     * @param reasonPhrase The reason phrase for this status code
+     */
+    private static void addStatusCodeMap(int statusCode, String reasonPhrase) {
+        int classIndex = statusCode / 100;
+        REASON_PHRASES[classIndex][statusCode - classIndex * 100] = reasonPhrase;
+    }
+
+    // ----------------------------------------------------- Static Initializer
+
+    /** Set up status code to "reason phrase" map. */
+    static {
+    	
+        // The response codes for HTTP, as of version 1.1.
+
+        /* 2XX: generally "OK" */
+    	
+        addStatusCodeMap(HttpURLConnection.HTTP_OK, "OK.");
+        addStatusCodeMap(HttpURLConnection.HTTP_CREATED, "Created.");
+        addStatusCodeMap(HttpURLConnection.HTTP_ACCEPTED, "Accepted.");
+        addStatusCodeMap(HttpURLConnection.HTTP_NOT_AUTHORITATIVE, "Non-Authoritative Information.");
+        addStatusCodeMap(HttpURLConnection.HTTP_NO_CONTENT, "No Content.");
+        addStatusCodeMap(HttpURLConnection.HTTP_RESET, "Reset Content.");
+        addStatusCodeMap(HttpURLConnection.HTTP_PARTIAL, "Partial Content.");
+        
+        /* 3XX: relocation/redirect */
+
+        addStatusCodeMap(HttpURLConnection.HTTP_MULT_CHOICE, "Multiple Choices.");
+        addStatusCodeMap(HttpURLConnection.HTTP_MOVED_PERM, "Moved Permanently.");
+        addStatusCodeMap(HttpURLConnection.HTTP_MOVED_TEMP, "Temporary Redirect.");
+        addStatusCodeMap(HttpURLConnection.HTTP_SEE_OTHER, "See Other.");
+        addStatusCodeMap(HttpURLConnection.HTTP_NOT_MODIFIED, "Not Modified.");
+        addStatusCodeMap(HttpURLConnection.HTTP_USE_PROXY, "Use Proxy.");
+        
+        /* 4XX: client error */
+        
+        addStatusCodeMap(HttpURLConnection.HTTP_BAD_REQUEST, "Bad Request.");
+        addStatusCodeMap(HttpURLConnection.HTTP_UNAUTHORIZED, "Unauthorized.");
+        addStatusCodeMap(HttpURLConnection.HTTP_PAYMENT_REQUIRED, "Payment Required.");
+        addStatusCodeMap(HttpURLConnection.HTTP_FORBIDDEN, "Forbidden.");
+        addStatusCodeMap(HttpURLConnection.HTTP_NOT_FOUND, "Not Found.");
+        addStatusCodeMap(HttpURLConnection.HTTP_BAD_METHOD, "Method Not Allowed.");
+        addStatusCodeMap(HttpURLConnection.HTTP_NOT_ACCEPTABLE, "Not Acceptable.");
+        addStatusCodeMap(HttpURLConnection.HTTP_PROXY_AUTH, "Proxy Authentication Required.");
+        addStatusCodeMap(HttpURLConnection.HTTP_CLIENT_TIMEOUT, "Request Timeout.");
+        addStatusCodeMap(HttpURLConnection.HTTP_CONFLICT, "Conflict.");
+        addStatusCodeMap(HttpURLConnection.HTTP_GONE,"Gone.");
+        addStatusCodeMap(HttpURLConnection.HTTP_LENGTH_REQUIRED,"Length Required.");
+        addStatusCodeMap(HttpURLConnection.HTTP_PRECON_FAILED, "Precondition Failed.");
+        addStatusCodeMap(HttpURLConnection.HTTP_ENTITY_TOO_LARGE, "Request Entity Too Large.");
+        addStatusCodeMap(HttpURLConnection.HTTP_REQ_TOO_LONG, "Request-URI Too Large.");
+        addStatusCodeMap(HttpURLConnection.HTTP_UNSUPPORTED_TYPE, "Unsupported Media Type.");
+        
+        /* 5XX: server error */
+        
+        addStatusCodeMap(HttpURLConnection.HTTP_INTERNAL_ERROR, "Internal Server Error.");
+        addStatusCodeMap(HttpURLConnection.HTTP_NOT_IMPLEMENTED, "Not Implemented.");
+        addStatusCodeMap(HttpURLConnection.HTTP_BAD_GATEWAY, "Bad Gateway.");
+        addStatusCodeMap(HttpURLConnection.HTTP_UNAVAILABLE, "Service Unavailable.");
+        addStatusCodeMap(HttpURLConnection.HTTP_GATEWAY_TIMEOUT, "Gateway Timeout.");
+        addStatusCodeMap(HttpURLConnection.HTTP_VERSION, "HTTP Version Not Supported.");
+        
+    }
+
+
+}

+ 11 - 0
src/main/java/com/muzhi/zgd/mapper/BumenMapper.java

@@ -0,0 +1,11 @@
+package com.muzhi.zgd.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.muzhi.zgd.entity.Bumen;
+import org.springframework.stereotype.Repository;
+
+//在对应的Mapper上面继承基本的类BaseMapper
+@Repository//代表持久层,或者加入@Mapper注解
+public interface BumenMapper extends BaseMapper<Bumen> {
+    //所有的CRUD操作都已经编写完成了
+}

+ 11 - 0
src/main/java/com/muzhi/zgd/mapper/EmployeeMapper.java

@@ -0,0 +1,11 @@
+package com.muzhi.zgd.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.muzhi.zgd.entity.Employee;
+import org.springframework.stereotype.Repository;
+
+//在对应的Mapper上面继承基本的类BaseMapper
+@Repository//代表持久层,或者加入@Mapper注解
+public interface EmployeeMapper extends BaseMapper<Employee> {
+    //所有的CRUD操作都已经编写完成了
+}

+ 12 - 0
src/main/java/com/muzhi/zgd/mapper/JiaozhigongMapper.java

@@ -0,0 +1,12 @@
+package com.muzhi.zgd.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.muzhi.zgd.entity.Bumen;
+import com.muzhi.zgd.entity.Jiaozhigong;
+import org.springframework.stereotype.Repository;
+
+//在对应的Mapper上面继承基本的类BaseMapper
+@Repository//代表持久层,或者加入@Mapper注解
+public interface JiaozhigongMapper extends BaseMapper<Jiaozhigong> {
+    //所有的CRUD操作都已经编写完成了
+}

+ 5 - 0
src/main/java/com/muzhi/zgd/mapper/xml/BumenMapper.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+        <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.muzhi.zgd.mapper.BumenMapper">
+
+</mapper>

+ 5 - 0
src/main/java/com/muzhi/zgd/mapper/xml/EmployeeMapper.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+        <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.muzhi.zgd.mapper.EmployeeMapper">
+
+</mapper>

+ 5 - 0
src/main/java/com/muzhi/zgd/mapper/xml/JiaozhigongMapper.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+        <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.muzhi.zgd.mapper.JiaozhigongMapper">
+
+</mapper>

+ 54 - 0
src/main/java/com/muzhi/zgd/oauth2/ApiClientConfig.java

@@ -0,0 +1,54 @@
+/**
+ * <p>Coyright (R) 2014 正方软件股份有限公司。<p>
+ */
+package com.muzhi.zgd.oauth2;
+
+/**
+ * 
+ * @className	: ApiClientConfig
+ * @description	: TODO(描述这个类的作用)
+ * @author 		:万大龙(743)
+ * @date		: 2017年11月4日 上午9:07:51
+ * @version 	V1.0
+ */
+public class ApiClientConfig {
+	
+	private String appKey;
+	
+	private String appSecret;
+	
+	private String accessTokenUrl = "/manager/oauth2/accessToken";
+
+	public ApiClientConfig() {}
+	
+	public ApiClientConfig(String appKey, String appSecret, String accessTokenUrl) {
+		this.appKey = appKey;
+		this.appSecret = appSecret;
+		this.accessTokenUrl = accessTokenUrl;
+	}
+
+	public String getAppKey() {
+		return appKey;
+	}
+
+	public void setAppKey(String appKey) {
+		this.appKey = appKey;
+	}
+
+	public String getAppSecret() {
+		return appSecret;
+	}
+
+	public void setAppSecret(String appSecret) {
+		this.appSecret = appSecret;
+	}
+
+	public String getAccessTokenUrl() {
+		return accessTokenUrl;
+	}
+
+	public void setAccessTokenUrl(String accessTokenUrl) {
+		this.accessTokenUrl = accessTokenUrl;
+	}
+	
+}

+ 85 - 0
src/main/java/com/muzhi/zgd/oauth2/ApiToken.java

@@ -0,0 +1,85 @@
+/**
+ * <p>Coyright (R) 2014 正方软件股份有限公司。<p>
+ */
+package com.muzhi.zgd.oauth2;
+
+import com.alibaba.fastjson.JSONObject;
+import com.muzhi.zgd.exception.HttpResponseException;
+import com.muzhi.zgd.handler.PlainTextResponseHandler;
+import com.muzhi.zgd.handler.ResponseHandler;
+import com.muzhi.zgd.http.ContentType;
+import com.muzhi.zgd.http.HttpConnectionUtils;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * 
+ * @className	: Token
+ * @description	: TODO(描述这个类的作用)
+ * @author 		:樊新亮(1505)
+ * @date		: 2017年9月23日 下午8:29:20
+ * @version 	V1.0
+ */
+public class ApiToken{
+	
+	public static ResponseHandler<String> textHandler = new PlainTextResponseHandler();
+
+	private static ApiToken token;
+	private String accessToken;
+	private Long tokenExpiryTime;
+	private ApiClientConfig config;
+	
+	private ApiToken() {}
+	
+	public static synchronized ApiToken get() {
+		if(token == null) {
+			token = new ApiToken();
+		}
+		return token;
+	}
+	
+	public ApiToken set(ApiClientConfig config) {
+		this.config = config;
+		return token;
+	}
+	
+	public String getAccessToken() throws HttpResponseException, IOException{
+		if(accessToken == null && tokenExpiryTime == null) {
+			refreshToken();
+		}
+		if(System.currentTimeMillis() >= tokenExpiryTime - 10000) {
+			refreshToken();
+		}
+		return accessToken;
+	}
+
+	/**
+	 * 刷新令牌
+	 * @description	: TODO
+	 * @author 		: 樊新亮(1505)
+	 * @date 		:2017年9月23日 下午9:08:34
+	 * @return
+	 */
+	public ApiToken refreshToken() throws HttpResponseException, IOException{
+
+		Map<String,Object> paramsMap = new HashMap<String, Object>();
+		paramsMap.put("appKey", this.config.getAppKey());
+		paramsMap.put("appSecret", this.config.getAppSecret());
+		
+		/**获取token*/
+		String text = HttpConnectionUtils.httpRequestWithPost(this.config.getAccessTokenUrl(), paramsMap, ContentType.UTF_8 , textHandler);
+		JSONObject ret = JSONObject.parseObject(text);
+		if("success".equalsIgnoreCase(ret.getString("status"))) {
+			accessToken = ret.getJSONObject("token").getString("accessToken");
+			Long expiresIn = ret.getJSONObject("token").getLong("tokenExpiryTime");
+			tokenExpiryTime = System.currentTimeMillis() + expiresIn * 1000;
+		} else if("fail".equalsIgnoreCase(ret.getString("status"))){
+			throw new HttpResponseException(ret.getString("token"));
+		}
+		
+		return token;
+	}
+	
+}

+ 14 - 0
src/main/java/com/muzhi/zgd/service/DingAccessTokenService.java

@@ -0,0 +1,14 @@
+package com.muzhi.zgd.service;
+
+/**
+ * @Author ZhangKan
+ * @Data 15:34
+ */
+public interface DingAccessTokenService {
+
+    //获取access_token的方法(浙工大)
+    String getAccessToken();
+
+    //获取access_token的方法(牧之测试架构3)
+    String getMuZhiAccessToken();
+}

+ 19 - 0
src/main/java/com/muzhi/zgd/service/EmployeeService.java

@@ -0,0 +1,19 @@
+package com.muzhi.zgd.service;
+
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.muzhi.zgd.entity.Employee;
+import com.muzhi.zgd.entity.vo.EmployeeDataVo;
+import com.muzhi.zgd.entity.vo.EmployeeQuery;
+
+public interface EmployeeService extends IService<Employee> {
+
+    //获取公司在职员工id列表(已去除",[])
+    String getEmployeeId();
+
+    //查询钉钉接口中的花名册信息
+    String getDingHuamingce();
+
+    //获取数据库中员工花名册employee实体类表数据进行前端接口调用展示数据
+    public EmployeeDataVo<Employee> getHuamingce(Integer page, Integer limit, EmployeeQuery employeeQuery);
+}

+ 13 - 0
src/main/java/com/muzhi/zgd/service/LianJieQiService.java

@@ -0,0 +1,13 @@
+package com.muzhi.zgd.service;
+
+import java.util.Map;
+
+/**
+ * @Author ZhangKan
+ * @Data 15:34
+ */
+public interface LianJieQiService {
+
+    //获取宜搭表单返回的表单id,然后通过id获取表单其他数据进行业务处理
+    String getSPid(String id);
+}

+ 20 - 0
src/main/java/com/muzhi/zgd/service/ZGDjiaozhigongService.java

@@ -0,0 +1,20 @@
+package com.muzhi.zgd.service;
+
+/**
+ * @Author ZhangKan
+ * @Data 15:34
+ */
+public interface ZGDjiaozhigongService{
+
+    //获取浙工大教职工信息
+    String getJiaozhigong() throws Exception;
+
+    //向牧之测试架构4同步测试人员数据【主要用于测试浙工大需求:抓取浙工大教职工数据创建到钉钉中,并同时修改更新每个人员的其他字段信息】
+    String addJiaozhigong();
+
+    //向浙工大架构同步教职工人员数据【主要用于浙工大需求:抓取浙工大教职工数据创建到钉钉中,并同时修改更新每个人员的其他字段信息】
+    String addJiaozhigongZGD() throws Exception;
+
+    //浙工大教职工数据同步至本地数据库
+    String addJiaozhigongToBD() throws Exception;
+}

+ 72 - 0
src/main/java/com/muzhi/zgd/service/impl/DingAccessTokenServiceImpl.java

@@ -0,0 +1,72 @@
+package com.muzhi.zgd.service.impl;
+
+import com.dingtalk.api.DefaultDingTalkClient;
+import com.dingtalk.api.request.OapiGettokenRequest;
+import com.dingtalk.api.response.OapiGettokenResponse;
+import com.muzhi.zgd.service.DingAccessTokenService;
+import com.taobao.api.ApiException;
+import org.springframework.stereotype.Service;
+
+
+/**
+ * @Author ZhangKan
+ * @Data 15:39
+ */
+
+@Service
+public class DingAccessTokenServiceImpl implements DingAccessTokenService{
+    //DingAccessTokenService
+
+    //浙江工业大学
+    //APPKEY
+    private static String APPKEY = "dingvoya54lxbinex2oq";
+    //APPSECRET
+    private static String APPSECRET = "T_TcyTRDFYVZp6z1eMgcapvvm4QQW6f7hwE-1Vxckcw5XQriYsvRohzIotIXK6tR";
+
+    public static String accessToken = null;
+
+
+    //牧之测试架构4
+    //APPKEY
+    private static String APPKEY1 = "ding2katvzyqvlkunqtb";
+    //APPSECRET
+    private static String APPSECRET1 = "vSctQrVm5cGos0X6K86NN0A8Vv6-SmN4W_VRXjsqPqZRhZtbG6xfPATOZhPi3VBE";
+
+    public static String accessToken1 = null;
+
+    //获取access_token的方法(浙工大)
+    @Override
+    public String getAccessToken() {
+        DefaultDingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/gettoken");
+        OapiGettokenRequest request = new OapiGettokenRequest();
+        request.setAppkey(APPKEY);
+        request.setAppsecret(APPSECRET);
+        request.setHttpMethod("GET");
+        try {
+            OapiGettokenResponse response = client.execute(request);
+            accessToken = response.getAccessToken();
+            System.out.println("浙工大AccessToken:" + accessToken);
+        } catch (ApiException e) {
+            e.printStackTrace();
+        }
+        return accessToken;
+    }
+
+    //获取access_token的方法(牧之测试架构4)
+    @Override
+    public String getMuZhiAccessToken() {
+        DefaultDingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/gettoken");
+        OapiGettokenRequest request = new OapiGettokenRequest();
+        request.setAppkey(APPKEY1);
+        request.setAppsecret(APPSECRET1);
+        request.setHttpMethod("GET");
+        try {
+            OapiGettokenResponse response = client.execute(request);
+            accessToken1 = response.getAccessToken();
+            System.out.println("牧之测试架构4的AccessToken:" + accessToken1);
+        } catch (ApiException e) {
+            e.printStackTrace();
+        }
+        return accessToken1;
+    }
+}

File diff suppressed because it is too large
+ 191 - 0
src/main/java/com/muzhi/zgd/service/impl/EmployeeServiceImpl.java


+ 39 - 0
src/main/java/com/muzhi/zgd/service/impl/LianJieQiServiceImpl.java

@@ -0,0 +1,39 @@
+package com.muzhi.zgd.service.impl;
+
+
+import com.muzhi.zgd.service.LianJieQiService;
+import org.springframework.stereotype.Service;
+
+
+@Service
+public class LianJieQiServiceImpl implements LianJieQiService {
+
+    /**
+     * 获取宜搭表单返回的表单id,然后通过id获取表单其他数据进行业务处理
+     * @param id(宜搭表单id)
+     * @return
+     */
+
+    @Override
+    public String getSPid(String id){
+
+        Boolean zhi = null;
+
+        if (id.equals("测试")){
+            zhi = true;
+        }else {
+            zhi = false;
+        }
+
+        System.out.println("宜搭表单id:" + id);
+
+        System.out.println("校验结果:" + zhi);
+
+//        Map map = new HashMap();
+//
+//        map.put("jiaoyanjieguo", zhi);
+//        map.put("jiaoyanxinxi","系统中没有职位【1】,请重新输入!");
+
+        return "连接器抓取宜搭表单数据执行完成!";
+    }
+}

File diff suppressed because it is too large
+ 2227 - 0
src/main/java/com/muzhi/zgd/service/impl/ZGDjiaozhigongServiceImpl.java


+ 50 - 0
src/main/resources/application.properties

@@ -0,0 +1,50 @@
+server.port=8093
+
+server.tomcat.uri-encoding=UTF-8
+
+# 服务名
+spring.application.name=springboot-zgd
+# 环境设置:dev、test、prod(开发环境、测试环境、生产环境)
+spring.profiles.active=dev
+
+# mysql数据库连接
+# 本地测试数据库
+spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
+spring.datasource.url=jdbc:mysql://localhost:3306/dingtalk?serverTimezone=GMT%2B8
+spring.datasource.username=root
+spring.datasource.password=123456
+
+#定时同步
+
+#配置日志,当前为默认的控制台输出,也可以用log4j
+mybatis-plus.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl
+
+#控制台显示sql
+spring.jpa.show-sql=true
+#更新或者创建数据表结构
+#spring.jpa.hibernate.ddl-auto=update
+
+#返回json的全局时间格式
+spring.jackson.date-format=yyyy-MM-dd HH:mm:ss
+spring.jackson.time-zone=GMT+8
+#配置mapper xml文件的路径
+mybatis-plus.mapper-locations=classpath:com/muzhi/zgd/mapper/xml/*.xml
+
+#mybatis-plus.config-location=classpath:mybatis/mybatis-config.xml
+
+#禁用缓存
+spring.thymeleaf.cache=false
+#spring.thymeleaf.mode= LEGACYHTML5
+#spring.resources.chain.strategy.content.enabled=true
+#spring.resources.chain.strategy.content.paths=/**
+#spring.thymeleaf.check-template = true
+#spring.thymeleaf.servlet.content-type=text/html
+#spring.thymeleaf.enabled = true
+#spring.thymeleaf.encoding = UTF-8
+#spring.thymeleaf.prefix = classpath:/static/
+#spring.thymeleaf.suffix = .html
+
+#定义日期提交的格式(日期的格式化):SpingMVC将页面提交的值需要转换为指定类型;默认的是yyyy/MM/dd
+#spring.mvc.date-format=yyyy-MM-dd
+
+spring.resources.static-locations=classpath:/META-INF/resources/,classpath:/resources/,classpath:/static/,classpath:/public/,classpath:/templates/

+ 313 - 0
src/test/java/com/muzhi/zgd/APITest/ApiHttpClientTest.java

@@ -0,0 +1,313 @@
+package com.muzhi.zgd.APITest;
+
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.dingtalk.api.DefaultDingTalkClient;
+import com.dingtalk.api.DingTalkClient;
+import com.dingtalk.api.request.OapiV2DepartmentCreateRequest;
+import com.dingtalk.api.request.OapiV2DepartmentListsubRequest;
+import com.dingtalk.api.request.OapiV2UserGetRequest;
+import com.dingtalk.api.request.OapiV2UserGetbymobileRequest;
+import com.dingtalk.api.response.OapiV2DepartmentCreateResponse;
+import com.dingtalk.api.response.OapiV2DepartmentListsubResponse;
+import com.dingtalk.api.response.OapiV2UserGetResponse;
+import com.dingtalk.api.response.OapiV2UserGetbymobileResponse;
+import com.muzhi.zgd.entity.Bumen;
+import com.muzhi.zgd.http.ApiHttpClientUtils;
+import com.muzhi.zgd.http.HttpConnectionUtils;
+import com.muzhi.zgd.mapper.BumenMapper;
+import com.muzhi.zgd.oauth2.ApiClientConfig;
+import com.muzhi.zgd.service.DingAccessTokenService;
+import com.taobao.api.ApiException;
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+@SpringBootTest
+public class ApiHttpClientTest {
+
+    @Autowired
+    private DingAccessTokenService dingAccessTokenService;
+
+    @Autowired
+    private BumenMapper bumenMapper;
+
+    public static String jiaozhigong = null;
+    public static String bumen = null;
+
+    public static String bumenXQ = null;
+
+    /**不带认证的调用方式*/
+    @Test
+    public void invokeNotToken() throws Exception {
+        String baseURL = "http://172.16.16.134:83/zfdsb/api/info/dingding/getTeacherInfo";
+        Map<String, Object> paramsMap = new HashMap<>();
+
+        //连接超时 单位毫秒
+        HttpConnectionUtils.connectTimeout=1000000;
+        //读取超时 单位毫秒
+        HttpConnectionUtils.readTimeout=3000000;
+
+        String res = ApiHttpClientUtils.get().invokeApiWithGetNotToken(baseURL, paramsMap);
+        System.out.println(res);
+    }
+
+
+    /**带认证的调用方式*/
+    @Test
+    public void invoke() throws Exception {
+        ApiClientConfig config = new ApiClientConfig();
+        config.setAppKey("C5DF1E3771BD1C21E053C81010ACD243");
+        config.setAppSecret("MIIBUwIBADANBgkqhkiG9w0BAQEFAASCAT0wggE5AgEAAkEAns8fOx4QJtW3VvCPJJs3k+D3CuT7WWMuON2gN6RQPU12xT3VcGVQGFoSMENN90edS60SygYsxTAsr9PBVvB+DwIDAQABAkBpSvJuA9S5quFQJ1cA8li7F2E0O/XaokO3OFpOCgeZXIN7ieS5vW+LjdZm8KWZhjo7nwobSriwmYHxUZ0O7+4BAiEAzo2A6LHbHqpY+8Z6zGSlj0WUmo7+sOd22O6Enno9Z8ECIQDE06rrKuJ28bs5yBPMDYguNFM1yJw76U46K0oCIBfZzwIgTF5nRiHUWV80bUqyRnYD/JgGXKr4IiJCf+yYXhvmLkECIGRk4sVY9nJdEnaCizaFoHSQ0/CXBrm4YuJgujsjS4cZAiBsRtcfHPChQVa+7fRpOfJfhFz0mup7r7nilt0FzdFYJg==");
+        config.setAccessTokenUrl("http://172.16.16.134:83/zfdsb/oauth2/accessToken");
+        String baseURL = "http://172.16.16.134:83/zfdsb/api/info/dingding/getTeacherInfo";
+
+        Map<String, Object> paramsMap = new HashMap<String, Object>();
+        paramsMap.put("gxsj","2021-08-30");
+
+        //连接超时 单位毫秒
+        HttpConnectionUtils.connectTimeout=1000000;
+        //读取超时 单位毫秒
+        HttpConnectionUtils.readTimeout=3000000;
+
+        String res = ApiHttpClientUtils.get(config).invokeApiWithGet(baseURL, paramsMap);
+        System.out.println(res);
+    }
+
+
+    //查询教职工部门下面创建过的钉钉部门
+    @Test
+    public void chaxunBumen() {
+        jiaozhigong = "[{\"BMMC\":\"教职工子部门test666\"},{\"BMMC\":\"教职工子部门test2\"}]";
+
+        JSONArray jsonArray = JSON.parseArray(jiaozhigong);
+        System.out.println("jsonArray:" + jsonArray);
+
+        String bumen = null;
+
+        try {
+            DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/v2/department/listsub");
+            OapiV2DepartmentListsubRequest req = new OapiV2DepartmentListsubRequest();
+
+            //教职工部门id(教职工主部门id)
+            req.setDeptId(528235397L);
+
+            OapiV2DepartmentListsubResponse rsp = client.execute(req, dingAccessTokenService.getAccessToken());
+            bumen = rsp.getBody();
+            System.out.println(rsp.getBody());
+        } catch (ApiException e) {
+            e.printStackTrace();
+        }
+
+        JSONObject jsonObject = JSON.parseObject(bumen);
+        JSONArray resultArray = jsonObject.getJSONArray("result");
+        System.out.println("教职工主部门下的子部门列表:" + resultArray);
+
+        for (int i = 0; i<jsonArray.size(); i++){
+            System.out.println("部门名称的值:" + jsonArray.getJSONObject(i).getString("BMMC"));
+
+//            for (int a = 0; a<resultArray.size(); a++){
+//
+//            }
+        }
+    }
+
+    //查询用户详情(用于查询钉钉中该人员存在于哪几个部门列表)
+    @Test
+    public void getBumenList(){
+
+        String bumenXX = null;
+
+        try {
+            DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/v2/user/get");
+            OapiV2UserGetRequest req = new OapiV2UserGetRequest();
+            req.setUserid("manager5889");
+            OapiV2UserGetResponse rsp = client.execute(req, dingAccessTokenService.getMuZhiAccessToken());
+            bumenXX = rsp.getBody();
+            System.out.println(rsp.getBody());
+        } catch (ApiException e) {
+            e.printStackTrace();
+        }
+
+        JSONObject result111;
+        String bumen111 =null;
+
+        //通过fastjson工具转换成json对象,逐层解析
+        JSONObject jsonObject1 = JSON.parseObject(bumenXX);
+        try {
+            result111 = jsonObject1.getJSONObject("result");
+            bumen111 = result111.getString("dept_id_list");
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+        System.out.println("接口返回部门id数组集合:" + bumen111);
+
+        //将String数组进行处理,去掉所有的双引号("")和中括号([])
+        String bumenR = bumen111.replace("\"", "").
+                replaceAll("\\[", "").
+                replaceAll("\\]", "");
+        System.out.println("处理后的部门id列表:" + bumenR);
+
+    }
+
+    //通过人员手机号查询该人员userid是否存在
+    @Test
+    public void getUserID(){
+
+        String userid = null;
+
+        try {
+            DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/v2/user/getbymobile");
+            OapiV2UserGetbymobileRequest req = new OapiV2UserGetbymobileRequest();
+            //通过人员手机号查询该人员userid
+            req.setMobile("15221837004");
+            OapiV2UserGetbymobileResponse rsp = client.execute(req, dingAccessTokenService.getMuZhiAccessToken());
+            userid = rsp.getBody();
+            System.out.println(rsp.getBody());
+        } catch (ApiException e) {
+            e.printStackTrace();
+        }
+
+        JSONObject jsonObject666 = JSON.parseObject(userid);
+        System.out.println("接口返回信息:" + jsonObject666);
+
+        JSONObject result666;
+        String userid1 =null;
+        try {
+            result666 = jsonObject666.getJSONObject("result");
+            userid1 = result666.getString("userid");
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+        System.out.println("返回userid结果:" + userid1);
+
+        if (userid1==null || userid1==""){
+            System.out.println("该人员在钉钉中不存在!");
+        }else {
+            System.out.println("该人员userid为:" + userid1);
+        }
+    }
+
+    //查询部门列表详情,同时插入本地数据库供调用查询部门是否存在
+    @Test
+    public void addBumenToBD() {
+
+        try {
+            DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/v2/department/listsub");
+            OapiV2DepartmentListsubRequest req = new OapiV2DepartmentListsubRequest();
+            //TODO 教职工部门id
+            req.setDeptId(522007355L);
+            OapiV2DepartmentListsubResponse rsp = client.execute(req, dingAccessTokenService.getMuZhiAccessToken());
+            bumenXQ = rsp.getBody();
+            System.out.println(rsp.getBody());
+        } catch (ApiException e) {
+            e.printStackTrace();
+        }
+
+        JSONObject jsonObject = JSON.parseObject(bumenXQ);
+        JSONArray resultArray = jsonObject.getJSONArray("result");
+        System.out.println(resultArray);
+
+        //先清除数据库中部门表的数据
+        bumenMapper.delete(null);
+
+        //向数据库部门表中插入目前钉钉架构中教职工部门下面的所有的部门id、部门名称
+        Bumen bumen = new Bumen();
+        for (int x = 0; x<resultArray.size(); x++){
+            bumen.setBmid(resultArray.getJSONObject(x).getString("dept_id"));
+            bumen.setBmmc(resultArray.getJSONObject(x).getString("name"));
+            bumenMapper.insert(bumen);
+        }
+
+    }
+
+    //在教职工部门下面创建钉钉部门
+    @Test
+    public void addBumen() {
+        jiaozhigong = "[{\"BMMC\":\"教职工子部门test222\"},{\"BMMC\":\"\"},{\"BMMC\":\"教职工子部门test333\"}]";
+
+        JSONArray jsonArray = JSON.parseArray(jiaozhigong);
+        System.out.println("jsonArray:" + jsonArray);
+
+        for (int i = 0; i<jsonArray.size(); i++) {
+
+            QueryWrapper<Bumen> queryWrapper = new QueryWrapper<>();
+            queryWrapper.select("bmid").eq("bmmc", jsonArray.getJSONObject(i).getString("BMMC"));
+
+            Bumen bumen1 = bumenMapper.selectOne(queryWrapper);
+            System.out.println("查询结果部门id:" + bumen1);
+
+            String bmid111 = null;
+
+            if (!jsonArray.getJSONObject(i).getString("BMMC").isEmpty() || !jsonArray.getJSONObject(i).getString("BMMC").equals("")) {
+
+                if (bumen1 == null) {
+                    System.out.println("数据库部门为空!!!");
+
+                    String dept_id = null;
+
+                    try {
+                        DingTalkClient client111 = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/v2/department/create");
+                        OapiV2DepartmentCreateRequest req111 = new OapiV2DepartmentCreateRequest();
+
+                        //教职工部门id(各部门创在在该教职工主部门下面)
+                        req111.setParentId(528235397L);
+                        //创建的部门名称(对应各个教职工所在的不同部门名称)
+                        req111.setName(jsonArray.getJSONObject(i).getString("BMMC"));
+
+                        OapiV2DepartmentCreateResponse rsp111 = client111.execute(req111, dingAccessTokenService.getAccessToken());
+                        System.out.println(rsp111.getBody());
+                        bumen = rsp111.getBody();
+                        //通过fastjson工具转换成json对象,逐层解析
+                        //将String类型的花名册json数据转换为Object数据对象
+                        JSONObject jsonObject = JSON.parseObject(bumen);
+
+                        //直接将花名册对象通过Object转换成Array数组格式
+                        JSONObject result = jsonObject.getJSONObject("result");
+                        System.out.println("result:" + result);
+
+                        dept_id = result.getString("dept_id");
+                        System.out.println("创建部门返回的部门id:" + dept_id);
+                        bmid111 = dept_id;
+                        System.out.println("bmid111:" + bmid111);
+
+                        //TODO 可以考虑每次创建完部门后向数据库的表中插入这个部门名称和部门id,每次创建部门之前先去数据库进行查找对应的部门id,如果不存在该部门名称则执行创建部门代码
+                        Bumen bumen = new Bumen();
+                        bumen.setBmid(dept_id);
+                        bumen.setBmmc(jsonArray.getJSONObject(i).getString("BMMC"));
+                        bumenMapper.insert(bumen);
+
+                    } catch (ApiException e) {
+                        e.printStackTrace();
+                    }
+                    System.out.println("创建部门后返回的部门id:" + dept_id);
+                } else {
+                    System.out.println("数据库部门有值!!!");
+
+                    String bmid = null;
+
+                    try {
+                        bmid = bumen1.getBmid();
+                        bmid111 = bmid;
+                        System.out.println("最终取出来的部门id:" + bmid);
+                    } catch (Exception e) {
+                        e.printStackTrace();
+                    }
+
+                    System.out.println("从数据查询bmid111的值:" + bmid111);
+                }
+            }else {
+                bmid111 = "529743351";
+                System.out.println("其他未知部门id:" + bmid111);
+            }
+        }
+    }
+}

+ 14 - 0
src/test/java/com/muzhi/zgd/APITest/Test1.java

@@ -0,0 +1,14 @@
+package com.muzhi.zgd.APITest;
+
+import org.springframework.boot.test.context.SpringBootTest;
+import org.junit.jupiter.api.Test;
+
+@SpringBootTest
+class Test1 {
+
+    @Test
+    public void list(){
+
+
+    }
+}

+ 13 - 0
src/test/java/com/muzhi/zgd/TestApplicationTests.java

@@ -0,0 +1,13 @@
+package com.muzhi.zgd;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+
+@SpringBootTest
+class TestApplicationTests {
+
+    @Test
+    void contextLoads() {
+    }
+
+}